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 
16 
17 class IdDictField;
18 class IdDictLabel;
19 class IdDictSubRegion;
20 class IdDictRegion;
21 class IdDictGroup;
22 class IdDictMgr;
23 
24 class MultiRange;
25 class ExpandedIdentifier;
26 class IdDictDictEntry;
27 
28 
29 
31 public:
34 
35  // ==================================
36  //** @name Constructor/destructor
37  // @{
38 
40  IdDictDictionary (const std::string& name,
41  const std::string& version = "",
42  const std::string& date = "",
43  const std::string& author = "");
45 
46 
48  // ==================================
49  //** @name Simple accessors.
50  // @{
51 
53  const std::string& name() const;
54 
56  const std::string& version() const;
57 
59  size_t n_regions() const;
60 
62  const IdDictRegion& region(size_t i) const;
63 
65  const std::string& file_name() const;
66 
68  const std::string& dict_tag() const;
69 
70 
72  // ==================================
73  //** @name Search for field/label/region by name.
74  // @{
75 
76  IdDictField* find_field (const std::string& name) const;
77  IdDictLabel* find_label (const std::string& field, const std::string& label) const;
78  int get_label_value (const std::string& field, const std::string& label, int& value) const; // > 0 == error
79  IdDictSubRegion* find_subregion (const std::string& subregion_name) const;
80  IdDictRegion* find_region (const std::string& region_name) const;
81  IdDictRegion* find_region (const std::string& region_name, const std::string& group_name) const;
82  IdDictGroup* find_group (const std::string& group_name) const;
83 
84 
86  // ==================================
87  //** @name Find first region that matches id
88  // @{
89 
90  int find_region(const ExpandedIdentifier& id, size_type& index) const;
92  IdDictRegion* find_region(const ExpandedIdentifier& id,const std::string& group_name) const;
93 
94 
96  // ==================================
97  //** @name Methods used to initialize the object.
98  // @{
99 
101  const std::vector<IdDictRegion*>& all_regions();
102 
103  void add_field (IdDictField* field);
104  void add_subregion (IdDictSubRegion* subregion);
107  void add_subdictionary_name (const std::string& name);
108  void set_parent_dict (IdDictDictionary* parent_dict);
109 
111  void set_file_name (const std::string& name);
112 
114  void set_dict_tag (const std::string& tag);
115 
116  void resolve_references (const IdDictMgr& idd);
117  void generate_implementation (const IdDictMgr& idd, const std::string& tag = "");
118  void reset_implementation ();
119  bool verify () const;
120  void sort ();
121  void clear ();
122 
124  void integrate_bits ();
125 
126 
128  // ==================================
129  //** @name Range building
130  // @{
131 
133  MultiRange build_multirange () const;
134 
140  const Range& prefix = Range(),
141  const std::string& last_field = "") const;
142 
150  const std::string& group_name,
151  const Range& prefix = Range(),
152  const std::string& last_field = "") const;
153 
154 
156  // ==================================
157  //** @name Packing and unpacking
158  // @{
159 
172  int pack32 (const ExpandedIdentifier& id,
173  size_t index1,
174  size_t index2,
175  Identifier& packedId) const;
176 
194  int pack32 (const int* fields,
195  size_t index1,
196  size_t index2,
197  size_t region_index,
198  Identifier& packedId,
199  size_t first_field_index=0) const;
200 
204  int reset (size_t index1,
205  size_t index2,
206  size_t region_index,
207  Identifier& packedId) const;
208 
209 
210 
218  int unpack (const std::string& group,
219  const Identifier& id,
220  const ExpandedIdentifier& prefix,
221  size_t index2,
222  ExpandedIdentifier& unpackedId) const;
223 
231  int unpack (const std::string& group,
232  const Identifier& id,
233  const ExpandedIdentifier& prefix,
234  size_t index2,
235  const std::string& sep,
236  std::string& unpackedId) const;
237 
246  int unpack (const Identifier& id,
247  size_t first_field_index,
248  size_t field_index,
249  size_t region_index,
250  int& field) const;
251 
252 
261  int copy (const Identifier& idin,
262  size_t first_field_index,
263  size_t begin_field_index,
264  size_t end_field_index,
265  size_t region_index,
266  Identifier& idout) const;
267 
268 
270  // ==================================
271  //** @name Configuration and diagnostics
272  // @{
273 
277  bool do_checks () const;
278  void set_do_checks (bool do_checks);
279 
283  bool do_neighbours () const;
284  void set_do_neighbours (bool do_neighbours);
285 
287  void dump() const;
288 
289 
291 
292 private:
293  std::string m_name{};
294  std::string m_version{};
295  std::string m_date{};
296  std::string m_author{};
297 
298  using entries_type = std::vector<IdDictDictEntry*>;
300  using entries_const_it = entries_type::const_iterator;
301 
302  using regions_type = std::vector<IdDictRegion*>;
304  using regions_const_it = regions_type::const_iterator;
305 
306  using groups_type = std::vector<IdDictGroup*>;
308  using groups_const_it = groups_type::const_iterator;
309 
310  std::map<std::string, IdDictField*> m_fields;
311  std::map<std::string, IdDictSubRegion*> m_subregions;
312  std::vector<IdDictRegion*> m_regions; // corresponding regions for REs
313  std::vector<IdDictRegion*> m_all_regions; // all regions
314  std::vector<IdDictGroup*> m_groups;
315  std::vector<std::string> m_subdictionary_names;
317 
318  std::string m_file_name{};
319  std::string m_dict_tag{};
321  bool m_do_checks{false};
322  bool m_do_neighbours{true};
323 };
324 
325 //-------------------
326 // inline definitions
327 //-------------------
328 
329 // Dictionary name.
330 inline
331 const std::string&
333 {
334  return m_name;
335 }
336 
337 
338 // Dictionary version.
339 inline
340 const std::string&
342 {
343  return m_version;
344 }
345 
346 
347 // Access region by index.
348 inline
349 const IdDictRegion&
351 {
352  return *m_regions.at(i);
353 }
354 
355 
356 // Number of regions
357 inline
358 size_t
360 {
361  return m_regions.size();
362 }
363 
364 
365 // Access to file name
366 inline const std::string&
368  return m_file_name;
369 }
370 
371 
373 inline const std::string&
375  return m_dict_tag;
376 }
377 
378 
380 inline void
382  m_file_name = name;
383 }
384 
385 
387 inline void
389  m_dict_tag = tag;
390 }
391 
392 
394 inline
395 const std::vector<IdDictRegion*>& IdDictDictionary::all_regions()
396 {
397  return m_all_regions;
398 }
399 
400 
401 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IdDictDictionary::find_region
IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictDictionary.cxx:101
IdDictDictionary::dump
void dump() const
Dump regions and trees for each group.
Definition: IdDictDictionary.cxx:1089
IdDictDictionary::all_regions
const std::vector< IdDictRegion * > & all_regions()
Non-const access to vector of all regions.
Definition: IdDictDictionary.h:395
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictDictionary.cxx:290
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:608
IdDictGroup
Definition: IdDictGroup.h:25
IdDictDictionary::m_dict_tag
std::string m_dict_tag
Definition: IdDictDictionary.h:319
IdDictDictionary::version
const std::string & version() const
Dictionary version.
Definition: IdDictDictionary.h:341
IdDictDictionary::generate_implementation
void generate_implementation(const IdDictMgr &idd, const std::string &tag="")
Definition: IdDictDictionary.cxx:172
IdDictDictionary::m_groups
std::vector< IdDictGroup * > m_groups
Definition: IdDictDictionary.h:314
IdDictDictionary::entries_const_it
entries_type::const_iterator entries_const_it
Definition: IdDictDictionary.h:300
index
Definition: index.py:1
IdDictDictionary::region
const IdDictRegion & region(size_t i) const
Region at index i.
Definition: IdDictDictionary.h:350
IdDictDictionary::find_label
IdDictLabel * find_label(const std::string &field, const std::string &label) const
Definition: IdDictDictionary.cxx:67
Range.h
IdDictDictionary::entries_type
std::vector< IdDictDictEntry * > entries_type
Definition: IdDictDictionary.h:298
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
IdDictDictionary::m_do_checks
bool m_do_checks
Definition: IdDictDictionary.h:321
IdDictDictionary::groups_type
std::vector< IdDictGroup * > groups_type
Definition: IdDictDictionary.h:306
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:388
IdDictDictionary::~IdDictDictionary
~IdDictDictionary()
ExpandedIdentifier.h
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
IdDictDictionary::name
const std::string & name() const
Dictionary name.
Definition: IdDictDictionary.h:332
IdDictDictEntry
Definition: IdDictDictEntry.h:13
IdDictDictionary::file_name
const std::string & file_name() const
Access to file name.
Definition: IdDictDictionary.h:367
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:444
IdDictDictionary::find_field
IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:47
CalibDbCompareRT.region_id
region_id
Definition: CalibDbCompareRT.py:67
IdDictRegion
Definition: IdDictRegion.h:20
IdDictDictionary::resolve_references
void resolve_references(const IdDictMgr &idd)
Definition: IdDictDictionary.cxx:153
IdDictDictionary::m_version
std::string m_version
Definition: IdDictDictionary.h:294
IdDictDictionary::verify
bool verify() const
Here, we verify global constraints : (this must only be applied after the resolve_references and gene...
Definition: IdDictDictionary.cxx:1012
IdDictDictionary::reset_implementation
void reset_implementation()
Definition: IdDictDictionary.cxx:223
IdDictDictionary::m_parent_dict
IdDictDictionary * m_parent_dict
Definition: IdDictDictionary.h:316
IdDictLabel
Definition: IdDictLabel.h:10
IdDictMgr
Definition: IdDictMgr.h:14
IdDictDictionary::m_fields
std::map< std::string, IdDictField * > m_fields
Definition: IdDictDictionary.h:310
IdDictDictionary::IdDictDictionary
IdDictDictionary()
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name) const
Definition: IdDictDictionary.cxx:115
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:296
IdDictDictionary::m_generated_implementation
bool m_generated_implementation
Definition: IdDictDictionary.h:320
IdDictDictionary::set_file_name
void set_file_name(const std::string &name)
Set file name.
Definition: IdDictDictionary.h:381
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:307
IdDictDictionary::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictDictionary.h:312
IdDictDictionary::groups_const_it
groups_type::const_iterator groups_const_it
Definition: IdDictDictionary.h:308
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:129
IdDictDictionary::regions_const_it
regions_type::const_iterator regions_const_it
Definition: IdDictDictionary.h:304
IdDictDictionary::do_checks
bool do_checks() const
Checks are performed by default in debug compilation and NOT in optimized compilation.
Definition: IdDictDictionary.cxx:969
IdDictDictionary::m_date
std::string m_date
Definition: IdDictDictionary.h:295
IdDictDictionary::get_label_value
int get_label_value(const std::string &field, const std::string &label, int &value) const
Definition: IdDictDictionary.cxx:75
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:664
IdDictDictionary::sort
void sort()
Sort:
Definition: IdDictDictionary.cxx:1033
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:149
IdDictDictionary::clear
void clear()
Definition: IdDictDictionary.cxx:1049
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
IdDictDictionary::add_field
void add_field(IdDictField *field)
Definition: IdDictDictionary.cxx:84
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:979
IdDictDictionary::m_do_neighbours
bool m_do_neighbours
Definition: IdDictDictionary.h:322
IdDictDictionary::regions_it
regions_type::iterator regions_it
Definition: IdDictDictionary.h:303
IdDictDictionary::regions_type
std::vector< IdDictRegion * > regions_type
Definition: IdDictDictionary.h:302
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:33
IdDictDictionary
Definition: IdDictDictionary.h:30
IdDictDictionary::entries_it
entries_type::iterator entries_it
Definition: IdDictDictionary.h:299
IdDictDictionary::find_subregion
IdDictSubRegion * find_subregion(const std::string &subregion_name) const
Definition: IdDictDictionary.cxx:91
IdDictDictionary::m_subdictionary_names
std::vector< std::string > m_subdictionary_names
Definition: IdDictDictionary.h:315
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
IdDictDictionary::m_name
std::string m_name
Definition: IdDictDictionary.h:293
IdDictDictionary::dict_tag
const std::string & dict_tag() const
Access to the dictionary tag.
Definition: IdDictDictionary.h:374
IdDictDictionary::m_subregions
std::map< std::string, IdDictSubRegion * > m_subregions
Definition: IdDictDictionary.h:311
IdDictDictionary::add_dictentry
void add_dictentry(IdDictDictEntry *entry)
Definition: IdDictDictionary.cxx:138
IdDictDictionary::set_parent_dict
void set_parent_dict(IdDictDictionary *parent_dict)
Definition: IdDictDictionary.cxx:133
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:984
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:105
IdDictField
Definition: IdDictField.h:15
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:318
IdDictDictionary::n_regions
size_t n_regions() const
Number of contained regions.
Definition: IdDictDictionary.h:359
IdDictDictionary::integrate_bits
void integrate_bits()
Set up integral of bits for efficient unpacking.
Definition: IdDictDictionary.cxx:281
value_type
Definition: EDM_MasterSearch.h:11
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:882
IdDictDictionary::add_subregion
void add_subregion(IdDictSubRegion *subregion)
Definition: IdDictDictionary.cxx:124
IdDictDictionary::m_all_regions
std::vector< IdDictRegion * > m_all_regions
Definition: IdDictDictionary.h:313
Identifier
Definition: IdentifierFieldParser.cxx:14
IdDictDictionary::set_do_checks
void set_do_checks(bool do_checks)
Definition: IdDictDictionary.cxx:974