From 3994d88146228f697ef12251d88da1b64ae645bc Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 15 May 2026 13:58:52 -0400 Subject: [PATCH 1/4] refactor(u4): remove dead Cerenkov instrumentation Remove the unused INSTRUMENTED path from Local_G4Cerenkov_modified, including stale debug hooks, photon-count override plumbing, and OpticksDebug/OpticksRandom references. --- u4/Local_G4Cerenkov_modified.cc | 112 -------------------------------- u4/Local_G4Cerenkov_modified.hh | 23 ------- 2 files changed, 135 deletions(-) diff --git a/u4/Local_G4Cerenkov_modified.cc b/u4/Local_G4Cerenkov_modified.cc index 57ef909b75..a0563b7eda 100644 --- a/u4/Local_G4Cerenkov_modified.cc +++ b/u4/Local_G4Cerenkov_modified.cc @@ -75,11 +75,6 @@ #include "Local_G4Cerenkov_modified.hh" -#ifdef INSTRUMENTED -#include "OpticksDebug.hh" -#include "OpticksRandom.hh" -#endif - #include "SLOG.hh" #include "U4.hh" @@ -105,9 +100,6 @@ Local_G4Cerenkov_modified::Local_G4Cerenkov_modified(const G4String& processName fMaxBetaChange(0.0), fMaxPhotons(0), fStackingFlag(true), -#ifdef INSTRUMENTED - override_fNumPhotons(0), -#endif fNumPhotons(0) { SetProcessSubType(fCerenkov); @@ -236,13 +228,6 @@ G4VParticleChange* Local_G4Cerenkov_modified::PostStepDoIt(const G4Track& aTrack fNumPhotons = (G4int) G4Poisson(MeanNumberOfPhotons); -#ifdef INSTRUMENTED - if( override_fNumPhotons > 0 ) - { - fNumPhotons = override_fNumPhotons ; - } -#endif - // calculate the fNumPhotons1 and fNumPhotons2 { @@ -310,19 +295,6 @@ G4VParticleChange* Local_G4Cerenkov_modified::PostStepDoIt(const G4Track& aTrack fNumPhotons2 = MeanNumberOfPhotons2; -#ifdef INSTRUMENTED - par->append( BetaInverse, "BetaInverse" ); - par->append( beta , "beta" ); - par->append( Pmin , "Pmin" ); - par->append( Pmax , "Pmax" ); - - par->append( nMax , "nMax" ); - par->append( maxCos , "maxCos" ); - par->append( maxSin2 , "maxSin2" ); - par->append( fNumPhotons, "fNumPhotons" ); -#endif - - if (MeanNumberOfPhotons1 <= 0.0 or MeanNumberOfPhotons2<=0.0) { @@ -393,36 +365,9 @@ G4VParticleChange* Local_G4Cerenkov_modified::PostStepDoIt(const G4Track& aTrack G4double sin2Theta(0.); #endif -#ifdef INSTRUMENTED - unsigned head_count = 0 ; - unsigned tail_count = 0 ; - unsigned continue_count = 0 ; - unsigned condition_count = 0 ; - int seqidx = -1 ; - if(rnd) - { - rnd->setSequenceIndex(i); - seqidx = rnd->getSequenceIndex(); - - if(i < 10) std::cout - << " i " << std::setw(6) << i - << " seqidx " << std::setw(7) << seqidx - << " Pmin/eV " << std::fixed << std::setw(10) << std::setprecision(5) << Pmin/eV - << " Pmax/eV " << std::fixed << std::setw(10) << std::setprecision(5) << Pmax/eV - << " dp/eV " << std::fixed << std::setw(10) << std::setprecision(5) << dp/eV - << " maxSin2 " << std::fixed << std::setw(10) << std::setprecision(5) << maxSin2 - << std::endl - ; - - } -#endif - // sample an energy do { -#ifdef INSTRUMENTED - head_count += 1 ; -#endif rand0 = G4UniformRand(); sampledEnergy = Pmin + rand0 * dp; sampledRI = Rindex->Value(sampledEnergy); @@ -432,17 +377,10 @@ G4VParticleChange* Local_G4Cerenkov_modified::PostStepDoIt(const G4Track& aTrack #else // check if n(E) > 1/beta if (sampledRI < BetaInverse) { -#ifdef INSTRUMENTED - continue_count += 1 ; -#endif continue; } #endif - -#ifdef INSTRUMENTED - tail_count += 1 ; -#endif cosTheta = BetaInverse / sampledRI; @@ -465,46 +403,7 @@ G4VParticleChange* Local_G4Cerenkov_modified::PostStepDoIt(const G4Track& aTrack #endif // Loop checking, 07-Aug-2015, Vladimir Ivanchenko -#ifdef INSTRUMENTED - - if( i < 10 ) std::cout - << " tc " << std::setw(6) << tail_count - << " u0 " << std::fixed << std::setw(10) << std::setprecision(5) << rand0 - << " eV " << std::fixed << std::setw(10) << std::setprecision(5) << sampledEnergy/eV - << " ri " << std::fixed << std::setw(10) << std::setprecision(5) << sampledRI - << " ct " << std::fixed << std::setw(10) << std::setprecision(5) << cosTheta - << " s2 " << std::fixed << std::setw(10) << std::setprecision(5) << sin2Theta - << " rand1*maxSin2 " << std::fixed << std::setw(10) << std::setprecision(5) << rand1*maxSin2 - << " rand1*maxSin2 - sin2Theta " << std::fixed << std::setw(10) << std::setprecision(5) << rand1*maxSin2 - sin2Theta - << " loop " << ( rand1*maxSin2 > sin2Theta ? "Y" : "N" ) - << std::endl - ; - - - } while ( looping_condition(condition_count) && rand1*maxSin2 > sin2Theta ); -#else } while (rand1*maxSin2 > sin2Theta); -#endif - -#ifdef INSTRUMENTED - G4double sampledEnergy_eV = sampledEnergy/eV ; - G4double sampledWavelength_nm = h_Planck*c_light/sampledEnergy/nm ; - - gen->append( sampledEnergy_eV , "sampledEnergy" ); - gen->append( sampledWavelength_nm , "sampledWavelength" ); - gen->append( sampledRI , "sampledRI" ); - gen->append( cosTheta , "cosTheta" ); - - gen->append( sin2Theta , "sin2Theta" ); - gen->append( head_count , tail_count, "head_tail" ); - gen->append( continue_count , condition_count, "continue_condition" ); - gen->append( BetaInverse , "BetaInverse" ); - - if(rnd) - { - rnd->setSequenceIndex(-1); - } -#endif @@ -606,17 +505,6 @@ G4VParticleChange* Local_G4Cerenkov_modified::PostStepDoIt(const G4Track& aTrack } -#ifdef INSTRUMENTED -bool Local_G4Cerenkov_modified::looping_condition(unsigned& count) -{ - count += 1 ; - return true ; -} - - -#endif - - // BuildThePhysicsTable for the Cerenkov process // --------------------------------------------- // diff --git a/u4/Local_G4Cerenkov_modified.hh b/u4/Local_G4Cerenkov_modified.hh index 387565c67e..6d7b002744 100644 --- a/u4/Local_G4Cerenkov_modified.hh +++ b/u4/Local_G4Cerenkov_modified.hh @@ -78,25 +78,10 @@ // Class Definition ///////////////////// -#ifdef INSTRUMENTED -template struct OpticksDebug ; -struct OpticksRandom ; -#endif - - class Local_G4Cerenkov_modified : public G4VProcess { public: -#ifdef INSTRUMENTED - template friend struct Local_G4Cerenkov_modifiedTest ; - bool looping_condition(unsigned& count); - OpticksDebug* gen ; - OpticksDebug* par ; - OpticksRandom* rnd ; -#endif - - //////////////////////////////// // Constructors and Destructor //////////////////////////////// @@ -252,12 +237,6 @@ private: G4bool fStackingFlag; -#ifdef INSTRUMENTED -public: - G4int override_fNumPhotons ; -private: -#endif - G4int fNumPhotons; G4int fNumPhotons1; // mean G4int fNumPhotons2; // mean @@ -325,5 +304,3 @@ G4PhysicsTable* Local_G4Cerenkov_modified::GetPhysicsTable() const } #endif /* Local_G4Cerenkov_modified_h */ - - From 512499f950043032f2fb03c5fdab6ea7b613d245 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 15 May 2026 14:24:16 -0400 Subject: [PATCH 2/4] refactor(u4): remove stale Cerenkov debug prints --- u4/Local_G4Cerenkov_modified.cc | 58 --------------------------------- 1 file changed, 58 deletions(-) diff --git a/u4/Local_G4Cerenkov_modified.cc b/u4/Local_G4Cerenkov_modified.cc index a0563b7eda..7007cb8744 100644 --- a/u4/Local_G4Cerenkov_modified.cc +++ b/u4/Local_G4Cerenkov_modified.cc @@ -736,17 +736,6 @@ G4double const G4double Rfact = 369.81/(eV * cm); -#ifdef X_INSTRUMENTED - std::cout - << "Local_G4Cerenkov_modified::GetAverageNumberOfPhotons" - << " Rfact " << std::fixed << std::setw(10) << std::setprecision(5) << Rfact - << " eV " << std::fixed << std::setw(10) << std::setprecision(7) << eV - << " cm " << std::fixed << std::setw(10) << std::setprecision(5) << cm - << " charge " << std::fixed << std::setw(10) << std::setprecision(5) << charge - << std::endl - ; -#endif - if(beta <= 0.0)return 0.0; G4double BetaInverse = 1./beta; @@ -997,40 +986,6 @@ G4double G4double NumPhotons = Rfact * charge/eplus * charge/eplus * (dp1 - ge1 * BetaInverse*BetaInverse); - -#ifdef X_INSTRUMENTED - std::cout - << "Local_G4Cerenkov_modified::GetAverageNumberOfPhotons" - << " BetaInverse " << std::fixed << std::setw(10) << std::setprecision(5) << BetaInverse - << " maxRI " << std::fixed << std::setw(10) << std::setprecision(5) << maxRI - << " minRI " << std::fixed << std::setw(10) << std::setprecision(5) << minRI - << " cross_num " << cross_num - << " dp1 " << std::fixed << std::setw(10) << std::setprecision(5) << dp1 - << " dp1/eV " << std::fixed << std::setw(10) << std::setprecision(5) << dp1/eV - << " ge1 " << std::fixed << std::setw(10) << std::setprecision(5) << ge1 - << " NumPhotons " << std::fixed << std::setw(10) << std::setprecision(5) << NumPhotons - << std::endl - ; - - for(int i=0 ; i < cross_num ; i++) - { - - G4bool isOutRange; - G4double cai0 = CerenkovAngleIntegrals->GetValue(the_energies_threshold[2*i+0], isOutRange); - G4double cai1 = CerenkovAngleIntegrals->GetValue(the_energies_threshold[2*i+1], isOutRange); - - std::cout - << "Local_G4Cerenkov_modified::GetAverageNumberOfPhotons" - << " the_energies_threshold[2*i+0]/eV " << std::fixed << std::setw(10) << std::setprecision(5) << the_energies_threshold[2*i+0]/eV - << " the_energies_threshold[2*i+1]/eV " << std::fixed << std::setw(10) << std::setprecision(5) << the_energies_threshold[2*i+1]/eV - << " cai0 " << std::fixed << std::setw(20) << std::setprecision(10) << cai0 - << " cai1 " << std::fixed << std::setw(20) << std::setprecision(10) << cai1 - << std::endl - ; - } -#endif - - return NumPhotons; } @@ -1146,19 +1101,6 @@ G4double Local_G4Cerenkov_modified::GetAverageNumberOfPhotons_s2(const G4double const G4double Rfact = 369.81/(eV * cm); G4double NumPhotons = Rfact * charge/eplus * charge/eplus * s2integral ; -#ifdef X_INSTRUMENTED - std::cout - << "Local_G4Cerenkov_modified::GetAverageNumberOfPhotons_s2" - << " Rfact " << std::fixed << std::setw(10) << std::setprecision(5) << Rfact - << " eV " << std::fixed << std::setw(10) << std::setprecision(7) << eV - << " cm " << std::fixed << std::setw(10) << std::setprecision(5) << cm - << " mm " << std::fixed << std::setw(10) << std::setprecision(5) << mm - << " charge " << std::fixed << std::setw(10) << std::setprecision(5) << charge - << " s2integral " << std::fixed << std::setw(10) << std::setprecision(5) << s2integral - << " NumPhotons " << std::fixed << std::setw(10) << std::setprecision(5) << NumPhotons - << std::endl - ; -#endif return NumPhotons ; } From 2d05c198f7acbf44558640e3a75bcf0e48aa6b97 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 15 May 2026 14:11:29 -0400 Subject: [PATCH 3/4] refactor(u4): remove Geant4 optical process shims 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. --- u4/CMakeLists.txt | 5 - u4/ShimG4OpAbsorption.cc | 147 ------------------- u4/ShimG4OpAbsorption.hh | 39 ----- u4/ShimG4OpRayleigh.cc | 281 ------------------------------------- u4/ShimG4OpRayleigh.hh | 42 ------ u4/U4Physics.cc | 24 +--- u4/U4Physics.hh | 12 -- u4/U4Stack.h | 5 +- u4/U4StackAuto.h | 71 ---------- u4/tests/U4SimulateTest.sh | 2 - u4/u4s.sh | 11 +- 11 files changed, 6 insertions(+), 633 deletions(-) delete mode 100644 u4/ShimG4OpAbsorption.cc delete mode 100644 u4/ShimG4OpAbsorption.hh delete mode 100644 u4/ShimG4OpRayleigh.cc delete mode 100644 u4/ShimG4OpRayleigh.hh diff --git a/u4/CMakeLists.txt b/u4/CMakeLists.txt index 8493026caa..c8af1a77f5 100644 --- a/u4/CMakeLists.txt +++ b/u4/CMakeLists.txt @@ -24,8 +24,6 @@ set(SOURCES U4Cerenkov_Debug.cc U4Hit_Debug.cc - ShimG4OpAbsorption.cc - ShimG4OpRayleigh.cc Local_G4Cerenkov_modified.cc Local_DsG4Scintillation.cc @@ -88,9 +86,6 @@ set(HEADERS U4Cerenkov_Debug.hh U4Hit_Debug.hh - ShimG4OpAbsorption.hh - ShimG4OpRayleigh.hh - Local_G4Cerenkov_modified.hh Local_DsG4Scintillation.hh U4Physics.hh diff --git a/u4/ShimG4OpAbsorption.cc b/u4/ShimG4OpAbsorption.cc deleted file mode 100644 index c608a0b156..0000000000 --- a/u4/ShimG4OpAbsorption.cc +++ /dev/null @@ -1,147 +0,0 @@ -#include - -#include "G4SystemOfUnits.hh" - -#include "ShimG4OpAbsorption.hh" -#include "SEvt.hh" -#include "SLOG.hh" -#include "ssys.h" -#include "U4UniformRand.h" -#include "U4Stack.h" - - -const plog::Severity ShimG4OpAbsorption::LEVEL = SLOG::EnvLevel("ShimG4OpAbsorption", "DEBUG") ; - - -ShimG4OpAbsorption::ShimG4OpAbsorption(const G4String& processName, G4ProcessType type ) - : - G4OpAbsorption(processName, type) -{ -} - -ShimG4OpAbsorption::~ShimG4OpAbsorption(){} - - - - -//#ifdef DEBUG_TAG -/** -ShimG4OpAbsorption::ResetNumberOfInteractionLengthLeft --------------------------------------------------------- - -Shim makes process classname appear in SBacktrace.h enabling U4Random::flat/U4Stack::Classify - -**/ - -const bool ShimG4OpAbsorption::FLOAT = ssys::getenvbool("ShimG4OpAbsorption_FLOAT") ; -const int ShimG4OpAbsorption::PIDX = ssys::getenvint("PIDX",-1); -const bool ShimG4OpAbsorption::PIDX_ENABLED = ssys::getenvbool("ShimG4OpAbsorption__PIDX_ENABLED") ; - - -// void ShimG4OpAbsorption::ResetNumberOfInteractionLengthLeft(){ G4VProcess::ResetNumberOfInteractionLengthLeft(); } - void ShimG4OpAbsorption::ResetNumberOfInteractionLengthLeft() -{ - G4double u = G4UniformRand() ; - - LOG(LEVEL) - << U4UniformRand::Desc(u, SEvt::UU ) - ; - -#ifndef PRODUCTION - SEvt::AddTag( 1, U4Stack_AbsorptionDiscreteReset, u ); -#endif - - if(FLOAT) - { - float f = -1.f*std::log( float(u) ) ; - theNumberOfInteractionLengthLeft = f ; - } - else - { - theNumberOfInteractionLengthLeft = -1.*G4Log(u) ; - } - theInitialNumberOfInteractionLength = theNumberOfInteractionLengthLeft; - -} - - G4double ShimG4OpAbsorption::GetMeanFreePath(const G4Track& aTrack, G4double, G4ForceCondition* ) -{ - G4double len = G4OpAbsorption::GetMeanFreePath( aTrack, 0, 0 ); - //std::cout << "ShimG4OpAbsorption::GetMeanFreePath " << len << std::endl ; - - //std::raise(SIGINT); - - return len ; -} - - - G4double ShimG4OpAbsorption::PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition) -{ - if ( (previousStepSize < 0.0) || (theNumberOfInteractionLengthLeft<=0.0)) { - // beggining of tracking (or just after DoIt of this process) - ResetNumberOfInteractionLengthLeft(); - } else if ( previousStepSize > 0.0) { - // subtract NumberOfInteractionLengthLeft - SubtractNumberOfInteractionLengthLeft(previousStepSize); - } else { - // zero step - // DO NOTHING - } - - // condition is set to "Not Forced" - *condition = NotForced; - - // get mean free path - currentInteractionLength = GetMeanFreePath(track, previousStepSize, condition); - - G4double value; - if (currentInteractionLength 1){ - G4cout << "G4VDiscreteProcess::PostStepGetPhysicalInteractionLength "; - G4cout << "[ " << GetProcessName() << "]" <DumpInfo(); - G4cout << " in Material " << track.GetMaterial()->GetName() < 0.0) { - // subtract NumberOfInteractionLengthLeft - SubtractNumberOfInteractionLengthLeft(previousStepSize); - } else { - // zero step - // DO NOTHING - } - - // condition is set to "Not Forced" - *condition = NotForced; - - // get mean free path - currentInteractionLength = GetMeanFreePath(track, previousStepSize, condition); - - G4double value; - if (currentInteractionLength 1){ - G4cout << "G4VDiscreteProcess::PostStepGetPhysicalInteractionLength "; - G4cout << "[ " << GetProcessName() << "]" <DumpInfo(); - G4cout << " in Material " << track.GetMaterial()->GetName() <0) { - G4cout << "Scattering Photon!" << G4endl; - G4cout << "Old Momentum Direction: " - << aParticle->GetMomentumDirection() << G4endl; - G4cout << "Old Polarization: " - << aParticle->GetPolarization() << G4endl; - } - - G4double cosTheta; - G4ThreeVector OldMomentumDirection, NewMomentumDirection; - G4ThreeVector OldPolarization, NewPolarization; - - G4double rand, constant; - G4double CosTheta, SinTheta, SinPhi, CosPhi, unit_x, unit_y, unit_z; - - G4double u ; - G4double u_loopexit ; - - - do { - // Try to simulate the scattered photon momentum direction - // w.r.t. the initial photon momentum direction - - CosTheta = G4UniformRand(); - -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag( 1, U4Stack_RayleighScatter, CosTheta ); // 0 -#endif -#endif - - SinTheta = std::sqrt(1.-CosTheta*CosTheta); - // consider for the angle 90-180 degrees - - u = G4UniformRand() ; - -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag( 1, U4Stack_RayleighScatter, u ); // 1 -#endif -#endif - - if (u < 0.5) CosTheta = -CosTheta; - - // simulate the phi angle - - u = G4UniformRand() ; - -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag( 1, U4Stack_RayleighScatter, u ); // 2 -#endif -#endif - - rand = twopi*u; - SinPhi = std::sin(rand); - CosPhi = std::cos(rand); - - // start constructing the new momentum direction - unit_x = SinTheta * CosPhi; - unit_y = SinTheta * SinPhi; - unit_z = CosTheta; - NewMomentumDirection.set (unit_x,unit_y,unit_z); - - // Rotate the new momentum direction into global reference system - OldMomentumDirection = aParticle->GetMomentumDirection(); - OldMomentumDirection = OldMomentumDirection.unit(); - NewMomentumDirection.rotateUz(OldMomentumDirection); - NewMomentumDirection = NewMomentumDirection.unit(); - - // calculate the new polarization direction - // The new polarization needs to be in the same plane as the new - // momentum direction and the old polarization direction - OldPolarization = aParticle->GetPolarization(); - constant = -NewMomentumDirection.dot(OldPolarization); - - NewPolarization = OldPolarization + constant*NewMomentumDirection; - NewPolarization = NewPolarization.unit(); - - // There is a corner case, where the Newmomentum direction - // is the same as oldpolariztion direction: - // random generate the azimuthal angle w.r.t. Newmomentum direction - - u = G4UniformRand() ; - -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag( 1, U4Stack_RayleighScatter, u ); // 3 -#endif -#endif - - if (NewPolarization.mag() == 0.) { - rand = u*twopi; - NewPolarization.set(std::cos(rand),std::sin(rand),0.); - NewPolarization.rotateUz(NewMomentumDirection); - } else { - // There are two directions which are perpendicular - // to the new momentum direction - if (u < 0.5) NewPolarization = -NewPolarization; - } - - // simulate according to the distribution cos^2(theta) - cosTheta = NewPolarization.dot(OldPolarization); - - u_loopexit = G4UniformRand() ; - -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag( 1, U4Stack_RayleighScatter, u_loopexit ); // 4 -#endif -#endif - - // Loop checking, 13-Aug-2015, Peter Gumplinger - } while (std::pow(cosTheta,2) < u_loopexit ); - - aParticleChange.ProposePolarization(NewPolarization); - aParticleChange.ProposeMomentumDirection(NewMomentumDirection); - - if (verboseLevel>0) { - G4cout << "New Polarization: " - << NewPolarization << G4endl; - G4cout << "Polarization Change: " - << *(aParticleChange.GetPolarization()) << G4endl; - G4cout << "New Momentum Direction: " - << NewMomentumDirection << G4endl; - G4cout << "Momentum Change: " - << *(aParticleChange.GetMomentumDirection()) << G4endl; - } - - return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); -} - - - - diff --git a/u4/ShimG4OpRayleigh.hh b/u4/ShimG4OpRayleigh.hh deleted file mode 100644 index d3114c183a..0000000000 --- a/u4/ShimG4OpRayleigh.hh +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once -/** -ShimG4OpRayleigh -=================== - -class G4OpRayleigh : public G4VDiscreteProcess - -**/ - -#include "plog/Severity.h" -#include "G4OpRayleigh.hh" -#include "U4_API_EXPORT.hh" - -class U4_API ShimG4OpRayleigh : public G4OpRayleigh -{ - static const plog::Severity LEVEL ; - public: - ShimG4OpRayleigh(); - virtual ~ShimG4OpRayleigh(); - - static const bool FLOAT ; - static const int PIDX ; - static const bool PIDX_ENABLED ; - - void ResetNumberOfInteractionLengthLeft(); - G4double GetMeanFreePath(const G4Track& aTrack, - G4double , - G4ForceCondition* ); - - G4double PostStepGetPhysicalInteractionLength( - const G4Track& track, - G4double previousStepSize, - G4ForceCondition* condition - ); - - - G4VParticleChange* PostStepDoIt(const G4Track& aTrack, - const G4Step& aStep); - -}; - - diff --git a/u4/U4Physics.cc b/u4/U4Physics.cc index 9d0caf334d..734d0e239b 100644 --- a/u4/U4Physics.cc +++ b/u4/U4Physics.cc @@ -20,9 +20,9 @@ Boundary class changes need to match in all the below:: #include "G4ProcessManager.hh" #include "G4FastSimulationManagerProcess.hh" - +#include "G4OpAbsorption.hh" #include "G4OpBoundaryProcess.hh" - +#include "G4OpRayleigh.hh" #include "SLOG.hh" const plog::Severity U4Physics::LEVEL = SLOG::EnvLevel("U4Physics", "DEBUG") ; @@ -153,9 +153,6 @@ void U4Physics::ConstructEM() #include "Local_G4Cerenkov_modified.hh" #include "Local_DsG4Scintillation.hh" -#include "ShimG4OpAbsorption.hh" -#include "ShimG4OpRayleigh.hh" - std::string U4Physics::desc() const { @@ -177,14 +174,7 @@ std::string U4Physics::desc() const std::string U4Physics::Desc() // static { - std::stringstream ss ; -#ifdef DEBUG_TAG - ss << ( ShimG4OpAbsorption::FLOAT ? "ShimG4OpAbsorption_FLOAT" : "ShimG4OpAbsorption_ORIGINAL" ) ; - ss << "_" ; - ss << ( ShimG4OpRayleigh::FLOAT ? "ShimG4OpRayleigh_FLOAT" : "ShimG4OpRayleigh_ORIGINAL" ) ; -#endif - std::string str = ss.str(); - return str ; + return {}; } @@ -260,20 +250,12 @@ void U4Physics::ConstructOp() if(OpAbsorption_DISABLE == 0) { -#ifdef DEBUG_TAG - fAbsorption = new ShimG4OpAbsorption(); -#else fAbsorption = new G4OpAbsorption(); -#endif } if(OpRayleigh_DISABLE == 0) { -#ifdef DEBUG_TAG - fRayleigh = new ShimG4OpRayleigh(); -#else fRayleigh = new G4OpRayleigh(); -#endif } if(OpBoundaryProcess_DISABLE == 0) diff --git a/u4/U4Physics.hh b/u4/U4Physics.hh index 0f5754c4cc..19c198e3d4 100644 --- a/u4/U4Physics.hh +++ b/u4/U4Physics.hh @@ -17,13 +17,8 @@ This is intended solely for use from U4AppTest class Local_G4Cerenkov_modified ; class Local_DsG4Scintillation ; -#ifdef DEBUG_TAG -class ShimG4OpAbsorption ; -class ShimG4OpRayleigh ; -#else class G4OpAbsorption ; class G4OpRayleigh ; -#endif class G4VProcess ; class G4ProcessManager ; @@ -40,13 +35,8 @@ struct U4_API U4Physics : public G4VUserPhysicsList Local_G4Cerenkov_modified* fCerenkov ; Local_DsG4Scintillation* fScintillation ; -#ifdef DEBUG_TAG - ShimG4OpAbsorption* fAbsorption ; - ShimG4OpRayleigh* fRayleigh ; -#else G4OpAbsorption* fAbsorption ; G4OpRayleigh* fRayleigh ; -#endif G4VProcess* fBoundary ; G4FastSimulationManagerProcess* fFastSim ; @@ -80,5 +70,3 @@ struct U4_API U4Physics : public G4VUserPhysicsList int OpBoundaryProcess_LASTPOST = 0 ; int FastSim_ENABLE = 0 ; }; - - diff --git a/u4/U4Stack.h b/u4/U4Stack.h index 64dbef6e13..a929237e31 100644 --- a/u4/U4Stack.h +++ b/u4/U4Stack.h @@ -47,8 +47,8 @@ struct U4Stack static unsigned TagToStack(unsigned tag); static constexpr const char* Unclassified_ = "Unclassified" ; // 0 - static constexpr const char* RestDiscreteReset_ = "RestDiscreteReset" ; // 1: not used as use Shims to idenify processes in SBacktrace - static constexpr const char* DiscreteReset_ = "DiscreteReset" ; // 2 : G4OpAbsoption G4OpRayleigh but now use Shims to identify + static constexpr const char* RestDiscreteReset_ = "RestDiscreteReset"; // 1 + static constexpr const char* DiscreteReset_ = "DiscreteReset"; // 2: G4OpAbsorption/G4OpRayleigh share this reset path static constexpr const char* ScintDiscreteReset_ = "ScintDiscreteReset" ; // 3 static constexpr const char* BoundaryDiscreteReset_ = "BoundaryDiscreteReset" ; // 4 static constexpr const char* RayleighDiscreteReset_ = "RayleighDiscreteReset" ; // 5 @@ -171,4 +171,3 @@ inline unsigned U4Stack::TagToStack(unsigned tag) } return stack ; } - diff --git a/u4/U4StackAuto.h b/u4/U4StackAuto.h index 1abcfeb07c..1c478cc0e9 100644 --- a/u4/U4StackAuto.h +++ b/u4/U4StackAuto.h @@ -59,68 +59,6 @@ G4SteppingManager::DefinePhysicalStepLength G4SteppingManager::Stepping )" ; - - static constexpr const char* RayleighDiscreteReset = R"( -U4Random::flat -G4VProcess::ResetNumberOfInteractionLengthLeft -ShimG4OpRayleigh::ResetNumberOfInteractionLengthLeft -G4VDiscreteProcess::PostStepGetPhysicalInteractionLength -G4VProcess::PostStepGPIL -G4SteppingManager::DefinePhysicalStepLength -G4SteppingManager::Stepping -)" ; - - static constexpr const char* ShimRayleighDiscreteReset_ = "ShimRayleighDiscreteReset" ; // 5 - static constexpr const char* ShimRayleighDiscreteReset = R"( -U4Random::flat -ShimG4OpRayleigh::ResetNumberOfInteractionLengthLeft -G4VDiscreteProcess::PostStepGetPhysicalInteractionLength -G4VProcess::PostStepGPIL -G4SteppingManager::DefinePhysicalStepLength -G4SteppingManager::Stepping -)" ; - - static constexpr const char* Shim2RayleighDiscreteReset_ = "Shim2RayleighDiscreteReset" ; // 5 - static constexpr const char* Shim2RayleighDiscreteReset = R"( -U4Random::flat -ShimG4OpRayleigh::ResetNumberOfInteractionLengthLeft -ShimG4OpRayleigh::PostStepGetPhysicalInteractionLength -G4VProcess::PostStepGPIL -G4SteppingManager::DefinePhysicalStepLength -G4SteppingManager::Stepping -)" ; - - - - static constexpr const char* AbsorptionDiscreteReset = R"( -U4Random::flat -G4VProcess::ResetNumberOfInteractionLengthLeft -ShimG4OpAbsorption::ResetNumberOfInteractionLengthLeft -G4VDiscreteProcess::PostStepGetPhysicalInteractionLength -G4VProcess::PostStepGPIL -G4SteppingManager::DefinePhysicalStepLength -G4SteppingManager::Stepping -)" ; - static constexpr const char* ShimAbsorptionDiscreteReset_ = "ShimAbsorptionDiscreteReset" ; // 6 - static constexpr const char* ShimAbsorptionDiscreteReset = R"( -U4Random::flat -ShimG4OpAbsorption::ResetNumberOfInteractionLengthLeft -G4VDiscreteProcess::PostStepGetPhysicalInteractionLength -G4VProcess::PostStepGPIL -G4SteppingManager::DefinePhysicalStepLength -G4SteppingManager::Stepping -)" ; - - static constexpr const char* Shim2AbsorptionDiscreteReset_ = "Shim2AbsorptionDiscreteReset" ; // 6 - static constexpr const char* Shim2AbsorptionDiscreteReset = R"( -U4Random::flat -ShimG4OpAbsorption::ResetNumberOfInteractionLengthLeft -ShimG4OpAbsorption::PostStepGetPhysicalInteractionLength -G4VProcess::PostStepGPIL -G4SteppingManager::DefinePhysicalStepLength -G4SteppingManager::Stepping -)"; - static constexpr const char *BoundaryBurn_SurfaceReflectTransmitAbsorb = R"( U4Random::flat G4OpBoundaryProcess::PostStepDoIt @@ -173,14 +111,6 @@ inline unsigned U4StackAuto::Classify(const char* summary) if(strstr(summary, BoundaryDiscreteReset)) stack = U4Stack_BoundaryDiscreteReset ; if(strstr(summary, BoundaryDiscreteReset2)) stack = U4Stack_BoundaryDiscreteReset ; - if(strstr(summary, RayleighDiscreteReset)) stack = U4Stack_RayleighDiscreteReset ; - if(strstr(summary, ShimRayleighDiscreteReset)) stack = U4Stack_RayleighDiscreteReset ; - if(strstr(summary, Shim2RayleighDiscreteReset)) stack = U4Stack_RayleighDiscreteReset ; - - if(strstr(summary, AbsorptionDiscreteReset)) stack = U4Stack_AbsorptionDiscreteReset ; - if(strstr(summary, ShimAbsorptionDiscreteReset)) stack = U4Stack_AbsorptionDiscreteReset ; - if(strstr(summary, Shim2AbsorptionDiscreteReset)) stack = U4Stack_AbsorptionDiscreteReset ; - if(strstr(summary, BoundaryBurn_SurfaceReflectTransmitAbsorb)) stack = U4Stack_BoundaryBurn_SurfaceReflectTransmitAbsorb ; if(strstr(summary, BoundaryDiDiTransCoeff)) stack = U4Stack_BoundaryDiDiTransCoeff ; if(strstr(summary, AbsorptionEffDetect)) stack = U4Stack_AbsorptionEffDetect ; @@ -192,4 +122,3 @@ inline bool U4StackAuto::IsClassified(unsigned stack) { return stack != U4Stack_Unclassified ; } - diff --git a/u4/tests/U4SimulateTest.sh b/u4/tests/U4SimulateTest.sh index cb7bca0f02..5f9dd78e6f 100755 --- a/u4/tests/U4SimulateTest.sh +++ b/u4/tests/U4SimulateTest.sh @@ -144,8 +144,6 @@ loglevel(){ export junoPMTOpticalModelSimple=INFO #export SEvt=INFO ## thus is exceedingly verbose export SEventConfig=INFO - export ShimG4OpAbsorption=INFO - export ShimG4OpRayleigh=INFO } diff --git a/u4/u4s.sh b/u4/u4s.sh index 800b7c57b5..f790bcb213 100755 --- a/u4/u4s.sh +++ b/u4/u4s.sh @@ -97,16 +97,7 @@ fi export A_FOLD # A_FOLD is needed for loading "$A_FOLD/sframe.npy" export A_CFBASE # A_CFBASE needed for loading "$A_CFBASE/CSGFoundry/SSim" -export ShimG4OpAbsorption_FLOAT=1 -export ShimG4OpRayleigh_FLOAT=1 - -# cf U4Physics::Desc -physdesc="" -[ -n "$ShimG4OpAbsorption_FLOAT" ] && physdesc="${physdesc}ShimG4OpAbsorption_FLOAT" -[ -z "$ShimG4OpAbsorption_FLOAT" ] && physdesc="${physdesc}ShimG4OpAbsorption_ORIGINAL" -physdesc="${physdesc}_" -[ -n "$ShimG4OpRayleigh_FLOAT" ] && physdesc="${physdesc}ShimG4OpRayleigh_FLOAT" -[ -z "$ShimG4OpRayleigh_FLOAT" ] && physdesc="${physdesc}ShimG4OpRayleigh_ORIGINAL" +physdesc="G4OpAbsorption_G4OpRayleigh" #sel=PIDX_0_ sel=ALL From ad761c172823dc933e0051c05608225635187277 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 15 May 2026 16:03:52 -0400 Subject: [PATCH 4/4] refactor(u4): remove legacy G4Opticks scintillation path --- u4/Local_DsG4Scintillation.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/u4/Local_DsG4Scintillation.cc b/u4/Local_DsG4Scintillation.cc index 8423ef566c..6635fff194 100644 --- a/u4/Local_DsG4Scintillation.cc +++ b/u4/Local_DsG4Scintillation.cc @@ -80,7 +80,6 @@ #include "G4Electron.hh" #include "globals.hh" - #include "U4Stack.h" #include "SEvt.hh" @@ -782,7 +781,6 @@ Local_DsG4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep return change ; } - // BuildThePhysicsTable for the scintillation process // -------------------------------------------------- //