CbmRoot
Loading...
Searching...
No Matches
CbmQaCheckerObjectDB.h
Go to the documentation of this file.
1/* Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#ifndef CbmQaCheckerObjectDB_h
11#define CbmQaCheckerObjectDB_h 1
12
14
15#include <set>
16#include <string>
17#include <utility>
18#include <vector>
19
20class TString;
21class TDirectory;
22
23namespace cbm::qa::checker
24{
28 class ObjectDB {
29 public:
31 double ratioMin = 0.95;
32 double ratioMax = 1.05;
33 double pvalThreshold = 0.05;
34 std::string compMethod = "E";
35 };
36
38 ObjectDB() = default;
39
41 ~ObjectDB() = default;
42
44 ObjectDB(const ObjectDB&) = delete;
45
47 ObjectDB(ObjectDB&&) = delete;
48
50 ObjectDB& operator=(const ObjectDB&) = delete;
51
54
58 void AddVersion(const char* label, const char* path);
59
62 void AddDataset(const char* dataset);
63
65 void Clear();
66
70 const std::string& GetDataset(int iDataset) const { return fvDatasets[iDataset]; }
71
74 int GetDefaultID() const { return fDefVersionID; }
75
79 const std::string& GetFileLabel(int iFile) const { return fvFileLabels[iFile]; }
80
86 std::string GetInputFileName(int iVersion, int iFile, int iDataset) const;
87
92 //const std::string& GetObject(int iFile, int iObject) const { return fvObjects[iFile][iObject]; }
93 const std::pair<std::string, uint32_t>& GetObject(int iFile, int iObject) const
94 {
95 return fvObjects[iFile][iObject];
96 }
97
101 const ObjectParameters& GetObjectParameters(uint32_t paramIndex) const { return fvObjectParameters[paramIndex]; }
103 int GetNofDatasets() const { return fvDatasets.size(); }
104
106 int GetNofObjects() const { return fvObjects.size(); }
107
110 int GetNofObjects(int iFile) const { return fvObjects[iFile].size(); }
111
113 int GetNofObjectParameters() const { return fvObjectParameters.size(); }
114
116 int GetNofFiles() const { return fvFiles.size(); }
117
119 int GetNofVersions() const { return fvVersionLabels.size(); }
120
122 const std::string& GetOutputPath() const { return fsOutputPath; }
123
125 double GetPvalThreshold() const { return fPvalThresh; }
126
128 double GetRatioRangeMax() const { return fRatioMax; }
129
131 double GetRatioRangeMin() const { return fRatioMin; }
132
135 const std::string& GetVersionLabel(int iVersion) const { return fvVersionLabels[iVersion]; }
136
139 const std::string& GetVersionPath(int iVersion) const { return fvVersionPaths[iVersion]; }
140
142 void Init();
143
146 void ReadFromYAML(const char* configName);
147
154 std::string ToString(int verbose = 1) const;
155
161 void SetDefaultLabel(const char* defaultLabel) { fsDefaultLabel = defaultLabel; }
162
165 void SetInputRootPath(const char* pathName) { fsInputRootPath = pathName; }
166
169 void SetOutputPath(const char* path) { fsOutputPath = path; }
170
173 void SetPvalThreshold(double pVal);
174
178 void SetRatioRange(double min, double max);
179
180 private:
184 void ReadObjectList(int iFile);
185
190 static void CollectObjectPaths(TDirectory* pDir, const TString& parentPah, std::set<std::string>& paths);
191
192 int fDefVersionID = -1;
193
194 std::string fsInputRootPath = "";
195 std::string fsOutputPath = "";
196 std::string fsDefaultLabel = "";
197
198 std::vector<std::string> fvDatasets;
199 std::vector<std::string> fvFiles;
200 std::vector<char> fvbProcessWholeFile;
201 std::vector<int> fvObjectFirstGlobIndex;
202 std::vector<std::string> fvFileLabels;
203
205 std::vector<std::vector<std::pair<std::string, uint32_t>>> fvObjects;
206
207 std::vector<ObjectParameters> fvObjectParameters;
208 std::vector<std::string> fvVersionLabels;
209 std::vector<std::string> fvVersionPaths;
210
211 double fPvalThresh{0.05};
212 double fRatioMax{1.05};
213 double fRatioMin{0.95};
214 };
215} // namespace cbm::qa::checker
216
217#endif // CbmQaCheckerObjectDB_h
Common definitions for QA-Checker framework.
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
double GetRatioRangeMin() const
Gets lower bound of the accepted ratio range.
std::vector< std::string > fvFileLabels
Container of file labels (used in output)
const std::string & GetOutputPath() const
Gets output path.
int GetNofObjects() const
Gets total number of objects.
ObjectDB(const ObjectDB &)=delete
Copy constructor.
void ReadObjectList(int iFile)
Reads list of histograms from file.
std::string ToString(int verbose=1) const
String representation of the content.
static void CollectObjectPaths(TDirectory *pDir, const TString &parentPah, std::set< std::string > &paths)
Loops over ROOT-file and collects object paths.
std::string GetInputFileName(int iVersion, int iFile, int iDataset) const
Gets name of file from indexes of version, file and dataset.
const std::string & GetVersionPath(int iVersion) const
Gets version path.
int GetNofObjects(int iFile) const
Gets number of objects in file.
int GetNofObjectParameters() const
Gets number of object parameters.
std::vector< int > fvObjectFirstGlobIndex
First global index of object in a file.
std::vector< std::string > fvVersionPaths
Container of version paths.
void AddDataset(const char *dataset)
Adds dataset.
int GetNofDatasets() const
Gets number of datasets.
std::vector< ObjectParameters > fvObjectParameters
Container of object parameters.
std::string fsInputRootPath
Root path for input files.
ObjectDB & operator=(const ObjectDB &)=delete
Copy assignment operator.
void SetPvalThreshold(double pVal)
Sets P-value threshold.
const std::pair< std::string, uint32_t > & GetObject(int iFile, int iObject) const
Gets object name by its local index and index of file.
void SetRatioRange(double min, double max)
Sets ratio accepted range.
int GetDefaultID() const
Gets index of default version.
double GetPvalThreshold() const
Gets p-value threshold.
~ObjectDB()=default
Destructor.
std::vector< std::string > fvDatasets
Container of dataset names.
const ObjectParameters & GetObjectParameters(uint32_t paramIndex) const
Gets object parameters by its local index.
int GetNofVersions() const
Gets number of versions.
const std::string & GetVersionLabel(int iVersion) const
Gets version label.
std::vector< char > fvbProcessWholeFile
If the whole file should be processed.
double GetRatioRangeMax() const
Gets upper bound of the accepted ratio range.
std::vector< std::string > fvFiles
Container of file names.
void AddVersion(const char *label, const char *path)
Adds version.
int GetNofFiles() const
Gets number of files.
ObjectDB(ObjectDB &&)=delete
Move constructor.
std::vector< std::string > fvVersionLabels
Container of version labels.
const std::string & GetFileLabel(int iFile) const
Gets label of file.
double fRatioMin
Lower boundary for ratio deviation.
const std::string & GetDataset(int iDataset) const
Gets name of dataset.
void SetInputRootPath(const char *pathName)
Sets root path to input files.
void SetDefaultLabel(const char *defaultLabel)
Sets default version label.
void SetOutputPath(const char *path)
Sets the output path.
double fPvalThresh
P-value threshold for histograms equality.
double fRatioMax
Upper boundary for ratio deviation.
void ReadFromYAML(const char *configName)
Reads DB from YAML node.
int fDefVersionID
Index of default version.
void Init()
Initializes the database.
std::string fsDefaultLabel
Name of default version label.
std::vector< std::vector< std::pair< std::string, uint32_t > > > fvObjects
Container of object names and corresponding parameter IDs in fvObjectParameters.
ObjectDB()=default
Default constructor.
ObjectDB & operator=(ObjectDB &&)=delete
Move assignment operator.
std::string fsOutputPath
Path to the output file.