Skip to content

Commit 4202972

Browse files
mfagginMattia Faggin
andauthored
[Common] move from retrieveBlob to getFromtimeStamp for TrackTuner inputs (#12748)
Co-authored-by: Mattia Faggin <mfaggin@cern.ch>
1 parent 5934471 commit 4202972

File tree

1 file changed

+35
-37
lines changed

1 file changed

+35
-37
lines changed

Common/Tools/TrackTuner.h

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <ReconstructionDataFormats/Track.h>
4040

4141
#include <TGraphErrors.h>
42+
#include <TList.h>
4243

4344
#include <fmt/core.h>
4445

@@ -104,7 +105,6 @@ struct TrackTuner : o2::framework::ConfigurableGroup {
104105
bool isConfigFromConfigurables = false;
105106
int nPhiBins = 1;
106107

107-
o2::ccdb::CcdbApi ccdbApi;
108108
std::map<std::string, std::string> metadata;
109109

110110
std::vector<std::unique_ptr<TGraphErrors>> grDcaXYResVsPtPionMC;
@@ -449,51 +449,52 @@ struct TrackTuner : o2::framework::ConfigurableGroup {
449449

450450
void getDcaGraphs()
451451
{
452-
std::string fullNameInputFile = "";
453-
std::string fullNameFileQoverPt = "";
452+
std::string fullNameInputFile = pathInputFile + std::string("/") + nameInputFile;
453+
std::string fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt;
454+
TList* ccdb_object_dca = nullptr;
455+
TList* ccdb_object_qoverpt = nullptr;
456+
457+
std::string grOneOverPtPionNameMC = "sigmaVsPtMc";
458+
std::string grOneOverPtPionNameData = "sigmaVsPtData";
454459

455460
if (isInputFileFromCCDB) {
456461
/// use input correction file from CCDB
457462

458-
// properly init the ccdb
459-
std::string tmpDir = ".";
460-
ccdbApi.init("http://alice-ccdb.cern.ch");
463+
// get the TList from the DCA correction file present in CCDB
464+
ccdb_object_dca = o2::ccdb::BasicCCDBManager::instance().get<TList>(pathInputFile);
465+
LOG(info) << " [TrackTuner] ccdb_object_dca " << ccdb_object_dca;
461466

462-
// get the DCA correction file from CCDB
463-
if (!ccdbApi.retrieveBlob(pathInputFile.data(), tmpDir, metadata, 0, false, nameInputFile.data())) {
464-
LOG(fatal) << "[TrackTuner] input file for DCA corrections not found on CCDB, please check the pathInputFile and nameInputFile!";
467+
// get the TList from the Q/Pt correction file from CCDB
468+
if (updateCurvature || updateCurvatureIU) {
469+
ccdb_object_qoverpt = o2::ccdb::BasicCCDBManager::instance().get<TList>(pathFileQoverPt);
470+
LOG(info) << " [TrackTuner] ccdb_object_qoverpt " << ccdb_object_qoverpt;
465471
}
466-
467-
// get the Q/Pt correction file from CCDB
468-
if (!ccdbApi.retrieveBlob(pathFileQoverPt.data(), tmpDir, metadata, 0, false, nameFileQoverPt.data())) {
469-
LOG(fatal) << "[TrackTuner] input file for Q/Pt corrections not found on CCDB, please check the pathFileQoverPt and nameFileQoverPt!";
470-
}
471-
// point to the file in the tmp local folder
472-
fullNameInputFile = tmpDir + std::string("/") + nameInputFile;
473-
fullNameFileQoverPt = tmpDir + std::string("/") + nameFileQoverPt;
474472
} else {
475473
/// use input correction file from local filesystem
476-
fullNameInputFile = pathInputFile + std::string("/") + nameInputFile;
477-
fullNameFileQoverPt = pathFileQoverPt + std::string("/") + nameFileQoverPt;
478-
}
479-
/// open the input correction file
480-
std::unique_ptr<TFile> inputFile(TFile::Open(fullNameInputFile.c_str(), "READ"));
481-
if (!inputFile.get()) {
482-
LOG(fatal) << "Something wrong with the input file" << fullNameInputFile << " for dca correction. Fix it!";
483-
}
484-
std::unique_ptr<TFile> inputFileQoverPt(TFile::Open(fullNameFileQoverPt.c_str(), "READ"));
485-
if (!inputFileQoverPt.get() && (updateCurvature || updateCurvatureIU)) {
486-
LOG(fatal) << "Something wrong with the Q/Pt input file" << fullNameFileQoverPt << " for Q/Pt correction. Fix it!";
474+
475+
/// open the input correction file - dca correction
476+
TFile* inputFile = TFile::Open(fullNameInputFile.c_str(), "READ");
477+
if (!inputFile) {
478+
LOG(fatal) << "[TrackTuner] Something wrong with the local input file" << fullNameInputFile << " for dca correction. Fix it!";
479+
}
480+
ccdb_object_dca = dynamic_cast<TList*>(inputFile->Get("ccdb_object"));
481+
482+
/// open the input correction file - q/pt correction
483+
TFile* inputFileQoverPt = TFile::Open(fullNameFileQoverPt.c_str(), "READ");
484+
if (!inputFileQoverPt && (updateCurvature || updateCurvatureIU)) {
485+
LOG(fatal) << "Something wrong with the Q/Pt input file" << fullNameFileQoverPt << " for Q/Pt correction. Fix it!";
486+
}
487+
ccdb_object_qoverpt = dynamic_cast<TList*>(inputFileQoverPt->Get("ccdb_object"));
487488
}
488489

489-
// choose wheter to use corrections w/ PV refit or w/o it, and retrieve the proper TDirectory
490+
// choose wheter to use corrections w/ PV refit or w/o it, and retrieve the proper TList
490491
std::string dir = "woPvRefit";
491492
if (usePvRefitCorrections) {
492493
dir = "withPvRefit";
493494
}
494-
TDirectory* td = dynamic_cast<TDirectory*>(inputFile->Get(dir.c_str()));
495+
TList* td = dynamic_cast<TList*>(ccdb_object_dca->FindObject(dir.c_str()));
495496
if (!td) {
496-
LOG(fatal) << "TDirectory " << td << " not found in input file" << inputFile->GetName() << ". Fix it!";
497+
LOG(fatal) << "[TrackTuner] TList " << td << " not found in ccdb_object_dca. Fix it!";
497498
}
498499

499500
int inputNphiBins = nPhiBins;
@@ -522,7 +523,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup {
522523
/// Lambda expression to get the TGraphErrors from file
523524
auto loadGraph = [&](int phiBin, const std::string& strBaseName) -> TGraphErrors* {
524525
std::string strGraphName = inputNphiBins != 0 ? fmt::format("{}_{}", strBaseName, phiBin) : strBaseName;
525-
TObject* obj = td->Get(strGraphName.c_str());
526+
TObject* obj = td->FindObject(strGraphName.c_str());
526527
if (!obj) {
527528
LOG(fatal) << "[TrackTuner] TGraphErrors not found in the Input Root file: " << strGraphName;
528529
td->ls();
@@ -564,12 +565,9 @@ struct TrackTuner : o2::framework::ConfigurableGroup {
564565
}
565566
}
566567

567-
std::string grOneOverPtPionNameMC = "sigmaVsPtMc";
568-
std::string grOneOverPtPionNameData = "sigmaVsPtData";
569-
570568
if (updateCurvature || updateCurvatureIU) {
571-
grOneOverPtPionMC.reset(dynamic_cast<TGraphErrors*>(inputFileQoverPt->Get(grOneOverPtPionNameMC.c_str())));
572-
grOneOverPtPionData.reset(dynamic_cast<TGraphErrors*>(inputFileQoverPt->Get(grOneOverPtPionNameData.c_str())));
569+
grOneOverPtPionMC.reset(dynamic_cast<TGraphErrors*>(ccdb_object_qoverpt->FindObject(grOneOverPtPionNameMC.c_str())));
570+
grOneOverPtPionData.reset(dynamic_cast<TGraphErrors*>(ccdb_object_qoverpt->FindObject(grOneOverPtPionNameData.c_str())));
573571
}
574572
} // getDcaGraphs() ends here
575573

0 commit comments

Comments
 (0)