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 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id$
16 #ifndef CALOIDENTIFIER_CALOIDHELPER_H
17 #define CALOIDENTIFIER_CALOIDHELPER_H
18 
19 
21 #include "Identifier/Identifier.h"
23 #include "boost/range/iterator_range.hpp"
24 #include <vector>
25 #include <set>
26 class MultiRange;
27 class IMessageSvc;
28 class IdDictRegion;
29 
30 
35  : public AtlasDetectorID
36 {
37 public:
38  enum { NOT_VALID=999999 };
39 
40 
42 
44  typedef std::vector<Identifier>::const_iterator id_iterator;
46  typedef boost::iterator_range<id_iterator> id_range;
47 
48 
49 
61  class HashGroup
62  {
63  public:
68  HashGroup();
69 
70 
81  template <class T>
82  int init (T& parent,
83  const std::string& type,
84  const MultiRange& full_range,
85  Identifier (T::*idfunc) (const ExpandedIdentifier&) const,
87 
88 
101  int init (const std::string& name,
102  const std::set<Identifier>& ids,
104  IMessageSvc* msgSvc,
105  const MultiRange* full_range = 0);
106 
107 
110 
114  id_iterator end() const;
116  id_range range() const;
117 
119  Identifier id (IdentifierHash hashId) const;
120 
121 
129  int get_hash (Identifier id, IdentifierHash& hash_id) const;
130 
131 
141 
143  const std::vector<Identifier>& ids() const;
144 
147 
149  IdContext context() const;
150 
151 
152  private:
154  std::vector<Identifier> m_id_vec;
155 
158  };
159 
160 
168  CaloIDHelper (const std::string& name);
169 
170 
172  const HashGroup& channels() const;
173 
175  const HashGroup& regions() const;
176 
181 
182 
188 
189 
195 
196 
210  virtual int get_id (const IdentifierHash& hash_id,
211  Identifier& id,
212  const IdContext* context = 0 ) const;
213 
214 
230  virtual int get_hash (const Identifier& id,
231  IdentifierHash& hash_id,
232  const IdContext* context = 0 ) const;
233 
234 
239 
240 
245 
246 
248  const std::vector<const IdDictRegion*>& dictRegions() const;
249 
250 
255  float etaGranularity(const IdentifierHash regHash) const;
256 
257 
262  float phiGranularity(const IdentifierHash regHash) const;
263 
264 
269  float eta0(const IdentifierHash regHash) const;
270 
271 
276  float phi0(const IdentifierHash regHash) const;
277 
278 
280  std::string name() const;
281 
283  IMessageSvc* msgSvc();
284 
285 
286 
287 protected:
294  int initialize_base_from_dictionary (const IdDictMgr& dict_mgr,
295  const std::string& dict_name);
296 
297 
302 
303 
305  const IdDictDictionary* dict() const;
306 
307 
314  int fill_vec_of_dict_regions (const std::string& group_name = "");
315 
316 
325  virtual int get_expanded_id (const Identifier& id,
326  ExpandedIdentifier& exp_id,
327  const IdContext* context) const = 0;
328 
329 
330 private:
332  std::string m_name;
333 
336 
339 
342 
344  std::vector<const IdDictRegion*> m_vecOfDictRegions;
345 };
346 
347 
349 
350 
351 #endif // not CALOIDENTIFIER_CALOIDHELPER_H
CaloIDHelper::m_name
std::string m_name
Name of this helper.
Definition: CaloIDHelper.h:332
CaloIDHelper::HashGroup::m_id_vec
std::vector< Identifier > m_id_vec
List of Identifiers for this group.
Definition: CaloIDHelper.h:154
CaloIDHelper::HashGroup::m_end_index
size_type m_end_index
Ending index for this group's context.
Definition: CaloIDHelper.h:157
CaloIDHelper::NOT_VALID
@ NOT_VALID
Definition: CaloIDHelper.h:38
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:108
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::name
std::string name() const
Return the name for this helper.
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:448
CaloIDHelper::regions
const HashGroup & regions() const
Return the HashGroup for regions.
CaloIDHelper::size_type
Identifier::size_type size_type
Definition: CaloIDHelper.h:41
CaloIDHelper::m_vecOfDictRegions
std::vector< const IdDictRegion * > m_vecOfDictRegions
List of IdDictRegion objects.
Definition: CaloIDHelper.h:344
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:338
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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:36
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: DetectorDescription/Identifier/Identifier/Range.h:351
CaloIDHelper::eta0
float eta0(const IdentifierHash regHash) const
Return the minimum eta of region, or NOT_VALID.
Definition: CaloIDHelper.cxx:207
IdentifierHash.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
CaloIDHelper::m_dict
const IdDictDictionary * m_dict
The dictionary for this helper.
Definition: CaloIDHelper.h:341
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:335
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloIDHelper::HashGroup::context
IdContext context() const
Return the context for this group.
Definition: CaloIDHelper.cxx:83
Identifier::size_type
IDENTIFIER_TYPE size_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:41
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.
CaloIDHelper::id_range
boost::iterator_range< id_iterator > id_range
Type for range over identifiers.
Definition: CaloIDHelper.h:46
IdentifierHash
Definition: IdentifierHash.h:38
CaloIDHelper::id_iterator
std::vector< Identifier >::const_iterator id_iterator
Type for iterators over identifiers.
Definition: CaloIDHelper.h:44
CaloIDHelper::HashGroup
Manage a list of identifiers.
Definition: CaloIDHelper.h:62
IdContext
class IdContext
Definition: IdContext.h:34
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).