LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
EventRange.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_EventRange_h
2 #define canvas_Persistency_Provenance_EventRange_h
3 
4 // An EventRange has a SubRun number, and two event numbers
5 // corresponding to the half-open range:
6 //
7 // [beginEvent, endEvent)
8 
11 
12 #include <ostream>
13 
14 namespace art {
15 
16  class EventRange {
17  public:
18  explicit EventRange() = default;
19 
20  static EventRange invalid();
22 
23  explicit EventRange(SubRunNumber_t s,
26 
27  bool operator<(EventRange const& other) const;
28  bool operator==(EventRange const& other) const;
29  bool operator!=(EventRange const& other) const;
30 
31  auto
32  subRun() const
33  {
34  return subRun_;
35  }
36  bool
37  empty() const
38  {
39  return begin_ == end_;
40  }
41  auto
42  begin() const
43  {
44  return begin_;
45  }
46  auto
47  end() const
48  {
49  return end_;
50  }
51  auto
52  size() const
53  {
54  return is_valid() ? end_ - begin_ : -1ull;
55  }
56 
57  static bool are_valid(EventRange const& l, EventRange const& r);
58 
59  bool is_valid() const;
60  bool is_full_subRun() const;
61  bool contains(SubRunNumber_t s, EventNumber_t e) const;
62 
63  // is_same(other) == true:
64  // implies is_subset(other) == true
65  // implies is_superset(other) == true
66  bool is_same(EventRange const& other) const;
67  bool is_adjacent(EventRange const& other) const;
68  bool is_disjoint(EventRange const& other) const;
69  bool is_subset(EventRange const& other) const;
70  bool is_superset(EventRange const& other) const;
71  bool is_overlapping(EventRange const& other) const;
72 
73  bool merge(EventRange const& other);
74  void set_end(EventNumber_t const e);
75 
76  private:
77  void
79  {
80  if (is_full_subRun())
82  << "\nAn EventRange created using EventRange::forSubRun cannot be "
83  "modified.\n";
84  }
85 
89  };
90 
91  std::ostream& operator<<(std::ostream& os, EventRange const& r);
92 }
93 
94 #endif /* canvas_Persistency_Provenance_EventRange_h */
95 
96 // Local variables:
97 // mode: c++
98 // End:
std::ostream & operator<<(std::ostream &os, EDAnalyzer::Table< T > const &t)
Definition: EDAnalyzer.h:184
bool operator==(EventRange const &other) const
Definition: EventRange.cc:66
Float_t s
Definition: plot.C:23
bool is_full_subRun() const
Definition: EventRange.cc:105
bool is_adjacent(EventRange const &other) const
Definition: EventRange.cc:112
SubRunNumber_t subRun_
Definition: EventRange.h:86
bool is_superset(EventRange const &other) const
Definition: EventRange.cc:145
auto end() const
Definition: EventRange.h:47
bool empty() const
Definition: EventRange.h:37
auto size() const
Definition: EventRange.h:52
static bool are_valid(EventRange const &l, EventRange const &r)
Definition: EventRange.cc:93
static EventRange forSubRun(SubRunNumber_t s)
Definition: EventRange.cc:25
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:118
bool operator!=(EventRange const &other) const
Definition: EventRange.cc:73
EventNumber_t end_
Definition: EventRange.h:88
bool operator<(EventRange const &other) const
Definition: EventRange.cc:52
static EventRange invalid()
Definition: EventRange.cc:19
bool is_subset(EventRange const &other) const
Definition: EventRange.cc:136
EventNumber_t begin_
Definition: EventRange.h:87
bool is_same(EventRange const &other) const
Definition: EventRange.cc:128
bool is_overlapping(EventRange const &other) const
Definition: EventRange.cc:154
bool merge(EventRange const &other)
Definition: EventRange.cc:39
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void require_not_full_SubRun()
Definition: EventRange.h:78
void set_end(EventNumber_t const e)
Definition: EventRange.cc:79
auto subRun() const
Definition: EventRange.h:32
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:117
HLT enums.
EventRange()=default
Float_t e
Definition: plot.C:34
bool contains(SubRunNumber_t s, EventNumber_t e) const
Definition: EventRange.cc:87
bool is_valid() const
Definition: EventRange.cc:99
bool is_disjoint(EventRange const &other) const
Definition: EventRange.cc:120
auto begin() const
Definition: EventRange.h:42