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 <fun4all/SubsysReco.h>
0005 #include <fun4all/Fun4AllServer.h>
0006 #include <fun4all/Fun4AllInputManager.h>
0007 #include <fun4all/Fun4AllDstInputManager.h>
0008 #include <fun4all/Fun4AllDstOutputManager.h>
0009 #include <calovalid/TriggerValid.h>
0010 #include <ffamodules/CDBInterface.h>
0011 #include <ffamodules/FlagHandler.h>
0012 #include <calotrigger/LL1PacketGetter.h>
0013 #include <calotrigger/CaloTriggerEmulator.h>
0014 #include <caloreco/CaloTowerBuilder.h>
0015 #include <caloreco/CaloTowerCalib.h>
0016 #include <caloreco/CaloWaveformProcessing.h>
0017 #include <phool/recoConsts.h>
0018 #include <QA.C>
0019
0020 R__LOAD_LIBRARY(libcalo_reco.so)
0021 R__LOAD_LIBRARY(libcalotrigger.so)
0022 R__LOAD_LIBRARY(libtriggervalid.so)
0023 R__LOAD_LIBRARY(libfun4allraw.so)
0024 R__LOAD_LIBRARY(libfun4all.so)
0025 R__LOAD_LIBRARY(libemulatortreemaker.so)
0026 #endif
0027
0028 void Fun4All_Calo_Emulator(const int runnumber, int nEvents = 0)
0029 {
0030
0031
0032 std::string fname1 = Form("/sphenix/tg/tg01/commissioning/CaloCalibWG/dlis/DST_PRDF-000%d-0000.root", runnumber);;
0033 Fun4AllServer *se = Fun4AllServer::instance();
0034
0035 recoConsts *rc = recoConsts::instance();
0036
0037
0038
0039
0040
0041
0042 rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2023");
0043 rc->set_uint64Flag("TIMESTAMP", runnumber);
0044
0045 int verbosity = 0;
0046 se->Verbosity(1);
0047
0048
0049
0050 CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFWaveform;
0051
0052
0053 CaloTowerBuilder *ctbEMCal = new CaloTowerBuilder("EMCALBUILDER");
0054 ctbEMCal->set_detector_type(CaloTowerDefs::CEMC);
0055 ctbEMCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0056 ctbEMCal->set_builder_type(buildertype);
0057 ctbEMCal->set_outputNodePrefix("WAVEFORM_");
0058 ctbEMCal->set_nsamples(12);
0059 ctbEMCal->set_offlineflag(true);
0060 se->registerSubsystem(ctbEMCal);
0061
0062 CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
0063 ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0064 ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0065 ctbOHCal->set_builder_type(buildertype);
0066 ctbOHCal->set_outputNodePrefix("WAVEFORM_");
0067 ctbOHCal->set_nsamples(12);
0068 ctbOHCal->set_offlineflag(true);
0069 se->registerSubsystem(ctbOHCal);
0070
0071 CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
0072 ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0073 ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0074 ctbIHCal->set_builder_type(buildertype);
0075 ctbIHCal->set_outputNodePrefix("WAVEFORM_");
0076 ctbIHCal->set_nsamples(12);
0077 ctbIHCal->set_offlineflag(true);
0078 se->registerSubsystem(ctbIHCal);
0079
0080 CaloTowerCalib *calib = new CaloTowerCalib();
0081 calib->set_detector_type(CaloTowerDefs::HCALOUT);
0082 calib->set_inputNodePrefix("WAVEFORM_");
0083 calib->set_outputNodePrefix("TOWERSWAVEFORM_CALIB_");
0084 se->registerSubsystem(calib);
0085
0086 calib = new CaloTowerCalib();
0087 calib->set_detector_type(CaloTowerDefs::HCALIN);
0088 calib->set_inputNodePrefix("WAVEFORM_");
0089 calib->set_outputNodePrefix("TOWERSWAVEFORM_CALIB_");
0090 se->registerSubsystem(calib);
0091
0092 calib = new CaloTowerCalib();
0093 calib->set_detector_type(CaloTowerDefs::CEMC);
0094 calib->set_inputNodePrefix("WAVEFORM_");
0095 calib->set_outputNodePrefix("TOWERSWAVEFORM_CALIB_");
0096 se->registerSubsystem(calib);
0097
0098
0099 CaloTriggerEmulator *te = new CaloTriggerEmulator("CALOTRIGGEREMULATOR_PHOTON");
0100 te->Verbosity(verbosity);
0101
0102
0103
0104
0105 te->setTriggerType("PHOTON");
0106
0107
0108 te->setNSamples(12);
0109
0110
0111 te->setTriggerSample(6);
0112
0113 te->setTriggerDelay(5);
0114 te->useEMCAL(true);
0115 te->useHCALIN(false);
0116 te->useHCALOUT(false);
0117
0118
0119 te->setEmcalLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/emcal_ll1_lut.root");
0120
0121
0122
0123 te->setThreshold(1);
0124
0125
0126
0127
0128 se->registerSubsystem(te);
0129
0130 Fun4AllInputManager *in = new Fun4AllDstInputManager("in");
0131 in->fileopen(fname1);
0132 se->registerInputManager(in);
0133
0134
0135 TriggerValid *tt2 = new TriggerValid("TriggerValid");
0136 se->registerSubsystem(tt2);
0137
0138 char outfile_hist[100];
0139 sprintf(outfile_hist, "/sphenix/tg/tg01/commissioning/CaloCalibWG/dlis/HIST_TRIGGER_QA-%08d-%04d.root", runnumber, 0);
0140 string fulloutfile_hist = outfile_hist;
0141
0142 Fun4AllOutputManager *out = new Fun4AllDstOutputManager("TriggerOut", "/sphenix/tg/tg01/commissioning/CaloCalibWG/dlis/DST_EMULATOR.root");
0143 out->UseFileRule();
0144 se->registerOutputManager(out);
0145
0146
0147
0148 se->run(nEvents);
0149 se->End();
0150 TString qaname = fulloutfile_hist;
0151 std::string qaOutputFileName(qaname.Data());
0152 QAHistManagerDef::saveQARootFile(qaOutputFileName);
0153
0154 cout << "JOB COMPLETE :)" <<endl;
0155 }