ATLAS Offline Software
IdDictGroup.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef IDDICT_IdDictGroup_H
6 #define IDDICT_IdDictGroup_H
7 
8 #include <string>
9 #include <vector>
10 #include <variant>
11 #include <utility>
12 #include <memory>
13 
14 class IdDictDictEntry;
15 class IdDictRegion;
16 class IdDictMgr;
17 class IdDictDictionary;
19 class Identifier;
20 class ExpandedIdentifier;
21 class MultiRange;
22 
23 
24 
25 class IdDictGroup{
26 public:
27  // ==================================
28  //** @name Constructor/destructor
29  // @{
30 
31  IdDictGroup ();
32  IdDictGroup (const std::string& name);
33  ~IdDictGroup ();
34 
35 
37  // ==================================
38  //** @name Simple accessors.
39  // @{
40 
41  const std::string& name();
42  const std::vector<IdDictDictEntry*>& entries();
43  const std::vector<IdDictRegion*>& regions();
44 
45 
47  // ==================================
48  //** @name Methods used to initialize the object.
49  // @{
51 
52  MultiRange build_multirange () const;
54 
55  void resolve_references (const IdDictMgr& idd,
57  size_t& index);
58  void generate_implementation (const IdDictMgr& idd,
60  const std::string& tag = "");
61  void reset_implementation ();
62  bool verify () const;
63  void sort ();
64  void clear ();
65 
66 
76  int unpack (const Identifier& id,
78  size_t index2,
79  ExpandedIdentifier& unpackedId,
80  std::vector<const IdDictFieldImplementation*>* impls = nullptr) const;
81 
85  void build_region_tree();
86 
87 
91  void dump() const;
92 
93 
97  void dump_regions() const;
98 
99 
103  void dump_tree() const;
104 
105 
106 private:
113  void add_tree_field (const IdDictRegion& re, unsigned ifield, unsigned inode);
114 
115  std::string m_name;
116  std::vector<IdDictDictEntry*> m_entries; // just the RegionEntries
117  std::vector<IdDictRegion*> m_regions; // regions derived from entries
119 
120 
186  void optimize();
187 
190 
195  std::unique_ptr<std::vector<const IdDictFieldImplementation*> > m_other_impls;
196 
205  using ChildPair = std::pair<size_t, unsigned>;
206  std::variant<std::vector<unsigned>, ChildPair> m_children;
207 
209  // of an identifier.
210  static constexpr unsigned END = static_cast<unsigned> (-1);
211  };
213  std::vector<IdDictRegionTreeNode> m_region_tree;
214 };
215 
216 #endif
IdDictGroup::m_name
std::string m_name
Definition: IdDictGroup.h:115
IdDictGroup
Definition: IdDictGroup.h:25
index
Definition: index.py:1
IdDictGroup::sort
void sort()
Sort:
Definition: IdDictGroup.cxx:148
IdDictGroup::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictGroup.h:117
IdDictGroup::verify
bool verify() const
Definition: IdDictGroup.cxx:134
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
IdDictDictEntry
Definition: IdDictDictEntry.h:13
IdDictGroup::dump_tree
void dump_tree() const
Dump the tree structure built from the regions for fast unpacking.
Definition: IdDictGroup.cxx:541
IdDictRegion
Definition: IdDictRegion.h:20
IdDictGroup::generate_implementation
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="")
Definition: IdDictGroup.cxx:88
IdDictGroup::m_entries
std::vector< IdDictDictEntry * > m_entries
Definition: IdDictGroup.h:116
IdDictGroup::resolve_references
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, size_t &index)
Definition: IdDictGroup.cxx:76
IdDictMgr
Definition: IdDictMgr.h:14
IdDictGroup::build_region_tree
void build_region_tree()
Take the list of regions and build a tree structure for fast unpacking.
Definition: IdDictGroup.cxx:478
IdDictGroup::IdDictGroup
IdDictGroup()
Definition: IdDictGroup.cxx:22
IdDictGroup::IdDictRegionTreeNode::m_impl
const IdDictFieldImplementation & m_impl
Reference to the the implementation field.
Definition: IdDictGroup.h:189
IdDictGroup::build_multirange
MultiRange build_multirange() const
Get MultiRange for this group.
Definition: IdDictGroup.cxx:51
IdDictGroup::unpack
int unpack(const Identifier &id, const ExpandedIdentifier &prefix, size_t index2, ExpandedIdentifier &unpackedId, std::vector< const IdDictFieldImplementation * > *impls=nullptr) const
Unpack the value_type id to an expanded Identifier, considering the provided prefix (result will incl...
Definition: IdDictGroup.cxx:230
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
IdDictGroup::clear
void clear()
Definition: IdDictGroup.cxx:178
IdDictGroup::add_dictentry
void add_dictentry(IdDictDictEntry *entry)
Definition: IdDictGroup.cxx:71
IdDictGroup::IdDictRegionTreeNode::IdDictRegionTreeNode
IdDictRegionTreeNode(const IdDictFieldImplementation &impl)
Constructor, taking a reference to the implementation.
Definition: IdDictGroup.cxx:190
IdDictGroup::regions
const std::vector< IdDictRegion * > & regions()
Definition: IdDictGroup.cxx:46
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
IdDictGroup::m_region_tree
std::vector< IdDictRegionTreeNode > m_region_tree
The list of region nodes.
Definition: IdDictGroup.h:213
IdDictGroup::IdDictRegionTreeNode::END
static constexpr unsigned END
Special value used to indicate that we've reached the end.
Definition: IdDictGroup.h:210
MultiRange
A MultiRange combines several Ranges.
Definition: MultiRange.h:17
master.dictionary
dictionary
Definition: master.py:47
Trk::index2
@ index2
Definition: BoundarySurfaceFace.h:49
IdDictGroup::IdDictRegionTreeNode
Tree structure for fast unpacking.
Definition: IdDictGroup.h:182
IdDictGroup::IdDictRegionTreeNode::optimize
void optimize()
Compress the vector of node indices, if they are all the same.
Definition: IdDictGroup.cxx:199
IdDictDictionary
Definition: IdDictDictionary.h:30
impl
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:46
IdDictGroup::IdDictRegionTreeNode::m_children
std::variant< std::vector< unsigned >, ChildPair > m_children
Definition: IdDictGroup.h:206
IdDictGroup::name
const std::string & name()
Definition: IdDictGroup.cxx:36
IdDictGroup::reset_implementation
void reset_implementation()
Definition: IdDictGroup.cxx:123
IdDictGroup::m_generated_implementation
bool m_generated_implementation
Definition: IdDictGroup.h:118
IdDictGroup::add_tree_field
void add_tree_field(const IdDictRegion &re, unsigned ifield, unsigned inode)
Recursively add new nodes to the tree structure.
Definition: IdDictGroup.cxx:339
re
const boost::regex re(r_e)
IdDictGroup::entries
const std::vector< IdDictDictEntry * > & entries()
Definition: IdDictGroup.cxx:41
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdDictGroup::~IdDictGroup
~IdDictGroup()
Definition: IdDictGroup.cxx:33
IdDictGroup::IdDictRegionTreeNode::m_other_impls
std::unique_ptr< std::vector< const IdDictFieldImplementation * > > m_other_impls
Implementations for other field descriptions that this ored field of the identifier may contain.
Definition: IdDictGroup.h:195
IdDictGroup::dump_regions
void dump_regions() const
Dump the list of regions for this group.
Definition: IdDictGroup.cxx:521
IdDictGroup::IdDictRegionTreeNode::ChildPair
std::pair< size_t, unsigned > ChildPair
References to child nodes.
Definition: IdDictGroup.h:205
inode
Definition: listroot.cxx:155
IdDictGroup::dump
void dump() const
Dump regions and tree for this group.
Definition: IdDictGroup.cxx:510
Identifier
Definition: IdentifierFieldParser.cxx:14