Skip to content
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

Fix bug in hitlets time ordering #1173

Merged
merged 8 commits into from May 2, 2023
Merged

Fix bug in hitlets time ordering #1173

merged 8 commits into from May 2, 2023

Conversation

dachengx
Copy link
Collaborator

@dachengx dachengx commented May 1, 2023

Before you submit this PR: make sure to put all operations-related information in a wiki-note, a PR should be about code and is publicly accessible

What does the code in this PR do / what does it improve?

In

hitlet_time_shift = (hitlets['left'] - hitlets['left_integration']) * hitlets['dt']
hitlets['time'] = hitlets['time'] - hitlet_time_shift
hitlets['length'] = (hitlets['right_integration'] - hitlets['left_integration'])
hitlet_time_shift is calculated but in
hitlets = strax.sort_by_time(hitlets)
hitlets is sorted, so
hit_max_times = np.sort(
hitlets['time']
+ hitlets['dt'] * hit_max_sample(records, hitlets)
+ hitlet_time_shift # add time shift again to get correct maximum
)
will mix hitlets with different order in time into hit_max_times.

Additionally,

tight_coincidence_channel = get_tight_coin(
hit_max_times,
hitlets['channel'],
peaklet_max_times,
self.tight_coincidence_window_left,
self.tight_coincidence_window_right,
self.channel_range)
hit_max_times and hitlets['channel'] might not have the same time order.

Can you briefly describe how it works?

The new codes will not set the variable used in get_tight_coin in hitlets['time'] order.

Can you give a minimal working example (or illustrate with a figure)?

Please include the following if applicable:

  • Update the docstring(s)
  • Update the documentation
  • Tests to check the (new) code is working as desired.
  • Does it solve one of the open issues on github?

Notes on testing

  • Until the automated tests pass, please mark the PR as a draft.
  • On the XENONnT fork we test with database access, on private forks there is no database access for security considerations.

All italic comments can be removed from this template.

@dachengx dachengx requested a review from FaroutYLq May 1, 2023 05:14
Copy link
Contributor

@FaroutYLq FaroutYLq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for catching this. The fix looks good to me. I would suggest doing small S1 wfsim and check distribution of S1 tight coincidence to understand the artifact in the most vulnerable scenario.

straxen/plugins/peaklets/peaklets.py Outdated Show resolved Hide resolved
straxen/plugins/peaklets/peaklets.py Outdated Show resolved Hide resolved
straxen/plugins/peaklets/peaklets.py Outdated Show resolved Hide resolved
@FaroutYLq
Copy link
Contributor

Looks good to me now. Thanks!

@dachengx dachengx requested a review from WenzDaniel May 1, 2023 11:55
@coveralls
Copy link

Coverage Status

Coverage: 93.443% (+0.02%) from 93.418% when pulling 59ad229 on fix_tc_order into b1a0884 on master.

@dachengx dachengx merged commit 6037144 into master May 2, 2023
7 checks passed
@dachengx dachengx deleted the fix_tc_order branch May 2, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants