From c8bff440e7848a33f369dff1ce11f726cecbbe20 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 10 Sep 2018 11:16:41 -0500 Subject: 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. --- src/sno_charge.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/sno_charge.c') 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; -- cgit