File indexing completed on 2025-01-18 09:14:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "DDG4/Geant4SteppingAction.h"
0014
0015 #include <G4Step.hh>
0016 #include <G4TrackStatus.hh>
0017
0018
0019 namespace dd4hep {
0020
0021
0022 namespace sim {
0023
0024
0025
0026
0027
0028
0029
0030
0031 class TestSteppingAction : public Geant4SteppingAction {
0032 std::size_t m_calls_steps { 0UL };
0033 std::size_t m_calls_suspended { 0UL };
0034 std::size_t m_calls_kill { 0UL };
0035
0036 public:
0037
0038 TestSteppingAction(Geant4Context* context, const std::string& nam)
0039 : Geant4SteppingAction(context, nam)
0040 {
0041 }
0042
0043 virtual ~TestSteppingAction() {
0044 info("+++ Track Calls Steps: %ld", m_calls_steps);
0045 info("+++ Track Calls Suspended: %ld", m_calls_suspended);
0046 info("+++ Track Calls Killed: %ld", m_calls_kill);
0047 }
0048
0049 virtual void operator()(const G4Step* step, G4SteppingManager*) {
0050 if(m_calls_steps % 5 == 0 ) {
0051 ++m_calls_suspended;
0052 step->GetTrack()->SetTrackStatus(fSuspend);
0053 } else if((m_calls_steps + 1) % 30 == 0 ) {
0054 ++m_calls_kill;
0055 step->GetTrack()->SetTrackStatus(fStopAndKill);
0056 }
0057 ++m_calls_steps;
0058 }
0059 };
0060 }
0061 }
0062
0063 #include "DDG4/Factories.h"
0064 DECLARE_GEANT4ACTION_NS(dd4hep::sim,TestSteppingAction)