Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:16:47

0001 #ifndef FUN4ALL_JETSKIMMEDPRODUCTIONYEAR2_C
0002 #define FUN4ALL_JETSKIMMEDPRODUCTIONYEAR2_C
0003 
0004 #include <QA.C>
0005 #include <Calo_Calib.C>
0006 #include <HIJetReco.C>
0007 #include <Jet_QA.C>
0008 #include <G4_Global.C>
0009 #include <G4_Centrality.C>
0010 
0011 #include <mbd/MbdReco.h>
0012 
0013 #include <caloreco/CaloTowerBuilder.h>
0014 
0015 #include <epd/EpdReco.h>
0016 
0017 #include <zdcinfo/ZdcReco.h>
0018 
0019 #include <globalvertex/GlobalVertexReco.h>
0020 
0021 #include <centrality/CentralityReco.h>
0022 
0023 #include <globalqa/GlobalQA.h>
0024 
0025 #include <calotrigger/MinimumBiasClassifier.h>
0026 
0027 #include <calovalid/CaloValid.h>
0028 
0029 #include <jetdstskimmer/JetDSTSkimmer.h>
0030 
0031 #include <ffamodules/CDBInterface.h>
0032 #include <ffamodules/FlagHandler.h>
0033 #include <ffamodules/HeadReco.h>
0034 #include <ffamodules/SyncReco.h>
0035 
0036 #include <fun4all/Fun4AllDstInputManager.h>
0037 #include <fun4all/Fun4AllDstOutputManager.h>
0038 #include <fun4all/Fun4AllInputManager.h>
0039 #include <fun4all/Fun4AllRunNodeInputManager.h>
0040 #include <fun4all/Fun4AllServer.h>
0041 #include <fun4all/Fun4AllUtils.h>
0042 #include <fun4all/SubsysReco.h>
0043 
0044 #include <phool/recoConsts.h>
0045 
0046 
0047 R__LOAD_LIBRARY(libfun4all.so)
0048 R__LOAD_LIBRARY(libcalo_reco.so)
0049 R__LOAD_LIBRARY(libcalotrigger.so)
0050 R__LOAD_LIBRARY(libcentrality.so)
0051 R__LOAD_LIBRARY(libffamodules.so)
0052 R__LOAD_LIBRARY(libmbd.so)
0053 R__LOAD_LIBRARY(libglobalvertex.so)
0054 R__LOAD_LIBRARY(libcalovalid.so)
0055 R__LOAD_LIBRARY(libglobalQA.so)
0056 R__LOAD_LIBRARY(libJetDSTSkimmer.so)
0057 R__LOAD_LIBRARY(libepd.so)
0058 R__LOAD_LIBRARY(libzdcinfo.so)
0059 
0060 void Fun4All_JetSkimmedProductionYear2(int nEvents = 1000,
0061                         const std::string &fname_calo = "DST_CALOFITTING_run3oo_pro001_pcdb001_v001-00082703-00000.root",
0062                         const std::string &fname_zdc  = "DST_ZDC_RAW_run3oo_pro001_pcdb001_v001-00082703-00000.root",
0063                         const std::string &fname_sepd  = "DST_SEPD_RAW_run3oo_pro001_pcdb001_v001-00082703-00000.root",
0064                         const std::string &outfile_low  = "DST_JETCALO_run3oo_pro001_pcdb001_v001-00082703-00000.root",
0065                         const std::string &outfile_high = "DST_Jet_run3oo_pro001_pcdb001_v001-00082703-00000.root",
0066                         const std::string &outfile_hist = "HIST_JETQA_run3oo_pro001_pcdb001_v001-00082703-00000.root",
0067                         const std::string &dbtag = "newcdbtag"
0068   )
0069 {
0070   Fun4AllServer *se = Fun4AllServer::instance();
0071   se->Verbosity(1);
0072   se->VerbosityDownscale(10000);
0073   recoConsts *rc = recoConsts::instance();
0074 
0075   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(fname_calo);
0076   int runnumber = runseg.first;
0077 
0078   // conditions DB flags and timestamp
0079   rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0080   rc->set_uint64Flag("TIMESTAMP", runnumber);
0081   CDBInterface::instance()->Verbosity(1);
0082 
0083   FlagHandler *flag = new FlagHandler();
0084   se->registerSubsystem(flag);
0085 
0086   // MBD/BBC Reconstruction
0087   MbdReco *mbdreco = new MbdReco();
0088   se->registerSubsystem(mbdreco);
0089 
0090   // sEPD Reconstruction--Calib Info
0091   CaloTowerBuilder *caEPD = new CaloTowerBuilder("SEPDBUILDER");
0092   caEPD->set_detector_type(CaloTowerDefs::SEPD);
0093   caEPD->set_builder_type(CaloTowerDefs::kPRDFTowerv4);
0094   caEPD->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0095   caEPD->set_nsamples(12);
0096   caEPD->set_offlineflag();
0097   se->registerSubsystem(caEPD);
0098 
0099   EpdReco *epdreco = new EpdReco();
0100   se->registerSubsystem(epdreco);
0101 
0102   //we need to do the ZDC fitting here...
0103   CaloTowerBuilder *caZDC = new CaloTowerBuilder("ZDCBUILDER");
0104   caZDC->set_detector_type(CaloTowerDefs::ZDC);
0105   caZDC->set_builder_type(CaloTowerDefs::kPRDFTowerv4);
0106   if( (runnumber > RunnumberRange::RUN2PP_FIRST && runnumber < RunnumberRange::RUN2PP_LAST)
0107      || (runnumber > RunnumberRange::RUN3PP_FIRST && runnumber < RunnumberRange::RUN3PP_LAST) ){
0108     caZDC->set_processing_type(CaloWaveformProcessing::FAST);
0109   }
0110   else {
0111     caZDC->set_processing_type(CaloWaveformProcessing::FUNCFIT);
0112     caZDC->set_funcfit_type(2);
0113   }
0114   caZDC->set_nsamples(16);
0115   caZDC->set_offlineflag();
0116   se->registerSubsystem(caZDC);
0117 
0118 
0119   // ZDC Reconstruction--Calib Info
0120   ZdcReco *zdcreco = new ZdcReco();
0121   zdcreco->set_zdc1_cut(0.0);
0122   zdcreco->set_zdc2_cut(0.0);
0123   se->registerSubsystem(zdcreco);
0124 
0125   // Official vertex storage
0126   GlobalVertexReco *gvertex = new GlobalVertexReco();
0127   se->registerSubsystem(gvertex);
0128 
0129   GlobalQA *gqa = new GlobalQA("GlobalQA");
0130   se->registerSubsystem(gqa);
0131 
0132   /////////////////////////////////////////////////////
0133   // Set status of CALO towers, calibrate, cluster
0134   std::cout << "Processing Calo Calibration" << std::endl;
0135   Process_Calo_Calib();
0136 
0137   CaloValid *ca = new CaloValid("CaloValid");
0138   ca->set_timing_cut_width(200);
0139   se->registerSubsystem(ca);
0140 
0141   // Centrality required for HI
0142   Centrality();
0143 
0144 
0145   // Jet reco related flags
0146   Enable::QA = true;
0147   
0148   // Au+Au mode
0149   HIJETS::is_pp = false;
0150   
0151   // QA options
0152   JetQA::HasTracks        = false;
0153   JetQA::DoInclusive      = true;
0154   JetQA::DoTriggered      = false;
0155   JetQA::RestrictPtToTrig = false;
0156   JetQA::RestrictEtaByR   = true;
0157   JetQA::DoPP             = HIJETS::is_pp;
0158   JetQA::UseBkgdSub       = true;
0159   JetQA::HasCalos         = true;
0160   
0161   if (!HIJETS::is_pp)
0162     {
0163       std::cout << ">>> Running Centrality()" << std::endl;
0164       Centrality();
0165     }
0166   
0167   // HIJetReco macro 
0168   std::cout << ">>> Running HIJetReco()" << std::endl;
0169   HIJetReco();
0170   
0171   // Jet DST skimmer with map-based threshold
0172   std::cout << ">>> Configuring JetDSTSkimmer" << std::endl;
0173   JetDSTSkimmer *jetDSTSkimmer = new JetDSTSkimmer();
0174   
0175   // Jet thresholds: map from node name [set min jet pT]
0176   std::map<std::string, float> jetNodePts;
0177   
0178   jetNodePts["AntiKt_Tower_r03_Sub1"] = 10.0F;
0179   jetDSTSkimmer->SetJetNodeThresholds(jetNodePts);
0180   
0181   // Cluster thresholds: map from cluster node [set min cluster pT]
0182   std::map<std::string, float> clusterNodePts;
0183   clusterNodePts["CLUSTERINFO_CEMC"] = 8.0F;
0184   jetDSTSkimmer->SetClusterNodeThresholds(clusterNodePts);
0185   
0186   jetDSTSkimmer->Verbosity(0);
0187   se->registerSubsystem(jetDSTSkimmer);
0188   std::cout << ">>> JetDSTSkimmer registered" << std::endl;
0189   
0190   // Filter out beam-background events
0191   /*
0192   BeamBackgroundFilterAndQA *filter =
0193     new BeamBackgroundFilterAndQA("BeamBackgroundFilterAndQA");
0194   filter->Verbosity(std::max(Enable::QA_VERBOSITY, Enable::JETQA_VERBOSITY));
0195   filter->SetConfig(
0196             {
0197               .debug          = false,
0198               .doQA           = Enable::QA,
0199               .doEvtAbort     = false,
0200               .filtersToApply = {"StreakSideband"}
0201             });
0202   se->registerSubsystem(filter);
0203   */
0204   // Register modules necessary for QA
0205   if (Enable::QA)
0206     {
0207       std::cout << ">>> Enabling QA: DoRhoCalculation + Jet_QA" << std::endl;
0208       DoRhoCalculation();
0209       Jet_QA();
0210     }
0211 
0212   Fun4AllInputManager *InCalo = new Fun4AllDstInputManager("in");
0213   InCalo->AddFile(fname_calo);
0214   se->registerInputManager(InCalo);
0215 
0216   Fun4AllInputManager *InZDC = new Fun4AllDstInputManager("inzdc");
0217   InZDC->AddFile(fname_zdc);
0218   se->registerInputManager(InZDC);
0219 
0220   Fun4AllInputManager *InSEPD = new Fun4AllDstInputManager("insepd");
0221   InSEPD->AddFile(fname_sepd);
0222   se->registerInputManager(InSEPD);
0223 
0224   // --- Output managers ---
0225   // DST_JETCALO: low-threshold output — keeps raw tower and ZDC data
0226   Fun4AllDstOutputManager *outlower = new Fun4AllDstOutputManager("DSTOUTLOW", outfile_low);
0227   outlower->AddNode("Sync");
0228   outlower->AddNode("EventHeader");
0229   outlower->AddNode("12001");
0230   outlower->AddNode("14001");
0231   outlower->AddNode("TOWERS_HCALIN");
0232   outlower->AddNode("TOWERS_HCALOUT");
0233   outlower->AddNode("TOWERS_CEMC");
0234   outlower->AddNode("TOWERS_SEPD");
0235   outlower->AddNode("MbdRawContainer");
0236   outlower->AddNode("TriggerRunInfo");
0237   outlower->StripCompositeNode("Packets");
0238   se->registerOutputManager(outlower);
0239 
0240   // DST_Jet: high-threshold output — strips raw tower data, keeps jets
0241   Fun4AllDstOutputManager *outhigher = new Fun4AllDstOutputManager("DSTOUTHIGH", outfile_high);
0242   outhigher->StripNode("TOWERINFO_CALIB_HCALIN");
0243   outhigher->StripNode("TOWERS_HCALIN");
0244   outhigher->StripNode("TOWERINFO_CALIB_HCALOUT");
0245   outhigher->StripNode("TOWERS_HCALOUT");
0246   outhigher->StripNode("TOWERINFO_CALIB_CEMC");
0247   outhigher->StripNode("TOWERS_CEMC");
0248   outhigher->StripNode("TOWERS_SEPD");
0249   outhigher->StripNode("TOWERINFO_CALIB_ZDC");
0250   outhigher->StripNode("12001");
0251   outhigher->StripCompositeNode("Packets");
0252   se->registerOutputManager(outhigher);
0253 
0254   se->run(nEvents);
0255   se->End();
0256 
0257   if (Enable::QA)
0258   {
0259     QAHistManagerDef::saveQARootFile(outfile_hist);
0260   }
0261 
0262   CDBInterface::instance()->Print();  // print used DB files
0263   se->PrintTimer();
0264   delete se;
0265   std::cout << "All done!" << std::endl;
0266   gSystem->Exit(0);
0267 }
0268 
0269 #endif