CbmRoot
Loading...
Searching...
No Matches
CbmQaCheckerCore.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#include "CbmQaCheckerCore.h"
11
13#include "Logger.h"
14#include "TClonesArray.h"
15#include "TFile.h"
16//#include <boost/filesystem.hpp>
17#include <regex>
18
20
21// ---------------------------------------------------------------------------------------------------------------------
22//
24{
25 // Define object names data base
26 fpObjDB = std::make_shared<ObjectDB>();
27}
28
29// ---------------------------------------------------------------------------------------------------------------------
30//
31void Core::AddVersion(const char* version, const char* pathName) { fpObjDB->AddVersion(version, pathName); }
32
33// ---------------------------------------------------------------------------------------------------------------------
34//
35void Core::AddDataset(const char* dataset) { fpObjDB->AddDataset(dataset); }
36
37// ---------------------------------------------------------------------------------------------------------------------
38//
39void Core::RegisterOutFile(const char* filename)
40{
41 LOG(info) << "Core: Registering output file: " << filename;
42 fpObjDB->SetOutputPath(filename);
43}
44
45// ---------------------------------------------------------------------------------------------------------------------
46//
47int Core::Process(Option_t* opt)
48{
49 // ----- Init the object database
50 fpObjDB->Init();
51
53
54 int nDatasets = fpObjDB->GetNofDatasets();
55 int nFiles = fpObjDB->GetNofFiles();
56 int nVersions = fpObjDB->GetNofVersions();
57
58 std::vector<ECmpInference> cmpSummary(nVersions * nFiles * nDatasets, ECmpInference::StronglyEqual);
59
60 // ----- Process datasets and files
61 for (int iDS = 0; iDS < nDatasets; ++iDS) {
62 for (int iFile = 0; iFile < nFiles; ++iFile) {
63 // Create and process a file handler
64 auto pFileHandler = std::make_unique<FileHandler>(fpObjDB, iDS, iFile);
65 auto cmpRes = pFileHandler->Process(opt);
66 for (int iVer = 0; iVer < nVersions; ++iVer) {
67 cmpSummary[nVersions * (iDS * nFiles + iFile) + iVer] = cmpRes[iVer];
68 }
69 } // iFile
70 } // iDS
71
73 LOG(info) << "Summary:";
74 for (int iDS{0}; iDS < nDatasets; ++iDS) {
75 LOG(info) << "\tDataset: " << fpObjDB->GetDataset(iDS);
76 for (int iFile{0}; iFile < nFiles; ++iFile) {
77 LOG(info) << "\t\tFile: " << fpObjDB->GetFileLabel(iDS);
78 for (int iVer{0}; iVer < nVersions; ++iVer) {
79 auto versionInference = cmpSummary[nVersions * (iDS * nFiles + iFile) + iVer];
80 LOG(info) << "\t\t\tVersion: " << fpObjDB->GetVersionLabel(iVer)
81 << " (path: " << fpObjDB->GetInputFileName(iVer, iFile, iDS) << "): " << ToString(versionInference);
82 res = std::max(versionInference, res);
83 }
84 }
85 }
86 return static_cast<int>(res);
87}
88
89// ---------------------------------------------------------------------------------------------------------------------
90//
91void Core::SetFromYAML(const char* configName) { fpObjDB->ReadFromYAML(configName); }
92
93// ---------------------------------------------------------------------------------------------------------------------
94//
96{
97 TFile outFile(fpObjDB->GetOutputPath().c_str(), "RECREATE");
98 for (int iDS = 0; iDS < fpObjDB->GetNofDatasets(); ++iDS) {
99 auto* pDSDir = outFile.mkdir(fpObjDB->GetDataset(iDS).c_str());
100 for (int iFile = 0; iFile < fpObjDB->GetNofFiles(); ++iFile) {
101 pDSDir->mkdir(fpObjDB->GetFileLabel(iFile).c_str());
102 }
103 }
104 outFile.Close();
105}
Core class of the QA checking framework (declaration)
A handler class to process versions from similar files (declaration)
Core class for CBM QA checker framework (declaration)
void RegisterOutFile(const char *filename)
Registers root-file for storing output.
void SetFromYAML(const char *configName)
Sets checker configuration from YAML file.
void AddDataset(const char *datasetName)
Adds a dataset name.
int Process(Option_t *comparisonMethod="E")
Runs checking routine.
void AddVersion(const char *label, const char *path)
Adds a version of QA output for a comparison.
std::shared_ptr< ObjectDB > fpObjDB
Database of names.
void PrepareOutputFile()
Prepares output file (creates directory structure)
ECmpInference
The object comparison inference.
@ StronglyEqual
All the comparison methods gave equality.
std::string ToString(ECmpInference inference)
String representation of the ECmpInference enum.