Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extended/medical/electronScattering/src/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 /// \file medical/electronScattering/src/TrackingAction.cc
27 /// \brief Implementation of the TrackingAction class
28 //
29 //
30 // $Id: TrackingAction.cc 69009 2013-04-15 09:33:05Z gcosmo $
31 //
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "TrackingAction.hh"
36 
37 #include "DetectorConstruction.hh"
38 #include "RunAction.hh"
39 #include "HistoManager.hh"
40 
41 #include "G4Track.hh"
42 #include "G4PhysicalConstants.hh"
43 #include "G4SystemOfUnits.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 :fDetector(DET), fRunAction(RA)
49 {
50  fZend = 0.5*(fDetector->GetThicknessWorld());
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 { }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
63 
64  G4double charge = track->GetDefinition()->GetPDGCharge();
66  G4ThreeVector direction = track->GetMomentumDirection();
67 
68  if (charge == 0.0) return;
69  if (position.z() < fZend) return;
70  if (direction.z() <= 0.) return;
71 
72  G4double rmin, dr, ds;
73  G4int ih = 1;
74 
75  //projected angle at exit
76  //
77  G4double ux = direction.x(), uy = direction.y(), uz = direction.z();
78  G4double thetax = std::atan(ux/uz);
79  G4double thetay = std::atan(uy/uz);
80  analysisManager->FillH1(ih, thetax);
81  analysisManager->FillH1(ih, thetay);
82 
83  //dN/dS at exit
84  //
85  G4double x = position.x(), y = position.y();
86  G4double r = std::sqrt(x*x + y*y);
87  ih = 2;
88  dr = analysisManager->GetH1Width(ih);
89  rmin = ((int)(r/dr))*dr;
90  ds = twopi*(rmin + 0.5*dr)*dr;
91  analysisManager->FillH1(ih, r, 1/ds);
92 
93  //d(N/cost)/dS at exit
94  //
95  ih = 3;
96  dr = analysisManager->GetH1Width(ih);
97  rmin = ((int)(r/dr))*dr;
98  ds = twopi*(rmin + 0.5*dr)*dr;
99  analysisManager->FillH1(ih, r, 1/(uz*ds));
100 
101  //vector of d(N/cost)/dS at exit
102  //
103  fRunAction->SumFluence(r, 1/uz);
104 
105  //space angle at exit : dN/dOmega
106  //
107  ih = 5;
108  G4double theta = std::acos(uz);
109  if (theta > 0.) {
110  G4double dtheta = analysisManager->GetH1Width(ih);
111  G4double unit = analysisManager->GetH1Unit(ih);
112  if (dtheta > 0.) {
113  G4double weight = unit*unit/(twopi*std::sin(theta)*dtheta);
114  analysisManager->FillH1(ih, theta, weight);
115  }
116  }
117 
118  //measured space angle at exit : dN/dOmega_meas
119  //
120  ih = 6;
121  const G4double dist = fDetector->GetThicknessFrame();
122  G4double thetam = std::atan(r/dist);
123  if (thetam > 0.) {
124  G4double dtheta = analysisManager->GetH1Width(ih);
125  G4double unit = analysisManager->GetH1Unit(ih);
126  if (dtheta > 0.) {
127  G4double weight = unit*unit/(twopi*std::sin(thetam)*dtheta);
128  analysisManager->FillH1(ih, thetam, weight);
129  }
130  }
131 
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
G4ParticleDefinition * GetDefinition() const
double x() const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const G4ThreeVector & GetPosition() const
int G4int
Definition: G4Types.hh:78
double z() const
void PreUserTrackingAction(const G4Track *)
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
void PostUserTrackingAction(const G4Track *)
const G4ThreeVector & GetMomentumDirection() const
double y() const
double G4double
Definition: G4Types.hh:76
G4double GetPDGCharge() const