ATLAS Offline Software
Loading...
Searching...
No Matches
IOVPayloadContainer Class Reference

This class is a container for the payload of conditions data. More...

#include <IOVPayloadContainer.h>

Collaboration diagram for IOVPayloadContainer:

Classes

class  AttrListCollSortStart
class  AttrListCollSortStop

Public Types

typedef std::vector< CondAttrListCollection * > payloadVec
typedef payloadVec::const_iterator const_iterator
typedef payloadVec::size_type size_type

Public Member Functions

structors
 IOVPayloadContainer ()
 ~IOVPayloadContainer ()
 IOVPayloadContainer (const IOVPayloadContainer &cont)
IOVPayloadContaineroperator= (const IOVPayloadContainer &cont)
Payload accessors
const_iterator begin () const
 Begin of payload vector.
const_iterator end () const
 End of payload vector.
CondAttrListCollectionat (unsigned int i) const
 Element access.
size_type size () const
 size of payload vector
const_iterator find (const IOVTime &time) const
 find the first payload that has a IOVRange which includes the

Payload setting

class IOVPayloadContainerCnv_p1
class IOVPayloadContainerPTCnv_p1
payloadVec m_payloadVec
bool merge (CondAttrListCollection *attrListColl)
 Add in new payload, checking that it is not a duplicate.

Detailed Description

This class is a container for the payload of conditions data.

It is intended to be used to store conditions data from COOL as file meta data.

Definition at line 35 of file IOVPayloadContainer.h.

Member Typedef Documentation

◆ const_iterator

typedef payloadVec::const_iterator IOVPayloadContainer::const_iterator

Definition at line 39 of file IOVPayloadContainer.h.

◆ payloadVec

Definition at line 38 of file IOVPayloadContainer.h.

◆ size_type

typedef payloadVec::size_type IOVPayloadContainer::size_type

Definition at line 40 of file IOVPayloadContainer.h.

Constructor & Destructor Documentation

◆ IOVPayloadContainer() [1/2]

IOVPayloadContainer::IOVPayloadContainer ( )
inline

Definition at line 102 of file IOVPayloadContainer.h.

103{}

◆ ~IOVPayloadContainer()

IOVPayloadContainer::~IOVPayloadContainer ( )

Definition at line 7 of file IOVPayloadContainer.cxx.

8{
9 for(CondAttrListCollection* col : m_payloadVec) {
10 delete col;
11 }
12}

◆ IOVPayloadContainer() [2/2]

IOVPayloadContainer::IOVPayloadContainer ( const IOVPayloadContainer & cont)

Definition at line 14 of file IOVPayloadContainer.cxx.

15{
16 m_payloadVec.reserve(cont.m_payloadVec.size());
17 for(CondAttrListCollection* col : cont.m_payloadVec) {
18 m_payloadVec.push_back(new CondAttrListCollection(*col));
19 }
20}

Member Function Documentation

◆ at()

CondAttrListCollection * IOVPayloadContainer::at ( unsigned int i) const
inline

Element access.

Definition at line 128 of file IOVPayloadContainer.h.

129{
130 if (i < m_payloadVec.size()) return m_payloadVec[i];
131 return (0);
132}

◆ begin()

IOVPayloadContainer::const_iterator IOVPayloadContainer::begin ( ) const
inline

Begin of payload vector.

Definition at line 107 of file IOVPayloadContainer.h.

108{
109 return (m_payloadVec.begin());
110}

◆ end()

IOVPayloadContainer::const_iterator IOVPayloadContainer::end ( ) const
inline

End of payload vector.

Definition at line 114 of file IOVPayloadContainer.h.

115{
116 return (m_payloadVec.end());
117}

◆ find()

IOVPayloadContainer::const_iterator IOVPayloadContainer::find ( const IOVTime & time) const
inline

find the first payload that has a IOVRange which includes the

Definition at line 136 of file IOVPayloadContainer.h.

137{
138 // Find first collection where time < stop time
139 const_iterator result = std::lower_bound(m_payloadVec.begin(),
140 m_payloadVec.end(),
141 time, AttrListCollSortStop()) ;
142 // At end return:
143 if ( result == m_payloadVec.end() ) return (result) ;
144
145 // If time == stop, move forward one
146 if ( (*result)->minRange().stop() == time) ++result;
147
148 // At end return:
149 if ( result == m_payloadVec.end() ) return (result) ;
150
151 // Check that time is in interval
152 if ( (*result)->minRange().start() <= time) return (result);
153
154 // Not found
155 return (m_payloadVec.end());
156}
payloadVec::const_iterator const_iterator

◆ merge()

bool IOVPayloadContainer::merge ( CondAttrListCollection * attrListColl)

Add in new payload, checking that it is not a duplicate.

Returns true if merge is ok, false if it is a duplicate. Takes over ownership. Then the new AttrListColl will replace existing one when there is an overlap of the two IOVs, and returns true.

Definition at line 36 of file IOVPayloadContainer.cxx.

37{
38 // We insert new payload ordered by its minimal IOVRange start
39 // time. Duplicates are removed.
40 //
41 // Check for an IOV overlap of the incoming attrListColl with the
42 // previous one. If there is an overlap, then the previous one is
43 // deleted and the new one is kept.
44 //
45 typedef std::vector<CondAttrListCollection*>::iterator iterator;
46 iterator it = std::lower_bound(m_payloadVec.begin(),
47 m_payloadVec.end(),
48 attrListColl->minRange().start(),
50
51 bool debug = true;
52 debug = false;
53 if (debug) {
54
55 std::cout << "IOVPayloadContainer::merge - after lowerbound" << std::endl;
56
57 if (m_payloadVec.begin() != m_payloadVec.end()) {
58 std::cout << "IOVPayloadContainer::merge - begin range "
59 << (*m_payloadVec.begin())->minRange()
60 << std::endl;
61 }
62 if (it != m_payloadVec.end()) {
63 std::cout << "IOVPayloadContainer::merge - it range "
64 << (*it)->minRange()
65 << std::endl;
66 }
67 std::cout << "IOVPayloadContainer::merge - attrList range "
68 << attrListColl->minRange()
69 << std::endl;
70 }
71
72
73 if (it != m_payloadVec.begin()) {
74 // Check to see if the new AttrListColl matches the one before
75 // the insertion point, ignoring the minRange. If they match,
76 // then we reject the new one, but use the new stop for the
77 // previous AttrListColl.
78 iterator itPrev = it;
79 --itPrev;
80
81 if (debug) std::cout << "IOVPayloadContainer::merge - not begin " << std::endl;
82
83 if ((*itPrev)->isSameButMinRange(*attrListColl)) {
84
85 // New AttrListColl matches previous one.
86 // Reset IOV to earliest start and latest stop.
87 // Reject insertion of the new one.
88
89 // We must save start/stop, reset, and set start/stop
90 const IOVTime startPrev = (*itPrev)->minRange().start();
91 const IOVTime stopPrev = (*itPrev)->minRange().stop();
92 const IOVTime startNew = attrListColl->minRange().start();
93 const IOVTime stopNew = attrListColl->minRange().stop();
94 IOVTime start = (startPrev < startNew) ? startPrev : startNew;
95 IOVTime stop = (stopPrev > stopNew) ? stopPrev : stopNew;
96 (*itPrev)->resetMinRange();
97 (*itPrev)->addNewStart(start);
98 (*itPrev)->addNewStop(stop);
99
100 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange " << (*itPrev)->minRange() << std::endl;
101
102
103 // Now delete or truncate all subsequent IOVs which overlap
104 for (; it != m_payloadVec.end(); ++it) {
105
106 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange, subsequent start/stop "
107 << (*it)->minRange().start() << " " << (*it)->minRange().stop()
108 << std::endl;
109
110 if ((*it)->minRange().stop() <= stop) {
111 // remove attribute list collection
112 CondAttrListCollection* oldAttrListColl = (*it);
113 delete oldAttrListColl;
114 it = m_payloadVec.erase(it);
115 //we deleted the nth element, so that now 'it'
116 //points at the unchecked n+1th element
117
118 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange, remove payload "
119 << std::endl;
120
121 if (it != m_payloadVec.end())
122 {
123 --it; //have to do this otherwise the check on this element will be skipped.
124 continue; // go to the next element
125 }
126 }
127 else if ((*it)->minRange().start() < stop) {
128 // Must truncate old IOV: reset old start to new stop
129 const IOVTime oldStop = (*it)->minRange().stop();
130 (*it)->resetMinRange();
131 (*it)->addNewStart(stop);
132 (*it)->addNewStop(oldStop);
133
134 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange, truncate start/stop "
135 << (*it)->minRange().start() << " " << (*it)->minRange().stop()
136 << std::endl;
137
138 }
139 // we can now leave the loop
140 break;
141 }
142
143 return false;
144 }
145
146 if (debug) std::cout << "IOVPayloadContainer::merge - is NOT SameButMinRange - check stop " << (*itPrev)->minRange() << std::endl;
147
148 if (attrListColl->minRange().start() < (*itPrev)->minRange().stop()) {
149 // Must truncate prev IOV: reset prev stop to new start
150
151 // But we must first check to see if the current IOV lies
152 // completely within the previous one
153 CondAttrListCollection* prevColl = *itPrev;
154 if (attrListColl->minRange().stop() < prevColl->minRange().stop()) {
155 CondAttrListCollection* prevColl1 = new CondAttrListCollection(*prevColl);
156 prevColl1->addNewStart(attrListColl->minRange().stop());
157
158 if (debug) std::cout << "IOVPayloadContainer::merge - attrListColl falls within prev IOV range: "
159 << prevColl->minRange().start() << " "
160 << prevColl->minRange().stop()
161 << std::endl;
162
163 // Now insert the duplicated attribute list collection
164 // (DO NOT increment the iterator for the next
165 // insert!)
166 it = m_payloadVec.insert(it, prevColl1);
167
168 if (debug) std::cout << "IOVPayloadContainer::merge - duplicated previous and insert "
169 << prevColl1->minRange().start() << " "
170 << prevColl1->minRange().stop()
171 << std::endl;
172 }
173
174 const IOVTime oldStart = prevColl->minRange().start();
175 prevColl->resetMinRange();
176 prevColl->addNewStart(oldStart);
177 prevColl->addNewStop(attrListColl->minRange().start());
178
179 if (debug) std::cout << "IOVPayloadContainer::merge - reset prev stop "
180 << prevColl->minRange().start() << " " << prevColl->minRange().stop()
181 << std::endl;
182 }
183 }
184
185 bool checkOverlap = false;
186 iterator last = m_payloadVec.end();
187 if (it != last) {
188 // Return if duplicate
189 if ( (**it) == (*attrListColl) ) {
190
191 if (debug) std::cout << "IOVPayloadContainer::merge - duplicate - reject new one " << std::endl;
192
193 return false;
194 }
195 // Now check if there is a partial match - payload is the
196 // same, the starts are the same and the new stop is > old
197 // stop
198
199 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange - ignoreIOVs: " << (*it)->isSameButMinRange(*attrListColl, true) << std::endl;
200
201 if ((*it)->isSameButMinRange(*attrListColl, true)) {
202
203 // Payload is the same, ignoring the IOVs
204
205 // Check that starts are the same, and if new stop is
206 // later keep the new one. And if the new stop is earlier
207 // reject the new one.
208
209 if ((*it)->minRange().start() == attrListColl->minRange().start() &&
210 (*it)->minRange().stop() < attrListColl->minRange().stop()) {
211
212 // New AttrListColl extends the max of the old
213 // one. Replace with the new one.
214
215 CondAttrListCollection* old = *it;
216 delete old;
217 (*it) = attrListColl;
218 const IOVTime stop = attrListColl->minRange().stop();
219
220 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange with later stop -> replace " << (*it)->minRange() << std::endl;
221
222 // Now delete or truncate all subsequent IOVs which overlap
223 ++it;
224 for (; it != m_payloadVec.end(); ++it) {
225
226 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange, subsequent start/stop "
227 << (*it)->minRange().start() << " " << (*it)->minRange().stop()
228 << std::endl;
229
230 if ((*it)->minRange().stop() <= stop) {
231 // remove attribute list collection
232 CondAttrListCollection* oldAttrListColl = (*it);
233 delete oldAttrListColl;
234 it = m_payloadVec.erase(it);
235 //we deleted the nth element, so that now 'it'
236 //points at the unchecked n+1th element
237
238
239 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange, remove payload "
240 << std::endl;
241
242 if (it != m_payloadVec.end()) {
243 --it; //have to do this otherwise the check on this element will be skipped.
244 continue; // go to the next element
245 }
246 }
247 else if ((*it)->minRange().start() < stop) {
248 // Must truncate old IOV: reset old start to new stop
249 const IOVTime oldStop = (*it)->minRange().stop();
250 (*it)->resetMinRange();
251 (*it)->addNewStart(stop);
252 (*it)->addNewStop(oldStop);
253
254 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange, truncate start/stop "
255 << (*it)->minRange().start() << " " << (*it)->minRange().stop()
256 << std::endl;
257
258 }
259 // we can now leave the loop
260 break;
261 }
262
263 return true;
264 }
265 else if ((*it)->minRange().start() == attrListColl->minRange().start() &&
266 (*it)->minRange().stop() > attrListColl->minRange().stop()) {
267
268 if (debug) std::cout << "IOVPayloadContainer::merge - isSameButMinRange, new stop is earlier - reject "
269 << (*it)->minRange().start() << " " << (*it)->minRange().stop()
270 << std::endl;
271 return false;
272 }
273
274 }
275
276 checkOverlap = true; // at least one existing AttrListColl
277 }
278
279 if (checkOverlap) {
280 // AttrListColls differ in content
281 //
282 // Look for overlap of IOVs
283 //
284
285 // Save start iterator, and new IOV
286 iterator itStart = it;
287 IOVTime newStart = attrListColl->minRange().start();
288 IOVTime newStop = attrListColl->minRange().stop();
289
290 if (debug) std::cout << "IOVPayloadContainer::merge - checkOverlap, new start/stop "
291 << newStart << " " << newStop
292 << std::endl;
293
294 // If the new stop is at MAX, then the stop is not correctly
295 // set. This may happen in online mode where the stop is
296 // open-ended.
297 // We treat this in one of two ways:
298 // 1) if new start and old start are the same => set new stop to old stop
299 // 2) if new start < old start => set new stop to old start
300 bool isAtMax = false;
301 if (newStop.isTimestamp()) isAtMax = newStop.timestamp() == IOVTime::MAXTIMESTAMP;
302 else isAtMax = newStop.re_time() == IOVTime::MAXRETIME;
303 if (isAtMax) {
304
305 if (debug) std::cout << "IOVPayloadContainer::merge - new stop at max " << std::endl;
306
307 if (newStart == (*it)->minRange().start()) {
308 // Set new stop to old stop
309 attrListColl->resetMinRange();
310 attrListColl->addNewStart(newStart);
311 newStop = (*it)->minRange().stop();
312 attrListColl->addNewStop(newStop);
313
314 if (debug) std::cout << "IOVPayloadContainer::merge - set new stop to old stop " << std::endl;
315
316 }
317 else { // newStart < oldStart
318 // Set new top to old start
319 attrListColl->resetMinRange();
320 attrListColl->addNewStart(newStart);
321 newStop = (*it)->minRange().start();
322 attrListColl->addNewStop(newStop);
323
324 if (debug) std::cout << "IOVPayloadContainer::merge - set new stop to old start " << std::endl;
325
326 }
327 }
328
329 // Move back start iterator if we are past begin and the new
330 // start is less than the current start
331 if (it != m_payloadVec.begin() && newStart < (*it)->minRange().start()) {
332
333 if (debug) std::cout << "IOVPayloadContainer::merge - move back "
334 << std::endl;
335
336 --itStart;
337 }
338
339 if (debug) std::cout << "IOVPayloadContainer::merge - checkOverlap, current start/stop "
340 << (*itStart)->minRange().start() << " " << (*itStart)->minRange().stop()
341 << std::endl;
342
343 // If old start is less than new start, set the old stop to
344 // the new start (i.e. truncate the old IOV)
345 if ((*itStart)->minRange().start() < newStart && newStart < (*itStart)->minRange().stop() ) {
346// if ((*itStart)->minRange().start() < newStart) {
347 const IOVTime oldStart = (*itStart)->minRange().start();
348 (*itStart)->resetMinRange();
349 (*itStart)->addNewStart(oldStart);
350 (*itStart)->addNewStop(newStart);
351
352 if (debug) std::cout << "IOVPayloadContainer::merge - reset old stop "
353 << (*itStart)->minRange().start() << " " << (*itStart)->minRange().stop()
354 << " " << newStart
355 << std::endl;
356
357 }
358
359 // Now insert the new attribute list collection
360 it = m_payloadVec.insert(it, attrListColl);
361
362 if (debug) std::cout << "IOVPayloadContainer::merge - insert payload "
363 << std::endl;
364
365 // Move the iterator forward
366 ++it;
367
368 // Now delete or truncate all subsequent IOVs which overlap
369 for (; it != m_payloadVec.end(); ++it) {
370
371 if (debug) std::cout << "IOVPayloadContainer::merge - checkOverlap, subsequent start/stop "
372 << (*it)->minRange().start() << " " << (*it)->minRange().stop()
373 << std::endl;
374
375 if ((*it)->minRange().stop() <= newStop) {
376 // remove attribute list collection
377 CondAttrListCollection* oldAttrListColl = (*it);
378 delete oldAttrListColl;
379 it = m_payloadVec.erase(it);
380
381 if (debug) std::cout << "IOVPayloadContainer::merge - remove payload "
382 << std::endl;
383
384 if (it != m_payloadVec.end()) {
385 --it; //have to do this otherwise the check on this element will be skipped.
386 continue; // go to the next element
387 }
388 }
389 else if ((*it)->minRange().start() < newStop) {
390 // Must truncate old IOV: reset old start to new stop
391 const IOVTime oldStop = (*it)->minRange().stop();
392 (*it)->resetMinRange();
393 (*it)->addNewStart(newStop);
394 (*it)->addNewStop(oldStop);
395
396 if (debug) std::cout << "IOVPayloadContainer::merge - checkOverlap, truncate start/stop "
397 << (*it)->minRange().start() << " " << (*it)->minRange().stop()
398 << std::endl;
399
400 }
401 // we can now leave the loop
402 break;
403 }
404
405 return true;
406 }
407
408 if (debug) std::cout << "IOVPayloadContainer::merge - no overlap, add in attrListColl " << std::endl;
409
410 // no overlaps - add in attribute list
411 m_payloadVec.insert(it, attrListColl);
412
413 return (true);
414}
const bool debug
void addNewStart(const IOVTime &start)
Add new start time to minRange - make sure that start is >= to new start.
void addNewStop(const IOVTime &stop)
Add new stop time to minRange - make sure that stop is <= to new stop.
void resetMinRange()
Reset minRange according to the IOVs of the contained channels.
const IOVRange & minRange() const
Current minimal IOVRange.
const IOVTime & stop() const
Definition IOVRange.h:39
const IOVTime & start() const
Definition IOVRange.h:38
static constexpr uint64_t MAXTIMESTAMP
Definition IOVTime.h:58
uint64_t timestamp() const noexcept
Definition IOVTime.h:108
uint64_t re_time() const noexcept
Definition IOVTime.h:107
bool isTimestamp() const noexcept
Definition IOVTime.h:111
static constexpr uint64_t MAXRETIME
Definition IOVTime.h:53
JetConstituentVector::iterator iterator

◆ operator=()

IOVPayloadContainer & IOVPayloadContainer::operator= ( const IOVPayloadContainer & cont)

Definition at line 22 of file IOVPayloadContainer.cxx.

23{
24 for(CondAttrListCollection* col : m_payloadVec) {
25 delete col;
26 }
27 m_payloadVec.clear();
28 m_payloadVec.reserve(cont.m_payloadVec.size());
29 for(CondAttrListCollection* col : cont.m_payloadVec) {
30 m_payloadVec.push_back(new CondAttrListCollection(*col));
31 }
32 return *this;
33}

◆ size()

IOVPayloadContainer::size_type IOVPayloadContainer::size ( ) const
inline

size of payload vector

Definition at line 121 of file IOVPayloadContainer.h.

122{
123 return (m_payloadVec.size());
124}

◆ IOVPayloadContainerCnv_p1

friend class IOVPayloadContainerCnv_p1
friend

Definition at line 82 of file IOVPayloadContainer.h.

◆ IOVPayloadContainerPTCnv_p1

friend class IOVPayloadContainerPTCnv_p1
friend

Definition at line 83 of file IOVPayloadContainer.h.

Member Data Documentation

◆ m_payloadVec

payloadVec IOVPayloadContainer::m_payloadVec
private

Definition at line 97 of file IOVPayloadContainer.h.


The documentation for this class was generated from the following files: