Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:11

0001 #pragma once
0002 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0003 
0004 #include <frog/FROG.h>
0005 
0006 #include <GlobalVariables.C>
0007 #include <G4_Input.C>
0008 #include <QA.C>
0009 #include <caloreco/CaloGeomMapping.h>
0010 #include <caloreco/CaloTowerBuilder.h>
0011 #include <caloreco/CaloTowerCalib.h>
0012 #include <caloreco/CaloWaveformProcessing.h>
0013 
0014 
0015 #include <calowaveformsim/CaloWaveformSim.h>
0016 
0017 #include <ffamodules/CDBInterface.h>
0018 #include <ffamodules/FlagHandler.h>
0019 #include <ffamodules/HeadReco.h>
0020 #include <ffamodules/SyncReco.h>
0021 #include <fun4all/Fun4AllRunNodeInputManager.h>
0022 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0023 
0024 #include <fun4all/Fun4AllUtils.h>
0025 #include <fun4all/Fun4AllDstOutputManager.h>
0026 #include <fun4all/Fun4AllInputManager.h>
0027 #include <fun4all/Fun4AllServer.h>
0028 #include <fun4all/SubsysReco.h>
0029 
0030 #include <phool/recoConsts.h>
0031 //////// FOR CALOCALIB //////////
0032 #include <calotrigger/CaloTriggerEmulator.h>
0033 #include <calotrigger/TriggerRunInfoReco.h>
0034 //////////////////
0035 
0036 #include <calowaveformsim/TriggerPerformance.h>
0037 #include <CaloEmulatorTreeMaker.h>
0038 R__LOAD_LIBRARY(libFROG.so)
0039 R__LOAD_LIBRARY(libdlutility.so)
0040   R__LOAD_LIBRARY(libfun4all.so)
0041 R__LOAD_LIBRARY(libfun4allraw.so)
0042 R__LOAD_LIBRARY(libCaloWaveformSim.so)
0043 R__LOAD_LIBRARY(libcalo_reco.so)
0044 R__LOAD_LIBRARY(libffamodules.so)
0045 //////// FOR CALOCALIB //////////
0046   R__LOAD_LIBRARY(libcalotrigger.so)
0047 R__LOAD_LIBRARY(libtriggervalid.so)
0048 R__LOAD_LIBRARY(libemulatortreemaker.so)
0049 #endif
0050 
0051 void Fun4All_Sim(
0052          const std::string filename = "DST_CALO_CLUSTER_pythia8_Detroit-0000000021-000000.root",
0053          const int nEvents = 100)
0054 {
0055 
0056   // example input file
0057   gSystem->Load("libFROG");
0058 
0059   FROG *fr = new FROG();
0060 
0061   std::string input_1 = fr->location(filename.c_str());
0062 
0063   Fun4AllServer *se = Fun4AllServer::instance();
0064   se->Verbosity(1);
0065 
0066   recoConsts *rc = recoConsts::instance();
0067 
0068 
0069   std::pair<int, int> run_seg = Fun4AllUtils::GetRunSegment(filename.c_str());
0070   int runnumber = run_seg.first;
0071   int segment = run_seg.second;
0072 
0073   Enable::CDB = true;
0074   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0075   rc->set_uint64Flag("TIMESTAMP", 21);
0076   CDBInterface::instance()->Verbosity(1);
0077 
0078   //===============
0079   // Input options
0080   //===============
0081   // verbosity setting (applies to all input managers)
0082 
0083   // register the flag handling
0084   FlagHandler *flag = new FlagHandler();
0085   se->registerSubsystem(flag);
0086 
0087   //////// FOR CALOCALIB //////////
0088   TriggerRunInfoReco *trr = new TriggerRunInfoReco("TriggerRunInfoReco");
0089   trr->UseEmulator(true);  
0090   trr->Verbosity(0);
0091   se->registerSubsystem(trr);
0092   //////// FOR CALOCALIB //////////
0093   CaloTriggerEmulator *te = new CaloTriggerEmulator("CALOTRIGGEREMULATOR");
0094   te->setNSamples(12);
0095   te->setTriggerSample(6);
0096   te->setTriggerDelay(5);
0097   te->SetIsData(false);
0098   te->setEmcalLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/emcal_ll1_lut_0.50tr_new.root");
0099   te->setHcalinLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/hcalin_ll1_lut_0.50tr_new.root");
0100   te->setHcaloutLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/hcalout_ll1_lut_0.50tr_new.root");
0101   se->registerSubsystem(te);
0102   /////////////////////////////////
0103 
0104 
0105   TriggerPerformance *tp = new TriggerPerformance("TriggerPerformance","histo_trigger.root");
0106   tp->UseEmulator(true);
0107   tp->Verbosity(0);
0108   se->registerSubsystem(tp);
0109   //  std::string trigger = "HIJET";
0110 
0111   // char outfile_hist[1000];
0112   //  sprintf(outfile_hist, "/sphenix/tg/tg01/commissioning/CaloCalibWG/dlis/HIST_%s_TRIGGER_QA-%08d-%04d.root", trigger.c_str(), runnumber, segment);
0113   //  string fulloutfile_hist = outfile_hist;
0114 
0115 
0116   //  EmulatorHistos *tt2 = new EmulatorHistos("EmulatorHistos");
0117   //  se->registerSubsystem(tt2);
0118 
0119   // char outfile_dst[100];
0120   // sprintf(outfile_dst, "/sphenix/tg/tg01/commissioning/CaloCalibWG/dlis/DST_EMULATOR-%08d-%04d.root", runnumber, segment);
0121   // string fulloutfile_dst = outfile_dst;
0122 
0123   // char outfile_tree[1000];
0124   // sprintf(outfile_tree, "/sphenix/tg/tg01/commissioning/CaloCalibWG/dlis/TREE_%s_TRIGGER_EMU-%08d-%04d.root", trigger.c_str(), runnumber, segment);
0125   // string fulloutfile_tree = outfile_tree;
0126 
0127   // CaloEmulatorTreeMaker *tt1 = new CaloEmulatorTreeMaker("CaloEmulatorTreemaker",fulloutfile_tree);
0128   // tt1->UseCaloTowerBuilder(true);
0129   // tt1->UseLL1(true);
0130   // tt1->SetIsSim(true);
0131   // tt1->Verbosity(0);
0132   // se->registerSubsystem(tt1);
0133   Fun4AllInputManager *in1 = new Fun4AllDstInputManager("in1");
0134   in1->fileopen(input_1.c_str());
0135   in1->Verbosity(0);
0136   se->registerInputManager(in1);
0137 
0138   std::cout << "Adding Geometry file" << std::endl;
0139   Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0140   std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0141   intrue2->AddFile(geoLocation);
0142   se->registerInputManager(intrue2);
0143   
0144   se->run(nEvents);
0145 
0146   se->End();
0147 
0148   // TString qaname = fulloutfile_hist;
0149   // std::string qaOutputFileName(qaname.Data());
0150   // QAHistManagerDef::saveQARootFile(qaOutputFileName);
0151 
0152   se->PrintTimer();
0153   gSystem->Exit(0);
0154 }