48 #include "GaudiKernel/SystemOfUnits.h"
49 #include "GeoModelKernel/GeoBox.h"
50 #include "GeoModelKernel/GeoDefinitions.h"
51 #include "GeoModelKernel/GeoFullPhysVol.h"
52 #include "GeoModelKernel/GeoIdentifierTag.h"
53 #include "GeoModelKernel/GeoLogVol.h"
54 #include "GeoModelKernel/GeoMaterial.h"
55 #include "GeoModelKernel/GeoNameTag.h"
56 #include "GeoModelKernel/GeoPhysVol.h"
57 #include "GeoModelKernel/GeoSerialDenominator.h"
58 #include "GeoModelKernel/GeoShapeIntersection.h"
59 #include "GeoModelKernel/GeoShapeShift.h"
60 #include "GeoModelKernel/GeoShapeSubtraction.h"
61 #include "GeoModelKernel/GeoShapeUnion.h"
62 #include "GeoModelKernel/GeoTransform.h"
63 #include "GeoModelKernel/GeoTrd.h"
64 #include "GeoModelKernel/GeoTube.h"
71 #define useAssemblies false
75 const std::map<std::string, float> rpcYTrans = {
76 std::make_pair<std::string, float>(
"RPC26", -9.1),
77 std::make_pair<std::string, float>(
"RPC27", -9.1),
78 std::make_pair<std::string, float>(
"RPC28", -27.7),
79 std::make_pair<std::string, float>(
"RPC29", -8.8),
81 const std::map<std::string, float> rpcZTrans = {
82 std::make_pair<std::string, float>(
"RPC26", 3.22),
83 std::make_pair<std::string, float>(
"RPC27", 3.06),
84 std::make_pair<std::string, float>(
"RPC28", 3.11),
85 std::make_pair<std::string, float>(
"RPC29", 3.11),
97 longWidth =
s->GetWidth2();
98 thickness =
s->GetThickness(mysql);
103 std::string stname(m_station->GetName(), 0, 3);
113 <<
" is assembly = " << isAssembly );
122 bool is_barrel = (stName.compare(0, 1,
"B") == 0);
124 std::string geometry_version =
manager->geometryVersion();
127 double totthick =
thickness + extratop + extrabottom;
138 const GeoShape *strd =
nullptr;
140 if ((extratop + extrabottom) != 0.) {
142 dx = extratop / 2. - extrabottom / 2.;
145 strd = &((*maintrd) << GeoTrf::Translate3D(
dx, 0., 0.));
154 if (stname ==
"CSS") {
162 if ((
comp->name).compare(0, 3,
"CSC") == 0) {
164 cthick =
comp->GetThickness(mysql);
165 cypos = clen -
comp->posy + 1.0 -
length / 2.;
166 cxpos = -totthick / 2. +
comp->posz + cthick / 2. + 0.1;
170 GeoIntrusivePtr<GeoShape> box{
new GeoBox(cthick / 2.,
longWidth / 2., (
length - clen) / 2.)};
171 strd = &(strd->subtract((*box) << GeoTrf::Translate3D(cxpos, 0., cypos)));
178 if ((stname ==
"BMS" && std::abs(zi) == 5) || (stname ==
"BMS" && std::abs(zi) == 1 &&
fi != 3)) {
181 double cutthick = 0.;
182 double top_edge = 0.;
186 cutlen =
length - top_edge;
187 if ((
comp->posy != 0 && cutlen > 0.1) ||
comp->dy > 0.75 *
length) {
188 cutthick =
comp->GetThickness(mysql) + 1.;
192 GeoIntrusivePtr<GeoShape> box1{
new GeoBox(cutthick / 2., (
longWidth + 2.) / 2., cutlen)};
193 strd = &(strd->subtract((*box1) << GeoTrf::Translate3D((totthick - cutthick) / 2., 0.,
length / 2.)));
199 bool testEIL = (stname ==
"EIL" && std::abs(zi) != 1 && (std::abs(zi) != 4 ||
fi == 0 ||
fi == 4));
201 if ((
m_enableFineClashFixing && (stname ==
"BML" || stname ==
"BIL" || stname ==
"BOL" || stname ==
"BMS" || stname ==
"BIS" || stname ==
"BOS")) || testEIL) {
202 double root3 = 1.7320508;
204 double mdt_half_thick = -1.;
210 int mdt_index[4] = {0, 0, 0, 0};
213 if (
comp->name.compare(0,3,
"MDT") == 0) {
220 GeoIntrusivePtr<GeoShape> box{
new GeoBox((totthick + 2.) / 2., (
longWidth + 2.) / 2., halfpitch)};
221 GeoIntrusivePtr<const GeoShape> frontcyl{
new GeoTube(0.0, halfpitch + 0.001,
longWidth / 2.)};
223 GeoIntrusivePtr<const GeoShape> backcyl{
new GeoTube(0.0, halfpitch - 0.001, (
longWidth + 2.) / 2.)};
228 strd = &(strd->subtract((*box) << GeoTrf::Translate3D(0., 0.,
length / 2.)));
232 mdt_half_thick =
comp->GetThickness(mysql) / 2.;
233 mdt_pos = -totthick / 2. +
comp->posz + mdt_half_thick;
234 mdt_pos += amdbOrigine_along_thickness;
235 xtube1 =
sign * (mdt_half_thick - (root3 + 1.) * halfpitch);
236 xtube2 =
sign * (mdt_half_thick - (3 * root3 + 1.) * halfpitch);
237 strd = &(strd->add((*frontcyl) << GeoTrf::Translate3D(mdt_pos + xtube1, 0.,
length / 2. - halfpitch)));
238 strd = &(strd->subtract((*backcyl) << GeoTrf::Translate3D(mdt_pos + xtube1, 0., -
length / 2.)));
240 if (stname ==
"BIL" || (stname ==
"BIS" && std::abs(zi) != 8) || testEIL) {
241 strd = &(strd->add((*frontcyl) << GeoTrf::Translate3D(mdt_pos + xtube2, 0.,
length / 2. - halfpitch)));
242 strd = &(strd->subtract((*backcyl) << GeoTrf::Translate3D(mdt_pos + xtube2, 0., -
length / 2.)));
248 if (stname !=
"EIL") {
249 if (zi < 0 && !is_mirrored)
258 if (zi < 0 && !is_mirrored && stName[0] ==
'B') {
260 amdbOrigine_along_length += halfpitch;
263 ATH_MSG_VERBOSE(
"amdb origine: in the length direction = " << amdbOrigine_along_length
264 <<
" in the thickness direction = " << amdbOrigine_along_thickness);
267 ATH_MSG_DEBUG(
"Station " << stName <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" will be described as Assembly" );
275 if (stName.compare(0, 3,
"BOG") == 0 && (
manager->IncludeCutoutsBogFlag() ||
manager->IncludeCutoutsFlag())) {
277 ATH_MSG_VERBOSE(
"amdb org: length= " << amdbOrigine_along_length <<
" thickness= " << amdbOrigine_along_thickness );
279 std::string statType = stName.substr(0, 3);
281 ATH_MSG_DEBUG(
"Station " << stName <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" has components with cutouts " );
285 bool foundCutouts =
false;
296 if (std::abs(
cut->dx - 600.7) < 0.1) {
301 if (std::abs(
cut->dx + 600.7) < 0.1) {
306 if (std::abs(
cut->lengthY - 180.2) < 0.001) {
309 if (std::abs(
cut->dy - 1019.8) < 0.001) {
310 cut->dy = 1216.4185 -
cut->lengthY;
313 cut->setThickness(totthick * 1.01);
315 (
cut->ijob ==
c->index)) {
327 if (stName.compare(0, 1,
"T") == 0 && stName.compare(2, 1,
"E") == 0 && stName.compare(1, 1,
"4") != 0) {
328 GeoTrd *strdoverlap =
new GeoTrd(totthick / 4, totthick / 4,
width / 2,
longWidth / 2, 400. / 2);
329 strd = &(strd->subtract((*strdoverlap) << GeoTrf::Translate3D(-totthick / 4., 0., -
length / 2 + 400. / 2.)));
332 const GeoMaterial *mtrd =
nullptr;
338 GeoLogVol *ltrd =
new GeoLogVol(std::string(stName) +
"_Station", strd, mtrd);
339 GeoPhysVol *ptrd =
new GeoPhysVol(ltrd);
341 double ypos{0.}, zpos{0.}, xpos{0.}, irad{0.};
342 std::array<int, 2> ndbz{0, 0};
345 int nDoubletR{0}, nRpc{0}, nTgc{0}, nCsc{0}, nMdt{0};
346 double previous_depth = 0.;
347 ATH_MSG_VERBOSE(
" Station Name = " << stName <<
" fi/zi " <<
fi <<
"/" << zi <<
" defining the n. of DoubletR to " );
351 std::string_view cn = std::string_view(
d->name).substr(0, 3);
360 if (!(stname.compare(0, 2,
"BI") == 0) && nDoubletR == 1 && nRpc > 1 &&
depth * previous_depth < 0)
364 previous_depth =
depth;
376 ATH_MSG_DEBUG(
" " << nDoubletR<<
" nMdt/Rpc/Tgc/Csc " << nMdt <<
"/" << nRpc <<
"/" << nTgc <<
"/" << nCsc );
381 double LBheight{0.}, LBwidth{0.}, LByShift{0.};
382 std::array<double, 2> LBpos{-1, -1};
385 std::string_view cname = std::string_view(
c->name).substr(0, 2);
388 LByShift =
lb->yShift;
391 LBpos[numLB] =
c->posy +
c->dy / 2.;
392 LBheight =
lb->height;
401 std::string_view cname = std::string_view(
c->name).substr(0, 3);
402 if (cname ==
"CRO" || cname ==
"CMI" || cname ==
"CHV") {
412 std::string CMIcomponentNumber =
"";
415 std::string_view cn = std::string_view(
d->name).substr(0, 3);
417 CMIcomponentNumber = (
d->name).substr(3, 2);
424 std::string_view cn = std::string_view(
d->name).substr(0, 2);
430 ATH_MSG_ERROR(
"MuonChamber :: cannot associate a CMI subtype to the LB component " );
436 if (stName.compare(0, 1,
"B") == 0) {
437 mstat =
new MuonStation(stName.substr(0, 3),
width, totthick,
length,
longWidth, totthick,
length, zi,
fi + 1,
438 (zi < 0 && !is_mirrored));
440 mstat =
new MuonStation(stName.substr(0, 3),
width,
length, totthick,
longWidth,
length, totthick, zi,
fi + 1,
441 (zi < 0 && !is_mirrored));
443 mstat->setPhysVol(ptrd);
444 manager->addMuonStation(std::unique_ptr<MuonStation>(mstat));
445 ATH_MSG_DEBUG(
" Building a MuonStation for this MuonChamber "
446 <<
m_station->
GetName() <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" is_mirrored " << is_mirrored);
452 ATH_MSG_VERBOSE(
" Component index " <<
c->index <<
" in loop for " << stName <<
" " << stationType <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" cName "
453 <<
c->name <<
" thickness " <<
c->GetThickness(mysql) <<
" length " <<
c->dy <<
" w, lw " <<
c->dx1 <<
" " <<
c->dx2 );
454 ATH_MSG_VERBOSE(
" Component local (amdb) coords " <<
c->posx <<
" " <<
c->posy <<
" " <<
c->posz );
456 ypos = -
thickness / 2. +
c->posz +
c->GetThickness(mysql) / 2.;
460 ypos = -
thickness / 2. + (
c->posz + amdbOrigine_along_thickness) +
c->GetThickness(mysql) / 2.;
461 zpos = -
length / 2. + amdbOrigine_along_length +
c->posy +
c->dy / 2.;
464 const std::string &techname =
c->name;
465 std::string_view
type = std::string_view(techname).substr(0, 3);
467 GeoVPhysVol *lv =
nullptr;
468 GeoVPhysVol *lvd =
nullptr;
469 GeoVPhysVol *lvs =
nullptr;
470 GeoVPhysVol *lvo =
nullptr;
471 GeoFullPhysVol *lvm =
nullptr;
472 GeoFullPhysVol *lvr =
nullptr;
473 GeoFullPhysVol *lvt =
nullptr;
474 GeoFullPhysVol *lvc =
nullptr;
479 std::string statType = stName.substr(0, 3);
480 double cthickness =
c->GetThickness(mysql);
482 std::vector<Cutout *> vcutdef;
483 std::vector<std::unique_ptr<Cutout>> vcutdef_todel;
486 cut->setThickness(cthickness * 1.01);
490 double tempdx =
cut->dx;
491 double tempdy =
cut->dy;
492 double templengthY =
cut->lengthY;
496 if (stName.compare(0, 3,
"BOG") == 0) {
498 cut->lengthY = templengthY + 31.;
504 if (std::abs(
cut->dead1) > 1. && techname ==
"MDT03")
509 cut->lengthY = templengthY;
524 if (stName.compare(0, 3,
"BMS") == 0) {
526 if (std::abs(zi) == 1) {
529 if (
type ==
"RPC" ||
type ==
"DED") {
530 cut->widthXl += 2 * margin;
531 cut->widthXs += 2 * margin;
533 cut->lengthY += 2 * margin;
548 if (stName.compare(0, 3,
"BOS") == 0 && zi == -6 &&
type ==
"MDT") {
549 cut->dy =
c->dy -
cut->dy -
cut->lengthY - halfpitch;
551 if (techname ==
"MDT03")
561 if (
type ==
"MDT" && (is_mirrored || zi < 0) && stName.compare(0, 1,
"B") == 0) {
566 cutmirr->
dx = -cutmirr->
dx;
569 vcutdef.push_back(cutmirr);
570 vcutdef_todel.emplace_back(cutmirr);
571 ATH_MSG_VERBOSE(
"adding for application mirrored cut \n" << *cutmirr );
573 }
else if (
type ==
"RPC" ||
type ==
"DED") {
576 if (stName.compare(0, 3,
"BMS") == 0 && zi == 4 && (
c->index == 20 ||
c->index == 21 ||
c->index == 24 ||
c->index == 25)) {
577 cutRpcType->
dy = 1102.5;
580 if (stName.compare(0, 3,
"BOS") == 0 && zi == 6 &&
type ==
"DED")
581 cutRpcType->
dy = 706.;
583 cutRpcType->
dy = cutRpcType->
dy -
c->posy;
584 cutRpcType->
dx = cutRpcType->
dx -
c->posx;
588 if (
rp->iswap == -1) {
589 cutRpcType->
dy =
c->dy - (cutRpcType->
dy + cutRpcType->
lengthY);
593 ATH_MSG_VERBOSE(
" Rpc or ded cutout redefined as follows \n" << *cutRpcType );
594 vcutdef.push_back(cutRpcType);
595 vcutdef_todel.emplace_back(cutRpcType);
596 }
else if (
type ==
"TGC") {
601 tgccut->
dy -=
c->posy;
604 vcutdef.push_back(tgccut);
605 vcutdef_todel.emplace_back(tgccut);
607 vcutdef.push_back(
cut);
613 ATH_MSG_DEBUG(
c->name <<
" of station " << stName <<
" at fi/zi " <<
fi + 1 <<
"/" << zi <<
" has " << ncutouts <<
" cutouts " );
618 GeoTransform *xfcomponent{
nullptr};
619 GeoAlignableTransform *xfaligncomponent{
nullptr};
623 if (stName.compare(0, 1,
"B") != 0 && is_mirrored)
624 mstat->setxAmdbCRO(-xpos);
626 mstat->setxAmdbCRO(xpos);
630 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos) * GeoTrf::TranslateY3D(xpos);
632 if (zi < 0 && !is_mirrored && stName[0] ==
'B') {
635 htcomponent = htcomponent * GeoTrf::TranslateZ3D(halfpitch);
640 if (zi < 0 && stName.compare(0, 3,
"BOG") == 0 && is_mirrored) {
648 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
649 std::string
key =std::string( stName) + techname;
653 bool mdtCutoutFlag = ((stname ==
"BOS" && std::abs(zi) == 6) || stname ==
"BMG" || techname ==
"MDT14" || (stname ==
"BMS" && (std::abs(zi) == 1 &&
fi == 3)) ||
654 (stname ==
"EMS" && (std::abs(zi) == 1 || std::abs(zi) == 3)));
655 if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
657 }
else if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG")) == 0) && zi < 0) {
662 if (fpv ==
nullptr) {
663 std::unique_ptr<Mdt>
r = std::make_unique<Mdt>(mysql,
c, stName + techname);
664 ATH_MSG_DEBUG(
" Building an MDT for station " <<
key <<
" component name is " <<
c->name <<
665 " stName "<<stName<<
" techName: "<<techname<<
" manager->IncludeCutoutsFlag() "
666 <<
manager->IncludeCutoutsFlag() <<
" manager->IncludeCutoutsBogFlag() " <<
manager->IncludeCutoutsBogFlag() );
669 if ((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) {
670 lvm =
r->build(matManager, mysql, vcutdef);
672 lvm =
r->build(matManager, mysql);
676 GeoFullPhysVol *rfpv = (GeoFullPhysVol *)fpv;
677 ATH_MSG_VERBOSE(
" This MDT for station " <<
key <<
" component name is " <<
c->name <<
" already exists; clone it " );
681 }
else if (
type ==
"SPA" &&
manager->MinimalGeoFlag() == 0) {
682 if (techname ==
"SPA01" && stName.compare(0, 1,
"C") == 0) {
683 ATH_MSG_DEBUG(
"Ficticious spacer SPA01 in CSC chamber - skip it " );
689 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos);
690 xfcomponent =
new GeoTransform(htcomponent);
691 std::string
key = std::string(stName) + techname;
692 if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
694 }
else if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
699 if (fpv ==
nullptr) {
700 std::unique_ptr<Spacer>
r = std::make_unique<Spacer>(mysql,
c);
701 ATH_MSG_DEBUG(
" Building a SPA for m_station "<<
key <<
" component name is " <<
c->name );
702 if (
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) {
703 lv =
r->build(matManager, 1);
705 lv =
r->build(matManager);
712 }
else if ((
type ==
"CHV" ||
type ==
"CRO" ||
type ==
"CMI" ||
type ==
"LB0" ||
type ==
"LBI") &&
manager->MinimalGeoFlag() == 0) {
713 std::unique_ptr<SpacerBeam>
r = std::make_unique<SpacerBeam>(mysql,
c);
714 BeamHeight =
r->height;
716 double xpos = (
c->posz + amdbOrigine_along_thickness) -
thickness / 2. + BeamHeight / 2.;
717 if (
type.compare(0, 2,
"LB") == 0)
721 if (std::abs(
c->excent) > 0.001) {
730 if (stName ==
"EML1" || stName ==
"EML6") {
731 if ((
c->dx1 >
width) && zpos < 0.) {
734 if ((
c->dx1 /
longWidth) > 0.98 && zpos > 0.) {
743 if (stname ==
"BOL" && zi == 1 && (
fi + 1) == 3) {
744 r->length =
length - halfpitch;
745 zpos = -halfpitch / 2.;
750 htcomponent = GeoTrf::Translate3D(xpos, ypos, zpos) * GeoTrf::RotateX3D(
angle);
752 htcomponent = GeoTrf::Translate3D(xpos, -ypos, zpos) * GeoTrf::RotateX3D(-
angle);
754 xfcomponent =
new GeoTransform(htcomponent);
756 std::string
key = stName + techname;
757 if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
759 }
else if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
763 if (
type.substr(0, 2) ==
"LB")
766 ATH_MSG_DEBUG(
" Building a SpacerBeam for m_station "<<
key <<
" component name is "<<
c->name );
768 if (fpv ==
nullptr || (stName.compare(0, 3,
"BOG") == 0 &&
type ==
"CMI")) {
769 if (stName.compare(0, 3,
"BOG") == 0) {
770 ATH_MSG_VERBOSE(
" Building a SpacerBeam for station " <<
key <<
" component name is " <<
c->name );
772 if (
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) {
773 lvo =
r->build(matManager, 1, is_barrel);
775 lvo =
r->build(matManager, is_barrel);
782 if (stName.compare(0, 3,
"BOG") == 0)
783 ATH_MSG_VERBOSE(
" This spacerbeam for station " <<
key <<
" component name is " <<
c->name <<
" already exists; re-use it " );
787 }
else if (
type ==
"RPC") {
790 int ndivy =
rp->ndivy;
791 int ndivz =
rp->ndivz;
793 if (ndivz != 1 || ndivy != 1) {
794 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
797 double xpos =
c->posx;
802 ATH_MSG_VERBOSE(
" In station " << stName <<
" with " << nDoubletR <<
" doubletR,"
803 <<
" RPC " << (
c->name).substr(3, 2) <<
" has swap flag = " <<
rp->iswap <<
" ypos, zpos " << ypos <<
" " << zpos <<
" " );
805 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
806 if (
rp->iswap == -1) {
809 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
813 bool rpcCutoutFlag = (stname ==
"BOS" && std::abs(zi) == 6) || (stname ==
"BMS" && (std::abs(zi) == 2 || std::abs(zi) == 4 || std::abs(zi) == 6)) ||
814 (stname ==
"BMS" && std::abs(zi) == 1 &&
fi == 3);
815 std::string
key = stName + techname;
816 if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
819 }
else if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
824 if (fpv ==
nullptr) {
825 std::unique_ptr<Rpc>
r = std::make_unique<Rpc>(mysql,
c);
826 r->setLogVolName(std::string(stName) + techname);
827 if (stName.find(
"BI") != std::string::npos) {
828 std::map<std::string, float>::const_iterator yItr = rpcYTrans.find(techname);
829 if (yItr != rpcYTrans.end())
830 r->y_translation = yItr->second;
831 std::map<std::string, float>::const_iterator zItr = rpcZTrans.find(techname);
832 if (zItr != rpcZTrans.end())
833 r->z_translation = zItr->second;
836 if ((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) {
837 lvr =
r->build(matManager, mysql,
manager->MinimalGeoFlag(), 1, vcutdef);
839 lvr =
r->build(matManager, mysql,
manager->MinimalGeoFlag());
844 GeoFullPhysVol *rfpv = (GeoFullPhysVol *)fpv;
848 }
else if (
type ==
"DED" &&
manager->MinimalGeoFlag() == 0) {
849 double xpos =
c->posx;
852 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
854 xfcomponent =
new GeoTransform(htcomponent);
856 bool dedCutoutFlag = (stname ==
"BOS" && std::abs(zi) == 6) || (stname ==
"BMS" && (std::abs(zi) == 2 || std::abs(zi) == 4 || std::abs(zi) == 6)) ||
857 (stname ==
"BMS" && std::abs(zi) == 1 &&
fi == 3);
858 std::string
key = std::string(stName) + techname;
859 if (((
manager->IncludeCutoutsFlag() && dedCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
862 }
else if (((
manager->IncludeCutoutsFlag() && dedCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
869 if (fpv ==
nullptr) {
870 std::unique_ptr<Ded>
r = std::make_unique<Ded>(mysql,
c);
871 ATH_MSG_VERBOSE(
" Building a DED for station " <<
key <<
" component name is " <<
c->name );
872 if ((
manager->IncludeCutoutsFlag() && dedCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) {
873 lvd =
r->build(matManager, mysql, 1, vcutdef);
875 lvd =
r->build(matManager, mysql);
881 ATH_MSG_VERBOSE(
" Re-using DED for station " <<
key <<
" component name is " <<
c->name );
884 }
else if (
type ==
"SUP" &&
manager->MinimalGeoFlag() == 0) {
890 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
891 std::string
key = std::string(stName) + techname;
892 if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
894 }
else if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
899 if (fpv ==
nullptr) {
905 }
else if (
type ==
"TGC") {
908 irad = tgInner->
posy;
910 double orad = tgOuter->
posy + tgOuter->
dy;
911 double start = -(orad - irad) / 2. + (tg->
posy - irad) + tg->
dy / 2;
913 htcomponent = GeoTrf::TranslateX3D(xstart + tg->
posz) * GeoTrf::TranslateZ3D(
start);
914 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
917 std::string
key = std::string(stName) + techname;
918 if (
manager->IncludeCutoutsFlag()) {
930 sprintf(chswidth,
"%i",
int(10 *
c->dx1));
934 if (fpv ==
nullptr) {
935 std::unique_ptr<Tgc>
t = std::make_unique<Tgc>(mysql,
c);
936 t->setLogVolName(std::string(stName) + techname);
937 if (
manager->IncludeCutoutsFlag()) {
938 lvt =
t->build(matManager, mysql,
manager->MinimalGeoFlag(), 1, vcutdef);
940 lvt =
t->build(matManager, mysql,
manager->MinimalGeoFlag());
944 GeoFullPhysVol *rfpv = (GeoFullPhysVol *)fpv;
948 }
else if (
type ==
"CSC") {
949 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos);
950 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
952 std::string
key = std::string(stName) + techname;
953 if (
manager->IncludeCutoutsFlag() && zi >= 0) {
955 }
else if (
manager->IncludeCutoutsFlag() && zi < 0) {
960 if (fpv ==
nullptr) {
961 std::unique_ptr<Csc>
t = std::make_unique<Csc>(mysql,
c);
962 t->setLogVolName(std::string(stName) + techname);
964 if (
manager->IncludeCutoutsFlag()) {
965 lvc =
t->build(matManager, mysql,
manager->MinimalGeoFlag(), 1, vcutdef);
967 lvc =
t->build(matManager, mysql,
manager->MinimalGeoFlag());
972 GeoFullPhysVol *rfpv = (GeoFullPhysVol *)fpv;
984 if (lvm &&
manager->mdtIdHelper()) {
986 int stationPhi =
fi + 1;
994 GeoNameTag *
nm =
new GeoNameTag(stag);
995 ptrd->add(
new GeoIdentifierTag(
c->index));
998 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
1000 ptrd->add(xfaligncomponent);
1003 std::unique_ptr<MdtReadoutElement>
det = std::make_unique<MdtReadoutElement>(lvm, stName,
manager);
1006 det->setHasCutouts(ncutouts > 0);
1007 det->setNMdtInStation(nMdt);
1009 det->setIdentifier(
id);
1010 det->setMultilayer(ml);
1011 det->setParentStationPV(PVConstLink(ptrd));
1012 det->setParentMuonStation(mstat);
1017 mstat->setBlineFixedPointInAmdbLRS(
c->posx,
c->posy,
c->posz);
1020 if (
c->posy < b0.y())
1021 mstat->setBlineFixedPointInAmdbLRS(b0.x(),
c->posy, b0.z());
1024 int jobIndex =
c->index;
1026 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1027 ATH_MSG_DEBUG( std::string(stName + techname) <<
" trying to build a MDT Id from stType/eta/phi/ml/tl/t " << stationType <<
"/" << stationEta <<
"/"
1028 << stationPhi <<
"/" << ml <<
"/" << tubel <<
"/" <<
tube <<
endmsg <<
" Copy number is " <<
c->index <<
" tagName " << stag );
1031 manager->addMdtReadoutElement(std::move(
det));
1034 if (lvc &&
manager->cscIdHelper()) {
1036 int stationEta = zi;
1037 int stationPhi =
fi + 1;
1038 int chamberLayer = 1;
1041 std::string stag =
"cl[" +
MuonGM::buildString(chamberLayer, 0) +
"]" + techname +
"component";
1042 GeoNameTag *
nm =
new GeoNameTag(stag);
1043 ptrd->add(
new GeoIdentifierTag(
c->index));
1046 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
1048 ptrd->add(xfaligncomponent);
1051 std::unique_ptr<CscReadoutElement>
det = std::make_unique<CscReadoutElement>(lvc, stName,
manager);
1056 det->setHasCutouts(ncutouts > 0);
1057 Identifier id = csc_id->
channelID(stationType, stationEta, stationPhi, chamberLayer, 1, 0, 1);
1058 det->setIdentifier(
id);
1059 det->setChamberLayer(chamberLayer);
1060 det->setParentStationPV(PVConstLink(ptrd));
1061 det->setParentMuonStation(mstat);
1063 int jobIndex =
c->index;
1065 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1066 ATH_MSG_DEBUG( stName << techname <<
" trying to build a CSC Id from stType/eta/phi/ml " << stationType <<
"/" << stationEta <<
"/"
1067 << stationPhi <<
"/" << chamberLayer <<
"/ and /1/0/1" <<
endmsg <<
" Copy number is " <<
c->index <<
" tagName " << stag );
1070 manager->addCscReadoutElement(std::move(
det));
1073 if (lvt &&
manager->tgcIdHelper()) {
1074 ATH_MSG_DEBUG(
" Adding a TGC chamber to the tree zi,fi, is_mirrored " << zi <<
" " <<
fi + 1 <<
" " << is_mirrored );
1081 stationEta = tg->
index;
1083 stationEta = -stationEta;
1086 int ttag = 1000 * stationPhi + tg->
index;
1087 std::string stag =
"stPhiJob[" +
MuonGM::buildString(ttag, 0) +
"]" + techname +
"tgccomponent";
1088 GeoNameTag *
nm =
new GeoNameTag(stag);
1097 ptrd->add(
new GeoIdentifierTag(geoid));
1100 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
1103 ptrd->add(xfaligncomponent);
1106 std::unique_ptr<TgcReadoutElement>
det = std::make_unique<TgcReadoutElement>(lvt, stName,
manager);
1109 det->setHasCutouts(ncutouts > 0);
1111 det->setIdentifier(
id);
1112 det->setParentStationPV(PVConstLink(ptrd));
1113 det->setParentMuonStation(mstat);
1115 int jobIndex =
c->index;
1117 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1119 ATH_MSG_DEBUG( stName << techname <<
" trying to build a TGC Id from stType/eta/phi " << stationType <<
"/" << stationEta <<
"/" << stationPhi
1120 <<
"/ and /1/0/1" <<
endmsg <<
" Copy number is " << geoid <<
" tagName = " << stag );
1121 manager->addTgcReadoutElement(std::move(
det));
1126 int ndivy =
rp->ndivy;
1127 int ndivz =
rp->ndivz;
1129 if (ndivz != 1 || ndivy != 1) {
1130 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
1133 double zpos = -
length / 2. +
c->posy +
c->dy / 2.;
1134 double xpos =
c->posx;
1142 int stationEta = zi;
1143 int stationPhi =
fi + 1;
1147 if (nRpc > 1 && nDoubletR == 2 && ypos > 0.)
1152 if (stname.find(
"BI") != std::string::npos) {
1153 if (stname.find(
"BIS") != std::string::npos) {
1155 if (std::abs(stationEta)>= 7){
1156 ATH_MSG_DEBUG(
"BIS78 station eta: "<<stationEta<<
" phi: "<<stationPhi<<
" dR: "<<
doubletR<<
" dZ:"<< doubletZ <<
" rp: "<<
rp->posz);
1158 if (std::abs(stationEta) >= 7 &&
rp->posz > 80)
1165 if (stname.find(
"BIL") != std::string::npos && std::abs(stationEta) < 7 && std::abs(stationEta) != 2 && std::abs(stationEta) != 5) {
1172 if (zi <= 0 && !is_mirrored) {
1200 if (zi < 0 && is_mirrored && doubletZ == 3) {
1204 }
else if (zi < 0 && is_mirrored && doubletZ == 2 &&
doubletR == 1 && stName ==
"BMS6") {
1211 int measuresPhi = 0;
1216 int tag = doubletZ +
doubletR * 100 + dbphi * 1000;
1217 if (
rp->iswap == -1)
1224 if (
rp->iswap == -1)
1229 GeoNameTag *
nm =
new GeoNameTag(stag);
1230 ptrd->add(
new GeoIdentifierTag(geoid));
1233 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
1235 ptrd->add(xfaligncomponent);
1238 std::unique_ptr<RpcReadoutElement>
det = std::make_unique<RpcReadoutElement>(lvr, stName, zi,
fi + 1, is_mirrored,
manager);
1242 det->setIdentifier(
id);
1243 det->setHasCutouts(ncutouts > 0);
1245 det->setDoubletZ(doubletZ);
1248 ATH_MSG_DEBUG( stName << techname <<
" trying to build a RPC Id from stType/eta/phi/dbR/dbZ/dbP " << stationType <<
"/" << stationEta <<
"/"
1250 <<
" Copy number " << geoid <<
" tagName= " << stag );
1251 det->setParentStationPV(PVConstLink(ptrd));
1252 det->setParentMuonStation(mstat);
1254 int jobIndex =
c->index;
1256 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1259 if (stName.find(
"BI") != std::string::npos) {
1260 std::map<std::string, float>::const_iterator yItr = rpcYTrans.find(techname);
1261 if (yItr != rpcYTrans.end())
1262 det->setYTranslation(yItr->second);
1263 std::map<std::string, float>::const_iterator zItr = rpcZTrans.find(techname);
1264 if (zItr != rpcZTrans.end())
1265 det->setZTranslation(zItr->second);
1271 manager->addRpcReadoutElement(std::move(
det));
1275 std::string cname =
c->name;
1276 ATH_MSG_VERBOSE(
" yes, the component is a SupComponent named " << cname );
1277 GeoNameTag *
nm =
new GeoNameTag(stName +
"_stName " + techname +
" supcomponent");
1278 ptrd->add(
new GeoIdentifierTag(
c->index));
1280 ptrd->add(xfcomponent);
1290 GeoNameTag *
nm =
new GeoNameTag(stName +
"_stName " + techname +
" dedcomponent");
1291 ptrd->add(
new GeoIdentifierTag(
c->index));
1294 ptrd->add(xfcomponent);
1306 GeoNameTag *
nm =
new GeoNameTag(stName +
"_stName " + techname +
" component");
1307 ptrd->add(
new GeoIdentifierTag(
c->index));
1310 ptrd->add(xfcomponent);
1315 GeoNameTag *
nm =
new GeoNameTag(stName +
"_stName " + techname +
" component");
1316 ptrd->add(
new GeoIdentifierTag(
c->index));
1318 ptrd->add(xfcomponent);
1323 mstat->updateBlineFixedPointInAmdbLRS();
1331 re->m_Ssize =
cc->dx1;
1332 re->m_LongSsize =
cc->dx2;
1333 re->m_Rsize =
cc->dy;
1334 re->m_LongRsize =
cc->dy;
1335 re->m_Zsize =
cc->GetThickness(mysql);
1336 re->m_LongZsize =
cc->GetThickness(mysql);
1337 re->m_RlengthUpToMaxWidth =
cc->maxwdy;
1338 re->m_excent =
cc->excent;
1341 std::string tname =
cc->name;
1342 re->setTechnologyName(tname);
1344 if (
ip.isAssigned) {
1345 re->setStationS(
ip.shift);
1347 ATH_MSG_ERROR(
" MuonChamber::setCscReadoutGeom: position not found " );
1361 re->m_Etastripwidth =
re->m_Etastrippitch;
1362 re->m_Phistripwidth =
re->m_Phistrippitch;
1368 re->m_Ssize =
cc->dx1;
1369 re->m_LongSsize =
cc->dx2;
1371 if (
re->m_inBarrel) {
1372 re->m_Rsize =
cc->GetThickness(mysql);
1373 re->m_LongRsize =
cc->GetThickness(mysql);
1374 re->m_Zsize =
cc->dy;
1375 re->m_LongZsize =
cc->dy;
1377 re->m_Rsize =
cc->dy;
1378 re->m_LongRsize =
cc->dy;
1379 re->m_Zsize =
cc->GetThickness(mysql);
1380 re->m_LongZsize =
cc->GetThickness(mysql);
1383 re->m_cutoutShift =
cc->cutoutTubeXShift;
1384 re->m_tubelenStepSize =
cc->tubelenStepSize;
1386 if (
ip.isAssigned) {
1387 re->setStationS(
ip.shift);
1389 ATH_MSG_ERROR(
" MuonChamber::setMdtReadoutGeom: position not found " );
1393 std::string tname =
cc->name;
1394 re->setTechnologyName(tname);
1397 re->m_tubepitch = thism->
pitch;
1398 re->m_tubelayerpitch = thism->
y[1] - thism->
y[0];
1400 re->m_deadlength =
cc->deadx;
1404 if (
re->m_inBarrel) {
1405 re->m_ntubesperlayer =
int(
re->m_Zsize /
re->m_tubepitch);
1407 re->m_ntubesinastep =
re->m_ntubesperlayer;
1408 re->m_tubelength[0] =
re->m_Ssize;
1410 re->m_ntubesperlayer =
int(
re->m_Rsize /
re->m_tubepitch);
1411 re->m_nsteps =
int(
re->m_Rsize /
re->m_tubelenStepSize);
1412 re->m_ntubesinastep =
int(
re->m_tubelenStepSize /
re->m_tubepitch);
1413 re->m_tubelength[0] =
re->m_Ssize;
1414 double diff = (
re->m_LongSsize -
re->m_Ssize) * (
re->m_LongRsize -
re->m_tubepitch / 2.) /
re->m_LongRsize;
1415 for (
int is = 0; is <
re->m_nsteps; ++is) {
1416 double len =
re->m_Ssize + is *
diff /
re->m_nsteps;
1417 re->m_tubelength[is] = len;
1421 for (
int tl = 0;
tl <
re->m_nlayers; ++
tl) {
1422 re->m_firstwire_x[
tl] = thism->
x[
tl];
1423 re->m_firstwire_y[
tl] = thism->
y[
tl];
1431 re->m_Ssize =
cc->dx1;
1432 re->m_LongSsize =
cc->dx2;
1433 re->m_Rsize =
cc->GetThickness(mysql);
1434 re->m_LongRsize =
cc->GetThickness(mysql);
1435 re->m_Zsize =
cc->dy;
1436 re->m_LongZsize =
cc->dy;
1438 re->m_hasDEDontop =
true;
1439 if (
cc->iswap == -1)
1440 re->m_hasDEDontop =
false;
1442 if (
ip.isAssigned) {
1443 re->setStationS(
ip.shift);
1445 ATH_MSG_ERROR(
" MuonChamber::setRpcReadoutGeom: position not found " );
1449 std::string tname =
cc->name;
1450 re->setTechnologyName(tname);
1459 if (
re->getStationName().find(
"BI") != std::string::npos) {
1460 re->setNumberOfLayers(3);
1465 if (
re->numberOfLayers() == 3) {
1466 constexpr
double rpc3GapLayerThickness = 11.8;
1470 re->m_gasGap_xPos[
gasGap -1] = (
gasGap - 2) * rpc3GapLayerThickness - 0.74;
1477 if (!
re->m_hasDEDontop) {
1484 re->m_nphistripsperpanel =
int((
re->m_Ssize /
re->m_nphistrippanels) /
re->m_phistrippitch);
1485 if (
re->getStationName().compare(0, 3,
"BME") != 0) {
1486 re->m_nphistripsperpanel-=(
re->m_nphistripsperpanel % 8) ;
1488 re->m_netastripsperpanel =
int((
re->m_Zsize) /
re->m_etastrippitch);
1489 re->m_netastripsperpanel -= (
re->m_netastripsperpanel % 8);
1491 re->m_phipaneldead =
re->m_Ssize /
re->m_nphistrippanels -
1492 re->m_nphistripsperpanel *
re->m_phistrippitch +
1494 re->m_phipaneldead =
re->m_phipaneldead / 2.;
1495 re->m_etapaneldead =
re->m_Zsize -
re->m_netastripsperpanel *
re->m_etastrippitch + genericRpc->
stripSeparation;
1496 re->m_etapaneldead =
re->m_etapaneldead / 2.;
1497 re->m_phistriplength =
re->m_LongZsize;
1498 re->m_etastriplength =
re->m_LongSsize /
re->m_nphistrippanels;
1500 re->m_first_phistrip_s[0] = -
re->m_Ssize / 2. +
re->m_phipaneldead +
re->m_phistripwidth / 2.;
1501 if (
re->m_nphistrippanels == 2) {
1502 re->m_first_phistrip_s[1] =
re->m_phipaneldead +
re->m_phistripwidth / 2.;
1506 re->m_phistrip_z = -
re->m_Zsize / 2. +
offset +
re->m_phistriplength / 2.;
1509 re->m_first_etastrip_z = -
re->m_Zsize / 2. +
re->m_etapaneldead +
re->m_etastripwidth / 2.;
1510 re->m_etastrip_s[0] = -
re->m_Ssize / 2. +
offset +
re->m_etastriplength / 2.;
1511 if (
re->m_nphistrippanels == 2) {
1512 re->m_etastrip_s[1] =
re->m_Ssize / 2. -
offset -
re->m_etastriplength / 2.;
1520 const std::string& stName) {
1522 re->setSsize(
cc->dx1);
1523 re->setLongSsize(
cc->dx2);
1524 re->setRsize(
cc->dy);
1525 re->setLongRsize(
cc->dy);
1526 re->setZsize(
cc->GetThickness(mysql));
1527 re->setLongZsize(
cc->GetThickness(mysql));
1530 re->setFrameThickness(genericTgc->
frame_h,
1534 const std::string &tname =
cc->name;
1536 re->setTechnologyName(tname);
1538 if (
ip.isAssigned) {
1539 re->setStationS(
ip.shift);
1541 throw std::runtime_error(
" MuonChamberLite::setTgcReadoutGeom position not found ");
1545 sprintf(
index,
"%i",
cc->index);
1547 re->setReadOutName(stName.substr(0, 4) +
'_' +
index);
1554 for (std::size_t
i = 0;
i < ncomp; ++
i) {
1555 double newpos = -
re->getZsize() / 2. + thist->
positions[
i] + thist->
tck[
i] / 2.;
1556 if ( thist->
materials[
i].find(
"TGCGas") != std::string::npos) {