EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_G4_simple_hadron.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_G4_simple_hadron.C
1 #pragma once
2 #include <phgenfit/Track.h>
10 #include <fun4all/SubsysReco.h>
13 #include <g4histos/G4HitNtuple.h>
16 #include <g4main/PHG4Reco.h>
20 #include <phool/recoConsts.h>
21 
22 R__LOAD_LIBRARY(libfun4all.so)
23 R__LOAD_LIBRARY(libg4detectors.so)
24 R__LOAD_LIBRARY(libg4lblvtx.so)
25 R__LOAD_LIBRARY(libg4trackfastsim.so)
26 
28  int nEvents = -1, // number of events
29  float phi_deg_min = 0, // phi range
30  TString out_name = "out_AKiselev") // output filename
31 {
32  float phi_min = phi_deg_min*TMath::Pi()/180.;
33  TString phi_range = Form("_%.0f_%.0f",phi_deg_min,phi_deg_min+45.);
34  TString outputFile = out_name+phi_range+"_FastSimEval.root";
35  // ======================================================================================================
36  // Make the Server
38  // ======================================================================================================
39  // Particle Generator Setup
41  gen->set_name(std::string("pi-")); // geantino, pi-, pi+, mu-, mu+, e-., e+, proton, ... (currently passed as an input)
42  gen->set_vtx(0,0,0); // Vertex generation range
43  gen->set_mom_range(5.,50.); // Momentum generation range in GeV/c
44  gen->set_z_range(0.,0.);
45  gen->set_eta_range(2,6);
46  gen->set_phi_range(phi_min,phi_min+TMath::Pi()/4.);
47  se->registerSubsystem(gen);
48  // ======================================================================================================
49  PHG4Reco *g4Reco = new PHG4Reco();
50  g4Reco->SetWorldMaterial("G4_Galactic");
51  g4Reco->set_field(3.0);
52  // ======================================================================================================
53  double si_z_pos[] = {25.,49.,73.,97.,121};
54  double si_max_r = 44.;
55  double si_min_r = 0.0001;
56  double si_thick = 0.02811;
57 
59  // here is our silicon:
60  for (int ilayer = 0; ilayer < 5; ilayer++)
61  {
62  cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
63  cyl->set_string_param("material" , "G4_Si" );
64  cyl->set_double_param("radius" , si_min_r );
65  cyl->set_double_param("thickness", si_max_r );
66  cyl->set_double_param("place_z" , si_z_pos[ilayer]);
67  cyl->set_double_param("length" , si_thick );
68  cyl->SetActive();
69  cyl->SuperDetector("SVTX");
70  g4Reco->registerSubsystem(cyl);
71  }
72 
74  g4Reco->registerSubsystem(truth);
75 
76  se->registerSubsystem(g4Reco);
77 
78  //---------------------------
79  // fast pattern recognition and full Kalman filter
80  // output evaluation file for truth track and reco tracks are PHG4TruthInfoContainer
81  //---------------------------
82  PHG4TrackFastSim *kalman = new PHG4TrackFastSim("PHG4TrackFastSim");
83  kalman->set_use_vertex_in_fitting(false);
84  kalman->set_sub_top_node_name("SVTX");
85  kalman->set_trackmap_out_name("SvtxTrackMap");
86 
87  // add Si Trtacker
88  kalman->add_phg4hits(
89  "G4HIT_SVTX", // const std::string& phg4hitsNames,
91  20./10000./sqrt(12.), // radial-resolution [cm]
92  20./10000./sqrt(12.), // azimuthal-resolution [cm]
93  999., // z-resolution [cm]
94  1, // efficiency,
95  0 // noise hits
96  );
97  //kalman->Verbosity(10);
98  se->registerSubsystem(kalman);
99 
100  PHG4TrackFastSimEval *fast_sim_eval = new PHG4TrackFastSimEval("FastTrackingEval");
101  fast_sim_eval->set_filename(outputFile);
102  se->registerSubsystem(fast_sim_eval);
103 
104  // ======================================================================================================
105  // IOManagers...
106  const std::string dst_name = std::string(out_name+phi_range)+"_G4LBLVtx.root";
107  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",dst_name);
108  out->Verbosity(0);
109  se->registerOutputManager(out);
110 
112  se->registerInputManager(in);
113 
114  if (nEvents <= 0) return;
115 
116  se->run(nEvents);
117  se->End();
118  delete se;
119 
120  gSystem->Exit(0);
121 }