XENONnT / straxen

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

Non-positive hits raises error for corner cases #1357

Open dachengx opened 6 months ago

dachengx commented 6 months ago

Describe the bug After strax.find_hit_integration_bounds, the "right_integration" might be equal to "left_integration" for hits or lone_hits, so that later will raise error in the functions which require positive length.

There are two cases.

To Reproduce The first one is for the 519th chunk of 048880

import cutax
st = cutax.xenonnt_offline(xedocs_version='global_v14')
run_id = '048880'
chunk_number = 519
st.make(run_id, 'peaklets', _chunk_number=chunk_number)

shows error

  File "/home/xudc/straxen/straxen/plugins/peaklets/peaklets.py", line 262, in compute
    strax.sum_waveform(
  File "/opt/miniconda3/envs/XENONnT_2024.03.1/lib/python3.9/site-packages/numba/np/arraymath.py", line 572, in impl_max 
    raise ValueError("zero-size array to reduction operation "
ValueError: zero-size array to reduction operation maximum which has no identity

because in https://github.com/AxFoundation/strax/blob/ebcb699fd85edb30b133fcb00e48dafa46faca4c/strax/processing/peak_building.py#L329-L331, if hit["length"] is 0, r_start and r_end are the same.

The second one is for 11th chunk of 044256

import cutax
st = cutax.xenonnt_offline(xedocs_version='global_v14')
run_id = '044256'
chunk_number = 11
st.make(run_id, 'merged_s2s', _chunk_number=chunk_number)

shows error

  File "/opt/XENONnT/anaconda/envs/XENONnT_2024.02.1/lib/python3.9/site-packages/strax/processing/general.py", line 150, in _fully_contained_in_sanity
    raise ValueError(f"{names} should have non-negative length!")
ValueError: things should have non-negative length!

also reported in slack thread. Because in https://github.com/XENONnT/straxen/blob/33992c2c8d0de8a7b1cc13a97f42b79f26c05f86/straxen/plugins/merged_s2s/merged_s2s.py#L140, lh["length"] is 0.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Versions module version path git
python 3.9.19 /opt/XENONnT/anaconda/envs/XENONnT_2024.03.1/bin/python None
strax 1.6.2 /home/xudc/strax/strax branch:master ebcb699
straxen 2.2.1 /home/xudc/straxen/straxen branch:master 33992c2
cutax 1.17.1 /home/xudc/cutax/cutax branch:master adccde0
yuema137 commented 6 months ago

Seems to be a very low-level bug. Let me try to look into it