Geant4  10.02.p01
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 78723 2014-01-20 10:32:17Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "TrackingAction.hh"
35 
36 #include "Run.hh"
37 #include "PrimaryGeneratorAction.hh"
38 #include "HistoManager.hh"
39 
40 #include "G4RunManager.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
46  fPrimary(prim)
47 {}
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
52 {
53  G4int trackID = track->GetTrackID();
54  if (trackID == 1) fTrackLength = 0;
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61  // histograms
62  //
63  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
64 
65  G4int trackID = track->GetTrackID();
66 
67  Run* run
69 
70  //
71 
72  G4double tracklen = track->GetTrackLength();
73 
74  // *** FOR ELECTRONS
75 
76  //track length of primary particle or charged secondaries
77  //
78  if (trackID == 1 && track->GetDefinition()->GetPDGCharge() == -1)
79  {
80  run->AddTrackLength(tracklen);
81  analysisManager->FillH1(1, tracklen);
82  } ;
83 
84  //extract projected range of primary particle
85  //
86  if (trackID == 1 && track->GetDefinition()->GetPDGCharge() == -1)
87  {
88  G4double pr = (track->GetPosition())*
90  run->AddProjRange(pr);
91  analysisManager->FillH1(2, pr);
92  }
93 
94  //extract penetration range of primary particle
95  //
96  if (trackID == 1 && track->GetDefinition()->GetPDGCharge() == -1)
97  {
98  G4double pene = std::sqrt((track->GetPosition())*(track->GetPosition()));
99  run->AddPenetration(pene);
100  analysisManager->FillH1(3, pene);
101  };
102 
103  // *** FOR Geant4-DNA PROTONS, ALPHA AND CHARGED STATES AND IONS
104  // track->GetDefinition()->GetPDGMass() > 0 avoids gammas
105 
106  //track length of primary particle or charged secondaries
107  //
108 
109  if (track->GetDefinition()->GetPDGCharge() >= 0
110  && track->GetDefinition()->GetPDGMass() > 0)
111  {
112  //local cumulation is required before scoring once
113  fTrackLength = fTrackLength + tracklen;
114 
115  if (track->GetKineticEnergy()==0)
116  {
118  analysisManager->FillH1(1, fTrackLength);
119  }
120  }
121 
122  //extract projected range of primary particle
123  //
124 
125  if (track->GetDefinition()->GetPDGCharge() >= 0
126  && track->GetDefinition()->GetPDGMass() > 0)
127  {
128  G4double pr = (track->GetPosition())*
130 
131  if (track->GetKineticEnergy()==0)
132  {
133  run->AddProjRange(pr);
134  analysisManager->FillH1(2, pr);
135  }
136  }
137 
138  //extract penetration range of primary particle
139  //
140  if (track->GetDefinition()->GetPDGCharge() >= 0
141  && track->GetDefinition()->GetPDGMass() > 0)
142  {
143  G4double pene = std::sqrt((track->GetPosition())*(track->GetPosition()));
144 
145  if (track->GetKineticEnergy()==0)
146  {
147  run->AddPenetration(pene);
148  analysisManager->FillH1(3, pene);
149  }
150  };
151 
152 }
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction class.
G4ParticleDefinition * GetDefinition() const
PrimaryGeneratorAction * fPrimary
const G4ThreeVector & GetPosition() const
G4double fTrackLength
int G4int
Definition: G4Types.hh:78
G4ParticleMomentum GetParticleMomentumDirection() const
G4double GetKineticEnergy() const
void PreUserTrackingAction(const G4Track *)
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
G4int GetTrackID() const
void PostUserTrackingAction(const G4Track *)
G4double GetTrackLength() const
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4double GetPDGMass() const
G4ParticleGun * GetParticleGun()
void AddPenetration(G4double x)
Definition: Run.cc:97
void AddTrackLength(G4double t)
Definition: Run.cc:88
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double GetPDGCharge() const
G4Run * GetNonConstCurrentRun() const
void AddProjRange(G4double x)
Definition: Run.hh:63