diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-03-26 14:49:19 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-03-26 14:49:19 -0500 |
commit | e4e65e47901f54fec3f8413522eebdd97c6ffe07 (patch) | |
tree | 9bb43e30de32dd63f489e831bde9b1d55545ff46 /src/sno_charge.c | |
parent | cecc9132b729e9c701211a317bff381f808fe505 (diff) | |
download | sddm-e4e65e47901f54fec3f8413522eebdd97c6ffe07.tar.gz sddm-e4e65e47901f54fec3f8413522eebdd97c6ffe07.tar.bz2 sddm-e4e65e47901f54fec3f8413522eebdd97c6ffe07.zip |
small update to the charge likelihood calculation
This commit updates the charge likelihood calculation to calculate:
P(hit,q|n) = P(q|hit,n)*P(hit|n)
This has almost no effect on the fit results, but is technically correct.
Diffstat (limited to 'src/sno_charge.c')
-rw-r--r-- | src/sno_charge.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/sno_charge.c b/src/sno_charge.c index f78da38..4b51954 100644 --- a/src/sno_charge.c +++ b/src/sno_charge.c @@ -54,6 +54,7 @@ static double qmean, qstd; * init_charge() by integrating the charge PDF up to the mean threshold for all * channels. */ static double log_pmiss[MAX_PE]; +static double log_phit[MAX_PE]; /* Keep track of whether init_charge() has been called so we can exit if a * function is called before being initialized. */ @@ -164,6 +165,28 @@ double get_pq(double q, int n) return interp1d(q,x,pq[n-1],nq); } +double get_log_phit(int n) +{ + /* Returns the log of the probability that the channel discriminator fired + * given `n` PE were generated. */ + if (!initialized) { + fprintf(stderr, "charge interpolation hasn't been initialized!\n"); + exit(1); + } + + if (n == 0) { + /* If no PE were generated, there is a 100% chance that the + * discriminator didn't fire. */ + return -INFINITY; + } else if (n > MAX_PE) { + /* For n > MAX_PE we assume there is a 100% chance that the + * discriminator fires. */ + return 0.0; + } + + return log_phit[n-1]; +} + double get_log_pmiss(int n) { /* Returns the log of the probability that the channel discriminator didn't @@ -290,6 +313,18 @@ void init_charge(void) params[0] = i; gsl_integration_cquad(&F, 0, MEAN_THRESH/MEAN_HIPT, 0, 1e-9, w, &result, &error, &nevals); log_pmiss[i-1] = log(result); + log_phit[i-1] = log(1.0-result); + } + + /* Set the PDF for the charge to 0 before the discriminator level. */ + for (i = 1; i <= MAX_PE; i++) { + for (j = 0; j < nq; j++) { + if (x[j] < MEAN_THRESH/MEAN_HIPT) pq[i-1][j] = 0.0; + } + double norm = trapz(&pq[i-1][0],x[1]-x[0],nq); + for (j = 0; j < nq; j++) { + pq[i-1][j] /= norm; + } } F.function = &gsl_smear; |