Skip to content

refactor(u4): remove legacy G4Opticks scintillation path#332

Open
plexoos wants to merge 4 commits into
mainfrom
cleanup-geant4
Open

refactor(u4): remove legacy G4Opticks scintillation path#332
plexoos wants to merge 4 commits into
mainfrom
cleanup-geant4

Conversation

@plexoos
Copy link
Copy Markdown
Member

@plexoos plexoos commented May 15, 2026

This PR removes stale Geant4 optical-process instrumentation from u4 and simplifies U4Physics to use the stock Geant4 optical processes directly.

While auditing the Geant4 integration, we found that the old Cerenkov INSTRUMENTED path was no longer wired into the build. It was confined to Local_G4Cerenkov_modified, referenced stale OpticksDebug / OpticksRandom hooks, and was not enabled by any current CMake compile definition.

The ShimG4Op* classes had a similar historical/debug purpose. They were only selected from U4Physics when DEBUG_TAG was defined. Their job was not to change normal optical physics behavior, but to make absorption/rayleigh process names visible in SBacktrace so U4Random::flat and U4Stack::Classify could tag Geant4 random consumption. They also carried debug-only alignment helpers such as SEvt::AddTag, FLOAT calculation switches, and PIDX logging.

This also removes the legacy WITH_G4OPTICKS path from Local_DsG4Scintillation. That code bridged to the old G4Opticks integration through headers such as G4Opticks.hh, CGenstep.hh, CTrack.hh, and CPhotonInfo.hh, which are no longer present in the current tree. The repository does not define
WITH_G4OPTICKS, and the active scintillation genstep collection path is the modern STANDALONE / U4::CollectGenstep_DsG4Scintillation_r4695 path.

Modern workflows do not need those shims in U4Physics, so keeping them increases maintenance cost and preserves old Geant4-derived/debug code paths that are easy to misread as active physics behavior.

The branch contains cleanups:

  • Remove the unused INSTRUMENTED and X_INSTRUMENTED paths
  • Remove ShimG4OpAbsorption and ShimG4OpRayleigh, and always construct G4OpAbsorption/G4OpRayleigh in U4Physics
  • Remove the legacy WITH_G4OPTICKS scintillation integration path

plexoos added 4 commits May 15, 2026 16:04
Remove the unused INSTRUMENTED path from Local_G4Cerenkov_modified, including stale debug hooks,
photon-count override plumbing, and OpticksDebug/OpticksRandom references.
Drop ShimG4OpAbsorption and ShimG4OpRayleigh and always construct stock G4OpAbsorption and
G4OpRayleigh in U4Physics.

Remove the shim-specific build entries, physics description plumbing, stack classification patterns,
and test script log settings.
@plexoos plexoos changed the title refactor(u4): remove stale Geant4 optical instrumentation refactor(u4): remove legacy G4Opticks scintillation path May 15, 2026
@plexoos plexoos requested a review from ggalgoczi May 15, 2026 20:51
@plexoos plexoos self-assigned this May 15, 2026
@plexoos plexoos added this to simphony May 15, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in simphony May 15, 2026
@plexoos plexoos added this to the 1.0.0 milestone May 15, 2026
@plexoos plexoos marked this pull request as ready for review May 15, 2026 20:52
Copilot AI review requested due to automatic review settings May 15, 2026 20:52
Copy link
Copy Markdown
Contributor

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 removes legacy/debug Geant4 optical-process instrumentation from u4, simplifying optical physics setup to use stock Geant4 absorption and Rayleigh processes and deleting stale G4Opticks/Cerenkov instrumentation paths.

Changes:

  • Removes ShimG4OpAbsorption/ShimG4OpRayleigh sources, headers, build entries, env setup, and log configuration.
  • Simplifies U4Physics to always construct stock G4OpAbsorption and G4OpRayleigh.
  • Deletes stale INSTRUMENTED, X_INSTRUMENTED, and WITH_G4OPTICKS code paths from local Cerenkov/scintillation implementations.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
u4/U4StackAuto.h Removes shim-specific absorption/Rayleigh stack classification patterns.
u4/U4Stack.h Updates reset-path comments for stock absorption/Rayleigh behavior.
u4/u4s.sh Removes shim env variables and uses a stock-process physics descriptor.
u4/U4Physics.hh Removes shim forward declarations and members.
u4/U4Physics.cc Includes stock Geant4 optical process headers and constructs stock processes.
u4/tests/U4SimulateTest.sh Removes shim log-level exports.
u4/ShimG4OpRayleigh.hh Deletes legacy Rayleigh shim header.
u4/ShimG4OpRayleigh.cc Deletes legacy Rayleigh shim implementation.
u4/ShimG4OpAbsorption.hh Deletes legacy absorption shim header.
u4/ShimG4OpAbsorption.cc Deletes legacy absorption shim implementation.
u4/Local_G4Cerenkov_modified.hh Removes instrumented Cerenkov declarations.
u4/Local_G4Cerenkov_modified.cc Removes instrumented Cerenkov debug/random hooks.
u4/Local_DsG4Scintillation.hh Removes legacy G4Opticks declarations.
u4/Local_DsG4Scintillation.cc Removes legacy G4Opticks genstep/user-info path.
u4/CMakeLists.txt Removes shim files from library source/header lists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread u4/U4Physics.cc
#ifdef DEBUG_TAG
fAbsorption = new ShimG4OpAbsorption();
#else
fAbsorption = new G4OpAbsorption();
Comment thread u4/U4Physics.cc
#ifdef DEBUG_TAG
fRayleigh = new ShimG4OpRayleigh();
#else
fRayleigh = new G4OpRayleigh();
Copy link
Copy Markdown
Contributor

@ggalgoczi ggalgoczi left a comment

Choose a reason for hiding this comment

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

This breaks PR #271 .

I use the processes that would be deleted here from the codebase to align GPU and CPU photon histories for the best debugging. shim processes are designed to align the per-step RNG consumption to match cuRAND.

@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented May 15, 2026

Okay, I’ll wait for your answers in #271 to clarify that test/study. Based on my current understanding, these shims are not required if the goal is simply to consume the same random-number sequence.

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

Labels

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants