Public Member Functions | |
BLCMDtrap () | |
Default constructor. Defines the command, args, etc. | |
virtual | ~BLCMDtrap () |
Destructor. | |
BLCMDtrap (const BLCMDtrap &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() | |
G4String | commandName () |
commandName() returns "trap". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the trap 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 trapezoid | |
G4double | getLength () |
getLength() returns the length of the trapezoid | |
G4double | getWidth () |
getWidth() returns the width of the trapezoid | |
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 | height |
G4double | upperWidth |
G4double | lowerWidth |
G4double | Xul |
G4double | Xur |
G4double | Xll |
G4double | Xlr |
G4double | length |
G4String | material |
G4String | color |
G4int | kill |
G4double | maxStep |
G4Trap * | trap |
BLCMDtrap::BLCMDtrap | ( | ) |
Default constructor. Defines the command, args, etc.
References BLCMDTYPE_ELEMENT, color, height, kill, length, lowerWidth, material, maxStep, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), trap, UNINITIALIZED, upperWidth, Xll, Xlr, Xul, and Xur.
Referenced by clone(), and command().
00112 : BLGroupElement() 00113 { 00114 // register the commandName(), and its synopsis and description. 00115 registerCommand(BLCMDTYPE_ELEMENT); 00116 setSynopsis("construct a solid trapezoid with axis along z."); 00117 setDescription("This is a direct interface to G4Trap.\n" 00118 "The trapezoid is symmetrical left-right, but upper or\n" 00119 "lower width can be larger or smaller."); 00120 00121 // provide initial values for fields 00122 height = 0.0; 00123 upperWidth = UNINITIALIZED; 00124 lowerWidth = UNINITIALIZED; 00125 Xul = Xur = Xll = Xlr = 0.0; 00126 length = 0.0; 00127 material = "Vacuum"; 00128 color = "1,1,1"; 00129 kill = 0; 00130 maxStep = -1.0; 00131 trap = 0; 00132 }
BLCMDtrap::BLCMDtrap | ( | const BLCMDtrap & | r | ) |
Copy constructor.
References color, height, kill, length, lowerWidth, material, maxStep, trap, upperWidth, Xll, Xlr, Xul, and Xur.
00135 : BLGroupElement(r) 00136 { 00137 // copy fields one at a time (transfers default values from the 00138 // default object to this new object). 00139 height = r.height; 00140 upperWidth = r.upperWidth; 00141 lowerWidth = r.lowerWidth; 00142 Xul = r.Xul; 00143 Xur = r.Xur; 00144 Xll = r.Xll; 00145 Xlr = r.Xlr; 00146 length = r.length; 00147 material = r.material; 00148 color = r.color; 00149 kill = r.kill; 00150 maxStep = r.maxStep; 00151 trap = r.trap; 00152 }
BLElement* BLCMDtrap::clone | ( | ) | [inline, virtual] |
G4String BLCMDtrap::commandName | ( | ) | [inline, virtual] |
int BLCMDtrap::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the trap command.
Implements BLCommand.
References BLCMDtrap(), BLParam::getDouble(), BLCommand::getMaterial(), BLCommand::handleNamedArgs(), material, maxStep, Param, BLCommand::print(), BLCommand::printError(), and BLGroupElement::setName().
00155 { 00156 if(argv.size() != 1) { 00157 printError("trap: Invalid command, must have name"); 00158 return -1; 00159 } 00160 00161 if(argv[0] == "default") { 00162 return defaultTrap.handleNamedArgs(namedArgs); 00163 } 00164 00165 BLCMDtrap *t = new BLCMDtrap(defaultTrap); 00166 t->setName(argv[0]); 00167 int retval = t->handleNamedArgs(namedArgs); 00168 00169 if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep"); 00170 00171 // check material exists 00172 if(t->material.size() > 0) getMaterial(t->material,false); 00173 00174 t->print(argv[0]); 00175 00176 return retval; 00177 }
void BLCMDtrap::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References BLCommand::argDouble(), BLCommand::argInt(), BLCommand::argString(), color, height, kill, length, lowerWidth, material, maxStep, upperWidth, Xll, Xlr, Xul, and Xur.
00180 { 00181 argDouble(height,"height","The height of the solid trapezoid (mm)"); 00182 argDouble(upperWidth,"upperWidth","The upper width solid trapezoid (mm)"); 00183 argDouble(lowerWidth,"lowerWidth","The lowerWidth of the solid trapezoid (mm)"); 00184 argDouble(Xul,"Xul","X position of upper left corner (mm)"); 00185 argDouble(Xur,"Xur","X position of upper right corner (mm)"); 00186 argDouble(Xll,"Xll","X position of lower left corner (mm)"); 00187 argDouble(Xlr,"Xlr","X position of lower right corner (mm)"); 00188 argDouble(length,"length","The length of the solid trapezoid (mm)"); 00189 argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)"); 00190 argString(material,"material","The material of the trapezoid"); 00191 argString(color,"color","The color of the trapezoid (''=invisible)"); 00192 argInt(kill,"kill","Set nonzero to kill every track that enters."); 00193 }
void BLCMDtrap::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [virtual] |
construct() - construct the trapezoid
Implements BLElement.
References color, BLGroupElement::constructChildren(), BLParam::getDouble(), getLength(), BLCommand::getMaterial(), BLElement::getName(), BLManager::getObject(), BLCommand::getVisAttrib(), height, kill, length, lowerWidth, material, maxStep, Param, trap, UNINITIALIZED, upperWidth, Xll, Xlr, Xul, and Xur.
00201 { 00202 G4String thisname = parentName+getName(); 00203 00204 if(lowerWidth != UNINITIALIZED) { 00205 Xll = -lowerWidth/2.0; 00206 Xlr = lowerWidth/2.0; 00207 } 00208 if(upperWidth != UNINITIALIZED) { 00209 Xul = -upperWidth/2.0; 00210 Xur = upperWidth/2.0; 00211 } 00212 00213 if(!trap) { 00214 G4ThreeVector p[8]; 00215 p[0][2] = p[1][2] = p[2][2] = p[3][2] = -length/2.0; 00216 p[4][2] = p[5][2] = p[6][2] = p[7][2] = length/2.0; 00217 p[0][1] = p[1][1] = p[4][1] = p[5][1] = -height/2.0; 00218 p[2][1] = p[3][1] = p[6][1] = p[7][1] = height/2.0; 00219 p[0][0] = p[4][0] = Xll; 00220 p[1][0] = p[5][0] = Xlr; 00221 p[2][0] = p[6][0] = Xul; 00222 p[3][0] = p[7][0] = Xur; 00223 trap = new G4Trap(thisname+"Trap", p); 00224 } 00225 G4Material *mat = getMaterial(material); 00226 G4LogicalVolume *lv = new G4LogicalVolume(trap,mat, thisname+"LogVol"); 00227 lv->SetVisAttributes(getVisAttrib(color)); 00228 if(maxStep < 0.0) maxStep = Param.getDouble("maxStep"); 00229 lv->SetUserLimits(new G4UserLimits(maxStep)); 00230 00231 // geant4 rotation convention is backwards from g4beamline 00232 G4RotationMatrix *g4rot = 0; 00233 if(relativeRotation) 00234 g4rot = new G4RotationMatrix(relativeRotation->inverse()); 00235 00236 G4VPhysicalVolume *pv = new G4PVPlacement(g4rot, relativePosition,lv, 00237 thisname, parent,false,0); 00238 00239 if(kill) 00240 BLManager::getObject()-> 00241 registerSteppingAction(pv,new BLKillTrack(thisname)); 00242 00243 // get globalRotation and globalPosition 00244 G4RotationMatrix *globalRotation = 0; 00245 if(relativeRotation && parentRotation) { 00246 globalRotation = 00247 new G4RotationMatrix(*parentRotation * *relativeRotation); 00248 } else if(relativeRotation) { 00249 globalRotation = relativeRotation; 00250 } else if(parentRotation) { 00251 globalRotation = parentRotation; 00252 } 00253 G4ThreeVector globalPosition(relativePosition + parentPosition); 00254 if(parentRotation) 00255 globalPosition = *parentRotation * relativePosition + 00256 parentPosition; 00257 00258 constructChildren(lv,thisname,globalRotation,globalPosition); 00259 00260 printf("BLCMDtrap::Construct %s parent=%s relZ=%.1f globZ=%.1f\n" 00261 "\tzmin=%.1f zmax=%.1f kill=%d\n", 00262 thisname.c_str(),parentName.c_str(),relativePosition[2], 00263 globalPosition[2], 00264 globalPosition[2]-getLength()/2.0, 00265 globalPosition[2]+getLength()/2.0, 00266 kill); 00267 00268 }
G4double BLCMDtrap::getLength | ( | ) | [inline, virtual] |
getLength() returns the length of the trapezoid
Implements BLElement.
References length.
Referenced by construct().
00080 { return length; }
G4double BLCMDtrap::getWidth | ( | ) | [inline, virtual] |
getWidth() returns the width of the trapezoid
Implements BLElement.
References lowerWidth, and upperWidth.
00083 { 00084 return (upperWidth>lowerWidth ? upperWidth : lowerWidth); 00085 }
G4double BLCMDtrap::getHeight | ( | ) | [inline, virtual] |
getHeight() returns the height of the tube/cylinder.
Implements BLElement.
References height.
00088 { return height; }
G4bool BLCMDtrap::isOK | ( | ) | [inline, virtual] |
bool BLCMDtrap::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [inline, virtual] |
void BLCMDtrap::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [inline, virtual] |
generatePoints() from BLElement.
Implements BLElement.
References trap.
00099 { v.clear(); 00100 for(int n=0; n<npoints*5; ++n) 00101 v.push_back(trap->GetPointOnSurface()); 00102 }
bool BLCMDtrap::isWithin | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [inline, virtual] |
G4double BLCMDtrap::height [private] |
Referenced by BLCMDtrap(), construct(), defineNamedArgs(), and getHeight().
G4double BLCMDtrap::upperWidth [private] |
Referenced by BLCMDtrap(), construct(), defineNamedArgs(), and getWidth().
G4double BLCMDtrap::lowerWidth [private] |
Referenced by BLCMDtrap(), construct(), defineNamedArgs(), and getWidth().
G4double BLCMDtrap::Xul [private] |
Referenced by BLCMDtrap(), construct(), and defineNamedArgs().
G4double BLCMDtrap::Xur [private] |
Referenced by BLCMDtrap(), construct(), and defineNamedArgs().
G4double BLCMDtrap::Xll [private] |
Referenced by BLCMDtrap(), construct(), and defineNamedArgs().
G4double BLCMDtrap::Xlr [private] |
Referenced by BLCMDtrap(), construct(), and defineNamedArgs().
G4double BLCMDtrap::length [private] |
Referenced by BLCMDtrap(), construct(), defineNamedArgs(), and getLength().
G4String BLCMDtrap::material [private] |
Referenced by BLCMDtrap(), command(), construct(), and defineNamedArgs().
G4String BLCMDtrap::color [private] |
Referenced by BLCMDtrap(), construct(), and defineNamedArgs().
G4int BLCMDtrap::kill [private] |
Referenced by BLCMDtrap(), construct(), and defineNamedArgs().
G4double BLCMDtrap::maxStep [private] |
Referenced by BLCMDtrap(), command(), construct(), and defineNamedArgs().
G4Trap* BLCMDtrap::trap [private] |
Referenced by BLCMDtrap(), construct(), generatePoints(), isOutside(), and isWithin().