Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3112f3c
baseline fix (abs on np.ptp output and zero mask
jvmead Sep 30, 2025
34422e1
feeding RMS from wvfm filter (baseline function) stage through to sum…
jvmead Sep 30, 2025
6e2874a
ongoing bug fixing for passing rms forward to hitfinder
jvmead Oct 1, 2025
5689218
changing settings so that inputs are compatabile with 600 tick wvfms
jvmead Oct 21, 2025
70477b7
removing default values so yaml has to specify
jvmead Oct 21, 2025
04524a0
narrower segment width to avoid signal in wvfms without padding (may …
jvmead Oct 22, 2025
ae54255
removing factor 4 from fwvfm and adding clipped to wvfm/data/
jvmead Oct 24, 2025
722e63b
work in progress - still doesn't sync up with expectation
jvmead Oct 24, 2025
12a5706
trying to fix clipped tag unsucessfully
jvmead Oct 29, 2025
09811b0
running now, need to sanity check
jvmead Nov 3, 2025
9305893
sanity check looks good now
jvmead Nov 4, 2025
11a4d28
inherited for summed wvfms
jvmead Nov 4, 2025
af1426e
pushing last changes
jvmead Nov 4, 2025
46a57c7
Fix NaN baselines
mjkramer Nov 18, 2025
2460c87
fix for the fix
jvmead Nov 18, 2025
ccb9929
removing derivative and option to not just use local maxima
jvmead Nov 18, 2025
e526cd9
Merge remote-tracking branch 'upstream/develop' into feature/baseline…
jvmead Nov 18, 2025
3126fd0
Merge branch 'removing_derivative_option' into feature/baseline_fix_r…
jvmead Nov 18, 2025
53d6bbc
resolving conflicts
jvmead Nov 18, 2025
10718c4
fix the args
jvmead Nov 18, 2025
8dde15a
revert back to cherry picked version
jvmead Nov 18, 2025
d35d3cb
fprompt testing avoiding edge cases or filling with nan
jvmead Nov 19, 2025
d75456d
playing with logic of masking
jvmead Nov 19, 2025
7c39c1e
fixes from mathilde for running on run2 data
jvmead Nov 19, 2025
97726bd
Merge branch 'develop' into feature/adc_clip_tag
jvmead Nov 20, 2025
1686a0f
tidyup before test
jvmead Nov 20, 2025
287f9f4
fixing rogue line in wvmf sum
jvmead Nov 20, 2025
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
65 changes: 65 additions & 0 deletions data/proto_nd_flow/2x2_run2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# The configuration accept the following three ways for e_field, lifetime, response_bin_size
# Can be extended to other parameters
# a single value, e.g e_field: 0.50
# a list with a single element, e.g e_field: [0.50]
# a list with the length of module numbers, e_field: [0.50, 0.51, 0.49, 0.52]
# Note that if simulation with module variation is activated,
# but the list of the parameter of interest is shorter than the number of modules,
# then it would likely to take the first value
temperature: 87.17 # K
e_field: 0.50 # kV/cm
lifetime: 2.2e+3 # us
time_interval: [0, 200.] # us
long_diff: 4.0e-6 # cm * cm / us
tran_diff: 8.8e-6 # cm * cm / us
drift_length: 30.27225 # cm
response_sampling: 0.1 # us
response_bin_size: 0.04434 # cm
time_padding: 190 # us
time_window: 189.1 # us
tpc_offsets: # cm
- [33.5, 0., 33.5]
- [33.5, 0., -33.5]
- [-33.5, 0., 33.5]
- [-33.5, 0., -33.5]
tile_map:
- [[7,5,3,1],[8,6,4,2]]
- [[16,14,12,10],[15,13,11,9]]
module_to_io_groups:
1: [1, 2]
2: [3, 4]
3: [5, 6]
4: [7, 8]

# Light geometry parameters
module_to_tpcs:
1: [0, 1]
2: [2, 3]
3: [4, 5]
4: [6, 7]
n_op_channel: 384
tpc_to_op_channel:
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]
- [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
- [96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143]
- [144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191]
- [192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239]
- [240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287]
- [288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335]
- [336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]

# Light simulation parameters
singlet_fraction: 0.3
tau_s: 0.001 # us
tau_t: 1.530 # us
op_channel_efficiency: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
light_gain: [-7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0] # ADC us / PE
light_det_noise_sample_spacing: 0.016 # us
light_trig_threshold: [-4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000, -4500, -2000]
light_trig_mode: 1
light_window: [0, 9.6] # us
light_trig_window: [1.6, 14.4] # us
light_digit_sample_spacing: 0.016 # us
light_nbit: 14
max_light_truth_ids: 50 # set to zero to disable light truth backtracking
mc_truth_threshold: 0.1 # pe/us
8 changes: 6 additions & 2 deletions src/proto_nd_flow/reco/light/adc64_event_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ class LightADC64EventGenerator(H5FlowGenerator):
``wvfm`` datatype::

samples i2(n_adc,n_channels,n_samples), sample 10-bit ADC value (lowest 6 bits are not used)
clipped ?(n_adc,n_channels), boolean indicator if any samples are saturated
'''
defaults = dict(
n_adcs = 8,
n_channels = 64,
batch_size = 64,
sync_channel = 0,
sync_threshold = 40000,
sync_buffer = 200,
sync_buffer = 200,
clock_timestamp_factor = 1.0,
utime_ms_window = 1000,
tai_ns_window = 1000,
Expand All @@ -89,7 +90,8 @@ def event_dtype(self): return np.dtype([
])

def wvfm_dtype(self): return np.dtype([
('samples', 'i2', (self.n_adcs, self.n_channels, self.n_samples)) # sample value
('samples', 'i2', (self.n_adcs, self.n_channels, self.n_samples)), # sample value
('clipped', '?', (self.n_adcs, self.n_channels)) # boolean indicator if any samples are saturated
])

def __init__(self, **params):
Expand Down Expand Up @@ -187,6 +189,8 @@ def next(self):
event_arr[ievent]['tai_ns'][iadc] = time[data_index]['tai_s']*1e9 + time[data_index]['tai_ns']
event_arr[ievent]['wvfm_valid'][iadc, channels] = True
wvfm_arr[ievent]['samples'][iadc, channels] = data[data_index]['voltage']
# Check for clipping (ADC saturation at max value ~32764)
wvfm_arr[ievent]['clipped'][iadc, channels] = np.any(np.abs(data[data_index]['voltage']) >= 32764, axis=-1)

# apply different clock frequency
event_arr['tai_ns'] = (event_arr['tai_ns'] * self.clock_timestamp_factor).astype(event_arr.dtype['tai_ns'].base)
Expand Down
88 changes: 36 additions & 52 deletions src/proto_nd_flow/reco/light/hit_finder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from networkx import random_shell_graph
import numpy as np
import numpy.ma as ma
from collections import defaultdict
Expand All @@ -22,17 +23,16 @@ class WaveformHitFinder(H5FlowStage):

Parameters:
- ``wvfm_dset_name``: ``str``, path to input waveforms
- ``rms_dset_name``: ``str``, path to noise RMS dataset from baselining func in wvfm filtering stage
- ``t_ns_dset_name``: ``str``, path to corrected light PPS timestamps
- ``hits_dset_name``: ``str``, path to output hits dataset
- ``near_samples``: ``int``, number of neighboring samples to keep
- ``hit_level``: ``str``, "sipm" or "sum" hit finder (defines variable names)
- ``mad_factor``: ``float``, factor of median abs dev used to define threshold under which noise width is taken
- ``noise_factor``: ``float``, factor of noise width used to define threshold over which hit finder is run
- ``n_bins_rolled``: ``int``, number of bins over which the rolling threshold of the hit finder is defined
- ``rt_sqrt_factor``: ``float``, factor used to scale the statistical contribution to the rolling threshold
- ``pe_weight``: ``float``, weight applied to the PEs in rolling threshold statistical component
- ``rising_edge``: ``bool``, True => hit finder tags first bin over rolling threshold as the hit
- ``local_maxima``: ``bool``, True => uses 5 sample window after rising edge, tags hits as argmax of those samples (otherwise uses derivative based method)
- ``prompt_window``: ``float``, Prompt light window in ns (fprompt caluclation input for PSD)
- ``long_window``: ``float``, Long light window in ns (fprompt caluclation input for PSD)
- ``tick_duration``: ``float``, Duration of ticks in ADC sampling
Expand Down Expand Up @@ -68,6 +68,7 @@ class WaveformHitFinder(H5FlowStage):
class_version = '2.0.0'

default_hits_dset_name = 'light/hits'
default_rms_dset_name = 'light/rms'
default_near_samples = 3
default_interpolation = 256
default_global_threshold = 2000
Expand Down Expand Up @@ -156,45 +157,38 @@ def calculate_fprompt(self, summed_wvfm, interactions, prompt_window_ns, long_wi
for j in range(interactions.shape[1]):
# Loop over each trap type
for k in range(interactions.shape[2]):
# Skip if no peak found in this channel
if not np.any(interactions[i, j, k]):
prompt_int[i, j, k] = np.nan
total_int[i, j, k] = np.nan
continue
# Calculate the prompt and total integrals
t0_bin = np.argmax(interactions[i, j, k]) - 5
end_prompt = t0_bin + prompt_bins
end_total = t0_bin + total_bins
prompt_int[i, j, k] = np.sum(summed_wvfm[i, j, k, t0_bin:end_prompt])
total_int[i, j, k] = np.sum(summed_wvfm[i, j, k, t0_bin:end_total])
# Calculate fprompt
with np.errstate(divide='ignore', invalid='ignore'):
fprompt = np.where(
(total_int > 0) & (prompt_int > 0) & ~np.isnan(prompt_int) & ~np.isnan(total_int),
np.divide(prompt_int, total_int),
np.nan
)
return total_int, fprompt

if end_prompt > summed_wvfm.shape[-1] or end_total > summed_wvfm.shape[-1] or t0_bin < 0:
prompt_int[i, j, k] = np.nan
total_int[i, j, k] = np.nan
else:
prompt_int[i, j, k] = np.sum(summed_wvfm[i, j, k, t0_bin:end_prompt])
total_int[i, j, k] = np.sum(summed_wvfm[i, j, k, t0_bin:end_total])
# create mask
invalid_mask = (total_int <= 0) | (prompt_int <= 0) | np.isnan(prompt_int) | np.isnan(total_int)
# Calculate fprompt using masked arrays
prompt_int_masked = ma.array(prompt_int, mask=invalid_mask)
total_int_masked = ma.array(total_int, mask=invalid_mask)
fprompt = ma.divide(prompt_int_masked, total_int_masked)
fprompt = fprompt.filled(np.nan)

def get_noise_threshold(self, wvfms, n_mad_factor):
# Initialize median and MAD
median = np.ma.median(wvfms, axis=-1)
mad = np.ma.median(np.abs(wvfms - median[..., np.newaxis]), axis=-1)
# identify outliers in the waveform
mad_factor = n_mad_factor * mad
noise_mask = np.abs(wvfms - median[..., np.newaxis]) < mad_factor[..., np.newaxis]
# set non mask values to nan
noise_samples = np.where(noise_mask, wvfms, np.nan)
# calculate noise as stddev of noise_samples
noise = np.where(np.nansum(noise_samples, axis=-1) != 0,
np.nanstd(noise_samples, axis=-1),
np.nan)
return noise
return total_int, fprompt


def peak_finder(self, wvfm, noise,
n_noise_factor,
n_bins_rolled,
n_sqrt_rt_factor,
pe_weight,
use_rising_edge=False,
use_local_maxima=True):
use_rising_edge=False):

# height = flat threshold over noise (n*sigma)
height = n_noise_factor * noise[..., np.newaxis] * np.ones(wvfm.shape[-1])
Expand All @@ -211,24 +205,14 @@ def peak_finder(self, wvfm, noise,
first_bins_over[..., 1:] &= ~bins_over_dynamic_threshold[..., :-1]
if use_rising_edge:
return first_bins_over
# Peak finding
elif use_local_maxima:
# check 5 bins after first_bins_over and add argmax
peak_bins = np.zeros_like(wvfm, dtype=bool)
first_bins_indices = np.where(first_bins_over)
for idx in zip(*first_bins_indices):
start_idx = idx[-1]
end_idx = min(start_idx + 5, wvfm.shape[-1])
peak_bin = np.argmax(wvfm[idx[:-1] + (slice(start_idx, end_idx),)])
peak_bins[idx[:-1] + (start_idx + peak_bin,)] = True
else:
# Derivative-based peak detection
wvfm_d1 = np.gradient(wvfm, axis=-1)
wvfm_d2 = np.gradient(wvfm_d1, axis=-1)
peak_bins = (wvfm > dynamic_threshold) & (wvfm > height) & \
(wvfm_d1 < 0) & (wvfm_d2 < 0)
# Keep only the first peak in consecutive runs
peak_bins[..., 1:] &= ~peak_bins[..., :-1]
# check 5 bins after first_bins_over and add argmax
peak_bins = np.zeros_like(wvfm, dtype=bool)
first_bins_indices = np.where(first_bins_over)
for idx in zip(*first_bins_indices):
start_idx = idx[-1]
end_idx = min(start_idx + 5, wvfm.shape[-1])
peak_bin = np.argmax(wvfm[idx[:-1] + (slice(start_idx, end_idx),)])
peak_bins[idx[:-1] + (start_idx + peak_bin,)] = True

return peak_bins

Expand All @@ -237,19 +221,18 @@ def __init__(self, **params):
super(WaveformHitFinder, self).__init__(**params)
self.wvfm_dset_name = params.get('wvfm_dset_name')
self.wvfm_align_dset_name = f'{self.wvfm_dset_name}/alignment'
self.rms_dset_name = params.get('rms_dset_name')
self.t_ns_dset_name = params.get('t_ns_dset_name')
self.hits_dset_name = params.get('hits_dset_name',
self.default_hits_dset_name)
self.near_samples = params.get('near_samples',
self.default_near_samples)
self.hit_level = params.get('hit_level')
self.mad_factor = params.get('mad_factor')
self.noise_factor = params.get('noise_factor')
self.n_bins_rolled = params.get('n_bins_rolled')
self.rt_sqrt_factor = params.get('rt_sqrt_factor')
self.pe_weight = params.get('pe_weight')
self.rising_edge = params.get('rising_edge')
self.local_maxima = params.get('local_maxima')
self.prompt_window = params.get('prompt_window')
self.long_window = params.get('long_window')
self.tick_duration = params.get('tick_duration')
Expand Down Expand Up @@ -334,15 +317,15 @@ def run(self, source_name, source_slice, cache):

wvfm_det = np.broadcast_to(np.arange(wvfms.shape[-2]).reshape(1,1,-1), wvfms.shape[:-1])

noise = self.get_noise_threshold(wvfms, self.mad_factor)
noise = cache[self.rms_dset_name].reshape(cache[source_name].shape)[
'rms']

peaks_found = self.peak_finder(wvfms, noise,
self.noise_factor,
self.n_bins_rolled,
self.rt_sqrt_factor,
self.pe_weight,
self.rising_edge,
self.local_maxima)
self.rising_edge)

t0_bin = np.argmax(peaks_found, axis=-1)

Expand All @@ -357,6 +340,7 @@ def run(self, source_name, source_slice, cache):
threshold_mask = peak_max >=self.threshold[peaks[1:-1]].ravel()

if self.hit_level=="sum_tpc" or self.hit_level=="sum":

integrals, fprompts = self.calculate_fprompt(wvfms, peaks_found,
self.prompt_window,
self.long_window,
Expand Down
Loading
Loading