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