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