From b76bdaf70731152b1fdacbcb8d53269f98d087b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 24 Feb 2026 21:22:54 +0100 Subject: [PATCH 1/6] [ALICE3] make the LUT collection writeable to file --- ALICE3/Core/DelphesO2TrackSmearer.h | 310 ++++++++++------------------ 1 file changed, 113 insertions(+), 197 deletions(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.h b/ALICE3/Core/DelphesO2TrackSmearer.h index afb0c7690cf..71defed1a14 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.h +++ b/ALICE3/Core/DelphesO2TrackSmearer.h @@ -12,7 +12,6 @@ /// /// @file DelphesO2TrackSmearer.h /// @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 @@ -29,155 +28,127 @@ #include -#include #include -#include #include #include -/////////////////////////////// -/// DelphesO2/src/lutCovm.hh // -/////////////////////////////// - -/// @author: Roberto Preghenella -/// @email: preghenella@bo.infn.it - -// #pragma // once -#define LUTCOVM_VERSION 20210801 - -struct map_t { - int nbins = 1; - float min = 0.; - float max = 1.e6; - bool log = false; - float eval(int bin) - { - float width = (max - min) / nbins; - float val = min + (bin + 0.5) * width; - if (log) - return pow(10., val); - return val; - } - // function needed to interpolate some dimensions - float fracPositionWithinBin(float val) - { - float width = (max - min) / nbins; - int bin; - float returnVal = 0.5f; - if (log) { - bin = static_cast((log10(val) - min) / width); - returnVal = ((log10(val) - min) / width) - bin; - } else { - bin = static_cast((val - min) / width); - returnVal = val / width - bin; - } - return returnVal; - } - - int find(float val) - { - float width = (max - min) / nbins; - int bin; - if (log) - bin = static_cast((log10(val) - min) / width); // Changed due to MegaLinter error. - // bin = (int)((log10(val) - min) / width); // Original line. - else - bin = static_cast((val - min) / width); // Changed due to MegaLinter error. - // bin = (int)((val - min) / width); // Original line. - if (bin < 0) - return 0; - if (bin > nbins - 1) - return nbins - 1; - return bin; - } //; - void print() { printf("nbins = %d, min = %f, max = %f, log = %s \n", nbins, min, max, log ? "on" : "off"); } //; -}; - -struct lutHeader_t { - int version = LUTCOVM_VERSION; - int pdg = 0; - float mass = 0.; - float field = 0.; - map_t nchmap; - map_t radmap; - map_t etamap; - map_t ptmap; - bool check_version() - { - return (version == LUTCOVM_VERSION); - } //; - void print() - { - printf(" version: %d \n", version); - printf(" pdg: %d \n", pdg); - printf(" field: %f \n", field); - printf(" nchmap: "); - nchmap.print(); - printf(" radmap: "); - radmap.print(); - printf(" etamap: "); - etamap.print(); - printf(" ptmap: "); - ptmap.print(); - } //; -}; - -struct lutEntry_t { - float nch = 0.; - float eta = 0.; - float pt = 0.; - bool valid = false; - float eff = 0.; - float eff2 = 0.; - float itof = 0.; - float otof = 0.; - float covm[15] = {0.}; - float eigval[5] = {0.}; - float eigvec[5][5] = {{0.}}; - float eiginv[5][5] = {{0.}}; - void print() - { - printf(" --- lutEntry: pt = %f, eta = %f (%s)\n", pt, eta, valid ? "valid" : "not valid"); - printf(" efficiency: %f\n", eff); - printf(" covMatix: "); - int k = 0; - for (int i = 0; i < 5; ++i) { - for (int j = 0; j < i + 1; ++j) - printf("% e ", covm[k++]); - printf("\n "); - } - printf("\n"); - } -}; - -//////////////////////////////////// -/// DelphesO2/src/TrackSmearer.hh // -//////////////////////////////////// - -/// @author: Roberto Preghenella -/// @email: preghenella@bo.infn.it - -// #ifndef _DelphesO2_TrackSmearer_h_ -// #define _DelphesO2_TrackSmearer_h_ - -// #include "ReconstructionDataFormats/Track.h" -// #include "classes/DelphesClasses.h" -// #include "lutCovm.hh" -// #include - -using O2Track = o2::track::TrackParCov; - namespace o2 { namespace delphes { -class TrackSmearer +class DelphesO2TrackSmearer : public TNamed { public: - TrackSmearer() = default; - ~TrackSmearer() = default; +#define LUTCOVM_VERSION 20210801 + struct map_t { + int nbins = 1; + float min = 0.; + float max = 1.e6; + bool log = false; + float eval(int bin) + { + float width = (max - min) / nbins; + float val = min + (bin + 0.5) * width; + if (log) + return pow(10., val); + return val; + } + // function needed to interpolate some dimensions + float fracPositionWithinBin(float val) + { + float width = (max - min) / nbins; + int bin; + float returnVal = 0.5f; + if (log) { + bin = static_cast((log10(val) - min) / width); + returnVal = ((log10(val) - min) / width) - bin; + } else { + bin = static_cast((val - min) / width); + returnVal = val / width - bin; + } + return returnVal; + } + + int find(float val) + { + float width = (max - min) / nbins; + int bin; + if (log) + bin = static_cast((log10(val) - min) / width); // Changed due to MegaLinter error. + // bin = (int)((log10(val) - min) / width); // Original line. + else + bin = static_cast((val - min) / width); // Changed due to MegaLinter error. + // bin = (int)((val - min) / width); // Original line. + if (bin < 0) + return 0; + if (bin > nbins - 1) + return nbins - 1; + return bin; + } //; + void print() { printf("nbins = %d, min = %f, max = %f, log = %s \n", nbins, min, max, log ? "on" : "off"); } //; + }; + + struct lutHeader_t { + int version = LUTCOVM_VERSION; + int pdg = 0; + float mass = 0.; + float field = 0.; + map_t nchmap; + map_t radmap; + map_t etamap; + map_t ptmap; + bool check_version() + { + return (version == LUTCOVM_VERSION); + } //; + void print() + { + printf(" version: %d \n", version); + printf(" pdg: %d \n", pdg); + printf(" field: %f \n", field); + printf(" nchmap: "); + nchmap.print(); + printf(" radmap: "); + radmap.print(); + printf(" etamap: "); + etamap.print(); + printf(" ptmap: "); + ptmap.print(); + } //; + }; + + struct lutEntry_t { + float nch = 0.; + float eta = 0.; + float pt = 0.; + bool valid = false; + float eff = 0.; + float eff2 = 0.; + float itof = 0.; + float otof = 0.; + float covm[15] = {0.}; + float eigval[5] = {0.}; + float eigvec[5][5] = {{0.}}; + float eiginv[5][5] = {{0.}}; + void print() + { + printf(" --- lutEntry: pt = %f, eta = %f (%s)\n", pt, eta, valid ? "valid" : "not valid"); + printf(" efficiency: %f\n", eff); + printf(" covMatix: "); + int k = 0; + for (int i = 0; i < 5; ++i) { + for (int j = 0; j < i + 1; ++j) + printf("% e ", covm[k++]); + printf("\n "); + } + printf("\n"); + } + }; + + DelphesO2TrackSmearer() = default; + ~DelphesO2TrackSmearer() = default; /** LUT methods **/ bool loadTable(int pdg, const char* filename, bool forceReload = false); @@ -189,8 +160,8 @@ class TrackSmearer lutHeader_t* getLUTHeader(int pdg) { return mLUTHeader[getIndexPDG(pdg)]; } //; lutEntry_t* getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff); - bool smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float interpolatedEff); - bool smearTrack(O2Track& o2track, int pdg, float nch); + bool smearTrack(o2::track::TrackParCov& o2track, lutEntry_t* lutEntry, float interpolatedEff); + bool smearTrack(o2::track::TrackParCov& o2track, int pdg, float nch); // bool smearTrack(Track& track, bool atDCA = true); // Only in DelphesO2 double getPtRes(const int pdg, const float nch, const float eta, const float pt); double getEtaRes(const int pdg, const float nch, const float eta, const float pt); @@ -198,57 +169,8 @@ class TrackSmearer double getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt); double getEfficiency(const int pdg, const float nch, const float eta, const float pt); - int getIndexPDG(const int pdg) - { - switch (abs(pdg)) { - case 11: - return 0; // Electron - case 13: - return 1; // Muon - case 211: - return 2; // Pion - case 321: - return 3; // Kaon - case 2212: - return 4; // Proton - case 1000010020: - return 5; // Deuteron - case 1000010030: - return 6; // Triton - case 1000020030: - return 7; // Helium3 - case 1000020040: - return 8; // Alphas - default: - return 2; // Default: pion - } - } - - const char* getParticleName(int pdg) - { - switch (abs(pdg)) { - case 11: - return "electron"; - case 13: - return "muon"; - case 211: - return "pion"; - case 321: - return "kaon"; - case 2212: - return "proton"; - case 1000010020: - return "deuteron"; - case 1000010030: - return "triton"; - case 1000020030: - return "helium3"; - case 1000020040: - return "alpha"; - default: - return "pion"; // Default: pion - } - } + static int getIndexPDG(const int pdg); + const char* getParticleName(int pdg); void setdNdEta(float val) { mdNdEta = val; } //; void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } //; @@ -269,10 +191,4 @@ class TrackSmearer } // namespace delphes } // namespace o2 -// #endif /** _DelphesO2_TrackSmearer_h_ **/ - -namespace o2::delphes -{ -using DelphesO2TrackSmearer = TrackSmearer; -} #endif // ALICE3_CORE_DELPHESO2TRACKSMEARER_H_ From 9fc286bf3f610a8f84f938da90a72c0ecd994412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 24 Feb 2026 21:23:42 +0100 Subject: [PATCH 2/6] Update DelphesO2TrackSmearer.cxx --- ALICE3/Core/DelphesO2TrackSmearer.cxx | 116 +++++++++++++++++--------- 1 file changed, 77 insertions(+), 39 deletions(-) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.cxx b/ALICE3/Core/DelphesO2TrackSmearer.cxx index 7fca0dc19be..c6fbf2f42d2 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.cxx +++ b/ALICE3/Core/DelphesO2TrackSmearer.cxx @@ -13,7 +13,6 @@ /// \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 @@ -21,19 +20,6 @@ /// @email: preghenella@bo.infn.it /// -////////////////////////////// -// DelphesO2/src/lutCovm.cc // -////////////////////////////// - -/// @author: Roberto Preghenella -/// @email: preghenella@bo.infn.it - -// #include "TrackSmearer.hh" -// #include "TrackUtils.hh" -// #include "TRandom.h" -// #include -// #include - #include "ALICE3/Core/DelphesO2TrackSmearer.h" #include "ALICE3/Core/GeometryContainer.h" @@ -51,7 +37,59 @@ namespace delphes /*****************************************************************/ -bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) +int DelphesO2TrackSmearer::getIndexPDG(const int pdg) +{ + switch (abs(pdg)) { + case 11: + return 0; // Electron + case 13: + return 1; // Muon + case 211: + return 2; // Pion + case 321: + return 3; // Kaon + case 2212: + return 4; // Proton + case 1000010020: + return 5; // Deuteron + case 1000010030: + return 6; // Triton + case 1000020030: + return 7; // Helium3 + case 1000020040: + return 8; // Alphas + default: + return 2; // Default: pion + } +} + +const char* DelphesO2TrackSmearer::getParticleName(int pdg) +{ + switch (abs(pdg)) { + case 11: + return "electron"; + case 13: + return "muon"; + case 211: + return "pion"; + case 321: + return "kaon"; + case 2212: + return "proton"; + case 1000010020: + return "deuteron"; + case 1000010030: + return "triton"; + case 1000020030: + return "helium3"; + case 1000020040: + return "alpha"; + default: + return "pion"; // Default: pion + } +} + +bool DelphesO2TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) { if (!filename || filename[0] == '\0') { LOG(info) << " --- No LUT file provided for PDG " << pdg << ". Skipping load."; @@ -109,17 +147,17 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) const int nrad = mLUTHeader[ipdg]->radmap.nbins; const int neta = mLUTHeader[ipdg]->etamap.nbins; const int npt = mLUTHeader[ipdg]->ptmap.nbins; - mLUTEntry[ipdg] = new lutEntry_t****[nnch]; + mLUTEntry[ipdg] = new DelphesO2TrackSmearer::lutEntry_t****[nnch]; for (int inch = 0; inch < nnch; ++inch) { - mLUTEntry[ipdg][inch] = new lutEntry_t***[nrad]; + mLUTEntry[ipdg][inch] = new DelphesO2TrackSmearer::lutEntry_t***[nrad]; for (int irad = 0; irad < nrad; ++irad) { - mLUTEntry[ipdg][inch][irad] = new lutEntry_t**[neta]; + mLUTEntry[ipdg][inch][irad] = new DelphesO2TrackSmearer::lutEntry_t**[neta]; for (int ieta = 0; ieta < neta; ++ieta) { - mLUTEntry[ipdg][inch][irad][ieta] = new lutEntry_t*[npt]; + mLUTEntry[ipdg][inch][irad][ieta] = new DelphesO2TrackSmearer::lutEntry_t*[npt]; for (int ipt = 0; ipt < npt; ++ipt) { - 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)) { + mLUTEntry[ipdg][inch][irad][ieta][ipt] = new DelphesO2TrackSmearer::lutEntry_t; + lutFile.read(reinterpret_cast(mLUTEntry[ipdg][inch][irad][ieta][ipt]), sizeof(DelphesO2TrackSmearer::lutEntry_t)); + if (lutFile.gcount() != sizeof(DelphesO2TrackSmearer::lutEntry_t)) { LOG(info) << " --- troubles reading covariance matrix entry for PDG " << pdg << ": " << localFilename << std::endl; LOG(info) << " --- expected/detected " << sizeof(lutHeader_t) << "/" << lutFile.gcount() << std::endl; return false; @@ -137,7 +175,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) /*****************************************************************/ -lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff) +DelphesO2TrackSmearer::lutEntry_t* DelphesO2TrackSmearer::getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff) { const int ipdg = getIndexPDG(pdg); if (!mLUTHeader[ipdg]) { @@ -210,7 +248,7 @@ lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, const floa /*****************************************************************/ -bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float interpolatedEff) +bool DelphesO2TrackSmearer::smearTrack(o2::track::TrackParCov& o2track, DelphesO2TrackSmearer::lutEntry_t* lutEntry, float interpolatedEff) { bool isReconstructed = true; // generate efficiency @@ -263,7 +301,7 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte /*****************************************************************/ -bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch) +bool DelphesO2TrackSmearer::smearTrack(o2::track::TrackParCov& o2track, int pdg, float nch) { auto pt = o2track.getPt(); switch (pdg) { @@ -274,7 +312,7 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch) } auto eta = o2track.getEta(); float interpolatedEff = 0.0f; - lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff); + DelphesO2TrackSmearer::lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff); if (!lutEntry || !lutEntry->valid) return false; return smearTrack(o2track, lutEntry, interpolatedEff); @@ -282,20 +320,20 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch) /*****************************************************************/ // relative uncertainty on pt -double TrackSmearer::getPtRes(const int pdg, const float nch, const float eta, const float pt) +double DelphesO2TrackSmearer::getPtRes(const int pdg, const float nch, const float eta, const float pt) { float dummy = 0.0f; - lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); + DelphesO2TrackSmearer::lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt; return val; } /*****************************************************************/ // relative uncertainty on eta -double TrackSmearer::getEtaRes(const int pdg, const float nch, const float eta, const float pt) +double DelphesO2TrackSmearer::getEtaRes(const int pdg, const float nch, const float eta, const float pt) { float dummy = 0.0f; - lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); + DelphesO2TrackSmearer::lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); 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 @@ -303,27 +341,27 @@ double TrackSmearer::getEtaRes(const int pdg, const float nch, const float eta, } /*****************************************************************/ // absolute uncertainty on pt -double TrackSmearer::getAbsPtRes(const int pdg, const float nch, const float eta, const float pt) +double DelphesO2TrackSmearer::getAbsPtRes(const int pdg, const float nch, const float eta, const float pt) { float dummy = 0.0f; - lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); + DelphesO2TrackSmearer::lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt * lutEntry->pt; return val; } /*****************************************************************/ // absolute uncertainty on eta -double TrackSmearer::getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt) +double DelphesO2TrackSmearer::getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt) { float dummy = 0.0f; - lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); + DelphesO2TrackSmearer::lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy); 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; } /*****************************************************************/ // efficiency -double TrackSmearer::getEfficiency(const int pdg, const float nch, const float eta, const float pt) +double DelphesO2TrackSmearer::getEfficiency(const int pdg, const float nch, const float eta, const float pt) { float efficiency = 0.0f; getLUTEntry(pdg, nch, 0., eta, pt, efficiency); @@ -331,10 +369,10 @@ double TrackSmearer::getEfficiency(const int pdg, const float nch, const float e } /*****************************************************************/ // Only in DelphesO2 -// bool TrackSmearer::smearTrack(Track& track, bool atDCA) +// bool DelphesO2TrackSmearer::smearTrack(Track& track, bool atDCA) // { -// O2Track o2track; +// o2::track::TrackParCov o2track; // TrackUtils::convertTrackToO2Track(track, o2track, atDCA); // int pdg = track.PID; // float nch = mdNdEta; // use locally stored dNch/deta for the time being @@ -344,11 +382,11 @@ double TrackSmearer::getEfficiency(const int pdg, const float nch, const float e // return true; // #if 0 -// lutEntry_t* lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT); +// DelphesO2TrackSmearer::lutEntry_t* lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT); // if (!lutEntry) // return; -// O2Track o2track; +// o2::track::TrackParCov o2track; // TrackUtils::convertTrackToO2Track(track, o2track, atDCA); // smearTrack(o2track, lutEntry); // TrackUtils::convertO2TrackToTrack(o2track, track, atDCA); From abd591c73efc96c96e091e51176de98ecefab9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 24 Feb 2026 21:24:18 +0100 Subject: [PATCH 3/6] Update DelphesO2LutWriter.h --- ALICE3/Core/DelphesO2LutWriter.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ALICE3/Core/DelphesO2LutWriter.h b/ALICE3/Core/DelphesO2LutWriter.h index 1528ab80bac..99c5b1405bc 100644 --- a/ALICE3/Core/DelphesO2LutWriter.h +++ b/ALICE3/Core/DelphesO2LutWriter.h @@ -46,7 +46,7 @@ class DelphesO2LutWriter void setAtLeastHits(int n) { mAtLeastHits = n; } void setAtLeastCorr(int n) { mAtLeastCorr = n; } void setAtLeastFake(int n) { mAtLeastFake = n; } - bool fatSolve(lutEntry_t& lutEntry, + bool fatSolve(o2::delphes::DelphesO2TrackSmearer::lutEntry_t& lutEntry, float pt = 0.1, float eta = 0.0, const float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion], @@ -57,14 +57,14 @@ class DelphesO2LutWriter void print() const; bool fwdSolve(float* covm, float pt = 0.1, float eta = 0.0, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion]); - bool fwdPara(lutEntry_t& lutEntry, float pt = 0.1, float eta = 0.0, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion], float Bfield = 0.5); + bool fwdPara(o2::delphes::DelphesO2TrackSmearer::lutEntry_t& lutEntry, float pt = 0.1, float eta = 0.0, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion], float Bfield = 0.5); void lutWrite(const char* filename = "lutCovm.dat", int pdg = 211, float field = 0.2, size_t itof = 0, size_t otof = 0); TGraph* lutRead(const char* filename, int pdg, int what, int vs, float nch = 0., float radius = 0., float eta = 0., float pt = 0.); o2::fastsim::FastTracker fat; private: - void diagonalise(lutEntry_t& lutEntry); + void diagonalise(o2::delphes::DelphesO2TrackSmearer::lutEntry_t& lutEntry); float etaMaxBarrel = 1.75f; bool usePara = true; // use fwd parameterisation bool useDipole = false; // use dipole i.e. flat parametrization for efficiency and momentum resolution From 078df08697b4273cb97c1a9cc8915ee218d2396e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 24 Feb 2026 21:24:45 +0100 Subject: [PATCH 4/6] Update DelphesO2LutWriter.cxx --- ALICE3/Core/DelphesO2LutWriter.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ALICE3/Core/DelphesO2LutWriter.cxx b/ALICE3/Core/DelphesO2LutWriter.cxx index 987383092ec..9632584b72b 100644 --- a/ALICE3/Core/DelphesO2LutWriter.cxx +++ b/ALICE3/Core/DelphesO2LutWriter.cxx @@ -73,7 +73,7 @@ std::string DelphesO2LutWriter::LutBinning::toString() const return str; } -bool DelphesO2LutWriter::fatSolve(lutEntry_t& lutEntry, +bool DelphesO2LutWriter::fatSolve(o2::delphes::DelphesO2TrackSmearer::lutEntry_t& lutEntry, float pt, float eta, const float mass, @@ -147,7 +147,7 @@ bool DelphesO2LutWriter::fwdSolve(float*, float, float, float) } #endif -bool DelphesO2LutWriter::fwdPara(lutEntry_t& lutEntry, float pt, float eta, float mass, float Bfield) +bool DelphesO2LutWriter::fwdPara(o2::delphes::DelphesO2TrackSmearer::lutEntry_t& lutEntry, float pt, float eta, float mass, float Bfield) { lutEntry.valid = false; @@ -230,7 +230,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si } // write header - lutHeader_t lutHeader; + o2::delphes::DelphesO2TrackSmearer::lutHeader_t lutHeader; // pid lutHeader.pdg = pdg; const TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(pdg); @@ -245,7 +245,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si return; } lutHeader.field = field; - auto setMap = [](map_t& map, LutBinning b) { + auto setMap = [](o2::delphes::DelphesO2TrackSmearer::map_t& map, LutBinning b) { map.log = b.log; map.nbins = b.nbins; map.min = b.min; @@ -267,7 +267,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si const int nrad = lutHeader.radmap.nbins; const int neta = lutHeader.etamap.nbins; const int npt = lutHeader.ptmap.nbins; - lutEntry_t lutEntry; + o2::delphes::DelphesO2TrackSmearer::lutEntry_t lutEntry; // write entries int nCalls = 0; @@ -319,7 +319,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si retval = fwdSolve(lutEntry.covm, lutEntry.pt, lutEntry.eta, lutHeader.mass); } if (useDipole) { // Using the parametrization at the border of the barrel only for efficiency and momentum resolution - lutEntry_t lutEntryBarrel; + o2::delphes::DelphesO2TrackSmearer::lutEntry_t lutEntryBarrel; retval = fatSolve(lutEntryBarrel, lutEntry.pt, etaMaxBarrel, lutHeader.mass, itof, otof, q); lutEntry.valid = lutEntryBarrel.valid; lutEntry.covm[14] = lutEntryBarrel.covm[14]; @@ -339,7 +339,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si LOGF(info, "Diagonalizing"); diagonalise(lutEntry); LOGF(info, "Writing"); - lutFile.write(reinterpret_cast(&lutEntry), sizeof(lutEntry_t)); + lutFile.write(reinterpret_cast(&lutEntry), sizeof(o2::delphes::DelphesO2TrackSmearer::lutEntry_t)); } } } @@ -349,7 +349,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si lutFile.close(); } -void DelphesO2LutWriter::diagonalise(lutEntry_t& lutEntry) +void DelphesO2LutWriter::diagonalise(o2::delphes::DelphesO2TrackSmearer::lutEntry_t& lutEntry) { static constexpr int kEig = 5; TMatrixDSym m(kEig); @@ -399,7 +399,7 @@ TGraph* DelphesO2LutWriter::lutRead(const char* filename, int pdg, int what, int smearer.loadTable(pdg, filename); auto lutHeader = smearer.getLUTHeader(pdg); lutHeader->print(); - map_t lutMap; + o2::delphes::DelphesO2TrackSmearer::map_t lutMap; switch (vs) { case kNch: lutMap = lutHeader->nchmap; From 7c1439575e76d459b1529bd23cca9b16e04a49bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 24 Feb 2026 22:26:45 +0200 Subject: [PATCH 5/6] Add files via upload --- ALICE3/Macros/writeLUTCollection.C | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ALICE3/Macros/writeLUTCollection.C diff --git a/ALICE3/Macros/writeLUTCollection.C b/ALICE3/Macros/writeLUTCollection.C new file mode 100644 index 00000000000..427abe165fb --- /dev/null +++ b/ALICE3/Macros/writeLUTCollection.C @@ -0,0 +1,43 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file writeLUTCollection.C +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Writer for the collection of LUTs for DelphesO2TrackSmearer + +#include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/Core/GeometryContainer.h" + +#include + +#include + +#include + +void writeLUTCollection(std::string geometryFile = "/home/njacazio/alice/O2Physics/ALICE3/Macros/Configuration/a3geo.ini") +{ + + fair::Logger::SetConsoleSeverity(fair::Severity::debug); + auto& ccdb = o2::ccdb::BasicCCDBManager::instance(); + ccdb.setURL("http://alice-ccdb.cern.ch"); + ccdb.setTimestamp(-1); + + const std::string filename = "ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/el"; + const std::string localFilename = o2::fastsim::GeometryEntry::accessFile(filename, "./.ALICE3/LUTs/", &ccdb, -10); + + o2::delphes::DelphesO2TrackSmearer mSmearer; + mSmearer.loadTable(11, localFilename.c_str(), true); + + TFile outFile("/tmp/LUTCollection.root", "RECREATE"); + outFile.cd(); + mSmearer.Write(); + outFile.Close(); +} From 8793ae6e38ea91732427f0ed8aaf3299981e1fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 24 Feb 2026 21:31:24 +0100 Subject: [PATCH 6/6] Update DelphesO2TrackSmearer.h --- ALICE3/Core/DelphesO2TrackSmearer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ALICE3/Core/DelphesO2TrackSmearer.h b/ALICE3/Core/DelphesO2TrackSmearer.h index 71defed1a14..85d30f2279c 100644 --- a/ALICE3/Core/DelphesO2TrackSmearer.h +++ b/ALICE3/Core/DelphesO2TrackSmearer.h @@ -173,6 +173,7 @@ class DelphesO2TrackSmearer : public TNamed const char* getParticleName(int pdg); void setdNdEta(float val) { mdNdEta = val; } //; void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } //; + void print(); protected: static constexpr unsigned int nLUTs = 9; // Number of LUT available