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 
17 #include "AthenaKernel/CLASS_DEF.h"
21 #include "IdDict/IdDictDefs.h"
22 
26 #include "boost/range/iterator_range.hpp"
27 
28 #include <vector>
29 #include <algorithm>
30 
31 
32 class Range;
33 class LArHEC_region;
34 
35 
41 {
42 public:
43 
45  LArHEC_Base_ID (const std::string& name,
46  const std::string& group,
47  bool supercell);
48 
50 
52  Identifier region_id (const ExpandedIdentifier& exp_id ) const ;
53 
55  Identifier channel_id (const ExpandedIdentifier& exp_id ) const ;
56 
58  Identifier region_id (int pos_neg, int sampling, int region ) const ;
59  Identifier region_id (int pos_neg, int sampling, int region, bool checks) const;
60 
63  int eta, int phi ) const;
65  int eta, int phi, bool checks) const;
66 
70  int eta, int phi ) const;
71 
82  Identifier channel_id ( int pos_neg, int sampling, int sector, int region,
83  int eta, int phi_sector ) const;
84 
88 
91  Identifier channel_id (const Identifier regionId,
92  int eta, int phi ) const ;
93  Identifier channel_id (const Identifier regionId,
94  int eta, int phi, bool checks) const;
95 
97  bool is_supercell (const Identifier id)const;
98 
103 
109  id_range reg_range () const;
110 
116  id_range hec_range () const;
117 
119  const std::vector<Identifier>& channel_ids() const;
121  const std::vector<Identifier>& region_ids() const;
122 
123 
125  int pos_neg (const Identifier id)const;
126 
128  int sampling (const Identifier id)const;
129 
131  int region (const Identifier id)const;
132 
134  int eta (const Identifier id)const;
135 
137  int phi (const Identifier id)const;
138 
141  int eta_min(const Identifier regId) const;
144  int eta_max(const Identifier regId) const;
147  int phi_min(const Identifier regId) const;
150  int phi_max(const Identifier regId) const;
151 
152 
154  int initialize_base_from_dictionary (const IdDictMgr& dict_mgr,
155  const std::string& group_name);
156 
159  bool twoSymSides() const;
160 
161 
173  int get_neighbours(const IdentifierHash id,
174  const LArNeighbours::neighbourOption& option,
175  std::vector<IdentifierHash>& neighbourList) const;
176 
177 
180  // Inherited from CaloIDHelper:
181  //
182  //Identifier channel_id (IdentifierHash hashId) const;
183  //Identifier region_id (IdentifierHash hashId) const;
184  //IdentifierHash region_hash (Identifier regionId) const;
185  //size_type channel_hash_max() const;
186  //size_type region_hash_max() const;
187  //IdContext channel_context() const;
188  //IdContext region_context() const;
189  //const std::vector<const IdDictRegion*>& dictRegions() const;
190  //float etaGranularity(const IdentifierHash regHash) const;
191  //float phiGranularity(const IdentifierHash regHash) const;
192  //float eta0(const IdentifierHash regHash) const;
193  //float phi0(const IdentifierHash regHash) const;
194  //virtual int get_id (const IdentifierHash& hash_id,
195  // Identifier& id,
196  // const IdContext* context = 0 ) const;
197  //virtual int get_hash (const Identifier& id,
198  // IdentifierHash& hash_id,
199  // const IdContext* context = 0 ) const;
200 
201 
202 private:
203 
204  enum {NOT_VALID_HASH = 64000};
205 
206  int phi_min_init(const Identifier regId) const;
207 
208  // Check methods
209 
210  void region_id_checks (int pos_neg, int sampling, int region ) const;
211  void channel_id_checks (int pos_neg, int sampling, int region,
212  int eta, int phi ) const;
213  void channel_id_checks (const Identifier regionId,
214  int eta, int phi ) const;
215 
217  virtual int get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
218 
219  int initLevelsFromDict (const std::string& group_name) ;
220 
221  int init_hashes();
222 
223  static int get_prevInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
224  int& neighbourIndex, IdentifierHash* neighbList) ;
225 
226  static int get_nextInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
227  int& neighbourIndex, IdentifierHash* neighbList) ;
228 
229  int get_prevInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& minHash,
230  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
231 
232  int get_nextInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& maxHash,
233  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
234 
235  int get_prevInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
236  const double& absEta,
237  int& neighbourIndex, IdentifierHash* neighbList) const;
238 
239  int get_nextInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
240  const double& absEta,
241  int& neighbourIndex, IdentifierHash* neighbList) const;
242 
243 
244  int init_neighbors();
245 
246 
247  unsigned m_slar;
248 
258 
261 
263 
264  std::vector<short int> m_vecOfPhiMin;
265 
271  class HashCalc
272  {
273  public:
275  m_hash(0),
276  m_etamin(0),
277  m_phimin(0),
278  m_nphi(0) {}
283  };
284  std::vector<HashCalc> m_hash_calcs;
285 
286 
295 
297 
298  std::vector<LArHEC_region*> m_vecOfRegions;
299  std::vector<short int> m_vecOfCellInfo;
300 };
301 
302 
304 
305 #endif // LARHEC_BASE_ID_H
LArHEC_Base_ID::m_sampling_impl
IdDictFieldImplementation m_sampling_impl
Definition: LArHEC_Base_ID.h:290
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:296
LArHEC_Base_ID::m_hec_impl
IdDictFieldImplementation m_hec_impl
Definition: LArHEC_Base_ID.h:288
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:299
LArHEC_Base_ID::region_id_checks
void region_id_checks(int pos_neg, int sampling, int region) const
Definition: LArHEC_Base_ID.cxx:395
LArHEC_Base_ID
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
Definition: LArHEC_Base_ID.h:41
LArHEC_Base_ID::m_slar
unsigned m_slar
Definition: LArHEC_Base_ID.h:247
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:969
index
Definition: index.py:1
LArHEC_Base_ID::m_POSNEG_INDEX
size_type m_POSNEG_INDEX
Definition: LArHEC_Base_ID.h:252
LArHEC_Base_ID::m_ETA_INDEX
size_type m_ETA_INDEX
Definition: LArHEC_Base_ID.h:255
LArHEC_Base_ID::m_phi_impl
IdDictFieldImplementation m_phi_impl
Definition: LArHEC_Base_ID.h:293
LArHEC_Base_ID::initLevelsFromDict
int initLevelsFromDict(const std::string &group_name)
Definition: LArHEC_Base_ID.cxx:472
LArHEC_Base_ID::m_HEC_INDEX
size_type m_HEC_INDEX
Definition: LArHEC_Base_ID.h:251
LArID_Exception.h
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
LArHEC_Base_ID::m_REGION_INDEX
size_type m_REGION_INDEX
Definition: LArHEC_Base_ID.h:254
LArHEC_Base_ID::HashCalc::m_nphi
size_type m_nphi
Definition: LArHEC_Base_ID.h:282
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:257
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:100
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:272
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:451
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
TauGNNUtils::Variables::Scalar::absEta
bool absEta(const xAOD::TauJet &tau, float &out)
Definition: TauGNNUtils.cxx:107
LArHEC_Base_ID::region_id
Identifier region_id(int pos_neg, int sampling, int region) const
build a region identifier for a channel
IdDictDefs.h
LArHEC_Base_ID::m_vecOfPhiMin
std::vector< short int > m_vecOfPhiMin
Definition: LArHEC_Base_ID.h:264
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:885
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
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:249
LArHEC_Base_ID::~LArHEC_Base_ID
~LArHEC_Base_ID()
Definition: LArHEC_Base_ID.cxx:48
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:704
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:289
LArHEC_Base_ID::m_region_impl
IdDictFieldImplementation m_region_impl
Definition: LArHEC_Base_ID.h:291
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:168
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:1081
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:27
LArHEC_Base_ID::phi_min_init
int phi_min_init(const Identifier regId) const
Definition: LArHEC_Base_ID.cxx:121
LArHEC_Base_ID::init_neighbors
int init_neighbors()
Definition: LArHEC_Base_ID.cxx:1138
LArHEC_Base_ID::eta_min
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
Definition: LArHEC_Base_ID.cxx:74
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:411
LArHEC_Base_ID::m_slar_impl
IdDictFieldImplementation m_slar_impl
Definition: LArHEC_Base_ID.h:294
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:121
LArHEC_Base_ID::m_lar_impl
IdDictFieldImplementation m_lar_impl
Definition: LArHEC_Base_ID.h:287
LArHEC_Base_ID::HashCalc::HashCalc
HashCalc()
Definition: LArHEC_Base_ID.h:274
LArHEC_Base_ID.icc
LArHEC_Base_ID::m_two_sym_sides
bool m_two_sym_sides
Definition: LArHEC_Base_ID.h:262
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:915
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:284
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:260
IdentifierHash.h
LArHEC_Base_ID::m_LAR_INDEX
size_type m_LAR_INDEX
Definition: LArHEC_Base_ID.h:250
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:253
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:900
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:30
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:279
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:281
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:256
LArHEC_Base_ID::HashCalc::m_etamin
size_type m_etamin
Definition: LArHEC_Base_ID.h:280
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:690
LArHEC_Base_ID::m_full_channel_range
MultiRange m_full_channel_range
Definition: LArHEC_Base_ID.h:259
LArHEC_Base_ID::m_vecOfRegions
std::vector< LArHEC_region * > m_vecOfRegions
Definition: LArHEC_Base_ID.h:298
LArHEC_Base_ID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: LArHEC_Base_ID.h:204
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:1021
LArHEC_Base_ID::phi_max
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
Definition: LArHEC_Base_ID.cxx:147
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:292
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