112 ATH_MSG_VERBOSE(
" Building a MuonChamber for m_station " <<
m_station->
GetName() <<
" at zi, fi " << zi <<
" " << fi + 1 <<
" is_mirrored " << is_mirrored
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") {
155 StandardComponent *
comp =
nullptr;
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)) {
179 StandardComponent *
comp =
nullptr;
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;
203 StandardComponent *
comp =
nullptr;
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);
314 if ((
cut->subtype == mysql.allocPosFindSubtype(std::string(statType), fi, zi)) && (
cut->icut == mysql.allocPosFindCutout(std::string(statType), fi, zi)) &&
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 PVLink 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);
387 const LBI *
lb =
dynamic_cast<const LBI *
>(mysql.GetTechnology(
c->name));
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") {
403 CbmComponent *ccbm =
static_cast<CbmComponent *
>(
c);
404 ccbm->lb_height = LBheight;
405 ccbm->lb_width = LBwidth;
406 ccbm->hole_pos1 = LBpos[0];
407 ccbm->hole_pos2 = LBpos[1];
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);
426 LbiComponent *lbic =
static_cast<LbiComponent *
>(
d);
428 lbic->associated_CMIsubtype = CMIcomponentNumber;
430 ATH_MSG_ERROR(
"MuonChamber :: cannot associate a CMI subtype to the LB component " );
435 MuonStation *mstat{
nullptr};
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 PVLink lv{}, lvd{}, lvs{}, lvo{};
468 GeoIntrusivePtr<GeoFullPhysVol> lvm{}, lvr{}, lvt{}, lvc{};
470 double BeamHeight{0.};
473 std::string statType =
stName.substr(0, 3);
474 double cthickness =
c->GetThickness(mysql);
476 std::vector<Cutout *> vcutdef;
477 std::vector<std::unique_ptr<Cutout>> vcutdef_todel;
480 cut->setThickness(cthickness * 1.01);
482 if ((
cut->subtype == mysql.allocPosFindSubtype(std::string(statType), fi, zi)) && (
cut->icut == mysql.allocPosFindCutout(std::string(statType), fi, zi)) && (
cut->ijob ==
c->index)) {
484 double tempdx =
cut->dx;
485 double tempdy =
cut->dy;
486 double templengthY =
cut->lengthY;
490 if (
stName.compare(0, 3,
"BOG") == 0) {
492 cut->lengthY = templengthY + 31.;
498 if (std::abs(
cut->dead1) > 1. && techname ==
"MDT03")
503 cut->lengthY = templengthY;
518 if (
stName.compare(0, 3,
"BMS") == 0) {
520 if (std::abs(zi) == 1) {
523 if (
type ==
"RPC" ||
type ==
"DED") {
524 cut->widthXl += 2 * margin;
525 cut->widthXs += 2 * margin;
527 cut->lengthY += 2 * margin;
542 if (
stName.compare(0, 3,
"BOS") == 0 && zi == -6 &&
type ==
"MDT") {
543 cut->dy =
c->dy -
cut->dy -
cut->lengthY - halfpitch;
545 if (techname ==
"MDT03")
555 if (
type ==
"MDT" && (is_mirrored || zi < 0) &&
stName.compare(0, 1,
"B") == 0) {
559 Cutout *cutmirr =
new Cutout(*
cut);
560 cutmirr->dx = -cutmirr->dx;
563 vcutdef.push_back(cutmirr);
564 vcutdef_todel.emplace_back(cutmirr);
565 ATH_MSG_VERBOSE(
"adding for application mirrored cut \n" << *cutmirr );
567 }
else if (
type ==
"RPC" ||
type ==
"DED") {
568 Cutout *cutRpcType =
new Cutout(*
cut);
570 if (
stName.compare(0, 3,
"BMS") == 0 && zi == 4 && (
c->index == 20 ||
c->index == 21 ||
c->index == 24 ||
c->index == 25)) {
571 cutRpcType->dy = 1102.5;
574 if (
stName.compare(0, 3,
"BOS") == 0 && zi == 6 &&
type ==
"DED")
575 cutRpcType->dy = 706.;
577 cutRpcType->dy = cutRpcType->dy -
c->posy;
578 cutRpcType->dx = cutRpcType->dx -
c->posx;
581 RpcComponent *
rp =
static_cast<RpcComponent *
>(
c);
582 if (
rp->iswap == -1) {
583 cutRpcType->dy =
c->dy - (cutRpcType->dy + cutRpcType->lengthY);
587 ATH_MSG_VERBOSE(
" Rpc or ded cutout redefined as follows \n" << *cutRpcType );
588 vcutdef.push_back(cutRpcType);
589 vcutdef_todel.emplace_back(cutRpcType);
590 }
else if (
type ==
"TGC") {
594 Cutout *tgccut =
new Cutout(*
cut);
595 tgccut->dy -=
c->posy;
598 vcutdef.push_back(tgccut);
599 vcutdef_todel.emplace_back(tgccut);
601 vcutdef.push_back(
cut);
607 ATH_MSG_DEBUG(
c->name <<
" of station " <<
stName <<
" at fi/zi " << fi + 1 <<
"/" << zi <<
" has " << ncutouts <<
" cutouts " );
612 GeoTransform *xfcomponent{
nullptr};
613 GeoAlignableTransform *xfaligncomponent{
nullptr};
617 if (
stName.compare(0, 1,
"B") != 0 && is_mirrored)
618 mstat->setxAmdbCRO(-xpos);
620 mstat->setxAmdbCRO(xpos);
624 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos) * GeoTrf::TranslateY3D(xpos);
626 if (zi < 0 && !is_mirrored &&
stName[0] ==
'B') {
629 htcomponent = htcomponent * GeoTrf::TranslateZ3D(halfpitch);
634 if (zi < 0 &&
stName.compare(0, 3,
"BOG") == 0 && is_mirrored) {
642 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
643 std::string
key =std::string(
stName) + techname;
647 bool mdtCutoutFlag = ((stname ==
"BOS" && std::abs(zi) == 6) || stname ==
"BMG" || techname ==
"MDT14" || (stname ==
"BMS" && (std::abs(zi) == 1 && fi == 3)) ||
648 (stname ==
"EMS" && (std::abs(zi) == 1 || std::abs(zi) == 3)));
649 if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
650 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
651 }
else if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG")) == 0) && zi < 0) {
652 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
656 if (fpv ==
nullptr) {
657 std::unique_ptr<Mdt>
r = std::make_unique<Mdt>(mysql,
c,
stName + techname);
658 ATH_MSG_DEBUG(
" Building an MDT for station " <<
key <<
" component name is " <<
c->name <<
659 " stName "<<
stName<<
" techName: "<<techname<<
" manager->IncludeCutoutsFlag() "
660 <<
manager->IncludeCutoutsFlag() <<
" manager->IncludeCutoutsBogFlag() " <<
manager->IncludeCutoutsBogFlag() );
663 if ((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) {
664 lvm =
r->build(matManager, mysql, vcutdef);
666 lvm =
r->build(matManager, mysql);
670 GeoFullPhysVol *rfpv =
static_cast<GeoFullPhysVol *
>(fpv);
671 ATH_MSG_VERBOSE(
" This MDT for station " <<
key <<
" component name is " <<
c->name <<
" already exists; clone it " );
675 }
else if (
type ==
"SPA" &&
manager->MinimalGeoFlag() == 0) {
676 if (techname ==
"SPA01" &&
stName.compare(0, 1,
"C") == 0) {
677 ATH_MSG_DEBUG(
"Ficticious spacer SPA01 in CSC chamber - skip it " );
683 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos);
684 xfcomponent =
new GeoTransform(htcomponent);
685 std::string
key = std::string(
stName) + techname;
686 if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
687 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
688 }
else if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
689 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
693 if (fpv ==
nullptr) {
694 std::unique_ptr<Spacer>
r = std::make_unique<Spacer>(mysql,
c);
695 ATH_MSG_DEBUG(
" Building a SPA for m_station "<<
key <<
" component name is " <<
c->name );
696 if (
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) {
697 lv =
r->build(matManager, 1);
699 lv =
r->build(matManager);
706 }
else if ((
type ==
"CHV" ||
type ==
"CRO" ||
type ==
"CMI" ||
type ==
"LB0" ||
type ==
"LBI") &&
manager->MinimalGeoFlag() == 0) {
707 std::unique_ptr<SpacerBeam>
r = std::make_unique<SpacerBeam>(mysql,
c);
708 BeamHeight =
r->height;
710 double xpos = (
c->posz + amdbOrigine_along_thickness) -
thickness / 2. + BeamHeight / 2.;
711 if (
type.compare(0, 2,
"LB") == 0)
715 if (std::abs(
c->excent) > 0.001) {
725 if ((
c->dx1 >
width) && zpos < 0.) {
728 if ((
c->dx1 /
longWidth) > 0.98 && zpos > 0.) {
737 if (stname ==
"BOL" && zi == 1 && (fi + 1) == 3) {
738 r->length =
length - halfpitch;
739 zpos = -halfpitch / 2.;
744 htcomponent = GeoTrf::Translate3D(xpos, ypos, zpos) * GeoTrf::RotateX3D(
angle);
746 htcomponent = GeoTrf::Translate3D(xpos, -ypos, zpos) * GeoTrf::RotateX3D(-
angle);
748 xfcomponent =
new GeoTransform(htcomponent);
751 if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
752 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
753 }
else if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
754 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
757 if (
type.substr(0, 2) ==
"LB")
760 ATH_MSG_DEBUG(
" Building a SpacerBeam for m_station "<<
key <<
" component name is "<<
c->name );
762 if (fpv ==
nullptr || (
stName.compare(0, 3,
"BOG") == 0 &&
type ==
"CMI")) {
763 if (
stName.compare(0, 3,
"BOG") == 0) {
764 ATH_MSG_VERBOSE(
" Building a SpacerBeam for station " <<
key <<
" component name is " <<
c->name );
766 if (
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) {
767 lvo =
r->build(matManager, 1, is_barrel);
769 lvo =
r->build(matManager, is_barrel);
776 if (
stName.compare(0, 3,
"BOG") == 0)
777 ATH_MSG_VERBOSE(
" This spacerbeam for station " <<
key <<
" component name is " <<
c->name <<
" already exists; re-use it " );
781 }
else if (
type ==
"RPC") {
783 RpcComponent *
rp =
static_cast<RpcComponent *
>(
c);
784 int ndivy =
rp->ndivy;
785 int ndivz =
rp->ndivz;
787 if (ndivz != 1 || ndivy != 1) {
788 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
791 double xpos =
c->posx;
797 <<
" RPC " << (
c->name).substr(3, 2) <<
" has swap flag = " <<
rp->iswap <<
" ypos, zpos " << ypos <<
" " << zpos <<
" " );
799 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
800 if (
rp->iswap == -1) {
803 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
807 bool rpcCutoutFlag = (stname ==
"BOS" && std::abs(zi) == 6) || (stname ==
"BMS" && (std::abs(zi) == 2 || std::abs(zi) == 4 || std::abs(zi) == 6)) ||
808 (stname ==
"BMS" && std::abs(zi) == 1 && fi == 3);
810 if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
811 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0) +
"_" +
813 }
else if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
814 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0) +
"_" +
818 if (fpv ==
nullptr) {
819 std::unique_ptr<Rpc>
r = std::make_unique<Rpc>(mysql,
c);
820 r->setLogVolName(std::string(
stName) + techname);
821 if (
stName.find(
"BI") != std::string::npos) {
822 std::map<std::string, float>::const_iterator yItr = rpcYTrans.find(techname);
823 if (yItr != rpcYTrans.end())
824 r->y_translation = yItr->second;
825 std::map<std::string, float>::const_iterator zItr = rpcZTrans.find(techname);
826 if (zItr != rpcZTrans.end())
827 r->z_translation = zItr->second;
830 if ((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) {
831 lvr =
r->build(matManager, mysql,
manager->MinimalGeoFlag(), 1, vcutdef);
833 lvr =
r->build(matManager, mysql,
manager->MinimalGeoFlag());
838 auto rfpv = dynamic_pointer_cast<GeoFullPhysVol>(fpv);
842 }
else if (
type ==
"DED" &&
manager->MinimalGeoFlag() == 0) {
843 double xpos =
c->posx;
846 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
848 xfcomponent =
new GeoTransform(htcomponent);
850 bool dedCutoutFlag = (stname ==
"BOS" && std::abs(zi) == 6) || (stname ==
"BMS" && (std::abs(zi) == 2 || std::abs(zi) == 4 || std::abs(zi) == 6)) ||
851 (stname ==
"BMS" && std::abs(zi) == 1 && fi == 3);
852 std::string
key = std::string(
stName) + techname;
853 if (((
manager->IncludeCutoutsFlag() && dedCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
854 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0) +
"_" +
856 }
else if (((
manager->IncludeCutoutsFlag() && dedCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
857 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0) +
"_" +
863 if (fpv ==
nullptr) {
864 std::unique_ptr<Ded>
r = std::make_unique<Ded>(mysql,
c);
865 ATH_MSG_VERBOSE(
" Building a DED for station " <<
key <<
" component name is " <<
c->name );
866 if ((
manager->IncludeCutoutsFlag() && dedCutoutFlag) || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) {
867 lvd =
r->build(matManager, mysql, 1, vcutdef);
869 lvd =
r->build(matManager, mysql);
875 ATH_MSG_VERBOSE(
" Re-using DED for station " <<
key <<
" component name is " <<
c->name );
878 }
else if (
type ==
"SUP" &&
manager->MinimalGeoFlag() == 0) {
884 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
885 std::string
key = std::string(
stName) + techname;
886 if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
887 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
888 }
else if ((
manager->IncludeCutoutsFlag() || (
manager->IncludeCutoutsBogFlag() &&
stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
889 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
893 if (fpv ==
nullptr) {
899 }
else if (
type ==
"TGC") {
902 irad = tgInner->posy;
904 double orad = tgOuter->posy + tgOuter->dy;
905 double start = -(orad - irad) / 2. + (tg->posy - irad) + tg->dy / 2;
906 double xstart = -
thickness / 2. + tg->GetThickness(mysql) / 2.;
907 htcomponent = GeoTrf::TranslateX3D(xstart + tg->posz) * GeoTrf::TranslateZ3D(
start);
908 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
911 std::string
key = std::string(
stName) + techname;
912 if (
manager->IncludeCutoutsFlag()) {
913 if (mysql.allocPosFindCutout(statType, fi, zi) > 0) {
916 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
918 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
924 sprintf(chswidth,
"%i",
static_cast<int>(10 *
c->dx1));
928 if (fpv ==
nullptr) {
929 std::unique_ptr<Tgc>
t = std::make_unique<Tgc>(mysql,
c);
930 t->setLogVolName(std::string(
stName) + techname);
931 if (
manager->IncludeCutoutsFlag()) {
932 lvt =
t->build(matManager, mysql,
manager->MinimalGeoFlag(), 1, vcutdef);
934 lvt =
t->build(matManager, mysql,
manager->MinimalGeoFlag());
938 GeoFullPhysVol *rfpv =
static_cast<GeoFullPhysVol *
>(fpv);
942 }
else if (
type ==
"CSC") {
943 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos);
944 xfaligncomponent =
new GeoAlignableTransform(htcomponent);
946 std::string
key = std::string(
stName) + techname;
947 if (
manager->IncludeCutoutsFlag() && zi >= 0) {
948 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
949 }
else if (
manager->IncludeCutoutsFlag() && zi < 0) {
950 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType, fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType, fi, zi), 0);
954 if (fpv ==
nullptr) {
955 std::unique_ptr<Csc>
t = std::make_unique<Csc>(mysql,
c);
956 t->setLogVolName(std::string(
stName) + techname);
958 if (
manager->IncludeCutoutsFlag()) {
959 lvc =
t->build(matManager, mysql,
manager->MinimalGeoFlag(), 1, vcutdef);
961 lvc =
t->build(matManager, mysql,
manager->MinimalGeoFlag());
966 GeoFullPhysVol *rfpv =
static_cast<GeoFullPhysVol *
>(fpv);
978 if (lvm &&
manager->mdtIdHelper()) {
988 GeoNameTag *
nm =
new GeoNameTag(stag);
989 ptrd->add(
new GeoIdentifierTag(
c->index));
992 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
994 ptrd->add(xfaligncomponent);
997 std::unique_ptr<MdtReadoutElement>
det = std::make_unique<MdtReadoutElement>(lvm,
stName,
manager);
998 Position
ip = mysql.GetStationPosition(
stName.substr(0, 3), fi, zi);
1000 det->setHasCutouts(ncutouts > 0);
1001 det->setNMdtInStation(nMdt);
1003 det->setIdentifier(
id);
1004 det->setMultilayer(ml);
1005 det->setParentStationPV(PVConstLink(ptrd));
1006 det->setParentMuonStation(mstat);
1011 mstat->setBlineFixedPointInAmdbLRS(
c->posx,
c->posy,
c->posz);
1014 if (
c->posy < b0.y())
1015 mstat->setBlineFixedPointInAmdbLRS(b0.x(),
c->posy, b0.z());
1018 int jobIndex =
c->index;
1020 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1021 ATH_MSG_DEBUG( std::string(
stName + techname) <<
" trying to build a MDT Id from stType/eta/phi/ml/tl/t " << stationType <<
"/" << stationEta <<
"/"
1022 << stationPhi <<
"/" << ml <<
"/" << tubel <<
"/" <<
tube <<
endmsg <<
" Copy number is " <<
c->index <<
" tagName " << stag );
1025 manager->addMdtReadoutElement(std::move(
det));
1028 if (lvc &&
manager->cscIdHelper()) {
1032 int chamberLayer = 1;
1035 std::string stag =
"cl[" +
MuonGM::buildString(chamberLayer, 0) +
"]" + techname +
"component";
1036 GeoNameTag *
nm =
new GeoNameTag(stag);
1037 ptrd->add(
new GeoIdentifierTag(
c->index));
1040 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
1042 ptrd->add(xfaligncomponent);
1045 std::unique_ptr<CscReadoutElement>
det = std::make_unique<CscReadoutElement>(lvc,
stName,
manager);
1046 Position
ip = mysql.GetStationPosition(
stName.substr(0, 3), fi, zi);
1050 det->setHasCutouts(ncutouts > 0);
1051 Identifier id = csc_id->
channelID(stationType, stationEta, stationPhi, chamberLayer, 1, 0, 1);
1052 det->setIdentifier(
id);
1053 det->setChamberLayer(chamberLayer);
1054 det->setParentStationPV(PVConstLink(ptrd));
1055 det->setParentMuonStation(mstat);
1057 int jobIndex =
c->index;
1059 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1060 ATH_MSG_DEBUG(
stName << techname <<
" trying to build a CSC Id from stType/eta/phi/ml " << stationType <<
"/" << stationEta <<
"/"
1061 << stationPhi <<
"/" << chamberLayer <<
"/ and /1/0/1" <<
endmsg <<
" Copy number is " <<
c->index <<
" tagName " << stag );
1064 manager->addCscReadoutElement(std::move(
det));
1067 if (lvt &&
manager->tgcIdHelper()) {
1068 ATH_MSG_DEBUG(
" Adding a TGC chamber to the tree zi,fi, is_mirrored " << zi <<
" " << fi + 1 <<
" " << is_mirrored );
1071 ATH_MSG_VERBOSE(
"There's a TGC named " << techname <<
" of thickness " << tg->GetThickness(mysql) );
1081 std::string stag =
"stPhiJob[" +
MuonGM::buildString(ttag, 0) +
"]" + techname +
"tgccomponent";
1082 GeoNameTag *
nm =
new GeoNameTag(stag);
1091 ptrd->add(
new GeoIdentifierTag(geoid));
1094 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
1097 ptrd->add(xfaligncomponent);
1100 std::unique_ptr<TgcReadoutElement>
det = std::make_unique<TgcReadoutElement>(lvt,
stName,
manager);
1101 Position
ip = mysql.GetStationPosition(
stName.substr(0, 3), fi, zi);
1103 det->setHasCutouts(ncutouts > 0);
1105 det->setIdentifier(
id);
1106 det->setParentStationPV(PVConstLink(ptrd));
1107 det->setParentMuonStation(mstat);
1109 int jobIndex =
c->index;
1111 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1113 ATH_MSG_DEBUG(
stName << techname <<
" trying to build a TGC Id from stType/eta/phi " << stationType <<
"/" << stationEta <<
"/" << stationPhi
1114 <<
"/ and /1/0/1" <<
endmsg <<
" Copy number is " << geoid <<
" tagName = " << stag );
1115 manager->addTgcReadoutElement(std::move(
det));
1119 RpcComponent *
rp =
static_cast<RpcComponent *
>(
c);
1120 int ndivy =
rp->ndivy;
1121 int ndivz =
rp->ndivz;
1123 if (ndivz != 1 || ndivy != 1) {
1124 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
1127 double zpos = -
length / 2. +
c->posy +
c->dy / 2.;
1128 double xpos =
c->posx;
1141 if (nRpc > 1 && nDoubletR == 2 && ypos > 0.)
1146 if (stname.find(
"BI") != std::string::npos) {
1147 if (stname.find(
"BIS") != std::string::npos) {
1149 if (std::abs(stationEta)>= 7){
1150 ATH_MSG_DEBUG(
"BIS78 station eta: "<<stationEta<<
" phi: "<<stationPhi<<
" dR: "<<
doubletR<<
" dZ:"<< doubletZ <<
" rp: "<<
rp->posz);
1152 if (std::abs(stationEta) >= 7 &&
rp->posz > 80)
1159 if (stname.find(
"BIL") != std::string::npos && std::abs(stationEta) < 7 && std::abs(stationEta) != 2 && std::abs(stationEta) != 5) {
1166 if (zi <= 0 && !is_mirrored) {
1194 if (zi < 0 && is_mirrored && doubletZ == 3) {
1198 }
else if (zi < 0 && is_mirrored && doubletZ == 2 &&
doubletR == 1 &&
stName ==
"BMS6") {
1205 int measuresPhi = 0;
1210 int tag = doubletZ +
doubletR * 100 + dbphi * 1000;
1211 if (
rp->iswap == -1)
1218 if (
rp->iswap == -1)
1223 GeoNameTag *
nm =
new GeoNameTag(stag);
1224 ptrd->add(
new GeoIdentifierTag(geoid));
1227 xfaligncomponent->setDelta(GeoTrf::Transform3D::Identity());
1229 ptrd->add(xfaligncomponent);
1232 std::unique_ptr<RpcReadoutElement>
det = std::make_unique<RpcReadoutElement>(lvr,
stName, zi, fi + 1, is_mirrored,
manager);
1233 Position
ip = mysql.GetStationPosition(
stName.substr(0, 3), fi, zi);
1236 det->setIdentifier(
id);
1237 det->setHasCutouts(ncutouts > 0);
1239 det->setDoubletZ(doubletZ);
1242 ATH_MSG_DEBUG(
stName << techname <<
" trying to build a RPC Id from stType/eta/phi/dbR/dbZ/dbP " << stationType <<
"/" << stationEta <<
"/"
1244 <<
" Copy number " << geoid <<
" tagName= " << stag );
1245 det->setParentStationPV(PVConstLink(ptrd));
1246 det->setParentMuonStation(mstat);
1248 int jobIndex =
c->index;
1250 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
1253 if (
stName.find(
"BI") != std::string::npos) {
1254 std::map<std::string, float>::const_iterator yItr = rpcYTrans.find(techname);
1255 if (yItr != rpcYTrans.end())
1256 det->setYTranslation(yItr->second);
1257 std::map<std::string, float>::const_iterator zItr = rpcZTrans.find(techname);
1258 if (zItr != rpcZTrans.end())
1259 det->setZTranslation(zItr->second);
1265 manager->addRpcReadoutElement(std::move(
det));
1269 std::string cname =
c->name;
1270 ATH_MSG_VERBOSE(
" yes, the component is a SupComponent named " << cname );
1271 GeoNameTag *
nm =
new GeoNameTag(
stName +
"_stName " + techname +
" supcomponent");
1272 ptrd->add(
new GeoIdentifierTag(
c->index));
1274 ptrd->add(xfcomponent);
1284 GeoNameTag *
nm =
new GeoNameTag(
stName +
"_stName " + techname +
" dedcomponent");
1285 ptrd->add(
new GeoIdentifierTag(
c->index));
1288 ptrd->add(xfcomponent);
1300 GeoNameTag *
nm =
new GeoNameTag(
stName +
"_stName " + techname +
" component");
1301 ptrd->add(
new GeoIdentifierTag(
c->index));
1304 ptrd->add(xfcomponent);
1309 GeoNameTag *
nm =
new GeoNameTag(
stName +
"_stName " + techname +
" component");
1310 ptrd->add(
new GeoIdentifierTag(
c->index));
1312 ptrd->add(xfcomponent);
1317 mstat->updateBlineFixedPointInAmdbLRS();