25 declareProperty(
"AsideId",
m_AsideId=103);
26 declareProperty(
"CsideId",
m_CsideId=104);
27 declareProperty(
"rodId",
m_rodId);
28 declareProperty(
"databaseASDToPP",
m_databaseASDToPP=
"MuonTGC_Cabling_ASD2PP.db");
29 declareProperty(
"databaseInPP",
m_databaseInPP=
"MuonTGC_Cabling_PP.db");
30 declareProperty(
"databasePPToSL",
m_databasePPToSL=
"MuonTGC_Cabling_PP2SL.db");
40 int& maxChannelId)
const
55 SmartIF<StoreGateSvc>
detStore{serviceLocator()->service(
"DetectorStore")};
62 std::ifstream inASDToPP;
64 inASDToPP.open(dbASDToPP.c_str());
67 return StatusCode::FAILURE;
71 return StatusCode::FAILURE;
80 inInPP.open(dbInPP.c_str());
83 return StatusCode::FAILURE;
87 return StatusCode::FAILURE;
94 std::ifstream inPPToSL;
96 inPPToSL.open(dbPPToSL.c_str());
99 return StatusCode::FAILURE;
103 return StatusCode::FAILURE;
111 std::ifstream inSLBToROD;
113 inSLBToROD.open(dbSLBToROD.c_str());
116 return StatusCode::FAILURE;
118 if(inSLBToROD.bad()) {
120 return StatusCode::FAILURE;
126 m_cabling = std::make_unique<MuonTGC_Cabling::TGCCabling>(dbASDToPP,
141 if(!
m_cabling->updateCableASDToPP().isSuccess()) {
143 return StatusCode::SUCCESS;
146 return StatusCode::SUCCESS;
153 double & endPhi)
const
155 int sectorInReadout = rodID - 1;
166 int & startEndcapSector,
167 int & coverageOfEndcapSector,
168 int & startForwardSector,
169 int & coverageOfForwardSector)
const
171 int sectorInReadout = rodID - 1;
174 coverageOfEndcapSector =
177 startEndcapSector = sectorInReadout * coverageOfEndcapSector;
178 coverageOfForwardSector =
181 startForwardSector = sectorInReadout *coverageOfForwardSector;
190 double & endPhi)
const
192 int sectorInReadout = srodID - 17;
203 int & startEndcapSector,
204 int & coverageOfEndcapSector,
205 int & startForwardSector,
206 int & coverageOfForwardSector)
const
208 int sectorInReadout = srodID - 17;
211 coverageOfEndcapSector =
214 startEndcapSector = sectorInReadout * coverageOfEndcapSector;
215 coverageOfForwardSector =
218 startForwardSector = sectorInReadout *coverageOfForwardSector;
230 const int channelID)
const
265 const int octantNumber,
266 const int moduleNumber,
267 const int layerNumber,
269 const int wireOrStrip,
270 const int channelNumber)
const
278 <<
" side=" << subsystemNumber <<
" octant=" << octantNumber
279 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
280 <<
" chamber=" << rNumber <<
" w/s=" << wireOrStrip
281 <<
" channel=" << channelNumber);
302 const int subDetectorID,
307 bool orChannel)
const
331 if((!
status) && (!orChannel)) {
333 " getOfflineIDfromReadoutID :"
334 <<
" Cannot get OnineID for "
335 <<
" subdetectorID=" << subDetectorID
336 <<
" rodID=" << rodID
337 <<
" sswID=" << sswID
338 <<
" sbLoc=" << sbLoc
339 <<
" channel=" << channelID
340 <<
" [ Or =" << orChannel <<
"] ");
358 <<
" Cannot get OfflineID for "
359 <<
" side=" << subsystemNumber <<
" octant=" << octantNumber
360 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
361 <<
" chamber=" << rNumber <<
" w/s=" << wireOrStrip
362 <<
" channel=" << channelNumber);
377 bool adChannel)
const
399 ATH_MSG_WARNING(
" Fail to getOnlineIDfromOfflineID " <<
" for OfflineID=" << offlineID);
404 <<
" offlineID=" << offlineID
406 <<
" side=" << subsystemNumber <<
" octant=" << octantNumber
407 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
408 <<
" chamber=" << rNumber <<
" w/s=" << wireOrStrip
409 <<
" channel=" << channelNumber);
429 ATH_MSG_DEBUG(
" side=" << subsystemNumber <<
" octant=" << octantNumber
430 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
431 <<
" chamber=" << rNumber <<
" w/s=" << wireOrStrip
432 <<
" channel=" << channelNumber);
435 <<
" Cannot get ReadoutID for "
436 <<
" side=" << subsystemNumber <<
" octant=" << octantNumber
437 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
438 <<
" chamber=" << rNumber <<
" w/s=" << wireOrStrip
439 <<
" channel=" << channelNumber);
443 ATH_MSG_DEBUG(
" side=" << subsystemNumber <<
" octant=" << octantNumber
444 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
445 <<
" chamber=" << rNumber <<
" w/s=" << wireOrStrip
446 <<
" channel=" << channelNumber
447 <<
"adjacent=" << adChannel);
449 <<
" rodID=" << rodID
450 <<
" sswID=" << sswID
451 <<
" channelID=" << channelID);
461 int & subSystemNumber,
467 int & channelNumber)
const
470 const int iStation =
m_idHelperSvc->tgcIdHelper().stationName(offlineId);
471 const int stationType = (iStation - 39)/2;
473 if((stationType <1) || (stationType >4))
return false;
484 const int sectorEI[] = {-1, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11,
485 12, 13, 14, 15, 16, 18, 19, 20, 22, 23,
494 sector = sectorEI[
iPhi ];
511 int max_module = (regionType==
FORWARD||stationType==4) ?
515 const int iOctant =
static_cast<int>(sector/max_module);
516 const int iModule = sector % max_module;
519 const int rIndex = std::abs(
iEta);
522 const int iGasGap =
m_idHelperSvc->tgcIdHelper().gasGap(offlineId);
526 subSystemNumber = (
iEta > 0) ? 1 : -1;
528 octantNumber = iOctant;
539 const int modmapE[7] = { -1, 0, 1, 3, 4, 6, 7 };
540 const int modmapF[4] = { -1, 2, 5, 8 };
541 const int modmapEI[4] = { -1, 9, 10, 11 };
542 const int modmapFI[4] = { -1, 12, 13, 14 };
544 if(stationType != 4) {
546 moduleNumber = modmapE[iModule+1];
549 moduleNumber = modmapF[iModule+1];
554 moduleNumber = modmapEI[iModule+1];
557 moduleNumber = modmapFI[iModule+1];
565 const int lyr_offset[5]= { 0, -1, 2, 4, 6 };
566 layerNumber = iGasGap + lyr_offset[stationType];
569 wireOrStrip =
m_idHelperSvc->tgcIdHelper().isStrip(offlineId);
579 const int OffsetForT11S = 8;
584 if((wireOrStrip ==0) && (stationType == 4)) {
628 if(!asdin.
isValid())
return false;
635 if(asdout==
nullptr)
return false;
651 const int subSystemNumber,
652 const int octantNumber,
653 const int moduleNumber,
654 const int layerNumber,
656 const int wireOrStrip,
657 const int channelNumber)
const
670 <<
" side=" << sideType <<
" octant=" << octantNumber
671 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
672 <<
" chamber=" << rNumber <<
" w/s=" << signalType
673 <<
" channel=" << channelNumber);
685 <<
" side=" << sideType <<
" octant=" << octantNumber
686 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
687 <<
" chamber=" << rNumber <<
" w/s=" << signalType
688 <<
" channel=" << channelNumber);
690 if(!asdout.
isValid())
return false;
697 if(!asdin || !asdin->
isValid()) {
699 <<
" Illegal AsdIn for "
700 <<
" side=" << sideType <<
" octant=" << octantNumber
701 <<
" module=" << moduleNumber <<
" layer=" << layerNumber
702 <<
" chamber=" << rNumber <<
" w/s=" << signalType
703 <<
" channel=" << channelNumber);
705 if(asdin==
nullptr)
return false;
712 std::string stationNameStr;
715 stationNameStr = (asdin->
isForward()) ?
"T1F" :
"T1E";
718 stationNameStr = (asdin->
isForward()) ?
"T2F" :
"T2E";
721 stationNameStr = (asdin->
isForward()) ?
"T3F" :
"T3E";
724 stationNameStr = (asdin->
isForward()) ?
"T4F" :
"T4E";
727 delete asdin; asdin =
nullptr;
739 const int phiIE[] = { -1, 1, 2, 3, 4, 5, 6, 7, 8, -1, 9, 10,
740 11, 12, 13, 14, 15, -1, 16, 17, 18, -1, 19, 20,
754 const int OffsetForT11S = 8;
783 offlineId =
m_idHelperSvc->tgcIdHelper().channelID(stationNameStr,
802 int & subsystemNumber,
809 bool orChannel)
const
818 m_cabling->getASDOutFromReadout(sideType,
824 if(asdout==
nullptr) {
827 <<
" Cannot get OnlineID of "
828 <<
" side=" << sideType
829 <<
" rodID=" << rodID
830 <<
" sswID=" << sswID
831 <<
" sbLoc=" << sbLoc
832 <<
" channel=" << channelID
833 <<
" [ Or =" << orChannel <<
"] ");
839 <<
" Illegal ASDout for "
840 <<
" side=" << sideType
841 <<
" rodID=" << rodID
842 <<
" sswID=" << sswID
843 <<
" sbLoc=" << sbLoc
844 <<
" channel=" << channelID
845 <<
" [ Or =" << orChannel <<
"] ");
852 subsystemNumber = (asdout->
isAside()) ? 1 : -1;
866 wireOrStrip = (asdout->
isStrip()) ? 1 : 0;
883 const int subsystemNumber,
884 const int octantNumber,
885 const int moduleNumber,
886 const int layerNumber,
888 const int wireOrStrip,
889 const int channelNumber,
890 bool adChannel)
const
912 <<
" Cannot get ASDout for "
913 <<
" side=" << sideType
914 <<
" signal=" << signalType
915 <<
" octant=" << octantNumber
916 <<
" module=" << moduleNumber
917 <<
" layer=" << layerNumber
918 <<
" chamber=" << rNumber
919 <<
" channel=" << channelNumber);
922 if(!asdout.
isValid())
return false;
938 <<
" Cannot get ReadoutID for "
939 <<
" side=" << sideType
940 <<
" signal=" << signalType
941 <<
" octant=" << octantNumber
942 <<
" module=" << moduleNumber
943 <<
" layer=" << layerNumber
944 <<
" chamber=" << rNumber
945 <<
" channel=" << channelNumber);
963 const int iStation =
m_idHelperSvc->tgcIdHelper().stationName(elementID);
964 const int stationType = (iStation - 39)/2;
977 const int max_phi = (regionType==
FORWARD||stationType==4) ?
981 const int sector = ((
iPhi-1)+ max_phi/24 + max_phi)%max_phi;
982 int readoutSector =
static_cast<int>(sector/max_module);
985 readoutSector = (readoutSector /3);
986 readoutSector = 3*readoutSector + 1;
990 rodID = readoutSector +1;
999 const int subDetectorID,
1003 const int channelID,
1004 bool orChannel)
const
1009 int maxRodId, maxSRodId, maxSswId, maxSbloc, minChannelId ,maxChannelId;
1011 minChannelId, maxChannelId);
1014 if((sswID > maxSswId) ||
1015 (channelID < minChannelId) ||
1016 (channelID > maxChannelId)) {
1018 <<
" Illeagal channel ID"
1019 <<
" subdetectorID=" << subDetectorID
1020 <<
" rodID=" << rodID
1021 <<
" sswID=" << sswID
1022 <<
" sbLoc=" << sbLoc
1023 <<
" channel=" << channelID
1024 <<
" [ Or =" << orChannel <<
"] ");
1037 <<
" Cannot get OfflineID ");
1041 elementID =
m_idHelperSvc->tgcIdHelper().elementID(offlineID);
1052 const int subsectorID,
1055 const int sbLoc)
const
1064 <<
" Cannot get SLB of "
1066 <<
" rodID=" << rodID
1067 <<
" sswID=" << sswID
1068 <<
" sbLoc=" << sbLoc);
1085 offset = numOfSector - numOfSector/24;
1095 const int subsectorID,
1098 const int sbLoc)
const
1102 bool isAside = (subsectorID==
m_AsideId);
1109 <<
" Cannot get SLB of "
1111 <<
" rodID=" << rodID
1112 <<
" sswID=" << sswID
1113 <<
" sbLoc=" << sbLoc);
1120 <<
"dynamic_cast<const MuonTGC_Cabling::TGCModuleSLB*>(slb) failed.");
1131 const int subsectorID,
1134 const int sbLoc)
const
1138 bool isAside = (subsectorID==
m_AsideId);
1141 rxId =
m_cabling->getRxIdFromReadout(
side, rodID, sswID, sbLoc);
1144 <<
" Cannot get rxId of "
1146 <<
" rodID=" << rodID
1147 <<
" sswID=" << sswID
1148 <<
" sbLoc=" << sbLoc);
1161 const int subsectorID,
1164 const int rxId)
const
1172 <<
" Cannot get SLB of "
1174 <<
" rodID=" << rodID
1175 <<
" sswID=" << sswID
1176 <<
" rxId=" << rxId);
1193 offset = numOfSector - numOfSector/24;
1196 delete slb; slb =
nullptr;
1204 const bool isEndcap,
1205 const int moduleType,
1218 }
else if(isEndcap) {
1230 <<
" side=" << ((isAside) ?
"A" :
"C")
1231 <<
" region=" << ((isEndcap) ?
"Endcap" :
"Forward")
1232 <<
" type=" << moduleType
1236 if(!slb.
isValid())
return false;
1247 <<
" side=" << ((isAside) ?
"A" :
"C")
1248 <<
" region=" << ((isEndcap) ?
"Endcap" :
"Forward")
1249 <<
" type=" << moduleType
1252 <<
" rodID=" << rodID
1253 <<
" sswID=" << sswID
1254 <<
" sbLoc=" << sbLoc);
1256 if(!
status)
return false;
1266 const int subsectorID,
1269 const int sbLoc)
const
1272 if(!isAside && (subsectorID!=
m_CsideId)) {
1274 <<
" ERROR illegal subsectorID [="
1275 << subsectorID <<
"] ");
1278 int sectorInReadout = (rodID -1);
1284 <<
" ERROR sswID for SL should be 9 [now ="
1289 int offset, numOfSector, sector;
1290 if(0<=sbLoc && sbLoc <= 3) {
1293 offset = numOfSector - numOfSector/24;
1295 phi = (sector + sbLoc +
offset)%numOfSector+1;
1296 }
else if(sbLoc==4 || sbLoc==5) {
1299 offset = numOfSector - numOfSector/24;
1301 phi = (sector + (sbLoc-4) +
offset)% numOfSector+1;
1304 <<
" ERROR illegal sbLoc for SL [="
1315 const int subsectorID,
1318 const bool forward)
const
1321 if(!isAside && (subsectorID!=
m_CsideId)) {
1323 <<
" ERROR illegal subsectorID [="
1324 << subsectorID <<
"] ");
1328 int sectorInReadout = (srodID - 17);
1330 (sectorInReadout < 0)){
1335 int offset, tmpsector, numOfSector;
1339 offset = numOfSector - numOfSector/24;
1341 phi = (sector + tmpsector +
offset)%numOfSector + 1;
1344 offset = numOfSector - numOfSector/24;
1346 phi = (sector + tmpsector +
offset)%numOfSector + 1;
1355 const bool isEndcap,
1371 int sectorInReadout;
1374 sectorInReadout = sector %
1376 sbLoc = sectorInReadout;
1377 rodID = (sector-sectorInReadout)/
1382 sectorInReadout = sector %
1384 sbLoc = sectorInReadout +4;
1385 rodID = (sector-sectorInReadout)/
1399 const bool isEndcap,
1415 int sectorInReadout;
1418 sectorInReadout = sector %
1420 sbLoc = sectorInReadout;
1421 srodID = (sector-sectorInReadout)/
1426 sectorInReadout = sector %
1428 sbLoc = sectorInReadout;
1429 srodID = (sector-sectorInReadout)/
1443 const bool isEndcap,
1465 bool orChannel)
const
1493 int RoiRow =
static_cast<int>(roi/4);
1494 int RoiColumn =
static_cast<int>(roi%4);
1499 case 0: chip=0; hitId=1; sub=0;
break;
1500 case 1: chip=0; hitId=1; sub=1;
break;
1501 case 2: chip=0; hitId=2; sub=0;
break;
1502 case 3: chip=0; hitId=2; sub=1;
break;
1503 case 4: chip=0; hitId=3; sub=0;
break;
1504 case 5: chip=0; hitId=3; sub=1;
break;
1505 case 6: chip=0; hitId=4; sub=0;
break;
1506 case 7: chip=0; hitId=4; sub=1;
break;
1507 case 8: chip=0; hitId=5; sub=0;
break;
1508 case 9: chip=0; hitId=5; sub=1;
break;
1509 case 10: chip=0; hitId=6; sub=0;
break;
1510 case 11: chip=0; hitId=6; sub=1;
break;
1511 case 12: chip=1; hitId=1; sub=0;
break;
1512 case 13: chip=1; hitId=1; sub=1;
break;
1513 case 14: chip=1; hitId=2; sub=0;
break;
1514 case 15: chip=1; hitId=2; sub=1;
break;
1515 default:
status=
false;
break;
1519 case 0: chip=0; hitId=1; sub=1;
break;
1520 case 1: chip=1; hitId=1; sub=0;
break;
1521 case 2: chip=1; hitId=1; sub=1;
break;
1522 case 3: chip=1; hitId=2; sub=0;
break;
1523 case 4: chip=1; hitId=2; sub=1;
break;
1524 case 5: chip=1; hitId=3; sub=0;
break;
1525 case 6: chip=1; hitId=3; sub=1;
break;
1526 case 7: chip=1; hitId=4; sub=0;
break;
1527 case 8: chip=1; hitId=4; sub=1;
break;
1528 case 9: chip=1; hitId=5; sub=0;
break;
1529 case 10: chip=1; hitId=5; sub=1;
break;
1530 case 11: chip=1; hitId=6; sub=0;
break;
1531 case 12: chip=1; hitId=6; sub=1;
break;
1532 case 13: chip=2; hitId=1; sub=0;
break;
1533 case 14: chip=2; hitId=1; sub=1;
break;
1534 case 15: chip=2; hitId=2; sub=0;
break;
1535 case 16: chip=2; hitId=2; sub=1;
break;
1536 case 17: chip=2; hitId=3; sub=0;
break;
1537 case 18: chip=2; hitId=3; sub=1;
break;
1538 case 19: chip=2; hitId=4; sub=0;
break;
1539 case 20: chip=2; hitId=4; sub=1;
break;
1540 case 21: chip=2; hitId=5; sub=0;
break;
1541 case 22: chip=2; hitId=5; sub=1;
break;
1542 case 23: chip=2; hitId=6; sub=0;
break;
1543 case 24: chip=2; hitId=6; sub=1;
break;
1544 case 25: chip=3; hitId=1; sub=0;
break;
1545 case 26: chip=3; hitId=1; sub=1;
break;
1546 case 27: chip=3; hitId=2; sub=0;
break;
1547 case 28: chip=3; hitId=2; sub=1;
break;
1548 case 29: chip=3; hitId=3; sub=0;
break;
1549 case 30: chip=3; hitId=3; sub=1;
break;
1550 case 31: chip=3; hitId=4; sub=0;
break;
1551 case 32: chip=3; hitId=4; sub=1;
break;
1552 case 33: chip=3; hitId=5; sub=0;
break;
1553 case 34: chip=3; hitId=5; sub=1;
break;
1554 case 35: chip=3; hitId=6; sub=0;
break;
1555 case 36: chip=3; hitId=6; sub=1;
break;
1556 default:
status=
false;
break;
1562 case 0: chip=0; hitId=1; sub=0;
break;
1563 case 1: chip=0; hitId=1; sub=1;
break;
1564 case 2: chip=0; hitId=2; sub=0;
break;
1565 case 3: chip=0; hitId=2; sub=1;
break;
1566 default:
status=
false;
break;
1571 if(RoiRow < 5) { chip=0; hitId=1; sub=0; }
1572 else if(RoiRow < 8) { chip=0; hitId=3; sub=0; }
1573 else if(RoiRow < 12) { chip=0; hitId=5; sub=0; }
1574 else if(RoiRow < 25) { chip=1; hitId=1; sub=0; }
1575 else if(RoiRow < 37) { chip=1; hitId=5; sub=0; }
1579 if(RoiRow < 5) { chip=0; hitId=1; sub=1; }
1580 else if(RoiRow < 8) { chip=0; hitId=3; sub=1; }
1581 else if(RoiRow < 12) { chip=0; hitId=5; sub=1; }
1582 else if(RoiRow < 25) { chip=1; hitId=1; sub=1; }
1583 else if(RoiRow < 37) { chip=1; hitId=5; sub=1; }
1587 if(RoiRow < 5) { chip=0; hitId=2; sub=0; }
1588 else if(RoiRow < 8) { chip=0; hitId=4; sub=0; }
1589 else if(RoiRow < 12) { chip=0; hitId=6; sub=0; }
1590 else if(RoiRow < 25) { chip=1; hitId=2; sub=0; }
1591 else if(RoiRow < 37) { chip=1; hitId=6; sub=0; }
1595 if(RoiRow < 5) { chip=0; hitId=2; sub=1; }
1596 else if(RoiRow < 8) { chip=0; hitId=4; sub=1; }
1597 else if(RoiRow < 12) { chip=0; hitId=6; sub=1; }
1598 else if(RoiRow < 25) { chip=1; hitId=2; sub=1; }
1599 else if(RoiRow < 37) { chip=1; hitId=6; sub=1; }
1602 default:
status=
false;
break;
1621 int sub_strip)
const
1630 RoiRow = 12*chip_wire + 2*(hitId_wire - 1) + sub_wire;
1631 RoiColumn = 2*((hitId_strip - 1)%2) + sub_strip;
1632 }
else if(!isForward) {
1633 RoiColumn = 2*((hitId_strip - 1)%2) + sub_strip;
1635 case 0: RoiRow=0;
break;
1638 case 3: RoiRow=12*(chip_wire-1) + 2*(hitId_wire - 1) + sub_wire + 1;
break;
1643 roi = 4*RoiRow + RoiColumn;
1667 if(
index==0 && chip==0) hitId=1;
1668 else if(
index==0 && chip==1) hitId++;
1669 else if(
index==1 && chip==0) {chip=2; hitId++;}
1670 else if(
index==1 && chip==1) {chip=3; hitId++;}
1696 case 0:
index=0; hitId=5;
break;
1697 case 1:
index=0; hitId--;
break;
1698 case 2:
index=1; chip=0; hitId--;
break;
1699 case 3:
index=1; chip=1; hitId--;
break;
1711 const int subDetectorID,
1713 const int sectorInReadout,
1715 const bool isForward,
1719 const int pos)
const
1759 if(!
status)
return false;
1774 int & subDetectorID,
1776 int & sectorInReadout,
1794 if(!
status)
return false;
1816 if(!
status)
return false;
1828 const int subDetectorID,
1851 if(!
status)
return false;
1864 int & subDetectorID,
1880 if(!
status)
return false;
1887 return m_cabling->getLowPtCoincidenceFromReadout(sideType,