From b1e355f5249126f8a5bec4eab427bfe260dfb1a3 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Fri, 14 Jun 2019 15:31:20 -0500 Subject: 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. --- src/electron.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/electron.c') diff --git a/src/electron.c b/src/electron.c index 5b4133a..3f5d4d8 100644 --- a/src/electron.c +++ b/src/electron.c @@ -365,6 +365,21 @@ err: return -1; } +/* Returns the maximum kinetic energy for an electron in the range tables. + * + * If you call electron_get_range() or electron_get_dEdx() with a kinetic + * energy higher you will get a GSL interpolation error. */ +double electron_get_max_energy(void) +{ + if (!initialized) { + if (init()) { + exit(1); + } + } + + return x[size-1]; +} + double electron_get_range(double T, double rho) { /* Returns the approximate range a electron with kinetic energy `T` will travel -- cgit