def compute(self, raw_records_nv, start, end): strax.zero_out_of_bounds(raw_records_nv) # First we have to split rr into records and lone records: # Please note that we consider everything as a lone record which # does not satisfy the coincidence requirement intervals = coincidence(raw_records_nv, self.config['coincidence_level_recorder_nv'], self.config['resolving_time_recorder_nv']) # Always save the first and last resolving_time nanoseconds (e.g. 600 ns) since we cannot guarantee the gap # size to be larger. (We cannot use an OverlapingWindow plugin either since it requires disjoint objects.) if len(intervals): intervals_with_bounds = np.zeros((len(intervals) + 2, 2), dtype=np.int64) intervals_with_bounds[1:-1, :] = intervals intervals_with_bounds[0, :] = start, min( start + self.config['resolving_time_recorder_nv'], intervals[0, 0]) intervals_with_bounds[-1, :] = max( end - self.config['resolving_time_recorder_nv'], intervals[-1, 1]), end del intervals else: intervals_with_bounds = np.zeros((0, 2), dtype=np.int64) neighbors = strax.record_links(raw_records_nv) mask = pulse_in_interval(raw_records_nv, neighbors, *np.transpose(intervals_with_bounds)) rr, lone_records = straxen.mask_and_not(raw_records_nv, mask) # Compute some properties of the lone_records: # We compute only for lone_records baseline etc. since # raw_records_nv will be deleted, otherwise we could not change # the settings and reprocess the data in case of raw_records_nv lr = strax.raw_to_records(lone_records) del lone_records lr = strax.sort_by_time(lr) strax.zero_out_of_bounds(lr) strax.baseline( lr, baseline_samples=self.config['nbaseline_samples_lone_records_nv'], flip=True) strax.integrate(lr) lrs, lr = compute_lone_records(lr, self.config['channel_map']['nveto'], self.config['n_lone_records_nv']) lrs['time'] = start lrs['endtime'] = end return { 'raw_records_coin_nv': rr, 'lone_raw_records_nv': lr, 'lone_raw_record_statistics_nv': lrs }
def compute(self, raw_records_nv, start, end): if self.config['check_raw_record_overlaps_nv']: straxen.check_overlaps(raw_records_nv, n_channels=3000) # Cover the case if we do not want to have any coincidence: if self.config['coincidence_level_recorder_nv'] <= 1: rr = raw_records_nv lr = np.zeros(0, dtype=self.dtype['lone_raw_records_nv']) lrs = np.zeros(0, dtype=self.dtype['lone_raw_record_statistics_nv']) return { 'raw_records_coin_nv': rr, 'lone_raw_records_nv': lr, 'lone_raw_record_statistics_nv': lrs } # Search for hits to define coincidence intervals: temp_records = strax.raw_to_records(raw_records_nv) temp_records = strax.sort_by_time(temp_records) strax.zero_out_of_bounds(temp_records) strax.baseline(temp_records, baseline_samples=self.baseline_samples, flip=True) hits = strax.find_hits(temp_records, min_amplitude=self.hit_thresholds) del temp_records # First we have to split rr into records and lone records: # Please note that we consider everything as a lone record which # does not satisfy the coincidence requirement intervals = find_coincidence( hits, self.config['coincidence_level_recorder_nv'], self.config['resolving_time_recorder_nv'], self.config['pre_trigger_time_nv']) del hits # Always save the first and last resolving_time nanoseconds (e.g. 600 ns) since we cannot guarantee the gap # size to be larger. (We cannot use an OverlapingWindow plugin either since it requires disjoint objects.) if len(intervals): intervals_with_bounds = np.zeros(len(intervals) + 2, dtype=strax.time_fields) intervals_with_bounds['time'][1:-1] = intervals['time'] intervals_with_bounds['endtime'][1:-1] = intervals['endtime'] intervals_with_bounds['time'][0] = start intervals_with_bounds['endtime'][0] = min( start + self.config['resolving_time_recorder_nv'], intervals['time'][0]) intervals_with_bounds['time'][-1] = max( end - self.config['resolving_time_recorder_nv'], intervals['endtime'][-1]) intervals_with_bounds['endtime'][-1] = end del intervals else: intervals_with_bounds = np.zeros((0, 2), dtype=strax.time_fields) neighbors = strax.record_links(raw_records_nv) mask = pulse_in_interval( raw_records_nv, neighbors, intervals_with_bounds['time'], intervals_with_bounds['endtime'], ) rr, lone_records = straxen.mask_and_not(raw_records_nv, mask) # Compute some properties of the lone_records: # We compute only for lone_records baseline etc. since # raw_records_nv will be deleted, otherwise we could not change # the settings and reprocess the data in case of raw_records_nv lr = strax.raw_to_records(lone_records) del lone_records lr = strax.sort_by_time(lr) strax.zero_out_of_bounds(lr) strax.baseline(lr, baseline_samples=self.baseline_samples, flip=True) strax.integrate(lr) lrs, lr = compute_lone_records(lr, self.config['channel_map']['nveto'], self.config['n_lone_records_nv']) lrs['time'] = start lrs['endtime'] = end return { 'raw_records_coin_nv': rr, 'lone_raw_records_nv': lr, 'lone_raw_record_statistics_nv': lrs }