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 //
30 // $Id: TrackingAction.cc 88035 2015-01-26 10:22:08Z gcosmo $
31 //
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "TrackingAction.hh"
36 
37 #include "DetectorConstruction.hh"
38 #include "Run.hh"
39 #include "HistoManager.hh"
40 
41 #include "G4Track.hh"
42 #include "G4PhysicalConstants.hh"
43 #include "G4SystemOfUnits.hh"
44 #include "G4RunManager.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 :fDetector(DET)
50 {
51  fZend = 0.5*(fDetector->GetThicknessWorld());
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 { }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
64 
65  G4double charge = track->GetDefinition()->GetPDGCharge();
67  G4ThreeVector direction = track->GetMomentumDirection();
68 
69  if (charge == 0.0) return;
70  if (position.z() < fZend) return;
71  if (direction.z() <= 0.) return;
72 
73  G4double rmin, dr, ds;
74  G4int ih = 1;
75 
76  //projected angle at exit
77 
78  G4double ux = direction.x(), uy = direction.y(), uz = direction.z();
79  G4double thetax = std::atan(ux/uz);
80  G4double thetay = std::atan(uy/uz);
81  analysisManager->FillH1(ih, thetax);
82  analysisManager->FillH1(ih, thetay);
83 
84  //dN/dS at exit
85 
86  G4double x = position.x(), y = position.y();
87  G4double r = std::sqrt(x*x + y*y);
88  ih = 2;
89  dr = analysisManager->GetH1Width(ih);
90  rmin = ((int)(r/dr))*dr;
91  ds = twopi*(rmin + 0.5*dr)*dr;
92  analysisManager->FillH1(ih, r, 1/ds);
93 
94  //d(N/cost)/dS at exit
95 
96  ih = 3;
97  dr = analysisManager->GetH1Width(ih);
98  rmin = ((int)(r/dr))*dr;
99  ds = twopi*(rmin + 0.5*dr)*dr;
100  analysisManager->FillH1(ih, r, 1/(uz*ds));
101 
102  //vector of d(N/cost)/dS at exit
103 
104  Run* run = static_cast<Run*>(
106 
107  run->SumFluence(r, 1/uz);
108 
109  //space angle at exit : dN/dOmega
110 
111  ih = 5;
112  G4double theta = std::acos(uz);
113  if (theta > 0.) {
114  G4double dtheta = analysisManager->GetH1Width(ih);
115  G4double unit = analysisManager->GetH1Unit(ih);
116  if (dtheta > 0.) {
117  G4double weight = unit*unit/(twopi*std::sin(theta)*dtheta);
118  analysisManager->FillH1(ih, theta, weight);
119  }
120  }
121 
122  //measured space angle at exit : dN/dOmega_meas
123  //
124  ih = 6;
125  const G4double dist = fDetector->GetZdist_foil_detector();
126  G4double thetam = std::atan(r/dist);
127  if (thetam > 0.) {
128  G4double dtheta = analysisManager->GetH1Width(ih);
129  G4double unit = analysisManager->GetH1Unit(ih);
130  if (dtheta > 0.) {
131  G4double weight = unit*unit/(twopi*std::sin(thetam)*dtheta);
132  analysisManager->FillH1(ih, thetam, weight);
133  }
134  }
135 
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
G4ParticleDefinition * GetDefinition() const
double x() 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
void PreUserTrackingAction(const G4Track *)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void PostUserTrackingAction(const G4Track *)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4ThreeVector & GetMomentumDirection() const
double y() const
Detector construction class to define materials and geometry.
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
void SumFluence(G4double, G4double)
Definition: Run.cc:186
G4double GetPDGCharge() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const