diff options
Diffstat (limited to 'src/muon.c')
-rw-r--r-- | src/muon.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -18,9 +18,12 @@ static int initialized = 0; -static double *x, *dEdx, *csda_range; +static double *x, *dEdx_rad, *dEdx, *csda_range; static size_t size; +static gsl_interp_accel *acc_dEdx_rad; +static gsl_spline *spline_dEdx_rad; + static gsl_interp_accel *acc_dEdx; static gsl_spline *spline_dEdx; @@ -83,6 +86,7 @@ static int init() } x = malloc(sizeof(double)*n); + dEdx_rad = malloc(sizeof(double)*n); dEdx = malloc(sizeof(double)*n); csda_range = malloc(sizeof(double)*n); size = n; @@ -117,6 +121,9 @@ static int init() case 0: x[n] = value; break; + case 6: + dEdx_rad[n] = value; + break; case 7: dEdx[n] = value; break; @@ -133,6 +140,10 @@ static int init() fclose(f); + acc_dEdx_rad = gsl_interp_accel_alloc(); + spline_dEdx_rad = gsl_spline_alloc(gsl_interp_linear, size); + gsl_spline_init(spline_dEdx_rad, x, dEdx_rad, size); + acc_dEdx = gsl_interp_accel_alloc(); spline_dEdx = gsl_spline_alloc(gsl_interp_linear, size); gsl_spline_init(spline_dEdx, x, dEdx, size); @@ -172,6 +183,27 @@ double muon_get_range(double T, double rho) return gsl_spline_eval(spline_range, T, acc_range)/rho; } +double muon_get_dEdx_rad(double T, double rho) +{ + /* Returns the approximate radiative dE/dx for a muon in water with kinetic + * energy `T`. + * + * `T` should be in MeV and `rho` in g/cm^3. + * + * Return value is in MeV/cm. + * + * See http://pdg.lbl.gov/2018/AtomicNuclearProperties/adndt.pdf. */ + if (!initialized) { + if (init()) { + exit(1); + } + } + + if (T < spline_dEdx_rad->x[0]) return spline_dEdx_rad->y[0]; + + return gsl_spline_eval(spline_dEdx_rad, T, acc_dEdx_rad)*rho; +} + double muon_get_dEdx(double T, double rho) { /* Returns the approximate dE/dx for a muon in water with kinetic energy |