Back to home page

sPhenix code displayed by LXR

 
 

    


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

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