Back to home page

sPhenix code displayed by LXR

 
 

    


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

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