Skip to content
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

Possible fix for wrong secondary masses of photons and neutrinos #484

Merged
merged 5 commits into from
Apr 29, 2024

Conversation

LeanderSchlegel
Copy link
Member

Dear all,

with this PR we try to fix #483. @lukasmerten, @JulienDoerner and me discussed it and introduced a new function particleMass(int id) in ParticleMass.cpp to fix the bug by calling it in setId(int newId) in ParticleState.cpp. It gives all particles other than nuclei or electrons/positrons a zero rest-mass and could possibly be extended for other particles when needed.

Copy link
Member

@JulienDoerner JulienDoerner left a comment

Choose a reason for hiding this comment

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

The solution looks good to me.
I have only smaller style comments.

And maybe we should include a test in the testCore part explicitly checking the secondary mass.

CHANGELOG.md Outdated

### New features:

### Interface changes:
* Added new backwards-compatible function particleMass that returns particle mass also for non-nuclei
Copy link
Member

Choose a reason for hiding this comment

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

Add this to new features, as the old interface stays the same.
There is no change in behaviour for the old functions, which are available for the user.

@param id id of the particle following the PDG numbering scheme
@returns The mass of a the particle
*/
double particleMass(int id);
Copy link
Member

Choose a reason for hiding this comment

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

add whiteline between the function definition and the comment for the next function.

if (isNucleus(id))
return nuclearMass(id);
if (abs(id) == 11)
m = mass_electron;
Copy link
Member

Choose a reason for hiding this comment

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

why is it here not a direct return statement. This would reduce the code amount.

@lukasmerten
Copy link
Member

Looks good to me. Let's wait for more comments otherwise I will merge in the next days.

@LeanderSchlegel
Copy link
Member Author

Thank you very much for your feedback!
As suggested by Julien and in discussion with him, I added two small tests in testCore, one extending the test of addSecondary to also check their masses and one new test, covering the new function particleMass(int id).

…ing new test for the particleMass() function
@lukasmerten lukasmerten merged commit 1dba43e into CRPropa:master Apr 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Small technical bug leading to wrong masses for secondary photons or neutrinos
3 participants