ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCell_Base_ID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
10
11
14#include "IdDict/IdDictMgr.h"
15
16
17CaloCell_Base_ID::CaloCell_Base_ID(const std::string& name,
18 const LArEM_Base_ID* em_id,
19 const LArHEC_Base_ID* hec_id,
20 const LArFCAL_Base_ID* fcal_id,
21 const LArMiniFCAL_ID* minifcal_id,
22 const Tile_Base_ID* tile_id,
23 bool supercell)
24 : AtlasDetectorID (name, ""),
25 m_emHelper(em_id),
26 m_hecHelper(hec_id),
27 m_fcalHelper(fcal_id),
28 m_minifcalHelper(minifcal_id),
29 m_tileHelper(tile_id),
32 m_caloNeighbours (nullptr),
33 m_supercell(supercell ? 1 : 0)
34{
35 m_helpers[LAREM] = em_id;
36 m_helpers[LARHEC] = hec_id;
37 m_helpers[LARFCAL] = fcal_id;
38 m_helpers[TILE] = tile_id;
39 m_helpers[LARMINIFCAL] = minifcal_id;
40
41 for (int i=0; i < NSUBCALO; i++) {
42 if (i == 0) {
43 m_cell_min[i] = 0;
44 m_reg_min[i] = 0;
45 }
46 else {
47 m_cell_min[i] = m_cell_max[i-1];
48 m_reg_min[i] = m_reg_max[i-1];
49 }
50
51 m_cell_max[i] = m_cell_min[i] + m_helpers[i]->channels().hash_max();
52 m_reg_max[i] = m_reg_min[i] + m_helpers[i]->regions().hash_max();
53 }
54
57
58 // count number of helpers with enabled neighbors and instantiate
59 // super neighbors in case this is more than 1
60
61 int nNeigh(0);
62
63 if ( m_emHelper->do_neighbours() ) nNeigh++;
64 if ( m_hecHelper->do_neighbours() ) nNeigh++;
65 if ( m_fcalHelper->do_neighbours() ) nNeigh++;
66 if ( m_minifcalHelper->do_neighbours() ) nNeigh++;
67 if ( m_tileHelper->do_neighbours() ) nNeigh++;
68
69 if ( nNeigh > 1 ) {
71 }
72}
73
74
79
80
82{
83 ATH_MSG_DEBUG("Initialize");
84
85 // Check whether this helper should be reinitialized
86 if (!reinitialize(dict_mgr)) {
87 ATH_MSG_DEBUG("Request to reinitialize not satisfied - tags have not changed");
88 return (0);
89 }
90 else {
91 ATH_MSG_DEBUG("(Re)initialize");
92 }
93
94 // init base object
95 if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
96
97 // Register version of the different dictionaries
98 if (register_dict_tag(dict_mgr, "LArCalorimeter")) return(1);
99 if (register_dict_tag(dict_mgr, "TileCalorimeter")) return(1);
100
101 //
102 // ... initialize cell / region vectors
103 //
104 m_region_vec.clear();
106
107 m_cell_vec.clear();
109
110 for (int i=0; i < NSUBCALO; i++) {
111 m_region_vec.insert (m_region_vec.end(),
112 m_helpers[i]->regions().begin(),
113 m_helpers[i]->regions().end());
114 m_cell_vec.insert (m_cell_vec.end(),
115 m_helpers[i]->channels().begin(),
116 m_helpers[i]->channels().end());
117 }
118 assert (m_region_vec.size() == m_region_hash_max);
119 assert (m_cell_vec.size() == m_cell_hash_max);
120
121 // initialize CaloCell neighbours
122 if(m_caloNeighbours) {
123 std::string neighbourFile;
124 if ( !m_supercell ) {
125 neighbourFile = dict_mgr.find_metadata("FULLATLASNEIGHBORS");
126 }
127 else {
128 // use this file name for Super Cells - should be replaced by db tag ...
129 neighbourFile = "SuperCaloNeighborsSuperCells-April2014.dat";
130 }
131 if (neighbourFile.empty()) throw std::runtime_error("CaloCell_ID: Cannot find the CaloNeighbour file name");
132 ATH_MSG_DEBUG("Initializing Super3D Neighbors from file " << neighbourFile);
133 m_caloNeighbours->initialize(this, neighbourFile);
134 }
135
136 return 0;
137}
138
139
141{
142 int calo_sampl = (int) Unknown;
143
144 if(m_emHelper->is_em_barrel(id)) {
145 calo_sampl = m_emHelper->sampling(id)+(int)PreSamplerB;
146 }
147 else if (m_emHelper->is_em_endcap_outer(id)) {
148 calo_sampl = m_emHelper->sampling(id)+(int)PreSamplerE;
149 }
150 else if (m_emHelper->is_em_endcap_inner(id)) {
151 calo_sampl = m_emHelper->sampling(id)+(int)EME1;
152 }
153
154 else if(m_hecHelper->is_lar_hec(id)) {
155 calo_sampl = m_hecHelper->sampling(id) + (int) HEC0;
156 }
157
158 else if(m_minifcalHelper->is_lar_minifcal(id)) {
159 // must do minifcal before fcal because miniFCAL IS FCAL
160 calo_sampl = m_minifcalHelper->depth(id) - 1 + (int) MINIFCAL0;
161 }
162 else if(m_fcalHelper->is_lar_fcal(id)) {
163 calo_sampl = m_fcalHelper->module(id) - 1 + (int) FCAL0;
164 }
165
166 else if (m_tileHelper->is_tile_barrel( id )) {
167 calo_sampl = TileBar0 + m_tileHelper->sample(id);
168 }
169
170 else if (m_tileHelper->is_tile_extbarrel( id )) {
171 calo_sampl = TileExt0 + m_tileHelper->sample(id);
172 }
173
174 else if (m_tileHelper->is_tile_gap( id )) {
175 calo_sampl = TileGap1 - 1 + m_tileHelper->sample(id);
176 }
177
178 return calo_sampl;
179}
180
182{
183 Identifier id = cell_id (caloHash);
184 return calo_sample(id);
185}
186
187
188int
190 const LArNeighbours::neighbourOption& option,
191 std::vector<IdentifierHash>& neighbourList) const
192{
193 int result = 1;
194
195 int subCalo = NOT_VALID;
196 IdentifierHash subHash = subcalo_cell_hash (caloHashId, subCalo);
197
198 switch (subCalo) {
199 case LAREM:
200 em_idHelper()->get_neighbours(subHash, option, neighbourList);
201 break;
202
203 case LARHEC:
204 hec_idHelper()->get_neighbours(subHash, option, neighbourList);
205 break;
206
207 case LARFCAL:
208 fcal_idHelper()->get_neighbours(subHash, option, neighbourList);
209 break;
210
211 case TILE:
212 tile_idHelper()->get_neighbours(subHash, option, neighbourList);
213 break;
214
215 case LARMINIFCAL:
216 minifcal_idHelper()->get_neighbours(subHash, option, neighbourList);
217 break;
218
219 default:
220 neighbourList.resize(0);
221 return result;
222 }
223
224 unsigned int shift = caloHashId - subHash;
225 int neighbourIndex = neighbourList.size();
226
227 if (neighbourIndex > 0) {
228 if (shift != 0) {
229 for (int iN = 0 ; iN <neighbourIndex ; ++iN) {
230 neighbourList[iN] += shift;
231 }
232 }
233 result = 0 ;
234 }
235
236 if ( m_caloNeighbours ) {
237 if ( (option & LArNeighbours::prevSuperCalo) ){
238 result = m_caloNeighbours->get_prevInCalo(caloHashId,neighbourList);
239 if ( result != 0 )
240 return result;
241 }
242
243 if ( (option & LArNeighbours::nextSuperCalo) ){
244 result = m_caloNeighbours->get_nextInCalo(caloHashId,neighbourList);
245 if ( result != 0 )
246 return result;
247 }
248 }
249
250 return result;
251}
252
253std::string CaloCell_Base_ID::cell_name(const Identifier id) const {
254 std::ostringstream s1;
256 s1 << (this->pos_neg(id) == 0 ? "/C-SIDE" : "/A-SIDE");
257 if (this->is_tile(id)) {
258 s1 << "/SECTION " << this->section(id) << "/SIDE " << this->side(id)
259 << "/MODULE " << this->module(id) << "/TOWER " << this->tower(id)
260 << "/SAMPLE " << this->sample(id);
261
262 } else {
263 s1 << "/REGION " << this->region(id) << "/IETA " << this->eta(id)
264 << "/iPHI " << this->phi(id);
265 }
266 return s1.str();
267}
268
269std::string
271 const IdContext *context /*= 0*/,
272 char sep /*= '.'*/) const
273{
274 if (is_em (id))
275 return m_emHelper->show_to_string (id, context, sep);
276 if (is_hec (id))
277 return m_hecHelper->show_to_string (id, context, sep);
278 if (is_fcal (id))
279 return m_fcalHelper->show_to_string (id, context, sep);
280 if (is_minifcal (id))
281 return m_minifcalHelper->show_to_string (id, context, sep);
282 if (is_tile (id))
283 return m_tileHelper->show_to_string (id, context, sep);
284 return "Unable to decode id";
285}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x)
Helper base class for offline cell identifiers.
@ Unknown
Definition TruthClasses.h:9
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
AtlasDetectorID(const std::string &name, const std::string &group)
std::string show_to_string(const Identifier id, const IdContext *context=0, char sep='.') const
std::string cell_name(const Identifier id) const
Returns the cell-location in a human readable form.
bool is_fcal(const Identifier id) const
test if the id belongs to the FCAL - true also for MiniFCAL
CaloNeighbours * m_caloNeighbours
std::array< size_type, NSUBCALO > m_reg_max
int section(const Identifier id) const
Tile field values (NOT_VALID == invalid request)
std::vector< Identifier > m_cell_vec
std::array< size_type, NSUBCALO > m_reg_min
int side(const Identifier id) const
Tile field values (NOT_VALID == invalid request)
int get_neighbours(const IdentifierHash caloHash, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found
std::array< const CaloIDHelper *, NSUBCALO > m_helpers
const LArHEC_Base_ID * m_hecHelper
bool is_minifcal(const Identifier id) const
test if the id belongs to the MiniFCAL
const LArFCAL_Base_ID * fcal_idHelper() const
access to FCAL idHelper
size_type m_region_hash_max
const LArHEC_Base_ID * hec_idHelper() const
access to HEC idHelper
const Tile_Base_ID * tile_idHelper() const
access to Tile idHelper
int sample(const Identifier id) const
Tile field values (NOT_VALID == invalid request)
const LArEM_Base_ID * em_idHelper() const
access to EM idHelper
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
int region(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
bool is_hec(const Identifier id) const
test if the id belongs to the HEC
std::array< size_type, NSUBCALO > m_cell_max
const LArMiniFCAL_ID * minifcal_idHelper() const
access to MiniFCAL idHelper
const LArFCAL_Base_ID * m_fcalHelper
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
const Tile_Base_ID * m_tileHelper
bool is_em(const Identifier id) const
test if the id belongs to LArEM
IdentifierHash subcalo_cell_hash(const Identifier cellId, int &subCalo) const
create hash id from 'global' cell id
CaloCell_Base_ID(const std::string &name, const LArEM_Base_ID *em_id, const LArHEC_Base_ID *hec_id, const LArFCAL_Base_ID *fcal_id, const LArMiniFCAL_ID *minifcal_id, const Tile_Base_ID *tile_id, bool supercell)
enumeration of samplings (i.e.layers) separately for various sub calorimeters
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
std::array< size_type, NSUBCALO > m_cell_min
int tower(const Identifier id) const
Tile field values (NOT_VALID == invalid request)
int calo_sample(const Identifier id) const
returns an int taken from Sampling enum and describing the subCalo to which the Id belongs.
const LArEM_Base_ID * m_emHelper
std::vector< Identifier > m_region_vec
const LArMiniFCAL_ID * m_minifcalHelper
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
const std::string & find_metadata(const std::string &name) const
Access to meta data, name/value pairs.
Definition IdDictMgr.cxx:87
This is a "hash" representation of an Identifier.
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
int get_neighbours(const IdentifierHash id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = prevInPhi,...
int get_neighbours(const IdentifierHash id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = all2D,...
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
int get_neighbours(const IdentifierHash id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = prevInPhi,...
Helper class for LArMiniFCAL offline identifiers.
int get_neighbours(const IdentifierHash id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = all2D,...
This class factors out code common between TileID and Tile_SuperCell_ID.
int get_neighbours(const IdentifierHash &id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = prevInPhi,...