Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:54

0001 #ifndef FUN4ALL_CALOONLYJETVALID_C
0002 #define FUN4ALL_CALOONLYJETVALID_C
0003 
0004 // c++ utilities
0005 #include <fstream>
0006 #include <iostream>
0007 #include <optional>
0008 #include <string>
0009 #include <utility>
0010 #include <vector>
0011 
0012 // coresoftware headers
0013 #include <ffamodules/CDBInterface.h>
0014 #include <ffamodules/FlagHandler.h>
0015 #include <fun4all/Fun4AllDstInputManager.h>
0016 #include <fun4all/Fun4AllDstOutputManager.h>
0017 #include <fun4all/Fun4AllInputManager.h>
0018 #include <fun4all/Fun4AllRunNodeInputManager.h>
0019 #include <fun4all/Fun4AllServer.h>
0020 #include <fun4all/Fun4AllUtils.h>
0021 #include <g4centrality/PHG4CentralityReco.h>
0022 #include <globalvertex/GlobalVertexReco.h>
0023 #include <jetbackground/DetermineTowerRho.h>
0024 #include <jetbackground/TowerRho.h>
0025 #include <mbd/MbdReco.h>
0026 #include <phool/recoConsts.h>
0027 #include <qautils/QAHistManagerDef.h>
0028 #include <zdcinfo/ZdcReco.h>
0029 
0030 // f4a macros
0031 #include <G4_ActsGeom.C>
0032 #include <G4_Centrality.C>
0033 #include <G4_Global.C>
0034 #include <G4_Magnet.C>
0035 #include <GlobalVariables.C>
0036 #include <HIJetReco.C>
0037 #include <Jet_QA.C>
0038 #include <QA.C>
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 // types for convenience
0053 typedef std::vector<std::string> SVec;
0054 
0055 
0056 
0057 // macro body -----------------------------------------------------------------
0058 
0059 void Fun4All_CaloOnlyJetValid(
0060   const int  verb   = 10,
0061   const int  nEvts  = 100,
0062   const int  nSkip  = 0,
0063   const SVec inputs = {
0064     "./lists/runs/dst_calo_run2pp-00042586.list"
0065   },
0066   const std::string  qaBase = "HIST_JET_QA_TEST",
0067   std::optional<int> run    = std::nullopt
0068 ) {
0069 
0070   // turn on QA
0071   Enable::QA = true;
0072 
0073   // turn on pp mode
0074   HIJETS::is_pp = true;
0075 
0076   // qa options
0077   JetQA::HasTracks = false;
0078   JetQA::DoInclusive = true;
0079   JetQA::DoTriggered = true;
0080   JetQA::RestrictPtToTrig = false;
0081   JetQA::RestrictEtaByR = true;
0082 
0083   // initialize fun4all ------------------------------------------------------
0084 
0085   // announce start of macro
0086   std::cout << "\n -------- OwO -- Starting Jet QA Macro -- OwO -------- \n "
0087             << "                [Using Calo-only Jets]\n"
0088             << std::endl;
0089 
0090   // grab instances f4a, the cdb, etc.
0091   Fun4AllServer* se = Fun4AllServer::instance();
0092   CDBInterface*  cb = CDBInterface::instance();
0093   recoConsts*    rc = recoConsts::instance();
0094   se -> Verbosity(verb);
0095 
0096   // turn on cdb
0097   Enable::CDB = true;
0098 
0099   // if needed, try to grab run from files
0100   int runNum = 6;
0101   int segNum = 0;
0102   if (!run.has_value()) {
0103 
0104     // grab first file from first input list
0105     ifstream    firstList(inputs.at(0));
0106     std::string firstFile("");
0107     std::getline(firstList, firstFile);
0108 
0109     // now extract the run and segment numbers...
0110     std::pair<int, int> runAndSeg = Fun4AllUtils::GetRunSegment(firstFile);
0111     runNum = runAndSeg.first;
0112     segNum = runAndSeg.second;
0113   } else {
0114     runNum = run.value();
0115   }
0116 
0117   // set cdb tags
0118   rc -> set_StringFlag("CDB_GLOBALTAG", "ProdA_2023");
0119   rc -> set_uint64Flag("TIMESTAMP", runNum);
0120 
0121   // register dst input managers
0122   for (size_t iInput = 0; iInput < inputs.size(); ++iInput) {
0123     Fun4AllDstInputManager* inManager = new Fun4AllDstInputManager("InputManager" + std::to_string(iInput));
0124     inManager -> AddListFile(inputs[iInput], 1);
0125     se        -> registerInputManager(inManager);
0126   }
0127 
0128   // register & run necessary reconstruction ----------------------------------
0129 
0130   // do vertex & centrality reconstruction
0131   Global_Reco(); 
0132   if (!HIJETS::is_pp) {
0133     Centrality();
0134   }
0135 
0136   // do jet reconstruction & rho calculation
0137   HIJetReco();  
0138   DoRhoCalculation();
0139 
0140   // register qa modules ------------------------------------------------------
0141 
0142   Jet_QA();
0143 
0144   // run modules and exit -----------------------------------------------------
0145 
0146   // run4all
0147   se -> run(nEvts);
0148   se -> skip(nSkip);
0149   se -> End();
0150 
0151   // create output file name
0152   std::string qaFileName = qaBase;
0153   qaFileName += "-" + std::to_string(runNum);
0154   qaFileName += "-" + std::to_string(segNum);
0155   qaFileName += ".root";
0156 
0157   // save qa output and exit
0158   QAHistManagerDef::saveQARootFile(qaFileName);
0159   delete se;
0160 
0161   // announce end and exit
0162   std::cout << "\n -------- UwU -- Finished Jet QA Macro -- UwU -------- \n " << std::endl;
0163   gSystem -> Exit(0);
0164   return;
0165 
0166 }
0167 
0168 #endif
0169 
0170 // end ------------------------------------------------------------------------