XENONnT / epix

Electron and Photon Instructions generator for XENON
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Fix clustering indexing issue. #45

Closed PavelKavrigin closed 2 years ago

PavelKavrigin commented 2 years ago

This PR fixes the issue with cluster indexing:

#41

The issue report contains a notebook which explains the problem and demonstrates the results with and without the fix. Nevertheless, I will need to add some output here (master branch vs. this branch) where we see the difference. I will also check if this fix affects the computing time.

PavelKavrigin commented 2 years ago

With this fix the elapsed time for epix.find_cluster function increases by 20% (tested for 4000 primary events from AmBe simulation). I am not sure yet how to show the difference in the results though. In the notebook with the description of this problem I used a branch which explicitly records some intermediate steps, and we see the problem in the clustering when we look at these intermediate dataframes. If we just look at the result (i.e. deposited energy spectra), we do not see the difference that clearly (at least with this number of events):

2021-10-26_fix_spectra

I show here the NR spectra without and with the fix. We see that the spectrum without this fix is biased towards higher energy depositions. This happens because NRs and ERs are mixed during clustering, but we do not see a drastic difference because of the weighted averaging of energy depositions in clusters.

PavelKavrigin commented 2 years ago

@HenningSE - The warnings should disappear now.

PavelKavrigin commented 2 years ago

Yeah, I am not sure if this is crucial right now or not. If we merge it as it is, we should at least create an issue which should be addressed in the future. I wrote the fix in a C-like way with a loop, because I had not managed to make 'groupby' work properly with this mixed order of indices.