ATLAS Offline Software
Loading...
Searching...
No Matches
PLR_ID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
5/***************************************************************************
6 Inner Detector identifier package
7 -------------------------------------------
8***************************************************************************/
9
10
13#include "IdDict/IdDictField.h"
14#include "IdDict/IdDictMgr.h"
15#include "IdDict/IdDictRegion.h"
17#include <set>
18#include <algorithm>
19#include <iostream>
20
21
22
23
25 // changes compared to PixelID:
32}
33
34int
36 ATH_MSG_INFO("Initialize from dictionary");
37 // Check whether this helper should be reinitialized
38 if (!reinitialize(dict_mgr)) {
39 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
40 return(0);
41 } else {
42 ATH_MSG_DEBUG("(Re)initialize");
43 }
44
45 // init base object
46 if (PixelID::initialize_from_dictionary(dict_mgr)) return(1);
47
48 // Register version of InnerDetector dictionary
49 if (register_dict_tag(dict_mgr, "InnerDetector")) return(1);
50
51 m_dict = dict_mgr.find_dictionary("InnerDetector");
52 if (!m_dict) {
53 ATH_MSG_FATAL("PLR_ID::initialize_from_dict - cannot access InnerDetector dictionary");
54 return(1);
55 }
56
57 AtlasDetectorID::setDictVersion(dict_mgr, "InnerDetector");
58
59 // Initialize the field indices
60 if (initLevelsFromDict()) return(1);
61
62 // save indet id
63 m_pixel_id = lumi();
64 if (!is_lumi(m_pixel_id)) {
65 ATH_MSG_FATAL("PLR_ID::initialize_from_dict - cannot get plr id dictionary");
66 return(1);
67 }
68
69 //
70 // Set barrel field for testing is_barrel
71 //
72 int barrel_value;
73 m_barrel_field.clear();
74 // barrel
75 if (m_dict->get_label_value("barrel_endcap", "barrel", barrel_value)) {
76 ATH_MSG_FATAL("Could not get value for label 'barrel' of field 'barrel_endcap' in dictionary " << m_dict->name());
77
78 return(1);
79 }
80 m_barrel_field.add_value(barrel_value);
81 m_barrel_field.add_value(barrel_value);
82 ATH_MSG_DEBUG("PLR_ID::initialize_from_dict Set barrel field values: " << (std::string)m_barrel_field);
83
84
85 //DBM
86 //Set dbm field for testing is_dbm
87 //
88 // WARNING:
89 // modified to skip DBM when appropriate dictionary is not present
90 // by adding +999 or -999 to the field
91 //
92
93 int dbm_value{};
94 m_dbm_field.clear();
95 if (m_dict->get_label_value("barrel_endcap", "negative_dbm", dbm_value)) {
96 if (m_dict->version().find("DBM") != std::string::npos) {
97 ATH_MSG_WARNING("Could not get value for label 'negative_dbm' of field 'barrel_endcap' in dictionary " << m_dict->name());
98
99 }
100 //return (1);
101 m_dbm_field.add_value(-999);
102 } else {
103 m_dbm_field.add_value(dbm_value);
104 }
105 if (m_dict->get_label_value("barrel_endcap", "positive_dbm", dbm_value)) {
106 if (m_dict->version().find("DBM") != std::string::npos) {
107 ATH_MSG_WARNING("Could not get value for label 'positive_dbm' of field 'barrel_endcap' in dictionary " << m_dict->name());
108
109 }
110 //return (1);
111 m_dbm_field.add_value(999);
112 } else {
113 m_dbm_field.add_value(dbm_value);
114 }
115 ATH_MSG_DEBUG("PLR_ID::initialize_from_dict Set dbm field values: " << (std::string)m_dbm_field);
116
117 //
118 // Build multirange for the valid set of identifiers
119 //
120
121
122 // Find value for the field InnerDetector
123 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary("ATLAS");
124 int inDetField = -1;
125 if (atlasDict->get_label_value("subdet", "InnerDetector", inDetField)) {
126 ATH_MSG_FATAL("Could not get value for label 'InnerDetector' of field 'subdet' in dictionary " << atlasDict->name());
127
128 return(1);
129 }
130
131 // Find value for the field LuminosityDetectors
132 int lumiField = -1;
133 if (m_dict->get_label_value("part", "LuminosityDetectors", lumiField)) {
134 ATH_MSG_FATAL("Could not get value for label 'LuminosityDetectors' of field 'part' in dictionary " << m_dict->name());
135
136 return(1);
137 }
138
139 // Find value for the field PLR
140 int plrField = -1;
141 if (m_dict->get_label_value("PLR_or_BCM", "PLR", plrField)) {
142 ATH_MSG_FATAL("Could not get value for label 'PLR' of field 'PLR_or_BCM' in dictionary " << m_dict->name());
143
144 return(1);
145 }
146
147 ATH_MSG_DEBUG("PLR_ID::initialize_from_dict Found field values: InDet/LuminosityDetectors/PLR "
148 << inDetField << "/" << lumiField << "/" << plrField);
149
150
151 // Set up id for region and range prefix
152 ExpandedIdentifier region_id;
153 region_id.add(inDetField);
154 region_id.add(lumiField);
155 region_id.add(plrField);
156 Range prefix;
157 m_full_wafer_range = m_dict->build_multirange(region_id, prefix, "eta_module");
158 m_full_pixel_range = m_dict->build_multirange(region_id, prefix);
159
160 // Set the base identifier for PLR
161 m_baseIdentifier = ((Identifier::value_type) 0);
165
166 // Set the base expanded identifier for PLR
168
169 // Setup the hash tables
170 if (init_hashes()) return(1);
171
172 // Setup hash tables for finding neighbors
173 if (init_neighbors()) return(1);
174 ATH_MSG_DEBUG("PLR_ID::initialize_from_dict");
175 ATH_MSG_DEBUG("Wafer range -> " << (std::string)m_full_wafer_range);
176 ATH_MSG_DEBUG("Pixel range -> " << (std::string)m_full_pixel_range);
177
178 return 0;
179}
180
181
182int
184
185 if (!m_dict) {
186 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - dictionary NOT initialized");
187 return(1);
188 }
189
190 // Find out which identifier field corresponds to each level. Use
191 // names to find each field/leve.
192
193 m_INDET_INDEX = 999;
194 m_LUMI_INDEX = 999;
195 m_PLR_INDEX = 999;
196 m_BARREL_EC_INDEX = 999;
197 m_LAYER_DISK_INDEX = 999;
198 m_PHI_MODULE_INDEX = 999;
199 m_ETA_MODULE_INDEX = 999;
200 m_PHI_INDEX_INDEX = 999;
201 m_ETA_INDEX_INDEX = 999;
202
203 // Save index to a PIXEL region for unpacking
206 if (m_dict->find_region(id, m_pixel_region_index)) {
207 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find pixel region index: id, reg " << (std::string)id << " " << m_pixel_region_index);
208
209 return(1);
210 }
211
212 // Get levels
213 const IdDictField* field = m_dict->find_field("subdet");
214 if (field) {
215 m_INDET_INDEX = field->index();
216 } else {
217 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'subdet' field");
218
219 return(1);
220 }
221
222 field = m_dict->find_field("part");
223 if (field) {
224 m_LUMI_INDEX = field->index();
225 } else {
226 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'part' field");
227 return(1);
228 }
229
230 field = m_dict->find_field("PLR_or_BCM");
231 if (field) {
232 m_PLR_INDEX = field->index();
233 } else {
234 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'PLR_or_BCM' field");
235 return(1);
236 }
237
238 field = m_dict->find_field("barrel_endcap");
239 if (field) {
240 m_BARREL_EC_INDEX = 3; //this will clash with another value
241 if (m_BARREL_EC_INDEX != field->index()){
242 ATH_MSG_INFO("Hardcoded value 3, field index " << field->index());
243 }
244 } else {
245 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'barrel_endcap' field");
246 return(1);
247 }
248
249 field = m_dict->find_field("layer");
250 if (field) {
252 } else {
253 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'layer' field");
254 return(1);
255 }
256
257 field = m_dict->find_field("phi_module");
258 if (field) {
260 } else {
261 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'phi_module' field");
262 return(1);
263 }
264 field = m_dict->find_field("eta_module");
265 if (field) {
266
268 } else {
269 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'eta_module' field");
270 return(1);
271 }
272 field = m_dict->find_field("phi_index");
273 if (field) {
274
276 } else {
277 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'phi_index' field");
278 return(1);
279 }
280 field = m_dict->find_field("eta_index");
281 if (field) {
282
284 } else {
285 ATH_MSG_FATAL("PLR_ID::initLevelsFromDict - unable to find 'eta_index' field");
286 return(1);
287 }
288
289 // Set the field implementations: for bec, lay/disk, eta/phi mod
290 // there are two kinds - shifted and non-shifted
291
292 const IdDictRegion& region = m_dict->region(m_pixel_region_index);
293
303
304
305 ATH_MSG_DEBUG("decode index and bit fields for each level:");
306 ATH_MSG_DEBUG("indet " << m_indet_impl.show_to_string());
307 ATH_MSG_DEBUG("lumi " << m_lumi_impl.show_to_string());
308 ATH_MSG_DEBUG("plr " << m_plr_impl.show_to_string());
309 ATH_MSG_DEBUG("bec " << m_bec_impl.show_to_string());
310 ATH_MSG_DEBUG("bec_shift " << m_bec_shift_impl.show_to_string());
311 ATH_MSG_DEBUG("lay_disk " << m_lay_disk_impl.show_to_string());
312 ATH_MSG_DEBUG("lay_disk_shift " << m_lay_disk_shift_impl.show_to_string());
313 ATH_MSG_DEBUG("phi_mod " << m_phi_mod_impl.show_to_string());
314 ATH_MSG_DEBUG("phi_mod_shift " << m_phi_mod_shift_impl.show_to_string());
315 ATH_MSG_DEBUG("eta_mod " << m_eta_mod_impl.show_to_string());
316 ATH_MSG_DEBUG("eta_mod_shift " << m_eta_mod_shift_impl.show_to_string());
317 ATH_MSG_DEBUG("phi_index " << m_phi_index_impl.show_to_string());
318 ATH_MSG_DEBUG("eta_index " << m_eta_index_impl.show_to_string());
319 ATH_MSG_DEBUG("bec_eta_mod " << m_bec_eta_mod_impl.show_to_string());
320
321
322
323
324 std::cout << "indet " << m_indet_impl.decode_index() << " "
325 << (std::string) m_indet_impl.ored_field() << " "
326 << std::hex << m_indet_impl.mask() << " "
327 << m_indet_impl.zeroing_mask() << " "
328 << std::dec << m_indet_impl.shift()
329 << " " << m_indet_impl.bits() << " " << m_indet_impl.bits_offset() << " ";
330 m_indet_impl.ored_field().show();
331 std::cout << "lumi " << m_lumi_impl.decode_index() << " "
332 << (std::string) m_lumi_impl.ored_field() << " "
333 << std::hex << m_lumi_impl.mask() << " "
334 << m_lumi_impl.zeroing_mask() << " "
335 << std::dec << m_lumi_impl.shift()
336 << " " << m_lumi_impl.bits() << " " << m_lumi_impl.bits_offset() << " ";
337 m_lumi_impl.ored_field().show();
338 std::cout << "plr " << m_plr_impl.decode_index() << " "
339 << (std::string) m_plr_impl.ored_field() << " "
340 << std::hex << m_plr_impl.mask() << " "
341 << m_plr_impl.zeroing_mask() << " "
342 << std::dec << m_plr_impl.shift()
343 << " " << m_plr_impl.bits() << " " << m_plr_impl.bits_offset() << " ";
344 m_plr_impl.ored_field().show();
345 std::cout << "bec " << m_bec_impl.decode_index() << " "
346 << (std::string) m_bec_impl.ored_field() << " "
347 << std::hex << m_bec_impl.mask() << " "
348 << m_bec_impl.zeroing_mask() << " "
349 << std::dec << m_bec_impl.shift()
350 << " " << m_bec_impl.bits() << " " << m_bec_impl.bits_offset() << " ";
351 m_bec_impl.ored_field().show();
352 std::cout << "bec_shift " << m_bec_shift_impl.decode_index() << " "
353 << (std::string) m_bec_shift_impl.ored_field() << " "
354 << std::hex << m_bec_shift_impl.mask() << " "
355 << m_bec_shift_impl.zeroing_mask() << " "
356 << std::dec << m_bec_shift_impl.shift()
357 << " " << m_bec_shift_impl.bits() << " " << m_bec_shift_impl.bits_offset() << " ";
358 m_bec_shift_impl.ored_field().show();
359 std::cout << "lay_disk " << m_lay_disk_impl.decode_index() << " "
360 << (std::string) m_lay_disk_impl.ored_field() << " "
361 << std::hex << m_lay_disk_impl.mask() << " "
362 << m_lay_disk_impl.zeroing_mask() << " "
363 << std::dec << m_lay_disk_impl.shift()
364 << " " << m_lay_disk_impl.bits() << " " << m_lay_disk_impl.bits_offset() << " ";
365 m_lay_disk_impl.ored_field().show();
366 std::cout << "lay_disk_shift " << m_lay_disk_shift_impl.decode_index() << " "
367 << (std::string) m_lay_disk_shift_impl.ored_field() << " "
368 << std::hex << m_lay_disk_shift_impl.mask() << " "
369 << m_lay_disk_shift_impl.zeroing_mask() << " "
370 << std::dec << m_lay_disk_shift_impl.shift()
371 << " " << m_lay_disk_shift_impl.bits() << " " << m_lay_disk_shift_impl.bits_offset() << " ";
372 m_lay_disk_shift_impl.ored_field().show();
373 std::cout << "phi_mod " << m_phi_mod_impl.decode_index() << " "
374 << (std::string) m_phi_mod_impl.ored_field() << " "
375 << std::hex << m_phi_mod_impl.mask() << " "
376 << m_phi_mod_impl.zeroing_mask() << " "
377 << std::dec << m_phi_mod_impl.shift()
378 << " " << m_phi_mod_impl.bits() << " " << m_phi_mod_impl.bits_offset() << " ";
379 m_phi_mod_impl.ored_field().show();
380 std::cout << "phi_mod_shift " << m_phi_mod_shift_impl.decode_index() << " "
381 << (std::string) m_phi_mod_shift_impl.ored_field() << " "
382 << std::hex << m_phi_mod_shift_impl.mask() << " "
383 << m_phi_mod_shift_impl.zeroing_mask() << " "
384 << std::dec << m_phi_mod_shift_impl.shift()
385 << " " << m_phi_mod_shift_impl.bits() << " " << m_phi_mod_shift_impl.bits_offset() << " ";
386 m_phi_mod_shift_impl.ored_field().show();
387 std::cout << "eta_mod " << m_eta_mod_impl.decode_index() << " "
388 << (std::string) m_eta_mod_impl.ored_field() << " "
389 << std::hex << m_eta_mod_impl.mask() << " "
390 << m_eta_mod_impl.zeroing_mask() << " "
391 << std::dec << m_eta_mod_impl.shift()
392 << " " << m_eta_mod_impl.bits() << " " << m_eta_mod_impl.bits_offset() << " ";
393 m_eta_mod_impl.ored_field().show();
394 std::cout << "eta_mod_shift " << m_eta_mod_shift_impl.decode_index() << " "
395 << (std::string) m_eta_mod_shift_impl.ored_field() << " "
396 << std::hex << m_eta_mod_shift_impl.mask() << " "
397 << m_eta_mod_shift_impl.zeroing_mask() << " "
398 << std::dec << m_eta_mod_shift_impl.shift()
399 << " " << m_eta_mod_shift_impl.bits() << " " << m_eta_mod_shift_impl.bits_offset() << " ";
400 m_eta_mod_shift_impl.ored_field().show();
401 std::cout << "phi_index " << m_phi_index_impl.decode_index() << " "
402 << (std::string) m_phi_index_impl.ored_field() << " "
403 << std::hex << m_phi_index_impl.mask() << " "
404 << m_phi_index_impl.zeroing_mask() << " "
405 << std::dec << m_phi_index_impl.shift()
406 << " " << m_phi_index_impl.bits() << " " << m_phi_index_impl.bits_offset() << " ";
407 m_phi_index_impl.ored_field().show();
408 std::cout << "eta_index " << m_eta_index_impl.decode_index() << " "
409 << (std::string) m_eta_index_impl.ored_field() << " "
410 << std::hex << m_eta_index_impl.mask() << " "
411 << m_eta_index_impl.zeroing_mask() << " "
412 << std::dec << m_eta_index_impl.shift()
413 << " " << m_eta_index_impl.bits() << " " << m_eta_index_impl.bits_offset() << " ";
414 m_eta_index_impl.ored_field().show();
415 std::cout << "bec_eta_mod " << m_bec_eta_mod_impl.decode_index() << " "
416 << (std::string) m_bec_eta_mod_impl.ored_field() << " "
417 << std::hex << m_bec_eta_mod_impl.mask() << " "
418 << m_bec_eta_mod_impl.zeroing_mask() << " "
419 << std::dec << m_bec_eta_mod_impl.shift()
420 << " " << m_bec_eta_mod_impl.bits() << " " << m_bec_eta_mod_impl.bits_offset() << " ";
421 m_bec_eta_mod_impl.ored_field().show();
422
423
424 std::cout << "PLR_ID::initLevelsFromDict - found levels " << std::endl;
425 std::cout << "subdet " << m_INDET_INDEX << std::endl;
426 std::cout << "part " << m_LUMI_INDEX << std::endl;
427 std::cout << "plr " << m_PLR_INDEX << std::endl;
428 std::cout << "barrel_endcap " << m_BARREL_EC_INDEX << std::endl;
429 std::cout << "layer or disk " << m_LAYER_DISK_INDEX << std::endl;
430 std::cout << "phi_module " << m_PHI_MODULE_INDEX << std::endl;
431 std::cout << "eta_module " << m_ETA_MODULE_INDEX << std::endl;
432 std::cout << "phi_index " << m_PHI_INDEX_INDEX << std::endl;
433 std::cout << "eta_index " << m_ETA_INDEX_INDEX << std::endl;
434
435 return(0);
436}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
int lumi_field_value() const
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
int plr_field_value() const
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
Identifier lumi(void) const
bool is_lumi(Identifier id) const
int indet_field_value() const
Provide efficient access to individual field values, for subclass idhelpers.
int get_label_value(const std::string &field, const std::string &label, int &value) const
const std::string & name() const
Dictionary name.
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
const IdDictFieldImplementation & implementation(size_t i) const
PLR_ID()
Definition PLR_ID.cxx:24
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition PLR_ID.cxx:35
size_type m_LUMI_INDEX
Definition PLR_ID.h:33
size_type m_PLR_INDEX
Definition PLR_ID.h:34
IdDictFieldImplementation m_plr_impl
Definition PLR_ID.h:40
IdDictFieldImplementation m_lumi_impl
Definition PLR_ID.h:39
int initLevelsFromDict()
Definition PLR_ID.cxx:183
IdDictFieldImplementation m_bec_eta_mod_impl
Definition PixelID.h:324
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition PixelID.cxx:185
size_type m_ETA_MODULE_INDEX
Definition PixelID.h:295
Identifier m_pixel_id
Definition PixelID.h:299
IdDictFieldImplementation m_lay_disk_shift_impl
Definition PixelID.h:319
Range::field m_dbm_field
Definition PixelID.h:326
IdDictFieldImplementation m_eta_mod_impl
Definition PixelID.h:317
MultiRange m_full_wafer_range
Definition PixelID.h:301
PixelID()
Definition PixelID.cxx:24
size_type m_LAYER_DISK_INDEX
Definition PixelID.h:293
IdDictFieldImplementation m_lay_disk_impl
Definition PixelID.h:315
const IdDictDictionary * m_dict
Definition PixelID.h:300
size_type m_pixel_region_index
Definition PixelID.h:289
IdDictFieldImplementation m_phi_mod_shift_impl
Definition PixelID.h:320
int init_neighbors()
Definition PixelID.cxx:438
size_type m_BARREL_EC_INDEX
Definition PixelID.h:292
IdDictFieldImplementation m_phi_mod_impl
Definition PixelID.h:316
IdDictFieldImplementation m_phi_index_impl
Definition PixelID.h:322
int init_hashes()
Definition PixelID.cxx:331
ExpandedIdentifier m_baseExpandedIdentifier
Definition PixelID.h:287
Range::field m_barrel_field
Definition PixelID.h:305
size_type m_PHI_INDEX_INDEX
Definition PixelID.h:296
size_type m_INDET_INDEX
Definition PixelID.h:290
size_type m_PHI_MODULE_INDEX
Definition PixelID.h:294
IdDictFieldImplementation m_eta_mod_shift_impl
Definition PixelID.h:321
Identifier m_baseIdentifier
Definition PixelID.h:286
IdDictFieldImplementation m_bec_impl
Definition PixelID.h:314
size_type m_ETA_INDEX_INDEX
Definition PixelID.h:297
IdDictFieldImplementation m_indet_impl
Definition PixelID.h:312
IdDictFieldImplementation m_eta_index_impl
Definition PixelID.h:323
IdDictFieldImplementation m_bec_shift_impl
Definition PixelID.h:318
MultiRange m_full_pixel_range
Definition PixelID.h:302
A Range describes the possible ranges for the field values of an ExpandedIdentifier.