Belle II Software prerelease-11-00-00a
IntervalOfValidity.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <iosfwd>
12#include <Rtypes.h>
13
14namespace Belle2 {
19 class EventMetaData;
20
25 class IntervalOfValidity final {
26 public:
29
37 IntervalOfValidity(int experimentLow, int runLow, int experimentHigh, int runHigh);
38
43
50 bool contains(const int experiment, const int run) const;
51
57 bool contains(const EventMetaData& event) const;
58
63 bool empty() const {return ((m_experimentLow < 0) && (m_experimentHigh < 0));};
64
70 static IntervalOfValidity always() {return IntervalOfValidity(0, 0, -1, -1);};
71
75 bool operator==(const IntervalOfValidity& other) const
76 {
77 return (m_experimentLow == other.m_experimentLow) && (m_runLow == other.m_runLow) &&
79 }
80
84 bool operator!=(const IntervalOfValidity& other) const
85 {
86 return !(*this == other);
87 }
88
94 bool contains(const IntervalOfValidity& iov) const {return overlap(iov) == iov;};
95
101 bool overlaps(const IntervalOfValidity& iov) const {return !overlap(iov).empty();};
102
109
116 bool trimOverlap(IntervalOfValidity& iov, bool trimOlder = true);
117
126 {
127 return m_experimentLow;
128 }
129
133 int getRunLow() const
134 {
135 return m_runLow;
136 }
137
146 {
147 return m_experimentHigh;
148 }
149
153 int getRunHigh() const
154 {
155 return m_runHigh;
156 }
157
163 friend std::istream& operator>> (std::istream& input, IntervalOfValidity& iov);
164
170 friend std::ostream& operator<< (std::ostream& output, const IntervalOfValidity& iov);
171
172 private:
173
177
181
185
189
198 int checkLowerBound(int experiment, int run) const;
199
208 int checkUpperBound(int experiment, int run) const;
209
213 void makeValid();
214
216 };
217
218}
Store event, run, and experiment numbers.
A class that describes the interval of experiments/runs for which an object in the database is valid.
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
int getRunHigh() const
Getter for highest run number.
int getRunLow() const
Getter for lowest run number.
ClassDefNV(IntervalOfValidity, 2)
describes the interval of experiments/runs for which an object in the database is valid.
~IntervalOfValidity()=default
Destructor.
bool trimOverlap(IntervalOfValidity &iov, bool trimOlder=true)
Remove the overlap between two intervals of validity by shortening one of them.
friend std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Output stream operator for writing IoV data to a text file.
int checkUpperBound(int experiment, int run) const
Helper function to check whether a given experiment/run number is above or below the upper bound of t...
bool empty() const
Function that checks whether the validity interval is empty.
bool operator!=(const IntervalOfValidity &other) const
Check whether two intervals of validity are different.
void makeValid()
Helper function to set the interval to empty if the upper bound is below the lower one.
bool contains(const IntervalOfValidity &iov) const
Function that checks the validity interval contains another interval of validity.
int m_runLow
Lowest run number.
friend std::istream & operator>>(std::istream &input, IntervalOfValidity &iov)
Input stream operator for reading IoV data from a text file.
int getExperimentLow() const
Getter for lowest experiment number.
int checkLowerBound(int experiment, int run) const
Helper function to check whether a given experiment/run number is above or below the lower bound of t...
bool overlaps(const IntervalOfValidity &iov) const
Function that checks the validity interval overlaps with another interval of validity.
int m_experimentLow
Lowest experiment number.
IntervalOfValidity overlap(const IntervalOfValidity &iov) const
Function that determines the overlap of the validity interval with another interval of validity.
int getExperimentHigh() const
Getter for highest experiment number.
int m_experimentHigh
Highest experiment number.
bool contains(const int experiment, const int run) const
Function that checks whether the (experiment, run) is inside the validity interval.
IntervalOfValidity()
Default constructor which will create an empty iov.
int m_runHigh
Highest run number.
bool operator==(const IntervalOfValidity &other) const
Check whether two intervals of validity are identical.
Abstract base class for different kinds of events.