ATLAS Offline Software
Loading...
Searching...
No Matches
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
61class MdtIdHelper : public MuonIdHelper {
62public:
68 static constexpr int maxNTubesPerLayer = 120;
69
70 // Constructor
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
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
174private:
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
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
247CLASS_DEF(MdtIdHelper, 4170, 1)
248
249// Construct Atlas Identifiers from components
250
251#endif // MUONIDHELPERS_MDTIDHELPER_H
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
MdtIdHelper MDT_ID
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
This is a "hash" representation of an Identifier.
Identifier multilayerID(const Identifier &channeldID) const
std::pair< int, int > tubeLayerMinMax(const Identifier &id) const
static int stationPhiMin()
static int stationEtaMax(bool barrel)
bool validChannel(const Identifier &id, int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
ranges_by_station_t m_module_ranges_by_station
unsigned int detEleHashIdx(const Identifier &id) const
std::array< unsigned int, s_detDim > m_detectorElement_hashes
virtual ~MdtIdHelper()=default
int multilayer(const Identifier &id) const
Access to components of the ID.
Identifier parentID(const Identifier &id) const
get parent id from channel id
Identifier elementID(int stationName, int stationEta, int stationPhi) const
bool validElement(const Identifier &id) const
std::tuple< int, int, int, int > stationEtaPhiMinMax(const Identifier &id) const
static int stationPhiMax()
std::pair< int, int > tubeMinMax(const Identifier &id) const
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool isBME(const Identifier &id) const
is this a BME chamber
static int multilayerMin()
bool valid(const Identifier &id) const
Public validation of levels.
std::pair< int, int > stationPhiMinMax(const Identifier &id) const
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
bool isStNameInTech(const std::string &stationName) const override
The valid element checks converted the identifier to a stationName string in order to assess whether ...
ranges_by_station_t m_channel_ranges_by_station
int mdtTechnology() const
Utility methods.
int tube(const Identifier &id) const
static constexpr unsigned s_mlDim
std::pair< int, int > stationEtaMinMax(const Identifier &id) const
int init_id_to_hashes()
IdDictFieldImplementation m_lay_impl
static int tubeLayerMax()
static constexpr unsigned s_etaDim
int tubeLayer(const Identifier &id) const
static constexpr unsigned int s_detDim
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
IdDictFieldImplementation m_tub_impl
static int stationEtaMin(bool barrel)
Access to min and max of level ranges.
int channel(const Identifier &id) const override
unsigned int moduleHashIdx(const Identifier &id) const
std::array< unsigned int, s_modHash > m_module_hashes
std::pair< int, int > multilayerMinMax(const Identifier &id) const
unsigned int m_tubesMax
static constexpr unsigned s_phiDim
std::pair< int, int > findMinMax(const Identifier &id, const size_type field_index, const ranges_by_station_t &ranges_by_station) const
static int multilayerMax()
static constexpr unsigned int s_modHash
size_type m_TUBELAYER_INDEX
static constexpr int maxNTubesPerLayer
The maxNTubesPerLayer represents the absolute maximum of tubes which are built into a single multilay...
Definition MdtIdHelper.h:68
int numberOfMultilayers(const Identifier &id) const
IdDictFieldImplementation m_mla_impl
int tubeMax() const
bool isBMG(const Identifier &id) const
is this a BMG chamber
static int tubeLayerMin()
bool measuresPhi(const Identifier &id) const override
always false for MDTs
int gasGap(const Identifier &id) const override
the gas-gap function for the MDT's returns the tube layer
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
static constexpr unsigned s_stDim
static int tubeMin()
std::vector< std::vector< const Range * > > ranges_by_station_t
void idChannels(const Identifier &id, std::vector< Identifier > &vect) const
int stationEta(const Identifier &id) const
int stationPhi(const Identifier &id) const
int stationName(const Identifier &id) const
Identifier::size_type size_type
MuonIdHelper(const std::string &logName, const std::string &group)