BLCMDtorus Class Reference

Inheritance diagram for BLCMDtorus:

BLGroupElement BLElement BLCommand

List of all members.


Detailed Description

BLCMDtorus implements a torus of material.

Public Member Functions

 BLCMDtorus ()
 Default constructor. Defines the command, args, etc.
virtual ~BLCMDtorus ()
 Destructor.
 BLCMDtorus (const BLCMDtorus &r)
 Copy constructor.
BLElementclone ()
 clone()
G4String commandName ()
 commandName() returns "torus".
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
 command() implements the torus 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 torus.
G4double getLength ()
 getLength() returns the length of the torus, assuming full 2pi around the major radius.
G4double getWidth ()
 getWidth() returns the width of the torus, assuming full 2pi around the major radius.
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

G4double innerRadius
G4double outerRadius
G4double majorRadius
G4double initialPhi
G4double finalPhi
G4String material
G4String color
G4int kill
G4double maxStep
G4Torus * torus

Friends

class Surface

Constructor & Destructor Documentation

BLCMDtorus::BLCMDtorus (  ) 

Default constructor. Defines the command, args, etc.

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

Referenced by clone(), and command().

00130                        : BLGroupElement()
00131 {
00132         // register the commandName(), and its synopsis and description.
00133         registerCommand(BLCMDTYPE_ELEMENT);
00134         setSynopsis("construct a torus.");
00135         setDescription("This is a direct interface to G4Torus. "
00136                 "The major radius is in the X-Y plane, with phi=0 "
00137                 "along X.");
00138 
00139         // provide initial values for fields
00140         innerRadius = 0.0;
00141         outerRadius = 0.0;
00142         majorRadius = 0.0;
00143         initialPhi = 0.0;
00144         finalPhi = 360*deg;
00145         material = "Vacuum";
00146         color = "1,1,1";
00147         kill = 0;
00148         maxStep = -1.0;
00149         torus = 0;
00150 }

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

Destructor.

00056 { }

BLCMDtorus::BLCMDtorus ( const BLCMDtorus r  ) 

Copy constructor.

References color, finalPhi, initialPhi, innerRadius, kill, majorRadius, material, maxStep, outerRadius, and torus.

00153                                           : BLGroupElement(r)
00154 {
00155         // copy fields one at a time (transfers default values from the
00156         // default object to this new object).
00157         innerRadius = r.innerRadius;
00158         outerRadius = r.outerRadius;
00159         majorRadius = r.majorRadius;
00160         initialPhi = r.initialPhi;
00161         finalPhi = r.finalPhi;
00162         material = r.material;
00163         color = r.color;
00164         kill = r.kill;
00165         maxStep = r.maxStep;
00166         torus = r.torus;
00167 }


Member Function Documentation

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

clone()

Implements BLElement.

References BLCMDtorus().

00062 { return new BLCMDtorus(*this); }

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

commandName() returns "torus".

Implements BLCommand.

00065 { return "torus"; }

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

command() implements the torus command.

Implements BLCommand.

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

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

void BLCMDtorus::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, majorRadius, material, maxStep, and outerRadius.

00195 {
00196         argDouble(innerRadius,"innerRadius","The inner radius of the torus (mm)");
00197         argDouble(outerRadius,"outerRadius","The outer radius of the torus (mm)");
00198         argDouble(majorRadius,"majorRadius","The major radius of the torus (mm)");
00199         argDouble(initialPhi,"initialPhi","The initial phi around major radius (0 degrees).",deg);
00200         argDouble(finalPhi,"finalPhi","The final phi around major radius (360 degrees).",deg);
00201         argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)");
00202         argString(material,"material","The material of the torus");
00203         argString(color,"color","The color of the torus (''=invisible)");
00204         argInt(kill,"kill","Set nonzero to kill every track that enters.");
00205 }

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

construct() - construct the torus.

@ new Surface(this,globalRotation,globalPosition);

Implements BLElement.

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

00213 {
00214         G4String thisname = parentName+getName();
00215 
00216         if(!torus)
00217                 torus = new G4Torus(thisname+"Torus",innerRadius,outerRadius,
00218                         majorRadius,initialPhi,finalPhi-initialPhi);
00219         G4Material *mat = getMaterial(material);
00220         G4LogicalVolume *lv = new G4LogicalVolume(torus,mat, thisname+"LogVol");
00221         lv->SetVisAttributes(getVisAttrib(color));
00222         if(maxStep < 0.0) maxStep = Param.getDouble("maxStep");
00223         lv->SetUserLimits(new G4UserLimits(maxStep));
00224 
00225         // geant4 rotation convention is backwards from g4beamline
00226         G4RotationMatrix *g4rot = 0;
00227         if(relativeRotation)
00228                 g4rot = new G4RotationMatrix(relativeRotation->inverse());
00229 
00230         G4VPhysicalVolume *pv = new G4PVPlacement(g4rot,
00231                                         relativePosition,lv,thisname,
00232                                         parent,false,0);
00233 
00234         // handle kill parameter
00235         if(kill)
00236                 BLManager::getObject()->
00237                         registerSteppingAction(pv,new BLKillTrack(thisname));
00238 
00239         // get globalRotation and globalPosition
00240         G4RotationMatrix *globalRotation = 0;
00241         if(relativeRotation && parentRotation) {
00242                 globalRotation = 
00243                     new G4RotationMatrix(*parentRotation * *relativeRotation);
00244         } else if(relativeRotation) {
00245                 globalRotation = relativeRotation;
00246         } else if(parentRotation) {
00247                 globalRotation = parentRotation;
00248         }
00249         G4ThreeVector globalPosition(relativePosition + parentPosition);
00250         if(parentRotation)
00251                 globalPosition = *parentRotation * relativePosition +
00252                                 parentPosition;
00253 
00254         constructChildren(lv,thisname,globalRotation,globalPosition);
00255 
00256 ///@@   new Surface(this,globalRotation,globalPosition);
00257 
00258         printf("BLCMDtorus::Construct %s parent=%s relZ=%.1f globZ=%.1f\n"
00259                         "\tzmin=%.1f zmax=%.1f\n",
00260                 thisname.c_str(),parentName.c_str(),relativePosition[2],
00261                 globalPosition[2],
00262                 globalPosition[2]-getLength()/2.0,
00263                 globalPosition[2]+getLength()/2.0);
00264 }

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

getLength() returns the length of the torus, assuming full 2pi around the major radius.

Implements BLElement.

References outerRadius.

Referenced by construct().

00083 { return outerRadius*2; }

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

getWidth() returns the width of the torus, assuming full 2pi around the major radius.

Implements BLElement.

References majorRadius, and outerRadius.

00087 { return (majorRadius+outerRadius)*2; }

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

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

Implements BLElement.

References majorRadius, and outerRadius.

00090 { return (majorRadius+outerRadius)*2; }

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

isOK() returns true.

Implements BLElement.

00093 { return true; }

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

isOutside() from BLElement.

Implements BLElement.

References BLAssert, and torus.

00097                 { BLAssert(torus!=0);  return torus->Inside(local) != kInside; }

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

generatePoints() from BLElement.

Implements BLElement.

References torus.

00101                 { v.clear();
00102                   for(int n=0; n<npoints*5; ++n)
00103                         v.push_back(torus->GetPointOnSurface());
00104                 }

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

isWithin() from BLGroupElement.

Implements BLGroupElement.

References BLAssert, and torus.

00108                 { BLAssert(torus!=0);  return torus->Inside(local) != kOutside; }


Friends And Related Function Documentation

friend class Surface [friend]


Member Data Documentation

G4double BLCMDtorus::innerRadius [private]

G4double BLCMDtorus::outerRadius [private]

G4double BLCMDtorus::majorRadius [private]

G4double BLCMDtorus::initialPhi [private]

G4double BLCMDtorus::finalPhi [private]

G4String BLCMDtorus::material [private]

G4String BLCMDtorus::color [private]

G4int BLCMDtorus::kill [private]

G4double BLCMDtorus::maxStep [private]

G4Torus* BLCMDtorus::torus [private]


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