Geant4  9.6.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 //
30 // $Id$
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  HistoManager* HM)
49 :fDetector(DET), fRunAction(RA), fHistoManager(HM)
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  G4double charge = track->GetDefinition()->GetPDGCharge();
65  G4ThreeVector direction = track->GetMomentumDirection();
66 
67  if (charge == 0.0) return;
68  if (position.z() < fZend) return;
69  if (direction.z() <= 0.) return;
70 
71  G4double rmin, dr, ds;
72  G4int ih = 1;
73 
74  //projected angle at exit
75  //
76  G4double ux = direction.x(), uy = direction.y(), uz = direction.z();
77  if (fHistoManager->HistoExist(ih)) {
78  G4double thetax = std::atan(ux/uz);
79  G4double thetay = std::atan(uy/uz);
80  fHistoManager->FillHisto(ih, thetax);
81  fHistoManager->FillHisto(ih, thetay);
82  }
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  if (fHistoManager->HistoExist(ih)) {
90  dr = fHistoManager->GetBinWidth(ih);
91  rmin = ((int)(r/dr))*dr;
92  ds = twopi*(rmin + 0.5*dr)*dr;
93  fHistoManager->FillHisto(ih, r, 1/ds);
94  }
95 
96  //d(N/cost)/dS at exit
97  //
98  ih = 3;
99  if (fHistoManager->HistoExist(ih)) {
100  dr = fHistoManager->GetBinWidth(ih);
101  rmin = ((int)(r/dr))*dr;
102  ds = twopi*(rmin + 0.5*dr)*dr;
103  fHistoManager->FillHisto(ih, r, 1/(uz*ds));
104  }
105 
106  //vector of d(N/cost)/dS at exit
107  //
108  fRunAction->SumFluence(r, 1/uz);
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112