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
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
### Bug fixes:
* Fixed sign for exponential decay of magn. field strength with Galactic height in LogarithmicSpiralField
* Fixed r term in source distribution for SNR and Pulsar
* Fixed wrong mass inheritance for secondaries other than nuclei or electron/positron

### New features:
* Added new backwards-compatible function particleMass that returns particle mass also for non-nuclei

### Interface changes:

Expand Down
12 changes: 11 additions & 1 deletion include/crpropa/ParticleMass.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ namespace crpropa {
* \addtogroup PhysicsDefinitions
* @{
*/


/** Get the particle mass by lookup from a table.
For nuclei, the function nuclearMass is called, for the case of
electrons or positrons the mass_electron is returned and for all
other cases like photons and also neutrinos, zero mass is returned.
@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.


/** Get the nucleus mass by lookup from a table.
The masses are the atomic masses from the NIST database:
http://www.nist.gov/pml/data/comp.cfm
Expand All @@ -17,6 +26,7 @@ namespace crpropa {
@returns The mass of a the nucleus
*/
double nuclearMass(int id);

/** Get the nucleus mass by lookup from a table.
The masses are the atomic masses from the NIST database:
http://www.nist.gov/pml/data/comp.cfm
Expand Down
8 changes: 8 additions & 0 deletions src/ParticleMass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ struct NuclearMassTable {

static NuclearMassTable nuclearMassTable;

double particleMass(int id) {
if (isNucleus(id))
return nuclearMass(id);
if (abs(id) == 11)
return mass_electron;
return 0.0;
}

double nuclearMass(int id) {
int A = massNumber(id);
int Z = chargeNumber(id);
Expand Down
4 changes: 1 addition & 3 deletions src/ParticleState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,12 @@ double ParticleState::getRigidity() const {

void ParticleState::setId(int newId) {
id = newId;
pmass = particleMass(id);
if (isNucleus(id)) {
pmass = nuclearMass(id);
charge = chargeNumber(id) * eplus;
if (id < 0)
charge *= -1; // anti-nucleus
} else {
if (abs(id) == 11)
pmass = mass_electron;
charge = HepPID::charge(id) * eplus;
}
}
Expand Down