File indexing completed on 2025-08-05 08:18:20
0001 #ifndef MACRO_FUN4ALLG4EXAMPLE03_C
0002 #define MACRO_FUN4ALLG4EXAMPLE03_C
0003
0004 #include <g4exampledetector03/G4Example03Subsystem.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(libg4example03detector.so)
0028 R__LOAD_LIBRARY(libg4histos.so)
0029
0030 void Fun4All_G4_Example03(int nEvents = 1)
0031 {
0032
0033
0034
0035 Fun4AllServer *se = Fun4AllServer::instance();
0036 recoConsts *rc = recoConsts::instance();
0037
0038
0039
0040 rc->set_IntFlag("RANDOMSEED", 12345);
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 G4Example03Subsystem *example03 = new G4Example03Subsystem("HoleInBox");
0074 example03->set_color(1, 1, 0, 1);
0075 example03->SetActive();
0076 g4Reco->registerSubsystem(example03);
0077
0078 example03 = new G4Example03Subsystem("AnotherHoleInBox");
0079 example03->set_double_param("place_x", 40.);
0080 example03->set_double_param("place_y", 40.);
0081 example03->set_double_param("rot_x", 45.);
0082 example03->set_string_param("material", "G4_Fe");
0083 example03->set_color(1, 0, 0, 1);
0084 example03->SetActive();
0085 g4Reco->registerSubsystem(example03);
0086
0087 example03 = new G4Example03Subsystem("YetAnotherHoleInBox");
0088 example03->set_double_param("place_x", -40.);
0089 example03->set_double_param("place_z", 40.);
0090 example03->set_double_param("rot_y", 45.);
0091 example03->set_double_param("rot_z", 45.);
0092 example03->set_string_param("material", "G4_Cu");
0093 example03->set_color(0, 1, 0, 1);
0094 example03->SetActive();
0095 g4Reco->registerSubsystem(example03);
0096
0097
0098 example03 = new G4Example03Subsystem("BewareOfTheBlackHole");
0099 example03->set_double_param("place_z", 40.);
0100 example03->set_double_param("rot_y", 45.);
0101 example03->set_double_param("rot_z", 45.);
0102 example03->set_color(1, 0, 1, 1);
0103 example03->BlackHole();
0104 example03->SetActive();
0105 g4Reco->registerSubsystem(example03);
0106
0107
0108 example03 = new G4Example03Subsystem("InActiveHoleInBox");
0109 example03->set_double_param("place_z", -40.);
0110 example03->set_double_param("rot_y", 45.);
0111 example03->set_double_param("rot_z", 45.);
0112 example03->set_string_param("material", "G4_W");
0113 example03->set_color(0, 1, 1, 1);
0114 g4Reco->registerSubsystem(example03);
0115
0116 se->registerSubsystem(g4Reco);
0117
0118
0119
0120
0121
0122 G4HitNtuple *hits = new G4HitNtuple("Hits");
0123 hits->AddNode("HoleInBox", 0);
0124 se->registerSubsystem(hits);
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 Fun4AllInputManager *in = new Fun4AllDummyInputManager("Dummy");
0136 se->registerInputManager(in);
0137
0138 if (nEvents <= 0)
0139 {
0140 return 0;
0141 }
0142 se->run(nEvents);
0143 example03->Print();
0144 se->End();
0145 std::cout << "All done" << std::endl;
0146 delete se;
0147 gSystem->Exit(0);
0148 }
0149
0150 #endif