REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDataQualityRules.h
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23#ifndef RestCore_TRestDataQualityRules
24#define RestCore_TRestDataQualityRules
25
26#include "TObject.h"
27#include "TString.h"
28#include "TVector2.h"
29
31class TRestDataQualityRules : public TObject {
32 private:
34 std::vector<TString> fTypes; //<
35
37 std::vector<TString> fValues; //<
38
40 std::vector<TVector2> fRanges; //<
41
43 std::vector<Int_t> fBits; //<
44
45 Bool_t EvaluateMetadataRule(TString value, TVector2 range);
46
47 public:
48 void AddRule(TString type, TString value, TVector2 range, Int_t bit) {
49 fTypes.push_back(type);
50 fValues.push_back(value);
51 fRanges.push_back(range);
52 fBits.push_back(bit);
53 }
54
55 void ClearRules() {
56 fTypes.clear();
57 fValues.clear();
58 fRanges.clear();
59 fBits.clear();
60 }
61
62 inline Int_t GetNumberOfRules() const { return fTypes.size(); }
63
64 std::vector<TString> GetTypes() { return fTypes; }
65
66 std::vector<TString> GetValues() { return fValues; }
67
68 std::vector<TVector2> GetRanges() { return fRanges; }
69
70 std::vector<Int_t> GetBits() { return fBits; }
71
72 TString GetType(unsigned int n) {
73 if (fTypes.size() <= n)
74 return "";
75 else
76 return fTypes[n];
77 }
78
79 TString GetValue(unsigned int n) {
80 if (fValues.size() <= n)
81 return "";
82 else
83 return fValues[n];
84 }
85
86 TVector2 GetRange(unsigned int n) { return (n < fRanges.size()) ? fRanges[n] : TVector2(0, 0); }
87
88 Int_t GetBit(unsigned int n) {
89 if (fBits.size() <= n)
90 return -1;
91 else
92 return fBits[n];
93 }
94
96
98
99 // If new members are added, removed or modified in this class version number must be increased!
100 ClassDef(TRestDataQualityRules, 1);
101};
102#endif
A class to define the properties of a rule inside TRestDataQualityRules.
std::vector< TString > fValues
The value of the rule. I.e. observable name, metadata member, ...
std::vector< TString > fTypes
The rule type. I.e. obsAverage, metadata, ...
std::vector< TVector2 > fRanges
The range where it should be found the value of the rule to enable the corresponding bit.
TRestDataQualityRules()
Default constructor.
std::vector< Int_t > fBits
The bit position for the corresponding rule.
~TRestDataQualityRules()
Default destructor.