9 #include <simulation/kernel/SteppingAction.h>
10 #include <simulation/kernel/UserInfo.h>
11 #include <framework/logging/Logger.h>
12 #include <framework/gearbox/Unit.h>
14 #include <G4UnitsTable.hh>
19 using namespace Simulation;
40 G4Track* track = step->GetTrack();
45 if (track->GetVolume() == NULL) {
46 B2WARNING(
"SteppingAction: Track in NULL volume, terminating!\n"
47 <<
"step_no=" << track->GetCurrentStepNumber() <<
" type=" << track->GetDefinition()->GetParticleName()
48 <<
"\n position=" << G4BestUnit(track->GetPosition(),
"Length") <<
" momentum=" << G4BestUnit(track->GetMomentum(),
"Energy"));
49 track->SetTrackStatus(fStopAndKill);
57 const G4ThreeVector stepPrePos = step->GetPreStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
58 const G4ThreeVector stepPostPos = step->GetPostStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
59 if (stepPrePos.perp() < (rAbsorber *
Unit::cm) && stepPostPos.perp() > (rAbsorber *
Unit::cm)) {
63 track->SetTrackStatus(fStopAndKill);
72 B2WARNING(
"SteppingAction: Too many steps for this track, terminating!\n"
73 <<
"step_no=" << track->GetCurrentStepNumber() <<
"type=" << track->GetDefinition()->GetParticleName()
74 <<
"\n position=" << G4BestUnit(track->GetPosition(),
"Length") <<
" momentum=" << G4BestUnit(track->GetMomentum(),
"Energy"));
75 track->SetTrackStatus(fStopAndKill);
84 if (info && info->getTrajectory()) {
86 if (trajectory.
empty()) {
87 const G4ThreeVector stepPos = step->GetPreStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
88 const G4ThreeVector stepMom = step->GetPreStepPoint()->GetMomentum() / CLHEP::MeV *
Unit::MeV;
90 stepPos.x(), stepPos.y(), stepPos.z(),
91 stepMom.x(), stepMom.y(), stepMom.z()
94 const G4ThreeVector stepPos = step->GetPostStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
95 const G4ThreeVector stepMom = step->GetPostStepPoint()->GetMomentum() / CLHEP::MeV *
Unit::MeV;
97 stepPos.x(), stepPos.y(), stepPos.z(),
98 stepMom.x(), stepMom.y(), stepMom.z()
Class to save the full simulated trajectory of a particle.
void addPoint(float x, float y, float z, float px, float py, float pz)
Add a point to the trajectory.
bool empty() const
return true if size()==0
std::vector< float > m_absorbers
The absorbers defined at given radii where tracks across them will be destroyed.
virtual void UserSteppingAction(const G4Step *step)
The method will be called at each step during simulation.
virtual ~SteppingAction()
Destructor.
int m_maxNumberSteps
The maximum number of steps before the track transportation is stopped and the track is killed.
SteppingAction()
Constructor.
bool m_storeTrajectories
if true, check if the track has attached trajectory info and append step information if necessary
UserInfo class which is used to attach additional information to Geant4 particles and tracks.
static const double mm
[millimeters]
static const double MeV
[megaelectronvolt]
static const double cm
Standard units with the value = 1.
Abstract base class for different kinds of events.