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 #include "boost/range/iterator_range.hpp"
23 
24 #include <vector>
25 #include <algorithm>
26 
27 class Range;
28 class LArHEC_region;
29 
30 
36 {
37 public:
38 
40  LArHEC_Base_ID (const std::string& name,
41  const std::string& group,
42  bool supercell);
43 
45 
47  Identifier region_id (const ExpandedIdentifier& exp_id ) const ;
48 
50  Identifier channel_id (const ExpandedIdentifier& exp_id ) const ;
51 
53  Identifier region_id (int pos_neg, int sampling, int region ) const ;
54  Identifier region_id (int pos_neg, int sampling, int region, bool checks) const;
55 
58  int eta, int phi ) const;
60  int eta, int phi, bool checks) const;
61 
65  int eta, int phi ) const;
66 
77  Identifier channel_id ( int pos_neg, int sampling, int sector, int region,
78  int eta, int phi_sector ) const;
79 
83 
86  Identifier channel_id (const Identifier regionId,
87  int eta, int phi ) const ;
88  Identifier channel_id (const Identifier regionId,
89  int eta, int phi, bool checks) const;
90 
92  bool is_supercell (const Identifier id)const;
93 
98 
104  id_range reg_range () const;
105 
111  id_range hec_range () const;
112 
114  const std::vector<Identifier>& channel_ids() const;
116  const std::vector<Identifier>& region_ids() const;
117 
118 
120  int pos_neg (const Identifier id)const;
121 
123  int sampling (const Identifier id)const;
124 
126  int region (const Identifier id)const;
127 
129  int eta (const Identifier id)const;
130 
132  int phi (const Identifier id)const;
133 
136  int eta_min(const Identifier regId) const;
139  int eta_max(const Identifier regId) const;
142  int phi_min(const Identifier regId) const;
145  int phi_max(const Identifier regId) const;
146 
147 
149  int initialize_base_from_dictionary (const IdDictMgr& dict_mgr,
150  const std::string& group_name);
151 
154  bool twoSymSides() const;
155 
156 
168  int get_neighbours(const IdentifierHash id,
169  const LArNeighbours::neighbourOption& option,
170  std::vector<IdentifierHash>& neighbourList) const;
171 
172 
175  // Inherited from CaloIDHelper:
176  //
177  //Identifier channel_id (IdentifierHash hashId) const;
178  //Identifier region_id (IdentifierHash hashId) const;
179  //IdentifierHash region_hash (Identifier regionId) const;
180  //size_type channel_hash_max() const;
181  //size_type region_hash_max() const;
182  //IdContext channel_context() const;
183  //IdContext region_context() const;
184  //const std::vector<const IdDictRegion*>& dictRegions() const;
185  //float etaGranularity(const IdentifierHash regHash) const;
186  //float phiGranularity(const IdentifierHash regHash) const;
187  //float eta0(const IdentifierHash regHash) const;
188  //float phi0(const IdentifierHash regHash) const;
189  //virtual int get_id (const IdentifierHash& hash_id,
190  // Identifier& id,
191  // const IdContext* context = 0 ) const;
192  //virtual int get_hash (const Identifier& id,
193  // IdentifierHash& hash_id,
194  // const IdContext* context = 0 ) const;
195 
196 
197 private:
198 
199  enum {NOT_VALID_HASH = 64000};
200 
201  int phi_min_init(const Identifier regId) const;
202 
203  // Check methods
204 
205  void region_id_checks (int pos_neg, int sampling, int region ) const;
206  void channel_id_checks (int pos_neg, int sampling, int region,
207  int eta, int phi ) const;
208  void channel_id_checks (const Identifier regionId,
209  int eta, int phi ) const;
210 
212  virtual int get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
213 
214  int initLevelsFromDict (const std::string& group_name) ;
215 
216  int init_hashes();
217 
218  static int get_prevInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
219  int& neighbourIndex, IdentifierHash* neighbList) ;
220 
221  static int get_nextInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
222  int& neighbourIndex, IdentifierHash* neighbList) ;
223 
224  int get_prevInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& minHash,
225  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
226 
227  int get_nextInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& maxHash,
228  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
229 
230  int get_prevInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
231  const double& absEta,
232  int& neighbourIndex, IdentifierHash* neighbList) const;
233 
234  int get_nextInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
235  const double& absEta,
236  int& neighbourIndex, IdentifierHash* neighbList) const;
237 
238 
239  int init_neighbors();
240 
241 
242  unsigned m_slar;
243 
253 
256 
258 
259  std::vector<short int> m_vecOfPhiMin;
260 
266  class HashCalc
267  {
268  public:
270  m_hash(0),
271  m_etamin(0),
272  m_phimin(0),
273  m_nphi(0) {}
278  };
279  std::vector<HashCalc> m_hash_calcs;
280 
281 
290 
292 
293  std::vector<LArHEC_region*> m_vecOfRegions;
294  std::vector<short int> m_vecOfCellInfo;
295 };
296 
297 
299 
300 #endif // LARHEC_BASE_ID_H
LArHEC_Base_ID::m_sampling_impl
IdDictFieldImplementation m_sampling_impl
Definition: LArHEC_Base_ID.h:285
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:291
LArHEC_Base_ID::m_hec_impl
IdDictFieldImplementation m_hec_impl
Definition: LArHEC_Base_ID.h:283
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:294
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:36
LArHEC_Base_ID::m_slar
unsigned m_slar
Definition: LArHEC_Base_ID.h:242
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:247
LArHEC_Base_ID::m_ETA_INDEX
size_type m_ETA_INDEX
Definition: LArHEC_Base_ID.h:250
LArHEC_Base_ID::m_phi_impl
IdDictFieldImplementation m_phi_impl
Definition: LArHEC_Base_ID.h:288
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:246
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
LArHEC_Base_ID::m_REGION_INDEX
size_type m_REGION_INDEX
Definition: LArHEC_Base_ID.h:249
LArHEC_Base_ID::HashCalc::m_nphi
size_type m_nphi
Definition: LArHEC_Base_ID.h:277
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:252
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:267
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:259
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:14
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:244
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:284
LArHEC_Base_ID::m_region_impl
IdDictFieldImplementation m_region_impl
Definition: LArHEC_Base_ID.h:286
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:32
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
LArHEC_Base_ID::m_slar_impl
IdDictFieldImplementation m_slar_impl
Definition: LArHEC_Base_ID.h:289
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:121
LArHEC_Base_ID::m_lar_impl
IdDictFieldImplementation m_lar_impl
Definition: LArHEC_Base_ID.h:282
LArHEC_Base_ID::HashCalc::HashCalc
HashCalc()
Definition: LArHEC_Base_ID.h:269
LArHEC_Base_ID.icc
LArHEC_Base_ID::m_two_sym_sides
bool m_two_sym_sides
Definition: LArHEC_Base_ID.h:257
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:279
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:255
IdentifierHash.h
LArHEC_Base_ID::m_LAR_INDEX
size_type m_LAR_INDEX
Definition: LArHEC_Base_ID.h:245
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:248
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:274
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:276
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:251
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:275
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:254
LArHEC_Base_ID::m_vecOfRegions
std::vector< LArHEC_region * > m_vecOfRegions
Definition: LArHEC_Base_ID.h:293
LArHEC_Base_ID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: LArHEC_Base_ID.h:199
CaloIDHelper::id_range
boost::iterator_range< id_iterator > id_range
Type for range over identifiers.
Definition: CaloIDHelper.h:44
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
CaloIDHelper::id_iterator
std::vector< Identifier >::const_iterator id_iterator
Type for iterators over identifiers.
Definition: CaloIDHelper.h:42
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:287
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