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 }
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.
00195 { 00196 G4String thisname = parentName+getName(); 00197 00198 if(!tubs) 00199 tubs = new G4Tubs(thisname+"Tubs", innerRadius, outerRadius, 00200 length/2.0, initialPhi,finalPhi-initialPhi); 00201 G4Material *mat = getMaterial(material); 00202 G4LogicalVolume *lv = new G4LogicalVolume(tubs,mat, thisname+"LogVol"); 00203 lv->SetVisAttributes(getVisAttrib(color)); 00204 if(maxStep < 0.0) maxStep = Param.getDouble("maxStep"); 00205 lv->SetUserLimits(new G4UserLimits(maxStep)); 00206 00207 // geant4 rotation convention is backwards from g4beamline 00208 G4RotationMatrix *g4rot = 0; 00209 if(relativeRotation) 00210 g4rot = new G4RotationMatrix(relativeRotation->inverse()); 00211 00212 G4VPhysicalVolume *pv = new G4PVPlacement(g4rot, relativePosition,lv, 00213 thisname, parent,false,0); 00214 00215 if(kill) 00216 BLManager::getObject()-> 00217 registerSteppingAction(pv,new BLKillTrack(thisname)); 00218 00219 // get globalRotation and globalPosition 00220 G4RotationMatrix *globalRotation = 0; 00221 if(relativeRotation && parentRotation) { 00222 globalRotation = 00223 new G4RotationMatrix(*parentRotation * *relativeRotation); 00224 } else if(relativeRotation) { 00225 globalRotation = relativeRotation; 00226 } else if(parentRotation) { 00227 globalRotation = parentRotation; 00228 } 00229 G4ThreeVector globalPosition(relativePosition + parentPosition); 00230 if(parentRotation) 00231 globalPosition = *parentRotation * relativePosition + 00232 parentPosition; 00233 00234 constructChildren(lv,thisname,globalRotation,globalPosition); 00235 00236 printf("BLCMDtubs::Construct %s parent=%s relZ=%.1f globZ=%.1f\n" 00237 "\tzmin=%.1f zmax=%.1f kill=%d\n", 00238 thisname.c_str(),parentName.c_str(),relativePosition[2], 00239 globalPosition[2], 00240 globalPosition[2]-getLength()/2.0, 00241 globalPosition[2]+getLength()/2.0, 00242 kill); 00243 }
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.
00246 { 00247 generateTubs(npoints, innerRadius, outerRadius, initialPhi, finalPhi, 00248 length, v); 00249 }
G4bool BLCMDtubs::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
isOutside() from BLElement
Implements BLElement.
References finalPhi, initialPhi, length, and outerRadius.
00252 { 00253 G4double r = sqrt(local[0]*local[0]+local[1]*local[1]); 00254 G4double phi = atan2(local[1],local[0]); 00255 bool phiInside = phi > initialPhi+0.001 && phi < finalPhi-0.001; 00256 if(!phiInside && phi < 0.0) { 00257 phi += pi+pi; 00258 phiInside = phi > initialPhi+0.001 && phi < finalPhi-0.001; 00259 } 00260 return r < innerRadius+tolerance || r > outerRadius-tolerance || 00261 fabs(local[2]) > length/2.0-tolerance || !phiInside; 00262 }
bool BLCMDtubs::isWithin | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
isWithin() from BLGroupElement
Implements BLGroupElement.
References finalPhi, initialPhi, innerRadius, length, and outerRadius.
00265 { 00266 G4double r = sqrt(local[0]*local[0]+local[1]*local[1]); 00267 G4double phi = atan2(local[1],local[0]); 00268 if(phi < 0.0 && phi < initialPhi-0.001) phi += pi+pi; 00269 return r > innerRadius-tolerance && r < outerRadius+tolerance && 00270 fabs(local[2]) < length/2.0+tolerance && 00271 phi >= initialPhi-0.001 && phi < finalPhi+0.001; 00272 }
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().