ECCE @ EIC 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 #pragma once
2 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
3 #include <fun4all/SubsysReco.h>
10 #include <g4eval/PHG4DSTReader.h>
12 #include <g4main/PHG4Reco.h>
14 #include <phool/recoConsts.h>
15 R__LOAD_LIBRARY(libg4eval.so)
16 R__LOAD_LIBRARY(libfun4all.so)
17 R__LOAD_LIBRARY(libg4testbench.so)
18 R__LOAD_LIBRARY(libg4detectors.so)
19 #endif
20 int Fun4All_G4_Cylinder(const int nEvents = 10, const char * outfile = NULL)
21 {
22 
23  gSystem->Load("libfun4all");
24  gSystem->Load("libg4detectors.so");
25  gSystem->Load("libg4testbench.so");
26 
28  // Make the Server
31  se->Verbosity(0);
32 
34 // rc->set_IntFlag("RANDOMSEED", 12345); // if you want to use a fixed seed
35  // PHG4ParticleGenerator generates particle
36  // distributions in eta/phi/mom range
37  PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
38  //gen->set_name("gamma");
39  gen->set_name("e+");
40  gen->set_vtx(0, 0, 0);
41  gen->set_eta_range(-0.05, +0.05);
42  gen->set_mom_range(0.4, 10.0);
43  gen->set_phi_range(0., 90. / 180.*TMath::Pi()); // 0-90 deg
44  se->registerSubsystem(gen);
45 
46  PHG4Reco* g4Reco = new PHG4Reco();
47  g4Reco->set_field(1.5); // 1.5 T solenoidal field
48 
49 
50  double si_thickness[6] = {0.02, 0.02, 0.0625, 0.032, 0.032, 0.032};
51  double svxrad[6] = {2.71, 4.63, 11.765, 25.46, 41.38, 63.66};
52  double length[6] = {20., 20., 36., -1., - 1., - 1.}; // -1 use eta coverage to determine length
54  // here is our silicon:
55  for (int ilayer = 0; ilayer < 6; ilayer++)
56  {
57  cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
58  cyl->set_double_param("radius",svxrad[ilayer]);
59  cyl->set_string_param("material","G4_Si");
60  cyl->set_double_param("thickness",si_thickness[ilayer]);
61  cyl->SetActive();
62  cyl->SuperDetector("SVTX");
63  if (length[ilayer] > 0)
64  {
65  cyl->set_double_param("length",length[ilayer]);
66  }
67  g4Reco->registerSubsystem( cyl );
68  }
69  se->registerSubsystem( g4Reco );
70 
71  if (outfile)
72  {
73  Fun4AllOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",outfile);
74  se->registerOutputManager(out);
75  }
77  se->registerInputManager( in );
78 
79 
80  if (nEvents > 0)
81  {
82  se->run(nEvents);
83  // finish job - close and save output files
84  se->End();
85  std::cout << "All done" << std::endl;
86 
87  // cleanup - delete the server and exit
88  delete se;
89  gSystem->Exit(0);
90  }
91  return 0;
92 }
93 
94 PHG4ParticleGenerator *get_gen(const char *name="PGENERATOR")
95 {
98  return pgun;
99 }