Back to home page

sPhenix code displayed by LXR

 
 

    


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

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