diff options
Diffstat (limited to 'src/dc.c')
-rw-r--r-- | src/dc.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -29,6 +29,47 @@ #define MAX_PAIRS 10000 +/* Returns 1 if the event is tagged as failing the ITC cut. The definition for + * the ITC cut comes from the SNOMAN companion: + * + * This tags events having fewer than 60% of the tubes within 93 ns + * coincidence ("in-time"). The number of in-time hits is the maximum + * number in any position of a 93 ns sliding window applied to the PMT time + * spectrum of the event. + * + */ +int is_itc(event *ev) +{ + size_t i, j; + double t_array[MAX_PMTS]; + int nhit, n, maxn; + double start; + + nhit = 0; + for (i = 0; i < MAX_PMTS; i++) { + /* Only loop over hit PMTs with good calibrations. */ + if (!ev->pmt_hits[i].hit || ev->pmt_hits[i].flags) continue; + + t_array[nhit++] = ev->pmt_hits[i].t; + } + + /* Sort the times. */ + gsl_sort(t_array,1,nhit); + + maxn = 0; + for (i = 0; i < nhit; i++) { + start = t_array[i]; + n = 1; + for (j = i+1; j < nhit; j++) { + if (t_array[j] < start + ITC_TIME_WINDOW) n += 1; + else break; + } + if (n > maxn) maxn = n; + } + + return maxn/(double) nhit < ITC_TIME_FRACTION; +} + /* Returns 1 if the event is tagged as failing the FTS cut. The definition for * the FTS cut comes from the SNOMAN companion: * @@ -153,6 +194,8 @@ uint32_t get_dc_word(event *ev, zebraFile *f, zebraBank *bmast, zebraBank *bev) status |= DC_OWL_TRIGGER; if (is_fts(ev)) status |= DC_FTS; + if (is_itc(ev)) + status |= DC_ITC; return status; } |