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

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

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

Destructor.

00055 { }

BLCMDtorus::BLCMDtorus ( const BLCMDtorus r  ) 

Copy constructor.

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

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


Member Function Documentation

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

clone()

Implements BLElement.

References BLCMDtorus().

00061 { return new BLCMDtorus(*this); }

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

commandName() returns "torus".

Implements BLCommand.

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

00169 {
00170         if(argv.size() != 1) {
00171                 printError("torus: Invalid command, must have name");
00172                 return -1;
00173         }
00174 
00175         if(argv[0] == "default") {
00176                 return defaultTorus.handleNamedArgs(namedArgs);
00177         }
00178 
00179         BLCMDtorus *t = new BLCMDtorus(defaultTorus);
00180         t->setName(argv[0]);
00181         int retval = t->handleNamedArgs(namedArgs);
00182 
00183         if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep");
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 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.

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

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.

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

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

00082 { 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.

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

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

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

Implements BLElement.

References majorRadius, and outerRadius.

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

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

isOK() returns true.

Implements BLElement.

00092 { return true; }

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

isOutside() from BLElement.

Implements BLElement.

References torus.

00096                 { assert(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.

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

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

isWithin() from BLGroupElement.

Implements BLGroupElement.

References torus.

00107                 { assert(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