Public Member Functions | |
BLCMDtubs () | |
Default constructor. Defines the command, args, etc. | |
virtual | ~BLCMDtubs () |
Destructor. | |
BLCMDtubs (const BLCMDtubs &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() | |
G4String | commandName () |
commandName() returns "tubs". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the tubs 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 tube/cylinder. | |
G4double | getLength () |
getLength() returns the length of the tube/cylinder. | |
G4double | getWidth () |
getWidth() returns the width of the tube/cylinder. | |
G4double | getHeight () |
getHeight() returns the height of the tube/cylinder. | |
G4bool | isOK () |
isOK() returns true. | |
void | generatePoints (int npoints, std::vector< G4ThreeVector > &v) |
generatePoints() from BLElement | |
G4bool | isOutside (G4ThreeVector &local, G4double tolerance) |
isOutside() from BLElement | |
bool | isWithin (G4ThreeVector &local, G4double tolerance) |
isWithin() from BLGroupElement | |
Private Attributes | |
G4double | innerRadius |
G4double | outerRadius |
G4double | initialPhi |
G4double | finalPhi |
G4double | length |
G4String | material |
G4String | color |
G4int | kill |
G4double | maxStep |
G4Tubs * | tubs |
BLCMDtubs::BLCMDtubs | ( | ) |
Default constructor. Defines the command, args, etc.
References BLCMDTYPE_ELEMENT, color, finalPhi, initialPhi, innerRadius, kill, length, material, maxStep, outerRadius, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), and tubs.
Referenced by clone(), and command().
00106 : BLGroupElement() 00107 { 00108 // register the commandName(), and its synopsis and description. 00109 registerCommand(BLCMDTYPE_ELEMENT); 00110 setSynopsis("construct a tube or cylinder with axis along z."); 00111 setDescription("This is a direct interface to G4Tubs, which can\n" 00112 "implement a tube or cylinder; either can subtend less " 00113 "than 360 degrees in phi."); 00114 00115 // provide initial values for fields 00116 innerRadius = 0.0; 00117 outerRadius = 0.0; 00118 initialPhi = 0.0; 00119 finalPhi = 360.0*deg; 00120 length = 0.0; 00121 material = "Vacuum"; 00122 color = "1,1,1"; 00123 kill = 0; 00124 maxStep = -1.0; 00125 tubs = 0; 00126 }
BLCMDtubs::BLCMDtubs | ( | const BLCMDtubs & | r | ) |
Copy constructor.
References color, finalPhi, initialPhi, innerRadius, kill, length, material, maxStep, outerRadius, and tubs.
00129 : BLGroupElement(r) 00130 { 00131 // copy fields one at a time (transfers default values from the 00132 // default object to this new object). 00133 innerRadius = r.innerRadius; 00134 outerRadius = r.outerRadius; 00135 initialPhi = r.initialPhi; 00136 finalPhi = r.finalPhi; 00137 length = r.length; 00138 material = r.material; 00139 color = r.color; 00140 kill = r.kill; 00141 maxStep = r.maxStep; 00142 tubs = r.tubs; 00143 }
BLElement* BLCMDtubs::clone | ( | ) | [inline, virtual] |
G4String BLCMDtubs::commandName | ( | ) | [inline, virtual] |
int BLCMDtubs::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the tubs command.
Implements BLCommand.
References BLCMDtubs(), BLParam::getDouble(), BLCommand::getMaterial(), BLCommand::handleNamedArgs(), material, maxStep, Param, BLCommand::print(), BLCommand::printError(), and BLGroupElement::setName().
00146 { 00147 if(argv.size() != 1) { 00148 printError("tubs: Invalid command, must have name"); 00149 return -1; 00150 } 00151 00152 if(argv[0] == "default") { 00153 return defaultTubs.handleNamedArgs(namedArgs); 00154 } 00155 00156 BLCMDtubs *t = new BLCMDtubs(defaultTubs); 00157 t->setName(argv[0]); 00158 int retval = t->handleNamedArgs(namedArgs); 00159 00160 if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep"); 00161 00162 // check material exists 00163 if(t->material.size() > 0) getMaterial(t->material,false); 00164 00165 t->print(argv[0]); 00166 00167 return retval; 00168 }
void BLCMDtubs::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References BLCommand::argDouble(), BLCommand::argInt(), BLCommand::argString(), color, finalPhi, initialPhi, innerRadius, kill, length, material, maxStep, and outerRadius.
00171 { 00172 argDouble(innerRadius,"innerRadius","The inside of the tube, 0.0 for cylinder (mm)", 00173 mm); 00174 argDouble(outerRadius,"outerRadius","The outer radius of the tube or cylinder (mm)", 00175 mm); 00176 argDouble(initialPhi,"initialPhi","The initial Phi value (deg; 0 for all)", 00177 deg); 00178 argDouble(finalPhi,"finalPhi","The final Phi value (deg; 360 for all)", 00179 deg); 00180 argDouble(length,"length","The length of the tube or cylinder (mm)", 00181 mm); 00182 argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)", 00183 mm); 00184 argString(material,"material","The material of the tube or cylinder"); 00185 argString(color,"color","The color of the tube or cylinder (''=invisible)"); 00186 argInt(kill,"kill","Set nonzero to kill every track that enters."); 00187 argDouble(outerRadius,"radius","Synonym for outerRadius (mm)",mm); 00188 }
void BLCMDtubs::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [virtual] |
construct() - construct the tube/cylinder.
Implements BLElement.
References color, BLGroupElement::constructChildren(), finalPhi, BLParam::getDouble(), getLength(), BLCommand::getMaterial(), BLElement::getName(), BLManager::getObject(), BLCommand::getVisAttrib(), initialPhi, innerRadius, kill, length, material, maxStep, outerRadius, Param, and tubs.
00196 { 00197 G4String thisname = parentName+getName(); 00198 00199 if(!tubs) 00200 tubs = new G4Tubs(thisname+"Tubs", innerRadius, outerRadius, 00201 length/2.0, initialPhi,finalPhi-initialPhi); 00202 G4Material *mat = getMaterial(material); 00203 G4LogicalVolume *lv = new G4LogicalVolume(tubs,mat, thisname+"LogVol"); 00204 lv->SetVisAttributes(getVisAttrib(color)); 00205 if(maxStep < 0.0) maxStep = Param.getDouble("maxStep"); 00206 lv->SetUserLimits(new G4UserLimits(maxStep)); 00207 00208 // geant4 rotation convention is backwards from g4beamline 00209 G4RotationMatrix *g4rot = 0; 00210 if(relativeRotation) 00211 g4rot = new G4RotationMatrix(relativeRotation->inverse()); 00212 00213 G4VPhysicalVolume *pv = new G4PVPlacement(g4rot, relativePosition,lv, 00214 thisname, parent,false,0); 00215 00216 if(kill) 00217 BLManager::getObject()-> 00218 registerSteppingAction(pv,new BLKillTrack(thisname)); 00219 00220 // get globalRotation and globalPosition 00221 G4RotationMatrix *globalRotation = 0; 00222 if(relativeRotation && parentRotation) { 00223 globalRotation = 00224 new G4RotationMatrix(*parentRotation * *relativeRotation); 00225 } else if(relativeRotation) { 00226 globalRotation = relativeRotation; 00227 } else if(parentRotation) { 00228 globalRotation = parentRotation; 00229 } 00230 G4ThreeVector globalPosition(relativePosition + parentPosition); 00231 if(parentRotation) 00232 globalPosition = *parentRotation * relativePosition + 00233 parentPosition; 00234 00235 constructChildren(lv,thisname,globalRotation,globalPosition); 00236 00237 printf("BLCMDtubs::Construct %s parent=%s relZ=%.1f globZ=%.1f\n" 00238 "\tzmin=%.1f zmax=%.1f kill=%d\n", 00239 thisname.c_str(),parentName.c_str(),relativePosition[2], 00240 globalPosition[2], 00241 globalPosition[2]-getLength()/2.0, 00242 globalPosition[2]+getLength()/2.0, 00243 kill); 00244 }
G4double BLCMDtubs::getLength | ( | ) | [inline, virtual] |
getLength() returns the length of the tube/cylinder.
Implements BLElement.
References length.
Referenced by construct().
00079 { return length; }
G4double BLCMDtubs::getWidth | ( | ) | [inline, virtual] |
getWidth() returns the width of the tube/cylinder.
Implements BLElement.
References outerRadius.
00082 { return 2.0*outerRadius; }
G4double BLCMDtubs::getHeight | ( | ) | [inline, virtual] |
getHeight() returns the height of the tube/cylinder.
Implements BLElement.
References outerRadius.
00085 { return 2.0*outerRadius; }
G4bool BLCMDtubs::isOK | ( | ) | [inline, virtual] |
void BLCMDtubs::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [virtual] |
generatePoints() from BLElement
Implements BLElement.
References finalPhi, BLElement::generateTubs(), initialPhi, innerRadius, length, and outerRadius.
00247 { 00248 generateTubs(npoints, innerRadius, outerRadius, initialPhi, finalPhi, 00249 length, v); 00250 }
G4bool BLCMDtubs::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
isOutside() from BLElement
Implements BLElement.
References finalPhi, initialPhi, length, and outerRadius.
00253 { 00254 G4double r = sqrt(local[0]*local[0]+local[1]*local[1]); 00255 G4double phi = atan2(local[1],local[0]); 00256 bool phiInside = phi > initialPhi+0.001 && phi < finalPhi-0.001; 00257 if(!phiInside && phi < 0.0) { 00258 phi += pi+pi; 00259 phiInside = phi > initialPhi+0.001 && phi < finalPhi-0.001; 00260 } 00261 return r < innerRadius+tolerance || r > outerRadius-tolerance || 00262 fabs(local[2]) > length/2.0-tolerance || !phiInside; 00263 }
bool BLCMDtubs::isWithin | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
isWithin() from BLGroupElement
Implements BLGroupElement.
References finalPhi, initialPhi, innerRadius, length, and outerRadius.
00266 { 00267 G4double r = sqrt(local[0]*local[0]+local[1]*local[1]); 00268 G4double phi = atan2(local[1],local[0]); 00269 if(phi < 0.0 && phi < initialPhi-0.001) phi += pi+pi; 00270 return r > innerRadius-tolerance && r < outerRadius+tolerance && 00271 fabs(local[2]) < length/2.0+tolerance && 00272 phi >= initialPhi-0.001 && phi < finalPhi+0.001; 00273 }
G4double BLCMDtubs::innerRadius [private] |
Referenced by BLCMDtubs(), construct(), defineNamedArgs(), generatePoints(), and isWithin().
G4double BLCMDtubs::outerRadius [private] |
Referenced by BLCMDtubs(), construct(), defineNamedArgs(), generatePoints(), getHeight(), getWidth(), isOutside(), and isWithin().
G4double BLCMDtubs::initialPhi [private] |
Referenced by BLCMDtubs(), construct(), defineNamedArgs(), generatePoints(), isOutside(), and isWithin().
G4double BLCMDtubs::finalPhi [private] |
Referenced by BLCMDtubs(), construct(), defineNamedArgs(), generatePoints(), isOutside(), and isWithin().
G4double BLCMDtubs::length [private] |
Referenced by BLCMDtubs(), construct(), defineNamedArgs(), generatePoints(), getLength(), isOutside(), and isWithin().
G4String BLCMDtubs::material [private] |
Referenced by BLCMDtubs(), command(), construct(), and defineNamedArgs().
G4String BLCMDtubs::color [private] |
Referenced by BLCMDtubs(), construct(), and defineNamedArgs().
G4int BLCMDtubs::kill [private] |
Referenced by BLCMDtubs(), construct(), and defineNamedArgs().
G4double BLCMDtubs::maxStep [private] |
Referenced by BLCMDtubs(), command(), construct(), and defineNamedArgs().
G4Tubs* BLCMDtubs::tubs [private] |
Referenced by BLCMDtubs(), and construct().