Skip to content

Commit

Permalink
Merge pull request #84 from coderdj/cuts_pr
Browse files Browse the repository at this point in the history
Add some basic cuts
  • Loading branch information
JelleAalbers committed Aug 31, 2018
2 parents 1415e5e + adb1fe1 commit e7743ec
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion strax/xenon/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import common, plugins, pax_interface # noqa
from . import common, plugins, cut_plugins, pax_interface # noqa
48 changes: 48 additions & 0 deletions strax/xenon/cut_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import numpy as np

import strax
export, __all__ = strax.exporter()


class FiducialCylinder1T(strax.Plugin):
"""Implementation of fiducial volume cylinder 1T,
ported from lax.sciencerun0.py"""
depends_on = ('event_positions',)
provides = 'fiducial_cylinder_1t'
dtype = [('cut_fiducial_cylinder', np.bool, 'One tonne fiducial cylinder')]

def compute(self, events):
arr = np.all([(-92.9 < events['z']), (-9 > events['z']),
(36.94 > np.sqrt(events['x']**2 + events['y']**2))], axis=0)
return dict(cut_fiducial_cylinder=arr)


class S1MaxPMT(strax.LoopPlugin):
"""Removes events where the largest hit in S1 is too large
port from lax.sciencerun0.py"""
depends_on = ('events', 'event_basics', 'peak_basics')
dtype = [('cut_s1_max_pmt', np.bool, 'S1 max PMT cut')]

def compute_loop(self, event, peaks):
ret = dict(cut_s1_max_pmt=True)
if not len(peaks) or np.isnan(event['s1_index']):
return ret

peak = peaks[event['s1_index']]
max_channel = peak['max_pmt_area']
ret['cut_s1_max_pmt']=(max_channel < 0.052 * event['s1_area'] + 4.15)
return ret


class S1LowEnergyRange(strax.Plugin):
"""Pass only events with cs1<200"""
depends_on = ('events', 'corrected_areas')
dtype = [('cut_s1_low_energy_range', np.bool, "Event under 200pe")]

def compute(self, events):
ret = np.all([events['cs1'] < 200], axis=0)
return dict(cut_s1_low_energy_range=ret)

class SR1Cuts(strax.MergeOnlyPlugin):
depends_on = ['fiducial_cylinder_1t', 's1_max_pmt', 's1_low_energy_range' ]
save_when = strax.SaveWhen.ALWAYS
4 changes: 4 additions & 0 deletions strax/xenon/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def compute(self, records):

@export
class PeakBasics(strax.Plugin):
__version__ = "0.0.1"
parallel = True
depends_on = ('peaks',)
dtype = [
Expand All @@ -156,6 +157,8 @@ class PeakBasics(strax.Plugin):
'n_channels'), np.int16),
(('PMT number which contributes the most PE',
'max_pmt'), np.int16),
(('Area of signal in the largest-contributing PMT (PE)',
'max_pmt_area'), np.int32),
(('Width (in ns) of the central 50% area of the peak',
'range_50p_area'), np.float32),
(('Fraction of area seen by the top array',
Expand All @@ -176,6 +179,7 @@ def compute(self, peaks):
r['n_channels'] = (p['area_per_channel'] > 0).sum(axis=1)
r['range_50p_area'] = p['width'][:, 5]
r['max_pmt'] = np.argmax(p['area_per_channel'], axis=1)
r['max_pmt_area'] = np.max(p['area_per_channel'], axis=1)

# TODO: get n_top_pmts from config...
area_top = (p['area_per_channel'][:, :127]
Expand Down

0 comments on commit e7743ec

Please sign in to comment.