File indexing completed on 2026-09-22 08:09:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "TrackingAction.hh"
0030
0031 #include "EventAction.hh"
0032 #include "HistoManager.hh"
0033 #include "Run.hh"
0034
0035 #include "G4ParticleTypes.hh"
0036 #include "G4RunManager.hh"
0037 #include "G4StepStatus.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4Track.hh"
0040 #include "G4UnitsTable.hh"
0041
0042
0043
0044 TrackingAction::TrackingAction(EventAction* event) : fEventAction(event) {}
0045
0046
0047
0048 void TrackingAction::PreUserTrackingAction(const G4Track* track)
0049 {
0050
0051 if (track->GetTrackID() == 1) return;
0052
0053 Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0054
0055 G4String name = track->GetDefinition()->GetParticleName();
0056 G4double meanLife = track->GetDefinition()->GetPDGLifeTime();
0057 G4double energy = track->GetKineticEnergy();
0058 if (meanLife != 0) run->ParticleCount(name, energy, meanLife);
0059 }
0060
0061
0062
0063 void TrackingAction::PostUserTrackingAction(const G4Track* track)
0064 {
0065
0066 G4StepStatus status = track->GetStep()->GetPostStepPoint()->GetStepStatus();
0067 if (status != fWorldBoundary) return;
0068
0069 const G4ParticleDefinition* particle = track->GetParticleDefinition();
0070 G4String name = particle->GetParticleName();
0071 G4double energy = track->GetKineticEnergy();
0072
0073 fEventAction->AddEflow(energy);
0074
0075 Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0076 run->ParticleFlux(name, energy);
0077
0078
0079
0080 G4AnalysisManager* analysis = G4AnalysisManager::Instance();
0081
0082 G4int ih = 0;
0083 G4String type = particle->GetParticleType();
0084 G4double charge = particle->GetPDGCharge();
0085 if (charge > 3.)
0086 ih = 10;
0087 else if (particle == G4Gamma::Gamma())
0088 ih = 4;
0089 else if (particle == G4Electron::Electron())
0090 ih = 5;
0091 else if (particle == G4Positron::Positron())
0092 ih = 5;
0093 else if (particle == G4Neutron::Neutron())
0094 ih = 6;
0095 else if (particle == G4Proton::Proton())
0096 ih = 7;
0097 else if (particle == G4Deuteron::Deuteron())
0098 ih = 8;
0099 else if (particle == G4Alpha::Alpha())
0100 ih = 9;
0101 else if (type == "nucleus")
0102 ih = 10;
0103 else if (type == "baryon")
0104 ih = 11;
0105 else if (type == "meson")
0106 ih = 12;
0107 else if (type == "lepton")
0108 ih = 13;
0109 if (ih > 0) analysis->FillH1(ih, energy);
0110 }
0111
0112