diff --git a/core/qa/CbmQaManager.cxx b/core/qa/CbmQaManager.cxx index ad7231030129b3a2cf23f17b29569198c03d9531..38de139993530dc8614c0886a649ff36062816d1 100644 --- a/core/qa/CbmQaManager.cxx +++ b/core/qa/CbmQaManager.cxx @@ -56,17 +56,17 @@ void CbmQaManager::Finish() } } - // Process histogram checking - if (fpCrossCheckFile.get()) { + // Process histogram benchmarking + if (fpBenchmarkInput.get()) { for (auto* task : *(this->GetListOfTasks())) { auto* pQaTask = dynamic_cast<CbmQaTask*>(task); if (pQaTask) { - LOG(info) << "Histograms check for the task " << pQaTask->GetName(); + LOG(info) << "Histograms benchmark for the task " << pQaTask->GetName(); pQaTask->CompareQaObjects(); } } - if (fpCompareOutput.get()) { - fpCompareOutput->Close(); + if (fpBenchmarkOutput.get()) { + fpBenchmarkOutput->Close(); } } } @@ -84,11 +84,11 @@ InitStatus CbmQaManager::Init() pQaTask->SetConfigName(fsConfigName.Data()); pQaTask->SetVersionTag(fsVersionTag); pQaTask->SetDefaultTag(fsDefaultTag); - if (fpCrossCheckFile.get() != nullptr) { - pQaTask->SetCheckFile(fpCrossCheckFile); + if (fpBenchmarkInput.get() != nullptr) { + pQaTask->SetCheckFile(fpBenchmarkInput); } - if (fpCompareOutput.get() != nullptr) { - pQaTask->SetCompareOutput(fpCompareOutput); + if (fpBenchmarkOutput.get() != nullptr) { + pQaTask->SetCompareOutput(fpBenchmarkOutput); } } } @@ -98,32 +98,32 @@ InitStatus CbmQaManager::Init() // --------------------------------------------------------------------------------------------------------------------- // -void CbmQaManager::OpenCrossCheckFile(const TString& path) +void CbmQaManager::OpenBenchmarkInput(const TString& path) { if (path.Length()) { auto pFile = std::make_shared<TFile>(path, "READONLY"); if (pFile->IsOpen()) { - fpCrossCheckFile = std::move(pFile); - LOG(info) << fName << ": opening cross-check file " << fpCrossCheckFile->GetName(); + fpBenchmarkInput = std::move(pFile); + LOG(info) << fName << ": opening benchmark input file " << fpBenchmarkInput->GetName(); } else { - LOG(error) << fName << ": cross-check file " << path << " was not open"; + LOG(error) << fName << ": benchmark input file " << path << " was not opened"; } } } // --------------------------------------------------------------------------------------------------------------------- // -void CbmQaManager::OpenCompareOutput(const TString& path) +void CbmQaManager::OpenBenchmarkOutput(const TString& path) { if (path.Length()) { auto pFile = std::make_shared<TFile>(path, "RECREATE"); if (pFile->IsOpen()) { - fpCompareOutput = std::move(pFile); - LOG(info) << fName << ": opening comparison output file " << fpCompareOutput->GetName(); + fpBenchmarkOutput = std::move(pFile); + LOG(info) << fName << ": opening benchmark output file " << fpBenchmarkOutput->GetName(); } else { - LOG(error) << fName << ": comparison output file " << path << " was not open"; + LOG(error) << fName << ": benchmark output file " << path << " was not opened"; } } } diff --git a/core/qa/CbmQaManager.h b/core/qa/CbmQaManager.h index 06f2f141a2e245d8dacc6421550b7dc7231d22ec..81417c179755db80c7fde46a22db4a1099fc723b 100644 --- a/core/qa/CbmQaManager.h +++ b/core/qa/CbmQaManager.h @@ -70,12 +70,12 @@ class CbmQaManager : public FairTask { /// \brief Open cross-check file /// \param path Path to the cross-check file /// - /// Opens the cross-check ROOT-file with the QA-chain output, obtained under the default code base. - void OpenCrossCheckFile(const TString& path); + /// Opens the benchmark input ROOT-file with the QA-chain output, obtained under the default code base. + void OpenBenchmarkInput(const TString& path); - /// \brief Open comparison output file + /// \brief Open benchmark output file /// \param path Path to the comparison output - void OpenCompareOutput(const TString& path); + void OpenBenchmarkOutput(const TString& path); /// \brief Sets YAML config name void SetConfigName(const TString& name) { fsConfigName = name; } @@ -92,6 +92,7 @@ class CbmQaManager : public FairTask { TString fsVersionTag = ""; ///< Version tag (git SHA etc.) TString fsDefaultTag = ""; ///< Default tag (git SHA etc.) - std::shared_ptr<TFile> fpCrossCheckFile = nullptr; ///< A file with default ROOT objects used for the cross-check - std::shared_ptr<TFile> fpCompareOutput = nullptr; ///< An output file for histograms cross-check + std::shared_ptr<TFile> fpBenchmarkInput = + nullptr; ///< A benchmark file with default ROOT objects used for the cross-check + std::shared_ptr<TFile> fpBenchmarkOutput = nullptr; ///< An output file for histograms cross-check }; diff --git a/core/qa/CbmQaTask.cxx b/core/qa/CbmQaTask.cxx index ab431fafd4fba28266b802b82a13f1e29e36e2da..cf5943daee936249369dc116ae9ffdb02b9478e3 100644 --- a/core/qa/CbmQaTask.cxx +++ b/core/qa/CbmQaTask.cxx @@ -228,7 +228,7 @@ bool CbmQaTask::CompareQaObjects() const auto& configEntry = configEntryIt->second; // Get default object - auto* pObjCheck = fpCheckFile->Get(objName); + auto* pObjCheck = fpBenchmarkInput->Get(objName); if (!pObjCheck) { LOG(warn) << fName << "::CompareQaObjects(): ROOT object " << objName << " is not found in the check file"; continue; diff --git a/core/qa/CbmQaTask.h b/core/qa/CbmQaTask.h index 732d33e5224f85239eaef4ee49e51704c3170e61..c13ff090fd00d78d768c3e97b20b0760b61fae0a 100644 --- a/core/qa/CbmQaTask.h +++ b/core/qa/CbmQaTask.h @@ -138,11 +138,11 @@ class CbmQaTask : public FairTask, public CbmQaIO { /// \brief Sets check-file /// \param pCheckFile Shared pointer to the cross-check file - void SetCheckFile(const std::shared_ptr<TFile>& pCheckFile) { fpCheckFile = pCheckFile; } + void SetCheckFile(const std::shared_ptr<TFile>& pCheckFile) { fpBenchmarkInput = pCheckFile; } /// \brief Sets compare output file /// \param pCompareOutput Shared pointer to the comparison output file - void SetCompareOutput(const std::shared_ptr<TFile>& pCompareOutput) { fpCompareOutput = pCompareOutput; } + void SetCompareOutput(const std::shared_ptr<TFile>& pCompareOutput) { fpBenchmarkOutput = pCompareOutput; } /// \brief Sets version tag void SetVersionTag(const TString& tag) { fsVersionTag = tag; } @@ -255,8 +255,8 @@ class CbmQaTask : public FairTask, public CbmQaIO { TString fsVersionTag = ""; ///< Version tag (git SHA etc.) TString fsDefaultTag = ""; ///< Default tag (git SHA etc.) - std::shared_ptr<TFile> fpCheckFile = nullptr; ///< A file with default ROOT objects used for the cross-check - std::shared_ptr<TFile> fpCompareOutput = nullptr; ///< An output file for histograms cross-check + std::shared_ptr<TFile> fpBenchmarkInput = nullptr; ///< A file with default ROOT objects used for the cross-check + std::shared_ptr<TFile> fpBenchmarkOutput = nullptr; ///< An output file for histograms cross-check ClassDefOverride(CbmQaTask, 0); }; @@ -357,9 +357,9 @@ bool CbmQaTask::CompareTwoObjects(const TObject* pObjL, const TObject* pObjR, co } // Write comparison result - if (fpCompareOutput.get()) { - fpCompareOutput->mkdir(objName); - auto* pDir = fpCompareOutput->GetDirectory(objName); + if (fpBenchmarkOutput.get()) { + fpBenchmarkOutput->mkdir(objName); + auto* pDir = fpBenchmarkOutput->GetDirectory(objName); pDir->cd(); pObjL->Write(Form("%s_%s", pObjL->GetName(), fsVersionTag.Data())); pObjR->Write(Form("%s_%s", pObjL->GetName(), fsDefaultTag.Data())); diff --git a/external/InstallQa.cmake b/external/InstallQa.cmake index c740eeb3433e1b2ef7b92a7a9fa94943cdc1112a..fb8f0cec6372421370d5aa878fc2bb3cbca46678 100644 --- a/external/InstallQa.cmake +++ b/external/InstallQa.cmake @@ -5,7 +5,7 @@ set(QA_SRC_URL "https://git.cbm.gsi.de/CbmSoft/cbmroot_qa.git") download_project_if_needed(PROJECT QA_source GIT_REPOSITORY ${QA_SRC_URL} GIT_TAG ${QA_VERSION} - SOURCE_DIR ${CMAKE_SOURCE_DIR}/qa + SOURCE_DIR ${CMAKE_SOURCE_DIR}/qa_data TEST_FILE README.md ) diff --git a/macro/mcbm/CMakeLists.txt b/macro/mcbm/CMakeLists.txt index 54f2a6da697c0b209103b016b2c9292cc6a16439..83167d260e83a7971fc6d14fae3f84015a44482a 100644 --- a/macro/mcbm/CMakeLists.txt +++ b/macro/mcbm/CMakeLists.txt @@ -109,7 +109,7 @@ ForEach(setup IN LISTS cbm_setup) If(${CBM_TEST_MODEL} MATCHES Weekly) Set(qa_benchmark "") Else() - Set(qa_benchmark ${CBMROOT_SOURCE_DIR}/qa/defaults/${setup}_test.qa.root) + Set(qa_benchmark ${CBMROOT_SOURCE_DIR}/qa_data/defaults/${setup}_test.qa.root) EndIf() Set(testname mcbm_qa_event_mc_${setup}) diff --git a/macro/mcbm/mcbm_qa.C b/macro/mcbm/mcbm_qa.C index a28ed5642b9519ef83e01b7f91c863321bcf4a43..33b75bbbae0c86dcd0e4d8d2d134a1d2f366fed9 100644 --- a/macro/mcbm/mcbm_qa.C +++ b/macro/mcbm/mcbm_qa.C @@ -50,18 +50,18 @@ /* clang-format off */ /// \brief QA macro execution function -/// \param nEvents Number of events to proceed -/// \param dataset Prefix of the output files files upstream the simulation/reconstruction chain -/// \param setupName Name of the setup -/// \param bUseMC Flag for MC (simulation) usage -/// \param config QA YAML configuraiton file -/// \param defaultPath Path to a default QA output, obtained for a given setup and given number of events +/// \param nEvents Number of events to proceed +/// \param dataset Prefix of the output files files upstream the simulation/reconstruction chain +/// \param setupName Name of the setup +/// \param bUseMC Flag for MC (simulation) usage +/// \param config QA YAML configuraiton file +/// \param benchmarkInput Path to a benchmark QA output, obtained for a given setup and given number of events void mcbm_qa(Int_t nEvents = 0, TString dataset = "data/mcbm_beam_2020_03_test", TString setupName = "mcbm_beam_2020_03", Bool_t bUseMC = kTRUE, TString config = "", - TString crossCheckFile = "") + TString benchmarkInput = "") /* clang-format on */ { @@ -77,8 +77,6 @@ void mcbm_qa(Int_t nEvents = 0, int verbose = 6; // verbose level TString myName = "mcbm_qa"; // this macro's name for screen output TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory - TString qaConfig = (config.Length() ? config : srcDir + "/macro/qa/configs/qa_tasks_config_" + setupName + ".yaml"); - // NOTE: SZh 28.07.2024: config can depend from the setup // ------------------------------------------------------------------------ // ----- In- and output file names ------------------------------------ @@ -87,6 +85,8 @@ void mcbm_qa(Int_t nEvents = 0, TString parFile = dataset + ".par.root"; TString recFile = dataset + ".rec.root"; TString sinkFile = dataset + ".qa.root"; + TString qaConfig = (config.Length() ? config : srcDir + "/macro/qa/configs/qa_tasks_config_" + setupName + ".yaml"); + TString benchmarkOut = sinkFile + ".qa.benchmark.root"; // ------------------------------------------------------------------------ // ----- Load the geometry setup ------------------------------------- @@ -192,11 +192,11 @@ void mcbm_qa(Int_t nEvents = 0, // ------------------------------------------------------------------------ // ----- QA manager --------------------------------------------------- - auto* qaManager = new CbmQaManager(3); + auto* qaManager = new CbmQaManager(verbose); qaManager->SetConfigName(qaConfig); - if (crossCheckFile.Length()) { - qaManager->OpenCrossCheckFile(crossCheckFile); - qaManager->OpenCompareOutput("compareResult.root"); + if (benchmarkInput.Length()) { + qaManager->OpenBenchmarkInput(benchmarkInput); + qaManager->OpenBenchmarkOutput(benchmarkOut); qaManager->SetDefaultTag("default"); qaManager->SetVersionTag("this"); // TODO: read git SHA } diff --git a/macro/run/run_qa.C b/macro/run/run_qa.C index 2eed8d369af3f7c034dc314546e1ba3281e36916..befadd502f9d0b6666fe559f7978b3deefd220e1 100644 --- a/macro/run/run_qa.C +++ b/macro/run/run_qa.C @@ -1,6 +1,6 @@ /* Copyright (C) 2006-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Denis Bertini [committer], Florian Uhlig */ + Authors: Sergey Gorbunov, Denis Bertini [committer], Florian Uhlig, Sergei Zharko */ // -------------------------------------------------------------------------- // @@ -34,15 +34,44 @@ #include <FairRuntimeDb.h> #include <FairSystemInfo.h> +#include <TROOT.h> #include <TStopwatch.h> +#include <TString.h> + +#include <Logger> #endif void run_qa(TString data = "test", TString setup = "sis100_electron", Int_t nEvents = -1, TString dataTra2 = "", TString dataTra3 = "", TString configName = "", TString sEvBuildRaw = ""); -void run_qa(TString dataTra, TString dataRaw, TString dataReco, TString dataPar, TString dataSink, - TString setup = "sis100_electron", Int_t nEvents = -1, TString dataTra2 = "", TString dataTra3 = "", - TString configName = "", TString sEvBuildRaw = "") +/// @brief Main macro execution function +/// @param dataTraColl Collision transport input +/// @param dataRaw Digitization input +/// @param dataReco Reconstruction input +/// @param dataPar Parameter file +/// @param dataSink QA output +/// @param setup Setup name +/// @param nEvents Number of events to procede +/// @param dataTraSign Signal transport input +/// @param dataTraBeam Beam transport input +/// @param config QA configuration file input +/// @param sEvBuildRaw Event builder type ("", "Ideal", "Real") +/// @param sBenchmark Benchmark file input +/* clang-format off */ +void run_qa(TString dataTraColl, + TString dataRaw, + TString dataReco, + TString dataPar, + TString dataSink, + TString setup = "sis100_electron", + Int_t nEvents = -1, + TString dataTraSign = "", + TString dataTraBeam = "", + TString config = "", + TString sEvBuildRaw = "", + TString sBenchmark = "" + ) +/* clang-format on */ { gROOT->SetBatch(kTRUE); @@ -66,13 +95,15 @@ void run_qa(TString dataTra, TString dataRaw, TString dataReco, TString dataPar, // ------------------------------------------------------------------------ // ----- In- and output file names ------------------------------------ - TString traFile = dataTra + ".tra.root"; - TString tra2File = dataTra2 + ".tra.root"; - TString tra3File = dataTra3 + ".tra.root"; - TString rawFile = dataRaw + ".raw.root"; - TString parFile = dataPar + ".par.root"; - TString recFile = dataReco + ".reco.root"; - TString sinkFile = dataSink + ".qa.root"; + TString traFileColl = dataTraColl + ".tra.root"; + TString traFileSign = dataTraSign + ".tra.root"; + TString traFileBeam = dataTraBeam + ".tra.root"; + TString rawFile = dataRaw + ".raw.root"; + TString parFile = dataPar + ".par.root"; + TString recFile = dataReco + ".reco.root"; + TString sinkFile = dataSink + ".qa.root"; + TString benchmarkOut = dataSink + ".qa.benchmark.root"; + TString qaConfig = (config.Length() ? config : srcDir + "/macro/qa/configs/qa_tasks_config_" + setup + ".yaml"); // ------------------------------------------------------------------------ // ----- Load the geometry setup ------------------------------------- @@ -89,7 +120,7 @@ void run_qa(TString dataTra, TString dataRaw, TString dataReco, TString dataPar, // ------------------------------------------------------------------------ // ----- Some global switches ----------------------------------------- - Bool_t bEventBasedReco = !sEvBuildRaw.IsNull(); + bool bEventBasedReco = !sEvBuildRaw.IsNull(); bool bUseMvd = geo->IsActive(ECbmModuleId::kMvd); bool bUseSts = geo->IsActive(ECbmModuleId::kSts); bool bUseRich = geo->IsActive(ECbmModuleId::kRich); @@ -159,10 +190,10 @@ void run_qa(TString dataTra, TString dataRaw, TString dataReco, TString dataPar, // ----- FairRunAna --------------------------------------------------- FairFileSource* inputSource = new FairFileSource(rawFile); - inputSource->AddFriend(traFile); + inputSource->AddFriend(traFileColl); inputSource->AddFriend(recFile); - if (!dataTra2.IsNull()) inputSource->AddFriend(tra2File); - if (!dataTra3.IsNull()) inputSource->AddFriend(tra3File); + if (!dataTraSign.IsNull()) inputSource->AddFriend(traFileSign); + if (!dataTraBeam.IsNull()) inputSource->AddFriend(traFileBeam); FairRunAna* run = new FairRunAna(); run->SetSource(inputSource); @@ -175,15 +206,22 @@ void run_qa(TString dataTra, TString dataRaw, TString dataReco, TString dataPar, monitorFile.ReplaceAll("qa", "qa.monitor"); FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monitorFile); - auto* qaManager = new CbmQaManager(3); + auto* qaManager = new CbmQaManager(verbose); + qaManager->SetConfigName(qaConfig); + if (!sBenchmark.IsNull()) { + qaManager->OpenBenchmarkInput(sBenchmark); + qaManager->OpenBenchmarkOutput(benchmarkOut); + qaManager->SetDefaultTag("default"); + qaManager->SetVersionTag("this"); + } run->AddTask(qaManager); // ------------------------------------------------------------------------ // ----- MCDataManager ----------------------------------- CbmMCDataManager* mcManager = new CbmMCDataManager("MCDataManager", 0); - mcManager->AddFile(traFile); - if (!dataTra2.IsNull()) mcManager->AddFile(tra2File); - if (!dataTra3.IsNull()) mcManager->AddFile(tra3File); + mcManager->AddFile(traFileColl); + if (!dataTraSign.IsNull()) mcManager->AddFile(traFileSign); + if (!dataTraBeam.IsNull()) mcManager->AddFile(traFileBeam); qaManager->AddTask(mcManager); // ------------------------------------------------------------------------ @@ -262,9 +300,6 @@ void run_qa(TString dataTra, TString dataRaw, TString dataReco, TString dataPar, pCaOutputQa->SetProcessFullTs(!bEventBasedReco); pCaOutputQa->SetStsTrackingMode(); pCaOutputQa->ReadParameters(caParFile.Data()); - if (configName.Length() != 0) { - pCaOutputQa->SetConfigName(configName); - } pCaOutputQa->SetUseMvd(bUseMvd); pCaOutputQa->SetUseSts(bUseSts); //pCaOutputQa->SetUseMuch(bUseMuch);