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

Computation of pointing-dependent weights for MC events #1259

Merged
merged 15 commits into from
Jun 21, 2024

Conversation

moralejo
Copy link
Collaborator

@moralejo moralejo commented Jun 5, 2024

This is to avoid jumps in RF performance in the "mid-points" between training pointing nodes, just because the event statistics occasionally have jumps between neighboring nodes.

The idea is to use "sample_weight", i.e. a weight for each event in the training set, calculated such that each of the pointing nodes has the same total weight.

The calculation is done with all events that are passed to the RFs. Of course, the energy (and impact) range of those events between culmination and high zenith change a lot, so "same number of events" does not mean much when comparing such extremes, but the point here is to avoid steps between neighboring bins (and for those, indeed, the numbers of events are comparable quantities). Only if the impact and energy ranges were poorly chosen (and distributions truncated) would this normalization result in performance jumps like the ones we have without it.

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 85.36585% with 6 lines in your changes missing coverage. Please review.

Project coverage is 73.27%. Comparing base (e097079) to head (5974bb8).
Report is 21 commits behind head on main.

Files Patch % Lines
lstchain/reco/dl1_to_dl2.py 78.57% 3 Missing ⚠️
lstchain/reco/utils.py 85.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1259      +/-   ##
==========================================
+ Coverage   73.05%   73.27%   +0.22%     
==========================================
  Files         134      134              
  Lines       14039    14081      +42     
==========================================
+ Hits        10256    10318      +62     
+ Misses       3783     3763      -20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@moralejo
Copy link
Collaborator Author

moralejo commented Jun 6, 2024

It seems to work well:
image

Gammaness cut is 0.5 for the standard, and tuned to get the same amount of events at zd~18 deg.

With "standard RFs", aside from the (smooth) physical dependence with zenith, we have jumps which result from the non-smoothness of the evolution of the number of training events with pointing, along declination lines. The jump above (in the blue histogram) is located at the mid-point between two training nodes.

These artifacts can be removed with the changes proposed here. In all likelihood they are partly responsible for the few-percent systematic errors in flux estimation that we have.

@moralejo moralejo marked this pull request as ready for review June 6, 2024 09:29
@moralejo
Copy link
Collaborator Author

moralejo commented Jun 6, 2024

@vuillaut The training with the Crab line took nearly 10 hours in cp03. Is that normal, or perhaps the use of weights makes it slower?

lstchain/reco/utils.py Outdated Show resolved Hide resolved
@vuillaut
Copy link
Member

vuillaut commented Jun 7, 2024

@vuillaut The training with the Crab line took nearly 10 hours in cp03. Is that normal, or perhaps the use of weights makes it slower?

Hi
Using how many cores ?
But that sounds right

lstchain/reco/utils.py Outdated Show resolved Hide resolved
lstchain/data/lstchain_standard_config.json Show resolved Hide resolved
lstchain/reco/utils.py Show resolved Hide resolved
@moralejo moralejo requested a review from vuillaut June 11, 2024 14:46
Copy link
Member

@morcuended morcuended left a comment

Choose a reason for hiding this comment

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

Looks good. I just left some comments that could be added and some other formatting stuff for docstrings (although we are not keeping consistency across the code, it would be good to enforce it for proper docs rendering)

lstchain/reco/utils.py Show resolved Hide resolved
lstchain/reco/utils.py Outdated Show resolved Hide resolved
lstchain/reco/utils.py Outdated Show resolved Hide resolved
lstchain/reco/utils.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Show resolved Hide resolved
moralejo and others added 5 commits June 20, 2024 18:10
Co-authored-by: Daniel Morcuende <dmorcuende@iaa.es>
Co-authored-by: Daniel Morcuende <dmorcuende@iaa.es>
Co-authored-by: Daniel Morcuende <dmorcuende@iaa.es>
Co-authored-by: Daniel Morcuende <dmorcuende@iaa.es>
Improved comments
@moralejo moralejo requested a review from morcuended June 20, 2024 16:13
@moralejo moralejo dismissed vuillaut’s stale review June 21, 2024 10:07

I can't find the allegedly non-addressed suggestion. And there is another approval.

@moralejo moralejo merged commit 609a977 into main Jun 21, 2024
9 checks passed
@moralejo moralejo deleted the rf_event_weighting branch June 21, 2024 10:08
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.

5 participants