EventIDBase.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_EVENTIDBASE_H
2 #define GAUDIKERNEL_EVENTIDBASE_H 1
3 
15 //<<<<<< INCLUDES >>>>>>
16 
17 #include <iostream>
18 #include <stdint.h>
19 
28 class EventIDBase {
29 public:
30 
31  typedef unsigned int number_type;
32 
34 
36  EventIDBase(number_type run_number,
38  number_type time_stamp=0,
39  number_type time_stamp_ns_offset=0,
40  number_type lumi_block=0,
41  number_type bunch_crossing_id=0);
42  // Use default copy constructor.
43  virtual ~EventIDBase();
45 
47  number_type run_number () const { return m_run_number; }
48 
50  uint64_t event_number () const { return m_event_number; }
51 
53  number_type time_stamp () const { return m_time_stamp; }
54 
56  number_type time_stamp_ns_offset () const { return m_time_stamp_ns_offset; }
57 
59  number_type lumi_block () const { return m_lumiBlock; }
60 
62  number_type bunch_crossing_id () const { return m_bunch_crossing_id; }
63 
65  void set_run_number (number_type runNumber) { m_run_number = runNumber; }
66 
68  void set_event_number (uint64_t eventNumber) { m_event_number = eventNumber; }
69 
71  void set_time_stamp (number_type timeStamp) { m_time_stamp = timeStamp; }
72 
74  void set_time_stamp_ns_offset (number_type timeStampNs) {
75  m_time_stamp_ns_offset = timeStampNs;
76  }
77 
79  void set_lumi_block (number_type lumiBlock) { m_lumiBlock = lumiBlock; }
80 
82  void set_bunch_crossing_id (number_type bcid) { m_bunch_crossing_id = bcid; }
83 
85  friend bool operator<(const EventIDBase& lhs, const EventIDBase& rhs);
86  friend bool operator>(const EventIDBase& lhs, const EventIDBase& rhs);
87  friend bool operator==(const EventIDBase& lhs, const EventIDBase& rhs);
88  friend bool operator!=(const EventIDBase& lhs, const EventIDBase& rhs);
89  friend bool operator<=(const EventIDBase& lhs, const EventIDBase& rhs);
90  friend bool operator>=(const EventIDBase& lhs, const EventIDBase& rhs);
91 
93  friend std::ostream& operator<<(std::ostream& os, const EventIDBase& rhs);
94 
95 private:
96 
98  number_type m_run_number {0};
99 
102 
104  number_type m_time_stamp {0};
105 
107  number_type m_time_stamp_ns_offset {0};
108 
111  number_type m_lumiBlock {0};
112 
114  number_type m_bunch_crossing_id {0};
115 
116 };
117 
118 
119 inline bool operator<(const EventIDBase& lhs, const EventIDBase& rhs) {
120  // We are assuming that ALL events will have run and event numbers,
121  // and never just a time stamp.
122  // FIXME: any use for also ordering by lumi-block ?
123  return lhs.m_run_number<rhs.m_run_number ||
124  ( lhs.m_run_number==rhs.m_run_number &&
125  lhs.m_event_number<rhs.m_event_number) ;
126 }
127 
128 inline bool operator==(const EventIDBase& lhs, const EventIDBase& rhs) {
129  // We assume that equality via run/event numbers is sufficient
130  return lhs.m_run_number == rhs.m_run_number &&
131  lhs.m_event_number == rhs.m_event_number;
132 }
133 inline bool operator>(const EventIDBase& lhs, const EventIDBase& rhs) {
134  return !( (lhs < rhs) || (lhs == rhs));
135 }
136 inline bool operator!=(const EventIDBase& lhs, const EventIDBase& rhs) {
137  return !(lhs == rhs);
138 }
139 inline bool operator<=(const EventIDBase& lhs, const EventIDBase& rhs) {
140  return !(lhs > rhs);
141 }
142 inline bool operator>=(const EventIDBase& lhs, const EventIDBase& rhs) {
143  return !(lhs < rhs);
144 }
145 
147  os << "["
148  << rhs.m_run_number
149  << "," << rhs.m_event_number;
150 
151  if ( rhs.m_time_stamp != 0 ) {
152  os << "," << rhs.m_time_stamp << ":" << rhs.m_time_stamp_ns_offset;
153  }
154 
155  if ( rhs.m_lumiBlock != 0) {
156  os << ",l:" << rhs.m_lumiBlock;
157  }
158 
159  if ( rhs.m_bunch_crossing_id != 0) {
160  os << ",b:" << rhs.m_bunch_crossing_id;
161  }
162  os << "]";
163  return os;
164 }
165 
166 
167 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>>
168 
169 #endif // EVENTINFO_EVENTID_H
170 
171 
172 
173 
174 
175 
void set_time_stamp(number_type timeStamp)
set time stamp
Definition: EventIDBase.h:71
std::ostream & operator<<(std::ostream &os, const EventIDBase &rhs)
Definition: EventIDBase.h:146
void set_time_stamp_ns_offset(number_type timeStampNs)
set time stamp in ns
Definition: EventIDBase.h:74
void set_lumi_block(number_type lumiBlock)
set luminosity block identifier
Definition: EventIDBase.h:79
uint64_t m_event_number
event number
Definition: EventIDBase.h:101
void set_run_number(number_type runNumber)
set run number
Definition: EventIDBase.h:65
number_type bunch_crossing_id() const
bunch crossing ID, 32 bit unsigned
Definition: EventIDBase.h:62
number_type m_lumiBlock
luminosity block number: the number which uniquely tags a luminosity block within a run ...
Definition: EventIDBase.h:111
friend bool operator==(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:128
friend std::ostream & operator<<(std::ostream &os, const EventIDBase &rhs)
Extraction operators.
Definition: EventIDBase.h:146
number_type m_time_stamp_ns_offset
time stamp ns - ns time offset for time_stamp, 32 bit unsigned
Definition: EventIDBase.h:107
friend bool operator<=(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:139
void set_bunch_crossing_id(number_type bcid)
set bunch crossing ID
Definition: EventIDBase.h:82
unsigned long long uint64_t
Definition: instrset.h:144
number_type m_bunch_crossing_id
bunch crossing ID, 32 bit unsigned
Definition: EventIDBase.h:114
number_type lumi_block() const
luminosity block identifier, 32 bit unsigned
Definition: EventIDBase.h:59
number_type time_stamp() const
time stamp - posix time in seconds from 1970, 32 bit unsigned
Definition: EventIDBase.h:53
bool operator>(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:133
number_type m_time_stamp
posix time in seconds since 1970/01/01
Definition: EventIDBase.h:104
uint64_t event_number() const
event number - 64 bit unsigned
Definition: EventIDBase.h:50
void set_event_number(uint64_t eventNumber)
set event number
Definition: EventIDBase.h:68
friend bool operator!=(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:136
number_type m_run_number
run number
Definition: EventIDBase.h:98
number_type run_number() const
run number - 32 bit unsigned
Definition: EventIDBase.h:47
bool operator==(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:128
friend bool operator>(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:133
number_type time_stamp_ns_offset() const
time stamp ns - ns time offset for time_stamp, 32 bit unsigned
Definition: EventIDBase.h:56
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:119
friend bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Comparison operators.
Definition: EventIDBase.h:119
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:28
bool operator!=(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:136
bool operator>=(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:142
unsigned int number_type
Definition: EventIDBase.h:31
friend bool operator>=(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:142
virtual ~EventIDBase()
Definition: EventIDBase.cpp:27
STL class.
bool operator<=(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:139