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 "DetectorConstruction.hh"
37 #include "Run.hh"
38 #include "HistoManager.hh"
39 
40 #include "G4RunManager.hh"
41 #include "G4Track.hh"
42 #include "G4HadronicProcessType.hh"
43 
44 #include "G4SystemOfUnits.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 :G4UserTrackingAction(), fDetector(det)
50 { }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {
56 
57  Run* run = static_cast<Run*>(
59 
60  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
61 
62  //which volume ?
63  //
64  G4LogicalVolume* lVolume = track->GetVolume()->GetLogicalVolume();
65  G4int iVol = 0;
66  if (lVolume == fDetector->GetLogicTarget()) iVol = 1;
67  if (lVolume == fDetector->GetLogicDetector()) iVol = 2;
68 
69  //secondary particles only
70  if (track->GetTrackID() == 1) return;
71 
72  const G4ParticleDefinition* particle = track->GetParticleDefinition();
73  G4String name = particle->GetParticleName();
74  G4int pid = particle->GetPDGEncoding();
75  G4int Z = particle->GetAtomicNumber();
76  G4int A = particle->GetAtomicMass();
77  G4double charge = particle->GetPDGCharge();
78  G4double energy = track->GetKineticEnergy();
79  G4double time = track->GetGlobalTime();
80  G4double weight = track->GetWeight();
81 
82  run->ParticleCount(name,energy,iVol);
83 
84  //Radioactive decay products
85  G4int processType = track->GetCreatorProcess()->GetProcessSubType();
86  if (processType == fRadioactiveDecay) {
87  //fill ntuple id = 3
88  G4int id = 3;
89  analysisManager->FillNtupleDColumn(id,0, double(pid));
90  analysisManager->FillNtupleDColumn(id,1, double(Z));
91  analysisManager->FillNtupleDColumn(id,2, double(A));
92  analysisManager->FillNtupleDColumn(id,3, energy);
93  analysisManager->FillNtupleDColumn(id,4, time/s);
94  analysisManager->FillNtupleDColumn(id,5, weight);
95  analysisManager->AddNtupleRow(id);
96 
97  if (charge < 3.) {
98  //fill ntuple id = 0
99  id = 0;
100  analysisManager->FillNtupleDColumn(id,0, double(pid));
101  analysisManager->FillNtupleDColumn(id,1, energy);
102  analysisManager->FillNtupleDColumn(id,2, time/s);
103  analysisManager->FillNtupleDColumn(id,3, weight);
104  analysisManager->AddNtupleRow(id);
105 
106  analysisManager->FillH1(6, energy, weight);
107  }
108  }
109 
110  //all unstable ions produced in target
111  G4bool unstableIon = ((charge > 2.) && !(particle->GetPDGStable()));
112  if ((unstableIon) && (iVol == 1)) {
113  //fill ntuple id = 1
114  G4int id = 1;
115  analysisManager->FillNtupleDColumn(id,0, double(pid));
116  analysisManager->FillNtupleDColumn(id,1, time/s);
117  analysisManager->FillNtupleDColumn(id,2, weight);
118  analysisManager->AddNtupleRow(id);
119  }
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125 { }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128 
const XML_Char * name
Definition: expat.h:151
G4LogicalVolume * GetLogicTarget()
G4bool GetPDGStable() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4int GetAtomicNumber() const
const XML_Char * s
Definition: expat.h:262
const G4VProcess * GetCreatorProcess() const
G4double GetKineticEnergy() const
double A(double temperature)
void PreUserTrackingAction(const G4Track *)
bool G4bool
Definition: G4Types.hh:79
const G4ParticleDefinition * GetParticleDefinition() const
G4int GetTrackID() const
G4double GetGlobalTime() const
void PostUserTrackingAction(const G4Track *)
G4int GetAtomicMass() const
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4LogicalVolume * GetLogicalVolume() const
G4double energy(const ThreeVector &p, const G4double m)
G4VPhysicalVolume * GetVolume() const
G4double GetWeight() const
Detector construction class to define materials and geometry.
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double GetPDGCharge() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4int GetProcessSubType() const
Definition: G4VProcess.hh:426
G4Run * GetNonConstCurrentRun() const
G4LogicalVolume * GetLogicDetector()
void ParticleCount(G4String, G4double)
Definition: Run.cc:114