Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:20:36

0001 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 00, 0)
0002 
0003 #include <fun4all/Fun4AllDstOutputManager.h>
0004 #include <fun4all/Fun4AllInputManager.h>
0005 #include <fun4all/Fun4AllOutputManager.h>
0006 #include <fun4all/Fun4AllServer.h>
0007 #include <fun4all/SubsysReco.h>
0008 
0009 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0010 
0011 #include <g4detectors/PHG4BlockSubsystem.h>
0012 
0013 #include <g4eval/PHG4DSTReader.h>
0014 #include <g4eval/SvtxEvaluator.h>
0015 
0016 #include <g4histos/G4HitNtuple.h>
0017 
0018 #include <g4main/PHG4ParticleGenerator.h>
0019 #include <g4main/PHG4ParticleGun.h>
0020 #include <g4main/PHG4Reco.h>
0021 #include <g4main/PHG4SimpleEventGenerator.h>
0022 #include <g4main/PHG4TruthSubsystem.h>
0023 
0024 #include <g4tpc/PHG4TpcDigitizer.h>
0025 #include <g4tpc/PHG4TpcElectronDrift.h>
0026 #include <g4tpc/PHG4TpcPadPlane.h>
0027 #include <g4tpc/PHG4TpcPadPlaneReadout.h>
0028 #include <g4tpc/PHG4TpcSubsystem.h>
0029 
0030 #include <phgeom/PHGeomFileImport.h>
0031 
0032 #include <phool/recoConsts.h>
0033 
0034 #include <tpc2019/TpcPrototypeClusterizer.h>
0035 #include <tpc2019/TpcPrototypeGenFitTrkFinder.h>
0036 #include <tpc2019/TpcPrototypeGenFitTrkFitter.h>
0037 #include <tpc2019/TpcPrototypeUnpacker.h>
0038 
0039 #include <trackreco/PHGenFitTrkFitter.h>
0040 #include <trackreco/PHGenFitTrkProp.h>
0041 #include <trackreco/PHHoughSeeding.h>
0042 #include <trackreco/PHInitVertexing.h>
0043 #include <trackreco/PHTrackSeeding.h>
0044 #include <trackreco/PHTruthTrackSeeding.h>
0045 #include <trackreco/PHTruthVertexing.h>
0046 
0047 R__LOAD_LIBRARY(libfun4allraw.so)
0048 R__LOAD_LIBRARY(libg4tpc.so)
0049 R__LOAD_LIBRARY(libintt.so)
0050 R__LOAD_LIBRARY(libmvtx.so)
0051 R__LOAD_LIBRARY(libtpc2019.so)
0052 R__LOAD_LIBRARY(libtrack_reco.so)
0053 #endif
0054 
0055 int n_tpc_layer_inner = 0;
0056 int tpc_layer_rphi_count_inner = 1152;
0057 int n_tpc_layer_mid = 16;
0058 int n_tpc_layer_outer = 0;
0059 int n_gas_layer = n_tpc_layer_inner + n_tpc_layer_mid + n_tpc_layer_outer;
0060 
0061 using namespace std;
0062 
0063 int Fun4All_TestBeam_TPC(int nEvents = 10, int nSkip = 0,
0064                          //    const string &input_file = "data/tpc_beam/tpc_beam_00000171-0000.evt",//initial good 120 Gev proton run
0065                          //    const string &input_file = "data/tpc_beam/tpc_beam_00000191-0000.evt",  //readjusted HV to lwoer gain
0066                          //    const string &input_file = "data/tpc_beam/tpc_beam_00000217-0000.evt",  //moved beam to reduce drift
0067 //    const string &input_file = "data/tpc_beam/tpc_beam_00000241-0000.evt",  //moved beam to increase drift
0068     const string &input_file = "data/tpc_beam/tpc_beam_00000300-0000.evt",  //moved beam to increase drift
0069                          bool eventDisp = false, int verbosity = 0)
0070 {
0071   gSystem->Load("libfun4all");
0072   gSystem->Load("libqa_modules");
0073   gSystem->Load("libg4tpc");
0074   gSystem->Load("libtrack_io.so");
0075   gSystem->Load("libfun4all.so");
0076   gSystem->Load("libtpc2019.so");
0077   gSystem->Load("libfun4all.so");
0078   gSystem->Load("libtrack_reco.so");
0079   bool dstoutput = false;
0080 
0081   const double TPCDriftLength = 40;
0082 
0083   ///////////////////////////////////////////
0084   // Make the Server
0085   //////////////////////////////////////////
0086   Fun4AllServer *se = Fun4AllServer::instance();
0087   se->Verbosity(1);
0088   recoConsts *rc = recoConsts::instance();
0089   // only set this if you want a fixed random seed to make
0090   // results reproducible for testing
0091   rc->set_IntFlag("RANDOMSEED", 12345678);
0092 
0093   //swap out with the test beam geometry for the analysis stage
0094   PHGeomFileImport *import = new PHGeomFileImport("TpcPrototypeGeometry.gdml");
0095   se->registerSubsystem(import);
0096 
0097   PHG4TpcPadPlane *padplane = new PHG4TpcPadPlaneReadout();
0098 
0099   // The pad plane readout default is set in PHG4TpcPadPlaneReadout
0100   //only build mid-layer and to size
0101   padplane->set_int_param("tpc_minlayer_inner", 0);
0102   padplane->set_int_param("ntpc_layers_inner", 0);
0103   padplane->set_int_param("ntpc_layers_outer", 0);
0104   padplane->set_double_param("maxdriftlength", TPCDriftLength);
0105   padplane->set_int_param("ntpc_phibins_mid", 16 * 8 * 12);
0106 
0107   TpcPrototypeUnpacker *tpcfee = new TpcPrototypeUnpacker((input_file) + string("_TpcPrototypeUnpacker.root"));
0108   tpcfee->Verbosity(verbosity);
0109 //    tpcfee->Verbosity(TpcPrototypeUnpacker::VERBOSITY_MORE);
0110   tpcfee->registerPadPlane(padplane);
0111   tpcfee->setNPreSample(5);
0112   tpcfee->setNPostSample(7);
0113 
0114   se->registerSubsystem(tpcfee);
0115 
0116   //
0117   //  // For the Tpc
0118   //  //==========
0119   //  TpcPrototypeClusterizer *tpcclusterizer = new TpcPrototypeClusterizer();
0120   //  tpcclusterizer->Verbosity(verbosity);
0121   //  ;
0122   //  se->registerSubsystem(tpcclusterizer);
0123   //
0124   //-------------
0125   // Tracking
0126   //------------
0127 
0128   //  // Find all clusters associated with each seed track
0129   TpcPrototypeGenFitTrkFinder *finder = new TpcPrototypeGenFitTrkFinder();
0130   finder->Verbosity(verbosity);
0131   finder->set_do_evt_display(eventDisp);
0132   finder->set_do_eval(false);
0133   finder->set_eval_filename(input_file + "_TpcPrototypeGenFitTrkFinder.root");
0134   se->registerSubsystem(finder);
0135   ////
0136   ////  //
0137   //  //------------------------------------------------
0138   //  // Fitting of tracks using Kalman Filter
0139   //  //------------------------------------------------
0140   //
0141   TpcPrototypeGenFitTrkFitter *kalman = new TpcPrototypeGenFitTrkFitter();
0142   kalman->Verbosity(verbosity);
0143 //  kalman->Verbosity(2); // use a higher verbosity to print
0144   kalman->set_do_evt_display(eventDisp);
0145   kalman->set_eval_filename(input_file + "_TpcPrototypeGenFitTrkFitter.root");
0146   kalman->set_do_eval(true);
0147   se->registerSubsystem(kalman);
0148 
0149   if (dstoutput)
0150   {
0151     Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", input_file + "_DST.root");
0152     se->registerOutputManager(out);
0153   }
0154 
0155   Fun4AllInputManager *in = new Fun4AllPrdfInputManager("PRDFin");
0156   in->fileopen(input_file);
0157   se->registerInputManager(in);
0158 
0159 //  gSystem->ListLibraries();
0160   se->skip(nSkip);
0161   se->run(nEvents);
0162 
0163   se->End();
0164 
0165   //   std::cout << "All done" << std::endl;
0166   delete se;
0167   //   return 0;
0168   gSystem->Exit(0);
0169   return 0;
0170 }
0171 
0172 // for using QuickTest to check if macro loads
0173 void RunLoadTest() {}