CbmRoot
Loading...
Searching...
No Matches
CbmQaManager.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 "CbmQaManager.h"
11
12#include "CbmQaTask.h"
13#include "Logger.h"
14
15#include <iomanip>
16
17// ---------------------------------------------------------------------------------------------------------------------
18//
19CbmQaManager::CbmQaManager(int verbose) : FairTask("CbmQaManager", verbose) {}
20
21
22// ---------------------------------------------------------------------------------------------------------------------
23//
25{
26 using std::left;
27 using std::right;
28 using std::setw;
29
30 // Check QA-tasks
31 for (auto* task : *(this->GetListOfTasks())) {
32 auto* pQaTask = dynamic_cast<CbmQaTask*>(task);
33 if (pQaTask) {
34 LOG(info) << "Checking the task " << pQaTask->GetName();
35 pQaTask->Check();
36 pQaTask->ReadCheckListFromConfig();
37 }
38 }
39
40 // Process check flags
41 LOG(info) << fName << " check-list:";
42 fStatus = true;
43 for (auto* task : *(this->GetListOfTasks())) {
44 auto* pQaTask = dynamic_cast<CbmQaTask*>(task);
45 if (pQaTask) {
46 LOG(info) << "Check list for the task " << pQaTask->GetName();
47 const auto& mCheckList = pQaTask->GetCheckList();
48 for (const auto& [entryName, flags] : mCheckList) {
49 LOG(info) << '\t' << left << setw(40) << entryName << right << setw(10)
50 << (flags.fResult ? "\e[1;32mpassed\e[0m" : "\e[1;31mfailed\e[0m")
51 << (flags.fStatus ? " " : " IGNORED ") << flags.fMsg;
52 if (flags.fStatus) {
53 fStatus &= flags.fResult;
54 }
55 }
56 }
57 }
58
59 // Process histogram benchmarking
60 if (fpBenchmarkInput.get()) {
61 for (auto* task : *(this->GetListOfTasks())) {
62 auto* pQaTask = dynamic_cast<CbmQaTask*>(task);
63 if (pQaTask) {
64 LOG(info) << "Histograms benchmark for the task " << pQaTask->GetName();
65 pQaTask->CompareQaObjects();
66 }
67 }
68 if (fpBenchmarkOutput.get()) {
69 fpBenchmarkOutput->Close();
70 }
71 }
72}
73
74// ---------------------------------------------------------------------------------------------------------------------
75//
77{
78 // Apply configuration file to all underlying tasks
79 if (fsConfigName.Length()) {
80 LOG(info) << "CbmQaManager: using configuration file " << fsConfigName;
81 for (auto* task : *(this->GetListOfTasks())) {
82 auto* pQaTask = dynamic_cast<CbmQaTask*>(task);
83 if (pQaTask) {
84 pQaTask->SetConfigName(fsConfigName.Data());
85 pQaTask->SetVersionTag(fsVersionTag);
86 pQaTask->SetDefaultTag(fsDefaultTag);
87 if (fpBenchmarkInput.get() != nullptr) {
88 pQaTask->SetCheckFile(fpBenchmarkInput);
89 }
90 if (fpBenchmarkOutput.get() != nullptr) {
91 pQaTask->SetCompareOutput(fpBenchmarkOutput);
92 }
93 }
94 }
95 }
96 return kSUCCESS;
97}
98
99// ---------------------------------------------------------------------------------------------------------------------
100//
101void CbmQaManager::OpenBenchmarkInput(const TString& path)
102{
103 if (path.Length()) {
104 auto pFile = std::make_shared<TFile>(path, "READONLY");
105 if (pFile->IsOpen()) {
106 fpBenchmarkInput = std::move(pFile);
107 LOG(info) << fName << ": opening benchmark input file " << fpBenchmarkInput->GetName();
108 }
109 else {
110 LOG(error) << fName << ": benchmark input file " << path << " was not opened";
111 }
112 }
113}
114
115// ---------------------------------------------------------------------------------------------------------------------
116//
117void CbmQaManager::OpenBenchmarkOutput(const TString& path)
118{
119 if (path.Length()) {
120 auto pFile = std::make_shared<TFile>(path, "RECREATE");
121 if (pFile->IsOpen()) {
122 fpBenchmarkOutput = std::move(pFile);
123 LOG(info) << fName << ": opening benchmark output file " << fpBenchmarkOutput->GetName();
124 }
125 else {
126 LOG(error) << fName << ": benchmark output file " << path << " was not opened";
127 }
128 }
129}
Manager task for other QA taska (implementation)
A base class for CBM QA task logic.
TString fsConfigName
Name of the configuration YAML file (passed to underlying QA tasks)
void Finish()
Action of the task in the end of the run.
std::shared_ptr< TFile > fpBenchmarkOutput
An output file for histograms cross-check.
void OpenBenchmarkInput(const TString &path)
Open cross-check file.
TString fsDefaultTag
Default tag (git SHA etc.)
void OpenBenchmarkOutput(const TString &path)
Open benchmark output file.
InitStatus Init()
Task initialization.
CbmQaManager(int verbose=1)
Constructor from parameters.
bool fStatus
Status of QA: true - all tasks passed, false - at least one of the task failed.
TString fsVersionTag
Version tag (git SHA etc.)
std::shared_ptr< TFile > fpBenchmarkInput
A benchmark file with default ROOT objects used for the cross-check.