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 /*
4  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id$
16 #ifndef CALOIDENTIFIER_LARHEC_BASE_ID_H
17 #define CALOIDENTIFIER_LARHEC_BASE_ID_H
18 
19 
20 #include "AthenaKernel/CLASS_DEF.h"
24 #include "IdDict/IdDictDefs.h"
25 
29 #include "boost/range/iterator_range.hpp"
30 
31 #include <vector>
32 #include <algorithm>
33 
34 
35 class Range;
36 class LArHEC_region;
37 
38 
44 {
45 public:
46 
48  LArHEC_Base_ID (const std::string& name, bool supercell);
49 
51 
53  Identifier region_id (const ExpandedIdentifier& exp_id ) const ;
54 
56  Identifier channel_id (const ExpandedIdentifier& exp_id ) const ;
57 
59  Identifier region_id (int pos_neg, int sampling, int region ) const ;
60  Identifier region_id (int pos_neg, int sampling, int region, bool checks) const;
61 
64  int eta, int phi ) const;
66  int eta, int phi, bool checks) const;
67 
71  int eta, int phi ) const;
72 
83  Identifier channel_id ( int pos_neg, int sampling, int sector, int region,
84  int eta, int phi_sector ) const;
85 
89 
92  Identifier channel_id (const Identifier regionId,
93  int eta, int phi ) const ;
94  Identifier channel_id (const Identifier regionId,
95  int eta, int phi, bool checks) const;
96 
98  bool is_supercell (const Identifier id)const;
99 
104 
106  id_iterator reg_begin (void) const;
108  id_iterator reg_end (void) const;
110  id_range reg_range () const;
111 
113  id_iterator hec_begin (void) const;
115  id_iterator hec_end (void) const;
117  id_range hec_range () const;
118 
120  const std::vector<Identifier>& channel_ids() const;
122  const std::vector<Identifier>& region_ids() const;
123 
124 
126  int pos_neg (const Identifier id)const;
127 
129  int sampling (const Identifier id)const;
130 
132  int region (const Identifier id)const;
133 
135  int eta (const Identifier id)const;
136 
138  int phi (const Identifier id)const;
139 
142  int eta_min(const Identifier regId) const;
145  int eta_max(const Identifier regId) const;
148  int phi_min(const Identifier regId) const;
151  int phi_max(const Identifier regId) const;
152 
153 
155  int initialize_base_from_dictionary (const IdDictMgr& dict_mgr,
156  const std::string& group_name);
157 
160  bool twoSymSides() const;
161 
162 
174  int get_neighbours(const IdentifierHash id,
175  const LArNeighbours::neighbourOption& option,
176  std::vector<IdentifierHash>& neighbourList) const;
177 
178 
181  // Inherited from CaloIDHelper:
182  //
183  //Identifier channel_id (IdentifierHash hashId) const;
184  //Identifier region_id (IdentifierHash hashId) const;
185  //IdentifierHash region_hash (Identifier regionId) const;
186  //size_type channel_hash_max() const;
187  //size_type region_hash_max() const;
188  //IdContext channel_context() const;
189  //IdContext region_context() const;
190  //const std::vector<const IdDictRegion*>& dictRegions() const;
191  //float etaGranularity(const IdentifierHash regHash) const;
192  //float phiGranularity(const IdentifierHash regHash) const;
193  //float eta0(const IdentifierHash regHash) const;
194  //float phi0(const IdentifierHash regHash) const;
195  //virtual int get_id (const IdentifierHash& hash_id,
196  // Identifier& id,
197  // const IdContext* context = 0 ) const;
198  //virtual int get_hash (const Identifier& id,
199  // IdentifierHash& hash_id,
200  // const IdContext* context = 0 ) const;
201 
202 
203 private:
204 
205  enum {NOT_VALID_HASH = 64000};
206 
207  int phi_min_init(const Identifier regId) const;
208 
209  // Check methods
210 
211  void region_id_checks (int pos_neg, int sampling, int region ) const;
212  void channel_id_checks (int pos_neg, int sampling, int region,
213  int eta, int phi ) const;
214  void channel_id_checks (const Identifier regionId,
215  int eta, int phi ) const;
216 
218  virtual int get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
219 
220  int initLevelsFromDict (const std::string& group_name) ;
221 
222  int init_hashes(void) ;
223 
224  static int get_prevInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
225  int& neighbourIndex, IdentifierHash* neighbList) ;
226 
227  static int get_nextInPhi(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
228  int& neighbourIndex, IdentifierHash* neighbList) ;
229 
230  int get_prevInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& minHash,
231  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
232 
233  int get_nextInEta(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& maxHash,
234  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
235 
236  int get_prevInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
237  const double& absEta,
238  int& neighbourIndex, IdentifierHash* neighbList) const;
239 
240  int get_nextInSamp(const LArHEC_region* hecRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
241  const double& absEta,
242  int& neighbourIndex, IdentifierHash* neighbList) const;
243 
244 
245  int init_neighbors(void) ;
246 
247 
248  unsigned m_slar;
249 
259 
262 
264 
265  std::vector<short int> m_vecOfPhiMin;
266 
272  class HashCalc
273  {
274  public:
276  m_hash(0),
277  m_etamin(0),
278  m_phimin(0),
279  m_nphi(0) {}
284  };
285  std::vector<HashCalc> m_hash_calcs;
286 
287 
296 
298 
299  std::vector<LArHEC_region*> m_vecOfRegions;
300  std::vector<short int> m_vecOfCellInfo;
301 };
302 
303 
305 
306 #endif // LARHEC_BASE_ID_H
LArHEC_Base_ID::m_sampling_impl
IdDictFieldImplementation m_sampling_impl
Definition: LArHEC_Base_ID.h:291
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:297
LArHEC_Base_ID::m_hec_impl
IdDictFieldImplementation m_hec_impl
Definition: LArHEC_Base_ID.h:289
LArHEC_Base_ID::eta
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
LArHEC_Base_ID::reg_begin
id_iterator reg_begin(void) const
begin iterator over set of region Identifiers
LArHEC_Base_ID::m_vecOfCellInfo
std::vector< short int > m_vecOfCellInfo
Definition: LArHEC_Base_ID.h:300
LArHEC_Base_ID::region_id_checks
void region_id_checks(int pos_neg, int sampling, int region) const
Definition: LArHEC_Base_ID.cxx:392
LArHEC_Base_ID
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
Definition: LArHEC_Base_ID.h:44
LArHEC_Base_ID::m_slar
unsigned m_slar
Definition: LArHEC_Base_ID.h:248
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:966
index
Definition: index.py:1
LArHEC_Base_ID::m_POSNEG_INDEX
size_type m_POSNEG_INDEX
Definition: LArHEC_Base_ID.h:253
LArHEC_Base_ID::m_ETA_INDEX
size_type m_ETA_INDEX
Definition: LArHEC_Base_ID.h:256
LArHEC_Base_ID::m_phi_impl
IdDictFieldImplementation m_phi_impl
Definition: LArHEC_Base_ID.h:294
LArHEC_Base_ID::initLevelsFromDict
int initLevelsFromDict(const std::string &group_name)
Definition: LArHEC_Base_ID.cxx:469
LArHEC_Base_ID::m_HEC_INDEX
size_type m_HEC_INDEX
Definition: LArHEC_Base_ID.h:252
LArID_Exception.h
LArHEC_Base_ID::reg_end
id_iterator reg_end(void) const
end iterator over set of region Identifiers
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
LArHEC_Base_ID::m_REGION_INDEX
size_type m_REGION_INDEX
Definition: LArHEC_Base_ID.h:255
LArHEC_Base_ID::HashCalc::m_nphi
size_type m_nphi
Definition: LArHEC_Base_ID.h:283
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:258
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:98
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:273
LArHEC_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
LArHEC_Base_ID::hec_end
id_iterator hec_end(void) const
end iterator over full set of Hec Identifiers for channels
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:448
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
IdDictDefs.h
LArHEC_Base_ID::m_vecOfPhiMin
std::vector< short int > m_vecOfPhiMin
Definition: LArHEC_Base_ID.h:265
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:882
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
IdDictMgr
Definition: IdDictDefs.h:32
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:250
LArHEC_Base_ID::~LArHEC_Base_ID
~LArHEC_Base_ID()
Definition: LArHEC_Base_ID.cxx:46
LArHEC_region
This class provides an interface to deal with regions in the neighbours finding
Definition: LArHEC_region.h:21
LArHEC_Base_ID::init_neighbors
int init_neighbors(void)
Definition: LArHEC_Base_ID.cxx:1135
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:701
CaloIDHelper
Base class to factor out code common among Calo ID helpers.
Definition: CaloIDHelper.h:34
LArHEC_Base_ID::m_pn_impl
IdDictFieldImplementation m_pn_impl
Definition: LArHEC_Base_ID.h:290
LArHEC_Base_ID::m_region_impl
IdDictFieldImplementation m_region_impl
Definition: LArHEC_Base_ID.h:292
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:166
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:1078
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
LArHEC_Base_ID::phi_min_init
int phi_min_init(const Identifier regId) const
Definition: LArHEC_Base_ID.cxx:119
LArHEC_Base_ID::eta_min
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
Definition: LArHEC_Base_ID.cxx:72
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:408
LArHEC_Base_ID::m_slar_impl
IdDictFieldImplementation m_slar_impl
Definition: LArHEC_Base_ID.h:295
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
LArHEC_Base_ID::m_lar_impl
IdDictFieldImplementation m_lar_impl
Definition: LArHEC_Base_ID.h:288
LArHEC_Base_ID::HashCalc::HashCalc
HashCalc()
Definition: LArHEC_Base_ID.h:275
LArHEC_Base_ID.icc
LArHEC_Base_ID::m_two_sym_sides
bool m_two_sym_sides
Definition: LArHEC_Base_ID.h:263
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:912
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:285
LArHEC_Base_ID::LArHEC_Base_ID
LArHEC_Base_ID(const std::string &name, bool supercell)
Constructor.
Definition: LArHEC_Base_ID.cxx:30
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:261
IdentifierHash.h
LArHEC_Base_ID::m_LAR_INDEX
size_type m_LAR_INDEX
Definition: LArHEC_Base_ID.h:251
LArHEC_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
LArHEC_Base_ID::hec_begin
id_iterator hec_begin(void) const
begin iterator over full set of Hec Identifiers for channels
LArHEC_Base_ID::m_SAMPLING_INDEX
size_type m_SAMPLING_INDEX
Definition: LArHEC_Base_ID.h:254
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:897
IdDictFieldImplementation.h
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:280
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:282
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:257
LArHEC_Base_ID::HashCalc::m_etamin
size_type m_etamin
Definition: LArHEC_Base_ID.h:281
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:234
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::m_full_channel_range
MultiRange m_full_channel_range
Definition: LArHEC_Base_ID.h:260
LArHEC_Base_ID::m_vecOfRegions
std::vector< LArHEC_region * > m_vecOfRegions
Definition: LArHEC_Base_ID.h:299
LArHEC_Base_ID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: LArHEC_Base_ID.h:205
LArHEC_Base_ID::init_hashes
int init_hashes(void)
Definition: LArHEC_Base_ID.cxx:687
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::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:1018
LArHEC_Base_ID::phi_max
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
Definition: LArHEC_Base_ID.cxx:145
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:293
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