Skip to content

check for IsMultithreadedApplication, add guard for no SD code attached - #712

Merged
SeverinDiederichs merged 1 commit into
apt-sim:masterfrom
SeverinDiederichs:fix_adept_init_on_mt_master
Oct 22, 2026
Merged

SeverinDiederichs merged 1 commit into
apt-sim:masterfrom
SeverinDiederichs:fix_adept_init_on_mt_master

Conversation

@SeverinDiederichs

Copy link
Copy Markdown
Collaborator

This PR fixes a critical bug that was observed with CMSSW:

AdePT was incorrectly constructed on the master thread, which had no SD codes attached. Therefore, the AdePT kernels ignored all hits in the SD code which were solely due to the energy deposition. Still, a very large number of hits was returned, as e.g., all first and last steps of particles were returned (and on the worker thread the SD code was available), thus the scoring happened by accident.

The problem was that the guard:

if (tid == G4Threading::MASTER_ID && G4MTRunManager::GetMasterRunManager() != nullptr) return;

Did not fire, as the GetMasterRunManager is a nullptr in CMSSW, despite being an MT application, due to their custom run manager. Therefore, the correct check is:

G4Threading::IsMultithreadedApplication()

A defensive check is added to warn when no SD code is attached at all.

Now, the total energy deposition in CMSSW looks much better:
cms_EB_edep_before_after_fix

Assisted-by: Claude Code (Claude Fable 5)

@SeverinDiederichs SeverinDiederichs added the bug Type: Something isn't working label Oct 22, 2026
@SeverinDiederichs

Copy link
Copy Markdown
Collaborator Author

@codex review

@SeverinDiederichs

Copy link
Copy Markdown
Collaborator Author

/run-test

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T14:36:08.811574Z
We couldn’t complete this review. Comment @codex review to try again.
138b614 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 merged commit 02b4aef into apt-sim:master Oct 22, 2026
6 checks passed
@SeverinDiederichs
SeverinDiederichs deleted the fix_adept_init_on_mt_master branch October 22, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Type: Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant