From 3b2155fb54fe93e27ae0b6033fdac39e5ee61cbb Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Tue, 26 Aug 2025 09:38:37 +0200 Subject: [PATCH 1/5] (WIP) use getforTimeStamp (not working). --- Common/Tools/TrackTuner.h | 47 +++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index 60cf377a410..f5cab4ab125 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -447,10 +447,16 @@ struct TrackTuner : o2::framework::ConfigurableGroup { return outputString; } + std::string getFullNameInputPath() { + return pathInputFile + std::string("/") + nameInputFile; + } + void getDcaGraphs() { - std::string fullNameInputFile = ""; + std::string fullNameInputFile = pathInputFile + std::string("/") + nameInputFile; + //std::string fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt; std::string fullNameFileQoverPt = ""; + TDirectoryFile* ccdb_object = nullptr; if (isInputFileFromCCDB) { /// use input correction file from CCDB @@ -458,29 +464,42 @@ struct TrackTuner : o2::framework::ConfigurableGroup { // properly init the ccdb std::string tmpDir = "."; ccdbApi.init("http://alice-ccdb.cern.ch"); + LOG(info) << "[TrackTuner] CCDB Api OK!"; - // get the DCA correction file from CCDB - if (!ccdbApi.retrieveBlob(pathInputFile.data(), tmpDir, metadata, 0, false, nameInputFile.data())) { - LOG(fatal) << "[TrackTuner] input file for DCA corrections not found on CCDB, please check the pathInputFile and nameInputFile!"; - } + //o2::ccdb::BasicCCDBManager::instance().setURL("http://alice-ccdb.cern.ch"); LOG(info) << "[Tracktuner] address to CCDB service ..."; + //o2::ccdb::BasicCCDBManager::instance().setCaching(true); + //o2::ccdb::BasicCCDBManager::instance().setLocalObjectValidityChecking(); + //o2::ccdb::BasicCCDBManager::instance().setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + //o2::ccdb::BasicCCDBManager::instance().setFatalWhenNull(false); + //LOG(info) << " [TrackTuner] CCDB service OK!"; + + // get the directory from the DCA correction file present in CCDB + + ccdb_object = o2::ccdb::BasicCCDBManager::instance().get(fullNameInputFile); + LOG(info) << " [TrackTuner] ccdb_object " << ccdb_object; // get the Q/Pt correction file from CCDB if (!ccdbApi.retrieveBlob(pathFileQoverPt.data(), tmpDir, metadata, 0, false, nameFileQoverPt.data())) { LOG(fatal) << "[TrackTuner] input file for Q/Pt corrections not found on CCDB, please check the pathFileQoverPt and nameFileQoverPt!"; } + // point to the file in the tmp local folder - fullNameInputFile = tmpDir + std::string("/") + nameInputFile; + //fullNameInputFile = tmpDir + std::string("/") + nameInputFile; fullNameFileQoverPt = tmpDir + std::string("/") + nameFileQoverPt; } else { /// use input correction file from local filesystem - fullNameInputFile = pathInputFile + std::string("/") + nameInputFile; fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt; + + /// open the input correction file + TFile* inputFile = TFile::Open(fullNameInputFile.c_str(), "READ"); + if (!inputFile) { + LOG(fatal) << "[TrackTuner] Something wrong with the local input file" << fullNameInputFile << " for dca correction. Fix it!"; + } + + ccdb_object = dynamic_cast(inputFile->Get("ccdb_object")); + } - /// open the input correction file - std::unique_ptr inputFile(TFile::Open(fullNameInputFile.c_str(), "READ")); - if (!inputFile.get()) { - LOG(fatal) << "Something wrong with the input file" << fullNameInputFile << " for dca correction. Fix it!"; - } + std::unique_ptr inputFileQoverPt(TFile::Open(fullNameFileQoverPt.c_str(), "READ")); if (!inputFileQoverPt.get() && (updateCurvature || updateCurvatureIU)) { LOG(fatal) << "Something wrong with the Q/Pt input file" << fullNameFileQoverPt << " for Q/Pt correction. Fix it!"; @@ -491,9 +510,9 @@ struct TrackTuner : o2::framework::ConfigurableGroup { if (usePvRefitCorrections) { dir = "withPvRefit"; } - TDirectory* td = dynamic_cast(inputFile->Get(dir.c_str())); + TDirectory* td = dynamic_cast(ccdb_object->Get(dir.c_str())); if (!td) { - LOG(fatal) << "TDirectory " << td << " not found in input file" << inputFile->GetName() << ". Fix it!"; + LOG(fatal) << "[TrackTuner] TDirectory " << td << " not found in ccdb_object. Fix it!"; } int inputNphiBins = nPhiBins; From 6e5cde1e67a4ef9bd6ac6816741a4b3877f7230f Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Tue, 26 Aug 2025 10:47:47 +0200 Subject: [PATCH 2/5] Fix path and use TList structure. --- Common/Tools/TrackTuner.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index f5cab4ab125..58de7759460 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -39,6 +39,7 @@ #include #include +#include #include @@ -453,10 +454,10 @@ struct TrackTuner : o2::framework::ConfigurableGroup { void getDcaGraphs() { - std::string fullNameInputFile = pathInputFile + std::string("/") + nameInputFile; + std::string fullNameInputFile = pathInputFile; // + std::string("/") + nameInputFile; //std::string fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt; std::string fullNameFileQoverPt = ""; - TDirectoryFile* ccdb_object = nullptr; + TList* ccdb_object = nullptr; if (isInputFileFromCCDB) { /// use input correction file from CCDB @@ -475,14 +476,10 @@ struct TrackTuner : o2::framework::ConfigurableGroup { // get the directory from the DCA correction file present in CCDB - ccdb_object = o2::ccdb::BasicCCDBManager::instance().get(fullNameInputFile); + ccdb_object = o2::ccdb::BasicCCDBManager::instance().get(fullNameInputFile); LOG(info) << " [TrackTuner] ccdb_object " << ccdb_object; - // get the Q/Pt correction file from CCDB - if (!ccdbApi.retrieveBlob(pathFileQoverPt.data(), tmpDir, metadata, 0, false, nameFileQoverPt.data())) { - LOG(fatal) << "[TrackTuner] input file for Q/Pt corrections not found on CCDB, please check the pathFileQoverPt and nameFileQoverPt!"; } - // point to the file in the tmp local folder //fullNameInputFile = tmpDir + std::string("/") + nameInputFile; fullNameFileQoverPt = tmpDir + std::string("/") + nameFileQoverPt; @@ -496,7 +493,8 @@ struct TrackTuner : o2::framework::ConfigurableGroup { LOG(fatal) << "[TrackTuner] Something wrong with the local input file" << fullNameInputFile << " for dca correction. Fix it!"; } - ccdb_object = dynamic_cast(inputFile->Get("ccdb_object")); + + ccdb_object = dynamic_cast(inputFile->Get("ccdb_object")); } @@ -505,14 +503,13 @@ struct TrackTuner : o2::framework::ConfigurableGroup { LOG(fatal) << "Something wrong with the Q/Pt input file" << fullNameFileQoverPt << " for Q/Pt correction. Fix it!"; } - // choose wheter to use corrections w/ PV refit or w/o it, and retrieve the proper TDirectory + // choose wheter to use corrections w/ PV refit or w/o it, and retrieve the proper TList std::string dir = "woPvRefit"; - if (usePvRefitCorrections) { - dir = "withPvRefit"; - } - TDirectory* td = dynamic_cast(ccdb_object->Get(dir.c_str())); + + TList* td = dynamic_cast(ccdb_object->FindObject(dir.c_str())); if (!td) { - LOG(fatal) << "[TrackTuner] TDirectory " << td << " not found in ccdb_object. Fix it!"; + LOG(fatal) << "[TrackTuner] TList " << td << " not found in ccdb_object. Fix it!"; + } int inputNphiBins = nPhiBins; @@ -541,7 +538,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { /// Lambda expression to get the TGraphErrors from file auto loadGraph = [&](int phiBin, const std::string& strBaseName) -> TGraphErrors* { std::string strGraphName = inputNphiBins != 0 ? fmt::format("{}_{}", strBaseName, phiBin) : strBaseName; - TObject* obj = td->Get(strGraphName.c_str()); + TObject* obj = td->FindObject(strGraphName.c_str()); if (!obj) { LOG(fatal) << "[TrackTuner] TGraphErrors not found in the Input Root file: " << strGraphName; td->ls(); From 95fc514cfd47e14b07d569ff62e7e8e51309f493 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Tue, 26 Aug 2025 12:07:15 +0200 Subject: [PATCH 3/5] Change to getFromTimeStamp for dca and q/pt. --- Common/Tools/TrackTuner.h | 71 ++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index 58de7759460..418b68125e8 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -448,16 +448,20 @@ struct TrackTuner : o2::framework::ConfigurableGroup { return outputString; } - std::string getFullNameInputPath() { + std::string getFullNameInputPath() + { return pathInputFile + std::string("/") + nameInputFile; } void getDcaGraphs() { - std::string fullNameInputFile = pathInputFile; // + std::string("/") + nameInputFile; - //std::string fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt; - std::string fullNameFileQoverPt = ""; - TList* ccdb_object = nullptr; + std::string fullNameInputFile = pathInputFile + std::string("/") + nameInputFile; + std::string fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt; + TList* ccdb_object_dca = nullptr; + TList* ccdb_object_qoverpt = nullptr; + + std::string grOneOverPtPionNameMC = "sigmaVsPtMc"; + std::string grOneOverPtPionNameData = "sigmaVsPtData"; if (isInputFileFromCCDB) { /// use input correction file from CCDB @@ -467,49 +471,41 @@ struct TrackTuner : o2::framework::ConfigurableGroup { ccdbApi.init("http://alice-ccdb.cern.ch"); LOG(info) << "[TrackTuner] CCDB Api OK!"; - //o2::ccdb::BasicCCDBManager::instance().setURL("http://alice-ccdb.cern.ch"); LOG(info) << "[Tracktuner] address to CCDB service ..."; - //o2::ccdb::BasicCCDBManager::instance().setCaching(true); - //o2::ccdb::BasicCCDBManager::instance().setLocalObjectValidityChecking(); - //o2::ccdb::BasicCCDBManager::instance().setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - //o2::ccdb::BasicCCDBManager::instance().setFatalWhenNull(false); - //LOG(info) << " [TrackTuner] CCDB service OK!"; - - // get the directory from the DCA correction file present in CCDB - - ccdb_object = o2::ccdb::BasicCCDBManager::instance().get(fullNameInputFile); - LOG(info) << " [TrackTuner] ccdb_object " << ccdb_object; + // get the TList from the DCA correction file present in CCDB + ccdb_object_dca = o2::ccdb::BasicCCDBManager::instance().get(pathInputFile); + LOG(info) << " [TrackTuner] ccdb_object_dca " << ccdb_object_dca; + // get the TList from the Q/Pt correction file from CCDB + if (updateCurvature || updateCurvatureIU) { + ccdb_object_qoverpt = o2::ccdb::BasicCCDBManager::instance().get(pathFileQoverPt); + LOG(info) << " [TrackTuner] ccdb_object_qoverpt " << ccdb_object_qoverpt; } - // point to the file in the tmp local folder - //fullNameInputFile = tmpDir + std::string("/") + nameInputFile; - fullNameFileQoverPt = tmpDir + std::string("/") + nameFileQoverPt; } else { /// use input correction file from local filesystem - fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt; - - /// open the input correction file + + /// open the input correction file - dca correction TFile* inputFile = TFile::Open(fullNameInputFile.c_str(), "READ"); if (!inputFile) { LOG(fatal) << "[TrackTuner] Something wrong with the local input file" << fullNameInputFile << " for dca correction. Fix it!"; } + ccdb_object_dca = dynamic_cast(inputFile->Get("ccdb_object")); - - ccdb_object = dynamic_cast(inputFile->Get("ccdb_object")); - - } - - std::unique_ptr inputFileQoverPt(TFile::Open(fullNameFileQoverPt.c_str(), "READ")); - if (!inputFileQoverPt.get() && (updateCurvature || updateCurvatureIU)) { - LOG(fatal) << "Something wrong with the Q/Pt input file" << fullNameFileQoverPt << " for Q/Pt correction. Fix it!"; + /// open the input correction file - q/pt correction + TFile* inputFileQoverPt = TFile::Open(fullNameFileQoverPt.c_str(), "READ"); + if (!inputFileQoverPt && (updateCurvature || updateCurvatureIU)) { + LOG(fatal) << "Something wrong with the Q/Pt input file" << fullNameFileQoverPt << " for Q/Pt correction. Fix it!"; + } + ccdb_object_qoverpt = dynamic_cast(inputFileQoverPt->Get("ccdb_object")); } // choose wheter to use corrections w/ PV refit or w/o it, and retrieve the proper TList std::string dir = "woPvRefit"; - - TList* td = dynamic_cast(ccdb_object->FindObject(dir.c_str())); + if (usePvRefitCorrections) { + dir = "withPvRefit"; + } + TList* td = dynamic_cast(ccdb_object_dca->FindObject(dir.c_str())); if (!td) { - LOG(fatal) << "[TrackTuner] TList " << td << " not found in ccdb_object. Fix it!"; - + LOG(fatal) << "[TrackTuner] TList " << td << " not found in ccdb_object_dca. Fix it!"; } int inputNphiBins = nPhiBins; @@ -580,12 +576,9 @@ struct TrackTuner : o2::framework::ConfigurableGroup { } } - std::string grOneOverPtPionNameMC = "sigmaVsPtMc"; - std::string grOneOverPtPionNameData = "sigmaVsPtData"; - if (updateCurvature || updateCurvatureIU) { - grOneOverPtPionMC.reset(dynamic_cast(inputFileQoverPt->Get(grOneOverPtPionNameMC.c_str()))); - grOneOverPtPionData.reset(dynamic_cast(inputFileQoverPt->Get(grOneOverPtPionNameData.c_str()))); + grOneOverPtPionMC.reset(dynamic_cast(ccdb_object_qoverpt->FindObject(grOneOverPtPionNameMC.c_str()))); + grOneOverPtPionData.reset(dynamic_cast(ccdb_object_qoverpt->FindObject(grOneOverPtPionNameData.c_str()))); } } // getDcaGraphs() ends here From 8cc1e0ed8d5c488cfb87fcb4322007a2494dae45 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Tue, 26 Aug 2025 14:08:14 +0200 Subject: [PATCH 4/5] Remove unused ccdbApi. --- Common/Tools/TrackTuner.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index 418b68125e8..ce9841e2952 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -105,7 +105,6 @@ struct TrackTuner : o2::framework::ConfigurableGroup { bool isConfigFromConfigurables = false; int nPhiBins = 1; - o2::ccdb::CcdbApi ccdbApi; std::map metadata; std::vector> grDcaXYResVsPtPionMC; @@ -466,11 +465,6 @@ struct TrackTuner : o2::framework::ConfigurableGroup { if (isInputFileFromCCDB) { /// use input correction file from CCDB - // properly init the ccdb - std::string tmpDir = "."; - ccdbApi.init("http://alice-ccdb.cern.ch"); - LOG(info) << "[TrackTuner] CCDB Api OK!"; - // get the TList from the DCA correction file present in CCDB ccdb_object_dca = o2::ccdb::BasicCCDBManager::instance().get(pathInputFile); LOG(info) << " [TrackTuner] ccdb_object_dca " << ccdb_object_dca; From cd547a264fa3e3da775cacb07bf901daa9529bb8 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Wed, 27 Aug 2025 10:44:45 +0200 Subject: [PATCH 5/5] Remove unused function. --- Common/Tools/TrackTuner.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index ce9841e2952..ca7ae6c5eb5 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -447,11 +447,6 @@ struct TrackTuner : o2::framework::ConfigurableGroup { return outputString; } - std::string getFullNameInputPath() - { - return pathInputFile + std::string("/") + nameInputFile; - } - void getDcaGraphs() { std::string fullNameInputFile = pathInputFile + std::string("/") + nameInputFile;