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
Routines for lone hit integration #261
Conversation
Hopefully this keeps codefactor happy...
strax/processing/peak_building.py
Outdated
result[last_hit_index[ch]][1] = min(result[last_hit_index[ch]][1], | ||
h['time']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering if it would not be better to do it the other way around. If we always preserve the left-left extension we fix the photon start time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tough to say. We're not changing the hit timings, just the regions in which lone hits are integrated. If two hits are near each other both of their areas will be distorted. Maybe it's slightly more important to preserve the first hit's area in general, since the second might be an afterpulse. In most lone hit analyses (e.g. for gain monitoring) you would anyway want to remove partially integrated hits, so probably the choice doesn't matter so much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I see thanks.
# TODO: when we add amplitude multiplier, adjust this too! | ||
h['area'] = ( | ||
r['data'][start:end].sum() | ||
+ (r['baseline'] % 1) * (end - start)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add two new fields in hits which indicate left_extended=bounds[hit_i][0] and right_extended=bounds[hit_i][1]. In this way we could identify overlapping lone hits more easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I added two new hit properties, left_integration
and right_integration
to store the integration bound indices. We can then cut on right_integration - left_integration - length to remove partially integrated hits.
This adds
strax.integrate_lone_hits
, which computes the area of lone hits while taking into account (left, right) extensions from the original region above threshold. See XENONnT/straxen#103 for a description of the current problem.Description
A sample should be integrated exactly once if it occurs within (left, right) of a sample above threshold in that channel, and not integrated otherwise.
_find_hit_integration_bounds
determines the windows. These are based on the (left, right) extension, but shorter if that would cause overlap with another hit's window or with a peak. Finally,integrate_hits
just computes the integral in these windows.In detail, the 'dispute resolution' for overlapping 'claims' in
find_hit_integration_bounds
works by these rules:peaklet_gap_threshold
, which strax requires to be >= the left + right extensions.Tests
I compared the area of lone_hits in a one-minute triggerless converted XENON1T run, 180215_1029. As described in XENONnT/straxen#103, the pulse filter can mask this issue, so I tested this without the filter (red line), with the filter (blue line) and with the filter but with the rest of the pulse processing done as if the filter wasn't there (green line) -- i.e. only zeroing the waveform far away from the hit and integrating a large (left, right) extension away from the hit. Dashed vertical lines show the median area.
Current master:
After this change:
You can see that: