The Gaudi Framework  master (9f3f8895)
Loading...
Searching...
No Matches
EventIDBase Class Reference

This class provides a unique identification for each event, in terms of run/event number and/or a time stamp. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/EventIDBase.h>

Public Types

typedef unsigned int number_type
typedef uint64_t event_number_t

Static Public Attributes

static const number_type UNDEFNUM = std::numeric_limits<EventIDBase::number_type>::max()
static const event_number_t UNDEFEVT = std::numeric_limits<EventIDBase::event_number_t>::max()

Friends

class EventIDRange

structors

enum  Type {
  Invalid = 0 , RunEvent = 1 << 1 , TimeStamp = 1 << 2 , LumiEvent = 1 << 3 ,
  RunLumi = 1 << 4
}
bool operator== (const EventIDBase &lhs, const EventIDBase &rhs)
 Comparison operators.
bool operator< (const EventIDBase &lhs, const EventIDBase &rhs)
bool operator> (const EventIDBase &lhs, const EventIDBase &rhs)
bool operator!= (const EventIDBase &lhs, const EventIDBase &rhs)
bool operator<= (const EventIDBase &lhs, const EventIDBase &rhs)
bool operator>= (const EventIDBase &lhs, const EventIDBase &rhs)
EventIDBase min (const EventIDBase &lhs, const EventIDBase &rhs)
EventIDBase max (const EventIDBase &lhs, const EventIDBase &rhs)
std::ostream & operator<< (std::ostream &os, const EventIDBase &rhs)
 Extraction operators.
EventIDBase min (const EventIDBase &lhs, const EventIDBase &rhs)
EventIDBase max (const EventIDBase &lhs, const EventIDBase &rhs)
bool operator< (const EventIDBase &lhs, const EventIDBase &rhs)
bool operator== (const EventIDBase &lhs, const EventIDBase &rhs)
std::ostream & operator<< (std::ostream &os, const EventIDBase &rhs)
unsigned m_type { Invalid }
number_type m_run_number { UNDEFNUM }
 run number
event_number_t m_event_number { UNDEFEVT }
 event number
number_type m_time_stamp { UNDEFNUM }
 posix time in seconds since 1970/01/01
number_type m_time_stamp_ns_offset { UNDEFNUM }
 time stamp ns - ns time offset for time_stamp, 32 bit unsigned
number_type m_lumi_block { UNDEFNUM }
 luminosity block number: the number which uniquely tags a luminosity block within a run
number_type m_bunch_crossing_id { UNDEFNUM }
 bunch crossing ID, 32 bit unsigned
 EventIDBase ()
 EventIDBase (number_type run_number, event_number_t event_number, number_type time_stamp=UNDEFNUM, number_type time_stamp_ns_offset=0, number_type lumi_block=UNDEFNUM, number_type bunch_crossing_id=0)
 EventIDBase (std::tuple< number_type, number_type, event_number_t > run_lumi_ev, std::tuple< number_type, number_type > time_stamp, number_type bunch_crossing_id)
virtual ~EventIDBase ()=default
number_type run_number () const
 run number - 32 bit unsigned
event_number_t event_number () const
 event number - 64 bit unsigned
number_type time_stamp () const
 time stamp - posix time in seconds from 1970, 32 bit unsigned
number_type time_stamp_ns_offset () const
 time stamp ns - ns time offset for time_stamp, 32 bit unsigned
number_type lumi_block () const
 luminosity block identifier, 32 bit unsigned
number_type bunch_crossing_id () const
 bunch crossing ID, 32 bit unsigned
void set_run_number (number_type runNumber)
 set run number
void set_event_number (event_number_t eventNumber)
 set event number
void set_time_stamp (number_type timeStamp)
 set time stamp
void set_time_stamp_ns_offset (number_type timeStampNs)
 set time stamp in ns
void set_lumi_block (number_type lumiBlock)
 set luminosity block identifier
void set_bunch_crossing_id (number_type bcid)
 set bunch crossing ID
bool isRunEvent () const
bool isTimeStamp () const
bool isLumiEvent () const
bool isRunLumi () const
bool isValid () const
void setRE ()
void setTS ()
void setLE ()
void setRL ()

Detailed Description

This class provides a unique identification for each event, in terms of run/event number and/or a time stamp.

Definition at line 53 of file EventIDBase.h.

Member Typedef Documentation

◆ event_number_t

typedef uint64_t EventIDBase::event_number_t

Definition at line 56 of file EventIDBase.h.

◆ number_type

typedef unsigned int EventIDBase::number_type

Definition at line 55 of file EventIDBase.h.

Member Enumeration Documentation

◆ Type

enum EventIDBase::Type
private
Enumerator
Invalid 
RunEvent 
TimeStamp 
LumiEvent 
RunLumi 

Definition at line 150 of file EventIDBase.h.

150{ Invalid = 0, RunEvent = 1 << 1, TimeStamp = 1 << 2, LumiEvent = 1 << 3, RunLumi = 1 << 4 };

Constructor & Destructor Documentation

◆ EventIDBase() [1/3]

EventIDBase::EventIDBase ( )
inline

Definition at line 66 of file EventIDBase.h.

66{}

◆ EventIDBase() [2/3]

EventIDBase::EventIDBase ( number_type run_number,
event_number_t event_number,
number_type time_stamp = UNDEFNUM,
number_type time_stamp_ns_offset = 0,
number_type lumi_block = UNDEFNUM,
number_type bunch_crossing_id = 0 )

Definition at line 27 of file EventIDBase.cpp.

36
37 if ( m_time_stamp != UNDEFNUM ) {
38 setTS();
40 }
41
43
45}
number_type lumi_block() const
luminosity block identifier, 32 bit unsigned
Definition EventIDBase.h:91
static const event_number_t UNDEFEVT
Definition EventIDBase.h:59
number_type m_bunch_crossing_id
bunch crossing ID, 32 bit unsigned
number_type m_lumi_block
luminosity block number: the number which uniquely tags a luminosity block within a run
number_type run_number() const
run number - 32 bit unsigned
Definition EventIDBase.h:79
number_type time_stamp_ns_offset() const
time stamp ns - ns time offset for time_stamp, 32 bit unsigned
Definition EventIDBase.h:88
event_number_t m_event_number
event number
number_type m_run_number
run number
number_type m_time_stamp_ns_offset
time stamp ns - ns time offset for time_stamp, 32 bit unsigned
number_type m_time_stamp
posix time in seconds since 1970/01/01
number_type bunch_crossing_id() const
bunch crossing ID, 32 bit unsigned
Definition EventIDBase.h:94
static const number_type UNDEFNUM
Definition EventIDBase.h:58
event_number_t event_number() const
event number - 64 bit unsigned
Definition EventIDBase.h:82
number_type time_stamp() const
time stamp - posix time in seconds from 1970, 32 bit unsigned
Definition EventIDBase.h:85

◆ EventIDBase() [3/3]

EventIDBase::EventIDBase ( std::tuple< number_type, number_type, event_number_t > run_lumi_ev,
std::tuple< number_type, number_type > time_stamp,
number_type bunch_crossing_id )

Definition at line 47 of file EventIDBase.cpp.

49 : EventIDBase( std::get<0>( run_lumi_ev ), // run number
50 std::get<2>( run_lumi_ev ), // event number
51 std::get<0>( time_stamp ), // timestamp in seconds
52 std::get<1>( time_stamp ), // nanoseconds offst
53 std::get<1>( run_lumi_ev ), // lumi block

◆ ~EventIDBase()

virtual EventIDBase::~EventIDBase ( )
virtualdefault

Member Function Documentation

◆ bunch_crossing_id()

number_type EventIDBase::bunch_crossing_id ( ) const
inline

bunch crossing ID, 32 bit unsigned

Definition at line 94 of file EventIDBase.h.

94{ return m_bunch_crossing_id; }

◆ event_number()

event_number_t EventIDBase::event_number ( ) const
inline

event number - 64 bit unsigned

Definition at line 82 of file EventIDBase.h.

82{ return m_event_number; }

◆ isLumiEvent()

bool EventIDBase::isLumiEvent ( ) const
inline

Definition at line 142 of file EventIDBase.h.

142{ return m_type & LumiEvent; }
unsigned m_type

◆ isRunEvent()

bool EventIDBase::isRunEvent ( ) const
inline

Definition at line 140 of file EventIDBase.h.

140{ return m_type & RunEvent; }

◆ isRunLumi()

bool EventIDBase::isRunLumi ( ) const
inline

Definition at line 143 of file EventIDBase.h.

143{ return m_type & RunLumi; }

◆ isTimeStamp()

bool EventIDBase::isTimeStamp ( ) const
inline

Definition at line 141 of file EventIDBase.h.

141{ return m_type & TimeStamp; }

◆ isValid()

bool EventIDBase::isValid ( ) const
inline

Definition at line 144 of file EventIDBase.h.

144{ return m_type != Invalid; }

◆ lumi_block()

number_type EventIDBase::lumi_block ( ) const
inline

luminosity block identifier, 32 bit unsigned

Definition at line 91 of file EventIDBase.h.

91{ return m_lumi_block; }

◆ run_number()

number_type EventIDBase::run_number ( ) const
inline

run number - 32 bit unsigned

Definition at line 79 of file EventIDBase.h.

79{ return m_run_number; }

◆ set_bunch_crossing_id()

void EventIDBase::set_bunch_crossing_id ( number_type bcid)
inline

set bunch crossing ID

Definition at line 127 of file EventIDBase.h.

127{ m_bunch_crossing_id = bcid; }

◆ set_event_number()

void EventIDBase::set_event_number ( event_number_t eventNumber)
inline

set event number

Definition at line 104 of file EventIDBase.h.

104 {
105 m_event_number = eventNumber;
106 if ( m_run_number != UNDEFNUM ) setRE();
107 if ( m_lumi_block != UNDEFNUM ) setLE();
108 }

◆ set_lumi_block()

void EventIDBase::set_lumi_block ( number_type lumiBlock)
inline

set luminosity block identifier

Definition at line 120 of file EventIDBase.h.

120 {
121 m_lumi_block = lumiBlock;
122 if ( m_run_number != UNDEFNUM ) setRL();
123 if ( m_event_number != UNDEFEVT ) setLE();
124 }

◆ set_run_number()

void EventIDBase::set_run_number ( number_type runNumber)
inline

set run number

Definition at line 97 of file EventIDBase.h.

97 {
98 m_run_number = runNumber;
99 if ( m_event_number != UNDEFEVT ) setRE();
100 if ( m_lumi_block != UNDEFNUM ) setRL();
101 }

◆ set_time_stamp()

void EventIDBase::set_time_stamp ( number_type timeStamp)
inline

set time stamp

Definition at line 111 of file EventIDBase.h.

111 {
112 m_time_stamp = timeStamp;
113 setTS();
114 }

◆ set_time_stamp_ns_offset()

void EventIDBase::set_time_stamp_ns_offset ( number_type timeStampNs)
inline

set time stamp in ns

Definition at line 117 of file EventIDBase.h.

117{ m_time_stamp_ns_offset = timeStampNs; }

◆ setLE()

void EventIDBase::setLE ( )
inlineprivate

Definition at line 156 of file EventIDBase.h.

156{ m_type |= LumiEvent; }

◆ setRE()

void EventIDBase::setRE ( )
inlineprivate

Definition at line 154 of file EventIDBase.h.

154{ m_type |= RunEvent; }

◆ setRL()

void EventIDBase::setRL ( )
inlineprivate

Definition at line 157 of file EventIDBase.h.

157{ m_type |= RunLumi; }

◆ setTS()

void EventIDBase::setTS ( )
inlineprivate

Definition at line 155 of file EventIDBase.h.

155{ m_type |= TimeStamp; }

◆ time_stamp()

number_type EventIDBase::time_stamp ( ) const
inline

time stamp - posix time in seconds from 1970, 32 bit unsigned

Definition at line 85 of file EventIDBase.h.

85{ return m_time_stamp; }

◆ time_stamp_ns_offset()

number_type EventIDBase::time_stamp_ns_offset ( ) const
inline

time stamp ns - ns time offset for time_stamp, 32 bit unsigned

Definition at line 88 of file EventIDBase.h.

88{ return m_time_stamp_ns_offset; }

◆ EventIDRange

friend class EventIDRange
friend

Definition at line 61 of file EventIDBase.h.

◆ max [1/2]

EventIDBase max ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 191 of file EventIDBase.h.

191 {
192
193 //"max" is much trickier because we need to handle invalid number explicilty by
194 // checking if a EventIDBase is TS or Run/Lumi
195
196 std::tuple<EventIDBase::number_type, EventIDBase::number_type, EventIDBase::event_number_t> run_lumi_ev;
197 std::tuple<EventIDBase::number_type, EventIDBase::number_type> time_stamp;
198
199 if ( lhs.isTimeStamp() && rhs.isTimeStamp() ) { // both time-stamp, compare them
200 time_stamp = std::max( std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset ),
201 std::tie( rhs.m_time_stamp, rhs.m_time_stamp_ns_offset ) );
202 } else if ( lhs.isTimeStamp() ) { // only lhs time-stamp: Use it
203 time_stamp = std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset );
204 } else { // otherwise use rhs time-stamp which might be UNDEFNUM (in case both input values are Run-Lumi only)
205 time_stamp = std::tie( rhs.m_time_stamp, rhs.m_time_stamp_ns_offset );
206 }
207
208 if ( lhs.isRunLumi() && rhs.isRunLumi() ) { // both run-lumi, compare them
209 run_lumi_ev = std::max( std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number ),
210 std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number ) );
211
212 } else if ( lhs.isRunLumi() ) { // only lhs run-lumi: Use it
213 run_lumi_ev = std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number );
214 } else { // otherwise use rhs run-lumi which might be UNDEFNUM (in case both input values are TS-only)
215 run_lumi_ev = std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number );
216 }
217
218 return EventIDBase( run_lumi_ev, time_stamp, lhs.bunch_crossing_id() );
219 }
bool isTimeStamp() const
bool isRunLumi() const

◆ max [2/2]

EventIDBase max ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

◆ min [1/2]

EventIDBase min ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 178 of file EventIDBase.h.

178 {
179
180 //"min" is easy b/c the numbers denoting invalidty for TS or Run/Event/LB are the
181 // largest possible numbers, so naturally larger than any valid number
182
183 return EventIDBase( std::min( std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number ),
184 std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number ) ),
185 std::min( std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset ),
186 std::tie( rhs.m_time_stamp, rhs.m_time_stamp_ns_offset ) ),
187 lhs.bunch_crossing_id() // bcid doesn't really matter here
188 );
189 }

◆ min [2/2]

EventIDBase min ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

◆ operator!=

bool operator!= ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 133 of file EventIDBase.h.

133{ return !( lhs == rhs ); }

◆ operator< [1/2]

bool operator< ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 221 of file EventIDBase.h.

221 {
222 // first try ordering by timestamp if both are non-zero
223 // then try ordering by run/lumi/event
224 // this assumes that both EventIDBase have the same set of values defined.
225
226 if ( lhs.isTimeStamp() && rhs.isTimeStamp() ) {
227 return lhs.m_time_stamp < rhs.m_time_stamp;
228 } else {
229 return std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number ) <
230 std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number );
231 }
232 }

◆ operator< [2/2]

bool operator< ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

◆ operator<< [1/2]

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

Definition at line 240 of file EventIDBase.h.

240 {
241 if ( rhs.m_type == EventIDBase::Invalid ) return os << "[INVALID]";
242
243 const char* separator = "";
244 os << "[";
245 if ( rhs.m_run_number != EventIDBase::UNDEFNUM ) {
246 os << rhs.m_run_number;
247 separator = ",";
248 }
249
251 os << separator << rhs.m_event_number;
252 separator = ",";
253 }
254
255 if ( rhs.isTimeStamp() ) {
256 os << separator << "t:" << rhs.m_time_stamp;
257 if ( rhs.m_time_stamp_ns_offset != 0 ) {
258 os << "." << std::setfill( '0' ) << std::setw( 9 ) << rhs.m_time_stamp_ns_offset;
259 }
260 separator = ",";
261 }
262
263 if ( rhs.isLumiEvent() || rhs.isRunLumi() ) {
264 os << separator << "l:" << rhs.m_lumi_block;
265 separator = ",";
266 }
267
268 if ( rhs.m_bunch_crossing_id != 0 ) { os << separator << "b:" << rhs.m_bunch_crossing_id; }
269 os << "]";
270 return os;
271 }
bool isLumiEvent() const

◆ operator<< [2/2]

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

Extraction operators.

◆ operator<=

bool operator<= ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 134 of file EventIDBase.h.

134{ return !( lhs > rhs ); }

◆ operator== [1/2]

bool operator== ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 234 of file EventIDBase.h.

234 {
235 // We assume that equality via run/event/lumi numbers is sufficient
236 return ( lhs.m_run_number == rhs.m_run_number && lhs.m_event_number == rhs.m_event_number &&
237 lhs.m_lumi_block == rhs.m_lumi_block );
238 }

◆ operator== [2/2]

bool operator== ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Comparison operators.

◆ operator>

bool operator> ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 132 of file EventIDBase.h.

132{ return rhs < lhs; }

◆ operator>=

bool operator>= ( const EventIDBase & lhs,
const EventIDBase & rhs )
friend

Definition at line 135 of file EventIDBase.h.

135{ return !( lhs < rhs ); }

Member Data Documentation

◆ m_bunch_crossing_id

number_type EventIDBase::m_bunch_crossing_id { UNDEFNUM }
private

bunch crossing ID, 32 bit unsigned

Definition at line 176 of file EventIDBase.h.

176{ UNDEFNUM };

◆ m_event_number

event_number_t EventIDBase::m_event_number { UNDEFEVT }
private

event number

Definition at line 163 of file EventIDBase.h.

163{ UNDEFEVT };

◆ m_lumi_block

number_type EventIDBase::m_lumi_block { UNDEFNUM }
private

luminosity block number: the number which uniquely tags a luminosity block within a run

Definition at line 173 of file EventIDBase.h.

173{ UNDEFNUM };

◆ m_run_number

number_type EventIDBase::m_run_number { UNDEFNUM }
private

run number

Definition at line 160 of file EventIDBase.h.

160{ UNDEFNUM };

◆ m_time_stamp

number_type EventIDBase::m_time_stamp { UNDEFNUM }
private

posix time in seconds since 1970/01/01

Definition at line 166 of file EventIDBase.h.

166{ UNDEFNUM };

◆ m_time_stamp_ns_offset

number_type EventIDBase::m_time_stamp_ns_offset { UNDEFNUM }
private

time stamp ns - ns time offset for time_stamp, 32 bit unsigned

Definition at line 169 of file EventIDBase.h.

169{ UNDEFNUM };

◆ m_type

unsigned EventIDBase::m_type { Invalid }
private

Definition at line 152 of file EventIDBase.h.

152{ Invalid };

◆ UNDEFEVT

const EventIDBase::event_number_t EventIDBase::UNDEFEVT = std::numeric_limits<EventIDBase::event_number_t>::max()
static

Definition at line 59 of file EventIDBase.h.

◆ UNDEFNUM

const EventIDBase::number_type EventIDBase::UNDEFNUM = std::numeric_limits<EventIDBase::number_type>::max()
static

Definition at line 58 of file EventIDBase.h.


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