ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasDetectorID.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 Detector Description
7 -----------------------------------------
8***************************************************************************/
9
15#include "IdDict/IdDictField.h"
16#include "IdDict/IdDictLabel.h"
17#include "IdDict/IdDictMgr.h"
18#include "IdDict/IdDictRange.h"
19#include "IdDict/IdDictRegion.h"
20#include <format>
21
22namespace{
23
24 Identifier makeId(const IdDictFieldImplementation & impl0,
25 const IdDictFieldImplementation & impl1, int det, int subdet){
26 Identifier result = impl0.new_pack(det);
27 impl1.pack(subdet, result);
28 return result;
29 }
30}
31
32AtlasDetectorID::AtlasDetectorID(const std::string &name,
33 const std::string& group)
34 : AthMessaging(name),
36{
37}
39
40const std::string& AtlasDetectorID::group() const
41{
42 return m_group;
43}
44
46 return Identifier{};
47}
49 return Identifier{};
50}
52 return Identifier{};
53}
55 return Identifier{};
56}
58 return Identifier{};
59}
61 return Identifier{};
62}
66
68 return m_det_impl.new_pack(lar_field_value());
69}
70
72 return m_det_impl.new_pack(tile_field_value());
73}
74
76 return m_det_impl.new_pack(muon_field_value());
77}
78
80 return m_det_impl.new_pack(calo_field_value());
81}
82
86
90
94
98
102
106
110
114
118
122
126
132
138
140 Identifier & /*id*/,
141 const IdContext * /*context*/) const {
142 return 0;
143}
144
146 IdentifierHash & /*hash_id*/,
147 const IdContext * /*context*/) const {
148 return 0;
149}
150
152 const std::string &dict_name) {
153 // Register version of dictionary dict_name
154
155 // Access dictionary by name
156 const IdDictDictionary *dict = dict_mgr.find_dictionary(dict_name);
157 if (!dict) {
158 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" No dictionary found");
159 return 1;
160
161 }
162 // Add in dict name, file name and version
163 m_dict_names.push_back(dict_name);
164 m_file_names.push_back(dict->file_name());
165 m_dict_tags.push_back(dict->dict_tag());
166 return 0;
167}
168
172 // If no tag has been registered, then reinitialize
173 if (m_dict_tags.empty() || m_dict_names.empty() ){
174 return true;
175 }
176
177 // Loop over dict names and check version tags
178 if (m_dict_names.size() != m_dict_tags.size()) [[unlikely]]{
179 ATH_MSG_ERROR("reinitialize: dict names and tags vectors not the same length ");
180 ATH_MSG_ERROR("names: " << m_dict_names.size() << " tags: " << m_dict_tags.size());
181 }
182 for (unsigned int i = 0; i < m_dict_names.size(); ++i) {
183 // Access dictionary by name
184 const IdDictDictionary *dict = dict_mgr.find_dictionary(m_dict_names[i]);
185 if (!dict)[[unlikely]] {
186 ATH_MSG_ERROR("reinitialize: could not find dict - " << m_dict_names[i]);
187 return false;
188 }
189 if (m_dict_tags[i] != dict->dict_tag()) {
190 // Remove all memory of versions
191 m_dict_names.clear();
192 m_dict_tags.clear();
193 m_file_names.clear();
194 return true;
195 }
196 }
197
198 // Tags match - don't reinitialize
199 return false;
200}
201
203
204 // Register version of ATLAS dictionary
205 if (register_dict_tag(dict_mgr, "ATLAS")){
206 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" - Failed to register dict tag");
207 return 1;
208 }
209 // Initialize helper, needed for init of AtlasDetectorID
210 if (!m_helper) {
211 m_helper = std::make_unique<AtlasDetectorIDHelper>();
212 }
213
214 if (m_helper->initialize_from_dictionary(dict_mgr)){
215 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" - Initialization from dictionary failed.");
216 return 1;
217 }
218 // Initialize level indices and id values from dicts
219 if (initLevelsFromDict(dict_mgr)) {
220 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" - Level initialization from dictionary failed.");
221 return 1;
222 }
224 ATH_MSG_DEBUG("initialize_from_dictionary - OK");
225 return 0;
226}
227
229 return m_dict_version;
230}
232 return id.fields() > 0 && id[0] == m_INDET_ID;
233}
235 return id.fields() > 0 && id[0] == m_LAR_ID;
236}
238 return id.fields() > 0 && id[0] == m_TILE_ID;
239}
241 return id.fields() > 0 && id[0] == m_MUON_ID;
242}
244 return id.fields() > 0 && id[0] == m_CALO_ID;
245}
247 return is_indet(id) && id.fields() > 1 && id[1] == m_PIXEL_ID;
248}
249
251 return is_indet(id) && id.fields() > 1 && id[1] == m_SCT_ID;
252}
254 return is_indet(id) && id.fields() > 1;
255}
257 return is_indet(id) && id.fields() > 1 && id[1] == m_HGTD_ID;
258}
260 return is_indet(id) && id.fields() > 1 && id[1] == m_LUMI_ID;
261}
263 return is_lumi(id) && id.fields() > 2 && id[2] == m_LUMI_PLR_ID;
264}
265
267 return is_lar(id) && id.fields() > 1 && std::abs(id[1]) == m_LAR_EM_ID;
268}
270 return is_lar(id) && id.fields() > 1 && std::abs(id[1]) == m_LAR_HEC_ID;
271}
272
274 return is_lar(id) && id.fields() > 1 && std::abs(id[1]) == m_LAR_FCAL_ID;
275}
276
278 return is_lar_fcal(id) && id.fields() > 3 &&std::abs(id[3]) == 0;
279}
280
282 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_MDT_ID;
283}
284
286 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_CSC_ID;
287}
288
290 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_RPC_ID;
291}
292
294 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_TGC_ID;
295}
296
298 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_STGC_ID;
299}
300
302 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_MM_ID;
303}
304
305// Short print out of any identifier:
306void AtlasDetectorID::show(const Identifier id, const IdContext *context, char sep) const {
307 ATH_MSG_INFO(show_to_string(id, context, sep));
308}
309
310// or provide the printout in string form
311std::string
312AtlasDetectorID::show_to_string(const Identifier id, const IdContext *context, char sep) const {
313 // Do a generic printout of identifier
314
315 std::string result("Unable to decode id");
316 unsigned int max_index = (context) ? context->end_index() : 999;
317
318 if (!id.is_valid()) {
319 return "[INVALID]";
320 }
321
323 return result;
324
325 // Find the dictionary to use:
326 const IdDictDictionary * dict = dictionary(id);
327 ExpandedIdentifier expId{};
328 ExpandedIdentifier prefix{}; // default is null prefix
329 Identifier compact = id;
330
331 if (!dict) {
332 ATH_MSG_WARNING(__func__<<" No detector type associated to id "<<id);
333 return result;
334 }
335 if (dict->unpack(m_group, compact, prefix, max_index, expId)) {
336 return result;
337 }
338
339 bool first = true;
340 result = "";
341 if ('.' == sep)
342 result = "[";
343 for (unsigned int i = 0; i < expId.fields(); ++i) {
344 if (first)
345 first = false;
346 else
347 result += sep;
348 result += std::format("{}", expId[i]);
349 }
350 if ('.' == sep)
351 result += "]";
352 return result;
353}
354
355void AtlasDetectorID::print(Identifier id, const IdContext *context) const {
356 ATH_MSG_INFO(print_to_string(id, context));
357}
358
360 const IdContext *context) const {
361 // Print out for any Atlas identifier
362 std::string result;
364
365 // Do a generic printout of identifier from dictionary
366 unsigned int max_index = (context) ? context->end_index() : 999;
367
368 // Find the dictionary to use:
369 const IdDictDictionary *dict = dictionary(id);
370 ExpandedIdentifier expId;
371 ExpandedIdentifier prefix; // default is null prefix
372 Identifier compact = id;
373 if (!dict) {
374 ATH_MSG_WARNING(__func__<<":"<<__LINE__<<" No dictionary could be associated to "<<id);
375 return result;
376 }
377 if (dict->unpack(m_group, compact, prefix, max_index," ", result)) {
378 return result;
379 }
380 }
381 return result;
382}
383const std::vector<std::string> & AtlasDetectorID::dict_names() const {
384 return m_dict_names;
385}
386const std::vector<std::string>& AtlasDetectorID::file_names() const {
387 return m_file_names;
388}
389const std::vector<std::string> & AtlasDetectorID::dict_tags() const {
390 return m_dict_tags;
391}
393 return m_do_checks;
394}
398
400 return m_do_neighbours;
401}
402
406
407void AtlasDetectorID::setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) {
408 const IdDictDictionary *dict = dict_mgr.find_dictionary(name);
409 m_dict_version = dict->version();
410}
411
412std::string AtlasDetectorID::to_range(const ExpandedIdentifier &id) const {
413
414 // Build a string from the contents of an identifier
415 int fields = id.fields();
416 std::string result;
417 for (int i = 0; i < fields; ++i) {
418 if (i > 0) {
419 result += '/'; // add '/' only if NOT first one
420 }
421 result += std::format("{}", id[i]);
422 }
423 return result;
424}
425
427
428 // Set do_checks flag
429 if (dict_mgr.do_checks())
430 m_do_checks = true;
431 // Set do_neighbours flag
432 if (!dict_mgr.do_neighbours())
433 m_do_neighbours = false;
434
435
436 const IdDictField *field{nullptr};
437
438 // Find out from the dictionary the detector and subdetector
439 // levels and id values
466
467 // Save generic dict for top levels
468 const IdDictDictionary *top_dict {nullptr};
469
470 auto assignSystemId = [this, &field](const std::string& systemName,
471 int& idToAssign,
472 bool mandatory = true) ->bool {
473 const IdDictLabel *label = field->find_label(systemName);
474 if (label && label->valued()){
475 idToAssign = label->value();
476 ATH_MSG_VERBOSE("Assign system "<<systemName<<" to "<<idToAssign<<".");
477 return true;
478 } else if (label) {
479 ATH_MSG_ERROR("initLevelsFromDict - label "<<systemName<<" does NOT have a value ");
480 return false;
481 }
482 if (mandatory) {
483 ATH_MSG_ERROR("initLevelsFromDict - unable to find '"<<systemName<<"' label");
484 return false;
485 }
486 ATH_MSG_DEBUG("initLevelsFromDict - unable to find '"<<systemName<<"' label");
487 return true;
488 };
489 // Get det ids
490
491 // Initialize ids for InDet subdet
492 m_indet_dict = dict_mgr.find_dictionary("InnerDetector");
493 if (!m_indet_dict) {
494 ATH_MSG_WARNING("initLevelsFromDict - cannot access InnerDetector dictionary");
495 } else {
496 // Found InDet dict
497 top_dict = m_indet_dict; // save as top_dict
498 // Check if this is High Luminosity LHC layout
499 // should just use std::string::contains once that is available... (C++23)
500 std::string versionString = m_indet_dict->version();
501 m_isHighLuminosityLHC = (versionString.find("ITk") != std::string::npos || versionString.find("P2-RUN4") != std::string::npos);
502
503 // Get InDet subdets
504 field = m_indet_dict->find_field("part");
505 if (!field) {
506 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field for InnerDetector dictionary");
507 return 1;
508 }
509
510 if (!assignSystemId("Pixel", m_PIXEL_ID)) {
511 return 1;
512 }
513 if (!assignSystemId("SCT", m_SCT_ID)) {
514 return 1;
515 }
516 if (!assignSystemId("TRT", m_TRT_ID, !m_isHighLuminosityLHC)) {
517 return 1;
518 }
520 if (!assignSystemId("LuminosityDetectors", m_LUMI_ID, versionString.find("PLR") != std::string::npos ||
521 versionString.find("P2-RUN4") != std::string::npos)) {
522 return 1;
523 }
524 if (!assignSystemId("HGTD", m_HGTD_ID)){
525 return 1;
526 }
527 }
528 }
529 // Initialize ids for Forward dets
530 m_fwd_dict = dict_mgr.find_dictionary("ForwardDetectors");
531 if (!m_fwd_dict) {
532 ATH_MSG_WARNING("initLevelsFromDict - cannot access ForwardDetectors dictionary");
533 } else {
534
535 // Found ForwardDetectors dict
536
537 if (!top_dict){
538 top_dict = m_fwd_dict; // save as top_dict
539 }
540 // Get Forward subdets
541
542 field = m_fwd_dict->find_field("part");
543 if (!field) {
544 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field for ForwardDetectors dictionary");
545 return 1;
546 }
547 if (!assignSystemId("ALFA", m_ALFA_ID)) {
548 return 1;
549 }
550 if (!assignSystemId("BCM", m_BCM_ID)) {
551 return 1;
552 }
553 if (!assignSystemId("LUCID", m_LUCID_ID)) {
554 return 1;
555 }
556 if (!assignSystemId("ZDC", m_ZDC_ID)) {
557 return 1;
558 }
559 }
560
561 // Initialize ids for LAr detectors
562 m_lar_dict = dict_mgr.find_dictionary("LArCalorimeter");
563 if (!m_lar_dict) {
564 ATH_MSG_WARNING("initLevelsFromDict - cannot access LArCalorimeter dictionary");
565 } else {
566 // Found LAr dict
567
568 if (!top_dict) {
569 top_dict = m_lar_dict; // save as top_dict
570 }
571 field = m_lar_dict->find_field("part");
572 if (!field) {
573 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field for LArCalorimeter dictionary");
574 return 1;
575 }
576 if (!assignSystemId("LArEM", m_LAR_EM_ID)) {
577 return 1;
578 }
579 if (!assignSystemId("LArHEC", m_LAR_HEC_ID)) {
580 return 1;
581 }
582 if (!assignSystemId("LArFCAL", m_LAR_FCAL_ID)) {
583 return 1;
584 }
585 field = m_lar_dict->find_field("module");
586 if (field) {
587 m_LAR_FCAL_MODULE_INDEX = field->index();
588 } else {
589 ATH_MSG_DEBUG("initLevelsFromDict - unable to find 'module' field for miniFCAL");
590 }
591 }
592
593 // Initialize ids for Tile calo
594 m_tile_dict = dict_mgr.find_dictionary("TileCalorimeter");
595 if (!m_tile_dict) {
596 ATH_MSG_WARNING("initLevelsFromDict - cannot access TileCalorimeter dictionary");
597 } else {
598 // File Tile
599 if (!top_dict)
600 top_dict = m_tile_dict; // save as top_dict
601 }
602
603 // Initialize ids for Muon detectors
604 m_muon_dict = dict_mgr.find_dictionary("MuonSpectrometer");
605 if (!m_muon_dict) {
606 ATH_MSG_WARNING("initLevelsFromDict - cannot access MuonSpectrometer dictionary");
607 } else {
608 // Found muon dict
609 if (!top_dict){
610 top_dict = m_muon_dict; // save as top_dict
611 }
612 /*
613 During initialisation from the dictionary we parse the
614 information which muon stationName belongs to which muon
615 subsystem. This information is not entirely encoded in the
616 identifiers however it is frequently tested during
617 reconstruction. In order to speed up these checks this info
618 is now stored locally into m_muon_tech_bits.
619 P.Fleischmann 04.04.2013
620 */
621 if (m_muon_tech_bits.empty()) {
622 // we only need to load this once
623 field = m_muon_dict->find_field("stationName");
624 if (!field) {
625 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'stationName' field for MuonSpectrometer dictionary");
626 return 1;
627 }
628
629 size_type nStationNames = field->get_label_number();
630 std::string stationNameString{};
631
632 // first check for the maximum value assigned to any stationName
633 int stationNameIndex{};
634 int maxStationNameIndex{-1};
635 for (size_type i = 0; i < nStationNames; ++i) {
636 // in case no individual values are given,
637 // the order inside the dictionary is used
638 const IdDictLabel& label = field->label(i);
639 stationNameIndex = label.valued() ? label.value() : i;
640
641 maxStationNameIndex = std::max(maxStationNameIndex, stationNameIndex);
642 }
643
644 // the vector may contain gaps (value=0) in case of jumps
645 // in the values
646 m_muon_tech_bits.resize(maxStationNameIndex + 1);
647
648 // loop over all stationNames and search for associations
649 // to technology
650 for (size_type i = 0; i < nStationNames; ++i) {
651 const IdDictLabel& label = field->label(i);
652 stationNameString = label.name();
653 // in case no individual values are given,
654 // the order inside the dictionary is used
655 stationNameIndex = label.valued() ? label.value() : i;
656 // next loop over all regions to look for
657 // stationName <-> technology associations
658 bool found{false}, stationNameFound{false}, technologyFound{false};
659 std::string techLabel{};
660 size_t nregions = m_muon_dict->n_regions();
661 for (size_type j = 0; j < nregions; ++j) {
662 const IdDictRegion& region = m_muon_dict->region(j);
663 // loop over all entries of a region to look for
664 // stationName and technology information
665 stationNameFound = technologyFound = false;
666 size_t nentries = region.n_entries();
667 for (size_type k = 0; k < nentries; ++k) {
668 const IdDictRange *range =
669 dynamic_cast<const IdDictRange *>(&region.entry(k));
670 if (!range) {
671 continue;
672 }
673
674 if (range->field_name() == "stationName") {
675
676 if (range->label() == stationNameString) {
677 // we found a region containing the current stationName
678 stationNameFound = true;
679 continue;
680 } else {
681 // we found a region containing a different stationName,
682 // let's skip
683 break;
684 }
685 } else if (range->field_name() == "technology") {
686 technologyFound = true;
687 techLabel = range->label();
688 }
689
690 if (!stationNameFound || !technologyFound) {
691 continue;
692 }
693
694 // we found a stationName <-> technology association
695 if (techLabel == "MDT") {
696 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasMDT;
697 } else if (techLabel == "RPC") {
698 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasRPC;
699 } else if (techLabel == "CSC") {
700 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasCSC;
701 } else if (techLabel == "TGC"){
702 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasTGC;
703 } else if (techLabel == "MM") {
704 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasMM;
705 } else if (techLabel == "STGC") {
707 } else {
709 }
710 found = true;
711 break;
712 } // end of loop overregion entries
713
714 if (found) {
715 // no need to continue to look for this stationName,
716 // since each stationName must be uniquely associated
717 // to a technology, except for MDT/PRC
718 break;
719 }
720
721 } // end of loop over regions
722
723 } // end of loop over stationNames
724 }
725 // end of filling stationName <-> technology associations
726
727 field = m_muon_dict->find_field("technology");
728 if (field) {
729 m_MUON_SUBDET_INDEX = field->index();
730 }
731 else {
732 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'technology' field for MuonSpectrometer dictionary");
733 return 1;
734 }
735
736 if (!assignSystemId("MDT", m_MDT_ID)) {
737 return 1;
738 }
739 if (!assignSystemId("RPC", m_RPC_ID)) {
740 return 1;
741 }
742 if (!assignSystemId("TGC", m_TGC_ID)) {
743 return 1;
744 }
745 if (!assignSystemId("STGC", m_STGC_ID, false)) {
746 return 1;
747 }
748 if (!assignSystemId("MM", m_MM_ID, false)) {
749 return 1;
750 }
751 if (!assignSystemId("CSC", m_CSC_ID, false)) {
752 return 1;
753 }
754 }
755
756 // Initialize id for Calo and fields for lvl1 and dead material
757 m_calo_dict = dict_mgr.find_dictionary("Calorimeter");
758 if (!m_calo_dict) {
759 ATH_MSG_WARNING("initLevelsFromDict - Warning cannot access Calorimeter dictionary");
760 } else {
761 // Found calo dict
762 if (!top_dict) {
763 top_dict = m_calo_dict; // save as top_dict
764 }
765 // Set lvl1 field for is_lvl1_trig_towers
766 int value{0};
767 m_lvl1_field.clear();
768 // negative half
769 if (m_calo_dict->get_label_value("DetZside", "negative_lvl1_side", value)) {
770 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'negative_lvl1_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
771 return 1;
772 }
773 m_lvl1_field.add_value(value);
774 // positive half
775 if (m_calo_dict->get_label_value("DetZside", "positive_lvl1_side", value)) {
776 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'positive_lvl1_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
777 return 1;
778 }
779 m_lvl1_field.add_value(value);
780 // Set lar dead material field for is_lar_dm
781 m_lar_dm_field.clear();
782 // negative half
783 if (m_calo_dict->get_label_value("DetZside", "negative_DMLar_side", value)) {
784 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'negative_DMLar_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
785 return 1;
786 }
787 m_lar_dm_field.add_value(value);
788 // positive half
789 if (m_calo_dict->get_label_value("DetZside", "positive_DMLar_side", value)) {
790 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'positive_DMLar_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
791 return 1;
792 }
793 m_lar_dm_field.add_value(value);
794
795 // Set tile dead material field for is_tile_dm
796 m_tile_dm_field.clear();
797 // negative half
798 if (m_calo_dict->get_label_value("DetZside", "negative_DMTile_side", value)) {
799 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'negative_DMTile_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
800 return 1;
801 }
802 m_tile_dm_field.add_value(value);
803 // positive half
804 if (m_calo_dict->get_label_value("DetZside", "positive_DMTile_side", value)) {
805 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'positive_DMTile_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
806 return 1;
807 }
808 m_tile_dm_field.add_value(value);
809
810 // Set lvl1 field for is_lvl1_online
811 m_lvl1_onl_field.clear();
812 if (m_calo_dict->get_label_value("DetZside", "no_side", value)) {
813 ATH_MSG_DEBUG("initLevelsFromDict - Could not get value for label 'no_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
814 } else {
815 m_lvl1_onl_field.add_value(value);
816 }
817 }
818
819 // set det/subdet indices
820 if (top_dict){
821
822 field = top_dict->find_field("subdet");
823 if (field) {
824 m_DET_INDEX = field->index();
825 } else {
826 ATH_MSG_ERROR("initLevelsFromDict - - unable to find 'subdet' field from dict "
827 << top_dict->name());
828 return 1;
829 }
830
831 if (!assignSystemId("InnerDetector", m_INDET_ID)) {
832 return 1;
833 }
834 if (!assignSystemId("ForwardDetectors", m_FWD_ID)) {
835 return 1;
836 }
837 if (!assignSystemId("LArCalorimeter", m_LAR_ID)) {
838 return 1;
839 }
840 if (!assignSystemId("TileCalorimeter", m_TILE_ID)) {
841 return 1;
842 }
843
844 if (!assignSystemId("MuonSpectrometer", m_MUON_ID)) {
845 return 1;
846 }
847 if (!assignSystemId("Calorimeter", m_CALO_ID)) {
848 return 1;
849 }
850 // Get name of next level
851 std::string name{};
852 if (top_dict->name() == "InnerDetector") {
853 name = "part";
854 } else if (top_dict->name() == "Calorimeter") {
855 name = "DetZside";
856 } else if (top_dict->name() == "LArCalorimeter") {
857 name = "part";
858 } else if (top_dict->name() == "MuonSpectrometer") {
859 name = "stationName";
860 } else if (top_dict->name() == "TileCalorimeter") {
861 name = "section";
862 } else if (top_dict->name() == "ForwardDetectors") {
863 name = "part";
864 }
865 // While we're here, save the index to the sub-detector level
866 // ("part" for InDet)
867 field = top_dict->find_field(name);
868 if (field) {
869 m_SUBDET_INDEX = field->index();
870 }
871 else {
872 ATH_MSG_ERROR("initLevelsFromDict - unable to find field " << name << " from dict "<< top_dict->name());
873 return 1;
874 }
875 } else {
876 ATH_MSG_ERROR("initLevelsFromDict - no top dictionary defined");
877 return 1;
878 }
879
880 // Set the field implementations
881
882 size_type region_index = m_helper->pixel_region_index();
883 if (m_indet_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
884
885 const IdDictRegion& region = m_indet_dict->region(region_index);
886
887 // Detector
889
890 // Add on extra values to assure that one has a value per
891 // bit. This is needed to avoid an overflow decoding error
892 // when a pixel channel id is decoded
893 if (not m_det_impl.ored_field().isEnumerated()) {
894 ATH_MSG_ERROR("initLevelsFromDict - ERROR det implementation is not enumerated: "
895 << m_det_impl);
896 return 1;
897 }
898
899 size_type bits = m_det_impl.bits();
900 size_type nvalues = static_cast<size_type>(1) << bits;
901 Range::field det = m_det_impl.ored_field();
902 size_type max = det.get_maximum();
903 for (size_type i = det.get_values().size(); i < nvalues; ++i) {
904 ++max;
905 det.add_value(max);
906 }
907 // Replace ored field with modified one
908 m_det_impl.set_ored_field(det);
909 ATH_MSG_VERBOSE("set extra bits "<< m_det_impl);
910
911 // InDet part
913 }
914
915 // Calo side: LVL1, LAr & Tile DeadMat
916 region_index = m_helper->lvl1_region_index();
917 if (m_calo_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
918 const IdDictRegion& region = m_calo_dict->region(region_index);
920 }
921
922 // LAr part
923 region_index = m_helper->lar_em_region_index();
924 if (m_lar_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
925 const IdDictRegion& region = m_lar_dict->region(region_index);
927 }
928
929 // LAr part
930 region_index = m_helper->lar_fcal_region_index();
931 if (m_lar_dict && AtlasDetectorIDHelper::UNDEFINED != region_index &&
933 const IdDictRegion& region = m_lar_dict->region(region_index);
935 }
936
937 // Muon station name
938 region_index = m_helper->mdt_region_index();
939 if (m_muon_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
940 const IdDictRegion& region = m_muon_dict->region(region_index);
942 // Muon MDT
944 // Muon RPC
945 region_index = m_helper->rpc_region_index();
946 if (AtlasDetectorIDHelper::UNDEFINED != region_index) {
947 const IdDictRegion& rpc_region = m_muon_dict->region(region_index);
949 }
950 }
951 return 0;
952}
953
954
957{
958 ExpandedIdentifier result;
959 return (result << m_INDET_ID);
960}
961
964{
965 ExpandedIdentifier result;
966 return (result << m_LAR_ID);
967}
968
971{
972 ExpandedIdentifier result;
973 return (result << m_TILE_ID);
974}
975
978{
979 ExpandedIdentifier result;
980 return (result << m_MUON_ID);
981}
982
985{
986 ExpandedIdentifier result;
987 return (result << m_CALO_ID);
988}
989
992{
993 ExpandedIdentifier result;
994 return (result << m_FWD_ID);
995}
996
999{
1000 ExpandedIdentifier result(indet_exp());
1001 return (result << m_PIXEL_ID);
1002}
1003
1006{
1007 ExpandedIdentifier result(indet_exp());
1008 return (result << m_SCT_ID);
1009}
1010
1013{
1014 ExpandedIdentifier result(indet_exp());
1015 return (result << m_TRT_ID);
1016}
1017
1020{
1021 ExpandedIdentifier result(indet_exp());
1022 return (result << m_HGTD_ID);
1023}
1024
1027{
1028 ExpandedIdentifier result(indet_exp());
1029 return (result << m_LUMI_ID);
1030}
1031
1034{
1035 ExpandedIdentifier result(lar_exp());
1036 return (result << m_LAR_EM_ID);
1037}
1038
1041{
1042 ExpandedIdentifier result(lar_exp());
1043 return (result << m_LAR_HEC_ID);
1044}
1045
1048{
1049 ExpandedIdentifier result(lar_exp());
1050 return (result << m_LAR_FCAL_ID);
1051}
1052
1055{
1056 ExpandedIdentifier result(fwd_exp());
1057 return (result << m_ALFA_ID);
1058}
1059
1062{
1063 ExpandedIdentifier result(fwd_exp());
1064 return (result << m_BCM_ID);
1065}
1066
1069{
1070 ExpandedIdentifier result(fwd_exp());
1071 return (result << m_LUCID_ID);
1072}
1073
1076{
1077 ExpandedIdentifier result(fwd_exp());
1078 return (result << m_ZDC_ID);
1079}
1080
1082 if (is_indet(id)) {
1083 return m_indet_dict;
1084 }
1085 if (is_lar(id)) {
1086 return m_lar_dict;
1087 }
1088 if (is_tile(id)) {
1089 return m_tile_dict;
1090 }
1091 if (is_muon(id)) {
1092 return m_muon_dict;
1093 }
1094 if (is_lvl1_trig_towers(id) || is_lvl1_online(id) || is_lar_dm(id) || is_tile_dm(id)) {
1095 return m_calo_dict;
1096 }
1097 if (is_forward(id)) {
1098 return m_fwd_dict;
1099 }
1100 return nullptr;
1101}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
#define max(a, b)
Definition cfImp.cxx:41
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Identifier lar_hec(void) const
virtual std::string dictionaryVersion(void) const override
Range::field m_lvl1_field
ExpandedIdentifier zdc_exp(void) const
bool m_do_checks
Flag for subclasses to know whether or not to perform checks.
int muon_field_value() const
Identifier hgtd(void) const
Identifier lar_dm(void) const
std::string m_dict_version
bool m_do_neighbours
Flag for subclasses to know whether or not to perform neighbour initialization.
IdDictFieldImplementation m_det_impl
const IdDictDictionary * m_calo_dict
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
virtual bool do_neighbours(void) const override
Neighbour initialization is performed by default One can switch or query this mode for any idHelper w...
bool is_lar_em(Identifier id) const
Identifier tile(void) const
IdContext detsystem_context(void) const
IdContext (indicates id length) for detector systems.
Range::field m_lar_dm_field
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override
Create compact id from hash id (return == 0 for OK).
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
const IdDictDictionary * m_muon_dict
const IdDictDictionary * dictionary(const Identifier &id) const
size_type m_SUBDET_INDEX
IdDictFieldImplementation m_calo_side_impl
ExpandedIdentifier bcm_exp(void) const
ExpandedIdentifier lar_em_exp(void) const
LAr.
ExpandedIdentifier sct_exp(void) const
Identifier trt(void) const
std::vector< std::string > m_dict_names
List of dictionary names used by this helper.
ExpandedIdentifier pixel_exp(void) const
Inner Detector:
Identifier::size_type size_type
bool is_mdt(Identifier id) const
std::string m_group
Group name.
bool is_indet(Identifier id) const
ExpandedIdentifier lar_exp(void) const
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
Identifier stgc(void) const
ExpandedIdentifier lar_hec_exp(void) const
ExpandedIdentifier muon_exp(void) const
static constexpr int invalidId
IdDictFieldImplementation m_lar_part_impl
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_lar(Identifier id) const
Range::field m_lvl1_onl_field
virtual bool do_checks(void) const override
Checks are performed by default in debug compilation and NOT in optimized compilation.
bool is_stgc(Identifier id) const
IdDictFieldImplementation m_lar_fcal_module_impl
IdDictFieldImplementation m_muon_mdt_impl
bool is_rpc(Identifier id) const
virtual ~AtlasDetectorID()
IdDictFieldImplementation m_indet_part_impl
Identifier mdt(void) const
void show(Identifier id, const IdContext *context=0, char sep='.') const
Short print out of any identifier (optionally provide separation character - default is '.
Identifier lar_lvl1(void) const
bool is_sct(Identifier id) const
static constexpr int invalidIndex
IdDictFieldImplementation m_muon_rpc_impl
ExpandedIdentifier indet_exp(void) const
Detector systems:
ExpandedIdentifier lumi_exp(void) const
bool is_lar_dm(Identifier id) const
LAr/Tile dead material:
int calo_field_value() const
virtual void set_do_checks(bool do_checks) override
std::vector< std::string > m_dict_tags
List of dictionary versions used by this helper.
bool is_tgc(Identifier id) const
size_type m_MUON_SUBDET_INDEX
ExpandedIdentifier lar_fcal_exp(void) const
bool is_lar_fcal(Identifier id) const
bool is_pixel(Identifier id) const
std::string to_range(const ExpandedIdentifier &id) const
bool is_plr(Identifier id) const
const std::vector< std::string > & dict_names(void) const
Dictionary names.
const std::vector< std::string > & dict_tags(void) const
Version tags for subdet dictionaries.
bool is_lvl1_online(Identifier id) const
const std::vector< std::string > & file_names(void) const
File names for subdet dictionaries.
const IdDictDictionary * m_tile_dict
ExpandedIdentifier fwd_exp(void) const
const IdDictDictionary * m_fwd_dict
bool is_muon(Identifier id) const
Identifier mm(void) const
int initLevelsFromDict(const IdDictMgr &dict_mgr)
ExpandedIdentifier trt_exp(void) const
int lar_field_value() const
bool is_hgtd(Identifier id) const
bool is_calo(Identifier id) const
IdContext subdet_context(void) const
IdContext (indicates id length) for sub-detector.
Identifier calo(void) const
bool is_tile_dm(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 csc(void) const
bool is_csc(Identifier id) const
Identifier lar(void) const
Identifier sct(void) const
Identifier pixel(void) const
bool is_tile(Identifier id) const
Identifier muon(void) const
ExpandedIdentifier tile_exp(void) const
bool is_lar_minifcal(Identifier id) const
bool is_mm(Identifier id) const
const IdDictDictionary * m_indet_dict
void print(Identifier id, const IdContext *context=0) const
Expanded print out of any identifier.
ExpandedIdentifier lucid_exp(void) const
Identifier lumi(void) const
bool is_forward(Identifier id) const
virtual void set_do_neighbours(bool do_neighbours) override
bool is_lumi(Identifier id) const
ExpandedIdentifier alfa_exp(void) const
Forward.
ExpandedIdentifier hgtd_exp(void) const
int tile_field_value() const
bool is_lar_hec(Identifier id) const
Identifier lar_em(void) const
Identifier rpc(void) const
const IdDictDictionary * m_lar_dict
const std::string & group() const
Group name for this helper.
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const override
Create hash id from compact id (return == 0 for OK).
std::unique_ptr< AtlasDetectorIDHelper > m_helper
Identifier tgc(void) const
Identifier lar_fcal(void) const
bool is_trt(Identifier id) const
ExpandedIdentifier calo_exp(void) const
std::vector< unsigned int > m_muon_tech_bits
Range::field m_tile_dm_field
Identifier indet(void) const
Detector systems:
AtlasDetectorID(const std::string &name, const std::string &group)
bool is_lvl1_trig_towers(Identifier id) const
int indet_field_value() const
Provide efficient access to individual field values, for subclass idhelpers.
IdDictFieldImplementation m_muon_station_name_impl
Identifier tile_dm(void) const
std::vector< std::string > m_file_names
List of dictionary file names used by this helper.
size_type fields() const
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
const std::string & name() const
Dictionary name.
const IdDictField * find_field(const std::string &name) const
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Identifier new_pack(int value) const
void pack(int value, Identifier &id) const
bool do_checks() const
Check whether or not to do checks for ids.
Definition IdDictMgr.cxx:62
bool do_neighbours() const
Check whether or not to init neighbours.
Definition IdDictMgr.cxx:74
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
const IdDictRegionEntry & entry(size_t i) const
size_t n_entries() const
const IdDictFieldImplementation & implementation(size_t i) const
This is a "hash" representation of an Identifier.
std::string label(const std::string &format, int i)
Definition label.h:19
#define unlikely(x)