9#include <framework/database/IntervalOfValidity.h>
10#include <framework/dataobjects/EventMetaData.h>
11#include <framework/logging/Logger.h>
21 if ((experimentLow < 0) && (runLow >= 0)) {
22 B2ERROR(
"A run number of " << runLow <<
" is given for an undefined low experiment number. Setting run to undefined, too.");
25 if ((experimentHigh < 0) && (runHigh >= 0)) {
26 B2ERROR(
"A run number of " << runHigh <<
" is given for an undefined high experiment number. Setting run to undefined, too.");
29 if ((experimentLow >= 0) && (experimentHigh >= 0)) {
30 if ((experimentLow > experimentHigh) || ((experimentLow == experimentHigh) && (runHigh >= 0) && (runLow > runHigh))) {
31 B2ERROR(
"The given lower and higher experiment/run numbers of " << experimentLow <<
"/" << runLow <<
" and " << experimentHigh <<
32 "/" << runHigh <<
", respectively, are in the wrong order, Swapping them.");
43 if (
empty())
return false;
57 if (
empty())
return false;
82 if (
empty())
return false;
92 auto experiment = (int) event.getExperiment();
93 auto run = (int) event.getRun();
103 result.m_experimentLow = iov.m_experimentLow;
104 result.m_runLow = iov.m_runLow;
107 result.m_experimentHigh = iov.m_experimentHigh;
108 result.m_runHigh = iov.m_runHigh;
119 bool thisOlder =
checkLowerBound(iov.m_experimentLow, iov.m_runLow) >= 0;
157 throw std::runtime_error(
"cannot read from stream");
162 while (input.good()) {
163 auto c = input.peek();
165 if (((c ==
' ') || (c ==
'\n') || (c ==
'\t'))) {
167 if (index == 0 && str[0].
empty()) {
176 if (index == 4)
break;
183 throw std::invalid_argument(
"IoV needs to be four values (firstExp,firstRun,finalExp,finalRun)");
186 iov.m_experimentLow = stoi(str[0]);
187 iov.m_runLow = stoi(str[1]);
188 iov.m_experimentHigh = stoi(str[2]);
189 iov.m_runHigh = stoi(str[3]);
190 }
catch (std::invalid_argument& e) {
191 throw std::invalid_argument(
"experiment and run numbers must be integers");
199 output << iov.m_experimentLow <<
"," << iov.m_runLow <<
"," << iov.m_experimentHigh <<
"," << iov.m_runHigh;
bool trimOverlap(IntervalOfValidity &iov, bool trimOlder=true)
Remove the overlap between two intervals of validity by shortening one of them.
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.
void makeValid()
Helper function to set the interval to empty if the upper bound is below the lower one.
int m_runLow
Lowest run 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 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.
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
std::istream & operator>>(std::istream &input, IntervalOfValidity &iov)
Abstract base class for different kinds of events.