Skip to content

Conversation

@GernotMaier
Copy link
Contributor

@GernotMaier GernotMaier commented Aug 13, 2025

Add an application to derive single telescope and array trigger rates from reduced event data lists.
This replaces the implementation of simtools-calculate-trigger-rate, which relies on sim_telarray histograms.

Minimal implementation to replace functionality of simtools-calculate-trigger-rate - at this point we can generate a lot of plots and derive the proton-induced trigger rates (with the additional functionality compared to simtools-calculate-trigger-rate that we can do this also for arrays). There are a couple of items missing, which will be added in upcoming pull requests (e.g., derive proton+helium trigger rates; understand output file format; derive errors on trigger rates, etc).

Most work in this PR is in filling histograms and plotting them correctly.

Tested this for all telescope types and get:

  • LST (South): 3845 Hz (Konrad's number is 3584-3946 Hz; exact threshold not available)
  • SST (South): 305 Hz (Konrad's number is ~410 Hz - but I've had a too E_min in the simulations, so a lower one is expected)
  • MST (FlashCam, South): 4051 Hz (KBs: 4295 Hz)
  • MST (NectarCam, North): 3990 Hz (KBs: 4332 Hz - but again too high E_min in MC)
  • LST (North): 3665 Hz (Konrad's number is 3584-3946 Hz; exact threshold not available)

Konrad's numbers are from https://www.mpi-hd.mpg.de/hfm/CTA/MC/Prod6/Config/Rates/prates.lis

For testing, there are a couple of single-telescope sims available at /lustre/fs22/group/cta/users/maierg/single-telescope-tests/merged_hdf5_files These are quickly made sims and not all parameters might be optimal.

To test, run e.g.

---
applications:
- application: simtools-derive-trigger-rates
  configuration:
    array_layout_name:
    - 1mst
    event_data_file: ../test-data/proton_za20deg_azm000deg_South_1mst_6.0.0.hdf5
    model_version: 6.0.0
    output_path: simtools-output
    plot_histograms: true
    site: South
    use_plain_output_path: true
    log_level: DEBUG
  test_name: hdf5_arrays_from_db
schema_name: application_workflow.metaschema
schema_version: 0.4.0

Closes #1001 (this tool now can calculate trigger rates for any array configuration)
Closes #1023 (issue partly outdated, partly covered with this PR)

@GernotMaier GernotMaier self-assigned this Aug 13, 2025
@GernotMaier GernotMaier added the no-changelog-needed No Changelog entry required for this PR label Aug 13, 2025
@ctao-dpps-sonarqube

This comment has been minimized.

@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.16%. Comparing base (99e4e8f) to head (159bdc2).
⚠️ Report is 50 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1685   +/-   ##
=======================================
  Coverage   98.16%   98.16%           
=======================================
  Files          90       90           
  Lines       11593    11620   +27     
=======================================
+ Hits        11380    11407   +27     
  Misses        213      213           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ctao-dpps-sonarqube

This comment has been minimized.

@GernotMaier GernotMaier requested a review from Copilot August 13, 2025 13:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Collaborator

@tobiaskleiner tobiaskleiner left a comment

Choose a reason for hiding this comment

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

@GernotMaier thanks for the very nice updates. Have just added few minor comments, but nothing blocking to merge.

Command line arguments
----------------------
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is missing no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

"""
Define histograms including event data, binning, naming, and labels.
All histograms are defined for simulated and triggered event (note
Copy link
Collaborator

Choose a reason for hiding this comment

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

events

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

-1.0 * self.core_distance_bins.max(),
self.core_distance_bins.max(),
len(self.core_distance_bins),
hists["energy"] = self.get_histogram_definition(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks a bit repetetive, can it be simplified with a dictionary containting the parameters and a loop?

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought of that as well while reviewing, but realised that we replace one repetitive code with another one defining the dictionary, so decided to drop it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@orelgueta orelgueta 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 this, very nice improvement!

I made a few minor comments, none of them is blocking, but will wait for answers before approving.

Comment on lines +384 to +387
reduced_info["scatter_area"] = self.scatter_area(
core_scatter_min=reduced_info.get("core_scatter_min", 0.0 * u.m),
core_scatter_max=reduced_info.get("core_scatter_max", 0.0 * u.m),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the default be zero? Can it be derived from the layout instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've chosen 0 to make sure that the results do not make sense.

Not sure how they can be read from the layout, isn't this a CORSIKA configuration parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I guess in this class you can't know the layout. I lost track a bit of which file I am in, I saw above that a layout is used, but it's not transferred to this class. If the idea is to make sure the results don't make sense, then this code does the job.

Copy link
Contributor

@orelgueta orelgueta left a comment

Choose a reason for hiding this comment

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

Approving now that comments were taken into account

@GernotMaier
Copy link
Contributor Author

Thanks @tobiaskleiner and @orelgueta for the review. I've updated the code accordingly. Let me know if something is missing.

@ctao-sonarqube
Copy link

ctao-sonarqube bot commented Sep 2, 2025

@GernotMaier GernotMaier merged commit 41b24b0 into main Sep 2, 2025
14 checks passed
@GernotMaier GernotMaier deleted the derive-trigger-rates branch September 2, 2025 14:06
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.

Further development of the trigger rate application Consider expanding the trigger rate tool to provide the rate for individual telescopes

4 participants