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 const IdDictField* IdDictDictionary::find_field(const std::string& name) const {
48  auto it = m_fields.find(name);
49 
50  if (it == m_fields.end()) {
51  // If parent exists, look for field there
52  if (m_parent_dict) {
53  it = m_parent_dict->m_fields.find(name);
54  if (it == m_parent_dict->m_fields.end()) {
55  return nullptr;
56  }
57  } else {
58  return nullptr;
59  }
60  }
61 
62  return it->second;
63 }
64 
66  auto it = m_fields.find(name);
67 
68  if (it == m_fields.end()) {
69  // If parent exists, look for field there
70  if (m_parent_dict) {
71  it = m_parent_dict->m_fields.find(name);
72  if (it == m_parent_dict->m_fields.end()) {
73  return nullptr;
74  }
75  } else {
76  return nullptr;
77  }
78  }
79 
80  return it->second;
81 }
82 
83 const IdDictLabel*
84 IdDictDictionary::find_label(const std::string& field, const std::string& label) const {
85  const IdDictField* idField = find_field(field);
86 
87  if (!idField) return nullptr;
88 
89  return(idField->find_label(label));
90 }
91 
92 int IdDictDictionary::get_label_value(const std::string& field, const std::string& label, int& value) const {
93  const IdDictLabel* idLabel = find_label(field, label);
94 
95  if (!idLabel || !idLabel->valued()) return(1);
96 
97  value = idLabel->value();
98  return(0);
99 }
100 
102  if (field == 0) return;
103 
104  m_fields[field->name()] = field;
105 }
106 
109  std::map <std::string, IdDictSubRegion*>::const_iterator it;
110 
111  it = m_subregions.find(name);
112 
113  if (it == m_subregions.end()) return(0);
114 
115  return((*it).second);
116 }
117 
118 const IdDictRegion*
119 IdDictDictionary::find_region(const std::string& region_name) const {
120  return find_region(region_name, "");
121 }
122 
124 IdDictDictionary::find_region(const std::string& region_name, const std::string& group_name) {
125  for (IdDictRegion* region : m_regions) {
126  if (!region) continue;
127  if ((group_name != "") && (region->group_name() != group_name)) continue;
128  if ((region_name != "") && (region->name() != region_name)) continue;
129  return region;
130  }
131  return nullptr;
132 }
133 
134 const IdDictRegion*
135 IdDictDictionary::find_region(const std::string& region_name, const std::string& group_name) const {
136  for (IdDictRegion* region : m_regions) {
137  if (!region) continue;
138  if ((group_name != "") && (region->group_name() != group_name)) continue;
139  if ((region_name != "") && (region->name() != region_name)) continue;
140  return region;
141  }
142  return nullptr;
143 }
144 
147  for (IdDictGroup* g : m_groups) {
148  if (g && g->name() == group_name) return g;
149  }
150  return nullptr;
151 }
152 
153 const IdDictGroup*
154 IdDictDictionary::find_group(const std::string& group_name) const {
155  for (const IdDictGroup* g : m_groups) {
156  if (g && g->name() == group_name) return g;
157  }
158  return nullptr;
159 }
160 
162  if (subregion == 0) return;
163  m_subregions[subregion->name()] = subregion;
164 }
165 
167  m_subdictionary_names.push_back(name);
168 }
169 
171 {
172  m_parent_dict = parent_dict;
173 }
174 
176  // Add region to corresponding group
178 
179  if (0 == group) {
181  m_groups.push_back(group);
182  }
183  group->add_dictentry(region);
184 }
185 
187  m_all_regions.push_back(region);
188 }
189 
191  {
193 
194  for (it = m_subregions.begin(); it != m_subregions.end(); ++it) {
195  IdDictSubRegion* subregion = (*it).second;
196  subregion->resolve_references(idd, *this);
197  }
198  }
199  {
200  size_t index = 0;
201  for (IdDictGroup* g : m_groups) {
202  g->resolve_references(idd, *this, index);
203  }
204  }
205 }
206 
208  const std::string& tag) {
209  if (Debugger::debug()) {
210  std::cout << "IdDictDictionary::generate_implementation>" << std::endl;
211  }
212 
214  // Propagate to each region and copy their generation into the
215  // dict's vector.
216  for (IdDictGroup* g : m_groups) {
217  g->generate_implementation(idd, *this, tag);
218  // Get regions from group and save in m_regions
219  for (IdDictRegion* re : g->regions()) {
220  m_regions.push_back(re);
221  }
222  }
223 
224  // Loop again over groups and set the bit-packing - starting at
225  // level 0
226  for (IdDictGroup* g : m_groups) {
227  // Copy to temporary vector all regions in the group. And
228  // look for regions in local m_regions vector for any
229  // regions "dummy", which come from reference
230  // dictionaries.
231  // Skip special group
232  if ("dummy" == g->name()) continue;
233 
234  get_bits(m_regions, 0, g->name());
235  }
236 
237  // Set integral over the number of bits
238  integrate_bits();
239 
240  for (IdDictGroup* g : m_groups) {
241  g->build_region_tree();
242  }
243 
244  // Set neighbours for regions
246  for (itr = m_regions.begin(); itr != m_regions.end(); ++itr) {
247  (*itr)->find_neighbours(*this);
248  }
249 
251  }
252 }
253 
256  m_regions.clear();
258  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
259  (*it)->reset_implementation();
260  }
262  }
263 }
264 
265 int
267  // Find first region that matches id
268 
270 
271  size_type i = 0;
272  for (it = m_regions.begin(); it != m_regions.end(); ++it, ++i) {
273  const IdDictRegion& region = *(*it);
274 
276 
277  if (range.match(id) && range.fields() >= id.fields()) {
278  index = i;
279  return(0);
280  }
281  }
282 
283  return(1);
284 }
285 
287  return find_region(id, "");
288 }
289 
290 const IdDictRegion* IdDictDictionary::find_region(const ExpandedIdentifier& id, const std::string& group_name) const {
291  // Find first region that matches id
292 
293  IdDictRegion* pRegion = 0;
294 
296 
297  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
298  IdDictRegion& region = *(*it);
299  if ((group_name != "") && (region.group_name() != group_name)) continue;
300 
302 
303  if (range.match(id) && range.fields() >= id.fields()) {
304  pRegion = &region;
305  }
306  }
307 
308  return(pRegion);
309 }
310 
311 void
313  // For each region, loop over its levels and set the bit offset
314  // for each FieldImplementation
315 
316  for (IdDictRegion* region : m_regions) {
318  }
319 }
320 
323 
325 
326  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
327  const IdDictGroup& group = *(*it);
328 
329  MultiRange group_mr = group.build_multirange();
330 
331  for (unsigned int i = 0; i < group_mr.size(); ++i) {
332  const Range& range = group_mr[i];
333  result.add(range);
334  }
335  }
336 
337  return(result);
338 }
339 
341  const Range& prefix,
342  const std::string& last_field) const {
344 
346  if ("" == last_field) {
347  // Take all fields
348  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
349  const IdDictRegion& region = *(*it);
350 
351  // skip regions created from parents
352  if ("dummy" == region.name()) continue;
353 
354  // skip empty regions - may arise from alternate_regions
355  // where a tag selects an empty region
356  if (region.is_empty()) continue;
357 
359  // Check region selection
360  if (range.match(region_id)) result.add(std::move(range));
361  }
362  } else {
363  // Not all fields required
364  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
365  const IdDictRegion& region = *(*it);
366 
367  // skip regions created from parents
368  if ("dummy" == region.name()) continue;
369 
370  // skip empty regions - may arise from alternate_regions
371  // where a tag selects an empty region
372  if (region.is_empty()) continue;
373 
375  // Check region selection
376  if (range.match(region_id)) {
377  // Build new range up to last_field and add it to result -
378  // remove duplicate ranges with addRangeToMR
379  Range new_range(prefix); // Prepend with prefix
380 
381  size_t nimpl = region.n_implementation();
382  for (size_t i = 0; i < nimpl; ++i) {
384 
385 // new_range.add(impl.m_field);
386  new_range.add(impl.range()->build_range());
387 
388  if (last_field == impl.range()->field()->name()) {
389  break;
390  }
391  }
392  result.add(std::move(new_range));
393  }
394  }
395  }
396 
397  return(result);
398 }
399 
401  const std::string& group_name,
402  const Range& prefix,
403  const std::string& last_field) const {
405 
407  if ("" == last_field) {
408  // Take all fields
409  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
410  const IdDictRegion& region = *(*it);
411 
412  // skip regions created from parents
413  if ("dummy" == region.name()) continue;
414 
415  // skip empty regions - may arise from alternate_regions
416  // where a tag selects an empty region
417  if (region.is_empty()) continue;
418 
420  // Check region selection
421  if (range.match(region_id) && region.group_name() == group_name) result.add(std::move(range));
422  }
423  } else {
424  // Not all fields required
425  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
426  const IdDictRegion& region = *(*it);
427 
428  // skip regions created from parents
429  if ("dummy" == region.name()) continue;
430 
431  // skip empty regions - may arise from alternate_regions
432  // where a tag selects an empty region
433  if (region.is_empty()) continue;
434 
436  // Check region selection
437  if (range.match(region_id) && region.group_name() == group_name) {
438  // Build new range up to last_field and add it to result -
439  // remove duplicate ranges with addRangeToMR
440  Range new_range(prefix); // Prepend with prefix
441 
442  size_t nimpl = region.n_implementation();
443  for (size_t i = 0; i < nimpl; ++i) {
445 
446 // new_range.add(impl.m_field);
447  new_range.add(impl.range()->build_range());
448 
449  if (last_field == impl.range()->field()->name()) {
450  break;
451  }
452  }
453  result.add(std::move(new_range));
454  }
455  }
456  }
457 
458  return(result);
459 }
460 
474 int
476  size_t index1,
477  size_t index2,
478  Identifier& packedId) const {
479  packedId = 0;
480 
481 
482  // Preconditions...
483 
484  if (index2 < index1) {
485  // bad parameters.
486  return(1);
487  }
488 
489  if (index1 >= id.fields()) {
490  // nothing very useful !!
491  return(1);
492  }
493 
494  if (index2 >= id.fields()) {
495  // bad parameter...
496  return(1);
497  }
498 
508  for (size_t k = 0; k < m_regions.size(); ++k) {
509  bool selected = true;
510 
511  const IdDictRegion& region = *m_regions[k];
512 
513  // Must skip empty regions - can arise when a tag selects an
514  // empty region
515  if (region.is_empty()) continue;
516 
517  for (size_t i = 0; i < region.n_implementation(); ++i) {
518  if (i >= id.fields()) break;
519 
521 
522  if (!impl.field().match(id[i])) {
523  selected = false;
524  break;
525  }
526  }
527 
528  if (selected) {
529  size_t position = Identifier::NBITS;
530  // We have the proper region.
531  for (size_t i = index1; i <= index2; ++i) {
533 
534  Identifier::value_type index = impl.ored_field().get_value_index(id[i]);
535 
536  if (0 == position && impl.bits() > 0) {
537  return(1);
538  }
539 
540  position -= impl.bits();
541  packedId |= (index << position);
542  }
543  break;
544  }
545  }
546 
547 
548  return(0);
549 }
550 
551 int
553  size_t index1,
554  size_t index2,
555  size_t region_index,
556  Identifier& packedId,
557  size_t first_field_index) const {
558  // Preconditions...
559 
560  if (m_do_checks) {
561  if (index2 < index1) {
562  // bad parameters.
563  std::cout << "IdDictDictionary::pack32 - index2 < index1 - 1,2"
564  << index1 << " " << index2 << std::endl;
565  return(1);
566  }
567 
568  if (region_index >= m_regions.size()) {
569  // bad parameters.
570  std::cout << "IdDictDictionary::pack32 - region index incorrect - index,size"
571  << region_index << " " << m_regions.size() << std::endl;
572  return(1);
573  }
574  }
575 
576 
577  // Get the region
578  const IdDictRegion& region = *m_regions[region_index];
579 
580  if (m_do_checks) {
581  if (region.is_empty()) {
582  std::cout << "IdDictDictionary::pack32 - region id empty" << std::endl;
583  // bad parameters.
584  return(1);
585  }
586  if (index1 < first_field_index) {
587  std::cout << "IdDictDictionary::pack32 - first_field_index > index1 "
588  << first_field_index << " " << index1 << std::endl;
589  return(1);
590  }
591  }
592 
593  // Set the starting position
594  size_t position = Identifier::NBITS;
595  if (!first_field_index) {
597  position -= impl.bits_offset();
598  }
599 
600  size_t field_index = 0;
601  for (size_t i = index1; i <= index2; ++i, ++field_index) {
603 
604  if (m_do_checks) {
605  // Field should be within allowed range
606  if (!impl.ored_field().match(fields[field_index])) {
607  std::cout << "IdDictDictionary::pack32 - field does NOT match: value, allowed values "
608  << fields[field_index] << " " << (std::string) impl.ored_field()
609  << std::endl;
610  // bad parameters.
611  return(1);
612  }
613 
614  // Check that we don't try to go below 0
615  if (0 == position && impl.bits() > 0) {
616  std::cout << "IdDictDictionary::pack32 - going past 0" << std::endl;
617  return(1);
618  }
619  }
620 
622  if (impl.decode_index()) {
623  index = impl.ored_field().get_value_index(fields[field_index]);
624  } else {
625  index = (Identifier::value_type) fields[field_index];
626  }
627 
628  position -= impl.bits();
629  packedId |= (index << position);
630  }
631 
632 
633  return(0);
634 }
635 
640  size_t index2,
641  size_t region_index,
642  Identifier& packedId) const {
643  // Preconditions...
644 
645  if (m_do_checks) {
646  if (index2 < index1) {
647  // bad parameters.
648  std::cout << "IdDictDictionary::pack32 - index2 < index1 - 1,2"
649  << index1 << " " << index2 << std::endl;
650  return(1);
651  }
652 
653  if (region_index >= m_regions.size()) {
654  // bad parameters.
655  std::cout << "IdDictDictionary::pack32 - region index incorrect - index,size"
656  << region_index << " " << m_regions.size() << std::endl;
657  return(1);
658  }
659  }
660 
661 
662  // Get the region
663  const IdDictRegion& region = *m_regions[region_index];
664 
665  if (m_do_checks) {
666  if (region.is_empty()) {
667  std::cout << "IdDictDictionary::pack32 - region id empty" << std::endl;
668  // bad parameters.
669  return(1);
670  }
671  }
672 
673  size_t field_index = 0;
674  for (size_t i = index1; i <= index2; ++i, ++field_index) {
676 
677  size_t position = Identifier::NBITS - impl.bits_offset() - impl.bits();
678 
679  Identifier::value_type mask = (((Identifier::value_type) 1 << impl.bits()) - 1) << position;
680 
682 
683  packedId &= (mask);
684  }
685  return(0);
686 }
687 
695 int IdDictDictionary::unpack(const std::string& group,
696  const Identifier& id,
697  const ExpandedIdentifier& prefix,
698  size_t index2,
699  ExpandedIdentifier& unpackedId) const
700 {
701  const IdDictGroup* g = find_group (group);
702  int ret = 1;
703  if (g) {
704  ret = g->unpack (id, prefix, index2, unpackedId);
705  }
706  return ret;
707 }
708 
716 int IdDictDictionary::unpack(const std::string& group,
717  const Identifier& id,
718  const ExpandedIdentifier& prefix,
719  size_t index2,
720  const std::string& sep,
721  std::string& unpackedId) const
722 {
723  const IdDictGroup* g = find_group (group);
724  ExpandedIdentifier unpacked;
725  std::vector<const IdDictFieldImplementation*> impls;
726  int ret = 1;
727  if (g) {
728  ret = g->unpack (id, prefix, index2, unpacked, &impls);
729  }
730  if (ret == 0) {
731  assert (unpacked.fields() == impls.size());
732  for (size_t i = 0; i < unpacked.fields(); ++i) {
733  // Add value to string
734 
735  std::string str_value("nil");
736 
737  const IdDictFieldImplementation& impl = *impls[i];
739 
740  // The policy below is:
741  // - if a value is a character string or name, just add this name
742  // - if a value is a number, then prefix it with the
743  // name of the field
744  //
745  // NOTE: min/max is a number, but for value/label we
746  // distinguish between number and name by looking for an IdDictLabel
747  const IdDictRange* range = impl.range();
748  const IdDictLabel* label = range->field()->find_label(range->label());
749  switch (range->specification()) {
751  // For a range of values (numbers), add in the field name
752  str_value = range->field()->name() + ' '+std::to_string(value);
753  break;
754 
757  str_value = "";
758  if (!label) {
759  // Is a number, add in field name
760  str_value += range->field()->name() + ' ';
761  }
762  str_value += range->label();
763  break;
764 
767  str_value = "";
768  // Is a name
769  if (label) {
770  // Found label with "find_label" on the field
771  if (label->valued()) {
772  str_value += range->label();
773  }
774  } else {
775  // If not found with the "find" above, we must
776  // get the value and name from the range
777  // itself.
778 
779  unsigned int index1 = 0;
780  for (int v : range->values()) {
781  if (value == v) break;
782  ++index1;
783  }
784 
785  if (index1 < range->labels().size()) {
786  if (isNumber(range->labels()[index1])) {
787  str_value += range->field()->name() + ' ';
788  }
789  str_value += range->labels()[index1];
790  } else {
791  std::cout << "IdDictDictionary::unpack - Could not find value." << std::endl;
792  std::cout << "value " << value << std::endl;
793  std::cout << "field values " << std::endl;
794  for (int v : range->values()) {
795  std::cout << v << " ";
796  }
797  std::cout << std::endl;
798  }
799  }
800  break;
801 
803 
804  std::cout << "unknown" << std::endl;
805 
806  break;
807  }
808 
809  if (i > 0) unpackedId += sep;
810  unpackedId += str_value;
811  }
812  }
813 
814  return ret;
815 }
816 
825 int
827  size_t first_field_index,
828  size_t field_index,
829  size_t region_index,
830  int& field) const {
831  field = 0;
832 
833  if (m_do_checks) {
834  // Check regions
835  if (region_index >= m_regions.size()) {
836  std::cout << "IdDictDictionary::unpack - region index too large. Index, nregions "
837  << region_index << " " << m_regions.size() << std::endl;
838  return(1);
839  }
840  }
841 
842  const IdDictRegion& region = *m_regions.at(region_index);
843 
844  if (m_do_checks) {
845  // check number of fields
846  if (field_index >= region.n_implementation()) {
847  std::cout << "IdDictDictionary::unpack - field index too large. Index, nfields "
848  << field_index << " " << region.n_implementation()
849  << std::endl;
850  return(1);
851  }
852  }
853 
854  const IdDictFieldImplementation& impl = region.implementation(field_index);
855  size_t prefix_offset = 0;
856 
857  size_t position = Identifier::NBITS; // overall bit position
858 
859  // One or more fields missing from prefix, get the offset
860  if (first_field_index) {
861  if (m_do_checks) {
862  if (first_field_index >= region.n_implementation()) {
863  std::cout << "IdDictDictionary::unpack - first_field_index too large. Index, nfields "
864  << first_field_index << " " << region.n_implementation()
865  << std::endl;
866  return(1);
867  }
868  }
869 
870  // One or more fields missing from prefix, get the offset
871  prefix_offset = region.implementation(first_field_index).bits_offset();
872 
873  if (m_do_checks) {
874  // Should have a non-zero number of bits
875  if (impl.bits() == 0) {
876  std::cout << "IdDictDictionary::unpack - no bits for this field. Region, field indexes "
877  << region_index << " " << field_index << std::endl;
878  return(1);
879  }
880 
881  // Check the shift value
882  if (impl.bits() + impl.bits_offset() - prefix_offset > position) {
883  std::cout << "IdDictDictionary::unpack - bits + offset too large. Region, field indexes, bits, offset "
884  << region_index << " " << field_index << " "
885  << impl.bits() << " " << impl.bits_offset() << " " << prefix_offset
886  << std::endl;
887  return(1);
888  }
889  }
890  }
891 
892  Identifier::value_type mask = (static_cast<Identifier::value_type>(1) << impl.bits()) - 1;
893 
894  size_t index = id.extract(position -= impl.bits() + impl.bits_offset() - prefix_offset, mask);
895 
896  field = index;
897  if (impl.decode_index()) field = impl.ored_field().get_value_at(index);
898 
899 
900  return(0);
901 }
902 
912 int
914  size_t first_field_index,
915  size_t begin_field_index,
916  size_t end_field_index,
917  size_t region_index,
918  Identifier& idout) const {
919  idout = Identifier();
920  if (region_index >= m_regions.size()) {
921  std::cout << "IdDictDictionary::copy - region index too large. Index, nregions "
922  << region_index << " " << m_regions.size() << std::endl;
923  return(1);
924  }
925 
926  const IdDictRegion& region = *m_regions[region_index];
927 
928  if (first_field_index >= region.n_implementation() ||
929  begin_field_index >= region.n_implementation() ||
930  end_field_index >= region.n_implementation()) {
931  std::cout << "IdDictDictionary::copy - field index too large. Indexes first, begin, end, nfields "
932  << first_field_index << " "
933  << begin_field_index << " "
934  << end_field_index << " "
936  << std::endl;
937  return(1);
938  }
939 
940  size_t missing_offset = 0;
941  if (first_field_index) {
942  if (first_field_index > begin_field_index) {
943  std::cout << "IdDictDictionary::copy - first_field_index > begin_field_index. Indexes "
944  << first_field_index << " " << begin_field_index << std::endl;
945  return(1);
946  }
947  // One or more fields missing from prefix, get the offset
948  missing_offset = region.implementation(first_field_index).bits_offset();
949  }
950 
951  size_t prefix_offset = 0;
952  if (begin_field_index) {
953  if (begin_field_index > end_field_index) {
954  std::cout << "IdDictDictionary::copy - begin_field_index > end_field_index. Indexes "
955  << begin_field_index << " " << end_field_index << std::endl;
956  return(1);
957  }
958  // One or more fields missing from prefix, get the offset
959  prefix_offset = region.implementation(begin_field_index).bits_offset();
960  }
961 
962  const IdDictFieldImplementation& impl = region.implementation(end_field_index);
963  size_t suffix_offset = impl.bits() + impl.bits_offset();
964 
965  size_t position = Identifier::NBITS; // overall bit position
966 
967  if (position < prefix_offset - missing_offset) {
968  std::cout << "IdDictDictionary::copy - position < prefix + missing. "
969  << prefix_offset << " " << missing_offset << std::endl;
970  return(1);
971  }
972 
973 
974  if (position < suffix_offset + missing_offset) {
975  std::cout << "IdDictDictionary::copy - position < suffix + missing. "
976  << suffix_offset << " " << missing_offset << std::endl;
977  return(1);
978  }
979 
980 
981  // prepare the mask for copying
982 
984 
985  Identifier::value_type prefix_mask =
986  prefix_offset ? (static_cast<Identifier::value_type>(1) << (position - prefix_offset + missing_offset)) - 1 : 0;
987 
988  Identifier::value_type suffix_mask =
989  (static_cast<Identifier::value_type>(1) << (position - suffix_offset + missing_offset)) - 1;
990 
991  mask -= prefix_mask + suffix_mask;
992 
993  idout = idin.mask_shift(mask, missing_offset);
994 
995 
996  return(0);
997 }
998 
999 bool
1001  return(m_do_checks);
1002 }
1003 
1004 void
1007 }
1008 
1009 bool
1011  return(m_do_neighbours);
1012 }
1013 
1014 void
1017 }
1018 
1044  // check #1
1045 
1047 
1048  if (mr.has_overlap()) return(false);
1049 
1050 
1051  return(true);
1052 }
1053 
1065  // verify
1066  if (verify()) {
1067  std::map< ExpandedIdentifier, IdDictDictEntry* > regions;
1068 
1070 
1071  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
1072  (*it)->sort();
1073  }
1074  } else {
1075  std::cout << "IdDictDictionary::sort - WARNING verify is FALSE - cannot sort "
1076  << std::endl;
1077  }
1078 }
1079 
1081  {
1083 
1084  for (it = m_subregions.begin(); it != m_subregions.end(); ++it) {
1085  IdDictSubRegion* subregion = (*it).second;
1086  subregion->clear();
1087  delete subregion;
1088  }
1089 
1090  m_subregions.clear();
1091  }
1092 
1093  {
1095 
1096  for (it = m_fields.begin(); it != m_fields.end(); ++it) {
1097  IdDictField* field = (*it).second;
1098  field->clear();
1099  delete field;
1100  }
1101 
1102  m_fields.clear();
1103  }
1104 
1105  {
1107 
1108  for (it = m_groups.begin(); it != m_groups.end(); ++it) {
1109  IdDictGroup* group = *it;
1110  group->clear();
1111  delete group;
1112  }
1113 
1114  m_groups.clear();
1115  }
1116 }
1117 
1118 
1119 void
1121 {
1122  std::cout << "=== IdDictDictionary " << m_name << " " << m_version << " "
1123  << m_date << " " << m_author << "\n";
1124  for (const IdDictGroup* g : m_groups) {
1125  g->dump();
1126  }
1127  std::cout.flush();
1128 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
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:1120
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:321
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:639
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:207
IdDictRange::by_minmax
@ by_minmax
Definition: IdDictRange.h:26
IdDictDictionary::m_groups
std::vector< IdDictGroup * > m_groups
Definition: IdDictDictionary.h:317
IdDictDictionary::resolve_references
void resolve_references(IdDictMgr &idd)
Definition: IdDictDictionary.cxx:190
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:353
IdDictRange::by_label
@ by_label
Definition: IdDictRange.h:24
Identifier::mask_shift
value_type mask_shift(value_type mask, size_type shift) const
extract field(s) by masking first, then shifting
IdDictDictionary.h
IdDictDictionary::find_subregion
IdDictSubRegion * find_subregion(const std::string &subregion_name)
Definition: IdDictDictionary.cxx:108
skel.it
it
Definition: skel.GENtoEVGEN.py:407
IdDictRange::by_labels
@ by_labels
Definition: IdDictRange.h:25
IdDictDictionary::find_field
const IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:47
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
IdDictDictionary::m_do_checks
bool m_do_checks
Definition: IdDictDictionary.h:324
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:335
IdDictLabel::valued
bool valued() const
Definition: IdDictLabel.h:58
m_name
std::string m_name
Definition: ColumnarPhysliteTest.cxx:64
MuonR4::to_string
std::string to_string(const SectorProjector proj)
Definition: MsTrackSeeder.cxx:66
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::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:475
IdDictGroup.h
CalibDbCompareRT.region_id
region_id
Definition: CalibDbCompareRT.py:67
IdDictRegion
Definition: IdDictRegion.h:20
IdDictDictionary::m_version
std::string m_version
Definition: IdDictDictionary.h:297
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:1043
IdDictDictionary::reset_implementation
void reset_implementation()
Definition: IdDictDictionary.cxx:254
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
IdDictDictionary::m_parent_dict
IdDictDictionary * m_parent_dict
Definition: IdDictDictionary.h:319
get_bits.h
IdDictLabel
Definition: IdDictLabel.h:10
IdDictDictionary::find_region
const IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictDictionary.cxx:119
IdDictRegion::implementation
const IdDictFieldImplementation & implementation(size_t i) const
Definition: IdDictRegion.cxx:34
IdDictMgr
Definition: IdDictMgr.h:15
IdDictDictionary::m_fields
std::map< std::string, IdDictField * > m_fields
Definition: IdDictDictionary.h:313
beamspotnt.labels
list labels
Definition: bin/beamspotnt.py:1446
IdDictDictionary::IdDictDictionary
IdDictDictionary()
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:299
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
IdDictDictionary::m_generated_implementation
bool m_generated_implementation
Definition: IdDictDictionary.h:323
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:310
IdDictDictionary::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictDictionary.h:315
IdDictDictionary::groups_const_it
groups_type::const_iterator groups_const_it
Definition: IdDictDictionary.h:311
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:166
IdDictDictionary::regions_const_it
regions_type::const_iterator regions_const_it
Definition: IdDictDictionary.h:307
IdDictRegion::resolve_references
virtual void resolve_references(IdDictMgr &idd, IdDictDictionary &dictionary) override
Definition: IdDictRegion.cxx:127
IdDictDictionary::do_checks
bool do_checks() const
Checks are performed by default in debug compilation and NOT in optimized compilation.
Definition: IdDictDictionary.cxx:1000
IdDictRegion::integrate_bits
void integrate_bits()
Definition: IdDictRegion.cxx:246
Debugger::debug
static bool debug()
Definition: Debugger.h:18
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name)
Definition: IdDictDictionary.cxx:146
IdDictRegion::n_implementation
size_t n_implementation() const
Definition: IdDictRegion.cxx:28
IdDictDictionary::m_date
std::string m_date
Definition: IdDictDictionary.h:298
IdDictDictionary::get_label_value
int get_label_value(const std::string &field, const std::string &label, int &value) const
Definition: IdDictDictionary.cxx:92
python.update_ci_reference_files.mr
mr
Definition: update_ci_reference_files.py:418
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:695
IdDictDictionary::sort
void sort()
Sort:
Definition: IdDictDictionary.cxx:1064
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:186
IdDictDictionary::clear
void clear()
Definition: IdDictDictionary.cxx:1080
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
IdDictDictionary::add_field
void add_field(IdDictField *field)
Definition: IdDictDictionary.cxx:101
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:1010
IdDictDictionary::m_do_neighbours
bool m_do_neighbours
Definition: IdDictDictionary.h:325
IdDictDictionary::regions_it
regions_type::iterator regions_it
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
MultiRange.h
IdDictDictionary::size_type
Identifier::size_type size_type
Definition: IdDictDictionary.h:33
IdDictDictionary
Definition: IdDictDictionary.h:30
IdDictFieldImplementation.h
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:318
IdDictField.h
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
IdDictDictionary::m_name
std::string m_name
Definition: IdDictDictionary.h:296
IdDictDictionary::m_subregions
std::map< std::string, IdDictSubRegion * > m_subregions
Definition: IdDictDictionary.h:314
IdDictDictionary::add_dictentry
void add_dictentry(IdDictDictEntry *entry)
Definition: IdDictDictionary.cxx:175
IdDictDictionary::set_parent_dict
void set_parent_dict(IdDictDictionary *parent_dict)
Definition: IdDictDictionary.cxx:170
MultiRange::size
size_type size() const
Definition: MultiRange.cxx:70
re
const boost::regex re(r_e)
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:1015
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:312
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:913
IdDictDictionary::add_subregion
void add_subregion(IdDictSubRegion *subregion)
Definition: IdDictDictionary.cxx:161
IdDictField::find_label
const IdDictLabel * find_label(const std::string &name) const
Definition: IdDictField.cxx:23
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:316
Identifier
Definition: IdentifierFieldParser.cxx:14
IdDictDictionary::set_do_checks
void set_do_checks(bool do_checks)
Definition: IdDictDictionary.cxx:1005