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 #include "PrimaryGeneratorAction.hh"
39 #include "RunAction.hh"
40 #include "HistoManager.hh"
41 
42 #include "G4Track.hh"
43 #include "G4PhysicalConstants.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 :G4UserTrackingAction(), fPrimary(prim)
49 {
50  // parameters for generator action #3
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 {
58  G4int selectedGeneratorAction = fPrimary->GetSelectedAction();
60  G4int id = 0;
61 
62  if(selectedGeneratorAction==2)
63  {
64  //energy spectrum
65  //
66  id = 1;
67  analysis->FillH1(id, track->GetKineticEnergy());
68  }
69 
70  else if(selectedGeneratorAction==0)
71  {
72  //particle direction: cos(alpha)
73  //
74  id = 5;
76  G4double cosalpha = um.z();
77  analysis->FillH1(id, cosalpha);
78 
79  //particle direction: psi
80  //
81  id = 6;
82  G4double psi = std::atan2(um.y(), um.x());
83  if (psi < 0.) psi += twopi;
84  analysis->FillH1(id, psi);
85  }
86  else if(selectedGeneratorAction==3)
87  {
88  //particle direction in local frame: cos(alpha)
89  //
90  id = 5;
91  G4ThreeVector um = track->GetMomentumDirection();
92  G4double cosalpha = fNewUz*um;
93  analysis->FillH1(id, cosalpha);
94 
95  //particle direction in local frame: psi
96  //
97  id = 6;
98  // complete local frame
99  G4ThreeVector u1(1.,0.,0.); u1.rotateUz(fNewUz);
100  G4ThreeVector u2(0.,1.,0.); u2.rotateUz(fNewUz);
101  //
102  G4double psi = std::atan2(u2*um, u1*um);
103  if (psi < 0.) psi += twopi;
104  analysis->FillH1(id, psi);
105  }
106 
107  else if(selectedGeneratorAction==4)
108  {
109  G4ThreeVector vertex = track->GetVertexPosition();
110  G4double r = vertex.mag();
111  if (r <= 0.0) return;
112  //local frame : new uz = ur
113  G4ThreeVector ur = vertex/r;
114 
115  //vertex position. radial distribution dN/dv = f(r)
116  //
117  id = 2;
118  G4double dr = analysis->GetH1Width(id);
119  G4double dv = 2*twopi*r*r*dr;
120  if (dv > 0.) analysis->FillH1(id, r, 1./dv);
121 
122  //vertex position: cos(theta)
123  //
124  id = 3;
125  G4double costheta = ur.z();
126  analysis->FillH1(id, costheta);
127 
128  //vertex position: phi
129  //
130  id = 4;
131  G4double phi = std::atan2(ur.y(), ur.x());
132  if (phi < 0.) phi += twopi;
133  analysis->FillH1(id, phi);
134 
135  //particle direction in local frame: cos(alpha)
136  //
137  id = 5;
138  G4ThreeVector um = track->GetMomentumDirection();
139  G4double cosalpha = ur*um;
140  analysis->FillH1(id, cosalpha);
141 
142  //particle direction in local frame: psi
143  //
144  id = 6;
145  // complete local frame
146  G4ThreeVector u1(1.,0.,0.); u1.rotateUz(ur);
147  G4ThreeVector u2(0.,1.,0.); u2.rotateUz(ur);
148  //
149  G4double psi = std::atan2(u2*um, u1*um);
150  if (psi < 0.) psi += twopi;
151  analysis->FillH1(id, psi);
152  }
153 }
154 
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
156 
158 { }
159 
160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
161