ATLAS Offline Software
MmIdHelper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ******************************************************************************
6 // ATLAS Muon Identifier Helpers Package
7 // -----------------------------------------
8 // ******************************************************************************
9 
10 #ifndef MUONIDHELPERS_MMIDHELPER_H
11 #define MUONIDHELPERS_MMIDHELPER_H
12 
13 // Includes
14 class MsgStream;
16 
17 // ******************************************************************************
18 // class MmIdHelper
19 // ******************************************************************************//
20 // Description
21 // -----------
22 // This factory class constructs MicroMegas (MM) identifiers and ranges and provides access
23 // to the levels. ATLAS note ATL-MUON-2001-014 provides a complete description
24 // of the hierarchical identifier scheme.
25 // MmIdHelper provides an interface to the following fields of the identifier.
26 //
27 // Field Range Notes
28 // ==============================================================================
29 // nectar: todo: update this section for MM
30 // StationName unsigned integer maps to T1F,T3E,etc.
31 // StationEta [-5,-1] backward endcap (-1 at lowest R)
32 // [1,5] forward endcap (1 at lowest R)
33 // StationPhi [1,48] endcap: increases with phi
34 // [1,24] forward: increases with phi
35 // Technology [5] maps to MM --> <label name="MM" value="5" /> in IdDictMuonSpectrometer_R.01.xml
36 // Multilayer [1,2] barrel: increases with R
37 // endcap: increases with |Z|
38 // GasGap [1,2] doublet: increases with |Z|
39 // [1,3] triplet: increases with |Z|
40 // Channel [1,n] increases with R for IsStrip=0 (wire gang)
41 // increases with phi for IsStrip=1 (strip)
42 // ==============================================================================
43 //
44 // Inheritance
45 // -----------
46 // Inherits from MuonIdHelpers/MuonIdHelpers
47 //
48 // Author
49 // ------
50 // Nektarios Chr. Benekos <nectarios.benekos@cern.ch>
51 // Jochen Meyer <Jochen.Meyer@cern.ch>
52 // ******************************************************************************
53 
54 class MmIdHelper : public MuonIdHelper {
55 public:
56  // Constructor
57  MmIdHelper();
58 
59  // Destructor
60  virtual ~MmIdHelper() = default;
61 
63 
65  virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr) override;
66  virtual int get_module_hash(const Identifier& id, IdentifierHash& hash_id) const override;
67  virtual int get_detectorElement_hash(const Identifier& id, IdentifierHash& hash_id) const override;
68 
70 
71  // Identifier builders
73  Identifier elementID(int stationName, int stationEta, int stationPhi, bool& isValid) const;
74 
75  Identifier elementID(const std::string& stationNameStr, int stationEta, int stationPhi) const;
76  Identifier elementID(const std::string& stationNameStr, int stationEta, int stationPhi, bool& isValid) const;
77 
79 
80  Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const;
81  Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel, bool& isValid) const;
82 
83  Identifier channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const;
84  Identifier channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap, int channel,
85  bool& isValid) const;
86 
87  Identifier channelID(const Identifier& id, int multilayer, int gasGap, int channel) const;
88  Identifier channelID(const Identifier& id, int multilayer, int gasGap, int channel, bool& isValid) const;
89 
90  Identifier parentID(const Identifier& id) const;
91 
92  Identifier multilayerID(const Identifier& channeldID) const;
93  Identifier multilayerID(const Identifier& moduleID, int multilayer) const;
94  Identifier multilayerID(const Identifier& moduleID, int multilayer, bool& isValid) const;
95 
96  Identifier pcbID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int pcb) const;
97  Identifier pcbID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int pcb, bool& isValid) const;
98  Identifier pcbID(const std::string& stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int pcb) const;
99  Identifier pcbID(const std::string& stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int pcb, bool& isValid) const;
100  Identifier pcbID(const Identifier& channelID, int pcb) const;
101  Identifier pcbID(const Identifier& channelID, int pcb, bool& isValid) const;
102  Identifier pcbID(const Identifier& channelID) const;
103  /*
104  One readout board of the Micromegas cover 512 channels and they are named according to their radial position in a layer (0-15).
105  This helper function creates a dummy identifier which can be associated with a front end board, which is primarily needed to deal with the correlation between DCS data and the hits in athena.
106  The identifier always points to the innermost channel that is read out by a given front end board, i.e. radius*512 + 1 (_1 since athena counts from one). For the outer quads it is (radius-10)*512+1 since athena restarts from channel 1 in the outer quads but the DAQ convention for radius counts for the full sector and only febs 0-9 are reading out the inner quad
107  The las function is meant to translate an athena identifier to a feb ID. It returns the same fields except for the channel which is set to the coresponding feb channel by doing ((channel-1)/512)*512+1 (one also needs to take into account the quad, see the actual implementation for that)
108  */
109  Identifier febID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int radius) const;
110  Identifier febID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int radius, bool& isValid) const;
111  Identifier febID(const std::string& stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int radius) const;
112  Identifier febID(const std::string& stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int radius, bool& isValid) const;
113  Identifier febID(const Identifier& channelID, int radius) const;
114  Identifier febID(const Identifier& channelID, int radius, bool& isValid) const;
115  Identifier febID(const Identifier& channelID) const;
116 
117 
118  // for an Identifier id, get the list of the daughter readout channel ids
119  void idChannels(const Identifier& id, std::vector<Identifier>& vect) const;
120 
121  // Access to levels: missing field returns 0
122  int gasGap(const Identifier& id) const override;
123  int multilayer(const Identifier& id) const;
124  int channel(const Identifier& id) const override;
125  bool isStereo(const Identifier& id) const;
126  bool measuresPhi(const Identifier& id) const override; // Returns false
127 
128  int numberOfMultilayers(const Identifier& id) const;
129 
130  // Access to min and max of level ranges
131  // to be remove when we moved to compact ids
132  static int stationEtaMin() ;
133  static int stationEtaMax() ;
134  static int stationPhiMin() ;
135  static int stationPhiMax() ;
136  static int multilayerMin() ;
137  static int multilayerMax() ;
138  static int gasGapMin() ;
139  static int gasGapMax() ;
140  static int channelMin() ;
141  static int channelMax() ;
142 
143  // Access to min and max of level ranges
144  int stationEtaMin(const Identifier& id) const;
145  int stationEtaMax(const Identifier& id) const;
146  int stationPhiMin(const Identifier& id) const;
147  int stationPhiMax(const Identifier& id) const;
148  int multilayerMin(const Identifier& id) const;
149  int multilayerMax(const Identifier& id) const;
150  int gasGapMin(const Identifier& id) const;
151  int gasGapMax(const Identifier& id) const;
152  int channelMin(const Identifier& id) const;
153  int channelMax(const Identifier& id) const;
154 
155  // Utility methods
156  static int sectorType(const std::string& stationName, int stationEta) ;
157  int sectorType(int stationName, int stationEta) const;
158 
159  // Public validation of levels
160  bool valid(const Identifier& id) const;
161  bool validElement(const Identifier& id) const;
162 
163 private:
164  static int getFirstPcbChnl(int stationEta, int pcb) ;
165  static int getFirstRadiusChnl(int stationEta, int pcb) ;
166  bool isStNameInTech(const std::string& stationName) const override;
167 
168  int stationEtaMin(const ExpandedIdentifier& expId) const;
169  int stationEtaMax(const ExpandedIdentifier& expId) const;
170  int stationPhiMin(const ExpandedIdentifier& expId) const;
171  int stationPhiMax(const ExpandedIdentifier& expId) const;
172  int multilayerMin(const ExpandedIdentifier& expId) const;
173  int multilayerMax(const ExpandedIdentifier& expId) const;
174  int gasGapMin(const ExpandedIdentifier& expId) const;
175  int gasGapMax(const ExpandedIdentifier& expId) const;
176  int channelMin(const ExpandedIdentifier& expId) const;
177  int channelMax(const ExpandedIdentifier& expId) const;
178 
179  int init_id_to_hashes();
181  static constexpr unsigned int s_stDim = 2;
183  static constexpr unsigned int s_etaDim = 4;
185  static constexpr unsigned int s_phiDim = 8;
187  static constexpr unsigned int s_mlDim = 2;
188 
189  static constexpr unsigned int s_modHashDim = s_stDim * s_etaDim * s_phiDim;
190  static constexpr unsigned int s_detHashDim = s_modHashDim * s_mlDim;
191 
192  std::array<unsigned int, s_modHashDim> m_module_hashes{};
193  std::array<unsigned int, s_detHashDim> m_detectorElement_hashes{};
194 
195  unsigned int moduleHashIdx(const Identifier& id) const;
196  unsigned int detEleHashIdx(const Identifier& id) const;
199 
200  // compact id indices
202 
206 
207  // Check level values
208  bool validElement(const ExpandedIdentifier& expId, int stationName, int stationEta, int stationPhi) const;
209  bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const;
210 
211  // Utility methods
212  int mmTechnology() const;
213  bool LargeSector(int stationName) const;
214  bool SmallSector(int stationName) const;
215 
216  // Level indices
218 
219  // Level ranges
220  enum MmRanges {
223  StationPhiMin = 1, // ED: change for MM
224  StationPhiMax = 8, // ED: change for MM
230  ChannelMax = 200
231  };
232 
233 }; // end class MmIdHelper
234 /*******************************************************************************/
235 // For backwards compatibility
237 
238 CLASS_DEF(MmIdHelper, 4175, 1)
239 
240 #endif // MUONIDHELPERS_MMIDHELPER_H
MmIdHelper::MultilayerMin
@ MultilayerMin
Definition: MmIdHelper.h:225
MmIdHelper::s_etaDim
static constexpr unsigned int s_etaDim
-2, -1 , 1, 2
Definition: MmIdHelper.h:183
MmIdHelper::stationPhiMin
static int stationPhiMin()
Definition: MmIdHelper.cxx:839
MuonIdHelper.h
MmIdHelper::MmRanges
MmRanges
Definition: MmIdHelper.h:220
MmIdHelper::~MmIdHelper
virtual ~MmIdHelper()=default
MmIdHelper::get_module_hash
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MmIdHelper.cxx:267
MmIdHelper::measuresPhi
bool measuresPhi(const Identifier &id) const override
Definition: MmIdHelper.cxx:857
MmIdHelper::MmIdHelper
MmIdHelper()
Definition: MmIdHelper.cxx:17
MmIdHelper::stationPhiMax
static int stationPhiMax()
Definition: MmIdHelper.cxx:841
MmIdHelper::s_mlDim
static constexpr unsigned int s_mlDim
2 multilayer
Definition: MmIdHelper.h:187
MmIdHelper::getFirstPcbChnl
static int getFirstPcbChnl(int stationEta, int pcb)
Definition: MmIdHelper.cxx:305
MmIdHelper::ChannelMin
@ ChannelMin
Definition: MmIdHelper.h:229
MmIdHelper::s_detHashDim
static constexpr unsigned int s_detHashDim
Definition: MmIdHelper.h:190
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
MmIdHelper::validElement
bool validElement(const Identifier &id) const
Definition: MmIdHelper.cxx:671
MmIdHelper::channelMax
static int channelMax()
Definition: MmIdHelper.cxx:863
MmIdHelper::febID
Identifier febID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int radius) const
Definition: MmIdHelper.cxx:345
MmIdHelper::StationPhiMax
@ StationPhiMax
Definition: MmIdHelper.h:224
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
MmIdHelper::isStNameInTech
bool isStNameInTech(const std::string &stationName) const override
The valid element checks converted the identifier to a stationName string in order to assess whether ...
Definition: MmIdHelper.cxx:670
MmIdHelper::get_detectorElement_hash
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MmIdHelper.cxx:274
MuonIdHelper::stationName
int stationName(const Identifier &id) const
Definition: MuonIdHelper.cxx:810
isValid
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition: AtlasPID.h:878
MmIdHelper::SmallSector
bool SmallSector(int stationName) const
Definition: MmIdHelper.cxx:874
MmIdHelper::GasGapMin
@ GasGapMin
Definition: MmIdHelper.h:227
MmIdHelper::detEleHashIdx
unsigned int detEleHashIdx(const Identifier &id) const
Definition: MmIdHelper.cxx:237
MmIdHelper::multilayer
int multilayer(const Identifier &id) const
Definition: MmIdHelper.cxx:828
MmIdHelper::m_gap_impl
IdDictFieldImplementation m_gap_impl
Definition: MmIdHelper.h:204
AtlasDetectorID::size_type
Identifier::size_type size_type
Definition: AtlasDetectorID.h:385
MmIdHelper::multilayerID
Identifier multilayerID(const Identifier &channeldID) const
Definition: MmIdHelper.cxx:282
IdDictMgr
Definition: IdDictMgr.h:15
MmIdHelper::StationEtaMin
@ StationEtaMin
Definition: MmIdHelper.h:221
MuonIdHelper
Definition: MuonIdHelper.h:77
MmIdHelper::MultilayerIndex
@ MultilayerIndex
Definition: MmIdHelper.h:217
MmIdHelper::m_mplet_impl
IdDictFieldImplementation m_mplet_impl
Definition: MmIdHelper.h:203
MmIdHelper::ChannelMax
@ ChannelMax
Definition: MmIdHelper.h:230
MmIdHelper::multilayerMax
static int multilayerMax()
Definition: MmIdHelper.cxx:845
MmIdHelper::MmIndices
MmIndices
Definition: MmIdHelper.h:217
MmIdHelper::gasGapMax
static int gasGapMax()
Definition: MmIdHelper.cxx:859
MmIdHelper::m_GASGAP_INDEX
size_type m_GASGAP_INDEX
Definition: MmIdHelper.h:201
MmIdHelper::m_cha_impl
IdDictFieldImplementation m_cha_impl
Definition: MmIdHelper.h:205
MmIdHelper::m_detectorElement_hashes
std::array< unsigned int, s_detHashDim > m_detectorElement_hashes
Definition: MmIdHelper.h:193
MmIdHelper::MultilayerMax
@ MultilayerMax
Definition: MmIdHelper.h:226
MmIdHelper::GasGapIndex
@ GasGapIndex
Definition: MmIdHelper.h:217
MmIdHelper::moduleHashIdx
unsigned int moduleHashIdx(const Identifier &id) const
Definition: MmIdHelper.cxx:229
MuonIdHelper::stationPhi
int stationPhi(const Identifier &id) const
Definition: MuonIdHelper.cxx:820
MmIdHelper::s_modHashDim
static constexpr unsigned int s_modHashDim
Definition: MmIdHelper.h:189
MmIdHelper::mmTechnology
int mmTechnology() const
Utility methods.
Definition: MmIdHelper.cxx:866
MmIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Definition: MmIdHelper.cxx:731
MmIdHelper::parentID
Identifier parentID(const Identifier &id) const
Definition: MmIdHelper.cxx:818
MmIdHelper::s_stDim
static constexpr unsigned int s_stDim
Small and big wedges.
Definition: MmIdHelper.h:181
MuonIdHelper::stationEta
int stationEta(const Identifier &id) const
Definition: MuonIdHelper.cxx:815
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MmIdHelper::StationEtaMax
@ StationEtaMax
Definition: MmIdHelper.h:222
MmIdHelper::StationPhiMin
@ StationPhiMin
Definition: MmIdHelper.h:223
MmIdHelper::init_id_to_hashes
int init_id_to_hashes()
Definition: MmIdHelper.cxx:241
MmIdHelper::stationEtaMin
static int stationEtaMin()
Definition: MmIdHelper.cxx:835
MmIdHelper::s_phiDim
static constexpr unsigned int s_phiDim
8 phi station
Definition: MmIdHelper.h:185
MmIdHelper::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: MmIdHelper.cxx:23
MmIdHelper::channel
int channel(const Identifier &id) const override
Definition: MmIdHelper.cxx:832
MmIdHelper
Definition: MmIdHelper.h:54
MmIdHelper::gasGap
int gasGap(const Identifier &id) const override
get the hashes
Definition: MmIdHelper.cxx:830
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:67
MmIdHelper::channelMin
static int channelMin()
Definition: MmIdHelper.cxx:861
MmIdHelper::pcbID
Identifier pcbID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int pcb) const
Definition: MmIdHelper.cxx:309
MmIdHelper::LargeSector
bool LargeSector(int stationName) const
Definition: MmIdHelper.cxx:872
MmIdHelper::stationEtaMax
static int stationEtaMax()
Definition: MmIdHelper.cxx:837
MmIdHelper::getFirstRadiusChnl
static int getFirstRadiusChnl(int stationEta, int pcb)
Definition: MmIdHelper.cxx:341
MmIdHelper::validChannel
bool validChannel(const Identifier &id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Definition: MmIdHelper.cxx:702
MM_ID
MmIdHelper MM_ID
Definition: MmIdHelper.h:236
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
MmIdHelper::idChannels
void idChannels(const Identifier &id, std::vector< Identifier > &vect) const
Definition: MmIdHelper.cxx:377
MmIdHelper::valid
bool valid(const Identifier &id) const
Definition: MmIdHelper.cxx:664
MmIdHelper::m_module_hashes
std::array< unsigned int, s_modHashDim > m_module_hashes
Definition: MmIdHelper.h:192
MmIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Definition: MmIdHelper.cxx:768
MmIdHelper::isStereo
bool isStereo(const Identifier &id) const
Definition: MmIdHelper.cxx:849
MmIdHelper::m_stationShift
unsigned int m_stationShift
Minimal station index found.
Definition: MmIdHelper.h:198
MmIdHelper::GasGapMax
@ GasGapMax
Definition: MmIdHelper.h:228
MmIdHelper::ChannelIndex
@ ChannelIndex
Definition: MmIdHelper.h:217
MmIdHelper::multilayerMin
static int multilayerMin()
Definition: MmIdHelper.cxx:843
MmIdHelper::sectorType
static int sectorType(const std::string &stationName, int stationEta)
Definition: MmIdHelper.cxx:877
MmIdHelper::numberOfMultilayers
int numberOfMultilayers(const Identifier &id) const
Definition: MmIdHelper.cxx:489
MmIdHelper::gasGapMin
static int gasGapMin()
Definition: MmIdHelper.cxx:847
Identifier
Definition: IdentifierFieldParser.cxx:14