diff --git a/ALICE3/Core/FlatLutEntry.cxx b/ALICE3/Core/FlatLutEntry.cxx index 66a6cedf860..fae711f6b8e 100644 --- a/ALICE3/Core/FlatLutEntry.cxx +++ b/ALICE3/Core/FlatLutEntry.cxx @@ -149,6 +149,16 @@ lutEntry_t* FlatLutData::getEntry(int nch_bin, int rad_bin, int eta_bin, int pt_ return reinterpret_cast(mData.data() + offset); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) } +void FlatLutData::setEntry(int rad_bin, const lutEntry_t& entry) +{ + const int nch_bin = getHeaderRef().nchmap.find(entry.nch); + const int eta_bin = getHeaderRef().etamap.find(entry.eta); + const int pt_bin = getHeaderRef().ptmap.find(entry.pt); + // Calculate the linear index based on the entry's bin indices + const size_t offset = getEntryOffset(nch_bin, rad_bin, eta_bin, pt_bin); + std::memcpy(mData.data() + offset, &entry, sizeof(lutEntry_t)); +} + const lutHeader_t& FlatLutData::getHeaderRef() const { return *reinterpret_cast(mDataRef.data()); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) diff --git a/ALICE3/Core/FlatLutEntry.h b/ALICE3/Core/FlatLutEntry.h index 7e095f989c1..c7cc6b7c508 100644 --- a/ALICE3/Core/FlatLutEntry.h +++ b/ALICE3/Core/FlatLutEntry.h @@ -139,6 +139,11 @@ class FlatLutData */ lutEntry_t* getEntry(int nch_bin, int rad_bin, int eta_bin, int pt_bin); + /** + * @brief Set LUT entry + */ + void setEntry(int rad_bin, const lutEntry_t& entry); + /** * @brief Get LUT header (view) */ @@ -200,12 +205,12 @@ class FlatLutData */ void reset(); - private: /** * @brief Linear index calculation for entry access */ [[nodiscard]] size_t getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const; + private: /** * @brief Update dimensions from the current header */ diff --git a/ALICE3/Core/SecondaryLut.h b/ALICE3/Core/SecondaryLut.h index 863fd76010d..cfe36f0af7b 100644 --- a/ALICE3/Core/SecondaryLut.h +++ b/ALICE3/Core/SecondaryLut.h @@ -47,6 +47,8 @@ struct SecondaryLutAxis { [[nodiscard]] float lowEdge(int bin) const; /// Upper edge in the variable's natural units [[nodiscard]] float upEdge(int bin) const; + /// Number of bins in the axis + [[nodiscard]] int getNbins() const { return nbins; } ClassDefNV(SecondaryLutAxis, 1); };