The Gaudi Framework  master (594c33fa)
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. More...
 
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::ostreamoperator<< (std::ostream &os, const EventIDBase &rhs)
 Extraction operators. More...
 
unsigned m_type { Invalid }
 
number_type m_run_number { UNDEFNUM }
 run number More...
 
event_number_t m_event_number { UNDEFEVT }
 event number More...
 
number_type m_time_stamp { UNDEFNUM }
 posix time in seconds since 1970/01/01 More...
 
number_type m_time_stamp_ns_offset { UNDEFNUM }
 time stamp ns - ns time offset for time_stamp, 32 bit unsigned More...
 
number_type m_lumi_block { UNDEFNUM }
 luminosity block number: the number which uniquely tags a luminosity block within a run More...
 
number_type m_bunch_crossing_id { UNDEFNUM }
 bunch crossing ID, 32 bit unsigned More...
 
 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 More...
 
event_number_t event_number () const
 event number - 64 bit unsigned More...
 
number_type time_stamp () const
 time stamp - posix time in seconds from 1970, 32 bit unsigned More...
 
number_type time_stamp_ns_offset () const
 time stamp ns - ns time offset for time_stamp, 32 bit unsigned More...
 
number_type lumi_block () const
 luminosity block identifier, 32 bit unsigned More...
 
number_type bunch_crossing_id () const
 bunch crossing ID, 32 bit unsigned More...
 
void set_run_number (number_type runNumber)
 set run number More...
 
void set_event_number (event_number_t eventNumber)
 set event number More...
 
void set_time_stamp (number_type timeStamp)
 set time stamp More...
 
void set_time_stamp_ns_offset (number_type timeStampNs)
 set time stamp in ns More...
 
void set_lumi_block (number_type lumiBlock)
 set luminosity block identifier More...
 
void set_bunch_crossing_id (number_type bcid)
 set bunch crossing ID More...
 
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 66 of file EventIDBase.h.

Member Typedef Documentation

◆ event_number_t

typedef uint64_t EventIDBase::event_number_t

Definition at line 69 of file EventIDBase.h.

◆ number_type

typedef unsigned int EventIDBase::number_type

Definition at line 68 of file EventIDBase.h.

Member Enumeration Documentation

◆ Type

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

Definition at line 183 of file EventIDBase.h.

183 { 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 79 of file EventIDBase.h.

79 {};

◆ 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.

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

107 { return m_bunch_crossing_id; }

◆ event_number()

event_number_t EventIDBase::event_number ( ) const
inline

event number - 64 bit unsigned

Definition at line 95 of file EventIDBase.h.

95 { return m_event_number; }

◆ isLumiEvent()

bool EventIDBase::isLumiEvent ( ) const
inline

Definition at line 155 of file EventIDBase.h.

155 { return m_type & LumiEvent; }

◆ isRunEvent()

bool EventIDBase::isRunEvent ( ) const
inline

Definition at line 153 of file EventIDBase.h.

153 { return m_type & RunEvent; }

◆ isRunLumi()

bool EventIDBase::isRunLumi ( ) const
inline

Definition at line 156 of file EventIDBase.h.

156 { return m_type & RunLumi; }

◆ isTimeStamp()

bool EventIDBase::isTimeStamp ( ) const
inline

Definition at line 154 of file EventIDBase.h.

154 { return m_type & TimeStamp; }

◆ isValid()

bool EventIDBase::isValid ( ) const
inline

Definition at line 157 of file EventIDBase.h.

157 { return m_type != Invalid; }

◆ lumi_block()

number_type EventIDBase::lumi_block ( ) const
inline

luminosity block identifier, 32 bit unsigned

Definition at line 104 of file EventIDBase.h.

104 { return m_lumi_block; }

◆ run_number()

number_type EventIDBase::run_number ( ) const
inline

run number - 32 bit unsigned

Definition at line 92 of file EventIDBase.h.

92 { 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 140 of file EventIDBase.h.

140 { m_bunch_crossing_id = bcid; }

◆ set_event_number()

void EventIDBase::set_event_number ( event_number_t  eventNumber)
inline

set event number

Definition at line 117 of file EventIDBase.h.

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

◆ set_lumi_block()

void EventIDBase::set_lumi_block ( number_type  lumiBlock)
inline

set luminosity block identifier

Definition at line 133 of file EventIDBase.h.

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

◆ set_run_number()

void EventIDBase::set_run_number ( number_type  runNumber)
inline

set run number

Definition at line 110 of file EventIDBase.h.

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

◆ set_time_stamp()

void EventIDBase::set_time_stamp ( number_type  timeStamp)
inline

set time stamp

Definition at line 124 of file EventIDBase.h.

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

◆ set_time_stamp_ns_offset()

void EventIDBase::set_time_stamp_ns_offset ( number_type  timeStampNs)
inline

set time stamp in ns

Definition at line 130 of file EventIDBase.h.

130 { m_time_stamp_ns_offset = timeStampNs; }

◆ setLE()

void EventIDBase::setLE ( )
inlineprivate

Definition at line 189 of file EventIDBase.h.

189 { m_type |= LumiEvent; }

◆ setRE()

void EventIDBase::setRE ( )
inlineprivate

Definition at line 187 of file EventIDBase.h.

187 { m_type |= RunEvent; }

◆ setRL()

void EventIDBase::setRL ( )
inlineprivate

Definition at line 190 of file EventIDBase.h.

190 { m_type |= RunLumi; }

◆ setTS()

void EventIDBase::setTS ( )
inlineprivate

Definition at line 188 of file EventIDBase.h.

188 { m_type |= TimeStamp; }

◆ SortByLumiEvent()

static auto EventIDBase::SortByLumiEvent ( )
inlinestatic

Definition at line 172 of file EventIDBase.h.

172  {
174  ::details::make_cmp( []( const EventIDBase& e ) { return std::tie( e.m_lumi_block, e.m_event_number ); } ) );
175  };

◆ SortByRunEvent()

static auto EventIDBase::SortByRunEvent ( )
inlinestatic

Definition at line 167 of file EventIDBase.h.

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

◆ SortByRunLumi()

static auto EventIDBase::SortByRunLumi ( )
inlinestatic

Definition at line 177 of file EventIDBase.h.

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

◆ SortByTimeStamp()

static auto EventIDBase::SortByTimeStamp ( )
inlinestatic

Definition at line 162 of file EventIDBase.h.

162  {
164  []( const EventIDBase& e ) { return std::tie( e.m_time_stamp, e.m_time_stamp_ns_offset ); } ) );
165  };

◆ time_stamp()

number_type EventIDBase::time_stamp ( ) const
inline

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

Definition at line 98 of file EventIDBase.h.

98 { 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 101 of file EventIDBase.h.

101 { return m_time_stamp_ns_offset; }

Friends And Related Function Documentation

◆ EventIDRange

friend class EventIDRange
friend

Definition at line 74 of file EventIDBase.h.

◆ max

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

Definition at line 225 of file EventIDBase.h.

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

◆ min

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

Definition at line 212 of file EventIDBase.h.

212  {
213 
214  //"min" is easy b/c the numbers denoting invalidty for TS or Run/Event/LB are the
215  // largest possible numbers, so naturally larger than any valid number
216 
221  lhs.bunch_crossing_id() // bcid doesn't really matter here
222  );
223 }

◆ operator!=

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

Definition at line 146 of file EventIDBase.h.

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

◆ operator<

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

Definition at line 255 of file EventIDBase.h.

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

◆ operator<<

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

Extraction operators.

Definition at line 274 of file EventIDBase.h.

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

◆ operator<=

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

Definition at line 147 of file EventIDBase.h.

147 { return !( lhs > rhs ); }

◆ operator==

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

Comparison operators.

Definition at line 268 of file EventIDBase.h.

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

◆ operator>

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

Definition at line 145 of file EventIDBase.h.

145 { return rhs < lhs; }

◆ operator>=

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

Definition at line 148 of file EventIDBase.h.

148 { 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 209 of file EventIDBase.h.

◆ m_event_number

event_number_t EventIDBase::m_event_number { UNDEFEVT }
private

event number

Definition at line 196 of file EventIDBase.h.

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

◆ m_run_number

number_type EventIDBase::m_run_number { UNDEFNUM }
private

run number

Definition at line 193 of file EventIDBase.h.

◆ m_time_stamp

number_type EventIDBase::m_time_stamp { UNDEFNUM }
private

posix time in seconds since 1970/01/01

Definition at line 199 of file EventIDBase.h.

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

◆ m_type

unsigned EventIDBase::m_type { Invalid }
private

Definition at line 185 of file EventIDBase.h.

◆ UNDEFEVT

Definition at line 72 of file EventIDBase.h.

◆ UNDEFNUM

Definition at line 71 of file EventIDBase.h.


The documentation for this class was generated from the following files:
EventIDBase::m_time_stamp_ns_offset
number_type m_time_stamp_ns_offset
time stamp ns - ns time offset for time_stamp, 32 bit unsigned
Definition: EventIDBase.h:202
EventIDBase::m_run_number
number_type m_run_number
run number
Definition: EventIDBase.h:193
EventIDBase::lumi_block
number_type lumi_block() const
luminosity block identifier, 32 bit unsigned
Definition: EventIDBase.h:104
EventIDBase::m_bunch_crossing_id
number_type m_bunch_crossing_id
bunch crossing ID, 32 bit unsigned
Definition: EventIDBase.h:209
EventIDBase::setLE
void setLE()
Definition: EventIDBase.h:189
EventIDBase::EventIDBase
EventIDBase()
Definition: EventIDBase.h:79
EventIDBase::RunLumi
@ RunLumi
Definition: EventIDBase.h:183
EventIDBase::bunch_crossing_id
number_type bunch_crossing_id() const
bunch crossing ID, 32 bit unsigned
Definition: EventIDBase.h:107
std::tuple
EventIDBase::UNDEFEVT
static const event_number_t UNDEFEVT
Definition: EventIDBase.h:72
std::setfill
T setfill(T... args)
details::add_deref
auto add_deref(Fun f)
Definition: EventIDBase.h:46
EventIDBase::UNDEFNUM
static const number_type UNDEFNUM
Definition: EventIDBase.h:71
EventIDBase::m_lumi_block
number_type m_lumi_block
luminosity block number: the number which uniquely tags a luminosity block within a run
Definition: EventIDBase.h:206
std::tie
T tie(T... args)
EventIDBase::m_event_number
event_number_t m_event_number
event number
Definition: EventIDBase.h:196
EventIDBase::RunEvent
@ RunEvent
Definition: EventIDBase.h:183
EventIDBase::LumiEvent
@ LumiEvent
Definition: EventIDBase.h:183
EventIDBase::isLumiEvent
bool isLumiEvent() const
Definition: EventIDBase.h:155
details::make_cmp
auto make_cmp(Proj p, Cmp cmp={})
Definition: EventIDBase.h:51
EventIDBase::TimeStamp
@ TimeStamp
Definition: EventIDBase.h:183
std::min
T min(T... args)
EventIDBase::setRL
void setRL()
Definition: EventIDBase.h:190
EventIDBase::Invalid
@ Invalid
Definition: EventIDBase.h:183
EventIDBase::isTimeStamp
bool isTimeStamp() const
Definition: EventIDBase.h:154
EventIDBase::time_stamp
number_type time_stamp() const
time stamp - posix time in seconds from 1970, 32 bit unsigned
Definition: EventIDBase.h:98
EventIDBase::run_number
number_type run_number() const
run number - 32 bit unsigned
Definition: EventIDBase.h:92
EventIDBase::isRunLumi
bool isRunLumi() const
Definition: EventIDBase.h:156
EventIDBase::setRE
void setRE()
Definition: EventIDBase.h:187
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:66
EventIDBase::time_stamp_ns_offset
number_type time_stamp_ns_offset() const
time stamp ns - ns time offset for time_stamp, 32 bit unsigned
Definition: EventIDBase.h:101
std::setw
T setw(T... args)
EventIDBase::setTS
void setTS()
Definition: EventIDBase.h:188
std::max
T max(T... args)
EventIDBase::event_number
event_number_t event_number() const
event number - 64 bit unsigned
Definition: EventIDBase.h:95
EventIDBase::m_type
unsigned m_type
Definition: EventIDBase.h:185
EventIDBase::m_time_stamp
number_type m_time_stamp
posix time in seconds since 1970/01/01
Definition: EventIDBase.h:199