Geant4  10.03.p03
 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 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 #include "G4Positron.hh"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
47  fPrimary(prim)
48 {}
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 {
54  G4int trackID = track->GetTrackID();
55  if (trackID == 1) fTrackLength = 0;
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  // histograms
63  //
64  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
65 
66  G4int trackID = track->GetTrackID();
67 
68  Run* run
70 
71  //
72 
73  G4double tracklen = track->GetTrackLength();
74 
75  // *** FOR ELECTRONS
76 
77  //track length of primary particle or charged secondaries
78  //
79  if (trackID == 1 && track->GetDefinition()->GetPDGCharge() == -1)
80  {
81  run->AddTrackLength(tracklen);
82  analysisManager->FillH1(1, tracklen);
83  } ;
84 
85  //extract projected range of primary particle
86  //
87  if (trackID == 1 && track->GetDefinition()->GetPDGCharge() == -1)
88  {
89  G4double pr = (track->GetPosition())*
91  run->AddProjRange(pr);
92  analysisManager->FillH1(2, pr);
93  }
94 
95  //extract penetration range of primary particle
96  //
97  if (trackID == 1 && track->GetDefinition()->GetPDGCharge() == -1)
98  {
99  G4double pene = std::sqrt((track->GetPosition())*(track->GetPosition()));
100  run->AddPenetration(pene);
101  analysisManager->FillH1(3, pene);
102  };
103 
104  // *** FOR Geant4-DNA PROTONS, ALPHA AND CHARGED STATES AND IONS
105  // track->GetDefinition()->GetPDGMass() > 0 avoids gammas
106 
107  //track length of primary particle or charged secondaries
108  //
109 
110  if (track->GetDefinition()->GetPDGCharge() >= 0
111  && track->GetDefinition()->GetPDGMass() > 0
113  )
114  {
115  //local cumulation is required before scoring once
116  fTrackLength = fTrackLength + tracklen;
117 
118  if (track->GetKineticEnergy()==0)
119  {
120  run->AddTrackLength(fTrackLength);
121  analysisManager->FillH1(1, fTrackLength);
122  }
123  }
124 
125  //extract projected range of primary particle
126  //
127 
128  if (track->GetDefinition()->GetPDGCharge() >= 0
129  && track->GetDefinition()->GetPDGMass() > 0
131  )
132  {
133  G4double pr = (track->GetPosition())*
135 
136  if (track->GetKineticEnergy()==0)
137  {
138  run->AddProjRange(pr);
139  analysisManager->FillH1(2, pr);
140  }
141  }
142 
143  //extract penetration range of primary particle
144  //
145  if (track->GetDefinition()->GetPDGCharge() >= 0
146  && track->GetDefinition()->GetPDGMass() > 0
148  )
149  {
150  G4double pene = std::sqrt((track->GetPosition())*(track->GetPosition()));
151 
152  if (track->GetKineticEnergy()==0)
153  {
154  run->AddPenetration(pene);
155  analysisManager->FillH1(3, pene);
156  }
157  };
158 
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
The primary generator action class with particle gun.
G4ParticleDefinition * GetDefinition() const
const G4ThreeVector & GetPosition() const
int G4int
Definition: G4Types.hh:78
G4ParticleMomentum GetParticleMomentumDirection() const
G4double GetKineticEnergy() const
void PreUserTrackingAction(const G4Track *)
G4int GetTrackID() const
void PostUserTrackingAction(const G4Track *)
G4double GetTrackLength() const
static G4Positron * PositronDefinition()
Definition: G4Positron.cc:89
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:102
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double GetPDGCharge() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const
void AddProjRange(G4double x)
Definition: Run.hh:63