LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
EventRange.cc
Go to the documentation of this file.
3 
4 using art::EventRange;
5 
6 namespace {
7  void
8  require_ordering(art::EventNumber_t const b, art::EventNumber_t const e)
9  {
10  if (b > e)
12  << "The 'begin' value for an EventRange must be less "
13  << "than the 'end' value.\n"
14  << " begin: " << b << " end: " << e << '\n';
15  }
16 }
17 
19 EventRange::invalid()
20 {
21  return EventRange{};
22 }
23 
26 {
28 }
29 
31  EventNumber_t const b,
32  EventNumber_t const e)
33  : subRun_{s}, begin_{b}, end_{e}
34 {
35  require_ordering(begin_, end_);
36 }
37 
38 bool
40 {
42  if (!are_valid(*this, other))
43  return false;
44 
45  bool const mergeable = is_adjacent(other);
46  if (mergeable)
47  end_ = other.end_;
48  return mergeable;
49 }
50 
51 bool
53 {
54  if (subRun_ == other.subRun_) {
55  if (begin_ == other.begin_) {
56  return end_ < other.end_;
57  } else {
58  return begin_ < other.begin_;
59  }
60  } else {
61  return subRun_ < other.subRun_;
62  }
63 }
64 
65 bool
67 {
68  return subRun_ == other.subRun_ && begin_ == other.begin_ &&
69  end_ == other.end_;
70 }
71 
72 bool
74 {
75  return !operator==(other);
76 }
77 
78 void
80 {
82  require_ordering(begin_, e);
83  end_ = e;
84 }
85 
86 bool
88 {
89  return subRun_ == s && e >= begin_ && e < end_;
90 }
91 
92 bool
94 {
95  return l.is_valid() && r.is_valid();
96 }
97 
98 bool
100 {
101  return art::is_valid(subRun_);
102 }
103 
104 bool
106 {
107  return art::is_valid(subRun_) && begin_ == 0 &&
109 }
110 
111 bool
113 {
114  if (!are_valid(*this, other))
115  return false;
116  return subRun_ == other.subRun_ && end_ == other.begin_;
117 }
118 
119 bool
121 {
122  if (!are_valid(*this, other))
123  return false;
124  return (subRun_ == other.subRun_) ? end_ <= other.begin_ : true;
125 }
126 
127 bool
129 {
130  if (!are_valid(*this, other))
131  return false;
132  return operator==(other);
133 }
134 
135 bool
137 {
138  if (!are_valid(*this, other))
139  return false;
140  return subRun_ == other.subRun_ && begin_ >= other.begin_ &&
141  end_ <= other.end_;
142 }
143 
144 bool
146 {
147  if (!are_valid(*this, other))
148  return false;
149  return subRun_ == other.subRun_ && begin_ <= other.begin_ &&
150  end_ >= other.end_;
151 }
152 
153 bool
155 {
156  if (!are_valid(*this, other))
157  return false;
158  return !is_disjoint(other) && !is_subset(other) && !is_superset(other);
159 }
160 
161 std::ostream&
162 art::operator<<(std::ostream& os, EventRange const& r)
163 {
164  os << "SubRun: " << r.subRun();
165  if (r.is_full_subRun())
166  os << " (full sub-run)";
167  else
168  os << " Event range: [" << r.begin() << ',' << r.end() << ')';
169  return os;
170 }
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
constexpr bool is_valid(IDNumber_t< L > const id)
Definition: IDNumber.h: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
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
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
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