Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_TestBeam_TPC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_TestBeam_TPC.C
1 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 00, 0)
2 
7 #include <fun4all/SubsysReco.h>
8 
10 
12 
13 #include <g4eval/PHG4DSTReader.h>
14 #include <g4eval/SvtxEvaluator.h>
15 
16 #include <g4histos/G4HitNtuple.h>
17 
19 #include <g4main/PHG4ParticleGun.h>
20 #include <g4main/PHG4Reco.h>
23 
24 #include <g4tpc/PHG4TpcDigitizer.h>
26 #include <g4tpc/PHG4TpcPadPlane.h>
28 #include <g4tpc/PHG4TpcSubsystem.h>
29 
30 #include <phgeom/PHGeomFileImport.h>
31 
32 #include <phool/recoConsts.h>
33 
38 
40 #include <trackreco/PHGenFitTrkProp.h>
41 #include <trackreco/PHHoughSeeding.h>
46 
47 R__LOAD_LIBRARY(libfun4allraw.so)
48 R__LOAD_LIBRARY(libg4tpc.so)
49 R__LOAD_LIBRARY(libintt.so)
50 R__LOAD_LIBRARY(libmvtx.so)
51 R__LOAD_LIBRARY(libtpc2019.so)
52 R__LOAD_LIBRARY(libtrack_reco.so)
53 #endif
54 
57 int n_tpc_layer_mid = 16;
59 int n_gas_layer = n_tpc_layer_inner + n_tpc_layer_mid + n_tpc_layer_outer;
60 
61 using namespace std;
62 
63 int Fun4All_TestBeam_TPC(int nEvents = 10, int nSkip = 0,
64  // const string &input_file = "data/tpc_beam/tpc_beam_00000171-0000.evt",//initial good 120 Gev proton run
65  // const string &input_file = "data/tpc_beam/tpc_beam_00000191-0000.evt", //readjusted HV to lwoer gain
66  // const string &input_file = "data/tpc_beam/tpc_beam_00000217-0000.evt", //moved beam to reduce drift
67 // const string &input_file = "data/tpc_beam/tpc_beam_00000241-0000.evt", //moved beam to increase drift
68  const string &input_file = "data/tpc_beam/tpc_beam_00000300-0000.evt", //moved beam to increase drift
69  bool eventDisp = false, int verbosity = 0)
70 {
71  gSystem->Load("libfun4all");
72  gSystem->Load("libqa_modules");
73  gSystem->Load("libg4tpc");
74  gSystem->Load("libtrack_io.so");
75  gSystem->Load("libfun4all.so");
76  gSystem->Load("libtpc2019.so");
77  gSystem->Load("libfun4all.so");
78  gSystem->Load("libtrack_reco.so");
79  bool dstoutput = false;
80 
81  const double TPCDriftLength = 40;
82 
84  // Make the Server
87  se->Verbosity(1);
89  // only set this if you want a fixed random seed to make
90  // results reproducible for testing
91  rc->set_IntFlag("RANDOMSEED", 12345678);
92 
93  //swap out with the test beam geometry for the analysis stage
94  PHGeomFileImport *import = new PHGeomFileImport("TpcPrototypeGeometry.gdml");
95  se->registerSubsystem(import);
96 
97  PHG4TpcPadPlane *padplane = new PHG4TpcPadPlaneReadout();
98 
99  // The pad plane readout default is set in PHG4TpcPadPlaneReadout
100  //only build mid-layer and to size
101  padplane->set_int_param("tpc_minlayer_inner", 0);
102  padplane->set_int_param("ntpc_layers_inner", 0);
103  padplane->set_int_param("ntpc_layers_outer", 0);
104  padplane->set_double_param("maxdriftlength", TPCDriftLength);
105  padplane->set_int_param("ntpc_phibins_mid", 16 * 8 * 12);
106 
107  TpcPrototypeUnpacker *tpcfee = new TpcPrototypeUnpacker((input_file) + string("_TpcPrototypeUnpacker.root"));
108  tpcfee->Verbosity(verbosity);
109 // tpcfee->Verbosity(TpcPrototypeUnpacker::VERBOSITY_MORE);
110  tpcfee->registerPadPlane(padplane);
111  tpcfee->setNPreSample(5);
112  tpcfee->setNPostSample(7);
113 
114  se->registerSubsystem(tpcfee);
115 
116  //
117  // // For the Tpc
118  // //==========
119  // TpcPrototypeClusterizer *tpcclusterizer = new TpcPrototypeClusterizer();
120  // tpcclusterizer->Verbosity(verbosity);
121  // ;
122  // se->registerSubsystem(tpcclusterizer);
123  //
124  //-------------
125  // Tracking
126  //------------
127 
128  // // Find all clusters associated with each seed track
130  finder->Verbosity(verbosity);
131  finder->set_do_evt_display(eventDisp);
132  finder->set_do_eval(false);
133  finder->set_eval_filename(input_file + "_TpcPrototypeGenFitTrkFinder.root");
134  se->registerSubsystem(finder);
137  // //------------------------------------------------
138  // // Fitting of tracks using Kalman Filter
139  // //------------------------------------------------
140  //
142  kalman->Verbosity(verbosity);
143 // kalman->Verbosity(2); // use a higher verbosity to print
144  kalman->set_do_evt_display(eventDisp);
145  kalman->set_eval_filename(input_file + "_TpcPrototypeGenFitTrkFitter.root");
146  kalman->set_do_eval(true);
147  se->registerSubsystem(kalman);
148 
149  if (dstoutput)
150  {
151  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", input_file + "_DST.root");
152  se->registerOutputManager(out);
153  }
154 
156  in->fileopen(input_file);
157  se->registerInputManager(in);
158 
159 // gSystem->ListLibraries();
160  se->skip(nSkip);
161  se->run(nEvents);
162 
163  se->End();
164 
165  // std::cout << "All done" << std::endl;
166  delete se;
167  // return 0;
168  gSystem->Exit(0);
169  return 0;
170 }
171 
172 // for using QuickTest to check if macro loads
173 void RunLoadTest() {}