From 4bb23628a6e69f05cfae7f1106fa68d65d231c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 17 Sep 2025 17:21:29 +0200 Subject: [PATCH 1/7] Linter fixes --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 49 +++++++++++++++++++++------ 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index f4ea4ebdf3c..f7c7f43ddff 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -36,6 +36,8 @@ #include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include + namespace o2 { namespace delphes @@ -45,11 +47,38 @@ namespace delphes bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) { - auto ipdg = getIndexPDG(pdg); + if (!filename || filename[0] == '\0') { + LOG(info) << " --- No LUT file provided for PDG " << pdg << ". Skipping load."; + return false; + } + const auto ipdg = getIndexPDG(pdg); + LOGF(info, "Will load %s lut file ..: '%s'", getParticleName(pdg), filename); if (mLUTHeader[ipdg] && !forceReload) { std::cout << " --- LUT table for PDG " << pdg << " has been already loaded with index " << ipdg << std::endl; return false; } + if (strncmp(filename, "ccdb:", 5) == 0) { // Check if filename starts with "ccdb:" + LOG(info) << " --- LUT file source identified as CCDB."; + std::string path = std::string(filename).substr(5); // Remove "ccdb:" prefix + const std::string outPath = "/tmp/LUTs/"; + filename = Form("%s/%s/snapshot.root", outPath.c_str(), path.c_str()); + std::ifstream checkFile(filename); // Check if file already exists + if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB + LOG(info) << " --- CCDB source detected for PDG " << pdg << ": " << path; + if (!mCcdbManager) { + LOG(fatal) << " --- CCDB manager not set. Please set it before loading LUT from CCDB."; + } + std::map metadata; + mCcdbManager->getCCDBAccessor().retrieveBlob(path, outPath, metadata, 1); + // Add CCDB handling logic here if needed + LOG(info) << " --- Now retrieving LUT file from CCDB to: " << filename; + } else { // File exists, proceed to load + LOG(info) << " --- LUT file already exists: " << filename << ". Skipping download."; + checkFile.close(); + } + return loadTable(pdg, filename, forceReload); + } + mLUTHeader[ipdg] = new lutHeader_t; std::ifstream lutFile(filename, std::ifstream::binary); @@ -139,7 +168,7 @@ lutEntry_t* } } } else { - float comparisonValue = mLUTHeader[ipdg]->nchmap.log ? log10(nch) : nch; + float comparisonValue = mLUTHeader[ipdg]->nchmap.log ? std::log10(nch) : nch; if (mWhatEfficiency == 1) { if (inch > 0 && comparisonValue < mLUTHeader[ipdg]->nchmap.max) { interpolatedEff = (0.5f + fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff + (0.5f - fraction) * mLUTEntry[ipdg][inch - 1][irad][ieta][ipt]->eff; @@ -192,7 +221,7 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte double val = 0.; for (int j = 0; j < 5; ++j) val += lutEntry->eigvec[j][i] * o2track.getParam(j); - params_[i] = gRandom->Gaus(val, sqrt(lutEntry->eigval[i])); + params_[i] = gRandom->Gaus(val, std::sqrt(lutEntry->eigval[i])); } // transform back params vector for (int i = 0; i < 5; ++i) { @@ -202,7 +231,7 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte o2track.setParam(val, i); } // should make a sanity check that par[2] sin(phi) is in [-1, 1] - if (fabs(o2track.getParam(2)) > 1.) { + if (std::fabs(o2track.getParam(2)) > 1.) { std::cout << " --- smearTrack failed sin(phi) sanity check: " << o2track.getParam(2) << std::endl; } // set covariance matrix @@ -234,7 +263,7 @@ double TrackSmearer::getPtRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto val = sqrt(lutEntry->covm[14]) * lutEntry->pt; + auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt; return val; } @@ -244,8 +273,8 @@ double TrackSmearer::getEtaRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto sigmatgl = sqrt(lutEntry->covm[9]); // sigmatgl2 - auto etaRes = fabs(sin(2.0 * atan(exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty + auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 + auto etaRes = std::fabs(sin(2.0 * atan(exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty etaRes /= lutEntry->eta; // relative uncertainty return etaRes; } @@ -255,7 +284,7 @@ double TrackSmearer::getAbsPtRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto val = sqrt(lutEntry->covm[14]) * pow(lutEntry->pt, 2); + auto val = std::sqrt(lutEntry->covm[14]) * pow(lutEntry->pt, 2); return val; } @@ -265,8 +294,8 @@ double TrackSmearer::getAbsEtaRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto sigmatgl = sqrt(lutEntry->covm[9]); // sigmatgl2 - auto etaRes = fabs(sin(2.0 * atan(exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty + auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 + auto etaRes = std::fabs(sin(2.0 * atan(exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty return etaRes; } /*****************************************************************/ From 9a2451410fb6e0083a488f9a517c97977662de67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 17 Sep 2025 17:25:12 +0200 Subject: [PATCH 2/7] Refactor track smearing for Helium-3 PDG code --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index f7c7f43ddff..5abc1c038bd 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -246,8 +246,12 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch) { auto pt = o2track.getPt(); - if (abs(pdg) == 1000020030) { - pt *= 2.f; + static constexpr int kHelium3Pdg = 1000020030; + switch (pdg) { + case kHelium3Pdg: + case -kHelium3Pdg: + pt *= 2.f; + break; } auto eta = o2track.getEta(); float interpolatedEff = 0.0f; @@ -273,9 +277,9 @@ double TrackSmearer::getEtaRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 - auto etaRes = std::fabs(sin(2.0 * atan(exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty - etaRes /= lutEntry->eta; // relative uncertainty + auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 + auto etaRes = std::fabs(sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty + etaRes /= lutEntry->eta; // relative uncertainty return etaRes; } /*****************************************************************/ @@ -294,8 +298,8 @@ double TrackSmearer::getAbsEtaRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 - auto etaRes = std::fabs(sin(2.0 * atan(exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty + auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 + auto etaRes = std::fabs(sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty return etaRes; } /*****************************************************************/ From 1e346bf1253b8a6d1db8ba0075452fcdfe57d817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Wed, 17 Sep 2025 17:32:57 +0200 Subject: [PATCH 3/7] Replace std::cout with LOG for consistency --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 132 +++++++++++++++----------- 1 file changed, 76 insertions(+), 56 deletions(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index 5abc1c038bd..53e6f30ee7c 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -36,6 +36,7 @@ #include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include #include namespace o2 @@ -54,7 +55,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) const auto ipdg = getIndexPDG(pdg); LOGF(info, "Will load %s lut file ..: '%s'", getParticleName(pdg), filename); if (mLUTHeader[ipdg] && !forceReload) { - std::cout << " --- LUT table for PDG " << pdg << " has been already loaded with index " << ipdg << std::endl; + LOG(info) << " --- LUT table for PDG " << pdg << " has been already loaded with index " << ipdg << std::endl; return false; } if (strncmp(filename, "ccdb:", 5) == 0) { // Check if filename starts with "ccdb:" @@ -83,26 +84,26 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) std::ifstream lutFile(filename, std::ifstream::binary); if (!lutFile.is_open()) { - std::cout << " --- cannot open covariance matrix file for PDG " << pdg << ": " << filename << std::endl; + LOG(info) << " --- cannot open covariance matrix file for PDG " << pdg << ": " << filename << std::endl; delete mLUTHeader[ipdg]; mLUTHeader[ipdg] = nullptr; return false; } lutFile.read(reinterpret_cast(mLUTHeader[ipdg]), sizeof(lutHeader_t)); if (lutFile.gcount() != sizeof(lutHeader_t)) { - std::cout << " --- troubles reading covariance matrix header for PDG " << pdg << ": " << filename << std::endl; + LOG(info) << " --- troubles reading covariance matrix header for PDG " << pdg << ": " << filename << std::endl; delete mLUTHeader[ipdg]; mLUTHeader[ipdg] = nullptr; return false; } if (mLUTHeader[ipdg]->version != LUTCOVM_VERSION) { - std::cout << " --- LUT header version mismatch: expected/detected = " << LUTCOVM_VERSION << "/" << mLUTHeader[ipdg]->version << std::endl; + LOG(info) << " --- LUT header version mismatch: expected/detected = " << LUTCOVM_VERSION << "/" << mLUTHeader[ipdg]->version << std::endl; delete mLUTHeader[ipdg]; mLUTHeader[ipdg] = nullptr; return false; } if (mLUTHeader[ipdg]->pdg != pdg) { - std::cout << " --- LUT header PDG mismatch: expected/detected = " << pdg << "/" << mLUTHeader[ipdg]->pdg << std::endl; + LOG(info) << " --- LUT header PDG mismatch: expected/detected = " << pdg << "/" << mLUTHeader[ipdg]->pdg << std::endl; delete mLUTHeader[ipdg]; mLUTHeader[ipdg] = nullptr; return false; @@ -122,14 +123,14 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) mLUTEntry[ipdg][inch][irad][ieta][ipt] = new lutEntry_t; lutFile.read(reinterpret_cast(mLUTEntry[ipdg][inch][irad][ieta][ipt]), sizeof(lutEntry_t)); if (lutFile.gcount() != sizeof(lutEntry_t)) { - std::cout << " --- troubles reading covariance matrix entry for PDG " << pdg << ": " << filename << std::endl; + LOG(info) << " --- troubles reading covariance matrix entry for PDG " << pdg << ": " << filename << std::endl; return false; } } } } } - std::cout << " --- read covariance matrix table for PDG " << pdg << ": " << filename << std::endl; + LOG(info) << " --- read covariance matrix table for PDG " << pdg << ": " << filename << std::endl; mLUTHeader[ipdg]->print(); lutFile.close(); @@ -152,43 +153,58 @@ lutEntry_t* // Interpolate if requested auto fraction = mLUTHeader[ipdg]->nchmap.fracPositionWithinBin(nch); if (mInterpolateEfficiency) { - if (fraction > 0.5) { - if (mWhatEfficiency == 1) { - if (inch < mLUTHeader[ipdg]->nchmap.nbins - 1) { - interpolatedEff = (1.5f - fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff + (-0.5f + fraction) * mLUTEntry[ipdg][inch + 1][irad][ieta][ipt]->eff; - } else { - interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff; - } - } - if (mWhatEfficiency == 2) { - if (inch < mLUTHeader[ipdg]->nchmap.nbins - 1) { - interpolatedEff = (1.5f - fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2 + (-0.5f + fraction) * mLUTEntry[ipdg][inch + 1][irad][ieta][ipt]->eff2; - } else { - interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2; - } + static constexpr float fractionThreshold = 0.5f; + if (fraction > fractionThreshold) { + switch (mWhatEfficiency) { + case 1: + if (inch < mLUTHeader[ipdg]->nchmap.nbins - 1) { + interpolatedEff = (1.5f - fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff + (-0.5f + fraction) * mLUTEntry[ipdg][inch + 1][irad][ieta][ipt]->eff; + } else { + interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff; + } + break; + case 2: + if (inch < mLUTHeader[ipdg]->nchmap.nbins - 1) { + interpolatedEff = (1.5f - fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2 + (-0.5f + fraction) * mLUTEntry[ipdg][inch + 1][irad][ieta][ipt]->eff2; + } else { + interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2; + } + break; + default: + LOG(fatal) << " --- getLUTEntry: unknown efficiency type " << mWhatEfficiency; } } else { float comparisonValue = mLUTHeader[ipdg]->nchmap.log ? std::log10(nch) : nch; - if (mWhatEfficiency == 1) { - if (inch > 0 && comparisonValue < mLUTHeader[ipdg]->nchmap.max) { - interpolatedEff = (0.5f + fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff + (0.5f - fraction) * mLUTEntry[ipdg][inch - 1][irad][ieta][ipt]->eff; - } else { - interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff; - } - } - if (mWhatEfficiency == 2) { - if (inch > 0 && comparisonValue < mLUTHeader[ipdg]->nchmap.max) { - interpolatedEff = (0.5f + fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2 + (0.5f - fraction) * mLUTEntry[ipdg][inch - 1][irad][ieta][ipt]->eff2; - } else { - interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2; - } + switch (mWhatEfficiency) { + case 1: + if (inch > 0 && comparisonValue < mLUTHeader[ipdg]->nchmap.max) { + interpolatedEff = (0.5f + fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff + (0.5f - fraction) * mLUTEntry[ipdg][inch - 1][irad][ieta][ipt]->eff; + } else { + interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff; + } + break; + case 2: + if (inch > 0 && comparisonValue < mLUTHeader[ipdg]->nchmap.max) { + interpolatedEff = (0.5f + fraction) * mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2 + (0.5f - fraction) * mLUTEntry[ipdg][inch - 1][irad][ieta][ipt]->eff2; + } else { + interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2; + } + break; + default: + LOG(fatal) << " --- getLUTEntry: unknown efficiency type " << mWhatEfficiency; } } } else { - if (mWhatEfficiency == 1) - interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff; - if (mWhatEfficiency == 2) - interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2; + switch (mWhatEfficiency) { + case 1: + interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff; + break; + case 2: + interpolatedEff = mLUTEntry[ipdg][inch][irad][ieta][ipt]->eff2; + break; + default: + LOG(fatal) << " --- getLUTEntry: unknown efficiency type " << mWhatEfficiency; + } } return mLUTEntry[ipdg][inch][irad][ieta][ipt]; } //; @@ -201,10 +217,14 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte // generate efficiency if (mUseEfficiency) { auto eff = 0.; - if (mWhatEfficiency == 1) - eff = lutEntry->eff; - if (mWhatEfficiency == 2) - eff = lutEntry->eff2; + switch (mWhatEfficiency) { + case 1: + eff = lutEntry->eff; + break; + case 2: + eff = lutEntry->eff2; + break; + } if (mInterpolateEfficiency) eff = interpolatedEff; if (gRandom->Uniform() > eff) @@ -216,23 +236,24 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte return false; // transform params vector and smear - double params_[5]; - for (int i = 0; i < 5; ++i) { + static constexpr int kParSize = 5; + double params_[kParSize]; + for (int i = 0; i < kParSize; ++i) { double val = 0.; - for (int j = 0; j < 5; ++j) + for (int j = 0; j < kParSize; ++j) val += lutEntry->eigvec[j][i] * o2track.getParam(j); params_[i] = gRandom->Gaus(val, std::sqrt(lutEntry->eigval[i])); } // transform back params vector - for (int i = 0; i < 5; ++i) { + for (int i = 0; i < kParSize; ++i) { double val = 0.; - for (int j = 0; j < 5; ++j) + for (int j = 0; j < kParSize; ++j) val += lutEntry->eiginv[j][i] * params_[j]; o2track.setParam(val, i); } // should make a sanity check that par[2] sin(phi) is in [-1, 1] if (std::fabs(o2track.getParam(2)) > 1.) { - std::cout << " --- smearTrack failed sin(phi) sanity check: " << o2track.getParam(2) << std::endl; + LOG(info) << " --- smearTrack failed sin(phi) sanity check: " << o2track.getParam(2) << std::endl; } // set covariance matrix for (int i = 0; i < 15; ++i) @@ -246,10 +267,9 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch) { auto pt = o2track.getPt(); - static constexpr int kHelium3Pdg = 1000020030; switch (pdg) { - case kHelium3Pdg: - case -kHelium3Pdg: + case o2::constants::physics::kHelium3: + case -o2::constants::physics::kHelium3: pt *= 2.f; break; } @@ -277,9 +297,9 @@ double TrackSmearer::getEtaRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 - auto etaRes = std::fabs(sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty - etaRes /= lutEntry->eta; // relative uncertainty + auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 + auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty + etaRes /= lutEntry->eta; // relative uncertainty return etaRes; } /*****************************************************************/ @@ -298,8 +318,8 @@ double TrackSmearer::getAbsEtaRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 - auto etaRes = std::fabs(sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty + auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2 + auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty return etaRes; } /*****************************************************************/ From d49e1a23ee428e5de9a34b46ec3e2f10e335ec50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 18 Sep 2025 04:50:18 +0200 Subject: [PATCH 4/7] Fix --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index 53e6f30ee7c..c263724c991 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -10,14 +10,14 @@ // or submit itself to any jurisdiction. /// -/// @file DelphesO2TrackSmearer.cxx -/// @brief Porting to O2Physics of DelphesO2 code. +/// \file DelphesO2TrackSmearer.cxx +/// \author: Roberto Preghenella +/// \brief Porting to O2Physics of DelphesO2 code. /// Minimal changes have been made to the original code for adaptation purposes, formatting and commented parts have been considered. /// Relevant sources: /// DelphesO2/src/lutCovm.hh https://github.com/AliceO2Group/DelphesO2/blob/master/src/lutCovm.hh /// DelphesO2/src/TrackSmearer.cc https://github.com/AliceO2Group/DelphesO2/blob/master/src/TrackSmearer.cc /// DelphesO2/src/TrackSmearer.hh https://github.com/AliceO2Group/DelphesO2/blob/master/src/TrackSmearer.hh -/// @author: Roberto Preghenella /// @email: preghenella@bo.infn.it /// @@ -153,8 +153,8 @@ lutEntry_t* // Interpolate if requested auto fraction = mLUTHeader[ipdg]->nchmap.fracPositionWithinBin(nch); if (mInterpolateEfficiency) { - static constexpr float fractionThreshold = 0.5f; - if (fraction > fractionThreshold) { + static constexpr float kFractionThreshold = 0.5f; + if (fraction > kFractionThreshold) { switch (mWhatEfficiency) { case 1: if (inch < mLUTHeader[ipdg]->nchmap.nbins - 1) { @@ -237,18 +237,18 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte // transform params vector and smear static constexpr int kParSize = 5; - double params_[kParSize]; + double params[kParSize]; for (int i = 0; i < kParSize; ++i) { double val = 0.; for (int j = 0; j < kParSize; ++j) val += lutEntry->eigvec[j][i] * o2track.getParam(j); - params_[i] = gRandom->Gaus(val, std::sqrt(lutEntry->eigval[i])); + params[i] = gRandom->Gaus(val, std::sqrt(lutEntry->eigval[i])); } // transform back params vector for (int i = 0; i < kParSize; ++i) { double val = 0.; for (int j = 0; j < kParSize; ++j) - val += lutEntry->eiginv[j][i] * params_[j]; + val += lutEntry->eiginv[j][i] * params[j]; o2track.setParam(val, i); } // should make a sanity check that par[2] sin(phi) is in [-1, 1] @@ -308,7 +308,7 @@ double TrackSmearer::getAbsPtRes(int pdg, float nch, float eta, float pt) { float dummy = 0.0f; auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); - auto val = std::sqrt(lutEntry->covm[14]) * pow(lutEntry->pt, 2); + auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt * lutEntry->pt; return val; } From df534e56e4421303a5f3c318a2fbcf909df1570b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 18 Sep 2025 04:51:45 +0200 Subject: [PATCH 5/7] Update --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index c263724c991..97a8bbd7d02 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -256,7 +256,8 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte LOG(info) << " --- smearTrack failed sin(phi) sanity check: " << o2track.getParam(2) << std::endl; } // set covariance matrix - for (int i = 0; i < 15; ++i) + static constexpr int kCovMatSize = 15; + for (int i = 0; i < kCovMatSize; ++i) o2track.setCov(lutEntry->covm[i], i); return isReconstructed; } From 476e2a7db35a86b2cb938742f0eb38f7fe715a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 18 Sep 2025 04:54:02 +0200 Subject: [PATCH 6/7] Fix --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index 97a8bbd7d02..dfc04eedd14 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -11,7 +11,7 @@ /// /// \file DelphesO2TrackSmearer.cxx -/// \author: Roberto Preghenella +/// \author Roberto Preghenella /// \brief Porting to O2Physics of DelphesO2 code. /// Minimal changes have been made to the original code for adaptation purposes, formatting and commented parts have been considered. /// Relevant sources: From 228a3cfa90fd2afdf93a99d6e8d6e1787a79d616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 18 Sep 2025 05:17:35 +0200 Subject: [PATCH 7/7] Megalinter --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index dfc04eedd14..af72d0cf8b0 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -39,6 +39,9 @@ #include #include +#include +#include + namespace o2 { namespace delphes