Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-10-16 08:19:50

0001 #ifndef MACRO_FUN4ALLSINGLETRACKAN_C
0002 #define MACRO_FUN4ALLSINGLETRACKAN_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <G4_ActsGeom.C>
0007 #include <G4_Global.C>
0008 #include <G4_Magnet.C>
0009 #include <QA.C>
0010 #include <Trkr_Clustering.C>
0011 #include <Trkr_Reco.C>
0012 #include <Trkr_RecoInit.C>
0013 #include <Trkr_TpcReadoutInit.C>
0014 #include <G4Setup_sPHENIX.C>
0015 
0016 #include <tpccalib/PHTpcResiduals.h>
0017 
0018 #include <trackingqa/SiliconSeedsQA.h>
0019 #include <trackingqa/TpcSeedsQA.h>
0020 #include <trackingqa/TpcSiliconQA.h>
0021 
0022 #include <trackingdiagnostics/TrackResiduals.h>
0023 #include <trackingdiagnostics/TrkrNtuplizer.h>
0024 
0025 #include <kfparticle_sphenix/KFParticle_sPHENIX.h>
0026 
0027 #include <ffamodules/CDBInterface.h>
0028 
0029 #include <fun4all/Fun4AllDstInputManager.h>
0030 #include <fun4all/Fun4AllDstOutputManager.h>
0031 #include <fun4all/Fun4AllInputManager.h>
0032 #include <fun4all/Fun4AllOutputManager.h>
0033 #include <fun4all/Fun4AllRunNodeInputManager.h>
0034 #include <fun4all/Fun4AllServer.h>
0035 #include <fun4all/Fun4AllUtils.h>
0036 
0037 #include <uspin/SpinDBNode.h>
0038 
0039 #include <phool/recoConsts.h>
0040 
0041 #include <bcolumicount/StreamingBcoReco.h>
0042 #include <bcolumicount/BcoLumiReco.h>
0043 #include <ffamodules/SyncReco.h>
0044 
0045 // here you need your package name (set in configure.ac)
0046 #include <singletrackan/SingleTrackAN.h>
0047 R__LOAD_LIBRARY(libfun4all.so)
0048 R__LOAD_LIBRARY(libsingletrackan.so)
0049 
0050 
0051 void Fun4All_SingleTrackAN(const int nevnt = -1, 
0052   const char *inputfile = "/sphenix/lustre01/sphnxpro/production/run3pp/physics/ana573_2026p003_v001/DST_TRKR_TRACKS/run_00079500_00079600/DST_TRKR_TRACKS_run3pp_ana573_2026p003_v001-00079516-00000.root",
0053   const char *inputfile_lumi = "/sphenix/tg/tg01/coldqcd/dillfitz/singletrackan/lumi/Oct13/DST_STREAMING_LUMIINFO-00079516-00000.root",
0054   const std::string& outputdir = "/sphenix/tg/tg01/coldqcd/dillfitz/singletrackan/",
0055   const char *inputfile_bco = "../streamingbcodsts/DST_STREAMING_BCOINFO-00079516.root"
0056 )
0057 {
0058 
0059 
0060   Fun4AllServer *se = Fun4AllServer::instance();
0061 
0062   Fun4AllInputManager *in = new Fun4AllDstInputManager("DSTin");
0063   in->fileopen(inputfile);
0064   se->registerInputManager(in);
0065 
0066   Fun4AllInputManager *in_bco = new Fun4AllDstInputManager("DSTin_bco");
0067   in_bco->fileopen(inputfile_bco);
0068   se->registerInputManager(in_bco);
0069 
0070 
0071   Fun4AllInputManager *in_lumi = new Fun4AllDstInputManager("DSTin_lumi");
0072   in_lumi->fileopen(inputfile_lumi);
0073   se->registerInputManager(in_lumi);
0074 
0075 
0076   G4TRACKING::convert_seeds_to_svtxtracks = false;
0077   std::cout << "Converting to seeds : " << G4TRACKING::convert_seeds_to_svtxtracks << std::endl;
0078   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(inputfile);
0079   int runnumber = runseg.first;
0080   int segment = runseg.second;
0081 
0082   G4TRACKING::SC_CALIBMODE = false;
0083   Enable::MVTX_APPLYMISALIGNMENT = true;
0084   ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0085   TRACKING::streaming_mode = true;
0086 
0087   TString outfile = outputdir + runnumber + "-" + segment + ".root";
0088 
0089   std::string theOutfile = outfile.Data();
0090 
0091 
0092   auto *rc = recoConsts::instance();
0093   rc->set_IntFlag("RUNNUMBER", runnumber);
0094   rc->set_IntFlag("RUNSEGMENT", segment);
0095 
0096   Enable::CDB = true;
0097   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0098   rc->set_uint64Flag("TIMESTAMP", runnumber);
0099 
0100 
0101   // if you want to rebuild the geometry before reconstructing data
0102   bool rebuild_tracking_geometry = true;
0103   if(rebuild_tracking_geometry)
0104     {
0105       // To make simulation geometry before running reconstruction
0106       
0107       Enable::MVTX = true;
0108       Enable::INTT = true;
0109       Enable::TPC = true;
0110       Enable::MICROMEGAS = true;
0111       
0112       G4TPC::tpc_survey_position = true; // to use TPC survey position, set to true
0113       G4Init();
0114       G4Setup();
0115     }
0116 
0117   TpcReadoutInit(runnumber);
0118  // these lines show how to override the drift velocity and time offset values set in TpcReadoutInit
0119   // G4TPC::tpc_drift_velocity_reco = 0.0073844; // cm/ns
0120   // TpcClusterZCrossingCorrection::_vdrift = G4TPC::tpc_drift_velocity_reco;
0121   // G4TPC::tpc_tzero_reco = -5*50;  // ns
0122   std::cout << " run: " << runnumber
0123             << " samples: " << TRACKING::reco_tpc_maxtime_sample
0124             << " pre: " << TRACKING::reco_tpc_time_presample
0125             << " vdrift: " << G4TPC::tpc_drift_velocity_reco
0126             << std::endl;
0127 
0128   if(!rebuild_tracking_geometry)
0129     {
0130       std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0131       Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0132       ingeo->AddFile(geofile);
0133       se->registerInputManager(ingeo);
0134     }
0135   
0136   G4TPC::REJECT_LASER_EVENTS=true;
0137   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0138 
0139   // to turn on the default static corrections, enable the two lines below
0140   G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0141 
0142   //to turn on the average corrections, enable the three lines below
0143   //note: these are designed to be used only if static corrections are also applied
0144   G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0145 
0146   G4MAGNET::magfield_rescale = 1;
0147   TrackingInit();
0148 
0149   // reject laser events if G4TPC::REJECT_LASER_EVENTS is true
0150   //Reject_Laser_Events();
0151 
0152   
0153   //*********************** Go from clusters to seeds ******************** //
0154 
0155   // auto *hitsinclus = new Fun4AllDstInputManager("ClusterInputManager");
0156   // hitsinclus->fileopen(inputclusterRawHitFile);
0157   // se->registerInputManager(hitsinclus);
0158 
0159   // Tracking_Reco_TrackSeed_run2pp();
0160 
0161   // ************************************************* //
0162 
0163   // Go from seeds to tracks
0164 
0165   // Track Matching
0166   // Tracking_Reco_TrackMatching_run2pp("TRKR_CLUSTER_SEED");
0167 
0168   /*
0169    * Either converts seeds to tracks with a straight line/helix fit
0170    * or run the full Acts track kalman filter fit
0171    */
0172   /*
0173   if (G4TRACKING::convert_seeds_to_svtxtracks)
0174   {
0175     auto *converter = new TrackSeedTrackMapConverter;
0176     // Default set to full SvtxTrackSeeds. Can be set to
0177     // SiliconTrackSeedContainer or TpcTrackSeedContainer
0178     converter->setTrackSeedName("SvtxTrackSeedContainer");
0179     converter->setFieldMap(G4MAGNET::magfield_tracking);
0180     converter->Verbosity(0);
0181     se->registerSubsystem(converter);
0182   }
0183   else
0184   {
0185     Tracking_Reco_TrackFit_run2pp(theOutfile,"TRKR_CLUSTER_SEED");
0186   }
0187 
0188   //vertexing and propagation to vertex
0189   Tracking_Reco_Vertex_run2pp("TRKR_CLUSTER_SEED");
0190   */
0191   // ****************** register spin info *****************
0192   SpinDBNode *spin = new SpinDBNode();
0193   se->registerSubsystem(spin);
0194 
0195   StreamingBcoReco *streaming_bco = new StreamingBcoReco();
0196   //streaming_bco->Verbosity(2);
0197   se->registerSubsystem(streaming_bco);
0198 
0199   
0200   SingleTrackAN *singleTrackAN = new SingleTrackAN("SingleTrackAN");
0201   singleTrackAN->set_output_filename(theOutfile);
0202   //  SingleTrackAN->Verbosity(0);
0203   se->registerSubsystem(singleTrackAN);
0204 
0205 
0206   se->run(nevnt);
0207   se->End();
0208   delete se;
0209   gSystem->Exit(0);
0210 }
0211 
0212 #endif