2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
6#include <utility> //std::pair
8namespace Muon::MuonStationIndex{
9 inline ChIndex toChamberIndex( StIndex stIndex, bool isSmall ) {
14 return static_cast<ChIndex>(2*toInt(stIndex) + !isSmall);
16 return isSmall ? ChIndex::BEE : ChIndex::ChUnknown;
17 /** There's no BES -> the station indices shift by 1 to the right */
22 return static_cast<ChIndex>(2*toInt(stIndex) -1 + !isSmall);
26 return ChIndex::ChUnknown;
28 inline bool isBarrel(const StIndex index) {
39 inline bool isBarrel(const ChIndex index) {
53 inline bool isSmall(const ChIndex index) {
69 inline StIndex toStationIndex( ChIndex index ) {
96 /// Don't do anything for
97 case ChIndex::ChIndexMax:
98 case ChIndex::ChUnknown:
101 return StIndex::StUnknown;
103 inline LayerIndex toLayerIndex( ChIndex index ) {
104 return toLayerIndex(toStationIndex(index));
106 inline LayerIndex toLayerIndex(StIndex index) {
110 return LayerIndex::Inner;
113 return LayerIndex::Middle;
116 return LayerIndex::Outer;
118 return LayerIndex::BarrelExtended;
120 return LayerIndex::Extended;
121 case StIndex::StUnknown:
122 case StIndex::StIndexMax:
125 return LayerIndex::LayerIndexMax;
127 inline DetectorRegionIndex toDetectorRegionIndex(ChIndex index, int8_t etaSign){
129 return DetectorRegionIndex::Barrel;
131 return DetectorRegionIndex::EndcapA;
133 return DetectorRegionIndex::EndcapC;
136 inline unsigned int sectorLayerHash(DetectorRegionIndex regionIdx,
137 LayerIndex layerIndex ){
138 return toInt(regionIdx)*toInt(LayerIndex::LayerIndexMax) + toInt(layerIndex);
140 inline unsigned int regionChamberHash( DetectorRegionIndex regionIdx, ChIndex chamberIdx){
141 return toInt(regionIdx)*toInt(ChIndex::ChIndexMax) + toInt(chamberIdx);
143 inline std::pair< DetectorRegionIndex, LayerIndex > decomposeSectorLayerHash( unsigned int hash ) {
144 assert(hash < sectorLayerHashMax());
145 return std::make_pair( static_cast< DetectorRegionIndex >( hash / toInt(LayerIndex::LayerIndexMax) ),
146 static_cast< LayerIndex >( hash % toInt(LayerIndex::LayerIndexMax) ) );
148 inline std::pair< DetectorRegionIndex, ChIndex> decomposeRegionChamberHash( unsigned int hash ) {
149 assert( hash < regionChamberHashMax());
150 return std::make_pair( static_cast< DetectorRegionIndex >( hash / toInt(ChIndex::ChIndexMax) ),
151 static_cast< ChIndex >( hash % toInt(ChIndex::ChIndexMax) ) );