Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-30 08:19:27

0001 /*
0002  * This macro shows a minimum working example of running track fitting over
0003  * the production cluster and track seed DSTs.. There are some analysis 
0004  * modules run at the end which package clusters, and clusters on tracks 
0005  * into trees for analysis.
0006  */
0007 
0008 #include <fun4all/Fun4AllUtils.h>
0009 #include <G4_ActsGeom.C>
0010 #include <G4_Global.C>
0011 #include <G4_Magnet.C>
0012 #include <GlobalVariables.C>
0013 #include <QA.C>
0014 #include <Trkr_Clustering.C>
0015 #include <Trkr_Reco.C>
0016 #include <Trkr_RecoInit.C>
0017 #include <Trkr_TpcReadoutInit.C>
0018 
0019 #include <ffamodules/CDBInterface.h>
0020 
0021 #include <fun4all/Fun4AllDstInputManager.h>
0022 #include <fun4all/Fun4AllDstOutputManager.h>
0023 #include <fun4all/Fun4AllInputManager.h>
0024 #include <fun4all/Fun4AllOutputManager.h>
0025 #include <fun4all/Fun4AllRunNodeInputManager.h>
0026 #include <fun4all/Fun4AllServer.h>
0027 
0028 #include <phool/recoConsts.h>
0029 
0030 #include <cdbobjects/CDBTTree.h>
0031 
0032 #include <tpccalib/PHTpcResiduals.h>
0033 
0034 #include <calotrigger/TriggerRunInfoReco.h>
0035 
0036 #include <track_eec/triggerSelector.h>
0037 #include <track_eec/trackEEC.h>
0038 
0039 #include <cstdio>
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(libTrackingDiagnostics.so)
0046 R__LOAD_LIBRARY(libtrackingqa.so)
0047 R__LOAD_LIBRARY(libcalotrigger.so)
0048 R__LOAD_LIBRARY(libTrackEEC.so)
0049 void Fun4All_trackEEC(
0050     const int nEvents = 10,
0051     const int runnumber = 79597,
0052     const int segment = 0,
0053     const std::string& seedfilelist = "/sphenix/lustre01/sphnxpro/production/run3pp/physics/ana538_2025p011_v001/DST_TRKR_SEED/run_00079500_00079600/DST_TRKR_SEED_run3pp_ana538_2025p011_v001-00079516-00009.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   // distortion calibration mode
0072   /*
0073    * set to true to enable residuals in the TPC with
0074    * TPC clusters not participating to the ACTS track fit
0075    */
0076   G4TRACKING::SC_CALIBMODE = false;
0077   Enable::MVTX_APPLYMISALIGNMENT = true;
0078   ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0079   TRACKING::streaming_mode = true;
0080   
0081   TString outfile = outfilename + "_" + runnumber + "-" + segment + "-" + (segment+9);
0082 
0083   std::string theOutfile = outfile.Data();
0084 
0085   auto *se = Fun4AllServer::instance();
0086   se->Verbosity(2);
0087 
0088   auto *rc = recoConsts::instance();
0089   rc->set_IntFlag("RUNNUMBER", runnumber);
0090   //rc->set_IntFlag("RUNSEGMENT", segment);
0091   
0092   Enable::CDB = true;
0093   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0094   rc->set_uint64Flag("TIMESTAMP", runnumber);
0095   std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0096 
0097   Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0098   ingeo->AddFile(geofile);
0099   se->registerInputManager(ingeo);
0100 
0101   TpcReadoutInit( runnumber );
0102   // these lines show how to override the drift velocity and time offset values set in TpcReadoutInit
0103   // G4TPC::tpc_drift_velocity_reco = 0.0073844; // cm/ns
0104   // TpcClusterZCrossingCorrection::_vdrift = G4TPC::tpc_drift_velocity_reco;
0105   // G4TPC::tpc_tzero_reco = -5*50;  // ns
0106   G4TPC::REJECT_LASER_EVENTS=true;
0107   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0108 
0109   // to turn on the default static corrections, enable the two lines below
0110   G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0111 
0112   //to turn on the average corrections, enable the three lines below
0113   //note: these are designed to be used only if static corrections are also applied
0114   G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0115   G4TPC::USE_PHI_AS_RAD_AVERAGE_CORRECTIONS = false;
0116    // to use a custom file instead of the database file:
0117   G4TPC::average_correction_filename = CDBInterface::instance()->getUrl("TPC_LAMINATION_FIT_CORRECTION");
0118 
0119   G4MAGNET::magfield_rescale = 1;
0120   TrackingInit();
0121 
0122   auto *hitsinseed = new Fun4AllDstInputManager("SeedInputManager");
0123   hitsinseed->AddListFile(seedfilelist);
0124   se->registerInputManager(hitsinseed);
0125 
0126   Reject_Laser_Events();
0127 
0128   TriggerRunInfoReco *trigReco = new TriggerRunInfoReco("TriggerRunInfoReco");
0129   trigReco->UseEmulator(false);
0130   se->registerSubsystem(trigReco);
0131 
0132   triggerSelector *trigSel = new triggerSelector("triggerSelector");
0133   trigSel->setTriggerName("Jet 10 GeV");
0134   se->registerSubsystem(trigSel);
0135   
0136   Tracking_Reco_TrackMatching_run2pp("TRKR_CLUSTER_SEED");
0137   
0138   
0139   /*
0140    * Either converts seeds to tracks with a straight line/helix fit
0141    * or run the full Acts track kalman filter fit
0142    */
0143   if (G4TRACKING::convert_seeds_to_svtxtracks)
0144   {
0145     auto *converter = new TrackSeedTrackMapConverter;
0146     // Default set to full SvtxTrackSeeds. Can be set to
0147     // SiliconTrackSeedContainer or TpcTrackSeedContainer
0148     converter->setTrackSeedName("SvtxTrackSeedContainer");
0149     converter->setFieldMap(G4MAGNET::magfield_tracking);
0150     converter->setClusterMapName("TRKR_CLUSTER_SEED");
0151     converter->Verbosity(0);
0152     se->registerSubsystem(converter);
0153   }
0154   else
0155   {
0156     Tracking_Reco_TrackFit_run2pp(theOutfile,"TRKR_CLUSTER_SEED");
0157   }
0158 
0159   //vertexing and propagation to vertex
0160   Tracking_Reco_Vertex_run2pp("TRKR_CLUSTER_SEED");
0161 
0162   TString residoutfile = "/sphenix/tg/tg01/jets/bkimelman/track_EEC/trackDSTs/July15_2026_cuts/" + theOutfile + "_trackEECs.root";
0163   std::string residstring(residoutfile.Data());
0164 
0165   trackEEC *EEC = new trackEEC("trackEEC");
0166   EEC->SetOutfileName(residstring);
0167   se->registerSubsystem(EEC);
0168 
0169 
0170   se->run(nEvents);
0171   se->End();
0172   se->PrintTimer();
0173 
0174   std::cout << "CDB Files used:" << std::endl;
0175   CDBInterface::instance()->Print();
0176   
0177   delete se;
0178   std::cout << "Finished" << std::endl;
0179   gSystem->Exit(0);
0180 }