File indexing completed on 2025-12-16 09:24:10
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 R__LOAD_LIBRARY(libfun4all.so)
0039 R__LOAD_LIBRARY(libffamodules.so)
0040 R__LOAD_LIBRARY(libphool.so)
0041 R__LOAD_LIBRARY(libcdbobjects.so)
0042 R__LOAD_LIBRARY(libtrack_reco.so)
0043 R__LOAD_LIBRARY(libcalo_reco.so)
0044 R__LOAD_LIBRARY(libcalotrigger.so)
0045 R__LOAD_LIBRARY(libcentrality.so)
0046 R__LOAD_LIBRARY(libmbd.so)
0047 R__LOAD_LIBRARY(libepd.so)
0048 R__LOAD_LIBRARY(libzdcinfo.so)
0049 void Fun4All_TrackCaloAnalysis(
0050 const int nEvents = 10,
0051 const std::string& trackfilename = "DST_TRKR_TRACKS_run2pp_ana475_2024p017_v001-00053877-00000.root",
0052 const std::string& trackdir = "/sphenix/lustre01/sphnxpro/production/run2pp/physics/ana475_2024p017_v001/DST_TRKR_TRACKS/run_00053800_00053900/dst/",
0053 const std::string& calofilename = "DST_CALO_run2pp_ana468_2024p012_v001-00053877-00000.root",
0054 const std::string& calodir = "/sphenix/lustre01/sphnxpro/production/run2pp/physics/ana468_2024p012_v001/DST_CALO/run_00053800_00053900/dst/",
0055 const std::string& outfilename = "tracks_calos",
0056 const std::string& outdir = "./")
0057 {
0058 std::string inputTrackFile = trackdir + trackfilename;
0059 std::string inputCaloFile = calodir + calofilename;
0060
0061 std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(trackfilename);
0062 int runnumber = runseg.first;
0063 int segment = runseg.second;
0064
0065 std::string theOutfileheader = outdir + outfilename + "_" + std::to_string(runnumber) + "-" + std::to_string(segment);
0066
0067 Enable::MVTX_APPLYMISALIGNMENT = true;
0068 ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0069 TRACKING::pp_mode = true;
0070
0071 auto *se = Fun4AllServer::instance();
0072 se->Verbosity(1);
0073
0074 auto *rc = recoConsts::instance();
0075 rc->set_IntFlag("RUNNUMBER", runnumber);
0076 rc->set_IntFlag("RUNSEGMENT", segment);
0077
0078 Enable::CDB = true;
0079 rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0080 rc->set_uint64Flag("TIMESTAMP", runnumber);
0081 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0082
0083 Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0084 ingeo->AddFile(geofile);
0085 se->registerInputManager(ingeo);
0086
0087 TpcReadoutInit( runnumber );
0088 std::cout << " run: " << runnumber
0089 << " samples: " << TRACKING::reco_tpc_maxtime_sample
0090 << " pre: " << TRACKING::reco_tpc_time_presample
0091 << " vdrift: " << G4TPC::tpc_drift_velocity_reco
0092 << std::endl;
0093
0094 G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0095
0096
0097 G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0098 G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS = false;
0099
0100
0101
0102 G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0103 G4TPC::USE_PHI_AS_RAD_AVERAGE_CORRECTIONS = false;
0104
0105 G4TPC::average_correction_filename = CDBInterface::instance()->getUrl("TPC_LAMINATION_FIT_CORRECTION");
0106
0107 G4MAGNET::magfield_rescale = 1;
0108 TrackingInit();
0109
0110 auto *trackin = new Fun4AllDstInputManager("TrackInManager");
0111 trackin->fileopen(inputTrackFile);
0112 se->registerInputManager(trackin);
0113
0114 auto *caloin = new Fun4AllDstInputManager("CaloInManager");
0115 caloin->fileopen(inputCaloFile);
0116 se->registerInputManager(caloin);
0117
0118 Global_Reco();
0119
0120 auto *projection = new PHActsTrackProjection("CaloProjection");
0121 float new_cemc_rad = 99;
0122 bool doEMcalRadiusCorr = true;
0123 if (doEMcalRadiusCorr)
0124 {
0125 projection->setLayerRadius(SvtxTrack::CEMC, new_cemc_rad);
0126 }
0127 se->registerSubsystem(projection);
0128
0129
0130
0131
0132 if (Enable::DSTOUT)
0133 {
0134 std::string dstOutputFileName= theOutfileheader + "_dst.root";
0135 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", dstOutputFileName);
0136 out->AddNode("Sync");
0137 out->AddNode("EventHeader");
0138 out->AddNode("SvtxTrackMap");
0139 out->AddNode("GlobalVertexMap");
0140 out->AddNode("CLUSTERINFO_CEMC");
0141 se->registerOutputManager(out);
0142 }
0143
0144 se->run(nEvents);
0145 se->End();
0146 se->PrintTimer();
0147
0148 if(Enable::QA)
0149 {
0150 std::string qaOutputFileName = theOutfileheader + "_qa.root";
0151 QAHistManagerDef::saveQARootFile(qaOutputFileName);
0152 }
0153
0154 CDBInterface::instance()->Print();
0155 delete se;
0156 std::cout << "Finished" << std::endl;
0157 gSystem->Exit(0);
0158
0159 return;
0160 }
0161
0162 std::string GetFirstLine(const std::string& listname)
0163 {
0164 std::ifstream file(listname);
0165
0166 std::string firstLine;
0167 if (file.is_open()) {
0168 if (std::getline(file, firstLine)) {
0169 std::cout << "First Line: " << firstLine << std::endl;
0170 } else {
0171 std::cerr << "Unable to read first line of file" << std::endl;
0172 }
0173 file.close();
0174 } else {
0175 std::cerr << "Unable to open file" << std::endl;
0176 }
0177 return firstLine;
0178 }