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 
8 #include "IdDict/IdDictField.h"
9 #include "IdDict/IdDictGroup.h"
10 #include "IdDict/IdDictMgr.h"
11 #include "IdDict/IdDictRegion.h"
12 #include <iostream>
13 
15  AthMessaging("AtlasDetectorIDHelper") {
16 }
17 
18 int
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  IdDictGroup* group = dict->find_group(grp);
39  if (!group || !group->regions().size()) {
40  ATH_MSG_VERBOSE("The group "<<grp<<" is not present.");
41  regionIdx = UNDEFINED;
42  return;
43  }
44  regionIdx = group->regions().front()->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  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") {
68  m_isHighLuminosityLHC = true;
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
73  if (!m_isHighLuminosityLHC) {
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 }
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:101
IdDictMgr.h
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:25
IdDictDictionary::version
const std::string & version() const
Dictionary version.
Definition: IdDictDictionary.h:341
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:592
IdDictDictionary.h
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
IdDictField::index
size_t index() const
Definition: IdDictField.h:67
IdDictGroup.h
AtlasDetectorID::tile_exp
ExpandedIdentifier tile_exp(void) const
Definition: AtlasDetectorID.h:494
AtlasDetectorIDHelper::UNDEFINED
@ UNDEFINED
Definition: AtlasDetectorIDHelper.h:20
IdDictDictionary::find_field
IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:47
IdDictRegion
Definition: IdDictRegion.h:20
AtlasDetectorIDHelper::AtlasDetectorIDHelper
AtlasDetectorIDHelper()
Definition: AtlasDetectorIDHelper.cxx:14
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
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
IdDictMgr
Definition: IdDictMgr.h:15
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name) const
Definition: IdDictDictionary.cxx:115
IdDictMgr::find_dictionary
IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Definition: IdDictMgr.cxx:124
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:599
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:578
AtlasDetectorID::sct_exp
ExpandedIdentifier sct_exp(void) const
Definition: AtlasDetectorID.h:529
AtlasDetectorIDHelper::initialize_from_dictionary
int initialize_from_dictionary(const IdDictMgr &dict_mgr)
Initialization from the identifier dictionary.
Definition: AtlasDetectorIDHelper.cxx:19
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:564
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
IdDictField.h
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:536
AtlasDetectorID::bcm_exp
ExpandedIdentifier bcm_exp(void) const
Definition: AtlasDetectorID.h:585
IdDictRegion::index
size_t index() const
Definition: IdDictRegion.h:168
AtlasDetectorID::lar_fcal_exp
ExpandedIdentifier lar_fcal_exp(void) const
Definition: AtlasDetectorID.h:571
IdDictRegion.h
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:522
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:557
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:52
AtlasDetectorIDHelper::m_station_field
IdDictField * m_station_field
Definition: AtlasDetectorIDHelper.h:119