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 ()
 
 IOVData (const IOVData &)=default
 
 IOVData (IOVData &&)=default
 
IOVDataoperator= (const IOVData &)=default
 
IOVDataoperator= (IOVData &&)=default
 
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() [1/3]

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  }

◆ IOVData() [2/3]

template<class T >
IOVData< T >::IOVData ( const IOVData< T > &  )
default

◆ IOVData() [3/3]

template<class T >
IOVData< T >::IOVData ( IOVData< T > &&  )
default

Member Function Documentation

◆ add()

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

Definition at line 97 of file CoolQuery.h.

97  {
98  data.push_back(std::pair<IOVRange, T>(range, val));
99  m_last = data.begin();
100  m_lastData = false;
101 }

◆ clear()

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

Definition at line 70 of file CoolQuery.h.

70  {
71  data.clear();
72  m_last = data.begin();
73  m_lastData = false;
74  }

◆ getOverlap()

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

Definition at line 178 of file CoolQuery.h.

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

◆ getValue()

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

Definition at line 104 of file CoolQuery.h.

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

◆ operator=() [1/2]

template<class T >
IOVData& IOVData< T >::operator= ( const IOVData< T > &  )
default

◆ operator=() [2/2]

template<class T >
IOVData& IOVData< T >::operator= ( IOVData< T > &&  )
default

Member Data Documentation

◆ data

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

Definition at line 86 of file CoolQuery.h.

◆ m_last

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

Definition at line 92 of file CoolQuery.h.

◆ m_lastData

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

Definition at line 89 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:92
skel.it
it
Definition: skel.GENtoEVGEN.py:407
python.getProblemFolderFromLogs.elem
elem
Definition: getProblemFolderFromLogs.py:90
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:70
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
IOVData::m_lastData
bool m_lastData
Definition: CoolQuery.h:89
IOVData::data
std::list< std::pair< IOVRange, T > > data
Definition: CoolQuery.h:86
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:104
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35