ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
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
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
33
#include "TrackingAction.hh"
34
35
#include "Run.hh"
36
#include "EventAction.hh"
37
#include "HistoManager.hh"
38
39
#include "
G4RunManager.hh
"
40
#include "
G4Track.hh
"
41
#include "
G4StepStatus.hh
"
42
#include "
G4ParticleTypes.hh
"
43
#include "
G4IonTable.hh
"
44
45
#include "
G4SystemOfUnits.hh
"
46
#include "
G4UnitsTable.hh
"
47
48
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49
50
TrackingAction::TrackingAction
(
EventAction
* event)
51
:
G4UserTrackingAction
(), fEventAction(event)
52
{
53
fTimeBirth
=
fTimeEnd
= 0.;
54
}
55
56
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58
TrackingAction::~TrackingAction
()
59
{ }
60
61
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
63
void
TrackingAction::PreUserTrackingAction
(
const
G4Track
*
track
)
64
{
65
Run
* run =
static_cast<
Run
*
>
(
66
G4RunManager::GetRunManager
()->
GetNonConstCurrentRun
());
67
68
G4ParticleDefinition
*
particle
= track->
GetDefinition
();
69
G4String
name
= particle->
GetParticleName
();
70
G4double
meanLife = particle->
GetPDGLifeTime
();
71
G4double
ekin = track->
GetKineticEnergy
();
72
fTimeBirth
= track->
GetGlobalTime
();
73
74
//count secondary particles
75
if
(track->
GetTrackID
() > 1) run->
ParticleCount
(name,ekin,meanLife);
76
}
77
78
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
80
void
TrackingAction::PostUserTrackingAction
(
const
G4Track
* track)
81
{
82
Run
* run =
static_cast<
Run
*
>
(
83
G4RunManager::GetRunManager
()->
GetNonConstCurrentRun
());
84
85
G4AnalysisManager
*
analysis
=
G4AnalysisManager::Instance
();
86
87
const
G4ParticleDefinition
* particle = track->
GetParticleDefinition
();
88
G4String
name = particle->
GetParticleName
();
89
G4double
meanLife = particle->
GetPDGLifeTime
();
90
G4double
ekin = track->
GetKineticEnergy
();
91
fTimeEnd
= track->
GetGlobalTime
();
92
if
((particle->
GetPDGStable
())&&(ekin == 0.))
fTimeEnd
=
DBL_MAX
;
93
94
// count population of ions with meanLife > 0.
95
if
((
G4IonTable::IsIon
(particle))&&(meanLife != 0.)) {
96
G4int
id
= run->
GetIonId
(name);
97
G4double
unit = analysis->
GetH1Unit
(
id
);
98
G4double
tmin = analysis->
GetH1Xmin
(
id
)*unit;
99
G4double
tmax = analysis->
GetH1Xmax
(
id
)*unit;
100
G4double
binWidth = analysis->
GetH1Width
(
id
)*unit;
101
102
G4double
t1
=
std::max
(
fTimeBirth
,tmin);
103
G4double
t2
=
std::min
(
fTimeEnd
,tmax);
104
for
(
G4double
time
= t1;
time
<
t2
;
time
+= binWidth)
105
analysis->
FillH1
(
id
,
time
);
106
}
107
108
// keep only emerging particles
109
G4StepStatus
status = track->
GetStep
()->
GetPostStepPoint
()->
GetStepStatus
();
110
if
(status !=
fWorldBoundary
)
return
;
111
112
fEventAction
->
AddEflow
(ekin);
113
run->
ParticleFlux
(name,ekin);
114
115
// histograms: energy flow and activities of emerging particles
116
117
G4int
ih1 = 0, ih2 = 0;
118
G4String
type = particle->
GetParticleType
();
119
G4double
charge
= particle->
GetPDGCharge
();
120
G4double
time
= track->
GetGlobalTime
();
121
if
(charge > 3.) {ih1 = 10; ih2 = 20;}
122
else
if
(particle ==
G4Gamma::Gamma
()) {ih1 = 4; ih2 = 14;}
123
else
if
(particle ==
G4Electron::Electron
()) {ih1 = 5; ih2 = 15;}
124
else
if
(particle ==
G4Positron::Positron
()) {ih1 = 5; ih2 = 15;}
125
else
if
(particle ==
G4Neutron::Neutron
()) {ih1 = 6; ih2 = 16;}
126
else
if
(particle ==
G4Proton::Proton
()) {ih1 = 7; ih2 = 17;}
127
else
if
(particle ==
G4Deuteron::Deuteron
()) {ih1 = 8; ih2 = 18;}
128
else
if
(particle ==
G4Alpha::Alpha
()) {ih1 = 9; ih2 = 19;}
129
else
if
(type ==
"nucleus"
) {ih1 = 10; ih2 = 20;}
130
else
if
(type ==
"baryon"
) {ih1 = 11; ih2 = 21;}
131
else
if
(type ==
"meson"
) {ih1 = 12; ih2 = 22;}
132
else
if
(type ==
"lepton"
) {ih1 = 13; ih2 = 23;};
133
if
(ih1 > 0) analysis->
FillH1
(ih1,ekin);
134
if
(ih2 > 0) analysis->
FillH1
(ih2,time);
135
136
}
137
138
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
radioactivedecay
Activation
src
TrackingAction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:55
using
1.8.2 with
ECCE GitHub integration