From 9c17ea1f4fab7be2de659c1b0ee9d45394639b7a Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Wed, 8 Mar 2023 23:06:28 +0100 Subject: [PATCH] QA-Checker: fixes --- core/qa/checker/CbmQaCheckerCore.cxx | 3 +- core/qa/checker/CbmQaCheckerCore.h | 6 ++-- core/qa/checker/CbmQaCheckerFileHandler.cxx | 3 +- core/qa/checker/CbmQaCheckerFileHandler.h | 4 +-- core/qa/checker/CbmQaCheckerObjectDB.cxx | 4 ++- core/qa/checker/CbmQaCheckerObjectDB.h | 36 +++------------------ macro/qa/CMakeLists.txt | 6 ++-- macro/qa/qa_compare.C | 6 ++-- 8 files changed, 22 insertions(+), 46 deletions(-) diff --git a/core/qa/checker/CbmQaCheckerCore.cxx b/core/qa/checker/CbmQaCheckerCore.cxx index 7af9029e32..17eff8f3a4 100644 --- a/core/qa/checker/CbmQaCheckerCore.cxx +++ b/core/qa/checker/CbmQaCheckerCore.cxx @@ -14,12 +14,11 @@ #include "Logger.h" #include "TClonesArray.h" +#include "TFile.h" #include "TFolder.h" //#include <boost/filesystem.hpp> #include <regex> -#include <yaml-cpp/yaml.h> - using cbm::qa::checker::Core; // --------------------------------------------------------------------------------------------------------------------- diff --git a/core/qa/checker/CbmQaCheckerCore.h b/core/qa/checker/CbmQaCheckerCore.h index e44233d276..bb7c73981b 100644 --- a/core/qa/checker/CbmQaCheckerCore.h +++ b/core/qa/checker/CbmQaCheckerCore.h @@ -13,14 +13,14 @@ #include "CbmQaCheckerObjectDB.h" #include "CbmQaCheckerTypedefs.h" -#include "TFile.h" +#include "Rtypes.h" -#include <bitset> #include <memory> #include <string> -#include <unordered_map> #include <vector> +class TFile; + namespace cbm::qa::checker { /// @brief Core class for CBM QA checker framework (declaration) diff --git a/core/qa/checker/CbmQaCheckerFileHandler.cxx b/core/qa/checker/CbmQaCheckerFileHandler.cxx index a28a8c99f1..75c8d0cd97 100644 --- a/core/qa/checker/CbmQaCheckerFileHandler.cxx +++ b/core/qa/checker/CbmQaCheckerFileHandler.cxx @@ -173,11 +173,12 @@ TNamed* FileHandler::ReadObjectFromFile(TFile* pFile, const std::string& path) c TObject* pObj = pFile; size_t iPos = 0; // Index of first symbol size_t iNext = 0; // Index of last symbol + // Read object iteratively, running throug directories or folders, provided by path while (iPos < path.size()) { // get name iNext = path.find_first_of('/', iPos); if (iNext > path.size()) { iNext = path.size(); } - std::string part = path.substr(iPos, iNext - iPos); + std::string part = path.substr(iPos, iNext - iPos); // short name of next object/directory/folder in the path iPos = iNext + 1; if (!part.size()) { continue; } diff --git a/core/qa/checker/CbmQaCheckerFileHandler.h b/core/qa/checker/CbmQaCheckerFileHandler.h index 0557ad3206..7f5e0ce862 100644 --- a/core/qa/checker/CbmQaCheckerFileHandler.h +++ b/core/qa/checker/CbmQaCheckerFileHandler.h @@ -19,7 +19,7 @@ #include <vector> class TNamed; -class TFolder; +class TDirectory; class TFile; namespace cbm::qa::checker @@ -72,7 +72,7 @@ namespace cbm::qa::checker /// @return Pointer to created TDirectory object TDirectory* CreateNestedDirectory(const std::string& path); - /// @brief Reads object from file by the provided full path to the object. + /// @brief Iteratively reads object from file by the provided full path to the object /// @param pFile Pointer to TFile instance /// @param path Full path to the object inside the file /// @return A pointer to TNamed object diff --git a/core/qa/checker/CbmQaCheckerObjectDB.cxx b/core/qa/checker/CbmQaCheckerObjectDB.cxx index 99e03d9430..582c06ab67 100644 --- a/core/qa/checker/CbmQaCheckerObjectDB.cxx +++ b/core/qa/checker/CbmQaCheckerObjectDB.cxx @@ -15,6 +15,8 @@ #include <regex> #include <sstream> +#include <yaml-cpp/yaml.h> + using cbm::qa::checker::ObjectDB; // --------------------------------------------------------------------------------------------------------------------- @@ -224,7 +226,7 @@ void ObjectDB::ReadFromYAML(const char* configName) std::string ObjectDB::ToString() const { std::stringstream msg; - msg << "*** CBM QA-Checker: defied files ****\n\n"; + msg << "*** CBM QA-Checker: defined files ****\n\n"; msg << "----- Versions:\n"; for (size_t iV = 0; iV < fvVersionLabels.size(); ++iV) { diff --git a/core/qa/checker/CbmQaCheckerObjectDB.h b/core/qa/checker/CbmQaCheckerObjectDB.h index 49eea504b9..23619482c7 100644 --- a/core/qa/checker/CbmQaCheckerObjectDB.h +++ b/core/qa/checker/CbmQaCheckerObjectDB.h @@ -12,23 +12,10 @@ #include "CbmQaCheckerTypedefs.h" -#include "Logger.h" - #include <string> #include <utility> #include <vector> -#include <yaml-cpp/yaml.h> - -// TMP -#include <boost/core/demangle.hpp> - -#include <typeinfo> -template<typename T> -std::string type_str() -{ - return boost::core::demangle(typeid(T).name()); -} namespace cbm::qa::checker { @@ -70,27 +57,18 @@ namespace cbm::qa::checker /// @brief Gets name of dataset /// @param iDataset Index of dataset /// @return Name of dataset - const auto& GetDataset(int iDataset) const { return fvDatasets[iDataset]; } - - /// @brief Gets reference to dataset name array - const auto& GetDatasets() const { return fvDatasets; } + const std::string& GetDataset(int iDataset) const { return fvDatasets[iDataset]; } /// @brief Gets index of default version /// @return Index of default version int GetDefaultID() const { return fDefVersionID; } - /// @brief Gets label of the default version - const std::string& GetDefaultLabel() const - { - assert(fDefVersionID > -1); - return GetVersionLabel(fDefVersionID); - } - /// @brief Gets label of file /// @param iFile Index of file /// @return Label of file - const auto& GetFileLabel(int iFile) const { return fvFileLabels[iFile]; } + const std::string& GetFileLabel(int iFile) const { return fvFileLabels[iFile]; } + private: /// @brief Gets iterator range for object names stored in a file /// @note The iterator_range object behaves itself just like an ordinary STL container. /// @param iFile Index of file @@ -105,9 +83,11 @@ namespace cbm::qa::checker int iBegin = itBegin - fvGlobalToFileObject.begin(); int iEnd = itEnd - fvGlobalToFileObject.begin(); + return boost::make_iterator_range(fvObjects.begin() + iBegin, fvObjects.begin() + iEnd); } + public: /// @brief Gets comparison result /// @param iDS Index of dataset /// @param iFile Index of file @@ -154,16 +134,10 @@ namespace cbm::qa::checker /// @param iVersion Index of version const std::string& GetVersionLabel(int iVersion) const { return fvVersionLabels[iVersion]; } - /// @brief Gets reference to version label array - const auto& GetVersionLabels() const { return fvVersionLabels; } - /// @brief Gets version path /// @param iVersion Index of version const std::string& GetVersionPath(int iVersion) const { return fvVersionPaths[iVersion]; } - /// @brief Gets reference to version path array - const auto& GetVersionPaths() const { return fvVersionPaths; } - /// @brief Initializes the database void Init(); diff --git a/macro/qa/CMakeLists.txt b/macro/qa/CMakeLists.txt index ae6a55dd28..a08bf9ad7d 100644 --- a/macro/qa/CMakeLists.txt +++ b/macro/qa/CMakeLists.txt @@ -49,11 +49,11 @@ endif() # ===== Cleanup the data directory ======================================= -add_test(run_cleanup ${CMAKE_COMMAND} +add_test(qa_cleanup ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/scripts/cleanmacrodir.cmake) -set_tests_properties(run_cleanup PROPERTIES +set_tests_properties(qa_cleanup PROPERTIES TIMEOUT ${timeOutTime} - FIXTURES_SETUP run_cleanup + FIXTURES_SETUP qa_cleanup ) # ============================================================================ diff --git a/macro/qa/qa_compare.C b/macro/qa/qa_compare.C index 8006515495..ee32e588d9 100644 --- a/macro/qa/qa_compare.C +++ b/macro/qa/qa_compare.C @@ -23,9 +23,9 @@ int qa_compare( const char* configName = "objects.yaml", const char* datasetName = "s100e", - const char* oldVersionInputDir = "../run/data", // NOTE: Files from external repository - const char* newVersionInputDir = "../run/data", // NOTE: Files from preceding fixture - const char* outputName = "QACheckerOutput.h" // TODO: Add tag of a merge request or commit + const char* oldVersionInputDir = "../run/data", // NOTE: Files from external repository + const char* newVersionInputDir = "../run/data", // NOTE: Files from preceding fixture + const char* outputName = "QACheckerOutput.root" // TODO: Add tag of a merge request or commit ) /* clang-format on */ { -- GitLab