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 ObjectDB() = default;
32
34 ~ObjectDB() = default;
35
37 ObjectDB(const ObjectDB&) = delete;
38
40 ObjectDB(ObjectDB&&) = delete;
41
43 ObjectDB& operator=(const ObjectDB&) = delete;
44
47
51 void AddVersion(const char* label, const char* path);
52
55 void AddDataset(const char* dataset);
56
58 void Clear();
59
63 const std::string& GetDataset(int iDataset) const { return fvDatasets[iDataset]; }
64
67 int GetDefaultID() const { return fDefVersionID; }
68
72 const std::string& GetFileLabel(int iFile) const { return fvFileLabels[iFile]; }
73
79 std::string GetInputFileName(int iVersion, int iFile, int iDataset) const;
80
85 const std::string& GetObject(int iFile, int iObject) const { return fvObjects[iFile][iObject]; }
86
88 int GetNofDatasets() const { return fvDatasets.size(); }
89
91 int GetNofObjects() const { return fvObjects.size(); }
92
95 int GetNofObjects(int iFile) const { return fvObjects[iFile].size(); }
96
98 int GetNofFiles() const { return fvFiles.size(); }
99
101 int GetNofVersions() const { return fvVersionLabels.size(); }
102
104 const std::string& GetOutputPath() const { return fsOutputPath; }
105
107 double GetPvalThreshold() const { return fPvalThresh; }
108
110 double GetRatioRangeMax() const { return fRatioMax; }
111
113 double GetRatioRangeMin() const { return fRatioMin; }
114
117 const std::string& GetVersionLabel(int iVersion) const { return fvVersionLabels[iVersion]; }
118
121 const std::string& GetVersionPath(int iVersion) const { return fvVersionPaths[iVersion]; }
122
124 void Init();
125
128 void ReadFromYAML(const char* configName);
129
136 std::string ToString(int verbose = 1) const;
137
143 void SetDefaultLabel(const char* defaultLabel) { fsDefaultLabel = defaultLabel; }
144
147 void SetInputRootPath(const char* pathName) { fsInputRootPath = pathName; }
148
151 void SetOutputPath(const char* path) { fsOutputPath = path; }
152
155 void SetPvalThreshold(double pVal);
156
160 void SetRatioRange(double min, double max);
161
162 private:
166 void ReadObjectList(int iFile);
167
172 static void CollectObjectPaths(TDirectory* pDir, const TString& parentPah, std::set<std::string>& paths);
173
174 int fDefVersionID = -1;
175
176 std::string fsInputRootPath = "";
177 std::string fsOutputPath = "";
178 std::string fsDefaultLabel = "";
179
180 std::vector<std::string> fvDatasets;
181 std::vector<std::string> fvFiles;
182 std::vector<char> fvbProcessWholeFile;
183 std::vector<int> fvObjectFirstGlobIndex;
184 std::vector<std::string> fvFileLabels;
185 std::vector<std::vector<std::string>> fvObjects;
186 std::vector<std::string> fvVersionLabels;
187 std::vector<std::string> fvVersionPaths;
188
189 double fPvalThresh{0.05};
190 double fRatioMax{1.05};
191 double fRatioMin{0.95};
192 };
193} // namespace cbm::qa::checker
194
195#endif // CbmQaCheckerObjectDB_h
Common definitions for QA-Checker framework.
A data base class for processed objects.
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.
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::string fsInputRootPath
Root path for input files.
ObjectDB & operator=(const ObjectDB &)=delete
Copy assignment operator.
std::vector< std::vector< std::string > > fvObjects
Container of object names vs file id.
void SetPvalThreshold(double pVal)
Sets P-value threshold.
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.
int GetNofVersions() const
Gets number of versions.
const std::string & GetObject(int iFile, int iObject) const
Gets object name by its local index and index of file.
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.
ObjectDB()=default
Default constructor.
ObjectDB & operator=(ObjectDB &&)=delete
Move assignment operator.
std::string fsOutputPath
Path to the output file.