ATLAS Offline Software
MmIdHelper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 init_id_to_hashes();
170  static constexpr unsigned int s_stDim = 2;
172  static constexpr unsigned int s_etaDim = 4;
174  static constexpr unsigned int s_phiDim = 8;
176  static constexpr unsigned int s_mlDim = 2;
177 
178  static constexpr unsigned int s_modHashDim = s_stDim * s_etaDim * s_phiDim;
179  static constexpr unsigned int s_detHashDim = s_modHashDim * s_mlDim;
180 
181  std::array<unsigned int, s_modHashDim> m_module_hashes{};
182  std::array<unsigned int, s_detHashDim> m_detectorElement_hashes{};
183 
184  unsigned int moduleHashIdx(const Identifier& id) const;
185  unsigned int detEleHashIdx(const Identifier& id) const;
188 
189  // compact id indices
191 
195 
196  // Check level values
197  bool validElement(const Identifier& id, int stationName, int stationEta, int stationPhi) const;
198  bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const;
199 
200  // Utility methods
201  int mmTechnology() const;
202  bool LargeSector(int stationName) const;
203  bool SmallSector(int stationName) const;
204 
205  // Level indices
207 
208  // Level ranges
209  enum MmRanges {
212  StationPhiMin = 1, // ED: change for MM
213  StationPhiMax = 8, // ED: change for MM
219  ChannelMax = 200
220  };
221 
222 }; // end class MmIdHelper
223 /*******************************************************************************/
224 // For backwards compatibility
226 
227 CLASS_DEF(MmIdHelper, 4175, 1)
228 
229 #endif // MUONIDHELPERS_MMIDHELPER_H
MmIdHelper::MultilayerMin
@ MultilayerMin
Definition: MmIdHelper.h:214
MmIdHelper::s_etaDim
static constexpr unsigned int s_etaDim
-2, -1 , 1, 2
Definition: MmIdHelper.h:172
MmIdHelper::stationPhiMin
static int stationPhiMin()
Definition: MmIdHelper.cxx:807
MuonIdHelper.h
MmIdHelper::MmRanges
MmRanges
Definition: MmIdHelper.h:209
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:261
max
#define max(a, b)
Definition: cfImp.cxx:41
MmIdHelper::measuresPhi
bool measuresPhi(const Identifier &id) const override
Definition: MmIdHelper.cxx:825
MmIdHelper::MmIdHelper
MmIdHelper()
Definition: MmIdHelper.cxx:11
MmIdHelper::stationPhiMax
static int stationPhiMax()
Definition: MmIdHelper.cxx:809
MmIdHelper::s_mlDim
static constexpr unsigned int s_mlDim
2 multilayer
Definition: MmIdHelper.h:176
MmIdHelper::getFirstPcbChnl
static int getFirstPcbChnl(int stationEta, int pcb)
Definition: MmIdHelper.cxx:299
MmIdHelper::ChannelMin
@ ChannelMin
Definition: MmIdHelper.h:218
MmIdHelper::s_detHashDim
static constexpr unsigned int s_detHashDim
Definition: MmIdHelper.h:179
MmIdHelper::validElement
bool validElement(const Identifier &id) const
Definition: MmIdHelper.cxx:637
MmIdHelper::channelMax
static int channelMax()
Definition: MmIdHelper.cxx:831
MmIdHelper::febID
Identifier febID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int radius) const
Definition: MmIdHelper.cxx:339
MmIdHelper::StationPhiMax
@ StationPhiMax
Definition: MmIdHelper.h:213
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:636
MmIdHelper::get_detectorElement_hash
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MmIdHelper.cxx:268
MuonIdHelper::stationName
int stationName(const Identifier &id) const
Definition: MuonIdHelper.cxx:804
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
MmIdHelper::SmallSector
bool SmallSector(int stationName) const
Definition: MmIdHelper.cxx:842
MmIdHelper::GasGapMin
@ GasGapMin
Definition: MmIdHelper.h:216
MmIdHelper::detEleHashIdx
unsigned int detEleHashIdx(const Identifier &id) const
Definition: MmIdHelper.cxx:231
MmIdHelper::multilayer
int multilayer(const Identifier &id) const
Definition: MmIdHelper.cxx:796
MmIdHelper::m_gap_impl
IdDictFieldImplementation m_gap_impl
Definition: MmIdHelper.h:193
AtlasDetectorID::size_type
Identifier::size_type size_type
Definition: AtlasDetectorID.h:384
MmIdHelper::multilayerID
Identifier multilayerID(const Identifier &channeldID) const
Definition: MmIdHelper.cxx:276
IdDictMgr
Definition: IdDictDefs.h:32
MmIdHelper::StationEtaMin
@ StationEtaMin
Definition: MmIdHelper.h:210
MuonIdHelper
Definition: MuonIdHelper.h:80
MmIdHelper::MultilayerIndex
@ MultilayerIndex
Definition: MmIdHelper.h:206
MmIdHelper::m_mplet_impl
IdDictFieldImplementation m_mplet_impl
Definition: MmIdHelper.h:192
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
MmIdHelper::ChannelMax
@ ChannelMax
Definition: MmIdHelper.h:219
MmIdHelper::multilayerMax
static int multilayerMax()
Definition: MmIdHelper.cxx:813
MmIdHelper::MmIndices
MmIndices
Definition: MmIdHelper.h:206
MmIdHelper::gasGapMax
static int gasGapMax()
Definition: MmIdHelper.cxx:827
MmIdHelper::m_GASGAP_INDEX
size_type m_GASGAP_INDEX
Definition: MmIdHelper.h:190
MmIdHelper::m_cha_impl
IdDictFieldImplementation m_cha_impl
Definition: MmIdHelper.h:194
MmIdHelper::m_detectorElement_hashes
std::array< unsigned int, s_detHashDim > m_detectorElement_hashes
Definition: MmIdHelper.h:182
MmIdHelper::MultilayerMax
@ MultilayerMax
Definition: MmIdHelper.h:215
MmIdHelper::GasGapIndex
@ GasGapIndex
Definition: MmIdHelper.h:206
MmIdHelper::moduleHashIdx
unsigned int moduleHashIdx(const Identifier &id) const
Definition: MmIdHelper.cxx:223
MuonIdHelper::stationPhi
int stationPhi(const Identifier &id) const
Definition: MuonIdHelper.cxx:814
MmIdHelper::s_modHashDim
static constexpr unsigned int s_modHashDim
Definition: MmIdHelper.h:178
MmIdHelper::mmTechnology
int mmTechnology() const
Utility methods.
Definition: MmIdHelper.cxx:834
MmIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Definition: MmIdHelper.cxx:706
MmIdHelper::parentID
Identifier parentID(const Identifier &id) const
Definition: MmIdHelper.cxx:786
MmIdHelper::s_stDim
static constexpr unsigned int s_stDim
Small and big wedges.
Definition: MmIdHelper.h:170
MuonIdHelper::stationEta
int stationEta(const Identifier &id) const
Definition: MuonIdHelper.cxx:809
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MmIdHelper::StationEtaMax
@ StationEtaMax
Definition: MmIdHelper.h:211
MmIdHelper::StationPhiMin
@ StationPhiMin
Definition: MmIdHelper.h:212
MmIdHelper::init_id_to_hashes
int init_id_to_hashes()
Definition: MmIdHelper.cxx:235
MmIdHelper::stationEtaMin
static int stationEtaMin()
Definition: MmIdHelper.cxx:803
MmIdHelper::s_phiDim
static constexpr unsigned int s_phiDim
8 phi station
Definition: MmIdHelper.h:174
MmIdHelper::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: MmIdHelper.cxx:17
MmIdHelper::channel
int channel(const Identifier &id) const override
Definition: MmIdHelper.cxx:800
MmIdHelper
Definition: MmIdHelper.h:54
MmIdHelper::gasGap
int gasGap(const Identifier &id) const override
get the hashes
Definition: MmIdHelper.cxx:798
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:64
MmIdHelper::channelMin
static int channelMin()
Definition: MmIdHelper.cxx:829
MmIdHelper::pcbID
Identifier pcbID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int pcb) const
Definition: MmIdHelper.cxx:303
MmIdHelper::LargeSector
bool LargeSector(int stationName) const
Definition: MmIdHelper.cxx:840
MmIdHelper::stationEtaMax
static int stationEtaMax()
Definition: MmIdHelper.cxx:805
MmIdHelper::getFirstRadiusChnl
static int getFirstRadiusChnl(int stationEta, int pcb)
Definition: MmIdHelper.cxx:335
MmIdHelper::validChannel
bool validChannel(const Identifier &id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Definition: MmIdHelper.cxx:683
MM_ID
MmIdHelper MM_ID
Definition: MmIdHelper.h:225
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdentifierHash
Definition: IdentifierHash.h:38
MmIdHelper::idChannels
void idChannels(const Identifier &id, std::vector< Identifier > &vect) const
Definition: MmIdHelper.cxx:371
MmIdHelper::valid
bool valid(const Identifier &id) const
Definition: MmIdHelper.cxx:613
MmIdHelper::m_module_hashes
std::array< unsigned int, s_modHashDim > m_module_hashes
Definition: MmIdHelper.h:181
MmIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Definition: MmIdHelper.cxx:736
MmIdHelper::isStereo
bool isStereo(const Identifier &id) const
Definition: MmIdHelper.cxx:817
MmIdHelper::m_stationShift
unsigned int m_stationShift
Minimal station index found.
Definition: MmIdHelper.h:187
MmIdHelper::GasGapMax
@ GasGapMax
Definition: MmIdHelper.h:217
MmIdHelper::ChannelIndex
@ ChannelIndex
Definition: MmIdHelper.h:206
MmIdHelper::multilayerMin
static int multilayerMin()
Definition: MmIdHelper.cxx:811
MmIdHelper::sectorType
static int sectorType(const std::string &stationName, int stationEta)
Definition: MmIdHelper.cxx:845
MmIdHelper::numberOfMultilayers
int numberOfMultilayers(const Identifier &id) const
Definition: MmIdHelper.cxx:464
MmIdHelper::gasGapMin
static int gasGapMin()
Definition: MmIdHelper.cxx:815