CRPropa / CRPropa3

CRPropa is a public astrophysical simulation framework for propagating extraterrestrial ultra-high energy particles. https://crpropa.github.io/CRPropa3/
https://crpropa.desy.de
GNU General Public License v3.0
69 stars 68 forks source link

Small technical bug leading to wrong masses for secondary photons or neutrinos #483

Closed LeanderSchlegel closed 5 months ago

LeanderSchlegel commented 5 months ago

Dear all,

we noticed a small technical bug in the set of the particle rest-mass for secondaries, in the case of non-nuclei secondaries like photons or neutrinos they inherit the primary particles mass, while for nuclei, electrons or positrons the mass is set as expected. It should probably not affect the physics in the other modules and can be fixed easily, I discussed it with @lukasmerten and @JulienDoerner and would open a PR to fix it.

The bug can be reproduced with the minimal example creating an electron and adding a secondary photon. c = Candidate(11) c.addSecondary(22,1*EeV) print (c.secondaries[0].current.getMass()) 9.10938291e-31

Instead of the rest-mass 0, the photon inherits the electrons rest-mass. The bug seems to be created when addSecondary() after inheriting the current-state, calls setId() from ParticleState.cpp, where for other than nuclei or electron/positrons, the mass can not be set.

Cheers, Leander