ATLAS Offline Software
Loading...
Searching...
No Matches
LArMiniFCAL_ID.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef LARMiniFCAL_ID_H
6#define LARMiniFCAL_ID_H
7
13#include <vector>
14#include <algorithm>
15#include <set>
16#include <ranges>
17class IdDictMgr;
18
19
48
49
51{
52public:
53
54 typedef Identifier::size_type size_type ;
55
57
59
62 bool is_initialized() const;
63
65 Identifier module_id (const ExpandedIdentifier& exp_id) const ;
66
68 Identifier channel_id (const ExpandedIdentifier& exp_id) const ;
69
71 Identifier module_id ( int pos_neg, int module ) const ;
72 Identifier module_id ( int pos_neg, int module, bool checks ) const ;
73
75 Identifier channel_id( int pos_neg, int module, int depth,
76 int eta, int phi ) const ;
77 Identifier channel_id( int pos_neg, int module, int depth,
78 int eta, int phi, bool checks ) const ;
79
82 Identifier module_id (const Identifier id ) const;
83
86 Identifier channel_id( const Identifier moduleId, int depth,
87 int eta, int phi) const ;
88 Identifier channel_id( const Identifier moduleId, int depth,
89 int eta, int phi, bool checks) const ;
90
91 bool is_supercell (const Identifier channelId) const;
92
94 Identifier module_id (IdentifierHash module_hash_id) const;
95
98
101
103 size_type module_hash_max () const;
104
106 using id_iterator = std::vector<Identifier>::const_iterator;
108 using id_range = std::ranges::subrange<id_iterator>;
109
111 id_iterator mod_begin () const;
113 id_iterator mod_end () const;
115 id_range mod_range () const;
116
120 id_iterator minifcal_end () const;
122 id_range minifcal_range () const;
123
125 const std::vector<Identifier>& channel_ids() const;
126
128 const std::vector<Identifier>& module_ids() const;
129
130
132 int pos_neg (const Identifier id)const;
134 int module (const Identifier id)const;
136 int depth (const Identifier id)const;
138 int eta (const Identifier id)const;
140 int phi (const Identifier id)const;
141
144 int eta_min(const Identifier regId) const;
147 int eta_max(const Identifier regId) const;
150 int phi_min(const Identifier regId) const;
153 int phi_max(const Identifier regId) const;
154
159 int get_neighbours(const IdentifierHash id, const LArNeighbours::neighbourOption& option, std::vector<IdentifierHash>& neighbourList) const;
160
163 IdContext module_context () const;
164
166 virtual int initialize_from_dictionary (const IdDictMgr& dict_mgr);
167
170 // Inherited from CaloIDHelper:
171 //
172 //Identifier channel_id (IdentifierHash hashId) const;
173 //Identifier region_id (IdentifierHash hashId) const;
174 //IdentifierHash channel_hash (Identifier channelId) const;
175 //IdentifierHash region_hash (Identifier regionId) const;
176 //size_type channel_hash_max() const;
177 //size_type region_hash_max() const;
178 //IdContext channel_context() const;
179 //IdContext region_context() const;
180 //const std::vector<const IdDictRegion*>& dictRegions() const;
181 //float etaGranularity(const IdentifierHash regHash) const;
182 //float phiGranularity(const IdentifierHash regHash) const;
183 //float eta0(const IdentifierHash regHash) const;
184 //float phi0(const IdentifierHash regHash) const;
185 //virtual int get_id (const IdentifierHash& hash_id,
186 // Identifier& id,
187 // const IdContext* context = 0 ) const;
188 //virtual int get_hash (const Identifier& id,
189 // IdentifierHash& hash_id,
190 // const IdContext* context = 0 ) const;
191
192
193private:
194
195
196 enum {NOT_VALID_HASH = 64000};
197
198 int phi_min_init(const Identifier regId) const;
199
200 std::vector<std::set<IdentifierHash> > m_neighbors_2d_vec;
201 std::vector<std::set<IdentifierHash> > m_neighbors_3d_next_vec;
202 std::vector<std::set<IdentifierHash> > m_neighbors_3d_prev_vec;
203
204 // Check methods
205
206 void module_id_checks ( int pos_neg, int module ) const;
207 void channel_id_checks ( int pos_neg, int module,
208 int depth, int eta, int phi ) const;
209 void channel_id_checks ( const Identifier moduleId,
210 int depth, int eta, int phi) const;
211
213 virtual int get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
214
215 int initLevelsFromDict();
216
217 int init_hashes();
218
219 int init_neighbors_from_file(const std::string& filename, std::vector<std::set<IdentifierHash> > &vec);
220
221 int init_neighbors_2d(const std::string& filename)
222 {
224 }
225
226 int init_neighbors_3d_next(const std::string& filename)
227 {
229 }
230
231 int init_neighbors_3d_prev(const std::string& filename)
232 {
234 }
235
236 int init_neighbors(const IdDictMgr& dict_mgr) ;
237
238 // flag to protect for when helper hasn't been able to be
239 // initialized - no description in xml dictionary
249
253
255
256 std::vector<short int> m_vecOfCellInfo;
257 std::vector<short int> m_vecOfPhiMin;
258
259
267
269
270};
271
272//using the macro below we can assign an identifier (and a version)
273//This is required and checked at compile time when you try to record/retrieve
274CLASS_DEF( LArMiniFCAL_ID , 79264204 , 1 )
275
276
277//--------------------
278// Inline definitions
279//--------------------
280
281//----------------------------------------------------------------------------
282inline bool
284{
285 return m_is_initialized;
286}
287
288//----------------------------------------------------------------------------
289inline Identifier
291{
292 return this->module_id ( exp_id[m_POSNEG_INDEX],
293 exp_id[m_MODULE_INDEX] );
294}
295
296//----------------------------------------------------------------------------
297inline Identifier
299{
300 return this->channel_id (exp_id[m_POSNEG_INDEX],
301 exp_id[m_MODULE_INDEX],
302 exp_id[m_DEPTH_INDEX],
303 exp_id[m_ETA_INDEX],
304 exp_id[m_PHI_INDEX]);
305}
306
307//----------------------------------------------------------------------------
308inline Identifier
309LArMiniFCAL_ID::module_id (int pos_neg, int module, bool checks) const
310{
311
313
314 // Do checks
315 if(checks) {
316 module_id_checks ( pos_neg, module );
317 }
318
319 // Pack fields independently
322 m_pn_impl.pack (pos_neg, result);
323 m_module_impl.pack (module, result);
324
325 return result;
326}
327
328inline Identifier
329LArMiniFCAL_ID::module_id (int pos_neg, int module) const
330{
331 return module_id (pos_neg, module, do_checks());
332}
333
334//----------------------------------------------------------------------------
335inline Identifier
337 int eta, int phi,
338 bool checks ) const
339{
340
341 // Do checks
342 if(checks) {
343 channel_id_checks( pos_neg, module, depth, eta, phi );
344 }
345
347 // Pack fields independently
350 m_pn_impl.pack (pos_neg, result);
351 m_module_impl.pack (module, result);
352 m_depth_impl.pack (depth, result);
353 m_eta_impl.pack (eta, result);
354 m_phi_impl.pack (phi, result);
355
356 return result;
357}
358
359inline Identifier
361 int eta, int phi ) const
362{
363 return channel_id (pos_neg, module, depth, eta, phi, do_checks());
364}
365
366//----------------------------------------------------------------------------
367inline Identifier
368LArMiniFCAL_ID::module_id ( const Identifier channelId ) const
369{
370
371 Identifier result(channelId);
372 // reset depth/eta/phi
373 m_depth_impl.reset(result);
374 m_eta_impl.reset(result);
375 m_phi_impl.reset(result);
376 return (result);
377}
378
379//----------------------------------------------------------------------------
380inline Identifier
382 int eta, int phi,
383 bool checks) const
384{
385 // Do checks
386 if(checks) {
388 }
389
391
392 // Reset the fields and then set the values
393 m_depth_impl.reset (result);
394 m_eta_impl.reset (result);
395 m_phi_impl.reset (result);
396 m_depth_impl.pack (depth, result);
397 m_eta_impl.pack (eta, result);
398 m_phi_impl.pack (phi, result);
399
400 return result;
401}
402
403inline Identifier
405 int eta, int phi) const
406{
407 return channel_id (module_id, depth, eta, phi, do_checks());
408}
409
410//----------------------------------------------------------------------------
412{
413 return region_id(module_hash_id);
414}
415
416//----------------------------------------------------------------------------
421
422//----------------------------------------------------------------------------
424{
425 return channel_hash (channelId);
426}
427
428//----------------------------------------------------------------------------
433
434//----------------------------------------------------------------------------
436{
437 return regions().begin();
438}
439
440//----------------------------------------------------------------------------
442{
443 return regions().end();
444}
445
446//----------------------------------------------------------------------------
448{
449 return regions().range();
450}
451
452//----------------------------------------------------------------------------
457
458//----------------------------------------------------------------------------
463
464//----------------------------------------------------------------------------
469
470//----------------------------------------------------------------------------
471inline const std::vector<Identifier>& LArMiniFCAL_ID::channel_ids() const
472{
473 return channels().ids();
474}
475
476//----------------------------------------------------------------------------
477inline const std::vector<Identifier>& LArMiniFCAL_ID::module_ids() const
478{
479 return regions().ids();
480}
481
482//----------------------------------------------------------------------------
483inline int LArMiniFCAL_ID::pos_neg (const Identifier id)const
484{
485 return (m_pn_impl.unpack(id));
486}
487
488//----------------------------------------------------------------------------
489inline int LArMiniFCAL_ID::module (const Identifier id)const
490{
491 return (m_module_impl.unpack(id));
492}
493
494//----------------------------------------------------------------------------
495inline int LArMiniFCAL_ID::depth (const Identifier id)const
496{
497 int result = m_depth_impl.unpack(id);
498 return(result);
499}
500
501//----------------------------------------------------------------------------
502inline int LArMiniFCAL_ID::eta (const Identifier id)const
503{
504 int result = m_eta_impl.unpack(id);
505 return(result);
506}
507
508//----------------------------------------------------------------------------
509inline int LArMiniFCAL_ID::phi(const Identifier id)const
510{
511 int result = m_phi_impl.unpack(id);
512 return(result);
513}
514
515//----------------------------------------------------------------------------
516inline int LArMiniFCAL_ID::phi_min(const Identifier modId) const
517{
518 IdentifierHash modHash = module_hash(modId);
519 unsigned int index = modHash;
520 return (m_vecOfPhiMin[index]);
521}
522
523//----------------------------------------------------------------------------
524inline bool LArMiniFCAL_ID::is_supercell(const Identifier /*channelId*/) const
525{
526 return false;
527}
528
529#endif // LARMiniFCAL_ID_H
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Base class to factor out code common among Calo ID helpers.
std::vector< size_t > vec
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
int lar_fcal_field_value() const
virtual bool do_checks(void) const override
Checks are performed by default in debug compilation and NOT in optimized compilation.
int lar_field_value() const
const std::vector< Identifier > & ids() const
Return a vector of all Identifiers for this group.
id_iterator end() const
Return an end iterator over the group's Identifiers.
id_iterator begin() const
Return a begin iterator over the group's Identifiers.
id_range range() const
Return an iterator range over the group's Identifiers.
const HashGroup & regions() const
Return the HashGroup for regions.
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
Identifier channel_id(IdentifierHash hashId) const
Return the channel (cell) Identifier for a given hash code (no checking).
size_type region_hash_max() const
One more than the largest region hash code.
IdentifierHash channel_hash(Identifier channelId) const
Convert a connected channel (cell) Identifier to a hash code.
CaloIDHelper(const std::string &name, const std::string &group)
Constructor.
Identifier region_id(IdentifierHash hashId) const
Return the region Identifier for a given hash code (no checking).
const HashGroup & channels() const
Return the HashGroup for channels (cells).
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
int unpack(Identifier id) const
Identifier manipulation methods.
This is a "hash" representation of an Identifier.
Helper class for LArMiniFCAL offline identifiers.
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
initialization from the identifier dictionary
size_type m_ETA_INDEX
IdDictFieldImplementation m_depth_impl
std::vector< short int > m_vecOfCellInfo
std::vector< Identifier >::const_iterator id_iterator
Type for iterators over identifiers.
void module_id_checks(int pos_neg, int module) const
id_iterator minifcal_end() const
end iterator over full set of Fcal Identifiers for channels
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
int init_neighbors_from_file(const std::string &filename, std::vector< std::set< IdentifierHash > > &vec)
size_type module_hash_max() const
region hash table max size
IdDictFieldImplementation m_phi_impl
IdentifierHash module_hash(Identifier module_id) const
create hash id from module 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 = all2D,...
id_iterator mod_end() const
end iterator over set of module Identifiers
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
IdDictFieldImplementation m_module_impl
id_iterator minifcal_begin() const
begin iterator over full set of Fcal Identifiers for channels
MultiRange m_full_depth_range
int depth(const Identifier id) const
depth [0,3]
bool is_initialized() const
check whether LArMiniFCAL ID helper has been initialized - returns false if description is not availa...
MultiRange m_full_module_range
IdDictFieldImplementation m_pn_mod_impl
IdentifierHash channel_hash_binary_search(Identifier channelId) const
create hash id from channel id – method NOT optimised, please use channel_hash() above
IdDictFieldImplementation m_pn_impl
int pos_neg(const Identifier id) const
pos_neg : +/- 2 (A/C side)
size_type m_POSNEG_INDEX
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
IdentifierHash channel_hash(Identifier channelId) const
Convert a connected channel (cell) Identifier to a hash code.
size_type m_PHI_INDEX
IdDictFieldImplementation m_lar_impl
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
bool is_supercell(const Identifier channelId) const
std::vector< short int > m_vecOfPhiMin
const std::vector< Identifier > & module_ids() const
provide access to module id vector, accessed via hash
id_range mod_range() const
range over set of module Identifiers
int init_neighbors_3d_next(const std::string &filename)
MultiRange m_full_channel_range
std::ranges::subrange< id_iterator > id_range
Type for range over identifiers.
size_type m_MiniFCAL_INDEX
int eta(const Identifier id) const
eta [0,63] module 1 ; [0,31] module 2 ; [0,15] module 3
IdContext module_context() const
context for modules – method kept for backward compatibility.
size_type m_LAR_INDEX
virtual int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
size_type m_fcal_region_index
IdDictFieldImplementation m_fcal_impl
IdDictFieldImplementation m_eta_impl
int phi_min_init(const Identifier regId) const
id_range minifcal_range() const
range over full set of Fcal Identifiers for channels
void channel_id_checks(int pos_neg, int module, int depth, int eta, int phi) const
std::vector< std::set< IdentifierHash > > m_neighbors_2d_vec
const std::vector< Identifier > & channel_ids() const
provide access to channel id vector, accessed via hash
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
int phi(const Identifier id) const
phi [0,15]
size_type m_DEPTH_INDEX
Identifier::size_type size_type
size_type m_MODULE_INDEX
int init_neighbors(const IdDictMgr &dict_mgr)
Identifier module_id(const ExpandedIdentifier &exp_id) const
module identifier for a channel from ExpandedIdentifier
int init_neighbors_3d_prev(const std::string &filename)
int init_neighbors_2d(const std::string &filename)
id_iterator mod_begin() const
begin iterator over set of module Identifiers
std::vector< std::set< IdentifierHash > > m_neighbors_3d_next_vec
std::vector< std::set< IdentifierHash > > m_neighbors_3d_prev_vec
A MultiRange combines several Ranges.
Definition MultiRange.h:17
std::string depth
tag string for intendation
Definition fastadd.cxx:46
Definition index.py:1