ATLAS Offline Software
Public Member Functions | Public Attributes | Private Attributes | List of all members
IOVData< T > Class Template Reference

#include <CoolQuery.h>

Collaboration diagram for IOVData< T >:

Public Member Functions

 IOVData ()
 
 ~IOVData ()
 
void clear ()
 
getValue (IOVTime time)
 
std::list< std::pair< IOVRange, T > > getOverlap (const IOVRange &range)
 
void add (IOVRange range, T val)
 

Public Attributes

std::list< std::pair< IOVRange, T > > data
 

Private Attributes

bool m_lastData
 
std::list< std::pair< IOVRange, T > >::iterator m_last
 

Detailed Description

template<class T>
class IOVData< T >

Definition at line 54 of file CoolQuery.h.

Constructor & Destructor Documentation

◆ IOVData()

template<class T >
IOVData< T >::IOVData ( )
inline

Definition at line 57 of file CoolQuery.h.

57  {
58  clear();
59  }

◆ ~IOVData()

template<class T >
IOVData< T >::~IOVData ( )
inline

Definition at line 61 of file CoolQuery.h.

61  {
62  clear();
63  }

Member Function Documentation

◆ add()

template<class T >
void IOVData< T >::add ( IOVRange  range,
val 
)

Definition at line 92 of file CoolQuery.h.

92  {
93  data.push_back(std::pair<IOVRange, T>(range, val));
94  m_last = data.begin();
95  m_lastData = false;
96 }

◆ clear()

template<class T >
void IOVData< T >::clear ( )
inline

Definition at line 65 of file CoolQuery.h.

65  {
66  data.clear();
67  m_last = data.begin();
68  m_lastData = false;
69  }

◆ getOverlap()

template<class T >
std::list< std::pair< IOVRange, T > > IOVData< T >::getOverlap ( const IOVRange range)

Definition at line 173 of file CoolQuery.h.

173  {
174 
175  std::list<std::pair<IOVRange, T> > mydata;
176  mydata.clear();
177 
178  // Find first time
179  IOVTime firsttime = range.start();
180  IOVTime lasttime = range.stop();
181 
182  // Use this to efficiently set the 'm_last' pointer
183  getValue(firsttime);
184 
185  // Pointer to found element
186  typename std::list<std::pair<IOVRange, T> >::iterator elem;
187 
188  std::pair<IOVRange, T> val;
189 
190  // Loop over elements
191  for (elem = m_last; elem != data.end(); ++elem) {
192 
193  val = *elem;
194 
195  // Truncate this if necessary
196  if (val.first.start() < firsttime || val.first.stop() > lasttime) {
197  IOVTime iovstart((val.first.start() < firsttime ? firsttime : val.first.start()));
198  IOVTime iovstop((val.first.stop() > lasttime ? lasttime : val.first.stop()));
199  val.first = IOVRange(iovstart, iovstop);
200  }
201  mydata.push_back(val);
202 
203  // Check if we are done
204  if (elem->first.isInRange(lasttime)) break;
205  }
206 
207  return mydata;
208 }

◆ getValue()

template<class T >
T IOVData< T >::getValue ( IOVTime  time)

Definition at line 99 of file CoolQuery.h.

99  {
100 
101  // bool verbose = false;
102  // if (verbose) {
103  // cout << endl << "getValue(" << time << ")" << endl;
104  // cout << "Data Size: " << data.size() << endl;
105  // }
106 
107  if (data.empty()) return T(-1);
108 
109  typename std::list<std::pair<IOVRange, T> >::iterator it;
110 
111  // if (verbose) {
112  // for (it = data.begin(); it != data.end(); it++)
113  // cout << "(" << it->first << ", " << it->second << ")" << endl;
114  // cout << "Last is valid - " << m_lastData << endl;
115  // }
116 
117  // Check if previous value is still good
118  if (m_lastData) {
119  // if (verbose) {
120  // cout << "Check previous " << m_last->first << endl;
121  // }
122 
123  if ((m_last->first).isInRange(time)) return m_last->second;
124 
125  // Previous not good, try next as best guess
126  if (++(m_last) != data.end()) {
127  // if (verbose) cout << "Check next " << m_last->first << endl;
128  if ((m_last->first).isInRange(time)) return m_last->second;
129  }
130  } else {
131  m_last = data.begin();
132  }
133 
134  m_lastData = false;
135 
136  // OK, suck it up and find the best value by stepping through entire list
137  // Make sure we start on a valid value
138  if ( m_last == data.end() ) --m_last;
139 
140  // Step forward looking for a match
141  if (m_last->first.stop() <= time) {
142 
143  // if (verbose) cout << "Search upwards" << endl;
144  for (++m_last; m_last != data.end(); ++m_last) {
145  // if (verbose) cout << m_last->first << endl;
146  if ((m_lastData = (m_last->first).isInRange(time))) return m_last->second;
147  }
148 
149  } else if ( m_last != data.begin() && m_last->first.start() > time) {
150 
151  // if (verbose) cout << "Search downwards" << endl;
152  do {
153  --m_last;
154  // if (verbose) cout << m_last->first << endl;
155  if ((m_lastData = (m_last->first).isInRange(time))) return m_last->second;
156  } while (m_last != data.begin());
157 
158  } else {
159 
160  if ((m_lastData = m_last->first.isInRange(time))) return m_last->second;
161 
162  }
163 
164  // Set to valid data if we didn't find anything
165  m_last = data.begin();
166  m_lastData = false;
167 
168  // If we got to here, we didn't find it
169  return T(-1);
170 }

Member Data Documentation

◆ data

template<class T >
std::list<std::pair<IOVRange, T > > IOVData< T >::data

Definition at line 81 of file CoolQuery.h.

◆ m_last

template<class T >
std::list<std::pair<IOVRange, T > >::iterator IOVData< T >::m_last
private

Definition at line 87 of file CoolQuery.h.

◆ m_lastData

template<class T >
bool IOVData< T >::m_lastData
private

Definition at line 84 of file CoolQuery.h.


The documentation for this class was generated from the following file:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IOVRange
Validity Range object. Holds two IOVTimes (start and stop)
Definition: IOVRange.h:30
IOVData::m_last
std::list< std::pair< IOVRange, T > >::iterator m_last
Definition: CoolQuery.h:87
skel.it
it
Definition: skel.GENtoEVGEN.py:396
IOVTime
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Definition: IOVTime.h:33
IOVData::clear
void clear()
Definition: CoolQuery.h:65
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
IOVData::m_lastData
bool m_lastData
Definition: CoolQuery.h:84
IOVData::data
std::list< std::pair< IOVRange, T > > data
Definition: CoolQuery.h:81
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
IOVData::getValue
T getValue(IOVTime time)
Definition: CoolQuery.h:99
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35