Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_G4_Write_Dst.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_G4_Write_Dst.C
1 #ifndef MACRO_FUN4ALLG4WRITEDST_C
2 #define MACRO_FUN4ALLG4WRITEDST_C
3 
4 #include <g4exampledetector01/G4Example01Subsystem.h>
5 
7 
10 #include <g4main/PHG4ParticleGun.h>
11 #include <g4main/PHG4Reco.h>
13 
18 #include <fun4all/Fun4AllServer.h>
19 #include <fun4all/SubsysReco.h>
20 
21 #include <phool/recoConsts.h>
22 
23 R__LOAD_LIBRARY(libfun4all.so)
24 R__LOAD_LIBRARY(libg4detectors.so)
25 R__LOAD_LIBRARY(libg4example01detector.so)
26 
28 {
30  // Make the Server
34  // if you want to fix the random seed to reproduce results
35  // set this flag
36  // rc->set_IntFlag("RANDOMSEED",12345);
37 
38  //
39  // Particle Generator
40  //
41 
42  // the PHG4ParticleGenerator makes cones using phi and eta
44  gen->set_name("geantino");
45  gen->set_vtx(0, 3, 0);
46  gen->set_eta_range(-0.9, 0.9);
47  gen->set_mom_range(1.0, 10.0);
48  gen->set_z_range(0., 0.);
49  gen->set_phi_range(0. * TMath::Pi(), 2. * TMath::Pi());
50  se->registerSubsystem(gen);
51 
52  PHG4ParticleGun *gun = new PHG4ParticleGun();
53  gun->set_name("pi-");
54  //gun->set_name("geantino");
55  //gun->set_name("proton");
56  gun->set_vtx(0, -5, -20); // shoots right into the original Examle01 volume
57  gun->set_mom(0, 0, 1);
58  // se->registerSubsystem(gun);
59 
60  //
61  // Geant4 setup
62  //
63  PHG4Reco *g4Reco = new PHG4Reco();
64  g4Reco->set_field(0); // no field
65  g4Reco->save_DST_geometry(false);
66  // try non default physics lists
67  //g4Reco->SetPhysicsList("FTFP_BERT_HP");
68 
69  G4Example01Subsystem *example01 = new G4Example01Subsystem("HoleInBox");
70  g4Reco->registerSubsystem(example01);
71 
72  se->registerSubsystem(g4Reco);
73 
75  // IOManagers...
77 
78  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", "G4Example01.root");
79  out->Verbosity(10);
80  se->registerOutputManager(out);
81 
82  // this (dummy) input manager just drives the event loop
84  se->registerInputManager(in);
85  // events = 0 => run forever
86  if (nEvents <= 0)
87  {
88  return 0;
89  }
90  se->run(nEvents);
91  example01->Print();
92  se->End();
93  std::cout << "All done" << std::endl;
94  delete se;
95  gSystem->Exit(0);
96 }
97 
98 #endif