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 //
26 // $Id: TrackingAction.cc 81501 2014-05-31 13:51:51Z ldesorgh $
27 //
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "TrackingAction.hh"
35 #include "HistoManager.hh"
36 
37 #include "G4Track.hh"
38 #include "G4SystemOfUnits.hh"
39 #include "G4PhysicalConstants.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42 
45 { }
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
48 
50 {
51  G4int pid = track->GetDynamicParticle()->GetPDGcode();
52  G4double ekin = track->GetKineticEnergy();
53  G4ThreeVector vertex = track->GetPosition();
54  G4ThreeVector direction = track->GetMomentumDirection();
55  G4double weight = track->GetWeight();
56 
57  G4double x = vertex.x(), y = vertex.y(), z = vertex.z();
58  G4double theta = direction.theta(), phi = direction.phi();
59  if (phi < 0.) phi += twopi;
60  G4double cost = std::cos(theta);
61 
62  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
63 
64  G4double r = vertex.mag();
65  G4double dr = analysisManager->GetH1Width(2);
66  G4double dv = 2*twopi*r*r*dr;
67 
68  // fill histograms
69  analysisManager->FillH1(1,ekin);
70  if (dv > 0.) analysisManager->FillH1(2, r, 1./dv);
71  analysisManager->FillH1(3,cost);
72  analysisManager->FillH1(4,phi);
73  analysisManager->FillH2(1,x,y);
74  analysisManager->FillH2(2,y,z);
75  analysisManager->FillH2(3,z,x);
76  analysisManager->FillH2(4,phi,cost);
77  analysisManager->FillH2(5,phi,theta);
78 
79  // fill ntuple
80  analysisManager->FillNtupleIColumn(0,pid);
81  analysisManager->FillNtupleDColumn(1,ekin);
82  analysisManager->FillNtupleDColumn(2,x);
83  analysisManager->FillNtupleDColumn(3,y);
84  analysisManager->FillNtupleDColumn(4,z);
85  analysisManager->FillNtupleDColumn(5,theta);
86  analysisManager->FillNtupleDColumn(6,phi);
87  analysisManager->FillNtupleDColumn(7,weight);
88  analysisManager->AddNtupleRow();
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
92 
93 
94 
95 
96 
97 
double x() const
const G4DynamicParticle * GetDynamicParticle() const
G4int GetPDGcode() const
const G4ThreeVector & GetPosition() const
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
double z() const
static constexpr double twopi
Definition: G4SIunits.hh:76
G4double GetKineticEnergy() const
void PreUserTrackingAction(const G4Track *)
double phi() const
double theta() const
const G4ThreeVector & GetMomentumDirection() const
double y() const
tuple z
Definition: test.py:28
G4double GetWeight() const
double G4double
Definition: G4Types.hh:76
double mag() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77