aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile2
-rw-r--r--src/sno_charge.c10
-rw-r--r--src/sno_charge.h2
-rw-r--r--src/zdab_utils.c7
4 files changed, 20 insertions, 1 deletions
diff --git a/src/Makefile b/src/Makefile
index e5ca1cd..7787558 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -38,7 +38,7 @@ test-find-peaks: test-find-peaks.o zebra.o likelihood.o pmt.o vector.o misc.o mu
calculate-csda-range: calculate-csda-range.o
-zdab-cat: zdab-cat.o zebra.o pmt.o vector.o misc.o zdab_utils.o pack2b.o db.o dqxx.o dict.o siphash.o release.o dc.o sort.o util.o hdf5_utils.o
+zdab-cat: zdab-cat.o zebra.o pmt.o vector.o misc.o zdab_utils.o pack2b.o db.o dqxx.o dict.o siphash.o release.o dc.o sort.o util.o hdf5_utils.o sno_charge.o
install:
@mkdir -p $(INSTALL_BIN)
diff --git a/src/sno_charge.c b/src/sno_charge.c
index 17e4ebc..f36bfb5 100644
--- a/src/sno_charge.c
+++ b/src/sno_charge.c
@@ -106,6 +106,16 @@ static double QSMEAR_ADC = 3.61;
/* Mean of simulated threshold distribution. */
static double MEAN_THRESH = 8.5;
+double get_qlo(void)
+{
+ return qlo;
+}
+
+double get_qhi(void)
+{
+ return qhi;
+}
+
static double nlopt_log_pq(unsigned int n, const double *x, double *grad, void *params)
{
int i;
diff --git a/src/sno_charge.h b/src/sno_charge.h
index 549ca2c..7c6513d 100644
--- a/src/sno_charge.h
+++ b/src/sno_charge.h
@@ -17,6 +17,8 @@
#ifndef SNO_CHARGE_H
#define SNO_CHARGE_H
+double get_qlo(void);
+double get_qhi(void);
double get_most_likely_mean_pe(double q);
void init_charge(void);
double get_log_pq(double q, int n);
diff --git a/src/zdab_utils.c b/src/zdab_utils.c
index a7669fa..d4e3215 100644
--- a/src/zdab_utils.c
+++ b/src/zdab_utils.c
@@ -23,6 +23,7 @@
#include "event.h"
#include "zebra.h"
#include "misc.h"
+#include "sno_charge.h"
char zdab_err[256];
@@ -196,6 +197,12 @@ int get_event(zebraFile *f, event *ev, zebraBank *bev)
ev->pmt_hits[id].flags |= PMT_FLAG_CHARGE;
}
+ /* Flag PMTs with charges below qlo, since otherwise the negative
+ * log likelihood will be nan. */
+ if (ev->pmt_hits[id].q < get_qlo()) {
+ ev->pmt_hits[id].flags |= PMT_FLAG_CHARGE;
+ }
+
if (pmts[id].pmt_type != pmt_types[i]) {
get_pmt_type_string(pmts[id].pmt_type,pmt_type_string);
fprintf(stderr, "%i/%i/%i has PMT type %s but expected %s based on bank\n", crate, card, channel, pmt_type_string, pmt_names[i]);