The Gaudi Framework  master (37c0b60a)
EventIDRange.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_EVENTIDRANGE_H
12 #define GAUDIKERNEL_EVENTIDRANGE_H 1
13 
24 #include <iostream>
25 #include <sstream>
26 #include <string>
27 
33 class EventIDRange {
34 public:
35  EventIDRange();
36  EventIDRange( const EventIDBase& start, const EventIDBase& stop );
37  EventIDRange( const EventIDRange& r ) : m_start( r.m_start ), m_stop( r.m_stop ) {}
38  EventIDRange& operator=( const EventIDRange& r );
39 
40  const EventIDBase& start() const { return m_start; }
41  const EventIDBase& stop() const { return m_stop; }
42 
43  bool isInRange( const EventIDBase& t ) const { // return ( t >= m_start && t < m_stop ); }
44  return ( std::tie( t.m_run_number, t.m_lumi_block, t.m_event_number ) >= // run/lumi larger than run/lumi of start
46 
47  std::tie( t.m_run_number, t.m_lumi_block, t.m_event_number ) < // run/lumi smaller than run/lumi of stop
49 
50  std::tie( t.m_time_stamp, t.m_time_stamp_ns_offset ) >= // time-stamp larger than time-stamp of start
52 
53  std::tie( t.m_time_stamp, t.m_time_stamp_ns_offset ) < // time-stap smaller than time-tamp of stop
55  }
56 
57  static EventIDRange intersect( const EventIDRange& it ) { return it; }
58  template <typename... T>
59  static EventIDRange intersect( const EventIDRange& first, const T&... rest ) {
60  EventIDRange r = intersect( rest... );
61 
62  EventIDBase i1 = max( first.start(), r.start() );
63  EventIDBase i2 = min( first.stop(), r.stop() );
64 
65  return EventIDRange( i1, i2 );
66  }
67 
68  friend bool operator==( const EventIDRange& lhs, const EventIDRange& rhs );
69  friend bool operator!=( const EventIDRange& lhs, const EventIDRange& rhs );
70 
71  friend std::ostream& operator<<( std::ostream& os, const EventIDRange& rhs );
72 
73  operator std::string() const;
74 
75 private:
78 };
79 
80 inline bool operator==( const EventIDRange& lhs, const EventIDRange& rhs ) {
81  return lhs.m_start == rhs.m_start && lhs.m_stop == rhs.m_stop;
82 }
83 
84 inline bool operator!=( const EventIDRange& lhs, const EventIDRange& rhs ) { return !( lhs == rhs ); }
85 
86 inline EventIDRange::operator std::string() const {
88  os << "{" << m_start << " - " << m_stop << "}";
89  return os.str();
90 }
91 
92 #endif
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
std::string
STL class.
EventIDRange
Event ID Range object. Holds two EventIDBases (start and stop)
Definition: EventIDRange.h:33
EventIDBase::m_run_number
number_type m_run_number
run number
Definition: EventIDBase.h:193
EventIDRange::m_start
EventIDBase m_start
Definition: EventIDRange.h:76
EventIDRange::isInRange
bool isInRange(const EventIDBase &t) const
Definition: EventIDRange.h:43
EventIDRange::operator!=
friend bool operator!=(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:84
EventIDRange::stop
const EventIDBase & stop() const
Definition: EventIDRange.h:41
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
EventIDRange::intersect
static EventIDRange intersect(const EventIDRange &it)
Definition: EventIDRange.h:57
std::tie
T tie(T... args)
bug_34121.t
t
Definition: bug_34121.py:31
EventIDBase::m_event_number
event_number_t m_event_number
event number
Definition: EventIDBase.h:196
std::ostream
STL class.
operator!=
bool operator!=(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:84
EventIDRange::operator<<
friend std::ostream & operator<<(std::ostream &os, const EventIDRange &rhs)
Definition: EventIDRange.cpp:39
EventIDRange::intersect
static EventIDRange intersect(const EventIDRange &first, const T &... rest)
Definition: EventIDRange.h:59
operator==
bool operator==(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:80
EventIDBase.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
EventIDRange::m_stop
EventIDBase m_stop
Definition: EventIDRange.h:77
std::ostringstream
STL class.
EventIDRange::operator=
EventIDRange & operator=(const EventIDRange &r)
Definition: EventIDRange.cpp:31
EventIDRange::start
const EventIDBase & start() const
Definition: EventIDRange.h:40
std::ostringstream::str
T str(T... args)
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:66
EventIDRange::operator==
friend bool operator==(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:80
EventIDBase::m_time_stamp
number_type m_time_stamp
posix time in seconds since 1970/01/01
Definition: EventIDBase.h:199
EventIDRange::EventIDRange
EventIDRange()
Definition: EventIDRange.cpp:23
EventIDRange::EventIDRange
EventIDRange(const EventIDRange &r)
Definition: EventIDRange.h:37