ATLAS Offline Software
Loading...
Searching...
No Matches
CondContBase::Compare Struct Reference

Comparison object needed by ConcurrentRangeMap. More...

#include <CondCont.h>

Collaboration diagram for CondContBase::Compare:

Public Member Functions

bool operator() (const RangeKey &r1, const RangeKey &r2) const
bool operator() (key_type t, const RangeKey &r2) const
bool inRange (key_type t, const RangeKey &r) const
int overlap (const EventContext &ctx, const RangeKey &oldRange, RangeKey &newRange) const
 Test if two ranges overlap, and adjust if needed.
int extendRange (RangeKey &range, const RangeKey &newRange) const
 Possibly extend an existing range at the end.

Detailed Description

Comparison object needed by ConcurrentRangeMap.

Definition at line 449 of file CondCont.h.

Member Function Documentation

◆ extendRange()

int CondContBase::Compare::extendRange ( RangeKey & range,
const RangeKey & newRange ) const

Possibly extend an existing range at the end.

Parameters
rangeTHe existing range.
newRangeRange being added.

Returns one of: 0 – no change was made to RANGE. 1 – RANGE was extended. -1 – newRange is a duplicate.

Definition at line 157 of file CondCont.cxx.

159{
160 // |--- range ---|
161 // |--- newRange ....
162 if (newRange.m_start < range.m_start) {
163 return 0;
164 }
165
166 // |--- range ---|
167 // |--- newRange ....
168 if (newRange.m_start > range.m_stop) {
169 return 0;
170 }
171
172 // |--- range ----------------|
173 // |--- newRange ---|
174 if (newRange.m_stop <= range.m_stop) {
175 return -1;
176 }
177
178 // |--- range ----|
179 // |--- newRange ---|
180 range.m_stop = newRange.m_stop;
181 range.m_range = EventIDRange (range.m_range.start(),
182 newRange.m_range.stop());
183 return 1;
184}
virtual bool range(const EventIDBase &t, EventIDRange &r) const =0
Return the mapped validity range for an IOV time.

◆ inRange()

bool CondContBase::Compare::inRange ( key_type t,
const RangeKey & r ) const
inline

Definition at line 455 of file CondCont.h.

456 {
457 return t >= r.m_start && t< r.m_stop;
458 }
int r
Definition globals.cxx:22

◆ operator()() [1/2]

bool CondContBase::Compare::operator() ( const RangeKey & r1,
const RangeKey & r2 ) const
inline

Definition at line 451 of file CondCont.h.

452 { return r1.m_start < r2.m_start; }

◆ operator()() [2/2]

bool CondContBase::Compare::operator() ( key_type t,
const RangeKey & r2 ) const
inline

Definition at line 453 of file CondCont.h.

454 { return t < r2.m_start; }

◆ overlap()

int CondContBase::Compare::overlap ( const EventContext & ctx,
const RangeKey & oldRange,
RangeKey & newRange ) const

Test if two ranges overlap, and adjust if needed.

Parameters
ctxEvent context passed to emplace().
oldRangeAn existing range in the container.
newRangeNew range being added.

Returns one of: 0 – no overlap between the ranges; NEWRANGE is unmodified. 1 – ranges overlap. NEWRANGE has been adjusted to avoid the overlap. If the start of NEWRANGE is changed, it must only be moved forward (increased), never backwards. -1 – duplicate: NEWRANGE is entirely inside OLDRANGE. Delete the new range.

Definition at line 38 of file CondCont.cxx.

41{
42 // |--- oldRange ---|
43 // |--- newRange ---|
44 if (newRange.m_stop <= oldRange.m_start) {
45 return 0;
46 }
47
48 // |--- oldRange ---|
49 // |--- newRange ---|
50 if (oldRange.m_stop <= newRange.m_start) {
51 return 0;
52 }
53
54 // |--- oldRange ---|
55 // |--- newRange ---|
56 if (newRange.m_start >= oldRange.m_start &&
57 newRange.m_stop <= oldRange.m_stop)
58 {
59 return -1;
60 }
61
62 // Current IOV key.
64 if (newRange.m_range.start().isTimeStamp()) {
65 cur = keyFromTimestamp (ctx.eventID());
66 }
67 else {
68 EventIDBase eid = ctx.eventID();
69 if (ctx.hasExtension()) {
70 EventIDBase::number_type conditionsRun =
72 if (conditionsRun != EventIDBase::UNDEFNUM) {
73 eid.set_run_number (conditionsRun);
74 }
75 }
76 cur = keyFromRunLBN (eid);
77 }
78
79 // Either this:
80 // |--- oldRange ---|
81 // |--- newRange ---|
82 //
83 // Or this
84 // |--- oldRange ---|
85 // |--- newRange ---|
86 // with the current IOV key after the end of oldRange.
87 //
88 // In either case, we start the start of newRange to the end of oldRange.
89 if (newRange.m_stop > oldRange.m_stop &&
90 (newRange.m_start >= oldRange.m_start ||
91 cur > oldRange.m_stop))
92 {
93 newRange.m_start = oldRange.m_stop;
94 if (oldRange.m_range.stop().isTimeStamp()) {
95 // If this is a mixed key, we need to copy only the timestamp part.
96 EventIDBase oldId = oldRange.m_range.stop();
97 EventIDBase newId = newRange.m_range.start();
98 newRange.m_range = EventIDRange (EventIDBase (newId.run_number(),
99 newId.event_number(),
100 oldId.time_stamp(),
101 oldId.time_stamp_ns_offset(),
102 newId.lumi_block(),
103 newId.bunch_crossing_id()),
104 newRange.m_range.stop());
105 }
106 else {
107 newRange.m_range = EventIDRange (oldRange.m_range.stop(),
108 newRange.m_range.stop());
109 }
110 }
111
112
113 // |--- oldRange ---|
114 // |--- newRange ---|
115 else if (newRange.m_start < oldRange.m_start &&
116 newRange.m_stop > oldRange.m_start)
117 {
118 // Change the end of newRange to the start of oldRange.
119 newRange.m_stop = oldRange.m_start;
120 if (oldRange.m_range.start().isTimeStamp()) {
121 // If this is a mixed key, we need to copy only the timestamp part.
122 EventIDBase oldId = oldRange.m_range.start();
123 EventIDBase newId = newRange.m_range.stop();
124 newRange.m_range = EventIDRange (newRange.m_range.start(),
125 EventIDBase (newId.run_number(),
126 newId.event_number(),
127 oldId.time_stamp(),
128 oldId.time_stamp_ns_offset(),
129 newId.lumi_block(),
130 newId.bunch_crossing_id()));
131 }
132 else {
133 newRange.m_range = EventIDRange (newRange.m_range.start(),
134 oldRange.m_range.start());
135 }
136 }
137
138 // Should have handled all cases by now!
139 else {
140 std::abort();
141 }
142
143 return 1;
144}
EventIDBase::number_type conditionsRun() const
static key_type keyFromTimestamp(const EventIDBase &b)
Make a timestamp key from an EventIDBase.
static key_type keyFromRunLBN(const EventIDBase &b)
Make a run+lbn key from an EventIDBase.
uint64_t key_type
Type used to store an IOV time internally.
Definition CondCont.h:204
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.

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