Skip to content

Add an interface for invoking the PostStepDoIt action of Geant4 hadronic process#2302

Open
whokion wants to merge 8 commits intoceleritas-project:developfrom
whokion:onload-process
Open

Add an interface for invoking the PostStepDoIt action of Geant4 hadronic process#2302
whokion wants to merge 8 commits intoceleritas-project:developfrom
whokion:onload-process

Conversation

@whokion
Copy link
Contributor

@whokion whokion commented Mar 6, 2026

This MR adds an interface for invoking the PostStepDoIt action of Geant4 hadronic processes for a given particle definition and hadronic process type. It will be used to sample final states of hadronic processes that are not yet implemented on the GPU. Potential onloaded particles and associated EM extra processes include:

  • Gamma for photonNuclear
  • Electron for electronNuclear
  • Positron for positronNuclear

It can also be used for

  • Muon for muonNuclear
  • Neutron for nCapture and neutronInelastic

Test cases will be added once the handling of onloaded particles is in place.

@whokion whokion requested a review from amandalund March 6, 2026 22:06
@whokion whokion added the physics Particles, processes, and stepping algorithms label Mar 6, 2026
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.17%. Comparing base (37e853d) to head (0c8ecac).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/celeritas/ext/HadronicInteractor.cc 0.00% 14 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2302      +/-   ##
===========================================
- Coverage    87.24%   87.17%   -0.07%     
===========================================
  Files         1357     1358       +1     
  Lines        43225    43267      +42     
  Branches     13667    13689      +22     
===========================================
+ Hits         37711    37719       +8     
- Misses        4478     4508      +30     
- Partials      1036     1040       +4     
Files with missing lines Coverage Δ
src/celeritas/ext/HadronicInteractor.cc 0.00% <0.00%> (ø)

... and 9 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

github-actions bot commented Mar 6, 2026

Test summary

 5 930 files   9 549 suites   21m 39s ⏱️
 2 204 tests  2 169 ✅  35 💤 0 ❌
32 830 runs  32 689 ✅ 141 💤 0 ❌

Results for commit 0c8ecac.

♻️ This comment has been updated with latest results.

Copy link
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 @whokion , I think it would help me understand the class's role if you could clarify:

  • when this is constructed
  • what class(es) own it
  • whether it's thread-local (presumably so since processes in geant4 are?)
  • whether this is meant for future use in geant4 applications or is just for internal use in Celeritas.

@whokion
Copy link
Contributor Author

whokion commented Mar 9, 2026

* when this is constructed
* what class(es) own it

This wrapper should be created in the constructor of celeritas transporter (i.e., LocalTransporter).

* whether it's thread-local (presumably so since processes in geant4 are?)
* whether this is meant for future use in geant4 applications or is just for internal use in Celeritas.

I believe this wrapper is primarily used internally within Celeritas to return the kinematic changes of primary particle if needed (for example, for electrons) and the secondary particles produced by interactions handled by the associated Geant4 process for onloaded particles. Depending on the particle type, the resulting secondaries may either be passed back to Geant4 tracking or pushed directly back to the offloading buffer if they are EM particles.

Copy link
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.

Since this is an implementation detail of Celeritas, let's follow celeritas conventions. The class does only one thing, so call it operator() instead of PostStepDoIt.

I think these will probably be owned by aux state data, since we'll probably need additional buffers to send back the track data?

@whokion
Copy link
Contributor Author

whokion commented Mar 10, 2026

I think these will probably be owned by aux state data, since we'll probably need additional buffers to send back the track data?

I tested this class with the local transport with a separate buffer (for fake onloaded tracks for now), but it can be instantiated anywhere once a physics list (with corresponding hadronic processes) is constructed.

Copy link
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.

I hope the next pull request includes a test? Thanks!

@whokion
Copy link
Contributor Author

whokion commented Mar 11, 2026

@sethrj Yes, that is the plan. For a realistic test, we should include (or enable) gamma- and electro-nuclear interactions in the list of processes to be offloaded. Later, we should also add low-energy neutron processes as a complete neutron-elastic interactor and the neutron-inelastic cross section are already available (only need to add the capture cross section below 20 MeV, which is also in my to-do list). That said, adding a unit test using a Geant4 physics list (with the EM extra) could still be worthwhile.

G4HadronicProcessType type)
: particle_(particle)
{
auto* proc_store = G4HadronicProcessStore::Instance();
Copy link
Member

Choose a reason for hiding this comment

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

I'd CELER_ASSERT(proc_store) here.

// Copyright Celeritas contributors: see top-level COPYRIGHT file for details
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/g4/HadronicInteractor.cc
Copy link
Member

Choose a reason for hiding this comment

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

One final thing (an I apologize for the confusion, I 'll add a readme later): the g4 directory is meant for components to be used from Geant4 apps (or other downstream code interacting with Geant4), not for internal celeritas adapters to Geant4 code. Could you move to celeritas/ext?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem - did not catch that. Moved from g4 to ext. Thanks.

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

Labels

physics Particles, processes, and stepping algorithms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants