refactor(u4): remove legacy G4Opticks scintillation path#332
Conversation
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.
There was a problem hiding this comment.
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
U4Physicsto always construct stockG4OpAbsorptionandG4OpRayleigh. - Deletes stale
INSTRUMENTED,X_INSTRUMENTED, andWITH_G4OPTICKScode 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.
| #ifdef DEBUG_TAG | ||
| fAbsorption = new ShimG4OpAbsorption(); | ||
| #else | ||
| fAbsorption = new G4OpAbsorption(); |
| #ifdef DEBUG_TAG | ||
| fRayleigh = new ShimG4OpRayleigh(); | ||
| #else | ||
| fRayleigh = new G4OpRayleigh(); |
ggalgoczi
left a comment
There was a problem hiding this comment.
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.
|
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. |
This PR removes stale Geant4 optical-process instrumentation from
u4and simplifiesU4Physicsto use the stock Geant4 optical processes directly.While auditing the Geant4 integration, we found that the old Cerenkov
INSTRUMENTEDpath was no longer wired into the build. It was confined toLocal_G4Cerenkov_modified, referenced staleOpticksDebug/OpticksRandomhooks, and was not enabled by any current CMake compile definition.The
ShimG4Op*classes had a similar historical/debug purpose. They were only selected fromU4PhysicswhenDEBUG_TAGwas defined. Their job was not to change normal optical physics behavior, but to make absorption/rayleigh process names visible inSBacktracesoU4Random::flatandU4Stack::Classifycould tag Geant4 random consumption. They also carried debug-only alignment helpers such asSEvt::AddTag,FLOATcalculation switches, andPIDXlogging.This also removes the legacy
WITH_G4OPTICKSpath fromLocal_DsG4Scintillation. That code bridged to the oldG4Opticksintegration through headers such asG4Opticks.hh,CGenstep.hh,CTrack.hh, andCPhotonInfo.hh, which are no longer present in the current tree. The repository does not defineWITH_G4OPTICKS, and the active scintillation genstep collection path is the modernSTANDALONE/U4::CollectGenstep_DsG4Scintillation_r4695path.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:
INSTRUMENTEDandX_INSTRUMENTEDpathsShimG4OpAbsorptionandShimG4OpRayleigh, and always constructG4OpAbsorption/G4OpRayleighinU4PhysicsWITH_G4OPTICKSscintillation integration path