File indexing completed on 2025-12-16 09:16:12
0001 #include <fun4all/Fun4AllUtils.h>
0002 #include <G4_ActsGeom.C>
0003 #include <G4_Magnet.C>
0004 #include <GlobalVariables.C>
0005 #include <Trkr_Reco.C>
0006 #include <Trkr_RecoInit.C>
0007 #include <Trkr_TpcReadoutInit.C>
0008 #include <QA.C>
0009
0010 #include <ffamodules/CDBInterface.h>
0011
0012 #include <fun4all/Fun4AllDstInputManager.h>
0013 #include <fun4all/Fun4AllDstOutputManager.h>
0014 #include <fun4all/Fun4AllInputManager.h>
0015 #include <fun4all/Fun4AllOutputManager.h>
0016 #include <fun4all/Fun4AllRunNodeInputManager.h>
0017 #include <fun4all/Fun4AllServer.h>
0018
0019 #include <trackreco/PHTrackPruner.h>
0020
0021 #include <phool/recoConsts.h>
0022
0023 #include <cdbobjects/CDBTTree.h>
0024
0025 #include <kfparticle_sphenix/KFParticle_sPHENIX.h>
0026
0027 #include <stdio.h>
0028
0029 #include "HF_selections_QM25.C"
0030
0031 #include <trackingdiagnostics/TrackResiduals.h>
0032 #include <trackingdiagnostics/TrkrNtuplizer.h>
0033
0034 using namespace HeavyFlavorReco;
0035
0036 R__LOAD_LIBRARY(libfun4all.so)
0037 R__LOAD_LIBRARY(libffamodules.so)
0038 R__LOAD_LIBRARY(libphool.so)
0039 R__LOAD_LIBRARY(libcdbobjects.so)
0040
0041
0042 void Fun4All_HF_IS25(
0043 const int nEvents = 100,
0044 const std::string inputDST = "DST_TRKR_TRACKS_run2pp_ana506_2024p023_v001-00053877-00000.root",
0045 const std::string inputDir = "/sphenix/lustre01/sphnxpro/production/run2pp/physics/ana506_2024p023_v001/DST_TRKR_TRACKS/run_00053800_00053900/dst/",
0046 const int nSkip = 0)
0047 {
0048 bool runTrkrNtuplizer = true;
0049 bool runQA = false;
0050
0051 std::string inputTrackFile = inputDir + inputDST;
0052
0053 std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(inputDST);
0054 int runnumber = runseg.first;
0055 std::stringstream nice_runnumber;
0056 nice_runnumber << std::setw(8) << std::setfill('0') << to_string(runnumber);
0057
0058 int rounded_up = 100*(std::ceil((float) runnumber/100));
0059 std::stringstream nice_rounded_up;
0060 nice_rounded_up << std::setw(8) << std::setfill('0') << to_string(rounded_up);
0061
0062 int rounded_down = 100*(std::floor((float) runnumber/100));
0063 std::stringstream nice_rounded_down;
0064 nice_rounded_down << std::setw(8) << std::setfill('0') << to_string(rounded_down);
0065
0066 int segment = runseg.second;
0067 std::stringstream nice_segment;
0068 nice_segment << std::setw(5) << std::setfill('0') << to_string(segment);
0069
0070 std::stringstream nice_skip;
0071 nice_skip << std::setw(5) << std::setfill('0') << to_string(nSkip);
0072
0073 auto rc = recoConsts::instance();
0074 rc->set_IntFlag("RUNNUMBER", runnumber);
0075
0076 Enable::CDB = true;
0077 rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0078 rc->set_uint64Flag("TIMESTAMP", runnumber);
0079 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0080
0081 TpcReadoutInit(runnumber);
0082 std::cout << " run: " << runnumber
0083 << " samples: " << TRACKING::reco_tpc_maxtime_sample
0084 << " pre: " << TRACKING::reco_tpc_time_presample
0085 << " vdrift: " << G4TPC::tpc_drift_velocity_reco
0086 << std::endl;
0087
0088
0089 trailer = "_" + nice_runnumber.str() + "_" + nice_segment.str() + "_" + nice_skip.str() + ".root";
0090
0091 if (run_pipi_reco) create_hf_directories(pipi_reconstruction_name, pipi_output_dir, pipi_output_reco_file);
0092 if (run_ppi_reco) create_hf_directories(ppi_reconstruction_name, ppi_output_dir, ppi_output_reco_file);
0093 if (run_KK_reco) create_hf_directories(KK_reconstruction_name, KK_output_dir, KK_output_reco_file);
0094
0095 auto se = Fun4AllServer::instance();
0096 se->Verbosity(1);
0097
0098 G4TRACKING::SC_CALIBMODE = false;
0099 Enable::MVTX_APPLYMISALIGNMENT = true;
0100 ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0101 TRACKING::pp_mode = true;
0102
0103 Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0104 ingeo->AddFile(geofile);
0105 se->registerInputManager(ingeo);
0106
0107 G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0108
0109
0110 G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0111 G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS = false;
0112
0113
0114
0115 G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0116 G4TPC::USE_PHI_AS_RAD_AVERAGE_CORRECTIONS = false;
0117
0118 G4TPC::average_correction_filename = CDBInterface::instance()->getUrl("TPC_LAMINATION_FIT_CORRECTION");
0119
0120 G4MAGNET::magfield_rescale = 1;
0121
0122 TrackingInit();
0123
0124 auto hitsintrack = new Fun4AllDstInputManager("TrackInputManager");
0125 hitsintrack->fileopen(inputTrackFile);
0126 se->registerInputManager(hitsintrack);
0127
0128
0129 std::string clus_file = "/sphenix/lustre01/sphnxpro/production/run2pp/physics/ana505_2024p023_v001/DST_TRKR_CLUSTER/run_"
0130 + nice_rounded_down.str() + "_" + nice_rounded_up.str()
0131 + "/dst/DST_TRKR_CLUSTER_run2pp_ana505_2024p023_v001-" + nice_runnumber.str() + "-" + nice_segment.str() + ".root";
0132
0133 auto hitsinclus = new Fun4AllDstInputManager("ClusterInputManager");
0134 hitsinclus->fileopen(clus_file);
0135 se->registerInputManager(hitsinclus);
0136
0137
0138
0139 if (run_pipi_reco) reconstruct_pipi_mass();
0140 if (run_ppi_reco) reconstruct_ppi_mass();
0141 if (run_KK_reco) reconstruct_KK_mass();
0142
0143 string nTuplizer_dir = output_dir + "/nTP/";
0144 string NTP_output_reco_file = nTuplizer_dir + processing_folder + "nTuplizer_tracks" + trailer;
0145
0146 if (runTrkrNtuplizer)
0147 {
0148 std::string makeDirectory = "mkdir -p " + nTuplizer_dir + processing_folder;
0149 system(makeDirectory.c_str());
0150
0151 TrkrNtuplizer* eval = new TrkrNtuplizer("TrkrNtuplizer", NTP_output_reco_file, "SvtxTrackMap", 3, 4, 48);
0152 int do_default = 0;
0153 eval->Verbosity(0);
0154 eval->runnumber(runnumber);
0155 eval->segment(segment);
0156 eval->do_hit_eval(false);
0157 eval->do_cluster_eval(false);
0158 eval->do_clus_trk_eval(false);
0159 eval->do_vertex_eval(false);
0160 eval->do_track_eval(true);
0161 eval->do_tpcseed_eval(false);
0162 eval->do_siseed_eval(false);
0163 se->registerSubsystem(eval);
0164 }
0165
0166 se->skip(nSkip);
0167 se->run(nEvents);
0168
0169 if (runQA)
0170 {
0171 std::string output_dir_QA = output_dir + "/qaOut";
0172 std::string makeDirectory = "mkdir -p " + output_dir_QA;
0173 system(makeDirectory.c_str());
0174 QA_Output(output_dir_QA + "/qaHists" + trailer);
0175 }
0176
0177 se->End();
0178 se->PrintTimer();
0179
0180 if (runTrkrNtuplizer) end_kfparticle(NTP_output_reco_file, nTuplizer_dir);
0181
0182 if (run_pipi_reco) end_kfparticle(pipi_output_reco_file, pipi_output_dir);
0183 if (run_ppi_reco) end_kfparticle(ppi_output_reco_file, ppi_output_dir);
0184 if (run_KK_reco) end_kfparticle(KK_output_reco_file, KK_output_dir);
0185
0186 delete se;
0187
0188 std::cout << "Finished" << std::endl;
0189 gSystem->Exit(0);
0190 }