BLCMDpolycone Class Reference

Inheritance diagram for BLCMDpolycone:

BLGroupElement BLElement BLCommand

List of all members.


Detailed Description

BLCMDpolycone implements a polycone of material, axis along Z.

Public Member Functions

 BLCMDpolycone ()
 Default constructor. Defines the command, args, etc.
virtual ~BLCMDpolycone ()
 Destructor.
 BLCMDpolycone (const BLCMDpolycone &r)
 Copy constructor.
BLElementclone ()
 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

Constructor & Destructor Documentation

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().

00118                              : BLGroupElement()
00119 {
00120         // register the commandName(), and its synopsis and description.
00121         registerCommand(BLCMDTYPE_ELEMENT);
00122         setSynopsis("construct a polycone with axis along z");
00123         setDescription("This is a direct interface to G4Polycone.\n"
00124                 "For a solid polycone, omit innerRadius and it will be\n"
00125                 "filled with zeroes. The number of entries in z, innerRadius,\n"
00126                 "and outerRadius must be the same. Note that a polycone is\n"
00127                 "placed at its z=0,r=0 point, which need not be its\n"
00128                 "geometric center.");
00129 
00130         // provide initial values for fields
00131         innerRadius = "";
00132         outerRadius = "";
00133         z = "";
00134         initialPhi = 0.0;
00135         finalPhi = 360.0*deg;
00136         material = "Vacuum";
00137         color = "1,1,1";
00138         kill = 0;
00139         maxStep = -1.0;
00140         polycone = 0;
00141         length = 0.0;
00142         maxRadius = 0.0;
00143 }

virtual BLCMDpolycone::~BLCMDpolycone (  )  [inline, virtual]

Destructor.

00059 { }

BLCMDpolycone::BLCMDpolycone ( const BLCMDpolycone r  ) 

Copy constructor.

References color, finalPhi, initialPhi, innerRadius, kill, length, material, maxRadius, maxStep, outerRadius, polycone, and z.

00146                                                    : BLGroupElement(r),
00147                                         irs(r.irs), ors(r.ors), zs(r.zs)
00148 {
00149         // copy fields one at a time (transfers default values from the
00150         // default object to this new object).
00151         innerRadius = r.innerRadius;
00152         outerRadius = r.outerRadius;
00153         z = r.z;
00154         initialPhi = r.initialPhi;
00155         finalPhi = r.finalPhi;
00156         material = r.material;
00157         color = r.color;
00158         kill = r.kill;
00159         maxStep = r.maxStep;
00160         polycone = r.polycone;
00161         length = r.length;
00162         maxRadius = r.maxRadius;
00163 }


Member Function Documentation

BLElement* BLCMDpolycone::clone (  )  [inline, virtual]

clone()

Implements BLElement.

References BLCMDpolycone().

00065 { return new BLCMDpolycone(*this); }

G4String BLCMDpolycone::commandName (  )  [inline, virtual]

commandName() returns "polycone".

Implements BLCommand.

00068 { return "polycone"; }

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().

00166 {
00167         if(argv.size() != 1) {
00168                 printError("polycone: Invalid command, must have name");
00169                 return -1;
00170         }
00171 
00172         if(argv[0] == "default") {
00173                 return defaultPolycone.handleNamedArgs(namedArgs);
00174         }
00175 
00176         BLCMDpolycone *t = new BLCMDpolycone(defaultPolycone);
00177         t->setName(argv[0]);
00178         int retval = t->handleNamedArgs(namedArgs);
00179 
00180         if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep");
00181 
00182         t->setup();
00183 
00184         // check material exists
00185         if(t->material.size() > 0) getMaterial(t->material,false);
00186 
00187         t->print(argv[0]);
00188 
00189         return retval;
00190 }

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().

00206 {
00207         // parse list arguments into the vectors
00208         zs = getList(z,',');
00209         if(zs.size() == 0)
00210                 printError("polycone: invalid z list");
00211         irs = getList(innerRadius,",");
00212         if(irs.size() == 0 && innerRadius.size() > 0)
00213                 printError("polycone: invalid innerRadius list");
00214         ors = getList(outerRadius,",");
00215         if(ors.size() == 0)
00216                 printError("polycone: invalid outerRadius list");
00217 
00218         // if innerRadius=="", fill irs[] with zeroes
00219         if(irs.size() == 0) {
00220                 for(unsigned i=0; i<zs.size(); ++i)
00221                         irs.push_back(0.0);
00222         }
00223 
00224         // check valididty of the lists
00225         if(zs.size()!=ors.size() || zs.size()!=irs.size())
00226                 printError("polycone: inconsistent array sizes");
00227 
00228         // compute object size and check z order
00229         G4double prevZ=-DBL_MAX, minZ=+DBL_MAX, maxZ=-DBL_MAX, maxR=0.0;
00230         bool ok=true;
00231         for(unsigned i=0; i<zs.size(); ++i) {
00232                 double z=zs[i];
00233                 if(z < prevZ) ok = false;
00234                 prevZ = z;
00235                 if(minZ > z) minZ = z;
00236                 if(maxZ < z) maxZ = z;
00237                 double r=ors[i];
00238                 if(maxR < r) maxR = r;
00239         }
00240         if(!ok) printError("polycone: invalid order of z values");
00241 
00242         maxRadius = maxR;
00243         length = 2.0*(fabs(minZ)>fabs(maxZ) ? fabs(minZ) : fabs(maxZ));
00244 /***
00245         unsigned int place, next;
00246         for(place=next=0; next<z.size(); place=next+1) {
00247                 next = z.find(",",place);
00248                 G4String p;
00249                 if(next < z.size())
00250                         p = z.substr(place,next-place);
00251                 else
00252                         p = z.substr(place);
00253                 if(p.size() == 0) break;
00254                 G4double z = atof(p.c_str());
00255                 zs.push_back(z);
00256                 if(minZ > z) minZ = z;
00257                 if(maxZ < z) maxZ = z;
00258         }
00259         // get innerRadius positions into irs[]
00260         for(place=next=0; next<innerRadius.size(); place=next+1) {
00261                 next = innerRadius.find(",",place);
00262                 G4String p;
00263                 if(next < innerRadius.size())
00264                         p = innerRadius.substr(place,next-place);
00265                 else
00266                         p = innerRadius.substr(place);
00267                 if(p.size() == 0) break;
00268                 irs.push_back(atof(p.c_str()));
00269         }
00270         // get outerRadius positions into ors[]
00271         for(place=next=0; next<outerRadius.size(); place=next+1) {
00272                 next = outerRadius.find(",",place);
00273                 G4String p;
00274                 if(next < outerRadius.size())
00275                         p = outerRadius.substr(place,next-place);
00276                 else
00277                         p = outerRadius.substr(place);
00278                 if(p.size() == 0) break;
00279                 G4double r = atof(p.c_str());
00280                 ors.push_back(r);
00281                 if(maxR < r) maxR = r;
00282         }
00283 ***/
00284 }

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.

00193 {
00194         argString(innerRadius,"innerRadius","Comma-separated list of inner radii (mm)",false);
00195         argString(outerRadius,"outerRadius","Comma-separated list of outer radii (mm)",false);
00196         argString(z,"z","Comma-separated list of z positions (mm)",false);
00197         argDouble(initialPhi,"initialPhi","The initial Phi value (deg; 0 for all)",deg);
00198         argDouble(finalPhi,"finalPhi","The final Phi value (deg; 360 for all)",deg);
00199         argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)",mm);
00200         argString(material,"material","The material of the polycone");
00201         argString(color,"color","The color of the polycone (''=invisible)");
00202         argInt(kill,"kill","Set nonzero to kill every track that enters.");
00203 }

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.

00292 {
00293         G4String thisname = parentName+getName();
00294 
00295         if(!polycone) {
00296                 polycone = new G4Polycone(thisname+"Polycone", 
00297                                 initialPhi,finalPhi-initialPhi,zs.size(),
00298                                 &zs[0],&irs[0],&ors[0]);
00299         }
00300         G4Material *mat = getMaterial(material);
00301         G4LogicalVolume *lv = new G4LogicalVolume(polycone,mat, thisname+"LogVol");
00302         lv->SetVisAttributes(getVisAttrib(color));
00303         if(maxStep < 0.0) maxStep = Param.getDouble("maxStep");
00304         lv->SetUserLimits(new G4UserLimits(maxStep));
00305 
00306         // geant4 rotation convention is backwards from g4beamline
00307         G4RotationMatrix *g4rot = 0;
00308         if(relativeRotation)
00309                 g4rot = new G4RotationMatrix(relativeRotation->inverse());
00310 
00311         G4VPhysicalVolume *pv = new G4PVPlacement(g4rot, relativePosition,lv,
00312                                         thisname, parent,false,0);
00313 
00314         if(kill)
00315                 BLManager::getObject()->
00316                         registerSteppingAction(pv,new BLKillTrack(thisname));
00317 
00318         // get globalRotation and globalPosition
00319         G4RotationMatrix *globalRotation = 0;
00320         if(relativeRotation && parentRotation) {
00321                 globalRotation = 
00322                     new G4RotationMatrix(*parentRotation * *relativeRotation);
00323         } else if(relativeRotation) {
00324                 globalRotation = relativeRotation;
00325         } else if(parentRotation) {
00326                 globalRotation = parentRotation;
00327         }
00328         G4ThreeVector globalPosition(relativePosition + parentPosition);
00329         if(parentRotation)
00330                 globalPosition = *parentRotation * relativePosition +
00331                                 parentPosition;
00332 
00333         constructChildren(lv,thisname,globalRotation,globalPosition);
00334 
00335         printf("BLCMDpolycone::Construct %s parent=%s relZ=%.1f globZ=%.1f\n"
00336                         "\tzmin=%.1f zmax=%.1f kill=%d\n",
00337                 thisname.c_str(),parentName.c_str(),relativePosition[2],
00338                 globalPosition[2],
00339                 globalPosition[2]-getLength()/2.0,
00340                 globalPosition[2]+getLength()/2.0,
00341                 kill);
00342 }

G4double BLCMDpolycone::getLength (  )  [inline, virtual]

getLength() returns the length of the tube/cylinder.

Implements BLElement.

References length.

Referenced by construct().

00088 { return length; }

G4double BLCMDpolycone::getWidth (  )  [inline, virtual]

getWidth() returns the width of the tube/cylinder.

Implements BLElement.

References maxRadius.

00091 { return 2.0*maxRadius; }

G4double BLCMDpolycone::getHeight (  )  [inline, virtual]

getHeight() returns the height of the tube/cylinder.

Implements BLElement.

References maxRadius.

00094 { return 2.0*maxRadius; }

G4bool BLCMDpolycone::isOK (  )  [inline, virtual]

isOK() returns true.

Implements BLElement.

00097 { return true; }

bool BLCMDpolycone::isOutside ( G4ThreeVector &  local,
G4double  tolerance 
) [inline, virtual]

isOutside() from BLElement.

Implements BLElement.

References polycone.

00101                 { assert(polycone!=0);  return polycone->Inside(local) != kInside; }

void BLCMDpolycone::generatePoints ( int  npoints,
std::vector< G4ThreeVector > &  v 
) [inline, virtual]

generatePoints() from BLElement.

Implements BLElement.

References polycone.

00105                 { v.clear();
00106                   for(int n=0; n<npoints*5; ++n)
00107                         v.push_back(polycone->GetPointOnSurface());
00108                 }

bool BLCMDpolycone::isWithin ( G4ThreeVector &  local,
G4double  tolerance 
) [inline, virtual]

isWithin() from BLGroupElement.

Implements BLGroupElement.

References polycone.

00112             { assert(polycone!=0);  return polycone->Inside(local) != kOutside; }


Member Data Documentation

G4String BLCMDpolycone::innerRadius [private]

G4String BLCMDpolycone::outerRadius [private]

G4String BLCMDpolycone::z [private]

G4double BLCMDpolycone::initialPhi [private]

G4double BLCMDpolycone::finalPhi [private]

G4String BLCMDpolycone::material [private]

G4String BLCMDpolycone::color [private]

G4int BLCMDpolycone::kill [private]

G4double BLCMDpolycone::maxStep [private]

G4Polycone* BLCMDpolycone::polycone [private]

G4double BLCMDpolycone::length [private]

Referenced by BLCMDpolycone(), getLength(), and setup().

G4double BLCMDpolycone::maxRadius [private]

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().


The documentation for this class was generated from the following file:
g4beamline