Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:24

0001 // ----------------------------------------------------------------------------
0002 // 'Fun4All_MakeTrksInJetQA.C'
0003 // Derek Anderson
0004 // 03.25.2024
0005 //
0006 // A Fun4All macro to run the TrksInJetQA module.
0007 // ----------------------------------------------------------------------------
0008 
0009 #define FUN4ALL_MAKETRACKSINJETSQA_C
0010 
0011 // c++ utilities
0012 #include <string>
0013 #include <vector>
0014 // fun4all libraries
0015 #include <fun4all/SubsysReco.h>
0016 #include <fun4all/Fun4AllServer.h>
0017 #include <fun4all/Fun4AllInputManager.h>
0018 #include <fun4all/Fun4AllOutputManager.h>
0019 #include <fun4all/Fun4AllDstInputManager.h>
0020 #include <fun4all/Fun4AllDstOutputManager.h>
0021 #include <fun4all/Fun4AllRunNodeInputManager.h>
0022 // f4a modules
0023 #include <ffamodules/CDBInterface.h>
0024 // phool libraries
0025 #include <phool/recoConsts.h>
0026 #include <phool/PHRandomSeed.h>
0027 // qa utils
0028 #include <qautils/QAHistManagerDef.h>
0029 // jet base software
0030 #include <jetbase/Jet.h>
0031 #include <jetbase/JetReco.h>
0032 #include <jetbase/FastJetAlgo.h>
0033 #include <jetbase/TrackJetInput.h>
0034 // module definition
0035 #include </sphenix/u/danderson/install/include/trksinjetqa/TrksInJetQA.h>
0036 // f4a macros
0037 #include <G4_Magnet.C>
0038 #include <G4_ActsGeom.C>
0039 #include <GlobalVariables.C>
0040 #include <Trkr_Clustering.C>
0041 
0042 // load libraries
0043 R__LOAD_LIBRARY(libg4dst.so)
0044 R__LOAD_LIBRARY(libg4jets.so)
0045 R__LOAD_LIBRARY(libfun4all.so)
0046 R__LOAD_LIBRARY(libjetbase.so)
0047 R__LOAD_LIBRARY(libqautils.so)
0048 R__LOAD_LIBRARY(libffamodules.so)
0049 R__LOAD_LIBRARY(/sphenix/u/danderson/install/lib/libtrksinjetqa.so)
0050 
0051 
0052 
0053 // macro body -----------------------------------------------------------------
0054 
0055 void Fun4All_MakeTrksInJetQA(
0056   const int         verb           = 10,
0057   const int64_t     nEvts          = 10,
0058   const std::string outFileBase    = "test",
0059   const std::string inTrkDSTs      = "input/pp200py8run11jet30.dst_tracks.list",
0060   const std::string inTrkHitDSTs   = "input/pp200py8run11jet30.dst_trkr_hit.list",
0061   const std::string inTrkClustDSTs = "input/pp200py8run11jet30.dst_trkr_cluster.list",
0062   const std::string inCalClustDSTs = "input/pp200py8run11jet30.dst_calo_cluster.list"
0063 ) {
0064 
0065   // initialize fun4all -------------------------------------------------------
0066 
0067   // grab instances of fun4all, etc
0068   Fun4AllServer* f4a = Fun4AllServer::instance();
0069   CDBInterface*  cdb = CDBInterface::instance();
0070   recoConsts*    rc  = recoConsts::instance();
0071 
0072   // turn on cdb
0073   Enable::CDB = true;
0074 
0075   // set cdb tags
0076   rc -> set_StringFlag("CDB_GLOBALTAG", "ProdA_2023");
0077   rc -> set_uint64Flag("TIMESTAMP", 6);
0078 
0079   // get url of geo file
0080   const std::string inGeoFile = cdb -> getUrl("Tracking_Geometry");
0081 
0082   // set up input managers
0083   Fun4AllDstInputManager*     trkManager   = new Fun4AllDstInputManager("TrackDstManager");
0084   Fun4AllDstInputManager*     hitManager   = new Fun4AllDstInputManager("TrackHitDstManager");
0085   Fun4AllDstInputManager*     clustManager = new Fun4AllDstInputManager("TrackClusterDstManager");
0086   Fun4AllDstInputManager*     caloManager  = new Fun4AllDstInputManager("CaloClusterDstManager");
0087   Fun4AllRunNodeInputManager* geoManager   = new Fun4AllRunNodeInputManager("GeometryManager");
0088   trkManager   -> AddListFile(inTrkDSTs.data(), 1);
0089   hitManager   -> AddListFile(inTrkHitDSTs.data(), 1);
0090   clustManager -> AddListFile(inTrkClustDSTs.data(), 1);
0091   caloManager  -> AddListFile(inCalClustDSTs.data(), 1);
0092   geoManager   -> AddFile(inGeoFile.data());
0093   f4a -> registerInputManager(trkManager);
0094   f4a -> registerInputManager(hitManager);
0095   f4a -> registerInputManager(clustManager);
0096   f4a -> registerInputManager(caloManager);
0097   f4a -> registerInputManager(geoManager);
0098 
0099   // initialize acts geometry
0100   G4TPC::tpc_drift_velocity_reco = (8.0 / 1000) * 107.0 / 105.0;
0101   G4MAGNET::magfield = "0.01";
0102   G4MAGNET::magfield_rescale = 1;
0103   ACTSGEOM::ActsGeomInit();
0104 
0105   // register jet finders -----------------------------------------------------
0106 
0107   // run track jet reconstruction
0108   JetReco* trkJetFinder = new JetReco();
0109   trkJetFinder -> add_input(new TrackJetInput(Jet::SRC::TRACK));
0110   trkJetFinder -> add_algo(new FastJetAlgo(Jet::ALGO::ANTIKT, 0.4), "AntiKt_Track_r04");
0111   trkJetFinder -> set_algo_node("ANTIKT");
0112   trkJetFinder -> set_input_node("TRACK");
0113   trkJetFinder -> Verbosity(verb);
0114   f4a  -> registerSubsystem(trkJetFinder);
0115 
0116   // run cluster jet reconstruction
0117   JetReco* clustJetFinder = new JetReco();
0118   clustJetFinder -> add_input(new TrackJetInput(Jet::SRC::CEMC_CLUSTER));
0119   clustJetFinder -> add_input(new TrackJetInput(Jet::SRC::HCALIN_CLUSTER));
0120   clustJetFinder -> add_input(new TrackJetInput(Jet::SRC::HCALOUT_CLUSTER));
0121   clustJetFinder -> add_algo(new FastJetAlgo(Jet::ALGO::ANTIKT, 0.4), "AntiKt_Cluster_r04");
0122   clustJetFinder -> set_algo_node("ANTIKT");
0123   clustJetFinder -> set_input_node("CLUSTER");
0124   clustJetFinder -> Verbosity(verb);
0125   f4a  -> registerSubsystem(clustJetFinder);
0126 
0127   // example of how to use modue as a plain SubsysReco module -----------------
0128 
0129   // construct output file names
0130   const std::string outTrkFile = outFileBase + ".track.root";
0131   const std::string outCalFile = outFileBase + ".clust.root";
0132 
0133   // initialize and register track jet qa module
0134   TrksInJetQA* trkJetQAReco = new TrksInJetQA("TrksInJetQA_TrackJets");
0135   trkJetQAReco -> SetOutFileName(outTrkFile);
0136   trkJetQAReco -> SetHistSuffix("TrackJetRecoReco");
0137   trkJetQAReco -> Configure(
0138     {
0139       .outMode     = TrksInJetQA::OutMode::File,
0140       .verbose     = verb,
0141       .doDebug     = true,
0142       .doInclusive = true,
0143       .doInJet     = true,
0144       .doHitQA     = true,
0145       .doClustQA   = true,
0146       .doTrackQA   = true,
0147       .doJetQA     = true,
0148       .rJet        = 0.4,
0149       .jetInNode   = "AntiKt_Track_r04"
0150     }
0151   );
0152   f4a -> registerSubsystem(trkJetQAReco);
0153 
0154   // initialize and register track jet qa module
0155   TrksInJetQA* clustJetQAReco = new TrksInJetQA("TrksInJetQA_ClustJets");
0156   clustJetQAReco -> SetOutFileName(outCalFile);
0157   clustJetQAReco -> SetHistSuffix("ClustJetRecoReco");
0158   clustJetQAReco -> Configure(
0159     {
0160       .outMode     = TrksInJetQA::OutMode::File,
0161       .verbose     = verb,
0162       .doDebug     = true,
0163       .doInclusive = true,
0164       .doInJet     = true,
0165       .doHitQA     = true,
0166       .doClustQA   = true,
0167       .doTrackQA   = true,
0168       .doJetQA     = true,
0169       .rJet        = 0.4,
0170       .jetInNode   = "AntiKt_Cluster_r04"
0171     }
0172   );
0173   f4a -> registerSubsystem(clustJetQAReco);
0174 
0175   // example of how to use module with qa framework ---------------------------
0176 
0177   const std::string outQAFile = outFileBase + ".qa.root";
0178 
0179   // initialize and register track jet qa module
0180   TrksInJetQA* trkJetQANode = new TrksInJetQA("TrksInJetQANode_TrackJets");
0181   trkJetQANode -> SetHistSuffix("TrackJetQANode");
0182   trkJetQANode -> Configure(
0183     {
0184       .outMode     = TrksInJetQA::OutMode::QA,
0185       .verbose     = verb,
0186       .doDebug     = true,
0187       .doInclusive = true,
0188       .doInJet     = true,
0189       .doHitQA     = true,
0190       .doClustQA   = true,
0191       .doTrackQA   = true,
0192       .doJetQA     = true,
0193       .rJet        = 0.4,
0194       .jetInNode   = "AntiKt_Track_r04"
0195     }
0196   );
0197   f4a -> registerSubsystem(trkJetQANode);
0198 
0199   // initialize and register track jet qa module
0200   TrksInJetQA* clustJetQANode = new TrksInJetQA("TrksInJetQANode_ClustJets");
0201   clustJetQANode -> SetHistSuffix("ClustJetQANode");
0202   clustJetQANode -> Configure(
0203     {
0204       .outMode     = TrksInJetQA::OutMode::QA,
0205       .verbose     = verb,
0206       .doDebug     = true,
0207       .doInclusive = true,
0208       .doInJet     = true,
0209       .doHitQA     = true,
0210       .doClustQA   = true,
0211       .doTrackQA   = true,
0212       .doJetQA     = true,
0213       .rJet        = 0.4,
0214       .jetInNode   = "AntiKt_Cluster_r04"
0215     }
0216   );
0217   f4a -> registerSubsystem(clustJetQANode);
0218 
0219   // run  modules and exit ----------------------------------------------------
0220 
0221   // run4all
0222   f4a -> run(nEvts);
0223   f4a -> End();
0224 
0225   // save qa output and exit
0226   QAHistManagerDef::saveQARootFile(outQAFile);
0227   delete f4a;
0228 
0229   // close and exit
0230   gSystem -> Exit(0);
0231   return;
0232 
0233 }
0234 
0235 // end ------------------------------------------------------------------------