Analysis Software
Documentation for sPHENIX simulation software
 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 
7 
8 #include <g4histos/G4HitNtuple.h>
9 
12 #include <g4main/PHG4ParticleGun.h>
13 #include <g4main/PHG4Reco.h>
15 
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 
31 {
33  // Make the Server
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
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
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