diff options
Diffstat (limited to 'src/zdab_utils.c')
-rw-r--r-- | src/zdab_utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
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) { |