File indexing completed on 2025-08-03 08:18:53
0001 #ifndef MACRO_FUN4ALLG4GEANTINO_C
0002 #define MACRO_FUN4ALLG4GEANTINO_C
0003
0004 #include <g4exampledetector01/G4Example01Subsystem.h>
0005
0006 #include <g4detectors/PHG4DetectorSubsystem.h>
0007
0008 #include <g4histos/G4HitNtuple.h>
0009
0010 #include <g4main/PHG4ParticleGenerator.h>
0011 #include <g4main/PHG4ParticleGeneratorBase.h>
0012 #include <g4main/PHG4ParticleGun.h>
0013 #include <g4main/PHG4Reco.h>
0014 #include <g4main/PHG4SimpleEventGenerator.h>
0015
0016 #include <fun4all/Fun4AllDstOutputManager.h>
0017 #include <fun4all/Fun4AllDummyInputManager.h>
0018 #include <fun4all/Fun4AllInputManager.h>
0019 #include <fun4all/Fun4AllOutputManager.h>
0020 #include <fun4all/Fun4AllServer.h>
0021 #include <fun4all/SubsysReco.h>
0022
0023 #include <phool/recoConsts.h>
0024
0025 R__LOAD_LIBRARY(libfun4all.so)
0026 R__LOAD_LIBRARY(libg4detectors.so)
0027 R__LOAD_LIBRARY(libg4example01detector.so)
0028 R__LOAD_LIBRARY(libg4histos.so)
0029
0030 void Fun4All_G4_Geantino(int nEvents = 1)
0031 {
0032
0033
0034
0035 Fun4AllServer *se = Fun4AllServer::instance();
0036 recoConsts *rc = recoConsts::instance();
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 PHG4ParticleGenerator *gen = new PHG4ParticleGenerator();
0047 gen->set_name("geantino");
0048 gen->set_vtx(0, 3, 0);
0049 gen->set_eta_range(-0.9, 0.9);
0050 gen->set_mom_range(1.0, 1.0);
0051 gen->set_z_range(0., 0.);
0052 gen->set_phi_range(0. * TMath::Pi(), 2. * TMath::Pi());
0053 se->registerSubsystem(gen);
0054
0055 PHG4ParticleGun *gun = new PHG4ParticleGun();
0056 gun->set_name("pi-");
0057
0058
0059 gun->set_vtx(0, -5, -20);
0060 gun->set_mom(0, 0, 1);
0061
0062
0063
0064
0065
0066 PHG4Reco *g4Reco = new PHG4Reco();
0067 g4Reco->set_field(0);
0068 g4Reco->save_DST_geometry(false);
0069
0070
0071
0072 G4Example01Subsystem *example01 = new G4Example01Subsystem("HoleInBox");
0073 g4Reco->registerSubsystem(example01);
0074
0075 se->registerSubsystem(g4Reco);
0076
0077
0078
0079
0080
0081 G4HitNtuple *hits = new G4HitNtuple("Hits", "HitNtuple.root");
0082 hits->AddNode("HoleInBox", 0);
0083 se->registerSubsystem(hits);
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 Fun4AllInputManager *in = new Fun4AllDummyInputManager("Dummy");
0095 se->registerInputManager(in);
0096
0097 if (nEvents <= 0)
0098 {
0099 return 0;
0100 }
0101 se->run(nEvents);
0102 example01->Print();
0103 se->End();
0104 std::cout << "All done" << std::endl;
0105 delete se;
0106 gSystem->Exit(0);
0107 }
0108
0109 #endif