ATLAS Offline Software
Loading...
Searching...
No Matches
TgcCablingMap.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
13
14using namespace MuonTGC_Cabling;
15namespace Muon {
16
18 : AthMessaging{"TgcCablingMap"},
19 TGCCabling{cfg},
20 m_idHelperSvc{cfg.idHelperSvc},
21 m_AsideId{cfg.AsideId},
22 m_CsideId{cfg.CsideId} {}
23
25void TgcCablingMap::getReadoutIDRanges(int& maxRodId, int& maxSRodId,
26 int& maxSswId, int& maxSbloc,
27 int& minChannelId,
28 int& maxChannelId) const {
29 maxRodId = TGCCabling::MAXRODID;
30 maxSRodId = TGCCabling::MAXSRODID;
31 maxSswId = TGCCabling::MAXSSWID;
32 maxSbloc = TGCCabling::MAXSBLOC;
33 minChannelId = TGCCabling::MINCHANNELID;
34 maxChannelId = TGCCabling::MAXCHANNELID;
35}
36
39 int& startEndcapSector,
40 int& coverageOfEndcapSector,
41 int& startForwardSector,
42 int& coverageOfForwardSector) const {
43 int sectorInReadout = srodID - 17; // srodID = 17..19
44 if (sectorInReadout >= TGCModuleId::NumberOfSReadoutSector) {
45 return false;
46 }
47
48 coverageOfEndcapSector =
50 startEndcapSector = sectorInReadout * coverageOfEndcapSector;
51 coverageOfForwardSector =
53 startForwardSector = sectorInReadout * coverageOfForwardSector;
54
55 return true;
56}
57
59// Readout ID is ored
60bool TgcCablingMap::isOredChannel(const int subDetectorID, const int rodID,
61 const int sswID, const int sbLoc,
62 const int channelID) const {
63 Identifier id;
64 return getOfflineIDfromReadoutID(id, subDetectorID, rodID, sswID, sbLoc,
65 channelID, true);
66}
67
69// Offline ID has adjacent Readout ID
70bool TgcCablingMap::hasAdjacentChannel(const Identifier& offlineID) const {
71 int subDetectorID{0}, rodID{0}, sswID{0}, sbLoc{0}, channelID{0};
72 return getReadoutIDfromOfflineID(offlineID, subDetectorID, rodID, sswID,
73 sbLoc, channelID, true);
74}
75
77// readout IDs -> offline IDs
79 const int subDetectorID,
80 const int rodID, const int sswID,
81 const int sbLoc,
82 const int channelID,
83 bool orChannel) const {
84 int subsystemNumber{0}, octantNumber{0}, moduleNumber{0}, layerNumber{0},
85 rNumber{0}, wireOrStrip{0}, channelNumber{0};
86
87 // ReadoutID -> OnlineID
88 bool status = getOnlineIDfromReadoutID(
89 subDetectorID, rodID, sswID, sbLoc, channelID, subsystemNumber,
90 octantNumber, moduleNumber, layerNumber, rNumber, wireOrStrip,
91 channelNumber, orChannel);
92 if ((!status) && (!orChannel)) {
93 ATH_MSG_VERBOSE(" getOfflineIDfromReadoutID :"
94 << " Cannot get OnineID for "
95 << " subdetectorID=" << subDetectorID
96 << " rodID=" << rodID << " sswID=" << sswID
97 << " sbLoc=" << sbLoc << " channel=" << channelID
98 << " [ Or =" << orChannel << "] ");
99 }
100 if (!status) {
101 return status;
102 }
103
104 // OnlineID -> OfflineID
105 status = getOfflineIDfromOnlineID(offlineID, subsystemNumber, octantNumber,
106 moduleNumber, layerNumber, rNumber,
107 wireOrStrip, channelNumber);
108
109 if (!status) {
110 ATH_MSG_VERBOSE(" getOfflineIDfromReadoutID :"
111 << " Cannot get OfflineID for "
112 << " side=" << subsystemNumber << " octant="
113 << octantNumber << " module=" << moduleNumber
114 << " layer=" << layerNumber << " chamber=" << rNumber
115 << " w/s=" << wireOrStrip
116 << " channel=" << channelNumber);
117 }
118
119 return status;
120}
121
123// offline IDs -> readout IDs
125 int& subDetectorID, int& rodID,
126 int& sswID, int& sbLoc,
127 int& channelID,
128 bool adChannel) const {
129 int subsystemNumber;
130 int octantNumber;
131 int moduleNumber;
132 int layerNumber;
133 int rNumber;
134 int wireOrStrip;
135 int channelNumber;
136
137 // OfflineID -> OnlineID
138 bool status = getOnlineIDfromOfflineID(
139 offlineID, subsystemNumber, octantNumber, moduleNumber, layerNumber,
140 rNumber, wireOrStrip, channelNumber);
141
142 if (!status) {
143 ATH_MSG_WARNING(" Fail to getOnlineIDfromOfflineID "
144 << " for OfflineID="
145 << m_idHelperSvc->toString(offlineID));
146 return status;
147 }
148
149 ATH_MSG_DEBUG("getOnlineIDfromOfflineID() "
150 << " offlineID=" << offlineID << " onlineID: "
151 << " side=" << subsystemNumber << " octant=" << octantNumber
152 << " module=" << moduleNumber << " layer=" << layerNumber
153 << " chamber=" << rNumber << " w/s=" << wireOrStrip
154 << " channel=" << channelNumber);
155
156 // OnlineID -> ReadoutID
157 status = getReadoutIDfromOnlineID(subDetectorID, rodID, sswID, sbLoc,
158 channelID, subsystemNumber, octantNumber,
159 moduleNumber, layerNumber, rNumber,
160 wireOrStrip, channelNumber, adChannel);
161
162 if (!status) {
163 if (adChannel) {
164 ATH_MSG_DEBUG(" Fail to getReadoutIDfromOnlineID");
165 ATH_MSG_DEBUG(" side=" << subsystemNumber << " octant="
166 << octantNumber << " module=" << moduleNumber
167 << " layer=" << layerNumber << " chamber="
168 << rNumber << " w/s=" << wireOrStrip
169 << " channel=" << channelNumber);
170 } else {
171 ATH_MSG_WARNING(" getReadoutIDfromOnlineID: "
172 << " Cannot get ReadoutID for "
173 << " side=" << subsystemNumber << " octant="
174 << octantNumber << " module=" << moduleNumber
175 << " layer=" << layerNumber
176 << " chamber=" << rNumber << " w/s=" << wireOrStrip
177 << " channel=" << channelNumber);
178 }
179 } else {
180 ATH_MSG_DEBUG(" SUCCESS getReadoutIDfromOnlineID");
181 ATH_MSG_DEBUG(" side=" << subsystemNumber << " octant=" << octantNumber
182 << " module=" << moduleNumber << " layer="
183 << layerNumber << " chamber=" << rNumber
184 << " w/s=" << wireOrStrip << " channel="
185 << channelNumber << "adjacent=" << adChannel);
186 ATH_MSG_DEBUG(" subDetectorID" << subDetectorID << " rodID=" << rodID
187 << " sswID=" << sswID
188 << " channelID=" << channelID);
189 }
190
191 return status;
192}
193
195// offline ID -> online IDs
197 const Identifier& offlineId, int& subSystemNumber, int& octantNumber,
198 int& moduleNumber, int& layerNumber, int& rNumber, int& wireOrStrip,
199 int& channelNumber) const {
200 // get station name in string format : T1F,T1E,T2F...
201 const int iStation = m_idHelperSvc->tgcIdHelper().stationName(offlineId);
202 const int stationType = (iStation - 39) / 2;
203
204 if ((stationType < 1) || (stationType > 4)) {
205 return false;
206 }
207
208 // eta and phi
209 int iEta = m_idHelperSvc->tgcIdHelper().stationEta(offlineId);
210 int iPhi = m_idHelperSvc->tgcIdHelper().stationPhi(offlineId);
211
212 // forward/endcap
213 enum { FORWARD, ENDCAP };
214 const int regionType =
215 m_idHelperSvc->tgcIdHelper().isForward(offlineId) ? FORWARD : ENDCAP;
216
217 // octant index and module index
218 const int sectorEI[] = {-1, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11,
219 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 0};
220 int sector = -1;
221 if (regionType == ENDCAP) {
222 if (stationType != 4) {
223 // Endcap
224 sector = (iPhi + 1) % TGCId::NUM_ENDCAP_SECTOR;
225 } else {
226 // EI
227 sector = sectorEI[iPhi];
228 // iPhi is redefined for internal use
229 if (sector == 0) {
230 iPhi = sector + TGCId::NUM_INNER_SECTOR;
231 } else {
232 iPhi = sector;
233 }
234 }
235 } else {
236 if (stationType != 4) {
237 // Forward
238 sector = iPhi % TGCId::NUM_FORWARD_SECTOR;
239 } else {
240 // FI
241 sector = iPhi % TGCId::NUM_INNER_SECTOR;
242 }
243 }
244 int max_module = (regionType == FORWARD || stationType == 4)
247 max_module /= TGCId::NUM_OCTANT;
248 const int iOctant = static_cast<int>(sector / max_module);
249 const int iModule = sector % max_module;
250
251 // R index
252 const int rIndex = std::abs(iEta);
253
254 // Gas gap
255 const int iGasGap = m_idHelperSvc->tgcIdHelper().gasGap(offlineId);
256
257 // convert to ASD-Out index
258
259 subSystemNumber = (iEta > 0) ? 1 : -1;
260
261 octantNumber = iOctant;
262
263 // module# convention
264 // <---- phi ----
265 //
266 // 7 6 4 3 1 0 11 10 9
267 // 8 5 2 14 13 12
268 //
269 // [M1,M2, M3] [EI/FI]
270
271 // module mapping N/A A B C D E F
272 const int modmapE[7] = {-1, 0, 1, 3, 4, 6, 7};
273 const int modmapF[4] = {-1, 2, 5, 8};
274 const int modmapEI[4] = {-1, 9, 10, 11};
275 const int modmapFI[4] = {-1, 12, 13, 14};
276
277 if (stationType != 4) { // T1, T2, T3
278 if (regionType == ENDCAP) {
279 moduleNumber = modmapE[iModule + 1];
280 rNumber = 5 - rIndex;
281 } else {
282 moduleNumber = modmapF[iModule + 1];
283 rNumber = rIndex - 1;
284 }
285 } else { // TI
286 if (regionType == ENDCAP) {
287 moduleNumber = modmapEI[iModule + 1];
288 rNumber = rIndex - 1; // 0-offset
289 } else {
290 moduleNumber = modmapFI[iModule + 1];
291 rNumber = rIndex - 1;
292 }
293 }
294
295 // layer#
296 // 0, (1), 2, ... 5, 6 (pivot) / 7, 8 (EI/FI)
297 // N/A T1 T2 T3 TI
298 const int lyr_offset[5] = {0, -1, 2, 4, 6};
299 layerNumber = iGasGap + lyr_offset[stationType];
300
301 // wire (0) or strip (1)
302 wireOrStrip = m_idHelperSvc->tgcIdHelper().isStrip(offlineId);
303
304 // Offline ID channel
305 int channel = m_idHelperSvc->tgcIdHelper().channel(offlineId);
306
307 // Offline ID cahnnel -> Online ID channel
308 // T11S : EI @ phi=2,11,13,14,15,19,20,21
309 // total number of wire channel = 16
310 // (T11 : 24 channel)
311 const int OffsetForT11S = 8;
312 // T10S : FI @ phi =2,5,8,11,14,17,20,23
313 // total number of wire channel = 30
314 // (T10 32 channel)
315
316 if ((wireOrStrip == 0) && (stationType == 4)) { // TI wire
317 if (regionType == ENDCAP) { // EI
318 // iPhi here is onlineID from 1 to 24.
319 switch (iPhi) {
320 case 2:
321 case 12:
322 case 14:
323 case 15:
324 case 16:
325 case 22:
326 case 23:
327 case 24:
328 // T11S
329 channel += OffsetForT11S;
330 break;
331 default:
332 break;
333 }
334 }
335 }
336 // SideType
338 if (subSystemNumber == 1) {
339 sideType = TGCId::Aside;
340 }
341 if (subSystemNumber == -1) {
342 sideType = TGCId::Cside;
343 }
344
345 // SignalType
347 if (wireOrStrip == 0) {
348 signalType = TGCId::Wire;
349 }
350 if (wireOrStrip == 1) {
351 signalType = TGCId::Strip;
352 }
353
354 // RegionType
356 if (regionType == FORWARD) {
357 region = TGCId::Forward;
358 }
359 if (regionType == ENDCAP) {
360 region = TGCId::Endcap;
361 }
362
363 // ASDIn
364 TGCChannelASDIn asdin(sideType, signalType, region, iPhi, layerNumber,
365 rIndex, channel);
366 if (!asdin.isValid()) {
367 return false;
368 }
369
370 // offline Id -> online Id
371 std::unique_ptr<TGCChannelId> asdout =
373 if (asdout == nullptr || !asdout->isValid()) {
374 return false;
375 }
376 channelNumber = asdout->getChannel();
377
378 return true;
379}
380
382// online IDs -> offline ID
384 Identifier& offlineId, const int subSystemNumber, const int octantNumber,
385 const int moduleNumber, const int layerNumber, const int rNumber,
386 const int wireOrStrip, const int channelNumber) const {
387 // SideType
389 if (subSystemNumber == 1) {
390 sideType = TGCId::Aside;
391 }
392 if (subSystemNumber == -1) {
393 sideType = TGCId::Cside;
394 }
395
396 // SignalType
398 if (wireOrStrip == 0) {
399 signalType = TGCId::Wire;
400 }
401 if (wireOrStrip == 1) {
402 signalType = TGCId::Strip;
403 }
404
405 ATH_MSG_VERBOSE("getOfflineIDfromOnlineID for "
406 << " side=" << sideType << " octant=" << octantNumber
407 << " module=" << moduleNumber << " layer=" << layerNumber
408 << " chamber=" << rNumber << " w/s=" << signalType
409 << " channel=" << channelNumber);
410
411 // ASDOut
412 TGCChannelASDOut asdout(sideType, signalType, octantNumber, moduleNumber,
413 layerNumber, rNumber, channelNumber);
414 if (!asdout.isValid()) {
415 ATH_MSG_WARNING(" Illegal AsdOut for "
416 << " side=" << sideType << " octant=" << octantNumber
417 << " module=" << moduleNumber
418 << " layer=" << layerNumber << " chamber=" << rNumber
419 << " w/s=" << signalType
420 << " channel=" << channelNumber);
421 return false;
422 }
423
424 // online Id -> offline Id
425 std::unique_ptr<TGCChannelId> asdin =
427 if (!asdin || !asdin->isValid()) {
428 ATH_MSG_WARNING(" getOfflineIDfromOnlineID :"
429 << " Illegal AsdIn for "
430 << " side=" << sideType << " octant=" << octantNumber
431 << " module=" << moduleNumber
432 << " layer=" << layerNumber << " chamber=" << rNumber
433 << " w/s=" << signalType
434 << " channel=" << channelNumber);
435 return false;
436 }
437
438 // build identifier
439 std::string stationNameStr;
440 switch (asdin->getStation()) {
441 case 0: // Triplet
442 stationNameStr = (asdin->isForward()) ? "T1F" : "T1E";
443 break;
444 case 1: // Middle Doublet
445 stationNameStr = (asdin->isForward()) ? "T2F" : "T2E";
446 break;
447 case 2: // Pivot Doublet
448 stationNameStr = (asdin->isForward()) ? "T3F" : "T3E";
449 break;
450 case 3: // Inner
451 stationNameStr = (asdin->isForward()) ? "T4F" : "T4E";
452 break;
453 default:
454 return false;
455 }
456 int stationEta = asdin->getChamber();
457 if (asdin->getSideType() == TGCId::Cside) {
458 stationEta *= -1;
459 }
460 int stationPhi = asdin->getSector();
461 int gasGap = asdin->getGasGap();
462 int isStrip = (asdin->isStrip()) ? 1 : 0;
463 int channel = asdin->getChannel();
464
465 if ((asdin->getStation() == 3) && (asdin->isEndcap())) {
466 // special treatment for EI
467 constexpr std::array<int, 25> phiIE{-1, 1, 2, 3, 4, 5, 6, 7, 8,
468 -1, 9, 10, 11, 12, 13, 14, 15, -1,
469 16, 17, 18, -1, 19, 20, 21};
470 stationPhi = phiIE[asdin->getSector()];
471 if (stationPhi < 0) {
472 return false;
473 }
474 }
475
476 // OnlineID --> OfflineID
477 // T11S : EI @ stationPhi=2,11,13,14,15,19,20,21
478 // total number of wire channel = 16
479 // (T11 24 channel)
480 const int OffsetForT11S = 8;
481 // T10S : FI @ statioPhi =2,5,8,11,14,17,20,23
482 // total number of wire channel = 30
483 // (T10 32 channel)
484 if ((asdin->getStation() == 3) && (!isStrip)) { // Inner Wire
485 if (asdin->isEndcap()) {
486 switch (stationPhi) {
487 case 2:
488 case 11:
489 case 13:
490 case 14:
491 case 15:
492 case 19:
493 case 20:
494 case 21:
495 // T11S
496 channel -= OffsetForT11S;
497 if (channel <= 0) {
498 return false;
499 }
500 break;
501 default:
502 break;
503 }
504 }
505 }
506
507 offlineId = m_idHelperSvc->tgcIdHelper().channelID(
508 stationNameStr, stationEta, stationPhi, gasGap, isStrip, channel);
509
510 return true;
511}
512
513// readout IDs -> online IDs
515 const int subDetectorID, const int rodID, const int sswID, const int sbLoc,
516 const int channelID, int& subsystemNumber, int& octantNumber,
517 int& moduleNumber, int& layerNumber, int& rNumber, int& wireOrStrip,
518 int& channelNumber, bool orChannel) const {
519 // SideType
521 if (subDetectorID == m_AsideId) {
522 sideType = TGCId::Aside;
523 }
524 if (subDetectorID == m_CsideId) {
525 sideType = TGCId::Cside;
526 }
527
528 // readout channel -> chamber channel
529 std::unique_ptr<TGCChannelId> asdout = getASDOutFromReadout(
530 sideType, rodID, sswID, sbLoc, channelID, orChannel);
531 if (asdout == nullptr) {
532 if (!orChannel) {
533 ATH_MSG_VERBOSE(" getOnlineIDfromReadoutID :"
534 << " Cannot get OnlineID of "
535 << " side=" << sideType << " rodID=" << rodID
536 << " sswID=" << sswID << " sbLoc=" << sbLoc
537 << " channel=" << channelID
538 << " [ Or =" << orChannel << "] ");
539 }
540 return false;
541 }
542 if (!asdout->isValid()) {
543 ATH_MSG_WARNING(" getOnlineIDfromReadoutID :"
544 << " Illegal ASDout for "
545 << " side=" << sideType << " rodID=" << rodID
546 << " sswID=" << sswID << " sbLoc=" << sbLoc
547 << " channel=" << channelID << " [ Or =" << orChannel
548 << "] ");
549
550 return false;
551 }
552 // SubsystemNumber
553 subsystemNumber = (asdout->isAside()) ? 1 : -1;
554
555 // OctantNumber
556 octantNumber = asdout->getOctant();
557
558 // RNumber
559 rNumber = asdout->getChamber();
560
561 // ModuleNumber
562 moduleNumber = asdout->getSectorModule();
563
564 layerNumber = asdout->getLayer();
565
566 // WireOrStrip
567 wireOrStrip = (asdout->isStrip()) ? 1 : 0;
568
569 // ChannelNumber
570 channelNumber = asdout->getChannel();
571
572 return true;
573}
574
576// online IDs -> readout IDs
578 int& subDetectorID, int& rodID, int& sswID, int& sbLoc, int& channelID,
579 const int subsystemNumber, const int octantNumber, const int moduleNumber,
580 const int layerNumber, const int rNumber, const int wireOrStrip,
581 const int channelNumber, bool adChannel) const {
582 // SideType
584 if (subsystemNumber == 1) {
585 sideType = TGCId::Aside;
586 }
587 if (subsystemNumber == -1) {
588 sideType = TGCId::Cside;
589 }
590
591 // SignalType
593 if (wireOrStrip == 0) {
594 signalType = TGCId::Wire;
595 }
596 if (wireOrStrip == 1) {
597 signalType = TGCId::Strip;
598 }
599
600 // ASDOut
601 TGCChannelASDOut asdout(sideType, signalType, octantNumber, moduleNumber,
602 layerNumber, rNumber, channelNumber);
603 if (!asdout.isValid()) {
604 ATH_MSG_WARNING(" getReadoutIDfromOnlineID() :"
605 << " Cannot get ASDout for "
606 << " side=" << sideType << " signal=" << signalType
607 << " octant=" << octantNumber
608 << " module=" << moduleNumber
609 << " layer=" << layerNumber << " chamber=" << rNumber
610 << " channel=" << channelNumber);
611 }
612
613 if (!asdout.isValid()) {
614 return false;
615 }
616
617 // chamber channel -> readout channel
618 bool status = getReadoutFromASDOut(asdout, sideType, rodID, sswID, sbLoc,
619 channelID, adChannel);
620 if (!status) {
621 if (adChannel) {
622 ATH_MSG_DEBUG("getReadoutIDfromASDOut fails for adjacent");
623 } else {
624 ATH_MSG_WARNING(" getReadoutIDfromASDOut :"
625 << " Cannot get ReadoutID for "
626 << " side=" << sideType << " signal=" << signalType
627 << " octant=" << octantNumber << " module="
628 << moduleNumber << " layer=" << layerNumber
629 << " chamber=" << rNumber
630 << " channel=" << channelNumber);
631 }
632 return false;
633 }
634
635 // SubDetectorID
636 if (sideType == TGCId::Aside) {
637 subDetectorID = m_AsideId;
638 }
639 if (sideType == TGCId::Cside) {
640 subDetectorID = m_CsideId;
641 }
642
643 return status;
644}
645
646// element ID -> readout IDs
648 int& subdetectorID,
649 int& rodID) const {
650 // get station name in string format : T1F,T1E,T2F...
651 const int iStation = m_idHelperSvc->tgcIdHelper().stationName(elementID);
652 const int stationType = (iStation - 39) / 2;
653
654 int iEta = m_idHelperSvc->tgcIdHelper().stationEta(elementID);
655 int iPhi = m_idHelperSvc->tgcIdHelper().stationPhi(elementID);
656
657 // forward/endcap
658 enum { FORWARD, ENDCAP };
659 const int regionType =
660 m_idHelperSvc->tgcIdHelper().isForward(elementID) ? FORWARD : ENDCAP;
661
662 // SideType
663 subdetectorID = (iEta > 0) ? m_AsideId : m_CsideId;
664
665 // sector index and module index
666 const int max_phi = (regionType == FORWARD || stationType == 4)
669 const int max_module = max_phi / TGCId::N_RODS;
670 const int sector = ((iPhi - 1) + max_phi / 24 + max_phi) % max_phi;
671 int readoutSector = static_cast<int>(sector / max_module);
672 // Inner case
673 if (stationType == 4) {
674 readoutSector = (readoutSector / 3);
675 readoutSector = 3 * readoutSector + 1;
676 }
677
678 rodID = readoutSector + 1;
679
680 return true;
681}
682
684// readout IDs -> element ID
686 const int subDetectorID,
687 const int rodID, const int sswID,
688 const int sbLoc,
689 const int channelID,
690 bool orChannel) const {
691 Identifier offlineID;
692
693 // get min/max values for ReadoutID parameters
694 int maxRodId, maxSRodId, maxSswId, maxSbloc, minChannelId, maxChannelId;
695 getReadoutIDRanges(maxRodId, maxSRodId, maxSswId, maxSbloc, minChannelId,
696 maxChannelId);
697
698 // check sswID and channelID in allowed range
699 if ((sswID > maxSswId) || (channelID < minChannelId) ||
700 (channelID > maxChannelId)) {
701 ATH_MSG_DEBUG(" getElementIDfromReadoutID() :"
702 << " Illeagal channel ID"
703 << " subdetectorID=" << subDetectorID
704 << " rodID=" << rodID << " sswID=" << sswID
705 << " sbLoc=" << sbLoc << " channel=" << channelID
706 << " [ Or =" << orChannel << "] ");
707 return false;
708 }
709
710 bool status = getOfflineIDfromReadoutID(offlineID, subDetectorID, rodID,
711 sswID, sbLoc, channelID, orChannel);
712 if (!status) {
714 " getElementIDfromReadoutID :" << " Cannot get OfflineID ");
715 return false;
716 }
717
718 elementID = m_idHelperSvc->tgcIdHelper().elementID(offlineID);
719 return true;
720}
721
723// readout ID -> SLB ID
725 bool& isEndcap, int& moduleType,
726 int& id, const int subsectorID,
727 const int rodID, const int sswID,
728 const int sbLoc) const {
729 isAside = (subsectorID == m_AsideId);
730
731 TGCId::SideType side = isAside ? TGCId::Aside : TGCId::Cside;
732
733 const TGCModuleId* slb = getSLBFromReadout(side, rodID, sswID, sbLoc);
734 if (!slb) {
735 ATH_MSG_VERBOSE(" getSLBIDfromReadoutID :"
736 << " Cannot get SLB of "
737 << " side" << side << " rodID=" << rodID
738 << " sswID=" << sswID << " sbLoc=" << sbLoc);
739 return false;
740 }
741
742 isEndcap = (slb->getRegionType() == TGCId::Endcap);
743 moduleType = (int)slb->getModuleType();
744 bool isInner = (moduleType == TGCId::WI || moduleType == TGCId::SI);
745 int offset, numOfSector;
746 if (isInner) {
747 numOfSector = TGCId::NUM_INNER_SECTOR;
748 } else {
749 if (isEndcap) {
750 numOfSector = TGCId::NUM_ENDCAP_SECTOR;
751 } else {
752 numOfSector = TGCId::NUM_FORWARD_SECTOR;
753 }
754 }
755 offset = numOfSector - numOfSector / 24;
756 phi = (slb->getSector() + offset) % numOfSector + 1;
757 id = slb->getId();
758
759 return true;
760}
761
763// readout ID -> rxID
765 const int subsectorID,
766 const int rodID, const int sswID,
767 const int sbLoc) const {
768 slbAddr = -1;
769
770 bool isAside = (subsectorID == m_AsideId);
771
772 TGCId::SideType side = isAside ? TGCId::Aside : TGCId::Cside;
773
774 const TGCModuleId* slb = getSLBFromReadout(side, rodID, sswID, sbLoc);
775 if (!slb) {
776 ATH_MSG_WARNING(" getSLBAddressfromReadoutID :"
777 << " Cannot get SLB of "
778 << " side" << side << " rodID=" << rodID
779 << " sswID=" << sswID << " sbLoc=" << sbLoc);
780 return false;
781 }
782
783 const TGCModuleSLB* modSlb = dynamic_cast<const TGCModuleSLB*>(slb);
784 if (!modSlb) {
785 ATH_MSG_WARNING("TgcCablingMap::getSLBAddressfromReadoutID "
786 << "dynamic_cast<const "
787 "TGCModuleSLB*>(slb) failed.");
788 return false;
789 }
790
791 slbAddr = modSlb->getSlbAddr();
792 return true;
793}
794
796// ROD_ID / SSW_ID / RX_ID -> SLB ID
797bool TgcCablingMap::getSLBIDfromRxID(int& phi, bool& isAside, bool& isEndcap,
798 int& moduleType, int& id,
799 const int subsectorID, const int rodID,
800 const int sswID, const int rxId) const {
801 isAside = (subsectorID == m_AsideId);
802 TGCId::SideType side = isAside ? TGCId::Aside : TGCId::Cside;
803
804 std::unique_ptr<TGCModuleId> slb = getSLBFromRxId(side, rodID, sswID, rxId);
805 if (!slb) {
806 ATH_MSG_WARNING("geSLBIDfromRxID :" << " Cannot get SLB of "
807 << " side" << side << " rodID="
808 << rodID << " sswID=" << sswID
809 << " rxId=" << rxId);
810 return false;
811 }
812
813 isEndcap = (slb->getRegionType() == TGCId::Endcap);
814 moduleType = (int)slb->getModuleType();
815 bool isInner = (moduleType == TGCId::WI || moduleType == TGCId::SI);
816 int offset, numOfSector;
817 if (isInner) {
818 numOfSector = TGCId::NUM_INNER_SECTOR;
819 } else {
820 if (isEndcap) {
821 numOfSector = TGCId::NUM_ENDCAP_SECTOR;
822 } else {
823 numOfSector = TGCId::NUM_FORWARD_SECTOR;
824 }
825 }
826 offset = numOfSector - numOfSector / 24;
827 phi = (slb->getSector() + offset) % numOfSector + 1;
828 id = slb->getId();
829 return true;
830}
831
833// SLB ID -> readout ID
834bool TgcCablingMap::getReadoutIDfromSLBID(const int phi, const bool isAside,
835 const bool isEndcap,
836 const int moduleType, const int id,
837 int& subsectorID, int& rodID,
838 int& sswID, int& sbLoc) const {
839 TGCId::ModuleType module = static_cast<TGCId::ModuleType>(moduleType);
840 TGCId::RegionType region = isEndcap ? TGCId::Endcap : TGCId::Forward;
841 bool isInner = (module == TGCId::WI || module == TGCId::SI);
842 int sector = -1; // sector=0-47(EC), 0-23(FWD), 0-23(INNER)
843 if (isInner) {
844 sector = phi % TGCId::NUM_INNER_SECTOR;
845 } else if (isEndcap) {
846 sector = (phi + 1) % TGCId::NUM_ENDCAP_SECTOR;
847 } else {
849 }
850 TGCId::SideType side = isAside ? TGCId::Aside : TGCId::Cside;
851
852 TGCModuleSLB slb(side, module, region, sector, id);
853
854 if (!slb.isValid()) {
855 ATH_MSG_WARNING("getReadoutIDfromSLBID "
856 << " phi=" << phi << " side=" << ((isAside) ? "A" : "C")
857 << " region=" << ((isEndcap) ? "Endcap" : "Forward")
858 << " type=" << moduleType << " id=" << id
859 << " Invalid SLB");
860 }
861 if (!slb.isValid()) {
862 return false;
863 }
864
865 subsectorID = (isAside ? m_AsideId : m_CsideId);
866
867 bool status = getReadoutFromSLB(slb, side, rodID, sswID, sbLoc);
868
869 if (!status) {
870 ATH_MSG_DEBUG(" FAIL getReadoutIDfromSLBID");
871 return false;
872 }
873 ATH_MSG_DEBUG(" SUCCESS getReadoutIDfromSLBID");
874 ATH_MSG_DEBUG(" phi=" << phi
875 << " side=" << ((isAside) ? "A" : "C")
876 << " region=" << ((isEndcap) ? "Endcap" : "Forward")
877 << " type=" << moduleType << " id=" << id << " side"
878 << side << " rodID=" << rodID << " sswID=" << sswID
879 << " sbLoc=" << sbLoc);
880 return true;
881}
882
884// readout ID -> SL ID
886 bool& isEndcap, const int subsectorID,
887 const int rodID, const int sswID,
888 const int sbLoc) const {
889 isAside = (subsectorID == m_AsideId);
890 if (!isAside && (subsectorID != m_CsideId)) {
891 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
892 << " ERROR illegal subsectorID [=" << subsectorID
893 << "] ");
894 return false;
895 }
896 int sectorInReadout = (rodID - 1); // rodID = 1..12 for both sides
897 if (sectorInReadout >= TGCId::N_RODS) {
898 return false;
899 }
900
901 // sswID check removed
902 if (sswID != 9) {
903 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
904 << " ERROR sswID for SL should be 9 [now =" << sswID
905 << "] ");
906 return false;
907 }
908
909 int offset, numOfSector, sector;
910 if (0 <= sbLoc && sbLoc <= 3) {
911 isEndcap = true;
912 numOfSector = TGCId::NUM_ENDCAP_SECTOR; // 48
913 offset = numOfSector - numOfSector / 24; // 48 - 2 = 46
914 sector = numOfSector * sectorInReadout / TGCId::N_RODS;
915 phi = (sector + sbLoc + offset) % numOfSector + 1;
916 } else if (sbLoc == 4 || sbLoc == 5) {
917 isEndcap = false;
918 numOfSector = TGCId::NUM_FORWARD_SECTOR;
919 offset = numOfSector - numOfSector / 24;
920 sector = numOfSector * sectorInReadout / TGCId::N_RODS;
921 phi = (sector + (sbLoc - 4) + offset) % numOfSector + 1;
922 } else {
923 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
924 << " ERROR illegal sbLoc for SL [=" << sbLoc << "] ");
925 return false;
926 }
927 return true;
928}
929
931// readout ID (only SROD) -> SL ID
933 const int subsectorID,
934 const int srodID, const int sector,
935 const bool forward) const {
936 isAside = (subsectorID == m_AsideId);
937 if (!isAside && (subsectorID != m_CsideId)) {
938 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
939 << " ERROR illegal subsectorID [=" << subsectorID
940 << "] ");
941 return false;
942 }
943
944 int sectorInReadout = (srodID - 17); // 0-2, srodID : 0x11-0x13 (17-19)
945 if ((sectorInReadout >= TGCModuleId::NumberOfSReadoutSector) ||
946 (sectorInReadout < 0)) {
947 ATH_MSG_WARNING(" Invalid SROD ID : " << srodID);
948 return false;
949 }
950
951 int offset, tmpsector, numOfSector;
952 // sswID check removed
953 if (forward) {
954 numOfSector = TGCId::NUM_FORWARD_SECTOR;
955 offset = numOfSector - numOfSector / 24; // 24 - 1
956 tmpsector = numOfSector * sectorInReadout /
958 phi = (sector + tmpsector + offset) % numOfSector + 1;
959 } else {
960 numOfSector = TGCId::NUM_ENDCAP_SECTOR;
961 offset = numOfSector - numOfSector / 24; // 48 - 2
962 tmpsector = numOfSector * sectorInReadout /
964 phi = (sector + tmpsector + offset) % numOfSector + 1;
965 }
966 return true;
967}
968
970// SL ID -> readout ID
971bool TgcCablingMap::getReadoutIDfromSLID(const int phi, const bool isAside,
972 const bool isEndcap, int& subsectorID,
973 int& rodID, int& sswID,
974 int& sbLoc) const {
975 if (isAside) {
976 subsectorID = m_AsideId;
977 } else {
978 subsectorID = m_CsideId;
979 }
980
981 if (isEndcap) {
983 return false;
984 }
985 } else {
987 return false;
988 }
989 }
990
991 int sector;
992 int sectorInReadout;
993 if (isEndcap) {
994 sector = (phi + 1) % TGCId::NUM_ENDCAP_SECTOR;
995 sectorInReadout = sector % (TGCId::NUM_ENDCAP_SECTOR / TGCId::N_RODS);
996 sbLoc = sectorInReadout;
997 rodID = (sector - sectorInReadout) /
999 1;
1000 } else {
1001 sector = phi % TGCId::NUM_FORWARD_SECTOR;
1002 sectorInReadout = sector % (TGCId::NUM_FORWARD_SECTOR / TGCId::N_RODS);
1003 sbLoc = sectorInReadout + 4;
1004 rodID = (sector - sectorInReadout) /
1006 1;
1007 }
1008 // Fixed SSWID for SL
1009 sswID = 9;
1010
1011 return true;
1012}
1013
1015// SL ID -> readout ID
1016bool TgcCablingMap::getSReadoutIDfromSLID(const int phi, const bool isAside,
1017 const bool isEndcap, int& subsectorID,
1018 int& srodID, int& sswID,
1019 int& sbLoc) const {
1020 if (isAside) {
1021 subsectorID = m_AsideId;
1022 } else {
1023 subsectorID = m_CsideId;
1024 }
1025
1026 if (isEndcap) {
1028 return false;
1029 }
1030 } else {
1032 return false;
1033 }
1034 }
1035
1036 int sector;
1037 int sectorInReadout;
1038 if (isEndcap) {
1039 sector = (phi + 1) % TGCId::NUM_ENDCAP_SECTOR;
1040 sectorInReadout =
1041 sector %
1043 TGCModuleId::NumberOfSReadoutSector); // [2-48, 1] % (48/3)
1044 sbLoc = sectorInReadout;
1045 srodID =
1046 (sector - sectorInReadout) / (TGCId::NUM_ENDCAP_SECTOR /
1048 0x11;
1049 } else {
1050 sector = phi % TGCId::NUM_FORWARD_SECTOR;
1051 sectorInReadout =
1052 sector %
1054 TGCModuleId::NumberOfSReadoutSector); // [2-23, 1] % (24/3)
1055 sbLoc = sectorInReadout;
1056 srodID =
1057 (sector - sectorInReadout) / (TGCId::NUM_FORWARD_SECTOR /
1059 0x11;
1060 }
1061 // Fixed SSWID for SL
1062 sswID = 9;
1063
1064 return true;
1065}
1066
1068// HPT ID -> readout ID
1069bool TgcCablingMap::getReadoutIDfromHPTID(const int phi, const bool isAside,
1070 const bool isEndcap, const bool,
1071 const int, int& subsectorID,
1072 int& rodID, int& sswID,
1073 int& sbLoc) const {
1074 return getReadoutIDfromSLID(phi, isAside, isEndcap, subsectorID, rodID,
1075 sswID, sbLoc);
1076}
1077
1079// CAUTION!!: return RDO value (not the value for simulation)
1080bool TgcCablingMap::getHighPtIDfromROINumber(int roi, bool isForward,
1081 bool isStrip, int& hpb, int& chip,
1082 int& hitId, int& sub) const {
1083 // for Strip, there is some ambiguity in the relation between hitID and ROI
1084 bool status = true;
1085 int RoiRow = static_cast<int>(roi / 4);
1086 int RoiColumn = static_cast<int>(roi % 4);
1087
1088 if (!isStrip) {
1089 if (isForward) {
1090 switch (RoiRow) {
1091 case 0:
1092 chip = 0;
1093 hitId = 1;
1094 sub = 0;
1095 break;
1096 case 1:
1097 chip = 0;
1098 hitId = 1;
1099 sub = 1;
1100 break;
1101 case 2:
1102 chip = 0;
1103 hitId = 2;
1104 sub = 0;
1105 break;
1106 case 3:
1107 chip = 0;
1108 hitId = 2;
1109 sub = 1;
1110 break;
1111 case 4:
1112 chip = 0;
1113 hitId = 3;
1114 sub = 0;
1115 break;
1116 case 5:
1117 chip = 0;
1118 hitId = 3;
1119 sub = 1;
1120 break;
1121 case 6:
1122 chip = 0;
1123 hitId = 4;
1124 sub = 0;
1125 break;
1126 case 7:
1127 chip = 0;
1128 hitId = 4;
1129 sub = 1;
1130 break;
1131 case 8:
1132 chip = 0;
1133 hitId = 5;
1134 sub = 0;
1135 break;
1136 case 9:
1137 chip = 0;
1138 hitId = 5;
1139 sub = 1;
1140 break;
1141 case 10:
1142 chip = 0;
1143 hitId = 6;
1144 sub = 0;
1145 break;
1146 case 11:
1147 chip = 0;
1148 hitId = 6;
1149 sub = 1;
1150 break;
1151 case 12:
1152 chip = 1;
1153 hitId = 1;
1154 sub = 0;
1155 break;
1156 case 13:
1157 chip = 1;
1158 hitId = 1;
1159 sub = 1;
1160 break;
1161 case 14:
1162 chip = 1;
1163 hitId = 2;
1164 sub = 0;
1165 break;
1166 case 15:
1167 chip = 1;
1168 hitId = 2;
1169 sub = 1;
1170 break;
1171 default:
1172 status = false;
1173 break;
1174 }
1175 } else {
1176 switch (RoiRow) {
1177 case 0:
1178 chip = 0;
1179 hitId = 1;
1180 sub = 1;
1181 break;
1182 case 1:
1183 chip = 1;
1184 hitId = 1;
1185 sub = 0;
1186 break;
1187 case 2:
1188 chip = 1;
1189 hitId = 1;
1190 sub = 1;
1191 break;
1192 case 3:
1193 chip = 1;
1194 hitId = 2;
1195 sub = 0;
1196 break;
1197 case 4:
1198 chip = 1;
1199 hitId = 2;
1200 sub = 1;
1201 break;
1202 case 5:
1203 chip = 1;
1204 hitId = 3;
1205 sub = 0;
1206 break;
1207 case 6:
1208 chip = 1;
1209 hitId = 3;
1210 sub = 1;
1211 break;
1212 case 7:
1213 chip = 1;
1214 hitId = 4;
1215 sub = 0;
1216 break;
1217 case 8:
1218 chip = 1;
1219 hitId = 4;
1220 sub = 1;
1221 break;
1222 case 9:
1223 chip = 1;
1224 hitId = 5;
1225 sub = 0;
1226 break;
1227 case 10:
1228 chip = 1;
1229 hitId = 5;
1230 sub = 1;
1231 break;
1232 case 11:
1233 chip = 1;
1234 hitId = 6;
1235 sub = 0;
1236 break;
1237 case 12:
1238 chip = 1;
1239 hitId = 6;
1240 sub = 1;
1241 break;
1242 case 13:
1243 chip = 2;
1244 hitId = 1;
1245 sub = 0;
1246 break;
1247 case 14:
1248 chip = 2;
1249 hitId = 1;
1250 sub = 1;
1251 break;
1252 case 15:
1253 chip = 2;
1254 hitId = 2;
1255 sub = 0;
1256 break;
1257 case 16:
1258 chip = 2;
1259 hitId = 2;
1260 sub = 1;
1261 break;
1262 case 17:
1263 chip = 2;
1264 hitId = 3;
1265 sub = 0;
1266 break;
1267 case 18:
1268 chip = 2;
1269 hitId = 3;
1270 sub = 1;
1271 break;
1272 case 19:
1273 chip = 2;
1274 hitId = 4;
1275 sub = 0;
1276 break;
1277 case 20:
1278 chip = 2;
1279 hitId = 4;
1280 sub = 1;
1281 break;
1282 case 21:
1283 chip = 2;
1284 hitId = 5;
1285 sub = 0;
1286 break;
1287 case 22:
1288 chip = 2;
1289 hitId = 5;
1290 sub = 1;
1291 break;
1292 case 23:
1293 chip = 2;
1294 hitId = 6;
1295 sub = 0;
1296 break;
1297 case 24:
1298 chip = 2;
1299 hitId = 6;
1300 sub = 1;
1301 break;
1302 case 25:
1303 chip = 3;
1304 hitId = 1;
1305 sub = 0;
1306 break;
1307 case 26:
1308 chip = 3;
1309 hitId = 1;
1310 sub = 1;
1311 break;
1312 case 27:
1313 chip = 3;
1314 hitId = 2;
1315 sub = 0;
1316 break;
1317 case 28:
1318 chip = 3;
1319 hitId = 2;
1320 sub = 1;
1321 break;
1322 case 29:
1323 chip = 3;
1324 hitId = 3;
1325 sub = 0;
1326 break;
1327 case 30:
1328 chip = 3;
1329 hitId = 3;
1330 sub = 1;
1331 break;
1332 case 31:
1333 chip = 3;
1334 hitId = 4;
1335 sub = 0;
1336 break;
1337 case 32:
1338 chip = 3;
1339 hitId = 4;
1340 sub = 1;
1341 break;
1342 case 33:
1343 chip = 3;
1344 hitId = 5;
1345 sub = 0;
1346 break;
1347 case 34:
1348 chip = 3;
1349 hitId = 5;
1350 sub = 1;
1351 break;
1352 case 35:
1353 chip = 3;
1354 hitId = 6;
1355 sub = 0;
1356 break;
1357 case 36:
1358 chip = 3;
1359 hitId = 6;
1360 sub = 1;
1361 break;
1362 default:
1363 status = false;
1364 break;
1365 }
1366 }
1367 } else if (isStrip) {
1368 if (isForward) {
1369 switch (RoiColumn) {
1370 case 0:
1371 chip = 0;
1372 hitId = 1;
1373 sub = 0;
1374 break;
1375 case 1:
1376 chip = 0;
1377 hitId = 1;
1378 sub = 1;
1379 break;
1380 case 2:
1381 chip = 0;
1382 hitId = 2;
1383 sub = 0;
1384 break;
1385 case 3:
1386 chip = 0;
1387 hitId = 2;
1388 sub = 1;
1389 break;
1390 default:
1391 status = false;
1392 break;
1393 }
1394 } else {
1395 switch (RoiColumn) {
1396 case 0:
1397 if (RoiRow < 5) {
1398 chip = 0;
1399 hitId = 1;
1400 sub = 0;
1401 } else if (RoiRow < 8) {
1402 chip = 0;
1403 hitId = 3;
1404 sub = 0;
1405 } else if (RoiRow < 12) {
1406 chip = 0;
1407 hitId = 5;
1408 sub = 0;
1409 } else if (RoiRow < 25) {
1410 chip = 1;
1411 hitId = 1;
1412 sub = 0;
1413 } else if (RoiRow < 37) {
1414 chip = 1;
1415 hitId = 5;
1416 sub = 0;
1417 } else {
1418 status = false;
1419 }
1420 break;
1421 case 1:
1422 if (RoiRow < 5) {
1423 chip = 0;
1424 hitId = 1;
1425 sub = 1;
1426 } else if (RoiRow < 8) {
1427 chip = 0;
1428 hitId = 3;
1429 sub = 1;
1430 } else if (RoiRow < 12) {
1431 chip = 0;
1432 hitId = 5;
1433 sub = 1;
1434 } else if (RoiRow < 25) {
1435 chip = 1;
1436 hitId = 1;
1437 sub = 1;
1438 } else if (RoiRow < 37) {
1439 chip = 1;
1440 hitId = 5;
1441 sub = 1;
1442 } else {
1443 status = false;
1444 }
1445 break;
1446 case 2:
1447 if (RoiRow < 5) {
1448 chip = 0;
1449 hitId = 2;
1450 sub = 0;
1451 } else if (RoiRow < 8) {
1452 chip = 0;
1453 hitId = 4;
1454 sub = 0;
1455 } else if (RoiRow < 12) {
1456 chip = 0;
1457 hitId = 6;
1458 sub = 0;
1459 } else if (RoiRow < 25) {
1460 chip = 1;
1461 hitId = 2;
1462 sub = 0;
1463 } else if (RoiRow < 37) {
1464 chip = 1;
1465 hitId = 6;
1466 sub = 0;
1467 } else {
1468 status = false;
1469 }
1470 break;
1471 case 3:
1472 if (RoiRow < 5) {
1473 chip = 0;
1474 hitId = 2;
1475 sub = 1;
1476 } else if (RoiRow < 8) {
1477 chip = 0;
1478 hitId = 4;
1479 sub = 1;
1480 } else if (RoiRow < 12) {
1481 chip = 0;
1482 hitId = 6;
1483 sub = 1;
1484 } else if (RoiRow < 25) {
1485 chip = 1;
1486 hitId = 2;
1487 sub = 1;
1488 } else if (RoiRow < 37) {
1489 chip = 1;
1490 hitId = 6;
1491 sub = 1;
1492 } else {
1493 status = false;
1494 }
1495 break;
1496 default:
1497 status = false;
1498 break;
1499 }
1500 }
1501 }
1502
1503 hpb = 0;
1504
1505 return status;
1506}
1507
1509bool TgcCablingMap::getROINumberfromHighPtID(int& roi, bool isForward,
1510 int, // hpb_wire
1511 int chip_wire, int hitId_wire,
1512 int sub_wire,
1513 int, // chip_strip
1514 int hitId_strip,
1515 int sub_strip) const {
1516 // for Strip, there is some ambiguity in the relation between hitID and ROI
1517 // CAUTION!!: return RDO value (not the value for simulation)
1518 bool status = true;
1519 int RoiRow = 0;
1520 int RoiColumn = 0;
1521
1522 if (isForward) {
1523 RoiRow = 12 * chip_wire + 2 * (hitId_wire - 1) + sub_wire;
1524 RoiColumn = 2 * ((hitId_strip - 1) % 2) + sub_strip;
1525 } else if (!isForward) {
1526 RoiColumn = 2 * ((hitId_strip - 1) % 2) + sub_strip;
1527 switch (chip_wire) {
1528 case 0:
1529 RoiRow = 0;
1530 break;
1531 case 1:
1532 case 2:
1533 case 3:
1534 RoiRow =
1535 12 * (chip_wire - 1) + 2 * (hitId_wire - 1) + sub_wire + 1;
1536 break;
1537 default:
1538 break;
1539 }
1540 }
1541
1542 roi = 4 * RoiRow + RoiColumn;
1543
1544 return status;
1545}
1546
1548// HighPtID used in Simulation -> HighPtID in RDO
1550 const bool isStrip,
1551 int& index, int& chip,
1552 int& hitId) const {
1553 if (isForward) {
1554 if (isStrip) { // FS
1555 index = 0;
1556 hitId--;
1557 } else if (!isStrip) { // FW
1558 index = 0;
1559 hitId++;
1560 }
1561 } else {
1562 if (isStrip) { // ES
1563 index = 0;
1564 hitId++;
1565 } else if (!isStrip) { // EW
1566 if (index == 0 && chip == 0) {
1567 hitId = 1;
1568 } else if (index == 0 && chip == 1) {
1569 hitId++;
1570 } else if (index == 1 && chip == 0) {
1571 chip = 2;
1572 hitId++;
1573 } else if (index == 1 && chip == 1) {
1574 chip = 3;
1575 hitId++;
1576 }
1577 }
1578 }
1579
1580 return true;
1581}
1582
1584// HighPtID in RDO -> HighPtID used in Simulation
1586 const bool isStrip,
1587 int& index, int& chip,
1588 int& hitId) const {
1589 if (isForward) {
1590 if (isStrip) { // FS
1591 index = 0;
1592 hitId++;
1593 } else if (!isStrip) { // FW
1594 index = 0;
1595 hitId--;
1596 }
1597 } else {
1598 if (isStrip) { // ES
1599 index = 0;
1600 hitId--;
1601 } else if (!isStrip) { // EW
1602 switch (chip) {
1603 case 0:
1604 index = 0;
1605 hitId = 5;
1606 break;
1607 case 1:
1608 index = 0;
1609 hitId--;
1610 break;
1611 case 2:
1612 index = 1;
1613 chip = 0;
1614 hitId--;
1615 break;
1616 case 3:
1617 index = 1;
1618 chip = 1;
1619 hitId--;
1620 break;
1621 default:
1622 break;
1623 }
1624 }
1625 }
1626
1627 return true;
1628}
1629
1631// high pt coincidence IDs -> offline IDs
1633 Identifier& offlineID, const int subDetectorID, const int rodID,
1634 const int sectorInReadout, const bool isStrip, const bool isForward,
1635 const int hpb, const int chip, const int hitID, const int pos) const {
1636 // all input is derived from TgcRawData
1637 int sswID = -1;
1638 int sbLoc = -1;
1639 int channelID = -1;
1640
1641 // SideType
1643 if (subDetectorID == m_AsideId) {
1644 sideType = TGCId::Aside;
1645 }
1646 if (subDetectorID == m_CsideId) {
1647 sideType = TGCId::Cside;
1648 }
1649
1650 // SignalType, RegionType
1651 TGCId::SignalType signalType = (isStrip) ? TGCId::Strip : TGCId::Wire;
1652 TGCId::RegionType regionType = (isForward) ? TGCId::Forward : TGCId::Endcap;
1653
1654 // ModuleType
1656 if (signalType == TGCId::Wire) {
1657 moduleType = TGCId::WD;
1658 } else {
1659 moduleType = TGCId::SD;
1660 }
1661
1662 // Get ReadoutID for pivot plane
1663 bool status = getReadoutFromHighPtID(
1664 sideType, rodID, sswID, sbLoc, channelID, signalType, regionType,
1665 sectorInReadout, hpb, chip, hitID, pos, moduleType, false);
1666
1667 if (!status) {
1668 return false;
1669 }
1670
1671 // get OfflineID for pivot plane
1672 return getOfflineIDfromReadoutID(offlineID, subDetectorID, rodID, sswID,
1673 sbLoc, channelID);
1674}
1675
1677// offline IDs -> high pt coincidence IDs
1679 int& subDetectorID, int& rodID,
1680 int& sectorInReadout,
1681 bool& isStrip, bool& isForward,
1682 int& hpb, int& chip, int& hitID,
1683 int& pos) const {
1684 int sswID = -1;
1685 int sbLoc = -1;
1686 int channelID = -1;
1687
1688 bool status = getReadoutIDfromOfflineID(offlineID, subDetectorID, rodID,
1689 sswID, sbLoc, channelID);
1690 if (!status) {
1691 return false;
1692 }
1693
1694 // SideType
1696 if (subDetectorID == m_AsideId) {
1697 sideType = TGCId::Aside;
1698 }
1699 if (subDetectorID == m_CsideId) {
1700 sideType = TGCId::Cside;
1701 }
1702
1703 TGCId::SignalType signalType;
1704 TGCId::RegionType regionType;
1705
1706 status = getHighPtIDFromReadout(sideType, rodID, sswID, sbLoc, channelID,
1707 signalType, regionType, sectorInReadout,
1708 hpb, chip, hitID, pos);
1709 if (!status) {
1710 return false;
1711 }
1712
1713 isStrip = (signalType == TGCId::Strip);
1714 isForward = (regionType == TGCId::Forward);
1715
1716 return true;
1717}
1718
1720// low pt coincidence IDs -> offline IDs
1722 Identifier& offlineID, const int subDetectorID, const int rodID,
1723 const int sswID, const int sbLoc, const int block, const int pos,
1724 bool middle) const {
1725 int channelID = -1;
1726
1727 // SideType
1729 if (subDetectorID == m_AsideId) {
1730 sideType = TGCId::Aside;
1731 }
1732 if (subDetectorID == m_CsideId) {
1733 sideType = TGCId::Cside;
1734 }
1735
1736 bool status = getReadoutFromLowPtCoincidence(sideType, rodID, sswID, sbLoc,
1737 channelID, block, pos, middle);
1738 if (!status) {
1739 return false;
1740 }
1741
1742 return getOfflineIDfromReadoutID(offlineID, subDetectorID, rodID, sswID,
1743 sbLoc, channelID);
1744}
1745
1746} // namespace Muon
#define FORWARD
Scalar phi() const
phi method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
bool getReadoutFromLowPtCoincidence(TGCId::SideType side, int rodId, int sswId, int sbLoc, int &channel, int block, int pos, bool middle=false) const
bool getReadoutFromSLB(const TGCModuleSLB &slb, TGCId::SideType &side, int &rodId, int &sswId, int &sbLoc) const
bool getHighPtIDFromReadout(TGCId::SideType side, int rodId, int sswId, int sbLoc, int channel, TGCId::SignalType &signal, TGCId::RegionType &region, int &sectorInReadout, int &hpbId, int &block, int &hitId, int &pos) const
std::unique_ptr< TGCChannelId > getASDOutFromReadout(TGCId::SideType side, int rodId, int sswId, int sbLoc, int channel, bool orChannel=false) const
TGCCabling(const TGCCabling &)=delete
bool getReadoutFromASDOut(const TGCChannelASDOut &asdout, TGCId::SideType &side, int &rodId, int &sswId, int &sbLoc, int &channel, bool orChannel=false) const
std::unique_ptr< TGCModuleId > getSLBFromRxId(TGCId::SideType side, int rodId, int sswId, int rxId) const
std::unique_ptr< TGCChannelId > getChannel(const TGCChannelId &channelId, TGCChannelId::ChannelIdType type, bool orChannel=false) const
bool getReadoutFromHighPtID(TGCId::SideType side, int rodId, int &sswId, int &sbLoc, int &channel, TGCId::SignalType signal, TGCId::RegionType region, int sectorInReadout, int hpbId, int block, int hitId, int pos, TGCId::ModuleType moduleType, bool orChannel) const
const TGCModuleId * getSLBFromReadout(TGCId::SideType side, int rodId, int sswId, int sbLoc) const
virtual bool isValid() const override
virtual bool isValid() const override
static constexpr int NUM_INNER_SECTOR
Definition TGCId.h:43
ModuleType getModuleType() const
Definition TGCId.h:137
static constexpr int NUM_ENDCAP_SECTOR
Definition TGCId.h:41
RegionType getRegionType() const
Definition TGCId.h:146
static constexpr int N_RODS
Definition TGCId.h:44
virtual int getSector() const
Definition TGCId.h:156
static constexpr int NUM_OCTANT
Definition TGCId.h:40
int getId() const
Definition TGCId.h:162
static constexpr int NUM_FORWARD_SECTOR
Definition TGCId.h:42
virtual bool isValid() const
bool getOfflineIDfromHighPtID(Identifier &offlineID, const int subDetectorID, const int rodID, const int sectorInReadout, const bool isStrip, const bool isForward, const int hpb, const int chip, const int hitID, const int pos) const
bool getCoveragefromSRodID(const int srodID, int &startEndcapSector, int &coverageOfEndcapSector, int &startForwardSector, int &coverageOfForwardSector) const
bool getSLBAddressfromReadoutID(int &slbAddr, const int subsectorID, const int rodID, const int sswID, const int sbLoc) const
bool getSLBIDfromReadoutID(int &phi, bool &isAside, bool &isEndcap, int &moduleType, int &id, const int subsectorID, const int rodID, const int sswID, const int sbLoc) const
bool getReadoutIDfromHPTID(const int phi, const bool isAside, const bool isEndcap, const bool isStrip, const int id, int &subsectorID, int &rodID, int &sswID, int &sbLoc) const
const Muon::IMuonIdHelperSvc * m_idHelperSvc
bool getHighPtIDfromOfflineID(const Identifier &offlineID, int &subDetectorID, int &rodID, int &sectorInReadout, bool &isStrip, bool &isForward, int &hpb, int &chip, int &hitID, int &pos) const
bool getElementIDfromReadoutID(Identifier &elementID, const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int channelID, bool orChannel=false) const
bool getReadoutIDfromSLBID(const int phi, const bool isAside, const bool isEndcap, const int moduleType, const int id, int &subsectorID, int &rodID, int &sswID, int &sbLoc) const
bool getReadoutIDfromOnlineID(int &subDetectorID, int &rodID, int &sswID, int &sbLoc, int &channelID, const int subsystemNumber, const int octantNumber, const int moduleNumber, const int layerNumber, const int rNumber, const int wireOrStrip, const int channelNumber, bool adChannel=false) const
bool getRDOHighPtIDfromSimHighPtID(const bool isForward, const bool isStrip, int &index, int &chip, int &hitId) const
bool getOnlineIDfromReadoutID(const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int channelID, int &subsystemNumber, int &octantNumber, int &moduleNumber, int &layerNumber, int &rNumber, int &wireOrStrip, int &channelNumber, bool orChannel=false) const
bool getOfflineIDfromReadoutID(Identifier &offlineID, const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int channelID, bool orChannel=false) const
To be ported.
bool getSLIDfromReadoutID(int &phi, bool &isAside, bool &isEndcap, const int subsectorID, const int rodID, const int sswID, const int sbLoc) const
bool getReadoutIDfromOfflineID(const Identifier &offlineID, int &subDetectorID, int &rodID, int &sswID, int &sbLoc, int &channelID, bool adChannel=false) const
bool getHighPtIDfromROINumber(int roi, bool isForward, bool isStrip, int &hpb, int &chip, int &hitID, int &sub) const
bool getOnlineIDfromOfflineID(const Identifier &offlineID, int &subsystemNumber, int &octantNumber, int &moduleNumber, int &layerNumber, int &rNumber, int &wireOrStrip, int &channelNumber) const
bool getSimHighPtIDfromRDOHighPtID(const bool isForward, const bool isStrip, int &index, int &chip, int &hitId) const
bool getSLBIDfromRxID(int &phi, bool &isAside, bool &isEndcap, int &moduleType, int &id, const int subsectorID, const int rodID, const int sswID, const int rxId) const
bool getOfflineIDfromLowPtCoincidenceID(Identifier &offlineID, const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int block, const int pos, bool middle=false) const
bool getSReadoutIDfromSLID(const int phi, const bool isAside, const bool isEndcap, int &subsectorID, int &srodID, int &sswID, int &sbLoc) const
bool hasAdjacentChannel(const Identifier &offlineID) const
bool getROINumberfromHighPtID(int &roi, bool isForward, int hpb_wire, int chip_wire, int hitId_wire, int sub_wire, int chip_strip, int hitId_strip, int sub_strip) const
bool getReadoutIDfromSLID(const int phi, const bool isAside, const bool isEndcap, int &subsectorID, int &rodID, int &sswID, int &sbLoc) const
bool getSLIDfromSReadoutID(int &phi, bool &isAside, const int subsectorID, const int srodID, const int sector, const bool forward) const
void getReadoutIDRanges(int &maxRodId, int &maxSRodId, int &maxSswId, int &maxSbloc, int &minChannelId, int &maxChannelId) const
bool isOredChannel(const int subDetectorID, const int rodID, const int sswID, const int sbLoc, const int channelID) const
To be ported.
TgcCablingMap(const Config &cfg)
bool getReadoutIDfromElementID(const Identifier &elementID, int &subdetectorID, int &rodID) const
bool getOfflineIDfromOnlineID(Identifier &offlineID, const int subsystemNumber, const int octantNumber, const int moduleNumber, const int layerNumber, const int rNumber, const int wireOrStrip, const int channelNumber) const
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition index.py:1