The Gaudi Framework  master (ff829712)
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
 
static auto SortByTimeStamp ()
 
static auto SortByRunEvent ()
 
static auto SortByLumiEvent ()
 
static auto SortByRunLumi ()
 
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 65 of file EventIDBase.h.

Member Typedef Documentation

◆ event_number_t

typedef uint64_t EventIDBase::event_number_t

Definition at line 68 of file EventIDBase.h.

◆ number_type

typedef unsigned int EventIDBase::number_type

Definition at line 67 of file EventIDBase.h.

Member Enumeration Documentation

◆ Type

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

Definition at line 182 of file EventIDBase.h.

182{ 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 78 of file EventIDBase.h.

78{}

◆ 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
static const event_number_t UNDEFEVT
Definition EventIDBase.h:71
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:91
number_type time_stamp_ns_offset() const
time stamp ns - ns time offset for time_stamp, 32 bit unsigned
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
static const number_type UNDEFNUM
Definition EventIDBase.h:70
event_number_t event_number() const
event number - 64 bit unsigned
Definition EventIDBase.h:94
number_type time_stamp() const
time stamp - posix time in seconds from 1970, 32 bit unsigned
Definition EventIDBase.h:97

◆ 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 106 of file EventIDBase.h.

106{ return m_bunch_crossing_id; }

◆ event_number()

event_number_t EventIDBase::event_number ( ) const
inline

event number - 64 bit unsigned

Definition at line 94 of file EventIDBase.h.

94{ return m_event_number; }

◆ isLumiEvent()

bool EventIDBase::isLumiEvent ( ) const
inline

Definition at line 154 of file EventIDBase.h.

154{ return m_type & LumiEvent; }
unsigned m_type

◆ isRunEvent()

bool EventIDBase::isRunEvent ( ) const
inline

Definition at line 152 of file EventIDBase.h.

152{ return m_type & RunEvent; }

◆ isRunLumi()

bool EventIDBase::isRunLumi ( ) const
inline

Definition at line 155 of file EventIDBase.h.

155{ return m_type & RunLumi; }

◆ isTimeStamp()

bool EventIDBase::isTimeStamp ( ) const
inline

Definition at line 153 of file EventIDBase.h.

153{ return m_type & TimeStamp; }

◆ isValid()

bool EventIDBase::isValid ( ) const
inline

Definition at line 156 of file EventIDBase.h.

156{ return m_type != Invalid; }

◆ lumi_block()

number_type EventIDBase::lumi_block ( ) const
inline

luminosity block identifier, 32 bit unsigned

Definition at line 103 of file EventIDBase.h.

103{ return m_lumi_block; }

◆ run_number()

number_type EventIDBase::run_number ( ) const
inline

run number - 32 bit unsigned

Definition at line 91 of file EventIDBase.h.

91{ 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 139 of file EventIDBase.h.

139{ m_bunch_crossing_id = bcid; }

◆ set_event_number()

void EventIDBase::set_event_number ( event_number_t eventNumber)
inline

set event number

Definition at line 116 of file EventIDBase.h.

116 {
117 m_event_number = eventNumber;
118 if ( m_run_number != UNDEFNUM ) setRE();
119 if ( m_lumi_block != UNDEFNUM ) setLE();
120 }

◆ set_lumi_block()

void EventIDBase::set_lumi_block ( number_type lumiBlock)
inline

set luminosity block identifier

Definition at line 132 of file EventIDBase.h.

132 {
133 m_lumi_block = lumiBlock;
134 if ( m_run_number != UNDEFNUM ) setRL();
135 if ( m_event_number != UNDEFEVT ) setLE();
136 }

◆ set_run_number()

void EventIDBase::set_run_number ( number_type runNumber)
inline

set run number

Definition at line 109 of file EventIDBase.h.

109 {
110 m_run_number = runNumber;
111 if ( m_event_number != UNDEFEVT ) setRE();
112 if ( m_lumi_block != UNDEFNUM ) setRL();
113 }

◆ set_time_stamp()

void EventIDBase::set_time_stamp ( number_type timeStamp)
inline

set time stamp

Definition at line 123 of file EventIDBase.h.

123 {
124 m_time_stamp = timeStamp;
125 setTS();
126 }

◆ set_time_stamp_ns_offset()

void EventIDBase::set_time_stamp_ns_offset ( number_type timeStampNs)
inline

set time stamp in ns

Definition at line 129 of file EventIDBase.h.

129{ m_time_stamp_ns_offset = timeStampNs; }

◆ setLE()

void EventIDBase::setLE ( )
inlineprivate

Definition at line 188 of file EventIDBase.h.

188{ m_type |= LumiEvent; }

◆ setRE()

void EventIDBase::setRE ( )
inlineprivate

Definition at line 186 of file EventIDBase.h.

186{ m_type |= RunEvent; }

◆ setRL()

void EventIDBase::setRL ( )
inlineprivate

Definition at line 189 of file EventIDBase.h.

189{ m_type |= RunLumi; }

◆ setTS()

void EventIDBase::setTS ( )
inlineprivate

Definition at line 187 of file EventIDBase.h.

187{ m_type |= TimeStamp; }

◆ SortByLumiEvent()

static auto EventIDBase::SortByLumiEvent ( )
inlinestatic

Definition at line 171 of file EventIDBase.h.

171 {
172 return ::details::add_deref(
173 ::details::make_cmp( []( const EventIDBase& e ) { return std::tie( e.m_lumi_block, e.m_event_number ); } ) );
174 }
auto make_cmp(Proj p, Cmp cmp={})
Definition EventIDBase.h:50

◆ SortByRunEvent()

static auto EventIDBase::SortByRunEvent ( )
inlinestatic

Definition at line 166 of file EventIDBase.h.

166 {
167 return ::details::add_deref(
168 ::details::make_cmp( []( const EventIDBase& e ) { return std::tie( e.m_run_number, e.m_event_number ); } ) );
169 }

◆ SortByRunLumi()

static auto EventIDBase::SortByRunLumi ( )
inlinestatic

Definition at line 176 of file EventIDBase.h.

176 {
177 return ::details::add_deref(
178 ::details::make_cmp( []( const EventIDBase& e ) { return std::tie( e.m_run_number, e.m_lumi_block ); } ) );
179 }

◆ SortByTimeStamp()

static auto EventIDBase::SortByTimeStamp ( )
inlinestatic

Definition at line 161 of file EventIDBase.h.

161 {
162 return ::details::add_deref( ::details::make_cmp(
163 []( const EventIDBase& e ) { return std::tie( e.m_time_stamp, e.m_time_stamp_ns_offset ); } ) );
164 }

◆ time_stamp()

number_type EventIDBase::time_stamp ( ) const
inline

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

Definition at line 97 of file EventIDBase.h.

97{ 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 100 of file EventIDBase.h.

100{ return m_time_stamp_ns_offset; }

Friends And Related Symbol Documentation

◆ EventIDRange

friend class EventIDRange
friend

Definition at line 73 of file EventIDBase.h.

◆ max [1/2]

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

◆ max [2/2]

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

Definition at line 223 of file EventIDBase.h.

223 {
224
225 //"max" is much trickier because we need to handle invalid number explicilty by
226 // checking if a EventIDBase is TS or Run/Lumi
227
228 std::tuple<EventIDBase::number_type, EventIDBase::number_type, EventIDBase::event_number_t> run_lumi_ev;
229 std::tuple<EventIDBase::number_type, EventIDBase::number_type> time_stamp;
230
231 if ( lhs.isTimeStamp() && rhs.isTimeStamp() ) { // both time-stamp, compare them
232 time_stamp = std::max( std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset ),
233 std::tie( rhs.m_time_stamp, rhs.m_time_stamp_ns_offset ) );
234 } else if ( lhs.isTimeStamp() ) { // only lhs time-stamp: Use it
235 time_stamp = std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset );
236 } else { // otherwise use rhs time-stamp which might be UNDEFNUM (in case both input values are Run-Lumi only)
237 time_stamp = std::tie( rhs.m_time_stamp, rhs.m_time_stamp_ns_offset );
238 }
239
240 if ( lhs.isRunLumi() && rhs.isRunLumi() ) { // both run-lumi, compare them
241 run_lumi_ev = std::max( std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number ),
242 std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number ) );
243
244 } else if ( lhs.isRunLumi() ) { // only lhs run-lumi: Use it
245 run_lumi_ev = std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number );
246 } else { // otherwise use rhs run-lumi which might be UNDEFNUM (in case both input values are TS-only)
247 run_lumi_ev = std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number );
248 }
249
250 return EventIDBase( run_lumi_ev, time_stamp, lhs.bunch_crossing_id() );
251 }
bool isTimeStamp() const
bool isRunLumi() const

◆ min [1/2]

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

◆ min [2/2]

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

Definition at line 210 of file EventIDBase.h.

210 {
211
212 //"min" is easy b/c the numbers denoting invalidty for TS or Run/Event/LB are the
213 // largest possible numbers, so naturally larger than any valid number
214
215 return EventIDBase( std::min( std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number ),
216 std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number ) ),
217 std::min( std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset ),
218 std::tie( rhs.m_time_stamp, rhs.m_time_stamp_ns_offset ) ),
219 lhs.bunch_crossing_id() // bcid doesn't really matter here
220 );
221 }

◆ operator!=

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

Definition at line 145 of file EventIDBase.h.

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

◆ operator< [1/2]

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

◆ operator< [2/2]

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

Definition at line 253 of file EventIDBase.h.

253 {
254 // first try ordering by timestamp if both are non-zero
255 // then try ordering by run/lumi/event
256 // this assumes that both EventIDBase have the same set of values defined.
257
258 if ( lhs.isTimeStamp() && rhs.isTimeStamp() ) {
259 return lhs.m_time_stamp < rhs.m_time_stamp;
260 } else {
261 return std::tie( lhs.m_run_number, lhs.m_lumi_block, lhs.m_event_number ) <
262 std::tie( rhs.m_run_number, rhs.m_lumi_block, rhs.m_event_number );
263 }
264 }

◆ operator<< [1/2]

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

Extraction operators.

◆ operator<< [2/2]

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

Definition at line 272 of file EventIDBase.h.

272 {
273 if ( rhs.m_type == EventIDBase::Invalid ) return os << "[INVALID]";
274
275 const char* separator = "";
276 os << "[";
277 if ( rhs.m_run_number != EventIDBase::UNDEFNUM ) {
278 os << rhs.m_run_number;
279 separator = ",";
280 }
281
283 os << separator << rhs.m_event_number;
284 separator = ",";
285 }
286
287 if ( rhs.isTimeStamp() ) {
288 os << separator << "t:" << rhs.m_time_stamp;
289 if ( rhs.m_time_stamp_ns_offset != 0 ) {
290 os << "." << std::setfill( '0' ) << std::setw( 9 ) << rhs.m_time_stamp_ns_offset;
291 }
292 separator = ",";
293 }
294
295 if ( rhs.isLumiEvent() || rhs.isRunLumi() ) {
296 os << separator << "l:" << rhs.m_lumi_block;
297 separator = ",";
298 }
299
300 if ( rhs.m_bunch_crossing_id != 0 ) { os << separator << "b:" << rhs.m_bunch_crossing_id; }
301 os << "]";
302 return os;
303 }
bool isLumiEvent() const

◆ operator<=

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

Definition at line 146 of file EventIDBase.h.

146{ return !( lhs > rhs ); }

◆ operator== [1/2]

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

Comparison operators.

◆ operator== [2/2]

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

Definition at line 266 of file EventIDBase.h.

266 {
267 // We assume that equality via run/event/lumi numbers is sufficient
268 return ( lhs.m_run_number == rhs.m_run_number && lhs.m_event_number == rhs.m_event_number &&
269 lhs.m_lumi_block == rhs.m_lumi_block );
270 }

◆ operator>

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

Definition at line 144 of file EventIDBase.h.

144{ return rhs < lhs; }

◆ operator>=

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

Definition at line 147 of file EventIDBase.h.

147{ 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 208 of file EventIDBase.h.

208{ UNDEFNUM };

◆ m_event_number

event_number_t EventIDBase::m_event_number { UNDEFEVT }
private

event number

Definition at line 195 of file EventIDBase.h.

195{ 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 205 of file EventIDBase.h.

205{ UNDEFNUM };

◆ m_run_number

number_type EventIDBase::m_run_number { UNDEFNUM }
private

run number

Definition at line 192 of file EventIDBase.h.

192{ UNDEFNUM };

◆ m_time_stamp

number_type EventIDBase::m_time_stamp { UNDEFNUM }
private

posix time in seconds since 1970/01/01

Definition at line 198 of file EventIDBase.h.

198{ 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 201 of file EventIDBase.h.

201{ UNDEFNUM };

◆ m_type

unsigned EventIDBase::m_type { Invalid }
private

Definition at line 184 of file EventIDBase.h.

184{ Invalid };

◆ UNDEFEVT

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

Definition at line 71 of file EventIDBase.h.

◆ UNDEFNUM

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

Definition at line 70 of file EventIDBase.h.


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