aboutsummaryrefslogtreecommitdiff
path: root/src/sno_charge.c
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-09-10 11:16:41 -0500
committertlatorre <tlatorre@uchicago.edu>2018-09-10 11:16:41 -0500
commitc8bff440e7848a33f369dff1ce11f726cecbbe20 (patch)
tree193f0c1ee91ad3fdf154f4917836b22534b1c840 /src/sno_charge.c
parent3228ad9f5a57b8e6b1e3c4cdcefce0536c012b92 (diff)
downloadsddm-c8bff440e7848a33f369dff1ce11f726cecbbe20.tar.gz
sddm-c8bff440e7848a33f369dff1ce11f726cecbbe20.tar.bz2
sddm-c8bff440e7848a33f369dff1ce11f726cecbbe20.zip
add a fast likelihood function
This commit adds a fast function to calculate the expected number of PE at a PMT without numerically integrating over the track. This calculation is *much* faster than integrating over the track (~30 ms compared to several seconds) and so we use it during the "quick" minimization phase of the fit to quickly find the best position.
Diffstat (limited to 'src/sno_charge.c')
-rw-r--r--src/sno_charge.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/sno_charge.c b/src/sno_charge.c
index fe1e553..31de608 100644
--- a/src/sno_charge.c
+++ b/src/sno_charge.c
@@ -101,7 +101,7 @@ double pq(double q, int n)
return gsl_spline_eval(splines[n-1], q, acc);
}
-double get_pmiss(int n)
+double get_log_pmiss(int n)
{
if (!initialized) {
fprintf(stderr, "charge interpolation hasn't been initialized!\n");
@@ -109,10 +109,9 @@ double get_pmiss(int n)
}
if (n == 0) {
- return 1.0;
- } else if (n > MAX_PE) {
- /* Assume the distribution is gaussian by the central limit theorem. */
return 0.0;
+ } else if (n > MAX_PE) {
+ return -INFINITY;
}
return pmiss[n-1];
@@ -223,7 +222,7 @@ void init_charge(void)
for (i = 1; i <= MAX_PE; i++) {
params[0] = i;
gsl_integration_cquad(&F, 0, MEAN_THRESH/MEAN_HIPT, 0, 1e-9, w, &result, &error, &nevals);
- pmiss[i-1] = result;
+ pmiss[i-1] = log(result);
}
F.function = &gsl_smear;