@@ -66,6 +66,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
6666 std::string path = std::string (filename).substr (5 ); // Remove "ccdb:" prefix
6767 const std::string outPath = " /tmp/LUTs/" ;
6868 filename = Form (" %s/%s/snapshot.root" , outPath.c_str (), path.c_str ());
69+ LOG (info) << " --- Local LUT filename will be: " << filename;
6970 std::ifstream checkFile (filename); // Check if file already exists
7071 if (!checkFile.is_open ()) { // File does not exist, retrieve from CCDB
7172 LOG (info) << " --- CCDB source detected for PDG " << pdg << " : " << path;
@@ -76,6 +77,15 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
7677 mCcdbManager ->getCCDBAccessor ().retrieveBlob (path, outPath, metadata, 1 );
7778 // Add CCDB handling logic here if needed
7879 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+ }
7989 } else { // File exists, proceed to load
8090 LOG (info) << " --- LUT file already exists: " << filename << " . Skipping download." ;
8191 checkFile.close ();
@@ -153,12 +163,13 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
153163
154164/* ****************************************************************/
155165
156- lutEntry_t*
157- TrackSmearer::getLUTEntry (int pdg, float nch, float radius, float eta, float pt, float & interpolatedEff)
166+ lutEntry_t* TrackSmearer::getLUTEntry (const int pdg, const float nch, const float radius, const float eta, const float pt, float & interpolatedEff)
158167{
159- auto ipdg = getIndexPDG (pdg);
160- if (!mLUTHeader [ipdg])
168+ const int ipdg = getIndexPDG (pdg);
169+ if (!mLUTHeader [ipdg]) {
161170 return nullptr ;
171+ }
172+
162173 auto inch = mLUTHeader [ipdg]->nchmap .find (nch);
163174 auto irad = mLUTHeader [ipdg]->radmap .find (radius);
164175 auto ieta = mLUTHeader [ipdg]->etamap .find (eta);
@@ -280,7 +291,6 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte
280291
281292bool TrackSmearer::smearTrack (O2Track& o2track, int pdg, float nch)
282293{
283-
284294 auto pt = o2track.getPt ();
285295 switch (pdg) {
286296 case o2::constants::physics::kHelium3 :
@@ -290,56 +300,56 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch)
290300 }
291301 auto eta = o2track.getEta ();
292302 float interpolatedEff = 0 .0f ;
293- auto lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, interpolatedEff);
303+ lutEntry_t* lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, interpolatedEff);
294304 if (!lutEntry || !lutEntry->valid )
295305 return false ;
296306 return smearTrack (o2track, lutEntry, interpolatedEff);
297307}
298308
299309/* ****************************************************************/
300310// relative uncertainty on pt
301- double TrackSmearer::getPtRes (int pdg, float nch, float eta, float pt)
311+ double TrackSmearer::getPtRes (const int pdg, const float nch, const float eta, const float pt)
302312{
303313 float dummy = 0 .0f ;
304- auto lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
314+ lutEntry_t* lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
305315 auto val = std::sqrt (lutEntry->covm [14 ]) * lutEntry->pt ;
306316 return val;
307317}
308318
309319/* ****************************************************************/
310320// relative uncertainty on eta
311- double TrackSmearer::getEtaRes (int pdg, float nch, float eta, float pt)
321+ double TrackSmearer::getEtaRes (const int pdg, const float nch, const float eta, const float pt)
312322{
313323 float dummy = 0 .0f ;
314- auto lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
324+ lutEntry_t* lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
315325 auto sigmatgl = std::sqrt (lutEntry->covm [9 ]); // sigmatgl2
316326 auto etaRes = std::fabs (std::sin (2.0 * std::atan (std::exp (-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
317327 etaRes /= lutEntry->eta ; // relative uncertainty
318328 return etaRes;
319329}
320330/* ****************************************************************/
321331// absolute uncertainty on pt
322- double TrackSmearer::getAbsPtRes (int pdg, float nch, float eta, float pt)
332+ double TrackSmearer::getAbsPtRes (const int pdg, const float nch, const float eta, const float pt)
323333{
324334 float dummy = 0 .0f ;
325- auto lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
335+ lutEntry_t* lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
326336 auto val = std::sqrt (lutEntry->covm [14 ]) * lutEntry->pt * lutEntry->pt ;
327337 return val;
328338}
329339
330340/* ****************************************************************/
331341// absolute uncertainty on eta
332- double TrackSmearer::getAbsEtaRes (int pdg, float nch, float eta, float pt)
342+ double TrackSmearer::getAbsEtaRes (const int pdg, const float nch, const float eta, const float pt)
333343{
334344 float dummy = 0 .0f ;
335- auto lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
345+ lutEntry_t* lutEntry = getLUTEntry (pdg, nch, 0 ., eta, pt, dummy);
336346 auto sigmatgl = std::sqrt (lutEntry->covm [9 ]); // sigmatgl2
337347 auto etaRes = std::fabs (std::sin (2.0 * std::atan (std::exp (-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
338348 return etaRes;
339349}
340350/* ****************************************************************/
341351// efficiency
342- double TrackSmearer::getEfficiency (int pdg, float nch, float eta, float pt)
352+ double TrackSmearer::getEfficiency (const int pdg, const float nch, const float eta, const float pt)
343353{
344354 float efficiency = 0 .0f ;
345355 getLUTEntry (pdg, nch, 0 ., eta, pt, efficiency);
@@ -360,7 +370,7 @@ double TrackSmearer::getEfficiency(int pdg, float nch, float eta, float pt)
360370// return true;
361371
362372// #if 0
363- // auto lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
373+ // lutEntry_t* lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
364374// if (!lutEntry)
365375// return;
366376
0 commit comments