BLCMDbox Class Reference

Inheritance diagram for BLCMDbox:

BLGroupElement BLElement BLCommand

List of all members.


Detailed Description

BLCMDbox implements a box of material.

Public Member Functions

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

Constructor & Destructor Documentation

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 }

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

Destructor.

00050 { }

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 }


Member Function Documentation

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

clone()

Implements BLElement.

References BLCMDbox().

00056 { return new BLCMDbox(*this); }

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

commandName() returns "box".

Implements BLCommand.

00059 { return "box"; }

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]

isOK() returns true.

Implements BLElement.

00085 { return true; }

G4bool BLCMDbox::isOutside ( G4ThreeVector &  local,
G4double  tolerance 
) [virtual]

isOutside() from BLElement.

Implements BLElement.

References height, length, and width.

00227 {
00228         return fabs(local[0]) > width/2.0-tolerance ||
00229                 fabs(local[1]) > height/2.0-tolerance ||
00230                 fabs(local[2]) > length/2.0-tolerance;
00231 }

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 }


Member Data Documentation

G4double BLCMDbox::height [private]

G4double BLCMDbox::width [private]

G4double BLCMDbox::length [private]

G4String BLCMDbox::material [private]

G4String BLCMDbox::color [private]

G4int BLCMDbox::kill [private]

G4double BLCMDbox::maxStep [private]

G4Box* BLCMDbox::box [private]

Referenced by BLCMDbox(), and construct().


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