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

First nVeto monitor plugin #634

Merged
merged 9 commits into from
Aug 20, 2021
44 changes: 44 additions & 0 deletions straxen/plugins/online_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,47 @@ def area_width_hist(self, data):
range=self.config['area_vs_width_bounds'],
bins=self.config['area_vs_width_nbins'])
return hist.T

JoranAngevaare marked this conversation as resolved.
Show resolved Hide resolved
@export
JoranAngevaare marked this conversation as resolved.
Show resolved Hide resolved
tuankhaibui marked this conversation as resolved.
Show resolved Hide resolved
@strax.takes_config(
strax.Option(
'n_nveto_pmts',
JoranAngevaare marked this conversation as resolved.
Show resolved Hide resolved
type=int,
default=120,
help='Number of nVeto PMTs'),
)
tuankhaibui marked this conversation as resolved.
Show resolved Hide resolved
class nVetoPeakMonitor(strax.Plugin):
tuankhaibui marked this conversation as resolved.
Show resolved Hide resolved
tuankhaibui marked this conversation as resolved.
Show resolved Hide resolved
depends_on = 'hitlets_nv', 'events_nv'
provides = 'nVeto_peak_monitor'
data_kind = 'nVeto_peak_monitor'
__version__ = '0.0.1'
tuankhaibui marked this conversation as resolved.
Show resolved Hide resolved
rechunk_on_save = False

def infer_dtype(self):
JoranAngevaare marked this conversation as resolved.
Show resolved Hide resolved
n_nveto_pmts = self.config['n_nveto_pmts']
dtype = [
(('Start time of the chunk', 'time'),
np.int64),
(('End time of the chunk', 'endtime'),
np.int64),
(('Hitlets per channel', 'hitlets_per_channel'),
(np.int64, n_nveto_pmts)),
(('Events of nVeto per chunk', 'events_nv_per_chunk'),
(np.int64)),
]
return dtype

def compute(self, hitlets_nv, events_nv, start, end):
JoranAngevaare marked this conversation as resolved.
Show resolved Hide resolved
# General setup
res = np.zeros(1, dtype=self.dtype)
res['time'] = start
res['endtime'] = end
n_pmt = self.config['n_nveto_pmts']
tuankhaibui marked this conversation as resolved.
Show resolved Hide resolved

hitlets_channel_count, _ = np.histogram(hitlets_nv['channel'],
bins=n_pmt,
JoranAngevaare marked this conversation as resolved.
Show resolved Hide resolved
range=[2000, 2000+n_pmt])
JoranAngevaare marked this conversation as resolved.
Show resolved Hide resolved
tuankhaibui marked this conversation as resolved.
Show resolved Hide resolved
# Count number of lone-hits per PMT
res['hitlets_per_channel'] = hitlets_channel_count
res['events_nv_per_chunk'] = len(events_nv)
return res