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 // note: default value of hashId is 0xFFFFFFFF (= invalid)
440 assert (hash_id < m_prev_phi_wafer_vec.size());
441 assert (hash_id < m_next_phi_wafer_vec.size());
442 assert (hash_id < m_prev_eta_wafer_vec.size());
443 assert (hash_id < m_next_eta_wafer_vec.size());
444
445 if (pphi) {
446 // Get previous phi hash id
447 ExpandedIdentifier expId = exp_id;
448 expId[m_PHI_MODULE_INDEX] = previous_phi;
450 expId[m_LAYER_INDEX],
451 expId[m_PHI_MODULE_INDEX],
452 expId[m_ETA_MODULE_INDEX]);
453 if (get_hash(id, hash_id, &wcontext)) {
454 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get previous phi hash, exp/compact "
455 << id.getString() << " " << show_to_string(id));
456 return (1);
457 }
458 m_prev_phi_wafer_vec[index] = hash_id;
459 }
460
461 if (nphi) {
462 // Get next phi hash id
463 ExpandedIdentifier expId = exp_id;
464 expId[m_PHI_MODULE_INDEX] = next_phi;
466 expId[m_LAYER_INDEX],
467 expId[m_PHI_MODULE_INDEX],
468 expId[m_ETA_MODULE_INDEX]);
469 if (get_hash(id, hash_id, &wcontext)) {
470 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get next phi hash, exp/compact " <<
471 id.getString() << " " << show_to_string(id));
472 return (1);
473 }
474 m_next_phi_wafer_vec[index] = hash_id;
475 }
476
477 if (peta) {
478 // Get previous eta hash id
479 ExpandedIdentifier expId = exp_id;
480 expId[m_ETA_MODULE_INDEX] = previous_eta;
482 expId[m_LAYER_INDEX],
483 expId[m_PHI_MODULE_INDEX],
484 expId[m_ETA_MODULE_INDEX]);
485 if (get_hash(id, hash_id, &wcontext)) {
486 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get previous eta hash, exp/compact "
487 << id.getString() << " " << show_to_string(id));
488 return (1);
489 }
490 m_prev_eta_wafer_vec[index] = hash_id;
491 }
492
493 if (neta) {
494 // Get next eta hash id
495 ExpandedIdentifier expId = exp_id;
496 expId[m_ETA_MODULE_INDEX] = next_eta;
498 expId[m_LAYER_INDEX],
499 expId[m_PHI_MODULE_INDEX],
500 expId[m_ETA_MODULE_INDEX]);
501 if (get_hash(id, hash_id, &wcontext)) {
502 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get next eta hash, exp/compact "
503 << id.getString() << " " << show_to_string(id));
504 return (1);
505 }
506 m_next_eta_wafer_vec[index] = hash_id;
507 }
508 }
509 }
510 return (0);
511}
512
513
514void HGTD_ID::set_useNewIdentifierScheme(bool switchIntoNewIdentifier)
515{
516 m_useNewIdentifierScheme = switchIntoNewIdentifier;
517}
518
523
524int
526{
527
528 if(!m_dict) {
529 ATH_MSG_FATAL(" HGTD_ID::initLevelsFromDict - dictionary NOT initialized ");
530 return (1);
531 }
532
533 // Find out which identifier field corresponds to each level. Use
534 // names to find each field/level.
535
536 m_INDET_INDEX = 999;
537 m_HGTD_INDEX = 999;
538 m_ENDCAP_INDEX = 999;
539 m_LAYER_INDEX = 999;
540 m_PHI_MODULE_INDEX = 999;
541 m_ETA_MODULE_INDEX = 999;
542 m_PHI_INDEX_INDEX = 999;
543 m_ETA_INDEX_INDEX = 999;
544
545 // Save index to a PIXEL region for unpacking
548 if (m_dict->find_region(id, m_hgtd_region_index)) {
549 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find hgtd region index: id, reg "
550 << (std::string)id << " " << m_hgtd_region_index);
551 return (1);
552 }
553 // Choose the name of the identification scheme based on the dictionary name,
554 // this information is gotten from HGTD_IDDetDescrCnv
555
557 m_endcap_ID = "endcap";
558 m_layer_ID = "layer";
559 m_moduleInLayer_Or_Row = "moduleInLayer";
560 m_moduleInRow = "dummyVariable";
561 m_padInModuleRow = "padInModuleRow";
562 m_padInModuleColumn = "padInModuleColumn";
563 }
564 // Get levels
565 const IdDictField* field = m_dict->find_field("subdet");
566 if (field) {
567 m_INDET_INDEX = field->index();
568 }
569 else {
570 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'subdet' field ");
571 return (1);
572 }
573
574 field = m_dict->find_field("part");
575 if (field) {
576 m_HGTD_INDEX = field->index();
577 }
578 else {
579 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'part' field ");
580 return (1);
581 }
582
583 field = m_dict->find_field(m_endcap_ID);
584 if (field) {
585 m_ENDCAP_INDEX = field->index();
586 }
587 else {
588 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'endcap' field " );
589 }
590 field = m_dict->find_field(m_layer_ID);
591 if (field) {
592 m_LAYER_INDEX = field->index();
593 }
594 else {
595 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'layer' field " );
596 }
597 field = m_dict->find_field(m_moduleInLayer_Or_Row);
598 if (field) {
599 m_PHI_MODULE_INDEX = field->index();
600 }
601 else {
602 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'moduleInLayer' field " );
603 return (1);
604 }
605 field = m_dict->find_field(m_moduleInRow);
606 if (field) {
607 m_ETA_MODULE_INDEX = field->index();
608 }
609 else {
610 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_eta_module' field " );
611 return (1);
612 }
613 field = m_dict->find_field(m_padInModuleRow);
614 if (field) {
615 m_PHI_INDEX_INDEX = field->index();
616 }
617 else {
618 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_phi_index' field " );
619 return (1);
620 }
621 field = m_dict->find_field(m_padInModuleColumn);
622 if (field) {
623 m_ETA_INDEX_INDEX = field->index();
624 }
625 else {
626 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_eta_index' field " );
627 return (1);
628 }
629 // Set the field implementations
630
631 const IdDictRegion& region = m_dict->region(m_hgtd_region_index);
632
641
642 ATH_MSG_DEBUG("decode index and bit fields for each level:");
643 for (int i{};i != nImplementations; ++i){
644 ATH_MSG_DEBUG( std::left << std::setw(15) << m_implNames[i] << m_impl[i]);
645 }
646 if (msgLvl(MSG::DEBUG)){
647 for (int i{};i != nImplementations; ++i){
648 msg() << formatOutput(m_implNames[i], m_impl[i]);
649 m_impl[i].ored_field().show(msg());
650 }
651 msg() << "HGTD_ID::initLevelsFromDict - found levels \n";
652 msg() << "subdet " << m_INDET_INDEX << "\n";
653 msg() << "part " << m_HGTD_INDEX << "\n";
654 msg() << "endcap " << m_ENDCAP_INDEX << "\n";
655 msg() << "layer " << m_LAYER_INDEX << "\n";
656 msg() << "phi_module " << m_PHI_MODULE_INDEX << "\n";
657 msg() << "eta_module " << m_ETA_MODULE_INDEX << "\n";
658 msg() << "phi_index " << m_PHI_INDEX_INDEX << "\n";
659 msg() << "eta_index " << m_ETA_INDEX_INDEX << "\n";
660 }
661 return 0;
662}
663
666{
667 return m_wafer_hash_max;
668}
669
672{
673 return m_pixel_hash_max;
674}
675
677{
678 return (m_wafer_vec.begin());
679}
680
682{
683 return (m_wafer_vec.end());
684}
685
687{
688 return (m_full_pixel_range.factory_begin());
689}
690
692{
693 return (m_full_pixel_range.factory_end());
694}
695
696void
698 ExpandedIdentifier& exp_id,
699 const IdContext* context) const
700{
701 exp_id.clear();
702 exp_id << indet_field_value()
704 << endcap(id)
705 << layer(id)
706 << phi_module(id)
707 << eta_module(id);
708 if(!context || context->end_index() == m_ETA_INDEX_INDEX) {
709 exp_id << phi_index(id)
710 << eta_index(id);
711 }
712}
713
714// From hash get Identifier
715int
717 Identifier& id,
718 const IdContext* context) const
719{
720 int result = 1;
721
722 size_t begin = (context) ? context->begin_index(): 0;
723 // cannot get hash if end is 0:
724 size_t end = (context) ? context->end_index() : 0;
725 if (0 == begin) {
726 // No hashes yet for ids with prefixes
727 if (m_ETA_MODULE_INDEX == end) {
728 if (hash_id < (unsigned int)(m_wafer_vec.end() - m_wafer_vec.begin())) {
729 id = m_wafer_vec[hash_id];
730 result = 0;
731 }
732 }
733 else if (m_ETA_INDEX_INDEX == end) {
734 // Do not know how to calculate pixel id from hash yet!!
735 result = 1;
736 }
737 }
738
739 return (result);
740}
741
742int
744 IdentifierHash& hash_id,
745 const IdContext* context) const
746{
747
748 // Get the hash code from either a vec (for wafers) or calculate
749 // it (pixels). For the former, we convert to compact and call
750 // get_hash again. For the latter, we calculate the hash from the
751 // Identifier.
752
753 int result = 1;
754
755 hash_id = 0;
756 size_t begin = (context) ? context->begin_index(): 0;
757 size_t end = (context) ? context->end_index() : 0;
758 if (0 == begin) {
759 // No hashes yet for ids with prefixes
760 if (m_ETA_MODULE_INDEX == end) {
761 hash_id = wafer_hash(id);
762 if (hash_id.is_valid()) result = 0;
763 }
764 else if (context && context->end_index() == m_ETA_INDEX_INDEX) {
765 // Must calculate for pixel hash
766 ExpandedIdentifier new_id;
767 get_expanded_id(id, new_id, context);
768 hash_id = m_full_pixel_range.cardinalityUpTo(new_id);
769 result = 0;
770 }
771 }
772
773 return (result);
774}
775
776void
778{
779 if (m_dict) {
780
781 int nids = 0;
782 IdContext context = wafer_context();
783 const_id_iterator first = m_wafer_vec.begin();
784 const_id_iterator last = m_wafer_vec.end();
785 for (; first != last; ++first, ++nids) {
786 Identifier id = (*first);
787 ExpandedIdentifier expId;
788 get_expanded_id(id, expId, &context);
789 Identifier new_id = wafer_id (expId[m_ENDCAP_INDEX],
790 expId[m_LAYER_INDEX],
791 expId[m_PHI_MODULE_INDEX],
792 expId[m_ETA_MODULE_INDEX]);
793 if (id != new_id) {
794 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old compact id not equal. New/old/expanded ids "
795 << show_to_string(new_id) << " " << show_to_string(id) << " "
796 << (std::string)expId);
797 continue;
798 }
799 }
800
801 nids = 0;
802 context = pixel_context();
805 for (; first_pixel != last_pixel && nids < 1000; ++first_pixel, ++nids) {
806 const ExpandedIdentifier& exp_id = *first_pixel;
807 ExpandedIdentifier new_exp_id;
808
809 Identifier id = wafer_id (exp_id[m_ENDCAP_INDEX],
810 exp_id[m_LAYER_INDEX],
811 exp_id[m_PHI_MODULE_INDEX],
812 exp_id[m_ETA_MODULE_INDEX]);
813
814 get_expanded_id(id, new_exp_id, &context);
815 if (exp_id[0] != new_exp_id[0] ||
816 exp_id[1] != new_exp_id[1] ||
817 exp_id[2] != new_exp_id[2] ||
818 exp_id[3] != new_exp_id[3] ||
819 exp_id[4] != new_exp_id[4] ||
820 exp_id[5] != new_exp_id[5]) {
821 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old expanded ids not equal. New/old/compact ids "
822 << (std::string)new_exp_id
823 << " " << (std::string)exp_id
824 << " " << show_to_string(id));
825 }
826
827 Identifier pid = pixel_id (exp_id[m_ENDCAP_INDEX],
828 exp_id[m_LAYER_INDEX],
829 exp_id[m_PHI_MODULE_INDEX],
830 exp_id[m_ETA_MODULE_INDEX],
831 exp_id[m_PHI_INDEX_INDEX],
832 exp_id[m_ETA_INDEX_INDEX]);
833 Identifier pid1 = pixel_id (endcap(pid),
834 layer(pid),
835 phi_module(pid),
836 eta_module(pid),
837 phi_index(pid),
838 eta_index(pid));
839 if (pid != pid1) {
840 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old pixel ids not equal. New/old ids "
841 << " " << show_to_string(pid1) << " "
842 << show_to_string(pid));
843 }
844 }
845
846 ATH_MSG_DEBUG("HGTD_ID::test_wafer_packing: Successful tested "
847 << nids << " ids. ");
848 }
849 else {
850 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: Unable to test wafer is packing - no dictionary has been defined. ");
851 }
852}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(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:525
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:716
id_vec m_wafer_vec
Definition HGTD_ID.h:259
void set_useNewIdentifierScheme(bool switchIntoNewIdentifier)
Definition HGTD_ID.cxx:514
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:665
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:681
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:676
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:671
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:691
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:777
bool get_useNewIdentifierScheme() const
Definition HGTD_ID.cxx:519
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:697
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:686
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:743
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
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 value_type value() const
constexpr bool is_valid() const
unsigned int value_type
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