Skip to content

Conversation

@EricMEsch
Copy link
Contributor

@EricMEsch EricMEsch commented Aug 7, 2025

This currently runs two tests which at the same time produce output for validation plots.

These are the energy of the two primary electrons (the neutrinos are not even created with bxdecay)
e-combined-primary-energy output

And the opening angle between the primary electrons.
e-primary-opening-angle output

I would say the energy looks good, i am not sure about the opening angles. I have to admit i have no idea what we would expect there.

The main issue is that we need high statistics for good plots, and that means longer simulation times.

I still need to add the plots to the validation suite, so this is just a draft, but i guess you can already comment on it.

Also i had to include the /RMG/Geometry/RegisterDetector Germanium det1 001 in the macros because otherwise the /RMG/Output/Vertex/StorePrimaryParticleInformation command would not exist. I assume this is because the simulation would run in non-persistency mode. But this means right now we write away information we do not need in the tests i added

@ManuelHu
Copy link
Contributor

ManuelHu commented Aug 7, 2025

Also i had to include the /RMG/Geometry/RegisterDetector Germanium det1 001 in the macros because otherwise the /RMG/Output/Vertex/StorePrimaryParticleInformation command would not exist. I assume this is because the simulation would run in non-persistency mode

slightly wrong. the vertex output scheme is only registered if there are any other output schemes registered, not depending on the persistence mode (you still can register output schemes and force no persistence, for example).

Anyhow, we could actually port the vertex scheme to an optional scheme, and still activate it by default (but also have an option to just enable the vertex scheme)

@EricMEsch
Copy link
Contributor Author

I guess i also have to add some conditional code to the CMakeLists to only include the test if remage is built with bxdecay support

@ManuelHu
Copy link
Contributor

ManuelHu commented Aug 8, 2025

I guess i also have to add some conditional code to the CMakeLists to only include the test if remage is built with bxdecay support

yes. we already have something similar for some other tests here:

if(NOT BxDecay0_FOUND)
set_tests_properties("hades/run-2nbb.mac" PROPERTIES DISABLED True)
set_tests_properties("hades/vis-2nbb.mac" PROPERTIES DISABLED True)
endif()

@gipert gipert added generators validation Validation and tests labels Aug 8, 2025
@gipert
Copy link
Member

gipert commented Aug 8, 2025

Also see https://remage.readthedocs.io/en/stable/developer.html#configuring-cmake for CMake tips related to plots for the validation report.

@EricMEsch
Copy link
Contributor Author

Changes i made to speed the tests up:

  • Kill secondary gammas (i cant kill electrons as electrons are the primary particle and that causes an expected crash (which should be caught by a warning but it somehow is not))
  • Simplified the geometry

But my tests on my local pc did only show like a 20% improvement at best

@gipert
Copy link
Member

gipert commented Aug 8, 2025

I wonder if we should implement some mode to only record the primary vertex/particle info on disk, without any actual tracking. To be used only for debugging / validation of generators. This could be useful for many checks, including #435.

Ideas?

@EricMEsch
Copy link
Contributor Author

I think it would be pretty useful, but i can not think of a simple solution... You can either

  • Skip the entire Geant4 initialization which might cause many problems
  • Intercept the particle before the GeneratePrimaries() function? But i doubt Geant4 would be happy with that
  • Try to immediately discard the primary track on the first step including all secondaries maybe produced... But that seems like an inefficient workaround

@gipert
Copy link
Member

gipert commented Aug 8, 2025

Try to immediately discard the primary track on the first step including all secondaries maybe produced... But that seems like an inefficient workaround

why do you think this would be inefficient? I think this is the best solution

@EricMEsch
Copy link
Contributor Author

EricMEsch commented Aug 8, 2025

Well Geant4 has to set up the entire world, physics databases etc. anyways. I am not really talking about a quantitative inefficiency, which might only be a few %. I more meant a logical/qualitative inefficiency.

As you are initializing the entire Framework and then only access a small isolated part. From a logical point of view the "cleanest" way would be to just access the isolated part on its own (at least from my point of view)... But that would be rather difficult to implement i think

@EricMEsch
Copy link
Contributor Author

But the speedup actually seems to be pretty good. ~15s seems reasonable. Although the statistics is not the best as you can see in the plots above

@gipert
Copy link
Member

gipert commented Aug 8, 2025

I think we should try to simulate a lot, for smooth histograms. Much more than what's in your tests here. In such a case, the app initialization time would be much lower than initialization time.

@EricMEsch
Copy link
Contributor Author

I think this is the best solution

I think that could be implemented with a single macro of /RMG/Processes/Stepping/. Would probably also be like 1 line of code

if(flag) step->GetTrack->SetTrackStatus(fKillTrackAndSecondaries);

@gipert
Copy link
Member

gipert commented Aug 8, 2025

yes, could you quickly test it?

@EricMEsch
Copy link
Contributor Author

EricMEsch commented Aug 8, 2025

The speedup looks good. From ~132secs to ~42secs on my local pc. I will quickly push something with the old version and increased statistics, wait for the pipeline to run the test and then push with the new version and compare

@EricMEsch
Copy link
Contributor Author

In the pipeline the old version takes ~331s (only the one simulation not the entire pipeline) and the new version ~99s

But 99s is still pretty long

@gipert
Copy link
Member

gipert commented Aug 8, 2025

can you post again the plots? how's the stats now?

@tdixon97
Copy link
Contributor

tdixon97 commented Aug 8, 2025 via email

@gipert
Copy link
Member

gipert commented Aug 8, 2025

go back on holiday smart ass

@EricMEsch
Copy link
Contributor Author

The plots are deployed with the validation report. The plots look squashed right now, i need to check what i need to specify to have them beside each other looking good
image

@gipert
Copy link
Member

gipert commented Aug 11, 2025

Yeah you have to somehow force using the original aspect ratio.

We should still optimize the runtime. We want to validate many decay modes so it would take a long time, with the current settings. Maybe you can play a bit with bin size and number of events? For example, you could halve the number of bins, reduce the number of events by a factor 4 and then check if things still look reasonably smooth.

Could you also already add more bb decay modes to at least the left plot?

@EricMEsch
Copy link
Contributor Author

This is how it looks now. Although in total it is running less primaries (4x 250 000 instead of 2x 1 000 000) it is now running 130s in the CI. I reduced the number of bins to 80. From the plots i would say it is still a little bit low statistics for the number of bins, but reducing the number of bins even further would make the histograms ugly. It might be fine decreasing the number of bins a little bit more... idk

The plotting itself only takes 5s, so removing a mode from one of the plots will not speed up anything.

image

@EricMEsch EricMEsch marked this pull request as ready for review August 11, 2025 13:47
Copilot AI review requested due to automatic review settings August 11, 2025 13:47
Copy link

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.

Pull Request Overview

This PR adds comprehensive unit tests and validation plots for the bxdecay0 generator integration. It creates a test framework to verify different double beta decay modes (0vbb, 2vbb, 0vbb_M1, 0vbb_lambda_0) and generates validation plots showing electron energy distributions and angular correlations.

  • Implements test suite for bxdecay0 generator with four decay modes
  • Adds plotting functionality to visualize primary electron energies and opening angles
  • Introduces SkipTracking feature to optimize test performance by skipping particle tracking

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/bxdecay/run_sims.py Main simulation runner for different decay modes
tests/bxdecay/plot_decay_modes.py Plotting script for energy and angular distributions
tests/bxdecay/macros/*.mac Simulation configuration templates
tests/bxdecay/gdml/geometry.gdml Simple germanium detector geometry
tests/bxdecay/CMakeLists.txt Build configuration for bxdecay tests
src/RMGSteppingAction.cc Implementation of SkipTracking feature
include/RMGSteppingAction.hh Header for SkipTracking functionality
docs/validation/*.md Documentation for bxdecay validation
Comments suppressed due to low confidence (1)

@EricMEsch
Copy link
Contributor Author

So all the comments are fixed except the two i left open. @gipert Do you still want the figures to have a double-beta specifier in their filename, although they are always stored under the /bxdecay0 folder?

@EricMEsch
Copy link
Contributor Author

oke, everything fixed now

@gipert gipert merged commit f2cf36f into legend-exp:main Aug 21, 2025
7 of 9 checks passed
@EricMEsch EricMEsch mentioned this pull request Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

generators validation Validation and tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants