2828// / @author: Roberto Preghenella
2929// / @email: preghenella@bo.infn.it
3030
31- // #include "TrackSmearer.hh"
32- // #include "TrackUtils.hh"
33- // #include "TRandom.h"
34- // #include <iostream>
35- // #include <fstream>
36-
3731#include " ALICE3/Core/DelphesO2TrackSmearer.h"
3832
33+ #include " ALICE3/Core/GeometryContainer.h"
34+
3935#include < CommonConstants/PhysicsConstants.h>
4036#include < Framework/Logger.h>
4137
42- #include < map>
38+ #include < TRandom.h>
39+
40+ #include < cmath>
41+ #include < fstream>
42+ #include < ostream>
4343#include < string>
4444
4545namespace o2
@@ -61,50 +61,21 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
6161 LOG (info) << " --- LUT table for PDG " << pdg << " has been already loaded with index " << ipdg << std::endl;
6262 return false ;
6363 }
64- if (strncmp (filename, " ccdb:" , 5 ) == 0 ) { // Check if filename starts with "ccdb:"
65- LOG (info) << " --- LUT file source identified as CCDB." ;
66- std::string path = std::string (filename).substr (5 ); // Remove "ccdb:" prefix
67- const std::string outPath = " /tmp/LUTs/" ;
68- filename = Form (" %s/%s/snapshot.root" , outPath.c_str (), path.c_str ());
69- LOG (info) << " --- Local LUT filename will be: " << filename;
70- std::ifstream checkFile (filename); // Check if file already exists
71- if (!checkFile.is_open ()) { // File does not exist, retrieve from CCDB
72- LOG (info) << " --- CCDB source detected for PDG " << pdg << " : " << path;
73- if (!mCcdbManager ) {
74- LOG (fatal) << " --- CCDB manager not set. Please set it before loading LUT from CCDB." ;
75- }
76- std::map<std::string, std::string> metadata;
77- mCcdbManager ->getCCDBAccessor ().retrieveBlob (path, outPath, metadata, 1 );
78- // Add CCDB handling logic here if needed
79- LOG (info) << " --- Now retrieving LUT file from CCDB to: " << filename;
80- if (mCleanupDownloadedFile ) { // Clean up the downloaded file if needed
81- bool status = loadTable (pdg, filename, forceReload);
82- if (std::remove (filename) != 0 ) {
83- LOG (warn) << " --- Could not remove temporary LUT file: " << filename;
84- } else {
85- LOG (info) << " --- Removed temporary LUT file: " << filename;
86- }
87- return status;
88- }
89- } else { // File exists, proceed to load
90- LOG (info) << " --- LUT file already exists: " << filename << " . Skipping download." ;
91- checkFile.close ();
92- }
93- return loadTable (pdg, filename, forceReload);
94- }
9564
65+ const std::string localFilename = o2::fastsim::GeometryEntry::accessFile (filename, " ./.ALICE3/LUTs/" , mCcdbManager , 10 );
9666 mLUTHeader [ipdg] = new lutHeader_t;
9767
98- std::ifstream lutFile (filename , std::ifstream::binary);
68+ std::ifstream lutFile (localFilename , std::ifstream::binary);
9969 if (!lutFile.is_open ()) {
100- LOG (info) << " --- cannot open covariance matrix file for PDG " << pdg << " : " << filename << std::endl;
70+ LOG (info) << " --- cannot open covariance matrix file for PDG " << pdg << " : " << localFilename << std::endl;
10171 delete mLUTHeader [ipdg];
10272 mLUTHeader [ipdg] = nullptr ;
10373 return false ;
10474 }
10575 lutFile.read (reinterpret_cast <char *>(mLUTHeader [ipdg]), sizeof (lutHeader_t));
10676 if (lutFile.gcount () != sizeof (lutHeader_t)) {
10777 LOG (info) << " --- troubles reading covariance matrix header for PDG " << pdg << " : " << filename << std::endl;
78+ LOG (info) << " --- expected/detected " << sizeof (lutHeader_t) << " /" << lutFile.gcount () << std::endl;
10879 delete mLUTHeader [ipdg];
10980 mLUTHeader [ipdg] = nullptr ;
11081 return false ;
@@ -147,7 +118,8 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
147118 mLUTEntry [ipdg][inch][irad][ieta][ipt] = new lutEntry_t;
148119 lutFile.read (reinterpret_cast <char *>(mLUTEntry [ipdg][inch][irad][ieta][ipt]), sizeof (lutEntry_t));
149120 if (lutFile.gcount () != sizeof (lutEntry_t)) {
150- LOG (info) << " --- troubles reading covariance matrix entry for PDG " << pdg << " : " << filename << std::endl;
121+ LOG (info) << " --- troubles reading covariance matrix entry for PDG " << pdg << " : " << localFilename << std::endl;
122+ LOG (info) << " --- expected/detected " << sizeof (lutHeader_t) << " /" << lutFile.gcount () << std::endl;
151123 return false ;
152124 }
153125 }
0 commit comments