The Gaudi Framework  v38r1p1 (ae26267b)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EventIDBase.h File Reference

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

#include <cstdint>
#include <iomanip>
#include <iostream>
#include <tuple>
#include "GaudiKernel/compose.h"
Include dependency graph for EventIDBase.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  details::arg_helper< lambda >
 
struct  details::arg_helper< Ret(T::*)(Arg) const >
 
class  EventIDBase
 This class provides a unique identification for each event, in terms of run/event number and/or a time stamp. More...
 

Namespaces

 details
 

Typedefs

template<typename lambda >
using details::argument_t = typename arg_helper< lambda >::type
 

Functions

template<typename Fun >
auto details::add_deref (Fun f)
 
template<typename Proj , typename Cmp = std::greater<>>
auto details::make_cmp (Proj p, Cmp cmp={})
 
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::ostreamoperator<< (std::ostream &os, const EventIDBase &rhs)
 

Detailed Description

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

Author
RD Schaffer R.D.S.nosp@m.chaf.nosp@m.fer@c.nosp@m.ern..nosp@m.ch
Paolo Calafiura pcala.nosp@m.fiur.nosp@m.a@lbl.nosp@m..gov
Charles Leggett

Definition in file EventIDBase.h.

Function Documentation

◆ max()

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

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
234  time_stamp = std::max( std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset ),
236  } else if ( lhs.isTimeStamp() ) { // only lhs time-stamp: Use it
237  time_stamp = std::tie( lhs.m_time_stamp, lhs.m_time_stamp_ns_offset );
238  } else { // otherwise use rhs time-stamp which might be UNDEFNUM (in case both input values are Run-Lumi only)
239  time_stamp = std::tie( rhs.m_time_stamp, rhs.m_time_stamp_ns_offset );
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 
)
inline

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 
)
inline

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 
)
inline

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 
)
inline

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 }
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::m_bunch_crossing_id
number_type m_bunch_crossing_id
bunch crossing ID, 32 bit unsigned
Definition: EventIDBase.h:209
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)
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::isLumiEvent
bool isLumiEvent() const
Definition: EventIDBase.h:155
std::min
T min(T... args)
EventIDBase::Invalid
@ Invalid
Definition: EventIDBase.h:183
EventIDBase::isTimeStamp
bool isTimeStamp() const
Definition: EventIDBase.h:154
EventIDBase::isRunLumi
bool isRunLumi() const
Definition: EventIDBase.h:156
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:66
std::setw
T setw(T... args)
std::max
T max(T... args)
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