Public Member Functions | |
BLCMDbox () | |
Default constructor. Defines the command, args, etc. | |
virtual | ~BLCMDbox () |
Destructor. | |
BLCMDbox (const BLCMDbox &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() | |
G4String | commandName () |
commandName() returns "box". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the box command. | |
void | defineNamedArgs () |
defineNamedArgs() defines the named arguments for the command. | |
virtual void | construct (G4RotationMatrix *relativeRotation, G4ThreeVector relativePosition, G4LogicalVolume *parent, G4String parentName, G4RotationMatrix *parentRotation, G4ThreeVector parentPosition) |
construct() - construct the box. | |
G4double | getLength () |
getLength() returns the length of the tube/cylinder. | |
G4double | getWidth () |
getWidth() returns the outer radius of the tube/cylinder. | |
G4double | getHeight () |
getHeight() returns the outer radius of the tube/cylinder. | |
G4bool | isOK () |
isOK() returns true. | |
bool | isOutside (G4ThreeVector &local, G4double tolerance) |
isOutside() from BLElement. | |
void | generatePoints (int npoints, std::vector< G4ThreeVector > &v) |
generatePoints() from BLElement. | |
bool | isWithin (G4ThreeVector &local, G4double tolerance) |
isWithin() from BLGroupElement. | |
Private Attributes | |
G4double | height |
G4double | width |
G4double | length |
G4String | material |
G4String | color |
G4int | kill |
G4double | maxStep |
G4Box * | box |
BLCMDbox::BLCMDbox | ( | ) |
Default constructor. Defines the command, args, etc.
References BLCMDTYPE_ELEMENT, box, color, height, kill, length, material, maxStep, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), and width.
Referenced by clone(), and command().
00100 : BLGroupElement() 00101 { 00102 // register the commandName(), and its synopsis and description. 00103 registerCommand(BLCMDTYPE_ELEMENT); 00104 setSynopsis("construct a box."); 00105 setDescription("This is a direct interface to G4Box."); 00106 00107 // provide initial values for fields 00108 height = 0.0; 00109 width = 0.0; 00110 length = 0.0; 00111 material = "Vacuum"; 00112 color = "1,1,1"; 00113 kill = 0; 00114 maxStep = -1.0; 00115 box = 0; 00116 }
BLCMDbox::BLCMDbox | ( | const BLCMDbox & | r | ) |
Copy constructor.
References box, color, height, kill, length, material, maxStep, and width.
00119 : BLGroupElement(r) 00120 { 00121 // copy fields one at a time (transfers default values from the 00122 // default object to this new object). 00123 height = r.height; 00124 width = r.width; 00125 length = r.length; 00126 material = r.material; 00127 color = r.color; 00128 kill = r.kill; 00129 maxStep = r.maxStep; 00130 box = r.box; 00131 }
BLElement* BLCMDbox::clone | ( | ) | [inline, virtual] |
G4String BLCMDbox::commandName | ( | ) | [inline, virtual] |
int BLCMDbox::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the box command.
Implements BLCommand.
References BLCMDbox(), BLParam::getDouble(), BLCommand::getMaterial(), BLCommand::handleNamedArgs(), material, maxStep, Param, BLCommand::print(), BLCommand::printError(), and BLGroupElement::setName().
00134 { 00135 if(argv.size() != 1) { 00136 printError("box: Invalid command, must have name"); 00137 return -1; 00138 } 00139 00140 if(argv[0] == "default") { 00141 return defaultBox.handleNamedArgs(namedArgs); 00142 } 00143 00144 BLCMDbox *t = new BLCMDbox(defaultBox); 00145 t->setName(argv[0]); 00146 int retval = t->handleNamedArgs(namedArgs); 00147 00148 if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep"); 00149 00150 // check material exists 00151 if(t->material.size() > 0) getMaterial(t->material,false); 00152 00153 t->print(argv[0]); 00154 00155 return retval; 00156 }
void BLCMDbox::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References BLCommand::argDouble(), BLCommand::argInt(), BLCommand::argString(), color, height, kill, length, material, maxStep, and width.
00159 { 00160 argDouble(height,"height","The height of the box (mm)"); 00161 argDouble(width,"width","The width of the box (mm)"); 00162 argDouble(length,"length","The length of the box (mm)"); 00163 argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)"); 00164 argString(material,"material","The material of the box"); 00165 argString(color,"color","The color of the box (''=invisible)"); 00166 argInt(kill,"kill","Set nonzero to kill every track that enters."); 00167 }
void BLCMDbox::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [virtual] |
construct() - construct the box.
Implements BLElement.
References box, color, BLGroupElement::constructChildren(), BLParam::getDouble(), getLength(), BLCommand::getMaterial(), BLElement::getName(), BLManager::getObject(), BLCommand::getVisAttrib(), height, kill, length, material, maxStep, Param, and width.
00175 { 00176 G4String thisname = parentName+getName(); 00177 00178 if(!box) 00179 box = new G4Box(thisname+"Box", width/2.0, height/2.0, 00180 length/2.0); 00181 G4Material *mat = getMaterial(material); 00182 G4LogicalVolume *lv = new G4LogicalVolume(box,mat, thisname+"LogVol"); 00183 lv->SetVisAttributes(getVisAttrib(color)); 00184 if(maxStep < 0.0) maxStep = Param.getDouble("maxStep"); 00185 lv->SetUserLimits(new G4UserLimits(maxStep)); 00186 00187 // geant4 rotation convention is backwards from g4beamline 00188 G4RotationMatrix *g4rot = 0; 00189 if(relativeRotation) 00190 g4rot = new G4RotationMatrix(relativeRotation->inverse()); 00191 00192 G4VPhysicalVolume *pv = new G4PVPlacement(g4rot, 00193 relativePosition,lv,thisname, 00194 parent,false,0); 00195 00196 // handle kill parameter 00197 if(kill) 00198 BLManager::getObject()-> 00199 registerSteppingAction(pv,new BLKillTrack(thisname)); 00200 00201 // get globalRotation and globalPosition 00202 G4RotationMatrix *globalRotation = 0; 00203 if(relativeRotation && parentRotation) { 00204 globalRotation = 00205 new G4RotationMatrix(*parentRotation * *relativeRotation); 00206 } else if(relativeRotation) { 00207 globalRotation = relativeRotation; 00208 } else if(parentRotation) { 00209 globalRotation = parentRotation; 00210 } 00211 G4ThreeVector globalPosition(relativePosition + parentPosition); 00212 if(parentRotation) 00213 globalPosition = *parentRotation * relativePosition + 00214 parentPosition; 00215 00216 constructChildren(lv,thisname,globalRotation,globalPosition); 00217 00218 printf("BLCMDbox::Construct %s parent=%s relZ=%.1f globZ=%.1f\n" 00219 "\tzmin=%.1f zmax=%.1f\n", 00220 thisname.c_str(),parentName.c_str(),relativePosition[2], 00221 globalPosition[2], 00222 globalPosition[2]-getLength()/2.0, 00223 globalPosition[2]+getLength()/2.0); 00224 }
G4double BLCMDbox::getLength | ( | ) | [inline, virtual] |
getLength() returns the length of the tube/cylinder.
Implements BLElement.
References length.
Referenced by construct().
00076 { return length; }
G4double BLCMDbox::getWidth | ( | ) | [inline, virtual] |
getWidth() returns the outer radius of the tube/cylinder.
Implements BLElement.
References width.
00079 { return width; }
G4double BLCMDbox::getHeight | ( | ) | [inline, virtual] |
getHeight() returns the outer radius of the tube/cylinder.
Implements BLElement.
References height.
00082 { return height; }
G4bool BLCMDbox::isOK | ( | ) | [inline, virtual] |
G4bool BLCMDbox::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
void BLCMDbox::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [virtual] |
generatePoints() from BLElement.
Implements BLElement.
References BLElement::generateBox(), height, length, and width.
00234 { 00235 generateBox(npoints,width,height,length,v); 00236 }
G4bool BLCMDbox::isWithin | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
isWithin() from BLGroupElement.
Implements BLGroupElement.
References height, length, and width.
00239 { 00240 return fabs(local[0]) < width/2.0+tolerance && 00241 fabs(local[1]) < height/2.0+tolerance && 00242 fabs(local[2]) < length/2.0+tolerance; 00243 }
G4double BLCMDbox::height [private] |
Referenced by BLCMDbox(), construct(), defineNamedArgs(), generatePoints(), getHeight(), isOutside(), and isWithin().
G4double BLCMDbox::width [private] |
Referenced by BLCMDbox(), construct(), defineNamedArgs(), generatePoints(), getWidth(), isOutside(), and isWithin().
G4double BLCMDbox::length [private] |
Referenced by BLCMDbox(), construct(), defineNamedArgs(), generatePoints(), getLength(), isOutside(), and isWithin().
G4String BLCMDbox::material [private] |
Referenced by BLCMDbox(), command(), construct(), and defineNamedArgs().
G4String BLCMDbox::color [private] |
Referenced by BLCMDbox(), construct(), and defineNamedArgs().
G4int BLCMDbox::kill [private] |
Referenced by BLCMDbox(), construct(), and defineNamedArgs().
G4double BLCMDbox::maxStep [private] |
Referenced by BLCMDbox(), command(), construct(), and defineNamedArgs().
G4Box* BLCMDbox::box [private] |
Referenced by BLCMDbox(), and construct().