ATLAS Offline Software
MuonStationIndex.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <cassert>
6 #include <utility> //std::pair
7 
8 namespace Muon::MuonStationIndex{
9  inline ChIndex toChamberIndex( StIndex stIndex, bool isSmall ) {
10  switch (stIndex) {
11  case StIndex::BI:
12  case StIndex::BM:
13  case StIndex::BO:
14  return static_cast<ChIndex>(2*toInt(stIndex) + !isSmall);
15  case StIndex::BE:
16  return isSmall ? ChIndex::BEE : ChIndex::ChUnknown;
17  /** There's no BES -> the station indices shift by 1 to the right */
18  case StIndex::EI:
19  case StIndex::EM:
20  case StIndex::EO:
21  case StIndex::EE:
22  return static_cast<ChIndex>(2*toInt(stIndex) -1 + !isSmall);
23  default:
24  break;
25  }
26  return ChIndex::ChUnknown;
27  }
28  inline bool isBarrel(const StIndex index) {
29  switch(index) {
30  case StIndex::BI:
31  case StIndex::BM:
32  case StIndex::BO:
33  case StIndex::BE:
34  return true;
35  default:
36  return false;
37  }
38  }
39  inline bool isBarrel(const ChIndex index) {
40  switch (index) {
41  case ChIndex::BIS:
42  case ChIndex::BIL:
43  case ChIndex::BMS:
44  case ChIndex::BML:
45  case ChIndex::BOL:
46  case ChIndex::BOS:
47  case ChIndex::BEE:
48  return true;
49  default:
50  return false;
51  }
52  }
53  inline bool isSmall(const ChIndex index) {
54  switch (index) {
55  case ChIndex::BIS:
56  case ChIndex::BMS:
57  case ChIndex::BOS:
58  case ChIndex::EIS:
59  case ChIndex::EMS:
60  case ChIndex::EOS:
61  case ChIndex::EES:
62  case ChIndex::CSS:
63  case ChIndex::BEE:
64  return true;
65  default:
66  return false;
67  }
68  }
69  inline StIndex toStationIndex( ChIndex index ) {
70  switch (index) {
71  case ChIndex::BIS:
72  case ChIndex::BIL:
73  return StIndex::BI;
74  case ChIndex::BMS:
75  case ChIndex::BML:
76  return StIndex::BM;
77  case ChIndex::BOL:
78  case ChIndex::BOS:
79  return StIndex::BO;
80  case ChIndex::BEE:
81  return StIndex::BE;
82  case ChIndex::EIL:
83  case ChIndex::EIS:
84  case ChIndex::CSL:
85  case ChIndex::CSS:
86  return StIndex::EI;
87  case ChIndex::EML:
88  case ChIndex::EMS:
89  return StIndex::EM;
90  case ChIndex::EOL:
91  case ChIndex::EOS:
92  return StIndex::EO;
93  case ChIndex::EEL:
94  case ChIndex::EES:
95  return StIndex::EE;
96  /// Don't do anything for
97  case ChIndex::ChIndexMax:
98  case ChIndex::ChUnknown:
99  break;
100  };
101  return StIndex::StUnknown;
102  }
103  inline LayerIndex toLayerIndex( ChIndex index ) {
104  return toLayerIndex(toStationIndex(index));
105  }
106  inline LayerIndex toLayerIndex(StIndex index) {
107  switch(index) {
108  case StIndex::BI:
109  case StIndex::EI:
110  return LayerIndex::Inner;
111  case StIndex::BM:
112  case StIndex::EM:
113  return LayerIndex::Middle;
114  case StIndex::EO:
115  case StIndex::BO:
116  return LayerIndex::Outer;
117  case StIndex::BE:
118  return LayerIndex::BarrelExtended;
119  case StIndex::EE:
120  return LayerIndex::Extended;
121  case StIndex::StUnknown:
122  case StIndex::StIndexMax:
123  break;
124  }
125  return LayerIndex::LayerIndexMax;
126  }
127  inline unsigned int sectorLayerHash(DetectorRegionIndex regionIdx,
128  LayerIndex layerIndex ){
129  return toInt(regionIdx)*toInt(LayerIndex::LayerIndexMax) + toInt(layerIndex);
130  }
131  inline std::pair< DetectorRegionIndex, LayerIndex > decomposeSectorLayerHash( unsigned int hash ) {
132  assert(hash < sectorLayerHashMax());
133  return std::make_pair( static_cast< DetectorRegionIndex >( hash / toInt(LayerIndex::LayerIndexMax) ),
134  static_cast< LayerIndex >( hash % toInt(LayerIndex::LayerIndexMax) ) );
135  }
136 }