Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef FUN4ALL_JETPRODUCTIONYEAR3_C
0002 #define FUN4ALL_JETPRODUCTIONYEAR3_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 //! 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 inputs:
0070  *    - For calo jets:
0071  *      - DST_CALO
0072  *    - For track jets:
0073  *      - DST_CALO (for beam background filter)
0074  *      - DST_TRKR_TRACKS
0075  *      - DST_TRKR_CLUSTER (for tracks-in-jets QA)
0076  */
0077 void Fun4All_JetProductionYear3(
0078   const int nEvents = 0,
0079   const bool useTwrs = true,
0080   const bool useTrks = false,
0081   const bool useFlow = false,
0082   const std::vector<std::string>& inlists = {
0083     "./input/dsts_calo_run2pp-00053877.goldenTrkCaloRun_allSeg.list",
0084     "./input/dsts_clust_run2pp-00053877.goldenTrkCaloRun_allSeg.list",
0085     "./input/dsts_track_run2pp-00053877.goldenTrkCaloRun_allSeg.list"
0086   },
0087   const std::string& outfile = "DST_JET-00053877-0000.root",
0088   const std::string& outfile_hist = "HIST_JETQA-00053877-0000.year3_tracktest.root",
0089   const std::string& dbtag = "ProdA_2024"
0090 ) {
0091 
0092   // set options --------------------------------------------------------------
0093 
0094   // turn on/off DST output and/or QA
0095   Enable::DSTOUT           = false;
0096   Enable::QA               = true;
0097   Enable::HIJETS_VERBOSITY = 0;
0098   Enable::JETQA_VERBOSITY  = std::max(Enable::VERBOSITY, Enable::HIJETS_VERBOSITY);
0099 
0100   // jet reco options
0101   Enable::HIJETS         = true;
0102   Enable::HIJETS_TOWER   = useTwrs;
0103   Enable::HIJETS_TRACK   = useTrks;
0104   Enable::HIJETS_PFLOW   = useFlow;
0105   HIJETS::is_pp          = false;
0106   HIJETS::do_vertex_type = true;
0107   HIJETS::vertex_type    = Enable::HIJETS_TRACK ? GlobalVertex::SVTX : GlobalVertex::MBD;
0108 
0109   // qa options
0110   JetQA::DoInclusive      = true;
0111   JetQA::DoTriggered      = true;
0112   JetQA::DoPP             = HIJETS::is_pp;
0113   JetQA::UseBkgdSub       = true;
0114   JetQA::RestrictPtToTrig = false;
0115   JetQA::RestrictEtaByR   = true;
0116   JetQA::HasTracks        = Enable::HIJETS_TRACK || Enable::HIJETS_PFLOW;
0117   JetQA::HasCalos         = Enable::HIJETS_TOWER || Enable::HIJETS_PFLOW;
0118 
0119   // tracking options
0120   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0121   Enable::MVTX_APPLYMISALIGNMENT        = true;
0122   ACTSGEOM::mvtx_applymisalignment      = Enable::MVTX_APPLYMISALIGNMENT;
0123   TRACKING::pp_mode                     = HIJETS::is_pp;
0124 
0125   // initialize interfaces, register inputs -----------------------------------
0126 
0127   // initialize F4A server
0128   Fun4AllServer* se = Fun4AllServer::instance();
0129   se->Verbosity(1);
0130 
0131   // grab 1st file from input lists
0132   std::ifstream files(inlists.front());
0133   std::string first;
0134   std::getline(files, first);
0135 
0136   // grab run and segment no.s
0137   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(first);
0138   int runnumber = runseg.first;
0139 
0140   // set up reconstruction constants, DB tag, timestamp
0141   recoConsts* rc = recoConsts::instance();
0142   rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0143   rc->set_uint64Flag("TIMESTAMP", runnumber);
0144 
0145   // connect to conditions database
0146   CDBInterface* cdb = CDBInterface::instance();
0147   cdb->Verbosity(1);
0148 
0149   // set up flag handler
0150   FlagHandler* flag = new FlagHandler();
0151   se->registerSubsystem(flag);
0152 
0153   // read in input
0154   for (std::size_t iin = 0; iin < inlists.size(); ++iin)
0155   {
0156     Fun4AllInputManager* indst = new Fun4AllDstInputManager("indst" + std::to_string(iin));
0157     indst->AddListFile(inlists[iin]);
0158     se->registerInputManager(indst);
0159   }
0160 
0161   // set up tracking
0162   if (JetQA::HasTracks)
0163   {
0164     // register tracking geometry
0165     Fun4AllRunNodeInputManager* ingeom = new Fun4AllRunNodeInputManager("ingeom");
0166     ingeom->AddFile(cdb->getUrl("Tracking_Geometry"));
0167     se->registerInputManager(ingeom);
0168 
0169     // initialize tracking
0170     TpcReadoutInit(runnumber);
0171     TrackingInit();
0172   }
0173 
0174   // register reconstruction modules ------------------------------------------
0175 
0176   // do vertex & centrality reconstruction
0177   Global_Reco();
0178   if (!HIJETS::is_pp)
0179   {
0180     Centrality();
0181   }
0182 
0183   // filter out beam-background events (use default parameters for
0184   // streak-sideband filter)
0185   BeamBackgroundFilterAndQA* filter = new BeamBackgroundFilterAndQA("BeamBackgroundFilterAndQA");
0186   filter->Verbosity(std::max(Enable::QA_VERBOSITY, Enable::JETQA_VERBOSITY));
0187   filter->SetConfig(
0188     {
0189       .debug          = false,
0190       .doQA           = Enable::QA,
0191       .doEvtAbort     = false,
0192       .filtersToApply = {"StreakSideband"}
0193     }
0194   );
0195   se->registerSubsystem(filter);
0196 
0197   // do jet reconstruction
0198   HIJetReco();  
0199 
0200   // register modules necessary for QA
0201   if (Enable::QA)
0202   {
0203     DoRhoCalculation();
0204     Jet_QA();
0205   }
0206 
0207   // if needed, save DST output
0208   if (Enable::DSTOUT)
0209   {
0210     Fun4AllDstOutputManager* out = new Fun4AllDstOutputManager("DSTOUT", outfile);
0211     out->StripNode("CEMCPackets");
0212     out->StripNode("HCALPackets");
0213     out->StripNode("ZDCPackets");
0214     out->StripNode("SEPDPackets");
0215     out->StripNode("MBDPackets");
0216     se->registerOutputManager(out);
0217   }
0218 
0219   // run & exit ---------------------------------------------------------------
0220 
0221   // run4all
0222   se->run(nEvents);
0223   se->End();
0224 
0225   // if needed, save QA output
0226   if (Enable::QA)
0227   {
0228     QAHistManagerDef::saveQARootFile(outfile_hist);
0229   }
0230 
0231   // print used DB files, time elapsed and delete server
0232   cdb->Print();
0233   se->PrintTimer();
0234   delete se;
0235 
0236   // announce end and exit
0237   std::cout << "Jets are done!" << std::endl;
0238   gSystem->Exit(0);
0239 
0240 }
0241 
0242 #endif
0243 
0244 // end ------------------------------------------------------------------------