File indexing completed on 2026-08-31 08:24:38
0001
0002
0003
0004
0005
0006
0007
0008 #include <GlobalVariables.C>
0009
0010 #include <G4_ActsGeom.C>
0011 #include <G4_Global.C>
0012 #include <G4_Magnet.C>
0013 #include <Trkr_Clustering.C>
0014 #include <Trkr_Reco.C>
0015 #include <Trkr_RecoInit.C>
0016 #include <Trkr_TpcReadoutInit.C>
0017 #include <QA.C>
0018
0019 #include <trackreco/PHActsTrackProjection.h>
0020
0021 #include <trackbase_historic/SvtxTrack.h>
0022
0023 #include <ffamodules/CDBInterface.h>
0024
0025 #include <fun4all/Fun4AllDstInputManager.h>
0026 #include <fun4all/Fun4AllDstOutputManager.h>
0027 #include <fun4all/Fun4AllInputManager.h>
0028 #include <fun4all/Fun4AllUtils.h>
0029 #include <fun4all/Fun4AllOutputManager.h>
0030 #include <fun4all/Fun4AllRunNodeInputManager.h>
0031 #include <fun4all/Fun4AllServer.h>
0032
0033 #include <phool/recoConsts.h>
0034
0035 #include <iostream>
0036 #include <filesystem>
0037
0038 #include <mbd/MbdReco.h>
0039 #include <mbdcalib/MbdTrackVertex.h>
0040
0041 R__LOAD_LIBRARY(libfun4all.so)
0042 R__LOAD_LIBRARY(libffamodules.so)
0043 R__LOAD_LIBRARY(libphool.so)
0044 R__LOAD_LIBRARY(libcdbobjects.so)
0045 R__LOAD_LIBRARY(libtrack_reco.so)
0046 R__LOAD_LIBRARY(libcalo_reco.so)
0047 R__LOAD_LIBRARY(libcalotrigger.so)
0048 R__LOAD_LIBRARY(libcentrality.so)
0049 R__LOAD_LIBRARY(libmbd.so)
0050 R__LOAD_LIBRARY(libepd.so)
0051 R__LOAD_LIBRARY(libzdcinfo.so)
0052 R__LOAD_LIBRARY(libmbd.so)
0053 R__LOAD_LIBRARY(libmbdcalib.so)
0054
0055 void Fun4All_MBD_TrackVertex(
0056 const int nEvents = 10,
0057 const std::string& trackfilename = "DST_TRKR_TRACKS_run2pp_ana475_2024p017_v001-00053877-00000.root",
0058 const std::string& calofilename = "DST_CALO_run2pp_ana468_2024p012_v001-00053877-00000.root",
0059 const std::string& outfilename = "mbd_trkvtx",
0060 const std::string& outdir = "./")
0061 {
0062 const std::string& inputTrackFile = trackfilename;
0063 const std::string& inputCaloFile = calofilename;
0064
0065 std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(trackfilename);
0066 int runnumber = runseg.first;
0067 int segment = runseg.second;
0068
0069 std::string theOutfileheader = outdir + outfilename + "_" + std::to_string(runnumber) + "-" + std::to_string(segment);
0070
0071 Enable::MVTX_APPLYMISALIGNMENT = true;
0072 ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0073 TRACKING::streaming_mode = true;
0074
0075 auto *se = Fun4AllServer::instance();
0076 se->Verbosity(1);
0077
0078 auto *rc = recoConsts::instance();
0079 rc->set_IntFlag("RUNNUMBER", runnumber);
0080 rc->set_IntFlag("RUNSEGMENT", segment);
0081
0082 Enable::CDB = true;
0083 rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0084 rc->set_uint64Flag("TIMESTAMP", runnumber);
0085 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0086
0087 Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0088 ingeo->AddFile(geofile);
0089 se->registerInputManager(ingeo);
0090
0091 TpcReadoutInit( runnumber );
0092 std::cout << " run: " << runnumber
0093 << " samples: " << TRACKING::reco_tpc_maxtime_sample
0094 << " pre: " << TRACKING::reco_tpc_time_presample
0095 << " vdrift: " << G4TPC::tpc_drift_velocity_reco
0096 << std::endl;
0097
0098 G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0099
0100
0101 G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0102
0103
0104
0105 G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0106
0107 G4MAGNET::magfield_rescale = 1;
0108 TrackingInit();
0109
0110 auto *trackin = new Fun4AllDstInputManager("TrackInManager");
0111 trackin->fileopen(inputTrackFile);
0112
0113 se->registerInputManager(trackin);
0114
0115 auto *caloin = new Fun4AllDstInputManager("CaloInManager");
0116 caloin->fileopen(inputCaloFile);
0117
0118 se->registerInputManager(caloin);
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 MbdReco *mbdreco = new MbdReco();
0133
0134
0135 rc->set_StringFlag("MBD_TT_T0", "mbd_tt_t0.calib");
0136 rc->set_StringFlag("MBD_TQ_T0", "mbd_tq_t0.calib");
0137 se->registerSubsystem(mbdreco);
0138
0139 Global_Reco();
0140
0141 MbdTrackVertex *mbdtrkvtx = new MbdTrackVertex();
0142 se->registerSubsystem( mbdtrkvtx );
0143
0144 if (Enable::DSTOUT)
0145 {
0146 std::string dstOutputFileName= theOutfileheader + "_dst.root";
0147 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", dstOutputFileName);
0148 out->AddNode("Sync");
0149 out->AddNode("EventHeader");
0150 out->AddNode("SvtxTrackMap");
0151 out->AddNode("GlobalVertexMap");
0152 out->AddNode("CLUSTERINFO_CEMC");
0153 se->registerOutputManager(out);
0154 }
0155
0156 se->run(nEvents);
0157 se->End();
0158 se->PrintTimer();
0159
0160 if(Enable::QA)
0161 {
0162 std::string qaOutputFileName = theOutfileheader + "_qa.root";
0163 QAHistManagerDef::saveQARootFile(qaOutputFileName);
0164 }
0165
0166 CDBInterface::instance()->Print();
0167 delete se;
0168 std::cout << "Finished" << std::endl;
0169 gSystem->Exit(0);
0170
0171 return;
0172 }
0173
0174 std::string GetFirstLine(const std::string& listname)
0175 {
0176 std::ifstream file(listname);
0177
0178 std::string firstLine;
0179 if (file.is_open()) {
0180 if (std::getline(file, firstLine)) {
0181 std::cout << "First Line: " << firstLine << std::endl;
0182 } else {
0183 std::cerr << "Unable to read first line of file" << std::endl;
0184 }
0185 file.close();
0186 } else {
0187 std::cerr << "Unable to open file" << std::endl;
0188 }
0189 return firstLine;
0190 }