112 <<
" is assembly = " << isAssembly );
124 double totthick =
thickness + extratop + extrabottom;
133 if (zi < 0 && !is_mirrored && stName[0] ==
'B') {
135 amdbOrigine_along_length += halfpitch;
139 << amdbOrigine_along_length <<
" in the thickness direction = " << amdbOrigine_along_thickness);
142 ATH_MSG_DEBUG(
"Station " << stName <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" will be described as Assembly" );
151 if (stName.compare(0, 3,
"BOG") == 0 && (
manager->IncludeCutoutsBogFlag() ||
manager->IncludeCutoutsFlag())) {
153 ATH_MSG_VERBOSE(
"amdb org: length= " << amdbOrigine_along_length <<
" thickness= " << amdbOrigine_along_thickness );
155 std::string statType = stName.substr(0, 3);
157 ATH_MSG_DEBUG(
"Station " << stName <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" has components with cutouts " );
161 bool foundCutouts =
false;
172 if (std::abs(
cut->dx - 600.7) < 0.1) {
177 if (std::abs(
cut->dx + 600.7) < 0.1) {
182 if (std::abs(
cut->lengthY - 180.2) < 0.001) {
185 if (std::abs(
cut->dy - 1019.8) < 0.001) {
186 cut->dy = 1216.4185 -
cut->lengthY;
189 cut->setThickness(totthick * 1.01);
190 if ((
cut->subtype == mysql.allocPosFindSubtype(std::string(statType),
fi, zi)) && (
cut->icut == mysql.allocPosFindCutout(std::string(statType),
fi, zi)) &&
191 (
cut->ijob ==
c->index)) {
203 double ypos{0.}, zpos{0.}, xpos{0.}, irad{0.};
204 std::array<int, 2 > ndbz{0, 0};
207 int nDoubletR{0}, nRpc{0}, nTgc{0}, nCsc{0}, nMdt{0};
208 double previous_depth = 0.;
210 ATH_MSG_VERBOSE(
" Station Name = " << stName <<
" fi/zi " <<
fi <<
"/" << zi <<
" defining the n. of DoubletR to " );
215 std::string_view cn = std::string_view(
d->name).substr(0, 3);
222 if (!(stname.compare(0, 2,
"BI") == 0) && nDoubletR == 1 && nRpc > 1 &&
depth * previous_depth < 0)
225 previous_depth =
depth;
227 else if (cn ==
"CSC") {
230 else if (cn ==
"TGC") {
233 else if (cn ==
"MDT") {
237 ATH_MSG_DEBUG(
"nDoubletR: " << nDoubletR<<
" nMdt/Rpc/Tgc/Csc " << nMdt <<
"/" << nRpc <<
"/" << nTgc <<
"/" << nCsc );
242 double LBheight{0.}, LBwidth{0.};
243 std::array<double, 2> LBpos{-1, -1};
246 std::string_view cname = std::string_view(
c->name).substr(0, 2);
248 const LBI *
lb =
dynamic_cast<const LBI *
>(mysql.GetTechnology(
c->name));
250 LBpos[numLB] =
c->posy +
c->dy / 2.;
251 LBheight =
lb->height;
260 std::string_view cname = std::string_view(
c->name).substr(0, 3);
261 if (cname ==
"CRO" || cname ==
"CMI" || cname ==
"CHV") {
262 CbmComponent *ccbm = (CbmComponent *)
c;
263 ccbm->lb_height = LBheight;
264 ccbm->lb_width = LBwidth;
265 ccbm->hole_pos1 = LBpos[0];
266 ccbm->hole_pos2 = LBpos[1];
271 std::string CMIcomponentNumber =
"";
274 std::string_view cn = std::string_view(
d->name).substr(0, 3);
276 CMIcomponentNumber = (
d->name).substr(3, 2);
283 std::string_view cn = std::string_view(
d->name).substr(0, 2);
285 LbiComponent *lbic = (LbiComponent *)
d;
287 lbic->associated_CMIsubtype = CMIcomponentNumber;
289 ATH_MSG_ERROR(
"MuonChamberLite :: cannot associate a CMI subtype to the LB component " );
295 if (stName.compare(0, 1,
"B") == 0) {
296 mstat =
new MuonStation(stName.substr(0, 3),
width, totthick,
length,
longWidth, totthick,
length, zi,
fi + 1,
297 (zi < 0 && !is_mirrored));
299 mstat =
new MuonStation(stName.substr(0, 3),
width,
length, totthick,
longWidth,
length, totthick, zi,
fi + 1,
300 (zi < 0 && !is_mirrored));
302 manager->addMuonStation(std::unique_ptr<MuonStation>(mstat));
304 <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" is_mirrored " << is_mirrored);
310 ATH_MSG_VERBOSE(
" Component index " <<
c->index <<
" in loop for " << stName <<
" " << stationType <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" cName "
311 <<
c->name <<
" thickness " <<
c->GetThickness(mysql) <<
" length " <<
c->dy <<
" w, lw " <<
c->dx1 <<
" " <<
c->dx2 );
312 ATH_MSG_VERBOSE(
" Component local (amdb) coords " <<
c->posx <<
" " <<
c->posy <<
" " <<
c->posz );
314 ypos = -
thickness / 2. +
c->posz +
c->GetThickness(mysql) / 2.;
318 ypos = -
thickness / 2. + (
c->posz + amdbOrigine_along_thickness) +
c->GetThickness(mysql) / 2.;
319 zpos = -
length / 2. + amdbOrigine_along_length +
c->posy +
c->dy / 2.;
322 const std::string &techname =
c->name;
323 std::string_view
type = std::string_view(techname).substr(0, 3);
327 GeoFullPhysVol *lvm =
nullptr;
328 GeoFullPhysVol *lvr =
nullptr;
329 GeoFullPhysVol *lvt =
nullptr;
330 GeoFullPhysVol *lvc =
nullptr;
335 std::string statType = stName.substr(0, 3);
336 double cthickness =
c->GetThickness(mysql);
338 std::vector<Cutout *> vcutdef;
339 std::vector<std::unique_ptr<Cutout>> vcutdef_todel;
342 cut->setThickness(cthickness * 1.01);
344 if ((
cut->subtype == mysql.allocPosFindSubtype(std::string(statType),
fi, zi)) && (
cut->icut == mysql.allocPosFindCutout(std::string(statType),
fi, zi)) && (
cut->ijob ==
c->index)) {
346 double tempdx =
cut->dx;
347 double tempdy =
cut->dy;
348 double templengthY =
cut->lengthY;
352 if (stName.compare(0, 3,
"BOG") == 0) {
354 cut->lengthY = templengthY + 31.;
360 if (std::abs(
cut->dead1) > 1. && techname ==
"MDT03")
365 cut->lengthY = templengthY;
373 if (stName.compare(0, 3,
"BMS") == 0) {
375 if (std::abs(zi) == 1) {
378 if (
type ==
"RPC" ||
type ==
"DED") {
379 cut->widthXl += 2 * margin;
380 cut->widthXs += 2 * margin;
382 cut->lengthY += 2 * margin;
397 if (stName.compare(0, 3,
"BOS") == 0 && zi == -6 &&
type ==
"MDT") {
398 cut->dy =
c->dy -
cut->dy -
cut->lengthY - halfpitch;
400 if (techname ==
"MDT03")
409 if (
type ==
"MDT" && (is_mirrored || zi < 0) && stName.compare(0, 1,
"B") == 0) {
413 Cutout *cutmirr =
new Cutout(*
cut);
414 cutmirr->dx = -cutmirr->dx;
417 vcutdef.push_back(cutmirr);
418 vcutdef_todel.emplace_back(cutmirr);
419 ATH_MSG_VERBOSE(
"adding for application mirrored cut \n" << *cutmirr );
421 }
else if (
type ==
"RPC" ||
type ==
"DED") {
422 Cutout *cutRpcType =
new Cutout(*
cut);
424 if (stName.compare(0, 3,
"BMS") == 0 && zi == 4 && (
c->index == 20 ||
c->index == 21 ||
c->index == 24 ||
c->index == 25)) {
425 cutRpcType->dy = 1102.5;
428 if (stName.compare(0, 3,
"BOS") == 0 && zi == 6 &&
type ==
"DED")
429 cutRpcType->dy = 706.;
431 cutRpcType->dy = cutRpcType->dy -
c->posy;
432 cutRpcType->dx = cutRpcType->dx -
c->posx;
435 RpcComponent *
rp = (RpcComponent *)
c;
436 if (
rp->iswap == -1) {
437 cutRpcType->dy =
c->dy - (cutRpcType->dy + cutRpcType->lengthY);
441 ATH_MSG_VERBOSE(
" Rpc or ded cutout redefined as follows \n" << *cutRpcType );
442 vcutdef.push_back(cutRpcType);
443 vcutdef_todel.emplace_back(cutRpcType);
444 }
else if (
type ==
"TGC") {
448 Cutout *tgccut =
new Cutout(*
cut);
449 tgccut->dy -=
c->posy;
452 vcutdef.push_back(tgccut);
453 vcutdef_todel.emplace_back(tgccut);
455 vcutdef.push_back(
cut);
461 ATH_MSG_DEBUG(
c->name <<
" of station " << stName <<
" at fi/zi " <<
fi + 1 <<
"/" << zi <<
" has " << ncutouts <<
" cutouts " );
465 GeoAlignableTransform *xfaligncomponent{
nullptr};
469 if (stName.compare(0, 1,
"B") != 0 && is_mirrored)
470 mstat->setxAmdbCRO(-xpos);
472 mstat->setxAmdbCRO(xpos);
476 MdtComponent *md= (MdtComponent *)
c;
477 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos) * GeoTrf::TranslateY3D(xpos);
479 if (zi < 0 && !is_mirrored && stName[0] ==
'B') {
482 htcomponent = htcomponent * GeoTrf::TranslateZ3D(halfpitch);
487 if (zi < 0 && stName.compare(0, 3,
"BOG") == 0 && is_mirrored) {
495 std::string
key =std::string( stName) + techname;
500 bool mdtCutoutFlag = ((stname ==
"BOS" && std::abs(zi) == 6) || stname ==
"BMG" || techname ==
"MDT14" || (stname ==
"BMS" && (std::abs(zi) == 1 &&
fi == 3)) ||
501 (stname ==
"EMS" && (std::abs(zi) == 1 || std::abs(zi) == 3)));
502 if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
504 }
else if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG")) == 0) && zi < 0) {
508 std::unique_ptr<Mdt>
r = std::make_unique<Mdt>(mysql,
c, stName + techname);
509 if ((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) {
510 if (!vcutdef.empty())
r->processCutouts(vcutdef);
516 }
else if (
type ==
"RPC") {
518 RpcComponent *
rp = (RpcComponent *)
c;
519 int ndivy =
rp->ndivy;
520 int ndivz =
rp->ndivz;
522 if (ndivz != 1 || ndivy != 1) {
523 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
526 double xpos =
c->posx;
531 ATH_MSG_VERBOSE(
" In station " << stName <<
" with " << nDoubletR <<
" doubletR,"
532 <<
" RPC " << (
c->name).substr(3, 2) <<
" has swap flag = " <<
rp->iswap <<
" ypos, zpos " << ypos <<
" " << zpos <<
" " );
534 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
535 if (
rp->iswap == -1) {
541 bool rpcCutoutFlag = (stname ==
"BOS" && std::abs(zi) == 6) || (stname ==
"BMS" && (std::abs(zi) == 2 || std::abs(zi) == 4 || std::abs(zi) == 6)) ||
542 (stname ==
"BMS" && std::abs(zi) == 1 &&
fi == 3);
543 std::string
key = stName + techname;
544 if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
545 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType,
fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType,
fi, zi), 0) +
"_" +
547 }
else if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
548 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType,
fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType,
fi, zi), 0) +
"_" +
553 }
else if (
type ==
"TGC") {
556 irad = tgInner->posy;
558 double orad = tgOuter->posy + tgOuter->
dy;
559 double start = -(orad - irad) / 2. + (tg->posy - irad) + tg->dy / 2;
560 double xstart = -
thickness / 2. + tg->GetThickness(mysql) / 2.;
561 htcomponent = GeoTrf::TranslateX3D(xstart + tg->posz) * GeoTrf::TranslateZ3D(
start);
564 std::string
key = std::string(stName) + techname;
565 if (
manager->IncludeCutoutsFlag()) {
566 if (mysql.allocPosFindCutout(statType,
fi, zi) > 0) {
577 sprintf(chswidth,
"%i",
int(10 *
c->dx1));
583 }
else if (
type ==
"CSC") {
584 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos);
586 std::string
key = std::string(stName) + techname;
587 if (
manager->IncludeCutoutsFlag() && zi >= 0) {
589 }
else if (
manager->IncludeCutoutsFlag() && zi < 0) {
603 if (lvm &&
manager->mdtIdHelper()) {
614 std::unique_ptr<MdtReadoutElement>
det = std::make_unique<MdtReadoutElement>(lvm, stName,
manager);
615 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
617 det->setHasCutouts(ncutouts > 0);
618 det->setNMdtInStation(nMdt);
620 det->setIdentifier(
id);
621 det->setMultilayer(ml);
622 det->setParentStationPV(PVConstLink(ptrd));
623 det->setParentMuonStation(mstat);
628 mstat->setBlineFixedPointInAmdbLRS(
c->posx,
c->posy,
c->posz);
630 const Amg::Vector3D b0 = mstat->getBlineFixedPointInAmdbLRS();
631 if (
c->posy < b0.y())
632 mstat->setBlineFixedPointInAmdbLRS(b0.x(),
c->posy, b0.z());
635 int jobIndex =
c->index;
637 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
638 manager->addMdtReadoutElement(std::move(
det));
641 if (lvc &&
manager->cscIdHelper()) {
645 int chamberLayer = 1;
649 std::unique_ptr<CscReadoutElement>
det = std::make_unique<CscReadoutElement>(lvc, stName,
manager);
650 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
654 det->setHasCutouts(ncutouts > 0);
655 Identifier id = csc_id->
channelID(stationType, stationEta, stationPhi, chamberLayer, 1, 0, 1);
656 det->setIdentifier(
id);
658 det->setChamberLayer(chamberLayer);
659 det->setParentStationPV(PVConstLink(ptrd));
660 det->setParentMuonStation(mstat);
662 int jobIndex =
c->index;
664 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
669 manager->addCscReadoutElement(std::move(
det));
672 if (lvt &&
manager->tgcIdHelper()) {
674 ATH_MSG_DEBUG(
" Adding a TGC chamber to the tree zi,fi, is_mirrored " << zi <<
" " <<
fi + 1 <<
" " << is_mirrored );
679 ATH_MSG_VERBOSE(
"There's a TGC named " << techname <<
" of thickness " << tg->GetThickness(mysql) );
689 std::unique_ptr<TgcReadoutElement>
det = std::make_unique<TgcReadoutElement>(lvt, stName,
manager);
690 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
692 det->setHasCutouts(ncutouts > 0);
694 det->setIdentifier(
id);
695 det->setParentStationPV(PVConstLink(ptrd));
696 det->setParentMuonStation(mstat);
698 int jobIndex =
c->index;
700 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
702 manager->addTgcReadoutElement(std::move(
det));
705 RpcComponent *
rp = (RpcComponent *)
c;
706 int ndivy =
rp->ndivy;
707 int ndivz =
rp->ndivz;
709 if (ndivz != 1 || ndivy != 1) {
710 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
713 double zpos = -
length / 2. +
c->posy +
c->dy / 2.;
714 double xpos =
c->posx;
727 if (nRpc > 1 && nDoubletR == 2 && ypos > 0.)
732 if (stname.find(
"BI") != std::string::npos) {
733 if (stname.find(
"BIS") != std::string::npos) {
735 if (std::abs(stationEta)>= 7){
736 ATH_MSG_DEBUG(
"BIS78 station eta: "<<stationEta<<
" phi: "<<stationPhi<<
" dR: "<<
doubletR<<
" dZ:"<< doubletZ <<
" rp: "<<
rp->posz);
738 if (std::abs(stationEta) >= 7 &&
rp->posz > 80)
745 if (stname.find(
"BIL") != std::string::npos && std::abs(stationEta) < 7 && std::abs(stationEta) != 2 && std::abs(stationEta) != 5) {
752 if (zi <= 0 && !is_mirrored) {
780 if (zi < 0 && is_mirrored && doubletZ == 3) {
784 }
else if (zi < 0 && is_mirrored && doubletZ == 2 &&
doubletR == 1 && stName ==
"BMS6") {
794 int tag = doubletZ +
doubletR * 100 + dbphi * 1000;
807 std::unique_ptr<RpcReadoutElement>
det = std::make_unique<RpcReadoutElement>(lvr, stName, zi,
fi + 1, is_mirrored,
manager);
808 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
810 det->setHasCutouts(ncutouts > 0);
812 det->setIdentifier(
id);
814 det->setDoubletZ(doubletZ);
816 if (stName.find(
"BI") != std::string::npos)
817 det->setNumberOfLayers(3);
818 det->setParentStationPV(PVConstLink(ptrd));
819 det->setParentMuonStation(mstat);
821 int jobIndex =
c->index;
823 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
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 det->setYTranslation(yItr->second);
831 std::map<std::string, float>::const_iterator zItr = rpcZTrans.find(techname);
832 if (zItr != rpcZTrans.end())
833 det->setZTranslation(zItr->second);
839 manager->addRpcReadoutElement(std::move(
det));
844 mstat->updateBlineFixedPointInAmdbLRS();