Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_G4_Cylinder.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_G4_Cylinder.C
1 #ifndef MACRO_FUN4ALLG4CYLINDER_C
2 #define MACRO_FUN4ALLG4CYLINDER_C
3 
4 #include <fun4all/SubsysReco.h>
11 #include <g4eval/PHG4DSTReader.h>
13 #include <g4main/PHG4Reco.h>
15 #include <phool/recoConsts.h>
16 
17 R__LOAD_LIBRARY(libg4eval.so)
18 R__LOAD_LIBRARY(libfun4all.so)
19 R__LOAD_LIBRARY(libg4testbench.so)
20 R__LOAD_LIBRARY(libg4detectors.so)
21 
22 int Fun4All_G4_Cylinder(const int nEvents = 10, const char * outfile = nullptr)
23 {
24 
26  // Make the Server
29  se->Verbosity(0);
30 
32 // rc->set_IntFlag("RANDOMSEED", 12345); // if you want to use a fixed seed
33  // PHG4ParticleGenerator generates particle
34  // distributions in eta/phi/mom range
35  PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
36  //gen->set_name("gamma");
37  gen->set_name("e+");
38  gen->set_vtx(0, 0, 0);
39  gen->set_eta_range(-0.05, +0.05);
40  gen->set_mom_range(0.4, 10.0);
41  gen->set_phi_range(0., 90. / 180.*TMath::Pi()); // 0-90 deg
42  se->registerSubsystem(gen);
43 
44  PHG4Reco* g4Reco = new PHG4Reco();
45  g4Reco->set_field(1.4); // 1.5 T solenoidal field
46 
47 
48  double si_thickness[6] = {0.02, 0.02, 0.0625, 0.032, 0.032, 0.032};
49  double svxrad[6] = {2.71, 4.63, 11.765, 25.46, 41.38, 63.66};
50  double length[6] = {20., 20., 36., -1., - 1., - 1.}; // -1 use eta coverage to determine length
52  // here is our silicon:
53  for (int ilayer = 0; ilayer < 6; ilayer++)
54  {
55  cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
56  cyl->set_double_param("radius",svxrad[ilayer]);
57  cyl->set_string_param("material","G4_Si");
58  cyl->set_double_param("thickness",si_thickness[ilayer]);
59  cyl->SetActive();
60  cyl->SuperDetector("SVTX");
61  if (length[ilayer] > 0)
62  {
63  cyl->set_double_param("length",length[ilayer]);
64  }
65  g4Reco->registerSubsystem( cyl );
66  }
67  se->registerSubsystem( g4Reco );
68 
69  if (outfile)
70  {
72  se->registerOutputManager(out);
73  }
75  se->registerInputManager( in );
76 
77 
78  if (nEvents > 0)
79  {
80  se->run(nEvents);
81  // finish job - close and save output files
82  se->End();
83  std::cout << "All done" << std::endl;
84 
85  // cleanup - delete the server and exit
86  delete se;
87  gSystem->Exit(0);
88  }
89  return 0;
90 }
91 
92 PHG4ParticleGenerator *get_gen(const char *name="PGENERATOR")
93 {
96  return pgun;
97 }
98 
99 #endif