From 0c7f410607abde5ca965315b54bc24029bd4ef15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sun, 20 Sep 2026 21:30:53 +0200 Subject: [PATCH 01/13] [ALICE3] cleanup DelphesO2 legacy code, fix warnings - Remove legacy DelphesO2 LUT and Smearer - Fix code check warnings --- ALICE3/Core/FlatLutEntry.cxx | 61 ++++--- ALICE3/Core/FlatLutEntry.h | 76 +++++--- ALICE3/Core/FlatLutWriter.cxx | 98 ++++++---- ALICE3/Core/FlatLutWriter.h | 22 +-- ALICE3/Core/FlatTrackSmearer.cxx | 89 ++++------ ALICE3/Core/FlatTrackSmearer.h | 45 ++--- ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx | 51 +++--- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 178 ++++++++++--------- ALICE3/TableProducer/OTF/onTheFlyTracker.cxx | 4 +- 9 files changed, 332 insertions(+), 292 deletions(-) diff --git a/ALICE3/Core/FlatLutEntry.cxx b/ALICE3/Core/FlatLutEntry.cxx index 8ced29cdb66..b5551d261c7 100644 --- a/ALICE3/Core/FlatLutEntry.cxx +++ b/ALICE3/Core/FlatLutEntry.cxx @@ -9,6 +9,9 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file FlatLutEntry.cxx +/// \brief Flat LUT implementation for compact helper tables used by the ALICE3 track smearing workflow. + #include "FlatLutEntry.h" #include @@ -22,33 +25,37 @@ #include #include -namespace o2::delphes +namespace o2::fastsim +{ +namespace { +constexpr float kBinCenterOffset = 0.5f; +} // namespace void lutEntry_t::print() const { LOGF(info, " nch = %f, eta = %f, pt = %f, valid = %s\n", nch, eta, pt, valid ? "true" : "false"); LOGF(info, " eff = %f, eff2 = %f, itof = %f, otof = %f\n", eff, eff2, itof, otof); LOGF(info, " covm: "); - for (int i = 0; i < 15; ++i) { + for (int i = 0; i < kNumCovarianceTerms; ++i) { LOGF(info, "%f ", covm[i]); } LOGF(info, "\n"); LOGF(info, " eigval: "); - for (int i = 0; i < 5; ++i) { + for (int i = 0; i < kNumEigenModes; ++i) { LOGF(info, "%f ", eigval[i]); } LOGF(info, "\n"); LOGF(info, " eigvec:\n"); - for (int i = 0; i < 5; ++i) { - for (int j = 0; j < 5; ++j) { + for (int i = 0; i < kNumEigenModes; ++i) { + for (int j = 0; j < kNumEigenModes; ++j) { LOGF(info, "%f ", eigvec[i][j]); } LOGF(info, "\n"); } LOGF(info, " eiginv:\n"); - for (int i = 0; i < 5; ++i) { - for (int j = 0; j < 5; ++j) { + for (int i = 0; i < kNumEigenModes; ++i) { + for (int j = 0; j < kNumEigenModes; ++j) { LOGF(info, "%f ", eiginv[i][j]); } LOGF(info, "\n"); @@ -58,8 +65,8 @@ void lutEntry_t::print() const float map_t::fracPositionWithinBin(float val) const { float width = (max - min) / nbins; - int bin; - float returnVal = 0.5f; + int bin = 0; + float returnVal = kBinCenterOffset; if (log) { bin = static_cast((std::log10(val) - min) / width); returnVal = ((std::log10(val) - min) / width) - bin; @@ -73,7 +80,7 @@ float map_t::fracPositionWithinBin(float val) const int map_t::find(float val) const { float width = (max - min) / nbins; - int bin; + int bin = 0; if (log) { bin = static_cast((std::log10(val) - min) / width); } else { @@ -93,7 +100,7 @@ void map_t::print() const LOGF(info, "nbins = %d, min = %f, max = %f, log = %s \n", nbins, min, max, log ? "on" : "off"); } -bool lutHeader_t::check_version() const +bool lutHeader_t::checkVersion() const { return (version == LUTCOVM_VERSION); } @@ -120,7 +127,7 @@ void FlatLutData::initialize(const lutHeader_t& header) mEtaBins = header.etamap.nbins; mPtBins = header.ptmap.nbins; - const size_t headerSize = sizeof(lutHeader_t); + constexpr size_t headerSize = sizeof(lutHeader_t); const size_t numEntries = static_cast(mNchBins) * mRadBins * mEtaBins * mPtBins; const size_t entriesSize = numEntries * sizeof(lutEntry_t); const size_t totalSize = headerSize + entriesSize; @@ -133,10 +140,10 @@ void FlatLutData::initialize(const lutHeader_t& header) size_t FlatLutData::getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const { - static constexpr size_t headerSize = sizeof(lutHeader_t); + static constexpr size_t HeaderSize = sizeof(lutHeader_t); const size_t linearIdx = getEntryIndex(nch_bin, rad_bin, eta_bin, pt_bin); - static constexpr size_t entrySize = sizeof(lutEntry_t); - return headerSize + linearIdx * entrySize; + static constexpr size_t EntrySize = sizeof(lutEntry_t); + return HeaderSize + linearIdx * EntrySize; } const lutEntry_t* FlatLutData::getEntryRef(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const @@ -200,26 +207,26 @@ void FlatLutData::view(const uint8_t* buffer, size_t size) void FlatLutData::validateBuffer(const uint8_t* buffer, size_t size) { - auto header = PreviewHeader(buffer, size); - auto mNchBins = header.nchmap.nbins; - auto mRadBins = header.radmap.nbins; - auto mEtaBins = header.etamap.nbins; - auto mPtBins = header.ptmap.nbins; + auto header = previewHeader(buffer, size); + const auto nchBins = header.nchmap.nbins; + const auto radBins = header.radmap.nbins; + const auto etaBins = header.etamap.nbins; + const auto ptBins = header.ptmap.nbins; - size_t expectedSize = sizeof(lutHeader_t) + static_cast(mNchBins) * mRadBins * mEtaBins * mPtBins * sizeof(lutEntry_t); + const size_t expectedSize = sizeof(lutHeader_t) + static_cast(nchBins) * radBins * etaBins * ptBins * sizeof(lutEntry_t); if (size < expectedSize) { throw framework::runtime_error_f("Buffer size mismatch: expected %zu, got %zu", expectedSize, size); } } -lutHeader_t FlatLutData::PreviewHeader(const uint8_t* buffer, size_t size) +lutHeader_t FlatLutData::previewHeader(const uint8_t* buffer, size_t size) { if (size < sizeof(lutHeader_t)) { throw framework::runtime_error_f("Buffer too small for LUT header: expected at least %zu, got %zu", sizeof(lutHeader_t), size); } const auto* header = reinterpret_cast(buffer); - if (!header->check_version()) { + if (!header->checkVersion()) { throw framework::runtime_error_f("LUT header version mismatch: expected %d, got %d", LUTCOVM_VERSION, header->version); } return *header; @@ -256,14 +263,14 @@ bool FlatLutData::isLoaded() const return ((!mData.empty()) || (!mDataRef.empty())); } -lutHeader_t FlatLutData::PreviewHeader(std::ifstream& file, const char* filename) +lutHeader_t FlatLutData::previewHeader(std::ifstream& file, const char* filename) { lutHeader_t tempHeader; file.read(reinterpret_cast(&tempHeader), sizeof(lutHeader_t)); if (file.gcount() != static_cast(sizeof(lutHeader_t))) { throw framework::runtime_error_f("Failed to read LUT header from %s", filename); } - if (!tempHeader.check_version()) { + if (!tempHeader.checkVersion()) { throw framework::runtime_error_f("LUT header version mismatch: expected %d, got %d", LUTCOVM_VERSION, tempHeader.version); } return tempHeader; @@ -272,7 +279,7 @@ lutHeader_t FlatLutData::PreviewHeader(std::ifstream& file, const char* filename FlatLutData FlatLutData::loadFromFile(std::ifstream& file, const char* filename) { // Read header first - lutHeader_t tempHeader = PreviewHeader(file, filename); + lutHeader_t tempHeader = previewHeader(file, filename); FlatLutData data; @@ -300,4 +307,4 @@ void FlatLutData::reset() resetDimensions(); } -} // namespace o2::delphes +} // namespace o2::fastsim diff --git a/ALICE3/Core/FlatLutEntry.h b/ALICE3/Core/FlatLutEntry.h index 330c3e6df87..7e095f989c1 100644 --- a/ALICE3/Core/FlatLutEntry.h +++ b/ALICE3/Core/FlatLutEntry.h @@ -9,9 +9,13 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file FlatLutEntry.h +/// \brief Flat LUT data structures and buffer handling for the ALICE3 fast smearing backend. + #ifndef ALICE3_CORE_FLATLUTENTRY_H_ #define ALICE3_CORE_FLATLUTENTRY_H_ +#include #include #include #include @@ -19,15 +23,22 @@ #include #include -#define LUTCOVM_VERSION 20210801 +static constexpr int LUTCOVM_VERSION = 20210801; -namespace o2::delphes +namespace o2::fastsim { +constexpr int kNumCovarianceTerms = 15; +constexpr int kNumEigenModes = 5; +typedef std::array CovarianceArray; +typedef std::array EigenArray; +typedef std::array EigenArrayDouble; +typedef std::array, kNumEigenModes> EigenMatrix; + /** - * @brief Flat LUT entry structure + * @brief Flat LUT entry structure. */ -struct lutEntry_t { +struct LutEntry { float nch = 0.f; float eta = 0.f; float pt = 0.f; @@ -36,41 +47,46 @@ struct lutEntry_t { float eff2 = 0.f; float itof = 0.f; float otof = 0.f; - float covm[15] = {0.f}; - float eigval[5] = {0.f}; - float eigvec[5][5] = {{0.f}}; - float eiginv[5][5] = {{0.f}}; + CovarianceArray covm = {0.f}; + EigenArray eigval = {0.f}; + EigenMatrix eigvec = {{{0.f}}}; + EigenMatrix eiginv = {{{0.f}}}; void print() const; }; +using lutEntry_t = LutEntry; + /** - * @brief Binning map + * @brief Binning map. */ -struct map_t { +struct Map { int nbins = 1; float min = 0.f; float max = 1.e6f; bool log = false; - float eval(int bin) const + [[nodiscard]] float eval(int bin) const { float width = (max - min) / nbins; float val = min + (bin + 0.5f) * width; - if (log) + if (log) { return std::pow(10.f, val); + } return val; } - float fracPositionWithinBin(float val) const; - int find(float val) const; + [[nodiscard]] float fracPositionWithinBin(float val) const; + [[nodiscard]] int find(float val) const; void print() const; }; +using map_t = Map; + /** - * @brief LUT header + * @brief LUT header. */ -struct lutHeader_t { +struct LutHeader { int version = LUTCOVM_VERSION; int pdg = 0; float mass = 0.f; @@ -80,12 +96,14 @@ struct lutHeader_t { map_t etamap; map_t ptmap; - bool check_version() const; + [[nodiscard]] bool checkVersion() const; void print() const; }; +using lutHeader_t = LutHeader; + /** - * @brief Flat LUT data container - single contiguous buffer + * @brief Flat LUT data container - single contiguous buffer. * Memory layout: [header][entry_0][entry_1]...[entry_N] * * All entries stored sequentially in a single allocation. @@ -104,7 +122,7 @@ class FlatLutData */ void initialize(const lutHeader_t& header); - size_t getEntryIndex(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const + [[nodiscard]] size_t getEntryIndex(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const { // Linear index: nch varies slowest, pt varies fastest // idx = nch * (rad*eta*pt) + rad * (eta*pt) + eta * pt + pt @@ -114,7 +132,7 @@ class FlatLutData /** * @brief Get LUT entry by bin indices (view) */ - const lutEntry_t* getEntryRef(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const; + [[nodiscard]] const lutEntry_t* getEntryRef(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const; /** * @brief Get LUT entry by bin indices (owned) @@ -124,7 +142,7 @@ class FlatLutData /** * @brief Get LUT header (view) */ - const lutHeader_t& getHeaderRef() const; + [[nodiscard]] const lutHeader_t& getHeaderRef() const; /** * @brief Get LUT header (owned) @@ -134,13 +152,13 @@ class FlatLutData /** * @brief Get raw data buffer */ - uint8_t* data() { return mData.data(); } // owned - const uint8_t* data() const { return mDataRef.data(); } // view + uint8_t* data() { return mData.data(); } // owned + [[nodiscard]] const uint8_t* data() const { return mDataRef.data(); } // view /** * @brief Total size in bytes */ - size_t bytes() const { return mDataRef.size(); } + [[nodiscard]] size_t bytes() const { return mDataRef.size(); } /** * @brief Construct a new FlatLutData from external buffer as a copy @@ -165,17 +183,17 @@ class FlatLutData /** * @brief Preview buffer header for version and other compatibility checks */ - static lutHeader_t PreviewHeader(const uint8_t* buffer, size_t size); + static lutHeader_t previewHeader(const uint8_t* buffer, size_t size); /** * @brief Preview file-stored header for version and other compatibility checks */ - static lutHeader_t PreviewHeader(std::ifstream& file, const char* filename); + static lutHeader_t previewHeader(std::ifstream& file, const char* filename); /** * @brief Check if the LUT is loaded */ - bool isLoaded() const; + [[nodiscard]] bool isLoaded() const; /** * @brief Reset LUT to empty @@ -186,7 +204,7 @@ class FlatLutData /** * @brief Linear index calculation for entry access */ - size_t getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const; + [[nodiscard]] size_t getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const; /** * @brief Update dimensions from the current header @@ -224,6 +242,6 @@ class FlatLutData int mPtBins = 0; }; -} // namespace o2::delphes +} // namespace o2::fastsim #endif // ALICE3_CORE_FLATLUTENTRY_H_ diff --git a/ALICE3/Core/FlatLutWriter.cxx b/ALICE3/Core/FlatLutWriter.cxx index 4fe806c4ef4..dfb874af223 100644 --- a/ALICE3/Core/FlatLutWriter.cxx +++ b/ALICE3/Core/FlatLutWriter.cxx @@ -30,12 +30,11 @@ #include #include +#include #include #include #include -using namespace o2::delphes; - namespace o2::fastsim { void FlatLutWriter::print() const @@ -57,7 +56,7 @@ void FlatLutWriter::print() const std::string FlatLutWriter::LutBinning::toString() const { - std::string str = ""; + std::string str; str.append(log ? "log" : "lin"); str.append(" nbins: "); str.append(std::to_string(nbins)); @@ -97,25 +96,28 @@ bool FlatLutWriter::fatSolve(lutEntry_t& lutEntry, lutEntry.itof = fat.getGoodHitProb(itof); lutEntry.otof = fat.getGoodHitProb(otof); - static constexpr int nCov = 15; - for (int i = 0; i < nCov; ++i) + for (int i = 0; i < kNumCovarianceTerms; ++i) { lutEntry.covm[i] = trkOut.getCov()[i]; + } // Define the efficiency auto totfake = 0.f; lutEntry.eff = 1.f; for (size_t i = 1; i < fat.getNLayers(); ++i) { - if (fat.isLayerInert(i)) + if (fat.isLayerInert(i)) { continue; // skip inert layers + } auto igoodhit = fat.getGoodHitProb(i); - if (igoodhit <= 0.f || i == itof || i == otof) + if (igoodhit <= 0.f || i == itof || i == otof) { continue; + } lutEntry.eff *= igoodhit; auto pairfake = 0.f; for (size_t j = i + 1; j < fat.getNLayers(); ++j) { auto jgoodhit = fat.getGoodHitProb(j); - if (jgoodhit <= 0.f || j == itof || j == otof) + if (jgoodhit <= 0.f || j == itof || j == otof) { continue; + } pairfake = (1.f - igoodhit) * (1.f - jgoodhit); break; } @@ -127,14 +129,14 @@ bool FlatLutWriter::fatSolve(lutEntry_t& lutEntry, } #ifdef USE_FWD_PARAM -bool FlatLutWriter::fwdSolve(float* covm, float pt, float eta, float mass) +bool FlatLutWriter::fwdSolve(CovarianceArray covm, float pt, float eta, float mass) { if (fwdRes(covm, pt, eta, mass) < 0) return false; return true; } #else -bool FlatLutWriter::fwdSolve(float*, float, float, float) +bool FlatLutWriter::fwdSolve(CovarianceArray, float, float, float) { return false; } @@ -155,9 +157,8 @@ bool FlatLutWriter::fwdPara(lutEntry_t& lutEntry, float pt, float eta, float mas return false; } - static constexpr int nCov = 15; - float covmbarrel[nCov] = {0.f}; - for (int i = 0; i < nCov; ++i) { + CovarianceArray covmbarrel = {0.f}; + for (int i = 0; i < kNumCovarianceTerms; ++i) { covmbarrel[i] = lutEntry.covm[i]; } @@ -242,7 +243,7 @@ void FlatLutWriter::lutWrite(const char* filename, int pdg, float field, size_t } lutHeader.mass = particle->Mass(); - const int q = std::abs(particle->Charge()) / 3; + const int q = std::abs(static_cast(particle->Charge())) / 3; if (q <= 0) { LOGF(error, "Negative or null charge (%f) for pdg code %d", particle->Charge(), pdg); lutFile.close(); @@ -290,7 +291,7 @@ void FlatLutWriter::lutWrite(const char* filename, int pdg, float field, size_t LOGF(info, "Writing nch bin %d/%d", inch, nnch); auto nch = lutHeader.nchmap.eval(inch); lutEntry.nch = nch; - fat.setdNdEtaCent(nch); + fat.setdNdEtaCent(static_cast(nch)); for (int irad = 0; irad < nrad; ++irad) { for (int ieta = 0; ieta < neta; ++ieta) { @@ -379,10 +380,9 @@ void FlatLutWriter::lutWrite(const char* filename, int pdg, float field, size_t void FlatLutWriter::diagonalise(lutEntry_t& lutEntry) { - static constexpr int kEig = 5; - TMatrixDSym m(kEig); + TMatrixDSym m(kNumEigenModes); - for (int i = 0, k = 0; i < kEig; ++i) { + for (int i = 0, k = 0; i < kNumEigenModes; ++i) { for (int j = 0; j < i + 1; ++j, ++k) { m(i, j) = lutEntry.covm[k]; m(j, i) = lutEntry.covm[k]; @@ -393,40 +393,49 @@ void FlatLutWriter::diagonalise(lutEntry_t& lutEntry) // Eigenvalues const TVectorD& eigenVal = eigen.GetEigenValues(); - for (int i = 0; i < kEig; ++i) + for (int i = 0; i < kNumEigenModes; ++i) { lutEntry.eigval[i] = eigenVal[i]; + } // Eigenvectors TMatrixD eigenVec = eigen.GetEigenVectors(); - for (int i = 0; i < kEig; ++i) - for (int j = 0; j < kEig; ++j) + for (int i = 0; i < kNumEigenModes; ++i) { + for (int j = 0; j < kNumEigenModes; ++j) { lutEntry.eigvec[i][j] = eigenVec[i][j]; + } + } // Inverse eigenvectors eigenVec.Invert(); - for (int i = 0; i < kEig; ++i) - for (int j = 0; j < kEig; ++j) + for (int i = 0; i < kNumEigenModes; ++i) { + for (int j = 0; j < kNumEigenModes; ++j) { lutEntry.eiginv[i][j] = eigenVec[i][j]; + } + } } TGraph* FlatLutWriter::lutRead(const char* filename, int pdg, int what, int vs, float nch, float radius, float eta, float pt) { LOGF(info, "Reading LUT file: %s", filename); - static const int kNch = 0; - static const int kEta = 1; - static const int kPt = 2; + enum VsType : uint8_t { + kNch = 0, + kEta = 1, + kPt = 2 + }; - static const int kEfficiency = 0; - static const int kEfficiency2 = 1; - static const int kEfficiencyInnerTOF = 2; - static const int kEfficiencyOuterTOF = 3; - static const int kPtResolution = 4; - static const int kRPhiResolution = 5; - static const int kZResolution = 6; + enum WhatType : uint8_t { + kEfficiency = 0, + kEfficiency2 = 1, + kEfficiencyInnerTOF = 2, + kEfficiencyOuterTOF = 3, + kPtResolution = 4, + kRPhiResolution = 5, + kZResolution = 6 + }; // Use TrackSmearer to load and access the LUT - o2::delphes::TrackSmearer smearer; + o2::fastsim::TrackSmearer smearer; if (!smearer.loadTable(pdg, filename)) { LOGF(error, "Failed to load LUT from %s", filename); return nullptr; @@ -452,7 +461,7 @@ TGraph* FlatLutWriter::lutRead(const char* filename, int pdg, int what, int vs, lutMap = lutHeader->ptmap; break; default: - LOGF(error, "Unknown vs: %d", vs); + LOG(fatal) << "Unknown vs: " << vs; return nullptr; } @@ -475,6 +484,10 @@ TGraph* FlatLutWriter::lutRead(const char* filename, int pdg, int what, int vs, LOGF(info, "Plot versus Pt"); g->GetXaxis()->SetTitle("p_{T} (GeV/c)"); break; + default: + LOG(fatal) << "Unknown vs: " << vs; + delete g; + return nullptr; } switch (what) { @@ -507,7 +520,7 @@ TGraph* FlatLutWriter::lutRead(const char* filename, int pdg, int what, int vs, g->GetYaxis()->SetTitle("Z Resolution (#mum)"); break; default: - LOGF(error, "Unknown what: %d", what); + LOG(fatal) << "Unknown what: " << what; delete g; return nullptr; } @@ -525,6 +538,10 @@ TGraph* FlatLutWriter::lutRead(const char* filename, int pdg, int what, int vs, case kPt: pt = lutMap.eval(i); break; + default: + LOG(fatal) << "Unknown vs: " << vs; + delete g; + return nullptr; } float eff = 0.f; @@ -549,6 +566,10 @@ TGraph* FlatLutWriter::lutRead(const char* filename, int pdg, int what, int vs, case kPt: cen = lutEntry->pt; break; + default: + LOG(fatal) << "Unknown vs: " << vs; + delete g; + return nullptr; } double val = 0.f; @@ -575,8 +596,9 @@ TGraph* FlatLutWriter::lutRead(const char* filename, int pdg, int what, int vs, val = std::sqrt(lutEntry->covm[1]) * 1.e4f; // z resolution (um) break; default: - LOGF(error, "Unknown what: %d", what); - break; + LOG(fatal) << "Unknown what: " << what; + delete g; + return nullptr; } g->AddPoint(cen, val); } diff --git a/ALICE3/Core/FlatLutWriter.h b/ALICE3/Core/FlatLutWriter.h index fd29a174c86..33de44dc8f8 100644 --- a/ALICE3/Core/FlatLutWriter.h +++ b/ALICE3/Core/FlatLutWriter.h @@ -23,7 +23,7 @@ #include namespace o2::fastsim { -using lutEntry_t = o2::delphes::lutEntry_t; +using lutEntry_t = o2::fastsim::lutEntry_t; /** * @brief LUT writer using flat binary format * @@ -39,10 +39,10 @@ class FlatLutWriter FlatLutWriter() = default; // Setters for binning configuration - void setBinningNch(bool log, int nbins, float min, float max) { mNchBinning = {log, nbins, min, max}; } - void setBinningRadius(bool log, int nbins, float min, float max) { mRadiusBinning = {log, nbins, min, max}; } - void setBinningEta(bool log, int nbins, float min, float max) { mEtaBinning = {log, nbins, min, max}; } - void setBinningPt(bool log, int nbins, float min, float max) { mPtBinning = {log, nbins, min, max}; } + void setBinningNch(bool log, int nbins, float min, float max) { mNchBinning = {.log = log, .nbins = nbins, .min = min, .max = max}; } + void setBinningRadius(bool log, int nbins, float min, float max) { mRadiusBinning = {.log = log, .nbins = nbins, .min = min, .max = max}; } + void setBinningEta(bool log, int nbins, float min, float max) { mEtaBinning = {.log = log, .nbins = nbins, .min = min, .max = max}; } + void setBinningPt(bool log, int nbins, float min, float max) { mPtBinning = {.log = log, .nbins = nbins, .min = min, .max = max}; } void setEtaMaxBarrel(float eta) { etaMaxBarrel = eta; } void setAtLeastHits(int n) { mAtLeastHits = n; } @@ -59,7 +59,7 @@ class FlatLutWriter const float nch = 1.0f); void print() const; - bool fwdSolve(float* covm, float pt = 0.1f, float eta = 0.0f, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion]); + bool fwdSolve(o2::fastsim::CovarianceArray covm, float pt = 0.1f, float eta = 0.0f, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion]); bool fwdPara(lutEntry_t& lutEntry, float pt = 0.1f, float eta = 0.0f, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion], float Bfield = 0.5f); void lutWrite(const char* filename = "lutCovm.dat", int pdg = 211, float field = 0.2f, size_t itof = 0, size_t otof = 0); TGraph* lutRead(const char* filename, int pdg, int what, int vs, float nch = 0.f, float radius = 0.f, float eta = 0.f, float pt = 0.f); @@ -84,13 +84,13 @@ class FlatLutWriter int nbins; float min; float max; - std::string toString() const; + [[nodiscard]] std::string toString() const; }; - LutBinning mNchBinning = {true, 20, 0.5f, 3.5f}; - LutBinning mRadiusBinning = {false, 1, 0.0f, 100.0f}; - LutBinning mEtaBinning = {false, 80, -4.0f, 4.0f}; - LutBinning mPtBinning = {true, 200, -2.0f, 2.0f}; + LutBinning mNchBinning = {.log = true, .nbins = 20, .min = 0.5f, .max = 3.5f}; + LutBinning mRadiusBinning = {.log = false, .nbins = 1, .min = 0.0f, .max = 100.0f}; + LutBinning mEtaBinning = {.log = false, .nbins = 80, .min = -4.0f, .max = 4.0f}; + LutBinning mPtBinning = {.log = true, .nbins = 200, .min = -2.0f, .max = 2.0f}; }; } // namespace o2::fastsim diff --git a/ALICE3/Core/FlatTrackSmearer.cxx b/ALICE3/Core/FlatTrackSmearer.cxx index d90c8a8997b..5c937d8a5a2 100644 --- a/ALICE3/Core/FlatTrackSmearer.cxx +++ b/ALICE3/Core/FlatTrackSmearer.cxx @@ -28,9 +28,9 @@ #include #include -namespace o2::delphes +namespace o2::fastsim { -int TrackSmearer::getIndexPDG(int pdg) +int TrackSmearer::getIndexPDG(const int pdg) { switch (std::abs(pdg)) { case 11: @@ -56,7 +56,7 @@ int TrackSmearer::getIndexPDG(int pdg) } } -const char* TrackSmearer::getParticleName(int pdg) +const char* TrackSmearer::getParticleName(const int pdg) { switch (std::abs(pdg)) { case 11: @@ -82,15 +82,6 @@ const char* TrackSmearer::getParticleName(int pdg) } } -void TrackSmearer::setWhatEfficiency(int val) -{ - // FIXME: this really should be an enum - if (val > 2) { - throw framework::runtime_error_f("getLUTEntry: unknown efficiency type %d", mWhatEfficiency); - } - mWhatEfficiency = val; -} - bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) { if (!filename || filename[0] == '\0') { @@ -139,7 +130,7 @@ bool TrackSmearer::adoptTable(int pdg, const uint8_t* buffer, size_t size, bool return false; } try { - auto header = FlatLutData::PreviewHeader(buffer, size); + auto header = FlatLutData::previewHeader(buffer, size); if (header.pdg != pdg && !checkSpecialCase(pdg, header)) { LOGF(error, "LUT header PDG mismatch: expected %d, got %d", pdg, header.pdg); return false; @@ -162,7 +153,7 @@ bool TrackSmearer::viewTable(int pdg, const uint8_t* buffer, size_t size, bool f return false; } try { - auto header = FlatLutData::PreviewHeader(buffer, size); + auto header = FlatLutData::previewHeader(buffer, size); if (header.pdg != pdg && !checkSpecialCase(pdg, header)) { LOGF(error, "LUT header PDG mismatch: expected %d, got %d", pdg, header.pdg); return false; @@ -188,22 +179,14 @@ bool TrackSmearer::hasTable(int pdg) const return mLUTData[ipdg].isLoaded(); } -bool TrackSmearer::checkSpecialCase(int pdg, lutHeader_t const& header) +bool TrackSmearer::checkSpecialCase(const int pdg, lutHeader_t const& header) { // Validate header - bool specialPdgCase = false; - switch (pdg) { - case o2::constants::physics::kAlpha: - // Special case: Allow Alpha particles to use He3 LUT - specialPdgCase = (header.pdg == o2::constants::physics::kHelium3); - if (specialPdgCase) { - LOGF(info, "Alpha particles (PDG %d) will use He3 LUT data (PDG %d)", pdg, header.pdg); - } - break; - default: - break; + if (pdg == o2::constants::physics::kAlpha && (header.pdg == o2::constants::physics::kHelium3)) { // Special case: Allow Alpha particles to use He3 LUT + LOGF(info, "Alpha particles (PDG %d) will use He3 LUT data (PDG %d)", pdg, header.pdg); + return true; } - return specialPdgCase; + return false; } const lutHeader_t* TrackSmearer::getLUTHeader(int pdg) const @@ -235,7 +218,7 @@ const lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, cons static constexpr float kFractionThreshold = 0.5f; if (fraction > kFractionThreshold) { switch (mWhatEfficiency) { - case 1: { + case kWhatEfficiencyReco: { const auto* entry_curr = mLUTData[ipdg].getEntryRef(inch, irad, ieta, ipt); if (inch < header.nchmap.nbins - 1) { const auto* entry_next = mLUTData[ipdg].getEntryRef(inch + 1, irad, ieta, ipt); @@ -245,7 +228,7 @@ const lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, cons } break; } - case 2: { + case kWhatEfficiencyRecoAndTOF: { const auto* entry_curr = mLUTData[ipdg].getEntryRef(inch, irad, ieta, ipt); if (inch < header.nchmap.nbins - 1) { const auto* entry_next = mLUTData[ipdg].getEntryRef(inch + 1, irad, ieta, ipt); @@ -255,11 +238,13 @@ const lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, cons } break; } + default: + LOG(fatal) << "Unknown efficiency type: " << mWhatEfficiency; } } else { float comparisonValue = header.nchmap.log ? std::log10(nch) : nch; switch (mWhatEfficiency) { - case 1: { + case kWhatEfficiencyReco: { const auto* entry_curr = mLUTData[ipdg].getEntryRef(inch, irad, ieta, ipt); if (inch > 0 && comparisonValue < header.nchmap.max) { const auto* entry_prev = mLUTData[ipdg].getEntryRef(inch - 1, irad, ieta, ipt); @@ -269,7 +254,7 @@ const lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, cons } break; } - case 2: { + case kWhatEfficiencyRecoAndTOF: { const auto* entry_curr = mLUTData[ipdg].getEntryRef(inch, irad, ieta, ipt); if (inch > 0 && comparisonValue < header.nchmap.max) { const auto* entry_prev = mLUTData[ipdg].getEntryRef(inch - 1, irad, ieta, ipt); @@ -279,18 +264,22 @@ const lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, cons } break; } + default: + LOG(fatal) << "Unknown efficiency type: " << mWhatEfficiency; } } } else { const auto* entry = mLUTData[ipdg].getEntryRef(inch, irad, ieta, ipt); if (entry) { switch (mWhatEfficiency) { - case 1: + case kWhatEfficiencyReco: interpolatedEff = entry->eff; break; - case 2: + case kWhatEfficiencyRecoAndTOF: interpolatedEff = entry->eff2; break; + default: + LOG(fatal) << "Unknown efficiency type: " << mWhatEfficiency; } } } @@ -298,7 +287,7 @@ const lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, cons return mLUTData[ipdg].getEntryRef(inch, irad, ieta, ipt); } -bool TrackSmearer::smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, float interpolatedEff) +bool TrackSmearer::smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, const float interpolatedEff) { bool isReconstructed = true; @@ -306,10 +295,10 @@ bool TrackSmearer::smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, floa if (mUseEfficiency) { auto eff = 0.f; switch (mWhatEfficiency) { - case 1: + case kWhatEfficiencyReco: eff = lutEntry->eff; break; - case 2: + case kWhatEfficiencyRecoAndTOF: eff = lutEntry->eff2; break; } @@ -327,20 +316,19 @@ bool TrackSmearer::smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, floa } // Transform params vector and smear - static constexpr int kParSize = 5; - double params[kParSize]; - for (int i = 0; i < kParSize; ++i) { + EigenArrayDouble params; + for (int i = 0; i < kNumEigenModes; ++i) { double val = 0.; - for (int j = 0; j < kParSize; ++j) { + for (int j = 0; j < kNumEigenModes; ++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 < kParSize; ++i) { + for (int i = 0; i < kNumEigenModes; ++i) { double val = 0.; - for (int j = 0; j < kParSize; ++j) { + for (int j = 0; j < kNumEigenModes; ++j) { val += lutEntry->eiginv[j][i] * params[j]; } o2track.setParam(val, i); @@ -352,22 +340,21 @@ bool TrackSmearer::smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, floa } // Set covariance matrix - static constexpr int kCovMatSize = 15; - for (int i = 0; i < kCovMatSize; ++i) { + for (int i = 0; i < kNumCovarianceTerms; ++i) { o2track.setCov(lutEntry->covm[i], i); } return isReconstructed; } -bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch) +bool TrackSmearer::smearTrack(O2Track& o2track, const int pdg, const float nch) { auto pt = o2track.getPt(); - switch (pdg) { - case o2::constants::physics::kHelium3: - case -o2::constants::physics::kHelium3: - pt *= 2.f; - break; + if (pdg == o2::constants::physics::kHelium3 || + pdg == -o2::constants::physics::kHelium3 || + pdg == o2::constants::physics::kAlpha || + pdg == -o2::constants::physics::kAlpha) { + pt *= 2.f; } auto eta = o2track.getEta(); @@ -423,4 +410,4 @@ double TrackSmearer::getEfficiency(const int pdg, const float nch, const float e return efficiency; } -} // namespace o2::delphes +} // namespace o2::fastsim diff --git a/ALICE3/Core/FlatTrackSmearer.h b/ALICE3/Core/FlatTrackSmearer.h index e7943d7c1c0..6008a560e9b 100644 --- a/ALICE3/Core/FlatTrackSmearer.h +++ b/ALICE3/Core/FlatTrackSmearer.h @@ -17,11 +17,12 @@ #include #include +#include #include #include #include -namespace o2::delphes +namespace o2::fastsim { /** * @brief Track smearing with flat LUT backend @@ -37,47 +38,49 @@ class TrackSmearer bool adoptTable(int pdg, const uint8_t* buffer, size_t size, bool forceReload = false); bool viewTable(int pdg, const uint8_t* buffer, size_t size, bool forceReload = false); bool viewTable(int pdg, std::span const& span, bool forceReload = false); - bool hasTable(int pdg) const; + [[nodiscard]] bool hasTable(int pdg) const; void useEfficiency(bool val) { mUseEfficiency = val; } void interpolateEfficiency(bool val) { mInterpolateEfficiency = val; } void skipUnreconstructed(bool val) { mSkipUnreconstructed = val; } - void setWhatEfficiency(int val); + enum EfficiencyType : uint8_t { + kWhatEfficiencyReco = 0, + kWhatEfficiencyRecoAndTOF = 1 + }; + void setWhatEfficiency(EfficiencyType val) { mWhatEfficiency = val; } - const lutHeader_t* getLUTHeader(int pdg) const; - const lutEntry_t* getLUTEntry(int pdg, float nch, float radius, float eta, float pt, float& interpolatedEff) const; + [[nodiscard]] const lutHeader_t* getLUTHeader(const int pdg) const; + const lutEntry_t* getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff) const; - bool smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, float interpolatedEff); - bool smearTrack(O2Track& o2track, int pdg, float nch); + bool smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, const float interpolatedEff); + bool smearTrack(O2Track& o2track, const int pdg, const float nch); - double getPtRes(const int pdg, const float nch, const float eta, const float pt) const; - double getEtaRes(const int pdg, const float nch, const float eta, const float pt) const; - double getAbsPtRes(const int pdg, const float nch, const float eta, const float pt) const; - double getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt) const; - double getEfficiency(const int pdg, const float nch, const float eta, const float pt) const; + [[nodiscard]] double getPtRes(const int pdg, const float nch, const float eta, const float pt) const; + [[nodiscard]] double getEtaRes(const int pdg, const float nch, const float eta, const float pt) const; + [[nodiscard]] double getAbsPtRes(const int pdg, const float nch, const float eta, const float pt) const; + [[nodiscard]] double getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt) const; + [[nodiscard]] double getEfficiency(const int pdg, const float nch, const float eta, const float pt) const; - static int getIndexPDG(int pdg); - static const char* getParticleName(int pdg); + static int getIndexPDG(const int pdg); + static const char* getParticleName(const int pdg); - void setdNdEta(float val) { mdNdEta = val; } void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } protected: - static constexpr unsigned int nLUTs = 9; // Number of LUT available - FlatLutData mLUTData[nLUTs]; // Flat data storage + static constexpr unsigned int nLUTs = 9; // Number of LUT available, une per particle species (electron, muon, pion, kaon, proton, deuteron, triton, helium3, alpha) + std::array mLUTData; // Flat data storage bool mUseEfficiency = true; bool mInterpolateEfficiency = false; bool mSkipUnreconstructed = true; // don't smear tracks that are not reco'ed - int mWhatEfficiency = 1; - float mdNdEta = 1600.f; + EfficiencyType mWhatEfficiency = kWhatEfficiencyReco; private: o2::ccdb::BasicCCDBManager* mCcdbManager = nullptr; - static bool checkSpecialCase(int pdg, lutHeader_t const& header); + static bool checkSpecialCase(const int pdg, lutHeader_t const& header); }; -} // namespace o2::delphes +} // namespace o2::fastsim #endif // ALICE3_CORE_FLATTRACKSMEARER_H_ diff --git a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx index 7f27c2512ea..c40e575282e 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx @@ -78,9 +78,9 @@ struct OnTheFlyRichPid { Produces upgradeRichSignal; // necessary for particle charges - Service pdg; + Service pdg{}; // Necessary for LUTs - Service ccdb; + Service ccdb{}; // add rich-specific configurables here Configurable bRichNumberOfSectors{"bRichNumberOfSectors", 21, "barrel RICH number of sectors"}; @@ -132,7 +132,7 @@ struct OnTheFlyRichPid { o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; // Track smearer array, one per geometry - std::vector> mSmearer; + std::vector> mSmearer; // needed: random number generator for smearing TRandom3 pRandomNumberGenerator; @@ -296,12 +296,12 @@ struct OnTheFlyRichPid { if (flagRICHLoadDelphesLUTs) { for (int icfg = 0; icfg < nGeometries; ++icfg) { - mSmearer.emplace_back(std::make_unique()); + mSmearer.emplace_back(std::make_unique()); mSmearer[icfg]->setCcdbManager(ccdb.operator->()); std::map globalConfiguration = mGeoContainer.getConfiguration(icfg, "global"); for (const auto& entry : globalConfiguration) { int pdg = 0; - if (entry.first.find("lut") != 0) { + if (!entry.first.starts_with("lut")) { continue; } if (entry.first.find("lutEl") != std::string::npos) { @@ -437,18 +437,14 @@ struct OnTheFlyRichPid { bool checkMagfieldLimit(o2::track::TrackParCov track, const float radius, const float magneticField) { o2::math_utils::CircleXYf_t trcCircle; - float sna, csa; + float sna = NAN, csa = NAN; track.getCircleParams(magneticField, trcCircle, sna, csa); // distance between circle centers (one circle is at origin -> easy) float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC); // condition of circles touching - if not satisfied returned value if false - if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) { - return true; - } else { - return false; - } + return centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius); } /// returns sector hit by the track (if any), -1 otherwise @@ -476,9 +472,8 @@ struct OnTheFlyRichPid { const float rSecRichSquared = rSecRich * rSecRich; const float zSecRichSquared = zSecRich * zSecRich; return (rSecRichSquared + zSecRichSquared) / (rSecRich + zSecRich / std::tan(polar)); - } else { - return kErrorValue; } + return kErrorValue; } /// returns Cherenkov angle in rad (above threshold) or bad flag (below threshold) @@ -516,10 +511,7 @@ struct OnTheFlyRichPid { // Require at least 3 photons on average for real angle reconstruction static constexpr float kMinPhotons = 3.f; - if (meanNumberofDetectedPhotons <= kMinPhotons) { - return false; - } - return true; + return meanNumberofDetectedPhotons > kMinPhotons; } /// returns linear interpolation @@ -552,15 +544,13 @@ struct OnTheFlyRichPid { float interpolatedResRing = interpolate(eta, kEtaSampling[lowerIndex], kEtaSampling[upperIndex], kResRingSamplingWithAbsWalls[lowerIndex], kResRingSamplingWithAbsWalls[upperIndex]); // std::cout << "Interpolated y value: " << interpolatedY << std::endl; return interpolatedResRing; - } else { - float interpolatedResRing = interpolate(eta, kEtaSampling[lowerIndex], kEtaSampling[upperIndex], kResRingSamplingWithoutAbsWalls[lowerIndex], kResRingSamplingWithoutAbsWalls[upperIndex]); - // std::cout << "Interpolated y value: " << interpolatedY << std::endl; - return interpolatedResRing; } - } else { - // std::cout << "Unable to interpolate. Target x value is outside the range of available data." << std::endl; - return kErrorValue; - } + float interpolatedResRing = interpolate(eta, kEtaSampling[lowerIndex], kEtaSampling[upperIndex], kResRingSamplingWithoutAbsWalls[lowerIndex], kResRingSamplingWithoutAbsWalls[upperIndex]); + // std::cout << "Interpolated y value: " << interpolatedY << std::endl; + return interpolatedResRing; + + } // std::cout << "Unable to interpolate. Target x value is outside the range of available data." << std::endl; + return kErrorValue; } /// To account border effects in bRICH @@ -579,7 +569,7 @@ struct OnTheFlyRichPid { iSecor = jSector; } } - if (flagSector == false) { + if (!flagSector) { return kErrorValue; // <-- Returning negative value } float rSecRich = radCenters[iSecor].X(); @@ -613,8 +603,9 @@ struct OnTheFlyRichPid { float extractRingAngularResolution(const float eta, const float n, const float nGas, const float thicknessRad, const float thicknessGas, const float pixelSize, const float thetaCherenkov, const float tileZlength) { // Check if input angle is error value - if (thetaCherenkov <= kErrorValue + 1) + if (thetaCherenkov <= kErrorValue + 1) { return kErrorValue; + } // Parametrization variables (notation from https://doi.org/10.1016/0168-9002(94)90532-0) const float phiC = 0.; const float thetaP = 0.; @@ -686,8 +677,9 @@ struct OnTheFlyRichPid { // float nPhotons = (tileZlength / 2.0 > radius) ? n0Photons * multiplicitySpectrumFactor * (1.-(2.0*radius)/(o2::constants::math::PI*tileZlength)) : n0Photons * multiplicitySpectrumFactor * (1.-(2.0*radius)/(o2::constants::math::PI*tileZlength) - (2.0/(tileZlength*o2::constants::math::PI))*(-(tileZlength/(2.0))*std::acos(tileZlength/(2.0*radius)) + radius*std::sqrt(1.-std::pow(tileZlength/(2.0*radius),2.0)))); // Considering "exact" resolution (eta by eta) const float nPhotons = n0Photons * multiplicitySpectrumFactor * fractionPhotonsProjectiveRICH(eta, tileZlength, radius); - if (nPhotons <= kErrorValue + 1) + if (nPhotons <= kErrorValue + 1) { return kErrorValue; + } // Ring angular resolution const float ringAngularResolution = singlePhotonAngularResolution / std::sqrt(nPhotons); return ringAngularResolution; @@ -736,8 +728,9 @@ struct OnTheFlyRichPid { float dNdEta = 0.f; if (flagRICHLoadDelphesLUTs) { for (const auto& track : tracks) { - if (!track.has_mcParticle()) + if (!track.has_mcParticle()) { continue; + } auto mcParticle = track.mcParticle(); if (std::abs(mcParticle.eta()) > multiplicityEtaRange) { continue; diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index ac844c857b4..98509cad615 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -61,26 +61,17 @@ #include #include #include +#include #include #include #include +#include #include #include -#include - using namespace o2; using namespace o2::framework; -std::array, 9> h2dInnerTimeResTrack; -std::array, 9> h2dInnerTimeResTotal; -std::array, 9> h2dOuterTimeResTrack; -std::array, 9> h2dOuterTimeResTotal; -std::array, 9>, 9> h2dInnerNsigmaTrue; -std::array, 9>, 9> h2dOuterNsigmaTrue; -std::array, 9>, 9> h2dInnerDeltaTrue; -std::array, 9>, 9> h2dOuterDeltaTrue; - struct OnTheFlyTofPid { Produces upgradeTofMC; Produces upgradeTof; @@ -88,9 +79,9 @@ struct OnTheFlyTofPid { Produces upgradeTofShortLived; // necessary for particle charges - Service pdg; + Service pdg{}; // Necessary for LUTs - Service ccdb; + Service ccdb{}; // these are the settings governing the TOF layers to be used // note that there are two layers foreseen for now: inner and outer TOF @@ -141,7 +132,7 @@ struct OnTheFlyTofPid { o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; // Track smearer array, one per geometry - std::vector> mSmearer; + std::vector> mSmearer; // needed: random number generator for smearing TRandom3 pRandomNumberGenerator; @@ -150,45 +141,66 @@ struct OnTheFlyTofPid { HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; OutputObj listEfficiency{"efficiency"}; - enum ParticleType : int { El = 0, // electron - Mu, // muon - Pi, // pion - Ka, // kaon - Pr, // proton - Sp, // sigma plus - Sm, // sigma minus - Xi, // xi - Om, // omega - De, // deuteron - Tr, // triton - He, // helium 3 - Al, // alpha - NParticles }; + enum ParticleId : int { El = 0, // electron + Mu, // muon + Pi, // pion + Ka, // kaon + Pr, // proton + Sp, // sigma plus + Sm, // sigma minus + Xi, // xi + Om, // omega + De, // deuteron + Tr, // triton + He, // helium 3 + Al, // alpha + NParticles }; + + std::array, NParticles> h2dInnerTimeResTrack; + std::array, NParticles> h2dInnerTimeResTotal; + std::array, NParticles> h2dOuterTimeResTrack; + std::array, NParticles> h2dOuterTimeResTotal; + std::array, NParticles>, NParticles> h2dInnerNsigmaTrue; + std::array, NParticles>, NParticles> h2dOuterNsigmaTrue; + std::array, NParticles>, NParticles> h2dInnerDeltaTrue; + std::array, NParticles>, NParticles> h2dOuterDeltaTrue; struct ParticleInfo { - const char* texName; - const char* name; - ParticleType type; - int pdgCode; - double mass; - float charge; + const std::string_view texName; + const std::string_view name; + const ParticleId type; + const int pdgCode; + const double mass; + const float charge; }; - static constexpr ParticleInfo Particles[NParticles] = { - {"#it{e}", "Elec", El, PDG_t::kElectron, o2::constants::physics::MassElectron, 1.f}, - {"#it{#mu}", "Muon", Mu, PDG_t::kMuonMinus, o2::constants::physics::MassMuon, 1.f}, - {"#it{#pi}", "Pion", Pi, PDG_t::kPiPlus, o2::constants::physics::MassPionCharged, 1.f}, - {"#it{K}", "Kaon", Ka, PDG_t::kKPlus, o2::constants::physics::MassKaonCharged, 1.f}, - {"#it{p}", "Prot", Pr, PDG_t::kProton, o2::constants::physics::MassProton, 1.f}, - {"#it{#SigmaPlus}", "Sigp", Sp, PDG_t::kSigmaPlus, o2::constants::physics::MassSigmaPlus, 1.f}, - {"#it{#SigmaMinus}", "Sigm", Sm, PDG_t::kSigmaMinus, o2::constants::physics::MassSigmaMinus, 1.f}, - {"#it{#Xi}", "Xi", Xi, PDG_t::kXiMinus, o2::constants::physics::MassXiMinus, 1.f}, - {"#it{#Omega}", "Omeg", Om, PDG_t::kOmegaMinus, o2::constants::physics::MassOmegaMinus, 1.f}, - {"#it{d}", "Deut", De, o2::constants::physics::kDeuteron, o2::constants::physics::MassDeuteron, 1.f}, - {"#it{t}", "Trit", Tr, o2::constants::physics::kTriton, o2::constants::physics::MassTriton, 1.f}, - {"^{3}He", "He", He, o2::constants::physics::kHelium3, o2::constants::physics::MassHelium3, 2.f}, - {"#it{#alpha}", "Al", Al, o2::constants::physics::kAlpha, o2::constants::physics::MassAlpha, 2.f}, - }; + static constexpr ParticleInfo particleEl{.texName = "#it{e}", .name = "Elec", .type = El, .pdgCode = PDG_t::kElectron, .mass = o2::constants::physics::MassElectron, .charge = 1.f}; + static constexpr ParticleInfo particleMu{.texName = "#it{#mu}", .name = "Muon", .type = Mu, .pdgCode = PDG_t::kMuonMinus, .mass = o2::constants::physics::MassMuon, .charge = 1.f}; + static constexpr ParticleInfo particlePi{.texName = "#it{#pi}", .name = "Pion", .type = Pi, .pdgCode = PDG_t::kPiPlus, .mass = o2::constants::physics::MassPionCharged, .charge = 1.f}; + static constexpr ParticleInfo particleKa{.texName = "#it{K}", .name = "Kaon", .type = Ka, .pdgCode = PDG_t::kKPlus, .mass = o2::constants::physics::MassKaonCharged, .charge = 1.f}; + static constexpr ParticleInfo particlePr{.texName = "#it{p}", .name = "Prot", .type = Pr, .pdgCode = PDG_t::kProton, .mass = o2::constants::physics::MassProton, .charge = 1.f}; + static constexpr ParticleInfo particleSp{.texName = "#it{#SigmaPlus}", .name = "Sigp", .type = Sp, .pdgCode = PDG_t::kSigmaPlus, .mass = o2::constants::physics::MassSigmaPlus, .charge = 1.f}; + static constexpr ParticleInfo particleSm{.texName = "#it{#SigmaMinus}", .name = "Sigm", .type = Sm, .pdgCode = PDG_t::kSigmaMinus, .mass = o2::constants::physics::MassSigmaMinus, .charge = 1.f}; + static constexpr ParticleInfo particleXi{.texName = "#it{#Xi}", .name = "Xi", .type = Xi, .pdgCode = PDG_t::kXiMinus, .mass = o2::constants::physics::MassXiMinus, .charge = 1.f}; + static constexpr ParticleInfo particleOm{.texName = "#it{#Omega}", .name = "Omeg", .type = Om, .pdgCode = PDG_t::kOmegaMinus, .mass = o2::constants::physics::MassOmegaMinus, .charge = 1.f}; + static constexpr ParticleInfo particleDe{.texName = "#it{d}", .name = "Deut", .type = De, .pdgCode = o2::constants::physics::kDeuteron, .mass = o2::constants::physics::MassDeuteron, .charge = 1.f}; + static constexpr ParticleInfo particleTr{.texName = "#it{t}", .name = "Trit", .type = Tr, .pdgCode = o2::constants::physics::kTriton, .mass = o2::constants::physics::MassTriton, .charge = 1.f}; + static constexpr ParticleInfo particleHe{.texName = "^{3}He", .name = "He", .type = He, .pdgCode = o2::constants::physics::kHelium3, .mass = o2::constants::physics::MassHelium3, .charge = 2.f}; + static constexpr ParticleInfo particleAl{.texName = "#it{#alpha}", .name = "Al", .type = Al, .pdgCode = o2::constants::physics::kAlpha, .mass = o2::constants::physics::MassAlpha, .charge = 2.f}; + + static constexpr std::array Particles = {particleEl, + particleMu, + particlePi, + particleKa, + particlePr, + particleSp, + particleSm, + particleXi, + particleOm, + particleDe, + particleTr, + particleHe, + particleAl}; bool doQaForParticle(const int pdgCode) { @@ -217,12 +229,12 @@ struct OnTheFlyTofPid { if (simConfig.flagTOFLoadDelphesLUTs) { for (int icfg = 0; icfg < nGeometries; ++icfg) { const std::string histPath = "Configuration_" + std::to_string(icfg) + "/"; - mSmearer.emplace_back(std::make_unique()); + mSmearer.emplace_back(std::make_unique()); mSmearer[icfg]->setCcdbManager(ccdb.operator->()); std::map globalConfiguration = mGeoContainer.getConfiguration(icfg, "global"); for (const auto& entry : globalConfiguration) { int pdg = 0; - if (entry.first.find("lut") != 0) { + if (!entry.first.starts_with("lut")) { continue; } if (entry.first.find("lutEl") != std::string::npos) { @@ -312,36 +324,38 @@ struct OnTheFlyTofPid { continue; } - auto addHistogram = [&](const std::string& name, const AxisSpec& axis) { + auto addHistoVsMomentum = [&](const std::string& name, const AxisSpec& axis) { return histos.add(name, "", kTH2F, {axisMomentum, axis}); }; - - const AxisSpec axisTrackTimeRes{plotsConfig.nBinsTimeRes, 0.0f, +200.0f, std::string("Track time resolution - ") + Particles[iTrue].texName + " (ps)"}; - h2dInnerTimeResTrack[iTrue] = addHistogram(std::string("iTOF/res/h2dInnerTimeResTrack") + Particles[iTrue].name + "VsP", axisTrackTimeRes); - h2dOuterTimeResTrack[iTrue] = addHistogram(std::string("oTOF/res/h2dOuterTimeResTrack") + Particles[iTrue].name + "VsP", axisTrackTimeRes); - const AxisSpec axisTotalTimeRes{plotsConfig.nBinsTimeRes, 0.0f, +200.0f, std::string("Total time resolution - ") + Particles[iTrue].texName + " (ps)"}; - h2dInnerTimeResTotal[iTrue] = addHistogram(std::string("iTOF/res/h2dInnerTimeResTotal") + Particles[iTrue].name + "VsP", axisTotalTimeRes); - h2dOuterTimeResTotal[iTrue] = addHistogram(std::string("oTOF/res/h2dOuterTimeResTotal") + Particles[iTrue].name + "VsP", axisTotalTimeRes); + const auto& pNameTrue = Particles[iTrue].name; + + const AxisSpec axisTrackTimeRes{plotsConfig.nBinsTimeRes, 0.0f, +200.0f, std::format("Track time resolution - {} (ps)", Particles[iTrue].texName)}; + h2dInnerTimeResTrack[iTrue] = addHistoVsMomentum(std::format("iTOF/res/h2dInnerTimeResTrack{}VsP", pNameTrue), axisTrackTimeRes); + h2dOuterTimeResTrack[iTrue] = addHistoVsMomentum(std::format("oTOF/res/h2dOuterTimeResTrack{}VsP", pNameTrue), axisTrackTimeRes); + const AxisSpec axisTotalTimeRes{plotsConfig.nBinsTimeRes, 0.0f, +200.0f, std::format("Total time resolution - {} (ps)", Particles[iTrue].texName)}; + h2dInnerTimeResTotal[iTrue] = addHistoVsMomentum(std::format("iTOF/res/h2dInnerTimeResTotal{}VsP", pNameTrue), axisTotalTimeRes); + h2dOuterTimeResTotal[iTrue] = addHistoVsMomentum(std::format("oTOF/res/h2dOuterTimeResTotal{}VsP", pNameTrue), axisTotalTimeRes); for (int iHyp = 0; iHyp < NParticles; iHyp++) { if (!doQaForParticle(Particles[iHyp].pdgCode)) { continue; } + const auto& pNameHypo = Particles[iHyp].texName; - std::string nameTitleInner = std::string("h2dInnerNsigmaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis"; - std::string nameTitleOuter = std::string("h2dOuterNsigmaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis"; - std::string nameTitleInnerDelta = std::string("h2dInnerDeltaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis"; - std::string nameTitleOuterDelta = std::string("h2dOuterDeltaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis"; + const std::string nameTitleInner = std::format("h2dInnerNsigmaTrue{}Vs{}", pNameTrue, pNameHypo); + const std::string nameTitleOuter = std::format("h2dOuterNsigmaTrue{}Vs{}", pNameTrue, pNameHypo); + const std::string nameTitleInnerDelta = std::format("h2dInnerDeltaTrue{}Vs{}", pNameTrue, pNameHypo); + const std::string nameTitleOuterDelta = std::format("h2dOuterDeltaTrue{}Vs{}", pNameTrue, pNameHypo); const AxisSpec axisX{plotsConfig.doSeparationVsPt.value ? axisPt : axisMomentum}; - const AxisSpec axisNsigmaCorrect{plotsConfig.nBinsNsigmaCorrectSpecies, plotsConfig.minNsigmaRange, plotsConfig.maxNsigmaRange, std::string("N#sigma - True ") + Particles[iTrue].texName + " vs " + Particles[iHyp].texName + " hypothesis"}; - const AxisSpec axisDeltaCorrect{plotsConfig.nBinsDeltaCorrectSpecies, plotsConfig.minDeltaRange, plotsConfig.maxDeltaRange, std::string("#Delta - True ") + Particles[iTrue].texName + " vs " + Particles[iHyp].texName + " hypothesis"}; - const AxisSpec axisNsigmaWrong{plotsConfig.nBinsNsigmaWrongSpecies, plotsConfig.minNsigmaRange, plotsConfig.maxNsigmaRange, std::string("N#sigma - True ") + Particles[iTrue].texName + " vs " + Particles[iHyp].texName + " hypothesis"}; - const AxisSpec axisDeltaWrong{plotsConfig.nBinsDeltaWrongSpecies, plotsConfig.minDeltaRange, plotsConfig.maxDeltaRange, std::string("#Delta - True ") + Particles[iTrue].texName + " vs " + Particles[iHyp].texName + " hypothesis"}; + const AxisSpec axisNsigmaCorrect{plotsConfig.nBinsNsigmaCorrectSpecies, plotsConfig.minNsigmaRange, plotsConfig.maxNsigmaRange, std::format("N#sigma - True {} vs {} hypothesis", Particles[iTrue].texName, Particles[iHyp].texName)}; + const AxisSpec axisDeltaCorrect{plotsConfig.nBinsDeltaCorrectSpecies, plotsConfig.minDeltaRange, plotsConfig.maxDeltaRange, std::format("#Delta - True {} vs {} hypothesis", Particles[iTrue].texName, Particles[iHyp].texName)}; + const AxisSpec axisNsigmaWrong{plotsConfig.nBinsNsigmaWrongSpecies, plotsConfig.minNsigmaRange, plotsConfig.maxNsigmaRange, std::format("N#sigma - True {} vs {} hypothesis", Particles[iTrue].texName, Particles[iHyp].texName)}; + const AxisSpec axisDeltaWrong{plotsConfig.nBinsDeltaWrongSpecies, plotsConfig.minDeltaRange, plotsConfig.maxDeltaRange, std::format("#Delta - True {} vs {} hypothesis", Particles[iTrue].texName, Particles[iHyp].texName)}; const AxisSpec axisNSigma{iTrue == iHyp ? axisNsigmaCorrect : axisNsigmaWrong}; const AxisSpec axisDelta{iTrue == iHyp ? axisDeltaCorrect : axisDeltaWrong}; - h2dInnerNsigmaTrue[iTrue][iHyp] = histos.add(std::string("iTOF/nsigma/h2dInnerNsigmaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis", nameTitleInner.c_str(), kTH2F, {axisX, axisNSigma}); - h2dOuterNsigmaTrue[iTrue][iHyp] = histos.add(std::string("oTOF/nsigma/h2dOuterNsigmaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis", nameTitleOuter.c_str(), kTH2F, {axisX, axisNSigma}); - h2dInnerDeltaTrue[iTrue][iHyp] = histos.add(std::string("iTOF/delta/h2dInnerDeltaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis", nameTitleInnerDelta.c_str(), kTH2F, {axisX, axisDelta}); - h2dOuterDeltaTrue[iTrue][iHyp] = histos.add(std::string("oTOF/delta/h2dOuterDeltaTrue") + Particles[iTrue].name + "Vs" + Particles[iHyp].name + "Hypothesis", nameTitleOuterDelta.c_str(), kTH2F, {axisX, axisDelta}); + h2dInnerNsigmaTrue[iTrue][iHyp] = histos.add(std::format("iTOF/nsigma/h2dInnerNsigmaTrue{}Vs{}", pNameTrue, pNameHypo), nameTitleInner.c_str(), kTH2F, {axisX, axisNSigma}); + h2dOuterNsigmaTrue[iTrue][iHyp] = histos.add(std::format("oTOF/nsigma/h2dOuterNsigmaTrue{}Vs{}", pNameTrue, pNameHypo), nameTitleOuter.c_str(), kTH2F, {axisX, axisNSigma}); + h2dInnerDeltaTrue[iTrue][iHyp] = histos.add(std::format("iTOF/delta/h2dInnerDeltaTrue{}Vs{}", pNameTrue, pNameHypo), nameTitleInnerDelta.c_str(), kTH2F, {axisX, axisDelta}); + h2dOuterDeltaTrue[iTrue][iHyp] = histos.add(std::format("oTOF/delta/h2dOuterDeltaTrue{}Vs{}", pNameTrue, pNameHypo), nameTitleOuterDelta.c_str(), kTH2F, {axisX, axisDelta}); } } } @@ -368,11 +382,6 @@ struct OnTheFlyTofPid { public: ~TOFLayerEfficiency() { - if (0) { - hHitMap->SaveAs(Form("/tmp/%s.png", hHitMap->GetName())); - hHitMapInPixel->SaveAs(Form("/tmp/%s.png", hHitMapInPixel->GetName())); - hHitMapInPixelBefore->SaveAs(Form("/tmp/%s.png", hHitMapInPixelBefore->GetName())); - } delete axisZ; delete axisRPhi; @@ -384,11 +393,11 @@ struct OnTheFlyTofPid { } TOFLayerEfficiency(float r, float l, std::array pDimensions, float fIA, float m) - : layerRadius(r), layerLength(l), pixelDimensionZ(pDimensions[0]), pixelDimensionRPhi(pDimensions[1]), fractionInactive(fIA), magField(m) + : layerRadius(r), layerLength(l), pixelDimensionZ(pDimensions[0]), pixelDimensionRPhi(pDimensions[1]), fractionInactive(fIA), magField(m), axisZ(new TAxis(static_cast(layerLength / pixelDimensionZ), -layerLength / 2, layerLength)) { // Assuming square pixels for simplicity const float circumference = o2::constants::math::TwoPI * layerRadius; - axisZ = new TAxis(static_cast(layerLength / pixelDimensionZ), -layerLength / 2, layerLength); + axisRPhi = new TAxis(static_cast(circumference / pixelDimensionRPhi), 0.f, circumference); const float inactiveBorderRPhi = pixelDimensionRPhi * std::sqrt(fractionInactive) / 2; @@ -484,12 +493,12 @@ struct OnTheFlyTofPid { if (fractionInactive <= 0.f) { return true; } - float x, y, z; + float x = NAN, y = NAN, z = NAN; if (!track.getXatLabR(layerRadius, x, magField)) { LOG(debug) << "Could not propagate track to TOF layer at radius " << layerRadius << " cm"; return false; } - bool b; + bool b = false; ROOT::Math::PositionVector3D hit = track.getXYZGloAt(x, magField, b); if (!b) { LOG(debug) << "Could not get hit position at radius " << layerRadius << " cm"; @@ -640,8 +649,9 @@ struct OnTheFlyTofPid { // First we compute the number of charged particles in the event if LUTs are loaded float dNdEta = 0.f; for (const auto& track : tracks) { - if (!track.has_mcParticle()) + if (!track.has_mcParticle()) { continue; + } auto mcParticle = track.mcParticle(); if (std::abs(mcParticle.eta()) > simConfig.multiplicityEtaRange) { continue; @@ -672,9 +682,9 @@ struct OnTheFlyTofPid { if (!track.has_mcParticle()) { // should always be OK but check please upgradeTofMC(-999.f, -999.f, -999.f, -999.f); continue; - } else { - LOG(debug) << "Track without mcParticle found!"; } + LOG(debug) << "Track without mcParticle found!"; + const auto& mcParticle = track.mcParticle(); o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdg); @@ -772,7 +782,7 @@ struct OnTheFlyTofPid { if (etStatus) { histos.fill(HIST("h1dEventTimedelta"), eventCollisionTimePS - tzero[0]); } - static_cast(listEfficiency->At(0))->Fill(etStatus, dNdEta); + dynamic_cast(listEfficiency->At(0))->Fill(etStatus, dNdEta); } // Then we do a second loop to compute the measured quantities with the measured event time diff --git a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx index 1e400241f37..ca0bc59230d 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx @@ -379,7 +379,7 @@ struct OnTheFlyTracker { o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; // Track smearer array, one per geometry - std::vector> mSmearer; + std::vector> mSmearer; // Configuration defined at init time o2::fastsim::GeometryContainer mGeoContainer; float mMagneticField = 0.0f; @@ -442,7 +442,7 @@ struct OnTheFlyTracker { decayer.setBField(mMagneticField); for (int igeo = 0; igeo < nGeometries; ++igeo) { const std::string histPath = "Configuration_" + std::to_string(igeo) + "/"; - mSmearer.emplace_back(std::make_unique()); + mSmearer.emplace_back(std::make_unique()); mSmearer[igeo]->setCcdbManager(ccdb.operator->()); std::map globalConfiguration = mGeoContainer.getConfiguration(igeo, "global"); if (enablePrimarySmearing) { From 9f7c8aae3e4ddb0d2feccf84552571b37509e263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sun, 20 Sep 2026 23:00:24 +0200 Subject: [PATCH 02/13] Update FlatLutEntry.cxx --- ALICE3/Core/FlatLutEntry.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ALICE3/Core/FlatLutEntry.cxx b/ALICE3/Core/FlatLutEntry.cxx index b5551d261c7..d517e902747 100644 --- a/ALICE3/Core/FlatLutEntry.cxx +++ b/ALICE3/Core/FlatLutEntry.cxx @@ -66,15 +66,13 @@ float map_t::fracPositionWithinBin(float val) const { float width = (max - min) / nbins; int bin = 0; - float returnVal = kBinCenterOffset; if (log) { bin = static_cast((std::log10(val) - min) / width); - returnVal = ((std::log10(val) - min) / width) - bin; + return ((std::log10(val) - min) / width) - bin; } else { bin = static_cast((val - min) / width); - returnVal = val / width - bin; + return val / width - bin; } - return returnVal; } int map_t::find(float val) const From 7f92242b7522aad630c9ea79babbbb52854db3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sun, 20 Sep 2026 23:04:11 +0200 Subject: [PATCH 03/13] Update FlatLutEntry.cxx --- ALICE3/Core/FlatLutEntry.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ALICE3/Core/FlatLutEntry.cxx b/ALICE3/Core/FlatLutEntry.cxx index d517e902747..fe7a18a3ecf 100644 --- a/ALICE3/Core/FlatLutEntry.cxx +++ b/ALICE3/Core/FlatLutEntry.cxx @@ -64,20 +64,18 @@ void lutEntry_t::print() const float map_t::fracPositionWithinBin(float val) const { - float width = (max - min) / nbins; - int bin = 0; + const float width = (max - min) / nbins; + const int bin = find(val); if (log) { - bin = static_cast((std::log10(val) - min) / width); return ((std::log10(val) - min) / width) - bin; } else { - bin = static_cast((val - min) / width); return val / width - bin; } } int map_t::find(float val) const { - float width = (max - min) / nbins; + const float width = (max - min) / nbins; int bin = 0; if (log) { bin = static_cast((std::log10(val) - min) / width); From 8a2f28108f25a7b71a28d6d2b5529c43cc3a53f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sun, 20 Sep 2026 21:30:53 +0200 Subject: [PATCH 04/13] Fixes --- ALICE3/Core/FlatLutEntry.cxx | 9 +++--- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 36 +++++++++++++-------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/ALICE3/Core/FlatLutEntry.cxx b/ALICE3/Core/FlatLutEntry.cxx index fe7a18a3ecf..ad8bb3b8e38 100644 --- a/ALICE3/Core/FlatLutEntry.cxx +++ b/ALICE3/Core/FlatLutEntry.cxx @@ -68,9 +68,8 @@ float map_t::fracPositionWithinBin(float val) const const int bin = find(val); if (log) { return ((std::log10(val) - min) / width) - bin; - } else { - return val / width - bin; } + return val / width - bin; } int map_t::find(float val) const @@ -156,12 +155,12 @@ lutEntry_t* FlatLutData::getEntry(int nch_bin, int rad_bin, int eta_bin, int pt_ const lutHeader_t& FlatLutData::getHeaderRef() const { - return *reinterpret_cast(mDataRef.data()); + return *static_cast(static_cast(mDataRef.data())); } lutHeader_t& FlatLutData::getHeader() { - return *reinterpret_cast(mData.data()); + return *static_cast(static_cast(mData.data())); } void FlatLutData::updateRef() @@ -221,7 +220,7 @@ lutHeader_t FlatLutData::previewHeader(const uint8_t* buffer, size_t size) if (size < sizeof(lutHeader_t)) { throw framework::runtime_error_f("Buffer too small for LUT header: expected at least %zu, got %zu", sizeof(lutHeader_t), size); } - const auto* header = reinterpret_cast(buffer); + const auto* header = static_cast(static_cast(buffer)); if (!header->checkVersion()) { throw framework::runtime_error_f("LUT header version mismatch: expected %d, got %d", LUTCOVM_VERSION, header->version); } diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index 98509cad615..c64fe1fecd9 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -228,7 +228,6 @@ struct OnTheFlyTofPid { pRandomNumberGenerator.SetSeed(0); // fully randomize if (simConfig.flagTOFLoadDelphesLUTs) { for (int icfg = 0; icfg < nGeometries; ++icfg) { - const std::string histPath = "Configuration_" + std::to_string(icfg) + "/"; mSmearer.emplace_back(std::make_unique()); mSmearer[icfg]->setCcdbManager(ccdb.operator->()); std::map globalConfiguration = mGeoContainer.getConfiguration(icfg, "global"); @@ -392,8 +391,13 @@ struct OnTheFlyTofPid { delete hHitMapInPixelBefore; } - TOFLayerEfficiency(float r, float l, std::array pDimensions, float fIA, float m) - : layerRadius(r), layerLength(l), pixelDimensionZ(pDimensions[0]), pixelDimensionRPhi(pDimensions[1]), fractionInactive(fIA), magField(m), axisZ(new TAxis(static_cast(layerLength / pixelDimensionZ), -layerLength / 2, layerLength)) + TOFLayerEfficiency(float r, float l, std::array pDimensions, float fIA, float m) : layerRadius(r), + layerLength(l), + pixelDimensionZ(pDimensions[0]), + pixelDimensionRPhi(pDimensions[1]), + fractionInactive(fIA), + magField(m), + axisZ(new TAxis(static_cast(layerLength / pixelDimensionZ), -layerLength / 2, layerLength)) { // Assuming square pixels for simplicity const float circumference = o2::constants::math::TwoPI * layerRadius; @@ -466,18 +470,22 @@ struct OnTheFlyTofPid { // LOG(warning) << "Local hit difference in z is bigger than the pixel size"; } hHitMapInPixelBefore->Fill(localZ, localRPhi); + enum PixelBin : int { kInactiveLeft = 0, + kInactiveRight = 1, + kInactiveBottom = 3, + kInactiveTop = 4 }; switch (axisInPixelRPhi->FindBin(localRPhi)) { - case 0: - case 1: - case 3: - case 4: + case kInactiveLeft: + case kInactiveRight: + case kInactiveBottom: + case kInactiveTop: return false; } switch (axisInPixelZ->FindBin(localZ)) { - case 0: - case 1: - case 3: - case 4: + case kInactiveLeft: + case kInactiveRight: + case kInactiveBottom: + case kInactiveTop: return false; } hHitMapInPixel->Fill(localZ, localRPhi); @@ -809,7 +817,7 @@ struct OnTheFlyTofPid { static std::array expectedTimeInnerTOF, expectedTimeOuterTOF; static std::array deltaTimeInnerTOF, deltaTimeOuterTOF; static std::array nSigmaInnerTOF, nSigmaOuterTOF; - float momentumHypotheses[NParticles]; // Store momentum hypothesis for each particle + std::array momentumHypotheses; // Store momentum hypothesis for each particle auto truePdgInfo = pdg->GetParticle(mcParticle.pdgCode()); float rigidity = momentum; // fallback to momentum if charge unknown @@ -866,8 +874,8 @@ struct OnTheFlyTofPid { double etaResolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-pseudorapidity)))) * std::sqrt(trkWithTime.mPseudorapidity.second); if (simConfig.flagTOFLoadDelphesLUTs) { if (mSmearer[collision.lutConfigId()]->hasTable(Particles[ii].pdgCode)) { // Only if the LUT for this particle was loaded - ptResolution = mSmearer[collision.lutConfigId()]->getAbsPtRes(Particles[ii].pdgCode, dNdEta, pseudorapidity, transverseMomentum); - etaResolution = mSmearer[collision.lutConfigId()]->getAbsEtaRes(Particles[ii].pdgCode, dNdEta, pseudorapidity, transverseMomentum); + ptResolution = mSmearer[collision.lutConfigId()]->getAbsPtRes(Particles[ii].pdgCode, pseudorapidity, dNdEta, transverseMomentum); + etaResolution = mSmearer[collision.lutConfigId()]->getAbsEtaRes(Particles[ii].pdgCode, pseudorapidity, dNdEta, transverseMomentum); } } const float innerTrackTimeReso = calculateTrackTimeResolutionAdvanced(transverseMomentum, pseudorapidity, ptResolution, etaResolution, Particles[ii].mass, simConfig.innerTOFRadius, mMagneticField); From 49d733d4638fb35aa6435e19530b1ab912ed4b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sun, 20 Sep 2026 23:26:08 +0200 Subject: [PATCH 05/13] FORMAT --- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index c64fe1fecd9..10dbda736e7 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -817,7 +817,7 @@ struct OnTheFlyTofPid { static std::array expectedTimeInnerTOF, expectedTimeOuterTOF; static std::array deltaTimeInnerTOF, deltaTimeOuterTOF; static std::array nSigmaInnerTOF, nSigmaOuterTOF; - std::array momentumHypotheses; // Store momentum hypothesis for each particle + std::array momentumHypotheses{}; // Store momentum hypothesis for each particle auto truePdgInfo = pdg->GetParticle(mcParticle.pdgCode()); float rigidity = momentum; // fallback to momentum if charge unknown From bd501c8a0f383ee118421015957145478c6ed459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 00:03:06 +0200 Subject: [PATCH 06/13] Fixes --- ALICE3/Core/FlatTrackSmearer.cxx | 6 ++--- ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx | 24 ++++++++++---------- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 18 +++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ALICE3/Core/FlatTrackSmearer.cxx b/ALICE3/Core/FlatTrackSmearer.cxx index 5c937d8a5a2..64c370d52a1 100644 --- a/ALICE3/Core/FlatTrackSmearer.cxx +++ b/ALICE3/Core/FlatTrackSmearer.cxx @@ -112,7 +112,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) LOGF(error, "LUT header PDG mismatch: expected %d, got %d; not loading", pdg, header.pdg); return false; } - } catch (framework::RuntimeErrorRef ref) { + } catch (framework::RuntimeErrorRef& ref) { LOGF(error, "%s", framework::error_from_ref(ref).what); return false; } @@ -136,7 +136,7 @@ bool TrackSmearer::adoptTable(int pdg, const uint8_t* buffer, size_t size, bool return false; } mLUTData[ipdg] = FlatLutData::AdoptFromBuffer(buffer, size); - } catch (framework::RuntimeErrorRef ref) { + } catch (framework::RuntimeErrorRef& ref) { LOGF(error, "%s", framework::error_from_ref(ref).what); } @@ -159,7 +159,7 @@ bool TrackSmearer::viewTable(int pdg, const uint8_t* buffer, size_t size, bool f return false; } mLUTData[ipdg] = FlatLutData::ViewFromBuffer(buffer, size); - } catch (framework::RuntimeErrorRef ref) { + } catch (framework::RuntimeErrorRef& ref) { LOGF(error, "%s", framework::error_from_ref(ref).what); } diff --git a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx index c40e575282e..529f1f7d0f5 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx @@ -78,7 +78,7 @@ struct OnTheFlyRichPid { Produces upgradeRichSignal; // necessary for particle charges - Service pdg{}; + Service pdgDatabase{}; // Necessary for LUTs Service ccdb{}; @@ -359,11 +359,11 @@ struct OnTheFlyRichPid { histos.add("hSectorID", "hSectorID", kTH1F, {axisSector}); const int kNspec = 9; // electron, muon, pion, kaon, proton, deuteron, triton, helium3, alpha - std::string particleNames1[kNspec] = {"#it{e}", "#it{#mu}", "#it{#pi}", "#it{K}", "#it{p}", "#it{d}", "#it{t}", "^{3}He", "#it{#alpha}"}; - std::string particleNames2[kNspec] = {"Elec", "Muon", "Pion", "Kaon", "Prot", "Deut", "Trit", "He3", "Al"}; + const std::array particleNames1 = {"#it{e}", "#it{#mu}", "#it{#pi}", "#it{K}", "#it{p}", "#it{d}", "#it{t}", "^{3}He", "#it{#alpha}"}; + const std::array particleNames2 = {"Elec", "Muon", "Pion", "Kaon", "Prot", "Deut", "Trit", "He3", "Al"}; for (int iTrue = 0; iTrue < kNspec; iTrue++) { - std::string nameTitleBarrelTrackRes = "h2dBarrelAngularResTrack" + particleNames2[iTrue] + "VsP"; - std::string nameTitleBarrelTotalRes = "h2dBarrelAngularResTotal" + particleNames2[iTrue] + "VsP"; + const std::string nameTitleBarrelTrackRes = "h2dBarrelAngularResTrack" + particleNames2[iTrue] + "VsP"; + const std::string nameTitleBarrelTotalRes = "h2dBarrelAngularResTotal" + particleNames2[iTrue] + "VsP"; const AxisSpec axisTrackAngularRes{static_cast(nBinsAngularRes), 0.0f, +5.0f, "Track angular resolution - " + particleNames1[iTrue] + " (mrad)"}; const AxisSpec axisTotalAngularRes{static_cast(nBinsAngularRes), 0.0f, +5.0f, "Total angular resolution - " + particleNames1[iTrue] + " (mrad)"}; histos.add(nameTitleBarrelTrackRes.c_str(), nameTitleBarrelTrackRes.c_str(), kTH2F, {axisMomentum, axisTrackAngularRes}); @@ -371,7 +371,7 @@ struct OnTheFlyRichPid { } for (int iTrue = 0; iTrue < kNspec; iTrue++) { for (int iHyp = 0; iHyp < kNspec; iHyp++) { - std::string nameTitle = "h2dBarrelNsigmaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis"; + const std::string nameTitle = "h2dBarrelNsigmaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis"; if (iTrue == iHyp) { const AxisSpec axisNsigmaCorrect{static_cast(nBinsNsigmaCorrectSpecies), -10.0f, +10.0f, "N#sigma - True " + particleNames1[iTrue] + " vs " + particleNames1[iHyp] + " hypothesis"}; histos.add(nameTitle.c_str(), nameTitle.c_str(), kTH2F, {axisMomentum, axisNsigmaCorrect}); @@ -578,9 +578,9 @@ struct OnTheFlyRichPid { // float zSecTof = detCenters[iSecor].Z(); const float rSecRichSquared = rSecRich * rSecRich; const float zSecRichSquared = zSecRich * zSecRich; - const float radiusRipple = (rSecRichSquared + zSecRichSquared) / (rSecRich + zSecRich / std::tan(polar)); - const float zRipple = radiusRipple / std::tan(polar); - const float absZ = std::hypot(radiusRipple - rSecRich, zRipple - zSecRich); + const float radRipple = (rSecRichSquared + zSecRichSquared) / (rSecRich + zSecRich / std::tan(polar)); + const float zRipple = radRipple / std::tan(polar); + const float absZ = std::hypot(radRipple - rSecRich, zRipple - zSecRich); float fraction = 1.; if (tileZlength / 2. - absZ < radius) { fraction = fraction - (1. / o2::constants::math::PI) * std::acos((tileZlength / 2. - absZ) / radius); @@ -727,7 +727,7 @@ struct OnTheFlyRichPid { // First we compute the number of charged particles in the event float dNdEta = 0.f; if (flagRICHLoadDelphesLUTs) { - for (const auto& track : tracks) { + for (const auto& track : tracks) { // We first compute the number of charged particles in the event if (!track.has_mcParticle()) { continue; } @@ -738,7 +738,7 @@ struct OnTheFlyRichPid { if (mcParticle.has_daughters()) { continue; } - const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + const auto& pdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); if (!pdgInfo) { // LOG(warning) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; continue; @@ -772,7 +772,7 @@ struct OnTheFlyRichPid { } // get particle to calculate Cherenkov angle and resolution - auto pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + const& auto pdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); if (pdgInfo == nullptr) { fillDummyValues(); continue; diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index 10dbda736e7..d51564006e6 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -79,7 +79,7 @@ struct OnTheFlyTofPid { Produces upgradeTofShortLived; // necessary for particle charges - Service pdg{}; + Service pdgDatabase{}; // Necessary for LUTs Service ccdb{}; @@ -567,7 +567,7 @@ struct OnTheFlyTofPid { // Todo: check the different mass hypothesis iteratively for (const auto& track : tracks) { - auto pdgInfo = pdg->GetParticle(track.mPdgCode); + auto pdgInfo = pdgDatabase->GetParticle(track.mPdgCode); if (pdgInfo == nullptr) { continue; } @@ -626,12 +626,12 @@ struct OnTheFlyTofPid { { // Compute tracking contribution to timing using the error propagation formula // Uses light speed in m/ps, magnetic field in T (*0.1 for conversion kGauss -> T) - double a0 = mass * mass; - double a1 = 0.299792458 * (0.1 * magneticField) * (0.01 * o2::constants::physics::LightSpeedCm2NS / 1e+3); - double a2 = (detRadius * 0.01) * (detRadius * 0.01) * (0.299792458) * (0.299792458) * (0.1 * magneticField) * (0.1 * magneticField) / 2.0; - double dtofOndPt = (std::pow(pt, 4) * std::pow(std::cosh(eta), 2) * std::acos(1.0 - a2 / std::pow(pt, 2)) - 2.0 * a2 * std::pow(pt, 2) * (a0 + std::pow(pt * std::cosh(eta), 2)) / std::sqrt(a2 * (2.0 * std::pow(pt, 2) - a2))) / (a1 * std::pow(pt, 3) * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); - double dtofOndEta = std::pow(pt, 2) * std::sinh(eta) * std::cosh(eta) * std::acos(1.0 - a2 / std::pow(pt, 2)) / (a1 * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); - double trackTimeResolution = std::hypot(std::fabs(dtofOndPt) * trackPtResolution, std::fabs(dtofOndEta) * trackEtaResolution); + const double a0 = 1.0 * mass * mass; + const double a1 = 0.299792458 * (0.1 * magneticField) * (0.01 * o2::constants::physics::LightSpeedCm2NS / 1e+3); + const double a2 = (detRadius * 0.01) * (detRadius * 0.01) * (0.299792458) * (0.299792458) * (0.1 * magneticField) * (0.1 * magneticField) / 2.0; + const double dtofOndPt = (std::pow(pt, 4) * std::pow(std::cosh(eta), 2) * std::acos(1.0 - a2 / std::pow(pt, 2)) - 2.0 * a2 * std::pow(pt, 2) * (a0 + std::pow(pt * std::cosh(eta), 2)) / std::sqrt(a2 * (2.0 * std::pow(pt, 2) - a2))) / (a1 * std::pow(pt, 3) * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); + const double dtofOndEta = std::pow(pt, 2) * std::sinh(eta) * std::cosh(eta) * std::acos(1.0 - a2 / std::pow(pt, 2)) / (a1 * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); + const double trackTimeResolution = std::hypot(std::fabs(dtofOndPt) * trackPtResolution, std::fabs(dtofOndEta) * trackEtaResolution); return trackTimeResolution; } @@ -667,7 +667,7 @@ struct OnTheFlyTofPid { if (mcParticle.has_daughters()) { continue; } - const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + const auto& pdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); if (!pdgInfo) { // LOG(warning) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; continue; From 96ed15006bb3474d2000708bcfee018c7398e100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 00:24:21 +0200 Subject: [PATCH 07/13] FIXES --- ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx | 4 +-- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 26 +++++++++---------- .../TableProducer/OTF/onTheFlyTrackerPid.cxx | 8 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx index 529f1f7d0f5..03f5adc1e6f 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx @@ -764,7 +764,7 @@ struct OnTheFlyRichPid { } const auto& mcParticle = track.mcParticle(); - o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdg); + o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdgDatabase); // float xPv = kErrorValue; if (o2track.propagateToDCA(mcPvVtx, mMagneticField)) { @@ -772,7 +772,7 @@ struct OnTheFlyRichPid { } // get particle to calculate Cherenkov angle and resolution - const& auto pdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); + const auto& pdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); if (pdgInfo == nullptr) { fillDummyValues(); continue; diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index d51564006e6..43ae5260204 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -166,12 +166,12 @@ struct OnTheFlyTofPid { std::array, NParticles>, NParticles> h2dOuterDeltaTrue; struct ParticleInfo { - const std::string_view texName; - const std::string_view name; - const ParticleId type; - const int pdgCode; - const double mass; - const float charge; + std::string_view texName; + std::string_view name; + ParticleId type; + int pdgCode; + double mass; + float charge; }; static constexpr ParticleInfo particleEl{.texName = "#it{e}", .name = "Elec", .type = El, .pdgCode = PDG_t::kElectron, .mass = o2::constants::physics::MassElectron, .charge = 1.f}; @@ -567,7 +567,7 @@ struct OnTheFlyTofPid { // Todo: check the different mass hypothesis iteratively for (const auto& track : tracks) { - auto pdgInfo = pdgDatabase->GetParticle(track.mPdgCode); + const auto& pdgInfo = pdgDatabase->GetParticle(track.mPdgCode); if (pdgInfo == nullptr) { continue; } @@ -694,7 +694,7 @@ struct OnTheFlyTofPid { LOG(debug) << "Track without mcParticle found!"; const auto& mcParticle = track.mcParticle(); - o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdg); + o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdgDatabase); float xPv = -100.f; static constexpr float TrkXThreshold = -99.f; // Threshold to consider a good propagation of the track @@ -731,7 +731,7 @@ struct OnTheFlyTofPid { } // get mass to calculate velocity - auto pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + const auto& pdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); if (pdgInfo == nullptr) { LOG(error) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; upgradeTofMC(-999.f, -999.f, -999.f, -999.f); @@ -818,7 +818,7 @@ struct OnTheFlyTofPid { static std::array deltaTimeInnerTOF, deltaTimeOuterTOF; static std::array nSigmaInnerTOF, nSigmaOuterTOF; std::array momentumHypotheses{}; // Store momentum hypothesis for each particle - auto truePdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + const auto& truePdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); float rigidity = momentum; // fallback to momentum if charge unknown // Use MC truth charge for rigidity calculation @@ -874,8 +874,8 @@ struct OnTheFlyTofPid { double etaResolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-pseudorapidity)))) * std::sqrt(trkWithTime.mPseudorapidity.second); if (simConfig.flagTOFLoadDelphesLUTs) { if (mSmearer[collision.lutConfigId()]->hasTable(Particles[ii].pdgCode)) { // Only if the LUT for this particle was loaded - ptResolution = mSmearer[collision.lutConfigId()]->getAbsPtRes(Particles[ii].pdgCode, pseudorapidity, dNdEta, transverseMomentum); - etaResolution = mSmearer[collision.lutConfigId()]->getAbsEtaRes(Particles[ii].pdgCode, pseudorapidity, dNdEta, transverseMomentum); + ptResolution = mSmearer[collision.lutConfigId()]->getAbsPtRes(Particles[ii].pdgCode, dNdEta, pseudorapidity, transverseMomentum); + etaResolution = mSmearer[collision.lutConfigId()]->getAbsEtaRes(Particles[ii].pdgCode, dNdEta, pseudorapidity, transverseMomentum); } } const float innerTrackTimeReso = calculateTrackTimeResolutionAdvanced(transverseMomentum, pseudorapidity, ptResolution, etaResolution, Particles[ii].mass, simConfig.innerTOFRadius, mMagneticField); @@ -914,7 +914,7 @@ struct OnTheFlyTofPid { if (plotsConfig.doQAplots) { for (int ii = 0; ii < NParticles; ii++) { - if (!doQaForParticle(Particles[ii].pdgCode) || std::fabs(mcParticle.pdgCode()) != pdg->GetParticle(Particles[ii].pdgCode)->PdgCode()) { + if (!doQaForParticle(Particles[ii].pdgCode) || std::fabs(mcParticle.pdgCode()) != pdgDatabase->GetParticle(Particles[ii].pdgCode)->PdgCode()) { continue; } if (trackLengthRecoInnerTOF > 0) { diff --git a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx index 5230849ff22..d3aa583b0de 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx @@ -386,8 +386,8 @@ struct OnTheFlyTrackerPid { Produces tableUpgradeTrkPidSignals; Produces tableUpgradeTrkPids; - Service pdg; - Service ccdb; + Service pdgDatabase{}; + Service ccdb{}; std::unique_ptr mToTLUT; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -625,7 +625,7 @@ struct OnTheFlyTrackerPid { const auto& mcParticle = track.mcParticle(); - const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + const auto& pdgInfo = pdgDatabase->GetParticle(mcParticle.pdgCode()); if (!pdgInfo) { tableUpgradeTrkPidSignals(truncatedMeanToT); tableUpgradeTrkPids(nSigmaValues[0], nSigmaValues[1], nSigmaValues[2], nSigmaValues[3], @@ -658,7 +658,7 @@ struct OnTheFlyTrackerPid { uint16_t hitMap = 0; int nHitLayers = 0; - o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdg); + o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdgDatabase); float xPv = -100.f; static constexpr float kTrkXThreshold = -99.f; From 5a679d5a98f3095f6e43102323a470c4af95a837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 00:30:47 +0200 Subject: [PATCH 08/13] FIXES2 --- .../TableProducer/OTF/onTheFlyTrackerPid.cxx | 86 ++++++++++--------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx index d3aa583b0de..d0a1937dcb8 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx @@ -61,6 +61,8 @@ #include #include +#include + using namespace o2; using namespace o2::framework; @@ -117,9 +119,8 @@ class ToTLUT ~ToTLUT() { for (const auto& hist_ptr : mLUTHistogramFlat) { - if (hist_ptr) { - delete hist_ptr; - } + + delete hist_ptr; } } @@ -131,7 +132,7 @@ class ToTLUT LOG(warning) << "Provided filename is empty for PDG " << pdg; return false; } - if (filename.rfind("ccdb:", 0) == 0) { // Check if filename starts with "ccdb:" + if (filename.starts_with("ccdb:")) { // Check if filename starts with "ccdb:" std::string ccdbPath = filename.substr(5); // remove "ccdb:" prefix const std::string outPath = "/tmp/ToTLUTs/"; const std::string localFilename = outPath + ccdbPath + "/snapshot.root"; @@ -150,10 +151,9 @@ class ToTLUT } testFile.close(); return load(pdg, localFilename); - } else { // File is found, proceed to load it - checkFile.close(); - return load(pdg, localFilename); - } + } // File is found, proceed to load it + checkFile.close(); + return load(pdg, localFilename); } // In case the file is already available locally TFile* f = TFile::Open(filename.c_str()); @@ -162,7 +162,7 @@ class ToTLUT return false; } - int currentPdgIdx; + int currentPdgIdx = 0; auto it = mPdgToIndexMap.find(pdg); if (it == mPdgToIndexMap.end()) { currentPdgIdx = mIndexToPdgMap.size(); @@ -201,7 +201,7 @@ class ToTLUT TH1F* histFromFile = dynamic_cast(f->Get(histName)); if (histFromFile) { - TH1F* clonedHist = static_cast(histFromFile->Clone()); + TH1F* clonedHist = dynamic_cast(histFromFile->Clone()); clonedHist->SetDirectory(nullptr); size_t flatIdx = getFlatIndex(currentPdgIdx, layer, etaBin, pBin); @@ -299,15 +299,17 @@ struct OnTheFlyTrackerPid { float calculateNsigma(float measuredToT, float expectedToT, float resolution) { - if (resolution <= 0) + if (resolution <= 0) { return 999.f; + } return (measuredToT - expectedToT) / resolution; } float getToTMeanFromMomentumSlice(const std::shared_ptr& hist, float momentum) { - if (!hist) + if (!hist) { return -1.f; + } int binX = hist->GetXaxis()->FindBin(momentum); TH1D* proj = hist->ProjectionY("temp", binX, binX); if (proj->GetEntries() < kMinEntriesForProjection) { @@ -321,8 +323,9 @@ struct OnTheFlyTrackerPid { float getToTResolutionFromMomentumSlice(const std::shared_ptr& hist, float momentum) { - if (!hist) + if (!hist) { return -1.f; + } int binX = hist->GetXaxis()->FindBin(momentum); TH1D* proj = hist->ProjectionY("temp", binX, binX); if (proj->GetEntries() < kMinEntriesForProjection) { @@ -338,7 +341,7 @@ struct OnTheFlyTrackerPid { { float length = -100; o2::math_utils::CircleXYf_t trcCircle; - float sna, csa; + float sna = NAN, csa = NAN; track.getCircleParams(magneticField, trcCircle, sna, csa); const float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC); @@ -359,12 +362,12 @@ struct OnTheFlyTrackerPid { const float point1[2] = {radical * ux + displace * vx, radical * uy + displace * vy}; const float point2[2] = {radical * ux - displace * vx, radical * uy - displace * vy}; - std::array mom; + std::array mom{}; track.getPxPyPzGlo(mom); const float scalarProduct1 = point1[0] * mom[0] + point1[1] * mom[1]; const float scalarProduct2 = point2[0] * mom[0] + point2[1] * mom[1]; - std::array startPoint; + std::array startPoint{}; track.getXYZGlo(startPoint); float cosAngle = -1000, modulus = -1000; @@ -525,24 +528,25 @@ struct OnTheFlyTrackerPid { for (size_t iTrue = 0; iTrue < particleInfo.size(); ++iTrue) { std::string trueName = particleInfo[iTrue].second; std::string trueNamePretty = trueName; // Fallback - if (trueName == "Elec") + if (trueName == "Elec") { trueNamePretty = "#it{e}"; - else if (trueName == "Muon") + } else if (trueName == "Muon") { trueNamePretty = "#it{#mu}"; - else if (trueName == "Pion") + } else if (trueName == "Pion") { trueNamePretty = "#it{#pi}"; - else if (trueName == "Kaon") + } else if (trueName == "Kaon") { trueNamePretty = "#it{K}"; - else if (trueName == "Prot") + } else if (trueName == "Prot") { trueNamePretty = "#it{p}"; - else if (trueName == "Deut") + } else if (trueName == "Deut") { trueNamePretty = "#it{d}"; - else if (trueName == "Trit") + } else if (trueName == "Trit") { trueNamePretty = "#it{t}"; - else if (trueName == "He3") + } else if (trueName == "He3") { trueNamePretty = "#it{^{3}He}"; - else if (trueName == "Al") + } else if (trueName == "Al") { trueNamePretty = "#it{^{4}He}"; + } if (enableLogPBins.value) { const AxisSpec axisMomentumLog{mLogBins, "#it{p/z} (GeV/#it{c})"}; @@ -558,24 +562,25 @@ struct OnTheFlyTrackerPid { for (size_t iHyp = 0; iHyp < particleInfo.size(); ++iHyp) { std::string hypName = particleInfo[iHyp].second; std::string hypNamePretty = hypName; // Fallback - if (hypName == "Elec") + if (hypName == "Elec") { hypNamePretty = "#it{e}"; - else if (hypName == "Muon") + } else if (hypName == "Muon") { hypNamePretty = "#it{#mu}"; - else if (hypName == "Pion") + } else if (hypName == "Pion") { hypNamePretty = "#it{#pi}"; - else if (hypName == "Kaon") + } else if (hypName == "Kaon") { hypNamePretty = "#it{K}"; - else if (hypName == "Prot") + } else if (hypName == "Prot") { hypNamePretty = "#it{p}"; - else if (hypName == "Deut") + } else if (hypName == "Deut") { hypNamePretty = "#it{d}"; - else if (hypName == "Trit") + } else if (hypName == "Trit") { hypNamePretty = "#it{t}"; - else if (hypName == "He3") + } else if (hypName == "He3") { hypNamePretty = "#it{^{3}He}"; - else if (hypName == "Al") + } else if (hypName == "Al") { hypNamePretty = "#it{^{4}He}"; + } std::string histName = "NSigma/BarrelNsigmaTrue" + trueName + "Vs" + hypName + "Hypothesis"; std::string histTitle = "Nsigma (True " + trueNamePretty + " vs Hyp " + hypNamePretty + "); #it{p/z} (GeV/#it{c}); N#sigma"; @@ -613,7 +618,7 @@ struct OnTheFlyTrackerPid { for (const auto& track : tracks) { float truncatedMeanToT = -1.0f; - std::array nSigmaValues; + std::array nSigmaValues{}; nSigmaValues.fill(999.f); if (!track.has_mcParticle()) { @@ -690,7 +695,7 @@ struct OnTheFlyTrackerPid { std::vector validToTs; for (int layer = kMinLayerForTruncation; layer < maxBarrelLayers.value; ++layer) { - if ((hitMap >> layer) & 0x1) { + if (((hitMap >> layer) & 0x1) != 0) { TH1F* totHist = mToTLUT->getHistogramForSampling(truePdgIdx, layer, binnedEta, binnedP); if (totHist && totHist->GetEntries() > 1) { @@ -704,14 +709,15 @@ struct OnTheFlyTrackerPid { const size_t nValid = validToTs.size(); size_t nUse = 0; - if (nValid == kMidLowValidHits || nValid == kMidHighValidHits) + if (nValid == kMidLowValidHits || nValid == kMidHighValidHits) { nUse = kMaxValidHitsForTruncation34; - else if (nValid == kMinValidHits || nValid == kLowValidHits) + } else if (nValid == kMinValidHits || nValid == kLowValidHits) { nUse = kMaxValidHitsForTruncation12; - else if (nValid == kHighValidHits1 || nValid == kHighValidHits2) + } else if (nValid == kHighValidHits1 || nValid == kHighValidHits2) { nUse = kMaxValidHitsForTruncation56; - else if (nValid >= kMaxValidHits) + } else if (nValid >= kMaxValidHits) { nUse = kMaxValidHitsForTruncation7Plus; + } if (nUse > 0 && nValid >= nUse) { std::sort(validToTs.begin(), validToTs.end()); From 6d987fcbdb18429801b1c2facc13374ca96761f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 00:37:16 +0200 Subject: [PATCH 09/13] FIX3 --- ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx index d0a1937dcb8..e7c48030735 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx @@ -61,8 +61,6 @@ #include #include -#include - using namespace o2; using namespace o2::framework; @@ -288,14 +286,13 @@ class ToTLUT o2::ccdb::BasicCCDBManager* mCcdbManager = nullptr; }; -static constexpr int kNumHypothesisParticles = 9; -std::array, kNumHypothesisParticles>, kNumHypothesisParticles> h2dBarrelNsigmaTrue; -std::array, kNumHypothesisParticles> h2dHitsPerTrackVsP; -std::array, kNumHypothesisParticles> h2dToTvsPperParticle; -std::array, kNumHypothesisParticles> h2dHitsPerTrackVsPLin; -std::array, kNumHypothesisParticles> h2dToTvsPperParticleLin; - struct OnTheFlyTrackerPid { + static constexpr int kNumHypothesisParticles = 9; + std::array, kNumHypothesisParticles>, kNumHypothesisParticles> h2dBarrelNsigmaTrue; + std::array, kNumHypothesisParticles> h2dHitsPerTrackVsP; + std::array, kNumHypothesisParticles> h2dToTvsPperParticle; + std::array, kNumHypothesisParticles> h2dHitsPerTrackVsPLin; + std::array, kNumHypothesisParticles> h2dToTvsPperParticleLin; float calculateNsigma(float measuredToT, float expectedToT, float resolution) { From 212e81f8f20b79481a0e63cba0d333f82d4cd2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 00:42:46 +0200 Subject: [PATCH 10/13] FIX4 --- ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx | 2 +- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 13 ++++++++++++- ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx | 6 +++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx index 03f5adc1e6f..31a915fc00d 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx @@ -696,7 +696,7 @@ struct OnTheFlyRichPid { { // Compute tracking contribution to timing using the error propagation formula // Uses light speed in m/ps, magnetic field in T (*0.1 for conversion kGauss -> T) - const double a0 = mass * mass; + const double a0 = 1.0 * mass * mass; const double a1 = refractiveIndex; const double a1Squared = a1 * a1; const float ptCoshEta = pt * std::cosh(eta); diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index 43ae5260204..c187e16d8e7 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -172,6 +172,15 @@ struct OnTheFlyTofPid { int pdgCode; double mass; float charge; + void set(const std::string_view texName_, const std::string_view name_, ParticleId type_, int pdgCode_, double mass_, float charge_) + { + texName = texName_; + name = name_; + type = type_; + pdgCode = pdgCode_; + mass = mass_; + charge = charge_; + } }; static constexpr ParticleInfo particleEl{.texName = "#it{e}", .name = "Elec", .type = El, .pdgCode = PDG_t::kElectron, .mass = o2::constants::physics::MassElectron, .charge = 1.f}; @@ -391,6 +400,8 @@ struct OnTheFlyTofPid { delete hHitMapInPixelBefore; } + TOFLayerEfficiency& operator=(const TOFLayerEfficiency&) = delete; + TOFLayerEfficiency(float r, float l, std::array pDimensions, float fIA, float m) : layerRadius(r), layerLength(l), pixelDimensionZ(pDimensions[0]), @@ -558,7 +569,7 @@ struct OnTheFlyTofPid { }; std::vector tracksWithTime; - bool eventTime(std::vector& tracks, + bool eventTime(const std::vector& tracks, std::array& tzero) { diff --git a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx index e7c48030735..8aefcebc4f5 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx @@ -336,7 +336,6 @@ struct OnTheFlyTrackerPid { float computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField) { - float length = -100; o2::math_utils::CircleXYf_t trcCircle; float sna = NAN, csa = NAN; track.getCircleParams(magneticField, trcCircle, sna, csa); @@ -344,7 +343,7 @@ struct OnTheFlyTrackerPid { const float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC); if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) { - length = 0.0f; + float length = 0.0f; const float ux = trcCircle.xC / centerDistance; const float uy = trcCircle.yC / centerDistance; const float vx = -uy; @@ -379,8 +378,9 @@ struct OnTheFlyTrackerPid { cosAngle /= modulus; length = trcCircle.rC * std::acos(cosAngle); length *= std::sqrt(1.0f + track.getTgl() * track.getTgl()); + return length; } - return length; + return -100.f; } Produces tableUpgradeTrkPidSignals; From 896d885a4d08c24a948828f06726889856bd4ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 00:55:19 +0200 Subject: [PATCH 11/13] FIXXX --- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 24 +++++++++++-------- .../TableProducer/OTF/onTheFlyTrackerPid.cxx | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index c187e16d8e7..d1937367a7e 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -371,12 +371,12 @@ struct OnTheFlyTofPid { struct TOFLayerEfficiency { private: - const float layerRadius; - const float layerLength; - const float pixelDimensionZ; - const float pixelDimensionRPhi; - const float fractionInactive; - const float magField; + float layerRadius; + float layerLength; + float pixelDimensionZ; + float pixelDimensionRPhi; + float fractionInactive; + float magField; TAxis* axisZ = nullptr; TAxis* axisRPhi = nullptr; @@ -418,16 +418,16 @@ struct OnTheFlyTofPid { const float inactiveBorderRPhi = pixelDimensionRPhi * std::sqrt(fractionInactive) / 2; const float inactiveBorderZ = pixelDimensionZ * std::sqrt(fractionInactive) / 2; static constexpr int NDimBorderArray = 4; - const double arrayRPhi[NDimBorderArray] = {-pixelDimensionRPhi / 2, -pixelDimensionRPhi / 2 + inactiveBorderRPhi, pixelDimensionRPhi / 2 - inactiveBorderRPhi, pixelDimensionRPhi / 2}; + const std::array arrayRPhi = {-pixelDimensionRPhi / 2, -pixelDimensionRPhi / 2 + inactiveBorderRPhi, pixelDimensionRPhi / 2 - inactiveBorderRPhi, pixelDimensionRPhi / 2}; for (int i = 0; i < NDimBorderArray; i++) { LOG(info) << "arrayRPhi[" << i << "] = " << arrayRPhi[i]; } - axisInPixelRPhi = new TAxis(3, arrayRPhi); - const double arrayZ[NDimBorderArray] = {-pixelDimensionZ / 2, -pixelDimensionZ / 2 + inactiveBorderZ, pixelDimensionZ / 2 - inactiveBorderZ, pixelDimensionZ / 2}; + axisInPixelRPhi = new TAxis(3, arrayRPhi.data()); + const std::array arrayZ = {-pixelDimensionZ / 2, -pixelDimensionZ / 2 + inactiveBorderZ, pixelDimensionZ / 2 - inactiveBorderZ, pixelDimensionZ / 2}; for (int i = 0; i < NDimBorderArray; i++) { LOG(info) << "arrayZ[" << i << "] = " << arrayZ[i]; } - axisInPixelZ = new TAxis(3, arrayZ); + axisInPixelZ = new TAxis(3, arrayZ.data()); hHitMap = new TH2F(Form("hHitMap_R%.0f", layerRadius), "HitMap;z (cm); r#phi (cm)", 1000, -1000, 1000, 1000, -1000, 1000); hHitMapInPixel = new TH2F(Form("hHitMapInPixel_R%.0f", layerRadius), "HitMapInPixel;z (cm); r#phi (cm)", 1000, -10, 10, 1000, -10, 10); @@ -491,6 +491,8 @@ struct OnTheFlyTofPid { case kInactiveBottom: case kInactiveTop: return false; + default: + break; } switch (axisInPixelZ->FindBin(localZ)) { case kInactiveLeft: @@ -498,6 +500,8 @@ struct OnTheFlyTofPid { case kInactiveBottom: case kInactiveTop: return false; + default: + break; } hHitMapInPixel->Fill(localZ, localRPhi); hHitMap->Fill(z, rphi); diff --git a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx index 8aefcebc4f5..dea6014a767 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx @@ -355,8 +355,8 @@ struct OnTheFlyTrackerPid { (-centerDistance + trcCircle.rC + radius) * (centerDistance + trcCircle.rC + radius)); - const float point1[2] = {radical * ux + displace * vx, radical * uy + displace * vy}; - const float point2[2] = {radical * ux - displace * vx, radical * uy - displace * vy}; + const std::array point1 = {radical * ux + displace * vx, radical * uy + displace * vy}; + const std::array point2 = {radical * ux - displace * vx, radical * uy - displace * vy}; std::array mom{}; track.getPxPyPzGlo(mom); From 9113965a670318118a48058a101f1ccd6933058c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 08:07:11 +0200 Subject: [PATCH 12/13] FIXXXXX --- ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx | 29 ++++++++++--------- .../TableProducer/OTF/onTheFlyTrackerPid.cxx | 13 +++++---- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx index d1937367a7e..e50656494fc 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -166,12 +166,12 @@ struct OnTheFlyTofPid { std::array, NParticles>, NParticles> h2dOuterDeltaTrue; struct ParticleInfo { - std::string_view texName; - std::string_view name; - ParticleId type; - int pdgCode; - double mass; - float charge; + std::string_view texName{}; + std::string_view name{}; + ParticleId type{}; + int pdgCode{}; + double mass{}; + float charge{}; void set(const std::string_view texName_, const std::string_view name_, ParticleId type_, int pdgCode_, double mass_, float charge_) { texName = texName_; @@ -400,6 +400,7 @@ struct OnTheFlyTofPid { delete hHitMapInPixelBefore; } + TOFLayerEfficiency(const TOFLayerEfficiency&) = delete; TOFLayerEfficiency& operator=(const TOFLayerEfficiency&) = delete; TOFLayerEfficiency(float r, float l, std::array pDimensions, float fIA, float m) : layerRadius(r), @@ -825,7 +826,7 @@ struct OnTheFlyTofPid { const float measuredTimeInnerTOF = trkWithTime.mInnerTOFTime.first - tzero[0]; const float measuredTimeOuterTOF = trkWithTime.mOuterTOFTime.first - tzero[0]; const float momentum = trkWithTime.mMomentum.first; - const float pseudorapidity = trkWithTime.mPseudorapidity.first; + const float eta = trkWithTime.mPseudorapidity.first; const float noSmearingPt = trkWithTime.mNoSmearingPt; // Straight to Nsigma @@ -884,17 +885,17 @@ struct OnTheFlyTofPid { float innerTotalTimeReso = simConfig.innerTOFTimeReso; float outerTotalTimeReso = simConfig.outerTOFTimeReso; if (simConfig.flagIncludeTrackTimeRes) { - const float transverseMomentum = momentumHypotheses[ii] / std::cosh(pseudorapidity); + const float transverseMomentum = momentumHypotheses[ii] / std::cosh(eta); double ptResolution = transverseMomentum * transverseMomentum * std::sqrt(trkWithTime.mMomentum.second); - double etaResolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-pseudorapidity)))) * std::sqrt(trkWithTime.mPseudorapidity.second); + double etaResolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * std::sqrt(trkWithTime.mPseudorapidity.second); if (simConfig.flagTOFLoadDelphesLUTs) { if (mSmearer[collision.lutConfigId()]->hasTable(Particles[ii].pdgCode)) { // Only if the LUT for this particle was loaded - ptResolution = mSmearer[collision.lutConfigId()]->getAbsPtRes(Particles[ii].pdgCode, dNdEta, pseudorapidity, transverseMomentum); - etaResolution = mSmearer[collision.lutConfigId()]->getAbsEtaRes(Particles[ii].pdgCode, dNdEta, pseudorapidity, transverseMomentum); + ptResolution = mSmearer[collision.lutConfigId()]->getAbsPtRes(Particles[ii].pdgCode, dNdEta, eta, transverseMomentum); + etaResolution = mSmearer[collision.lutConfigId()]->getAbsEtaRes(Particles[ii].pdgCode, dNdEta, eta, transverseMomentum); } } - const float innerTrackTimeReso = calculateTrackTimeResolutionAdvanced(transverseMomentum, pseudorapidity, ptResolution, etaResolution, Particles[ii].mass, simConfig.innerTOFRadius, mMagneticField); - const float outerTrackTimeReso = calculateTrackTimeResolutionAdvanced(transverseMomentum, pseudorapidity, ptResolution, etaResolution, Particles[ii].mass, simConfig.outerTOFRadius, mMagneticField); + const float innerTrackTimeReso = calculateTrackTimeResolutionAdvanced(transverseMomentum, eta, ptResolution, etaResolution, Particles[ii].mass, simConfig.innerTOFRadius, mMagneticField); + const float outerTrackTimeReso = calculateTrackTimeResolutionAdvanced(transverseMomentum, eta, ptResolution, etaResolution, Particles[ii].mass, simConfig.outerTOFRadius, mMagneticField); innerTotalTimeReso = std::hypot(simConfig.innerTOFTimeReso, innerTrackTimeReso); outerTotalTimeReso = std::hypot(simConfig.outerTOFTimeReso, outerTrackTimeReso); @@ -909,7 +910,7 @@ struct OnTheFlyTofPid { h2dOuterTimeResTotal[ii]->Fill(momentumHypotheses[ii], outerTotalTimeReso); if (ii == Pi) { histos.fill(HIST("h2dRelativePtResolution"), transverseMomentum, 100.0 * ptResolution / transverseMomentum); - histos.fill(HIST("h2dRelativeEtaResolution"), pseudorapidity, 100.0 * etaResolution / (std::fabs(pseudorapidity) + 1e-6)); + histos.fill(HIST("h2dRelativeEtaResolution"), eta, 100.0 * etaResolution / (std::fabs(eta) + 1e-6)); } } } diff --git a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx index dea6014a767..bf7a1f1350e 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -579,8 +580,8 @@ struct OnTheFlyTrackerPid { hypNamePretty = "#it{^{4}He}"; } - std::string histName = "NSigma/BarrelNsigmaTrue" + trueName + "Vs" + hypName + "Hypothesis"; - std::string histTitle = "Nsigma (True " + trueNamePretty + " vs Hyp " + hypNamePretty + "); #it{p/z} (GeV/#it{c}); N#sigma"; + const std::string histName = std::format("NSigma/BarrelNsigmaTrue{}Vs{}Hypothesis", trueName, hypName); + const std::string histTitle = std::format("Nsigma (True {} vs Hyp {}); #it{{p/z}} (GeV/#it{{c}}); N#sigma", trueNamePretty, hypNamePretty); h2dBarrelNsigmaTrue[iTrue][iHyp] = histos.add(histName.c_str(), histTitle.c_str(), kTH2F, {axisMomentumLog, axisNsigma}); } } @@ -588,12 +589,12 @@ struct OnTheFlyTrackerPid { if (enableLinearPBins.value) { const AxisSpec axisMomentumLin{numLinearBins.value, static_cast(linearPMin.value), static_cast(linearPMax.value), "#it{p/z} (GeV/#it{c})"}; - std::string hitsVsPLinName = "HitsPerTrackLin/hHitsPerTrackVsPLin_" + trueName; - std::string hitsVsPLinTitle = "N_hits vs #it{p/z} for " + trueNamePretty + " (linear); #it{p/z} (GeV/#it{c}); N_hits"; + const std::string hitsVsPLinName = std::format("HitsPerTrackLin/hHitsPerTrackVsPLin_{}", trueName); + const std::string hitsVsPLinTitle = std::format("N_hits vs #it{{p/z}} for {} (linear); #it{{p/z}} (GeV/#it{{c}}); N_hits", trueNamePretty); h2dHitsPerTrackVsPLin[iTrue] = histos.add(hitsVsPLinName.c_str(), hitsVsPLinTitle.c_str(), kTH2F, {axisMomentumLin, axisHitsPerTrack}); - std::string totVsPLinName = "ToTvsPLin/hToTvsPLin_" + trueName; - std::string totVsPLinTitle = "ToT vs #it{p/z} for " + trueNamePretty + " (linear); #it{p/z} (GeV/#it{c}); ToT (#mus/10#mum)"; + const std::string totVsPLinName = std::format("ToTvsPLin/hToTvsPLin_{}", trueName); + const std::string totVsPLinTitle = std::format("ToT vs #it{{p/z}} for {} (linear); #it{{p/z}} (GeV/#it{{c}}); ToT (#mus/10#mum)", trueNamePretty); h2dToTvsPperParticleLin[iTrue] = histos.add(totVsPLinName.c_str(), totVsPLinTitle.c_str(), kTH2F, {axisMomentumLin, axisToT}); } } From 2bcce468b8320bcbbf556b7533fbaa6e61d97f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Mon, 21 Sep 2026 13:59:10 +0200 Subject: [PATCH 13/13] Clean --- ALICE3/Core/FlatLutEntry.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ALICE3/Core/FlatLutEntry.cxx b/ALICE3/Core/FlatLutEntry.cxx index ad8bb3b8e38..984157f4520 100644 --- a/ALICE3/Core/FlatLutEntry.cxx +++ b/ALICE3/Core/FlatLutEntry.cxx @@ -27,10 +27,6 @@ namespace o2::fastsim { -namespace -{ -constexpr float kBinCenterOffset = 0.5f; -} // namespace void lutEntry_t::print() const {