G4XTankSteppingAction.cc
Go to the documentation of this file.
3 #include "G4XTankSimulator.h"
4 
5 #include <G4Step.hh>
6 
7 #include <G4VProcess.hh>
8 #include <sstream>
9 
10 using namespace G4XTankSimulatorAG;
11 using namespace std;
12 
14 
16 {
17 }
18 
20 {
21 }
22 
23 void G4XTankSteppingAction::UserSteppingAction(const G4Step *theStep) {
24 
25  fgParticleId = theStep->GetTrack()->GetDefinition()->GetPDGEncoding();
26 
27  if (fgParticleId == 0) {
28 
29  if (theStep->GetTrack()->GetNextVolume() != 0) {
30 
31  if (theStep->GetTrack()->GetNextVolume()->GetName() == "top" ||
32  theStep->GetTrack()->GetNextVolume()->GetName() == "side" ||
33  theStep->GetTrack()->GetNextVolume()->GetName() == "bottom") {
34 
36 
37  }
38  }
39  }
40 
41 
42 
43  // Particle data must be taken when they reach the muon counter's depth
44 
45  G4Track * theTrack = theStep->GetTrack ( );
46 
47  G4StepPoint * thePostPoint = theStep->GetPostStepPoint ( );
48  //G4VPhysicalVolume * thePostPV = thePostPoint->GetPhysicalVolume ( );
49  G4ParticleDefinition * particleType = theTrack->GetDefinition ( );
50 
51 
52  G4String process = "Undefined";
53  if ( thePostPoint->GetProcessDefinedStep() != NULL)
54  process = thePostPoint->GetProcessDefinedStep()->GetProcessName();
55 
56  G4double x = theStep->GetPostStepPoint()->GetPosition().x();
57  G4double y = theStep->GetPostStepPoint()->GetPosition().y();
58  G4double z = theStep->GetPostStepPoint()->GetPosition().z();
59  G4double z0 = theStep->GetPreStepPoint()->GetPosition().z();
60  G4VPhysicalVolume *thePrePV = theStep->GetPreStepPoint ( )->GetPhysicalVolume ( );
61  string prePVName = string (thePrePV->GetName());
62  string postPVName = "OutOfWorld";
63 
64  // Check if the particle entered the ground level
65  if( prePVName == "ground"){
66 
67  // Convert the depth to milimeters
68  double depth = fCounterDepth*CLHEP::mm;
69 
70  // Check if the particle reached the counter's depth
71  // The last condition (z > depth*2) is to avoid problems with neutrinos
72  if(z <= depth && z0 > depth && z > depth*2) {
73 
74  G4int trackid = theTrack->GetTrackID();
75 
76 /*
77  G4cerr << "\n===========================================\n";
78  G4cerr << " NEW PARTICLE ARRIVED TO COUNTER DEPTH of " << depth << " mm !!!! \n";
79  G4cerr << particleType->GetParticleName() << G4endl;
80  G4cerr << particleType->GetParticleName() << G4endl;
81  G4cerr << "PDG code: " << particleType->GetPDGEncoding() << G4endl;
82  G4cerr << "prePV: " << prePVName << G4endl;
83  G4cerr << "trackID " << trackid << G4endl;
84  G4cerr << "X:" << x/CLHEP::m << " m" << G4endl;
85  G4cerr << "Y:" << y/CLHEP::m << " m" << G4endl;
86  G4cerr << "Z:" << z/CLHEP::m << " m" << G4endl;
87  G4cerr << "===========================================\n";
88 */
89  fPData.Pname = particleType->GetParticleName();
90  fPData.PDGCode = particleType->GetPDGEncoding();
91  fPData.TrackID = trackid;
92  fPData.x = x;
93  fPData.y = y;
94  fPData.z = z;
95  fPData.px = theStep->GetPreStepPoint()->GetMomentumDirection().x();
96  fPData.py = theStep->GetPreStepPoint()->GetMomentumDirection().y();
97  fPData.pz = theStep->GetPreStepPoint()->GetMomentumDirection().z();
98  fPData.KinE = theStep->GetPreStepPoint()->GetKineticEnergy();
99  fPData.Time = theStep->GetPreStepPoint()->GetGlobalTime();
100 
101  fPartColl.push_back( fPData );
102 
103  }
104 
105  }
106 
107 
108 
109 }
constexpr double mm
Definition: AugerUnits.h:113

, generated on Tue Sep 26 2023.