Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add top channel at peak_basics and above #1270

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion straxen/plugins/events/event_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class EventBasics(strax.Plugin):
alternative S2 is selected as the largest S2 other than main S2
in the time window [main S1 time, main S1 time + max drift time].
"""
__version__ = '1.3.3'
__version__ = '1.3.4'

depends_on = ('events',
'peak_basics',
Expand Down Expand Up @@ -114,6 +114,7 @@ def _set_dtype_requirements(self):
('endtime', np.int64, 'end time since unix epoch [ns]'),
('area', np.float32, 'area, uncorrected [PE]'),
('n_channels', np.int16, 'count of contributing PMTs'),
("n_top_channels", np.int16, "count of top 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'),
Expand Down
8 changes: 6 additions & 2 deletions straxen/plugins/peaks/peak_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PeakBasics(strax.Plugin):
arrays.
NB: This plugin can therefore be loaded as a pandas DataFrame.
"""
__version__ = '0.1.4'
__version__ = '0.1.5'
parallel = True
depends_on = ('peaks',)
provides = 'peak_basics'
Expand All @@ -31,6 +31,8 @@ class PeakBasics(strax.Plugin):
'n_hits'), np.int32),
(('Number of PMTs contributing to the peak',
'n_channels'), np.int16),
(("Number of top PMTs contributing to the peak",
"n_top_channels"), np.int16),
(('PMT number which contributes the most PE',
'max_pmt'), np.int16),
(('Area of signal in the largest-contributing PMT (PE)',
Expand Down Expand Up @@ -75,7 +77,10 @@ def compute(self, peaks):
needed_fields = 'time length dt area type max_diff min_diff'
for q in needed_fields.split():
r[q] = p[q]

n_top = self.n_top_pmts
r['endtime'] = p['time'] + p['dt'] * p['length']
r["n_top_channels"] = (p["area_per_channel"][:, :n_top] > 0).sum(axis=1)
r['n_channels'] = (p['area_per_channel'] > 0).sum(axis=1)
r['n_hits'] = p['n_hits']
r['range_50p_area'] = p['width'][:, 5]
Expand All @@ -85,7 +90,6 @@ def compute(self, peaks):
r['tight_coincidence'] = p['tight_coincidence']
r['n_saturated_channels'] = p['n_saturated_channels']

n_top = self.n_top_pmts
area_top = p['area_per_channel'][:, :n_top].sum(axis=1)
# Recalculate to prevent numerical inaccuracy #442
area_total = p['area_per_channel'].sum(axis=1)
Expand Down