Skip to content

Commit

Permalink
Make peaklets dtype flexiable (#1299)
Browse files Browse the repository at this point in the history
  • Loading branch information
WenzDaniel committed Dec 19, 2023
1 parent 540d840 commit c532353
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 11 additions & 2 deletions straxen/plugins/merged_s2s/merged_s2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ def setup(self):
self.to_pe = self.gain_model

def infer_dtype(self):
return strax.unpack_dtype(self.deps["peaklets"].dtype_for("peaklets"))
peaklet_classification_dtype = self.deps["peaklet_classification"].dtype_for(
"peaklet_classification"
)
peaklets_dtype = self.deps["peaklets"].dtype_for("peaklets")
# The merged dtype is argument position dependent!
# It must be first classification then peaklet
# Otherwise strax will raise an error
# when checking for the returned dtype!
merged_s2s_dtype = strax.merged_dtype((peaklet_classification_dtype, peaklets_dtype))
return merged_s2s_dtype

def get_window_size(self):
return self.merged_s2s_get_window_size_factor * (
Expand Down Expand Up @@ -132,7 +141,7 @@ def compute(self, peaklets, lone_hits):
lh = strax.sort_by_time(lh)

# If sum_waveform_top_array is false, don't digitize the top array
n_top_pmts_if_digitize_top = self.n_top_pmts if self.sum_waveform_top_array else -1
n_top_pmts_if_digitize_top = self.n_top_pmts if "data_top" in self.dtype.names else -1
strax.add_lone_hits(merged_s2s, lh, self.to_pe, n_top_channels=n_top_pmts_if_digitize_top)

strax.compute_widths(merged_s2s)
Expand Down
5 changes: 4 additions & 1 deletion straxen/plugins/peaks/peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ def compute(self, peaklets, merged_s2s):
assert np.all(
peaks["time"][to_check][1:] >= strax.endtime(peaks)[to_check][:-1]
), "Peaks not disjoint"
return peaks

result = np.zeros(len(peaks), self.dtype)
strax.copy_to_buffer(peaks, result, "_copy_requested_peak_fields")
return result

0 comments on commit c532353

Please sign in to comment.