forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdRunRange.cxx
More file actions
95 lines (74 loc) · 2.39 KB
/
Copy pathIdRunRange.cxx
File metadata and controls
95 lines (74 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
// defines the run validity range of the object: //
// [mFirstRun, mLastRun] //
#include "CCDB/IdRunRange.h"
#include <fairlogger/Logger.h> // for LOG
using namespace o2::ccdb;
ClassImp(IdRunRange)
IdRunRange::IdRunRange() : mFirstRun(-1), mLastRun(-1)
{
// constructor
}
IdRunRange::IdRunRange(Int_t firstRun, Int_t lastRun) : mFirstRun(firstRun), mLastRun(lastRun)
{
// constructor
}
IdRunRange::~IdRunRange() = default;
Bool_t IdRunRange::isOverlappingWith(const IdRunRange &other) const
{
// check if this runRange overlaps other runRange
if (!(isValid() && other.isValid())) {
LOG(ERROR) << "Comparing invalid run ranges!";
return kFALSE;
}
if (isAnyRange() || other.isAnyRange()) {
LOG(ERROR) << "Comparing unspecified ranges!";
return kFALSE;
}
return ((mFirstRun < other.mFirstRun && other.mFirstRun <= mLastRun) ||
(other.mFirstRun <= mFirstRun && mFirstRun <= other.mLastRun));
}
Bool_t IdRunRange::isSupersetOf(const IdRunRange &other) const
{
// check if this runRange contains other runRange
if (!(isValid() && other.isValid())) {
LOG(ERROR) << "Comparing invalid run ranges!";
return kFALSE;
}
if (isAnyRange()) {
return kTRUE;
}
return mFirstRun <= other.mFirstRun && other.mFirstRun <= mLastRun && mFirstRun <= other.mLastRun &&
other.mLastRun <= mLastRun;
}
Bool_t IdRunRange::isEqual(const TObject *obj) const
{
// check if this runRange is equal to other runRange
if (this == obj) {
return kTRUE;
}
if (IdRunRange::Class() != obj->IsA()) {
return kFALSE;
}
IdRunRange *other = (IdRunRange *) obj;
return mFirstRun == other->mFirstRun && mLastRun == other->mLastRun;
}
Bool_t IdRunRange::isValid() const
{
// validity check
if (mFirstRun < 0 && mLastRun < 0) {
return kTRUE;
}
if (mFirstRun >= 0 && mLastRun >= mFirstRun) {
return kTRUE;
}
return kFALSE;
}