ATLAS Offline Software
CscIdHelper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ******************************************************************************
6 // ATLAS Muon Identifier Helpers Package
7 // ******************************************************************************
8 
9 #ifndef MUONIDHELPERS_CSCIDHELPER_H
10 #define MUONIDHELPERS_CSCIDHELPER_H
11 
13 
14 // ******************************************************************************
15 // class CscIdHelper
16 // ******************************************************************************
17 //
18 // Description
19 // -----------
20 // This factory class constructs CSC identifiers and ranges and provides access
21 // to the levels. ATLAS note ATL-MUON-2001-014 provides a complete description
22 // of the hierarchical identifier scheme. CscIdHelper provides an interface to the
23 // following fields of the identifier.
24 //
25 // Field Range Notes
26 // ==============================================================================
27 // StationName unsigned integer maps to "CSS", "CSL", etc.
28 // StationEta [-1,1] -1 for backward, 1 for forward endcap
29 // StationPhi [1,8] increases with Phi
30 // Technology [1] maps to "CSC"
31 // ChamberLayer [1,2] increases with |Z|
32 // WireLayer [1,4] increases with |Z|
33 // MeasuresPhi [0,1] 0 if measures R, 1 if measures Phi
34 // Strip [1,n] increases with R for MeasuresPhi=0
35 // increases with Phi for MeasuresPhi=1
36 // ==============================================================================
37 //
38 // Inheritance
39 // -----------
40 // Inherits from MuonIdHelpers/MuonIdHelper.
41 //
42 // Author
43 // ------
44 // Steven Goldfarb <Steven.Goldfarb@cern.ch>
45 //
46 // Compact Id implementation by
47 // Ketevi A. Assamagan <ketevi@bnl.gov>
48 // BNL, February 27th, 2003
49 //
50 // ******************************************************************************
51 
52 class CscIdHelper : public MuonIdHelper {
53 public:
54  // Constructor
55 
56  CscIdHelper();
57 
58  // Destructor
59 
60  virtual ~CscIdHelper() = default;
61 
63 
65  int initialize_from_dictionary(const IdDictMgr& dict_mgr) override;
66 
67  // need to overwrite get_module_hash and get_detectorElement_hash for Run2 geometries (since they contain both
68  // CSC chamberLayer 1 and 2 although only chamberLayer 2 is actually built into ATLAS)
69  // function checks whether chamberLayer 1 identifiers are around and in this case returns the correct module hash
70  int get_module_hash(const Identifier& id, IdentifierHash& hash_id) const override;
71  int get_detectorElement_hash(const Identifier& id, IdentifierHash& hash_id) const override;
72 
74 
75  // Identifier builders
77  Identifier elementID(int stationName, int stationEta, int stationPhi, bool& isValid) const;
78 
79  Identifier elementID(const std::string& stationNameStr, int stationEta, int stationPhi) const;
80  Identifier elementID(const std::string& stationNameStr, int stationEta, int stationPhi, bool& isValid) const;
81 
83 
85  int strip) const;
87  bool& isValid) const;
88 
89  Identifier channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int chamberLayer, int wireLayer,
90  int measuresPhi, int strip) const;
91  Identifier channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int chamberLayer, int wireLayer,
92  int measuresPhi, int strip, bool& isValid) const;
93 
94  Identifier channelID(const Identifier& id, int chamberLayer, int wireLayer, int measurePhi, int strip) const;
95  Identifier channelID(const Identifier& id, int chamberLayer, int wireLayer, int measurePhi, int strip, bool& isValid) const;
96 
97  Identifier parentID(const Identifier& id) const;
98 
99  // for an Identifier id, get the list of the daughter readout channel ids
100  void idChannels(const Identifier& id, std::vector<Identifier>& vect) const;
101 
102  // Access to levels: missing field returns 0
103 
104  int channel(const Identifier& id) const override;
105 
106  int chamberLayer(const Identifier& id) const;
107  int wireLayer(const Identifier& id) const;
108  bool measuresPhi(const Identifier& id) const override;
109  int strip(const Identifier& id) const;
110  int gasGap(const Identifier& id) const override; // Returns chamber Layer here
111 
112  int sector(const Identifier& id) const;
113  // Access to min and max of level ranges
114  // to be remove when we moved to compact ids
115 
116  static int stationEtaMin() ;
117  static int stationEtaMax() ;
118  static int stationPhiMin() ;
119  static int stationPhiMax() ;
120  static int chamberLayerMin() ;
121  static int chamberLayerMax() ;
122  static int wireLayerMin() ;
123  static int wireLayerMax() ;
124  static int measuresPhiMin() ;
125  static int measuresPhiMax() ;
126  static int stripMin() ;
127  static int stripMax() ;
128 
129  // Access to min and max of level ranges
130 
131  int stationEtaMin(const Identifier& id) const;
132  int stationEtaMax(const Identifier& id) const;
133  int stationPhiMin(const Identifier& id) const;
134  int stationPhiMax(const Identifier& id) const;
135  int chamberLayerMin(const Identifier& id) const;
136  int chamberLayerMax(const Identifier& id) const;
137  int wireLayerMin(const Identifier& id) const;
138  int wireLayerMax(const Identifier& id) const;
139  int measuresPhiMin(const Identifier& id) const;
140  int measuresPhiMax(const Identifier& id) const;
141  int stripMin(const Identifier& id) const;
142  int stripMax(const Identifier& id) const;
143 
144  // Public validation of levels
145 
146  bool valid(const Identifier& id) const;
147  bool validElement(const Identifier& id) const;
148 
149 private:
150  bool isStNameInTech(const std::string& stationName) const override;
151  int init_id_to_hashes();
152 
153  // CSS / CSL
154  static constexpr unsigned int s_stDim = 2;
155  // -1, 1 eta dimension
156  static constexpr unsigned int s_etaDim = 2;
158  static constexpr unsigned int s_phiDim = 8;
160  static constexpr unsigned int s_mlDim = 2;
161 
162  static constexpr unsigned int s_modHashDim = s_stDim * s_etaDim * s_phiDim;
163  static constexpr unsigned int s_detHashDim = s_modHashDim * s_mlDim;
164 
165  std::array<unsigned int, s_modHashDim> m_module_hashes{};
166  std::array<unsigned int, s_detHashDim> m_detectorElement_hashes{};
167 
168  unsigned int moduleHashIdx(const Identifier& id) const;
169  unsigned int detEleHashIdx(const Identifier& id) const;
172 
173 
174  // compact id indices
178 
183 
184  // Private validation of levels
185 
186  bool validElement(const Identifier& id, int stationName, int stationEta, int stationPhi) const;
187  bool validChannel(const Identifier& id, int stationName, int stationEta, int stationPhi, int chamberLayer, int wireLayer,
188  int measuresPhi, int strip) const;
189 
190  // Utility methods
191 
192  int cscTechnology() const;
193 
194  // hash offset of strips */
195  int strip_hash_offsets();
196 
197  // Level indices
198 
200 
201  // Level ranges
202 
203  enum CscRanges {
214  StripMin = 1,
215  StripMax = 216 // up to AMDB P
216  };
217  int m_hashOffset[2][2]{};
218 
219  unsigned int m_stripMaxPhi{UINT_MAX}; // maximum number of strips for layer which measuresPhi
220  unsigned int m_stripMaxEta{UINT_MAX}; // maximum number of strips for layer which does not measure phi
221  bool m_hasChamLay1{false};
222 };
223 
224 // For backwards compatibility
225 
227 
228 CLASS_DEF(CscIdHelper, 4171, 1)
229 
230 #endif // MUONIDHELPERS_CSCIDHELPER_H
CscIdHelper::valid
bool valid(const Identifier &id) const
Public validation of levels.
Definition: CscIdHelper.cxx:555
MuonIdHelper.h
CscIdHelper::stripMax
static int stripMax()
Definition: CscIdHelper.cxx:804
CscIdHelper::s_phiDim
static constexpr unsigned int s_phiDim
8 phi stations
Definition: CscIdHelper.h:158
CscIdHelper::ChamberLayerMax
@ ChamberLayerMax
Definition: CscIdHelper.h:209
max
#define max(a, b)
Definition: cfImp.cxx:41
CscIdHelper::moduleHashIdx
unsigned int moduleHashIdx(const Identifier &id) const
Definition: CscIdHelper.cxx:288
CscIdHelper::initialize_from_dictionary
int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: CscIdHelper.cxx:13
CscIdHelper::m_MEASURESPHI_INDEX
size_type m_MEASURESPHI_INDEX
Definition: CscIdHelper.h:177
CscIdHelper::m_hasChamLay1
bool m_hasChamLay1
Definition: CscIdHelper.h:221
CscIdHelper::idChannels
void idChannels(const Identifier &id, std::vector< Identifier > &vect) const
Definition: CscIdHelper.cxx:343
CscIdHelper::m_CHAMBERLAYER_INDEX
size_type m_CHAMBERLAYER_INDEX
Definition: CscIdHelper.h:175
CscIdHelper::StripMax
@ StripMax
Definition: CscIdHelper.h:215
CscIdHelper::measuresPhiMax
static int measuresPhiMax()
Definition: CscIdHelper.cxx:800
CscIdHelper::~CscIdHelper
virtual ~CscIdHelper()=default
MuonIdHelper::stationName
int stationName(const Identifier &id) const
Definition: MuonIdHelper.cxx:804
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
CscIdHelper::measuresPhiMin
static int measuresPhiMin()
Definition: CscIdHelper.cxx:798
CscIdHelper::chamberLayerMin
static int chamberLayerMin()
Definition: CscIdHelper.cxx:790
CscIdHelper::m_stationShift
unsigned int m_stationShift
Minimal station index found.
Definition: CscIdHelper.h:171
CscIdHelper::channel
int channel(const Identifier &id) const override
Definition: CscIdHelper.cxx:778
CscIdHelper::MeasuresPhiMin
@ MeasuresPhiMin
Definition: CscIdHelper.h:212
CscIdHelper::stationEtaMax
static int stationEtaMax()
Definition: CscIdHelper.cxx:784
CSC_ID
CscIdHelper CSC_ID
Definition: CscIdHelper.h:226
AtlasDetectorID::size_type
Identifier::size_type size_type
Definition: AtlasDetectorID.h:384
CscIdHelper::wireLayer
int wireLayer(const Identifier &id) const
Definition: CscIdHelper.cxx:772
CscIdHelper::strip_hash_offsets
int strip_hash_offsets()
Definition: CscIdHelper.cxx:655
CscIdHelper::s_modHashDim
static constexpr unsigned int s_modHashDim
Definition: CscIdHelper.h:162
CscIdHelper::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: CscIdHelper.cxx:585
IdDictMgr
Definition: IdDictDefs.h:32
CscIdHelper::m_module_hashes
std::array< unsigned int, s_modHashDim > m_module_hashes
Definition: CscIdHelper.h:165
MuonIdHelper
Definition: MuonIdHelper.h:80
CscIdHelper::parentID
Identifier parentID(const Identifier &id) const
get parent id from channel id
Definition: CscIdHelper.cxx:758
CscIdHelper::StationEtaMax
@ StationEtaMax
Definition: CscIdHelper.h:205
CscIdHelper::stationEtaMin
static int stationEtaMin()
Access to min and max of level ranges.
Definition: CscIdHelper.cxx:782
CscIdHelper::m_str_impl
IdDictFieldImplementation m_str_impl
Definition: CscIdHelper.h:182
CscIdHelper::validChannel
bool validChannel(const Identifier &id, int stationName, int stationEta, int stationPhi, int chamberLayer, int wireLayer, int measuresPhi, int strip) const
Definition: CscIdHelper.cxx:629
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
CscIdHelper::get_module_hash
int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: CscIdHelper.cxx:328
CscIdHelper::wireLayerMax
static int wireLayerMax()
Definition: CscIdHelper.cxx:796
CscIdHelper::m_stripMaxPhi
unsigned int m_stripMaxPhi
Definition: CscIdHelper.h:219
CscIdHelper::ChamberLayerIndex
@ ChamberLayerIndex
Definition: CscIdHelper.h:199
CscIdHelper::gasGap
int gasGap(const Identifier &id) const override
get the hashes
Definition: CscIdHelper.cxx:816
CscIdHelper::CscIdHelper
CscIdHelper()
Definition: CscIdHelper.cxx:7
CscIdHelper::ChamberLayerMin
@ ChamberLayerMin
Definition: CscIdHelper.h:208
CscIdHelper::StationEtaMin
@ StationEtaMin
Definition: CscIdHelper.h:204
CscIdHelper::WireLayerMin
@ WireLayerMin
Definition: CscIdHelper.h:210
CscIdHelper::m_WIRELAYER_INDEX
size_type m_WIRELAYER_INDEX
Definition: CscIdHelper.h:176
CscIdHelper::m_lay_impl
IdDictFieldImplementation m_lay_impl
Definition: CscIdHelper.h:180
MuonIdHelper::stationPhi
int stationPhi(const Identifier &id) const
Definition: MuonIdHelper.cxx:814
CscIdHelper::stationPhiMin
static int stationPhiMin()
Definition: CscIdHelper.cxx:786
CscIdHelper::init_id_to_hashes
int init_id_to_hashes()
Definition: CscIdHelper.cxx:300
CscIdHelper::sector
int sector(const Identifier &id) const
Definition: CscIdHelper.cxx:814
CscIdHelper::CscRanges
CscRanges
Definition: CscIdHelper.h:203
CscIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int chamberLayer, int wireLayer, int measuresPhi, int strip) const
Definition: CscIdHelper.cxx:706
CscIdHelper::s_detHashDim
static constexpr unsigned int s_detHashDim
Definition: CscIdHelper.h:163
CscIdHelper::m_stripMaxEta
unsigned int m_stripMaxEta
Definition: CscIdHelper.h:220
CscIdHelper::validElement
bool validElement(const Identifier &id) const
Definition: CscIdHelper.cxx:586
MuonIdHelper::stationEta
int stationEta(const Identifier &id) const
Definition: MuonIdHelper.cxx:809
CscIdHelper::m_cla_impl
IdDictFieldImplementation m_cla_impl
Definition: CscIdHelper.h:179
CscIdHelper::m_mea_impl
IdDictFieldImplementation m_mea_impl
Definition: CscIdHelper.h:181
CscIdHelper::s_stDim
static constexpr unsigned int s_stDim
Definition: CscIdHelper.h:154
CscIdHelper::CscIndices
CscIndices
Definition: CscIdHelper.h:199
CscIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Definition: CscIdHelper.cxx:678
CscIdHelper::MeasuresPhiIndex
@ MeasuresPhiIndex
Definition: CscIdHelper.h:199
CscIdHelper::stripMin
static int stripMin()
Definition: CscIdHelper.cxx:802
CscIdHelper::chamberLayerMax
static int chamberLayerMax()
Definition: CscIdHelper.cxx:792
CscIdHelper
Definition: CscIdHelper.h:52
CscIdHelper::strip
int strip(const Identifier &id) const
Definition: CscIdHelper.cxx:776
CscIdHelper::WireLayerMax
@ WireLayerMax
Definition: CscIdHelper.h:211
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
CscIdHelper::s_etaDim
static constexpr unsigned int s_etaDim
Definition: CscIdHelper.h:156
CscIdHelper::s_mlDim
static constexpr unsigned int s_mlDim
2 multi layer
Definition: CscIdHelper.h:160
CscIdHelper::WireLayerIndex
@ WireLayerIndex
Definition: CscIdHelper.h:199
CscIdHelper::detEleHashIdx
unsigned int detEleHashIdx(const Identifier &id) const
Definition: CscIdHelper.cxx:296
CscIdHelper::measuresPhi
bool measuresPhi(const Identifier &id) const override
Definition: CscIdHelper.cxx:774
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdentifierHash
Definition: IdentifierHash.h:38
CscIdHelper::StripMin
@ StripMin
Definition: CscIdHelper.h:214
CscIdHelper::wireLayerMin
static int wireLayerMin()
Definition: CscIdHelper.cxx:794
CscIdHelper::MeasuresPhiMax
@ MeasuresPhiMax
Definition: CscIdHelper.h:213
CscIdHelper::m_hashOffset
int m_hashOffset[2][2]
Definition: CscIdHelper.h:217
CscIdHelper::StationPhiMin
@ StationPhiMin
Definition: CscIdHelper.h:206
CscIdHelper::get_detectorElement_hash
int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: CscIdHelper.cxx:334
CscIdHelper::stationPhiMax
static int stationPhiMax()
Definition: CscIdHelper.cxx:788
CscIdHelper::chamberLayer
int chamberLayer(const Identifier &id) const
Definition: CscIdHelper.cxx:770
CscIdHelper::StripIndex
@ StripIndex
Definition: CscIdHelper.h:199
CscIdHelper::StationPhiMax
@ StationPhiMax
Definition: CscIdHelper.h:207
CscIdHelper::cscTechnology
int cscTechnology() const
Utility methods.
Definition: CscIdHelper.cxx:808
CscIdHelper::m_detectorElement_hashes
std::array< unsigned int, s_detHashDim > m_detectorElement_hashes
Definition: CscIdHelper.h:166