Skip to content

Fix CMS SteppingAction for new approach in CMSSW - #710

Merged
SeverinDiederichs merged 2 commits into
apt-sim:masterfrom
SeverinDiederichs:cms-stepping-action-config
Oct 21, 2026
Merged

SeverinDiederichs merged 2 commits into
apt-sim:masterfrom
SeverinDiederichs:cms-stepping-action-config

Conversation

@SeverinDiederichs

@SeverinDiederichs SeverinDiederichs commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

The CMS stepping action had hardcoded cuts and were outdated due to the new CMSSW Phase2SteppingAction.
The new Phase2SteppingAction revealed a real problem: if CMSSW decides to kill a track that was just returned from the GPU, it would be erased and the hostTrackData would be corrupted, and then, if the track returns more steps from the GPU, it would lead to corrupted memory access. Therefore, it is fundamental, that AdePT kills all particles on GPU exactly as CMSSW on CPU. That way, no particle that from the GPU comes to the CPU must be killed by CMSSW.

This includes propagating a flag whether a Russian Roulette is applicable to a particle (it is excluded only in the ECAL if the ancestor particle is an electron, positron or gamma). Luckily, the flag was in the padding and does not increase the track size.

  • Track-level kills mirror Phase2SteppingAction exactly: In the very forward region only the forward time cut applies, central tracks are killed in dead regions and beyond the central time cut, the e−/e+ vacuum cut compares the density inclusively, and kills no longer deposit energy.
  • ClassifySecondary mirrors Phase2TrackFilter: dead-region, time, low-density and gamma-threshold kills plus the per-region gamma Russian roulette, all without depositing rejected energy. The ECAL roulette applicability is evaluated on the host per injected track and inherited by descendants; survivors keep a weight above one so CMSSW does not play again, and probabilities too close to one are rejected at initialization.
  • A track killed by the user stepping action on a GPU-to-CPU hand-over now ends in that step.
  • Before, the stepping action parameters were hardcoded. Now, it is possible to hand them over from CMSSW to AdePT directly, which will be implemented on the CMS AdePT PhysicsList, as soon as this is merged, tagged, and cmsdist is updated.

Note that not depositing the energy of killed tracks changes the energy deposition by ~0.5%, but is consistent with CMSSW now.

Assisted-by: Claude Code (Claude Fable 5)

…tion exactly

The CMS stepping action had hardcoded cuts and only approximated the
CMSSW Phase2SteppingAction: it killed tracks beyond |z| = 50 m only
when they were also out of time, applied the dead-region and vacuum
cuts to very forward tracks, and deposited the kinetic energy of killed
tracks, which Phase2SteppingAction does not. Mirror the track-level
kills exactly: in the very forward region only the forward time cut
applies, central tracks are killed in dead regions and beyond the
central time cut, the e-/e+ vacuum cut uses an inclusive density
comparison, and kills no longer deposit energy.

The cuts come from CMSSW through a new CMSSteppingActionConfig
(g4integration) set via AdePTConfiguration::SetCMSSteppingActionConfig.
Its device-copyable part is the CMSSteppingActionParams
(transport/config), whose fields now name the CMSSW parameters they
mirror; in CMS builds it is the parameter type selected at build time
that the transport configuration already carries to the kernels.
AddDeadRegionName is kept for source compatibility and feeds the same
configuration. The defaults reproduce the previous behavior when no
configuration is set, and builds with other stepping actions are
unchanged.

Assisted-by: Claude Code (Claude Fable 5)
CMSSW applies its Phase2TrackFilter to the secondaries of the replayed
GPU steps and erases (and deletes) the ones it kills, although they are
placement-new'd pool objects that are already transported on the GPU,
so any filter mismatch corrupts the replay storage. The GPU therefore
takes the same decisions before a secondary is created: the CMS
ClassifySecondary kills secondaries in dead regions, out of time, below
the gamma threshold and low-energy ones in the low-density regions, and
plays the per-region gamma Russian roulette, all without depositing the
energy of a rejected secondary, exactly as the filter does.

The ECAL roulette only applies to gammas whose generator particle is
not a gamma or an e+-; this is evaluated on the host for every track
handed to the GPU and inherited by its descendants, which is exact
because the generator particle id never changes along an EM shower.
Roulette survivors keep a weight above one so that CMSSW does not play
again; survival probabilities so close to one that the float weight
would not stay above one are rejected at initialization.

A track that the user stepping action kills on a GPU-to-CPU hand-over
now ends in that step instead of being resurrected on the CPU, matching
Geant4 semantics and the CMSSW kills on replayed steps.

Assisted-by: Claude Code (Claude Fable 5)
@SeverinDiederichs

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-21T12:52:11.744814Z
We couldn’t complete this review. Comment @codex review to try again.
43c4406 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SeverinDiederichs SeverinDiederichs changed the title Cms stepping action config Fix CMS SteppingAction for new approach in CMSSW Oct 21, 2026
@SeverinDiederichs

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SeverinDiederichs

Copy link
Copy Markdown
Collaborator Author

/run-test

@SeverinDiederichs

Copy link
Copy Markdown
Collaborator Author

As the automatic AI review is broken: manual AI review with Codex 6.1 SoL ultra found no issues with the PR.

@SeverinDiederichs
SeverinDiederichs merged commit 1faed8d into apt-sim:master Oct 21, 2026
6 checks passed
@SeverinDiederichs
SeverinDiederichs deleted the cms-stepping-action-config branch October 21, 2026 16:01
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.

1 participant