ATLAS Offline Software
LArEM_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_LAREM_BASE_ID_H
17 #define CALOIDENTIFIER_LAREM_BASE_ID_H
18 
19 
26 #include "boost/range/iterator_range.hpp"
27 
28 
29 class IdDictRegion;
30 class LArEM_region;
31 
32 
33 
38 {
39 public:
41 
43  LArEM_Base_ID (const std::string& name, bool supercell);
44 
45  ~LArEM_Base_ID(void);
46 
48  Identifier region_id (const ExpandedIdentifier& exp_id) const;
49 
51  Identifier channel_id (const ExpandedIdentifier& exp_id) const;
52 
54  Identifier region_id (int barrel_ec, int sampling, int region ) const;
55  Identifier region_id (int barrel_ec, int sampling, int region, bool checks ) const;
56 
59  int eta, int phi ) const;
61  int eta, int phi, bool checks ) const;
62 
66 
69  Identifier channel_id (const Identifier regionId,
70  int eta, int phi ) const;
71  Identifier channel_id (const Identifier regionId,
72  int eta, int phi, bool checks ) const;
73 
78 
80  typedef std::vector<Identifier>::const_iterator id_iterator;
82  typedef boost::iterator_range<id_iterator> id_range;
83 
84 
86  id_iterator reg_begin (void) const;
88  id_iterator reg_end (void) const;
90  id_range reg_range () const;
91 
93  id_iterator em_begin (void) const;
95  id_iterator em_end (void) const;
97  id_range em_range () const;
98 
100  const std::vector<Identifier>& channel_ids() const;
101 
103  bool is_em_barrel (const Identifier id) const;
104 
106  bool is_em_endcap (const Identifier id) const;
107 
109  bool is_em_endcap_inner (const Identifier id) const;
110 
112  bool is_em_endcap_outer (const Identifier id) const;
113 
114 
115 
116 
130  int barrel_ec (const Identifier id)const;
131 
144  int sampling (const Identifier id)const;
145 
146 
170  int region (const Identifier id)const;
171 
229  int eta (const Identifier id)const;
230 
275  int phi (const Identifier id)const;
276 
277 
279  bool is_supercell (const Identifier id)const;
280 
281 
284  int eta_min(const Identifier regId) const;
287  int eta_max(const Identifier regId) const;
290  int phi_min(const Identifier regId) const;
293  int phi_max(const Identifier regId) const;
294 
295 
297  int initialize_base_from_dictionary (const IdDictMgr& dict_mgr,
298  const std::string& group_name);
299 
300 
303  bool twoSymSides() const;
304 
305 
319  int get_neighbours(const IdentifierHash id,
320  const LArNeighbours::neighbourOption& option,
321  std::vector<IdentifierHash>& neighbourList) const;
322 
323 
327  // Inherited from CaloIDHelper:
328  //
329  //Identifier channel_id (IdentifierHash hashId) const;
330  //Identifier region_id (IdentifierHash hashId) const;
331  //IdentifierHash region_hash (Identifier regionId) const;
332  //size_type channel_hash_max() const;
333  //size_type region_hash_max() const;
334  //IdContext channel_context() const;
335  //IdContext region_context() const;
336  //const std::vector<const IdDictRegion*>& dictRegions() const;
337  //float etaGranularity(const IdentifierHash regHash) const;
338  //float phiGranularity(const IdentifierHash regHash) const;
339  //float eta0(const IdentifierHash regHash) const;
340  //float phi0(const IdentifierHash regHash) const;
341  //virtual int get_id (const IdentifierHash& hash_id,
342  // Identifier& id,
343  // const IdContext* context = 0 ) const;
344  //virtual int get_hash (const Identifier& id,
345  // IdentifierHash& hash_id,
346  // const IdContext* context = 0 ) const;
347 
348 
349 private:
350  enum {NOT_VALID_HASH = 256000};
351 
352  // Check methods
353  void region_id_checks (int barrel_ec, int sampling, int region ) const;
354  void channel_id_checks (int barrel_ec, int sampling, int region,
355  int eta, int phi ) const;
356  void channel_id_checks (const Identifier regionId,
357  int eta, int phi ) const;
358 
360  virtual int get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
361 
362  int phi_min_init(const Identifier regId) const;
363 
364  int initLevelsFromDict (const std::string& group_name);
365  int init_hashes(void) ;
366 
367  static int get_prevInPhi(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
368  int& neighbourIndex, IdentifierHash* neighbList) ;
369 
370  static int get_nextInPhi(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
371  int& neighbourIndex, IdentifierHash* neighbList) ;
372 
373  int get_prevInEta(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& minHash,
374  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
375 
376  int get_nextInEta(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const float& gPhi, const unsigned int& maxHash,
377  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const;
378 
379  int get_prevInSamp(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
380  const double& gEta, const float& gPhi, const double& absEta,
381  int& neighbourIndex, IdentifierHash* neighbList) const;
382 
383  int get_nextInSamp(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
384  const double& gEta, const float& gPhi, const double& absEta,
385  int& neighbourIndex, IdentifierHash* neighbList) const;
386 
387  int get_prevInSubdet(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
388  const double& gEta, const float& gPhi, const double& absEta,
389  int& neighbourIndex, IdentifierHash* neighbList) const;
390 
391  int get_nextInSubdet(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
392  const double& gEta, const float& gPhi, const double& absEta,
393  int& neighbourIndex, IdentifierHash* neighbList) const;
394 
395 
396 
397  int init_neighbors(void) ;
398 
399 
400 private:
401  unsigned m_slar;
402 
404 
407 
417 
425 
427 
428  std::vector<int> m_vecOfPhiMin;
429 
435  class HashCalc
436  {
437  public:
439  m_hash(0),
440  m_etamin(0),
441  m_phimin(0),
442  m_nphi(0) {}
447  };
448  std::vector<HashCalc> m_hash_calcs;
449 
451 
452  std::vector<LArEM_region*> m_vecOfRegions;
453  std::vector<unsigned> m_cells; // stores starting hash number of each region, regions are ordered by hash so this array is ordered as well
454 
457 };
458 
459 
461 
462 
463 #endif // not CALOIDENTIFIER_LAREM_BASE_ID_H
LArNeighbours::neighbourOption
neighbourOption
Definition: LArNeighbours.h:12
LArEM_Base_ID::phi
int phi(const Identifier id) const
return phi according to :
LArEM_Base_ID::reg_range
id_range reg_range() const
Range over set of Region Identifiers.
LArEM_Base_ID::m_eta_impl
IdDictFieldImplementation m_eta_impl
Definition: LArEM_Base_ID.h:423
LArEM_Base_ID::phi_max
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
Definition: LArEM_Base_ID.cxx:125
LArEM_Base_ID::reg_end
id_iterator reg_end(void) const
end iterator over set of Region Identifiers
LArEM_Base_ID::m_ETA_INDEX
size_type m_ETA_INDEX
Definition: LArEM_Base_ID.h:414
LArEM_Base_ID::phi_min_init
int phi_min_init(const Identifier regId) const
Definition: LArEM_Base_ID.cxx:99
LArEM_Base_ID
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
Definition: LArEM_Base_ID.h:38
LArEM_Base_ID::m_slar_impl
IdDictFieldImplementation m_slar_impl
Definition: LArEM_Base_ID.h:426
LArEM_Base_ID::is_em_endcap_outer
bool is_em_endcap_outer(const Identifier id) const
test if the id belongs to the EM Endcap outer wheel
LArEM_Base_ID::HashCalc::m_nphi
size_type m_nphi
Definition: LArEM_Base_ID.h:446
index
Definition: index.py:1
LArEM_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
LArEM_Base_ID::init_neighbors
int init_neighbors(void)
Definition: LArEM_Base_ID.cxx:1314
LArEM_Base_ID::id_range
boost::iterator_range< id_iterator > id_range
Type for range over identifiers.
Definition: LArEM_Base_ID.h:82
LArID_Exception.h
LArEM_Base_ID::m_vecOfRegions
std::vector< LArEM_region * > m_vecOfRegions
Definition: LArEM_Base_ID.h:452
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
LArEM_Base_ID::region
int region(const Identifier id) const
return region according to :
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
LArEM_Base_ID::get_nextInSubdet
int get_nextInSubdet(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1251
CaloIDHelper::region_id
Identifier region_id(IdentifierHash hashId) const
Return the region Identifier for a given hash code (no checking).
LArEM_Base_ID::channel_id
Identifier channel_id(int barrel_ec, int sampling, int region, int eta, int phi, bool checks) const
LArEM_Base_ID::~LArEM_Base_ID
~LArEM_Base_ID(void)
Definition: LArEM_Base_ID.cxx:39
LArEM_Base_ID::init_hashes
int init_hashes(void)
Definition: LArEM_Base_ID.cxx:432
LArEM_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
LArEM_Base_ID::m_em_impl
IdDictFieldImplementation m_em_impl
Definition: LArEM_Base_ID.h:419
LArEM_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: LArEM_Base_ID.cxx:205
TrigVSI::AlgConsts::nPhi
constexpr int nPhi
Default bin number of phi for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:27
IdDictRegion
Definition: IdDictDefs.h:433
LArEM_Base_ID::channel_id
Identifier channel_id(const Identifier regionId, int eta, int phi) const
allows to build a cell id starting from a region id (e.g.
LArEM_Base_ID::eta
int eta(const Identifier id) const
return eta according to :
LArEM_Base_ID::get_nextInSamp
int get_nextInSamp(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1120
LArEM_Base_ID::LArEM_Base_ID
LArEM_Base_ID(const LArEM_Base_ID &)
LArEM_Base_ID::initLevelsFromDict
int initLevelsFromDict(const std::string &group_name)
Definition: LArEM_Base_ID.cxx:226
LArEM_Base_ID::get_prevInSamp
int get_prevInSamp(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1052
LArEM_Base_ID::m_sampling_impl
IdDictFieldImplementation m_sampling_impl
Definition: LArEM_Base_ID.h:421
LArEM_Base_ID::id_iterator
std::vector< Identifier >::const_iterator id_iterator
Type for iterators over identifiers.
Definition: LArEM_Base_ID.h:80
LArEM_Base_ID::m_full_em_range
MultiRange m_full_em_range
Definition: LArEM_Base_ID.h:406
CaloIDHelper::size_type
Identifier::size_type size_type
Definition: CaloIDHelper.h:39
LArEM_Base_ID::m_phi_impl
IdDictFieldImplementation m_phi_impl
Definition: LArEM_Base_ID.h:424
LArEM_region
This class provides an interface to deal with regions in the neighbours finding
Definition: LArEM_region.h:20
LArEM_Base_ID::operator=
LArEM_Base_ID & operator=(const LArEM_Base_ID &)
LArEM_Base_ID::eta_max
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
Definition: LArEM_Base_ID.cxx:78
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
LArEM_Base_ID::m_region_impl
IdDictFieldImplementation m_region_impl
Definition: LArEM_Base_ID.h:422
LArEM_Base_ID::size_type
Identifier::size_type size_type
Definition: LArEM_Base_ID.h:40
LArEM_Base_ID::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
LArEM_Base_ID::HashCalc
small class holding the starting hash value, the min eta and the number of phi bins of each region
Definition: LArEM_Base_ID.h:436
LArEM_Base_ID::region_id
Identifier region_id(int barrel_ec, int sampling, int region, bool checks) const
LArEM_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
CaloIDHelper
Base class to factor out code common among Calo ID helpers.
Definition: CaloIDHelper.h:34
LArEM_Base_ID::m_bec_reg_impl
IdDictFieldImplementation m_bec_reg_impl
Definition: LArEM_Base_ID.h:450
LArEM_Base_ID::channel_id
Identifier channel_id(int barrel_ec, int sampling, int region, int eta, int phi) const
build a cell identifier
LArEM_Base_ID::m_full_region_range
MultiRange m_full_region_range
Definition: LArEM_Base_ID.h:405
LArEM_Base_ID::HashCalc::HashCalc
HashCalc()
Definition: LArEM_Base_ID.h:438
LArEM_Base_ID::m_SAMPLING_INDEX
size_type m_SAMPLING_INDEX
Definition: LArEM_Base_ID.h:412
LArEM_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
LArEM_Base_ID::twoSymSides
bool twoSymSides() const
True if the + and - sides of the calorimeter are identical (true layout).
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
LArEM_Base_ID::region_id
Identifier region_id(int barrel_ec, int sampling, int region) const
build a region identifier
LArEM_Base_ID::m_lar_impl
IdDictFieldImplementation m_lar_impl
Definition: LArEM_Base_ID.h:418
LArEM_Base_ID::m_slar
unsigned m_slar
Definition: LArEM_Base_ID.h:401
LArEM_Base_ID::m_bec_impl
IdDictFieldImplementation m_bec_impl
Definition: LArEM_Base_ID.h:420
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
LArEM_Base_ID::get_prevInPhi
static int get_prevInPhi(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
Definition: LArEM_Base_ID.cxx:902
LArEM_Base_ID.icc
LArEM_Base_ID::eta_min
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
Definition: LArEM_Base_ID.cxx:52
LArEM_Base_ID::get_nextInPhi
static int get_nextInPhi(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
Definition: LArEM_Base_ID.cxx:917
LArEM_Base_ID::region_id_checks
void region_id_checks(int barrel_ec, int sampling, int region) const
Definition: LArEM_Base_ID.cxx:146
LArEM_Base_ID::m_EM_INDEX
size_type m_EM_INDEX
Definition: LArEM_Base_ID.h:410
MultiRange
A MultiRange combines several Ranges.
Definition: MultiRange.h:17
LArEM_Base_ID::m_cells
std::vector< unsigned > m_cells
Definition: LArEM_Base_ID.h:453
CaloIDHelper::name
const std::string & name() const
Return the name for this helper.
IdentifierHash.h
LArEM_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: LArEM_Base_ID.cxx:696
LArEM_Base_ID::barrel_ec
int barrel_ec(const Identifier id) const
return barrel_ec according to :
LArEM_Base_ID::get_prevInEta
int get_prevInEta(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
Definition: LArEM_Base_ID.cxx:932
LArEM_Base_ID::m_SLAR_INDEX
size_type m_SLAR_INDEX
Definition: LArEM_Base_ID.h:416
LArEM_Base_ID::em_end
id_iterator em_end(void) const
end iterator over full set of EM Identifiers
LArEM_Base_ID::m_PHI_INDEX
size_type m_PHI_INDEX
Definition: LArEM_Base_ID.h:415
LArEM_Base_ID::is_em_endcap_inner
bool is_em_endcap_inner(const Identifier id) const
test if the id belongs to the EM Endcap inner wheel
IdDictFieldImplementation.h
LArEM_Base_ID::HashCalc::m_phimin
size_type m_phimin
Definition: LArEM_Base_ID.h:445
LArEM_Base_ID::em_begin
id_iterator em_begin(void) const
begin iterator over full set of EM Identifiers
LArEM_Base_ID::channel_id
Identifier channel_id(const Identifier regionId, int eta, int phi, bool checks) const
LArEM_Base_ID::m_BEC_INDEX
size_type m_BEC_INDEX
Definition: LArEM_Base_ID.h:411
LArEM_Base_ID::m_two_sym_sides
bool m_two_sym_sides
Definition: LArEM_Base_ID.h:403
LArEM_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
CaloIDHelper.h
Base class to factor out code common among Calo ID helpers.
LArEM_Base_ID::HashCalc::m_etamin
size_type m_etamin
Definition: LArEM_Base_ID.h:444
LArEM_Base_ID::get_prevInSubdet
int get_prevInSubdet(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1183
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:234
LArEM_Base_ID::m_em_region_index
size_type m_em_region_index
Definition: LArEM_Base_ID.h:408
LArEM_Base_ID::get_nextInEta
int get_nextInEta(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &maxHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
Definition: LArEM_Base_ID.cxx:999
LArEM_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: LArEM_Base_ID.cxx:448
LArEM_Base_ID::channel_id_checks
void channel_id_checks(int barrel_ec, int sampling, int region, int eta, int phi) const
Definition: LArEM_Base_ID.cxx:162
Identifier::size_type
unsigned long long size_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:29
CaloIDHelper::id_range
boost::iterator_range< id_iterator > id_range
Type for range over identifiers.
Definition: CaloIDHelper.h:44
LArEM_Base_ID::channel_ids
const std::vector< Identifier > & channel_ids() const
provide access to channel id vector, accessed via hash
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
LArEM_Base_ID::em_range
id_range em_range() const
Range over full set of EM Identifiers.
CaloIDHelper::id_iterator
std::vector< Identifier >::const_iterator id_iterator
Type for iterators over identifiers.
Definition: CaloIDHelper.h:42
LArNeighbours.h
LArEM_Base_ID::reg_begin
id_iterator reg_begin(void) const
begin iterator over set of Region Identifiers
LArEM_Base_ID::m_vecOfPhiMin
std::vector< int > m_vecOfPhiMin
Definition: LArEM_Base_ID.h:428
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
LArEM_Base_ID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: LArEM_Base_ID.h:350
CaloIDHelper::region_hash
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
LArEM_Base_ID::m_LAR_INDEX
size_type m_LAR_INDEX
Definition: LArEM_Base_ID.h:409
LArEM_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
LArEM_Base_ID::m_REGION_INDEX
size_type m_REGION_INDEX
Definition: LArEM_Base_ID.h:413
LArEM_Base_ID::is_supercell
bool is_supercell(const Identifier id) const
Test if the identifier represents a supercell.
Definition: LArEM_Base_ID.cxx:46
LArEM_Base_ID::HashCalc::m_hash
IdentifierHash m_hash
Definition: LArEM_Base_ID.h:443
LArEM_Base_ID::is_em_endcap
bool is_em_endcap(const Identifier id) const
test if the id belongs to the EM Endcap
LArEM_Base_ID::LArEM_Base_ID
LArEM_Base_ID(const std::string &name, bool supercell)
Constructor.
Definition: LArEM_Base_ID.cxx:22
CaloIDHelper::channel_id
Identifier channel_id(IdentifierHash hashId) const
Return the channel (cell) Identifier for a given hash code (no checking).
LArEM_Base_ID::m_hash_calcs
std::vector< HashCalc > m_hash_calcs
Definition: LArEM_Base_ID.h:448
Identifier
Definition: IdentifierFieldParser.cxx:14