From c075eb0aeb8070d19f7b2c9c379645d3694ba04c Mon Sep 17 00:00:00 2001 From: SuJeong Ji <120470463+SuJeong-Ji@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:21:25 +0900 Subject: [PATCH 1/2] Small changes for encodeNSigma, decodeNSigma and encodeDCA of microtrack in LFResonanceTables.h --- PWGLF/DataModel/LFResonanceTables.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/PWGLF/DataModel/LFResonanceTables.h b/PWGLF/DataModel/LFResonanceTables.h index 67e1fb013c5..0ecde07c23e 100644 --- a/PWGLF/DataModel/LFResonanceTables.h +++ b/PWGLF/DataModel/LFResonanceTables.h @@ -351,16 +351,21 @@ struct PidNSigma { /// @brief Encode 0.2 sigma interval to 0~10 range static uint8_t encodeNSigma(float nSigma) { - float encoded = std::abs((nSigma - 1.5) / 0.2); // Convert to 0~10 range - encoded = std::min(std::max(encoded, 0.f), 10.f); // Clamp to 0~10 range - return (uint8_t)round(encoded); + const float x = std::abs(nSigma); + if (x <= 1.5) return 0; // Return 0 when absolute nSigma is smaller than 1.5 + float t = (x - 1.5) / 0.2; + int encoded = static_cast(std::ceil(t)); // (1.5,1.7]->1, ..., (3.3,3.5]->10 + if (encoded < 1) encoded = 1; + if (encoded > 10) encoded = 10; + return static_cast(encoded); } /// @brief Decode 0~10 value to original 1.5~3.5 sigma range static float decodeNSigma(uint8_t encoded) { - encoded = std::min(encoded, (uint8_t)10); // Safety check, should not be needed if encode is used properly - return (encoded * 0.2) + 1.5; + if (encoded == 0) return 1.5; + if (encoded > 10) encoded = 10; + return 1.5 + static_cast(encoded) * 0.2; } /// @brief Check if TOF info is available @@ -416,14 +421,15 @@ struct ResoMicroTrackSelFlag { flag = (DCAxyEncoded << 4) | DCAzEncoded; // Upper 4 bits = DCAxy, Lower 4 bits = DCAz } - /// @brief Convert DCA to 1~15 steps (0 value is not used) + /// @brief Convert DCA to 1~15 steps (|DCA|<0.1 is saved in 0) static uint8_t encodeDCA(float DCA) { - for (uint8_t i = 1; i < 15; i++) { - if (DCA < i * 0.1f) - return i; - } - return 15; + float x = std::fabs(DCA); + if (x < 0.1) return 0; + int encoded = static_cast(std::ceil((x - 0.1) / 0.1)); // (0.1, 0.2] -> 1, ..., (1.4, 1.5] -> 14 + if (encoded < 1) encoded = 1; + if (encoded > 14) encoded = 15; + return static_cast(encoded); } /// @brief Operator to convert to `uint8_t` (for SOA storage) From 7d479b91c037e42666b12ade3778afc44e39d092 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 30 Sep 2025 10:27:02 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- PWGLF/DataModel/LFResonanceTables.h | 40 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/PWGLF/DataModel/LFResonanceTables.h b/PWGLF/DataModel/LFResonanceTables.h index 0ecde07c23e..b8f60a6fc7a 100644 --- a/PWGLF/DataModel/LFResonanceTables.h +++ b/PWGLF/DataModel/LFResonanceTables.h @@ -351,21 +351,26 @@ struct PidNSigma { /// @brief Encode 0.2 sigma interval to 0~10 range static uint8_t encodeNSigma(float nSigma) { - const float x = std::abs(nSigma); - if (x <= 1.5) return 0; // Return 0 when absolute nSigma is smaller than 1.5 - float t = (x - 1.5) / 0.2; - int encoded = static_cast(std::ceil(t)); // (1.5,1.7]->1, ..., (3.3,3.5]->10 - if (encoded < 1) encoded = 1; - if (encoded > 10) encoded = 10; - return static_cast(encoded); + const float x = std::abs(nSigma); + if (x <= 1.5) + return 0; // Return 0 when absolute nSigma is smaller than 1.5 + float t = (x - 1.5) / 0.2; + int encoded = static_cast(std::ceil(t)); // (1.5,1.7]->1, ..., (3.3,3.5]->10 + if (encoded < 1) + encoded = 1; + if (encoded > 10) + encoded = 10; + return static_cast(encoded); } /// @brief Decode 0~10 value to original 1.5~3.5 sigma range static float decodeNSigma(uint8_t encoded) { - if (encoded == 0) return 1.5; - if (encoded > 10) encoded = 10; - return 1.5 + static_cast(encoded) * 0.2; + if (encoded == 0) + return 1.5; + if (encoded > 10) + encoded = 10; + return 1.5 + static_cast(encoded) * 0.2; } /// @brief Check if TOF info is available @@ -424,12 +429,15 @@ struct ResoMicroTrackSelFlag { /// @brief Convert DCA to 1~15 steps (|DCA|<0.1 is saved in 0) static uint8_t encodeDCA(float DCA) { - float x = std::fabs(DCA); - if (x < 0.1) return 0; - int encoded = static_cast(std::ceil((x - 0.1) / 0.1)); // (0.1, 0.2] -> 1, ..., (1.4, 1.5] -> 14 - if (encoded < 1) encoded = 1; - if (encoded > 14) encoded = 15; - return static_cast(encoded); + float x = std::fabs(DCA); + if (x < 0.1) + return 0; + int encoded = static_cast(std::ceil((x - 0.1) / 0.1)); // (0.1, 0.2] -> 1, ..., (1.4, 1.5] -> 14 + if (encoded < 1) + encoded = 1; + if (encoded > 14) + encoded = 15; + return static_cast(encoded); } /// @brief Operator to convert to `uint8_t` (for SOA storage)