Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-10-15 08:30:39

0001 /*
0002  * This macro shows a minimum working example of running the
0003  * TPC track reconstruction starting with hit unpackers
0004  */
0005 
0006 // leave the GlobalVariables.C at the beginning, an empty line afterwards
0007 // protects its position against reshuffling by clang-format
0008 #include <GlobalVariables.C>
0009 
0010 #include <G4Setup_sPHENIX.C>
0011 #include <G4_ActsGeom.C>
0012 #include <G4_Global.C>
0013 #include <G4_Magnet.C>
0014 #include <G4_Mbd.C>
0015 #include <QA.C>
0016 #include <Trkr_Clustering.C>
0017 #include <Trkr_LaserClustering.C>
0018 #include <Trkr_Reco.C>
0019 #include <Trkr_RecoInit.C>
0020 #include <Trkr_TpcReadoutInit.C>
0021 
0022 #include <cdbobjects/CDBTTree.h>
0023 
0024 #include <mvtxrawhitqa/MvtxRawHitQA.h>
0025 
0026 #include <inttrawhitqa/InttRawHitQA.h>
0027 
0028 #include <tpcqa/TpcRawHitQA.h>
0029 
0030 #include <trackingqa/InttClusterQA.h>
0031 #include <trackingqa/MicromegasClusterQA.h>
0032 #include <trackingqa/MvtxClusterQA.h>
0033 #include <trackingqa/SiliconSeedsQA.h>
0034 #include <trackingqa/TpcClusterQA.h>
0035 #include <trackingqa/TpcSeedsQA.h>
0036 #include <trackingqa/TpcSiliconQA.h>
0037 #include <trackingqa/TrackFittingQA.h>
0038 
0039 #include <ffamodules/CDBInterface.h>
0040 #include <ffamodules/FlagHandler.h>
0041 #include <ffamodules/HeadReco.h>
0042 #include <ffamodules/SyncReco.h>
0043 
0044 #include <fun4all/Fun4AllDstInputManager.h>
0045 #include <fun4all/Fun4AllDstOutputManager.h>
0046 #include <fun4all/Fun4AllInputManager.h>
0047 #include <fun4all/Fun4AllOutputManager.h>
0048 #include <fun4all/Fun4AllRunNodeInputManager.h>
0049 #include <fun4all/Fun4AllServer.h>
0050 #include <fun4all/Fun4AllUtils.h>
0051 
0052 #include <fun4all/Fun4AllReturnCodes.h>
0053 #include <fun4all/SubsysReco.h>
0054 
0055 #include <phool/recoConsts.h>
0056 
0057 #include <phgarfield/PHGarfield.h>
0058 #include <tpcconditions/TpcConditionsReco.h>
0059 #include <tpctrackreco/TpcCrossingFinder.h>
0060 #include <tpctrackreco/TpcPolyClusterTrkrClusterConverter.h>
0061 #include <tpctrackreco/TpcPolyTrackSeedConverter.h>
0062 #include <tpctrackreco/Tpc_AssembledTrackReco.h>
0063 #include <tpctrackreco/Tpc_ModuleTrackReco.h>
0064 #include <tpctrackreco/Tpc_PolyClusterizer.h>
0065 #include <tpctrackreco/Tpc_PolyTrackReco.h>
0066 #include <tpctrackreco/Tpc_PolyTrackVertexer.h>
0067 
0068 #include <fun4allraw/Fun4AllStreamingInputManager.h>
0069 #include <fun4allraw/InputManagerType.h>
0070 #include <fun4allraw/SingleGl1PoolInput.h>
0071 #include <fun4allraw/SingleInttPoolInput.h>
0072 #include <fun4allraw/SingleMicromegasPoolInput.h>
0073 #include <fun4allraw/SingleMvtxPoolInput.h>
0074 #include <fun4allraw/SingleTpcTimeFrameInput.h>
0075 
0076 #include <trackingdiagnostics/Tpc_AssembledTrackDisplay.h>
0077 #include <trackingdiagnostics/Tpc_ModuleTrackDisplay.h>
0078 #include <trackingdiagnostics/Tpc_PolyClusterDisplay.h>
0079 #include <trackingdiagnostics/Tpc_PolyClusterResiduals.h>
0080 #include <trackingdiagnostics/TrackResiduals.h>
0081 
0082 #include <format>
0083 R__LOAD_LIBRARY(libfun4all.so)
0084 R__LOAD_LIBRARY(libffamodules.so)
0085 R__LOAD_LIBRARY(libphool.so)
0086 R__LOAD_LIBRARY(libcdbobjects.so)
0087 R__LOAD_LIBRARY(libmvtx.so)
0088 R__LOAD_LIBRARY(libintt.so)
0089 R__LOAD_LIBRARY(libtpc.so)
0090 R__LOAD_LIBRARY(libmicromegas.so)
0091 R__LOAD_LIBRARY(libTpcConditions.so)
0092 R__LOAD_LIBRARY(libPHGarfield.so)
0093 R__LOAD_LIBRARY(libtpctrackreco.so)
0094 R__LOAD_LIBRARY(libTrackingDiagnostics.so)
0095 R__LOAD_LIBRARY(libtrackingqa.so)
0096 R__LOAD_LIBRARY(libtrack_reco.so)
0097 
0098 
0099 bool isGood(const std::string &infile);
0100 int getrunnumber(const std::string &listfile);
0101 
0102 
0103 void Fun4All_PRDF_SAseed_run3pp(
0104     const int nEvents = 0,
0105     const int /*runnumber_unused*/ = 79513,
0106     const std::string & /*dir*/ = "/.",
0107     const std::string &outfilename = "output_tracks",
0108     const std::string &input_gl1file = "gl1daq.list",
0109     const std::string &input_inttfile00 = "intt0.list",
0110     const std::string &input_inttfile01 = "intt1.list",
0111     const std::string &input_inttfile02 = "intt2.list",
0112     const std::string &input_inttfile03 = "intt3.list",
0113     const std::string &input_inttfile04 = "intt4.list",
0114     const std::string &input_inttfile05 = "intt5.list",
0115     const std::string &input_inttfile06 = "intt6.list",
0116     const std::string &input_inttfile07 = "intt7.list",
0117     const std::string &input_mvtxfile00 = "mvtx0.list",
0118     const std::string &input_mvtxfile01 = "mvtx1.list",
0119     const std::string &input_mvtxfile02 = "mvtx2.list",
0120     const std::string &input_mvtxfile03 = "mvtx3.list",
0121     const std::string &input_mvtxfile04 = "mvtx4.list",
0122     const std::string &input_mvtxfile05 = "mvtx5.list",
0123     const std::string &input_tpcfile00 = "tpc00_0.list",
0124     const std::string &input_tpcfile01 = "tpc01_0.list",
0125     const std::string &input_tpcfile02 = "tpc02_0.list",
0126     const std::string &input_tpcfile03 = "tpc03_0.list",
0127     const std::string &input_tpcfile04 = "tpc04_0.list",
0128     const std::string &input_tpcfile05 = "tpc05_0.list",
0129     const std::string &input_tpcfile06 = "tpc06_0.list",
0130     const std::string &input_tpcfile07 = "tpc07_0.list",
0131     const std::string &input_tpcfile08 = "tpc08_0.list",
0132     const std::string &input_tpcfile09 = "tpc09_0.list",
0133     const std::string &input_tpcfile10 = "tpc10_0.list",
0134     const std::string &input_tpcfile11 = "tpc11_0.list",
0135     const std::string &input_tpcfile12 = "tpc12_0.list",
0136     const std::string &input_tpcfile13 = "tpc13_0.list",
0137     const std::string &input_tpcfile14 = "tpc14_0.list",
0138     const std::string &input_tpcfile15 = "tpc15_0.list",
0139     const std::string &input_tpcfile16 = "tpc16_0.list",
0140     const std::string &input_tpcfile17 = "tpc17_0.list",
0141     const std::string &input_tpcfile18 = "tpc18_0.list",
0142     const std::string &input_tpcfile19 = "tpc19_0.list",
0143     const std::string &input_tpcfile20 = "tpc20_0.list",
0144     const std::string &input_tpcfile21 = "tpc21_0.list",
0145     const std::string &input_tpcfile22 = "tpc22_0.list",
0146     const std::string &input_tpcfile23 = "tpc23_0.list",
0147     const std::string &input_tpcfile001 = "tpc00_1.list",
0148     const std::string &input_tpcfile011 = "tpc01_1.list",
0149     const std::string &input_tpcfile021 = "tpc02_1.list",
0150     const std::string &input_tpcfile031 = "tpc03_1.list",
0151     const std::string &input_tpcfile041 = "tpc04_1.list",
0152     const std::string &input_tpcfile051 = "tpc05_1.list",
0153     const std::string &input_tpcfile061 = "tpc06_1.list",
0154     const std::string &input_tpcfile071 = "tpc07_1.list",
0155     const std::string &input_tpcfile081 = "tpc08_1.list",
0156     const std::string &input_tpcfile091 = "tpc09_1.list",
0157     const std::string &input_tpcfile101 = "tpc10_1.list",
0158     const std::string &input_tpcfile111 = "tpc11_1.list",
0159     const std::string &input_tpcfile121 = "tpc12_1.list",
0160     const std::string &input_tpcfile131 = "tpc13_1.list",
0161     const std::string &input_tpcfile141 = "tpc14_1.list",
0162     const std::string &input_tpcfile151 = "tpc15_1.list",
0163     const std::string &input_tpcfile161 = "tpc16_1.list",
0164     const std::string &input_tpcfile171 = "tpc17_1.list",
0165     const std::string &input_tpcfile181 = "tpc18_1.list",
0166     const std::string &input_tpcfile191 = "tpc19_1.list",
0167     const std::string &input_tpcfile201 = "tpc20_1.list",
0168     const std::string &input_tpcfile211 = "tpc21_1.list",
0169     const std::string &input_tpcfile221 = "tpc22_1.list",
0170     const std::string &input_tpcfile231 = "tpc23_1.list",
0171     const std::string &input_tpotfile = "tpot.list")
0172 {
0173 
0174   std::vector<std::string> gl1_infile;
0175   gl1_infile.push_back(input_gl1file);
0176 
0177   // MVTX
0178   std::vector<std::string> mvtx_infile;
0179   mvtx_infile.push_back(input_mvtxfile00);
0180   mvtx_infile.push_back(input_mvtxfile01);
0181   mvtx_infile.push_back(input_mvtxfile02);
0182   mvtx_infile.push_back(input_mvtxfile03);
0183   mvtx_infile.push_back(input_mvtxfile04);
0184   mvtx_infile.push_back(input_mvtxfile05);
0185 
0186   // INTT
0187   std::vector<std::string> intt_infile;
0188   intt_infile.push_back(input_inttfile00);
0189   intt_infile.push_back(input_inttfile01);
0190   intt_infile.push_back(input_inttfile02);
0191   intt_infile.push_back(input_inttfile03);
0192   intt_infile.push_back(input_inttfile04);
0193   intt_infile.push_back(input_inttfile05);
0194   intt_infile.push_back(input_inttfile06);
0195   intt_infile.push_back(input_inttfile07);
0196 
0197   std::vector<std::string> tpc_infile;
0198   tpc_infile.push_back(input_tpcfile00);
0199   tpc_infile.push_back(input_tpcfile01);
0200   tpc_infile.push_back(input_tpcfile02);
0201   tpc_infile.push_back(input_tpcfile03);
0202   tpc_infile.push_back(input_tpcfile04);
0203   tpc_infile.push_back(input_tpcfile05);
0204   tpc_infile.push_back(input_tpcfile06);
0205   tpc_infile.push_back(input_tpcfile07);
0206   tpc_infile.push_back(input_tpcfile08);
0207   tpc_infile.push_back(input_tpcfile09);
0208   tpc_infile.push_back(input_tpcfile10);
0209   tpc_infile.push_back(input_tpcfile11);
0210   tpc_infile.push_back(input_tpcfile12);
0211   tpc_infile.push_back(input_tpcfile13);
0212   tpc_infile.push_back(input_tpcfile14);
0213   tpc_infile.push_back(input_tpcfile15);
0214   tpc_infile.push_back(input_tpcfile16);
0215   tpc_infile.push_back(input_tpcfile17);
0216   tpc_infile.push_back(input_tpcfile18);
0217   tpc_infile.push_back(input_tpcfile19);
0218   tpc_infile.push_back(input_tpcfile20);
0219   tpc_infile.push_back(input_tpcfile21);
0220   tpc_infile.push_back(input_tpcfile22);
0221   tpc_infile.push_back(input_tpcfile23);
0222   tpc_infile.push_back(input_tpcfile001);
0223   tpc_infile.push_back(input_tpcfile011);
0224   tpc_infile.push_back(input_tpcfile021);
0225   tpc_infile.push_back(input_tpcfile031);
0226   tpc_infile.push_back(input_tpcfile041);
0227   tpc_infile.push_back(input_tpcfile051);
0228   tpc_infile.push_back(input_tpcfile061);
0229   tpc_infile.push_back(input_tpcfile071);
0230   tpc_infile.push_back(input_tpcfile081);
0231   tpc_infile.push_back(input_tpcfile091);
0232   tpc_infile.push_back(input_tpcfile101);
0233   tpc_infile.push_back(input_tpcfile111);
0234   tpc_infile.push_back(input_tpcfile121);
0235   tpc_infile.push_back(input_tpcfile131);
0236   tpc_infile.push_back(input_tpcfile141);
0237   tpc_infile.push_back(input_tpcfile151);
0238   tpc_infile.push_back(input_tpcfile161);
0239   tpc_infile.push_back(input_tpcfile171);
0240   tpc_infile.push_back(input_tpcfile181);
0241   tpc_infile.push_back(input_tpcfile191);
0242   tpc_infile.push_back(input_tpcfile201);
0243   tpc_infile.push_back(input_tpcfile211);
0244   tpc_infile.push_back(input_tpcfile221);
0245   tpc_infile.push_back(input_tpcfile231);
0246 
0247   // TPOT
0248   std::vector<std::string> tpot_infile;
0249   tpot_infile.push_back(input_tpotfile);
0250 
0251   int runnumber = -99999;
0252   if (!gl1_infile.empty())
0253   {
0254     runnumber = getrunnumber(gl1_infile[0]);
0255   }
0256   else if (!mvtx_infile.empty())
0257   {
0258     runnumber = getrunnumber(mvtx_infile[0]);
0259   }
0260   else if (!intt_infile.empty())
0261   {
0262     runnumber = getrunnumber(intt_infile[0]);
0263   }
0264   else if (!tpc_infile.empty())
0265   {
0266     runnumber = getrunnumber(tpc_infile[0]);
0267   }
0268   else if (!tpot_infile.empty())
0269   {
0270     runnumber = getrunnumber(tpot_infile[0]);
0271   }
0272   if (runnumber == -99999)
0273   {
0274     std::cout << "could not extract run number from input files (all lists empty?)"
0275               << std::endl;
0276     gSystem->Exit(1);
0277   }
0278 
0279 
0280   
0281   auto *se = Fun4AllServer::instance();
0282   se->Verbosity(1);
0283   auto *rc = recoConsts::instance();
0284 
0285   Enable::QA = true;
0286   TRACKING::tpc_zero_supp = true;
0287   TRACKING::streaming_mode = true;
0288   G4TPC::REJECT_LASER_EVENTS = true;
0289   G4TPC::sampa_tzero_bias = 0;
0290 
0291   // First order corrections will be applied from PHGarfield
0292   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = false;
0293   G4TPC::ENABLE_STATIC_CORRECTIONS = false;
0294   G4TPC::ENABLE_AVERAGE_CORRECTIONS = false;
0295 
0296 
0297 
0298   rc->set_IntFlag("RUNNUMBER", runnumber);
0299   rc->set_IntFlag("RUNSEGMENT", 0);
0300 
0301   Enable::CDB = true;
0302   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0303   rc->set_uint64Flag("TIMESTAMP", runnumber);
0304 
0305 
0306   G4MAGNET::magfield_rescale = 1;
0307 
0308   TpcReadoutInit(runnumber);
0309   std::cout << " run: " << runnumber
0310             << " samples: " << TRACKING::reco_tpc_maxtime_sample
0311             << " pre: " << TRACKING::reco_tpc_time_presample
0312             << " vdrift: " << G4TPC::tpc_drift_velocity_reco
0313             << std::endl;
0314 
0315 
0316   Enable::MVTX = true;
0317   Enable::INTT = true;
0318   Enable::TPC = true;
0319   Enable::MICROMEGAS = true;
0320 
0321   G4Init();
0322   G4Setup();
0323 
0324   TrackingInit();
0325 
0326   SyncReco *sync = new SyncReco();
0327   se->registerSubsystem(sync);
0328 
0329   HeadReco *head = new HeadReco();
0330   se->registerSubsystem(head);
0331 
0332   FlagHandler *flag = new FlagHandler();
0333   se->registerSubsystem(flag);
0334   
0335   int i = 0;
0336   int NumInputs = 0;
0337   Fun4AllStreamingInputManager *in = new Fun4AllStreamingInputManager("Comb");
0338 
0339   for (const auto &iter : gl1_infile)
0340   {
0341     if (isGood(iter))
0342     {
0343       SingleGl1PoolInput *gl1_sngl = new SingleGl1PoolInput("GL1_" + std::to_string(i));
0344       //    gl1_sngl->Verbosity(3);
0345       gl1_sngl->AddListFile(iter);
0346       in->registerStreamingInput(gl1_sngl, InputManagerType::GL1);
0347       i++;
0348     }
0349   }
0350 
0351   i=0;
0352   
0353   for (const auto &iter : intt_infile)
0354   {
0355     if (isGood(iter))
0356     {
0357       SingleInttPoolInput *intt_sngl = new SingleInttPoolInput("INTT_" + std::to_string(i));
0358       // intt_sngl->Verbosity(3);
0359 
0360       /// find the ebdc number from the filename
0361       std::string filepath;
0362       std::string felix;
0363       std::ifstream ifs(iter);
0364       while (std::getline(ifs, filepath))
0365       {
0366         auto pos = filepath.find("intt");
0367         felix = filepath.substr(pos + 4, 1);
0368         break;
0369       }
0370       intt_sngl->setHitContainerName("INTTRAWHIT_" + felix);
0371       intt_sngl->AddListFile(iter);
0372       in->registerStreamingInput(intt_sngl, InputManagerType::INTT);
0373       i++;
0374       NumInputs++;
0375     }
0376   }
0377   i = 0;
0378   for (const auto &iter : mvtx_infile)
0379   {
0380     if (isGood(iter))
0381     {
0382       /// find the ebdc number from the filename
0383       std::string filepath;
0384       std::string felix;
0385       std::ifstream ifs(iter);
0386       while (std::getline(ifs, filepath))
0387       {
0388         auto pos = filepath.find("mvtx");
0389         felix = filepath.substr(pos + 4, 1);
0390         break;
0391       }
0392 
0393       SingleMvtxPoolInput *mvtx_sngl = new SingleMvtxPoolInput("MVTX_" + std::to_string(i));
0394       //    mvtx_sngl->Verbosity(5);
0395       mvtx_sngl->setHitContainerName("MVTXRAWHIT_" + felix);
0396       mvtx_sngl->setRawEventHeaderName("MVTXRAWEVTHEADER_" + felix);
0397       mvtx_sngl->AddListFile(iter);
0398       in->registerStreamingInput(mvtx_sngl, InputManagerType::MVTX);
0399       i++;
0400       NumInputs++;
0401     }
0402   }
0403   i = 0;
0404   for (const auto &iter : tpc_infile)
0405   {
0406     if (isGood(iter))
0407     {
0408       /// find the ebdc number from the filename
0409       std::string filepath;
0410       std::string ebdc;
0411       std::ifstream ifs(iter);
0412       while (std::getline(ifs, filepath))
0413       {
0414         auto pos = filepath.find("ebdc");
0415         ebdc = filepath.substr(pos + 4, 4);
0416         break;
0417       }
0418 
0419       SingleTpcTimeFrameInput *tpc_sngl = new SingleTpcTimeFrameInput("TPC_" + std::to_string(i));
0420       //    tpc_sngl->Verbosity(2);
0421       //   tpc_sngl->DryRun();
0422       tpc_sngl->setHitContainerName("TPCRAWHIT_" + ebdc);
0423       tpc_sngl->AddListFile(iter);
0424       in->registerStreamingInput(tpc_sngl, InputManagerType::TPC);
0425       i++;
0426       NumInputs++;
0427     }
0428   }
0429   i = 0;
0430 
0431   for (const auto &iter : tpot_infile)
0432   {
0433     if (isGood(iter))
0434     {
0435       SingleMicromegasPoolInput *mm_sngl = new SingleMicromegasPoolInput("MICROMEGAS_" + std::to_string(i));
0436       //   sngl->Verbosity(3);
0437       mm_sngl->SetBcoRange(10);
0438       mm_sngl->SetNegativeBco(2);
0439       mm_sngl->SetBcoPoolSize(150);
0440       mm_sngl->AddListFile(iter);
0441       in->registerStreamingInput(mm_sngl, InputManagerType::MICROMEGAS);
0442       i++;
0443       NumInputs++;
0444     }
0445   }
0446 
0447   // if there is no input manager this macro will still run - so just quit here
0448   if (NumInputs == 0)
0449   {
0450     std::cout << "no file lists no input manager registered, quitting" << std::endl;
0451     gSystem->Exit(1);
0452   }
0453   se->registerInputManager(in);
0454 
0455 
0456   for (int felix = 0; felix < 6; felix++)
0457   {
0458     Mvtx_HitUnpacking(std::to_string(felix));
0459   }
0460   for (int server = 0; server < 8; server++)
0461   {
0462     Intt_HitUnpacking(std::to_string(server));
0463   }
0464   std::ostringstream ebdcname;
0465   for (int ebdc = 0; ebdc < 24; ebdc++)
0466   {
0467     for (int endpoint = 0; endpoint < 2; endpoint++)
0468     {
0469       ebdcname.str("");
0470       if (ebdc < 10)
0471       {
0472         ebdcname << "0";
0473       }
0474       ebdcname << ebdc << "_" << endpoint;
0475       Tpc_HitUnpacking(ebdcname.str());
0476     }
0477   }
0478   Micromegas_HitUnpacking();
0479 
0480   //==============================================================
0481 
0482   Mvtx_Clustering();
0483   Intt_Clustering();
0484   Micromegas_Clustering();
0485 
0486   //==============================================================
0487 
0488   Tpc_LaserEventIdentifying();
0489   Reject_Laser_Events();
0490 
0491   //==============================================================
0492 
0493   Tracking_Reco_SiliconSeed_run2pp();
0494   auto *converter = new TrackSeedTrackMapConverter("SiliconSeedToSvtxTrackMap");
0495   converter->setTrackSeedName("SiliconTrackSeedContainer");
0496   converter->setTrackMapName("SiliconSvtxTrackMap");
0497   converter->setClusterMapName("TRKR_CLUSTER");
0498   se->registerSubsystem(converter);
0499 
0500   auto *finder_svx = new PHSimpleVertexFinder("SiliconVertexFinder");
0501   finder_svx->Verbosity(0);
0502   finder_svx->setDcaCut(0.1);
0503   finder_svx->setTrackPtCut(0.2);
0504   finder_svx->setBeamLineCut(1);
0505   finder_svx->setTrackQualityCut(500);
0506   finder_svx->setNmvtxRequired(3);
0507   finder_svx->setOutlierPairCut(0.1);
0508   finder_svx->setTrackMapName("SiliconSvtxTrackMap");
0509   finder_svx->setVertexMapName("SiliconSvtxVertexMap");
0510   se->registerSubsystem(finder_svx);
0511 
0512   //==============================================================
0513   se->registerSubsystem(new TpcConditionsReco());
0514 
0515   // Configure the shared drift model before the crossing finder and clusterizer.
0516   auto *garfield = new PHGarfield();
0517   garfield->SetUseSurveyGeometry(true);
0518   se->registerSubsystem(garfield);
0519 
0520   se->registerSubsystem(new Tpc_ModuleTrackReco());     // makes TPC_MODULETRACKS
0521   se->registerSubsystem(new Tpc_AssembledTrackReco());  // makes TPC_ASSEMBLEDTRACKS
0522 
0523   auto *crossingFinder = new TpcCrossingFinder();
0524   crossingFinder->Verbosity(0);
0525   crossingFinder->setInputNodeName("TPC_ASSEMBLEDTRACKS");
0526   crossingFinder->setOutputNodeName("TPC_CROSSING_DECISIONS");
0527   crossingFinder->setVertexMapNodeName("SiliconSvtxVertexMap");  // optional, configurable
0528   se->registerSubsystem(crossingFinder);
0529 
0530   auto *cluster = new Tpc_PolyClusterizer();  // makes TPC_POLYCLUSTERS
0531   se->registerSubsystem(cluster);
0532 
0533   se->registerSubsystem(new Tpc_PolyTrackReco());      // makes TPC_POLYTRACKS
0534   se->registerSubsystem(new Tpc_PolyTrackVertexer());  // makes TPC_POLYTRACKVERTICES
0535 
0536   se->registerSubsystem(new TpcPolyTrackSeedConverter());           // converts TPC_POLYTRACKS to TpcTrackSeed
0537   se->registerSubsystem(new TpcPolyClusterTrkrClusterConverter());  // converts TPC_POLYCLUSTERS to TRKR_CLUSTER
0538 
0539   Tracking_Reco_TrackMatching_run2pp();
0540 
0541   
0542   Tracking_Reco_TrackFit_run2pp();
0543   // vertexing and propagation to vertex
0544   Tracking_Reco_Vertex_run2pp();
0545 
0546   
0547 
0548   if (Enable::QA)
0549   {
0550     se->registerSubsystem(new MvtxRawHitQA);
0551     se->registerSubsystem(new InttRawHitQA);
0552     se->registerSubsystem(new TpcRawHitQA);
0553     se->registerSubsystem(new MvtxClusterQA);
0554     se->registerSubsystem(new InttClusterQA);
0555     se->registerSubsystem(new TpcClusterQA);
0556     se->registerSubsystem(new MicromegasClusterQA);
0557 
0558     auto *siliconqa = new SiliconSeedsQA;
0559     siliconqa->setTrackMapName("SiliconSvtxTrackMap");
0560     siliconqa->setVertexMapName("SiliconSvtxVertexMap");
0561     se->registerSubsystem(siliconqa);
0562 
0563     auto *convertertpc = new TrackSeedTrackMapConverter("TpcSeedConverter");
0564     // Default set to full SvtxTrackSeeds. Can be set to
0565     // SiliconTrackSeedContainer or TpcTrackSeedContainer
0566     convertertpc->setTrackSeedName("TpcTrackSeedContainer");
0567     convertertpc->setTrackMapName("TpcSvtxTrackMap");
0568     convertertpc->setFieldMap(G4MAGNET::magfield_tracking);
0569     convertertpc->Verbosity(0);
0570     se->registerSubsystem(convertertpc);
0571 
0572     auto *findertpc = new PHSimpleVertexFinder("TpcSimpleVertexFinder");
0573     findertpc->Verbosity(0);
0574     findertpc->setDcaCut(1);
0575     findertpc->setTrackPtCut(0.2);
0576     findertpc->setBeamLineCut(1.5);
0577     findertpc->setTrackQualityCut(1000000000);
0578     //findertpc->setNmvtxRequired(3);
0579     findertpc->setRequireMVTX(false);
0580     findertpc->setOutlierPairCut(0.1);
0581     findertpc->set_pp_mode(false);
0582     findertpc->setTrackMapName("TpcSvtxTrackMap");
0583     findertpc->setVertexMapName("TpcSvtxVertexMap");
0584     se->registerSubsystem(findertpc);
0585 
0586     auto *tpcqa = new TpcSeedsQA;
0587     tpcqa->setTrackMapName("TpcSvtxTrackMap");
0588     tpcqa->setVertexMapName("TpcSvtxVertexMap");
0589     tpcqa->setSegment(rc->get_IntFlag("RUNSEGMENT"));
0590     se->registerSubsystem(tpcqa);
0591 
0592 
0593     se->registerSubsystem(new TpcSiliconQA);
0594     se->registerSubsystem(new TrackFittingQA);
0595   }
0596 
0597   se->run(nEvents);
0598   se->End();
0599   se->PrintTimer();
0600 
0601   if (Enable::QA)
0602   {
0603     std::string qaOutputFileName = outfilename + std::to_string(runnumber) + "_qa.root";
0604     QAHistManagerDef::saveQARootFile(qaOutputFileName);
0605   }
0606  
0607   CDBInterface::instance()->Print();
0608   delete se;
0609   std::cout << "Finished" << std::endl;
0610   gSystem->Exit(0);
0611 }
0612 
0613 bool isGood(const std::string &infile)
0614 {
0615   std::ifstream intest;
0616   intest.open(infile);
0617   bool goodfile = false;
0618   if (intest.is_open())
0619   {
0620     if (intest.peek() != std::ifstream::traits_type::eof())  // is it non zero?
0621     {
0622       goodfile = true;
0623     }
0624     intest.close();
0625   }
0626   return goodfile;
0627 }
0628 
0629 int getrunnumber(const std::string &listfile)
0630 {
0631   if (!isGood(listfile))
0632   {
0633     std::cout << "listfile " << listfile << " is bad" << std::endl;
0634     gSystem->Exit(1);
0635   }
0636   std::ifstream ifs(listfile);
0637   std::string filepath;
0638   std::getline(ifs, filepath);
0639 
0640   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(filepath);
0641   int runnumber = runseg.first;
0642   //  int segment = abs(runseg.second);
0643   return runnumber;
0644 }