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