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
Fun4All_G4_Momentum.C
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Fun4All_G4_Momentum.C
1
#ifndef FUN4ALL_G4_MOMENTUM_C
2
#define FUN4ALL_G4_MOMENTUM_C
3
4
#include <
g4detectors/PHG4CylinderSubsystem.h
>
5
6
#include <
g4trackfastsim/PHG4TrackFastSim.h
>
7
#include <
g4trackfastsim/PHG4TrackFastSimEval.h
>
8
9
#include <
g4main/PHG4ParticleGenerator.h
>
10
#include <
g4main/PHG4Reco.h
>
11
#include <
g4main/PHG4TruthSubsystem.h
>
12
13
#include <
fun4all/Fun4AllDstOutputManager.h
>
14
#include <
fun4all/Fun4AllDummyInputManager.h
>
15
#include <
fun4all/Fun4AllInputManager.h
>
16
#include <
fun4all/Fun4AllOutputManager.h
>
17
#include <
fun4all/Fun4AllServer.h
>
18
#include <
fun4all/SubsysReco.h
>
19
20
#include <
phool/recoConsts.h
>
21
22
#include <cmath>
23
24
R__LOAD_LIBRARY
(libfun4all.so)
25
R__LOAD_LIBRARY
(libg4testbench.so)
26
R__LOAD_LIBRARY
(libg4detectors.so)
27
R__LOAD_LIBRARY
(libg4trackfastsim.so)
28
29
int
Fun4All_G4_Momentum
(const
int
nEvents
= 1000, const
string
&evalfile = "FastTrackingEval.root", const
string
&outfile = "")
30
{
32
// Make the Server
34
Fun4AllServer
*se =
Fun4AllServer::instance
();
35
se->
Verbosity
(0);
36
37
recoConsts
*rc =
recoConsts::instance
();
38
// if you want to use a fixed seed for reproducible results
39
// rc->set_IntFlag("RANDOMSEED", 12345);
40
41
// PHG4ParticleGenerator generates particle
42
// distributions in eta/phi/mom range
43
PHG4ParticleGenerator
*gen =
new
PHG4ParticleGenerator
(
"PGENERATOR"
);
44
gen->
set_name
(
"pi-"
);
45
gen->
set_vtx
(0, 0, 0);
46
gen->
set_eta_range
(-0.05, 0.05);
// around midrapidity
47
gen->
set_mom_range
(4, 4);
// fixed 4 GeV/c
48
gen->
set_phi_range
(0., 90. / 180. *
M_PI
);
// 0-90 deg
49
se->
registerSubsystem
(gen);
50
51
PHG4Reco
*g4Reco =
new
PHG4Reco
();
52
g4Reco->
set_field
(1.5);
// 1.5 T constant solenoidal field
53
54
double
si_thickness[6] = {0.02, 0.02, 0.0625, 0.032, 0.032, 0.032};
55
double
svxrad[6] = {2.71, 4.63, 11.765, 25.46, 41.38, 63.66};
56
double
length
[6] = {20., 20., 36., -1., -1., -1.};
// -1 use eta coverage to determine length
57
PHG4CylinderSubsystem
*cyl;
58
// here is our silicon:
59
for
(
int
ilayer = 0; ilayer < 6; ilayer++)
60
{
61
cyl =
new
PHG4CylinderSubsystem
(
"SVTX"
, ilayer);
62
cyl->
set_double_param
(
"radius"
, svxrad[ilayer]);
63
cyl->
set_string_param
(
"material"
,
"G4_Si"
);
// Silicon (G4 definition)
64
cyl->
set_double_param
(
"thickness"
, si_thickness[ilayer]);
65
cyl->
SetActive
();
66
cyl->
SuperDetector
(
"SVTX"
);
67
if
(length[ilayer] > 0)
68
{
69
cyl->
set_double_param
(
"length"
, length[ilayer]);
70
}
71
g4Reco->
registerSubsystem
(cyl);
72
}
73
74
// Black hole swallows everything - prevent loopers from returning
75
// to inner detectors, length is given by default eta = +-1.1 range
76
cyl =
new
PHG4CylinderSubsystem
(
"BlackHole"
, 0);
77
cyl->
set_double_param
(
"radius"
, 80);
// 80 cm - everything stops here
78
cyl->
set_double_param
(
"thickness"
, 0.1);
// does not matter (but > 0)
79
cyl->
SetActive
();
80
cyl->
BlackHole
();
// eats everything
81
g4Reco->
registerSubsystem
(cyl);
82
83
PHG4TruthSubsystem
*truth =
new
PHG4TruthSubsystem
();
84
g4Reco->
registerSubsystem
(truth);
85
86
se->
registerSubsystem
(g4Reco);
87
88
//---------------------------
89
// fast pattern recognition and full Kalman filter
90
// output evaluation file for truth track and reco tracks are PHG4TruthInfoContainer
91
//---------------------------
92
PHG4TrackFastSim
*kalman =
new
PHG4TrackFastSim
(
"PHG4TrackFastSim"
);
93
kalman->
set_use_vertex_in_fitting
(
false
);
94
kalman->
set_sub_top_node_name
(
"SVTX"
);
95
kalman->
set_trackmap_out_name
(
"SvtxTrackMap"
);
96
97
// add Si Trtacker
98
kalman->
add_phg4hits
(
99
"G4HIT_SVTX"
,
// const std::string& phg4hitsNames,
100
PHG4TrackFastSim::Cylinder
,
// const DETECTOR_TYPE phg4dettype,
101
300
e
-4,
// radial-resolution [cm]
102
30
e
-4,
// azimuthal-resolution [cm]
103
1,
// z-resolution [cm]
104
1,
// efficiency,
105
0
// noise hits
106
);
107
108
se->
registerSubsystem
(kalman);
109
110
PHG4TrackFastSimEval
*fast_sim_eval =
new
PHG4TrackFastSimEval
(
"FastTrackingEval"
);
111
fast_sim_eval->
set_filename
(evalfile);
112
se->
registerSubsystem
(fast_sim_eval);
113
//---------------------------
114
115
//---------------------------
116
// output DST file for further offline analysis
117
//---------------------------
118
if
(!outfile.empty())
119
{
120
Fun4AllOutputManager
*out =
new
Fun4AllDstOutputManager
(
"DSTOUT"
, outfile);
121
se->
registerOutputManager
(out);
122
}
123
Fun4AllInputManager
*
in
=
new
Fun4AllDummyInputManager
(
"JADE"
);
124
se->
registerInputManager
(in);
125
126
if
(nEvents > 0)
127
{
128
se->
run
(nEvents);
129
// finish job - close and save output files
130
se->
End
();
131
std::cout <<
"All done"
<< std::endl;
132
133
// cleanup - delete the server and exit
134
delete
se;
135
gSystem->Exit(0);
136
}
137
return
0;
138
}
139
140
PHG4ParticleGenerator
*
get_gen
(
const
char
*
name
=
"PGENERATOR"
)
141
{
142
Fun4AllServer
*se =
Fun4AllServer::instance
();
143
PHG4ParticleGenerator
*pgun = (
PHG4ParticleGenerator
*) se->
getSubsysReco
(
name
);
144
return
pgun;
145
}
146
147
#endif
tutorials
blob
master
Momentum
Fun4All_G4_Momentum.C
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:26:00
using
1.8.2 with
ECCE GitHub integration