ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackingAction.cc
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 //
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 "G4Track.hh"
41 #include "G4PhysicalConstants.hh"
42 #include "G4SystemOfUnits.hh"
43 #include "G4RunManager.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 :fDetector(DET)
49 {
50  fZend = 0.5*(fDetector->GetThicknessWorld());
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 { }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
63 
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  Run* run = static_cast<Run*>(
105 
106  run->SumFluence(r, 1/uz);
107 
108  //space angle at exit : dN/dOmega
109 
110  ih = 5;
111  G4double theta = std::acos(uz);
112  if (theta > 0.) {
113  G4double dtheta = analysisManager->GetH1Width(ih);
114  G4double unit = analysisManager->GetH1Unit(ih);
115  if (dtheta > 0.) {
116  G4double weight = unit*unit/(twopi*std::sin(theta)*dtheta);
117  analysisManager->FillH1(ih, theta, weight);
118  }
119  }
120 
121  //measured space angle at exit : dN/dOmega_meas
122  //
123  ih = 6;
124  const G4double dist = fDetector->GetZdist_foil_detector();
125  G4double thetam = std::atan(r/dist);
126  if (thetam > 0.) {
127  G4double dtheta = analysisManager->GetH1Width(ih);
128  G4double unit = analysisManager->GetH1Unit(ih);
129  if (dtheta > 0.) {
130  G4double weight = unit*unit/(twopi*std::sin(thetam)*dtheta);
131  analysisManager->FillH1(ih, thetam, weight);
132  }
133  }
134 
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138