Belle II Software light-2406-ragdoll
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
49 bool contains(const EventMetaData& event) const;
50
55 bool empty() const {return ((m_experimentLow < 0) && (m_experimentHigh < 0));};
56
62 static IntervalOfValidity always() {return IntervalOfValidity(0, 0, -1, -1);};
63
67 bool operator==(const IntervalOfValidity& other) const
68 {
69 return (m_experimentLow == other.m_experimentLow) && (m_runLow == other.m_runLow) &&
71 }
72
76 bool operator!=(const IntervalOfValidity& other) const
77 {
78 return !(*this == other);
79 }
80
86 bool contains(const IntervalOfValidity& iov) const {return overlap(iov) == iov;};
87
93 bool overlaps(const IntervalOfValidity& iov) const {return !overlap(iov).empty();};
94
101
108 bool trimOverlap(IntervalOfValidity& iov, bool trimOlder = true);
109
118 {
119 return m_experimentLow;
120 }
121
125 int getRunLow() const
126 {
127 return m_runLow;
128 }
129
138 {
139 return m_experimentHigh;
140 }
141
145 int getRunHigh() const
146 {
147 return m_runHigh;
148 }
149
155 friend std::istream& operator>> (std::istream& input, IntervalOfValidity& iov);
156
162 friend std::ostream& operator<< (std::ostream& output, const IntervalOfValidity& iov);
163
164 private:
165
169
173
177
181
190 int checkLowerBound(int experiment, int run) const;
191
200 int checkUpperBound(int experiment, int run) const;
201
205 void makeValid();
206
208 };
210}
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
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.
bool contains(const EventMetaData &event) const
Function that checks whether the event is inside the validity interval.
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.
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.
Definition: ClusterUtils.h:24