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.
37{
38
39
40
41
42
43
44
45 typedef std::vector<CondAttrListCollection*>::iterator
iterator;
50
54
55 std::cout << "IOVPayloadContainer::merge - after lowerbound" << std::endl;
56
58 std::cout << "IOVPayloadContainer::merge - begin range "
60 << std::endl;
61 }
63 std::cout << "IOVPayloadContainer::merge - it range "
64 << (*it)->minRange()
65 << std::endl;
66 }
67 std::cout << "IOVPayloadContainer::merge - attrList range "
69 << std::endl;
70 }
71
72
74
75
76
77
79 --itPrev;
80
81 if (
debug) std::cout <<
"IOVPayloadContainer::merge - not begin " << std::endl;
82
83 if ((*itPrev)->isSameButMinRange(*attrListColl)) {
84
85
86
87
88
89
90 const IOVTime startPrev = (*itPrev)->minRange().start();
91 const IOVTime stopPrev = (*itPrev)->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
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
112 CondAttrListCollection* oldAttrListColl = (*it);
113 delete oldAttrListColl;
115
116
117
118 if (
debug) std::cout <<
"IOVPayloadContainer::merge - isSameButMinRange, remove payload "
119 << std::endl;
120
122 {
124 continue;
125 }
126 }
127 else if ((*it)->minRange().start() < stop) {
128
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
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
150
151
152
153 CondAttrListCollection* prevColl = *itPrev;
155 CondAttrListCollection* prevColl1 = new CondAttrListCollection(*prevColl);
157
158 if (
debug) std::cout <<
"IOVPayloadContainer::merge - attrListColl falls within prev IOV range: "
161 << std::endl;
162
163
164
165
167
168 if (
debug) std::cout <<
"IOVPayloadContainer::merge - duplicated previous and insert "
171 << std::endl;
172 }
173
178
179 if (
debug) std::cout <<
"IOVPayloadContainer::merge - reset prev stop "
181 << std::endl;
182 }
183 }
184
185 bool checkOverlap = false;
187 if (it != last) {
188
189 if ( (**it) == (*attrListColl) ) {
190
191 if (
debug) std::cout <<
"IOVPayloadContainer::merge - duplicate - reject new one " << std::endl;
192
193 return false;
194 }
195
196
197
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
204
205
206
207
208
209 if ((*it)->minRange().start() == attrListColl->
minRange().
start() &&
210 (*it)->minRange().stop() < attrListColl->
minRange().
stop()) {
211
212
213
214
215 CondAttrListCollection*
old = *
it;
217 (*it) = attrListColl;
219
220 if (
debug) std::cout <<
"IOVPayloadContainer::merge - isSameButMinRange with later stop -> replace " << (*it)->minRange() << std::endl;
221
222
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
232 CondAttrListCollection* oldAttrListColl = (*it);
233 delete oldAttrListColl;
235
236
237
238
239 if (
debug) std::cout <<
"IOVPayloadContainer::merge - isSameButMinRange, remove payload "
240 << std::endl;
241
244 continue;
245 }
246 }
247 else if ((*it)->minRange().start() < stop) {
248
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
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;
277 }
278
279 if (checkOverlap) {
280
281
282
283
284
285
289
290 if (
debug) std::cout <<
"IOVPayloadContainer::merge - checkOverlap, new start/stop "
291 << newStart << " " << newStop
292 << std::endl;
293
294
295
296
297
298
299
300 bool isAtMax = false;
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
311 newStop = (*it)->minRange().stop();
313
314 if (
debug) std::cout <<
"IOVPayloadContainer::merge - set new stop to old stop " << std::endl;
315
316 }
317 else {
318
321 newStop = (*it)->minRange().start();
323
324 if (
debug) std::cout <<
"IOVPayloadContainer::merge - set new stop to old start " << std::endl;
325
326 }
327 }
328
329
330
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
344
345 if ((*itStart)->minRange().start() < newStart && newStart < (*itStart)->minRange().stop() ) {
346
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
361
362 if (
debug) std::cout <<
"IOVPayloadContainer::merge - insert payload "
363 << std::endl;
364
365
367
368
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
377 CondAttrListCollection* oldAttrListColl = (*it);
378 delete oldAttrListColl;
380
381 if (
debug) std::cout <<
"IOVPayloadContainer::merge - remove payload "
382 << std::endl;
383
386 continue;
387 }
388 }
389 else if ((*it)->minRange().start() < newStop) {
390
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
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
412
413 return (true);
414}
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
const IOVTime & start() const
static constexpr uint64_t MAXTIMESTAMP
uint64_t timestamp() const noexcept
uint64_t re_time() const noexcept
bool isTimestamp() const noexcept
static constexpr uint64_t MAXRETIME
JetConstituentVector::iterator iterator