Skip to content
Snippets Groups Projects

Updates in QA task IO and checker

Merged Sergei Zharko requested to merge s.zharko/cbmroot:qa-checker-update-2 into master
11 files
+ 144
286
Compare changes
  • Side-by-side
  • Inline
Files
11
@@ -22,9 +22,11 @@
#include "TH2.h"
#include "TNamed.h"
#include "TProfile.h"
#include "TROOT.h"
#include <boost/algorithm/string.hpp>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <string>
@@ -163,6 +165,15 @@ void FileHandler::Process(Option_t* opt)
if (areDifferent) { pObjHandler->CreateCanvases(); }
}
pObjHandler->Write();
// Clean memory
for (auto* pObj : vpObjects) {
if (pObj) {
delete pObj;
pObj = nullptr;
}
}
} // iObj
}
@@ -170,28 +181,9 @@ void FileHandler::Process(Option_t* opt)
//
TNamed* FileHandler::ReadObjectFromFile(TFile* pFile, const std::string& path) const
{
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); // short name of next object/directory/folder in the path
iPos = iNext + 1;
if (!part.size()) { continue; }
// test TDirectoryFile
if (dynamic_cast<TDirectoryFile*>(pObj)) {
auto* pDir = static_cast<TDirectoryFile*>(pObj);
pObj = pDir->FindObjectAny(part.data());
}
// test TFolder
else if (dynamic_cast<TFolder*>(pObj)) {
auto* pDir = static_cast<TFolder*>(pObj);
pObj = pDir->FindObjectAny(part.data());
}
}
return dynamic_cast<TNamed*>(pObj);
int iPosSlash = path.find_last_of('/') + 1;
std::string baseName = path.substr(iPosSlash, path.size());
std::string pathName = path.substr(0, iPosSlash);
if (pathName.size() > 0) { pFile->cd(pathName.c_str()); }
return dynamic_cast<TNamed*>(pFile->FindObjectAny(baseName.c_str()));
}
Loading