ATLAS Offline Software
Public Member Functions | List of all members
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. More...
 
int extendRange (RangeKey &range, const RangeKey &newRange) const
 Possibly extend an existing range at the end. More...
 

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 158 of file CondCont.cxx.

160 {
161  // |--- range ---|
162  // |--- newRange ....
163  if (newRange.m_start < range.m_start) {
164  return 0;
165  }
166 
167  // |--- range ---|
168  // |--- newRange ....
169  if (newRange.m_start > range.m_stop) {
170  return 0;
171  }
172 
173  // |--- range ----------------|
174  // |--- newRange ---|
175  if (newRange.m_stop <= range.m_stop) {
176  return -1;
177  }
178 
179  // |--- range ----|
180  // |--- newRange ---|
181  range.m_stop = newRange.m_stop;
182  range.m_range = EventIDRange (range.m_range.start(),
183  newRange.m_range.stop());
184  return 1;
185 }

◆ 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  }

◆ 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 39 of file CondCont.cxx.

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

The documentation for this struct was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
CondContBase::keyFromTimestamp
static key_type keyFromTimestamp(const EventIDBase &b)
Make a timestamp key from an EventIDBase.
beamspotman.cur
def cur
Definition: beamspotman.py:671
CondContBase::keyFromRunLBN
static key_type keyFromRunLBN(const EventIDBase &b)
Make a run+lbn key from an EventIDBase.
Atlas::ExtendedEventContext::conditionsRun
EventIDBase::number_type conditionsRun() const
Definition: ExtendedEventContext.h:38
AtlasMcWeight::number_type
unsigned int number_type
Definition: AtlasMcWeight.h:20
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MCP::ScaleSmearParam::r2
@ r2
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
CondContBase::range
virtual bool range(const EventIDBase &t, EventIDRange &r) const =0
Return the mapped validity range for an IOV time.
CondContBase::key_type
uint64_t key_type
Type used to store an IOV time internally.
Definition: CondCont.h:204
MCP::ScaleSmearParam::r1
@ r1