Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef FUN4ALL_TRACKANDCALOJETVALID_C
0002 #define FUN4ALL_TRACKANDCALOJETVALID_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 #include <Trkr_Clustering.C>
0017 
0018 // coresoftware headers
0019 #include <jetqa/ConstituentsinJets.h>
0020 #include <jetqa/JetKinematicCheck.h>
0021 #include <jetqa/JetSeedCount.h>
0022 #include <jetqa/StructureinJets.h>
0023 #include <jetqa/TrksInJetQA.h>
0024 #include <jetqa/RhosinEvent.h>
0025 
0026 #include <g4centrality/PHG4CentralityReco.h>
0027 
0028 #include <globalvertex/GlobalVertexReco.h>
0029 
0030 #include <jetbackground/DetermineTowerRho.h>
0031 #include <jetbackground/TowerRho.h>
0032 
0033 #include <mbd/MbdReco.h>
0034 
0035 #include <zdcinfo/ZdcReco.h>
0036 
0037 #include <qautils/QAHistManagerDef.h>
0038 
0039 #include <ffamodules/CDBInterface.h>
0040 
0041 #include <fun4all/Fun4AllDstInputManager.h>
0042 #include <fun4all/Fun4AllInputManager.h>
0043 #include <fun4all/Fun4AllRunNodeInputManager.h>
0044 #include <fun4all/Fun4AllServer.h>
0045 #include <fun4all/Fun4AllUtils.h>
0046 
0047 #include <phool/recoConsts.h>
0048 
0049 // c++ includes
0050 #include <fstream>
0051 #include <iostream>
0052 #include <optional>
0053 #include <string>
0054 #include <utility>
0055 #include <vector>
0056 
0057 // load libraries
0058 R__LOAD_LIBRARY(libcentrality.so)
0059 R__LOAD_LIBRARY(libg4centrality.so)
0060 R__LOAD_LIBRARY(libfun4all.so)
0061 R__LOAD_LIBRARY(libffamodules.so)
0062 R__LOAD_LIBRARY(libjetbackground.so)
0063 R__LOAD_LIBRARY(libjetqa.so)
0064 R__LOAD_LIBRARY(libmbd.so)
0065 R__LOAD_LIBRARY(libqautils.so)
0066 R__LOAD_LIBRARY(libzdcinfo.so)
0067 
0068 // types for convenience
0069 using SVec = std::vector<std::string>;
0070 
0071 
0072 
0073 // macro body -----------------------------------------------------------------
0074 
0075 void Fun4All_TrackAndCaloJetValid(
0076   const int  verb   = 10,
0077   const int  nEvts  = 10,
0078   const int  nSkip  = 0,
0079   const SVec& inputs = {
0080     "../input/dst_global.list",
0081     "../input/dst_mbd_epd.list",
0082     "../input/dst_calo_cluster.list",
0083     "../input/dst_trkr_hit.list",
0084     "../input/dst_trkr_cluster.list",
0085     "../input/dst_trackseeds.list",
0086     "../input/dst_tracks.list"
0087   },
0088   const std::string&  qaBase = "HIST_JET_QA",
0089   std::optional<int> run    = std::nullopt
0090 ) {
0091 
0092   // turn on QA
0093   Enable::QA = true;
0094 
0095   // turn on pp mode
0096   HIJETS::is_pp = true;
0097 
0098   // qa options
0099   JetQA::HasTracks = false;
0100   JetQA::DoInclusive = true;
0101   JetQA::DoTriggered = true;
0102   JetQA::RestrictPtToTrig = false;
0103   JetQA::RestrictEtaByR = true;
0104 
0105   // initialize fun4all ------------------------------------------------------
0106 
0107   // announce start of macro
0108   std::cout << "\n -------- OwO -- Starting Jet QA Macro -- OwO -------- \n "
0109             << "              [Using Track-and-Calo Jets]\n"
0110             << std::endl;
0111 
0112   // grab instances f4a, the cdb, etc.
0113   Fun4AllServer* se = Fun4AllServer::instance();
0114   CDBInterface*  cb = CDBInterface::instance();
0115   recoConsts*    rc = recoConsts::instance();
0116   se->Verbosity(verb);
0117 
0118   // turn on cdb
0119   Enable::CDB = true;
0120 
0121   // if needed, try to grab run from files
0122   int runNum = 6;
0123   int segNum = 0;
0124   if (!run.has_value()) {
0125 
0126     // grab first file from first input list
0127     std::ifstream    firstList(inputs.at(0));
0128     std::string firstFile;
0129     std::getline(firstList, firstFile);
0130 
0131     // now extract the run and segment numbers...
0132     std::pair<int, int> runAndSeg = Fun4AllUtils::GetRunSegment(firstFile);
0133     runNum = runAndSeg.first;
0134     segNum = runAndSeg.second;
0135   } else {
0136     runNum = run.value();
0137   }
0138 
0139   // set cdb tags
0140   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2023");
0141   rc->set_uint64Flag("TIMESTAMP", runNum);
0142 
0143   // get url of geo file
0144   const std::string inGeoFile = cb->getUrl("Tracking_Geometry");
0145 
0146   // register dst input managers
0147   for (size_t iInput = 0; iInput < inputs.size(); ++iInput) {
0148     Fun4AllDstInputManager* inManager = new Fun4AllDstInputManager("InputManager" + std::to_string(iInput));
0149     inManager->AddListFile(inputs[iInput], 1);
0150     se->registerInputManager(inManager);
0151   }
0152 
0153   // register geometry manager
0154   Fun4AllRunNodeInputManager* geoManager = new Fun4AllRunNodeInputManager("GeometryManager");
0155   geoManager->AddFile(inGeoFile);
0156   se->registerInputManager(geoManager);
0157 
0158   // initialize acts geometry
0159   G4TPC::tpc_drift_velocity_reco = (8.0 / 1000) * 107.0 / 105.0;
0160   G4MAGNET::magfield = "0.01";
0161   G4MAGNET::magfield_rescale = 1;
0162   ACTSGEOM::ActsGeomInit();
0163 
0164   // register & run necessary reconstruction ----------------------------------
0165 
0166   // do vertex & centrality reconstruction
0167   Global_Reco(); 
0168   if (!HIJETS::is_pp) {
0169     Centrality();
0170   }
0171 
0172   // do jet reconstruction & rho calculation
0173   HIJetReco();  
0174   DoRhoCalculation();
0175 
0176   // register qa modules ------------------------------------------------------
0177 
0178   // add generic jet QA
0179   CommonJetQA();
0180 
0181   // add track jet QA
0182   JetsWithTracksQA();
0183 
0184   // run modules and exit -----------------------------------------------------
0185 
0186   // run4all
0187   se->run(nEvts);
0188   se->skip(nSkip);
0189   se->End();
0190 
0191   // create output file name
0192   std::string qaFileName = qaBase;
0193   qaFileName += "-" + std::to_string(runNum);
0194   qaFileName += "-" + std::to_string(segNum);
0195   qaFileName += ".root";
0196 
0197   // save qa output and exit
0198   QAHistManagerDef::saveQARootFile(qaFileName);
0199   delete se;
0200 
0201   // announce end and exit
0202   std::cout << "\n -------- UwU -- Finished Jet QA Macro -- UwU -------- \n " << std::endl;
0203   gSystem->Exit(0);
0204   return;
0205 
0206 }
0207 
0208 #endif
0209 
0210 // end ------------------------------------------------------------------------