Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-18 09:22:24

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