Back to home page

sPhenix code displayed by LXR

 
 

    


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

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