EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_G4_simple_hadron_GEM.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_G4_simple_hadron_GEM.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>
22 
23 #include "G4_GEM.C"
24 
25 R__LOAD_LIBRARY(libfun4all.so)
26 R__LOAD_LIBRARY(libg4detectors.so)
27 R__LOAD_LIBRARY(libg4lblvtx.so)
28 R__LOAD_LIBRARY(libg4trackfastsim.so)
29 
31  int nEvents = -1, // number of events
32  float phi_deg_min = 0, // phi range
33  TString out_name = "out_AKiselev_GEM") // output filename
34 {
35  float phi_min = phi_deg_min*TMath::Pi()/180.;
36  TString phi_range = Form("_%.0f_%.0f",phi_deg_min,phi_deg_min+45.);
37  TString outputFile = out_name+phi_range+"_FastSimEval.root";
38  // ======================================================================================================
39  // Make the Server
41  // ======================================================================================================
42  // Particle Generator Setup
44  gen->set_name(std::string("pi-")); // geantino, pi-, pi+, mu-, mu+, e-., e+, proton, ... (currently passed as an input)
45  gen->set_vtx(0,0,0); // Vertex generation range
46  gen->set_mom_range(5.,50.); // Momentum generation range in GeV/c
47  gen->set_z_range(0.,0.);
48  gen->set_eta_range(2,6);
49  gen->set_phi_range(phi_min,phi_min+TMath::Pi()/4.);
50  se->registerSubsystem(gen);
51  // ======================================================================================================
52  PHG4Reco *g4Reco = new PHG4Reco();
53  g4Reco->SetWorldMaterial("G4_Galactic");
54  g4Reco->set_field(3.0);
55  // ======================================================================================================
56  double si_z_pos[] = {25.,49.,73.,97.,121};
57  double si_max_r = 44.;
58  double si_min_r = 0.0001;
59  double si_thick = 0.02811;
60 
62  // here is our silicon:
63  for (int ilayer = 0; ilayer < 5; ilayer++)
64  {
65  cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
66  cyl->set_string_param("material" , "G4_Si" );
67  cyl->set_double_param("radius" , si_min_r );
68  cyl->set_double_param("thickness", si_max_r );
69  cyl->set_double_param("place_z" , si_z_pos[ilayer]);
70  cyl->set_double_param("length" , si_thick );
71  cyl->SetActive();
72  cyl->SuperDetector("SVTX");
73  g4Reco->registerSubsystem(cyl);
74  }
75 
76  FGEM_Init(); // Loading forward GEM geometry
77  FGEMSetup(g4Reco);
78  // ------------
79  // Forward RICH
81  g4Reco->registerSubsystem(RICH);
82 
83  //---------------------------
85  g4Reco->registerSubsystem(truth);
86 
87  se->registerSubsystem(g4Reco);
88 
89  //---------------------------
90  // fast pattern recognition and full Kalman filter
91  // output evaluation file for truth track and reco tracks are PHG4TruthInfoContainer
92  //---------------------------
93  PHG4TrackFastSim *kalman = new PHG4TrackFastSim("PHG4TrackFastSim");
94  kalman->set_use_vertex_in_fitting(false);
95  kalman->set_sub_top_node_name("SVTX");
96  kalman->set_trackmap_out_name("SvtxTrackMap");
97 
98  // add Si Trtacker
99  kalman->add_phg4hits(
100  "G4HIT_SVTX", // const std::string& phg4hitsNames,
102  20./10000./sqrt(12.), // radial-resolution [cm]
103  20./10000./sqrt(12.), // azimuthal-resolution [cm]
104  999., // z-resolution [cm]
105  1, // efficiency,
106  0 // noise hits
107  );
108 
109  kalman->add_phg4hits("G4HIT_FGEM", // const std::string& phg4hitsNames,
110  PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
111  50e-4,//1. / sqrt(12.), // const float radres,
112  50e-4, // const float phires,
113  999., // longitudinal (z) resolution [cm] (this number is not used in vertical plane geometry)
114  1, // const float eff,
115  0 // const float noise
116  );
117 
118  //kalman->Verbosity(10);
119  se->registerSubsystem(kalman);
120 
121  PHG4TrackFastSimEval *fast_sim_eval = new PHG4TrackFastSimEval("FastTrackingEval");
122  fast_sim_eval->set_filename(outputFile);
123  se->registerSubsystem(fast_sim_eval);
124 
125  // ======================================================================================================
126  // IOManagers...
127  const std::string dst_name = std::string(out_name+phi_range)+"_G4LBLVtx.root";
128  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",dst_name);
129  out->Verbosity(0);
130  se->registerOutputManager(out);
131 
133  se->registerInputManager(in);
134 
135  if (nEvents <= 0) return;
136 
137  se->run(nEvents);
138  se->End();
139  delete se;
140 
141  gSystem->Exit(0);
142 }