-
Notifications
You must be signed in to change notification settings - Fork 16
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
Photon ID shape parameter: correct very small negative values caused by computational precision in width of theta/module #90
Conversation
Co-authored-by: Giovanni Marchiori <[email protected]>
Hi @dasphy, |
Yes I think fabs() is better. I just pushed changes. |
@kjvbrt I don't like too much this solution, without even adding a comment to the code to explain the fabs, nor a warning in the output. I would have preferred the option that if the argument of sqrt is slightly negative the width is set to zero and a warning message is print to log, giving also the value of wtheta2. |
I added warnings in the log and set the value to 0 if |
Hi, what about having a hard crash or warning if the variable is negative more that The test now notifies only when the negative value is very small. |
Seems a good idea to me |
Co-authored-by: Juraj Smiesko <[email protected]>
Can you do the same change for all the cases? |
Sounds good to me, let me modify the code accordingly |
Nice, looks good to me. Will merge shortly... |
Thank you ! @kjvbrt |
Follow-up of #79 . In the width calculation:
double _w_theta_3Bin = sqrt(theta2_E_3Bin / sum_E_3Bin - std::pow(theta_E_3Bin / sum_E_3Bin, 2));
Mathematically the value inside sqrt() should never be negative, but a very small negative value might be produced, due to the precision of calculation in code.
A threshold
-1e-9
is set to correct this:if (_w_theta_3Bin2 < 0. && _w_theta_3Bin2 > -1e-9) _w_theta_3Bin2 = 0. ;
Tagging @giovannimarchiori , @kjvbrt
Cheers, Tong