Back to home page

sPhenix code displayed by LXR

 
 

    


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

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