ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasDetectorID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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 <stdio.h>
21#include <assert.h>
22#include <format>
23
24AtlasDetectorID::AtlasDetectorID(const std::string &name,
25 const std::string& group)
26 : AthMessaging(name),
28{
29}
33
34const std::string& AtlasDetectorID::group() const
35{
36 return m_group;
37}
38
40 return Identifier{};
41}
43 return Identifier{};
44}
46 return Identifier{};
47}
49 return Identifier{};
50}
52 return Identifier{};
53}
55 return Identifier{};
56}
59 // Pack field
61 return result;
62}
63
66 // Pack field
68 return result;
69}
70
73 // Pack field
75 return result;
76}
77
80 // Pack field
82 return result;
83}
84
87 // Pack field
89 return result;
90}
91
94 // Pack field
97 return result;
98}
99
102 // Pack field
105 return result;
106}
107
110 // Pack field
113 return result;
114}
115
118 // Pack field
121 return result;
122}
123
126 // Pack field
129 return result;
130}
131
134 // Pack field
137 return result;
138}
139
142 // Pack field
144 m_calo_side_impl.pack(-1, result);
145 return result;
146}
147
150 // Pack field
152 m_calo_side_impl.pack(-4, result);
153 return result;
154}
155
158 // Pack field
160 m_calo_side_impl.pack(-5, result);
161 return result;
162}
163
166 // Pack field
169 return result;
170}
171
174 // Pack field
177 return result;
178}
179
184
190
192 Identifier & /*id*/,
193 const IdContext * /*context*/) const {
194 return 0;
195}
196
198 IdentifierHash & /*hash_id*/,
199 const IdContext * /*context*/) const {
200 return 0;
201}
202
204 const std::string &dict_name) {
205 // Register version of dictionary dict_name
206
207 // Access dictionary by name
208 const IdDictDictionary *dict = dict_mgr.find_dictionary(dict_name);
209 if (!dict) {
210 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" No dictionary found");
211 return 1;
212
213 }
214 // Add in dict name, file name and version
215 m_dict_names.push_back(dict_name);
216 m_file_names.push_back(dict->file_name());
217 m_dict_tags.push_back(dict->dict_tag());
218 return 0;
219}
220
224 // If no tag has been registered, then reinitialize
225 if (m_dict_tags.size() == 0){
226 return true;
227 }
228 // If no dict names have been registered, then reinitialize
229 if (m_dict_names.size() == 0){
230 return true;
231 }
232 // Loop over dict names and check version tags
233 if (m_dict_names.size() != m_dict_tags.size()) {
234 ATH_MSG_ERROR("reinitialize: dict names and tags vectors not the same length ");
235 ATH_MSG_ERROR("names: " << m_dict_names.size() << " tags: " << m_dict_tags.size());
236 }
237 for (unsigned int i = 0; i < m_dict_names.size(); ++i) {
238 // Access dictionary by name
239 const IdDictDictionary *dict = dict_mgr.find_dictionary(m_dict_names[i]);
240 if (!dict) {
241 ATH_MSG_ERROR("reinitialize: could not find dict - " << m_dict_names[i]);
242 return false;
243 }
244 if (m_dict_tags[i] != dict->dict_tag()) {
245 // Remove all memory of versions
246 m_dict_names.clear();
247 m_dict_tags.clear();
248 m_file_names.clear();
249 return true;
250 }
251 }
252
253 // Tags match - don't reinitialize
254 return false;
255}
256
258
259 // Register version of ATLAS dictionary
260 if (register_dict_tag(dict_mgr, "ATLAS")){
261 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" - Failed to register dict tag");
262 return 1;
263 }
264 // Initialize helper, needed for init of AtlasDetectorID
265 if (!m_helper) {
266 m_helper = std::make_unique<AtlasDetectorIDHelper>().release();
267 }
268
269 if (m_helper->initialize_from_dictionary(dict_mgr)){
270 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" - Initialization from dictionary failed.");
271 return 1;
272 }
273 // Initialize level indices and id values from dicts
274 if (initLevelsFromDict(dict_mgr)) {
275 ATH_MSG_ERROR(__func__<<":"<<__LINE__<<" - Level initialization from dictionary failed.");
276 return 1;
277 }
279 ATH_MSG_DEBUG("initialize_from_dictionary - OK");
280 return 0;
281}
282
284 return m_dict_version;
285}
287 return id.fields() > 0 && id[0] == m_INDET_ID;
288}
290 return id.fields() > 0 && id[0] == m_LAR_ID;
291}
293 return id.fields() > 0 && id[0] == m_TILE_ID;
294}
296 return id.fields() > 0 && id[0] == m_MUON_ID;
297}
299 return id.fields() > 0 && id[0] == m_CALO_ID;
300}
302 return is_indet(id) && id.fields() > 1 && id[1] == m_PIXEL_ID;
303}
304
306 return is_indet(id) && id.fields() > 1 && id[1] == m_SCT_ID;
307}
309 return is_indet(id) && id.fields() > 1;
310}
312 return is_indet(id) && id.fields() > 1 && id[1] == m_HGTD_ID;
313}
315 return is_indet(id) && id.fields() > 1 && id[1] == m_LUMI_ID;
316}
318 return is_lumi(id) && id.fields() > 2 && id[2] == m_LUMI_PLR_ID;
319}
320
322 return is_lar(id) && id.fields() > 1 && std::abs(id[1]) == m_LAR_EM_ID;
323}
325 return is_lar(id) && id.fields() > 1 && std::abs(id[1]) == m_LAR_HEC_ID;
326}
327
329 return is_lar(id) && id.fields() > 1 && std::abs(id[1]) == m_LAR_FCAL_ID;
330}
331
333 return is_lar_fcal(id) && id.fields() > 3 &&std::abs(id[3]) == 0;
334}
335
337 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_MDT_ID;
338}
339
341 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_CSC_ID;
342}
343
345 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_RPC_ID;
346}
347
349 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_TGC_ID;
350}
351
353 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_STGC_ID;
354}
355
357 return id.fields() > 4 && id[0] == m_MUON_ID && id[4] == m_MM_ID;
358}
359
360// Short print out of any identifier:
361void AtlasDetectorID::show(const Identifier id, const IdContext *context, char sep) const {
362 ATH_MSG_INFO(show_to_string(id, context, sep));
363}
364
365// or provide the printout in string form
366std::string
367AtlasDetectorID::show_to_string(const Identifier id, const IdContext *context, char sep) const {
368 // Do a generic printout of identifier
369
370 std::string result("Unable to decode id");
371 unsigned int max_index = (context) ? context->end_index() : 999;
372
373 if (!id.is_valid()) {
374 return "[INVALID]";
375 }
376
378 return result;
379
380 // Find the dictionary to use:
381 const IdDictDictionary *dict{nullptr};
382 ExpandedIdentifier expId{};
383 ExpandedIdentifier prefix{}; // default is null prefix
384 Identifier compact = id;
385
386 if (is_indet(id)) {
387 dict = m_indet_dict;
388 } else if (is_lar(id)) {
389 dict = m_lar_dict;
390 } else if (is_tile(id)) {
391 dict = m_tile_dict;
392 } else if (is_muon(id)) {
393 dict = m_muon_dict;
394 } else if (is_lvl1_trig_towers(id) || is_lvl1_online(id) ||
395 is_lar_dm(id) || is_tile_dm(id)) {
396 dict = m_calo_dict;
397 } else if (is_forward(id)) {
398 dict = m_fwd_dict;
399 }
400
401 if (!dict) {
402 ATH_MSG_WARNING(__func__<<" No detector type associated to id "<<id);
403 return result;
404 }
405 if (dict->unpack(m_group, compact, prefix, max_index, expId)) {
406 return result;
407 }
408
409 bool first = true;
410 result = "";
411 if ('.' == sep)
412 result = "[";
413 for (unsigned int i = 0; i < expId.fields(); ++i) {
414 if (first)
415 first = false;
416 else
417 result += sep;
418 result += std::format("{}", expId[i]);
419 }
420 if ('.' == sep)
421 result += "]";
422 return result;
423}
424
425void AtlasDetectorID::print(Identifier id, const IdContext *context) const {
426 ATH_MSG_INFO(print_to_string(id, context));
427}
428
430 const IdContext *context) const {
431 // Print out for any Atlas identifier
432 std::string result;
434
435 // Do a generic printout of identifier from dictionary
436 unsigned int max_index = (context) ? context->end_index() : 999;
437
438 // Find the dictionary to use:
439 const IdDictDictionary *dict{nullptr};
440 ExpandedIdentifier expId;
441 ExpandedIdentifier prefix; // default is null prefix
442 Identifier compact = id;
443
444 if (is_indet(id)) {
445 dict = m_indet_dict;
446 } else if (is_lar(id)) {
447 dict = m_lar_dict;
448 } else if (is_tile(id)) {
449 dict = m_tile_dict;
450 } else if (is_muon(id)) {
451 dict = m_muon_dict;
452 } else if (is_lvl1_trig_towers(id) || is_lvl1_online(id) ||
453 is_lar_dm(id) || is_tile_dm(id)) {
454 dict = m_calo_dict;
455 } else if (is_forward(id)) {
456 dict = m_fwd_dict;
457 }
458
459 if (!dict) {
460 ATH_MSG_WARNING(__func__<<":"<<__LINE__<<" No dictionary could be associated to "<<id);
461 return result;
462 }
463 if (dict->unpack(m_group, compact, prefix, max_index," ", result)) {
464 return result;
465 }
466 }
467 return result;
468}
469const std::vector<std::string> & AtlasDetectorID::dict_names() const {
470 return m_dict_names;
471}
472const std::vector<std::string>& AtlasDetectorID::file_names() const {
473 return m_file_names;
474}
475const std::vector<std::string> & AtlasDetectorID::dict_tags() const {
476 return m_dict_tags;
477}
479 return m_do_checks;
480}
484
486 return m_do_neighbours;
487}
488
492
493void AtlasDetectorID::setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) {
494 const IdDictDictionary *dict = dict_mgr.find_dictionary(name);
495 m_dict_version = dict->version();
496}
497
498std::string AtlasDetectorID::to_range(const ExpandedIdentifier &id) const {
499
500 // Build a string from the contents of an identifier
501 int fields = id.fields();
502 std::string result("");
503 for (int i = 0; i < fields; ++i) {
504 if (i > 0) {
505 result += '/'; // add '/' only if NOT last one
506 }
507 result += std::format("{}", id[i]);
508 }
509 return result;
510}
511
513
514 // Set do_checks flag
515 if (dict_mgr.do_checks())
516 m_do_checks = true;
517 // Set do_neighbours flag
518 if (!dict_mgr.do_neighbours())
519 m_do_neighbours = false;
520
521
522 const IdDictField *field{nullptr};
523
524 // Find out from the dictionary the detector and subdetector
525 // levels and id values
526 m_DET_INDEX = 999;
527 m_SUBDET_INDEX = 999;
529 m_INDET_ID = -1;
530 m_LAR_ID = -1;
531 m_TILE_ID = -1;
532 m_MUON_ID = -1;
533 m_PIXEL_ID = -1;
534 m_SCT_ID = -1;
535 m_TRT_ID = -1;
536 m_HGTD_ID = -1;
537 m_FWD_ID = -1;
538 m_ALFA_ID = -1;
539 m_BCM_ID = -1;
540 m_LUCID_ID = -1;
541 m_ZDC_ID = -1;
542 m_LAR_EM_ID = -1;
543 m_LAR_HEC_ID = -1;
544 m_LAR_FCAL_ID = -1;
546 m_MDT_ID = -1;
547 m_CSC_ID = -1;
548 m_RPC_ID = -1;
549 m_TGC_ID = -1;
550 m_STGC_ID = -1;
551 m_MM_ID = -1;
552
553 // Save generic dict for top levels
554 const IdDictDictionary *top_dict {nullptr};
555
556 auto assignSystemId = [this, &field](const std::string& systemName,
557 int& idToAssign,
558 bool mandatory = true) ->bool {
559 const IdDictLabel *label = field->find_label(systemName);
560 if (label && label->valued()){
561 idToAssign = label->value();
562 ATH_MSG_VERBOSE("Assign system "<<systemName<<" to "<<idToAssign<<".");
563 return true;
564 } else if (label) {
565 ATH_MSG_ERROR("initLevelsFromDict - label "<<systemName<<" does NOT have a value ");
566 return false;
567 }
568 if (mandatory) {
569 ATH_MSG_ERROR("initLevelsFromDict - unable to find '"<<systemName<<"' label");
570 return false;
571 }
572 ATH_MSG_DEBUG("initLevelsFromDict - unable to find '"<<systemName<<"' label");
573 return true;
574 };
575 // Get det ids
576
577 // Initialize ids for InDet subdet
578 m_indet_dict = dict_mgr.find_dictionary("InnerDetector");
579 if (!m_indet_dict) {
580 ATH_MSG_WARNING("initLevelsFromDict - cannot access InnerDetector dictionary");
581 } else {
582 // Found InDet dict
583 top_dict = m_indet_dict; // save as top_dict
584 // Check if this is High Luminosity LHC layout
585 // should just use std::string::contains once that is available... (C++23)
586 std::string versionString = m_indet_dict->version();
587 m_isHighLuminosityLHC = (versionString.find("ITk") != std::string::npos || versionString.find("P2-RUN4") != std::string::npos);
588
589 // Get InDet subdets
590 field = m_indet_dict->find_field("part");
591 if (!field) {
592 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field for InnerDetector dictionary");
593 return 1;
594 }
595
596 if (!assignSystemId("Pixel", m_PIXEL_ID)) {
597 return 1;
598 }
599 if (!assignSystemId("SCT", m_SCT_ID)) {
600 return 1;
601 }
602 if (!assignSystemId("TRT", m_TRT_ID, !m_isHighLuminosityLHC)) {
603 return 1;
604 }
606 if (!assignSystemId("LuminosityDetectors", m_LUMI_ID, versionString.find("PLR") != std::string::npos ||
607 versionString.find("P2-RUN4") != std::string::npos)) {
608 return 1;
609 }
610 if (!assignSystemId("HGTD", m_HGTD_ID)){
611 return 1;
612 }
613 }
614 }
615 // Initialize ids for Forward dets
616 m_fwd_dict = dict_mgr.find_dictionary("ForwardDetectors");
617 if (!m_fwd_dict) {
618 ATH_MSG_WARNING("initLevelsFromDict - cannot access ForwardDetectors dictionary");
619 } else {
620
621 // Found ForwardDetectors dict
622
623 if (!top_dict){
624 top_dict = m_fwd_dict; // save as top_dict
625 }
626 // Get Forward subdets
627
628 field = m_fwd_dict->find_field("part");
629 if (!field) {
630 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field for ForwardDetectors dictionary");
631 return 1;
632 }
633 if (!assignSystemId("ALFA", m_ALFA_ID)) {
634 return 1;
635 }
636 if (!assignSystemId("BCM", m_BCM_ID)) {
637 return 1;
638 }
639 if (!assignSystemId("LUCID", m_LUCID_ID)) {
640 return 1;
641 }
642 if (!assignSystemId("ZDC", m_ZDC_ID)) {
643 return 1;
644 }
645 }
646
647 // Initialize ids for LAr detectors
648 m_lar_dict = dict_mgr.find_dictionary("LArCalorimeter");
649 if (!m_lar_dict) {
650 ATH_MSG_WARNING("initLevelsFromDict - cannot access LArCalorimeter dictionary");
651 } else {
652 // Found LAr dict
653
654 if (!top_dict) {
655 top_dict = m_lar_dict; // save as top_dict
656 }
657 field = m_lar_dict->find_field("part");
658 if (!field) {
659 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field for LArCalorimeter dictionary");
660 return 1;
661 }
662 if (!assignSystemId("LArEM", m_LAR_EM_ID)) {
663 return 1;
664 }
665 if (!assignSystemId("LArHEC", m_LAR_HEC_ID)) {
666 return 1;
667 }
668 if (!assignSystemId("LArFCAL", m_LAR_FCAL_ID)) {
669 return 1;
670 }
671 field = m_lar_dict->find_field("module");
672 if (field) {
673 m_LAR_FCAL_MODULE_INDEX = field->index();
674 } else {
675 ATH_MSG_DEBUG("initLevelsFromDict - unable to find 'module' field for miniFCAL");
676 }
677 }
678
679 // Initialize ids for Tile calo
680 m_tile_dict = dict_mgr.find_dictionary("TileCalorimeter");
681 if (!m_tile_dict) {
682 ATH_MSG_WARNING("initLevelsFromDict - cannot access TileCalorimeter dictionary");
683 } else {
684 // File Tile
685 if (!top_dict)
686 top_dict = m_tile_dict; // save as top_dict
687 }
688
689 // Initialize ids for Muon detectors
690 m_muon_dict = dict_mgr.find_dictionary("MuonSpectrometer");
691 if (!m_muon_dict) {
692 ATH_MSG_WARNING("initLevelsFromDict - cannot access MuonSpectrometer dictionary");
693 } else {
694 // Found muon dict
695 if (!top_dict){
696 top_dict = m_muon_dict; // save as top_dict
697 }
698 /*
699 During initialisation from the dictionary we parse the
700 information which muon stationName belongs to which muon
701 subsystem. This information is not entirely encoded in the
702 identifiers however it is frequently tested during
703 reconstruction. In order to speed up these checks this info
704 is now stored locally into m_muon_tech_bits.
705 P.Fleischmann 04.04.2013
706 */
707 if (m_muon_tech_bits.empty()) {
708 // we only need to load this once
709 field = m_muon_dict->find_field("stationName");
710 if (!field) {
711 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'stationName' field for MuonSpectrometer dictionary");
712 return 1;
713 }
714
715 size_type nStationNames = field->get_label_number();
716 std::string stationNameString{};
717
718 // first check for the maximum value assigned to any stationName
719 int stationNameIndex{};
720 int maxStationNameIndex{-1};
721 for (size_type i = 0; i < nStationNames; ++i) {
722 // in case no individual values are given,
723 // the order inside the dictionary is used
724 const IdDictLabel& label = field->label(i);
725 stationNameIndex = label.valued() ? label.value() : i;
726
727 maxStationNameIndex = std::max(maxStationNameIndex, stationNameIndex);
728 }
729
730 // the vector may contain gaps (value=0) in case of jumps
731 // in the values
732 m_muon_tech_bits.resize(maxStationNameIndex + 1);
733
734 // loop over all stationNames and search for associations
735 // to technology
736 for (size_type i = 0; i < nStationNames; ++i) {
737 const IdDictLabel& label = field->label(i);
738 stationNameString = label.name();
739 // in case no individual values are given,
740 // the order inside the dictionary is used
741 stationNameIndex = label.valued() ? label.value() : i;
742 // next loop over all regions to look for
743 // stationName <-> technology associations
744 bool found{false}, stationNameFound{false}, technologyFound{false};
745 std::string techLabel{};
746 size_t nregions = m_muon_dict->n_regions();
747 for (size_type j = 0; j < nregions; ++j) {
748 const IdDictRegion& region = m_muon_dict->region(j);
749 // loop over all entries of a region to look for
750 // stationName and technology information
751 stationNameFound = technologyFound = false;
752 size_t nentries = region.n_entries();
753 for (size_type k = 0; k < nentries; ++k) {
754 const IdDictRange *range =
755 dynamic_cast<const IdDictRange *>(&region.entry(k));
756 if (!range) {
757 continue;
758 }
759
760 if (range->field_name() == "stationName") {
761
762 if (range->label() == stationNameString) {
763 // we found a region containing the current stationName
764 stationNameFound = true;
765 continue;
766 } else {
767 // we found a region containing a different stationName,
768 // let's skip
769 break;
770 }
771 } else if (range->field_name() == "technology") {
772 technologyFound = true;
773 techLabel = range->label();
774 }
775
776 if (!stationNameFound || !technologyFound) {
777 continue;
778 }
779
780 // we found a stationName <-> technology association
781 if (techLabel == "MDT") {
782 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasMDT;
783 } else if (techLabel == "RPC") {
784 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasRPC;
785 } else if (techLabel == "CSC") {
786 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasCSC;
787 } else if (techLabel == "TGC"){
788 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasTGC;
789 } else if (techLabel == "MM") {
790 m_muon_tech_bits[stationNameIndex] = AtlasDetDescr::fAtlasMM;
791 } else if (techLabel == "STGC") {
793 } else {
795 }
796 found = true;
797 break;
798 } // end of loop overregion entries
799
800 if (found) {
801 // no need to continue to look for this stationName,
802 // since each stationName must be uniquely associated
803 // to a technology, except for MDT/PRC
804 break;
805 }
806
807 } // end of loop over regions
808
809 } // end of loop over stationNames
810 }
811 // end of filling stationName <-> technology associations
812
813 field = m_muon_dict->find_field("technology");
814 if (field) {
815 m_MUON_SUBDET_INDEX = field->index();
816 }
817 else {
818 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'technology' field for MuonSpectrometer dictionary");
819 return 1;
820 }
821
822 if (!assignSystemId("MDT", m_MDT_ID)) {
823 return 1;
824 }
825 if (!assignSystemId("RPC", m_RPC_ID)) {
826 return 1;
827 }
828 if (!assignSystemId("TGC", m_TGC_ID)) {
829 return 1;
830 }
831 if (!assignSystemId("STGC", m_STGC_ID, false)) {
832 return 1;
833 }
834 if (!assignSystemId("MM", m_MM_ID, false)) {
835 return 1;
836 }
837 if (!assignSystemId("CSC", m_CSC_ID, false)) {
838 return 1;
839 }
840 }
841
842 // Initialize id for Calo and fields for lvl1 and dead material
843 m_calo_dict = dict_mgr.find_dictionary("Calorimeter");
844 if (!m_calo_dict) {
845 ATH_MSG_WARNING("initLevelsFromDict - Warning cannot access Calorimeter dictionary");
846 } else {
847 // Found calo dict
848 if (!top_dict) {
849 top_dict = m_calo_dict; // save as top_dict
850 }
851 // Set lvl1 field for is_lvl1_trig_towers
852 int value{0};
853 m_lvl1_field.clear();
854 // negative half
855 if (m_calo_dict->get_label_value("DetZside", "negative_lvl1_side", value)) {
856 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'negative_lvl1_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
857 return 1;
858 }
859 m_lvl1_field.add_value(value);
860 // positive half
861 if (m_calo_dict->get_label_value("DetZside", "positive_lvl1_side", value)) {
862 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'positive_lvl1_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
863 return 1;
864 }
865 m_lvl1_field.add_value(value);
866 // Set lar dead material field for is_lar_dm
867 m_lar_dm_field.clear();
868 // negative half
869 if (m_calo_dict->get_label_value("DetZside", "negative_DMLar_side", value)) {
870 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'negative_DMLar_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
871 return 1;
872 }
873 m_lar_dm_field.add_value(value);
874 // positive half
875 if (m_calo_dict->get_label_value("DetZside", "positive_DMLar_side", value)) {
876 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'positive_DMLar_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
877 return 1;
878 }
879 m_lar_dm_field.add_value(value);
880
881 // Set tile dead material field for is_tile_dm
882 m_tile_dm_field.clear();
883 // negative half
884 if (m_calo_dict->get_label_value("DetZside", "negative_DMTile_side", value)) {
885 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'negative_DMTile_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
886 return 1;
887 }
888 m_tile_dm_field.add_value(value);
889 // positive half
890 if (m_calo_dict->get_label_value("DetZside", "positive_DMTile_side", value)) {
891 ATH_MSG_ERROR("initLevelsFromDict - Could not get value for label 'positive_DMTile_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
892 return 1;
893 }
894 m_tile_dm_field.add_value(value);
895
896 // Set lvl1 field for is_lvl1_online
897 m_lvl1_onl_field.clear();
898 if (m_calo_dict->get_label_value("DetZside", "no_side", value)) {
899 ATH_MSG_DEBUG("initLevelsFromDict - Could not get value for label 'no_side' of field 'DetZside' in dictionary " << m_calo_dict->name());
900 } else {
901 m_lvl1_onl_field.add_value(value);
902 }
903 }
904
905 // set det/subdet indices
906 if (top_dict){
907
908 field = top_dict->find_field("subdet");
909 if (field) {
910 m_DET_INDEX = field->index();
911 } else {
912 ATH_MSG_ERROR("initLevelsFromDict - - unable to find 'subdet' field from dict "
913 << top_dict->name());
914 return 1;
915 }
916
917 if (!assignSystemId("InnerDetector", m_INDET_ID)) {
918 return 1;
919 }
920 if (!assignSystemId("ForwardDetectors", m_FWD_ID)) {
921 return 1;
922 }
923 if (!assignSystemId("LArCalorimeter", m_LAR_ID)) {
924 return 1;
925 }
926 if (!assignSystemId("TileCalorimeter", m_TILE_ID)) {
927 return 1;
928 }
929
930 if (!assignSystemId("MuonSpectrometer", m_MUON_ID)) {
931 return 1;
932 }
933 if (!assignSystemId("Calorimeter", m_CALO_ID)) {
934 return 1;
935 }
936 // Get name of next level
937 std::string name{};
938 if (top_dict->name() == "InnerDetector") {
939 name = "part";
940 } else if (top_dict->name() == "Calorimeter") {
941 name = "DetZside";
942 } else if (top_dict->name() == "LArCalorimeter") {
943 name = "part";
944 } else if (top_dict->name() == "MuonSpectrometer") {
945 name = "stationName";
946 } else if (top_dict->name() == "TileCalorimeter") {
947 name = "section";
948 } else if (top_dict->name() == "ForwardDetectors") {
949 name = "part";
950 }
951 // While we're here, save the index to the sub-detector level
952 // ("part" for InDet)
953 field = top_dict->find_field(name);
954 if (field) {
955 m_SUBDET_INDEX = field->index();
956 }
957 else {
958 ATH_MSG_ERROR("initLevelsFromDict - unable to find field " << name << " from dict "<< top_dict->name());
959 return 1;
960 }
961 } else {
962 ATH_MSG_ERROR("initLevelsFromDict - no top dictionary defined");
963 return 1;
964 }
965
966 // Set the field implementations
967
968 size_type region_index = m_helper->pixel_region_index();
969 if (m_indet_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
970
971 const IdDictRegion& region = m_indet_dict->region(region_index);
972
973 // Detector
975
976 // Add on extra values to assure that one has a value per
977 // bit. This is needed to avoid an overflow decoding error
978 // when a pixel channel id is decoded
979 if (not m_det_impl.ored_field().isEnumerated()) {
980 ATH_MSG_ERROR("initLevelsFromDict - ERROR det implementation is not enumerated: "
981 << m_det_impl.show_to_string());
982 return 1;
983 }
984
985 size_type bits = m_det_impl.bits();
986 size_type nvalues = static_cast<size_type>(1) << bits;
987 Range::field det = m_det_impl.ored_field();
988 size_type max = det.get_maximum();
989 for (size_type i = det.get_values().size(); i < nvalues; ++i) {
990 ++max;
991 det.add_value(max);
992 }
993 // Replace ored field with modified one
994 m_det_impl.set_ored_field(det);
995 ATH_MSG_VERBOSE("set extra bits "<< m_det_impl.show_to_string());
996
997 // InDet part
999 }
1000
1001 // Calo side: LVL1, LAr & Tile DeadMat
1002 region_index = m_helper->lvl1_region_index();
1003 if (m_calo_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
1004 const IdDictRegion& region = m_calo_dict->region(region_index);
1006 }
1007
1008 // LAr part
1009 region_index = m_helper->lar_em_region_index();
1010 if (m_lar_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
1011 const IdDictRegion& region = m_lar_dict->region(region_index);
1013 }
1014
1015 // LAr part
1016 region_index = m_helper->lar_fcal_region_index();
1017 if (m_lar_dict && AtlasDetectorIDHelper::UNDEFINED != region_index &&
1018 m_LAR_FCAL_MODULE_INDEX != 999) {
1019 const IdDictRegion& region = m_lar_dict->region(region_index);
1021 }
1022
1023 // Muon station name
1024 region_index = m_helper->mdt_region_index();
1025 if (m_muon_dict && AtlasDetectorIDHelper::UNDEFINED != region_index) {
1026 const IdDictRegion& region = m_muon_dict->region(region_index);
1028 // Muon MDT
1030 // Muon RPC
1031 region_index = m_helper->rpc_region_index();
1032 if (AtlasDetectorIDHelper::UNDEFINED != region_index) {
1033 const IdDictRegion& rpc_region = m_muon_dict->region(region_index);
1035 }
1036 }
1037 return 0;
1038}
1039
1040
1043{
1045 return (result << m_INDET_ID);
1046}
1047
1050{
1052 return (result << m_LAR_ID);
1053}
1054
1057{
1059 return (result << m_TILE_ID);
1060}
1061
1064{
1066 return (result << m_MUON_ID);
1067}
1068
1071{
1073 return (result << m_CALO_ID);
1074}
1075
1078{
1080 return (result << m_FWD_ID);
1081}
1082
1085{
1087 return (result << m_PIXEL_ID);
1088}
1089
1092{
1094 return (result << m_SCT_ID);
1095}
1096
1099{
1101 return (result << m_TRT_ID);
1102}
1103
1106{
1108 return (result << m_HGTD_ID);
1109}
1110
1113{
1115 return (result << m_LUMI_ID);
1116}
1117
1120{
1122 return (result << m_LAR_EM_ID);
1123}
1124
1127{
1129 return (result << m_LAR_HEC_ID);
1130}
1131
1134{
1136 return (result << m_LAR_FCAL_ID);
1137}
1138
1141{
1143 return (result << m_ALFA_ID);
1144}
1145
1148{
1150 return (result << m_BCM_ID);
1151}
1152
1155{
1157 return (result << m_LUCID_ID);
1158}
1159
1162{
1164 return (result << m_ZDC_ID);
1165}
#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
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
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
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
AtlasDetectorIDHelper * m_helper
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)
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
size_type end_index() const
Definition IdContext.h:46
const std::string & name() const
Dictionary name.
const IdDictField * find_field(const std::string &name) 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