15 #include "GeoModelKernel/GeoElement.h"
16 #include "GeoModelKernel/GeoMaterial.h"
17 #include "GeoModelKernel/GeoFullPhysVol.h"
18 #include "GeoModelKernel/GeoPhysVol.h"
19 #include "GeoModelKernel/GeoVPhysVol.h"
20 #include "GeoModelKernel/GeoLogVol.h"
21 #include "GeoModelKernel/GeoPcon.h"
22 #include "GeoModelKernel/GeoTubs.h"
23 #include "GeoModelKernel/GeoTube.h"
24 #include "GeoModelKernel/GeoBox.h"
25 #include "GeoModelKernel/GeoCons.h"
26 #include "GeoModelKernel/GeoTransform.h"
27 #include "GeoModelKernel/GeoNameTag.h"
28 #include "GeoModelKernel/GeoAlignableTransform.h"
29 #include "GeoModelKernel/GeoIdentifierTag.h"
30 #include "GeoModelKernel/GeoVolumeTagCatalog.h"
31 #include "GeoModelKernel/GeoShapeIntersection.h"
32 #include "GeoModelKernel/GeoShapeSubtraction.h"
33 #include "GeoModelKernel/GeoShapeShift.h"
34 #include "GeoModelKernel/GeoShapeUnion.h"
35 #include "GeoModelKernel/GeoSerialTransformer.h"
43 #include "GaudiKernel/MsgStream.h"
44 #include "GaudiKernel/Bootstrap.h"
51 #include "CLHEP/Geometry/Transform3D.h"
53 #include "GaudiKernel/PhysicalConstants.h"
55 #include "GeoGenericFunctions/Abs.h"
56 #include "GeoGenericFunctions/Mod.h"
57 #include "GeoGenericFunctions/Rectangular.h"
58 #include "GeoGenericFunctions/Variable.h"
59 #include "GeoGenericFunctions/FixedConstant.h"
60 #include "GeoGenericFunctions/Sin.h"
61 #include "GeoGenericFunctions/Cos.h"
68 using namespace GeoXF;
73 using planeIndMap = std::map<int, unsigned int, std::less<int>>;
80 m_cryoMotherPhysical(nullptr),
90 if (m_cryoMotherPhysical)
return m_cryoMotherPhysical;
94 ISvcLocator *svcLocator = Gaudi::svcLocator();
96 if (svcLocator->service(
"MessageSvc",
msgSvc,
true )==StatusCode::FAILURE) {
97 throw std::runtime_error(
"Error in EMBConstruction, cannot access MessageSvc");
100 MsgStream
log(
msgSvc,
"LAr::BarrelCryostatConstruction");
104 if (svcLocator->service(
"DetectorStore",
detStore,
false )==StatusCode::FAILURE) {
105 throw std::runtime_error(
"Error in LArDetectorFactory, cannot access DetectorStore");
111 if (StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
return nullptr;
113 const GeoMaterial *Air = materialManager->
getMaterial(
"std::Air");
115 throw std::runtime_error(
"Error in BarrelCryostatConstruction, std::Air is not found.");
118 const GeoMaterial *Aluminium = materialManager->
getMaterial(
"std::Aluminium");
120 throw std::runtime_error(
"Error in BarrelCryostatConstruction, std::Aluminium is not found.");
123 const GeoMaterial *Titanium = materialManager->
getMaterial(
"std::Titanium");
125 Titanium = Aluminium;
130 const GeoMaterial *
LAr = materialManager->
getMaterial(
"std::LiquidArgon");
132 throw std::runtime_error(
"Error in BarrelCryostatConstruction, std::LiquidArgon is not found.");
139 planeIndMap innerWallPlanes, innerEndWallPlanes, outerWallPlanes, cryoMotherPlanes, totalLarPlanes, halfLarPlanes, sctEcCoolingPlanes;
140 planeIndMap::const_iterator iter;
144 if(svcLocator->service (
"GeoModelSvc",geoModel) == StatusCode::FAILURE)
145 throw std::runtime_error(
"Error in BarrelCryostatConstruction, cannot access GeoModelSvc");
146 if(svcLocator->service (
"RDBAccessSvc",rdbAccess) == StatusCode::FAILURE)
147 throw std::runtime_error(
"Error in BarrelCryostatConstruction, cannot access RDBAccessSvc");
155 std::string
names[]={
"EMB_POS",
"EMB_NEG",
"SOLENOID"};
156 GeoAlignableTransform *xf[]={
nullptr,
nullptr,
nullptr};
157 for (
int n=0;
n<3;
n++) {
161 if (larPosition->size()==0 ) {
162 larPosition = rdbAccess->
getRecordsetPtr(
"LArPosition",
"LArPosition-00");
163 if (larPosition->size()==0 ) {
164 throw std::runtime_error(
"Error, no lar position table in database!");
169 if (!posRec)
throw std::runtime_error(
"Error, no lar position record in the database") ;
171 xf[
n] =
new GeoAlignableTransform(xfPos);
175 if(!
status.isSuccess())
throw std::runtime_error ((
"Cannot store " +
names[
n]).c_str() );
178 GeoAlignableTransform *xfHalfLArPos=xf[0], *xfHalfLArNeg=xf[1], *xfSolenoid=xf[2];
187 larVersionKey.
node());
188 if(cryoCylinders->size()==0)
189 cryoCylinders = rdbAccess->
getRecordsetPtr(
"CryoCylinders",
"CryoCylinders-00");
194 larVersionKey.
node());
195 if(cryoPcons->size()==0)
199 for (
unsigned int ind=0;
ind<cryoPcons->size();
ind++)
201 int key = (*cryoPcons)[
ind]->getInt(
"PLANE_ID");
202 const std::string& pconName = (*cryoPcons)[
ind]->getString(
"PCON");
203 if(pconName==
"Barrel::InnerWall")
204 innerWallPlanes[
key] =
ind;
205 if (pconName==
"Barrel::InnerEndWall")
206 innerEndWallPlanes[
key] =
ind;
207 else if(pconName==
"Barrel::OuterWall")
208 outerWallPlanes[
key] =
ind;
209 else if(pconName==
"Barrel::CryoMother")
210 cryoMotherPlanes[
key] =
ind;
211 else if(pconName==
"Barrel::TotalLAr")
212 totalLarPlanes[
key] =
ind;
213 else if(pconName==
"Barrel::HalfLAr")
215 else if(pconName==
"Barrel::SctEcCooling")
216 sctEcCoolingPlanes[
key] =
ind;
232 std::string cryoMotherName =
"LAr::Barrel::Cryostat::MotherVolume";
259 double dphi_all = 2.*
M_PI;
261 GeoPcon* cryoMotherShape =
265 for(
unsigned int ind=0;
ind<cryoMotherPlanes.size();
ind++)
267 iter = cryoMotherPlanes.find(
ind);
269 if(iter==cryoMotherPlanes.end())
270 throw std::runtime_error(
"Error in BarrelCryostatConstruction, missing plane in CryoMother");
273 currentRecord = (*cryoPcons)[(*iter).second];
275 cryoMotherShape->addPlane(currentRecord->
getDouble(
"ZPLANE"),
289 const GeoLogVol* cryoMotherLogical =
290 new GeoLogVol(cryoMotherName, cryoMotherShape, Air);
292 m_cryoMotherPhysical =
new GeoFullPhysVol(cryoMotherLogical);
295 GeoVolumeTagCatalog::VolumeTagCatalog()->addTaggedVolume(
"Envelope",
"LArBarrel",m_cryoMotherPhysical);
303 for (
unsigned int ind=0;
ind < cryoCylinders->size();
ind++)
305 currentRecord = (*cryoCylinders)[
ind];
307 if(currentRecord->
getString(
"CYL_LOCATION")==
"Barrel::CryoMother")
310 const GeoMaterial *material = materialManager->
getMaterial(currentRecord->
getString(
"MATERIAL"));
314 std::ostringstream errorMessage;
315 errorMessage <<
"Error in BarrelCrysostat Construction" << std::endl;
316 errorMessage <<
"Material " << currentRecord->
getString(
"MATERIAL") <<
" is not found" << std::endl;
317 throw std::runtime_error(errorMessage.str().c_str());
321 std::ostringstream cylStream;
322 int cylID = currentRecord->
getInt(
"CYL_ID");
323 cylStream <<
"LAr::Barrel::Cryostat::Cylinder::#" << cylID;
324 std::string cylName= cylStream.str();
326 int cylNumber = currentRecord->
getInt(
"CYL_NUMBER");
329 double zInCryostat = zMin + dZ / 2.;
332 if ((*cryoEars).size()>0 && cylID==1) {
334 double rmin = record->
getDouble(
"EARRMIN");
335 double rmax = record->
getDouble(
"EARRMAX");
336 double zthick = record->
getDouble(
"EARZTHICKNESS");
337 double yvert = record->
getDouble(
"EARVERTICALEXTENT");
338 GeoTubs *tubs =
new GeoTubs(rmin,
344 GeoBox *box =
new GeoBox( rmax, yvert/2, rmax);
346 const GeoShape & shape = tubs->intersect(*box);
347 const GeoLogVol *logVol =
new GeoLogVol (
"LAr::Barrel::Cryostat::Sector::Ear",&shape, material);
348 GeoIntrusivePtr<GeoPhysVol>earPhysVol =
new GeoPhysVol(logVol);
350 m_cryoMotherPhysical->add(
new GeoNameTag(std::string(
"CryostatEarForward")));
351 m_cryoMotherPhysical->add(
new GeoIdentifierTag(cylNumber));
352 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat)));
353 m_cryoMotherPhysical->add(earPhysVol);
355 m_cryoMotherPhysical->add(
new GeoNameTag(cylName+std::string(
"CryostatEarBackward")));
356 m_cryoMotherPhysical->add(
new GeoIdentifierTag(cylNumber));
357 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(-zInCryostat)));
358 m_cryoMotherPhysical->add(earPhysVol);
361 if ((*cryoEars).size() > 0 && cylID==6) {
363 double rmin = record->
getDouble(
"LEGRMIN");
364 double rmax = record->
getDouble(
"LEGRMAX");
365 double zthick = record->
getDouble(
"LEGZTHICKNESS");
366 double yvert = record->
getDouble(
"LEGYMAX");
369 GeoTubs *tubs =
new GeoTubs(rmin,
375 GeoTrf::TranslateY3D
offset(rmax-yvert);
376 GeoBox * box =
new GeoBox(rmax,rmax, rmax);
377 const GeoShape & shape = tubs->subtract((*box)<<
offset);
379 const GeoLogVol *logVol =
new GeoLogVol (
"LAr::Barrel::Cryostat::Sector::Leg",&shape, material);
380 GeoIntrusivePtr<GeoPhysVol>legPhysVol =
new GeoPhysVol(logVol);
382 m_cryoMotherPhysical->add(
new GeoNameTag(std::string(
"CryostatLegForward")));
383 m_cryoMotherPhysical->add(
new GeoIdentifierTag(cylNumber));
384 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat+zthick)));
385 m_cryoMotherPhysical->add(legPhysVol);
387 m_cryoMotherPhysical->add(
new GeoNameTag(cylName+std::string(
"CryostatLegBackward")));
388 m_cryoMotherPhysical->add(
new GeoIdentifierTag(cylNumber));
389 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(-zInCryostat-zthick)));
390 m_cryoMotherPhysical->add(legPhysVol);
394 const GeoShape* solidBarrelCylinder =
nullptr;
395 const GeoLogVol* logicBarrelCylinder =
nullptr;
398 if(m_fullGeo || (10<=cylID && cylID<=14)) {
407 log <<
MSG::DEBUG <<
"Cut holes for feedthroughs in warm wall "
413 const double warmhole_radius = bellow_Router;
415 GeoTube *warmhole =
new GeoTube(0., warmhole_radius, (rmax - rmin) * 2);
417 const double r = (rmin + rmax) * 0.5;
418 const GeoShape *warmwall = solidBarrelCylinder;
420 const int NCrates = 16;
421 auto put = [&warmwall, &warmhole_pos, &
r, &
h1](
double pos){
424 warmwall = &(warmwall->subtract(
425 h1 << GeoTrf::Translate3D(
x,
y, warmhole_pos)
429 for(
int i = 0;
i < NCrates; ++
i){
434 solidBarrelCylinder = warmwall;
435 }
else if(cylID == 2){
436 log <<
MSG::DEBUG <<
"Cut holes for feedthroughs in cold wall "
443 GeoTube *coldhole =
new GeoTube(0., coldhole_radius, (rmax - rmin) * 2);
445 const double r = (rmin + rmax) * 0.5;
446 const GeoShape *coldwall = solidBarrelCylinder;
448 const int NCrates = 16;
449 for(
int i = 0;
i < NCrates; ++
i){
451 auto put = [&coldwall, &coldhole_pos, &
r, &
h1](
double pos){
454 coldwall = &(coldwall->subtract(
455 h1 << GeoTrf::Translate3D(
x,
y, coldhole_pos)
462 solidBarrelCylinder = coldwall;
466 logicBarrelCylinder =
new GeoLogVol(cylName,solidBarrelCylinder,material);
469 if(logicBarrelCylinder) {
473 GeoIntrusivePtr<GeoFullPhysVol> physBarrelCylinder =
new GeoFullPhysVol(logicBarrelCylinder);
475 m_cryoMotherPhysical->add(
new GeoNameTag(cylName+std::string(
"Phys")));
476 m_cryoMotherPhysical->add(
new GeoIdentifierTag(cylNumber));
479 if(10<=cylID && cylID<=14)
480 m_cryoMotherPhysical->add(xfSolenoid);
482 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat)));
483 m_cryoMotherPhysical->add(physBarrelCylinder);
493 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store SOLENOID");
497 GeoIntrusivePtr<GeoPhysVol> physBarrelCylinder =
new GeoPhysVol(logicBarrelCylinder);
499 m_cryoMotherPhysical->add(
new GeoNameTag(cylName+std::string(
"PhysForward")));
500 m_cryoMotherPhysical->add(
new GeoIdentifierTag(cylNumber));
501 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat)));
502 m_cryoMotherPhysical->add(physBarrelCylinder);
504 m_cryoMotherPhysical->add(
new GeoNameTag(cylName+std::string(
"PhysBackward")));
505 m_cryoMotherPhysical->add(
new GeoIdentifierTag(cylNumber));
506 if(m_activateFT && (cylID == 2 || cylID == 7)){
507 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180.*
Gaudi::Units::deg)));
508 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat)));
510 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(-zInCryostat)));
512 m_cryoMotherPhysical->add(physBarrelCylinder);
521 GeoPcon *outerWallPcon =
new GeoPcon(0,dphi_all);
523 for(
unsigned int ind=0;
ind<outerWallPlanes.size();
ind++) {
524 iter = outerWallPlanes.find(
ind);
526 if(iter==outerWallPlanes.end())
527 throw std::runtime_error(
"Error in BarrelCryostatConstruction, missing plane in OuterWall");
529 currentRecord = (*cryoPcons)[(*iter).second];
530 outerWallPcon->addPlane(currentRecord->
getDouble(
"ZPLANE"),
536 const GeoLogVol *outerWallLog =
new GeoLogVol(
"LAr::Barrel::Cryostat::OuterWall", outerWallPcon, Aluminium);
537 m_cryoMotherPhysical->add(
new GeoNameTag(std::string(
"Barrel Cryo OuterWall Phys")));
538 GeoIntrusivePtr<GeoPhysVol>outerWallPhys =
new GeoPhysVol(outerWallLog);
539 m_cryoMotherPhysical->add(outerWallPhys);
542 GeoPcon *innerWallPcon =
new GeoPcon(0,dphi_all);
544 for(
unsigned int ind=0;
ind<innerWallPlanes.size();
ind++) {
545 iter = innerWallPlanes.find(
ind);
547 if(iter==innerWallPlanes.end())
548 throw std::runtime_error(
"Error in BarrelCryostatConstruction, missing plane in InnerWall");
550 currentRecord = (*cryoPcons)[(*iter).second];
551 innerWallPcon->addPlane(currentRecord->
getDouble(
"ZPLANE"),
557 const GeoLogVol *innerWallLog =
new GeoLogVol(
"LAr::Barrel::Cryostat::InnerWall", innerWallPcon, Aluminium);
558 m_cryoMotherPhysical->add(
new GeoNameTag(std::string(
"Barrel Cryo InnerWall Phys")));
559 GeoIntrusivePtr<GeoPhysVol>innerWallPhys =
new GeoPhysVol(innerWallLog);
560 m_cryoMotherPhysical->add(innerWallPhys);
566 larVersionKey.
node());
567 if (cryoBolts->size() >0) {
568 log << MSG::INFO <<
" new description with barrel croystat bolts" <<
endmsg;
569 const IRDBRecord * cryoBoltsRecord = (*cryoBolts) [0];
570 double rmax_vis = cryoBoltsRecord->
getDouble(
"RBOLT");
571 int Nvis = cryoBoltsRecord->
getInt(
"NBOLT");
572 double PhiPos0 = cryoBoltsRecord->
getDouble(
"PHI0");
573 double RhoPosB = cryoBoltsRecord->
getDouble(
"RADIUS");
576 const GeoMaterial *bolt_material = materialManager->
getMaterial(cryoBoltsRecord->
getString(
"MATERIAL"));
577 if (!bolt_material) {
578 throw std::runtime_error(
"Error in BarrelCryostatConstruction, material for bolt not found");
584 if ((iter = innerWallPlanes.find(
index1))!= innerWallPlanes.end()) {
585 const IRDBRecord * pconsRecord = (*cryoPcons) [(*iter).second];
588 if ((iter = innerWallPlanes.find(
index2))!= innerWallPlanes.end()) {
589 const IRDBRecord * pconsRecord = (*cryoPcons) [(*iter).second];
592 if (z1>0. && z2>0.) {
593 double zthick_vis=(z2-z1)-0.1;
595 GeoTubs *tub_vis =
new GeoTubs(0.,rmax_vis,zthick_vis/2., (
double) 0., dphi_all);
596 const GeoLogVol * log_vis =
new GeoLogVol(
"LAr::Barrel::Cryostat::InnerWall::Vis",tub_vis,bolt_material);
597 GeoIntrusivePtr<GeoPhysVol> phys_vis =
new GeoPhysVol(log_vis);
599 double xxVis=((
double)(Nvis));
600 double ZposB=0.5*(z1+z2);
601 double twopi128 = 2.*
M_PI/xxVis;
602 GeoGenfun::Variable
i;
603 GeoGenfun::Mod Mod1(1.0),Mod128(xxVis),Mod2(2.0);
604 GeoGenfun::GENFUNCTION PhiPos = PhiPos0 + twopi128*Mod128(
i);
605 GeoGenfun::GENFUNCTION Int =
i - Mod1;
608 GeoXF::TRANSFUNCTION TX =
609 GeoXF::Pow(GeoTrf::TranslateX3D(1.0),RhoPosB*Cos(PhiPos))*
610 GeoXF::Pow(GeoTrf::TranslateY3D(1.0),RhoPosB*Sin(PhiPos))*
611 GeoXF::Pow(GeoTrf::TranslateZ3D(2*ZposB),Int(
i/128))*
612 GeoTrf::TranslateZ3D(-ZposB);
613 GeoSerialTransformer *st =
new GeoSerialTransformer(phys_vis, &TX, 2*Nvis);
614 innerWallPhys->add(st);
618 log << MSG::INFO <<
" old description withut bold in the geometry database " <<
endmsg;
625 larVersionKey.
node());
626 if (extraCones->size() > 0 ) {
629 const std::string& conName = cone->getString(
"CONE");
630 if (conName.find(
"ExtraInCryo") != std::string::npos) {
632 double extra_dz = 0.5*( cone->getDouble(
"DZ") );
633 double extra_rmin1 = cone->getDouble(
"RMIN1");
634 double extra_rmin2 = cone->getDouble(
"RMIN2");
635 double extra_rmax1 = cone->getDouble(
"RMAX1");
636 double extra_rmax2 = cone->getDouble(
"RMAX2");
637 double extra_phi0 = cone->getDouble(
"PHI0");
638 double extra_dphi = cone->getDouble(
"DPHI");
639 double extra_zpos = cone->getDouble(
"ZPOS");
643 if (extra_dphi>6.2831) extra_dphi = dphi_all;
648 =
new GeoCons(extra_rmin1,extra_rmin2,extra_rmax1,extra_rmax2,extra_dz,extra_phi0,extra_dphi);
650 std::ostringstream extraStream;
651 extraStream <<
"LAr::Barrel::Cryostat::ExtraMat" << nextra;
652 std::string extraName= extraStream.str();
655 GeoLogVol* extraLog =
new GeoLogVol(extraName,extraCons,Aluminium);
656 GeoIntrusivePtr<GeoPhysVol> extraPhys =
new GeoPhysVol(extraLog);
657 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(extra_zpos)));
658 m_cryoMotherPhysical->add(extraPhys);
665 const GeoMaterial* myMaterial;
666 double length,height,
width,pairSeparation,distFromRidge;
667 int nPairTot,indexWall;
669 if (newBlocks->size() >0 ) {
670 log << MSG::INFO <<
" new coil bumper description " <<
endmsg;
671 const IRDBRecord * newBlocksRecord = (*newBlocks) [0];
673 height = newBlocksRecord->
getDouble(
"HEIGHT");
675 pairSeparation = newBlocksRecord->
getDouble(
"PAIRSEP");
676 distFromRidge = newBlocksRecord->
getDouble(
"DISTANCEFROMRIDGE");
677 nPairTot = newBlocksRecord->
getInt(
"NPAIRTOT");
678 indexWall = newBlocksRecord->
getInt(
"INDEXWALL");
681 throw std::runtime_error(
"Error in BarrelCryostatConstruction, material for coil bumpber not found");
685 log << MSG::INFO <<
" old coil bumper description " <<
endmsg;
687 const IRDBRecord * tiBlocksRecord = (*tiBlocks) [0];
689 height = tiBlocksRecord->
getDouble(
"HEIGHT");
691 pairSeparation = tiBlocksRecord->
getDouble(
"PAIRSEP");
692 distFromRidge = tiBlocksRecord->
getDouble(
"DISTANCEFROMRIDGE");
693 nPairTot = tiBlocksRecord->
getInt(
"NPAIRTOT");
700 if ((iter = innerWallPlanes.find(indexWall))!= innerWallPlanes.end()) {
701 const IRDBRecord * pconsRecord = (*cryoPcons) [(*iter).second];
710 GeoBox *box =
new GeoBox(
length/2.0, height/2.0,
width/2.0);
711 GeoLogVol *logVol =
new GeoLogVol(
"LAr::Barrel::Cryostat::Sector::TitaniumBlock", box,myMaterial);
712 GeoIntrusivePtr<GeoPhysVol>physVol =
new GeoPhysVol(logVol);
714 double angle=pairSeparation/
r;
717 if (newBlocks->size() >0) {
718 GeoGenfun::Variable
i;
719 GeoGenfun::Mod Mod1(1.0),Mod2(2.0);
720 GeoGenfun::GENFUNCTION Truncate =
i - Mod1(
i);
721 GeoGenfun::GENFUNCTION AngleZ = -
angle/2.+
angle*Truncate(Mod2(
i/2))+ 2.*
M_PI/(1.0*nPairTot)*Truncate(
i/4) + 2*
M_PI/(2.*nPairTot);
722 GeoGenfun::GENFUNCTION TransZ = -
pos + 2.*
pos*Mod2(
i);
725 GeoXF::Pow(GeoTrf::TranslateZ3D(1.0),TransZ)*
726 GeoXF::Pow(GeoTrf::RotateZ3D(1.0),AngleZ)*
727 GeoTrf::Translate3D(0.,
r+height/2,0.);
728 GeoSerialTransformer *
t =
new GeoSerialTransformer(physVol, &
tx, nPairTot*4);
729 m_cryoMotherPhysical->add(
t);
733 GeoGenfun::Variable
i;
734 GeoGenfun::Mod Mod1(1.0),Mod2(2.0);
735 GeoGenfun::GENFUNCTION Truncate =
i - Mod1(
i);
738 Pow(GeoTrf::RotateZ3D(2*
M_PI/nPairTot),Truncate(
i/4))*
739 Pow(GeoTrf::RotateZ3D(
angle),Mod2(
i/2))*
740 GeoTrf::RotateZ3D(-
angle/2)*
741 Pow(GeoTrf::TranslateZ3D(2*
pos),Mod2(
i))*
742 GeoTrf::Translate3D(0,
r+height/2, -
pos);
743 GeoSerialTransformer *
t =
new GeoSerialTransformer(physVol, &
tx, nPairTot*4);
744 m_cryoMotherPhysical->add(
t);
749 log << MSG::WARNING <<
" could not find wall index plane => no coil bumper description " <<
endmsg;
756 if(!innerEndWallPlanes.empty()) {
757 GeoPcon *innerEndWallPcon =
new GeoPcon(0,dphi_all);
759 for(
unsigned int ind=0;
ind<innerEndWallPlanes.size();
ind++) {
760 iter = innerEndWallPlanes.find(
ind);
762 if(iter==innerEndWallPlanes.end())
763 throw std::runtime_error(
"Error in BarrelCryostatConstruction, missing plane in InnerEndWall");
765 currentRecord = (*cryoPcons)[(*iter).second];
766 innerEndWallPcon->addPlane(currentRecord->
getDouble(
"ZPLANE"),
772 const GeoLogVol *innerEndWallLog =
new GeoLogVol(
"LAr::Barrel::Cryostat::InnerEndWall", innerEndWallPcon, Aluminium);
773 m_cryoMotherPhysical->add(
new GeoNameTag(std::string(
"Barrel Cryo InnerEndWall Phys")));
774 GeoIntrusivePtr<GeoPhysVol>innerEndWallPhys =
new GeoPhysVol(innerEndWallLog);
775 m_cryoMotherPhysical->add(innerEndWallPhys);
776 m_cryoMotherPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(
M_PI)));
777 m_cryoMotherPhysical->add(innerEndWallPhys);
795 GeoPcon* totalLArShape =
799 for(
unsigned int ind=0;
ind<totalLarPlanes.size();
ind++)
801 iter = totalLarPlanes.find(
ind);
803 if(iter==totalLarPlanes.end())
804 throw std::runtime_error(
"Error in BarrelCryostatConstruction, missing plane in CryoMother");
807 currentRecord = (*cryoPcons)[(*iter).second];
808 totalLArShape->addPlane(currentRecord->
getDouble(
"ZPLANE"),
814 std::string totalLArName =
"LAr::Barrel::Cryostat::TotalLAr";
815 const GeoLogVol* totalLArLogical =
new GeoLogVol(totalLArName, totalLArShape,
LAr);
820 m_cryoMotherPhysical->add(
new GeoNameTag(
"Total LAR Volume"));
821 GeoIntrusivePtr<GeoPhysVol> totalLArPhysical =
new GeoPhysVol(totalLArLogical);
822 m_cryoMotherPhysical->add(totalLArPhysical);
838 std::string halfLArName =
"LAr::Barrel::Cryostat::HalfLAr";
839 GeoPcon* halfLArShape =
845 for(
unsigned int ind=0;
ind<halfLarPlanes.size();
ind++)
847 iter = halfLarPlanes.find(
ind);
849 if(iter==halfLarPlanes.end())
850 throw std::runtime_error(
"Error in BarrelCryostatConstruction, missing plane in CryoMother");
853 currentRecord = (*cryoPcons)[(*iter).second];
854 halfLArShape->addPlane(currentRecord->
getDouble(
"ZPLANE"),
861 const GeoLogVol* halfLArLogicalPos =
862 new GeoLogVol(halfLArName +
"::Pos", halfLArShape,
LAr);
863 GeoIntrusivePtr<GeoPhysVol> halfLArPhysicalPos =
new GeoPhysVol(halfLArLogicalPos);
865 const GeoLogVol* halfLArLogicalNeg =
866 new GeoLogVol(halfLArName +
"::Neg", halfLArShape,
LAr);
867 GeoIntrusivePtr<GeoPhysVol> halfLArPhysicalNeg =
new GeoPhysVol(halfLArLogicalNeg);
869 totalLArPhysical->add(
new GeoNameTag(halfLArName +
"::PosPhysical"));
872 totalLArPhysical->add(xfHalfLArPos);
873 totalLArPhysical->add(halfLArPhysicalPos);
875 totalLArPhysical->add(
new GeoNameTag(halfLArName +
"::NegPhysical"));
878 totalLArPhysical->add(xfHalfLArNeg);
879 totalLArPhysical->add(
new GeoTransform(GeoTrf::RotateY3D(180.*
Gaudi::Units::deg)) );
880 totalLArPhysical->add(halfLArPhysicalNeg);
894 GeoIntrusivePtr<GeoFullPhysVol> barrelPosEnvelope = barrelConstruction.
GetPositiveEnvelope();
895 if ( barrelPosEnvelope)
896 halfLArPhysicalPos->add(barrelPosEnvelope);
899 GeoIntrusivePtr<GeoFullPhysVol> barrelNegEnvelope = barrelConstruction.
GetNegativeEnvelope();
900 if ( barrelNegEnvelope)
901 halfLArPhysicalNeg->add(barrelNegEnvelope);
907 for (
unsigned int ind=0;
ind < cryoCylinders->size();
ind++) {
908 currentRecord = (*cryoCylinders)[
ind];
910 if(currentRecord->
getString(
"CYL_LOCATION")==
"Barrel::HalfLAr"||
911 currentRecord->
getString(
"CYL_LOCATION")==
"Barrel::TotalLAr") {
912 bool isHalfLar = currentRecord->
getString(
"CYL_LOCATION")==
"Barrel::HalfLAr";
914 const GeoMaterial *material = materialManager->
getMaterial(currentRecord->
getString(
"MATERIAL"));
917 std::ostringstream errorMessage;
918 errorMessage <<
"Error in BarrelCrysostat Construction" << std::endl;
919 errorMessage <<
"Material " << currentRecord->
getString(
"MATERIAL") <<
" is not found" << std::endl;
920 throw std::runtime_error(errorMessage.str().c_str());
923 std::ostringstream cylStream;
924 cylStream <<
"LAr::Barrel::Cryostat::";
927 const std::string& qualifier = currentRecord->
getString(
"QUALIFIER");
928 if (!qualifier.empty()) cylStream << qualifier <<
"::";
930 cylStream <<
"Cylinder::#" << currentRecord->
getInt(
"CYL_ID");
931 std::string cylName= cylStream.str();
933 GeoTubs* solidBarrelCylinder
940 const GeoLogVol* logicBarrelCylinder
941 =
new GeoLogVol(cylName,solidBarrelCylinder,material);
943 GeoIntrusivePtr<GeoPhysVol> physBarrelCylinder =
new GeoPhysVol(logicBarrelCylinder);
947 int cylNumber = currentRecord->
getInt(
"CYL_NUMBER");
952 halfLArPhysicalPos->add(
new GeoNameTag(cylName+std::string(
"PhysForward")));
953 halfLArPhysicalPos->add(
new GeoIdentifierTag(cylNumber));
955 halfLArPhysicalPos->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat)));
956 halfLArPhysicalPos->add(physBarrelCylinder);
958 halfLArPhysicalNeg->add(
new GeoNameTag(cylName+std::string(
"PhysBackward")));
959 halfLArPhysicalNeg->add(
new GeoIdentifierTag(cylNumber));
961 halfLArPhysicalNeg->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat)));
962 halfLArPhysicalNeg->add(physBarrelCylinder);
964 totalLArPhysical->add(
new GeoNameTag(cylName+std::string(
"PhysForward")));
965 totalLArPhysical->add(
new GeoIdentifierTag(cylNumber));
966 totalLArPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(zInCryostat)));
967 totalLArPhysical->add(physBarrelCylinder);
969 totalLArPhysical->add(
new GeoNameTag(cylName+std::string(
"PhysBackward")));
970 totalLArPhysical->add(
new GeoIdentifierTag(cylNumber));
971 totalLArPhysical->add(
new GeoTransform(GeoTrf::TranslateZ3D(-zInCryostat)));
972 totalLArPhysical->add(physBarrelCylinder);
987 GeoIntrusivePtr<GeoFullPhysVol> barrelPSPosEnvelope = barrelPSConstruction.
GetPositiveEnvelope();
988 GeoTransform *xfPos =
new GeoTransform(
GeoTrf::Transform3D(GeoTrf::TranslateZ3D(PresamplerMother_length+presamplerShift)));
990 halfLArPhysicalPos->add(xfPos);
992 halfLArPhysicalPos->add(barrelPSPosEnvelope);
996 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store PRESAMPLER_B_POS");
999 GeoIntrusivePtr<GeoFullPhysVol> barrelPSNegEnvelope = barrelPSConstruction.
GetNegativeEnvelope();
1000 GeoTransform *xfNeg =
new GeoTransform(
GeoTrf::Transform3D(GeoTrf::TranslateZ3D(PresamplerMother_length+presamplerShift)));
1002 halfLArPhysicalNeg->add(xfNeg);
1004 halfLArPhysicalNeg->add(barrelPSNegEnvelope);
1008 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store PRESAMPLER_B_NEG");
1015 if ((*cryoPconPhiSect).size()!=0){
1016 for(
unsigned i=0;
i<cryoPconPhiSect->size(); ++
i) {
1017 double startPhi = (*cryoPconPhiSect)[
i]->getDouble(
"STARTPHI");
1018 double dPhi = (*cryoPconPhiSect)[
i]->getDouble(
"DPHI");
1019 double centerPhi = startPhi + 0.5*
dPhi;
1021 const GeoMaterial* material = materialManager->
getMaterial((*cryoPconPhiSect)[
i]->getString(
"MATERIAL"));
1023 std::string
message = std::string(
"Error in BarrelCryostatConstruction! ") + (*cryoPconPhiSect)[
i]->getString(
"MATERIAL") + std::string(
" is not found.");
1024 throw std::runtime_error(
message.c_str());
1029 for(
unsigned int ii=0; ii<sctEcCoolingPlanes.size(); ii++) {
1030 iter = sctEcCoolingPlanes.find(ii);
1032 if(iter==sctEcCoolingPlanes.end()) {
1033 std::ostringstream
stream;
1034 stream <<
"Error in BarrelCryostatConstruction, missing plane " << ii <<
" in SCT-EC cooling";
1035 throw std::runtime_error(
stream.str().c_str());
1038 currentRecord = (*cryoPcons)[(*iter).second];
1039 pcon->addPlane(currentRecord->
getDouble(
"ZPLANE"),
1045 const GeoLogVol* sctCiCoolingLog =
new GeoLogVol(
"LAr::Barrel::Cryostat::SctCiCooling",pcon,material);
1046 GeoIntrusivePtr<GeoPhysVol> sctCiCoolingPhys =
new GeoPhysVol(sctCiCoolingLog);
1048 GeoTransform* xfPos1 =
new GeoTransform(GeoTrf::Transform3D::Identity());
1049 GeoTransform* xfPos2 =
new GeoTransform(GeoTrf::RotateZ3D(180*
Gaudi::Units::deg));
1053 m_cryoMotherPhysical->add(xfPos1);
1054 m_cryoMotherPhysical->add(sctCiCoolingPhys);
1055 m_cryoMotherPhysical->add(xfPos2);
1056 m_cryoMotherPhysical->add(sctCiCoolingPhys);
1057 m_cryoMotherPhysical->add(xfNeg1);
1058 m_cryoMotherPhysical->add(sctCiCoolingPhys);
1059 m_cryoMotherPhysical->add(xfNeg2);
1060 m_cryoMotherPhysical->add(sctCiCoolingPhys);
1063 else log <<
MSG::DEBUG <<
"CryoPconPhiSect table not found - not building SCT cooling " <<
endmsg;
1066 if(!rdbAccess->
getChildTag(
"LArBarrelDM",larVersionKey.
tag(),larVersionKey.
node()).empty() && m_fullGeo) {
1069 crackDMConstruction.
create(m_cryoMotherPhysical);
1072 return m_cryoMotherPhysical;