Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:55

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //==========================================================================
0011 
0012 // Framework include files
0013 #include "DDG4/Geant4SteppingAction.h"
0014 
0015 #include <G4Step.hh>
0016 #include <G4TrackStatus.hh>
0017 
0018 /// Namespace for the AIDA detector description toolkit
0019 namespace dd4hep {
0020 
0021   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0022   namespace sim {
0023     
0024     /// Class to count steps and suspend tracks every 5 steps
0025     /** Class to count steps and suspens tracks every 5 steps
0026      * Count steps and suspend
0027      *
0028      *  \version 1.0
0029      *  \ingroup DD4HEP_SIMULATION
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       /// Standard constructor
0038       TestSteppingAction(Geant4Context* context, const std::string& nam)
0039     : Geant4SteppingAction(context, nam) 
0040       {
0041       }
0042       /// Default destructor
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       /// stepping callback
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   }    // End namespace sim
0061 }      // End namespace dd4hep
0062 
0063 #include "DDG4/Factories.h"
0064 DECLARE_GEANT4ACTION_NS(dd4hep::sim,TestSteppingAction)