ATLAS Offline Software
Loading...
Searching...
No Matches
PixelID.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"
19#include <set>
20#include <algorithm>
21#include <iostream>
22
23
25 : AtlasDetectorID("PixelID", "pixel")
26{
27 m_barrel_field.add_value(0);
28 m_dbm_field.add_value(0); //DBM
29}
30
31void
33
34 // Fill expanded id
38 if (!m_full_wafer_range.match(id)) { // module range check is sufficient
39 ATH_MSG_ERROR("PixelID::wafer_id result is NOT ok. ID, range "
40 << (std::string) id << " " << (std::string) m_full_wafer_range);
41
42 }
43}
44
45void
47 int phi_index,int eta_index) const {
48 // Check that id is within allowed range
49 // Fill expanded id
53 if (!m_full_pixel_range.match(id)) {
54 ATH_MSG_ERROR("PixelID::pixel_id result is NOT ok. ID, range "
55 << (std::string) id << " " << (std::string) m_full_pixel_range);
56
57 }
58}
59
60int
62 // get max from dictionary
64 IdContext wafer_context1 = wafer_context();
65 get_expanded_id(id, expId, &wafer_context1);
66 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
67 const Range& range = m_full_wafer_range[i];
68 if (range.match(expId)) {
69 const Range::field& layer_disk_field = range[m_LAYER_DISK_INDEX];
70 if (not layer_disk_field.empty()) {
71 return(layer_disk_field.get_maximum());
72 }
73 }
74 }
75 return(-999); // default
76}
77
78int
80 // get max from dictionary
82 IdContext wafer_context1 = wafer_context();
83 get_expanded_id(id, expId, &wafer_context1);
84 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
85 const Range& range = m_full_wafer_range[i];
86 if (range.match(expId)) {
87 const Range::field& eta_field = range[m_ETA_MODULE_INDEX];
88 if (not eta_field.empty()) {
89 return(eta_field.get_maximum());
90 }
91 }
92 }
93 return(-999);
94}
95
96int PixelID::eta_module_min(const Identifier& id) const {
97 // get min from dictionary
99 IdContext wafer_context1 = wafer_context();
100 get_expanded_id(id, expId, &wafer_context1);
101 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
102 const Range& range = m_full_wafer_range[i];
103 if (range.match(expId)) {
104 const Range::field& eta_field = range[m_ETA_MODULE_INDEX];
105 if (not eta_field.empty()) {
106 return(eta_field.get_minimum());
107 }
108 }
109 }
110 return(-999);
111}
112
113bool
115 return(eta_module(id) == eta_module_min(id));
116}
117
118bool
120 return(eta_module(id) == eta_module_max(id));
121}
122
124 // get max from dictionary
125 ExpandedIdentifier expId;
126 IdContext wafer_context1 = wafer_context();
127
128 get_expanded_id(id, expId, &wafer_context1);
129 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
130 const Range& range = m_full_wafer_range[i];
131 if (range.match(expId)) {
132 const Range::field& phi_field = range[m_PHI_MODULE_INDEX];
133 if (not phi_field.empty()) {
134 return(phi_field.get_maximum());
135 }
136 }
137 }
138 // Failed to find the max
139 return(-999);
140}
141
142int
144 // get max from dictionary
145 ExpandedIdentifier expId;
146 IdContext wafer_context1 = wafer_context();
147 get_expanded_id(id, expId, &wafer_context1);
148 for (unsigned int i = 0; i < m_full_pixel_range.size(); ++i) {
149 const Range& range = m_full_pixel_range[i];
150 if (range.match(expId)) {
151 const Range::field& phi_field = range[m_PHI_INDEX_INDEX];
152 if (not phi_field.empty()) {
153 return(phi_field.get_maximum());
154 }
155 }
156 }
157 // Failed to find the max
158 return(-999);
159}
160
161int
163 // get max from dictionary
164 ExpandedIdentifier expId;
165 IdContext wafer_context1 = wafer_context();
166 get_expanded_id(id, expId, &wafer_context1);
167 for (unsigned int i = 0; i < m_full_pixel_range.size(); ++i) {
168 const Range& range = m_full_pixel_range[i];
169 if (range.match(expId)) {
170 const Range::field& eta_field = range[m_ETA_INDEX_INDEX];
171 if (not eta_field.empty()) {
172 return(eta_field.get_maximum());
173 }
174 }
175 }
176 return(-999); // default
177}
178
179bool
181 return(phi_module(id) == phi_module_max(id));
182}
183
184int
186
187 ATH_MSG_INFO("Initialize from dictionary");
188
189 // Check whether this helper should be reinitialized
190 if (!reinitialize(dict_mgr)) {
191 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
192 return(0);
193 } else {
194 ATH_MSG_DEBUG("(Re)initialize");
195 }
196
197 // init base object
198 if (AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return(1);
199
200 // Register version of InnerDetector dictionary
201 if (register_dict_tag(dict_mgr, "InnerDetector")) return(1);
202
203 m_dict = dict_mgr.find_dictionary("InnerDetector");
204 if (!m_dict) {
205 ATH_MSG_FATAL("PixelID::initialize_from_dict - cannot access InnerDetector dictionary");
206
207 return(1);
208 }
209
210 AtlasDetectorID::setDictVersion(dict_mgr, "InnerDetector");
211
212 // Initialize the field indices
213 if (initLevelsFromDict()) return(1);
214
215 // save indet id
216 m_pixel_id = pixel();
217 if (!is_pixel(m_pixel_id)) {
218 ATH_MSG_FATAL(" PixelID::initialize_from_dict - cannot get pixel id dictionary ");
219 return(1);
220 }
221
222 //
223 // Set barrel field for testing is_barrel
224 //
225 int barrel_value;
226 m_barrel_field.clear();
227 // barrel
228 if (m_dict->get_label_value("barrel_endcap", "barrel", barrel_value)) {
229 ATH_MSG_FATAL("Could not get value for label 'barrel' of field 'barrel_endcap' in dictionary "
230 << m_dict->name());
231 return(1);
232 }
233 m_barrel_field.add_value(barrel_value);
234 m_barrel_field.add_value(barrel_value);
235 ATH_MSG_DEBUG(" PixelID::initialize_from_dict "
236 << "Set barrel field values: "
237 << (std::string) m_barrel_field);
238
239 //DBM
240 //Set dbm field for testing is_dbm
241 //
242 // WARNING:
243 // modified to skip DBM when aprorpiate dictionary is not present
244 // by adding +999 or -999 to the field
245 //
246
247 int dbm_value;
248 m_dbm_field.clear();
249 if (m_dict->get_label_value("barrel_endcap", "negative_dbm", dbm_value)) {
250 if (m_dict->version().find("DBM") != std::string::npos) {
251 ATH_MSG_WARNING("Could not get value for label 'negative_dbm' of field 'barrel_endcap' in dictionary "
252 << m_dict->name());
253
254 }
255 //return (1);
256 m_dbm_field.add_value(-999);
257 } else {
258 m_dbm_field.add_value(dbm_value);
259 }
260 if (m_dict->get_label_value("barrel_endcap", "positive_dbm", dbm_value)) {
261 if (m_dict->version().find("DBM") != std::string::npos) {
262 ATH_MSG_WARNING("Could not get value for label 'positive_dbm' of field 'barrel_endcap' in dictionary "
263 << m_dict->name());
264
265 }
266 //return (1);
267 m_dbm_field.add_value(999);
268 } else {
269 m_dbm_field.add_value(dbm_value);
270 }
271 ATH_MSG_DEBUG("PixelID::initialize_from_dict Set dbm field values: " << (std::string)m_dbm_field);
272
273
274
275 //
276 // Build multirange for the valid set of identifiers
277 //
278
279
280 // Find value for the field InnerDetector
281 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary("ATLAS");
282 int inDetField = -1;
283 if (atlasDict->get_label_value("subdet", "InnerDetector", inDetField)) {
284 ATH_MSG_FATAL("Could not get value for label 'InnerDetector' of field 'subdet' in dictionary "
285 << atlasDict->name());
286
287 return(1);
288 }
289
290 // Find value for the field PIXEL
291 int pixelField = -1;
292 if (m_dict->get_label_value("part", "Pixel", pixelField)) {
293 ATH_MSG_FATAL("Could not get value for label 'Pixel' of field 'part' in dictionary "
294 << m_dict->name());
295
296 return(1);
297 }
298 ATH_MSG_DEBUG("PixelID::initialize_from_dict Found field values: InDet/Pixel "
299 << inDetField << "/" << pixelField);
300
301
302 // Set up id for region and range prefix
303 ExpandedIdentifier region_id;
304 region_id.add(inDetField);
305 region_id.add(pixelField);
306 Range prefix;
307 m_full_wafer_range = m_dict->build_multirange(region_id, prefix, "eta_module");
308 m_full_pixel_range = m_dict->build_multirange(region_id, prefix);
309
310 // Set the base identifier for Pixel
311 m_baseIdentifier = ((Identifier::value_type) 0);
314
315 // Set the base expanded identifier for Pixel
317
318 // Setup the hash tables
319 if (init_hashes()) return(1);
320
321 // Setup hash tables for finding neighbors
322 if (init_neighbors()) return(1);
323 ATH_MSG_DEBUG("PixelID::initialize_from_dict");
324 ATH_MSG_DEBUG("Wafer range -> " << (std::string)m_full_wafer_range);
325 ATH_MSG_DEBUG("Pixel range -> " << (std::string)m_full_pixel_range);
326
327 return 0;
328}
329
330int
332 //
333 // create a vector(s) to retrieve the hashes for compact ids. For
334 // the moment, we implement a hash for wafers but NOT for pixels
335 // (too many)
336 //
337
338 // wafer hash
339 m_wafer_hash_max = m_full_wafer_range.cardinality();
340 m_wafer_vec.clear();
342 unsigned int nids = 0;
343 std::set<Identifier> ids;
344 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
345 const Range& range = m_full_wafer_range[i];
346 ConstRangeIterator rit(range);
347 for (const auto & exp_id:rit) {
349 exp_id[m_LAYER_DISK_INDEX],
350 exp_id[m_PHI_MODULE_INDEX],
351 exp_id[m_ETA_MODULE_INDEX]);
352 if (!(ids.insert(id)).second) {
353 ATH_MSG_FATAL("PixelID::init_hashes "
354 << "Error: duplicated id for wafer id. nid " << nids
355 << " id " << show_to_string(id)
356 << " exp id " << (std::string) exp_id
357 << " " << (std::string) m_full_wafer_range);
358
359 return(1);
360 }
361 nids++;
362 }
363 }
364 if (ids.size() != m_wafer_hash_max) {
365 ATH_MSG_FATAL("PixelID::init_hashes "
366 << "Error: set size NOT EQUAL to hash max. size " << ids.size()
367 << " hash max " << m_wafer_hash_max);
368
369 return(1);
370 }
371
372 nids = 0;
373 std::set<Identifier>::const_iterator first = ids.begin();
374 std::set<Identifier>::const_iterator last = ids.end();
375 for (; first != last && nids < m_wafer_vec.size(); ++first) {
376 m_wafer_vec[nids] = (*first);
377 nids++;
378 }
379
380 // pixel hash - we do not keep a vec for the pixels - too large
381 m_pixel_hash_max = m_full_pixel_range.cardinality();
382
383 return(0);
384}
385
386int
388 unsigned short index = id;
389
390 if (index < m_prev_phi_wafer_vec.size()) {
391 if (m_prev_phi_wafer_vec[index] == NOT_VALID_HASH) return(1);
392
394 return(0);
395 }
396 return(1);
397}
398
399int
401 unsigned short index = id;
402
403 if (index < m_next_phi_wafer_vec.size()) {
404 if (m_next_phi_wafer_vec[index] == NOT_VALID_HASH) return(1);
405
407 return(0);
408 }
409 return(1);
410}
411
412int
414 unsigned short index = id;
415
416 if (index < m_prev_eta_wafer_vec.size()) {
417 if (m_prev_eta_wafer_vec[index] == NOT_VALID_HASH) return(1);
418
420 return(0);
421 }
422 return(1);
423}
424
425int
427 unsigned short index = id;
428 if (index < m_next_eta_wafer_vec.size()) {
429 if (m_next_eta_wafer_vec[index] == NOT_VALID_HASH) return(1);
430
432 return(0);
433 }
434 return(1);
435}
436
437int
439 //
440 // create a vector(s) to retrieve the hashes for compact ids for
441 // wafer neighbors.
442 //
443
444 ATH_MSG_DEBUG("PixelID::init_neighbors");
445
446 m_prev_phi_wafer_vec.clear();
447 m_next_phi_wafer_vec.clear();
448 m_prev_eta_wafer_vec.clear();
449 m_next_eta_wafer_vec.clear();
454
455 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
456 const Range& range = m_full_wafer_range[i];
457 const Range::field& phi_field = range[m_PHI_MODULE_INDEX];
458 const Range::field& eta_field = range[m_ETA_MODULE_INDEX];
459
460 // save the lowest value of the module offset
462 eta_field.get_minimum() : m_ETA_MODULE_OFFSET;
463 ConstRangeIterator rit(range);
464 for (const auto & exp_id: rit) {
469 bool pphi = phi_field.get_previous(exp_id[m_PHI_MODULE_INDEX], previous_phi);
470 bool nphi = phi_field.get_next(exp_id[m_PHI_MODULE_INDEX], next_phi);
471 bool peta = eta_field.get_previous(exp_id[m_ETA_MODULE_INDEX], previous_eta);
472 bool neta = eta_field.get_next(exp_id[m_ETA_MODULE_INDEX], next_eta);
473
474 IdContext wcontext = wafer_context();
475
476 // First get primary hash id
477 IdentifierHash hash_id;
479 exp_id[m_LAYER_DISK_INDEX],
480 exp_id[m_PHI_MODULE_INDEX],
481 exp_id[m_ETA_MODULE_INDEX]);
482 if (get_hash(id, hash_id, &wcontext)) {
483 ATH_MSG_FATAL("PixelID::init_neighbors - unable to get hash, exp/compact "
484 << id.getString() << " " << show_to_string(id));
485
486 return(1);
487 }
488
489 // index for the subsequent arrays
490 unsigned short index = hash_id;
491 assert(hash_id < m_prev_phi_wafer_vec.size());
492 assert(hash_id < m_next_phi_wafer_vec.size());
493 assert(hash_id < m_prev_eta_wafer_vec.size());
494 assert(hash_id < m_next_eta_wafer_vec.size());
495
496 if (pphi) {
497 // Get previous phi hash id
498 ExpandedIdentifier expId = exp_id;
499 expId[m_PHI_MODULE_INDEX] = previous_phi;
501 expId[m_LAYER_DISK_INDEX],
502 expId[m_PHI_MODULE_INDEX],
503 expId[m_ETA_MODULE_INDEX]);
504 if (get_hash(id, hash_id, &wcontext)) {
505 ATH_MSG_FATAL("PixelID::init_neighbors - unable to get previous phi hash, exp/compact "
506 << id.getString() << " " << show_to_string(id));
507
508 return(1);
509 }
510 m_prev_phi_wafer_vec[index] = hash_id;
511 }
512
513 if (nphi) {
514 // Get next phi hash id
515 ExpandedIdentifier expId = exp_id;
516 expId[m_PHI_MODULE_INDEX] = next_phi;
518 expId[m_LAYER_DISK_INDEX],
519 expId[m_PHI_MODULE_INDEX],
520 expId[m_ETA_MODULE_INDEX]);
521 if (get_hash(id, hash_id, &wcontext)) {
522 ATH_MSG_FATAL("PixelID::init_neighbors - unable to get next phi hash, exp/compact "
523 << id.getString() << " " << show_to_string(id));
524
525 return(1);
526 }
527 m_next_phi_wafer_vec[index] = hash_id;
528 }
529
530 if (peta) {
531 // Get previous eta hash id
532 ExpandedIdentifier expId = exp_id;
533 expId[m_ETA_MODULE_INDEX] = previous_eta;
535 expId[m_LAYER_DISK_INDEX],
536 expId[m_PHI_MODULE_INDEX],
537 expId[m_ETA_MODULE_INDEX]);
538 if (get_hash(id, hash_id, &wcontext)) {
539 ATH_MSG_FATAL("PixelID::init_neighbors - unable to get previous eta hash, exp/compact "
540 << id.getString() << " " << show_to_string(id));
541
542 return(1);
543 }
544 m_prev_eta_wafer_vec[index] = hash_id;
545 }
546
547 if (neta) {
548 // Get next eta hash id
549 ExpandedIdentifier expId = exp_id;
550 expId[m_ETA_MODULE_INDEX] = next_eta;
552 expId[m_LAYER_DISK_INDEX],
553 expId[m_PHI_MODULE_INDEX],
554 expId[m_ETA_MODULE_INDEX]);
555 if (get_hash(id, hash_id, &wcontext)) {
556 ATH_MSG_FATAL("PixelID::init_neighbors - unable to get next eta hash, exp/compact "
557 << id.getString() << " " << show_to_string(id));
558
559 return(1);
560 }
561 m_next_eta_wafer_vec[index] = hash_id;
562 }
563 }
564 }
565 return(0);
566}
567
568int
570
571 if (!m_dict) {
572 ATH_MSG_FATAL("PixelID::initLevelsFromDict - dictionary NOT initialized");
573 return(1);
574 }
575
576 // Find out which identifier field corresponds to each level. Use
577 // names to find each field/leve.
578
579 m_INDET_INDEX = 999;
580 m_PIXEL_INDEX = 999;
581 m_BARREL_EC_INDEX = 999;
582 m_LAYER_DISK_INDEX = 999;
583 m_PHI_MODULE_INDEX = 999;
584 m_ETA_MODULE_INDEX = 999;
585 m_PHI_INDEX_INDEX = 999;
586 m_ETA_INDEX_INDEX = 999;
587
588 // Save index to a PIXEL region for unpacking
591 if (m_dict->find_region(id, m_pixel_region_index)) {
592 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find pixel region index: id, reg "
593 << (std::string)id << " " << m_pixel_region_index);
594
595 return(1);
596 }
597
598 // Get levels
599 const IdDictField* field = m_dict->find_field("subdet");
600 if (field) {
601 m_INDET_INDEX = field->index();
602 } else {
603 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'subdet' field");
604
605 return(1);
606 }
607
608 field = m_dict->find_field("part");
609 if (field) {
610 m_PIXEL_INDEX = field->index();
611 } else {
612 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'part' field");
613 return(1);
614 }
615
616 field = m_dict->find_field("barrel_endcap");
617 if (field) {
618 m_BARREL_EC_INDEX = field->index();
619 } else {
620 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'barrel_endcap' field");
621 return(1);
622 }
623
624 field = m_dict->find_field("layer");
625 if (field) {
626 m_LAYER_DISK_INDEX = field->index();
627 } else {
628 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'layer' field");
629 return(1);
630 }
631
632 field = m_dict->find_field("phi_module");
633 if (field) {
634 m_PHI_MODULE_INDEX = field->index();
635 } else {
636 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'phi_module' field");
637 return(1);
638 }
639 field = m_dict->find_field("eta_module");
640 if (field) {
641 m_ETA_MODULE_INDEX = field->index();
642 } else {
643 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'eta_module' field");
644 return(1);
645 }
646 field = m_dict->find_field("phi_index");
647 if (field) {
648 m_PHI_INDEX_INDEX = field->index();
649 } else {
650 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'phi_index' field");
651 return(1);
652 }
653 field = m_dict->find_field("eta_index");
654 if (field) {
655 m_ETA_INDEX_INDEX = field->index();
656 } else {
657 ATH_MSG_FATAL("PixelID::initLevelsFromDict - unable to find 'eta_index' field");
658 return(1);
659 }
660
661 // Set the field implementations: for bec, lay/disk, eta/phi mod
662 // there are two kinds - shifted and non-shifted
663
664 const IdDictRegion& region = m_dict->region(m_pixel_region_index);
665
674
675
676 ATH_MSG_DEBUG("decode index and bit fields for each level:");
677 ATH_MSG_DEBUG("indet " << m_indet_impl.show_to_string());
678 ATH_MSG_DEBUG("pixel " << m_pixel_impl.show_to_string());
679 ATH_MSG_DEBUG("bec " << m_bec_impl.show_to_string());
680 ATH_MSG_DEBUG("bec_shift " << m_bec_shift_impl.show_to_string());
681 ATH_MSG_DEBUG("lay_disk " << m_lay_disk_impl.show_to_string());
682 ATH_MSG_DEBUG("lay_disk_shift " << m_lay_disk_shift_impl.show_to_string());
683 ATH_MSG_DEBUG("phi_mod " << m_phi_mod_impl.show_to_string());
684 ATH_MSG_DEBUG("phi_mod_shift " << m_phi_mod_shift_impl.show_to_string());
685 ATH_MSG_DEBUG("eta_mod " << m_eta_mod_impl.show_to_string());
686 ATH_MSG_DEBUG("eta_mod_shift " << m_eta_mod_shift_impl.show_to_string());
687 ATH_MSG_DEBUG("phi_index " << m_phi_index_impl.show_to_string());
688 ATH_MSG_DEBUG("eta_index " << m_eta_index_impl.show_to_string());
689 ATH_MSG_DEBUG("bec_eta_mod " << m_bec_eta_mod_impl.show_to_string());
690
691
692
693
694 std::cout << "indet " << m_indet_impl.decode_index() << " "
695 << (std::string) m_indet_impl.ored_field() << " "
696 << std::hex << m_indet_impl.mask() << " "
697 << m_indet_impl.zeroing_mask() << " "
698 << std::dec << m_indet_impl.shift()
699 << " " << m_indet_impl.bits() << " " << m_indet_impl.bits_offset() << " ";
700 m_indet_impl.ored_field().show();
701 std::cout << "pixel " << m_pixel_impl.decode_index() << " "
702 << (std::string) m_pixel_impl.ored_field() << " "
703 << std::hex << m_pixel_impl.mask() << " "
704 << m_pixel_impl.zeroing_mask() << " "
705 << std::dec << m_pixel_impl.shift()
706 << " " << m_pixel_impl.bits() << " " << m_pixel_impl.bits_offset() << " ";
707 m_pixel_impl.ored_field().show();
708 std::cout << "bec " << m_bec_impl.decode_index() << " "
709 << (std::string) m_bec_impl.ored_field() << " "
710 << std::hex << m_bec_impl.mask() << " "
711 << m_bec_impl.zeroing_mask() << " "
712 << std::dec << m_bec_impl.shift()
713 << " " << m_bec_impl.bits() << " " << m_bec_impl.bits_offset() << " ";
714 m_bec_impl.ored_field().show();
715 std::cout << "bec_shift " << m_bec_shift_impl.decode_index() << " "
716 << (std::string) m_bec_shift_impl.ored_field() << " "
717 << std::hex << m_bec_shift_impl.mask() << " "
718 << m_bec_shift_impl.zeroing_mask() << " "
719 << std::dec << m_bec_shift_impl.shift()
720 << " " << m_bec_shift_impl.bits() << " " << m_bec_shift_impl.bits_offset() << " ";
721 m_bec_shift_impl.ored_field().show();
722 std::cout << "lay_disk " << m_lay_disk_impl.decode_index() << " "
723 << (std::string) m_lay_disk_impl.ored_field() << " "
724 << std::hex << m_lay_disk_impl.mask() << " "
725 << m_lay_disk_impl.zeroing_mask() << " "
726 << std::dec << m_lay_disk_impl.shift()
727 << " " << m_lay_disk_impl.bits() << " " << m_lay_disk_impl.bits_offset() << " ";
728 m_lay_disk_impl.ored_field().show();
729 std::cout << "lay_disk_shift " << m_lay_disk_shift_impl.decode_index() << " "
730 << (std::string) m_lay_disk_shift_impl.ored_field() << " "
731 << std::hex << m_lay_disk_shift_impl.mask() << " "
732 << m_lay_disk_shift_impl.zeroing_mask() << " "
733 << std::dec << m_lay_disk_shift_impl.shift()
734 << " " << m_lay_disk_shift_impl.bits() << " " << m_lay_disk_shift_impl.bits_offset() << " ";
735 m_lay_disk_shift_impl.ored_field().show();
736 std::cout << "phi_mod " << m_phi_mod_impl.decode_index() << " "
737 << (std::string) m_phi_mod_impl.ored_field() << " "
738 << std::hex << m_phi_mod_impl.mask() << " "
739 << m_phi_mod_impl.zeroing_mask() << " "
740 << std::dec << m_phi_mod_impl.shift()
741 << " " << m_phi_mod_impl.bits() << " " << m_phi_mod_impl.bits_offset() << " ";
742 m_phi_mod_impl.ored_field().show();
743 std::cout << "phi_mod_shift " << m_phi_mod_shift_impl.decode_index() << " "
744 << (std::string) m_phi_mod_shift_impl.ored_field() << " "
745 << std::hex << m_phi_mod_shift_impl.mask() << " "
746 << m_phi_mod_shift_impl.zeroing_mask() << " "
747 << std::dec << m_phi_mod_shift_impl.shift()
748 << " " << m_phi_mod_shift_impl.bits() << " " << m_phi_mod_shift_impl.bits_offset() << " ";
749 m_phi_mod_shift_impl.ored_field().show();
750 std::cout << "eta_mod " << m_eta_mod_impl.decode_index() << " "
751 << (std::string) m_eta_mod_impl.ored_field() << " "
752 << std::hex << m_eta_mod_impl.mask() << " "
753 << m_eta_mod_impl.zeroing_mask() << " "
754 << std::dec << m_eta_mod_impl.shift()
755 << " " << m_eta_mod_impl.bits() << " " << m_eta_mod_impl.bits_offset() << " ";
756 m_eta_mod_impl.ored_field().show();
757 std::cout << "eta_mod_shift " << m_eta_mod_shift_impl.decode_index() << " "
758 << (std::string) m_eta_mod_shift_impl.ored_field() << " "
759 << std::hex << m_eta_mod_shift_impl.mask() << " "
760 << m_eta_mod_shift_impl.zeroing_mask() << " "
761 << std::dec << m_eta_mod_shift_impl.shift()
762 << " " << m_eta_mod_shift_impl.bits() << " " << m_eta_mod_shift_impl.bits_offset() << " ";
763 m_eta_mod_shift_impl.ored_field().show();
764 std::cout << "phi_index " << m_phi_index_impl.decode_index() << " "
765 << (std::string) m_phi_index_impl.ored_field() << " "
766 << std::hex << m_phi_index_impl.mask() << " "
767 << m_phi_index_impl.zeroing_mask() << " "
768 << std::dec << m_phi_index_impl.shift()
769 << " " << m_phi_index_impl.bits() << " " << m_phi_index_impl.bits_offset() << " ";
770 m_phi_index_impl.ored_field().show();
771 std::cout << "eta_index " << m_eta_index_impl.decode_index() << " "
772 << (std::string) m_eta_index_impl.ored_field() << " "
773 << std::hex << m_eta_index_impl.mask() << " "
774 << m_eta_index_impl.zeroing_mask() << " "
775 << std::dec << m_eta_index_impl.shift()
776 << " " << m_eta_index_impl.bits() << " " << m_eta_index_impl.bits_offset() << " ";
777 m_eta_index_impl.ored_field().show();
778 std::cout << "bec_eta_mod " << m_bec_eta_mod_impl.decode_index() << " "
779 << (std::string) m_bec_eta_mod_impl.ored_field() << " "
780 << std::hex << m_bec_eta_mod_impl.mask() << " "
781 << m_bec_eta_mod_impl.zeroing_mask() << " "
782 << std::dec << m_bec_eta_mod_impl.shift()
783 << " " << m_bec_eta_mod_impl.bits() << " " << m_bec_eta_mod_impl.bits_offset() << " ";
784 m_bec_eta_mod_impl.ored_field().show();
785
786
787 std::cout << "PixelID::initLevelsFromDict - found levels " << std::endl;
788 std::cout << "subdet " << m_INDET_INDEX << std::endl;
789 std::cout << "part " << m_PIXEL_INDEX << std::endl;
790 std::cout << "barrel_endcap " << m_BARREL_EC_INDEX << std::endl;
791 std::cout << "layer or disk " << m_LAYER_DISK_INDEX << std::endl;
792 std::cout << "phi_module " << m_PHI_MODULE_INDEX << std::endl;
793 std::cout << "eta_module " << m_ETA_MODULE_INDEX << std::endl;
794 std::cout << "phi_index " << m_PHI_INDEX_INDEX << std::endl;
795 std::cout << "eta_index " << m_ETA_INDEX_INDEX << std::endl;
796
797 return(0);
798}
799
802 return m_wafer_hash_max;
803}
804
807 return m_pixel_hash_max;
808}
809
813
817
821
825
826void
828 ExpandedIdentifier& exp_id,
829 const IdContext* context) const {
830 exp_id.clear();
832 exp_id << barrel_ec(id)
833 << layer_disk(id)
834 << phi_module(id)
835 << eta_module(id);
836 if (!context || context->end_index() == m_ETA_INDEX_INDEX) {
837 exp_id << phi_index(id)
838 << eta_index(id);
839 }
840}
841
842// From hash get Identifier
843int
845 Identifier& id,
846 const IdContext* context) const {
847 int result = 1;
848
849 size_t begin = (context) ? context->begin_index() : 0;
850 // cannot get hash if end is 0:
851 size_t end = (context) ? context->end_index() : 0;
852
853 if (0 == begin) {
854 // No hashes yet for ids with prefixes
855 if (m_ETA_MODULE_INDEX == end) {
856 if (hash_id < (unsigned int) (m_wafer_vec.end() - m_wafer_vec.begin())) {
857 id = m_wafer_vec[hash_id];
858 result = 0;
859 }
860 } else if (m_ETA_INDEX_INDEX == end) {
861 // Do not know how to calculate pixel id from hash yet!!
862 std::cout << "Do not know how to calculate pixel id from hash yet!!" << std::endl;
863 }
864 }
865 return(result);
866}
867
868int
870 IdentifierHash& hash_id,
871 const IdContext* context) const {
872 // Get the hash code from either a vec (for wafers) or calculate
873 // it (pixels). For the former, we convert to compact and call
874 // get_hash again. For the latter, we calculate the hash from the
875 // Identifier.
876
877 int result = 1;
878
879 hash_id = 0;
880 size_t begin = (context) ? context->begin_index() : 0;
881 size_t end = (context) ? context->end_index() : 0;
882 if (0 == begin) {
883 // No hashes yet for ids with prefixes
884 if (m_ETA_MODULE_INDEX == end) {
885 hash_id = wafer_hash(id);
886 if (hash_id.is_valid()) result = 0;
887 } else if (context && context->end_index() == m_ETA_INDEX_INDEX) {
888 // Must calculate for pixel hash
889 ExpandedIdentifier new_id;
890 get_expanded_id(id, new_id, context);
891 hash_id = m_full_pixel_range.cardinalityUpTo(new_id);
892 result = 0;
893 }
894 }
895 return(result);
896}
897
898void
900
901 if (m_dict) {
902 int nids = 0;
903 IdContext context = wafer_context();
904 const_id_iterator first = m_wafer_vec.begin();
905 const_id_iterator last = m_wafer_vec.end();
906 for (; first != last; ++first, ++nids) {
907 Identifier id = (*first);
908 ExpandedIdentifier expId;
909 get_expanded_id(id, expId, &context);
910 Identifier new_id = wafer_id(expId[m_BARREL_EC_INDEX],
911 expId[m_LAYER_DISK_INDEX],
912 expId[m_PHI_MODULE_INDEX],
913 expId[m_ETA_MODULE_INDEX]);
914 if (id != new_id) {
915 ATH_MSG_ERROR("PixelID::test_wafer_packing: new and old compact id not equal. New/old/expanded ids "
916 << show_to_string(new_id) << " " << show_to_string(id) << " "
917 << (std::string) expId);
918
919 continue;
920 }
921 }
922
923 nids = 0;
924 context = pixel_context();
927 for (; first_pixel != last_pixel && nids < 1000; ++first_pixel, ++nids) {
928 const ExpandedIdentifier& exp_id = *first_pixel;
929 ExpandedIdentifier new_exp_id;
930
932 exp_id[m_LAYER_DISK_INDEX],
933 exp_id[m_PHI_MODULE_INDEX],
934 exp_id[m_ETA_MODULE_INDEX]);
935
936 get_expanded_id(id, new_exp_id, &context);
937 if (exp_id[0] != new_exp_id[0] ||
938 exp_id[1] != new_exp_id[1] ||
939 exp_id[2] != new_exp_id[2] ||
940 exp_id[3] != new_exp_id[3] ||
941 exp_id[4] != new_exp_id[4] ||
942 exp_id[5] != new_exp_id[5]) {
943 ATH_MSG_ERROR("PixelID::test_wafer_packing: new and old expanded ids not equal. New/old/compact ids "
944 << (std::string) new_exp_id
945 << " " << (std::string) exp_id
946 << " " << show_to_string(id));
947
948 }
949
951 exp_id[m_LAYER_DISK_INDEX],
952 exp_id[m_PHI_MODULE_INDEX],
953 exp_id[m_ETA_MODULE_INDEX],
954 exp_id[m_PHI_INDEX_INDEX],
955 exp_id[m_ETA_INDEX_INDEX]);
956 Identifier pid1 = pixel_id(barrel_ec(pid),
957 layer_disk(pid),
958 phi_module(pid),
959 eta_module(pid),
960 phi_index(pid),
961 eta_index(pid));
962 if (pid != pid1) {
963 ATH_MSG_ERROR("PixelID::test_wafer_packing: new and old pixel ids not equal. New/old ids "
964 << " " << show_to_string(pid1) << " "
965 << show_to_string(pid));
966
967 }
968 }
969
970 ATH_MSG_DEBUG("PixelID::test_wafer_packing: Successfully tested " << nids << " ids.");
971
972 } else {
973 ATH_MSG_ERROR("PixelID::test_wafer_packing: Unable to test wafer is packing - no dictionary has been defined.");
974
975 }
976}
977
978
982
983 return(IdContext(id, 0, m_ETA_MODULE_INDEX));
984}
985
986
989 // For pixel only, the prefix is the first two levels
991}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the Pixel subdetector.
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
int pixel_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.
bool is_pixel(Identifier id) const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Identifier pixel(void) const
AtlasDetectorID(const std::string &name, const std::string &group)
int indet_field_value() const
Provide efficient access to individual field values, for subclass idhelpers.
void clear()
Erase all fields.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
size_type begin_index() const
Definition IdContext.h:45
size_type end_index() const
Definition IdContext.h:46
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
bool get_previous(element_type current, element_type &previous) const
Returns false if previous/next is at end of range, or not possible.
element_type get_minimum() const
Query the values.
bool empty() const
If true, this field does not have any constraints, and may hold any value representable by element_ty...
bool get_next(element_type current, element_type &next) const
element_type get_maximum() const
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
bool is_phi_module_max(const Identifier &id) const
To check for when phi wrap around may be needed.
Definition PixelID.cxx:180
const_id_iterator wafer_begin() const
Iterators over full set of ids. Wafer iterator is sorted.
Definition PixelID.cxx:810
int eta_index(const Identifier &id) const
Definition PixelID.h:645
int layer_disk(const Identifier &id) const
Definition PixelID.h:607
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
int eta_module_max(const Identifier &id) const
Definition PixelID.cxx:79
id_vec m_wafer_vec
Definition PixelID.h:306
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
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition PixelID.h:360
PixelID()
Definition PixelID.cxx:24
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition PixelID.h:600
size_type m_LAYER_DISK_INDEX
Definition PixelID.h:293
IdDictFieldImplementation m_lay_disk_impl
Definition PixelID.h:315
const_expanded_id_iterator pixel_end() const
Definition PixelID.cxx:822
const IdDictDictionary * m_dict
Definition PixelID.h:300
bool is_eta_module_max(const Identifier &id) const
For the barrel.
Definition PixelID.cxx:119
void pixel_id_checks(int barrel_ec, int layer_disk, int phi_module, int eta_module, int phi_index, int eta_index) const
Definition PixelID.cxx:46
Identifier pixel_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int phi_index, int eta_index) const
For an individual pixel.
Definition PixelID.h:428
hash_vec m_prev_phi_wafer_vec
Definition PixelID.h:307
size_type m_pixel_region_index
Definition PixelID.h:289
IdDictFieldImplementation m_phi_mod_shift_impl
Definition PixelID.h:320
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition PixelID.h:383
size_type wafer_hash_max() const
Definition PixelID.cxx:801
int init_neighbors()
Definition PixelID.cxx:438
int eta_module(const Identifier &id) const
Definition PixelID.h:632
size_type m_BARREL_EC_INDEX
Definition PixelID.h:292
int phi_index(const Identifier &id) const
Definition PixelID.h:639
IdDictFieldImplementation m_phi_mod_impl
Definition PixelID.h:316
const_id_iterator wafer_end() const
Definition PixelID.cxx:814
IdDictFieldImplementation m_phi_index_impl
Definition PixelID.h:322
int init_hashes()
Definition PixelID.cxx:331
ExpandedIdentifier m_baseExpandedIdentifier
Definition PixelID.h:287
hash_vec m_next_phi_wafer_vec
Definition PixelID.h:308
int eta_index_max(const Identifier &id) const
Definition PixelID.cxx:162
Identifier::size_type size_type
Definition PixelID.h:71
int layer_disk_max(const Identifier &id) const
Max/Min values for each field (error returns -999)
Definition PixelID.cxx:61
void get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context=0) const
Create expanded id from compact id (return == 0 for OK)
Definition PixelID.cxx:827
size_type m_pixel_hash_max
Definition PixelID.h:304
Range::field m_barrel_field
Definition PixelID.h:305
int get_next_in_eta(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in eta (return == 0 for neighbor found)
Definition PixelID.cxx:426
@ NOT_VALID_HASH
Definition PixelID.h:259
int initLevelsFromDict()
Definition PixelID.cxx:569
size_type m_PHI_INDEX_INDEX
Definition PixelID.h:296
MultiRange::const_identifier_factory const_expanded_id_iterator
Definition PixelID.h:73
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const override final
Create hash id from compact id (return == 0 for OK)
Definition PixelID.cxx:869
IdContext pixel_context() const
Definition PixelID.cxx:988
int phi_index_max(const Identifier &id) const
Definition PixelID.cxx:143
size_type m_PIXEL_INDEX
Definition PixelID.h:291
size_type m_INDET_INDEX
Definition PixelID.h:290
const_expanded_id_iterator pixel_begin() const
For pixel ids, only expanded id iterators are available.
Definition PixelID.cxx:818
size_type m_PHI_MODULE_INDEX
Definition PixelID.h:294
IdDictFieldImplementation m_eta_mod_shift_impl
Definition PixelID.h:321
int get_prev_in_eta(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in eta (return == 0 for neighbor found)
Definition PixelID.cxx:413
void wafer_id_checks(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
Definition PixelID.cxx:32
size_type m_wafer_hash_max
Definition PixelID.h:303
int get_prev_in_phi(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in phi (return == 0 for neighbor found)
Definition PixelID.cxx:387
Identifier m_baseIdentifier
Definition PixelID.h:286
IdContext wafer_context() const
Definition PixelID.cxx:980
std::vector< Identifier >::const_iterator const_id_iterator
Definition PixelID.h:72
int get_next_in_phi(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in phi (return == 0 for neighbor found)
Definition PixelID.cxx:400
IdDictFieldImplementation m_bec_impl
Definition PixelID.h:314
hash_vec m_prev_eta_wafer_vec
Definition PixelID.h:309
void test_wafer_packing() const
Tests of packing.
Definition PixelID.cxx:899
size_type m_ETA_INDEX_INDEX
Definition PixelID.h:297
IdDictFieldImplementation m_pixel_impl
Definition PixelID.h:313
int eta_module_min(const Identifier &id) const
Definition PixelID.cxx:96
IdDictFieldImplementation m_indet_impl
Definition PixelID.h:312
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override final
Create compact id from hash id (return == 0 for OK)
Definition PixelID.cxx:844
IdDictFieldImplementation m_eta_index_impl
Definition PixelID.h:323
IdDictFieldImplementation m_bec_shift_impl
Definition PixelID.h:318
int m_ETA_MODULE_OFFSET
Definition PixelID.h:298
hash_vec m_next_eta_wafer_vec
Definition PixelID.h:310
int phi_module(const Identifier &id) const
Definition PixelID.h:625
bool is_eta_module_min(const Identifier &id) const
For the barrel.
Definition PixelID.cxx:114
MultiRange m_full_pixel_range
Definition PixelID.h:302
size_type pixel_hash_max() const
Definition PixelID.cxx:806
int phi_module_max(const Identifier &id) const
Definition PixelID.cxx:123
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition index.py:1