BLCMDsphere Class Reference

Inheritance diagram for BLCMDsphere:

BLGroupElement BLElement BLCommand

List of all members.


Detailed Description

BLCMDsphere implements a sphere of material.

Public Member Functions

 BLCMDsphere ()
 Default constructor. Defines the command, args, etc.
virtual ~BLCMDsphere ()
 Destructor.
 BLCMDsphere (const BLCMDsphere &r)
 Copy constructor.
BLElementclone ()
 clone()
G4String commandName ()
 commandName() returns "sphere".
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
 command() implements the sphere 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 sphere
G4double getLength ()
 getLength() returns the length of the sphere
G4double getWidth ()
 getWidth() returns the width of the sphere
G4double getHeight ()
 getHeight() returns the height of the sphere
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 innerRadius
G4double outerRadius
G4double initialPhi
G4double finalPhi
G4double initialTheta
G4double finalTheta
G4String material
G4String color
G4int kill
G4double maxStep
G4Sphere * sphere

Constructor & Destructor Documentation

BLCMDsphere::BLCMDsphere (  ) 

Default constructor. Defines the command, args, etc.

References BLCMDTYPE_ELEMENT, color, finalPhi, finalTheta, initialPhi, initialTheta, innerRadius, kill, material, maxStep, outerRadius, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), and sphere.

Referenced by clone(), and command().

00110                          : BLGroupElement()
00111 {
00112         // register the commandName(), and its synopsis and description.
00113         registerCommand(BLCMDTYPE_ELEMENT);
00114         setSynopsis("construct a sphere (or section of one)");
00115         setDescription("This is a direct interface to G4Sphere.");
00116 
00117         // provide initial values for fields
00118         innerRadius = 0.0;
00119         outerRadius = 0.0;
00120         initialPhi = 0.0;
00121         finalPhi = 360.0*deg;
00122         initialTheta = 0.0;
00123         finalTheta = 360.0*deg;
00124         material = "Vacuum";
00125         color = "1,1,1";
00126         kill = 0;
00127         maxStep = -1.0;
00128         sphere = 0;
00129 }

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

Destructor.

00054 { }

BLCMDsphere::BLCMDsphere ( const BLCMDsphere r  ) 

Copy constructor.

References color, finalPhi, finalTheta, initialPhi, initialTheta, innerRadius, kill, material, maxStep, outerRadius, and sphere.

00132                                              : BLGroupElement(r)
00133 {
00134         // copy fields one at a time (transfers default values from the
00135         // default object to this new object).
00136         innerRadius = r.innerRadius;
00137         outerRadius = r.outerRadius;
00138         initialPhi = r.initialPhi;
00139         finalPhi = r.finalPhi;
00140         initialTheta = r.initialTheta;
00141         finalTheta = r.finalTheta;
00142         material = r.material;
00143         color = r.color;
00144         kill = r.kill;
00145         maxStep = r.maxStep;
00146         sphere = r.sphere;
00147 }


Member Function Documentation

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

clone()

Implements BLElement.

References BLCMDsphere().

00060 { return new BLCMDsphere(*this); }

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

commandName() returns "sphere".

Implements BLCommand.

00063 { return "sphere"; }

int BLCMDsphere::command ( BLArgumentVector argv,
BLArgumentMap namedArgs 
) [virtual]

command() implements the sphere command.

Implements BLCommand.

References BLCMDsphere(), BLParam::getDouble(), BLCommand::getMaterial(), BLCommand::handleNamedArgs(), material, maxStep, Param, BLCommand::print(), BLCommand::printError(), and BLGroupElement::setName().

00150 {
00151         if(argv.size() != 1) {
00152                 printError("sphere: Invalid command, must have name");
00153                 return -1;
00154         }
00155 
00156         if(argv[0] == "default") {
00157                 return defaultSphere.handleNamedArgs(namedArgs);
00158         }
00159 
00160         BLCMDsphere *t = new BLCMDsphere(defaultSphere);
00161         t->setName(argv[0]);
00162         int retval = t->handleNamedArgs(namedArgs);
00163 
00164         if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep");
00165 
00166         // check material exists
00167         if(t->material.size() > 0) getMaterial(t->material,false);
00168 
00169         t->print(argv[0]);
00170 
00171         return retval;
00172 }

void BLCMDsphere::defineNamedArgs (  )  [virtual]

defineNamedArgs() defines the named arguments for the command.

Reimplemented from BLCommand.

References BLCommand::argDouble(), BLCommand::argInt(), BLCommand::argString(), color, finalPhi, finalTheta, initialPhi, initialTheta, innerRadius, kill, material, maxStep, and outerRadius.

00175 {
00176         argDouble(innerRadius,"innerRadius","The inside radius of the sphere (mm)");
00177         argDouble(outerRadius,"outerRadius","The outer radius of the sphere (mm)");
00178         argDouble(initialPhi,"initialPhi","The initial Phi value (deg; 0 for all)",deg);
00179         argDouble(finalPhi,"finalPhi","The final Phi value (deg; 360 for all)",deg);
00180         argDouble(initialTheta,"initialTheta","The initialTheta of the sphere (deg, 0 for all)",deg);
00181         argDouble(finalTheta,"finalTheta","The finalTheta of the sphere (deg, 180 for all)",deg);
00182         argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)");
00183         argString(material,"material","The material of the sphere");
00184         argString(color,"color","The color of the sphere (''=invisible)");
00185         argInt(kill,"kill","Set nonzero to kill every track that enters.");
00186 }

void BLCMDsphere::construct ( G4RotationMatrix *  relativeRotation,
G4ThreeVector  relativePosition,
G4LogicalVolume *  parent,
G4String  parentName,
G4RotationMatrix *  parentRotation,
G4ThreeVector  parentPosition 
) [virtual]

construct() - construct the sphere

Implements BLElement.

References color, BLGroupElement::constructChildren(), finalPhi, finalTheta, BLParam::getDouble(), getLength(), BLCommand::getMaterial(), BLElement::getName(), BLManager::getObject(), BLCommand::getVisAttrib(), initialPhi, initialTheta, innerRadius, kill, material, maxStep, outerRadius, Param, and sphere.

00194 {
00195         G4String thisname = parentName+getName();
00196 
00197         if(!sphere)
00198                 sphere = new G4Sphere(thisname+"Sphere", innerRadius, outerRadius,
00199                                 initialPhi,(finalPhi-initialPhi),
00200                                 initialTheta,(finalTheta-initialTheta));
00201         G4Material *mat = getMaterial(material);
00202         G4LogicalVolume *lv = new G4LogicalVolume(sphere,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("BLCMDsphere::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 BLCMDsphere::getLength (  )  [inline, virtual]

getLength() returns the length of the sphere

Implements BLElement.

References outerRadius.

Referenced by construct().

00080 { return 2.0*outerRadius; }

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

getWidth() returns the width of the sphere

Implements BLElement.

References outerRadius.

00083 { return 2.0*outerRadius; }

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

getHeight() returns the height of the sphere

Implements BLElement.

References outerRadius.

00086 { return 2.0*outerRadius; }

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

isOK() returns true.

Implements BLElement.

00089 { return true; }

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

isOutside() from BLElement.

Implements BLElement.

References BLAssert, and sphere.

00093                 { BLAssert(sphere!=0);  return sphere->Inside(local) != kInside; }

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

generatePoints() from BLElement.

Implements BLElement.

References sphere.

00097                 { v.clear();
00098                   for(int n=0; n<npoints*5; ++n)
00099                         v.push_back(sphere->GetPointOnSurface());
00100                 }

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

isWithin() from BLGroupElement.

Implements BLGroupElement.

References BLAssert, and sphere.

00104             { BLAssert(sphere!=0);  return sphere->Inside(local) != kOutside; }


Member Data Documentation

G4double BLCMDsphere::innerRadius [private]

G4double BLCMDsphere::outerRadius [private]

G4double BLCMDsphere::initialPhi [private]

G4double BLCMDsphere::finalPhi [private]

G4double BLCMDsphere::initialTheta [private]

G4double BLCMDsphere::finalTheta [private]

G4String BLCMDsphere::material [private]

G4String BLCMDsphere::color [private]

G4int BLCMDsphere::kill [private]

G4double BLCMDsphere::maxStep [private]

G4Sphere* BLCMDsphere::sphere [private]


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