#include "SteppingAction.hh" #include "G4Step.hh" #include "G4Track.hh" SteppingAction::SteppingAction() : G4UserSteppingAction(), fNumGammaPhotons(0) {} SteppingAction::~SteppingAction() {} void SteppingAction::UserSteppingAction(const G4Step* step) { // Check if the particle is a gamma photon and its parent ID is 1 if (step->GetTrack()->GetDefinition()->GetParticleName() == "gamma" && step->GetTrack()->GetParentID() == 0) { // Increment the count of gamma photons reaching the detector fNumGammaPhotons++; } // Kill all secondaries if (step->GetTrack()->GetParentID() != 0) { step->GetTrack()->SetTrackStatus(fStopAndKill); } }