ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_photonDispersion.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_photonDispersion.C
1 #ifndef MACRO_FUN4ALLPHOTONDISPERSION_C
2 #define MACRO_FUN4ALLPHOTONDISPERSION_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <DisplayOn.C>
7 #include <G4Setup.C>
8 #include <G4_Global.C>
9 #include <G4_Input.C>
10 
11 #include <fun4all/Fun4AllServer.h>
12 
13 #include <phool/PHRandomSeed.h>
14 #include <phool/recoConsts.h>
15 
16 #include <getvectors/getVectors.h>
17 
18 R__LOAD_LIBRARY(libfun4all.so)
19 R__LOAD_LIBRARY(libgetvectors.so)
20 
21 using namespace mySim;
22 
24  const int nEvents = 1,
25  const string particle = "pi+",
26  const string productionNumber = "00000",
27  const string revisionNumber = "000")
28 {
29  //The next set of lines figures out folder revisions, file numbers etc
30  string outDir = "./";
31  if (outDir.substr(outDir.size() - 1, 1) != "/") outDir += "/";
32  outDir += particle + "/" + revisionNumber + "/";
33  string outputFileName = "outputData_" + particle + "_" + revisionNumber + "_" + productionNumber + ".root";
34 
35  string outputRecoDir = outDir + "/inReconstruction/";
36  string makeDirectory = "mkdir -p " + outputRecoDir;
37  system(makeDirectory.c_str());
38  string outputRecoFile = outputRecoDir + outputFileName;
39 
41  se->Verbosity(1);
42 
43  //Opt to print all random seed used for debugging reproducibility. Comment out to reduce stdout prints.
45 
46  //===============
47  // Input options
48  //===============
49  // verbosity setting (applies to all input managers)
51  // First enable the input generators
52  Input::SIMPLE = true;
53  // Input::SIMPLE_NUMBER = 2; // if you need 2 of them
54  // Input::SIMPLE_VERBOSITY = 1;
55 
56  InputInit();
57 
58  //--------------
59  // Set generator specific options
60  //--------------
61  // can only be set after InputInit() is called
62 
63  // Simple Input generator:
64  // if you run more than one of these Input::SIMPLE_NUMBER > 1
65  // add the settings for other with [1], next with [2]...
66  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles(particle, 100);
67  INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_function(PHG4SimpleEventGenerator::Gaus,
70  INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_mean(0., 0., 0.);
71  INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_width(0., 0., 0.);
73  INPUTGENERATOR::SimpleEventGenerator[0]->set_phi_range(-M_PI, M_PI);
74  INPUTGENERATOR::SimpleEventGenerator[0]->set_p_range(30., 30.);
75  // register all input generators with Fun4All
76  InputRegister();
77 
78  // turn the display on (default off)
79  Enable::DISPLAY = false;
80 
81  G4MAGNET::magfield_rescale = 1.; // make consistent with expected Babar field strength of 1.4T
82 
83  // Initialize the selected subsystems
84  Enable::PIPE = true;
85 
86  G4Init();
87  G4Setup();
88  Global_Reco();
89 
90  //-----------------
91  // Global Vertexing
92  //-----------------
93 
95  {
96  cout << "You can only enable Enable::GLOBAL_RECO or Enable::GLOBAL_FASTSIM, not both" << endl;
97  gSystem->Exit(1);
98  }
100  {
101  Global_Reco();
102  }
103  else if (Enable::GLOBAL_FASTSIM)
104  {
105  Global_FastSim();
106  }
107 
108  InputManagers();
109 
110  getVectors *dRICHCalc = new getVectors();
111  dRICHCalc->setOutputName(outputRecoFile);
112  se->registerSubsystem(dRICHCalc);
113  //-----------------
114  // Event processing
115  //-----------------
116  if (Enable::DISPLAY)
117  {
118  DisplayOn();
119 
120  gROOT->ProcessLine("Fun4AllServer *se = Fun4AllServer::instance();");
121  gROOT->ProcessLine("PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");");
122 
123  cout << "-------------------------------------------------" << endl;
124  cout << "You are in event display mode. Run one event with" << endl;
125  cout << "se->run(1)" << endl;
126  cout << "Run Geant4 command with following examples" << endl;
127  gROOT->ProcessLine("displaycmd()");
128 
129  return 0;
130  }
131 
132  // if we use a negative number of events we go back to the command line here
133  if (nEvents < 0)
134  {
135  return 0;
136  }
137  // if we run the particle generator and use 0 it'll run forever
138  if (nEvents == 0)
139  {
140  cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
141  cout << "it will run forever, so I just return without running anything" << endl;
142  return 0;
143  }
144 
145  se->run(nEvents);
146 
147  //-----
148  // Exit
149  //-----
150 
151  se->End();
152 
153  ifstream file(outputRecoFile.c_str());
154  if (file.good())
155  {
156  string moveOutput = "mv " + outputRecoFile + " " + outDir;
157  system(moveOutput.c_str());
158  }
159 
160  std::cout << "All done" << std::endl;
161  delete se;
162 
163  gSystem->Exit(0);
164  return 0;
165 }
166 #endif