|
39 | 39 | #include <ReconstructionDataFormats/Track.h> |
40 | 40 |
|
41 | 41 | #include <TGraphErrors.h> |
| 42 | +#include <TList.h> |
42 | 43 |
|
43 | 44 | #include <fmt/core.h> |
44 | 45 |
|
@@ -104,7 +105,6 @@ struct TrackTuner : o2::framework::ConfigurableGroup { |
104 | 105 | bool isConfigFromConfigurables = false; |
105 | 106 | int nPhiBins = 1; |
106 | 107 |
|
107 | | - o2::ccdb::CcdbApi ccdbApi; |
108 | 108 | std::map<std::string, std::string> metadata; |
109 | 109 |
|
110 | 110 | std::vector<std::unique_ptr<TGraphErrors>> grDcaXYResVsPtPionMC; |
@@ -449,51 +449,52 @@ struct TrackTuner : o2::framework::ConfigurableGroup { |
449 | 449 |
|
450 | 450 | void getDcaGraphs() |
451 | 451 | { |
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"; |
454 | 459 |
|
455 | 460 | if (isInputFileFromCCDB) { |
456 | 461 | /// use input correction file from CCDB |
457 | 462 |
|
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; |
461 | 466 |
|
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; |
465 | 471 | } |
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; |
474 | 472 | } else { |
475 | 473 | /// 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")); |
487 | 488 | } |
488 | 489 |
|
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 |
490 | 491 | std::string dir = "woPvRefit"; |
491 | 492 | if (usePvRefitCorrections) { |
492 | 493 | dir = "withPvRefit"; |
493 | 494 | } |
494 | | - TDirectory* td = dynamic_cast<TDirectory*>(inputFile->Get(dir.c_str())); |
| 495 | + TList* td = dynamic_cast<TList*>(ccdb_object_dca->FindObject(dir.c_str())); |
495 | 496 | 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!"; |
497 | 498 | } |
498 | 499 |
|
499 | 500 | int inputNphiBins = nPhiBins; |
@@ -522,7 +523,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { |
522 | 523 | /// Lambda expression to get the TGraphErrors from file |
523 | 524 | auto loadGraph = [&](int phiBin, const std::string& strBaseName) -> TGraphErrors* { |
524 | 525 | 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()); |
526 | 527 | if (!obj) { |
527 | 528 | LOG(fatal) << "[TrackTuner] TGraphErrors not found in the Input Root file: " << strGraphName; |
528 | 529 | td->ls(); |
@@ -564,12 +565,9 @@ struct TrackTuner : o2::framework::ConfigurableGroup { |
564 | 565 | } |
565 | 566 | } |
566 | 567 |
|
567 | | - std::string grOneOverPtPionNameMC = "sigmaVsPtMc"; |
568 | | - std::string grOneOverPtPionNameData = "sigmaVsPtData"; |
569 | | - |
570 | 568 | 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()))); |
573 | 571 | } |
574 | 572 | } // getDcaGraphs() ends here |
575 | 573 |
|
|
0 commit comments