-
Notifications
You must be signed in to change notification settings - Fork 621
[PWGHF,Tools] Address Bug tracker issues in LcToPKPi-related files #14358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
O2 linter results: ❌ 37 errors, |
| /// \param isMc boolean flag whether MC or data is processed | ||
| template <int ReconstructionType> | ||
| void reserveTables(size_t candidatesSize, bool isMc) | ||
| void reserveTables(int64_t candidatesSize, bool isMc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Doesn't the reserve method take an unsigned type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the reserve() function of the WritingCursor struct (which is a base struct for Produces), has an int64_t parameter.
And the clang-tidy confirms that: PWGHF/TableProducer/treeCreatorLcToPKPi.cxx:551:34: warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aalkin Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reserve() method did not change from 2019(?), and arrow still uses unsigned int64_t explicitly for its sizes. Regardless, the explicit ints are preferred to size_t which is implementation-dependent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why does the reserve method not use the uint64_t instead of int64_t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it calls arrow's method that expects int64_t and thus it was used when the method was implemented. There is no intent behind it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this mismatch between signed and unsigned type is coming already from arrow?
|
Help wanted
|
|
| kfCandPKPi.SetNonlinearMassConstraint(createLc ? static_cast<float>(MassLambdaCPlus) : static_cast<float>(MassXiCPlus)); | ||
| kfCandPiKP.SetNonlinearMassConstraint(createLc ? static_cast<float>(MassLambdaCPlus) : static_cast<float>(MassXiCPlus)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SetNonlinearMassConstraint() has a float parameter, while particle mass O2 constants are double.
BTW clang-tidy generates warning only when the conditional operator is used, otherwise (few lines below highlighted) there is no warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I was wondering, since below you still pass double values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the key difference is that below I pass constant expressions, and compiler does not consider it as narrowing conversion since this particular double value fits into float range.
And the expression with conditional operator is not constant (although 2-nd and 3-d operands are constexpr).
| } | ||
| if (indexRec > -1) { | ||
| flagChannelMain = sign * DecayChannelMain::DplusToPiKPi; | ||
| flagChannelMain = sign * static_cast<int8_t>(DecayChannelMain::DplusToPiKPi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless. It already is int8_t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Both sign and DplusToPiKPi are int8_t. Their product is int8_t as well. You don't need the cast at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, both sign and DplusToPiKPi are int8_t, but their product is promoted to int. I checked it both in ROOT interpreter mode and as a compiled code:
#include <iostream>
int main() {
int8_t a{2};
int8_t b{3};
auto c = a * b;
std::cout << "Type of a: " << typeid(a).name() << "\n";
std::cout << "Type of b: " << typeid(b).name() << "\n";
std::cout << "Type of c: " << typeid(c).name() << "\n";
return 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed, sorry. Actually, both operands are promoted to int before the multiplication, so it's the result that has to be casted to the LHC type, as you did correctly. Thanks!
| Configurable<double> maxR{"maxR", 200., "reject PCA's above this radius"}; | ||
| Configurable<double> maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; | ||
| Configurable<double> minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; | ||
| Configurable<double> minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; | ||
| Configurable<float> maxR{"maxR", 200., "reject PCA's above this radius"}; | ||
| Configurable<float> maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; | ||
| Configurable<float> minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; | ||
| Configurable<float> minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will invalidate existing wagon configuration. Not sure we want that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So will it be a better solution to revert Configurables' types to double and static_cast to float functions' arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we define Configurables with double precision which we never use, since immediately cast it to float. Is it worth fixing once with taking care of wagons adjusting (also once, and the place of concern is well known)?
I will take the responsibility to wide-post in the HF chat the announcement and ask service wagons owners to do adjustment.
Hi @vkucera, thanks for your feedback! |
|
No, it should be instantiated as a member of a workflow UPD: Done (O.L.) |
Clang-tidy issues present in workflows related to$\Lambda^+_c\rightarrow pK\pi^+$ reconstruction are fixed.
I am not 100% sure that some of the narrowing conversion issues are addressed in proper places (e.g. change of the Configurable
double->floatwhen it is consumed by function withfloatparameter; or issues withint8_tvalues), therefore an attentive look and feedback is appreciated.UPD: addressed (part of) issues in
Tools/KFparticle/KFUtilities.h- clang-tidy and O2 linter.