Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions PWGLF/DataModel/LFResonanceTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,24 +343,34 @@
/// @brief Constructor: Convert TPC & TOF values and save
PidNSigma(float TPCnSigma, float TOFnSigma, bool hasTOF)
{
uint8_t TPCencoded = encodeNSigma(TPCnSigma);

Check failure on line 346 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
uint8_t TOFencoded = hasTOF ? encodeNSigma(TOFnSigma) : 0x0F; // If TOF is not available, set all 4 bits to 1

Check failure on line 347 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
flag = (TPCencoded << 4) | TOFencoded; // Upper 4 bits = TPC, Lower 4 bits = TOF
}

/// @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)

Check failure on line 355 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return 0; // Return 0 when absolute nSigma is smaller than 1.5
float t = (x - 1.5) / 0.2;
int encoded = static_cast<int>(std::ceil(t)); // (1.5,1.7]->1, ..., (3.3,3.5]->10
if (encoded < 1)
encoded = 1;
if (encoded > 10)

Check failure on line 361 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
encoded = 10;
return static_cast<uint8_t>(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)

Check failure on line 371 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
encoded = 10;
return 1.5 + static_cast<float>(encoded) * 0.2;
}

/// @brief Check if TOF info is available
Expand All @@ -378,12 +388,12 @@
/// @brief Restore TOF nSigma value (if not available, return NAN)
static float getTOFnSigma(uint8_t encoded)
{
uint8_t TOFencoded = encoded & 0x0F; // Extract lower 4 bits

Check failure on line 391 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
return (TOFencoded == 0x0F) ? NAN : decodeNSigma(TOFencoded);
}

/// @brief Operator to convert to uint8_t (automatic conversion support)
operator uint8_t() const

Check failure on line 396 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
{
return flag;
}
Expand Down Expand Up @@ -411,19 +421,23 @@
/// @brief Constructor: Convert DCAxy/DCAz and save (default 1~15 values)
ResoMicroTrackSelFlag(float DCAxy, float DCAz)
{
uint8_t DCAxyEncoded = encodeDCA(DCAxy);

Check failure on line 424 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
uint8_t DCAzEncoded = encodeDCA(DCAz);
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)

Check failure on line 433 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return 0;
int encoded = static_cast<int>(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)

Check failure on line 438 in PWGLF/DataModel/LFResonanceTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
encoded = 15;
return static_cast<uint8_t>(encoded);
}

/// @brief Operator to convert to `uint8_t` (for SOA storage)
Expand Down
Loading