ATLAS Offline Software
CaloIDHelper.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-2024 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef CALOIDENTIFIER_CALOIDHELPER_H
14 #define CALOIDENTIFIER_CALOIDHELPER_H
15 
16 
18 #include "Identifier/Identifier.h"
20 #include "Identifier/MultiRange.h" //used in the icc file
22 #include "boost/range/iterator_range.hpp"
23 #include <vector>
24 #include <set>
25 class IMessageSvc;
26 class IdDictRegion;
27 
28 
33  : public AtlasDetectorID
34 {
35 public:
36  enum { NOT_VALID=999999 };
37 
38 
40 
42  typedef std::vector<Identifier>::const_iterator id_iterator;
44  typedef boost::iterator_range<id_iterator> id_range;
45 
46 
47 
59  class HashGroup
60  {
61  public:
66  HashGroup();
67 
68 
79  template <class T>
80  int init (T& parent,
81  const std::string& type,
82  const MultiRange& full_range,
83  Identifier (T::*idfunc) (const ExpandedIdentifier&) const,
85 
86 
99  int init (const std::string& name,
100  const std::set<Identifier>& ids,
102  IMessageSvc* msgSvc,
103  const MultiRange* full_range = 0);
104 
105 
108 
112  id_iterator end() const;
114  id_range range() const;
115 
117  Identifier id (IdentifierHash hashId) const;
118 
119 
127  int get_hash (Identifier id, IdentifierHash& hash_id) const;
128 
129 
139 
141  const std::vector<Identifier>& ids() const;
142 
145 
147  IdContext context() const;
148 
149 
150  private:
152  std::vector<Identifier> m_id_vec;
153 
156  };
157 
158 
166  CaloIDHelper (const std::string& name);
167 
168 
170  const HashGroup& channels() const;
171 
173  const HashGroup& regions() const;
174 
179 
180 
186 
187 
193 
194 
208  virtual int get_id (const IdentifierHash& hash_id,
209  Identifier& id,
210  const IdContext* context = 0 ) const;
211 
212 
228  virtual int get_hash (const Identifier& id,
229  IdentifierHash& hash_id,
230  const IdContext* context = 0 ) const;
231 
232 
237 
238 
243 
244 
246  const std::vector<const IdDictRegion*>& dictRegions() const;
247 
248 
253  float etaGranularity(const IdentifierHash regHash) const;
254 
255 
260  float phiGranularity(const IdentifierHash regHash) const;
261 
262 
267  float eta0(const IdentifierHash regHash) const;
268 
269 
274  float phi0(const IdentifierHash regHash) const;
275 
276 
278  const std::string& name() const;
279 
281  IMessageSvc* msgSvc();
282 
283 
284 
285 protected:
292  int initialize_base_from_dictionary (const IdDictMgr& dict_mgr,
293  const std::string& dict_name);
294 
295 
300 
301 
303  const IdDictDictionary* dict() const;
304 
305 
312  int fill_vec_of_dict_regions (const std::string& group_name = "");
313 
314 
323  virtual int get_expanded_id (const Identifier& id,
324  ExpandedIdentifier& exp_id,
325  const IdContext* context) const = 0;
326 
327 
328 private:
330  std::string m_name;
331 
334 
337 
340 
342  std::vector<const IdDictRegion*> m_vecOfDictRegions;
343 };
344 
345 
347 
348 
349 #endif // not CALOIDENTIFIER_CALOIDHELPER_H
CaloIDHelper::m_name
std::string m_name
Name of this helper.
Definition: CaloIDHelper.h:330
CaloIDHelper::HashGroup::m_id_vec
std::vector< Identifier > m_id_vec
List of Identifiers for this group.
Definition: CaloIDHelper.h:152
CaloIDHelper::HashGroup::m_end_index
size_type m_end_index
Ending index for this group's context.
Definition: CaloIDHelper.h:155
CaloIDHelper::NOT_VALID
@ NOT_VALID
Definition: CaloIDHelper.h:36
CaloIDHelper::channel_context
IdContext channel_context() const
Return the context for channels (cells).
CaloIDHelper::HashGroup::end
id_iterator end() const
Return an end iterator over the group's Identifiers.
CaloIDHelper::HashGroup::range
id_range range() const
Return an iterator range over the group's Identifiers.
CaloIDHelper::channel_hash_max
size_type channel_hash_max() const
One more than the largest channel (cell) hash code.
CaloIDHelper::fill_vec_of_dict_regions
int fill_vec_of_dict_regions(const std::string &group_name="")
Initialize the list of detector regions.
Definition: CaloIDHelper.cxx:259
CaloIDHelper::HashGroup::init
int init(T &parent, const std::string &type, const MultiRange &full_range, Identifier(T::*idfunc)(const ExpandedIdentifier &) const, size_type end_index)
Initialize.
CaloIDHelper::HashGroup::end_index
size_type end_index() const
Return the ending index of the context for this group.
CaloIDHelper::region_context
IdContext region_context() const
Return the context for regions.
CaloIDHelper::HashGroup::id
Identifier id(IdentifierHash hashId) const
Return the identifier for a given hash code (no checking).
CaloIDHelper::HashGroup::begin
id_iterator begin() const
Return a begin iterator over the group's Identifiers.
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
CaloIDHelper::get_id
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const
Convert a hash code to an Identifier for either channels or regions, depending on the context.
Definition: CaloIDHelper.cxx:119
CaloIDHelper::region_id
Identifier region_id(IdentifierHash hashId) const
Return the region Identifier for a given hash code (no checking).
CaloIDHelper::regions
HashGroup & regions()
Return the HashGroup for regions. non-const.
CaloIDHelper::CaloIDHelper
CaloIDHelper(const std::string &name)
Constructor.
Definition: CaloIDHelper.cxx:99
CaloIDHelper::HashGroup::get_hash
int get_hash(Identifier id, IdentifierHash &hash_id) const
Look up the hash code corresponding to an Identifier.
Definition: CaloIDHelper.cxx:68
IdDictRegion
Definition: IdDictDefs.h:433
CaloIDHelper::regions
const HashGroup & regions() const
Return the HashGroup for regions.
CaloIDHelper::size_type
Identifier::size_type size_type
Definition: CaloIDHelper.h:39
CaloIDHelper::m_vecOfDictRegions
std::vector< const IdDictRegion * > m_vecOfDictRegions
List of IdDictRegion objects.
Definition: CaloIDHelper.h:342
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
CaloIDHelper::region_hash_max
size_type region_hash_max() const
One more than the largest region hash code.
CaloIDHelper::etaGranularity
float etaGranularity(const IdentifierHash regHash) const
Return the eta granularity of a region, or NOT_VALID.
Definition: CaloIDHelper.cxx:185
CaloIDHelper::HashGroup::ids
const std::vector< Identifier > & ids() const
Return a vector of all Identifiers for this group.
CaloIDHelper::m_regions
HashGroup m_regions
Group of region Identifiers.
Definition: CaloIDHelper.h:336
CaloIDHelper::dict
const IdDictDictionary * dict() const
Return the dictionary for this subdetector.
CaloIDHelper
Base class to factor out code common among Calo ID helpers.
Definition: CaloIDHelper.h:34
CaloIDHelper::HashGroup::HashGroup
HashGroup()
Constructor.
Definition: CaloIDHelper.cxx:25
test_pyathena.parent
parent
Definition: test_pyathena.py:15
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
CaloIDHelper::HashGroup::hash
IdentifierHash hash(Identifier id) const
Look up the hash code corresponding to an Identifier.
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CaloIDHelper::initialize_base_from_dictionary
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &dict_name)
Do basic initialization of the helper.
Definition: CaloIDHelper.cxx:232
MultiRange
A MultiRange combines several Ranges.
Definition: MultiRange.h:17
CaloIDHelper::eta0
float eta0(const IdentifierHash regHash) const
Return the minimum eta of region, or NOT_VALID.
Definition: CaloIDHelper.cxx:207
CaloIDHelper::name
const std::string & name() const
Return the name for this helper.
IdentifierHash.h
RangeIterator.h
CaloIDHelper::get_hash
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const
Convert an Identifier to a hash code for either channels or regions, depending on the context.
Definition: CaloIDHelper.cxx:161
MultiRange.h
CaloIDHelper::m_dict
const IdDictDictionary * m_dict
The dictionary for this helper.
Definition: CaloIDHelper.h:339
IdDictDictionary
Definition: IdDictDefs.h:97
CaloIDHelper::channels
const HashGroup & channels() const
Return the HashGroup for channels (cells).
CaloIDHelper::msgSvc
IMessageSvc * msgSvc()
Return the message service for this helper (may be null).
CaloIDHelper::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
Convert a connected channel (cell) Identifier to a hash code.
CaloIDHelper::phi0
float phi0(const IdentifierHash regHash) const
Return the minimum phi of region, or NOT_VALID.
Definition: CaloIDHelper.cxx:218
CaloIDHelper::dictRegions
const std::vector< const IdDictRegion * > & dictRegions() const
Return the vector of IdDictRegion, accessed via region hash.
CaloIDHelper::m_channels
HashGroup m_channels
Group of channel (cell) Identifiers.
Definition: CaloIDHelper.h:333
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloIDHelper::HashGroup::context
IdContext context() const
Return the context for this group.
Definition: CaloIDHelper.cxx:83
CaloIDHelper::channels
HashGroup & channels()
Return the HashGroup for channels (cells). non-const.
CaloIDHelper::phiGranularity
float phiGranularity(const IdentifierHash regHash) const
Return the phi granularity of a region, or NOT_VALID.
Definition: CaloIDHelper.cxx:196
CaloIDHelper::get_expanded_id
virtual int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const =0
Create an expanded Identifier from an Identifier.
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
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
CaloIDHelper::HashGroup
Manage a list of identifiers.
Definition: CaloIDHelper.h:60
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
CaloIDHelper::region_hash
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
CaloIDHelper.icc
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
CaloIDHelper::HashGroup::hash_max
size_type hash_max() const
Return one more than the largest hash code.
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