ATLAS Offline Software
Classes | Public Member Functions | Static Public Attributes | Private Types | Private Attributes | Friends | List of all members
IOVTime Class Reference

Basic time unit for IOVSvc. Hold time as a combination of run and event numbers. More...

#include <IOVTime.h>

Collaboration diagram for IOVTime:

Classes

class  SortByRunEvent
 Predicate. Used to sort by run and event number. More...
 
class  SortByTimeStamp
 Predicate. Used to sort by time stamp. More...
 

Public Member Functions

 IOVTime ()
 
 IOVTime (uint64_t timestamp)
 
 IOVTime (uint32_t run, uint32_t event)
 
 IOVTime (uint32_t run, uint32_t event, uint64_t timestamp)
 
 IOVTime (const EventIDBase &eid)
 
void setTimestamp (uint64_t timestamp) noexcept
 
void setRETime (uint64_t time) noexcept
 
void setRunEvent (uint32_t run, uint32_t event) noexcept
 
void reset () noexcept
 
uint32_t run () const noexcept
 
uint32_t event () const noexcept
 
uint64_t re_time () const noexcept
 
uint64_t timestamp () const noexcept
 
bool isValid () const noexcept
 
bool isTimestamp () const noexcept
 
bool isRunEvent () const noexcept
 
bool isBoth () const noexcept
 
 operator std::string () const
 
 operator EventIDBase () const
 

Static Public Attributes

static constexpr uint32_t MINRUN = std::numeric_limits<uint32_t>::min()
 
static constexpr uint32_t MAXRUN = (std::numeric_limits<uint32_t>::max() >> 1)
 
static constexpr uint32_t MINEVENT = std::numeric_limits<uint32_t>::min()
 
static constexpr uint32_t MAXEVENT = (std::numeric_limits<uint32_t>::max())
 
static constexpr uint64_t MAXRETIME =( ((uint64_t) IOVTime::MAXRUN << 32) + IOVTime::MAXEVENT )
 
static constexpr uint64_t UNDEFRETIME = std::numeric_limits<uint64_t>::max()
 
static constexpr uint64_t MINTIMESTAMP = std::numeric_limits<uint64_t>::min()
 
static constexpr uint64_t MAXTIMESTAMP = (std::numeric_limits<uint64_t>::max() >> 1)
 
static constexpr uint64_t UNDEFTIMESTAMP = std::numeric_limits<uint64_t>::max()
 

Private Types

enum  IOVTime_type { UNDEF = 0, TIMESTAMP, RUN_EVT, BOTH }
 

Private Attributes

IOVTime_type m_status
 
uint64_t m_time
 
uint64_t m_timestamp
 

Friends

bool operator< (const IOVTime &lhs, const IOVTime &rhs) noexcept
 
bool operator> (const IOVTime &lhs, const IOVTime &rhs) noexcept
 
bool operator== (const IOVTime &lhs, const IOVTime &rhs) noexcept
 
bool operator!= (const IOVTime &lhs, const IOVTime &rhs) noexcept
 
bool operator>= (const IOVTime &lhs, const IOVTime &rhs) noexcept
 
bool operator<= (const IOVTime &lhs, const IOVTime &rhs) noexcept
 
std::ostream & operator<< (std::ostream &os, const IOVTime &rhs)
 
MsgStream & operator<< (MsgStream &os, const IOVTime &rhs)
 

Detailed Description

Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.

Definition at line 33 of file IOVTime.h.

Member Enumeration Documentation

◆ IOVTime_type

enum IOVTime::IOVTime_type
private
Enumerator
UNDEF 
TIMESTAMP 
RUN_EVT 
BOTH 

Definition at line 36 of file IOVTime.h.

36  {
37  UNDEF = 0,
38  TIMESTAMP,
39  RUN_EVT,
40  BOTH
41  };

Constructor & Destructor Documentation

◆ IOVTime() [1/5]

IOVTime::IOVTime ( )
inline

Definition at line 91 of file IOVTime.h.

◆ IOVTime() [2/5]

IOVTime::IOVTime ( uint64_t  timestamp)
inlineexplicit

Definition at line 93 of file IOVTime.h.

◆ IOVTime() [3/5]

IOVTime::IOVTime ( uint32_t  run,
uint32_t  event 
)
explicit

Definition at line 26 of file IOVTime.cxx.

26  :
29 {
30  m_time = ( (uint64_t) run << 32) + event;
31 }

◆ IOVTime() [4/5]

IOVTime::IOVTime ( uint32_t  run,
uint32_t  event,
uint64_t  timestamp 
)
explicit

Definition at line 35 of file IOVTime.cxx.

36  :
38 {
39  m_time = ( (uint64_t) run << 32) + event;
40 }

◆ IOVTime() [5/5]

IOVTime::IOVTime ( const EventIDBase &  eid)

Definition at line 44 of file IOVTime.cxx.

45 {
46  m_time = 0;
47  m_timestamp = eid.time_stamp()*1000000000LL + eid.time_stamp_ns_offset();
48 
49  if (eid.isRunEvent()) {
50  m_time = ( (uint64_t) eid.run_number() << 32) + eid.event_number();
51  if (eid.isTimeStamp()) {
53  } else {
55  }
56  } else if (eid.isLumiEvent()) {
57  m_time = ( (uint64_t) eid.lumi_block() << 32) + eid.event_number();
58  if (eid.isTimeStamp()) {
60  } else {
62  }
63  } else {
65  }
66 
67 }

Member Function Documentation

◆ event()

uint32_t IOVTime::event ( ) const
inlinenoexcept

Definition at line 106 of file IOVTime.h.

106 { return static_cast<uint32_t> (m_time & 0xFFFFFFFF); }

◆ isBoth()

bool IOVTime::isBoth ( ) const
inlinenoexcept

Definition at line 115 of file IOVTime.h.

115 { return (m_status == IOVTime::BOTH) ? 1 : 0; }

◆ isRunEvent()

bool IOVTime::isRunEvent ( ) const
inlinenoexcept

Definition at line 113 of file IOVTime.h.

113  { return (m_status == IOVTime::RUN_EVT ||
114  m_status == IOVTime::BOTH) ? 1 : 0; }

◆ isTimestamp()

bool IOVTime::isTimestamp ( ) const
inlinenoexcept

Definition at line 111 of file IOVTime.h.

111  { return (m_status == IOVTime::TIMESTAMP ||
112  m_status== IOVTime::BOTH) ? 1 : 0; }

◆ isValid()

bool IOVTime::isValid ( ) const
noexcept

Definition at line 117 of file IOVTime.cxx.

117  {
118 
119  // Cannot have BOTH undefined
122  return 0 ;
123  }
124 
125  // Check run/event to be < max
127  if ( run() > IOVTime::MAXRUN || event() > IOVTime::MAXEVENT ) {
128  return 0;
129  }
130  }
131 
132  // Check time < max
133  if (m_time == IOVTime::UNDEFRETIME) {
135  return 0;
136  }
137  }
138 
141  // May have both timestamp and run/event set
142  if ( run() > IOVTime::MAXRUN || event() > IOVTime::MAXEVENT ) {
143  return 0;
144  }
146  return 0;
147  }
148  }
149 
150  return 1;
151 
152 }

◆ operator EventIDBase()

IOVTime::operator EventIDBase ( ) const

Definition at line 168 of file IOVTime.cxx.

168  {
169  if (isBoth()) {
170  return EventIDBase(run(),EventIDBase::UNDEFEVT,
171  std::min(timestamp()/1000000000LL,(unsigned long long)(std::numeric_limits<unsigned int>::max()-1)),timestamp()%1000000000LL,
172  event());
173  } else if (isTimestamp()) {
174  return EventIDBase(EventIDBase::UNDEFNUM,EventIDBase::UNDEFEVT,
175  std::min(timestamp()/1000000000LL,(unsigned long long)(std::numeric_limits<unsigned int>::max()-1)),timestamp()%1000000000LL);
176  } else if (isRunEvent()) {
177  return EventIDBase(run(),EventIDBase::UNDEFEVT,
178  EventIDBase::UNDEFNUM,0,
179  event());
180  } else {
181  return EventIDBase();
182  }
183 }

◆ operator std::string()

IOVTime::operator std::string ( ) const

Definition at line 154 of file IOVTime.cxx.

154  {
155  std::ostringstream os;
156  os << "[";
157  if (isRunEvent()) {
158  os << (m_time>>32) << "," << ( m_time & 0xFFFFFFFF );
159  }
160  if (isTimestamp()) {
161  if (isRunEvent()) os << ":";
162  os << m_timestamp;
163  }
164  os << "]";
165  return os.str();
166 }

◆ re_time()

uint64_t IOVTime::re_time ( ) const
inlinenoexcept

Definition at line 107 of file IOVTime.h.

107 { return m_time; }

◆ reset()

void IOVTime::reset ( )
noexcept

Definition at line 108 of file IOVTime.cxx.

◆ run()

uint32_t IOVTime::run ( ) const
inlinenoexcept

Definition at line 105 of file IOVTime.h.

105 { return static_cast<uint32_t> (m_time>>32); }

◆ setRETime()

void IOVTime::setRETime ( uint64_t  time)
noexcept

Definition at line 84 of file IOVTime.cxx.

84  {
85  if (isTimestamp()) {
87  } else {
89  }
90  m_time = time;
91 }

◆ setRunEvent()

void IOVTime::setRunEvent ( uint32_t  run,
uint32_t  event 
)
noexcept

Definition at line 96 of file IOVTime.cxx.

96  {
97  if (isTimestamp()) {
99  } else {
101  }
102  m_time = ( (uint64_t) run << 32) + event;
103 }

◆ setTimestamp()

void IOVTime::setTimestamp ( uint64_t  timestamp)
noexcept

Definition at line 72 of file IOVTime.cxx.

72  {
73  if (isRunEvent()) {
75  } else {
77  }
79 }

◆ timestamp()

uint64_t IOVTime::timestamp ( ) const
inlinenoexcept

Definition at line 108 of file IOVTime.h.

108 { return m_timestamp; }

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const IOVTime lhs,
const IOVTime rhs 
)
friend

Definition at line 158 of file IOVTime.h.

158  {
159  return !(lhs == rhs) ;
160 }

◆ operator<

bool operator< ( const IOVTime lhs,
const IOVTime rhs 
)
friend

Definition at line 137 of file IOVTime.h.

137  {
138  if (lhs.isTimestamp() && rhs.isTimestamp()) {
139  return lhs.m_timestamp < rhs.m_timestamp;
140  } else {
141  return lhs.m_time < rhs.m_time;
142  }
143 }

◆ operator<< [1/2]

MsgStream& operator<< ( MsgStream &  os,
const IOVTime rhs 
)
friend

Definition at line 185 of file IOVTime.cxx.

185  {
186  os << (std::string) rhs;
187  return os;
188 }

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  os,
const IOVTime rhs 
)
friend

Definition at line 190 of file IOVTime.cxx.

190  {
191  os << (std::string) rhs;
192  return os;
193 }

◆ operator<=

bool operator<= ( const IOVTime lhs,
const IOVTime rhs 
)
friend

Definition at line 164 of file IOVTime.h.

164  {
165  return !( lhs > rhs );
166 }

◆ operator==

bool operator== ( const IOVTime lhs,
const IOVTime rhs 
)
friend

Definition at line 151 of file IOVTime.h.

151  {
152  if (lhs.isTimestamp() && rhs.isTimestamp()) {
153  return lhs.m_timestamp == rhs.m_timestamp;
154  } else {
155  return lhs.m_time == rhs.m_time;
156  }
157 }

◆ operator>

bool operator> ( const IOVTime lhs,
const IOVTime rhs 
)
friend

Definition at line 144 of file IOVTime.h.

144  {
145  if (lhs.isTimestamp() && rhs.isTimestamp()) {
146  return lhs.m_timestamp > rhs.m_timestamp;
147  } else {
148  return lhs.m_time > rhs.m_time;
149  }
150 }

◆ operator>=

bool operator>= ( const IOVTime lhs,
const IOVTime rhs 
)
friend

Definition at line 161 of file IOVTime.h.

161  {
162  return !( lhs < rhs );
163 }

Member Data Documentation

◆ m_status

IOVTime_type IOVTime::m_status
private

Definition at line 132 of file IOVTime.h.

◆ m_time

uint64_t IOVTime::m_time
private

Definition at line 133 of file IOVTime.h.

◆ m_timestamp

uint64_t IOVTime::m_timestamp
private

Definition at line 134 of file IOVTime.h.

◆ MAXEVENT

constexpr uint32_t IOVTime::MAXEVENT = (std::numeric_limits<uint32_t>::max())
staticconstexpr

Definition at line 51 of file IOVTime.h.

◆ MAXRETIME

constexpr uint64_t IOVTime::MAXRETIME =( ((uint64_t) IOVTime::MAXRUN << 32) + IOVTime::MAXEVENT )
staticconstexpr

Definition at line 53 of file IOVTime.h.

◆ MAXRUN

constexpr uint32_t IOVTime::MAXRUN = (std::numeric_limits<uint32_t>::max() >> 1)
staticconstexpr

Definition at line 48 of file IOVTime.h.

◆ MAXTIMESTAMP

constexpr uint64_t IOVTime::MAXTIMESTAMP = (std::numeric_limits<uint64_t>::max() >> 1)
staticconstexpr

Definition at line 58 of file IOVTime.h.

◆ MINEVENT

constexpr uint32_t IOVTime::MINEVENT = std::numeric_limits<uint32_t>::min()
staticconstexpr

Definition at line 50 of file IOVTime.h.

◆ MINRUN

constexpr uint32_t IOVTime::MINRUN = std::numeric_limits<uint32_t>::min()
staticconstexpr

Definition at line 44 of file IOVTime.h.

◆ MINTIMESTAMP

constexpr uint64_t IOVTime::MINTIMESTAMP = std::numeric_limits<uint64_t>::min()
staticconstexpr

Definition at line 56 of file IOVTime.h.

◆ UNDEFRETIME

constexpr uint64_t IOVTime::UNDEFRETIME = std::numeric_limits<uint64_t>::max()
staticconstexpr

Definition at line 54 of file IOVTime.h.

◆ UNDEFTIMESTAMP

constexpr uint64_t IOVTime::UNDEFTIMESTAMP = std::numeric_limits<uint64_t>::max()
staticconstexpr

Definition at line 59 of file IOVTime.h.


The documentation for this class was generated from the following files:
IOVTime::BOTH
@ BOTH
Definition: IOVTime.h:40
max
#define max(a, b)
Definition: cfImp.cxx:41
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
IOVTime::event
uint32_t event() const noexcept
Definition: IOVTime.h:106
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
IOVTime::timestamp
uint64_t timestamp() const noexcept
Definition: IOVTime.h:108
IOVTime::RUN_EVT
@ RUN_EVT
Definition: IOVTime.h:39
IOVTime::isBoth
bool isBoth() const noexcept
Definition: IOVTime.h:115
IOVTime::m_status
IOVTime_type m_status
Definition: IOVTime.h:132
IOVTime::UNDEFTIMESTAMP
static constexpr uint64_t UNDEFTIMESTAMP
Definition: IOVTime.h:59
python.LArBadChannelDBAlg.xFFFFFFFF
xFFFFFFFF
Definition: LArBadChannelDBAlg.py:73
IOVTime::isRunEvent
bool isRunEvent() const noexcept
Definition: IOVTime.h:113
IOVTime::MAXTIMESTAMP
static constexpr uint64_t MAXTIMESTAMP
Definition: IOVTime.h:58
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
IOVTime::isTimestamp
bool isTimestamp() const noexcept
Definition: IOVTime.h:111
IOVTime::m_timestamp
uint64_t m_timestamp
Definition: IOVTime.h:134
run
Definition: run.py:1
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
min
#define min(a, b)
Definition: cfImp.cxx:40
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition: IOVTime.h:51
IOVTime::run
uint32_t run() const noexcept
Definition: IOVTime.h:105
IOVTime::UNDEF
@ UNDEF
Definition: IOVTime.h:37
IOVTime::UNDEFRETIME
static constexpr uint64_t UNDEFRETIME
Definition: IOVTime.h:54
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
IOVTime::TIMESTAMP
@ TIMESTAMP
Definition: IOVTime.h:38
IOVTime::m_time
uint64_t m_time
Definition: IOVTime.h:133