Skip to content

Commit

Permalink
Save hits level information(hits time difference) in peaks (#716)
Browse files Browse the repository at this point in the history
* Add fields to calculate hits time difference

* Recover dtype of hits

* Update description of peak dtype

* Save S1 hits are and height into peaklets

* Add max and min height

* Fix numba version to 0.55.2

Related to XENONnT/base_environment#1261

* Add fields to `hitlet_with_data_dtype` to be compatible with `strax.split_peaks`

* Recover requirements.txt

* Remove max_hit_height and min_hit_height because they are not really useful

* Change the order of features
  • Loading branch information
dachengx committed May 2, 2023
1 parent fa9b4d8 commit db3aa02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 15 additions & 4 deletions strax/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,27 @@ def hitlet_with_data_dtype(n_samples=2):
dtype = hitlet_dtype()
additional_fields = [(('Hitlet data in PE/sample with ZLE (only the first length samples are filled)', 'data'),
np.float32, n_samples),
(('Dummy field required for splitting',
(('Dummy max_gap required for splitting',
'max_gap'), np.int32),
(('Dummy max_diff required for splitting',
'max_diff'), np.int32),
(('Dummy min_diff required for splitting',
'min_diff'), np.int32),
(('Maximum interior goodness of split',
'max_goodness_of_split'), np.float32),
]

return dtype + additional_fields


def peak_dtype(n_channels=100, n_sum_wv_samples=200, n_widths=11, digitize_top=True):
def peak_dtype(n_channels=100, n_sum_wv_samples=200, n_widths=11, digitize_top=True, hits_timing=True):
"""Data type for peaks - ranges across all channels in a detector
Remember to set channel to -1 (todo: make enum)
"""
if n_channels == 1:
raise ValueError("Must have more than one channel")
# Otherwise array changes shape?? badness ensues
dtype = peak_interval_dtype + [
dtype = peak_interval_dtype + [
# For peaklets this is likely to be overwritten:
(('Classification of the peak(let)',
'type'), np.int8),
Expand All @@ -209,10 +213,17 @@ def peak_dtype(n_channels=100, n_sum_wv_samples=200, n_widths=11, digitize_top=T
(('Maximum interior goodness of split',
'max_goodness_of_split'), np.float32),
]
if hits_timing:
dtype += [
(('Largest time difference between apexes of hits inside peak [ns]',
'max_diff'), np.int32),
(('Smallest time difference between apexes of hits inside peak [ns]',
'min_diff'), np.int32),
]
if digitize_top:
top_field = (('Waveform data in PE/sample (not PE/ns!), top array',
'data_top'), np.float32, n_sum_wv_samples)
dtype.insert(5, top_field)
dtype.insert(9, top_field)
return dtype


Expand Down
5 changes: 4 additions & 1 deletion strax/processing/peak_splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def _split_peaks(split_finder, peaks, orig_dt, is_split, min_area,
# is computed
r['dt'] = orig_dt
r['length'] = (split_i - prev_split_i) * p['dt'] / orig_dt
r['max_gap'] = -1 # Too lazy to compute this
# Too lazy to compute these
r['max_gap'] = -1
r['max_diff'] = -1
r['min_diff'] = -1
if r['length'] <= 0:
print(p['data'])
print(prev_split_i, split_i)
Expand Down

0 comments on commit db3aa02

Please sign in to comment.