The Gaudi Framework  master (d98a2936)
EventIDRange.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
23 #include <iostream>
24 #include <sstream>
25 #include <string>
26 
32 class EventIDRange {
33 public:
34  EventIDRange();
35  EventIDRange( const EventIDBase& start, const EventIDBase& stop );
36  EventIDRange( const EventIDRange& r ) : m_start( r.m_start ), m_stop( r.m_stop ) {}
37  EventIDRange& operator=( const EventIDRange& r );
38 
39  const EventIDBase& start() const { return m_start; }
40  const EventIDBase& stop() const { return m_stop; }
41 
42  bool isInRange( const EventIDBase& t ) const { // return ( t >= m_start && t < m_stop ); }
43  return ( std::tie( t.m_run_number, t.m_lumi_block, t.m_event_number ) >= // run/lumi larger than run/lumi of start
45 
46  std::tie( t.m_run_number, t.m_lumi_block, t.m_event_number ) < // run/lumi smaller than run/lumi of stop
48 
49  std::tie( t.m_time_stamp, t.m_time_stamp_ns_offset ) >= // time-stamp larger than time-stamp of start
51 
52  std::tie( t.m_time_stamp, t.m_time_stamp_ns_offset ) < // time-stap smaller than time-tamp of stop
54  }
55 
56  static EventIDRange intersect( const EventIDRange& it ) { return it; }
57  template <typename... T>
58  static EventIDRange intersect( const EventIDRange& first, const T&... rest ) {
59  EventIDRange r = intersect( rest... );
60 
61  EventIDBase i1 = max( first.start(), r.start() );
62  EventIDBase i2 = min( first.stop(), r.stop() );
63 
64  return EventIDRange( i1, i2 );
65  }
66 
67  friend bool operator==( const EventIDRange& lhs, const EventIDRange& rhs );
68  friend bool operator!=( const EventIDRange& lhs, const EventIDRange& rhs );
69 
70  friend std::ostream& operator<<( std::ostream& os, const EventIDRange& rhs );
71 
72  operator std::string() const;
73 
74 private:
77 };
78 
79 inline bool operator==( const EventIDRange& lhs, const EventIDRange& rhs ) {
80  return lhs.m_start == rhs.m_start && lhs.m_stop == rhs.m_stop;
81 }
82 
83 inline bool operator!=( const EventIDRange& lhs, const EventIDRange& rhs ) { return !( lhs == rhs ); }
84 
85 inline EventIDRange::operator std::string() const {
86  std::ostringstream os;
87  os << "{" << m_start << " - " << m_stop << "}";
88  return os.str();
89 }
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:201
EventIDRange
Event ID Range object. Holds two EventIDBases (start and stop)
Definition: EventIDRange.h:32
EventIDBase::m_run_number
number_type m_run_number
run number
Definition: EventIDBase.h:192
EventIDRange::m_start
EventIDBase m_start
Definition: EventIDRange.h:75
EventIDRange::isInRange
bool isInRange(const EventIDBase &t) const
Definition: EventIDRange.h:42
EventIDRange::operator!=
friend bool operator!=(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:83
EventIDRange::stop
const EventIDBase & stop() const
Definition: EventIDRange.h:40
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:205
EventIDRange::intersect
static EventIDRange intersect(const EventIDRange &it)
Definition: EventIDRange.h:56
bug_34121.t
t
Definition: bug_34121.py:31
EventIDBase::m_event_number
event_number_t m_event_number
event number
Definition: EventIDBase.h:195
operator!=
bool operator!=(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:83
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:58
operator==
bool operator==(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:79
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:76
EventIDRange::operator=
EventIDRange & operator=(const EventIDRange &r)
Definition: EventIDRange.cpp:31
EventIDRange::start
const EventIDBase & start() const
Definition: EventIDRange.h:39
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:65
EventIDRange::operator==
friend bool operator==(const EventIDRange &lhs, const EventIDRange &rhs)
Definition: EventIDRange.h:79
EventIDBase::m_time_stamp
number_type m_time_stamp
posix time in seconds since 1970/01/01
Definition: EventIDBase.h:198
EventIDRange::EventIDRange
EventIDRange()
Definition: EventIDRange.cpp:23
EventIDRange::EventIDRange
EventIDRange(const EventIDRange &r)
Definition: EventIDRange.h:36