This is optimized for a Liquid Hydrogen absorber, including optional safety windows.
Geometry test: For intersections with siblings and parent, behaves as if it were the enclosing cylinder of the outer windows. For placing children inside, behaves as the largest cylinder inside the LH2 (i.e. it does not extend into the windows).
Public Member Functions | |
BLCMDabsorber () | |
Default constructor. Defines the command, args, etc. | |
virtual | ~BLCMDabsorber () |
Destructor. | |
BLCMDabsorber (const BLCMDabsorber &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() | |
G4String | commandName () |
commandName() returns "absorber". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the absorber 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 tube/cylinder. | |
G4double | getLength () |
getLength() returns the totalLength of the absorber. | |
G4double | getWidth () |
getWidth() returns the outer radius of the tube/cylinder. | |
G4double | getHeight () |
getHeight() returns the outer radius of the tube/cylinder. | |
G4bool | isOK () |
isOK() returns true. | |
void | constructSolids () |
constructSolids() constructs all necessary G4VSolid-s | |
void | generatePoints (int npoints, std::vector< G4ThreeVector > &v) |
generatePoints() from BLElement | |
G4bool | isOutside (G4ThreeVector &local, G4double tolerance) |
isOutside() from BLElement | |
bool | isWithin (G4ThreeVector &local, G4double tolerance) |
isWithin() from BLGroupElement | |
Private Attributes | |
G4String | absWindow |
G4String | safetyWindow |
G4double | insideLength |
G4String | absMaterial |
G4String | windowMaterial |
G4String | safetyMaterial |
G4double | safetyDistance |
G4String | color |
G4double | maxStep |
G4double | totalLength |
G4double | outerRadius |
G4double | absTubsLength |
G4double | absTubsRadius |
BLWindowShape * | absWindowShape |
BLWindowShape * | safetyWindowShape |
G4VSolid * | safetyWinSolid |
G4VSolid * | safetyVolSolid |
G4VSolid * | safetyPipeSolid |
G4VSolid * | absWinSolid |
G4VSolid * | absVolSolid |
G4VSolid * | absPipeSolid |
BLCMDabsorber::BLCMDabsorber | ( | ) |
Default constructor. Defines the command, args, etc.
References absMaterial, absPipeSolid, absTubsLength, absTubsRadius, absVolSolid, absWindow, absWindowShape, absWinSolid, BLCMDTYPE_ELEMENT, color, insideLength, maxStep, outerRadius, BLCommand::registerCommand(), safetyDistance, safetyMaterial, safetyPipeSolid, safetyVolSolid, safetyWindow, safetyWindowShape, safetyWinSolid, BLCommand::setDescription(), BLCommand::setSynopsis(), totalLength, and windowMaterial.
Referenced by clone(), and command().
00124 : BLGroupElement() 00125 { 00126 // register the commandName(), and its synopsis and description. 00127 registerCommand(BLCMDTYPE_ELEMENT); 00128 setSynopsis("construct an absorber"); 00129 setDescription("The absorber has two windows with beampipe and an\n" 00130 "absorber material. Optionally it has an additional two safety windows with\n" 00131 "beampipe. The WindowShape(s) are read from a file, and they\n" 00132 "determine the thickness and length of the beampipe(s).\n" 00133 "For geometry testing, acts like a cylinder enclosing the\n" 00134 "windows. For placing children, acts like a cylinder inside\n" 00135 "the central absorber.\n\n" 00136 "Note that section 4.5 of the User's Guide has a dimensioned " 00137 "drawing of an absorber."); 00138 00139 // provide initial values for fields 00140 absWindow = ""; 00141 safetyWindow = ""; 00142 insideLength = 0.0; 00143 absMaterial = "LH2"; 00144 windowMaterial = "Al"; 00145 safetyMaterial = "Vacuum"; 00146 safetyDistance = 12.0*cm; 00147 color = "1,1,1"; 00148 maxStep = -1.0; 00149 totalLength = 0.0; 00150 outerRadius = 0.0; 00151 absTubsLength = 0.0; 00152 absTubsRadius = 0.0; 00153 absWindowShape = 0; 00154 safetyWindowShape = 0; 00155 safetyWinSolid = 0; 00156 safetyVolSolid = 0; 00157 safetyPipeSolid = 0; 00158 absWinSolid = 0; 00159 absVolSolid = 0; 00160 absPipeSolid = 0; 00161 }
BLCMDabsorber::BLCMDabsorber | ( | const BLCMDabsorber & | r | ) |
Copy constructor.
References absMaterial, absPipeSolid, absTubsLength, absTubsRadius, absVolSolid, absWindow, absWindowShape, absWinSolid, color, insideLength, maxStep, outerRadius, safetyDistance, safetyMaterial, safetyPipeSolid, safetyVolSolid, safetyWindow, safetyWindowShape, safetyWinSolid, totalLength, and windowMaterial.
00164 : BLGroupElement(r) 00165 { 00166 // copy fields one at a time (transfers default values from the 00167 // default object to this new object). 00168 absWindow = r.absWindow; 00169 safetyWindow = r.safetyWindow; 00170 insideLength = r.insideLength; 00171 absMaterial = r.absMaterial; 00172 windowMaterial = r.windowMaterial; 00173 safetyMaterial = r.safetyMaterial; 00174 safetyDistance = r.safetyDistance; 00175 color = r.color; 00176 maxStep = r.maxStep; 00177 totalLength = r.totalLength; 00178 outerRadius = r.outerRadius; 00179 absTubsLength = r.absTubsLength; 00180 absTubsRadius = r.absTubsRadius; 00181 absWindowShape = r.absWindowShape; 00182 safetyWindowShape = r.safetyWindowShape; 00183 safetyWinSolid = r.safetyWinSolid; 00184 safetyVolSolid = r.safetyVolSolid; 00185 safetyPipeSolid = r.safetyPipeSolid; 00186 absWinSolid = r.absWinSolid; 00187 absVolSolid = r.absVolSolid; 00188 absPipeSolid = r.absPipeSolid; 00189 }
BLElement* BLCMDabsorber::clone | ( | ) | [inline, virtual] |
G4String BLCMDabsorber::commandName | ( | ) | [inline, virtual] |
int BLCMDabsorber::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the absorber command.
Implements BLCommand.
References absMaterial, absWindow, absWindowShape, BLCMDabsorber(), constructSolids(), BLParam::getDouble(), BLCommand::getMaterial(), BLCommand::handleNamedArgs(), maxStep, Param, BLCommand::print(), BLCommand::printError(), safetyMaterial, safetyWindow, safetyWindowShape, BLGroupElement::setName(), and windowMaterial.
00192 { 00193 if(argv.size() != 1) { 00194 printError("absorber: Invalid command, must have name"); 00195 return -1; 00196 } 00197 00198 if(argv[0] == "default") { 00199 return defaultAbsorber.handleNamedArgs(namedArgs); 00200 } 00201 00202 BLCMDabsorber *t = new BLCMDabsorber(defaultAbsorber); 00203 t->setName(argv[0]); 00204 int retval = t->handleNamedArgs(namedArgs); 00205 00206 if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep"); 00207 00208 // get the WindowShape-s 00209 if(t->absWindowShape == 0) 00210 t->absWindowShape = new BLWindowShape(t->absWindow); 00211 if(t->safetyWindowShape == 0 && t->safetyWindow != "") 00212 t->safetyWindowShape = new BLWindowShape(t->safetyWindow); 00213 00214 t->constructSolids(); 00215 00216 // check that materials exist 00217 getMaterial(t->windowMaterial,false); 00218 getMaterial(t->safetyMaterial,false); 00219 getMaterial(t->absMaterial,false); 00220 00221 t->print(argv[0]); 00222 00223 return retval; 00224 }
void BLCMDabsorber::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References absMaterial, absWindow, BLCommand::argDouble(), BLCommand::argString(), color, insideLength, maxStep, safetyDistance, safetyMaterial, safetyWindow, and windowMaterial.
00227 { 00228 argString(absWindow,"absWindow","The name of the absorber window.",false); 00229 argString(safetyWindow,"safetyWindow","The name of the safety window.",false); 00230 argDouble(insideLength,"insideLength","Absorber length inside windows (mm)",mm,"",false); 00231 argString(absMaterial,"absMaterial","The material of the absorber",false); 00232 argString(windowMaterial,"windowMaterial","The material of the window(s)",false); 00233 argString(safetyMaterial,"safetyMaterial","The material inside the safety windows.",false); 00234 argDouble(safetyDistance,"safetyDistance","Distance between absorber and safety windows(mm)",mm,"",false); 00235 argString(color,"color","The color of the absorber (''=invisible)"); 00236 argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)"); 00237 }
void BLCMDabsorber::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [virtual] |
construct() - construct the tube/cylinder.
Implements BLElement.
References absMaterial, absPipeSolid, absVolSolid, absWinSolid, color, BLGroupElement::constructChildren(), BLCommand::getMaterial(), BLElement::getName(), BLCommand::getVisAttrib(), maxStep, safetyMaterial, safetyPipeSolid, safetyVolSolid, safetyWinSolid, and windowMaterial.
00245 { 00246 G4Material *winMat = getMaterial(windowMaterial); 00247 G4Material *sftyMat = getMaterial(safetyMaterial); 00248 G4Material *absMat = getMaterial(absMaterial); 00249 if(!winMat || !winMat || !absMat) { 00250 G4Exception("absorber","Missing material",FatalException, ""); 00251 } 00252 00253 G4UserLimits *limits = new G4UserLimits(maxStep); 00254 00255 G4LogicalVolume *swL = 0; 00256 G4LogicalVolume *svL = 0; 00257 G4LogicalVolume *spL = 0; 00258 if(safetyWinSolid && safetyVolSolid) { 00259 swL = new G4LogicalVolume(safetyWinSolid,winMat, 00260 getName()+"SftyWinLV"); 00261 svL = new G4LogicalVolume(safetyVolSolid,sftyMat, 00262 getName()+"SftyVolLV"); 00263 spL = new G4LogicalVolume(safetyPipeSolid,winMat, 00264 getName()+"SftyPipeLV"); 00265 swL->SetUserLimits(limits); 00266 svL->SetUserLimits(limits); 00267 spL->SetUserLimits(limits); 00268 } 00269 G4LogicalVolume *awL = new G4LogicalVolume(absWinSolid,winMat, 00270 getName()+"AbsWinLV"); 00271 G4LogicalVolume *avL = new G4LogicalVolume(absVolSolid,absMat, 00272 getName()+"AbsVolLV"); 00273 G4LogicalVolume *apL = new G4LogicalVolume(absPipeSolid,winMat, 00274 getName()+"AbsPipeLV"); 00275 awL->SetUserLimits(limits); 00276 avL->SetUserLimits(limits); 00277 apL->SetUserLimits(limits); 00278 #ifdef G4VIS_USE 00279 const G4VisAttributes *visible = getVisAttrib(color); 00280 const G4VisAttributes *vis2 = visible; 00281 if(color == "0,1,0") vis2 = getVisAttrib("0,0.6,0"); 00282 const G4VisAttributes *invisible = &G4VisAttributes::GetInvisible(); 00283 if(swL) swL->SetVisAttributes(color!="" ? vis2 : invisible); 00284 if(svL) svL->SetVisAttributes(color!="" ? vis2 : invisible); 00285 if(spL) spL->SetVisAttributes(color!="" ? vis2 : invisible); 00286 awL->SetVisAttributes(invisible); 00287 avL->SetVisAttributes(color!="" ? visible : invisible); 00288 apL->SetVisAttributes(color!="" ? visible : invisible); 00289 #endif 00290 00291 // geant4 rotation convention is backwards from g4beamline 00292 G4RotationMatrix *g4rot = 0; 00293 if(relativeRotation) 00294 g4rot = new G4RotationMatrix(relativeRotation->inverse()); 00295 00296 G4ThreeVector loc(relativePosition); 00297 G4LogicalVolume *pL = parent; 00298 if(swL) { 00299 new G4PVPlacement(g4rot,loc,swL,parentName+getName()+"SftyWin", 00300 pL,false,0); 00301 new G4PVPlacement(g4rot,loc,spL,parentName+getName()+"SftyPipe", 00302 pL,false,0); 00303 loc = G4ThreeVector(0.0,0.0,0.0); 00304 g4rot = 0; 00305 new G4PVPlacement(g4rot,loc,svL,parentName+getName()+"SftyVol", 00306 swL,false,0); 00307 pL = svL; 00308 } 00309 new G4PVPlacement(g4rot,loc,awL,parentName+getName()+"AbsWin", 00310 pL,false,0); 00311 new G4PVPlacement(g4rot,loc,apL,parentName+getName()+"AbsPipe", 00312 pL,false,0); 00313 loc = G4ThreeVector(0.0,0.0,0.0); 00314 new G4PVPlacement(0,loc,avL,parentName+getName()+"AbsVol", 00315 awL,false,0); 00316 00317 // Childrren need global position and rotation 00318 G4RotationMatrix *globalRotation = 0; 00319 if(relativeRotation && parentRotation) { 00320 globalRotation = 00321 new G4RotationMatrix(*parentRotation * *relativeRotation); 00322 } else if(relativeRotation) { 00323 globalRotation = relativeRotation; 00324 } else if(parentRotation) { 00325 globalRotation = parentRotation; 00326 } 00327 G4ThreeVector globalPosition(relativePosition + parentPosition); 00328 if(parentRotation) 00329 globalPosition = *parentRotation * relativePosition + 00330 parentPosition; 00331 00332 constructChildren(avL,parentName+getName(),globalRotation,globalPosition); 00333 }
G4double BLCMDabsorber::getLength | ( | ) | [inline, virtual] |
getLength() returns the totalLength of the absorber.
Implements BLElement.
References totalLength.
00097 { return totalLength; }
G4double BLCMDabsorber::getWidth | ( | ) | [inline, virtual] |
getWidth() returns the outer radius of the tube/cylinder.
Implements BLElement.
References outerRadius.
00100 { return outerRadius*2.0; }
G4double BLCMDabsorber::getHeight | ( | ) | [inline, virtual] |
getHeight() returns the outer radius of the tube/cylinder.
Implements BLElement.
References outerRadius.
00103 { return outerRadius*2.0; }
G4bool BLCMDabsorber::isOK | ( | ) | [inline, virtual] |
void BLCMDabsorber::constructSolids | ( | ) |
constructSolids() constructs all necessary G4VSolid-s
References absPipeSolid, absTubsLength, absTubsRadius, absVolSolid, absWindowShape, absWinSolid, BLWindowShape::flangeInnerRadius, BLWindowShape::flangeOuterRadius, BLWindowShape::flangeOutsideZ, BLElement::getName(), insideLength, outerRadius, BLWindowShape::r, safetyDistance, safetyPipeSolid, safetyVolSolid, safetyWindowShape, safetyWinSolid, BLWindowShape::t, totalLength, and BLWindowShape::z.
Referenced by command().
00336 { 00337 if(absWindowShape && absWinSolid == 0) { 00338 // allocate arrays for 2 G4Polycone-s (window and volume) 00339 int n = absWindowShape->r.size(); 00340 G4double z0 = absWindowShape->z[0]; 00341 G4double *r = new G4double[n+n]; 00342 G4double *zw = new G4double[n+n]; 00343 G4double *zv = new G4double[n+n]; 00344 G4double *zero = new G4double[n+n]; 00345 for(int j=0; j<n; ++j) { 00346 int k = n + n - j - 1; 00347 zero[j] = zero[k] = 0.0; 00348 // small flat at end (i.e. no corner at center) 00349 r[j] = r[k] = (j==0 ? absWindowShape->r[1]/4.0 : 00350 absWindowShape->r[j]); 00351 zv[k] = absWindowShape->z[j] - z0 + 0.5*insideLength; 00352 zv[j] = -zv[k]; 00353 zw[k] = zv[k] + absWindowShape->t[j]; 00354 zw[j] = -zw[k]; 00355 } 00356 absWinSolid = new G4Polycone(getName()+"AbsWin", 00357 0.0,360.0*deg,n+n,zw,zero,r); 00358 absVolSolid = new G4Polycone(getName()+"AbsVol", 00359 0.0,360.0*deg,n+n,zv,zero,r); 00360 // flange dimensions become dimensions of the absorber pipe 00361 G4double pipeLength = insideLength + 00362 2.0*(absWindowShape->flangeOutsideZ-z0); 00363 absPipeSolid = new G4Tubs(getName()+"AbsPipe", 00364 absWindowShape->flangeInnerRadius, 00365 absWindowShape->flangeOuterRadius, 00366 pipeLength/2.0, 0.0,360.0*deg); 00367 00368 totalLength = insideLength + 2.0*absWindowShape->t[0]; 00369 if(totalLength < pipeLength) totalLength = pipeLength; 00370 outerRadius = absWindowShape->r[n-1]; 00371 if(outerRadius < absWindowShape->flangeOuterRadius) 00372 outerRadius = absWindowShape->flangeOuterRadius; 00373 // size of absTubs (for children) 00374 absTubsRadius = r[n-1]; 00375 absTubsLength = insideLength - 2.0*z0; 00376 } 00377 if(safetyWindowShape && safetyWinSolid == 0) { 00378 // allocate arrays for 2 G4Polycone-s (window and volume) 00379 int n = safetyWindowShape->r.size(); 00380 G4double z0 = safetyWindowShape->z[0]; 00381 G4double *r = new G4double[n+n]; 00382 G4double *zw = new G4double[n+n]; 00383 G4double *zv = new G4double[n+n]; 00384 G4double *zero = new G4double[n+n]; 00385 for(int j=0; j<n; ++j) { 00386 int k = n + n - j - 1; 00387 zero[j] = zero[k] = 0.0; 00388 // small flat at end (i.e. no corner at center) 00389 r[j] = r[k] = (j==0 ? safetyWindowShape->r[1]/4.0 : 00390 safetyWindowShape->r[j]); 00391 zv[k] = safetyWindowShape->z[j] - z0 + 00392 0.5*insideLength + safetyDistance; 00393 zv[j] = -zv[k]; 00394 zw[k] = zv[k] + safetyWindowShape->t[j]; 00395 zw[j] = -zw[k]; 00396 } 00397 safetyWinSolid = new G4Polycone(getName()+"SftyWin", 00398 0.0,360.0*deg,n+n,zw,zero,r); 00399 safetyVolSolid = new G4Polycone(getName()+"SftyVol", 00400 0.0,360.0*deg,n+n,zv,zero,r); 00401 // flange dimensions become dimensions of the absorber pipe 00402 G4double pipeLength = insideLength + 2.0*safetyDistance + 00403 2.0*(safetyWindowShape->flangeOutsideZ-z0); 00404 safetyPipeSolid = new G4Tubs(getName()+"SftyPipe", 00405 safetyWindowShape->flangeInnerRadius, 00406 safetyWindowShape->flangeOuterRadius, 00407 pipeLength/2.0, 0.0,360.0*deg); 00408 00409 totalLength = insideLength + 2.0*safetyWindowShape->t[0]; 00410 if(totalLength < pipeLength) totalLength = pipeLength; 00411 outerRadius = safetyWindowShape->r[n-1]; 00412 if(outerRadius < safetyWindowShape->flangeOuterRadius) 00413 outerRadius = safetyWindowShape->flangeOuterRadius; 00414 } 00415 }
void BLCMDabsorber::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [virtual] |
generatePoints() from BLElement
Implements BLElement.
References BLElement::generateTubs(), outerRadius, and totalLength.
00418 { 00419 generateTubs(npoints, 0.0, outerRadius, 0.0, 360*deg, totalLength, v); 00420 }
G4bool BLCMDabsorber::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
isOutside() from BLElement
Implements BLElement.
References outerRadius, and totalLength.
00423 { 00424 G4double r = sqrt(local[0]*local[0]+local[1]*local[1]); 00425 return r > outerRadius-tolerance || 00426 fabs(local[2]) > totalLength/2.0-tolerance; 00427 }
bool BLCMDabsorber::isWithin | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [virtual] |
isWithin() from BLGroupElement
Implements BLGroupElement.
References absTubsLength, and absTubsRadius.
00430 { 00431 G4double r = sqrt(local[0]*local[0]+local[1]*local[1]); 00432 return r < absTubsRadius+tolerance && 00433 fabs(local[2]) < absTubsLength/2.0+tolerance; 00434 }
G4String BLCMDabsorber::absWindow [private] |
Referenced by BLCMDabsorber(), command(), and defineNamedArgs().
G4String BLCMDabsorber::safetyWindow [private] |
Referenced by BLCMDabsorber(), command(), and defineNamedArgs().
G4double BLCMDabsorber::insideLength [private] |
Referenced by BLCMDabsorber(), constructSolids(), and defineNamedArgs().
G4String BLCMDabsorber::absMaterial [private] |
Referenced by BLCMDabsorber(), command(), construct(), and defineNamedArgs().
G4String BLCMDabsorber::windowMaterial [private] |
Referenced by BLCMDabsorber(), command(), construct(), and defineNamedArgs().
G4String BLCMDabsorber::safetyMaterial [private] |
Referenced by BLCMDabsorber(), command(), construct(), and defineNamedArgs().
G4double BLCMDabsorber::safetyDistance [private] |
Referenced by BLCMDabsorber(), constructSolids(), and defineNamedArgs().
G4String BLCMDabsorber::color [private] |
Referenced by BLCMDabsorber(), construct(), and defineNamedArgs().
G4double BLCMDabsorber::maxStep [private] |
Referenced by BLCMDabsorber(), command(), construct(), and defineNamedArgs().
G4double BLCMDabsorber::totalLength [private] |
Referenced by BLCMDabsorber(), constructSolids(), generatePoints(), getLength(), and isOutside().
G4double BLCMDabsorber::outerRadius [private] |
Referenced by BLCMDabsorber(), constructSolids(), generatePoints(), getHeight(), getWidth(), and isOutside().
G4double BLCMDabsorber::absTubsLength [private] |
Referenced by BLCMDabsorber(), constructSolids(), and isWithin().
G4double BLCMDabsorber::absTubsRadius [private] |
Referenced by BLCMDabsorber(), constructSolids(), and isWithin().
BLWindowShape* BLCMDabsorber::absWindowShape [private] |
Referenced by BLCMDabsorber(), command(), and constructSolids().
BLWindowShape* BLCMDabsorber::safetyWindowShape [private] |
Referenced by BLCMDabsorber(), command(), and constructSolids().
G4VSolid* BLCMDabsorber::safetyWinSolid [private] |
Referenced by BLCMDabsorber(), construct(), and constructSolids().
G4VSolid* BLCMDabsorber::safetyVolSolid [private] |
Referenced by BLCMDabsorber(), construct(), and constructSolids().
G4VSolid* BLCMDabsorber::safetyPipeSolid [private] |
Referenced by BLCMDabsorber(), construct(), and constructSolids().
G4VSolid* BLCMDabsorber::absWinSolid [private] |
Referenced by BLCMDabsorber(), construct(), and constructSolids().
G4VSolid* BLCMDabsorber::absVolSolid [private] |
Referenced by BLCMDabsorber(), construct(), and constructSolids().
G4VSolid* BLCMDabsorber::absPipeSolid [private] |
Referenced by BLCMDabsorber(), construct(), and constructSolids().