File indexing completed on 2025-08-03 08:18:53
0001 #ifndef MACRO_FUN4ALLG4EXAMPLE01_C
0002 #define MACRO_FUN4ALLG4EXAMPLE01_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_Example01(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
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 PHG4ParticleGun *gun = new PHG4ParticleGun();
0057 gun->set_name("pi-");
0058
0059
0060 gun->set_vtx(0, -5, -20);
0061 gun->set_mom(0, 0, 1);
0062 se->registerSubsystem(gun);
0063
0064
0065
0066
0067 PHG4Reco *g4Reco = new PHG4Reco();
0068 g4Reco->set_field(0);
0069 g4Reco->save_DST_geometry(false);
0070
0071
0072
0073 G4Example01Subsystem *example01 = new G4Example01Subsystem("HoleInBox");
0074 g4Reco->registerSubsystem(example01);
0075
0076 se->registerSubsystem(g4Reco);
0077
0078
0079
0080
0081
0082 G4HitNtuple *hits = new G4HitNtuple("Hits");
0083 hits->AddNode("HoleInBox", 0);
0084 se->registerSubsystem(hits);
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 Fun4AllInputManager *in = new Fun4AllDummyInputManager("Dummy");
0096 se->registerInputManager(in);
0097
0098 if (nEvents <= 0)
0099 {
0100 return 0;
0101 }
0102 se->run(nEvents);
0103 example01->Print();
0104 se->End();
0105 std::cout << "All done" << std::endl;
0106 delete se;
0107 gSystem->Exit(0);
0108 }
0109
0110 #endif