Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 // $Id: TrackingAction.cc 69099 2013-04-18 12:25:19Z maire $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "TrackingAction.hh"
35 
36 #include "Run.hh"
37 #include "EventAction.hh"
38 #include "HistoManager.hh"
39 
40 #include "G4RunManager.hh"
41 #include "G4Track.hh"
42 #include "G4StepStatus.hh"
43 #include "G4ParticleTypes.hh"
44 
45 #include "G4SystemOfUnits.hh"
46 #include "G4UnitsTable.hh"
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
51 :G4UserTrackingAction(), fEventAction(event)
52 { }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 {
58  //count secondary particles
59  if (track->GetTrackID() == 1) return;
61  G4double energy = track->GetKineticEnergy();
62  Run* run = static_cast<Run*>(
64  run->ParticleCount(name,energy);
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 {
71  // keep only outgoing particle
72  G4StepStatus status = track->GetStep()->GetPostStepPoint()->GetStepStatus();
73  if (status != fWorldBoundary) return;
74 
75  const G4ParticleDefinition* particle = track->GetParticleDefinition();
76  G4String name = particle->GetParticleName();
77  G4double energy = track->GetKineticEnergy();
78 
79  fEventAction->AddEflow(energy);
80 
81  Run* run = static_cast<Run*>(
83  run->ParticleFlux(name,energy);
84 
85  // histograms: enery flow
86  //
87  G4AnalysisManager* analysis = G4AnalysisManager::Instance();
88 
89  G4int ih = 0;
90  G4String type = particle->GetParticleType();
91  G4double charge = particle->GetPDGCharge();
92  if (charge > 3.) ih = 10;
93  else if (particle == G4Gamma::Gamma()) ih = 4;
94  else if (particle == G4Electron::Electron()) ih = 5;
95  else if (particle == G4Positron::Positron()) ih = 5;
96  else if (particle == G4Neutron::Neutron()) ih = 6;
97  else if (particle == G4Proton::Proton()) ih = 7;
98  else if (particle == G4Deuteron::Deuteron()) ih = 8;
99  else if (particle == G4Alpha::Alpha()) ih = 9;
100  else if (type == "nucleus") ih = 10;
101  else if (type == "baryon") ih = 11;
102  else if (type == "meson") ih = 12;
103  else if (type == "lepton") ih = 13;
104  if (ih > 0) analysis->FillH1(ih,energy);
105 }
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 
void AddEflow(G4double Eflow)
Definition: EventAction.cc:73
G4ParticleDefinition * GetDefinition() const
const XML_Char * name
Definition: expat.h:151
G4StepStatus GetStepStatus() const
void ParticleFlux(G4String, G4double)
Definition: Run.cc:116
Event action class.
Definition: EventAction.hh:45
const G4Step * GetStep() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4StepStatus
Definition: G4StepStatus.hh:49
G4double GetKineticEnergy() const
void PreUserTrackingAction(const G4Track *)
const G4ParticleDefinition * GetParticleDefinition() const
static G4Proton * Proton()
Definition: G4Proton.cc:93
const G4String & GetParticleType() const
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
G4int GetTrackID() const
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
void PostUserTrackingAction(const G4Track *)
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:94
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static G4Positron * Positron()
Definition: G4Positron.cc:94
G4double energy(const ThreeVector &p, const G4double m)
G4StepPoint * GetPostStepPoint() const
static G4Electron * Electron()
Definition: G4Electron.cc:94
static G4Alpha * Alpha()
Definition: G4Alpha.cc:89
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double GetPDGCharge() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const
void ParticleCount(G4String, G4double)
Definition: Run.cc:114