XENONnT / straxen

Streaming analysis for XENON
BSD 3-Clause "New" or "Revised" License
20 stars 32 forks source link

Peaklets too long #1249

Open WenzDaniel opened 1 year ago

WenzDaniel commented 1 year ago

In about 1% of all peaks, peaks are longer than allowed by the max duration of merged_s2s. The reason is that already the respective peaklets are longer. These peaklets can span up to milliseconds. The reason is the ridiculously long max peaklet duration of 10 ms here: https://github.com/XENONnT/straxen/blob/34e12b603ea571f43f238bf069a6ab01f573e052/straxen/plugins/peaklets/peaklets.py#L130.

The down sampling of these peaklets will prevent the peak splitting algorithm to find suitable split points in data.

We might want to reduce this setting in the future. However, a new threshold needs a in depth testing.

WenzDaniel commented 1 year ago

Below are some example waveforms of these peaks:

example example2 example3

WenzDaniel commented 1 year ago

In this context I also found another but. If I change the setting e.g.:

st.set_config({'peaklet_max_duration': 0.5*10**6})
peaks_updated = st.get_array('025423', 'peaklets')

I run into an error:

File ~/mymodules/straxen/straxen/plugins/peaklets/peaklets.py:240, in Peaklets.compute(self, records, start, end)
    238 # If sum_waveform_top_array is false, don't digitize the top array
    239 n_top_pmts_if_digitize_top = self.n_top_pmts if self.sum_waveform_top_array else -1
--> 240 strax.sum_waveform(peaklets, hitlets, r, rlinks, self.to_pe, n_top_channels=n_top_pmts_if_digitize_top)
    242 strax.compute_widths(peaklets)
    244 # Split peaks using low-split natural breaks;
    245 # see https://github.com/XENONnT/straxen/pull/45
    246 # and https://github.com/AxFoundation/strax/pull/225

File /opt/XENONnT/anaconda/envs/XENONnT_development/lib/python3.9/site-packages/numba/np/arraymath.py:624, in array_max_impl()
    622 def array_max_impl(arry):
    623     if arry.size == 0:
--> 624         raise ValueError(MSG)
    626     it = np.nditer(arry)
    627     max_value = next(it).take(0)

ValueError: zero-size array to reduction operation maximum which has no identity
WenzDaniel commented 1 year ago

I did some deeper investigation. The bug seems to be related between the downsampling of peaks, and the start and end of two successive hits. Somehow peaks get assigned a zero length in some cases, but I do not understand the full process yet.