diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-06-14 15:31:20 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-06-14 15:31:20 -0500 |
commit | b1e355f5249126f8a5bec4eab427bfe260dfb1a3 (patch) | |
tree | 4357f8fce80ee772d66a7d12bc9e4ec94e1f83fd /src/proton.c | |
parent | 46b88c43a669fbdc0fd6438de5ecf6f02ee08677 (diff) | |
download | sddm-b1e355f5249126f8a5bec4eab427bfe260dfb1a3.tar.gz sddm-b1e355f5249126f8a5bec4eab427bfe260dfb1a3.tar.bz2 sddm-b1e355f5249126f8a5bec4eab427bfe260dfb1a3.zip |
set the maximum kinetic energy in the fit dynamically based on particle ID
The range and energy loss tables have different maximum values for electrons,
muons, and protons so we have to dynamically set the maximum energy of the fit
in order to avoid a GSL interpolation error.
This commit adds {electron,muon,proton}_get_max_energy() functions to return
the maximum energy in the tables and that is then used to set the maximum value
in the fit.
Diffstat (limited to 'src/proton.c')
-rw-r--r-- | src/proton.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/proton.c b/src/proton.c index 664d930..4714d76 100644 --- a/src/proton.c +++ b/src/proton.c @@ -165,6 +165,21 @@ err: return -1; } +/* Returns the maximum kinetic energy for a proton in the range tables. + * + * If you call proton_get_range() or proton_get_dEdx() with a kinetic + * energy higher you will get a GSL interpolation error. */ +double proton_get_max_energy(void) +{ + if (!initialized) { + if (init()) { + exit(1); + } + } + + return x[size-1]; +} + double proton_get_range(double T, double rho) { /* Returns the approximate range a proton with kinetic energy `T` will travel |