File indexing completed on 2025-12-16 09:24:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <GlobalVariables.C>
0011
0012 #include <G4_ActsGeom.C>
0013 #include <G4_Global.C>
0014 #include <G4_Magnet.C>
0015 #include <QA.C>
0016 #include <Trkr_Clustering.C>
0017 #include <Trkr_Reco.C>
0018 #include <Trkr_RecoInit.C>
0019 #include <Trkr_TpcReadoutInit.C>
0020
0021 #include <cdbobjects/CDBTTree.h>
0022
0023 #include <tpccalib/PHTpcResiduals.h>
0024
0025 #include <trackingqa/SiliconSeedsQA.h>
0026 #include <trackingqa/TpcSeedsQA.h>
0027 #include <trackingqa/TpcSiliconQA.h>
0028
0029 #include <trackingdiagnostics/TrackResiduals.h>
0030 #include <trackingdiagnostics/TrkrNtuplizer.h>
0031
0032 #include <ffamodules/CDBInterface.h>
0033
0034 #include <fun4all/Fun4AllDstInputManager.h>
0035 #include <fun4all/Fun4AllDstOutputManager.h>
0036 #include <fun4all/Fun4AllInputManager.h>
0037 #include <fun4all/Fun4AllOutputManager.h>
0038 #include <fun4all/Fun4AllRunNodeInputManager.h>
0039 #include <fun4all/Fun4AllServer.h>
0040 #include <fun4all/Fun4AllUtils.h>
0041
0042 #include <phool/recoConsts.h>
0043
0044 R__LOAD_LIBRARY(libfun4all.so)
0045 R__LOAD_LIBRARY(libffamodules.so)
0046 R__LOAD_LIBRARY(libphool.so)
0047 R__LOAD_LIBRARY(libcdbobjects.so)
0048 R__LOAD_LIBRARY(libTrackingDiagnostics.so)
0049 R__LOAD_LIBRARY(libtrackingqa.so)
0050 void Fun4All_TrackFitting(
0051 const int nEvents = 10,
0052 const std::string& seedfilename = "/sphenix/lustre01/sphnxpro/production/run2pp/physics/ana494_2024p021_v001/DST_TRKR_SEED/run_00053800_00053900/dst/DST_TRKR_SEED_run2pp_ana494_2024p021_v001-00053877-00000.root",
0053 const std::string& clusterfilename = "/sphenix/lustre01/sphnxpro/production/run2pp/physics/ana494_2024p021_v001/DST_TRKR_CLUSTER/run_00053800_00053900/dst/DST_TRKR_CLUSTER_run2pp_ana494_2024p021_v001-00053877-00000.root",
0054 const std::string& outfilename = "clusters_seeds",
0055 const bool convertSeeds = false)
0056 {
0057
0058 G4TRACKING::convert_seeds_to_svtxtracks = convertSeeds;
0059 std::cout << "Converting to seeds : " << G4TRACKING::convert_seeds_to_svtxtracks << std::endl;
0060 std::pair<int, int>
0061 runseg = Fun4AllUtils::GetRunSegment(seedfilename);
0062 int runnumber = runseg.first;
0063 int segment = runseg.second;
0064
0065 std::cout << " run: " << runnumber
0066 << " samples: " << TRACKING::reco_tpc_maxtime_sample
0067 << " pre: " << TRACKING::reco_tpc_time_presample
0068 << " vdrift: " << G4TPC::tpc_drift_velocity_reco
0069 << std::endl;
0070
0071
0072
0073
0074
0075
0076 G4TRACKING::SC_CALIBMODE = false;
0077 Enable::MVTX_APPLYMISALIGNMENT = true;
0078 ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0079 TRACKING::pp_mode = true;
0080
0081 std::string theOutfile = outfilename + "_" + std::to_string(runnumber) + "-" + std::to_string(segment) + ".root";
0082
0083 auto *se = Fun4AllServer::instance();
0084 se->Verbosity(1);
0085
0086 auto *rc = recoConsts::instance();
0087 rc->set_IntFlag("RUNNUMBER", runnumber);
0088
0089 Enable::CDB = true;
0090 rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0091 rc->set_uint64Flag("TIMESTAMP", runnumber);
0092 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0093
0094 Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0095 ingeo->AddFile(geofile);
0096 se->registerInputManager(ingeo);
0097
0098 TpcReadoutInit( runnumber );
0099
0100
0101
0102
0103 G4TPC::REJECT_LASER_EVENTS=true;
0104 G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0105
0106
0107 G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0108 G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS = false;
0109
0110
0111
0112 G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0113 G4TPC::USE_PHI_AS_RAD_AVERAGE_CORRECTIONS = false;
0114
0115 G4TPC::average_correction_filename = CDBInterface::instance()->getUrl("TPC_LAMINATION_FIT_CORRECTION");
0116 G4MAGNET::magfield_rescale = 1;
0117 TrackingInit();
0118
0119 auto *hitsinseed = new Fun4AllDstInputManager("SeedInputManager");
0120 hitsinseed->fileopen(seedfilename);
0121 se->registerInputManager(hitsinseed);
0122
0123 auto *hitsinclus = new Fun4AllDstInputManager("ClusterInputManager");
0124 hitsinclus->fileopen(clusterfilename);
0125 se->registerInputManager(hitsinclus);
0126
0127 Reject_Laser_Events();
0128
0129 Tracking_Reco_TrackMatching_run2pp();
0130
0131
0132
0133
0134
0135
0136 if (G4TRACKING::convert_seeds_to_svtxtracks)
0137 {
0138 auto *converter = new TrackSeedTrackMapConverter;
0139
0140
0141 converter->setTrackSeedName("SvtxTrackSeedContainer");
0142 converter->setFieldMap(G4MAGNET::magfield_tracking);
0143 converter->Verbosity(0);
0144 se->registerSubsystem(converter);
0145 }
0146 else
0147 {
0148 Tracking_Reco_TrackFit_run2pp(theOutfile);
0149 }
0150
0151
0152 Tracking_Reco_Vertex_run2pp();
0153
0154 std::string residstring = theOutfile + "_resid.root";
0155
0156 auto *resid = new TrackResiduals("TrackResiduals");
0157 resid->outfileName(residstring);
0158 resid->alignment(false);
0159
0160
0161 if (G4TRACKING::SC_CALIBMODE && !G4TRACKING::convert_seeds_to_svtxtracks)
0162 {
0163 resid->trackmapName("SvtxSiliconMMTrackMap");
0164 if (G4TRACKING::SC_USE_MICROMEGAS)
0165 {
0166 resid->set_doMicromegasOnly(true);
0167 }
0168 }
0169
0170 resid->clusterTree();
0171 resid->convertSeeds(G4TRACKING::convert_seeds_to_svtxtracks);
0172 resid->Verbosity(0);
0173 se->registerSubsystem(resid);
0174
0175 if (Enable::QA)
0176 {
0177 se->registerSubsystem(new SiliconSeedsQA);
0178 se->registerSubsystem(new TpcSeedsQA);
0179 se->registerSubsystem(new TpcSiliconQA);
0180 }
0181 se->run(nEvents);
0182 se->End();
0183 se->PrintTimer();
0184
0185 std::cout << "CDB Files used:" << std::endl;
0186 CDBInterface::instance()->Print();
0187
0188 if (Enable::QA)
0189 {
0190 std::string qaOutputFileName = theOutfile + "_qa.root";
0191 QAHistManagerDef::saveQARootFile(qaOutputFileName);
0192 }
0193
0194 delete se;
0195 std::cout << "Finished" << std::endl;
0196 gSystem->Exit(0);
0197 }