/
Fun4All_G4_EicDirc.C
93 lines (78 loc) · 2.86 KB
/
Fun4All_G4_EicDirc.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <fun4all/Fun4AllDstOutputManager.h>
#include <fun4all/Fun4AllDummyInputManager.h>
#include <fun4all/Fun4AllInputManager.h>
#include <fun4all/Fun4AllOutputManager.h>
#include <fun4all/Fun4AllServer.h>
#include <fun4all/SubsysReco.h>
#include <g4detectors/PHG4CylinderSubsystem.h>
#include <g4main/PHG4ParticleGenerator.h>
#include <g4main/PHG4TruthSubsystem.h>
#include <g4main/PHG4Reco.h>
#include <phool/recoConsts.h>
#include <g4eicdirc/G4EicDircSubsystem.h>
R__LOAD_LIBRARY(libfun4all.so)
R__LOAD_LIBRARY(libg4testbench.so)
R__LOAD_LIBRARY(libg4detectors.so)
R__LOAD_LIBRARY(libg4eicdirc.so)
int Fun4All_G4_EicDirc(const int nEvents = 1000, const char *outfile = NULL)
{
///////////////////////////////////////////
// Make the Server
//////////////////////////////////////////
Fun4AllServer *se = Fun4AllServer::instance();
se->Verbosity(0);
recoConsts *rc = recoConsts::instance();
// rc->set_IntFlag("RANDOMSEED", 12345); // if you want to use a fixed seed
// PHG4ParticleGenerator generates particle
// distributions in eta/phi/mom range
PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
gen->set_name("e+");
gen->set_vtx(0, 0, 0);
gen->set_eta_range(-0.5, +0.5);
gen->set_mom_range(0.5, 0.5); // GeV/c
// gen->set_phi_range(0., 90. / 180. * TMath::Pi()); // 0-90 deg
se->registerSubsystem(gen);
PHG4Reco *g4Reco = new PHG4Reco();
g4Reco->set_field(1.5); // 1.5 T solenoidal field
G4EicDircSubsystem *eicdirc = new G4EicDircSubsystem();
g4Reco->registerSubsystem(eicdirc);
// Black hole swallows everything - prevent loopers from returning
// to inner detectors
PHG4CylinderSubsystem *cyl = new PHG4CylinderSubsystem("BlackHole", 0);
cyl->set_double_param("radius", 80); // 80 cm
cyl->set_double_param("thickness", 0.1); // does not matter (but > 0)
cyl->SetActive();
cyl->BlackHole(); // eats everything
g4Reco->registerSubsystem(cyl);
PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
g4Reco->registerSubsystem(truth);
se->registerSubsystem(g4Reco);
//---------------------------
//---------------------------
// output DST file for further offlien analysis
//---------------------------
if (outfile)
{
Fun4AllOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outfile);
se->registerOutputManager(out);
}
Fun4AllInputManager *in = new Fun4AllDummyInputManager("JADE");
se->registerInputManager(in);
if (nEvents > 0)
{
se->run(nEvents);
// finish job - close and save output files
se->End();
std::cout << "All done" << std::endl;
// cleanup - delete the server and exit
delete se;
gSystem->Exit(0);
}
return 0;
}
PHG4ParticleGenerator *get_gen(const char *name = "PGENERATOR")
{
Fun4AllServer *se = Fun4AllServer::instance();
PHG4ParticleGenerator *pgun = (PHG4ParticleGenerator *) se->getSubsysReco(name);
return pgun;
}