ATLAS Offline Software
IdDictDictionaryRef.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 #include "IdDict/IdDictMgr.h"
8 #include "IdDict/IdDictRegion.h"
10 #include "Identifier/Range.h"
11 #include "IdDict/IdDictRangeRef.h"
12 #include "IdDict/IdDictRange.h"
14 
16  :
17  m_dictionary(0),
18  m_resolved_references(false),
19  m_generated_implementation(false),
20  m_propagated_information(false) {
21 }
22 
24 }
25 
28  IdDictRegion& /*region*/) {
29  if (!m_resolved_references) {
31  if (m_dictionary) {
34  }
35  m_resolved_references = true;
36  }
37 }
38 
41  IdDictRegion& region,
42  const std::string& tag) {
44  if (m_dictionary) {
46  // Propagate information to referenced dictionary:
47  //
48  // 1) Loop over ranges in this region and add them to the
49  // referenced dictionary, then propagate the generate
50  // implementation
51 
52  // 2) Duplicate the regions of the current dictionary in
53  // referenced dictionary. Only the top level range(s) need
54  // to be propagated to correctly calculate the bits of the
55  // upper levels.
56 
57  // Save a vector of entries to prepend, inverting their order
58  std::vector<IdDictRegionEntry*> prepend_entries;
60  for (it = region.m_entries.begin(); it != region.m_entries.end(); ++it) {
62  if (this == entry) break; // end when we get to the dictionary (this)
63  // If this is a range entry, add a duplicate to all
64  // regions in the subdictionary
65  IdDictRange* range = dynamic_cast<IdDictRange*> (entry);
66  if (range) {
67  prepend_entries.insert(prepend_entries.begin(), entry);
68  }
69  }
70 
71 
72 
73 
74  // Now prepend list to each region and generate each region
76  for (it2 = m_dictionary->m_all_regions.begin(); it2 != m_dictionary->m_all_regions.end(); ++it2) {
77  IdDictRegion& region2 = *(*it2);
78  for (it = prepend_entries.begin(); it != prepend_entries.end(); ++it) {
80  IdDictRange* range = dynamic_cast<IdDictRange*> (entry);
81  if (range) {
82  IdDictRangeRef* new_range = new IdDictRangeRef;
83  new_range->m_range = range;
84  region2.m_entries.insert(region2.m_entries.begin(), new_range);
85  }
86  }
87  }
88 
89  // Now copy all prefixes into new regions in the
90  // referenced dictionary
91  if (prepend_entries.size() > 0) {
92  // Save region number
93  const IdDictRegion& region2 = *m_dictionary->m_all_regions.back();
94  size_t region_number = region2.m_index + 1;
95 
97 
98  // Loop over all regions of current dict, add to ref dict (m_dictionary)
99  for (it = dictionary.m_all_regions.begin(); it != dictionary.m_all_regions.end(); ++it, ++region_number) {
100  IdDictRegion& region3 = *(*it);
101  IdDictRegion* new_region = new IdDictRegion;
102  new_region->m_name = "dummy";
103  new_region->m_group = "dummy";
104  new_region->m_index = region_number;
105 
106  // to all region vectors
107  m_dictionary->m_all_regions.push_back(new_region);
108  // to the entries of the dictionary
109  m_dictionary->add_dictentry(new_region);
110 
111  // Now add in only the ranges
113  size_t i = 0;
114  for (it = region3.m_entries.begin(); it != region3.m_entries.end(); ++it, ++i) {
115  if (i >= prepend_entries.size()) continue;
116 
118  IdDictRange* range = dynamic_cast<IdDictRange*> (entry);
119  if (range) {
120  IdDictRangeRef* new_range = new IdDictRangeRef;
121  new_range->m_range = range;
122  new_region->m_entries.push_back(new_range);
123  }
124  }
125  }
126  }
128  }
131  } else {
132  std::cout <<
133  "IdDictDictionaryRef::generate_implementation: - WARNING no dictionary found, cannot generate implementation "
134  << std::endl;
135  }
136  }
137 }
138 
143  }
144 }
145 
147  return(true);
148 }
149 
151  Range result;
152 
153  return(result);
154 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IdDictRange.h
IdDictMgr.h
IdDictRangeRef
Definition: IdDictRangeRef.h:18
get_generator_info.result
result
Definition: get_generator_info.py:21
IdDictDictionary::generate_implementation
void generate_implementation(const IdDictMgr &idd, const std::string &tag="")
Definition: IdDictDictionary.cxx:174
IdDictDictionaryRef::build_range
Range build_range() const
Definition: IdDictDictionaryRef.cxx:150
IdDictDictionary.h
IdDictDictionaryRef::resolve_references
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion &region)
Definition: IdDictDictionaryRef.cxx:26
Range.h
IdDictRangeRef::m_range
IdDictRange * m_range
Definition: IdDictRangeRef.h:33
skel.it
it
Definition: skel.GENtoEVGEN.py:396
IdDictDictionaryRef::~IdDictDictionaryRef
~IdDictDictionaryRef()
Definition: IdDictDictionaryRef.cxx:23
IdDictRegionEntry.h
IdDictRegion
Definition: IdDictRegion.h:20
IdDictDictionary::resolve_references
void resolve_references(const IdDictMgr &idd)
Definition: IdDictDictionary.cxx:147
IdDictRegion::m_name
std::string m_name
Definition: IdDictRegion.h:44
IdDictDictionaryRef::m_dictionary_name
std::string m_dictionary_name
Definition: IdDictDictionaryRef.h:31
IdDictDictionary::reset_implementation
void reset_implementation()
Definition: IdDictDictionary.cxx:221
IdDictDictionary::m_parent_dict
IdDictDictionary * m_parent_dict
Definition: IdDictDictionary.h:239
IdDictMgr
Definition: IdDictMgr.h:14
IdDictMgr::find_dictionary
IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Definition: IdDictMgr.cxx:115
IdDictRegion::m_index
size_t m_index
Definition: IdDictRegion.h:43
lumiFormat.i
int i
Definition: lumiFormat.py:85
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
IdDictDictionaryRef::m_propagated_information
bool m_propagated_information
Definition: IdDictDictionaryRef.h:39
IdDictDictionary::regions_it
regions_type::iterator regions_it
Definition: IdDictDictionary.h:226
IdDictRegion::m_entries
std::vector< IdDictRegionEntry * > m_entries
Definition: IdDictRegion.h:41
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
IdDictRegion::m_group
std::string m_group
Definition: IdDictRegion.h:45
master.dictionary
dictionary
Definition: master.py:47
IdDictRangeRef.h
IdDictDictionaryRef.h
IdDictDictionaryRef::reset_implementation
void reset_implementation()
Definition: IdDictDictionaryRef.cxx:139
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
IdDictDictionary
Definition: IdDictDictionary.h:30
IdDictRegionEntry
Definition: IdDictRegionEntry.h:14
IdDictFieldImplementation.h
IdDictRange
Definition: IdDictRange.h:18
IdDictDictionaryRef::verify
bool verify() const
Definition: IdDictDictionaryRef.cxx:146
IdDictDictionary::add_dictentry
void add_dictentry(IdDictDictEntry *entry)
Definition: IdDictDictionary.cxx:136
IdDictDictionaryRef::generate_implementation
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion &region, const std::string &tag="")
Definition: IdDictDictionaryRef.cxx:39
IdDictDictionaryRef::m_dictionary
IdDictDictionary * m_dictionary
Definition: IdDictDictionaryRef.h:32
IdDictDictionaryRef::m_generated_implementation
bool m_generated_implementation
Definition: IdDictDictionaryRef.h:38
IdDictRegion.h
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
IdDictDictionaryRef::m_resolved_references
bool m_resolved_references
Definition: IdDictDictionaryRef.h:37
IdDictDictionaryRef::IdDictDictionaryRef
IdDictDictionaryRef()
Definition: IdDictDictionaryRef.cxx:15
IdDictDictionary::m_all_regions
std::vector< IdDictRegion * > m_all_regions
Definition: IdDictDictionary.h:236