Skip to content

Implement check on Celeritas-Geant4 fast simulation particle consistency#2333

Open
drbenmorgan wants to merge 2 commits intoceleritas-project:developfrom
drbenmorgan:fastsim-particle-check
Open

Implement check on Celeritas-Geant4 fast simulation particle consistency#2333
drbenmorgan wants to merge 2 commits intoceleritas-project:developfrom
drbenmorgan:fastsim-particle-check

Conversation

@drbenmorgan
Copy link
Copy Markdown
Contributor

Offload of particles from Geant4 to Celeritas viaFastSimulationIntegration relies on:

  1. Particles requested for offload via SetupOptions.offload_particles having G4FastSimulationManagerProcess attached.
  2. Regions in which these particles should be offloaded have celeritas::FastSimulationModel attached.

The changes here implements a basic check and test on the first item, with placeholder documentation for the second (this requires addition of regions to SetupOptions, which is a larger task). The implementation of FastSimulationIntegration::verify_local_setup is extended to check the offload particles in general as is done in TrackingManagerIntegration (so is largely copy-paste), adding the needed loop over particles to check the presence of the needed process and CELER_VALIDATE on the result.

I wasn't sure about policy on testing expected failure cases, but implemented an additional fixture/test to check that the expected exception is thrown when a known offload particle does not have G4FastSimulationManagerProcess attached.

…egration.

Offload of particles to Celeritas in FastSimulationIntegration relies
on the requested offload particles having G4FastSimulationManagerProcess
attached to their process manager.

Follow pattern in TrackingManagerIntegration for verifying basic setup
before iterating of requested offload particles to check they have the
needed geant4 process attached, failing if it is not. Much of the
code is copy-pasted for simplicity/to have something.

TODO: Add check on offload regions having Celeritas model attched.
This require support for regions in SetupOptions.
FastSimulationIntegration should fail at its verify_local_setup
stage if Celeritas has been asked to offload particle type "A",
and "A" does not have G4FastSimulationManagerProcess attached.

Create a concrete test fixture from LarSphere as this already
provides exception checking capability needed to determine the
wanted exception is thrown. Overload make_physics_list to
only add Geant4 fast simulation for e- and gamma. Celeritas
default is to offload e-, e+ and gamma and thus should fail
due to e+ not having fast simulation attached.

Write the test case as simply as possible to trigger the exception
and check that this had indeed been thrown.
@drbenmorgan drbenmorgan requested a review from sethrj March 25, 2026 16:35
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 72.54902% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.58%. Comparing base (8447c5f) to head (e7360d8).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/accel/FastSimulationIntegration.cc 72.54% 8 Missing and 6 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2333      +/-   ##
===========================================
- Coverage    87.12%   85.58%   -1.54%     
===========================================
  Files         1365     1332      -33     
  Lines        43418    41851    -1567     
  Branches     13258    10864    -2394     
===========================================
- Hits         37827    35820    -2007     
- Misses        4366     4405      +39     
- Partials      1225     1626     +401     
Files with missing lines Coverage Δ
src/accel/FastSimulationIntegration.cc 74.57% <72.54%> (-12.93%) ⬇️

... and 734 files with indirect coverage changes

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

@github-actions
Copy link
Copy Markdown

Test summary

 5 596 files   9 042 suites   7m 38s ⏱️
 1 764 tests  1 755 ✅   9 💤 0 ❌
29 364 runs  29 233 ✅ 131 💤 0 ❌

Results for commit e7360d8.

@sethrj sethrj added enhancement New feature or request external Dependencies and framework-oriented features labels Mar 26, 2026
Copy link
Copy Markdown
Member

@sethrj sethrj left a comment

Choose a reason for hiding this comment

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

Thanks @drbenmorgan ! Looks like there's some easy-to-fix build errors in the CI.

Comment on lines +59 to +63
G4ProcessVector* pv = pm->GetProcessList();
CELER_ASSERT(pv);
for (auto j : range(pv->size()))
{
if (dynamic_cast<G4FastSimulationManagerProcess*>((*pv)[j]))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to add Span to geant4 so we can use for (auto* p : pv->view()) 😬 (then we could use a std::algorithm find_if(...) != pv.end())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request external Dependencies and framework-oriented features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants