Skip to content

Commit e844565

Browse files
authored
refactor(u4): remove WITH_G4OPTICKS guards from Local_DsG4Scintillation (#337)
This PR removes the `WITH_G4OPTICKS`-guarded code paths from `Local_DsG4Scintillation` and simplifies the class around the remaining Opticks-aware scintillation flow. `Local_DsG4Scintillation` now carries a small amount of legacy conditional compilation that makes the scintillation path harder to follow and maintain. This change consolidates the implementation by removing the old macro-gated branches and leaving a single supported path in this class. - reduces conditional compilation in the scintillation process - removes legacy photon ancestry/alignment handling tied to the old `WITH_G4OPTICKS` integration - no broader file-level changes outside `u4/Local_DsG4Scintillation.{cc,hh}`
1 parent 0af3431 commit e844565

2 files changed

Lines changed: 1 addition & 126 deletions

File tree

u4/Local_DsG4Scintillation.cc

Lines changed: 1 addition & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,6 @@
8484
#include "G4Electron.hh"
8585
#include "globals.hh"
8686

87-
#ifdef WITH_G4OPTICKS
88-
#include "G4Opticks.hh"
89-
#include "CGenstep.hh"
90-
#include "CTrack.hh"
91-
#include "CPhotonInfo.hh"
92-
#include "SLOG.hh"
93-
#endif
94-
95-
96-
97-
#ifdef WITH_G4OPTICKS
98-
//const plog::Severity Local_DsG4Scintillation::LEVEL = SLOG::EnvLevel("Local_DsG4Scintillation", "DEBUG") ;
99-
const plog::Severity Local_DsG4Scintillation::LEVEL = error ;
100-
#endif
101-
10287

10388
#include "U4Stack.h"
10489
#include "SEvt.hh"
@@ -582,35 +567,10 @@ Local_DsG4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep
582567

583568
}
584569

585-
//-------------------------------------------------//
586-
587-
#ifdef WITH_G4OPTICKS
588-
589-
CPho ancestor = CPhotonInfo::Get(&aTrack);
590-
int ancestor_id = ancestor.get_id() ;
591-
592-
593-
/**
594-
ancestor_id:-1
595-
normal case, meaning that aTrack was not a photon
596-
so the generation loop will yield "primary" photons
597-
with id : gs.offset + i
598-
599-
ancestor_id>-1
600-
aTrack is a photon that may be about to reemit (Num=0 or 1)
601-
ancestor_id is the absolute id of the primary parent photon,
602-
this id is retained thru any subsequent remission secondary generations
603-
**/
604-
605-
#endif
606-
607570
#ifdef STANDALONE
608571
U4::GenPhotonAncestor(&aTrack);
609572
#endif
610573

611-
612-
//-------------------------------------------------//
613-
614574
for(G4int scnt = 0 ; scnt < nscnt ; scnt++){
615575

616576
G4double ScintillationTime = 0.*ns;
@@ -639,18 +599,6 @@ Local_DsG4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep
639599

640600
G4int NumPhoton = NumVec[scnt] ;
641601

642-
643-
#ifdef WITH_G4OPTICKS
644-
if(flagReemission) assert( NumPhoton == 0 || NumPhoton == 1); // expecting only 0 or 1 remission photons
645-
bool is_opticks_genstep = NumPhoton > 0 && !flagReemission ;
646-
647-
CGenstep gs ;
648-
if(is_opticks_genstep && (m_opticksMode & 1))
649-
{
650-
gs = G4Opticks::Get()->collectGenstep_Local_DsG4Scintillation_r4695( &aTrack, &aStep, NumPhoton, scnt, ScintillationTime);
651-
}
652-
#endif
653-
654602
#ifdef STANDALONE
655603
if(flagReemission) assert( NumPhoton == 0 || NumPhoton == 1); // expecting only 0 or 1 remission photons
656604
bool is_opticks_genstep = NumPhoton > 0 && !flagReemission ;
@@ -665,9 +613,7 @@ Local_DsG4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep
665613
{
666614

667615
for(G4int i = 0 ; i < NumPhoton ; i++) {
668-
#ifdef WITH_G4OPTICKS
669-
G4Opticks::Get()->setAlignIndex( ancestor_id > -1 ? ancestor_id : gs.offset + i ); // aka photon_id
670-
#endif
616+
671617
#ifdef STANDALONE
672618
U4::GenPhotonBegin(i);
673619
#endif
@@ -845,11 +791,6 @@ Local_DsG4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep
845791
if ( verboseLevel > 0 ) {
846792
G4cout << " aSecondaryTrack->SetWeight( " << weight<< " ) ; aSecondaryTrack->GetWeight() = " << aSecondaryTrack->GetWeight() << G4endl;}
847793

848-
#ifdef WITH_G4OPTICKS
849-
aSecondaryTrack->SetUserInformation(CPhotonInfo::MakeScintillation(gs, i, ancestor ));
850-
G4Opticks::Get()->setAlignIndex(-1);
851-
#endif
852-
853794
#ifdef STANDALONE
854795
U4::GenPhotonEnd(i, aSecondaryTrack);
855796
#endif
@@ -876,55 +817,6 @@ Local_DsG4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep
876817
}
877818

878819

879-
880-
#ifdef WITH_G4OPTICKS
881-
G4MaterialPropertyVector* Local_DsG4Scintillation::getMaterialProperty(const char* name, G4int materialIndex)
882-
{
883-
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
884-
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
885-
assert( materialIndex < numOfMaterials );
886-
887-
G4Material* aMaterial = (*theMaterialTable)[materialIndex];
888-
G4MaterialPropertiesTable* aMaterialPropertiesTable = aMaterial->GetMaterialPropertiesTable();
889-
G4MaterialPropertyVector* prop = aMaterialPropertiesTable ? aMaterialPropertiesTable->GetProperty(name) : nullptr ;
890-
return prop ;
891-
}
892-
893-
G4PhysicsOrderedFreeVector* Local_DsG4Scintillation::getScintillationIntegral(G4int scnt, G4int materialIndex) const
894-
{
895-
G4PhysicsOrderedFreeVector* ScintillationIntegral = NULL;
896-
897-
if ( scnt == 0 ){
898-
ScintillationIntegral =
899-
(G4PhysicsOrderedFreeVector*)((*theFastIntegralTable)(materialIndex));
900-
}
901-
else{
902-
ScintillationIntegral =
903-
(G4PhysicsOrderedFreeVector*)((*theSlowIntegralTable)(materialIndex));
904-
}
905-
906-
return ScintillationIntegral ;
907-
}
908-
909-
910-
G4double Local_DsG4Scintillation::getSampledEnergy(G4int scnt, G4int materialIndex) const
911-
{
912-
G4PhysicsOrderedFreeVector* ScintillationIntegral = getScintillationIntegral(scnt, materialIndex);
913-
G4double CIIvalue = G4UniformRand()*ScintillationIntegral->GetMaxValue();
914-
G4double sampledEnergy = ScintillationIntegral->GetEnergy(CIIvalue);
915-
return sampledEnergy ;
916-
}
917-
918-
G4double Local_DsG4Scintillation::getSampledWavelength(G4int scnt, G4int materialIndex) const
919-
{
920-
G4double sampledEnergy = getSampledEnergy(scnt, materialIndex );
921-
G4double wavelength = h_Planck*c_light/sampledEnergy ;
922-
G4double wavelength_nm = wavelength/nm ;
923-
return wavelength_nm ;
924-
}
925-
#endif
926-
927-
928820
// BuildThePhysicsTable for the scintillation process
929821
// --------------------------------------------------
930822
//

u4/Local_DsG4Scintillation.hh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@
6969
#ifndef Local_DsG4Scintillation_h
7070
#define Local_DsG4Scintillation_h 1
7171

72-
73-
#ifdef WITH_G4OPTICKS
74-
#include "plog/Severity.h"
75-
#endif
76-
7772
#include "globals.hh"
7873
#include "templates.hh"
7974
#include "Randomize.hh"
@@ -111,11 +106,6 @@ class G4UIdirectory;
111106
class Local_DsG4Scintillation : public G4VRestDiscreteProcess, public G4UImessenger
112107
{ //too lazy to create another UImessenger class
113108

114-
private:
115-
#ifdef WITH_G4OPTICKS
116-
static const plog::Severity LEVEL ;
117-
#endif
118-
119109
public:
120110
static const bool FLOAT ;
121111
static const int PIDX ;
@@ -194,13 +184,6 @@ public: // With description
194184
void SetUseFastMu300nsTrick(const G4bool fastMu300nsTrick);
195185
G4bool GetUseFastMu300nsTrick() const;
196186

197-
#ifdef WITH_G4OPTICKS
198-
G4MaterialPropertyVector* getMaterialProperty(const char* name, G4int materialIndex) ;
199-
G4PhysicsOrderedFreeVector* getScintillationIntegral(G4int scnt, G4int materialIndex) const;
200-
G4double getSampledEnergy(G4int scnt, G4int materialIndex) const ;
201-
G4double getSampledWavelength(G4int scnt, G4int materialIndex) const ;
202-
#endif
203-
204187
void SetScintillationExcitationRatio(const G4double excitationratio);
205188
// Called to set the scintillation exciation ratio, needed when
206189
// the scintillation level excitation is different for different

0 commit comments

Comments
 (0)