#include <BLElement.hh>
BLElement defines elements to be placed into the geometry of g4beamline.
Normally an element implementation will derive a class from this one, and if it has an EM field, also derives from BLElementField. Usually all are in a single file named for the element command class. The default constructor of the derived class is used to implement the element command (see BLCommand), and the copy constructor is used by the element command to create instances of the element.
Note the constructor of the derived class must contain enough information so the size of the element is determined (getLength(), etc.). Or at least these must be known before the element command returns.
A non-default instance of this class represents a specific type of the element, complete with all argument values; it is created by the element command of the derived class. This instance can be placed multiple times by the place command and by place commands applied to groups in which the instance has been placed. After the command file has been read (i.e. all elements have been created and placed), then the World group is constructed, and that results in a traversal of the placement tree and the construction of all elements. Thus a single instance of this class can appear multiple times at multiple locations within the overall geometry.
When element argments are given on the place command, clone() is used to copy the element, and then defineNamedArgs() is called for each element argument. Then the cloned element is placed.
NOTE: Derived classes MUST use the copy constructor, not the default constructor! ONLY the default object should use the default constructor.
Public Member Functions | |
BLElement () | |
Default constructor. | |
virtual | ~BLElement () |
Destructor. | |
BLElement (const BLElement &r) | |
Copy constructor. | |
virtual BLElement * | clone ()=0 |
clone() will clone a copy of an element. Used when element arguments are given in a place command. | |
virtual G4String | getName () const |
getName() returns the element's name; do not confuse this with commandName(). Not used by the default instance. | |
virtual void | setName (G4String _name) |
setName() sets the element's name; Adds the BLElement to mapElement. Used by instances of the derived class representing real elements; not used by the default instance. virtual so derived base classes can keep a list of their elements. | |
virtual void | construct (G4RotationMatrix *relativeRotation, G4ThreeVector relativePosition, G4LogicalVolume *parent, G4String parentName, G4RotationMatrix *parentRotation, G4ThreeVector parentPosition)=0 |
construct() will construct a physical implementation of this element at a specific location within the overall geometry. The name of the implementation should be parentName plus the name of the element; the physical volume should be linked into the parent in the usual way. relativeRotation is an active rotation of this element wrt the parent's coordinate axes, and relativePosition is in the parent's coords as usual (if the parent is the world, the centerline coordinate transform is included) -- the rotation for G4VPlacement is relativeRotation->inverse(). parentRotation and parentPosition are the rotation and position of the parent, expressed in global coordinates -- most elements can ignore them, as they are normally used to construct a BLCoordinateTransform from global coordinates to the element's local coordinates (e.g. for GlobalField). | |
virtual G4double | getLength ()=0 |
getLength() returns this element's Length along the Z axis. | |
virtual G4double | getWidth ()=0 |
getWidth() returns this element's Width along the X axis. For asymmetric elements, the width is twice the element's futhest point from X=0. | |
virtual G4double | getHeight ()=0 |
getHeight() returns this element's height along the Y axis. For asymmetric elements, the width is twice the element's futhest point from Y=0. | |
virtual G4bool | isOK ()=0 |
isOK() returns true iff this element is ready to process beam. It is queried AFTER the reference particle is tracked, so it can reflect the status of tuning performed by the reference particle. | |
virtual G4bool | isGroupElement () |
isGroupElement() returns true if this is a BLGroupElement. That is, if this element can be the parent of other elements. | |
bool | getPlacedFlag () |
getPlacedFlag() returns true if this element has been placed. | |
void | setPlacedFlag (bool flag=true) |
setPlacedFlag() sets the flag for placing this element. | |
virtual void | generatePoints (int npoints, std::vector< G4ThreeVector > &v)=0 |
generatePoints() will generate points for the testGeometry() function (of BLGroupElement) for this element. It generates however many points are necessary to test extremes of its surface, plus randomly distributed ones on the surface, up to npoints total. Each point is in the local coordinates of the element. | |
virtual G4bool | isOutside (G4ThreeVector &local, G4double tolerance)=0 |
isOutside() returns true if the point is outside this element, or is within tolerance of being outside. local[] is the point in local coordinates of this element. | |
void | generateBox (unsigned int npoints, G4double width, G4double height, G4double length, std::vector< G4ThreeVector > &v) |
generateBox() generates geometry test points for a Box (a convenience method for derived classes to use) | |
void | generateTubs (unsigned int npoints, G4double innerRadius, G4double outerRadius, G4double initialPhi, G4double finalPhi, G4double length, std::vector< G4ThreeVector > &v) |
generateTubs() generates geometry test points for a Tubs (a convenience method for derived classes to use) | |
Static Public Member Functions | |
static BLElement * | find (G4String name) |
find() finds the BLElement with a given name. | |
static G4bool | allOK () |
allOK() returns true iff all elements are ready to process beam. | |
Private Attributes | |
G4String | name |
bool | placed |
Static Private Attributes | |
static std::map< G4String, BLElement * > | mapElement |
BLElement::BLElement | ( | ) | [inline] |
BLElement::BLElement | ( | const BLElement & | r | ) | [inline] |
virtual BLElement* BLElement::clone | ( | ) | [pure virtual] |
clone() will clone a copy of an element. Used when element arguments are given in a place command.
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
Referenced by BLCMDplace::handleNamedArgs().
virtual G4String BLElement::getName | ( | ) | const [inline, virtual] |
getName() returns the element's name; do not confuse this with commandName(). Not used by the default instance.
Reimplemented from BLCommand.
References name.
Referenced by ParticleFilterPlacement::AtRestGetPhysicalInteractionLength(), ParticleFilterPlacement::callback(), BLCMDfieldexpr::checkValidExpr(), BLCMDfieldexpr::command(), BLCMDendgroup::command(), BLCMDcorner::command(), BLCMDvirtualdetector::construct(), BLCMDusertrackfilter::construct(), BLCMDtubs::construct(), BLCMDtrap::construct(), BLCMDtrackerplane::construct(), BLCMDtorus::construct(), BLCMDsphere::construct(), BLCMDsolenoid::construct(), BLCMDrfdevice::construct(), BLCMDpolycone::construct(), BLCMDpillbox::construct(), BLCMDparticlefilter::construct(), BLCMDmultipole::construct(), BLCMDlilens::construct(), BLCMDidealsectorbend::construct(), BLCMDhelicalharmonic::construct(), BLCMDhelicaldipole::construct(), BLGroup::construct(), BLCMDgenericquad::construct(), BLCMDgenericbend::construct(), BLCMDfieldmap::construct(), BLCMDfieldexpr::construct(), BLCMDextrusion::construct(), BLCMDcorner::construct(), BLCMDbox::construct(), BLCMDabsorber::construct(), BLGroupElement::constructChildren(), BLCMDabsorber::constructSolids(), BLCMDfieldexpr::handleTimeDependence(), BLGroup::placeElement(), ParticleFilterPlacement::PostStepGetPhysicalInteractionLength(), and BLGroupElement::testGeometry().
00085 { return name; }
void BLElement::setName | ( | G4String | _name | ) | [virtual] |
setName() sets the element's name; Adds the BLElement to mapElement. Used by instances of the derived class representing real elements; not used by the default instance. virtual so derived base classes can keep a list of their elements.
Reimplemented in BLGroupElement.
References mapElement, and name.
Referenced by BLCMDvirtualdetector::command(), BLCMDusertrackfilter::command(), BLCMDtrackerplane::command(), BLCMDsolenoid::command(), BLCMDrfdevice::command(), BLCMDpillbox::command(), BLCMDparticlefilter::command(), BLCMDmultipole::command(), BLCMDlilens::command(), BLCMDidealsectorbend::command(), BLCMDhelicalharmonic::command(), BLCMDhelicaldipole::command(), BLCMDgenericquad::command(), BLCMDfieldmap::command(), BLCMDfieldexpr::command(), BLCMDcorner::command(), BLGroupElement::constructChildren(), and BLGroupElement::setName().
00026 { 00027 name = _name; 00028 mapElement[name] = this; 00029 }
BLElement * BLElement::find | ( | G4String | name | ) | [static] |
find() finds the BLElement with a given name.
Reimplemented in BLGroupElement.
References mapElement.
Referenced by BLCMDplace::command().
00032 { 00033 return mapElement[_name]; 00034 }
G4bool BLElement::allOK | ( | ) | [static] |
allOK() returns true iff all elements are ready to process beam.
References mapElement.
Referenced by main().
00037 { 00038 std::map<G4String,BLElement*>::iterator i; 00039 for(i=mapElement.begin(); i!=mapElement.end(); ++i) { 00040 if(!i->second->isOK()) return false; 00041 } 00042 return true; 00043 }
virtual void BLElement::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [pure virtual] |
construct() will construct a physical implementation of this element at a specific location within the overall geometry. The name of the implementation should be parentName plus the name of the element; the physical volume should be linked into the parent in the usual way. relativeRotation is an active rotation of this element wrt the parent's coordinate axes, and relativePosition is in the parent's coords as usual (if the parent is the world, the centerline coordinate transform is included) -- the rotation for G4VPlacement is relativeRotation->inverse(). parentRotation and parentPosition are the rotation and position of the parent, expressed in global coordinates -- most elements can ignore them, as they are normally used to construct a BLCoordinateTransform from global coordinates to the element's local coordinates (e.g. for GlobalField).
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
Referenced by BLGroupElement::constructChildren().
virtual G4double BLElement::getLength | ( | ) | [pure virtual] |
getLength() returns this element's Length along the Z axis.
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
Referenced by BLCMDplace::command(), and BLGroup::placeElement().
virtual G4double BLElement::getWidth | ( | ) | [pure virtual] |
getWidth() returns this element's Width along the X axis. For asymmetric elements, the width is twice the element's futhest point from X=0.
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
Referenced by BLGroup::placeElement().
virtual G4double BLElement::getHeight | ( | ) | [pure virtual] |
getHeight() returns this element's height along the Y axis. For asymmetric elements, the width is twice the element's futhest point from Y=0.
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
Referenced by BLGroup::placeElement().
virtual G4bool BLElement::isOK | ( | ) | [pure virtual] |
isOK() returns true iff this element is ready to process beam. It is queried AFTER the reference particle is tracked, so it can reflect the status of tuning performed by the reference particle.
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
virtual G4bool BLElement::isGroupElement | ( | ) | [inline, virtual] |
isGroupElement() returns true if this is a BLGroupElement. That is, if this element can be the parent of other elements.
Reimplemented in BLGroupElement.
Referenced by BLGroupElement::testGeometry().
bool BLElement::getPlacedFlag | ( | ) | [inline] |
getPlacedFlag() returns true if this element has been placed.
References placed.
Referenced by BLCMDplace::command().
00148 { return placed; }
void BLElement::setPlacedFlag | ( | bool | flag = true |
) | [inline] |
setPlacedFlag() sets the flag for placing this element.
References placed.
Referenced by BLCMDplace::command().
00151 { placed = flag; }
virtual void BLElement::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [pure virtual] |
generatePoints() will generate points for the testGeometry() function (of BLGroupElement) for this element. It generates however many points are necessary to test extremes of its surface, plus randomly distributed ones on the surface, up to npoints total. Each point is in the local coordinates of the element.
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
Referenced by BLGroupElement::testGeometry().
virtual G4bool BLElement::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [pure virtual] |
isOutside() returns true if the point is outside this element, or is within tolerance of being outside. local[] is the point in local coordinates of this element.
Implemented in BLGroup, BLCMDabsorber, BLCMDbox, BLCMDcorner, BLCMDextrusion, BLCMDfieldexpr, BLCMDfieldmap, BLCMDgenericbend, BLCMDgenericquad, BLCMDhelicaldipole, BLCMDhelicalharmonic, BLCMDidealsectorbend, BLCMDlilens, BLCMDmultipole, BLCMDparticlefilter, BLCMDpillbox, BLCMDpolycone, BLCMDrfdevice, BLCMDsolenoid, BLCMDsphere, BLCMDtorus, BLCMDtrackerplane, BLCMDtrap, BLCMDtubs, BLCMDusertrackfilter, and BLCMDvirtualdetector.
Referenced by BLGroupElement::testGeometry().
void BLElement::generateBox | ( | unsigned int | npoints, | |
G4double | width, | |||
G4double | height, | |||
G4double | length, | |||
std::vector< G4ThreeVector > & | v | |||
) |
generateBox() generates geometry test points for a Box (a convenience method for derived classes to use)
References rand.
Referenced by BLGroup::generatePoints(), BLCMDvirtualdetector::generatePoints(), BLCMDusertrackfilter::generatePoints(), BLCMDtrackerplane::generatePoints(), BLCMDparticlefilter::generatePoints(), BLCMDgenericbend::generatePoints(), and BLCMDbox::generatePoints().
00049 { 00050 v.clear(); 00051 G4double w=width/2.0, h=height/2.0, l=length/2.0; 00052 // the 8 corners 00053 v.push_back(G4ThreeVector(w,h,l)); 00054 v.push_back(G4ThreeVector(w,h,-l)); 00055 v.push_back(G4ThreeVector(w,-h,l)); 00056 v.push_back(G4ThreeVector(w,-h,-l)); 00057 v.push_back(G4ThreeVector(-w,h,l)); 00058 v.push_back(G4ThreeVector(-w,h,-l)); 00059 v.push_back(G4ThreeVector(-w,-h,l)); 00060 v.push_back(G4ThreeVector(-w,-h,-l)); 00061 // the 12 edge midpoints 00062 v.push_back(G4ThreeVector(0,h,l)); 00063 v.push_back(G4ThreeVector(0,h,-l)); 00064 v.push_back(G4ThreeVector(0,-h,l)); 00065 v.push_back(G4ThreeVector(0,-h,-l)); 00066 v.push_back(G4ThreeVector(w,0,l)); 00067 v.push_back(G4ThreeVector(w,0,-l)); 00068 v.push_back(G4ThreeVector(-w,0,l)); 00069 v.push_back(G4ThreeVector(-w,0,-l)); 00070 v.push_back(G4ThreeVector(w,h,0)); 00071 v.push_back(G4ThreeVector(w,-h,0)); 00072 v.push_back(G4ThreeVector(-w,h,0)); 00073 v.push_back(G4ThreeVector(-w,-h,0)); 00074 // the 6 face centers 00075 v.push_back(G4ThreeVector(w,0,0)); 00076 v.push_back(G4ThreeVector(-w,0,0)); 00077 v.push_back(G4ThreeVector(0,h,0)); 00078 v.push_back(G4ThreeVector(0,-h,0)); 00079 // BLCMDgenericbend requires these two be last: 00080 v.push_back(G4ThreeVector(0,0,l)); 00081 v.push_back(G4ThreeVector(0,0,-l)); 00082 // random points on the surfaces 00083 while(v.size() < npoints) { 00084 G4double x=0,y=0,z=0; 00085 switch(v.size() % 6) { 00086 case 0: x=w; y=rand()*height-h; z=rand()*length-l; break; 00087 case 1: x=-w; y=rand()*height-h; z=rand()*length-l; break; 00088 case 2: x=rand()*width-w; y=h; z=rand()*length-l; break; 00089 case 3: x=rand()*width-w; y=-h; z=rand()*length-l; break; 00090 case 4: x=rand()*width-w; y=rand()*height-h; z=l; break; 00091 case 5: x=rand()*width-w; y=rand()*height-h; z=-l; break; 00092 } 00093 v.push_back(G4ThreeVector(x,y,z)); 00094 } 00095 }
void BLElement::generateTubs | ( | unsigned int | npoints, | |
G4double | innerRadius, | |||
G4double | outerRadius, | |||
G4double | initialPhi, | |||
G4double | finalPhi, | |||
G4double | length, | |||
std::vector< G4ThreeVector > & | v | |||
) |
generateTubs() generates geometry test points for a Tubs (a convenience method for derived classes to use)
References rand.
Referenced by BLGroup::generatePoints(), BLCMDvirtualdetector::generatePoints(), BLCMDusertrackfilter::generatePoints(), BLCMDtubs::generatePoints(), BLCMDtrackerplane::generatePoints(), BLCMDsolenoid::generatePoints(), BLCMDrfdevice::generatePoints(), BLCMDpillbox::generatePoints(), BLCMDparticlefilter::generatePoints(), BLCMDmultipole::generatePoints(), BLCMDlilens::generatePoints(), BLCMDgenericquad::generatePoints(), and BLCMDabsorber::generatePoints().
00100 { 00101 v.clear(); 00102 G4double l=length/2.0; 00103 00104 // 8 points evenly spaced around outer (+inner) surface 00105 G4double dPhi = (finalPhi-initialPhi)/8.0; 00106 for(int i=0; i<9; ++i) { 00107 // if full cylinder, i=8 duplicates i=0 00108 if(i == 8 && dPhi >= 3.1415/4.0) break; 00109 G4double phi = (double)i*dPhi + initialPhi; 00110 G4double x = outerRadius * cos(phi); 00111 G4double y = outerRadius * sin(phi); 00112 v.push_back(G4ThreeVector(x,y,l)); 00113 v.push_back(G4ThreeVector(x,y,-l)); 00114 v.push_back(G4ThreeVector(x,y,0.0)); 00115 if(innerRadius > 0.0) { 00116 x = innerRadius * cos(phi); 00117 y = innerRadius * sin(phi); 00118 v.push_back(G4ThreeVector(x,y,l)); 00119 v.push_back(G4ThreeVector(x,y,-l)); 00120 v.push_back(G4ThreeVector(x,y,0.0)); 00121 } 00122 } 00123 // center of +z and =z ends, if innerRadius == 0 00124 if(innerRadius == 0.0) { 00125 v.push_back(G4ThreeVector(0.0,0.0,l)); 00126 v.push_back(G4ThreeVector(0.0,0.0,-l)); 00127 } 00128 // random points on the surface 00129 dPhi = finalPhi - initialPhi; 00130 G4double dR = outerRadius - innerRadius; 00131 while(v.size() < npoints) { 00132 G4double z=0.0,phi=0.0,r=0.0; 00133 switch(v.size() % 6) { 00134 case 0: // inner surface 00135 inner: if(innerRadius > 0.0) { 00136 phi = rand()*dPhi + initialPhi; 00137 r = innerRadius; 00138 z = rand()*length - l; 00139 break; 00140 } 00141 // flow into case 1 00142 case 1: // outer surface 00143 outer: phi = rand()*dPhi + initialPhi; 00144 r = outerRadius; 00145 z = rand()*length - l; 00146 break; 00147 case 2: // +z end 00148 phi = rand()*dPhi + initialPhi; 00149 r = rand()*dR + innerRadius; 00150 z = l; 00151 break; 00152 case 3: // -z end 00153 phi = rand()*dPhi + initialPhi; 00154 r = rand()*dR + innerRadius; 00155 z = -l; 00156 break; 00157 case 4: // initialPhi face 00158 if(dPhi >= 3.1415*2.0) goto inner; 00159 phi = initialPhi; 00160 r = rand()*dR + innerRadius; 00161 z = rand()*length - l; 00162 break; 00163 case 5: // finalPhi face 00164 if(dPhi >= 3.1415*2.0) goto outer; 00165 phi = finalPhi; 00166 r = rand()*dR + innerRadius; 00167 z = rand()*length - l; 00168 break; 00169 } 00170 v.push_back(G4ThreeVector(r*cos(phi),r*sin(phi),z)); 00171 } 00172 }
std::map< G4String, BLElement * > BLElement::mapElement [static, private] |
G4String BLElement::name [private] |
bool BLElement::placed [private] |
Referenced by BLElement(), getPlacedFlag(), and setPlacedFlag().