From cc0b56d8cb930ba386f59470160c1c460ab64eaf Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 9 Sep 2019 11:12:42 -0500 Subject: uncalibrate MC times and charges in get_event() This commit updates get_event() to fill in the uncalibrated charge and time info from the calibrated charge and time. The ECA calibrated time and ECA + PCA without walk correction times (ept and pt1) are just set to the calibrated time. The uncalibrated charges are set by multiplying the calibrated charge by the mean high-half point and adding a constant offset, and the ECA calibrated charges are set by taking the uncalibrated charges and subtracting the offset. The reason for filling these in is so that we can test the data cleaning cuts on MC. Although it would be better if these were filled in by the MC, this is better than nothing. --- src/zdab_utils.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/zdab_utils.c b/src/zdab_utils.c index 2259676..41be1c6 100644 --- a/src/zdab_utils.c +++ b/src/zdab_utils.c @@ -27,6 +27,15 @@ char zdab_err[256]; +/* Mean of high-half point distribution. */ +static double MEAN_HIPT = 46.0; + +/* Average value for the QHS/QHL/QLX pedestal. + * + * Note: This is *not* actually accurate. I just need something roughly correct + * to "uncalibrate" the Monte Carlo. */ +static double MEAN_PEDESTAL = 600.0; + size_t get_nhit(event *ev) { /* Returns the number of PMT hits in event `ev`. @@ -131,6 +140,8 @@ int get_event(zebraFile *f, event *ev, zebraBank *bev) /* Use standard time if this is MC since the multiphoton time * isn't calculated for MC. */ ev->pmt_hits[id].t = bpmt.pt; + ev->pmt_hits[id].ept = bpmt.pt; + ev->pmt_hits[id].pt1 = bpmt.pt; } else { /* Use the multiphoton PCA time since we are looking at high * energy events. */ @@ -194,6 +205,18 @@ int get_event(zebraFile *f, event *ev, zebraBank *bev) * * Therefore, we ignore it for MC. */ ev->pmt_hits[id].q = bpmt.phs; + + /* For the uncalibrated charges, multiply the charge by the + * mean high-half point and then add a constant offset. */ + ev->pmt_hits[id].qihl = fmax(fmin(bpmt.phl*MEAN_HIPT + MEAN_PEDESTAL,4095.0),0.0); + ev->pmt_hits[id].qihs = fmax(fmin(bpmt.phs*MEAN_HIPT + MEAN_PEDESTAL,4095.0),0.0); + ev->pmt_hits[id].qilx = fmax(fmin(bpmt.plx*MEAN_HIPT + MEAN_PEDESTAL,4095.0),0.0); + + /* For the ECA calibrated charges, just subtract the offset + * from the uncalibrated charges. */ + ev->pmt_hits[id].ehl = ev->pmt_hits[id].qihl - MEAN_PEDESTAL; + ev->pmt_hits[id].ehs = ev->pmt_hits[id].qihs - MEAN_PEDESTAL; + ev->pmt_hits[id].elx = ev->pmt_hits[id].qilx - MEAN_PEDESTAL; } else if (bpmt.pihs < 4095 && bpmt.pihs >= 300) { ev->pmt_hits[id].q = bpmt.phs; } else if (bpmt.pilx < 4095 && bpmt.pilx >= 300) { -- cgit