In addition to adding a corner to BLCoordinates, this class can be a BLElement that adds the corner angle to every track that enters it.
Public Member Functions | |
BLCMDcorner () | |
Default constructor. | |
~BLCMDcorner () | |
Destructor. | |
BLCMDcorner (const BLCMDcorner &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() - invalid. | |
G4String | commandName () |
commandName() returns "corner". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the corner 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() will construct the corner. Used for normal placements of a Corner object. | |
G4double | getLength () |
getLength() returns this element's Length along the Z axis. | |
G4double | getWidth () |
getWidth() returns this element's Width along the X axis. | |
G4double | getHeight () |
getHeight() returns this element's height along the Y axis. | |
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. | |
Private Attributes | |
G4double | radius |
G4double | height |
G4double | width |
G4double | length |
G4String | material |
G4String | color |
G4VSolid * | solid |
G4double | maxStep |
G4double | z |
G4String | rotation |
G4RotationMatrix | rotationMatrix |
G4RotationMatrix | centerlineRotation |
G4double | radiusCut |
Friends | |
class | BLCornerTrackRotation |
BLCMDcorner::BLCMDcorner | ( | ) |
Default constructor.
References BLCMDTYPE_LAYOUT, color, height, length, material, maxStep, radius, radiusCut, BLCommand::registerCommand(), rotation, BLCommand::setDescription(), BLCommand::setSynopsis(), solid, width, and z.
Referenced by command().
00130 : BLElement(), rotation() 00131 { 00132 registerCommand(BLCMDTYPE_LAYOUT); 00133 setSynopsis("Implement a corner in the centerline."); 00134 setDescription("The centerline is bent by a rotation.\n" 00135 "Every track that enters the volume also gets rotated.\n" 00136 "The z value is for the corner and the front face of the " 00137 "volume (if any).\n" 00138 "If the corner is paired with a bending magnet or other " 00139 "mechanism to bend the beam, no volume should be used.\n\n" 00140 "NOTE: This command is self-placing, do not use the place\n" 00141 "command; it also affects all following placements, and\n" 00142 "it cannot be issued inside a group.\n" 00143 "If radius=height=width=0 then no volume is associated\n" 00144 "with the corner, and a bending magnet should be placed\n" 00145 "nearby to bend the particles around the corner. Normally " 00146 "the bending magnet is placed before the corner, and is " 00147 "rotated by half the bend angle. For a sector bend, it's " 00148 "usually best to use the cornerarc command rather than this " 00149 "one.\n" 00150 "\nNOTE: all placements before this command must have z\n" 00151 "values before the corner, and all placements after this\n" 00152 "command must have z values after the corner. Note also\n" 00153 "that the angle is limited to 90 degrees.\n\n" 00154 "Note that the radiusCut is important to reduce or eliminate " 00155 "ambiguities in the global to centerline coordinate transform. " 00156 "It can also be used to 'shield' the beamline to prevent " 00157 "particles from taking unusual paths around the outside " 00158 "of beamline elements."); 00159 00160 // initial field values 00161 radius = 0.0; 00162 height = 0.0; 00163 width = 0.0; 00164 length = 1.0*mm; 00165 material = "Vacuum"; 00166 color = ""; 00167 solid = 0; 00168 maxStep = -99.0; 00169 z = 0.0; 00170 rotation = ""; 00171 radiusCut = 0.0; 00172 }
BLCMDcorner::~BLCMDcorner | ( | ) |
BLCMDcorner::BLCMDcorner | ( | const BLCMDcorner & | r | ) |
Copy constructor.
References color, height, length, material, maxStep, radius, radiusCut, rotation, solid, width, and z.
00179 : BLElement(r), rotation(r.rotation) 00180 { 00181 radius = r.radius; 00182 height = r.height; 00183 width = r.width; 00184 length = r.length; 00185 material = r.material; 00186 color = r.color; 00187 solid = 0; 00188 maxStep = r.maxStep; 00189 z = r.z; 00190 rotation = r.rotation; 00191 radiusCut = r.radiusCut; 00192 }
BLElement* BLCMDcorner::clone | ( | ) | [inline, virtual] |
G4String BLCMDcorner::commandName | ( | ) | [inline, virtual] |
int BLCMDcorner::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the corner command.
Implements BLCommand.
References BLCMDcorner(), centerlineRotation, BLCoordinates::corner(), BLGroup::getCurrent(), BLCoordinates::getCurrentRadiusCut(), BLCoordinates::getCurrentRotation(), BLParam::getDouble(), BLCommand::getMaterial(), BLElement::getName(), BLGroup::getWorld(), BLCommand::handleNamedArgs(), height, length, material, maxStep, Param, BLGroup::placeElement(), BLCommand::print(), BLCommand::printError(), radius, radiusCut, rotation, rotationMatrix, BLElement::setName(), BLCommand::stringToRotationMatrix(), and z.
00194 { 00195 if(argv.size() >= 1 && argv[0] == "default") { 00196 return defaultCorner.handleNamedArgs(namedArgs); 00197 } 00198 00199 if(BLGroup::getWorld() != BLGroup::getCurrent()) { 00200 printError("corner: cannot be issued inside a group."); 00201 return -1; 00202 } 00203 00204 BLCMDcorner *t = new BLCMDcorner(defaultCorner); 00205 if(argv.size() >= 1) t->setName(argv[0]); 00206 t->z = -DBL_MAX; 00207 int retval = t->handleNamedArgs(namedArgs); 00208 00209 if(argv.size() != 1 && (t->radius > 0.0 || t->height > 0.0)) { 00210 printError("corner: Invalid command, must have name"); 00211 return -1; 00212 } 00213 00214 if(t->z == -DBL_MAX) { 00215 printError("corner: z must be specified"); 00216 return -1; 00217 } 00218 if(t->maxStep <= 0.0) t->maxStep = Param.getDouble("maxStep"); 00219 if(t->radiusCut <= 0.0) t->radiusCut = 00220 BLCoordinates::getCurrentRadiusCut(); 00221 if(t->radiusCut <= 0.0) 00222 G4Exception("corner command","No radius cut",JustWarning, ""); 00223 00224 // get the rotationMatrix and the current centerline rotation 00225 t->rotationMatrix = *stringToRotationMatrix(t->rotation); 00226 t->centerlineRotation = *BLCoordinates::getCurrentRotation(); 00227 00228 // check for acute angle 00229 G4ThreeVector tmp(0.0,0.0,1.0); 00230 tmp = t->rotationMatrix * tmp; 00231 if(tmp[2] < 0.0) 00232 printError("corner: angle must be <= 90 degrees"); 00233 00234 G4ThreeVector cl_coord(0.0,0.0,t->z+t->length/2.0); 00235 00236 BLGroup::getWorld()->placeElement(t,cl_coord,t->getName()); 00237 BLCoordinates::corner(t->z,&t->rotationMatrix,t->radiusCut); 00238 00239 // check material exists 00240 if(t->material.size() > 0) getMaterial(t->material,false); 00241 00242 t->print(t->getName()); 00243 00244 return retval; 00245 }
void BLCMDcorner::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References BLCommand::argDouble(), BLCommand::argString(), color, height, length, material, maxStep, radius, radiusCut, rotation, width, and z.
00248 { 00249 argDouble(z,"z","The centerline Z of the corner (mm).",mm); 00250 argString(rotation,"rotation","The rotation of the corner (see above)."); 00251 argDouble(radiusCut,"radiusCut","The radius cut for this following segment (mm default=previous).",mm); 00252 argDouble(radius,"radius","The radius of the circular corner volume (mm).",mm); 00253 argDouble(height,"height","The height of the rectangular corner volume (mm).",mm); 00254 argDouble(width,"width","The width of the rectangular corner volume (mm).",mm); 00255 argDouble(length,"length","The length of the corner volume (mm).",mm); 00256 argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm).",mm); 00257 argString(material,"material","The material of the corner volume."); 00258 argString(color,"color","The color of the corner volume (''=invisible)."); 00259 00260 if(radius > 0.0) width = height = radius*2.0; 00261 }
void BLCMDcorner::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [virtual] |
construct() will construct the corner. Used for normal placements of a Corner object.
Implements BLElement.
References BLCornerTrackRotation, centerlineRotation, color, BLParam::getDouble(), BLCommand::getMaterial(), BLElement::getName(), BLManager::getObject(), BLCommand::getVisAttrib(), height, length, material, maxStep, Param, radius, BLManager::registerSteppingAction(), rotationMatrix, solid, and width.
00269 { 00270 G4String thisname = parentName+getName(); 00271 00272 if(!solid) { 00273 if(radius > 0.0) { 00274 solid = new G4Tubs(thisname+"Tubs", 0.0, radius, 00275 length/2.0, 0.0, 2.0*pi); 00276 height = width = 2.0*radius; 00277 } else if(height > 0.0 && width > 0.0) { 00278 solid = new G4Box(thisname+"Box",width/2.0, 00279 height/2.0,length/2.0); 00280 } else { 00281 // corner for a bending magnet 00282 return; 00283 } 00284 } 00285 G4Material *mat = getMaterial(material); 00286 G4LogicalVolume *lv = new G4LogicalVolume(solid,mat,thisname+"LogVol"); 00287 lv->SetVisAttributes(getVisAttrib(color)); 00288 if(maxStep < 0.0) maxStep = Param.getDouble("maxStep"); 00289 lv->SetUserLimits(new G4UserLimits(maxStep)); 00290 00291 // geant4 rotation convention is backwards from g4beamline 00292 G4RotationMatrix *g4rot = 0; 00293 if(relativeRotation) 00294 g4rot = new G4RotationMatrix(relativeRotation->inverse()); 00295 00296 G4VPhysicalVolume *pv = new G4PVPlacement(g4rot,relativePosition,lv, 00297 thisname,parent,false,0); 00298 00299 // BLCornerTrackRotation needs the rotation wrt the global coordinate 00300 // axes, so rotate our "local" rotationMatrix to the global axes 00301 G4RotationMatrix rot = centerlineRotation * 00302 rotationMatrix * 00303 centerlineRotation.inverse(); 00304 00305 BLCornerTrackRotation *cr = new BLCornerTrackRotation(thisname,pv,rot); 00306 BLManager::getObject()->registerSteppingAction(pv,cr); 00307 00308 printf("BLCMDcorner::Construct %s parent=%s relZ=%.1f globZ=%.1f\n", 00309 thisname.c_str(),parentName.c_str(),relativePosition[2], 00310 parentPosition[2]); 00311 }
G4double BLCMDcorner::getLength | ( | ) | [inline, virtual] |
getLength() returns this element's Length along the Z axis.
Implements BLElement.
References length.
00092 { return length; }
G4double BLCMDcorner::getWidth | ( | ) | [inline, virtual] |
getWidth() returns this element's Width along the X axis.
Implements BLElement.
References width.
00095 { return width; }
G4double BLCMDcorner::getHeight | ( | ) | [inline, virtual] |
getHeight() returns this element's height along the Y axis.
Implements BLElement.
References height.
00098 { return height; }
G4bool BLCMDcorner::isOK | ( | ) | [inline, virtual] |
bool BLCMDcorner::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [inline, virtual] |
void BLCMDcorner::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [inline, virtual] |
friend class BLCornerTrackRotation [friend] |
Referenced by construct().
G4double BLCMDcorner::radius [private] |
Referenced by BLCMDcorner(), command(), construct(), and defineNamedArgs().
G4double BLCMDcorner::height [private] |
Referenced by BLCMDcorner(), command(), construct(), defineNamedArgs(), and getHeight().
G4double BLCMDcorner::width [private] |
Referenced by BLCMDcorner(), construct(), defineNamedArgs(), and getWidth().
G4double BLCMDcorner::length [private] |
Referenced by BLCMDcorner(), command(), construct(), defineNamedArgs(), and getLength().
G4String BLCMDcorner::material [private] |
Referenced by BLCMDcorner(), command(), construct(), and defineNamedArgs().
G4String BLCMDcorner::color [private] |
Referenced by BLCMDcorner(), construct(), and defineNamedArgs().
G4VSolid* BLCMDcorner::solid [private] |
Referenced by BLCMDcorner(), construct(), and ~BLCMDcorner().
G4double BLCMDcorner::maxStep [private] |
Referenced by BLCMDcorner(), command(), construct(), and defineNamedArgs().
G4double BLCMDcorner::z [private] |
Referenced by BLCMDcorner(), command(), and defineNamedArgs().
G4String BLCMDcorner::rotation [private] |
Referenced by BLCMDcorner(), command(), and defineNamedArgs().
G4RotationMatrix BLCMDcorner::rotationMatrix [private] |
Referenced by command(), and construct().
G4RotationMatrix BLCMDcorner::centerlineRotation [private] |
Referenced by command(), and construct().
G4double BLCMDcorner::radiusCut [private] |
Referenced by BLCMDcorner(), command(), and defineNamedArgs().