ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_ID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "IdDict/IdDictMgr.h"
13#include <set>
14#include <algorithm>
15
17
18// Constructor
35
36// Destructor
39
40void
42 int layer,
43 int phi_module,
44 int eta_module ) const
45{
46
47 // Check that id is within allowed range
48
49 // Fill expanded id
53 if (!m_full_wafer_range.match(id)) { // module range check is sufficient
54 ATH_MSG_ERROR(" HGTD_ID::wafer_id result is NOT ok. ID, range "
55 << (std::string)id << " " << (std::string)m_full_wafer_range);
56 }
57}
58
59void
61 int layer,
62 int phi_module,
63 int eta_module,
64 int phi_index,
65 int eta_index) const
66{
67
68 // Check that id is within allowed range
69
70 // Fill expanded id
74
75 if (!m_full_pixel_range.match(id)) {
76 ATH_MSG_ERROR(" HGTD_ID::pixel_id result is NOT ok. ID, range "
77 << (std::string)id << " " << (std::string)m_full_pixel_range);
78 }
79}
80
81int
83{
84 // get max from dictionary
86 IdContext wafer_context1 = wafer_context();
87 get_expanded_id(id, expId, &wafer_context1);
88 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
89 const Range& range = m_full_wafer_range[i];
90 if (range.match(expId)) {
91 const Range::field& layer_field = range[m_LAYER_INDEX];
92 if (not layer_field.empty()) {
93 return (layer_field.get_maximum());
94 }
95 }
96 }
97 return (-999); // default
98}
99
100int
102{
103 // get max from dictionary
104 ExpandedIdentifier expId;
105 IdContext wafer_context1 = wafer_context();
106 get_expanded_id(id, expId, &wafer_context1);
107 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
108 const Range& range = m_full_wafer_range[i];
109 if (range.match(expId)) {
110 const Range::field& phi_module_field = range[m_PHI_MODULE_INDEX];
111 if (not phi_module_field.empty()) {
112 return (phi_module_field.get_maximum());
113 }
114 }
115 }
116 return (-999); // default
117}
118
119int
121{
122 // get max from dictionary
123 ExpandedIdentifier expId;
124 IdContext wafer_context1 = wafer_context();
125 get_expanded_id(id, expId, &wafer_context1);
126 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
127 const Range& range = m_full_wafer_range[i];
128 if (range.match(expId)) {
129 const Range::field& eta_module_field = range[m_ETA_MODULE_INDEX];
130 if (not eta_module_field.empty()) {
131 return (eta_module_field.get_maximum());
132 }
133 }
134 }
135 return (-999); // default
136}
137
138int
140{
141 // get min from dictionary
142 ExpandedIdentifier expId;
143 IdContext wafer_context1 = wafer_context();
144 get_expanded_id(id, expId, &wafer_context1);
145 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
146 const Range& range = m_full_wafer_range[i];
147 if (range.match(expId)) {
148 const Range::field& eta_module_field = range[m_ETA_MODULE_INDEX];
149 if (not eta_module_field.empty()) {
150 return (eta_module_field.get_minimum());
151 }
152 }
153 }
154 return (-999); // default
155}
156
157int
159{
160 // get max from dictionary
161 ExpandedIdentifier expId;
162 IdContext wafer_context1 = wafer_context();
163 get_expanded_id(id, expId, &wafer_context1);
164 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
165 const Range& range = m_full_wafer_range[i];
166 if (range.match(expId)) {
167 const Range::field& phi_field = range[m_PHI_INDEX_INDEX];
168 if (not phi_field.empty()) {
169 return (phi_field.get_maximum());
170 }
171 }
172 }
173 return (-999); // default
174}
175
176int
178{
179 // get max from dictionary
180 ExpandedIdentifier expId;
181 IdContext wafer_context1 = wafer_context();
182 get_expanded_id(id, expId, &wafer_context1);
183 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
184 const Range& range = m_full_wafer_range[i];
185 if (range.match(expId)) {
186 const Range::field& eta_field = range[m_ETA_INDEX_INDEX];
187 if (not eta_field.empty()) {
188 return (eta_field.get_maximum());
189 }
190 }
191 }
192 return (-999); // default
193}
194
195bool
197{
198 return (phi_module(id) == phi_module_max(id));
199}
200
201int
203{
204
205 ATH_MSG_INFO("Initialize from dictionary");
206
207 // Check whether this helper should be reinitialized
208 if (!reinitialize(dict_mgr)) {
209 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
210 return (0);
211 }
212 else {
213 ATH_MSG_DEBUG("(Re)initialize");
214 }
215
216 // init base object
217 if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
218
219 // Register version of InnerDetector dictionary
220 if (register_dict_tag(dict_mgr, "InnerDetector")) return(1);
221
222 m_dict = dict_mgr.find_dictionary ("InnerDetector");
223 if(!m_dict) {
224 ATH_MSG_FATAL(" HGTD_ID::initialize_from_dict - cannot access InnerDetector dictionary ");
225 return (1);
226 }
227
228 AtlasDetectorID::setDictVersion(dict_mgr, "InnerDetector");
229
230 // Initialize the field indices
231 if(initLevelsFromDict()) return (1);
232
233 //
234 // Build multirange for the valid set of identifiers
235 //
236
237 // Find value for the field InnerDetector
238 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
239 int inDetField = -1;
240 if (atlasDict->get_label_value("subdet", "InnerDetector", inDetField)) {
241 ATH_MSG_FATAL("Could not get value for label 'InnerDetector' of field 'subdet' in dictionary "
242 << atlasDict->name());
243 return (1);
244 }
245
246 // Find value for the field HGTD
247 int hgtdField = -1;
248 if (m_dict->get_label_value("part", "HGTD", hgtdField)) {
249 ATH_MSG_FATAL("Could not get value for label 'HGTD' of field 'part' in dictionary "
250 << m_dict->name());
251 return (1);
252 }
253 ATH_MSG_DEBUG(" HGTD_ID::initialize_from_dict "
254 << "Found field values: InDet/HGTD "
255 << inDetField << "/"
256 << hgtdField);
257
258 // Set up id for region and range prefix
259 ExpandedIdentifier region_id;
260 region_id.add(inDetField);
261 region_id.add(hgtdField);
262 Range prefix;
263 m_full_wafer_range = m_dict->build_multirange(region_id, prefix, m_moduleInRow);
264 m_full_pixel_range = m_dict->build_multirange(region_id, prefix);
265
266 // Setup the hash tables
267 if(init_hashes()) return (1);
268
269 // Setup hash tables for finding neighbors
270 if(init_neighbors()) return (1);
271
272 ATH_MSG_DEBUG("HGTD_ID::initialize_from_dict");
273 ATH_MSG_DEBUG("Wafer range -> " << (std::string)m_full_wafer_range);
274 ATH_MSG_DEBUG("Pixel range -> " << (std::string)m_full_pixel_range);
275 return 0;
276}
277
278int
280{
281
282 //
283 // create a vector(s) to retrieve the hashes for compact ids. For
284 // the moment, we implement a hash for wafers but NOT for pixels
285 // (too many)
286 //
287
288 // wafer hash
289 m_wafer_hash_max = m_full_wafer_range.cardinality();
290 m_wafer_vec.clear();
292 unsigned int nids = 0;
293 std::set<Identifier> ids;
294 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
295 const Range& range = m_full_wafer_range[i];
296 ConstRangeIterator rit(range);
297 auto first = rit.begin();
298 auto last = rit.end();
299 for (; first != last; ++first) {
300 const ExpandedIdentifier& exp_id = (*first);
301 Identifier id = wafer_id (exp_id[m_ENDCAP_INDEX],
302 exp_id[m_LAYER_INDEX],
303 exp_id[m_PHI_MODULE_INDEX],
304 exp_id[m_ETA_MODULE_INDEX]);
305 if(!(ids.insert(id)).second) {
306 ATH_MSG_FATAL(" HGTD_ID::init_hashes "
307 << " Error: duplicated id for wafer id. nid " << nids
308 << " id " << show_to_string(id)
309 << " exp id " << (std::string)exp_id
310 << " " << (std::string)m_full_wafer_range);
311 }
312 nids++;
313 }
314 }
315 if(ids.size() != m_wafer_hash_max) {
316 ATH_MSG_FATAL(" HGTD_ID::init_hashes "
317 << " Error: set size NOT EQUAL to hash max. size " << ids.size()
318 << " hash max " << m_wafer_hash_max);
319 return (1);
320 }
321
322 nids = 0;
323 std::set<Identifier>::const_iterator first = ids.begin();
324 std::set<Identifier>::const_iterator last = ids.end();
325 for (; first != last && nids < m_wafer_vec.size(); ++first) {
326 m_wafer_vec[nids] = (*first);
327 nids++;
328 }
329
330 // pixel hash - we do not keep a vec for the pixels - too large
331 // TODO: is it worthwhile/possible though for HGTD?
332 m_pixel_hash_max = m_full_pixel_range.cardinality();
333
334 return 0;
335
336}
337
338int
340{
341 unsigned short index = id;
342 if (index < m_prev_phi_wafer_vec.size()) {
343 if (m_prev_phi_wafer_vec[index] == NOT_VALID_HASH) return (1);
345 return (0);
346 }
347 return (1);
348}
349
350int
352{
353 unsigned short index = id;
354 if (index < m_next_phi_wafer_vec.size()) {
355 if (m_next_phi_wafer_vec[index] == NOT_VALID_HASH) return (1);
357 return (0);
358 }
359 return (1);
360}
361
362int
364{
365 unsigned short index = id;
366 if (index < m_prev_eta_wafer_vec.size()) {
367 if (m_prev_eta_wafer_vec[index] == NOT_VALID_HASH) return (1);
369 return (0);
370 }
371 return (1);
372}
373
374int
376{
377 unsigned short index = id;
378 if (index < m_next_eta_wafer_vec.size()) {
379 if (m_next_eta_wafer_vec[index] == NOT_VALID_HASH) return (1);
381 return (0);
382 }
383 return (1);
384}
385
386int
388{
389 //
390 // create a vector(s) to retrieve the hashes for compact ids for
391 // wafer neighbors.
392 //
393
394 ATH_MSG_DEBUG("HGTD_ID::init_neighbors");
395
396 m_prev_phi_wafer_vec.clear();
397 m_next_phi_wafer_vec.clear();
398 m_prev_eta_wafer_vec.clear();
399 m_next_eta_wafer_vec.clear();
404
405 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
406 const Range& range = m_full_wafer_range[i];
407 const Range::field& phi_field = range[m_PHI_MODULE_INDEX];
408 const Range::field& eta_field = range[m_ETA_MODULE_INDEX];
409 ConstRangeIterator rit(range);
410 auto first = rit.begin();
411 auto last = rit.end();
412 for (; first != last; ++first) {
413 const ExpandedIdentifier& exp_id = (*first);
418 bool pphi = phi_field.get_previous(exp_id[m_PHI_MODULE_INDEX], previous_phi);
419 bool nphi = phi_field.get_next (exp_id[m_PHI_MODULE_INDEX], next_phi);
420 bool peta = eta_field.get_previous(exp_id[m_ETA_MODULE_INDEX], previous_eta);
421 bool neta = eta_field.get_next (exp_id[m_ETA_MODULE_INDEX], next_eta);
422
423 IdContext wcontext = wafer_context();
424
425 // First get primary hash id
426 IdentifierHash hash_id;
427 Identifier id = wafer_id (exp_id[m_ENDCAP_INDEX],
428 exp_id[m_LAYER_INDEX],
429 exp_id[m_PHI_MODULE_INDEX],
430 exp_id[m_ETA_MODULE_INDEX]);
431 if (get_hash(id, hash_id, &wcontext)) {
432 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get hash, exp/compact "
433 << id.getString() << " " << show_to_string(id));
434 return (1);
435 }
436
437 // index for the subsequent arrays
438 unsigned short index = hash_id;
439 assert (hash_id < m_prev_phi_wafer_vec.size());
440 assert (hash_id < m_next_phi_wafer_vec.size());
441 assert (hash_id < m_prev_eta_wafer_vec.size());
442 assert (hash_id < m_next_eta_wafer_vec.size());
443
444 if (pphi) {
445 // Get previous phi hash id
446 ExpandedIdentifier expId = exp_id;
447 expId[m_PHI_MODULE_INDEX] = previous_phi;
449 expId[m_LAYER_INDEX],
450 expId[m_PHI_MODULE_INDEX],
451 expId[m_ETA_MODULE_INDEX]);
452 if (get_hash(id, hash_id, &wcontext)) {
453 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get previous phi hash, exp/compact "
454 << id.getString() << " " << show_to_string(id));
455 return (1);
456 }
457 m_prev_phi_wafer_vec[index] = hash_id;
458 }
459
460 if (nphi) {
461 // Get next phi hash id
462 ExpandedIdentifier expId = exp_id;
463 expId[m_PHI_MODULE_INDEX] = next_phi;
465 expId[m_LAYER_INDEX],
466 expId[m_PHI_MODULE_INDEX],
467 expId[m_ETA_MODULE_INDEX]);
468 if (get_hash(id, hash_id, &wcontext)) {
469 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get next phi hash, exp/compact " <<
470 id.getString() << " " << show_to_string(id));
471 return (1);
472 }
473 m_next_phi_wafer_vec[index] = hash_id;
474 }
475
476 if (peta) {
477 // Get previous eta hash id
478 ExpandedIdentifier expId = exp_id;
479 expId[m_ETA_MODULE_INDEX] = previous_eta;
481 expId[m_LAYER_INDEX],
482 expId[m_PHI_MODULE_INDEX],
483 expId[m_ETA_MODULE_INDEX]);
484 if (get_hash(id, hash_id, &wcontext)) {
485 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get previous eta hash, exp/compact "
486 << id.getString() << " " << show_to_string(id));
487 return (1);
488 }
489 m_prev_eta_wafer_vec[index] = hash_id;
490 }
491
492 if (neta) {
493 // Get next eta hash id
494 ExpandedIdentifier expId = exp_id;
495 expId[m_ETA_MODULE_INDEX] = next_eta;
497 expId[m_LAYER_INDEX],
498 expId[m_PHI_MODULE_INDEX],
499 expId[m_ETA_MODULE_INDEX]);
500 if (get_hash(id, hash_id, &wcontext)) {
501 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get next eta hash, exp/compact "
502 << id.getString() << " " << show_to_string(id));
503 return (1);
504 }
505 m_next_eta_wafer_vec[index] = hash_id;
506 }
507 }
508 }
509 return (0);
510}
511
512
513void HGTD_ID::set_useNewIdentifierScheme(bool switchIntoNewIdentifier)
514{
515 m_useNewIdentifierScheme = switchIntoNewIdentifier;
516}
517
522
523int
525{
526
527 if(!m_dict) {
528 ATH_MSG_FATAL(" HGTD_ID::initLevelsFromDict - dictionary NOT initialized ");
529 return (1);
530 }
531
532 // Find out which identifier field corresponds to each level. Use
533 // names to find each field/level.
534
535 m_INDET_INDEX = 999;
536 m_HGTD_INDEX = 999;
537 m_ENDCAP_INDEX = 999;
538 m_LAYER_INDEX = 999;
539 m_PHI_MODULE_INDEX = 999;
540 m_ETA_MODULE_INDEX = 999;
541 m_PHI_INDEX_INDEX = 999;
542 m_ETA_INDEX_INDEX = 999;
543
544 // Save index to a PIXEL region for unpacking
547 if (m_dict->find_region(id, m_hgtd_region_index)) {
548 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find hgtd region index: id, reg "
549 << (std::string)id << " " << m_hgtd_region_index);
550 return (1);
551 }
552 // Choose the name of the identification scheme based on the dictionary name,
553 // this information is gotten from HGTD_IDDetDescrCnv
554
556 m_endcap_ID = "endcap";
557 m_layer_ID = "layer";
558 m_moduleInLayer_Or_Row = "moduleInLayer";
559 m_moduleInRow = "dummyVariable";
560 m_padInModuleRow = "padInModuleRow";
561 m_padInModuleColumn = "padInModuleColumn";
562 }
563 // Get levels
564 const IdDictField* field = m_dict->find_field("subdet");
565 if (field) {
566 m_INDET_INDEX = field->index();
567 }
568 else {
569 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'subdet' field ");
570 return (1);
571 }
572
573 field = m_dict->find_field("part");
574 if (field) {
575 m_HGTD_INDEX = field->index();
576 }
577 else {
578 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'part' field ");
579 return (1);
580 }
581
582 field = m_dict->find_field(m_endcap_ID);
583 if (field) {
584 m_ENDCAP_INDEX = field->index();
585 }
586 else {
587 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'endcap' field " );
588 }
589 field = m_dict->find_field(m_layer_ID);
590 if (field) {
591 m_LAYER_INDEX = field->index();
592 }
593 else {
594 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'layer' field " );
595 }
596 field = m_dict->find_field(m_moduleInLayer_Or_Row);
597 if (field) {
598 m_PHI_MODULE_INDEX = field->index();
599 }
600 else {
601 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'moduleInLayer' field " );
602 return (1);
603 }
604 field = m_dict->find_field(m_moduleInRow);
605 if (field) {
606 m_ETA_MODULE_INDEX = field->index();
607 }
608 else {
609 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_eta_module' field " );
610 return (1);
611 }
612 field = m_dict->find_field(m_padInModuleRow);
613 if (field) {
614 m_PHI_INDEX_INDEX = field->index();
615 }
616 else {
617 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_phi_index' field " );
618 return (1);
619 }
620 field = m_dict->find_field(m_padInModuleColumn);
621 if (field) {
622 m_ETA_INDEX_INDEX = field->index();
623 }
624 else {
625 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_eta_index' field " );
626 return (1);
627 }
628 // Set the field implementations
629
630 const IdDictRegion& region = m_dict->region(m_hgtd_region_index);
631
640
641 ATH_MSG_DEBUG("decode index and bit fields for each level:");
642 for (int i{};i != nImplementations; ++i){
643 ATH_MSG_DEBUG( std::left << std::setw(15) << m_implNames[i] << m_impl[i]);
644 }
645 if (msgLvl(MSG::DEBUG)){
646 for (int i{};i != nImplementations; ++i){
647 msg() << formatOutput(m_implNames[i], m_impl[i]);
648 m_impl[i].ored_field().show(msg());
649 }
650 msg() << "HGTD_ID::initLevelsFromDict - found levels \n";
651 msg() << "subdet " << m_INDET_INDEX << "\n";
652 msg() << "part " << m_HGTD_INDEX << "\n";
653 msg() << "endcap " << m_ENDCAP_INDEX << "\n";
654 msg() << "layer " << m_LAYER_INDEX << "\n";
655 msg() << "phi_module " << m_PHI_MODULE_INDEX << "\n";
656 msg() << "eta_module " << m_ETA_MODULE_INDEX << "\n";
657 msg() << "phi_index " << m_PHI_INDEX_INDEX << "\n";
658 msg() << "eta_index " << m_ETA_INDEX_INDEX << "\n";
659 }
660 return 0;
661}
662
665{
666 return m_wafer_hash_max;
667}
668
671{
672 return m_pixel_hash_max;
673}
674
676{
677 return (m_wafer_vec.begin());
678}
679
681{
682 return (m_wafer_vec.end());
683}
684
686{
687 return (m_full_pixel_range.factory_begin());
688}
689
691{
692 return (m_full_pixel_range.factory_end());
693}
694
695void
697 ExpandedIdentifier& exp_id,
698 const IdContext* context) const
699{
700 exp_id.clear();
701 exp_id << indet_field_value()
703 << endcap(id)
704 << layer(id)
705 << phi_module(id)
706 << eta_module(id);
707 if(!context || context->end_index() == m_ETA_INDEX_INDEX) {
708 exp_id << phi_index(id)
709 << eta_index(id);
710 }
711}
712
713// From hash get Identifier
714int
716 Identifier& id,
717 const IdContext* context) const
718{
719 int result = 1;
720
721 size_t begin = (context) ? context->begin_index(): 0;
722 // cannot get hash if end is 0:
723 size_t end = (context) ? context->end_index() : 0;
724 if (0 == begin) {
725 // No hashes yet for ids with prefixes
726 if (m_ETA_MODULE_INDEX == end) {
727 if (hash_id < (unsigned int)(m_wafer_vec.end() - m_wafer_vec.begin())) {
728 id = m_wafer_vec[hash_id];
729 result = 0;
730 }
731 }
732 else if (m_ETA_INDEX_INDEX == end) {
733 // Do not know how to calculate pixel id from hash yet!!
734 result = 1;
735 }
736 }
737
738 return (result);
739}
740
741int
743 IdentifierHash& hash_id,
744 const IdContext* context) const
745{
746
747 // Get the hash code from either a vec (for wafers) or calculate
748 // it (pixels). For the former, we convert to compact and call
749 // get_hash again. For the latter, we calculate the hash from the
750 // Identifier.
751
752 int result = 1;
753
754 hash_id = 0;
755 size_t begin = (context) ? context->begin_index(): 0;
756 size_t end = (context) ? context->end_index() : 0;
757 if (0 == begin) {
758 // No hashes yet for ids with prefixes
759 if (m_ETA_MODULE_INDEX == end) {
760 hash_id = wafer_hash(id);
761 if (hash_id.is_valid()) result = 0;
762 }
763 else if (context && context->end_index() == m_ETA_INDEX_INDEX) {
764 // Must calculate for pixel hash
765 ExpandedIdentifier new_id;
766 get_expanded_id(id, new_id, context);
767 hash_id = m_full_pixel_range.cardinalityUpTo(new_id);
768 result = 0;
769 }
770 }
771
772 return (result);
773}
774
775void
777{
778 if (m_dict) {
779
780 int nids = 0;
781 IdContext context = wafer_context();
782 const_id_iterator first = m_wafer_vec.begin();
783 const_id_iterator last = m_wafer_vec.end();
784 for (; first != last; ++first, ++nids) {
785 Identifier id = (*first);
786 ExpandedIdentifier expId;
787 get_expanded_id(id, expId, &context);
788 Identifier new_id = wafer_id (expId[m_ENDCAP_INDEX],
789 expId[m_LAYER_INDEX],
790 expId[m_PHI_MODULE_INDEX],
791 expId[m_ETA_MODULE_INDEX]);
792 if (id != new_id) {
793 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old compact id not equal. New/old/expanded ids "
794 << show_to_string(new_id) << " " << show_to_string(id) << " "
795 << (std::string)expId);
796 continue;
797 }
798 }
799
800 nids = 0;
801 context = pixel_context();
804 for (; first_pixel != last_pixel && nids < 1000; ++first_pixel, ++nids) {
805 const ExpandedIdentifier& exp_id = *first_pixel;
806 ExpandedIdentifier new_exp_id;
807
808 Identifier id = wafer_id (exp_id[m_ENDCAP_INDEX],
809 exp_id[m_LAYER_INDEX],
810 exp_id[m_PHI_MODULE_INDEX],
811 exp_id[m_ETA_MODULE_INDEX]);
812
813 get_expanded_id(id, new_exp_id, &context);
814 if (exp_id[0] != new_exp_id[0] ||
815 exp_id[1] != new_exp_id[1] ||
816 exp_id[2] != new_exp_id[2] ||
817 exp_id[3] != new_exp_id[3] ||
818 exp_id[4] != new_exp_id[4] ||
819 exp_id[5] != new_exp_id[5]) {
820 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old expanded ids not equal. New/old/compact ids "
821 << (std::string)new_exp_id
822 << " " << (std::string)exp_id
823 << " " << show_to_string(id));
824 }
825
826 Identifier pid = pixel_id (exp_id[m_ENDCAP_INDEX],
827 exp_id[m_LAYER_INDEX],
828 exp_id[m_PHI_MODULE_INDEX],
829 exp_id[m_ETA_MODULE_INDEX],
830 exp_id[m_PHI_INDEX_INDEX],
831 exp_id[m_ETA_INDEX_INDEX]);
832 Identifier pid1 = pixel_id (endcap(pid),
833 layer(pid),
834 phi_module(pid),
835 eta_module(pid),
836 phi_index(pid),
837 eta_index(pid));
838 if (pid != pid1) {
839 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old pixel ids not equal. New/old ids "
840 << " " << show_to_string(pid1) << " "
841 << show_to_string(pid));
842 }
843 }
844
845 ATH_MSG_DEBUG("HGTD_ID::test_wafer_packing: Successful tested "
846 << nids << " ids. ");
847 }
848 else {
849 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: Unable to test wafer is packing - no dictionary has been defined. ");
850 }
851}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::string formatOutput(std::string_view title, const IdDictFieldImplementation &idDictFieldImp)
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 register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
int hgtd_field_value() const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
AtlasDetectorID(const std::string &name, const std::string &group)
int indet_field_value() const
Provide efficient access to individual field values, for subclass idhelpers.
ConstRangeIterator end() const
ConstRangeIterator begin() const
void clear()
Erase all fields.
size_type m_HGTD_INDEX
Definition HGTD_ID.h:245
hash_vec m_next_phi_wafer_vec
Definition HGTD_ID.h:262
int init_hashes()
Definition HGTD_ID.cxx:279
int get_next_in_phi(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in phi (return == 0 for neighbor found)
Definition HGTD_ID.cxx:351
int eta_module(const Identifier &id) const
Definition HGTD_ID.h:491
int initLevelsFromDict()
Definition HGTD_ID.cxx:524
size_type m_ETA_MODULE_INDEX
Definition HGTD_ID.h:249
void pixel_id_checks(int endcap, int layer, int phi_module, int eta_module, int phi_index, int eta_index) const
Definition HGTD_ID.cxx:60
std::string m_padInModuleColumn
Definition HGTD_ID.h:213
size_type m_PHI_INDEX_INDEX
Definition HGTD_ID.h:250
@ NOT_VALID_HASH
Definition HGTD_ID.h:217
hash_vec m_prev_eta_wafer_vec
Definition HGTD_ID.h:263
int eta_index(const Identifier &id) const
Definition HGTD_ID.h:505
std::string m_layer_ID
Definition HGTD_ID.h:209
Identifier wafer_id(int endcap, int layer, int phi_module, int eta_module) const
For a single crystal.
Definition HGTD_ID.h:289
void wafer_id_checks(int endcap, int layer, int phi_module, int eta_module) const
Definition HGTD_ID.cxx:41
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const
Create compact id from hash id (return == 0 for OK)
Definition HGTD_ID.cxx:715
id_vec m_wafer_vec
Definition HGTD_ID.h:259
void set_useNewIdentifierScheme(bool switchIntoNewIdentifier)
Definition HGTD_ID.cxx:513
std::array< IdDictFieldImplementation, nImplementations > m_impl
Definition HGTD_ID.h:275
int get_next_in_eta(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in eta (return == 0 for neighbor found)
Definition HGTD_ID.cxx:375
int phi_module_max(const Identifier &id) const
Definition HGTD_ID.cxx:101
size_type m_ENDCAP_INDEX
Definition HGTD_ID.h:246
Identifier pixel_id(int endcap, int layer, int phi_module, int eta_module, int phi_index, int eta_index) const
For an individual pixel.
Definition HGTD_ID.h:333
Identifier::size_type size_type
Definition HGTD_ID.h:52
size_type wafer_hash_max() const
Definition HGTD_ID.cxx:664
int get_prev_in_phi(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in phi (return == 0 for neighbor found)
Definition HGTD_ID.cxx:339
int init_neighbors()
Definition HGTD_ID.cxx:387
MultiRange::const_identifier_factory const_expanded_id_iterator
Definition HGTD_ID.h:54
hash_vec m_next_eta_wafer_vec
Definition HGTD_ID.h:264
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition HGTD_ID.h:406
int phi_index(const Identifier &id) const
Definition HGTD_ID.h:498
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
Initialization from the identifier dictionary.
Definition HGTD_ID.cxx:202
~HGTD_ID()
Definition HGTD_ID.cxx:37
MultiRange m_full_wafer_range
Definition HGTD_ID.h:254
size_type m_PHI_MODULE_INDEX
Definition HGTD_ID.h:248
IdContext pixel_context() const
Definition HGTD_ID.h:460
size_type m_LAYER_INDEX
Definition HGTD_ID.h:247
const_id_iterator wafer_end() const
Definition HGTD_ID.cxx:680
static constexpr std::array< std::string_view, nImplementations > m_implNames
Definition HGTD_ID.h:269
int eta_index_max(const Identifier &id) const
Definition HGTD_ID.cxx:177
IdContext wafer_context() const
Definition HGTD_ID.h:452
int phi_index_max(const Identifier &id) const
Definition HGTD_ID.cxx:158
size_type m_hgtd_region_index
Definition HGTD_ID.h:243
int eta_module_max(const Identifier &id) const
Definition HGTD_ID.cxx:120
const_id_iterator wafer_begin() const
Iterators over full set of ids. Wafer iterator is sorted.
Definition HGTD_ID.cxx:675
size_type m_ETA_INDEX_INDEX
Definition HGTD_ID.h:251
std::string m_moduleInLayer_Or_Row
Definition HGTD_ID.h:210
const IdDictDictionary * m_dict
Definition HGTD_ID.h:253
size_type pixel_hash_max() const
Definition HGTD_ID.cxx:670
int layer_max(const Identifier &id) const
Max/Min values for each field (error returns -999)
Definition HGTD_ID.cxx:82
int get_prev_in_eta(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in eta (return == 0 for neighbor found)
Definition HGTD_ID.cxx:363
const_expanded_id_iterator pixel_end() const
Definition HGTD_ID.cxx:690
size_type m_INDET_INDEX
Definition HGTD_ID.h:244
int layer(const Identifier &id) const
Definition HGTD_ID.h:477
void test_wafer_packing() const
Tests of packing.
Definition HGTD_ID.cxx:776
bool get_useNewIdentifierScheme() const
Definition HGTD_ID.cxx:518
int endcap(const Identifier &id) const
Values of different levels (failure returns 0)
Definition HGTD_ID.h:470
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 HGTD_ID.cxx:696
size_type m_wafer_hash_max
Definition HGTD_ID.h:256
const_expanded_id_iterator pixel_begin() const
For pixel ids, only expanded id iterators are available.
Definition HGTD_ID.cxx:685
std::vector< Identifier >::const_iterator const_id_iterator
Definition HGTD_ID.h:53
MultiRange m_full_pixel_range
Definition HGTD_ID.h:255
bool m_useNewIdentifierScheme
Definition HGTD_ID.h:205
std::string m_padInModuleRow
Definition HGTD_ID.h:212
hash_vec m_prev_phi_wafer_vec
Definition HGTD_ID.h:261
std::string m_moduleInRow
Definition HGTD_ID.h:211
int eta_module_min(const Identifier &id) const
Definition HGTD_ID.cxx:139
bool is_phi_module_max(const Identifier &id) const
To check for when phi wrap around may be needed.
Definition HGTD_ID.cxx:196
std::string m_endcap_ID
Definition HGTD_ID.h:208
@ kEtaIndex
Definition HGTD_ID.h:267
@ nImplementations
Definition HGTD_ID.h:268
@ kPhiMod
Definition HGTD_ID.h:267
@ kEtaMod
Definition HGTD_ID.h:267
@ kHgtd
Definition HGTD_ID.h:266
@ kIndet
Definition HGTD_ID.h:266
@ kLayer
Definition HGTD_ID.h:266
@ kPhiIndex
Definition HGTD_ID.h:267
size_type m_pixel_hash_max
Definition HGTD_ID.h:257
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const
Create hash id from compact id (return == 0 for OK)
Definition HGTD_ID.cxx:742
HGTD_ID()
Definition HGTD_ID.cxx:19
int phi_module(const Identifier &id) const
Definition HGTD_ID.h:484
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.
constexpr bool is_valid() const
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