MdGroundPropagatorAG/SteppingAction.cc
Go to the documentation of this file.
1 #include "SteppingAction.h"
2 
3 #include <fwk/CentralConfig.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/Reader.h>
6 #include <utl/MathConstants.h>
7 
8 //G4 classes
9 #include <G4SteppingManager.hh>
10 #include <G4Track.hh>
11 #include <G4Step.hh>
12 #include <G4StepPoint.hh>
13 #include <G4TrackStatus.hh>
14 #include <G4VPhysicalVolume.hh>
15 #include <G4ParticleDefinition.hh>
16 #include <G4ParticleTypes.hh>
17 
18 #include <string>
19 using std::string;
20 
21 using namespace fwk;
22 using namespace utl;
23 using namespace GroundPropagatorAG;
24 
25 SteppingAction::SteppingAction ( double depth ){
26 fDepth = depth;
27 }
28 
29 SteppingAction::~SteppingAction ( ){;}
30 
31 void SteppingAction::UserSteppingAction ( const G4Step * theStep )
32 {
33 
34  G4Track * theTrack = theStep->GetTrack ( );
35 
36  G4StepPoint * thePostPoint = theStep->GetPostStepPoint ( );
37  G4VPhysicalVolume * thePostPV = thePostPoint->GetPhysicalVolume ( );
38  G4ParticleDefinition * particleType = theTrack->GetDefinition ( );
39 
40  G4String process = "Undefined";
41  if ( thePostPoint->GetProcessDefinedStep() != NULL)
42  process = thePostPoint->GetProcessDefinedStep()->GetProcessName();
43 
44  if ( !thePostPV ) {//the post step volume is out of the world
45 
46  G4double x = theStep->GetPostStepPoint()->GetPosition().x();
47  G4double y = theStep->GetPostStepPoint()->GetPosition().y();
48  G4double z = theStep->GetPostStepPoint()->GetPosition().z();
49  G4VPhysicalVolume *thePrePV = theStep->GetPreStepPoint ( )->GetPhysicalVolume ( );
50  string prePVName = string (thePrePV->GetName());
51  string postPVName = "OutOfWorld";
52 
53  //Check if it a particle entering the counter level
54  if( prePVName == "SoilPhys"&& fabs(fDepth+z)< 1e-5 ) {
55  G4int trackid = theTrack->GetTrackID();
56  /*
57  G4cerr << "\n===========================================\n";
58  G4cerr << " NEW PARTICLE ARRIVED TO COUNTER DEPTH!!!! \n";
59  G4cerr << particleType->GetParticleName() << G4endl;
60  G4cerr << "PDG code: " << particleType->GetPDGEncoding() << G4endl;
61  G4cerr << "prePV: " << prePVName << G4endl;
62  G4cerr << "trackID " << trackid << G4endl;
63  G4cerr << "fDepth " << fDepth/CLHEP::m << " (m)" << std::endl;
64  G4cerr << "X:" << x/CLHEP::m << " m" << G4endl;
65  G4cerr << "Y:" << y/CLHEP::m << " m" << G4endl;
66  G4cerr << "Z:" << z/CLHEP::m << " m" << G4endl;
67  G4cerr << "===========================================\n";
68  */
69  fPData.Pname = particleType->GetParticleName();
70  fPData.PDGCode = particleType->GetPDGEncoding();
71  fPData.TrackID = trackid;
72  fPData.x = x;
73  fPData.y = y;
74  fPData.z = z;
75  fPData.px = theStep->GetPreStepPoint()->GetMomentumDirection().x();
76  fPData.py = theStep->GetPreStepPoint()->GetMomentumDirection().y();
77  fPData.pz = theStep->GetPreStepPoint()->GetMomentumDirection().z();
78  fPData.KinE = theStep->GetPreStepPoint()->GetKineticEnergy();
79  fPData.Time = theStep->GetPreStepPoint()->GetGlobalTime();
80 
81  fPartColl.push_back( fPData );
82 
83  }
84  return;//out of world
85  }
86 
87  return;
88 
89 }

, generated on Tue Sep 26 2023.