Back to home page

sPhenix code displayed by LXR

 
 

    


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

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