18#include "BDSAcceleratorComponent.hh"
19#include "BDSColours.hh"
21#include "BDSException.hh"
22#include "BDSBeamPipe.hh"
23#include "BDSBeamPipeFactory.hh"
24#include "BDSBeamPipeInfo.hh"
25#include "BDSUtilities.hh"
26#include "BDSWireScanner.hh"
29#include "G4LogicalVolume.hh"
30#include "G4PVPlacement.hh"
31#include "G4ThreeVector.hh"
33#include "G4TwoVector.hh"
34#include "G4VisAttributes.hh"
36#include "CLHEP/Units/PhysicalConstants.h"
40BDSWireScanner::BDSWireScanner(
const G4String& nameIn,
43 G4Material* wireMaterialIn,
44 G4double wireDiameterIn,
45 G4double wireLengthIn,
47 const G4ThreeVector& wireOffsetIn,
48 G4Colour* wireColourIn):
50 wireMaterial(wireMaterialIn),
51 wireDiameter(wireDiameterIn),
52 wireLength(wireLengthIn),
53 wireAngle(wireAngleIn),
54 wireOffset(wireOffsetIn),
55 wireColour(wireColourIn)
57 if (wireDiameter <= 0)
58 {
throw BDSException(__METHOD_NAME__,
"Error: wireDiameter for \"" + name +
"\" is not defined or must be greater than 0");}
61 {
throw BDSException(__METHOD_NAME__,
"Error: wire for \"" + name +
"\" must be > 0.");}
65 G4TwoVector offsetXY = G4TwoVector(wireOffset.x(), wireOffset.y());
66 G4TwoVector tipTop = G4TwoVector(0, 0.5*wireLength);
67 tipTop.rotate(wireAngle);
68 G4TwoVector tipBot = G4TwoVector(tipTop);
69 tipBot.rotate(CLHEP::pi);
72 G4double innerRadius = beamPipeInfo->IndicativeRadiusInner();
73 if (tipTop.mag() > innerRadius || tipBot.mag() > innerRadius)
74 {
throw BDSException(__METHOD_NAME__,
"wire for \"" + name +
"\" is too big to fit in beam pipe give offsets.");}
110 G4RotationMatrix* wireRot =
new G4RotationMatrix();
111 wireRot->rotateX(CLHEP::halfpi);
113 wireRot->rotateY(wireAngle);
117 G4VisAttributes* wireVisAttr =
new G4VisAttributes(*wireColour);
118 wireLV->SetVisAttributes(wireVisAttr);
123 G4PVPlacement* wirePV =
new G4PVPlacement(wireRot,
136 G4Tubs* wire =
new G4Tubs(
name +
"_wire_solid",
147 G4LogicalVolume* wireLV =
new G4LogicalVolume(solid,
Abstract class that represents a component of an accelerator.
void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume *accVacLVIn)
const G4String name
Const protected member variable that may not be changed by derived classes.
virtual void SetOutputFaceNormal(const G4ThreeVector &output)
Allow updating of face normals. Virtual so derived class may apply it to daughters.
static G4bool checkOverlaps
Useful variable often used in construction.
virtual std::set< G4LogicalVolume * > GetAcceleratorVacuumLogicalVolumes() const
Access the 'vacuum' volume(s) in this component if any. Default is empty set.
virtual void SetInputFaceNormal(const G4ThreeVector &input)
Allow updating of face normals. Virtual so derived class may apply it to daughters.
G4double chordLength
Protected member variable that can be modified by derived classes.
BDSBeamPipeInfo * beamPipeInfo
Optional beam pipe recipe that is written out to the survey if it exists.
The main interface for using the beam pipe factories.
static BDSBeamPipeFactory * Instance()
Singleton accessor.
Holder class for all information required to describe a beam pipe model.
A holder class for a piece of beam pipe geometry.
G4LogicalVolume * GetVacuumLogicalVolume() const
Access the vacuum volume to set fields and limits.
G4ThreeVector InputFaceNormal() const
Accessor.
G4ThreeVector OutputFaceNormal() const
Accessor.
G4Colour * GetColour(G4double red, G4double green, G4double blue, G4double alpha=1)
Get a cached anonymous colour by values.
static BDSColours * Instance()
singleton pattern
General exception with possible name of object and message.
G4LogicalVolume * GetContainerLogicalVolume() const
Accessor - see member for more info.
void InheritExtents(BDSGeometryComponent const *const anotherComponent)
Update the extents of this object with those of another object.
void RegisterRotationMatrix(G4RotationMatrix *rotationMatrix)
void RegisterDaughter(BDSGeometryComponent *anotherComponent)
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
G4VSolid * GetContainerSolid() const
Accessor - see member for more info.
void RegisterVisAttributes(G4VisAttributes *visAttribute)
void RegisterSolid(G4VSolid *solid)
virtual void BuildContainerLogicalVolume()
virtual G4VSolid * BuildWireSolid()
Allow overriding of certain bits of construction.
virtual G4LogicalVolume * BuildWireLV(G4VSolid *solid)
Allow overriding of certain bits of construction.