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 // Readout ID -> Online ID
85 int subsystemNumber{0}, octantNumber{0}, moduleNumber{0}, layerNumber{0},
86 rNumber{0}, wireOrStrip{0}, channelNumber{0};
87
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::SideType::Aside;
340 }
341 if (subSystemNumber == -1) {
342 sideType = TGCId::SideType::Cside;
343 }
344
345 // SignalType
347 if (wireOrStrip == 0) {
348 signalType = TGCId::SignalType::Wire;
349 }
350 if (wireOrStrip == 1) {
351 signalType = TGCId::SignalType::Strip;
352 }
353
354 // RegionType
356 if (regionType == FORWARD) {
358 }
359 if (regionType == 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::SideType::Aside;
391 } else if (subSystemNumber == -1) {
392 sideType = TGCId::SideType::Cside;
393 }
394
395 // SignalType
397 if (wireOrStrip == 0) {
398 signalType = TGCId::SignalType::Wire;
399 }
400 if (wireOrStrip == 1) {
401 signalType = TGCId::SignalType::Strip;
402 }
403
404 ATH_MSG_VERBOSE("getOfflineIDfromOnlineID for "
405 << " side=" << sideType << " octant=" << octantNumber
406 << " module=" << moduleNumber << " layer=" << layerNumber
407 << " chamber=" << rNumber << " w/s=" << signalType
408 << " channel=" << channelNumber);
409
410 // ASDOut
411 TGCChannelASDOut asdout(sideType, signalType, octantNumber, moduleNumber,
412 layerNumber, rNumber, channelNumber);
413 if (!asdout.isValid()) {
414 ATH_MSG_WARNING(" Illegal AsdOut for "
415 << " side=" << sideType << " octant=" << octantNumber
416 << " module=" << moduleNumber
417 << " layer=" << layerNumber << " chamber=" << rNumber
418 << " w/s=" << signalType
419 << " channel=" << channelNumber);
420 return false;
421 }
422
423 // online Id -> offline Id
424 std::unique_ptr<TGCChannelId> asdin =
426 if (!asdin || !asdin->isValid()) {
427 ATH_MSG_WARNING(" getOfflineIDfromOnlineID : Illegal AsdIn for "
428 << " side=" << sideType << " octant=" << octantNumber
429 << " module=" << moduleNumber
430 << " layer=" << layerNumber << " chamber=" << rNumber
431 << " w/s=" << signalType
432 << " channel=" << channelNumber);
433 return false;
434 }
435
436 // build identifier
437 std::string stationNameStr;
438 switch (asdin->getStation()) {
439 case TGCId::StationType::M1: // Triplet
440 stationNameStr = (asdin->isForward()) ? "T1F" : "T1E";
441 break;
442 case TGCId::StationType::M2: // Middle Doublet
443 stationNameStr = (asdin->isForward()) ? "T2F" : "T2E";
444 break;
445 case TGCId::StationType::M3: // Pivot Doublet
446 stationNameStr = (asdin->isForward()) ? "T3F" : "T3E";
447 break;
448 case TGCId::StationType::M4: // Inner
449 stationNameStr = (asdin->isForward()) ? "T4F" : "T4E";
450 break;
451 default:
452 return false;
453 }
454 int stationEta = asdin->getChamber();
455 if (asdin->getSideType() == TGCId::SideType::Cside) {
456 stationEta *= -1;
457 }
458 int stationPhi = asdin->getSector();
459 int gasGap = asdin->getGasGap();
460 int isStrip = (asdin->isStrip()) ? 1 : 0;
461 int channel = asdin->getChannel();
462
463 if ((asdin->getStation() == TGCId::StationType::M4) && (asdin->isEndcap())) {
464 // special treatment for EI
465 constexpr std::array<int, 25> phiIE{-1, 1, 2, 3, 4, 5, 6, 7, 8,
466 -1, 9, 10, 11, 12, 13, 14, 15, -1,
467 16, 17, 18, -1, 19, 20, 21};
468 stationPhi = phiIE[asdin->getSector()];
469 if (stationPhi < 0) {
470 return false;
471 }
472 }
473
474 // OnlineID --> OfflineID
475 // T11S : EI @ stationPhi=2,11,13,14,15,19,20,21
476 // total number of wire channel = 16
477 // (T11 24 channel)
478 const int OffsetForT11S = 8;
479 // T10S : FI @ statioPhi =2,5,8,11,14,17,20,23
480 // total number of wire channel = 30
481 // (T10 32 channel)
482 if ((asdin->getStation() == TGCId::StationType::M4) && (!isStrip)) { // Inner Wire
483 if (asdin->isEndcap()) {
484 switch (stationPhi) {
485 case 2:
486 case 11:
487 case 13:
488 case 14:
489 case 15:
490 case 19:
491 case 20:
492 case 21:
493 // T11S
494 channel -= OffsetForT11S;
495 if (channel <= 0) {
496 return false;
497 }
498 break;
499 default:
500 break;
501 }
502 }
503 }
504
505 offlineId = m_idHelperSvc->tgcIdHelper().channelID(
506 stationNameStr, stationEta, stationPhi, gasGap, isStrip, channel);
507
508 return true;
509}
510
511// readout IDs -> online IDs
513 const int subDetectorID, const int rodID, const int sswID, const int sbLoc,
514 const int channelID, int& subsystemNumber, int& octantNumber,
515 int& moduleNumber, int& layerNumber, int& rNumber, int& wireOrStrip,
516 int& channelNumber, bool orChannel) const {
517 // SideType
519 if (subDetectorID == m_AsideId) {
520 sideType = TGCId::SideType::Aside;
521 } else if (subDetectorID == m_CsideId) {
522 sideType = TGCId::SideType::Cside;
523 }
524
525 // readout channel -> chamber channel
526 std::unique_ptr<TGCChannelId> asdout = getASDOutFromReadout(
527 sideType, rodID, sswID, sbLoc, channelID, orChannel);
528 if (asdout == nullptr) {
529 if (!orChannel) {
530 ATH_MSG_VERBOSE(" getOnlineIDfromReadoutID :"
531 << " Cannot get OnlineID of "
532 << " side=" << sideType << " rodID=" << rodID
533 << " sswID=" << sswID << " sbLoc=" << sbLoc
534 << " channel=" << channelID
535 << " [ Or =" << orChannel << "] ");
536 }
537 return false;
538 }
539 if (!asdout->isValid()) {
540 ATH_MSG_WARNING(" getOnlineIDfromReadoutID :"
541 << " Illegal ASDout for "
542 << " side=" << sideType << " rodID=" << rodID
543 << " sswID=" << sswID << " sbLoc=" << sbLoc
544 << " channel=" << channelID << " [ Or =" << orChannel
545 << "] ");
546
547 return false;
548 }
549 // SubsystemNumber
550 subsystemNumber = (asdout->isAside()) ? 1 : -1;
551
552 // OctantNumber
553 octantNumber = asdout->getOctant();
554
555 // RNumber
556 rNumber = asdout->getChamber();
557
558 // ModuleNumber
559 moduleNumber = asdout->getSectorModule();
560
561 layerNumber = asdout->getLayer();
562
563 // WireOrStrip
564 wireOrStrip = (asdout->isStrip()) ? 1 : 0;
565
566 // ChannelNumber
567 channelNumber = asdout->getChannel();
568
569 return true;
570}
571
573// online IDs -> readout IDs
575 int& subDetectorID, int& rodID, int& sswID, int& sbLoc, int& channelID,
576 const int subsystemNumber, const int octantNumber, const int moduleNumber,
577 const int layerNumber, const int rNumber, const int wireOrStrip,
578 const int channelNumber, bool adChannel) const {
579 // SideType
581 if (subsystemNumber == 1) {
582 sideType = TGCId::SideType::Aside;
583 }
584 if (subsystemNumber == -1) {
585 sideType = TGCId::SideType::Cside;
586 }
587
588 // SignalType
590 if (wireOrStrip == 0) {
591 signalType = TGCId::SignalType::Wire;
592 }
593 if (wireOrStrip == 1) {
594 signalType = TGCId::SignalType::Strip;
595 }
596
597 // ASDOut
598 TGCChannelASDOut asdout(sideType, signalType, octantNumber, moduleNumber,
599 layerNumber, rNumber, channelNumber);
600 if (!asdout.isValid()) {
601 ATH_MSG_WARNING(" getReadoutIDfromOnlineID() :"
602 << " Cannot get ASDout for "
603 << " side=" << sideType << " signal=" << signalType
604 << " octant=" << octantNumber
605 << " module=" << moduleNumber
606 << " layer=" << layerNumber << " chamber=" << rNumber
607 << " channel=" << channelNumber);
608 }
609
610 if (!asdout.isValid()) {
611 return false;
612 }
613
614 // chamber channel -> readout channel
615 bool status = getReadoutFromASDOut(asdout, sideType, rodID, sswID, sbLoc,
616 channelID, adChannel);
617 if (!status) {
618 if (adChannel) {
619 ATH_MSG_DEBUG("getReadoutIDfromASDOut fails for adjacent");
620 } else {
621 ATH_MSG_WARNING(" getReadoutIDfromASDOut :"
622 << " Cannot get ReadoutID for "
623 << " side=" << sideType << " signal=" << signalType
624 << " octant=" << octantNumber << " module="
625 << moduleNumber << " layer=" << layerNumber
626 << " chamber=" << rNumber
627 << " channel=" << channelNumber);
628 }
629 return false;
630 }
631
632 // SubDetectorID
633 if (sideType == TGCId::SideType::Aside) {
634 subDetectorID = m_AsideId;
635 }
636 if (sideType == TGCId::SideType::Cside) {
637 subDetectorID = m_CsideId;
638 }
639
640 return status;
641}
642
643// element ID -> readout IDs
645 int& subdetectorID,
646 int& rodID) const {
647 // get station name in string format : T1F,T1E,T2F...
648 const int iStation = m_idHelperSvc->tgcIdHelper().stationName(elementID);
649 const int stationType = (iStation - 39) / 2;
650
651 int iEta = m_idHelperSvc->tgcIdHelper().stationEta(elementID);
652 int iPhi = m_idHelperSvc->tgcIdHelper().stationPhi(elementID);
653
654 // forward/endcap
655 enum { FORWARD, ENDCAP };
656 const int regionType =
657 m_idHelperSvc->tgcIdHelper().isForward(elementID) ? FORWARD : ENDCAP;
658
659 // SideType
660 subdetectorID = (iEta > 0) ? m_AsideId : m_CsideId;
661
662 // sector index and module index
663 const int max_phi = (regionType == FORWARD || stationType == 4)
666 const int max_module = max_phi / TGCId::N_RODS;
667 const int sector = ((iPhi - 1) + max_phi / 24 + max_phi) % max_phi;
668 int readoutSector = static_cast<int>(sector / max_module);
669 // Inner case
670 if (stationType == 4) {
671 readoutSector = (readoutSector / 3);
672 readoutSector = 3 * readoutSector + 1;
673 }
674
675 rodID = readoutSector + 1;
676
677 return true;
678}
679
681// readout IDs -> element ID
683 const int subDetectorID,
684 const int rodID, const int sswID,
685 const int sbLoc,
686 const int channelID,
687 bool orChannel) const {
688 Identifier offlineID;
689
690 // get min/max values for ReadoutID parameters
691 int maxRodId, maxSRodId, maxSswId, maxSbloc, minChannelId, maxChannelId;
692 getReadoutIDRanges(maxRodId, maxSRodId, maxSswId, maxSbloc, minChannelId,
693 maxChannelId);
694
695 // check sswID and channelID in allowed range
696 if ((sswID > maxSswId) || (channelID < minChannelId) ||
697 (channelID > maxChannelId)) {
698 ATH_MSG_DEBUG(" getElementIDfromReadoutID() :"
699 << " Illeagal channel ID"
700 << " subdetectorID=" << subDetectorID
701 << " rodID=" << rodID << " sswID=" << sswID
702 << " sbLoc=" << sbLoc << " channel=" << channelID
703 << " [ Or =" << orChannel << "] ");
704 return false;
705 }
706
707 bool status = getOfflineIDfromReadoutID(offlineID, subDetectorID, rodID,
708 sswID, sbLoc, channelID, orChannel);
709 if (!status) {
711 " getElementIDfromReadoutID :" << " Cannot get OfflineID ");
712 return false;
713 }
714
715 elementID = m_idHelperSvc->tgcIdHelper().elementID(offlineID);
716 return true;
717}
718
720// readout ID -> SLB ID
722 bool& isEndcap, int& moduleType,
723 int& id, const int subsectorID,
724 const int rodID, const int sswID,
725 const int sbLoc) const {
726 isAside = (subsectorID == m_AsideId);
727
729
730 const TGCModuleId* slb = getSLBFromReadout(side, rodID, sswID, sbLoc);
731 if (!slb) {
732 ATH_MSG_VERBOSE(" getSLBIDfromReadoutID :"
733 << " Cannot get SLB of "
734 << " side" << side << " rodID=" << rodID
735 << " sswID=" << sswID << " sbLoc=" << sbLoc);
736 return false;
737 }
738
739 isEndcap = (slb->getRegionType() == TGCId::RegionType::Endcap);
740 moduleType = (int)slb->getModuleType();
741 bool isInner = (moduleType == +TGCId::ModuleType::WI || moduleType == +TGCId::ModuleType::SI);
742 int offset, numOfSector;
743 if (isInner) {
744 numOfSector = TGCId::NUM_INNER_SECTOR;
745 } else {
746 if (isEndcap) {
747 numOfSector = TGCId::NUM_ENDCAP_SECTOR;
748 } else {
749 numOfSector = TGCId::NUM_FORWARD_SECTOR;
750 }
751 }
752 offset = numOfSector - numOfSector / 24;
753 phi = (slb->getSector() + offset) % numOfSector + 1;
754 id = slb->getId();
755
756 return true;
757}
758
760// readout ID -> rxID
762 const int subsectorID,
763 const int rodID, const int sswID,
764 const int sbLoc) const {
765 slbAddr = -1;
766
767 bool isAside = (subsectorID == m_AsideId);
768
770
771 const TGCModuleId* slb = getSLBFromReadout(side, rodID, sswID, sbLoc);
772 if (!slb) {
773 ATH_MSG_WARNING(" getSLBAddressfromReadoutID :"
774 << " Cannot get SLB of "
775 << " side" << side << " rodID=" << rodID
776 << " sswID=" << sswID << " sbLoc=" << sbLoc);
777 return false;
778 }
779
780 const TGCModuleSLB* modSlb = dynamic_cast<const TGCModuleSLB*>(slb);
781 if (!modSlb) {
782 ATH_MSG_WARNING("TgcCablingMap::getSLBAddressfromReadoutID "
783 << "dynamic_cast<const "
784 "TGCModuleSLB*>(slb) failed.");
785 return false;
786 }
787
788 slbAddr = modSlb->getSlbAddr();
789 return true;
790}
791
793// ROD_ID / SSW_ID / RX_ID -> SLB ID
794bool TgcCablingMap::getSLBIDfromRxID(int& phi, bool& isAside, bool& isEndcap,
795 int& moduleType, int& id,
796 const int subsectorID, const int rodID,
797 const int sswID, const int rxId) const {
798 isAside = (subsectorID == m_AsideId);
800
801 std::unique_ptr<TGCModuleId> slb = getSLBFromRxId(side, rodID, sswID, rxId);
802 if (!slb) {
803 ATH_MSG_WARNING("geSLBIDfromRxID :" << " Cannot get SLB of "
804 << " side" << side << " rodID="
805 << rodID << " sswID=" << sswID
806 << " rxId=" << rxId);
807 return false;
808 }
809
810 isEndcap = (slb->getRegionType() == TGCId::RegionType::Endcap);
811 moduleType = (int)slb->getModuleType();
812 bool isInner = (moduleType == +TGCId::ModuleType::WI || moduleType == +TGCId::ModuleType::SI);
813 int offset, numOfSector;
814 if (isInner) {
815 numOfSector = TGCId::NUM_INNER_SECTOR;
816 } else {
817 if (isEndcap) {
818 numOfSector = TGCId::NUM_ENDCAP_SECTOR;
819 } else {
820 numOfSector = TGCId::NUM_FORWARD_SECTOR;
821 }
822 }
823 offset = numOfSector - numOfSector / 24;
824 phi = (slb->getSector() + offset) % numOfSector + 1;
825 id = slb->getId();
826 return true;
827}
828
830// SLB ID -> readout ID
831bool TgcCablingMap::getReadoutIDfromSLBID(const int phi, const bool isAside,
832 const bool isEndcap,
833 const int moduleType, const int id,
834 int& subsectorID, int& rodID,
835 int& sswID, int& sbLoc) const {
836 TGCId::ModuleType module = static_cast<TGCId::ModuleType>(moduleType);
838 bool isInner = (module == TGCId::ModuleType::WI || module == TGCId::ModuleType::SI);
839 int sector = -1; // sector=0-47(EC), 0-23(FWD), 0-23(INNER)
840 if (isInner) {
841 sector = phi % TGCId::NUM_INNER_SECTOR;
842 } else if (isEndcap) {
843 sector = (phi + 1) % TGCId::NUM_ENDCAP_SECTOR;
844 } else {
846 }
848
849 TGCModuleSLB slb(side, module, region, sector, id);
850
851 if (!slb.isValid()) {
852 ATH_MSG_WARNING("getReadoutIDfromSLBID "
853 << " phi=" << phi << " side=" << ((isAside) ? "A" : "C")
854 << " region=" << ((isEndcap) ? "Endcap" : "Forward")
855 << " type=" << moduleType << " id=" << id
856 << " Invalid SLB");
857 }
858 if (!slb.isValid()) {
859 return false;
860 }
861
862 subsectorID = (isAside ? m_AsideId : m_CsideId);
863
864 bool status = getReadoutFromSLB(slb, side, rodID, sswID, sbLoc);
865
866 if (!status) {
867 ATH_MSG_DEBUG(" FAIL getReadoutIDfromSLBID");
868 return false;
869 }
870 ATH_MSG_DEBUG(" SUCCESS getReadoutIDfromSLBID");
871 ATH_MSG_DEBUG(" phi=" << phi
872 << " side=" << ((isAside) ? "A" : "C")
873 << " region=" << ((isEndcap) ? "Endcap" : "Forward")
874 << " type=" << moduleType << " id=" << id << " side"
875 << side << " rodID=" << rodID << " sswID=" << sswID
876 << " sbLoc=" << sbLoc);
877 return true;
878}
879
881// readout ID -> SL ID
883 bool& isEndcap, const int subsectorID,
884 const int rodID, const int sswID,
885 const int sbLoc) const {
886 isAside = (subsectorID == m_AsideId);
887 if (!isAside && (subsectorID != m_CsideId)) {
888 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
889 << " ERROR illegal subsectorID [=" << subsectorID
890 << "] ");
891 return false;
892 }
893 int sectorInReadout = (rodID - 1); // rodID = 1..12 for both sides
894 if (sectorInReadout >= TGCId::N_RODS) {
895 return false;
896 }
897
898 // sswID check removed
899 if (sswID != 9) {
900 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
901 << " ERROR sswID for SL should be 9 [now =" << sswID
902 << "] ");
903 return false;
904 }
905
906 int offset, numOfSector, sector;
907 if (0 <= sbLoc && sbLoc <= 3) {
908 isEndcap = true;
909 numOfSector = TGCId::NUM_ENDCAP_SECTOR; // 48
910 offset = numOfSector - numOfSector / 24; // 48 - 2 = 46
911 sector = numOfSector * sectorInReadout / TGCId::N_RODS;
912 phi = (sector + sbLoc + offset) % numOfSector + 1;
913 } else if (sbLoc == 4 || sbLoc == 5) {
914 isEndcap = false;
915 numOfSector = TGCId::NUM_FORWARD_SECTOR;
916 offset = numOfSector - numOfSector / 24;
917 sector = numOfSector * sectorInReadout / TGCId::N_RODS;
918 phi = (sector + (sbLoc - 4) + offset) % numOfSector + 1;
919 } else {
920 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
921 << " ERROR illegal sbLoc for SL [=" << sbLoc << "] ");
922 return false;
923 }
924 return true;
925}
926
928// readout ID (only SROD) -> SL ID
930 const int subsectorID,
931 const int srodID, const int sector,
932 const bool forward) const {
933 isAside = (subsectorID == m_AsideId);
934 if (!isAside && (subsectorID != m_CsideId)) {
935 ATH_MSG_WARNING(" getSLIDfromReadoutID : "
936 << " ERROR illegal subsectorID [=" << subsectorID
937 << "] ");
938 return false;
939 }
940
941 int sectorInReadout = (srodID - 17); // 0-2, srodID : 0x11-0x13 (17-19)
942 if ((sectorInReadout >= TGCModuleId::NumberOfSReadoutSector) ||
943 (sectorInReadout < 0)) {
944 ATH_MSG_WARNING(" Invalid SROD ID : " << srodID);
945 return false;
946 }
947
948 int offset, tmpsector, numOfSector;
949 // sswID check removed
950 if (forward) {
951 numOfSector = TGCId::NUM_FORWARD_SECTOR;
952 offset = numOfSector - numOfSector / 24; // 24 - 1
953 tmpsector = numOfSector * sectorInReadout /
955 phi = (sector + tmpsector + offset) % numOfSector + 1;
956 } else {
957 numOfSector = TGCId::NUM_ENDCAP_SECTOR;
958 offset = numOfSector - numOfSector / 24; // 48 - 2
959 tmpsector = numOfSector * sectorInReadout /
961 phi = (sector + tmpsector + offset) % numOfSector + 1;
962 }
963 return true;
964}
965
967// SL ID -> readout ID
968bool TgcCablingMap::getReadoutIDfromSLID(const int phi, const bool isAside,
969 const bool isEndcap, int& subsectorID,
970 int& rodID, int& sswID,
971 int& sbLoc) const {
972 if (isAside) {
973 subsectorID = m_AsideId;
974 } else {
975 subsectorID = m_CsideId;
976 }
977
978 if (isEndcap) {
980 return false;
981 }
982 } else {
984 return false;
985 }
986 }
987
988 int sector;
989 int sectorInReadout;
990 if (isEndcap) {
991 sector = (phi + 1) % TGCId::NUM_ENDCAP_SECTOR;
992 sectorInReadout = sector % (TGCId::NUM_ENDCAP_SECTOR / TGCId::N_RODS);
993 sbLoc = sectorInReadout;
994 rodID = (sector - sectorInReadout) /
996 1;
997 } else {
999 sectorInReadout = sector % (TGCId::NUM_FORWARD_SECTOR / TGCId::N_RODS);
1000 sbLoc = sectorInReadout + 4;
1001 rodID = (sector - sectorInReadout) /
1003 1;
1004 }
1005 // Fixed SSWID for SL
1006 sswID = 9;
1007
1008 return true;
1009}
1010
1012// SL ID -> readout ID
1013bool TgcCablingMap::getSReadoutIDfromSLID(const int phi, const bool isAside,
1014 const bool isEndcap, int& subsectorID,
1015 int& srodID, int& sswID,
1016 int& sbLoc) const {
1017 if (isAside) {
1018 subsectorID = m_AsideId;
1019 } else {
1020 subsectorID = m_CsideId;
1021 }
1022
1023 if (isEndcap) {
1025 return false;
1026 }
1027 } else {
1029 return false;
1030 }
1031 }
1032
1033 int sector;
1034 int sectorInReadout;
1035 if (isEndcap) {
1036 sector = (phi + 1) % TGCId::NUM_ENDCAP_SECTOR;
1037 sectorInReadout =
1038 sector %
1040 TGCModuleId::NumberOfSReadoutSector); // [2-48, 1] % (48/3)
1041 sbLoc = sectorInReadout;
1042 srodID =
1043 (sector - sectorInReadout) / (TGCId::NUM_ENDCAP_SECTOR /
1045 0x11;
1046 } else {
1047 sector = phi % TGCId::NUM_FORWARD_SECTOR;
1048 sectorInReadout =
1049 sector %
1051 TGCModuleId::NumberOfSReadoutSector); // [2-23, 1] % (24/3)
1052 sbLoc = sectorInReadout;
1053 srodID =
1054 (sector - sectorInReadout) / (TGCId::NUM_FORWARD_SECTOR /
1056 0x11;
1057 }
1058 // Fixed SSWID for SL
1059 sswID = 9;
1060
1061 return true;
1062}
1063
1065// HPT ID -> readout ID
1066bool TgcCablingMap::getReadoutIDfromHPTID(const int phi, const bool isAside,
1067 const bool isEndcap, const bool,
1068 const int, int& subsectorID,
1069 int& rodID, int& sswID,
1070 int& sbLoc) const {
1071 return getReadoutIDfromSLID(phi, isAside, isEndcap, subsectorID, rodID,
1072 sswID, sbLoc);
1073}
1074
1076// CAUTION!!: return RDO value (not the value for simulation)
1077bool TgcCablingMap::getHighPtIDfromROINumber(int roi, bool isForward,
1078 bool isStrip, int& hpb, int& chip,
1079 int& hitId, int& sub) const {
1080 // for Strip, there is some ambiguity in the relation between hitID and ROI
1081 bool status = true;
1082 int RoiRow = static_cast<int>(roi / 4);
1083 int RoiColumn = static_cast<int>(roi % 4);
1084
1085 if (!isStrip) {
1086 if (isForward) {
1087 switch (RoiRow) {
1088 case 0:
1089 chip = 0;
1090 hitId = 1;
1091 sub = 0;
1092 break;
1093 case 1:
1094 chip = 0;
1095 hitId = 1;
1096 sub = 1;
1097 break;
1098 case 2:
1099 chip = 0;
1100 hitId = 2;
1101 sub = 0;
1102 break;
1103 case 3:
1104 chip = 0;
1105 hitId = 2;
1106 sub = 1;
1107 break;
1108 case 4:
1109 chip = 0;
1110 hitId = 3;
1111 sub = 0;
1112 break;
1113 case 5:
1114 chip = 0;
1115 hitId = 3;
1116 sub = 1;
1117 break;
1118 case 6:
1119 chip = 0;
1120 hitId = 4;
1121 sub = 0;
1122 break;
1123 case 7:
1124 chip = 0;
1125 hitId = 4;
1126 sub = 1;
1127 break;
1128 case 8:
1129 chip = 0;
1130 hitId = 5;
1131 sub = 0;
1132 break;
1133 case 9:
1134 chip = 0;
1135 hitId = 5;
1136 sub = 1;
1137 break;
1138 case 10:
1139 chip = 0;
1140 hitId = 6;
1141 sub = 0;
1142 break;
1143 case 11:
1144 chip = 0;
1145 hitId = 6;
1146 sub = 1;
1147 break;
1148 case 12:
1149 chip = 1;
1150 hitId = 1;
1151 sub = 0;
1152 break;
1153 case 13:
1154 chip = 1;
1155 hitId = 1;
1156 sub = 1;
1157 break;
1158 case 14:
1159 chip = 1;
1160 hitId = 2;
1161 sub = 0;
1162 break;
1163 case 15:
1164 chip = 1;
1165 hitId = 2;
1166 sub = 1;
1167 break;
1168 default:
1169 status = false;
1170 break;
1171 }
1172 } else {
1173 switch (RoiRow) {
1174 case 0:
1175 chip = 0;
1176 hitId = 1;
1177 sub = 1;
1178 break;
1179 case 1:
1180 chip = 1;
1181 hitId = 1;
1182 sub = 0;
1183 break;
1184 case 2:
1185 chip = 1;
1186 hitId = 1;
1187 sub = 1;
1188 break;
1189 case 3:
1190 chip = 1;
1191 hitId = 2;
1192 sub = 0;
1193 break;
1194 case 4:
1195 chip = 1;
1196 hitId = 2;
1197 sub = 1;
1198 break;
1199 case 5:
1200 chip = 1;
1201 hitId = 3;
1202 sub = 0;
1203 break;
1204 case 6:
1205 chip = 1;
1206 hitId = 3;
1207 sub = 1;
1208 break;
1209 case 7:
1210 chip = 1;
1211 hitId = 4;
1212 sub = 0;
1213 break;
1214 case 8:
1215 chip = 1;
1216 hitId = 4;
1217 sub = 1;
1218 break;
1219 case 9:
1220 chip = 1;
1221 hitId = 5;
1222 sub = 0;
1223 break;
1224 case 10:
1225 chip = 1;
1226 hitId = 5;
1227 sub = 1;
1228 break;
1229 case 11:
1230 chip = 1;
1231 hitId = 6;
1232 sub = 0;
1233 break;
1234 case 12:
1235 chip = 1;
1236 hitId = 6;
1237 sub = 1;
1238 break;
1239 case 13:
1240 chip = 2;
1241 hitId = 1;
1242 sub = 0;
1243 break;
1244 case 14:
1245 chip = 2;
1246 hitId = 1;
1247 sub = 1;
1248 break;
1249 case 15:
1250 chip = 2;
1251 hitId = 2;
1252 sub = 0;
1253 break;
1254 case 16:
1255 chip = 2;
1256 hitId = 2;
1257 sub = 1;
1258 break;
1259 case 17:
1260 chip = 2;
1261 hitId = 3;
1262 sub = 0;
1263 break;
1264 case 18:
1265 chip = 2;
1266 hitId = 3;
1267 sub = 1;
1268 break;
1269 case 19:
1270 chip = 2;
1271 hitId = 4;
1272 sub = 0;
1273 break;
1274 case 20:
1275 chip = 2;
1276 hitId = 4;
1277 sub = 1;
1278 break;
1279 case 21:
1280 chip = 2;
1281 hitId = 5;
1282 sub = 0;
1283 break;
1284 case 22:
1285 chip = 2;
1286 hitId = 5;
1287 sub = 1;
1288 break;
1289 case 23:
1290 chip = 2;
1291 hitId = 6;
1292 sub = 0;
1293 break;
1294 case 24:
1295 chip = 2;
1296 hitId = 6;
1297 sub = 1;
1298 break;
1299 case 25:
1300 chip = 3;
1301 hitId = 1;
1302 sub = 0;
1303 break;
1304 case 26:
1305 chip = 3;
1306 hitId = 1;
1307 sub = 1;
1308 break;
1309 case 27:
1310 chip = 3;
1311 hitId = 2;
1312 sub = 0;
1313 break;
1314 case 28:
1315 chip = 3;
1316 hitId = 2;
1317 sub = 1;
1318 break;
1319 case 29:
1320 chip = 3;
1321 hitId = 3;
1322 sub = 0;
1323 break;
1324 case 30:
1325 chip = 3;
1326 hitId = 3;
1327 sub = 1;
1328 break;
1329 case 31:
1330 chip = 3;
1331 hitId = 4;
1332 sub = 0;
1333 break;
1334 case 32:
1335 chip = 3;
1336 hitId = 4;
1337 sub = 1;
1338 break;
1339 case 33:
1340 chip = 3;
1341 hitId = 5;
1342 sub = 0;
1343 break;
1344 case 34:
1345 chip = 3;
1346 hitId = 5;
1347 sub = 1;
1348 break;
1349 case 35:
1350 chip = 3;
1351 hitId = 6;
1352 sub = 0;
1353 break;
1354 case 36:
1355 chip = 3;
1356 hitId = 6;
1357 sub = 1;
1358 break;
1359 default:
1360 status = false;
1361 break;
1362 }
1363 }
1364 } else if (isStrip) {
1365 if (isForward) {
1366 switch (RoiColumn) {
1367 case 0:
1368 chip = 0;
1369 hitId = 1;
1370 sub = 0;
1371 break;
1372 case 1:
1373 chip = 0;
1374 hitId = 1;
1375 sub = 1;
1376 break;
1377 case 2:
1378 chip = 0;
1379 hitId = 2;
1380 sub = 0;
1381 break;
1382 case 3:
1383 chip = 0;
1384 hitId = 2;
1385 sub = 1;
1386 break;
1387 default:
1388 status = false;
1389 break;
1390 }
1391 } else {
1392 switch (RoiColumn) {
1393 case 0:
1394 if (RoiRow < 5) {
1395 chip = 0;
1396 hitId = 1;
1397 sub = 0;
1398 } else if (RoiRow < 8) {
1399 chip = 0;
1400 hitId = 3;
1401 sub = 0;
1402 } else if (RoiRow < 12) {
1403 chip = 0;
1404 hitId = 5;
1405 sub = 0;
1406 } else if (RoiRow < 25) {
1407 chip = 1;
1408 hitId = 1;
1409 sub = 0;
1410 } else if (RoiRow < 37) {
1411 chip = 1;
1412 hitId = 5;
1413 sub = 0;
1414 } else {
1415 status = false;
1416 }
1417 break;
1418 case 1:
1419 if (RoiRow < 5) {
1420 chip = 0;
1421 hitId = 1;
1422 sub = 1;
1423 } else if (RoiRow < 8) {
1424 chip = 0;
1425 hitId = 3;
1426 sub = 1;
1427 } else if (RoiRow < 12) {
1428 chip = 0;
1429 hitId = 5;
1430 sub = 1;
1431 } else if (RoiRow < 25) {
1432 chip = 1;
1433 hitId = 1;
1434 sub = 1;
1435 } else if (RoiRow < 37) {
1436 chip = 1;
1437 hitId = 5;
1438 sub = 1;
1439 } else {
1440 status = false;
1441 }
1442 break;
1443 case 2:
1444 if (RoiRow < 5) {
1445 chip = 0;
1446 hitId = 2;
1447 sub = 0;
1448 } else if (RoiRow < 8) {
1449 chip = 0;
1450 hitId = 4;
1451 sub = 0;
1452 } else if (RoiRow < 12) {
1453 chip = 0;
1454 hitId = 6;
1455 sub = 0;
1456 } else if (RoiRow < 25) {
1457 chip = 1;
1458 hitId = 2;
1459 sub = 0;
1460 } else if (RoiRow < 37) {
1461 chip = 1;
1462 hitId = 6;
1463 sub = 0;
1464 } else {
1465 status = false;
1466 }
1467 break;
1468 case 3:
1469 if (RoiRow < 5) {
1470 chip = 0;
1471 hitId = 2;
1472 sub = 1;
1473 } else if (RoiRow < 8) {
1474 chip = 0;
1475 hitId = 4;
1476 sub = 1;
1477 } else if (RoiRow < 12) {
1478 chip = 0;
1479 hitId = 6;
1480 sub = 1;
1481 } else if (RoiRow < 25) {
1482 chip = 1;
1483 hitId = 2;
1484 sub = 1;
1485 } else if (RoiRow < 37) {
1486 chip = 1;
1487 hitId = 6;
1488 sub = 1;
1489 } else {
1490 status = false;
1491 }
1492 break;
1493 default:
1494 status = false;
1495 break;
1496 }
1497 }
1498 }
1499
1500 hpb = 0;
1501
1502 return status;
1503}
1504
1506bool TgcCablingMap::getROINumberfromHighPtID(int& roi, bool isForward,
1507 int, // hpb_wire
1508 int chip_wire, int hitId_wire,
1509 int sub_wire,
1510 int, // chip_strip
1511 int hitId_strip,
1512 int sub_strip) const {
1513 // for Strip, there is some ambiguity in the relation between hitID and ROI
1514 // CAUTION!!: return RDO value (not the value for simulation)
1515 bool status = true;
1516 int RoiRow = 0;
1517 int RoiColumn = 0;
1518
1519 if (isForward) {
1520 RoiRow = 12 * chip_wire + 2 * (hitId_wire - 1) + sub_wire;
1521 RoiColumn = 2 * ((hitId_strip - 1) % 2) + sub_strip;
1522 } else if (!isForward) {
1523 RoiColumn = 2 * ((hitId_strip - 1) % 2) + sub_strip;
1524 switch (chip_wire) {
1525 case 0:
1526 RoiRow = 0;
1527 break;
1528 case 1:
1529 case 2:
1530 case 3:
1531 RoiRow =
1532 12 * (chip_wire - 1) + 2 * (hitId_wire - 1) + sub_wire + 1;
1533 break;
1534 default:
1535 break;
1536 }
1537 }
1538
1539 roi = 4 * RoiRow + RoiColumn;
1540
1541 return status;
1542}
1543
1545// HighPtID used in Simulation -> HighPtID in RDO
1547 const bool isStrip,
1548 int& index, int& chip,
1549 int& hitId) const {
1550 if (isForward) {
1551 if (isStrip) { // FS
1552 index = 0;
1553 hitId--;
1554 } else if (!isStrip) { // FW
1555 index = 0;
1556 hitId++;
1557 }
1558 } else {
1559 if (isStrip) { // ES
1560 index = 0;
1561 hitId++;
1562 } else if (!isStrip) { // EW
1563 if (index == 0 && chip == 0) {
1564 hitId = 1;
1565 } else if (index == 0 && chip == 1) {
1566 hitId++;
1567 } else if (index == 1 && chip == 0) {
1568 chip = 2;
1569 hitId++;
1570 } else if (index == 1 && chip == 1) {
1571 chip = 3;
1572 hitId++;
1573 }
1574 }
1575 }
1576
1577 return true;
1578}
1579
1581// HighPtID in RDO -> HighPtID used in Simulation
1583 const bool isStrip,
1584 int& index, int& chip,
1585 int& hitId) const {
1586 if (isForward) {
1587 if (isStrip) { // FS
1588 index = 0;
1589 hitId++;
1590 } else if (!isStrip) { // FW
1591 index = 0;
1592 hitId--;
1593 }
1594 } else {
1595 if (isStrip) { // ES
1596 index = 0;
1597 hitId--;
1598 } else if (!isStrip) { // EW
1599 switch (chip) {
1600 case 0:
1601 index = 0;
1602 hitId = 5;
1603 break;
1604 case 1:
1605 index = 0;
1606 hitId--;
1607 break;
1608 case 2:
1609 index = 1;
1610 chip = 0;
1611 hitId--;
1612 break;
1613 case 3:
1614 index = 1;
1615 chip = 1;
1616 hitId--;
1617 break;
1618 default:
1619 break;
1620 }
1621 }
1622 }
1623
1624 return true;
1625}
1626
1628// high pt coincidence IDs -> offline IDs
1630 Identifier& offlineID, const int subDetectorID, const int rodID,
1631 const int sectorInReadout, const bool isStrip, const bool isForward,
1632 const int hpb, const int chip, const int hitID, const int pos) const {
1633 // all input is derived from TgcRawData
1634 int sswID = -1;
1635 int sbLoc = -1;
1636 int channelID = -1;
1637
1638 // SideType
1640 if (subDetectorID == m_AsideId) {
1641 sideType = TGCId::SideType::Aside;
1642 }
1643 if (subDetectorID == m_CsideId) {
1644 sideType = TGCId::SideType::Cside;
1645 }
1646
1647 // SignalType, RegionType
1650
1651 // ModuleType
1653 if (signalType == TGCId::SignalType::Wire) {
1654 moduleType = TGCId::ModuleType::WD;
1655 } else {
1656 moduleType = TGCId::ModuleType::SD;
1657 }
1658
1659 // Get ReadoutID for pivot plane
1660 bool status = getReadoutFromHighPtID(
1661 sideType, rodID, sswID, sbLoc, channelID, signalType, regionType,
1662 sectorInReadout, hpb, chip, hitID, pos, moduleType, false);
1663
1664 if (!status) {
1665 return false;
1666 }
1667
1668 // get OfflineID for pivot plane
1669 return getOfflineIDfromReadoutID(offlineID, subDetectorID, rodID, sswID,
1670 sbLoc, channelID);
1671}
1672
1674// offline IDs -> high pt coincidence IDs
1676 int& subDetectorID, int& rodID,
1677 int& sectorInReadout,
1678 bool& isStrip, bool& isForward,
1679 int& hpb, int& chip, int& hitID,
1680 int& pos) const {
1681 int sswID = -1;
1682 int sbLoc = -1;
1683 int channelID = -1;
1684
1685 bool status = getReadoutIDfromOfflineID(offlineID, subDetectorID, rodID,
1686 sswID, sbLoc, channelID);
1687 if (!status) {
1688 return false;
1689 }
1690
1691 // SideType
1693 if (subDetectorID == m_AsideId) {
1694 sideType = TGCId::SideType::Aside;
1695 }
1696 if (subDetectorID == m_CsideId) {
1697 sideType = TGCId::SideType::Cside;
1698 }
1699
1700 TGCId::SignalType signalType;
1701 TGCId::RegionType regionType;
1702
1703 status = getHighPtIDFromReadout(sideType, rodID, sswID, sbLoc, channelID,
1704 signalType, regionType, sectorInReadout,
1705 hpb, chip, hitID, pos);
1706 if (!status) {
1707 return false;
1708 }
1709
1710 isStrip = (signalType == TGCId::SignalType::Strip);
1711 isForward = (regionType == TGCId::RegionType::Forward);
1712
1713 return true;
1714}
1715
1717// low pt coincidence IDs -> offline IDs
1719 Identifier& offlineID, const int subDetectorID, const int rodID,
1720 const int sswID, const int sbLoc, const int block, const int pos,
1721 bool middle) const {
1722 int channelID = -1;
1723
1724 // SideType
1726 if (subDetectorID == m_AsideId) {
1727 sideType = TGCId::SideType::Aside;
1728 }
1729 if (subDetectorID == m_CsideId) {
1730 sideType = TGCId::SideType::Cside;
1731 }
1732
1733 bool status = getReadoutFromLowPtCoincidence(sideType, rodID, sswID, sbLoc,
1734 channelID, block, pos, middle);
1735 if (!status) {
1736 return false;
1737 }
1738
1739 return getOfflineIDfromReadoutID(offlineID, subDetectorID, rodID, sswID,
1740 sbLoc, channelID);
1741}
1742
1743} // 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:45
ModuleType getModuleType() const
Definition TGCId.h:131
static constexpr int NUM_ENDCAP_SECTOR
Definition TGCId.h:43
RegionType getRegionType() const
Definition TGCId.h:137
static constexpr int N_RODS
Definition TGCId.h:46
virtual int getSector() const
Definition TGCId.h:144
static constexpr int NUM_OCTANT
Definition TGCId.h:42
int getId() const
Definition TGCId.h:150
static constexpr int NUM_FORWARD_SECTOR
Definition TGCId.h:44
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