Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:05

0001 #ifndef FUN4ALL_TRACKJETPRODUCTIONYEAR3_C
0002 #define FUN4ALL_TRACKJETPRODUCTIONYEAR3_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <G4_ActsGeom.C>
0007 #include <G4_Centrality.C>
0008 #include <G4_Global.C>
0009 #include <G4_Magnet.C>
0010 #include <HIJetReco.C>
0011 #include <Jet_QA.C>
0012 #include <QA.C>
0013 #include <Trkr_Reco.C>
0014 #include <Trkr_RecoInit.C>
0015 #include <Trkr_TpcReadoutInit.C>
0016 
0017 #include <g4centrality/PHG4CentralityReco.h>
0018 
0019 #include <globalvertex/GlobalVertexReco.h>
0020 
0021 #include <jetbackground/BeamBackgroundFilterAndQA.h>
0022 
0023 #include <mbd/MbdReco.h>
0024 
0025 #include <zdcinfo/ZdcReco.h>
0026 
0027 #include <qautils/QAHistManagerDef.h>
0028 
0029 #include <ffamodules/CDBInterface.h>
0030 #include <ffamodules/FlagHandler.h>
0031 
0032 #include <fun4all/Fun4AllDstInputManager.h>
0033 #include <fun4all/Fun4AllDstOutputManager.h>
0034 #include <fun4all/Fun4AllInputManager.h>
0035 #include <fun4all/Fun4AllRunNodeInputManager.h>
0036 #include <fun4all/Fun4AllServer.h>
0037 #include <fun4all/Fun4AllUtils.h>
0038 
0039 #include <phool/recoConsts.h>
0040 
0041 #include <fstream>
0042 #include <iostream>
0043 #include <optional>
0044 #include <string>
0045 #include <utility>
0046 #include <vector>
0047 
0048 // load libraries
0049 R__LOAD_LIBRARY(libcentrality.so)
0050 R__LOAD_LIBRARY(libg4centrality.so)
0051 R__LOAD_LIBRARY(libglobalvertex.so)
0052 R__LOAD_LIBRARY(libfun4all.so)
0053 R__LOAD_LIBRARY(libffamodules.so)
0054 R__LOAD_LIBRARY(libjetbackground.so)
0055 R__LOAD_LIBRARY(libjetqa.so)
0056 R__LOAD_LIBRARY(libmbd.so)
0057 R__LOAD_LIBRARY(libqautils.so)
0058 R__LOAD_LIBRARY(libzdcinfo.so)
0059 
0060 
0061 
0062 // ============================================================================
0063 //! Track jet production macro for year 3 (AuAu)
0064 // ============================================================================
0065 /*! Jet production macro for AuAu-running in year 3. Currently used for
0066  *  producing for QA. Can be adapted for production of JET DSTs in the
0067  *  future.
0068  *
0069  *  Necessary input for track jets:
0070  *    - DST_CALO (for beam background filter)
0071  *    - DST_TRKR_TRACKS
0072  *    - DST_TRKR_CLUSTER (for tracks-in-jets QA)
0073  */
0074 void Fun4All_TrackJetProductionYear3(
0075   const int nEvents = 0,
0076   const std::string& inlist = "./input/dsts_track_run2pp-00053877.goldenTrkCaloRun_allSeg.list",
0077   const std::string& outfile = "DST_JET-00053877-0000.root",
0078   const std::string& outfile_hist = "HIST_JETQA-00053877-0000.year2aa_tracktest.root",
0079   const std::string& dbtag = "ProdA_2024"
0080 ) {
0081 
0082   // set options --------------------------------------------------------------
0083 
0084   // turn on/off DST output and/or QA
0085   Enable::DSTOUT           = false;
0086   Enable::QA               = true;
0087   Enable::HIJETS_VERBOSITY = 0;
0088   Enable::JETQA_VERBOSITY  = std::max(Enable::VERBOSITY, Enable::HIJETS_VERBOSITY);
0089 
0090   // jet reco options
0091   Enable::HIJETS         = true;
0092   Enable::HIJETS_TOWER   = false;
0093   Enable::HIJETS_TRACK   = true;
0094   Enable::HIJETS_PFLOW   = false;
0095   HIJETS::is_pp          = false;
0096   HIJETS::do_vertex_type = true;
0097   HIJETS::vertex_type    = Enable::HIJETS_TRACK ? GlobalVertex::SVTX : GlobalVertex::MBD;
0098 
0099   // qa options
0100   JetQA::DoInclusive      = true;
0101   JetQA::DoTriggered      = true;
0102   JetQA::DoPP             = HIJETS::is_pp;
0103   JetQA::UseBkgdSub       = true;
0104   JetQA::RestrictPtToTrig = false;
0105   JetQA::RestrictEtaByR   = true;
0106   JetQA::HasTracks        = Enable::HIJETS_TRACK || Enable::HIJETS_PFLOW;
0107   JetQA::HasCalos         = Enable::HIJETS_TOWER || Enable::HIJETS_PFLOW;
0108 
0109   // tracking options
0110   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0111   Enable::MVTX_APPLYMISALIGNMENT        = true;
0112   ACTSGEOM::mvtx_applymisalignment      = Enable::MVTX_APPLYMISALIGNMENT;
0113   TRACKING::pp_mode                     = HIJETS::is_pp;
0114 
0115   // initialize interfaces, register inputs -----------------------------------
0116 
0117   // initialize F4A server
0118   Fun4AllServer* se = Fun4AllServer::instance();
0119   se->Verbosity(1);
0120 
0121   // grab 1st file from input lists
0122   std::ifstream files(inlist);
0123   std::string first;
0124   std::getline(files, first);
0125 
0126   // grab run and segment no.s
0127   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(first);
0128   int runnumber = runseg.first;
0129 
0130   // set up reconstruction constants, DB tag, timestamp
0131   recoConsts* rc = recoConsts::instance();
0132   rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0133   rc->set_uint64Flag("TIMESTAMP", runnumber);
0134 
0135   // connect to conditions database
0136   CDBInterface* cdb = CDBInterface::instance();
0137   cdb->Verbosity(1);
0138 
0139   // set up flag handler
0140   FlagHandler* flag = new FlagHandler();
0141   se->registerSubsystem(flag);
0142 
0143   // read in input
0144   Fun4AllInputManager* indst = new Fun4AllDstInputManager("indst");
0145   indst->AddListFile(inlist);
0146   se->registerInputManager(indst);
0147 
0148   // set up tracking
0149   if (JetQA::HasTracks)
0150   {
0151     // register tracking geometry
0152     Fun4AllRunNodeInputManager* ingeom = new Fun4AllRunNodeInputManager("ingeom");
0153     ingeom->AddFile(cdb->getUrl("Tracking_Geometry"));
0154     se->registerInputManager(ingeom);
0155 
0156     // initialize tracking
0157     TpcReadoutInit(runnumber);
0158     TrackingInit();
0159   }
0160 
0161   // register reconstruction modules ------------------------------------------
0162 
0163   // do vertex & centrality reconstruction
0164   Global_Reco();
0165   if (!HIJETS::is_pp)
0166   {
0167     Centrality();
0168   }
0169 
0170   // filter out beam-background events (use default parameters for
0171   // streak-sideband filter)
0172   BeamBackgroundFilterAndQA* filter = new BeamBackgroundFilterAndQA("BeamBackgroundFilterAndQA");
0173   filter->Verbosity(std::max(Enable::QA_VERBOSITY, Enable::JETQA_VERBOSITY));
0174   filter->SetConfig(
0175     {
0176       .debug          = false,
0177       .doQA           = Enable::QA,
0178       .doEvtAbort     = false,
0179       .filtersToApply = {"StreakSideband"}
0180     }
0181   );
0182   se->registerSubsystem(filter);
0183 
0184   // do jet reconstruction
0185   HIJetReco();  
0186 
0187   // register modules necessary for QA
0188   if (Enable::QA)
0189   {
0190     DoRhoCalculation();
0191     Jet_QA();
0192   }
0193 
0194   // if needed, save DST output
0195   if (Enable::DSTOUT)
0196   {
0197     Fun4AllDstOutputManager* out = new Fun4AllDstOutputManager("DSTOUT", outfile);
0198     out->StripNode("CEMCPackets");
0199     out->StripNode("HCALPackets");
0200     out->StripNode("ZDCPackets");
0201     out->StripNode("SEPDPackets");
0202     out->StripNode("MBDPackets");
0203     se->registerOutputManager(out);
0204   }
0205 
0206   // run & exit ---------------------------------------------------------------
0207 
0208   // run4all
0209   se->run(nEvents);
0210   se->End();
0211 
0212   // if needed, save QA output
0213   if (Enable::QA)
0214   {
0215     QAHistManagerDef::saveQARootFile(outfile_hist);
0216   }
0217 
0218   // print used DB files, time elapsed and delete server
0219   cdb->Print();
0220   se->PrintTimer();
0221   delete se;
0222 
0223   // announce end and exit
0224   std::cout << "Jets are done!" << std::endl;
0225   gSystem->Exit(0);
0226 
0227 }
0228 
0229 #endif
0230 
0231 // end ------------------------------------------------------------------------