SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
StepPrinter.cc
Go to the documentation of this file.
1 //~~~ SLIC ~~~//
2 #include "StepPrinter.hh"
3 
4 namespace slic {
5 
6 void StepPrinter::stepping(const G4Step *step) {
7  // Get the track associated with this step
8  auto track{step->GetTrack()};
9 
10  auto trackID{track->GetTrackID()};
11  if ((trackID_ > 0) && (trackID != trackID_)) return;
12 
13  // Get the particle name.
14  auto particleName{track->GetParticleDefinition()->GetParticleName()};
15 
16  // Get the energy of the particle
17  auto energy{step->GetPostStepPoint()->GetTotalEnergy()};
18 
19  // Get the volume the particle is in.
20  auto volume{track->GetVolume()->GetName()};
21 
22  // Get the next volume
23  auto nextVolume{track->GetNextVolume()->GetName()};
24 
25  // Get the region
26  auto region{track->GetVolume()->GetLogicalVolume()->GetRegion()->GetName()};
27 
28  std::cout << "*******************************\n"
29  << "* Step " << track->GetCurrentStepNumber() << "\n"
30  << "********************************\n"
31  << "\tEnergy of " << particleName << " : " << energy << "\n"
32  << "\tTrack ID: " << track->GetTrackID() << "\n"
33  << "\tStep #: " << track->GetCurrentStepNumber() << "\n"
34  << "\tParticle currently in " << volume << "\n"
35  << "\tRegion: " << region << "\n"
36  << "\tNext volume: " << nextVolume << "\n"
37  << "********************************\n"
38  << std::endl;
39 }
40 } // namespace slic
41 
42 DECLARE_PLUGIN(slic, StepPrinter)
#define DECLARE_PLUGIN(NS, NAME)
int trackID_
The track ID to filter on.
Definition: StepPrinter.hh:40
void stepping(const G4Step *step) final override
Definition: StepPrinter.cc:6
@ endl
Definition: LogStream.hh:26