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