ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasDetectorIDHelper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
10#include "IdDict/IdDictMgr.h"
11#include "IdDict/IdDictRegion.h"
12#include <iostream>
13
15 AthMessaging("AtlasDetectorIDHelper") {
16}
17
18int
20 if (m_initialized) return(0);
21
22 m_initialized = true;
23
24 AtlasDetectorID atlas_id ("", "");
25
26 const IdDictDictionary* dict = dict_mgr.find_dictionary("InnerDetector");
27
28 auto assignRegionFromAtlasID = [this, &dict](const ExpandedIdentifier& id,
29 size_type& regionIdx,
30 const std::string& techType) {
31 if (dict->find_region(id, regionIdx)) {
32 ATH_MSG_WARNING("initialize_from_dictionary - unable to find "<<techType<<" region index: id, reg "
33 << id << " " << regionIdx);
34 }
35 };
36
37 auto assignRegionIdxFromGrp = [this, &dict](const std::string& grp, size_type& regionIdx) {
38 const IdDictGroup* group = dict->find_group(grp);
39 if (!group || !group->n_regions()) {
40 ATH_MSG_VERBOSE("The group "<<grp<<" is not present.");
41 regionIdx = UNDEFINED;
42 return;
43 }
44 regionIdx = group->region(0).index();
45 ATH_MSG_VERBOSE("Region index for "<<grp<<" will be assigned to "<<regionIdx);
46
47 };
48
49 auto assignRegionIdxFromRegion = [this, &dict](const std::string& grp, size_type& regionIdx) {
50 const IdDictRegion* region = dict->find_region(grp);
51 if (!region) {
52 ATH_MSG_VERBOSE("The group "<<grp<<" is not present.");
53 regionIdx = UNDEFINED;
54 return;
55 }
56 regionIdx = region->index();
57 ATH_MSG_VERBOSE("Region index for "<<grp<<" will be assigned to "<<regionIdx);
58 };
59
60
61 if (!dict) {
62 ATH_MSG_ERROR("initialize_from_dictionary - cannot access InnerDetector dictionary");
63 return 1;
64 }
65
66 // Check if this is High Luminosity LHC layout
67 if (dict->version() == "ITkHGTD" || dict->version() == "ITkHGTDPLR" || dict->version() == "P2-RUN4") {
69 }
70 assignRegionFromAtlasID(atlas_id.pixel_exp(), m_pixel_region_index, "pixel");
71 // for High Luminosity LHC layout one cannot get the sct region as below, nor
72 // is there any trt regions
74 assignRegionFromAtlasID(atlas_id.sct_exp(), m_sct_region_index, "sct");
75 assignRegionFromAtlasID(atlas_id.trt_exp(), m_trt_region_index, "trt");
76 }
77
78 dict = dict_mgr.find_dictionary("LArCalorimeter");
79 if (!dict) {
80 ATH_MSG_WARNING("initialize_from_dictionary - cannot access LArCalorimeter dictionary");
81 return 1;
82 }
83 assignRegionFromAtlasID(atlas_id.lar_em_exp(), m_lar_em_region_index, "lar_em");
84 assignRegionFromAtlasID(atlas_id.lar_hec_exp(), m_lar_hec_region_index, "lar_hec");
85 assignRegionFromAtlasID(atlas_id.lar_fcal_exp(), m_lar_fcal_region_index, "lar_fcal");
86 // Get Calorimetry dictionary for both LVL1 and Dead material
87 dict = dict_mgr.find_dictionary("Calorimeter");
88 if (!dict) {
89 ATH_MSG_WARNING("initialize_from_dictionary - cannot access Calorimeter dictionary");
90 return 1;
91 }
92 // Save index to a LVL1 region for unpacking
93 assignRegionIdxFromRegion("Lvl1_0", m_lvl1_region_index);
94 // Save index to a Dead Material region for unpacking
95 assignRegionIdxFromRegion("DM_4_1_0_0", m_dm_region_index);
96
97 dict = dict_mgr.find_dictionary("TileCalorimeter");
98 if (!dict) {
99 ATH_MSG_WARNING("initialize_from_dictionary - cannot access TileCalorimeter dictionary");
100 return 1;
101 }
102
103 assignRegionFromAtlasID(atlas_id.tile_exp(), m_tile_region_index, "tile");
104
105 dict = dict_mgr.find_dictionary("MuonSpectrometer");
106 if (!dict) {
107 ATH_MSG_WARNING("initialize_from_dictionary - cannot access MuonSpectrometer dictionary");
108 return 1;
109 }
110 m_station_field = dict->find_field("stationName");
111 if (!m_station_field) {
112 ATH_MSG_WARNING("initialize_from_dictionary - cannot access stationName field");
113 return 1;
114 } else {
116 }
117 assignRegionIdxFromGrp("mdt", m_mdt_region_index);
118 assignRegionIdxFromGrp("csc", m_csc_region_index);
119 assignRegionIdxFromGrp("rpc", m_rpc_region_index);
120 assignRegionIdxFromGrp("tgc", m_tgc_region_index);
121 assignRegionIdxFromGrp("mm", m_mm_region_index);
122 assignRegionIdxFromGrp("stgc", m_stgc_region_index);
123
124 dict = dict_mgr.find_dictionary("ForwardDetectors");
125 if (!dict) {
126 ATH_MSG_WARNING("initialize_from_dictionary - cannot access ForwardDetectors dictionary");
127 return 1;
128 }
129
130 assignRegionFromAtlasID(atlas_id.alfa_exp(), m_alfa_region_index, "alfa");
131 assignRegionFromAtlasID(atlas_id.bcm_exp(), m_bcm_region_index, "bcm");
132 assignRegionFromAtlasID(atlas_id.lucid_exp(), m_lucid_region_index, "lucid");
133 assignRegionFromAtlasID(atlas_id.zdc_exp(), m_zdc_region_index, "zdc");
134
135 ATH_MSG_VERBOSE( "AtlasDetectorIDHelper::initialize_from_dictionary ");
136 ATH_MSG_VERBOSE( " pixel_region_index " << m_pixel_region_index);
137 ATH_MSG_VERBOSE( " sct_region_index " << m_sct_region_index);
138 ATH_MSG_VERBOSE( " trt_region_index " << m_trt_region_index);
139 ATH_MSG_VERBOSE( " lar_em_region_index " << m_lar_em_region_index);
140 ATH_MSG_VERBOSE( " lar_hec_region_index " << m_lar_hec_region_index);
141 ATH_MSG_VERBOSE( " lar_fcal_region_index " << m_lar_fcal_region_index);
142 ATH_MSG_VERBOSE( " lvl1_region_index " << m_lvl1_region_index);
143 ATH_MSG_VERBOSE( " tile_region_index " << m_tile_region_index);
144 ATH_MSG_VERBOSE( " mdt_region_index " << m_mdt_region_index);
145 ATH_MSG_VERBOSE( " csc_region_index " << m_csc_region_index);
146 ATH_MSG_VERBOSE( " rpc_region_index " << m_rpc_region_index);
147 ATH_MSG_VERBOSE( " tgc_region_index " << m_tgc_region_index);
148 ATH_MSG_VERBOSE( " muon_station_index " << m_muon_station_index);
149 return 0;
150}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
const IdDictField * m_station_field
Identifier::size_type size_type
int initialize_from_dictionary(const IdDictMgr &dict_mgr)
Initialization from the identifier dictionary.
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
ExpandedIdentifier zdc_exp(void) const
ExpandedIdentifier bcm_exp(void) const
ExpandedIdentifier lar_em_exp(void) const
LAr.
ExpandedIdentifier sct_exp(void) const
ExpandedIdentifier pixel_exp(void) const
Inner Detector:
ExpandedIdentifier lar_hec_exp(void) const
ExpandedIdentifier lar_fcal_exp(void) const
ExpandedIdentifier trt_exp(void) const
ExpandedIdentifier tile_exp(void) const
ExpandedIdentifier lucid_exp(void) const
ExpandedIdentifier alfa_exp(void) const
Forward.
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
size_t index() const