diff --git a/pax/datastructure.py b/pax/datastructure.py index bbcaa7fa..ddac59b4 100644 --- a/pax/datastructure.py +++ b/pax/datastructure.py @@ -199,6 +199,9 @@ class Peak(StrictModel): #: Total areas of all hits per PMT (pe). area_per_channel = np.array([], dtype='float64') + # contribution to tight coincidence, 1 or 0 for each channel + coincidence_per_channel = np.array([], dtype=np.int16) + #: Total area of all hits across all PMTs (pes). #: In XerawdpImitation mode, rightmost sample is not included in area integral. area = 0.0 diff --git a/pax/plugins/io/ROOTClass.py b/pax/plugins/io/ROOTClass.py index f64ef8ca..90fa1703 100644 --- a/pax/plugins/io/ROOTClass.py +++ b/pax/plugins/io/ROOTClass.py @@ -191,6 +191,7 @@ def _build_model_class(self, model): for _fn, length in (( ('area_per_channel', n_channels), ('hits_per_channel', n_channels), + ('coincidence_per_channel', n_channels), ('n_saturated_per_channel', n_channels), ('sum_waveform', n_waveform_samples), ('sum_waveform_top', n_waveform_samples), diff --git a/pax/plugins/peak_processing/BasicProperties.py b/pax/plugins/peak_processing/BasicProperties.py index 5da4ffa1..3403386d 100644 --- a/pax/plugins/peak_processing/BasicProperties.py +++ b/pax/plugins/peak_processing/BasicProperties.py @@ -119,16 +119,23 @@ def transform_event(self, event): # Compute a tight coincidence count (useful for distinguishing S1s from junk) x = peak.hits['index_of_maximum'] - l = peak.index_of_maximum - self.tight_coincidence_samples - r = peak.index_of_maximum + self.tight_coincidence_samples - peak.tight_coincidence = len(np.unique(peak.hits['channel'][(x >= l) & (x <= r)])) + left = peak.index_of_maximum - self.tight_coincidence_samples + right = peak.index_of_maximum + self.tight_coincidence_samples + peak.tight_coincidence = len(np.unique(peak.hits['channel'][(x >= left) & (x <= right)])) + + # list of pmts that contribute to tight coincidence of the peak + peak.coincidence_per_channel = np.zeros_like(peak.hits_per_channel) + for hitt in peak.hits: + if hitt['index_of_maximum'] >= left and hitt['index_of_maximum'] <= right: + pmt_index = hitt['channel'] + peak.coincidence_per_channel[pmt_index] = 1 # varying tight coincidence intervals peak.tight_coincidence_thresholds = np.zeros(5, dtype=np.int16) for ip, window in enumerate([5, 4, 3, 2, 1]): - l = peak.index_of_maximum - window - r = peak.index_of_maximum + window - peak.tight_coincidence_thresholds[ip] = len(np.unique(peak.hits['channel'][(x >= l) & (x <= r)])) + left = peak.index_of_maximum - window + right = peak.index_of_maximum + window + peak.tight_coincidence_thresholds[ip] = len(np.unique(peak.hits['channel'][(x >= left) & (x <= right)])) # Store the waveform; for tpc also store the top waveform put_w_in_center_of_field(w, peak.sum_waveform, cog_idx)