EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_G4_Lmon.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_G4_Lmon.C
1 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
2 #include <fun4all/SubsysReco.h>
9 #include <g4histos/G4HitNtuple.h>
13 #include <g4main/PHG4ParticleGun.h>
14 #include <g4main/PHG4Reco.h>
15 #include <g4lmondetector/G4LmonSubsystem.h>
16 #include <phool/recoConsts.h>
17 
18 R__LOAD_LIBRARY(libfun4all.so)
19 R__LOAD_LIBRARY(libg4detectors.so)
20 R__LOAD_LIBRARY(libg4lmondetector.so)
21 R__LOAD_LIBRARY(libg4histos.so)
22 
23 #endif
24 
25 void Fun4All_G4_Lmon(int nEvents = 1)
26 {
27 
28  gSystem->Load("libfun4all");
29  gSystem->Load("libg4detectors");
30  gSystem->Load("libg4testbench");
31  gSystem->Load("libg4histos");
32  gSystem->Load("libg4lmondetector.so");
33 
35  // Make the Server
39 // if you want to fix the random seed to reproduce results
40 // set this flag
41 // rc->set_IntFlag("RANDOMSEED",12345);
42 
43 //
44 // Particle Generator
45 //
46 
47 // the PHG4ParticleGenerator makes cones using phi and eta
49  gen->set_name("geantino");
50  gen->set_vtx(0, 3, 0);
51  gen->set_eta_range(-0.9, 0.9);
52  gen->set_mom_range(1.0, 10.0);
53  gen->set_z_range(0.,0.);
54  gen->set_phi_range(0.*TMath::Pi(), 2.*TMath::Pi());
55  // se->registerSubsystem(gen);
56 
57  PHG4ParticleGun *gun = new PHG4ParticleGun();
58  gun->set_name("gamma");
59  //gun->set_name("geantino");
60  gun->AddParticle("pi-", 0, 0, -1); // see the magnetic field with this one
61  gun->set_vtx(0, 0, 0); // shoots right into the original Examle01 volume
62  gun->set_mom(0, 0, -1); // hits the tagger
63  se->registerSubsystem(gun);
64 
65 //
66 // Geant4 setup
67 //
68  PHG4Reco* g4Reco = new PHG4Reco();
69  g4Reco->set_field(0); // no field
70  g4Reco->save_DST_geometry(false);
71 // try non default physics lists
72  //g4Reco->SetPhysicsList("FTFP_BERT_HP");
73 
74  G4LmonSubsystem *lmon = new G4LmonSubsystem("LumiMon");
75  g4Reco->registerSubsystem(lmon);
76 
77  se->registerSubsystem( g4Reco );
78 // this (dummy) input manager just drives the event loop
80  se->registerInputManager( in );
81 // events = 0 => run forever
82  if (nEvents <= 0)
83  {
84  return 0;
85  }
86  se->run(nEvents);
87  lmon->Print();
88  se->End();
89  std::cout << "All done" << std::endl;
90  delete se;
91  gSystem->Exit(0);
92 }