ATLAS Offline Software
MdtIdHelper.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 //<doc><file> $Id: MdtIdHelper.h,v 1.34 2009-01-20 22:44:13 kblack Exp $
11 //<version> $Name: not supported by cvs2svn $
12 
13 #ifndef MUONIDHELPERS_MDTIDHELPER_H
14 #define MUONIDHELPERS_MDTIDHELPER_H
15 
16 // Includes
17 
19 
20 // ******************************************************************************
21 // class MdtIdHelper
22 // ******************************************************************************
23 //
24 // Description
25 // -----------
26 // This factory class constructs MDT identifiers and ranges and provides access
27 // to the levels. ATLAS note ATL-MUON-2002-??? provides a complete description
28 // of the hierarchical identifier scheme. MdtIdHelper provides an interface to the
29 // following fields of the identifier.
30 //
31 // Field Range Notes
32 // ==============================================================================
33 // StationName unsigned integer maps to "BIL", "EMS" ,etc.
34 // StationEta [-6,-1] backward endcap (-1 at lowest R)
35 // [-8,8] barrel (increases with Z)
36 // [-6,-1]+[1,6] forward endcap (1 at lowest R)
37 // StationPhi [1,8] increases with phi
38 // Technology [0] maps to "MDT"
39 // Multilayer [1,2] barrel: increases with R
40 // endcap: increases with |Z|
41 // TubeLayer [1,4] barrel: increases with R
42 // endcap: increases with |Z|
43 // Tube [1,n] barrel: increases with |Z|
44 // endcap: increases with R
45 // ==============================================================================
46 //
47 // Inheritance
48 // -----------
49 // Inherits from MuonIdHelpers/MuonIdHelper.
50 //
51 // Author
52 // ------
53 // Steven Goldfarb <Steven.Goldfarb@cern.ch>
54 //
55 // Compact Id implementation by
56 // Ketevi A. Assamagan <ketevi@bnl.gov>
57 // BNL, March 10th, 2003
58 //
59 // ******************************************************************************
60 
61 class MdtIdHelper : public MuonIdHelper {
62 public:
68  static constexpr int maxNTubesPerLayer = 120;
69 
70  // Constructor
71  MdtIdHelper();
72 
73  // Destructor
74 
75  virtual ~MdtIdHelper() = default;
76 
78 
80  virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr) override;
81  virtual int get_module_hash(const Identifier& id, IdentifierHash& hash_id) const override;
82  virtual int get_detectorElement_hash(const Identifier& id, IdentifierHash& hash_id) const override;
83 
85 
86  // Atlas Identifier builders
87 
89  Identifier elementID(int stationName, int stationEta, int stationPhi, bool& isValid) const;
90 
91  Identifier elementID(const std::string& stationNameStr, int stationEta, int stationPhi) const;
92  Identifier elementID(const std::string& stationNameStr, int stationEta, int stationPhi, bool& isValid) const;
93 
95 
96  Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const;
97  Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube, bool& isValid) const;
98 
99  Identifier channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const;
100  Identifier channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube,
101  bool& isValid) const;
102 
103  Identifier channelID(const Identifier& id, int multilayer, int tubeLayer, int tube) const;
104  Identifier channelID(const Identifier& id, int multilayer, int tubeLayer, int tube, bool& isValid) const;
105 
106  Identifier parentID(const Identifier& id) const;
107 
108  Identifier multilayerID(const Identifier& channeldID) const;
109 
110  Identifier multilayerID(const Identifier& moduleID, int multilayer) const;
111  Identifier multilayerID(const Identifier& moduleID, int multilayer, bool& isValid) const;
112 
113  // for an Identifier id, get the list of the daughter readout channel ids
114  void idChannels(const Identifier& id, std::vector<Identifier>& vect) const;
115 
116  // Access to levels: missing field returns 0
117  int channel(const Identifier& id) const override;
118 
119  int multilayer(const Identifier& id) const;
120  int tubeLayer(const Identifier& id) const;
121  int tube(const Identifier& id) const;
122 
123  int numberOfMultilayers(const Identifier& id) const;
124 
125  // Access to min and max of level ranges
126 
127  static int stationEtaMin(bool barrel) ;
128  static int stationEtaMax(bool barrel) ;
129  static int stationPhiMin() ;
130  static int stationPhiMax() ;
131  static int multilayerMin() ;
132  static int multilayerMax() ;
133  static int tubeLayerMin() ;
134  static int tubeLayerMax() ;
135  static int tubeMin() ;
136  int tubeMax() const;
137 
138  // Access to min and max of level ranges
139 
140  int stationEtaMin(const Identifier& id) const;
141  int stationEtaMax(const Identifier& id) const;
142  int stationPhiMin(const Identifier& id) const;
143  int stationPhiMax(const Identifier& id) const;
144  int multilayerMin(const Identifier& id) const;
145  int multilayerMax(const Identifier& id) const;
146  int tubeLayerMin(const Identifier& id) const;
147  int tubeLayerMax(const Identifier& id) const;
148  int tubeMin(const Identifier& id) const;
149  int tubeMax(const Identifier& id) const;
150 
151  // etamin, etamax, phimin, phimax
152  std::tuple<int, int, int, int>
153  stationEtaPhiMinMax(const Identifier& id) const;
154  std::pair<int, int> stationEtaMinMax(const Identifier& id) const;
155  std::pair<int, int> stationPhiMinMax(const Identifier& id) const;
156  std::pair<int, int> multilayerMinMax(const Identifier& id) const;
157  std::pair<int, int> tubeLayerMinMax(const Identifier& id) const;
158  std::pair<int, int> tubeMinMax(const Identifier& id) const;
159 
160  // Public validation of levels
161 
162  bool valid(const Identifier& id) const;
163  bool validElement(const Identifier& id) const;
164 
166  int gasGap(const Identifier& id) const override;
168  bool measuresPhi(const Identifier& id) const override;
170  bool isBMG(const Identifier& id) const;
172  bool isBME(const Identifier& id) const;
173 
174 private:
175  bool isStNameInTech(const std::string& stationName) const override;
176  int init_id_to_hashes();
177 
178  static constexpr unsigned s_stDim = 55;
179  static constexpr unsigned s_etaDim = 16;
180  static constexpr unsigned s_phiDim = 8;
181  static constexpr unsigned s_mlDim = 2;
182  static constexpr unsigned int s_modHash = s_stDim * s_etaDim * s_phiDim;
183  static constexpr unsigned int s_detDim = s_modHash * s_mlDim;
184 
185  unsigned int moduleHashIdx(const Identifier& id) const;
186  unsigned int detEleHashIdx(const Identifier& id) const;
187 
188  std::array<unsigned int, s_modHash> m_module_hashes{};
189  std::array<unsigned int, s_detDim> m_detectorElement_hashes{};
190 
191  // compact id indices
196 
197  // Private validation of levels
198 
199  bool validElement(const Identifier& id, int stationName, int stationEta, int stationPhi) const;
200  bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const;
201 
202  // Utility method
203 
204  int mdtTechnology() const;
205 
206  // Level indices
207 
209 
210  // Level ranges
211 
212  enum MdtRanges {
223  TubeMin = 1,
224  TubeMax = 78
225  };
226  unsigned int m_tubesMax{UINT_MAX}; // maximum number of tubes in any chamber
227 
228  int m_BME_stat{-1};
229  int m_BMG_stat{-1};
230 
231  // To speed up the range scans needed by the MinMax functions,
232  // keep indices of ranges by station name.
233  using ranges_by_station_t = std::vector<std::vector<const Range*> >;
236 
237  std::pair<int, int>
238  findMinMax (const Identifier& id,
239  const size_type field_index,
240  const ranges_by_station_t& ranges_by_station) const;
241 };
242 
243 // For backwards compatibility
244 
246 
247 CLASS_DEF(MdtIdHelper, 4170, 1)
248 
249 // Construct Atlas Identifiers from components
250 
251 #endif // MUONIDHELPERS_MDTIDHELPER_H
MdtIdHelper::isBMG
bool isBMG(const Identifier &id) const
is this a BMG chamber
Definition: MdtIdHelper.cxx:734
MdtIdHelper::multilayer
int multilayer(const Identifier &id) const
Access to components of the ID.
Definition: MdtIdHelper.cxx:722
MdtIdHelper::validElement
bool validElement(const Identifier &id) const
Definition: MdtIdHelper.cxx:557
MuonIdHelper.h
MdtIdHelper::m_lay_impl
IdDictFieldImplementation m_lay_impl
Definition: MdtIdHelper.h:194
MdtIdHelper::tubeMax
int tubeMax() const
Definition: MdtIdHelper.cxx:770
MdtIdHelper::stationEtaMin
static int stationEtaMin(bool barrel)
Access to min and max of level ranges.
Definition: MdtIdHelper.cxx:740
MdtIdHelper::numberOfMultilayers
int numberOfMultilayers(const Identifier &id) const
Definition: MdtIdHelper.cxx:496
MdtIdHelper::MultilayerMax
@ MultilayerMax
Definition: MdtIdHelper.h:220
MdtIdHelper::StationPhiMax
@ StationPhiMax
Definition: MdtIdHelper.h:218
MdtIdHelper::StationEtaEndcapMax
@ StationEtaEndcapMax
Definition: MdtIdHelper.h:216
MdtIdHelper::s_etaDim
static constexpr unsigned s_etaDim
Definition: MdtIdHelper.h:179
MdtIdHelper::m_module_hashes
std::array< unsigned int, s_modHash > m_module_hashes
Definition: MdtIdHelper.h:188
MdtIdHelper::s_stDim
static constexpr unsigned s_stDim
Definition: MdtIdHelper.h:178
MdtIdHelper::StationPhiMin
@ StationPhiMin
Definition: MdtIdHelper.h:217
MdtIdHelper::MdtRanges
MdtRanges
Definition: MdtIdHelper.h:212
MdtIdHelper::tubeLayer
int tubeLayer(const Identifier &id) const
Definition: MdtIdHelper.cxx:724
MdtIdHelper::~MdtIdHelper
virtual ~MdtIdHelper()=default
MdtIdHelper::TubeMax
@ TubeMax
Definition: MdtIdHelper.h:224
MdtIdHelper::TubeMin
@ TubeMin
Definition: MdtIdHelper.h:223
MuonIdHelper::stationName
int stationName(const Identifier &id) const
Definition: MuonIdHelper.cxx:800
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:225
MdtIdHelper::multilayerMinMax
std::pair< int, int > multilayerMinMax(const Identifier &id) const
Definition: MdtIdHelper.cxx:515
MdtIdHelper::m_TUBELAYER_INDEX
size_type m_TUBELAYER_INDEX
Definition: MdtIdHelper.h:192
MdtIdHelper::TubeLayerMax
@ TubeLayerMax
Definition: MdtIdHelper.h:222
MdtIdHelper::m_detectorElement_hashes
std::array< unsigned int, s_detDim > m_detectorElement_hashes
Definition: MdtIdHelper.h:189
MdtIdHelper::moduleHashIdx
unsigned int moduleHashIdx(const Identifier &id) const
Definition: MdtIdHelper.cxx:306
MdtIdHelper::TubeIndex
@ TubeIndex
Definition: MdtIdHelper.h:208
MdtIdHelper::findMinMax
std::pair< int, int > findMinMax(const Identifier &id, const size_type field_index, const ranges_by_station_t &ranges_by_station) const
Definition: MdtIdHelper.cxx:417
MdtIdHelper::measuresPhi
bool measuresPhi(const Identifier &id) const override
always false for MDTs
Definition: MdtIdHelper.cxx:730
MdtIdHelper::multilayerMax
static int multilayerMax()
Definition: MdtIdHelper.cxx:762
MdtIdHelper::tubeMinMax
std::pair< int, int > tubeMinMax(const Identifier &id) const
Definition: MdtIdHelper.cxx:525
MdtIdHelper::StationEtaEndcapMin
@ StationEtaEndcapMin
Definition: MdtIdHelper.h:215
MdtIdHelper::s_phiDim
static constexpr unsigned s_phiDim
Definition: MdtIdHelper.h:180
MdtIdHelper::multilayerMin
static int multilayerMin()
Definition: MdtIdHelper.cxx:760
MdtIdHelper::tubeLayerMinMax
std::pair< int, int > tubeLayerMinMax(const Identifier &id) const
Definition: MdtIdHelper.cxx:520
AtlasDetectorID::size_type
Identifier::size_type size_type
Definition: AtlasDetectorID.h:384
MdtIdHelper::tubeLayerMax
static int tubeLayerMax()
Definition: MdtIdHelper.cxx:766
IdDictMgr
Definition: IdDictDefs.h:32
MdtIdHelper::m_BMG_stat
int m_BMG_stat
Definition: MdtIdHelper.h:229
MdtIdHelper::m_BME_stat
int m_BME_stat
Definition: MdtIdHelper.h:228
MuonIdHelper
Definition: MuonIdHelper.h:80
MdtIdHelper::stationEtaMax
static int stationEtaMax(bool barrel)
Definition: MdtIdHelper.cxx:748
MDT_ID
MdtIdHelper MDT_ID
Definition: MdtIdHelper.h:245
MdtIdHelper::MdtIndices
MdtIndices
Definition: MdtIdHelper.h:208
MdtIdHelper::channel
int channel(const Identifier &id) const override
Definition: MdtIdHelper.cxx:736
MdtIdHelper::TubeLayerMin
@ TubeLayerMin
Definition: MdtIdHelper.h:221
MdtIdHelper
Definition: MdtIdHelper.h:61
MdtIdHelper::tube
int tube(const Identifier &id) const
Definition: MdtIdHelper.cxx:726
MdtIdHelper::StationEtaBarrelMin
@ StationEtaBarrelMin
Definition: MdtIdHelper.h:213
MdtIdHelper::validChannel
bool validChannel(const Identifier &id, int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Definition: MdtIdHelper.cxx:606
MdtIdHelper::s_mlDim
static constexpr unsigned s_mlDim
Definition: MdtIdHelper.h:181
MdtIdHelper::init_id_to_hashes
int init_id_to_hashes()
Definition: MdtIdHelper.cxx:282
MdtIdHelper::stationEtaPhiMinMax
std::tuple< int, int, int, int > stationEtaPhiMinMax(const Identifier &id) const
Definition: MdtIdHelper.cxx:453
MdtIdHelper::stationEtaMinMax
std::pair< int, int > stationEtaMinMax(const Identifier &id) const
Definition: MdtIdHelper.cxx:443
MdtIdHelper::tubeMin
static int tubeMin()
Definition: MdtIdHelper.cxx:768
MuonIdHelper::stationPhi
int stationPhi(const Identifier &id) const
Definition: MuonIdHelper.cxx:810
MdtIdHelper::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: MdtIdHelper.cxx:15
MdtIdHelper::s_modHash
static constexpr unsigned int s_modHash
Definition: MdtIdHelper.h:182
MdtIdHelper::stationPhiMinMax
std::pair< int, int > stationPhiMinMax(const Identifier &id) const
Definition: MdtIdHelper.cxx:448
MdtIdHelper::detEleHashIdx
unsigned int detEleHashIdx(const Identifier &id) const
Definition: MdtIdHelper.cxx:316
MdtIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Definition: MdtIdHelper.cxx:659
MdtIdHelper::m_module_ranges_by_station
ranges_by_station_t m_module_ranges_by_station
Definition: MdtIdHelper.h:234
MuonIdHelper::stationEta
int stationEta(const Identifier &id) const
Definition: MuonIdHelper.cxx:805
MdtIdHelper::isBME
bool isBME(const Identifier &id) const
is this a BME chamber
Definition: MdtIdHelper.cxx:732
MdtIdHelper::MdtIdHelper
MdtIdHelper()
Definition: MdtIdHelper.cxx:8
MdtIdHelper::m_tub_impl
IdDictFieldImplementation m_tub_impl
Definition: MdtIdHelper.h:195
MdtIdHelper::valid
bool valid(const Identifier &id) const
Public validation of levels.
Definition: MdtIdHelper.cxx:531
MdtIdHelper::MultilayerMin
@ MultilayerMin
Definition: MdtIdHelper.h:219
MdtIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Definition: MdtIdHelper.cxx:630
MdtIdHelper::get_detectorElement_hash
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MdtIdHelper.cxx:326
MdtIdHelper::MultilayerIndex
@ MultilayerIndex
Definition: MdtIdHelper.h:208
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
DetectorZone::barrel
@ barrel
MdtIdHelper::stationPhiMax
static int stationPhiMax()
Definition: MdtIdHelper.cxx:758
MdtIdHelper::multilayerID
Identifier multilayerID(const Identifier &channeldID) const
Definition: MdtIdHelper.cxx:333
MdtIdHelper::gasGap
int gasGap(const Identifier &id) const override
the gas-gap function for the MDT's returns the tube layer
Definition: MdtIdHelper.cxx:728
MdtIdHelper::StationEtaBarrelMax
@ StationEtaBarrelMax
Definition: MdtIdHelper.h:214
MdtIdHelper::m_mla_impl
IdDictFieldImplementation m_mla_impl
Definition: MdtIdHelper.h:193
MdtIdHelper::get_module_hash
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MdtIdHelper.cxx:319
MdtIdHelper::TubeLayerIndex
@ TubeLayerIndex
Definition: MdtIdHelper.h:208
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
MdtIdHelper::maxNTubesPerLayer
static constexpr int maxNTubesPerLayer
The maxNTubesPerLayer represents the absolute maximum of tubes which are built into a single multilay...
Definition: MdtIdHelper.h:68
MdtIdHelper::s_detDim
static constexpr unsigned int s_detDim
Definition: MdtIdHelper.h:183
MdtIdHelper::ranges_by_station_t
std::vector< std::vector< const Range * > > ranges_by_station_t
Definition: MdtIdHelper.h:233
MdtIdHelper::stationPhiMin
static int stationPhiMin()
Definition: MdtIdHelper.cxx:756
MdtIdHelper::mdtTechnology
int mdtTechnology() const
Utility methods.
Definition: MdtIdHelper.cxx:773
MdtIdHelper::m_channel_ranges_by_station
ranges_by_station_t m_channel_ranges_by_station
Definition: MdtIdHelper.h:235
MdtIdHelper::tubeLayerMin
static int tubeLayerMin()
Definition: MdtIdHelper.cxx:764
MdtIdHelper::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: MdtIdHelper.cxx:556
MdtIdHelper::parentID
Identifier parentID(const Identifier &id) const
get parent id from channel id
Definition: MdtIdHelper.cxx:711
MdtIdHelper::idChannels
void idChannels(const Identifier &id, std::vector< Identifier > &vect) const
Definition: MdtIdHelper.cxx:355
MdtIdHelper::m_tubesMax
unsigned int m_tubesMax
Definition: MdtIdHelper.h:226
Identifier
Definition: IdentifierFieldParser.cxx:14