diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index 60cf377a410..ca7ae6c5eb5 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -39,6 +39,7 @@ #include #include +#include #include @@ -104,7 +105,6 @@ struct TrackTuner : o2::framework::ConfigurableGroup { bool isConfigFromConfigurables = false; int nPhiBins = 1; - o2::ccdb::CcdbApi ccdbApi; std::map metadata; std::vector> grDcaXYResVsPtPionMC; @@ -449,51 +449,52 @@ struct TrackTuner : o2::framework::ConfigurableGroup { void getDcaGraphs() { - std::string fullNameInputFile = ""; - std::string fullNameFileQoverPt = ""; + 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 - // properly init the ccdb - std::string tmpDir = "."; - ccdbApi.init("http://alice-ccdb.cern.ch"); + // 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 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!"; + // 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; } - - // 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; } else { /// use input correction file from local filesystem - fullNameInputFile = pathInputFile + std::string("/") + nameInputFile; - fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt; - } - /// 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!"; + + /// 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")); + + /// 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 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(inputFile->Get(dir.c_str())); + TList* td = dynamic_cast(ccdb_object_dca->FindObject(dir.c_str())); if (!td) { - LOG(fatal) << "TDirectory " << td << " not found in input file" << inputFile->GetName() << ". Fix it!"; + LOG(fatal) << "[TrackTuner] TList " << td << " not found in ccdb_object_dca. Fix it!"; } int inputNphiBins = nPhiBins; @@ -522,7 +523,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(); @@ -564,12 +565,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