19#include "TEfficiency.h"
25#include "TParameter.h"
27#include "TProfile2D.h"
28#include "TProfile3D.h"
39#include <yaml-cpp/yaml.h>
64 double fRatioMax = std::numeric_limits<double>::max();
162 void Exec(Option_t* )
override final;
165 void Finish() override final;
168 InitStatus
Init() override final;
171 InitStatus
ReInit() override final;
174 virtual InitStatus
InitQa() {
return kSUCCESS; }
196 bool CheckRange(std::string_view name, T var, T lo, T hi)
const;
206 bool CheckRange(std::string_view name, T var, T varErr, T lo, T hi)
const;
210 bool CheckRange(TH1*
h,
double meanMax,
double rmsMin,
double rmsMax);
222 void StoreCheckResult(
const std::string& tag,
bool result,
const std::string& msg =
"");
237 bool CompareTwoObjects(
const TObject* pObjL,
const TObject* pObjR,
const TString& objName,
238 const ObjectComparisonConfig& cfg);
286 if (var + 3.5 * varErr < lo) {
287 LOG(error) << fName <<
": " << name <<
" is found to be under the lower limit (" << var <<
" +- 3.5 x " << varErr
288 <<
" < " << lo <<
')';
291 if (var - 3.5 * varErr > hi) {
292 LOG(error) << fName <<
": " << name <<
" is found to be above the upper limit (" << var <<
" +-3.5 x " << varErr
293 <<
" > " << hi <<
')';
297 LOG(debug) << fName <<
": " << name <<
" is found to be within limit (" << lo <<
" <= " << var <<
" +- 3.5 x "
298 << varErr <<
" <= " << hi <<
')';
309 const auto* pHistL =
static_cast<const Obj*
>(pObjL);
310 const auto* pHistR =
dynamic_cast<const Obj*
>(pObjR);
312 LOG(error) << fName <<
"::CompareObjects(): the default " << pObjR->GetName()
313 <<
" has different type to the new object";
316 std::string opt =
"";
328 auto out = comparator(opt, cfg.
fStatOpt);
330 if (!out.fConsistent) {
331 LOG(info) << fName <<
": This and default versions of the object " << pObjL->GetName() <<
" are incompatible";
338 std::stringstream msg;
340 constexpr const char* kEqual =
"\e[1;32mequal\e[0m";
341 constexpr const char* kDiff =
"\e[1;32mdifferent\e[0m";
342 msg <<
"\tobject " << setw(12) << pObjL->ClassName() <<
' ' << setw(50) << objName;
344 msg <<
": point-by-point -> " << (out.fPointByPoint ? kEqual : kDiff);
346 res &= out.fPointByPoint;
351 msg <<
", ratio -> " << (bOk ? kEqual : kDiff) <<
"(lo: " << out.fRatioLo <<
", up: " << out.fRatioUp <<
')';
358 msg <<
", stat. test -> " << (bOk ? kEqual : kDiff) <<
"(chi2/NDF: " << out.fChi2NDF <<
')';
359 if (cfg.
fStat == 2) {
363 LOG(info) << msg.str();
371 pObjL->Write(Form(
"%s_%s", pObjL->GetName(),
fsVersionTag.Data()));
372 pObjR->Write(Form(
"%s_%s", pObjL->GetName(),
fsDefaultTag.Data()));
374 auto* pCanv = comparator.GetComparisonCanvas(cfg.
fCanvOpt);
376 pCanv->Write(Form(
"%s_cmp_canvas", pObjL->GetName()));
ECbmRecoMode
Reconstruct the full time slice or event-by-event.
A histogram comparison module for the QA task (declaration)
Module for ROOT objects IO interface (header)
Definition of CbmQaTable class.
Class characterising one event by a collection of links (indices) to data objects,...
Class to compare histograms of the QA task with default ones.
ROOT object IO interface for QA.
void SetVersionTag(const TString &tag)
Sets version tag.
void SetCheckFile(const std::shared_ptr< TFile > &pCheckFile)
Sets check-file.
CbmEvent * GetCurrentEvent()
Gets pointer to current event.
virtual void CreateSummary()
Initializes QA-task summary: canvases, tables etc.
virtual ~CbmQaTask()=default
Destructor.
void SetDefaultTag(const TString &tag)
Sets default tag.
const std::map< std::string, CheckFlags > & GetCheckList() const
Gets check-list.
const TString & GetVersionTag() const
Gets version tag.
std::string fsSetupName
Name of the setup (to draw on the canvases)
bool CheckRange(std::string_view name, T var, T lo, T hi) const
Checks range of variable.
CbmQaTask & operator=(const CbmQaTask &)=delete
Copy assignment operator.
void DisableEventMode()
Disables event-by-event execution.
const TString & GetDefaultTag() const
Gets default tag.
virtual void DeInit()
De-initialize the task.
void SetRecoMode(ECbmRecoMode recoMode)
Sets data processing (reconstruction) mode.
std::map< std::string, CheckFlags > fmCheckList
A QA check-list map.
InitStatus Init() override final
FairTask: Task initialization in the beginning of the run.
void SetCompareOutput(const std::shared_ptr< TFile > &pCompareOutput)
Sets compare output file.
std::shared_ptr< TFile > fpBenchmarkOutput
An output file for histograms cross-check.
bool CompareQaObjects()
Process ROOT objects comparison.
void DeInitBase()
De-initializes this task.
CbmQaTask(const CbmQaTask &)=delete
Copy constructor.
std::shared_ptr< TFile > fpBenchmarkInput
A file with default ROOT objects used for the cross-check.
virtual void ExecQa()
Method to fill histograms per event or time-slice.
CbmQaTask & operator=(CbmQaTask &&)=delete
Move assignment operator.
virtual InitStatus InitQa()
Initializes the task.
void Exec(Option_t *) override final
FairTask: Defines action of the task in the event/TS.
bool CompareTwoObjects(const TObject *pObjL, const TObject *pObjR, const TString &objName, const ObjectComparisonConfig &cfg)
Process object comparison.
const std::string & GetSetupName() const
Gets name of the setup.
virtual void Check()=0
Function to check, if the QA results are acceptable.
void StoreCheckResult(const std::string &tag, bool result, const std::string &msg="")
Stores check flag to the check-list.
int GetEventNumber() const
Get current event number.
CbmQaTask()=delete
Default constructor.
CbmQaTask(CbmQaTask &&)=delete
Move constructor.
TString fsVersionTag
Version tag (git SHA etc.)
void ReadCheckListFromConfig()
Reads check-list from the configuration file.
void SetSetupName(const char *setup)
Sets name of the setup.
TParameter< int > fNofEvents
Number of processed events.
bool IsMCUsed() const
Returns flag, whether MC information is used or not in the task.
bool fbUseMC
Flag, if MC is used.
TString fsDefaultTag
Default tag (git SHA etc.)
void PutSetupNameOnPad(double xMin, double yMin, double xMax, double yMax)
Puts setup title on the canvas.
ClassDefOverride(CbmQaTask, 0)
TClonesArray * fpBrEvents
Pointer to CbmEvent branch.
CbmEvent * fpCurrentEvent
Pointer to the current event.
ECbmRecoMode fRecoMode
Reconstruction mode.
void Finish() override final
FairTask: Defines action of the task in the end of run.
InitStatus ReInit() override final
FairTask: Task reinitialization.
Data class with information on a STS local track.
Contains a check result and its activeness status of the check-list entry.
bool fResult
Check result storage.
std::string fMsg
Supporting message for the check.
bool fStatus
Status of the check.
Contains configuration to compare two root objects (histograms)