Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Fun4All_G4_Geantino.C
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Fun4All_G4_Geantino.C
1
#ifndef MACRO_FUN4ALLG4GEANTINO_C
2
#define MACRO_FUN4ALLG4GEANTINO_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_Geantino
(
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
// rc->set_IntFlag("RANDOMSEED",12345);
40
41
//
42
// Particle Generator
43
//
44
45
// the PHG4ParticleGenerator makes cones using phi and eta
46
PHG4ParticleGenerator
*
gen
=
new
PHG4ParticleGenerator
();
47
gen->
set_name
(
"geantino"
);
48
gen->
set_vtx
(0, 3, 0);
49
gen->
set_eta_range
(-0.9, 0.9);
50
gen->
set_mom_range
(1.0, 1.0);
51
gen->
set_z_range
(0., 0.);
52
gen->
set_phi_range
(0. * TMath::Pi(), 2. * TMath::Pi());
53
se->
registerSubsystem
(gen);
54
55
PHG4ParticleGun
*gun =
new
PHG4ParticleGun
();
56
gun->
set_name
(
"pi-"
);
57
//gun->set_name("geantino");
58
//gun->set_name("proton");
59
gun->
set_vtx
(0, -5, -20);
// shoots right into the original Examle01 volume
60
gun->
set_mom
(0, 0, 1);
61
// se->registerSubsystem(gun);
62
63
//
64
// Geant4 setup
65
//
66
PHG4Reco
*g4Reco =
new
PHG4Reco
();
67
g4Reco->
set_field
(0);
// no field
68
g4Reco->
save_DST_geometry
(
false
);
69
// try non default physics lists
70
//g4Reco->SetPhysicsList("FTFP_BERT_HP");
71
72
G4Example01Subsystem
*example01 =
new
G4Example01Subsystem
(
"HoleInBox"
);
73
g4Reco->
registerSubsystem
(example01);
74
75
se->
registerSubsystem
(g4Reco);
76
78
// Fun4All modules
80
81
G4HitNtuple
*hits =
new
G4HitNtuple
(
"Hits"
,
"HitNtuple.root"
);
82
hits->
AddNode
(
"HoleInBox"
, 0);
83
se->
registerSubsystem
(hits);
84
86
// IOManagers...
88
89
// Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT","G4Example01.root");
90
// out->Verbosity(10);
91
// se->registerOutputManager(out);
92
93
// this (dummy) input manager just drives the event loop
94
Fun4AllInputManager
*
in
=
new
Fun4AllDummyInputManager
(
"Dummy"
);
95
se->
registerInputManager
(in);
96
// events = 0 => run forever
97
if
(nEvents <= 0)
98
{
99
return
0;
100
}
101
se->
run
(nEvents);
102
example01->
Print
();
103
se->
End
();
104
std::cout <<
"All done"
<< std::endl;
105
delete
se;
106
gSystem->Exit(0);
107
}
108
109
#endif
g4exampledetector
blob
master
simple
macros
Fun4All_G4_Geantino.C
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:16
using
1.8.2 with
sPHENIX GitHub integration