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 <GlobalVariables.C>
0005 #include <G4_Input.C>
0006
0007 #include <caloreco/CaloGeomMapping.h>
0008 #include <caloreco/CaloTowerBuilder.h>
0009 #include <caloreco/CaloTowerCalib.h>
0010 #include <caloreco/CaloWaveformProcessing.h>
0011
0012
0013 #include <calowaveformsim/CaloWaveformSim.h>
0014
0015 #include <ffamodules/CDBInterface.h>
0016 #include <ffamodules/FlagHandler.h>
0017 #include <ffamodules/HeadReco.h>
0018 #include <ffamodules/SyncReco.h>
0019
0020 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0021
0022 #include <fun4all/Fun4AllDstOutputManager.h>
0023 #include <fun4all/Fun4AllInputManager.h>
0024 #include <fun4all/Fun4AllServer.h>
0025 #include <fun4all/SubsysReco.h>
0026
0027 #include <phool/recoConsts.h>
0028
0029 #include <calotrigger/CaloTriggerEmulator.h>
0030 #include <calovalid/TriggerValid.h>
0031 #include <CaloEmulatorTreeMaker.h>
0032 R__LOAD_LIBRARY(libfun4all.so)
0033 R__LOAD_LIBRARY(libfun4allraw.so)
0034 R__LOAD_LIBRARY(libCaloWaveformSim.so)
0035 R__LOAD_LIBRARY(libcalo_reco.so)
0036 R__LOAD_LIBRARY(libffamodules.so)
0037 R__LOAD_LIBRARY(libcalotrigger.so)
0038 R__LOAD_LIBRARY(libtriggervalid.so)
0039 R__LOAD_LIBRARY(libemulatortreemaker.so)
0040 #endif
0041
0042 void Fun4All_Sim_Emulator(
0043 const int nEvents = 100,
0044 const string &inputFile0 = "g4hits_12.list",
0045 const string &inputFile1 = "dst_calo_cluster_12.list",
0046 const string &inputFile2 = "/sphenix/user/shuhangli/noisetree/macro/condor31/OutDir0/pedestalhg.root",
0047
0048
0049 const string &outputFile = "DST_CALO_WAVEFORM_pp-0000000011-00000.root",
0050 const string &outdir = ".",
0051 const string &cdbtag = "ProdA_2023")
0052 {
0053
0054 Fun4AllServer *se = Fun4AllServer::instance();
0055 se->Verbosity(1);
0056
0057 recoConsts *rc = recoConsts::instance();
0058
0059 Enable::CDB = true;
0060 rc->set_StringFlag("CDB_GLOBALTAG", cdbtag);
0061 rc->set_uint64Flag("TIMESTAMP", 7);
0062 CDBInterface::instance()->Verbosity(1);
0063
0064
0065
0066
0067
0068 Input::VERBOSITY = 1;
0069
0070
0071
0072
0073
0074 Input::READHITS = true;
0075
0076
0077
0078
0079 INPUTREADHITS::listfile[0] = inputFile0;
0080 INPUTREADHITS::listfile[1] = inputFile1;
0081
0082 InputInit();
0083
0084
0085 InputRegister();
0086
0087
0088 FlagHandler *flag = new FlagHandler();
0089 se->registerSubsystem(flag);
0090
0091 Enable::DSTOUT = false;
0092 Enable::DSTOUT_COMPRESS = false;
0093 DstOut::OutputDir = outdir;
0094 DstOut::OutputFile = outputFile;
0095
0096 CaloWaveformSim *caloWaveformSim;
0097
0098 caloWaveformSim= new CaloWaveformSim();
0099 caloWaveformSim->set_detector_type(CaloTowerDefs::HCALIN);
0100 caloWaveformSim->set_detector("HCALIN");
0101 caloWaveformSim->set_nsamples(16);
0102 caloWaveformSim->set_highgain(false);
0103 caloWaveformSim->set_timewidth(0.2);
0104 caloWaveformSim->set_peakpos(6);
0105
0106 se->registerSubsystem(caloWaveformSim);
0107
0108 caloWaveformSim= new CaloWaveformSim();
0109 caloWaveformSim->set_detector_type(CaloTowerDefs::HCALOUT);
0110 caloWaveformSim->set_detector("HCALOUT");
0111 caloWaveformSim->set_nsamples(16);
0112 caloWaveformSim->set_highgain(false);
0113 caloWaveformSim->set_timewidth(0.2);
0114 caloWaveformSim->set_peakpos(6);
0115
0116 se->registerSubsystem(caloWaveformSim);
0117
0118 caloWaveformSim= new CaloWaveformSim();
0119 caloWaveformSim->set_detector_type(CaloTowerDefs::CEMC);
0120 caloWaveformSim->set_detector("CEMC");
0121 caloWaveformSim->set_nsamples(16);
0122 caloWaveformSim->set_highgain(true);
0123 caloWaveformSim->set_timewidth(0.2);
0124 caloWaveformSim->set_peakpos(6);
0125 caloWaveformSim->set_calibName("cemc_pi0_twrSlope_v1_default");
0126 se->registerSubsystem(caloWaveformSim);
0127
0128 CaloTowerBuilder *ca2 = new CaloTowerBuilder();
0129 ca2->set_detector_type(CaloTowerDefs::HCALOUT);
0130 ca2->set_nsamples(16);
0131 ca2->set_dataflag(false);
0132 ca2->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0133 ca2->set_builder_type(CaloTowerDefs::kWaveformTowerv2);
0134 se->registerSubsystem(ca2);
0135
0136 ca2 = new CaloTowerBuilder();
0137 ca2->set_detector_type(CaloTowerDefs::HCALIN);
0138 ca2->set_nsamples(16);
0139 ca2->set_dataflag(false);
0140 ca2->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0141 ca2->set_builder_type(CaloTowerDefs::kWaveformTowerv2);
0142 se->registerSubsystem(ca2);
0143
0144 ca2 = new CaloTowerBuilder();
0145 ca2->set_detector_type(CaloTowerDefs::CEMC);
0146 ca2->set_nsamples(16);
0147 ca2->set_dataflag(false);
0148 ca2->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0149 ca2->set_builder_type(CaloTowerDefs::kWaveformTowerv2);
0150
0151 se->registerSubsystem(ca2);
0152
0153
0154
0155
0156 CaloTowerCalib *calib = new CaloTowerCalib();
0157 calib->set_detector_type(CaloTowerDefs::HCALOUT);
0158 calib->set_outputNodePrefix("TOWERSWAVEFORM_CALIB_");
0159 se->registerSubsystem(calib);
0160
0161 calib = new CaloTowerCalib();
0162 calib->set_detector_type(CaloTowerDefs::HCALIN);
0163 calib->set_outputNodePrefix("TOWERSWAVEFORM_CALIB_");
0164 se->registerSubsystem(calib);
0165
0166 calib = new CaloTowerCalib();
0167 calib->set_detector_type(CaloTowerDefs::CEMC);
0168 calib->set_outputNodePrefix("TOWERSWAVEFORM_CALIB_");
0169 se->registerSubsystem(calib);
0170
0171 CaloTriggerEmulator *te = new CaloTriggerEmulator("CALOTRIGGEREMULATOR");
0172 te->setTriggerType("JET");
0173 te->setNSamples(16);
0174 te->setTriggerSample(6);
0175
0176 te->setTriggerDelay(4);
0177 te->Verbosity(0);
0178 te->setThreshold(1, 4, 6, 8);
0179 te->setEmcalLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/emcal_ll1_lut.root");
0180 te->setHcalinLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/hcalin_ll1_lut.root");
0181 te->setHcaloutLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/hcalout_ll1_lut.root");
0182 se->registerSubsystem(te);
0183
0184
0185 InputManagers();
0186
0187 Fun4AllInputManager *hitsin = new Fun4AllNoSyncDstInputManager("DST2");
0188 hitsin->AddFile(inputFile2);
0189 hitsin->Repeat();
0190 se->registerInputManager(hitsin);
0191
0192 CaloEmulatorTreeMaker *tt1 = new CaloEmulatorTreeMaker("CaloEmulatorTreemaker","test1.root");
0193 tt1->UseCaloTowerBuilder(true);
0194 tt1->Verbosity(0);
0195 se->registerSubsystem(tt1);
0196
0197 TriggerValid *tt2 = new TriggerValid("TriggerValidation","test2.root");
0198 se->registerSubsystem(tt2);
0199
0200
0201 se->run(nEvents);
0202 CDBInterface::instance()->Print();
0203 se->End();
0204 se->PrintTimer();
0205 gSystem->Exit(0);
0206 }