Skip to content

Conversation

@Preet-Bhanjan
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the pwgcf label Oct 16, 2025
@github-actions
Copy link

github-actions bot commented Oct 16, 2025

O2 linter results: ❌ 0 errors, ⚠️ 0 warnings, 🔕 0 disabled

@github-actions github-actions bot changed the title Addition of resonance correlations [PWGCF] Addition of resonance correlations Oct 16, 2025
Preet-Bhanjan added a commit to Preet-Bhanjan/O2Physics that referenced this pull request Oct 16, 2025
[PWGCF] Please consider the following formatting changes to AliceO2Group#13422
@Preet-Bhanjan Preet-Bhanjan marked this pull request as ready for review October 16, 2025 15:26
Comment on lines 543 to 551
bool isPion, isKaon, isProton;
bool isDetectedPion = nSigmaToUse[0] < detectorNsigmaCut[0] && nSigmaToUse[0] > detectorNsigmaCut[0 + 3];
bool isDetectedKaon = nSigmaToUse[1] < detectorNsigmaCut[1] && nSigmaToUse[1] > detectorNsigmaCut[1 + 3];
bool isDetectedProton = nSigmaToUse[2] < detectorNsigmaCut[2] && nSigmaToUse[2] > detectorNsigmaCut[2 + 3];

bool isTofPion = nSigmaTOF[0] < tofNsigmaCut[0] && nSigmaTOF[0] > tofNsigmaCut[0 + 3];
bool isTofKaon = nSigmaTOF[1] < tofNsigmaCut[1] && nSigmaTOF[1] > tofNsigmaCut[1 + 3];
bool isTofProton = nSigmaTOF[2] < tofNsigmaCut[2] && nSigmaTOF[2] > tofNsigmaCut[2 + 3];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use named constants instead of 'magic' number as indexes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out. I will be using named constants from now on

Comment on lines 568 to 578
if (isPion) {
pid = PIONS;
} else if (isKaon) {
pid = KAONS;
} else if (isProton) {
pid = PROTONS;
} else {
return 0; // no particle satisfies the criteria
}

return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really confusing and error prone
If a pion has pid as PIONS it does not make too much sense that is also PIONS+1 because then PIONS is pions and also PIONS+1 is pions
It is confusing even writing it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to use PIONS, KAONS and PROTONS as indices for arrays/configurable arrays and have the getNsigmaPID to generate pid for pions, kaons, and protons as 1, 2, 3 (0 for not identified). I see it now that its confusing. I will modify it so that pid = PIONS(KAONS, etc) + 1 . I hope this will make it more readable and clear

Comment on lines 60 to 80
template <typename T>
auto projectMatrix(Array2D<T> const& mat, std::array<float, 6>& array1, std::array<float, 6>& array2, std::array<float, 6>& array3)
{
for (auto j = 0; j < static_cast<int>(mat.cols); ++j) {
array1[j] = mat(0, j);
array2[j] = mat(1, j);
array3[j] = mat(2, j);
}
return;
}
template <typename T, typename P>
auto readMatrix(Array2D<T> const& mat, P& array)
{
for (auto i = 0; i < static_cast<int>(mat.rows); ++i) {
for (auto j = 0; j < static_cast<int>(mat.cols); ++j) {
array[i][j] = mat(i, j);
}
}

return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really dangerous
The vectors structures does not have checks on their range which means that if they read or written out of their bounds most of the times it will not be noticed but other data is being read or overwritten which is really hard to fix and produces random results
Will it not work passing references to empty arrays of the right type and then filling the array with the corresponding elements?
Also named constants can be used to directly access the elements of the matrix without the need of serializing its content

@Preet-Bhanjan
Copy link
Contributor Author

Preet-Bhanjan commented Oct 17, 2025

This pull request got closed accidentally as I pushed new changes after rebuilding O2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants