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