Skip to content

Commit

Permalink
events are great
Browse files Browse the repository at this point in the history
  • Loading branch information
cfuselli committed Dec 6, 2023
1 parent fab4a77 commit 6ca1d6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
1 change: 0 additions & 1 deletion amstrax/plugins/events/event_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def _set_dtype_requirements(self):
('area', np.float32, 'area, uncorrected [PE]'),
('n_channels', np.int16, 'count of contributing PMTs'),
('n_hits', np.int16, 'count of hits contributing at least one sample to the peak'),
('n_competing', np.int32, 'number of competing peaks'),
('max_pmt', np.int16, 'PMT number which contributes the most PE'),
('max_pmt_area', np.float32, 'area in the largest-contributing PMT (PE)'),
('range_50p_area', np.float32, 'width, 50% area [ns]'),
Expand Down
13 changes: 4 additions & 9 deletions amstrax/plugins/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@
strax.Option('trigger_min_area', default=10,
help='Peaks must have more area (PE) than this to '
'cause events'),
strax.Option('trigger_min_competing', default=3, # not used
help='Peaks must have More nearby larger or slightly smaller'
' peaks to cause events'),
strax.Option('left_event_extension', default=int(0),
strax.Option('left_event_extension', default=int(5e5),
help='Extend events this many ns to the left from each '
'triggering peak'),
strax.Option('right_event_extension', default=int(5e4),
help='Extend events this many ns to the right from each '
'triggering peak'),
)
class Events(strax.OverlapWindowPlugin):
depends_on = ['peaks',
#'peak_basics',
#'peak_proximity',
'peak_classification'] # peak_basics instead of n_competing
'peak_basics',
]
rechunk_on_save = False
data_kind = 'events'
parallel = False
Expand All @@ -32,7 +27,7 @@ class Events(strax.OverlapWindowPlugin):
('time', np.int64, 'Event start time in ns since the unix epoch'),
('endtime', np.int64, 'Event end time in ns since the unix epoch')]
events_seen = 0
__version__ = '1.0.1'
__version__ = '1.0.2'


def get_window_size(self):
Expand Down
25 changes: 5 additions & 20 deletions amstrax/plugins/peaks/peak_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,9 @@
),
strax.Option(
's2_min_width',
default=750,
default=225,
help="Minimum width for S2s"
),
strax.Option(
's1_min_center_position',
default=0.2,
help="Minimum center position for S2s"
),
strax.Option(
's1_max_center_position',
default=0.44,
help="Maximum center position for S2s"
),
strax.Option(
's1_min_channels',
default=5,
Expand All @@ -81,12 +71,12 @@
),
strax.Option(
's2_min_area_fraction_top',
default=0.2,
default=0,
help="Minimum area fraction top for S2s"
),
strax.Option(
's1_max_area_fraction_top',
default=0.5,
default=.2,
help="Maximum area fraction top for S1s"
),
)
Expand All @@ -97,7 +87,7 @@ class PeakBasics(strax.Plugin):

parallel = "False"
rechunk_on_save = False
__version__ = "2.0"
__version__ = "2.1"
dtype = [
(('Start time of the peak (ns since unix epoch)',
'time'), np.int64),
Expand Down Expand Up @@ -180,15 +170,10 @@ def compute(self, peaks):
# 0 = unknown
# 1 = s1
# 2 = s2

# Negative or zero-area peaks have centertime at startime
center_position = (r['center_time'] - p['time']) / (p['dt'] * p['length'])


is_s1 = p['area'] >= self.config['s1_min_area']
is_s1 &= r['range_50p_area'] > self.config['s1_min_width']
is_s1 &= r['range_50p_area'] < self.config['s1_max_width']
is_s1 &= center_position > self.config['s1_min_center_position']
is_s1 &= center_position < self.config['s1_max_center_position']
is_s1 &= r['area_fraction_top'] <= self.config['s1_max_area_fraction_top']
is_s1 &= r['n_channels'] >= self.config['s1_min_channels']

Expand Down

0 comments on commit 6ca1d6c

Please sign in to comment.