Skip to content

Commit

Permalink
fix hit sorting, add raw-record-aqm overlap check (#961)
Browse files Browse the repository at this point in the history
* fix hit sorting, add raw-record-aqm overlap check

* infer n_channels instead of hardcoding
  • Loading branch information
RoBGlaBe authored Mar 9, 2022
1 parent 8797601 commit 8a8d469
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions straxen/plugins/acqmon_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AqmonHits(strax.Plugin):
GPS SYNC analysis, etc.
"""
save_when = strax.SaveWhen.TARGET
__version__ = '1.1.0'
__version__ = '1.1.1'
hit_min_amplitude_aqmon = straxen.URLConfig(
default=(
# Analogue signals
Expand Down Expand Up @@ -70,6 +70,12 @@ class AqmonHits(strax.Plugin):
track=True,
help='Number of samples to use at the start of the pulse to determine the baseline'
)
check_raw_record_aqmon_overlaps = straxen.URLConfig(
default=True,
track=False,
help='Crash if any of the pulses in raw_records_aqmon overlap with others '
'in the same channel'
)

depends_on = 'raw_records_aqmon'
provides = 'aqmon_hits'
Expand All @@ -83,11 +89,17 @@ def compute(self, raw_records_aqmon):
if not_allowed_channels:
raise ValueError(
f'Unknown channel {not_allowed_channels}. Only know {self.aqmon_channels}')

if self.check_raw_record_aqmon_overlaps:
straxen.check_overlaps(raw_records_aqmon,
n_channels = max(AqmonChannels).value + 1
)

records = strax.raw_to_records(raw_records_aqmon)
strax.sort_by_time(records)
strax.zero_out_of_bounds(records)
strax.baseline(records, baseline_samples=self.baseline_samples_aqmon, flip=True)
aqmon_hits = self.find_aqmon_hits_per_channel(records)
aqmon_hits = strax.sort_by_time(aqmon_hits)
return aqmon_hits

@property
Expand All @@ -109,7 +121,6 @@ def find_aqmon_hits_per_channel(self, records):
if np.sum(is_artificial):
aqmon_hits = np.concatenate([
aqmon_hits, self.get_deadtime_hits(records[is_artificial])])
strax.sort_by_time(aqmon_hits)
return aqmon_hits

def get_deadtime_hits(self, artificial_deadtime):
Expand Down

0 comments on commit 8a8d469

Please sign in to comment.