Public Member Functions | |
BLCMDpolycone () | |
Default constructor. Defines the command, args, etc. | |
virtual | ~BLCMDpolycone () |
Destructor. | |
BLCMDpolycone (const BLCMDpolycone &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() | |
G4String | commandName () |
commandName() returns "polycone". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the polycone command. | |
void | setup () |
setup() will handle the vector arguments. | |
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. | |
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 | |
G4String | innerRadius |
G4String | outerRadius |
G4String | z |
G4double | initialPhi |
G4double | finalPhi |
G4String | material |
G4String | color |
G4int | kill |
G4double | maxStep |
G4Polycone * | polycone |
G4double | length |
G4double | maxRadius |
std::vector< G4double > | irs |
std::vector< G4double > | ors |
std::vector< G4double > | zs |
BLCMDpolycone::BLCMDpolycone | ( | ) |
Default constructor. Defines the command, args, etc.
References BLCMDTYPE_ELEMENT, color, finalPhi, initialPhi, innerRadius, kill, length, material, maxRadius, maxStep, outerRadius, polycone, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), and z.
Referenced by clone(), and command().
00119 : BLGroupElement() 00120 { 00121 // register the commandName(), and its synopsis and description. 00122 registerCommand(BLCMDTYPE_ELEMENT); 00123 setSynopsis("construct a polycone with axis along z"); 00124 setDescription("This is a direct interface to G4Polycone.\n" 00125 "For a solid polycone, omit innerRadius and it will be\n" 00126 "filled with zeroes. The number of entries in z, innerRadius,\n" 00127 "and outerRadius must be the same. Note that a polycone is\n" 00128 "placed at its z=0,r=0 point, which need not be its\n" 00129 "geometric center."); 00130 00131 // provide initial values for fields 00132 innerRadius = ""; 00133 outerRadius = ""; 00134 z = ""; 00135 initialPhi = 0.0; 00136 finalPhi = 360.0*deg; 00137 material = "Vacuum"; 00138 color = "1,1,1"; 00139 kill = 0; 00140 maxStep = -1.0; 00141 polycone = 0; 00142 length = 0.0; 00143 maxRadius = 0.0; 00144 }
BLCMDpolycone::BLCMDpolycone | ( | const BLCMDpolycone & | r | ) |
Copy constructor.
References color, finalPhi, initialPhi, innerRadius, kill, length, material, maxRadius, maxStep, outerRadius, polycone, and z.
00147 : BLGroupElement(r), 00148 irs(r.irs), ors(r.ors), zs(r.zs) 00149 { 00150 // copy fields one at a time (transfers default values from the 00151 // default object to this new object). 00152 innerRadius = r.innerRadius; 00153 outerRadius = r.outerRadius; 00154 z = r.z; 00155 initialPhi = r.initialPhi; 00156 finalPhi = r.finalPhi; 00157 material = r.material; 00158 color = r.color; 00159 kill = r.kill; 00160 maxStep = r.maxStep; 00161 polycone = r.polycone; 00162 length = r.length; 00163 maxRadius = r.maxRadius; 00164 }
BLElement* BLCMDpolycone::clone | ( | ) | [inline, virtual] |
G4String BLCMDpolycone::commandName | ( | ) | [inline, virtual] |
int BLCMDpolycone::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the polycone command.
Implements BLCommand.
References BLCMDpolycone(), BLParam::getDouble(), BLCommand::getMaterial(), BLCommand::handleNamedArgs(), material, maxStep, Param, BLCommand::print(), BLCommand::printError(), BLGroupElement::setName(), and setup().
00167 { 00168 if(argv.size() != 1) { 00169 printError("polycone: Invalid command, must have name"); 00170 return -1; 00171 } 00172 00173 if(argv[0] == "default") { 00174 return defaultPolycone.handleNamedArgs(namedArgs); 00175 } 00176 00177 BLCMDpolycone *t = new BLCMDpolycone(defaultPolycone); 00178 t->setName(argv[0]); 00179 int retval = t->handleNamedArgs(namedArgs); 00180 00181 if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep"); 00182 00183 t->setup(); 00184 00185 // check material exists 00186 if(t->material.size() > 0) getMaterial(t->material,false); 00187 00188 t->print(argv[0]); 00189 00190 return retval; 00191 }
void BLCMDpolycone::setup | ( | ) |
setup() will handle the vector arguments.
References BLCommand::getList(), innerRadius, irs, length, maxRadius, ors, outerRadius, BLCommand::printError(), z, and zs.
Referenced by command().
00207 { 00208 // parse list arguments into the vectors 00209 zs = getList(z,','); 00210 if(zs.size() == 0) 00211 printError("polycone: invalid z list"); 00212 irs = getList(innerRadius,","); 00213 if(irs.size() == 0 && innerRadius.size() > 0) 00214 printError("polycone: invalid innerRadius list"); 00215 ors = getList(outerRadius,","); 00216 if(ors.size() == 0) 00217 printError("polycone: invalid outerRadius list"); 00218 00219 // if innerRadius=="", fill irs[] with zeroes 00220 if(irs.size() == 0) { 00221 for(unsigned i=0; i<zs.size(); ++i) 00222 irs.push_back(0.0); 00223 } 00224 00225 // check valididty of the lists 00226 if(zs.size()!=ors.size() || zs.size()!=irs.size()) 00227 printError("polycone: inconsistent array sizes"); 00228 00229 // compute object size and check z order 00230 G4double prevZ=-DBL_MAX, minZ=+DBL_MAX, maxZ=-DBL_MAX, maxR=0.0; 00231 bool ok=true; 00232 for(unsigned i=0; i<zs.size(); ++i) { 00233 double z=zs[i]; 00234 if(z < prevZ) ok = false; 00235 prevZ = z; 00236 if(minZ > z) minZ = z; 00237 if(maxZ < z) maxZ = z; 00238 double r=ors[i]; 00239 if(maxR < r) maxR = r; 00240 } 00241 if(!ok) printError("polycone: invalid order of z values"); 00242 00243 maxRadius = maxR; 00244 length = 2.0*(fabs(minZ)>fabs(maxZ) ? fabs(minZ) : fabs(maxZ)); 00245 /*** 00246 unsigned int place, next; 00247 for(place=next=0; next<z.size(); place=next+1) { 00248 next = z.find(",",place); 00249 G4String p; 00250 if(next < z.size()) 00251 p = z.substr(place,next-place); 00252 else 00253 p = z.substr(place); 00254 if(p.size() == 0) break; 00255 G4double z = atof(p.c_str()); 00256 zs.push_back(z); 00257 if(minZ > z) minZ = z; 00258 if(maxZ < z) maxZ = z; 00259 } 00260 // get innerRadius positions into irs[] 00261 for(place=next=0; next<innerRadius.size(); place=next+1) { 00262 next = innerRadius.find(",",place); 00263 G4String p; 00264 if(next < innerRadius.size()) 00265 p = innerRadius.substr(place,next-place); 00266 else 00267 p = innerRadius.substr(place); 00268 if(p.size() == 0) break; 00269 irs.push_back(atof(p.c_str())); 00270 } 00271 // get outerRadius positions into ors[] 00272 for(place=next=0; next<outerRadius.size(); place=next+1) { 00273 next = outerRadius.find(",",place); 00274 G4String p; 00275 if(next < outerRadius.size()) 00276 p = outerRadius.substr(place,next-place); 00277 else 00278 p = outerRadius.substr(place); 00279 if(p.size() == 0) break; 00280 G4double r = atof(p.c_str()); 00281 ors.push_back(r); 00282 if(maxR < r) maxR = r; 00283 } 00284 ***/ 00285 }
void BLCMDpolycone::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, material, maxStep, outerRadius, and z.
00194 { 00195 argString(innerRadius,"innerRadius","Comma-separated list of inner radii (mm)",false); 00196 argString(outerRadius,"outerRadius","Comma-separated list of outer radii (mm)",false); 00197 argString(z,"z","Comma-separated list of z positions (mm)",false); 00198 argDouble(initialPhi,"initialPhi","The initial Phi value (deg; 0 for all)",deg); 00199 argDouble(finalPhi,"finalPhi","The final Phi value (deg; 360 for all)",deg); 00200 argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)",mm); 00201 argString(material,"material","The material of the polycone"); 00202 argString(color,"color","The color of the polycone (''=invisible)"); 00203 argInt(kill,"kill","Set nonzero to kill every track that enters."); 00204 }
void BLCMDpolycone::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, irs, kill, material, maxStep, ors, Param, polycone, and zs.
00293 { 00294 G4String thisname = parentName+getName(); 00295 00296 if(!polycone) { 00297 polycone = new G4Polycone(thisname+"Polycone", 00298 initialPhi,finalPhi-initialPhi,zs.size(), 00299 &zs[0],&irs[0],&ors[0]); 00300 } 00301 G4Material *mat = getMaterial(material); 00302 G4LogicalVolume *lv = new G4LogicalVolume(polycone,mat, thisname+"LogVol"); 00303 lv->SetVisAttributes(getVisAttrib(color)); 00304 if(maxStep < 0.0) maxStep = Param.getDouble("maxStep"); 00305 lv->SetUserLimits(new G4UserLimits(maxStep)); 00306 00307 // geant4 rotation convention is backwards from g4beamline 00308 G4RotationMatrix *g4rot = 0; 00309 if(relativeRotation) 00310 g4rot = new G4RotationMatrix(relativeRotation->inverse()); 00311 00312 G4VPhysicalVolume *pv = new G4PVPlacement(g4rot, relativePosition,lv, 00313 thisname, parent,false,0); 00314 00315 if(kill) 00316 BLManager::getObject()-> 00317 registerSteppingAction(pv,new BLKillTrack(thisname)); 00318 00319 // get globalRotation and globalPosition 00320 G4RotationMatrix *globalRotation = 0; 00321 if(relativeRotation && parentRotation) { 00322 globalRotation = 00323 new G4RotationMatrix(*parentRotation * *relativeRotation); 00324 } else if(relativeRotation) { 00325 globalRotation = relativeRotation; 00326 } else if(parentRotation) { 00327 globalRotation = parentRotation; 00328 } 00329 G4ThreeVector globalPosition(relativePosition + parentPosition); 00330 if(parentRotation) 00331 globalPosition = *parentRotation * relativePosition + 00332 parentPosition; 00333 00334 constructChildren(lv,thisname,globalRotation,globalPosition); 00335 00336 printf("BLCMDpolycone::Construct %s parent=%s relZ=%.1f globZ=%.1f\n" 00337 "\tzmin=%.1f zmax=%.1f kill=%d\n", 00338 thisname.c_str(),parentName.c_str(),relativePosition[2], 00339 globalPosition[2], 00340 globalPosition[2]-getLength()/2.0, 00341 globalPosition[2]+getLength()/2.0, 00342 kill); 00343 }
G4double BLCMDpolycone::getLength | ( | ) | [inline, virtual] |
getLength() returns the length of the tube/cylinder.
Implements BLElement.
References length.
Referenced by construct().
00089 { return length; }
G4double BLCMDpolycone::getWidth | ( | ) | [inline, virtual] |
getWidth() returns the width of the tube/cylinder.
Implements BLElement.
References maxRadius.
00092 { return 2.0*maxRadius; }
G4double BLCMDpolycone::getHeight | ( | ) | [inline, virtual] |
getHeight() returns the height of the tube/cylinder.
Implements BLElement.
References maxRadius.
00095 { return 2.0*maxRadius; }
G4bool BLCMDpolycone::isOK | ( | ) | [inline, virtual] |
bool BLCMDpolycone::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [inline, virtual] |
void BLCMDpolycone::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [inline, virtual] |
generatePoints() from BLElement.
Implements BLElement.
References polycone.
00106 { v.clear(); 00107 for(int n=0; n<npoints*5; ++n) 00108 v.push_back(polycone->GetPointOnSurface()); 00109 }
bool BLCMDpolycone::isWithin | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [inline, virtual] |
G4String BLCMDpolycone::innerRadius [private] |
Referenced by BLCMDpolycone(), defineNamedArgs(), and setup().
G4String BLCMDpolycone::outerRadius [private] |
Referenced by BLCMDpolycone(), defineNamedArgs(), and setup().
G4String BLCMDpolycone::z [private] |
Referenced by BLCMDpolycone(), defineNamedArgs(), and setup().
G4double BLCMDpolycone::initialPhi [private] |
Referenced by BLCMDpolycone(), construct(), and defineNamedArgs().
G4double BLCMDpolycone::finalPhi [private] |
Referenced by BLCMDpolycone(), construct(), and defineNamedArgs().
G4String BLCMDpolycone::material [private] |
Referenced by BLCMDpolycone(), command(), construct(), and defineNamedArgs().
G4String BLCMDpolycone::color [private] |
Referenced by BLCMDpolycone(), construct(), and defineNamedArgs().
G4int BLCMDpolycone::kill [private] |
Referenced by BLCMDpolycone(), construct(), and defineNamedArgs().
G4double BLCMDpolycone::maxStep [private] |
Referenced by BLCMDpolycone(), command(), construct(), and defineNamedArgs().
G4Polycone* BLCMDpolycone::polycone [private] |
Referenced by BLCMDpolycone(), construct(), generatePoints(), isOutside(), and isWithin().
G4double BLCMDpolycone::length [private] |
Referenced by BLCMDpolycone(), getLength(), and setup().
G4double BLCMDpolycone::maxRadius [private] |
Referenced by BLCMDpolycone(), getHeight(), getWidth(), and setup().
std::vector<G4double> BLCMDpolycone::irs [private] |
Referenced by construct(), and setup().
std::vector<G4double> BLCMDpolycone::ors [private] |
Referenced by construct(), and setup().
std::vector<G4double> BLCMDpolycone::zs [private] |
Referenced by construct(), and setup().