Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:28

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