Closed drinkingkazu closed 1 year ago
PR 138 addresses these.
I agree with this change, it was indeed a behavior that bugged me and I can't remember why I didn't adopt the solution above from the beginning.
Hi @soleti @drinkingkazu, I definitely resonate the concept of the changes! One thing that I am troubling with since a week is that by doing current_fractions[ip][iadc][itrk] /= q_sum
, even there's one single segment contributing to a pixel readout, the fraction may not be 1.
https://github.com/DUNE/larnd-sim/blob/d78d36470eb94b74a640dea6b576c4b544a2584d/larndsim/fee.py#L455
Hi @soleti @drinkingkazu, I definitely resonate the concept of the changes! One thing that I am troubling with since a week is that by doing
current_fractions[ip][iadc][itrk] /= q_sum
, even there's one single segment contributing to a pixel readout, the fraction may not be 1.https://github.com/DUNE/larnd-sim/blob/d78d36470eb94b74a640dea6b576c4b544a2584d/larndsim/fee.py#L455
Hi @YifanC, I am a bit rusty with this code, can you explain a bit when/how that happens (a single segment and fraction < 1)?
Hi @soleti, this is based on the observation of testing this PR. Actually the fraction is not necessarily below 1, could be also above 1. The offset from single segment backtracking for example can be offset by a lot. In the test sample, I have seen ~30% fluctuation.
After discussing with @krwood, we think the issue is caused by the noise. If all noise is 0, then the fraction exports what we expect.
The main drive is the RESET_NOISE_CHARGE
. It is straightforward to bypass that by setting a "true_q" to reassemble "q_sum" without noise (reset noise).
Specifically, setting "true_q" to 0 here: https://github.com/DUNE/larnd-sim/blob/d78d36470eb94b74a640dea6b576c4b544a2584d/larndsim/fee.py#L380 and https://github.com/DUNE/larnd-sim/blob/d78d36470eb94b74a640dea6b576c4b544a2584d/larndsim/fee.py#L469.
However, DISCRIMINATOR_NOISE
and UNCORRELATED_NOISE_CHARGE
still leak to the fraction definition through: https://github.com/DUNE/larnd-sim/blob/d78d36470eb94b74a640dea6b576c4b544a2584d/larndsim/fee.py#L411 (among the two, DISCRIMINATOR_NOISE
yields larger impact)
It's not obvious to me how to have "true_q" uncontaminated by DISCRIMINATOR_NOISE
and UNCORRELATED_NOISE_CHARGE
without redo this part (https://github.com/DUNE/larnd-sim/blob/d78d36470eb94b74a640dea6b576c4b544a2584d/larndsim/fee.py#L411-L472). I feel the repetitive loops will make it unnecessarily slow.
Hi @soleti, sorry for pouring text here. Just want to update two things. In short, I think we have a solution.
I will submit a PR of feature_t0_vertex
branch with the proposed change to develop
.
Anyone who's interested could take a look. Thank you!
Hi @YifanC, thank you for looking into this. Now that you say it, I remembered why I implemented the fraction
the way it is right now: exactly because it was complicated to implement "true" fraction, given the noise. I think your solution should work, thanks for the PR.
Thank you for checking! Appreciated
The current version of the code a071fd4 computes the fraction by the following code piece in the fee.py L428-430:
As such, the "fraction" is normalized within the recorded set of segments. The number of segments to be recorded, N, is fixed while the code runs disregard of the number of segments that actually contribute to the subject packet. For instance, the current default is N=5.
The actual number of segments contributing to the subject packet (say M in this example) can exceed N. Consider a specific case where the packet carries value 10 contributed from M=6 segments with segment index numbers 1 to 6. The configuration sets N=5. Say the contributions in the respective order are 0.01, 0.02, 0.03, 0.04, 0.05, 0.85. In this case, the current code records the following values.
Intuitively, the "fraction" is useful to infer how much fraction of packet value (current, charge) each segment contributed. However, because the fraction is normalized within the recorded set of the segments, this becomes impossible when M>=N. Note the case where M=N is included in this situation since we cannot tell whether M=N or M>N from the given set of information.
Specifically, this leads to three issues:
I propose two changes.
Change 1 is to simply modify the noted lines of the code with the following:
(thanks to @soleti )
Change 2 is to add array sorting in the
fee.py
. That looks like below (only a part of the code here):The complete change can be seen here including some case handling.