ATLAS Offline Software
LArHEC_Base_ID.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef CALOIDENTIFIER_LARHEC_BASE_ID_H
14 #define CALOIDENTIFIER_LARHEC_BASE_ID_H
15 
16 
21 #include "AthenaKernel/CLASS_DEF.h"
22 
23 #include <vector>
24 #include <algorithm>
25 
26 class Range;
27 class LArHEC_region;
28 
29 
35 {
36 public:
37 
39  LArHEC_Base_ID (const std::string& name,
40  const std::string& group,
41  bool supercell);
42 
44 
46  Identifier region_id (const ExpandedIdentifier& exp_id ) const ;
47 
49  Identifier channel_id (const ExpandedIdentifier& exp_id ) const ;
50 
52  Identifier region_id (int pos_neg, int sampling, int region ) const ;
53  Identifier region_id (int pos_neg, int sampling, int region, bool checks) const;
54 
57  int eta, int phi ) const;
59  int eta, int phi, bool checks) const;
60 
64  int eta, int phi ) const;
65 
76  Identifier channel_id ( int pos_neg, int sampling, int sector, int region,
77  int eta, int phi_sector ) const;
78 
82 
85  Identifier channel_id (const Identifier regionId,
86  int eta, int phi ) const ;
87  Identifier channel_id (const Identifier regionId,
88  int eta, int phi, bool checks) const;
89 
91  bool is_supercell (const Identifier id)const;
92 
97 
103  id_range reg_range () const;
104 
110  id_range hec_range () const;
111 
113  const std::vector<Identifier>& channel_ids() const;
115  const std::vector<Identifier>& region_ids() const;
116 
117 
119  int pos_neg (const Identifier id)const;
120 
122  int sampling (const Identifier id)const;
123 
125  int region (const Identifier id)const;
126 
128  int eta (const Identifier id)const;
129 
131  int phi (const Identifier id)const;
132 
135  int eta_min(const Identifier regId) const;
138  int eta_max(const Identifier regId) const;
141  int phi_min(const Identifier regId) const;
144  int phi_max(const Identifier regId) const;
145 
146 
148  int initialize_base_from_dictionary (const IdDictMgr& dict_mgr,
149  const std::string& group_name);
150 
153  bool twoSymSides() const;
154 
155 
167  int get_neighbours(const IdentifierHash id,
168  const LArNeighbours::neighbourOption& option,
169  std::vector<IdentifierHash>& neighbourList) const;
170 
171 
174  // Inherited from CaloIDHelper:
175  //
176  //Identifier channel_id (IdentifierHash hashId) const;
177  //Identifier region_id (IdentifierHash hashId) const;
178  //IdentifierHash region_hash (Identifier regionId) const;
179  //size_type channel_hash_max() const;
180  //size_type region_hash_max() const;
181  //IdContext channel_context() const;
182  //IdContext region_context() const;
183  //const std::vector<const IdDictRegion*>& dictRegions() const;
184  //float etaGranularity(const IdentifierHash regHash) const;
185  //float phiGranularity(const IdentifierHash regHash) const;
186  //float eta0(const IdentifierHash regHash) const;
187  //float phi0(const IdentifierHash regHash) const;
188  //virtual int get_id (const IdentifierHash& hash_id,
189  // Identifier& id,
190  // const IdContext* context = 0 ) const;
191  //virtual int get_hash (const Identifier& id,
192  // IdentifierHash& hash_id,
193  // const IdContext* context = 0 ) const;
194 
195 
196 private:
197 
198  enum {NOT_VALID_HASH = 64000};
199 
200  int phi_min_init(const Identifier regId) const;
201 
202  // Check methods
203 
204  void region_id_checks (int pos_neg, int sampling, int region ) const;
205  void channel_id_checks (int pos_neg, int sampling, int region,
206  int eta, int phi ) const;
207  void channel_id_checks (const Identifier regionId,
208  int eta, int phi ) const;
209 
211  virtual int get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
212 
213  int initLevelsFromDict (const std::string& group_name) ;
214 
215  int init_hashes();
216 
217  static int get_prevInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
218  int& neighbourIndex, IdentifierHash* neighbList) ;
219 
220  static int get_nextInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
221  int& neighbourIndex, IdentifierHash* neighbList) ;
222 
223  int get_prevInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& minHash,
224  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
225 
226  int get_nextInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& maxHash,
227  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
228 
229  int get_prevInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
230  const double& absEta,
231  int& neighbourIndex, IdentifierHash* neighbList) const;
232 
233  int get_nextInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
234  const double& absEta,
235  int& neighbourIndex, IdentifierHash* neighbList) const;
236 
237 
238  int init_neighbors();
239 
240 
241  unsigned m_slar;
242 
252 
255 
257 
258  std::vector<short int> m_vecOfPhiMin;
259 
265  class HashCalc
266  {
267  public:
269  m_hash(0),
270  m_etamin(0),
271  m_phimin(0),
272  m_nphi(0) {}
277  };
278  std::vector<HashCalc> m_hash_calcs;
279 
280 
289 
291 
292  std::vector<LArHEC_region*> m_vecOfRegions;
293  std::vector<short int> m_vecOfCellInfo;
294 };
295 
296 
298 
299 #endif // LARHEC_BASE_ID_H
LArHEC_Base_ID::m_sampling_impl
IdDictFieldImplementation m_sampling_impl
Definition: LArHEC_Base_ID.h:284
LArHEC_Base_ID::channel_id
Identifier channel_id(const Identifier regionId, int eta, int phi) const
allows to build a channel id starting from a region id (e.g.
LArNeighbours::neighbourOption
neighbourOption
Definition: LArNeighbours.h:12
LArHEC_Base_ID::m_pn_reg_impl
IdDictFieldImplementation m_pn_reg_impl
Definition: LArHEC_Base_ID.h:290
LArHEC_Base_ID::m_hec_impl
IdDictFieldImplementation m_hec_impl
Definition: LArHEC_Base_ID.h:282
CaloIDHelper::id_iterator
std::vector< Identifier >::const_iterator id_iterator
Type for iterators over identifiers.
Definition: CaloIDHelper.h:42
LArHEC_Base_ID::hec_begin
id_iterator hec_begin() const
begin iterator over full set of Hec Identifiers for channels
LArHEC_Base_ID::eta
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
LArHEC_Base_ID::m_vecOfCellInfo
std::vector< short int > m_vecOfCellInfo
Definition: LArHEC_Base_ID.h:293
LArHEC_Base_ID::region_id_checks
void region_id_checks(int pos_neg, int sampling, int region) const
Definition: LArHEC_Base_ID.cxx:399
LArHEC_Base_ID
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
Definition: LArHEC_Base_ID.h:35
LArHEC_Base_ID::m_slar
unsigned m_slar
Definition: LArHEC_Base_ID.h:241
LArHEC_Base_ID::get_nextInEta
int get_nextInEta(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &maxHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
Definition: LArHEC_Base_ID.cxx:973
index
Definition: index.py:1
LArHEC_Base_ID::m_POSNEG_INDEX
size_type m_POSNEG_INDEX
Definition: LArHEC_Base_ID.h:246
LArHEC_Base_ID::m_ETA_INDEX
size_type m_ETA_INDEX
Definition: LArHEC_Base_ID.h:249
LArHEC_Base_ID::m_phi_impl
IdDictFieldImplementation m_phi_impl
Definition: LArHEC_Base_ID.h:287
LArHEC_Base_ID::initLevelsFromDict
int initLevelsFromDict(const std::string &group_name)
Definition: LArHEC_Base_ID.cxx:476
LArHEC_Base_ID::m_HEC_INDEX
size_type m_HEC_INDEX
Definition: LArHEC_Base_ID.h:245
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
LArHEC_Base_ID::m_REGION_INDEX
size_type m_REGION_INDEX
Definition: LArHEC_Base_ID.h:248
LArHEC_Base_ID::HashCalc::m_nphi
size_type m_nphi
Definition: LArHEC_Base_ID.h:276
CaloIDHelper::region_id
Identifier region_id(IdentifierHash hashId) const
Return the region Identifier for a given hash code (no checking).
LArHEC_Base_ID::m_SLAR_INDEX
size_type m_SLAR_INDEX
Definition: LArHEC_Base_ID.h:251
LArHEC_Base_ID::region_ids
const std::vector< Identifier > & region_ids() const
provide access to region id vector, accessed via hash
LArHEC_Base_ID::eta_max
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
Definition: LArHEC_Base_ID.cxx:104
LArHEC_Base_ID::channel_id
Identifier channel_id(int pos_neg, int sampling, int region, int eta, int phi, bool checks) const
LArHEC_Base_ID::hec_range
id_range hec_range() const
Range over full set of HEC Identifiers.
LArHEC_Base_ID::HashCalc
small class holding the starting hash value, the min eta and the number of phi bins of each region
Definition: LArHEC_Base_ID.h:266
LArHEC_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
LArHEC_Base_ID::get_expanded_id
virtual int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
Definition: LArHEC_Base_ID.cxx:455
LArHEC_Base_ID::reg_range
id_range reg_range() const
Range over set of Region Identifiers.
TrigVSI::AlgConsts::nPhi
constexpr int nPhi
Default bin number of phi for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:27
LArHEC_Base_ID::region_id
Identifier region_id(int pos_neg, int sampling, int region) const
build a region identifier for a channel
LArHEC_Base_ID::m_vecOfPhiMin
std::vector< short int > m_vecOfPhiMin
Definition: LArHEC_Base_ID.h:258
CaloIDHelper::size_type
Identifier::size_type size_type
Definition: CaloIDHelper.h:39
LArHEC_Base_ID::get_prevInPhi
static int get_prevInPhi(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
Definition: LArHEC_Base_ID.cxx:889
IdDictMgr
Definition: IdDictMgr.h:15
LArHEC_Base_ID::channel_hash_binary_search
IdentifierHash channel_hash_binary_search(Identifier channelId) const
create hash id from channel id – method NOT optimised, please use channel_hash() above
LArHEC_Base_ID::m_hec_region_index
size_type m_hec_region_index
Definition: LArHEC_Base_ID.h:243
LArHEC_Base_ID::~LArHEC_Base_ID
~LArHEC_Base_ID()
Definition: LArHEC_Base_ID.cxx:52
LArHEC_region
This class provides an interface to deal with regions in the neighbours finding
Definition: LArHEC_region.h:21
LArHEC_Base_ID::get_neighbours
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,...
Definition: LArHEC_Base_ID.cxx:708
CaloIDHelper
Base class to factor out code common among Calo ID helpers.
Definition: CaloIDHelper.h:34
LArHEC_Base_ID::hec_end
id_iterator hec_end() const
end iterator over full set of Hec Identifiers for channels
LArHEC_Base_ID::reg_end
id_iterator reg_end() const
end iterator over set of region Identifiers
LArHEC_Base_ID::m_pn_impl
IdDictFieldImplementation m_pn_impl
Definition: LArHEC_Base_ID.h:283
LArHEC_Base_ID::m_region_impl
IdDictFieldImplementation m_region_impl
Definition: LArHEC_Base_ID.h:285
LArHEC_Base_ID::initialize_base_from_dictionary
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &group_name)
initialization from the identifier dictionary
Definition: LArHEC_Base_ID.cxx:172
LArHEC_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
LArHEC_Base_ID::twoSymSides
bool twoSymSides() const
True if the + and - sides of the calorimeter are identical (true layout).
LArHEC_Base_ID::region_id
Identifier region_id(int pos_neg, int sampling, int region, bool checks) const
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
LArHEC_Base_ID::get_nextInSamp
int get_nextInSamp(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArHEC_Base_ID.cxx:1085
LArHEC_Base_ID::channel_id
Identifier channel_id(int pos_neg, int sampling, int region, int eta, int phi) const
build a cell identifier for a channel
AtlasDetectorID::group
const std::string & group() const
Group name for this helper.
Definition: AtlasDetectorID.cxx:34
LArHEC_Base_ID::phi_min_init
int phi_min_init(const Identifier regId) const
Definition: LArHEC_Base_ID.cxx:125
LArHEC_Base_ID::init_neighbors
int init_neighbors()
Definition: LArHEC_Base_ID.cxx:1142
LArHEC_Base_ID::eta_min
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
Definition: LArHEC_Base_ID.cxx:78
LArHEC_Base_ID::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
LArHEC_Base_ID::channel_id_checks
void channel_id_checks(int pos_neg, int sampling, int region, int eta, int phi) const
Definition: LArHEC_Base_ID.cxx:415
CaloIDHelper::id_range
std::ranges::subrange< id_iterator > id_range
Type for range over identifiers.
Definition: CaloIDHelper.h:44
LArHEC_Base_ID::m_slar_impl
IdDictFieldImplementation m_slar_impl
Definition: LArHEC_Base_ID.h:288
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:121
LArHEC_Base_ID::m_lar_impl
IdDictFieldImplementation m_lar_impl
Definition: LArHEC_Base_ID.h:281
LArHEC_Base_ID::HashCalc::HashCalc
HashCalc()
Definition: LArHEC_Base_ID.h:268
LArHEC_Base_ID.icc
LArHEC_Base_ID::m_two_sym_sides
bool m_two_sym_sides
Definition: LArHEC_Base_ID.h:256
LArHEC_Base_ID::region_id
Identifier region_id(const Identifier channelId) const
allows to know in which region is a channel/cell – valid for both kinds of channels
LArHEC_Base_ID::get_prevInEta
int get_prevInEta(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
Definition: LArHEC_Base_ID.cxx:919
MultiRange
A MultiRange combines several Ranges.
Definition: MultiRange.h:17
LArHEC_Base_ID::m_hash_calcs
std::vector< HashCalc > m_hash_calcs
Definition: LArHEC_Base_ID.h:278
CaloIDHelper::name
const std::string & name() const
Return the name for this helper.
LArHEC_Base_ID::m_full_region_range
MultiRange m_full_region_range
Definition: LArHEC_Base_ID.h:254
IdentifierHash.h
LArHEC_Base_ID::m_LAR_INDEX
size_type m_LAR_INDEX
Definition: LArHEC_Base_ID.h:244
LArHEC_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
LArHEC_Base_ID::m_SAMPLING_INDEX
size_type m_SAMPLING_INDEX
Definition: LArHEC_Base_ID.h:247
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
LArHEC_Base_ID::get_nextInPhi
static int get_nextInPhi(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
Definition: LArHEC_Base_ID.cxx:904
IdDictFieldImplementation.h
LArHEC_Base_ID::LArHEC_Base_ID
LArHEC_Base_ID(const std::string &name, const std::string &group, bool supercell)
Constructor.
Definition: LArHEC_Base_ID.cxx:34
LArHEC_Base_ID::is_supercell
bool is_supercell(const Identifier id) const
Test if the identifier represents a supercell.
LArHEC_Base_ID::HashCalc::m_hash
IdentifierHash m_hash
Definition: LArHEC_Base_ID.h:273
CaloIDHelper.h
Base class to factor out code common among Calo ID helpers.
LArHEC_Base_ID::HashCalc::m_phimin
size_type m_phimin
Definition: LArHEC_Base_ID.h:275
LArHEC_Base_ID::sampling
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
LArHEC_Base_ID::m_PHI_INDEX
size_type m_PHI_INDEX
Definition: LArHEC_Base_ID.h:250
TauScalarVars::absEta
bool absEta(const xAOD::TauJet &tau, float &out)
Definition: TauGNNDataLoader.cxx:118
LArHEC_Base_ID::HashCalc::m_etamin
size_type m_etamin
Definition: LArHEC_Base_ID.h:274
LArHEC_Base_ID::pos_neg
int pos_neg(const Identifier id) const
return pos_neg -2 (C side) or 2 (A side)
LArHEC_Base_ID::init_hashes
int init_hashes()
Definition: LArHEC_Base_ID.cxx:694
LArHEC_Base_ID::m_full_channel_range
MultiRange m_full_channel_range
Definition: LArHEC_Base_ID.h:253
LArHEC_Base_ID::m_vecOfRegions
std::vector< LArHEC_region * > m_vecOfRegions
Definition: LArHEC_Base_ID.h:292
LArHEC_Base_ID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: LArHEC_Base_ID.h:198
LArHEC_Base_ID::channel_id
Identifier channel_id(const Identifier regionId, int eta, int phi, bool checks) const
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
LArNeighbours.h
LArHEC_Base_ID::channel_ids
const std::vector< Identifier > & channel_ids() const
provide access to channel id vector, accessed via hash
LArHEC_Base_ID::reg_begin
id_iterator reg_begin() const
begin iterator over set of region Identifiers
LArHEC_Base_ID::get_prevInSamp
int get_prevInSamp(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArHEC_Base_ID.cxx:1025
LArHEC_Base_ID::phi_max
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
Definition: LArHEC_Base_ID.cxx:151
LArHEC_Base_ID::region
int region(const Identifier id) const
return region [0,1]
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
LArHEC_Base_ID::m_eta_impl
IdDictFieldImplementation m_eta_impl
Definition: LArHEC_Base_ID.h:286
CLASS_DEF.h
macros to associate a CLID to a type
LArHEC_Base_ID::phi
int phi(const Identifier id) const
return phi[0,63] outer part [0,31] inner part
CaloIDHelper::channel_id
Identifier channel_id(IdentifierHash hashId) const
Return the channel (cell) Identifier for a given hash code (no checking).
Identifier
Definition: IdentifierFieldParser.cxx:14