ATLAS Offline Software
IdDictDictionary.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 
7 #include "IdDict/IdDictField.h"
8 #include "IdDict/IdDictLabel.h"
9 #include "IdDict/IdDictRegion.h"
10 #include "IdDict/IdDictGroup.h"
11 #include "IdDict/IdDictSubRegion.h"
13 #include "IdDict/IdDictMgr.h"
14 #include "IdDict/IdDictRange.h"
15 #include "src/Debugger.h"
16 #include "src/get_bits.h"
17 #include "Identifier/MultiRange.h"
18 #include <iostream>
19 
20 using IdDict::get_bits;
21 
22 static bool isNumber(const std::string& str) {
23  bool result = true;
24 
25  for (unsigned int i = 0; i < str.size(); ++i) {
26  if (!isdigit(str[i])) return(false);
27  }
28  if (0 == str.size()) return(false);
29 
30  return(result);
31 }
32 
35 
37  const std::string& version /*= ""*/,
38  const std::string& date /*= ""*/,
39  const std::string& author /*= ""*/)
40  : m_name (name),
41  m_version (version),
42  m_date (date),
43  m_author (author)
44 {
45 }
46 
47 IdDictField* IdDictDictionary::find_field(const std::string& name) const {
48  std::map <std::string, IdDictField*>::const_iterator it;
49 
50  it = m_fields.find(name);
51 
52  if (it == m_fields.end()) {
53  // If parent exists, look for field there
54  if (m_parent_dict) {
55  it = m_parent_dict->m_fields.find(name);
56  if (it == m_parent_dict->m_fields.end()) {
57  return(0);
58  }
59  } else {
60  return(0);
61  }
62  }
63 
64  return((*it).second);
65 }
66 
67 IdDictLabel* IdDictDictionary::find_label(const std::string& field, const std::string& label) const {
68  IdDictField* idField = find_field(field);
69 
70  if (!idField) return nullptr;
71 
72  return(idField->find_label(label));
73 }
74 
75 int IdDictDictionary::get_label_value(const std::string& field, const std::string& label, int& value) const {
76  IdDictLabel* idLabel = find_label(field, label);
77 
78  if (!idLabel || !idLabel->valued()) return(1);
79 
80  value = idLabel->value();
81  return(0);
82 }
83 
85  if (field == 0) return;
86 
87  m_fields[field->name()] = field;
88 }
89 
91 IdDictDictionary::find_subregion(const std::string& name) const {
92  std::map <std::string, IdDictSubRegion*>::const_iterator it;
93 
94  it = m_subregions.find(name);
95 
96  if (it == m_subregions.end()) return(0);
97 
98  return((*it).second);
99 }
100 
101 IdDictRegion* IdDictDictionary::find_region(const std::string& region_name) const {
102  return find_region(region_name, "");
103 }
104 
105 IdDictRegion* IdDictDictionary::find_region(const std::string& region_name, const std::string& group_name) const {
106  for (IdDictRegion* region : m_regions) {
107  if (!region) continue;
108  if ((group_name != "") && (region->group_name() != group_name)) continue;
109  if ((region_name != "") && (region->name() != region_name)) continue;
110  return region;
111  }
112  return nullptr;
113 }
114 
116  for (size_t i = 0; i < m_groups.size(); ++i) {
118  if ((group != 0) && (group->name() == group_name)) return(group);
119  }
120 
121  return(0);
122 }
123 
125  if (subregion == 0) return;
126  m_subregions[subregion->name()] = subregion;
127 }
128 
130  m_subdictionary_names.push_back(name);
131 }
132 
134 {
135  m_parent_dict = parent_dict;
136 }
137 
139  // Add region to corresponding group
141 
142  if (0 == group) {
144  m_groups.push_back(group);
145  }
146  group->add_dictentry(region);
147 }
148 
150  m_all_regions.push_back(region);
151 }
152 
154  {
156 
157  for (it = m_subregions.begin(); it != m_subregions.end(); ++it) {
158  IdDictSubRegion* subregion = (*it).second;
159  subregion->resolve_references(idd, *this);
160  }
161  }
162  {
163  size_t index = 0;
164 
166  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
167  (*it)->resolve_references(idd, *this, index);
168  }
169  }
170 }
171 
173  const std::string& tag) {
174  if (Debugger::debug()) {
175  std::cout << "IdDictDictionary::generate_implementation>" << std::endl;
176  }
177 
179  // Propagate to each region and copy their generation into the
180  // dict's vector.
182  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
183  (*it)->generate_implementation(idd, *this, tag);
184  // Get regions from group and save in m_regions
185  const regions_type& regions = (*it)->regions();
187  for (it1 = regions.begin(); it1 != regions.end(); ++it1) {
188  m_regions.push_back(*it1);
189  }
190  }
191 
192  // Loop again over groups and set the bit-packing - starting at
193  // level 0
194  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
195  // Copy to temporary vector all regions in the group. And
196  // look for regions in local m_regions vector for any
197  // regions "dummy", which come from reference
198  // dictionaries.
199  // Skip special group
200  if ("dummy" == (*it)->name()) continue;
201 
202  get_bits(m_regions, 0, (*it)->name());
203 // get_bits (regions, 0, (*it)->name());
204  }
205 
206  // Set integral over the number of bits
207  integrate_bits();
208 
209  for (IdDictGroup* g : m_groups) {
210  g->build_region_tree();
211  }
212 
213  // Set neighbours for regions
215  for (itr = m_regions.begin(); itr != m_regions.end(); ++itr) {
216  (*itr)->find_neighbours(*this);
217  }
218 
220  }
221 }
222 
225  m_regions.clear();
227  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
228  (*it)->reset_implementation();
229  }
231  }
232 }
233 
234 int
236  // Find first region that matches id
237 
239 
240  size_type i = 0;
241  for (it = m_regions.begin(); it != m_regions.end(); ++it, ++i) {
242  const IdDictRegion& region = *(*it);
243 
245 
246  if (range.match(id) && range.fields() >= id.fields()) {
247  index = i;
248  return(0);
249  }
250  }
251 
252  return(1);
253 }
254 
256  return find_region(id, "");
257 }
258 
260  // Find first region that matches id
261 
262  IdDictRegion* pRegion = 0;
263 
265 
266  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
267  IdDictRegion& region = *(*it);
268  if ((group_name != "") && (region.group_name() != group_name)) continue;
269 
271 
272  if (range.match(id) && range.fields() >= id.fields()) {
273  pRegion = &region;
274  }
275  }
276 
277  return(pRegion);
278 }
279 
280 void
282  // For each region, loop over its levels and set the bit offset
283  // for each FieldImplementation
284 
285  for (IdDictRegion* region : m_regions) {
287  }
288 }
289 
292 
294 
295  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
296  const IdDictGroup& group = *(*it);
297 
298  MultiRange group_mr = group.build_multirange();
299 
300  for (unsigned int i = 0; i < group_mr.size(); ++i) {
301  const Range& range = group_mr[i];
302  result.add(range);
303  }
304  }
305 
306  return(result);
307 }
308 
310  const Range& prefix,
311  const std::string& last_field) const {
313 
315  if ("" == last_field) {
316  // Take all fields
317  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
318  const IdDictRegion& region = *(*it);
319 
320  // skip regions created from parents
321  if ("dummy" == region.name()) continue;
322 
323  // skip empty regions - may arise from alternate_regions
324  // where a tag selects an empty region
325  if (region.is_empty()) continue;
326 
328  // Check region selection
329  if (range.match(region_id)) result.add(std::move(range));
330  }
331  } else {
332  // Not all fields required
333  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
334  const IdDictRegion& region = *(*it);
335 
336  // skip regions created from parents
337  if ("dummy" == region.name()) continue;
338 
339  // skip empty regions - may arise from alternate_regions
340  // where a tag selects an empty region
341  if (region.is_empty()) continue;
342 
344  // Check region selection
345  if (range.match(region_id)) {
346  // Build new range up to last_field and add it to result -
347  // remove duplicate ranges with addRangeToMR
348  Range new_range(prefix); // Prepend with prefix
349 
350  size_t nimpl = region.n_implementation();
351  for (size_t i = 0; i < nimpl; ++i) {
353 
354 // new_range.add(impl.m_field);
355  new_range.add(impl.range()->build_range());
356 
357  if (last_field == impl.range()->field()->name()) {
358  break;
359  }
360  }
361  result.add(std::move(new_range));
362  }
363  }
364  }
365 
366  return(result);
367 }
368 
370  const std::string& group_name,
371  const Range& prefix,
372  const std::string& last_field) const {
374 
376  if ("" == last_field) {
377  // Take all fields
378  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
379  const IdDictRegion& region = *(*it);
380 
381  // skip regions created from parents
382  if ("dummy" == region.name()) continue;
383 
384  // skip empty regions - may arise from alternate_regions
385  // where a tag selects an empty region
386  if (region.is_empty()) continue;
387 
389  // Check region selection
390  if (range.match(region_id) && region.group_name() == group_name) result.add(std::move(range));
391  }
392  } else {
393  // Not all fields required
394  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
395  const IdDictRegion& region = *(*it);
396 
397  // skip regions created from parents
398  if ("dummy" == region.name()) continue;
399 
400  // skip empty regions - may arise from alternate_regions
401  // where a tag selects an empty region
402  if (region.is_empty()) continue;
403 
405  // Check region selection
406  if (range.match(region_id) && region.group_name() == group_name) {
407  // Build new range up to last_field and add it to result -
408  // remove duplicate ranges with addRangeToMR
409  Range new_range(prefix); // Prepend with prefix
410 
411  size_t nimpl = region.n_implementation();
412  for (size_t i = 0; i < nimpl; ++i) {
414 
415 // new_range.add(impl.m_field);
416  new_range.add(impl.range()->build_range());
417 
418  if (last_field == impl.range()->field()->name()) {
419  break;
420  }
421  }
422  result.add(std::move(new_range));
423  }
424  }
425  }
426 
427  return(result);
428 }
429 
443 int
445  size_t index1,
446  size_t index2,
447  Identifier& packedId) const {
448  packedId = 0;
449 
450 
451  // Preconditions...
452 
453  if (index2 < index1) {
454  // bad parameters.
455  return(1);
456  }
457 
458  if (index1 >= id.fields()) {
459  // nothing very useful !!
460  return(1);
461  }
462 
463  if (index2 >= id.fields()) {
464  // bad parameter...
465  return(1);
466  }
467 
477  for (size_t k = 0; k < m_regions.size(); ++k) {
478  bool selected = true;
479 
480  const IdDictRegion& region = *m_regions[k];
481 
482  // Must skip empty regions - can arise when a tag selects an
483  // empty region
484  if (region.is_empty()) continue;
485 
486  for (size_t i = 0; i < region.n_implementation(); ++i) {
487  if (i >= id.fields()) break;
488 
490 
491  if (!impl.field().match(id[i])) {
492  selected = false;
493  break;
494  }
495  }
496 
497  if (selected) {
498  size_t position = Identifier::NBITS;
499  // We have the proper region.
500  for (size_t i = index1; i <= index2; ++i) {
502 
503  Identifier::value_type index = impl.ored_field().get_value_index(id[i]);
504 
505  if (0 == position && impl.bits() > 0) {
506  return(1);
507  }
508 
509  position -= impl.bits();
510  packedId |= (index << position);
511  }
512  break;
513  }
514  }
515 
516 
517  return(0);
518 }
519 
520 int
522  size_t index1,
523  size_t index2,
524  size_t region_index,
525  Identifier& packedId,
526  size_t first_field_index) const {
527  // Preconditions...
528 
529  if (m_do_checks) {
530  if (index2 < index1) {
531  // bad parameters.
532  std::cout << "IdDictDictionary::pack32 - index2 < index1 - 1,2"
533  << index1 << " " << index2 << std::endl;
534  return(1);
535  }
536 
537  if (region_index >= m_regions.size()) {
538  // bad parameters.
539  std::cout << "IdDictDictionary::pack32 - region index incorrect - index,size"
540  << region_index << " " << m_regions.size() << std::endl;
541  return(1);
542  }
543  }
544 
545 
546  // Get the region
547  const IdDictRegion& region = *m_regions[region_index];
548 
549  if (m_do_checks) {
550  if (region.is_empty()) {
551  std::cout << "IdDictDictionary::pack32 - region id empty" << std::endl;
552  // bad parameters.
553  return(1);
554  }
555  if (index1 < first_field_index) {
556  std::cout << "IdDictDictionary::pack32 - first_field_index > index1 "
557  << first_field_index << " " << index1 << std::endl;
558  return(1);
559  }
560  }
561 
562  // Set the starting position
563  size_t position = Identifier::NBITS;
564  if (!first_field_index) {
566  position -= impl.bits_offset();
567  }
568 
569  size_t field_index = 0;
570  for (size_t i = index1; i <= index2; ++i, ++field_index) {
572 
573  if (m_do_checks) {
574  // Field should be within allowed range
575  if (!impl.ored_field().match(fields[field_index])) {
576  std::cout << "IdDictDictionary::pack32 - field does NOT match: value, allowed values "
577  << fields[field_index] << " " << (std::string) impl.ored_field()
578  << std::endl;
579  // bad parameters.
580  return(1);
581  }
582 
583  // Check that we don't try to go below 0
584  if (0 == position && impl.bits() > 0) {
585  std::cout << "IdDictDictionary::pack32 - going past 0" << std::endl;
586  return(1);
587  }
588  }
589 
591  if (impl.decode_index()) {
592  index = impl.ored_field().get_value_index(fields[field_index]);
593  } else {
594  index = (Identifier::value_type) fields[field_index];
595  }
596 
597  position -= impl.bits();
598  packedId |= (index << position);
599  }
600 
601 
602  return(0);
603 }
604 
609  size_t index2,
610  size_t region_index,
611  Identifier& packedId) const {
612  // Preconditions...
613 
614  if (m_do_checks) {
615  if (index2 < index1) {
616  // bad parameters.
617  std::cout << "IdDictDictionary::pack32 - index2 < index1 - 1,2"
618  << index1 << " " << index2 << std::endl;
619  return(1);
620  }
621 
622  if (region_index >= m_regions.size()) {
623  // bad parameters.
624  std::cout << "IdDictDictionary::pack32 - region index incorrect - index,size"
625  << region_index << " " << m_regions.size() << std::endl;
626  return(1);
627  }
628  }
629 
630 
631  // Get the region
632  const IdDictRegion& region = *m_regions[region_index];
633 
634  if (m_do_checks) {
635  if (region.is_empty()) {
636  std::cout << "IdDictDictionary::pack32 - region id empty" << std::endl;
637  // bad parameters.
638  return(1);
639  }
640  }
641 
642  size_t field_index = 0;
643  for (size_t i = index1; i <= index2; ++i, ++field_index) {
645 
646  size_t position = Identifier::NBITS - impl.bits_offset() - impl.bits();
647 
648  Identifier::value_type mask = (((Identifier::value_type) 1 << impl.bits()) - 1) << position;
649 
651 
652  packedId &= (mask);
653  }
654  return(0);
655 }
656 
664 int IdDictDictionary::unpack(const std::string& group,
665  const Identifier& id,
666  const ExpandedIdentifier& prefix,
667  size_t index2,
668  ExpandedIdentifier& unpackedId) const
669 {
670  const IdDictGroup* g = find_group (group);
671  int ret = 1;
672  if (g) {
673  ret = g->unpack (id, prefix, index2, unpackedId);
674  }
675  return ret;
676 }
677 
685 int IdDictDictionary::unpack(const std::string& group,
686  const Identifier& id,
687  const ExpandedIdentifier& prefix,
688  size_t index2,
689  const std::string& sep,
690  std::string& unpackedId) const
691 {
692  const IdDictGroup* g = find_group (group);
693  ExpandedIdentifier unpacked;
694  std::vector<const IdDictFieldImplementation*> impls;
695  int ret = 1;
696  if (g) {
697  ret = g->unpack (id, prefix, index2, unpacked, &impls);
698  }
699  if (ret == 0) {
700  assert (unpacked.fields() == impls.size());
701  for (size_t i = 0; i < unpacked.fields(); ++i) {
702  // Add value to string
703 
704  std::string str_value("nil");
705 
706  const IdDictFieldImplementation& impl = *impls[i];
708 
709  // The policy below is:
710  // - if a value is a character string or name, just add this name
711  // - if a value is a number, then prefix it with the
712  // name of the field
713  //
714  // NOTE: min/max is a number, but for value/label we
715  // distinguish between number and name by looking for an IdDictLabel
716  const IdDictRange* range = impl.range();
717  const IdDictLabel* label = range->field()->find_label(range->label());
718  switch (range->specification()) {
720  // For a range of values (numbers), add in the field name
721  str_value = range->field()->name() + ' '+std::to_string(value);
722  break;
723 
726  str_value = "";
727  if (!label) {
728  // Is a number, add in field name
729  str_value += range->field()->name() + ' ';
730  }
731  str_value += range->label();
732  break;
733 
736  str_value = "";
737  // Is a name
738  if (label) {
739  // Found label with "find_label" on the field
740  if (label->valued()) {
741  str_value += range->label();
742  }
743  } else {
744  // If not found with the "find" above, we must
745  // get the value and name from the range
746  // itself.
747 
748  unsigned int index1 = 0;
749  for (int v : range->values()) {
750  if (value == v) break;
751  ++index1;
752  }
753 
754  if (index1 < range->labels().size()) {
755  if (isNumber(range->labels()[index1])) {
756  str_value += range->field()->name() + ' ';
757  }
758  str_value += range->labels()[index1];
759  } else {
760  std::cout << "IdDictDictionary::unpack - Could not find value." << std::endl;
761  std::cout << "value " << value << std::endl;
762  std::cout << "field values " << std::endl;
763  for (int v : range->values()) {
764  std::cout << v << " ";
765  }
766  std::cout << std::endl;
767  }
768  }
769  break;
770 
772 
773  std::cout << "unknown" << std::endl;
774 
775  break;
776  }
777 
778  if (i > 0) unpackedId += sep;
779  unpackedId += str_value;
780  }
781  }
782 
783  return ret;
784 }
785 
794 int
796  size_t first_field_index,
797  size_t field_index,
798  size_t region_index,
799  int& field) const {
800  field = 0;
801 
802  if (m_do_checks) {
803  // Check regions
804  if (region_index >= m_regions.size()) {
805  std::cout << "IdDictDictionary::unpack - region index too large. Index, nregions "
806  << region_index << " " << m_regions.size() << std::endl;
807  return(1);
808  }
809  }
810 
811  const IdDictRegion& region = *m_regions.at(region_index);
812 
813  if (m_do_checks) {
814  // check number of fields
815  if (field_index >= region.n_implementation()) {
816  std::cout << "IdDictDictionary::unpack - field index too large. Index, nfields "
817  << field_index << " " << region.n_implementation()
818  << std::endl;
819  return(1);
820  }
821  }
822 
823  const IdDictFieldImplementation& impl = region.implementation(field_index);
824  size_t prefix_offset = 0;
825 
826  size_t position = Identifier::NBITS; // overall bit position
827 
828  // One or more fields missing from prefix, get the offset
829  if (first_field_index) {
830  if (m_do_checks) {
831  if (first_field_index >= region.n_implementation()) {
832  std::cout << "IdDictDictionary::unpack - first_field_index too large. Index, nfields "
833  << first_field_index << " " << region.n_implementation()
834  << std::endl;
835  return(1);
836  }
837  }
838 
839  // One or more fields missing from prefix, get the offset
840  prefix_offset = region.implementation(first_field_index).bits_offset();
841 
842  if (m_do_checks) {
843  // Should have a non-zero number of bits
844  if (impl.bits() == 0) {
845  std::cout << "IdDictDictionary::unpack - no bits for this field. Region, field indexes "
846  << region_index << " " << field_index << std::endl;
847  return(1);
848  }
849 
850  // Check the shift value
851  if (impl.bits() + impl.bits_offset() - prefix_offset > position) {
852  std::cout << "IdDictDictionary::unpack - bits + offset too large. Region, field indexes, bits, offset "
853  << region_index << " " << field_index << " "
854  << impl.bits() << " " << impl.bits_offset() << " " << prefix_offset
855  << std::endl;
856  return(1);
857  }
858  }
859  }
860 
861  Identifier::value_type mask = (static_cast<Identifier::value_type>(1) << impl.bits()) - 1;
862 
863  size_t index = id.extract(position -= impl.bits() + impl.bits_offset() - prefix_offset, mask);
864 
865  field = index;
866  if (impl.decode_index()) field = impl.ored_field().get_value_at(index);
867 
868 
869  return(0);
870 }
871 
881 int
883  size_t first_field_index,
884  size_t begin_field_index,
885  size_t end_field_index,
886  size_t region_index,
887  Identifier& idout) const {
888  idout = Identifier();
889  if (region_index >= m_regions.size()) {
890  std::cout << "IdDictDictionary::copy - region index too large. Index, nregions "
891  << region_index << " " << m_regions.size() << std::endl;
892  return(1);
893  }
894 
895  const IdDictRegion& region = *m_regions[region_index];
896 
897  if (first_field_index >= region.n_implementation() ||
898  begin_field_index >= region.n_implementation() ||
899  end_field_index >= region.n_implementation()) {
900  std::cout << "IdDictDictionary::copy - field index too large. Indexes first, begin, end, nfields "
901  << first_field_index << " "
902  << begin_field_index << " "
903  << end_field_index << " "
905  << std::endl;
906  return(1);
907  }
908 
909  size_t missing_offset = 0;
910  if (first_field_index) {
911  if (first_field_index > begin_field_index) {
912  std::cout << "IdDictDictionary::copy - first_field_index > begin_field_index. Indexes "
913  << first_field_index << " " << begin_field_index << std::endl;
914  return(1);
915  }
916  // One or more fields missing from prefix, get the offset
917  missing_offset = region.implementation(first_field_index).bits_offset();
918  }
919 
920  size_t prefix_offset = 0;
921  if (begin_field_index) {
922  if (begin_field_index > end_field_index) {
923  std::cout << "IdDictDictionary::copy - begin_field_index > end_field_index. Indexes "
924  << begin_field_index << " " << end_field_index << std::endl;
925  return(1);
926  }
927  // One or more fields missing from prefix, get the offset
928  prefix_offset = region.implementation(begin_field_index).bits_offset();
929  }
930 
931  const IdDictFieldImplementation& impl = region.implementation(end_field_index);
932  size_t suffix_offset = impl.bits() + impl.bits_offset();
933 
934  size_t position = Identifier::NBITS; // overall bit position
935 
936  if (position < prefix_offset - missing_offset) {
937  std::cout << "IdDictDictionary::copy - position < prefix + missing. "
938  << prefix_offset << " " << missing_offset << std::endl;
939  return(1);
940  }
941 
942 
943  if (position < suffix_offset + missing_offset) {
944  std::cout << "IdDictDictionary::copy - position < suffix + missing. "
945  << suffix_offset << " " << missing_offset << std::endl;
946  return(1);
947  }
948 
949 
950  // prepare the mask for copying
951 
953 
954  Identifier::value_type prefix_mask =
955  prefix_offset ? (static_cast<Identifier::value_type>(1) << (position - prefix_offset + missing_offset)) - 1 : 0;
956 
957  Identifier::value_type suffix_mask =
958  (static_cast<Identifier::value_type>(1) << (position - suffix_offset + missing_offset)) - 1;
959 
960  mask -= prefix_mask + suffix_mask;
961 
962  idout = idin.mask_shift(mask, missing_offset);
963 
964 
965  return(0);
966 }
967 
968 bool
970  return(m_do_checks);
971 }
972 
973 void
976 }
977 
978 bool
980  return(m_do_neighbours);
981 }
982 
983 void
986 }
987 
1013  // check #1
1014 
1016 
1017  if (mr.has_overlap()) return(false);
1018 
1019 
1020  return(true);
1021 }
1022 
1034  // verify
1035  if (verify()) {
1036  std::map< ExpandedIdentifier, IdDictDictEntry* > regions;
1037 
1039 
1040  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
1041  (*it)->sort();
1042  }
1043  } else {
1044  std::cout << "IdDictDictionary::sort - WARNING verify is FALSE - cannot sort "
1045  << std::endl;
1046  }
1047 }
1048 
1050  {
1052 
1053  for (it = m_subregions.begin(); it != m_subregions.end(); ++it) {
1054  IdDictSubRegion* subregion = (*it).second;
1055  subregion->clear();
1056  delete subregion;
1057  }
1058 
1059  m_subregions.clear();
1060  }
1061 
1062  {
1064 
1065  for (it = m_fields.begin(); it != m_fields.end(); ++it) {
1066  IdDictField* field = (*it).second;
1067  field->clear();
1068  delete field;
1069  }
1070 
1071  m_fields.clear();
1072  }
1073 
1074  {
1076 
1077  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
1078  IdDictGroup* group = *it;
1079  group->clear();
1080  delete group;
1081  }
1082 
1083  m_groups.clear();
1084  }
1085 }
1086 
1087 
1088 void
1090 {
1091  std::cout << "=== IdDictDictionary " << m_name << " " << m_version << " "
1092  << m_date << " " << m_author << "\n";
1093  for (const IdDictGroup* g : m_groups) {
1094  g->dump();
1095  }
1096  std::cout.flush();
1097 }
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
IdDictRange.h
IdDictLabel::value
int value() const
Definition: IdDictLabel.h:51
IdDictMgr.h
IdDictDictionary::dump
void dump() const
Dump regions and trees for each group.
Definition: IdDictDictionary.cxx:1089
IdDictRegion::clear
virtual void clear() override
Definition: IdDictRegion.cxx:225
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictDictionary.cxx:290
IdDictRegion::build_range
virtual Range build_range() const override
Definition: IdDictRegion.cxx:265
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
get_generator_info.result
result
Definition: get_generator_info.py:21
IdDictGroup
Definition: IdDictGroup.h:25
IdDictLabel.h
IdDictDictionary::generate_implementation
void generate_implementation(const IdDictMgr &idd, const std::string &tag="")
Definition: IdDictDictionary.cxx:172
IdDictRange::by_minmax
@ by_minmax
Definition: IdDictRange.h:26
IdDictDictionary::m_groups
std::vector< IdDictGroup * > m_groups
Definition: IdDictDictionary.h:314
IdDict::get_bits
void get_bits(const RV &regions, size_t level, const std::string &group)
Definition: get_bits.cxx:45
index
Definition: index.py:1
IdDictDictionary::region
const IdDictRegion & region(size_t i) const
Region at index i.
Definition: IdDictDictionary.h:350
IdDictRange::by_label
@ by_label
Definition: IdDictRange.h:24
IdDictDictionary::find_label
IdDictLabel * find_label(const std::string &field, const std::string &label) const
Definition: IdDictDictionary.cxx:67
Identifier::mask_shift
value_type mask_shift(value_type mask, size_type shift) const
extract field(s) by masking first, then shifting
IdDictDictionary.h
skel.it
it
Definition: skel.GENtoEVGEN.py:407
IdDictRange::by_labels
@ by_labels
Definition: IdDictRange.h:25
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
IdDictDictionary::m_do_checks
bool m_do_checks
Definition: IdDictDictionary.h:321
IdDictField::find_label
IdDictLabel * find_label(const std::string &name) const
Definition: IdDictField.cxx:23
athena.value
value
Definition: athena.py:124
ExpandedIdentifier::fields
size_type fields() const
IdDictSubRegion.h
IdDictDictionary::~IdDictDictionary
~IdDictDictionary()
Debugger.h
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
IdDictDictionary::name
const std::string & name() const
Dictionary name.
Definition: IdDictDictionary.h:332
IdDictLabel::valued
bool valued() const
Definition: IdDictLabel.h:58
m_name
std::string m_name
Definition: ColumnarPhysliteTest.cxx:63
IdDictDictEntry
Definition: IdDictDictEntry.h:13
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
IdDictGroup.h
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
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:459
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
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
IdDictDictionary::m_parent_dict
IdDictDictionary * m_parent_dict
Definition: IdDictDictionary.h:316
get_bits.h
IdDictLabel
Definition: IdDictLabel.h:10
IdDictRegion::implementation
const IdDictFieldImplementation & implementation(size_t i) const
Definition: IdDictRegion.cxx:34
IdDictMgr
Definition: IdDictMgr.h:14
IdDictDictionary::m_fields
std::map< std::string, IdDictField * > m_fields
Definition: IdDictDictionary.h:310
beamspotnt.labels
list labels
Definition: bin/beamspotnt.py:1446
IdDictDictionary::IdDictDictionary
IdDictDictionary()
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name) const
Definition: IdDictDictionary.cxx:115
Identifier::ALL_BITS
static constexpr value_type ALL_BITS
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:33
Trk::index1
@ index1
Definition: BoundarySurfaceFace.h:48
Identifier::NBITS
static constexpr unsigned int NBITS
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:31
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictDictionary::m_author
std::string m_author
Definition: IdDictDictionary.h:296
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
IdDictDictionary::m_generated_implementation
bool m_generated_implementation
Definition: IdDictDictionary.h:320
IdDictFieldImplementation::bits_offset
size_type bits_offset() const
Definition: IdDictFieldImplementation.h:208
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
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
IdDictRange::unknown
@ unknown
Definition: IdDictRange.h:21
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
IdDictRegion::integrate_bits
void integrate_bits()
Definition: IdDictRegion.cxx:246
Debugger::debug
static bool debug()
Definition: Debugger.h:18
IdDictRegion::n_implementation
size_t n_implementation() const
Definition: IdDictRegion.cxx:28
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
python.update_ci_reference_files.mr
mr
Definition: update_ci_reference_files.py:415
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
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
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
MultiRange.h
IdDictDictionary::size_type
Identifier::size_type size_type
Definition: IdDictDictionary.h:33
IdDictDictionary
Definition: IdDictDictionary.h:30
IdDictFieldImplementation.h
IdDictDictionary::find_subregion
IdDictSubRegion * find_subregion(const std::string &subregion_name) const
Definition: IdDictDictionary.cxx:91
IdDictRange
Definition: IdDictRange.h:18
python.PyAthena.v
v
Definition: PyAthena.py:154
get_generator_info.version
version
Definition: get_generator_info.py:33
impl
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:46
DeMoScan.index
string index
Definition: DeMoScan.py:362
IdDictDictionary::m_subdictionary_names
std::vector< std::string > m_subdictionary_names
Definition: IdDictDictionary.h:315
IdDictField.h
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
IdDictDictionary::m_name
std::string m_name
Definition: IdDictDictionary.h:293
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
MultiRange::size
size_type size() const
Definition: MultiRange.cxx:70
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:25
IdDictRange::by_values
@ by_values
Definition: IdDictRange.h:23
Range::add
void add(element_type value)
Add a required value. (ie. low = high = value)
Definition: DetectorDescription/Identifier/src/Range.cxx:76
Identifier::value_type
unsigned long long value_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:27
isNumber
bool isNumber(const std::string &s)
Definition: PoolSvc.cxx:53
str
Definition: BTagTrackIpAccessor.cxx:11
IdDictRegion.h
IdDictSubRegion
Definition: IdDictSubRegion.h:13
IdDictRange::by_value
@ by_value
Definition: IdDictRange.h:22
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
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdDictRegion::is_empty
bool is_empty() const
Definition: IdDictRegion.h:287
IdDictDictionary::integrate_bits
void integrate_bits()
Set up integral of bits for efficient unpacking.
Definition: IdDictDictionary.cxx:281
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:106
IdDictRegion::name
const std::string & name() const
Definition: IdDictRegion.h:154
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
fitman.k
k
Definition: fitman.py:528
IdDictRegion::group_name
virtual std::string group_name() const override
Definition: IdDictRegion.cxx:23
IdDictDictionary::m_all_regions
std::vector< IdDictRegion * > m_all_regions
Definition: IdDictDictionary.h:313
IdDictRegion::resolve_references
virtual void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary) override
Definition: IdDictRegion.cxx:127
Identifier
Definition: IdentifierFieldParser.cxx:14
IdDictDictionary::set_do_checks
void set_do_checks(bool do_checks)
Definition: IdDictDictionary.cxx:974