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

Make peaklets dtype flexiable #1299

Merged
merged 11 commits into from
Dec 19, 2023
21 changes: 15 additions & 6 deletions straxen/plugins/merged_s2s/merged_s2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class MergedS2s(strax.OverlapWindowPlugin):
),
)

n_top_pmts = straxen.URLConfig(type=int, help="Number of top TPC array PMTs")

n_tpc_pmts = straxen.URLConfig(type=int, help="Number of TPC PMTs")

sum_waveform_top_array = straxen.URLConfig(
default=True, type=bool, help="Digitize the sum waveform of the top array separately"
)

n_top_pmts = straxen.URLConfig(type=int, help="Number of top TPC array PMTs")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these lines are moved several lines below?

Copy link
Collaborator Author

@WenzDaniel WenzDaniel Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah because I added again back in sum_waveform_top_array must have added it at the wrong position. Otherwise the lineage would change. Even though the option is not needed anymore here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would approve the PR if moved back. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very picky, I like it ;) :D I will do just a sec.


n_tpc_pmts = straxen.URLConfig(type=int, help="Number of TPC PMTs")

merged_s2s_get_window_size_factor = straxen.URLConfig(
default=5, type=int, track=False, help="Factor of the window size for the merged_s2s plugin"
)
Expand All @@ -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