ATLAS Offline Software
AtlasDetectorIDHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 #include "IdDict/IdDictDefs.h"
8 #include <iostream>
9 
11  AthMessaging(msgSvc, "AtlasDetectorIDHelper") {
12 }
13 
14 int
16  bool quiet) {
17  if (m_initialized) return(0);
18 
19  m_initialized = true;
20 
21  AtlasDetectorID atlas_id;
23 
24  const IdDictDictionary* dict = dict_mgr.find_dictionary("InnerDetector");
25  if (!dict) {
26  ATH_MSG_WARNING("initialize_from_dictionary - cannot access InnerDetector dictionary");
27  return 1;
28  } else {
29  // Check if this is High Luminosity LHC layout
30  if (dict->m_version == "ITkHGTD" || dict->m_version == "ITkHGTDPLR" || dict->m_version == "P2-RUN4") {
31  m_isHighLuminosityLHC = true;
32  }
33 
34  // Save index to a PIXEL region for unpacking
35  id = atlas_id.pixel_exp();
36  if (dict->find_region(id, m_pixel_region_index)) {
37  ATH_MSG_WARNING("initialize_from_dictionary - unable to find pixel region index: id, reg "
38  << (std::string) id << " " << m_pixel_region_index);
39  }
40 
41  // for High Luminosity LHC layout one cannot get the sct region as below, nor
42  // is there any trt regions
43  if (!m_isHighLuminosityLHC) {
44  // Save index to a SCT region for unpacking
45  id = atlas_id.sct_exp();
46  if (dict->find_region(id, m_sct_region_index)) {
47  ATH_MSG_WARNING("initialize_from_dictionary - unable to find sct region index: id, reg "
48  << (std::string) id << " " << m_sct_region_index);
49  }
50 
51  // Save index to a TRT region for unpacking
52  id = atlas_id.trt_exp();
53  if (dict->find_region(id, m_trt_region_index)) {
54  ATH_MSG_WARNING("initialize_from_dictionary - unable to find trt region index: id, reg "
55  << (std::string) id << " " << m_trt_region_index);
56  }
57  }
58 
59  dict = dict_mgr.find_dictionary("LArCalorimeter");
60  if (!dict) {
61  ATH_MSG_WARNING("initialize_from_dictionary - cannot access LArCalorimeter dictionary");
62  return 1;
63  } else {
64  // Save index to a LAR_EM region for unpacking
65  id = atlas_id.lar_em_exp();
66  if (dict->find_region(id, m_lar_em_region_index)) {
67  ATH_MSG_WARNING("initialize_from_dictionary - unable to find lar_em region index: id, reg "
68  << (std::string) id << " " << m_lar_em_region_index);
69  }
70 
71  // Save index to a LAR_HEC region for unpacking
72  id = atlas_id.lar_hec_exp();
73  if (dict->find_region(id, m_lar_hec_region_index)) {
74  ATH_MSG_WARNING("initialize_from_dictionary - unable to find lar_hec region index: id, reg "
75  << (std::string) id << " " << m_lar_hec_region_index);
76  }
77 
78  // Save index to a LAR_FCAL region for unpacking
79  id = atlas_id.lar_fcal_exp();
80  if (dict->find_region(id, m_lar_fcal_region_index)) {
81  ATH_MSG_WARNING("initialize_from_dictionary - unable to find lar_fcal region index: id, reg "
82  << (std::string) id << " " << m_lar_fcal_region_index);
83  }
84  }
85 
86  // Get Calorimetry dictionary for both LVL1 and Dead material
87  dict = dict_mgr.find_dictionary("Calorimeter");
88  if (!dict) {
89  ATH_MSG_WARNING("initialize_from_dictionary - cannot access Calorimeter dictionary");
90  return 1;
91  } else {
92  // Save index to a LVL1 region for unpacking
93  IdDictRegion* reg = dict->find_region("Lvl1_0");
94  if (reg) {
96  } else {
97  ATH_MSG_WARNING("initialize_from_dictionary - unable to find lvl1 region");
98  }
99 
100  // Save index to a Dead Material region for unpacking
101  reg = dict->find_region("DM_4_1_0_0");
102  if (reg) {
103  m_dm_region_index = reg->m_index;
104  } else {
105  ATH_MSG_WARNING("initialize_from_dictionary - unable to find dead material region");
106  }
107  }
108 
109  dict = dict_mgr.find_dictionary("TileCalorimeter");
110  if (!dict) {
111  ATH_MSG_WARNING("initialize_from_dictionary - cannot access TileCalorimeter dictionary");
112  return 1;
113  } else {
114  // Save index to a TILE region for unpacking
115  id = atlas_id.tile_exp();
116  if (dict->find_region(id, m_tile_region_index)) {
117  ATH_MSG_WARNING("initialize_from_dictionary - unable to find tile region index: id, reg");
118  }
119  }
120 
121  dict = dict_mgr.find_dictionary("MuonSpectrometer");
122  if (!dict) {
123  ATH_MSG_WARNING("initialize_from_dictionary - cannot access MuonSpectrometer dictionary");
124  return 1;
125  } else {
126  m_station_field = dict->find_field("stationName");
127  if (!m_station_field) {
128  ATH_MSG_WARNING("initialize_from_dictionary - cannot access stationName field");
129  } else {
131  }
132  }
133 
134 
135  // Save index to a MDT region for unpacking
136  IdDictGroup* group = dict->find_group("mdt");
137  if (group) {
138  const std::vector<IdDictRegion*>& regions = group->regions();
139  if (regions.size() > 0) {
140  m_mdt_region_index = regions[0]->m_index;
141  }
142  }
143 
144 
145  if (UNDEFINED == m_mdt_region_index) {
146  int size = 0;
147  if (group) {
148  size = group->regions().size();
149  }
150  ATH_MSG_WARNING("initialize_from_dictionary - unable to find mdt region index: group, region size "
151  << group << " " << size);
152  }
153 
154  // Save index to a CSC region for unpacking
155  group = dict->find_group("csc");
156  if (group) {
157  if (group->regions().size() > 0) {
158  m_csc_region_index = group->regions()[0]->m_index;
159  }
160  }
161  if (UNDEFINED == m_csc_region_index) {
162  int size = 0;
163  if (group) {
164  size = group->regions().size();
165  }
166  ATH_MSG_DEBUG("initialize_from_dictionary - unable to find csc region index: group, region size "
167  << group << " " << size);
168  }
169 
170  // Save index to a RPC region for unpacking
171  group = dict->find_group("rpc");
172  if (group) {
173  if (group->regions().size() > 0) {
174  m_rpc_region_index = group->regions()[0]->m_index;
175  }
176  }
177  if (UNDEFINED == m_rpc_region_index) {
178  int size = 0;
179  if (group) {
180  size = group->regions().size();
181  }
182  ATH_MSG_WARNING("initialize_from_dictionary - unable to find rpc region index: group, region size "
183  << group << " " << size);
184  }
185 
186  // Save index to a TGC region for unpacking
187  group = dict->find_group("tgc");
188  if (group) {
189  if (group->regions().size() > 0) {
190  m_tgc_region_index = group->regions()[0]->m_index;
191  }
192  }
193  if (UNDEFINED == m_tgc_region_index) {
194  int size = 0;
195  if (group) {
196  size = group->regions().size();
197  }
198  ATH_MSG_WARNING("initialize_from_dictionary - unable to find tgc region index: group, region size "
199  << group << " " << size);
200  }
201 
202  // Save index to a MM region for unpacking
203  group = dict->find_group("mm");
204  if (group) {
205  if (group->regions().size() > 0) {
206  m_mm_region_index = group->regions()[0]->m_index;
207  }
208  }
209  if (UNDEFINED == m_mm_region_index) {
210  int size = 0;
211  if (group) {
212  size = group->regions().size();
213  }
214  if (!quiet) {
215  ATH_MSG_DEBUG("initialize_from_dictionary - unable to find mm region index: group, region size "
216  << group << " " << size);
217  }
218  }
219 
220  // Save index to a sTGC region for unpacking
221  group = dict->find_group("stgc");
222  if (group) {
223  if (group->regions().size() > 0) {
224  m_stgc_region_index = group->regions()[0]->m_index;
225  }
226  }
228  int size = 0;
229  if (group) {
230  size = group->regions().size();
231  }
232  if (!quiet) {
233  ATH_MSG_DEBUG("initialize_from_dictionary - unable to find stgc region index: group, region size "
234  << group << " " << size);
235  }
236  }
237  }
238 
239 
240  dict = dict_mgr.find_dictionary("ForwardDetectors");
241  if (!dict) {
242  ATH_MSG_WARNING("initialize_from_dictionary - cannot access ForwardDetectors dictionary");
243  return 1;
244  } else {
245  // Save index to a ALFA region for unpacking
246  id = atlas_id.alfa_exp();
247  if (dict->find_region(id, m_alfa_region_index)) {
248  ATH_MSG_WARNING("initialize_from_dictionary - unable to find alfa region index: id, reg "
249  << (std::string) id << " " << m_alfa_region_index);
250  }
251 
252  // Save index to a BCM region for unpacking
253  id = atlas_id.bcm_exp();
254  if (dict->find_region(id, m_bcm_region_index)) {
255  ATH_MSG_WARNING("initialize_from_dictionary - unable to find bcm region index: id, reg "
256  << (std::string) id << " " << m_bcm_region_index);
257  }
258 
259  // Save index to a LUCID region for unpacking
260  id = atlas_id.lucid_exp();
261  if (dict->find_region(id, m_lucid_region_index)) {
262  ATH_MSG_WARNING("initialize_from_dictionary - unable to find lucid region index: id, reg "
263  << (std::string) id << " " << m_lucid_region_index);
264  }
265 
266  // Save index to a ZDC region for unpacking
267  id = atlas_id.zdc_exp();
268  if (dict->find_region(id, m_zdc_region_index)) {
269  ATH_MSG_WARNING("initialize_from_dictionary - unable to find zdc region index: id, reg "
270  << (std::string) id << " " << m_zdc_region_index);
271  }
272  }
273 
274 // std::cout << "AtlasDetectorIDHelper::initialize_from_dictionary " << std::endl;
275 // std::cout << " pixel_region_index " << m_pixel_region_index << std::endl;
276 // std::cout << " sct_region_index " << m_sct_region_index << std::endl;
277 // std::cout << " trt_region_index " << m_trt_region_index << std::endl;
278 // std::cout << " lar_em_region_index " << m_lar_em_region_index << std::endl;
279 // std::cout << " lar_hec_region_index " << m_lar_hec_region_index << std::endl;
280 // std::cout << " lar_fcal_region_index " << m_lar_fcal_region_index << std::endl;
281 // std::cout << " lvl1_region_index " << m_lvl1_region_index << std::endl;
282 // std::cout << " tile_region_index " << m_tile_region_index << std::endl;
283 // std::cout << " mdt_region_index " << m_mdt_region_index << std::endl;
284 // std::cout << " csc_region_index " << m_csc_region_index << std::endl;
285 // std::cout << " rpc_region_index " << m_rpc_region_index << std::endl;
286 // std::cout << " tgc_region_index " << m_tgc_region_index << std::endl;
287 // std::cout << " muon_station_index " << m_muon_station_index << std::endl;
288 
289  return(0);
290 }
AtlasDetectorIDHelper::m_muon_station_index
size_type m_muon_station_index
Definition: AtlasDetectorIDHelper.h:83
IdDictDictionary::find_region
IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictMgr.cxx:368
IdDictField::m_index
size_t m_index
Definition: IdDictDefs.h:331
AtlasDetectorIDHelper::m_dm_region_index
size_type m_dm_region_index
Definition: AtlasDetectorIDHelper.h:75
AtlasDetectorIDHelper::m_trt_region_index
size_type m_trt_region_index
Definition: AtlasDetectorIDHelper.h:70
IdDictGroup
Definition: IdDictDefs.h:341
AtlasDetectorIDHelper::m_bcm_region_index
size_type m_bcm_region_index
Definition: AtlasDetectorIDHelper.h:85
quiet
bool quiet
Definition: TrigGlobEffCorrValidation.cxx:190
AtlasDetectorID::lucid_exp
ExpandedIdentifier lucid_exp(void) const
Definition: AtlasDetectorID.h:597
AtlasDetectorIDHelper::m_pixel_region_index
size_type m_pixel_region_index
Definition: AtlasDetectorIDHelper.h:68
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
AtlasDetectorIDHelper::m_mm_region_index
size_type m_mm_region_index
Definition: AtlasDetectorIDHelper.h:81
AtlasDetectorIDHelper::m_zdc_region_index
size_type m_zdc_region_index
Definition: AtlasDetectorIDHelper.h:87
AtlasDetectorIDHelper::m_isHighLuminosityLHC
bool m_isHighLuminosityLHC
Definition: AtlasDetectorIDHelper.h:67
AtlasDetectorID::tile_exp
ExpandedIdentifier tile_exp(void) const
Definition: AtlasDetectorID.h:499
AtlasDetectorIDHelper::UNDEFINED
@ UNDEFINED
Definition: AtlasDetectorIDHelper.h:20
IdDictDictionary::find_field
IdDictField * find_field(const std::string &name) const
Definition: IdDictMgr.cxx:311
IdDictRegion
Definition: IdDictDefs.h:433
IdDictDictionary::m_version
std::string m_version
Definition: IdDictDefs.h:284
AtlasDetectorIDHelper::m_lar_em_region_index
size_type m_lar_em_region_index
Definition: AtlasDetectorIDHelper.h:71
AtlasDetectorIDHelper::m_csc_region_index
size_type m_csc_region_index
Definition: AtlasDetectorIDHelper.h:78
IdDictDefs.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
IdDictMgr
Definition: IdDictDefs.h:32
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name) const
Definition: IdDictMgr.cxx:385
AtlasDetectorIDHelper::AtlasDetectorIDHelper
AtlasDetectorIDHelper(IMessageSvc *msgSvc)
Definition: AtlasDetectorIDHelper.cxx:10
IdDictMgr::find_dictionary
IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Definition: IdDictMgr.cxx:163
IdDictRegion::m_index
size_t m_index
Definition: IdDictDefs.h:460
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AtlasDetectorIDHelper::m_lvl1_region_index
size_type m_lvl1_region_index
Definition: AtlasDetectorIDHelper.h:74
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
AtlasDetectorID::zdc_exp
ExpandedIdentifier zdc_exp(void) const
Definition: AtlasDetectorID.h:604
AtlasDetectorIDHelper::m_stgc_region_index
size_type m_stgc_region_index
Definition: AtlasDetectorIDHelper.h:82
AtlasDetectorID::alfa_exp
ExpandedIdentifier alfa_exp(void) const
Forward.
Definition: AtlasDetectorID.h:583
AtlasDetectorID::sct_exp
ExpandedIdentifier sct_exp(void) const
Definition: AtlasDetectorID.h:534
AtlasDetectorIDHelper::m_rpc_region_index
size_type m_rpc_region_index
Definition: AtlasDetectorIDHelper.h:79
AtlasDetectorID::lar_hec_exp
ExpandedIdentifier lar_hec_exp(void) const
Definition: AtlasDetectorID.h:569
AtlasDetectorIDHelper::initialize_from_dictionary
int initialize_from_dictionary(const IdDictMgr &dict_mgr, bool quiet)
Initialization from the identifier dictionary.
Definition: AtlasDetectorIDHelper.cxx:15
AtlasDetectorIDHelper::m_lucid_region_index
size_type m_lucid_region_index
Definition: AtlasDetectorIDHelper.h:86
AtlasDetectorIDHelper.h
AtlasDetectorIDHelper::m_initialized
bool m_initialized
Definition: AtlasDetectorIDHelper.h:88
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
IdDictDictionary
Definition: IdDictDefs.h:97
AtlasDetectorIDHelper::m_alfa_region_index
size_type m_alfa_region_index
Definition: AtlasDetectorIDHelper.h:84
AtlasDetectorIDHelper::m_mdt_region_index
size_type m_mdt_region_index
Definition: AtlasDetectorIDHelper.h:77
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AtlasDetectorIDHelper::m_sct_region_index
size_type m_sct_region_index
Definition: AtlasDetectorIDHelper.h:69
AtlasDetectorID::trt_exp
ExpandedIdentifier trt_exp(void) const
Definition: AtlasDetectorID.h:541
AtlasDetectorID::bcm_exp
ExpandedIdentifier bcm_exp(void) const
Definition: AtlasDetectorID.h:590
AtlasDetectorID::lar_fcal_exp
ExpandedIdentifier lar_fcal_exp(void) const
Definition: AtlasDetectorID.h:576
AtlasDetectorIDHelper::m_lar_fcal_region_index
size_type m_lar_fcal_region_index
Definition: AtlasDetectorIDHelper.h:73
AtlasDetectorID::pixel_exp
ExpandedIdentifier pixel_exp(void) const
Inner Detector:
Definition: AtlasDetectorID.h:527
AtlasDetectorIDHelper::m_tile_region_index
size_type m_tile_region_index
Definition: AtlasDetectorIDHelper.h:76
AtlasDetectorIDHelper::m_lar_hec_region_index
size_type m_lar_hec_region_index
Definition: AtlasDetectorIDHelper.h:72
AtlasDetectorIDHelper::m_tgc_region_index
size_type m_tgc_region_index
Definition: AtlasDetectorIDHelper.h:80
AtlasDetectorID::lar_em_exp
ExpandedIdentifier lar_em_exp(void) const
LAr.
Definition: AtlasDetectorID.h:562
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
AtlasDetectorIDHelper::m_station_field
IdDictField * m_station_field
Definition: AtlasDetectorIDHelper.h:89