ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictRegion.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
9#include "src/Debugger.h"
10#include <iostream>
11
12IdDictRegion::IdDictRegion (const std::string& name,
13 const std::string& group,
14 const std::string& tag)
15 : m_name (name),
16 m_group (group),
17 m_tag (tag)
18{
19}
21
24
25
26std::string
28 return(m_group);
29}
30
31
33{
34 return m_implementation.size();
35}
36
37
39{
40 return m_implementation.at(i);
41}
42
43
44void
48
50void
51IdDictRegion::add_entry(std::unique_ptr<IdDictRegionEntry> entry) {
52 m_entries.push_back(std::move(entry));
53}
54
56void
57IdDictRegion::prepend_entry(std::unique_ptr<IdDictRegionEntry> entry) {
58 m_entries.insert(m_entries.begin(), std::move(entry));
59}
60
61
67
68
74
75
78{
80}
81
82
84void IdDictRegion::add_prev_samp_name (const std::string& name)
85{
86 m_prev_samp_names.push_back (name);
87
88}
89
90
92void IdDictRegion::add_next_samp_name (const std::string& name)
93{
94 m_next_samp_names.push_back (name);
95}
96
97
100{
101 m_prev_subdet_names.push_back (name);
102}
103
104
107{
108 m_next_subdet_names.push_back (name);
109}
110
111
113void IdDictRegion::set_etaphi (double eta0, double deta,
114 double phi0, double dphi)
115{
116 m_eta0 = eta0;
117 m_deta = deta;
118 m_phi0 = phi0;
119 m_dphi = dphi;
120}
121
122
125{
126 m_is_empty = true;
127}
128
129
130void
132 for (auto& entry : m_entries) {
133 entry->resolve_references(idd, dictionary, *this);
134 }
135}
136
137void
139 IdDictDictionary& dictionary,
140 const std::string& tag) {
141 if (Debugger::debug()) {
142 std::cout << "IdDictRegion::generate_implementation>" << std::endl;
143 }
145 for (auto& entry : m_entries) {
146 entry->generate_implementation(idd, dictionary, *this, tag);
147 }
149 }
150}
151
152void
154 // Find the neighbours
155 IdDictRegion* region = 0;
156
157 if ("" != m_next_abs_eta_name) {
158 region = dictionary.find_region(m_next_abs_eta_name, m_group);
159 if (region) {
160 region->m_prev_abs_eta = this;
161 m_next_abs_eta = region;
162 }
163 }
164 for (unsigned int i = 0; i < m_prev_samp_names.size(); ++i) {
165 if ("" != m_prev_samp_names[i]) {
166 region = dictionary.find_region(m_prev_samp_names[i], m_group);
167 if (region) {
168 m_prev_samp.push_back(region);
169 }
170 }
171 }
172 for (unsigned int i = 0; i < m_next_samp_names.size(); ++i) {
173 if ("" != m_next_samp_names[i]) {
174 region = dictionary.find_region(m_next_samp_names[i], m_group);
175 if (region) {
176 m_next_samp.push_back(region);
177 }
178 }
179 }
180
181 for (unsigned int i = 0; i < m_prev_subdet_names.size(); ++i) {
182 if ("" != m_prev_subdet_names[i]) {
183 region = dictionary.find_region(m_prev_subdet_names[i], m_group);
184 if (region) {
185 m_prev_subdet.push_back(region);
186 }
187 }
188 }
189 for (unsigned int i = 0; i < m_next_subdet_names.size(); ++i) {
190 if ("" != m_next_subdet_names[i]) {
191 region = dictionary.find_region(m_next_subdet_names[i], m_group);
192 if (region) {
193 m_next_subdet.push_back(region);
194 }
195 }
196 }
197}
198
199void
202 m_implementation.clear(); // remove implementation
203 for (auto& entry : m_entries) {
204 entry->reset_implementation();
205 }
206 // reset neighbours
207 m_prev_abs_eta = 0;
208 m_next_abs_eta = 0;
209 m_prev_samp.clear();
210 m_next_samp.clear();
211 m_prev_subdet.clear();
212 m_next_subdet.clear();
213
215 }
216}
217
219 return(true);
220}
221
222void
224 m_entries.clear();
225}
226
227size_t
229 return m_implementation.size();
230}
231
232size_t
234 return m_entries.size();
235}
236
237void
239 // For each region, loop over its levels and set the bit offset
240 // for each FieldImplementation
241
242 size_t bits_offset = 0;
244 impl.optimize(); // optimize for decoding
245 impl.set_bits_offset(bits_offset);
246 bits_offset += impl.bits();
247
248 // Set whether or not to decode index
249 Range::field field = impl.ored_field();
250 if ((not field.isBounded()) || (0 != field.get_minimum())) {
251 impl.set_decode_index(true);
252 }
253 }
254}
255
256Range
259
260 for (auto& entry : m_entries) {
261 Range r = entry->build_range();
262 result.add(std::move(r));
263 }
264 return(result);
265}
static bool debug()
Definition Debugger.h:18
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
virtual void reset_implementation() override
void find_neighbours(IdDictDictionary &dictionary)
std::vector< std::string > m_prev_samp_names
std::vector< const IdDictRegion * > m_prev_samp
std::vector< const IdDictRegion * > m_prev_subdet
void set_etaphi(double eta0, double deta, double phi0, double dphi)
Set eta/phi variables.
std::string m_name
void integrate_bits()
virtual void resolve_references(IdDictMgr &idd, IdDictDictionary &dictionary) override
IdDictRegion & operator=(IdDictRegion &&)
IdDictRegion(const std::string &name, const std::string &group, const std::string &tag)
void add_prev_subdet_name(const std::string &name)
Add a previous subdetector name.
void add_entry(std::unique_ptr< IdDictRegionEntry > entry)
Add entry to the end of the list.
virtual std::string group_name() const override
void add_prev_samp_name(const std::string &name)
Add a previous sample name.
void set_is_empty()
Set is_empty flag.
IdDictFieldImplementation & new_implementation()
Add a new implementation object and return a reference to it.
size_t fieldSize() const
std::vector< std::string > m_next_subdet_names
std::vector< IdDictFieldImplementation > m_implementation
std::string m_group
void prepend_entry(std::unique_ptr< IdDictRegionEntry > entry)
Add entry to the start of the list.
std::string m_next_abs_eta_name
IdDictRegion * m_next_abs_eta
double eta0() const
std::vector< std::string > m_prev_subdet_names
virtual ~IdDictRegion()
virtual void clear() override
virtual void set_index(size_t index) override
const std::string & name() const
const IdDictRegionEntry & entry(size_t i) const
size_t size() const
bool m_generated_implementation
std::vector< std::string > m_next_samp_names
std::string m_tag
std::vector< std::unique_ptr< IdDictRegionEntry > > m_entries
double phi0() const
std::vector< const IdDictRegion * > m_next_subdet
const std::string & tag() const
std::vector< const IdDictRegion * > m_next_samp
void add_next_samp_name(const std::string &name)
Add a next sample name.
virtual Range build_range() const override
double deta() const
IdDictRegion * m_prev_abs_eta
void add_next_subdet_name(const std::string &name)
Add a next subdetector name.
void set_next_abs_eta_name(const std::string &name)
Set the name for next_abs_eta.
const IdDictFieldImplementation & implementation(size_t i) const
virtual void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="") override
double dphi() const
virtual bool verify() const override
size_t n_implementation() const
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
int r
Definition globals.cxx:22
Definition index.py:1