EIC Software
Reference for
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_Example01.C
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Fun4All_G4_Example01.C
1
#ifndef MACRO_FUN4ALLG4EXAMPLE01_C
2
#define MACRO_FUN4ALLG4EXAMPLE01_C
3
4
#include <g4exampledetector01/G4Example01Subsystem.h>
5
6
#include <
g4detectors/PHG4DetectorSubsystem.h
>
7
8
#include <
g4histos/G4HitNtuple.h
>
9
10
#include <
g4main/PHG4ParticleGenerator.h
>
11
#include <
g4main/PHG4ParticleGeneratorBase.h
>
12
#include <
g4main/PHG4ParticleGun.h
>
13
#include <
g4main/PHG4Reco.h
>
14
#include <
g4main/PHG4SimpleEventGenerator.h
>
15
16
#include <
fun4all/Fun4AllDstOutputManager.h
>
17
#include <
fun4all/Fun4AllDummyInputManager.h
>
18
#include <
fun4all/Fun4AllInputManager.h
>
19
#include <
fun4all/Fun4AllOutputManager.h
>
20
#include <
fun4all/Fun4AllServer.h
>
21
#include <
fun4all/SubsysReco.h
>
22
23
#include <
phool/recoConsts.h
>
24
25
R__LOAD_LIBRARY
(libfun4all.so)
26
R__LOAD_LIBRARY
(libg4detectors.so)
27
R__LOAD_LIBRARY
(libg4example01detector.so)
28
R__LOAD_LIBRARY
(libg4histos.so)
29
30
void
Fun4All_G4_Example01
(
int
nEvents
= 1)
31
{
33
// Make the Server
35
Fun4AllServer
*se =
Fun4AllServer::instance
();
36
recoConsts
*rc =
recoConsts::instance
();
37
// if you want to fix the random seed to reproduce results
38
// set this flag
39
// nail this down so I know what the first event looks like...
40
// rc->set_IntFlag("RANDOMSEED",12345);
41
42
//
43
// Particle Generator
44
//
45
46
// the PHG4ParticleGenerator makes cones using phi and eta
47
// PHG4ParticleGenerator *gen = new PHG4ParticleGenerator();
48
// gen->set_name("e-");
49
// gen->set_vtx(0, 0, 0);
50
// gen->set_eta_range(-0.9, 0.9);
51
// gen->set_mom_range(1.0, 10.0);
52
// gen->set_z_range(0.,0.);
53
// gen->set_phi_range(-5/180.*TMath::Pi(), 5/180.*TMath::Pi());
54
// se->registerSubsystem(gen);
55
56
PHG4ParticleGun
*gun =
new
PHG4ParticleGun
();
57
gun->
set_name
(
"pi-"
);
58
//gun->set_name("geantino");
59
//gun->set_name("proton");
60
gun->
set_vtx
(0, -5, -20);
// shoots right into the original Examle01 volume
61
gun->
set_mom
(0, 0, 1);
62
se->
registerSubsystem
(gun);
63
64
//
65
// Geant4 setup
66
//
67
PHG4Reco
*g4Reco =
new
PHG4Reco
();
68
g4Reco->
set_field
(0);
// no field
69
g4Reco->
save_DST_geometry
(
false
);
70
// try non default physics lists
71
//g4Reco->SetPhysicsList("FTFP_BERT_HP");
72
73
G4Example01Subsystem
*example01 =
new
G4Example01Subsystem
(
"HoleInBox"
);
74
g4Reco->
registerSubsystem
(example01);
75
76
se->
registerSubsystem
(g4Reco);
77
79
// Fun4All modules
81
82
G4HitNtuple
*hits =
new
G4HitNtuple
(
"Hits"
);
83
hits->
AddNode
(
"HoleInBox"
, 0);
84
se->
registerSubsystem
(hits);
85
87
// IOManagers...
89
90
// Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT","G4Example01.root");
91
// out->Verbosity(10);
92
// se->registerOutputManager(out);
93
94
// this (dummy) input manager just drives the event loop
95
Fun4AllInputManager
*
in
=
new
Fun4AllDummyInputManager
(
"Dummy"
);
96
se->
registerInputManager
(in);
97
// events = 0 => run forever
98
if
(nEvents <= 0)
99
{
100
return
0;
101
}
102
se->
run
(nEvents);
103
example01->
Print
();
104
se->
End
();
105
std::cout <<
"All done"
<< std::endl;
106
delete
se;
107
gSystem->Exit(0);
108
}
109
110
#endif
g4exampledetector
blob
master
simple
macros
Fun4All_G4_Example01.C
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:55
using
1.8.2 with
EIC GitHub integration