113 <<
" is assembly = " << isAssembly );
125 double totthick =
thickness + extratop + extrabottom;
134 if (zi < 0 && !is_mirrored && stName[0] ==
'B') {
136 amdbOrigine_along_length += halfpitch;
140 << amdbOrigine_along_length <<
" in the thickness direction = " << amdbOrigine_along_thickness);
143 ATH_MSG_DEBUG(
"Station " << stName <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" will be described as Assembly" );
152 if (stName.compare(0, 3,
"BOG") == 0 && (
manager->IncludeCutoutsBogFlag() ||
manager->IncludeCutoutsFlag())) {
154 ATH_MSG_VERBOSE(
"amdb org: length= " << amdbOrigine_along_length <<
" thickness= " << amdbOrigine_along_thickness );
156 std::string statType = stName.substr(0, 3);
158 ATH_MSG_DEBUG(
"Station " << stName <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" has components with cutouts " );
162 bool foundCutouts =
false;
173 if (std::abs(
cut->dx - 600.7) < 0.1) {
178 if (std::abs(
cut->dx + 600.7) < 0.1) {
183 if (std::abs(
cut->lengthY - 180.2) < 0.001) {
186 if (std::abs(
cut->dy - 1019.8) < 0.001) {
187 cut->dy = 1216.4185 -
cut->lengthY;
190 cut->setThickness(totthick * 1.01);
191 if ((
cut->subtype == mysql.allocPosFindSubtype(std::string(statType),
fi, zi)) && (
cut->icut == mysql.allocPosFindCutout(std::string(statType),
fi, zi)) &&
192 (
cut->ijob ==
c->index)) {
204 double ypos{0.}, zpos{0.}, xpos{0.}, irad{0.};
205 std::array<int, 2 > ndbz{0, 0};
208 int nDoubletR{0}, nRpc{0}, nTgc{0}, nCsc{0}, nMdt{0};
209 double previous_depth = 0.;
211 ATH_MSG_VERBOSE(
" Station Name = " << stName <<
" fi/zi " <<
fi <<
"/" << zi <<
" defining the n. of DoubletR to " );
216 std::string_view cn = std::string_view(
d->name).substr(0, 3);
223 if (!(stname.compare(0, 2,
"BI") == 0) && nDoubletR == 1 && nRpc > 1 &&
depth * previous_depth < 0)
226 previous_depth =
depth;
228 else if (cn ==
"CSC") {
231 else if (cn ==
"TGC") {
234 else if (cn ==
"MDT") {
238 ATH_MSG_DEBUG(
"nDoubletR: " << nDoubletR<<
" nMdt/Rpc/Tgc/Csc " << nMdt <<
"/" << nRpc <<
"/" << nTgc <<
"/" << nCsc );
243 double LBheight{0.}, LBwidth{0.};
244 std::array<double, 2> LBpos{-1, -1};
247 std::string_view cname = std::string_view(
c->name).substr(0, 2);
249 const LBI *
lb =
dynamic_cast<const LBI *
>(mysql.GetTechnology(
c->name));
251 LBpos[numLB] =
c->posy +
c->dy / 2.;
252 LBheight =
lb->height;
261 std::string_view cname = std::string_view(
c->name).substr(0, 3);
262 if (cname ==
"CRO" || cname ==
"CMI" || cname ==
"CHV") {
263 CbmComponent *ccbm = (CbmComponent *)
c;
264 ccbm->lb_height = LBheight;
265 ccbm->lb_width = LBwidth;
266 ccbm->hole_pos1 = LBpos[0];
267 ccbm->hole_pos2 = LBpos[1];
272 std::string CMIcomponentNumber =
"";
275 std::string_view cn = std::string_view(
d->name).substr(0, 3);
277 CMIcomponentNumber = (
d->name).substr(3, 2);
284 std::string_view cn = std::string_view(
d->name).substr(0, 2);
286 LbiComponent *lbic = (LbiComponent *)
d;
288 lbic->associated_CMIsubtype = CMIcomponentNumber;
290 ATH_MSG_ERROR(
"MuonChamberLite :: cannot associate a CMI subtype to the LB component " );
296 if (stName.compare(0, 1,
"B") == 0) {
297 mstat =
new MuonStation(stName.substr(0, 3),
width, totthick,
length,
longWidth, totthick,
length, zi,
fi + 1,
298 (zi < 0 && !is_mirrored));
300 mstat =
new MuonStation(stName.substr(0, 3),
width,
length, totthick,
longWidth,
length, totthick, zi,
fi + 1,
301 (zi < 0 && !is_mirrored));
304 manager->addMuonStation(std::unique_ptr<MuonStation>(mstat));
306 <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" is_mirrored " << is_mirrored);
309 mstat->setPhysVol(ptrd);
313 ATH_MSG_VERBOSE(
" Component index " <<
c->index <<
" in loop for " << stName <<
" " << stationType <<
" at zi, fi " << zi <<
" " <<
fi + 1 <<
" cName "
314 <<
c->name <<
" thickness " <<
c->GetThickness(mysql) <<
" length " <<
c->dy <<
" w, lw " <<
c->dx1 <<
" " <<
c->dx2 );
315 ATH_MSG_VERBOSE(
" Component local (amdb) coords " <<
c->posx <<
" " <<
c->posy <<
" " <<
c->posz );
317 ypos = -
thickness / 2. +
c->posz +
c->GetThickness(mysql) / 2.;
321 ypos = -
thickness / 2. + (
c->posz + amdbOrigine_along_thickness) +
c->GetThickness(mysql) / 2.;
322 zpos = -
length / 2. + amdbOrigine_along_length +
c->posy +
c->dy / 2.;
325 const std::string &techname =
c->name;
326 std::string_view
type = std::string_view(techname).substr(0, 3);
330 GeoFullPhysVol *lvm =
nullptr;
331 GeoFullPhysVol *lvr =
nullptr;
332 GeoFullPhysVol *lvt =
nullptr;
333 GeoFullPhysVol *lvc =
nullptr;
338 std::string statType = stName.substr(0, 3);
339 double cthickness =
c->GetThickness(mysql);
341 std::vector<Cutout *> vcutdef;
342 std::vector<std::unique_ptr<Cutout>> vcutdef_todel;
345 cut->setThickness(cthickness * 1.01);
347 if ((
cut->subtype == mysql.allocPosFindSubtype(std::string(statType),
fi, zi)) && (
cut->icut == mysql.allocPosFindCutout(std::string(statType),
fi, zi)) && (
cut->ijob ==
c->index)) {
349 double tempdx =
cut->dx;
350 double tempdy =
cut->dy;
351 double templengthY =
cut->lengthY;
355 if (stName.compare(0, 3,
"BOG") == 0) {
357 cut->lengthY = templengthY + 31.;
363 if (std::abs(
cut->dead1) > 1. && techname ==
"MDT03")
368 cut->lengthY = templengthY;
376 if (stName.compare(0, 3,
"BMS") == 0) {
378 if (std::abs(zi) == 1) {
381 if (
type ==
"RPC" ||
type ==
"DED") {
382 cut->widthXl += 2 * margin;
383 cut->widthXs += 2 * margin;
385 cut->lengthY += 2 * margin;
400 if (stName.compare(0, 3,
"BOS") == 0 && zi == -6 &&
type ==
"MDT") {
401 cut->dy =
c->dy -
cut->dy -
cut->lengthY - halfpitch;
403 if (techname ==
"MDT03")
412 if (
type ==
"MDT" && (is_mirrored || zi < 0) && stName.compare(0, 1,
"B") == 0) {
416 Cutout *cutmirr =
new Cutout(*
cut);
417 cutmirr->dx = -cutmirr->dx;
420 vcutdef.push_back(cutmirr);
421 vcutdef_todel.emplace_back(cutmirr);
422 ATH_MSG_VERBOSE(
"adding for application mirrored cut \n" << *cutmirr );
424 }
else if (
type ==
"RPC" ||
type ==
"DED") {
425 Cutout *cutRpcType =
new Cutout(*
cut);
427 if (stName.compare(0, 3,
"BMS") == 0 && zi == 4 && (
c->index == 20 ||
c->index == 21 ||
c->index == 24 ||
c->index == 25)) {
428 cutRpcType->dy = 1102.5;
431 if (stName.compare(0, 3,
"BOS") == 0 && zi == 6 &&
type ==
"DED")
432 cutRpcType->dy = 706.;
434 cutRpcType->dy = cutRpcType->dy -
c->posy;
435 cutRpcType->dx = cutRpcType->dx -
c->posx;
438 RpcComponent *
rp = (RpcComponent *)
c;
439 if (
rp->iswap == -1) {
440 cutRpcType->dy =
c->dy - (cutRpcType->dy + cutRpcType->lengthY);
444 ATH_MSG_VERBOSE(
" Rpc or ded cutout redefined as follows \n" << *cutRpcType );
445 vcutdef.push_back(cutRpcType);
446 vcutdef_todel.emplace_back(cutRpcType);
447 }
else if (
type ==
"TGC") {
451 Cutout *tgccut =
new Cutout(*
cut);
452 tgccut->dy -=
c->posy;
455 vcutdef.push_back(tgccut);
456 vcutdef_todel.emplace_back(tgccut);
458 vcutdef.push_back(
cut);
464 ATH_MSG_DEBUG(
c->name <<
" of station " << stName <<
" at fi/zi " <<
fi + 1 <<
"/" << zi <<
" has " << ncutouts <<
" cutouts " );
468 GeoAlignableTransform *xfaligncomponent{
nullptr};
472 if (stName.compare(0, 1,
"B") != 0 && is_mirrored)
473 mstat->setxAmdbCRO(-xpos);
475 mstat->setxAmdbCRO(xpos);
479 MdtComponent *md= (MdtComponent *)
c;
480 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos) * GeoTrf::TranslateY3D(xpos);
482 if (zi < 0 && !is_mirrored && stName[0] ==
'B') {
485 htcomponent = htcomponent * GeoTrf::TranslateZ3D(halfpitch);
490 if (zi < 0 && stName.compare(0, 3,
"BOG") == 0 && is_mirrored) {
498 std::string
key =std::string( stName) + techname;
503 bool mdtCutoutFlag = ((stname ==
"BOS" && std::abs(zi) == 6) || stname ==
"BMG" || techname ==
"MDT14" || (stname ==
"BMS" && (std::abs(zi) == 1 &&
fi == 3)) ||
504 (stname ==
"EMS" && (std::abs(zi) == 1 || std::abs(zi) == 3)));
505 if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
507 }
else if (((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG")) == 0) && zi < 0) {
511 std::unique_ptr<Mdt>
r = std::make_unique<Mdt>(mysql,
c, stName + techname);
512 if ((
manager->IncludeCutoutsFlag() && mdtCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) {
513 if (!vcutdef.empty())
r->processCutouts(vcutdef);
519 }
else if (
type ==
"RPC") {
521 RpcComponent *
rp = (RpcComponent *)
c;
522 int ndivy =
rp->ndivy;
523 int ndivz =
rp->ndivz;
525 if (ndivz != 1 || ndivy != 1) {
526 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
529 double xpos =
c->posx;
534 ATH_MSG_VERBOSE(
" In station " << stName <<
" with " << nDoubletR <<
" doubletR,"
535 <<
" RPC " << (
c->name).substr(3, 2) <<
" has swap flag = " <<
rp->iswap <<
" ypos, zpos " << ypos <<
" " << zpos <<
" " );
537 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateY3D(xpos) * GeoTrf::TranslateZ3D(zpos);
538 if (
rp->iswap == -1) {
544 bool rpcCutoutFlag = (stname ==
"BOS" && std::abs(zi) == 6) || (stname ==
"BMS" && (std::abs(zi) == 2 || std::abs(zi) == 4 || std::abs(zi) == 6)) ||
545 (stname ==
"BMS" && std::abs(zi) == 1 &&
fi == 3);
546 std::string
key = stName + techname;
547 if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi >= 0) {
548 key +=
"p" +
buildString(mysql.allocPosFindSubtype(statType,
fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType,
fi, zi), 0) +
"_" +
550 }
else if (((
manager->IncludeCutoutsFlag() && rpcCutoutFlag) || (
manager->IncludeCutoutsBogFlag() && stName.compare(0, 3,
"BOG") == 0)) && zi < 0) {
551 key +=
"m" +
buildString(mysql.allocPosFindSubtype(statType,
fi, zi), 0) +
"_" +
buildString(mysql.allocPosFindCutout(statType,
fi, zi), 0) +
"_" +
556 }
else if (
type ==
"TGC") {
559 irad = tgInner->posy;
561 double orad = tgOuter->posy + tgOuter->
dy;
562 double start = -(orad - irad) / 2. + (tg->posy - irad) + tg->dy / 2;
563 double xstart = -
thickness / 2. + tg->GetThickness(mysql) / 2.;
564 htcomponent = GeoTrf::TranslateX3D(xstart + tg->posz) * GeoTrf::TranslateZ3D(
start);
567 std::string
key = std::string(stName) + techname;
568 if (
manager->IncludeCutoutsFlag()) {
569 if (mysql.allocPosFindCutout(statType,
fi, zi) > 0) {
584 }
else if (
type ==
"CSC") {
585 htcomponent = GeoTrf::TranslateX3D(ypos) * GeoTrf::TranslateZ3D(zpos);
587 std::string
key = std::string(stName) + techname;
588 if (
manager->IncludeCutoutsFlag() && zi >= 0) {
590 }
else if (
manager->IncludeCutoutsFlag() && zi < 0) {
604 if (lvm &&
manager->mdtIdHelper()) {
615 std::unique_ptr<MdtReadoutElement>
det = std::make_unique<MdtReadoutElement>(lvm, stName,
manager);
616 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
618 det->setHasCutouts(ncutouts > 0);
619 det->setNMdtInStation(nMdt);
621 det->setIdentifier(
id);
622 det->setMultilayer(ml);
623 det->setParentStationPV(PVConstLink(ptrd));
624 det->setParentMuonStation(mstat);
629 mstat->setBlineFixedPointInAmdbLRS(
c->posx,
c->posy,
c->posz);
631 const Amg::Vector3D b0 = mstat->getBlineFixedPointInAmdbLRS();
632 if (
c->posy < b0.y())
633 mstat->setBlineFixedPointInAmdbLRS(b0.x(),
c->posy, b0.z());
636 int jobIndex =
c->index;
638 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
639 manager->addMdtReadoutElement(std::move(
det));
642 if (lvc &&
manager->cscIdHelper()) {
646 int chamberLayer = 1;
650 std::unique_ptr<CscReadoutElement>
det = std::make_unique<CscReadoutElement>(lvc, stName,
manager);
651 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
655 det->setHasCutouts(ncutouts > 0);
656 Identifier id = csc_id->
channelID(stationType, stationEta, stationPhi, chamberLayer, 1, 0, 1);
657 det->setIdentifier(
id);
659 det->setChamberLayer(chamberLayer);
660 det->setParentStationPV(PVConstLink(ptrd));
661 det->setParentMuonStation(mstat);
663 int jobIndex =
c->index;
665 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
670 manager->addCscReadoutElement(std::move(
det));
673 if (lvt &&
manager->tgcIdHelper()) {
675 ATH_MSG_DEBUG(
" Adding a TGC chamber to the tree zi,fi, is_mirrored " << zi <<
" " <<
fi + 1 <<
" " << is_mirrored );
680 ATH_MSG_VERBOSE(
"There's a TGC named " << techname <<
" of thickness " << tg->GetThickness(mysql) );
690 std::unique_ptr<TgcReadoutElement>
det = std::make_unique<TgcReadoutElement>(lvt, stName,
manager);
691 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
693 det->setHasCutouts(ncutouts > 0);
695 det->setIdentifier(
id);
696 det->setParentStationPV(PVConstLink(ptrd));
697 det->setParentMuonStation(mstat);
699 int jobIndex =
c->index;
701 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
703 manager->addTgcReadoutElement(std::move(
det));
706 RpcComponent *
rp = (RpcComponent *)
c;
707 int ndivy =
rp->ndivy;
708 int ndivz =
rp->ndivz;
710 if (ndivz != 1 || ndivy != 1) {
711 ATH_MSG_ERROR(
" RPC segmentation z,y " << ndivz <<
" " << ndivy );
714 double zpos = -
length / 2. +
c->posy +
c->dy / 2.;
715 double xpos =
c->posx;
728 if (nRpc > 1 && nDoubletR == 2 && ypos > 0.)
733 if (stname.find(
"BI") != std::string::npos) {
734 if (stname.find(
"BIS") != std::string::npos) {
736 if (std::abs(stationEta)>= 7){
737 ATH_MSG_DEBUG(
"BIS78 station eta: "<<stationEta<<
" phi: "<<stationPhi<<
" dR: "<<
doubletR<<
" dZ:"<< doubletZ <<
" rp: "<<
rp->posz);
739 if (std::abs(stationEta) >= 7 &&
rp->posz > 80)
746 if (stname.find(
"BIL") != std::string::npos && std::abs(stationEta) < 7 && std::abs(stationEta) != 2 && std::abs(stationEta) != 5) {
753 if (zi <= 0 && !is_mirrored) {
781 if (zi < 0 && is_mirrored && doubletZ == 3) {
785 }
else if (zi < 0 && is_mirrored && doubletZ == 2 &&
doubletR == 1 && stName ==
"BMS6") {
795 int tag = doubletZ +
doubletR * 100 + dbphi * 1000;
808 std::unique_ptr<RpcReadoutElement>
det = std::make_unique<RpcReadoutElement>(lvr, stName, zi,
fi + 1, is_mirrored,
manager);
809 Position
ip = mysql.GetStationPosition(stName.substr(0, 3),
fi, zi);
811 det->setHasCutouts(ncutouts > 0);
813 det->setIdentifier(
id);
815 det->setDoubletZ(doubletZ);
817 if (stName.find(
"BI") != std::string::npos)
818 det->setNumberOfLayers(3);
819 det->setParentStationPV(PVConstLink(ptrd));
820 det->setParentMuonStation(mstat);
822 int jobIndex =
c->index;
824 mstat->addMuonReadoutElementWithAlTransf(
det.get(), xfaligncomponent, jobIndex);
828 if (stName.find(
"BI") != std::string::npos) {
829 std::map<std::string, float>::const_iterator yItr = rpcYTrans.find(techname);
830 if (yItr != rpcYTrans.end())
831 det->setYTranslation(yItr->second);
832 std::map<std::string, float>::const_iterator zItr = rpcZTrans.find(techname);
833 if (zItr != rpcZTrans.end())
834 det->setZTranslation(zItr->second);
840 manager->addRpcReadoutElement(std::move(
det));
845 mstat->updateBlineFixedPointInAmdbLRS();