ATLAS Offline Software
IdDictDictionary.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_IdDictDictionary_H
6 #define IDDICT_IdDictDictionary_H
7 
8 
9 #include "Identifier/Identifier.h" //typedef
10 #include "Identifier/Range.h" //member
12 
13 #include <vector>
14 #include <string>
15 #include <memory>
16 
17 
18 class IdDictField;
19 class IdDictLabel;
20 class IdDictSubRegion;
21 class IdDictRegion;
22 class IdDictGroup;
23 class IdDictMgr;
24 
25 class MultiRange;
26 class ExpandedIdentifier;
27 class IdDictDictEntry;
28 
29 
30 
32 public:
35 
36  // ==================================
37  //** @name Constructor/destructor
38  // @{
39 
41  IdDictDictionary (const std::string& name,
42  const std::string& version = "",
43  const std::string& date = "",
44  const std::string& author = "");
46 
47 
49  // ==================================
50  //** @name Simple accessors.
51  // @{
52 
54  const std::string& name() const;
55 
57  const std::string& version() const;
58 
60  size_t n_regions() const;
61 
63  const IdDictRegion& region(size_t i) const;
64 
66  const std::string& file_name() const;
67 
69  const std::string& dict_tag() const;
70 
71 
73  // ==================================
74  //** @name Search for field/label/region by name.
75  // @{
76 
77  const IdDictField* find_field (const std::string& name) const;
78  IdDictField* find_field (const std::string& name);
79  const IdDictLabel* find_label (const std::string& field, const std::string& label) const;
80  int get_label_value (const std::string& field, const std::string& label, int& value) const; // > 0 == error
81  IdDictSubRegion* find_subregion (const std::string& subregion_name);
82  const IdDictRegion* find_region (const std::string& region_name) const;
83  IdDictRegion* find_region (const std::string& region_name, const std::string& group_name);
84  const IdDictRegion* find_region (const std::string& region_name, const std::string& group_name) const;
85  IdDictGroup* find_group (const std::string& group_name);
86  const IdDictGroup* find_group (const std::string& group_name) const;
87 
88 
90  // ==================================
91  //** @name Find first region that matches id
92  // @{
93 
94  int find_region(const ExpandedIdentifier& id, size_type& index) const;
95  const IdDictRegion* find_region(const ExpandedIdentifier& id) const;
96  const IdDictRegion* find_region(const ExpandedIdentifier& id,const std::string& group_name) const;
97 
98 
100  // ==================================
101  //** @name Methods used to initialize the object.
102  // @{
103 
105  const std::vector<IdDictRegion*>& all_regions();
106 
107  IdDictField* add_field (std::unique_ptr<IdDictField> field);
108  IdDictSubRegion* add_subregion (std::unique_ptr<IdDictSubRegion> subregion);
109  void add_dictentry (std::unique_ptr<IdDictDictEntry> entry);
111  void add_subdictionary_name (const std::string& name);
112  void set_parent_dict (IdDictDictionary* parent_dict);
113 
115  void set_file_name (const std::string& name);
116 
118  void set_dict_tag (const std::string& tag);
119 
120  void resolve_references (IdDictMgr& idd);
121  void generate_implementation (const IdDictMgr& idd, const std::string& tag = "");
122  void reset_implementation ();
123  bool verify () const;
124  void sort ();
125  void clear ();
126 
128  void integrate_bits ();
129 
130 
132  // ==================================
133  //** @name Range building
134  // @{
135 
137  MultiRange build_multirange () const;
138 
144  const Range& prefix = Range(),
145  const std::string& last_field = "") const;
146 
154  const std::string& group_name,
155  const Range& prefix = Range(),
156  const std::string& last_field = "") const;
157 
158 
160  // ==================================
161  //** @name Packing and unpacking
162  // @{
163 
176  int pack32 (const ExpandedIdentifier& id,
177  size_t index1,
178  size_t index2,
179  Identifier& packedId) const;
180 
198  int pack32 (const int* fields,
199  size_t index1,
200  size_t index2,
201  size_t region_index,
202  Identifier& packedId,
203  size_t first_field_index=0) const;
204 
208  int reset (size_t index1,
209  size_t index2,
210  size_t region_index,
211  Identifier& packedId) const;
212 
213 
214 
222  int unpack (const std::string& group,
223  const Identifier& id,
224  const ExpandedIdentifier& prefix,
225  size_t index2,
226  ExpandedIdentifier& unpackedId) const;
227 
235  int unpack (const std::string& group,
236  const Identifier& id,
237  const ExpandedIdentifier& prefix,
238  size_t index2,
239  const std::string& sep,
240  std::string& unpackedId) const;
241 
250  int unpack (const Identifier& id,
251  size_t first_field_index,
252  size_t field_index,
253  size_t region_index,
254  int& field) const;
255 
256 
265  int copy (const Identifier& idin,
266  size_t first_field_index,
267  size_t begin_field_index,
268  size_t end_field_index,
269  size_t region_index,
270  Identifier& idout) const;
271 
272 
274  // ==================================
275  //** @name Configuration and diagnostics
276  // @{
277 
281  bool do_checks () const;
282  void set_do_checks (bool do_checks);
283 
287  bool do_neighbours () const;
288  void set_do_neighbours (bool do_neighbours);
289 
291  void dump() const;
292 
293 
295 
296 private:
297  std::string m_name{};
298  std::string m_version{};
299  std::string m_date{};
300  std::string m_author{};
301 
302  using entries_type = std::vector<IdDictDictEntry*>;
304  using entries_const_it = entries_type::const_iterator;
305 
306  using regions_type = std::vector<IdDictRegion*>;
308  using regions_const_it = regions_type::const_iterator;
309 
310  using groups_type = std::vector<IdDictGroup*>;
312  using groups_const_it = groups_type::const_iterator;
313 
314  std::map<std::string, std::unique_ptr<IdDictField> > m_fields;
315  std::map<std::string, std::unique_ptr<IdDictSubRegion> > m_subregions;
316  std::vector<IdDictRegion*> m_regions; // corresponding regions for REs
317  std::vector<IdDictRegion*> m_all_regions; // all regions
318  std::vector<std::unique_ptr<IdDictGroup> > m_groups;
319  std::vector<std::string> m_subdictionary_names;
321 
322  std::string m_file_name{};
323  std::string m_dict_tag{};
325  bool m_do_checks{false};
326  bool m_do_neighbours{true};
327 };
328 
329 //-------------------
330 // inline definitions
331 //-------------------
332 
333 // Dictionary name.
334 inline
335 const std::string&
337 {
338  return m_name;
339 }
340 
341 
342 // Dictionary version.
343 inline
344 const std::string&
346 {
347  return m_version;
348 }
349 
350 
351 // Access region by index.
352 inline
353 const IdDictRegion&
355 {
356  return *m_regions.at(i);
357 }
358 
359 
360 // Number of regions
361 inline
362 size_t
364 {
365  return m_regions.size();
366 }
367 
368 
369 // Access to file name
370 inline const std::string&
372  return m_file_name;
373 }
374 
375 
377 inline const std::string&
379  return m_dict_tag;
380 }
381 
382 
384 inline void
386  m_file_name = name;
387 }
388 
389 
391 inline void
393  m_dict_tag = tag;
394 }
395 
396 
398 inline
399 const std::vector<IdDictRegion*>& IdDictDictionary::all_regions()
400 {
401  return m_all_regions;
402 }
403 
404 
405 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IdDictDictionary::dump
void dump() const
Dump regions and trees for each group.
Definition: IdDictDictionary.cxx:1070
IdDictDictionary::all_regions
const std::vector< IdDictRegion * > & all_regions()
Non-const access to vector of all regions.
Definition: IdDictDictionary.h:399
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictDictionary.cxx:309
IdDictDictionary::reset
int reset(size_t index1, size_t index2, size_t region_index, Identifier &packedId) const
Reset fields from index1 to index2.
Definition: IdDictDictionary.cxx:623
IdDictGroup
Definition: IdDictGroup.h:25
IdDictDictionary::m_dict_tag
std::string m_dict_tag
Definition: IdDictDictionary.h:323
IdDictDictionary::version
const std::string & version() const
Dictionary version.
Definition: IdDictDictionary.h:345
IdDictDictionary::generate_implementation
void generate_implementation(const IdDictMgr &idd, const std::string &tag="")
Definition: IdDictDictionary.cxx:196
IdDictDictionary::entries_const_it
entries_type::const_iterator entries_const_it
Definition: IdDictDictionary.h:304
IdDictDictionary::resolve_references
void resolve_references(IdDictMgr &idd)
Definition: IdDictDictionary.cxx:186
index
Definition: index.py:1
IdDictDictionary::region
const IdDictRegion & region(size_t i) const
Region at index i.
Definition: IdDictDictionary.h:354
IdDictDictionary::find_subregion
IdDictSubRegion * find_subregion(const std::string &subregion_name)
Definition: IdDictDictionary.cxx:107
Range.h
IdDictDictionary::find_field
const IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:47
IdDictDictionary::entries_type
std::vector< IdDictDictEntry * > entries_type
Definition: IdDictDictionary.h:302
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
IdDictDictionary::m_do_checks
bool m_do_checks
Definition: IdDictDictionary.h:325
IdDictDictionary::groups_type
std::vector< IdDictGroup * > groups_type
Definition: IdDictDictionary.h:310
athena.value
value
Definition: athena.py:124
IdDictDictionary::set_dict_tag
void set_dict_tag(const std::string &tag)
Set the dictionary tag.
Definition: IdDictDictionary.h:392
IdDictDictionary::~IdDictDictionary
~IdDictDictionary()
ExpandedIdentifier.h
IdDictDictionary::m_subregions
std::map< std::string, std::unique_ptr< IdDictSubRegion > > m_subregions
Definition: IdDictDictionary.h:315
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
IdDictDictionary::name
const std::string & name() const
Dictionary name.
Definition: IdDictDictionary.h:336
IdDictDictionary::find_label
const IdDictLabel * find_label(const std::string &field, const std::string &label) const
Definition: IdDictDictionary.cxx:84
IdDictDictEntry
Definition: IdDictDictEntry.h:13
IdDictDictionary::file_name
const std::string & file_name() const
Access to file name.
Definition: IdDictDictionary.h:371
IdDictDictionary::pack32
int pack32(const ExpandedIdentifier &id, size_t index1, size_t index2, Identifier &packedId) const
Pack to 32bits the subset of id between (inclusive) index1 and index2 - this is generic,...
Definition: IdDictDictionary.cxx:459
CalibDbCompareRT.region_id
region_id
Definition: CalibDbCompareRT.py:67
IdDictRegion
Definition: IdDictRegion.h:21
IdDictDictionary::m_version
std::string m_version
Definition: IdDictDictionary.h:298
IdDictDictionary::add_field
IdDictField * add_field(std::unique_ptr< IdDictField > field)
Definition: IdDictDictionary.cxx:101
IdDictDictionary::verify
bool verify() const
Here, we verify global constraints : (this must only be applied after the resolve_references and gene...
Definition: IdDictDictionary.cxx:1027
IdDictDictionary::reset_implementation
void reset_implementation()
Definition: IdDictDictionary.cxx:243
IdDictDictionary::m_parent_dict
IdDictDictionary * m_parent_dict
Definition: IdDictDictionary.h:320
IdDictLabel
Definition: IdDictLabel.h:10
IdDictDictionary::find_region
const IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictDictionary.cxx:114
IdDictMgr
Definition: IdDictMgr.h:16
IdDictDictionary::IdDictDictionary
IdDictDictionary()
IdDictDictionary::m_groups
std::vector< std::unique_ptr< IdDictGroup > > m_groups
Definition: IdDictDictionary.h:318
Trk::index1
@ index1
Definition: BoundarySurfaceFace.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictDictionary::m_author
std::string m_author
Definition: IdDictDictionary.h:300
IdDictDictionary::m_generated_implementation
bool m_generated_implementation
Definition: IdDictDictionary.h:324
IdDictDictionary::set_file_name
void set_file_name(const std::string &name)
Set file name.
Definition: IdDictDictionary.h:385
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
IdDictDictionary::groups_it
groups_type::iterator groups_it
Definition: IdDictDictionary.h:311
IdDictDictionary::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictDictionary.h:316
IdDictDictionary::groups_const_it
groups_type::const_iterator groups_const_it
Definition: IdDictDictionary.h:312
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
IdDictDictionary::add_subdictionary_name
void add_subdictionary_name(const std::string &name)
Definition: IdDictDictionary.cxx:162
IdDictDictionary::regions_const_it
regions_type::const_iterator regions_const_it
Definition: IdDictDictionary.h:308
IdDictDictionary::do_checks
bool do_checks() const
Checks are performed by default in debug compilation and NOT in optimized compilation.
Definition: IdDictDictionary.cxx:984
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name)
Definition: IdDictDictionary.cxx:141
IdDictDictionary::m_fields
std::map< std::string, std::unique_ptr< IdDictField > > m_fields
Definition: IdDictDictionary.h:314
IdDictDictionary::m_date
std::string m_date
Definition: IdDictDictionary.h:299
IdDictDictionary::get_label_value
int get_label_value(const std::string &field, const std::string &label, int &value) const
Definition: IdDictDictionary.cxx:92
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
grepfile.sep
sep
Definition: grepfile.py:38
IdDictDictionary::unpack
int unpack(const std::string &group, const Identifier &id, const ExpandedIdentifier &prefix, size_t index2, ExpandedIdentifier &unpackedId) const
Unpack the value_type id to an expanded Identifier for a given group, considering the provided prefix...
Definition: IdDictDictionary.cxx:679
IdDictDictionary::sort
void sort()
Sort:
Definition: IdDictDictionary.cxx:1048
MultiRange
A MultiRange combines several Ranges.
Definition: MultiRange.h:17
Trk::index2
@ index2
Definition: BoundarySurfaceFace.h:49
IdDictDictionary::add_region
void add_region(IdDictRegion *region)
Definition: IdDictDictionary.cxx:182
IdDictDictionary::clear
void clear()
Definition: IdDictDictionary.cxx:1062
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
fillHVMap_fromASCII.date
string date
Definition: fillHVMap_fromASCII.py:8
IdDictDictionary::do_neighbours
bool do_neighbours() const
Neighbour initialization is performed by default One can switch or query this mode for any idHelper w...
Definition: IdDictDictionary.cxx:994
IdDictDictionary::m_do_neighbours
bool m_do_neighbours
Definition: IdDictDictionary.h:326
IdDictDictionary::regions_it
regions_type::iterator regions_it
Definition: IdDictDictionary.h:307
IdDictDictionary::regions_type
std::vector< IdDictRegion * > regions_type
Definition: IdDictDictionary.h:306
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
IdDictDictionary::size_type
Identifier::size_type size_type
Definition: IdDictDictionary.h:34
IdDictDictionary
Definition: IdDictDictionary.h:31
IdDictDictionary::entries_it
entries_type::iterator entries_it
Definition: IdDictDictionary.h:303
IdDictDictionary::m_subdictionary_names
std::vector< std::string > m_subdictionary_names
Definition: IdDictDictionary.h:319
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
IdDictDictionary::m_name
std::string m_name
Definition: IdDictDictionary.h:297
IdDictDictionary::dict_tag
const std::string & dict_tag() const
Access to the dictionary tag.
Definition: IdDictDictionary.h:378
IdDictDictionary::set_parent_dict
void set_parent_dict(IdDictDictionary *parent_dict)
Definition: IdDictDictionary.cxx:166
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:25
Identifier::value_type
unsigned long long value_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:27
IdDictSubRegion
Definition: IdDictSubRegion.h:13
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
IdDictDictionary::set_do_neighbours
void set_do_neighbours(bool do_neighbours)
Definition: IdDictDictionary.cxx:999
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:105
IdDictField
Definition: IdDictField.h:16
Identifier::size_type
unsigned long long size_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:29
IdDictDictionary::m_file_name
std::string m_file_name
Definition: IdDictDictionary.h:322
IdDictDictionary::n_regions
size_t n_regions() const
Number of contained regions.
Definition: IdDictDictionary.h:363
IdDictDictionary::integrate_bits
void integrate_bits()
Set up integral of bits for efficient unpacking.
Definition: IdDictDictionary.cxx:300
value_type
Definition: EDM_MasterSearch.h:11
IdDictDictionary::add_subregion
IdDictSubRegion * add_subregion(std::unique_ptr< IdDictSubRegion > subregion)
Definition: IdDictDictionary.cxx:157
IdDictDictionary::add_dictentry
void add_dictentry(std::unique_ptr< IdDictDictEntry > entry)
Definition: IdDictDictionary.cxx:171
IdDictDictionary::copy
int copy(const Identifier &idin, size_t first_field_index, size_t begin_field_index, size_t end_field_index, size_t region_index, Identifier &idout) const
Copy a number of fields of the value_type id into another value_type id.
Definition: IdDictDictionary.cxx:897
IdDictDictionary::m_all_regions
std::vector< IdDictRegion * > m_all_regions
Definition: IdDictDictionary.h:317
Identifier
Definition: IdentifierFieldParser.cxx:14
IdDictDictionary::set_do_checks
void set_do_checks(bool do_checks)
Definition: IdDictDictionary.cxx:989