Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/eventgenerator/particleGun/src/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 // $Id: TrackingAction.cc 89707 2015-04-28 07:38:57Z gcosmo $
31 //
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "TrackingAction.hh"
36 #include "PrimaryGeneratorAction.hh"
40 #include "RunAction.hh"
41 #include "HistoManager.hh"
42 
43 #include "G4Track.hh"
44 #include "G4PhysicalConstants.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 :G4UserTrackingAction(), fPrimary(prim)
50 {
51  // parameters for generator action #3
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {
59  G4int selectedGeneratorAction = fPrimary->GetSelectedAction();
60  G4AnalysisManager* analysis = G4AnalysisManager::Instance();
61  G4int id = 0;
62 
63  if(selectedGeneratorAction==2)
64  {
65  //energy spectrum
66  //
67  id = 1;
68  analysis->FillH1(id, track->GetKineticEnergy());
69  }
70 
71  else if(selectedGeneratorAction==0)
72  {
73  //particle direction: cos(alpha)
74  //
75  id = 5;
77  G4double cosalpha = um.z();
78  analysis->FillH1(id, cosalpha);
79 
80  //particle direction: psi
81  //
82  id = 6;
83  G4double psi = std::atan2(um.y(), um.x());
84  if (psi < 0.) psi += twopi;
85  analysis->FillH1(id, psi);
86  }
87  else if(selectedGeneratorAction==3)
88  {
89  //particle direction in local frame: cos(alpha)
90  //
91  id = 5;
92  G4ThreeVector um = track->GetMomentumDirection();
93  G4double cosalpha = fNewUz*um;
94  analysis->FillH1(id, cosalpha);
95 
96  //particle direction in local frame: psi
97  //
98  id = 6;
99  // complete local frame
100  G4ThreeVector u1(1.,0.,0.); u1.rotateUz(fNewUz);
101  G4ThreeVector u2(0.,1.,0.); u2.rotateUz(fNewUz);
102  //
103  G4double psi = std::atan2(u2*um, u1*um);
104  if (psi < 0.) psi += twopi;
105  analysis->FillH1(id, psi);
106  }
107 
108  else if(selectedGeneratorAction==4)
109  {
110  G4ThreeVector vertex = track->GetVertexPosition();
111  G4double r = vertex.mag();
112  if (r <= 0.0) return;
113  //local frame : new uz = ur
114  G4ThreeVector ur = vertex/r;
115 
116  //vertex position. radial distribution dN/dv = f(r)
117  //
118  id = 2;
119  G4double dr = analysis->GetH1Width(id);
120  G4double dv = 2*twopi*r*r*dr;
121  if (dv > 0.) analysis->FillH1(id, r, 1./dv);
122 
123  //vertex position: cos(theta)
124  //
125  id = 3;
126  G4double costheta = ur.z();
127  analysis->FillH1(id, costheta);
128 
129  //vertex position: phi
130  //
131  id = 4;
132  G4double phi = std::atan2(ur.y(), ur.x());
133  if (phi < 0.) phi += twopi;
134  analysis->FillH1(id, phi);
135 
136  //particle direction in local frame: cos(alpha)
137  //
138  id = 5;
139  G4ThreeVector um = track->GetMomentumDirection();
140  G4double cosalpha = ur*um;
141  analysis->FillH1(id, cosalpha);
142 
143  //particle direction in local frame: psi
144  //
145  id = 6;
146  // complete local frame
147  G4ThreeVector u1(1.,0.,0.); u1.rotateUz(ur);
148  G4ThreeVector u2(0.,1.,0.); u2.rotateUz(ur);
149  //
150  G4double psi = std::atan2(u2*um, u1*um);
151  if (psi < 0.) psi += twopi;
152  analysis->FillH1(id, psi);
153  }
154 }
155 
156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
157 
159 { }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 
const G4ThreeVector & GetVertexPosition() const
G4double GetKineticEnergy() const
Definition of the PrimaryGeneratorAction4 class.
double z() const
static constexpr double um
Definition: G4SIunits.hh:113
void PostUserTrackingAction(const G4Track *)
double G4double
Definition: G4Types.hh:76
static constexpr double twopi
Definition: G4SIunits.hh:76
The primary generator action class with particle gun.
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition of the PrimaryGeneratorAction2 class.
double mag() const
int G4int
Definition: G4Types.hh:78
Definition of the PrimaryGeneratorAction3 class.
double x() const
double y() const
const G4ThreeVector & GetMomentumDirection() const
void PreUserTrackingAction(const G4Track *)