actions
Loading...
Searching...
No Matches
gSteppingAction.cc
Go to the documentation of this file.
1#include "gSteppingAction.h"
3
4// Geant4
5#include "G4OpticalPhoton.hh"
6#include "G4Step.hh"
7#include "G4Track.hh"
8
9void GSteppingAction::UserSteppingAction(const G4Step* step) {
10 G4Track* track = step->GetTrack();
11
12 // Optical photons rarely take more than ~20 steps in Cherenkov detectors; a photon
13 // exceeding this is trapped (e.g. total internal reflection in a volume with no
14 // absorption length) and would step forever.
15 if (track->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition() &&
16 track->GetCurrentStepNumber() > MAX_OPTICAL_PHOTON_STEPS) {
17 track->SetTrackStatus(fStopAndKill);
18 return;
19 }
20
21 // A track can get stuck in a magnetic field stepping loop.
22 if (track->GetCurrentStepNumber() > MAX_TRACK_STEPS) {
23 track->SetTrackStatus(fStopAndKill);
24 return;
25 }
26
27 // Anything touching Kryptonite is killed.
28 static const G4String kryptonite = KRYPTONITE_KILL_MATERIAL;
29 if (track->GetMaterial()->GetName() == kryptonite) {
30 track->SetTrackStatus(fStopAndKill);
31 }
32}
void UserSteppingAction(const G4Step *step) override
Defines error codes used by the GEMC actions module.
#define KRYPTONITE_KILL_MATERIAL
Must match KRYPTONITE_MATERIAL in g4system/g4systemConventions.h.
#define MAX_OPTICAL_PHOTON_STEPS
#define MAX_TRACK_STEPS