ATLAS Offline Software
IdDictGroup.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include "IdDict/IdDictGroup.h"
6 #include "src/Debugger.h"
7 #include "IdDict/IdDictRegion.h"
10 #include "IdDict/IdDictMgr.h"
12 #include "Identifier/MultiRange.h"
13 #include "Identifier/Range.h"
15 
16 #include <iostream>
17 #include <map>
18 
19 
21  :
22  m_generated_implementation(false) {
23 }
24 
25 IdDictGroup::IdDictGroup (const std::string& name)
26  :
27  m_name(name),
28  m_generated_implementation(false) {
29 }
30 
32 }
33 
34 const std::string& IdDictGroup::name() {
35  return(m_name);
36 }
37 
38 const std::vector<IdDictDictEntry*>&
40  return(m_entries);
41 }
42 
43 const std::vector<IdDictRegion*>&
45  return(m_regions);
46 }
47 
51 
53 
54  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
55  const IdDictRegion& region = *(*it);
56 
57  // skip regions created from parents
58  if ("dummy" == region.m_name) continue;
59 
60  // skip empty regions - may arise from alternate_regions
61  // where a tag selects an empty region
62  if (region.m_is_empty) continue;
63 
64  Range r = region.build_range();
65  result.add(std::move(r));
66  }
67 
68  return(result);
69 }
70 
71 void
73  m_entries.push_back(region);
74 }
75 
76 void
79  size_t& index) {
81  for (it = m_entries.begin(); it != m_entries.end(); ++it) {
82  (*it)->set_index(index);
83  index++;
84 
85  (*it)->resolve_references(idd, dictionary);
86  }
87 }
88 
89 void
92  const std::string& tag) {
93  if (Debugger::debug()) {
94  std::cout << "IdDictGroup::generate_implementation>" << std::endl;
95  }
96 
98  // Loop over entries and fill regions vec with selected region
99  // (AltRegions have a selection)
101  for (it = m_entries.begin(); it != m_entries.end(); ++it) {
102  (*it)->generate_implementation(idd, dictionary, tag);
103  // Get region and save in m_regions
104  IdDictRegion* region = dynamic_cast<IdDictRegion*> (*it);
105  if (region) {
106  m_regions.push_back(region);
107  } else {
108  IdDictAltRegions* altregions = dynamic_cast<IdDictAltRegions*> (*it);
109  if (altregions) {
110  m_regions.push_back(altregions->m_selected_region);
111  }
112  }
113  }
114 
115  if (m_regions.size() != m_entries.size()) {
116  std::cout << "IdDictGroup::generate_implementation - mismatch of sizes: regions/entries "
117  << m_regions.size() << " " << m_entries.size()
118  << std::endl;
119  }
120 
122  }
123 }
124 
125 void
128  m_regions.clear();
130  for (it = m_entries.begin(); it != m_entries.end(); ++it) {
131  (*it)->reset_implementation();
132  }
134  }
135 }
136 
137 bool
139  // Should check that all regions have the same number of levels,
140  // which is part of the definition of a group
141  return(true);
142 }
143 
153  std::map< ExpandedIdentifier, IdDictDictEntry* > regions;
154 
156 
157  for (it = m_regions.begin(); it != m_regions.end(); ++it) {
158  const IdDictRegion& region = *(*it);
159  Range range = region.build_range();
160  RangeIterator itr(range);
161  auto first = itr.begin();
162  auto last = itr.end();
163  if (first != last) {
164  regions[*first] = *it;
165  } else {
166  std::cout << "IdDictDictionary::sort - WARNING empty region cannot sort "
167  << std::endl;
168  }
169  }
170  if (regions.size() == m_regions.size()) {
171  // Reorder the regions
173  std::vector<IdDictRegion*>::size_type vecIt = 0;
174  for (; mapIt != regions.end(); ++mapIt, ++vecIt) {
175  m_entries[vecIt] = (*mapIt).second;
176  }
177  } else {
178  std::cout << "IdDictGroup::sort - WARNING region map size is NOT the same as the vector size. Map size "
179  << regions.size() << " vector size " << m_regions.size()
180  << std::endl;
181  }
182 }
183 
184 void
187 
188  for (it = m_entries.begin(); it != m_entries.end(); ++it) {
189  IdDictDictEntry* region = *it;
190  region->clear();
191  delete region;
192  }
193 
194  m_entries.clear();
195 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IdDictMgr.h
beamspotman.r
def r
Definition: beamspotman.py:676
IdDictGroup::m_name
std::string m_name
Definition: IdDictGroup.h:47
get_generator_info.result
result
Definition: get_generator_info.py:21
index
Definition: index.py:1
IdDictGroup::sort
void sort()
Sort:
Definition: IdDictGroup.cxx:152
IdDictAltRegions::m_selected_region
IdDictRegion * m_selected_region
Definition: IdDictAltRegions.h:40
IdDictGroup::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictGroup.h:49
IdDictDictionary.h
Range.h
IdDictGroup::verify
bool verify() const
Definition: IdDictGroup.cxx:138
skel.it
it
Definition: skel.GENtoEVGEN.py:396
RangeIterator
This iterator is able to generate all possible identifiers, from a fully bounded Range.
Definition: RangeIterator.h:19
ExpandedIdentifier.h
Debugger.h
IdDictDictEntry::clear
virtual void clear()=0
IdDictDictEntry
Definition: IdDictDictEntry.h:13
IdDictAltRegions
Definition: IdDictAltRegions.h:20
IdDictGroup.h
IdDictRegion
Definition: IdDictRegion.h:20
IdDictGroup::generate_implementation
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="")
Definition: IdDictGroup.cxx:90
IdDictRegion::m_name
std::string m_name
Definition: IdDictRegion.h:44
RangeIterator::begin
RangeIterator begin() const
Definition: RangeIterator.cxx:12
IdDictAltRegions.h
IdDictGroup::m_entries
std::vector< IdDictDictEntry * > m_entries
Definition: IdDictGroup.h:48
IdDictGroup::resolve_references
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, size_t &index)
Definition: IdDictGroup.cxx:77
IdDictMgr
Definition: IdDictMgr.h:14
IdDictRegion::build_range
Range build_range() const
Definition: IdDictRegion.cxx:147
IdDictGroup::IdDictGroup
IdDictGroup()
Definition: IdDictGroup.cxx:20
IdDictRegion::m_is_empty
bool m_is_empty
Definition: IdDictRegion.h:47
IdDictGroup::build_multirange
MultiRange build_multirange() const
Get MultiRange for this group.
Definition: IdDictGroup.cxx:49
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
IdDictGroup::clear
void clear()
Definition: IdDictGroup.cxx:185
IdDictGroup::add_dictentry
void add_dictentry(IdDictDictEntry *entry)
Definition: IdDictGroup.cxx:72
IdDictDictionary::regions_it
regions_type::iterator regions_it
Definition: IdDictDictionary.h:226
Debugger::debug
static bool debug()
Definition: Debugger.h:18
IdDictGroup::regions
const std::vector< IdDictRegion * > & regions()
Definition: IdDictGroup.cxx:44
IdDictDictionary::regions_const_it
regions_type::const_iterator regions_const_it
Definition: IdDictDictionary.h:227
MultiRange
A MultiRange combines several Ranges.
Definition: MultiRange.h:17
master.dictionary
dictionary
Definition: master.py:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IdDictDictionary::entries_it
entries_type::iterator entries_it
Definition: IdDictDictionary.h:222
RangeIterator.h
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
MultiRange.h
IdDictDictionary
Definition: IdDictDictionary.h:30
RangeIterator::end
RangeIterator end() const
Definition: RangeIterator.cxx:24
IdDictGroup::name
const std::string & name()
Definition: IdDictGroup.cxx:34
IdDictGroup::reset_implementation
void reset_implementation()
Definition: IdDictGroup.cxx:126
IdDictGroup::m_generated_implementation
bool m_generated_implementation
Definition: IdDictGroup.h:50
DeMoScan.first
bool first
Definition: DeMoScan.py:536
IdDictGroup::entries
const std::vector< IdDictDictEntry * > & entries()
Definition: IdDictGroup.cxx:39
IdDictRegion.h
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
IdDictGroup::~IdDictGroup
~IdDictGroup()
Definition: IdDictGroup.cxx:31