ATLAS Offline Software
RangeIterator.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 "Identifier/Range.h"
7 
8 
9 
10 //-----------------------------------------------
13  return (*this);
14 }
15 
16 //-----------------------------------------------
19  return (*this);
20 }
21 
22 //-----------------------------------------------
24 RangeIterator::end () const {
25  Range r;
26  RangeIterator factory(r);
27  return (factory);
28 }
29 
30 //-----------------------------------------------
33  static const Range r;
34  static const ConstRangeIterator factory(r);
35  return (factory);
36 }
37 
38 
39 
40 //-----------------------------------------------
48  for (Range::size_type i = 0; i < range.fields (); ++i) {
49  Range::element_type minimum;
50  Range::element_type maximum;
51  m_indices.push_back (0);
52  const Range::field& f = range[i];
53  if (f.empty()){
54  m_id << 0;
55  m_min << 0;
56  m_max << 0;
57  } else {
58  minimum = f.get_minimum ();
59  maximum = f.get_maximum ();
60  m_id << minimum;
61  m_min << minimum;
62  m_max << maximum;
63  }
64  }
65 }
66 
67 
68 
69 //-----------------------------------------------
72  if (m_id.fields () == 0) return *this;
74  Range::size_type i = fields - 1;
75 
76  //
77  // Starting from the end, we try to increment the m_id fields
78  // If at a given position it's not possible (max reached)
79  // then we move back one pos and try again.
80  //
81  // As soon as increment is possible, then the rest of the m_id
82  // is reset to min values.
83  //
84 
85  for (;;) {
86  const Range::field& f = (*m_range)[i];
87  bool done = false;
89 
90  if (f.isEnumerated()) {
92  index++;
93  if (index < f.get_indices ()) {
94  m_indices[i] = index;
95  value = f.get_value_at (index);
96  done = true;
97  }
98  } else {
99  value = m_id[i];
100  if (value < m_max[i]) {
105  ++value;
106  done = true;
107  }
108  }
109  if (done) {
110  m_id[i] = value;
111  for (++i; i < fields; ++i) {
112  m_indices[i] = 0;
113  m_id[i] = m_min[i];
114  }
115 
116  break;
117  }
118 
124  if (i == 0) {
125  m_id.clear ();
126  break;
127  }
128 
129  --i;
130 
131  }
132  return *this;
133 }
134 
135 //-----------------------------------------------
138  return (m_id);
139 }
140 
141 //-----------------------------------------------
142 bool
144  if (m_id == other.m_id) return (true);
145  return (false);
146 }
147 
148 
149 
150 //-----------------------------------------------
152  m_range (&range) {
159  for (Range::size_type i = 0; i < range.fields (); ++i) {
160  Range::element_type minimum;
161  Range::element_type maximum;
162  m_indices.push_back (0);
163  const Range::field& f = range[i];
164  if (f.empty()){
165  m_id << 0;
166  m_min << 0;
167  m_max << 0;
168  } else {
169  minimum = f.get_minimum ();
170  maximum = f.get_maximum ();
171  m_id << minimum;
172  m_min << minimum;
173  m_max << maximum;
174  }
175  }
176 }
177 
178 
179 //-----------------------------------------------
182  if (m_id.fields () == 0) return *this;
184  Range::size_type i = fields - 1;
185  //
186  // Starting from the end, we try to increment the m_id fields
187  // If at a given position it's not possible (max reached)
188  // then we move back one pos and try again.
189  //
190  // As soon as increment is possible, then the rest of the m_id
191  // is reset to min values.
192  //
193  for (;;){
194  const Range::field& f = (*m_range)[i];
195  bool done = false;
197 
198  if (f.isEnumerated()) {
200  index++;
201  if (index < f.get_indices ()) {
202  m_indices[i] = index;
203  value = f.get_value_at (index);
204  done = true;
205  }
206  }else {
207  value = m_id[i];
208  if (value < m_max[i]){
213  ++value;
214  done = true;
215  }
216  }
217 
218  if (done) {
219  m_id[i] = value;
220  for (++i; i < fields; ++i) {
221  m_indices[i] = 0;
222  m_id[i] = m_min[i];
223  }
224  break;
225  }
226 
232  if (i == 0) {
233  m_id.clear ();
234  break;
235  }
236  --i;
237 
238  }
239  return *this;
240 }
241 
242 //-----------------------------------------------
243 const ExpandedIdentifier&
245  return (m_id);
246 }
247 
248 //-----------------------------------------------
249 bool
251  if (m_id == other.m_id) return (true);
252  return (false);
253 }
ConstRangeIterator::m_indices
std::vector< std::size_t > m_indices
Definition: RangeIterator.h:65
RangeIterator::m_indices
std::vector< std::size_t > m_indices
Definition: RangeIterator.h:39
beamspotman.r
def r
Definition: beamspotman.py:676
ConstRangeIterator
Definition: RangeIterator.h:46
ConstRangeIterator::m_id
ExpandedIdentifier m_id
Definition: RangeIterator.h:66
Range::size_type
ExpandedIdentifier::size_type size_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:33
index
Definition: index.py:1
Range.h
RangeIterator
This iterator is able to generate all possible identifiers, from a fully bounded Range.
Definition: RangeIterator.h:19
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
athena.value
value
Definition: athena.py:124
ExpandedIdentifier::fields
size_type fields() const
m_range
float m_range[NbCaloPart][2]
Definition: CellClusterLinkTool.h:55
RangeIterator::operator==
bool operator==(const RangeIterator &other) const
Definition: RangeIterator.cxx:143
RangeIterator::begin
RangeIterator begin() const
Definition: RangeIterator.cxx:12
RangeIterator::m_max
ExpandedIdentifier m_max
Definition: RangeIterator.h:42
ConstRangeIterator::operator==
bool operator==(const ConstRangeIterator &other) const
Definition: RangeIterator.cxx:250
lumiFormat.i
int i
Definition: lumiFormat.py:85
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
hist_file_dump.f
f
Definition: hist_file_dump.py:135
ConstRangeIterator::begin
ConstRangeIterator begin() const
Definition: RangeIterator.cxx:18
RangeIterator::operator*
ExpandedIdentifier & operator*()
Definition: RangeIterator.cxx:137
ConstRangeIterator::operator++
ConstRangeIterator operator++()
Definition: RangeIterator.cxx:181
ConstRangeIterator::operator*
const ExpandedIdentifier & operator*() const
Definition: RangeIterator.cxx:244
RangeIterator.h
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
RangeIterator::end
RangeIterator end() const
Definition: RangeIterator.cxx:24
DeMoScan.index
string index
Definition: DeMoScan.py:364
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
ConstRangeIterator::ConstRangeIterator
ConstRangeIterator()=default
IdentifierField
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
Definition: IdentifierField.h:21
RangeIterator::m_min
ExpandedIdentifier m_min
Definition: RangeIterator.h:41
ExpandedIdentifier::clear
void clear()
Erase all fields.
RangeIterator::operator++
RangeIterator & operator++()
Definition: RangeIterator.cxx:71
ConstRangeIterator::end
ConstRangeIterator end() const
Definition: RangeIterator.cxx:32
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:106
ConstRangeIterator::m_max
ExpandedIdentifier m_max
Definition: RangeIterator.h:68
RangeIterator::RangeIterator
RangeIterator()=default
ConstRangeIterator::m_min
ExpandedIdentifier m_min
Definition: RangeIterator.h:67
Range::element_type
ExpandedIdentifier::element_type element_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:32
RangeIterator::m_id
ExpandedIdentifier m_id
Definition: RangeIterator.h:40