Skip to content

Conversation

@LukasBeiske
Copy link
Contributor

@LukasBeiske LukasBeiske commented Jun 26, 2025

This changes the PointSourceSensitivityOptimizer to use the full cut optimization introduced in pyirf 0.13. The previous EventDisplay-like optimization can now be used via the PointSourceSensitivityGhOptimizer.

I did a quick comparison of the three optimizers using prod6 files (multiplicity >= 2 for gh opt and percentile cuts, as the HillasReconstructer is used):
gh_cuts
theta_cuts
mult_cuts
sensitivity

I am not sure, why the EventDisplay-like optimization results in a better sensitivity at high energies.

Fixes #2771

@ctao-dpps-sonarqube

This comment has been minimized.

@maxnoe
Copy link
Member

maxnoe commented Jun 26, 2025

How fine did you make the scanning of the cuts? In principle, the full cut opt should always be at least as good as the one that is restricted,.if it is allowed to find the same cuts.

@ctao-dpps-sonarqube

This comment has been minimized.

@LukasBeiske
Copy link
Contributor Author

LukasBeiske commented Jun 26, 2025

How fine did you make the scanning of the cuts? In principle, the full cut opt should always be at least as good as the one that is restricted,.if it is allowed to find the same cuts.

I kept everything at the default values, as we have them in here right now. So, if I'm not mistaken, the only difference would be that the EventDisplay-like optimization has a theta cut with 68% efficiency, while the full optimization only tries 60% and 70%.
But I doubt that this makes such a difference. I'll test that and take a closer look again tomorrow.

And, I think, there is no check for a minimum number of events per bin in the full cut optimization, while the 68% theta cut for the EventDisplay-like optimization has a minimum of 10 events per bin. However, this only seems to play a role for the two lowest energy bins, if at all.

@LukasBeiske
Copy link
Contributor Author

LukasBeiske commented Jun 27, 2025

There was still an error with the application of the cuts in the irf tool. It should be correct now and this improved the sensitivity situation a lot, but there are still some bins where the EventDisplay-like optimization outperforms the full optimization, even though the first uses a theta cut with 70% efficiency for this plot, which also gets tested in the full optimization.
sensitivity

@ctao-dpps-sonarqube
Copy link

Passed

Analysis Details

1 Issue

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 1 Code Smell

Coverage and Duplications

  • Coverage 89.10% Coverage (94.30% Estimated after merge)
  • Duplications 0.00% Duplicated Code (0.70% Estimated after merge)

Project ID: cta-observatory_ctapipe_AY52EYhuvuGcMFidNyUs

View in SonarQube

@maxnoe
Copy link
Member

maxnoe commented Jun 27, 2025

If I remember correctly, these percentiles cannot be compared directly, as the eventdisplay-like optimization computes the percentile on the events surviving the initial cut, whereas the full optimization computes it on all events.

@LukasBeiske
Copy link
Contributor Author

If I remember correctly, these percentiles cannot be compared directly, as the eventdisplay-like optimization computes the percentile on the events surviving the initial cut, whereas the full optimization computes it on all events.

Ah, good point, I forgot about that. I'll run the full optimization again with a finer gridding. I guess, these underperformance for some bins will disappear then.

@LukasBeiske
Copy link
Contributor Author

Running both optimizations with finer grids:

PointSourceSensitivityOptimizer:
  gh_cut_efficiency_step=0.02
  theta_cut_efficiency_step=0.02
  
PointSourceSensitivityGhOptimizer:
  gh_cut_efficiency_step=0.02

gets the performance of the full optimization closer, but some bins are still worse then with EventDisplay-like optimization.
sensitivity

Copy link
Member

@kosack kosack left a comment

Choose a reason for hiding this comment

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

gh_cut_efficiency_step=0.02
theta_cut_efficiency_step=0.02

If a smaller step is important to get a good sensitivity, please also update the ctapipe-quickstart configurations to provide the best values for users, and also the default values in the tool itself.

@LukasBeiske
Copy link
Contributor Author

LukasBeiske commented Jul 7, 2025

gh_cut_efficiency_step=0.02
theta_cut_efficiency_step=0.02

If a smaller step is important to get a good sensitivity, please also update the ctapipe-quickstart configurations to provide the best values for users, and also the default values in the tool itself.

I just noticed this (similar for the full optimization):
sensitivity

The config is exactly the same (default values) besides the stepsize. This doesn't make sense. I'm re-running everything now and, if this behavior is still there, I'll convert this PR to draft until I figure out whats going on here.

@LukasBeiske LukasBeiske marked this pull request as draft July 7, 2025 17:46
@maxnoe
Copy link
Member

maxnoe commented Oct 24, 2025

There was still an error with the application of the cuts in the irf tool.

Is this an error introduced here? Or does it affect main? If it affects also main, could you open a PR just with the bugfix please?

class PointSourceSensitivityOptimizer(PointSourceSensitivityOptimizerBase):
"""
Finds the combination of G/H cut, theta cut, and cut on the event-multiplicity
for each energy bin with the maximum point source sensitivity in a grid search.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for each energy bin with the maximum point source sensitivity in a grid search.
for each energy bin with the best point source sensitivity in a grid search.

sensitivity is lower = better

theta_min_angle = AstroQuantity(
default_value=u.Quantity(-1, u.deg),
physical_type=u.physical.angle,
help="Smallest angular cut value allowed (-1 means no cut)",
Copy link
Member

Choose a reason for hiding this comment

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

please use None to mean no cut.

).tag(config=True)

theta_max_angle = AstroQuantity(
default_value=u.Quantity(0.32, u.deg),
Copy link
Member

Choose a reason for hiding this comment

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

0.32 degrees is a special case for 0.4 degree wobble observations. I'm not sure this is a good default to use here, as we 0.4 degree is not a wobble offset we intend to use for CTAO.

It is used by LST to enable common observations with MAGIC, but a larger value would be much better for the large FoVs of the CTAO telescopes and the relatively large PSF of a single LST at low energies.

@LukasBeiske
Copy link
Contributor Author

There was still an error with the application of the cuts in the irf tool.

Is this an error introduced here? Or does it affect main? If it affects also main, could you open a PR just with the bugfix please?

This does not affect main, it was related to the application of the multiplicity cut introduced here.

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.

Add optimize based on full cut optimization in pyrif.cuts.optimize_cuts

4 participants