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 <fun4all/SubsysReco.h>
0005 #include <fun4all/Fun4AllServer.h>
0006 #include <fun4all/Fun4AllInputManager.h>
0007 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0008 #include <calovalid/TriggerValid.h>
0009 #include <ffamodules/CDBInterface.h>
0010 #include <ffamodules/FlagHandler.h>
0011 #include <CaloEmulatorTreeMaker.h>
0012 #include <calotrigger/LL1PacketGetter.h>
0013 #include <calotrigger/CaloTriggerEmulator.h>
0014 #include <caloreco/CaloTowerBuilder.h>
0015 #include <caloreco/CaloWaveformProcessing.h>
0016 #include <phool/recoConsts.h>
0017 R__LOAD_LIBRARY(libcalotrigger.so)
0018 R__LOAD_LIBRARY(libtriggervalid.so)
0019 R__LOAD_LIBRARY(libfun4allraw.so)
0020 R__LOAD_LIBRARY(libfun4all.so)
0021 R__LOAD_LIBRARY(libemulatortreemaker.so)
0022 #endif
0023 
0024 void Fun4All_RawData_Emulator(const int runnumber)
0025 { 
0026 
0027   // example input file
0028   std::string fname1 = Form("/sphenix/user/dlis/Projects/raw/triggertests/triggertest-000%d-0000.prdf", runnumber);;
0029   Fun4AllServer *se = Fun4AllServer::instance();
0030 
0031   recoConsts *rc = recoConsts::instance();
0032 
0033   //===============
0034   // conditions DB flags
0035   //===============
0036 
0037   //CDB to grab Lookup tables
0038   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2023");
0039   rc->set_uint64Flag("TIMESTAMP", runnumber);
0040   CDBInterface::instance()->Verbosity(1);
0041   
0042   int verbosity = 0;
0043   se->Verbosity(verbosity);
0044 
0045 
0046   // Get LL1 Data into NodeTree for Jet LL1 board
0047 
0048   LL1PacketGetter *la = new LL1PacketGetter("LL1PACKETGETTER_JET","JET", "HCAL");
0049   la->Verbosity(verbosity);
0050   se->registerSubsystem(la);
0051 
0052   // Get LL1 Data into Nodetree for EMCAL LL1 boards
0053 
0054   LL1PacketGetter *la1 = new LL1PacketGetter("LL1PACKETGETTER_EMCAL","NONE", "EMCAL");
0055   la1->Verbosity(verbosity);
0056   se->registerSubsystem(la1);
0057 
0058   // Need waveforms to build the trigger primitives for the emulator
0059   CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFWaveform;
0060 
0061   
0062   CaloTowerBuilder *ctbEMCal = new CaloTowerBuilder("EMCALBUILDER");
0063   ctbEMCal->set_detector_type(CaloTowerDefs::CEMC);
0064   ctbEMCal->set_processing_type(CaloWaveformProcessing::FAST);
0065   ctbEMCal->set_builder_type(buildertype);
0066   ctbEMCal->set_outputNodePrefix("WAVEFORM_");
0067   ctbEMCal->set_nsamples(12);
0068   se->registerSubsystem(ctbEMCal);
0069 
0070   CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
0071   ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0072   ctbOHCal->set_processing_type(CaloWaveformProcessing::FAST);
0073   ctbOHCal->set_builder_type(buildertype);
0074   ctbOHCal->set_outputNodePrefix("WAVEFORM_");
0075   ctbOHCal->set_nsamples(12);
0076   se->registerSubsystem(ctbOHCal);
0077 
0078   CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
0079   ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0080   ctbIHCal->set_processing_type(CaloWaveformProcessing::FAST);
0081   ctbIHCal->set_builder_type(buildertype);
0082   ctbIHCal->set_outputNodePrefix("WAVEFORM_");
0083   ctbIHCal->set_nsamples(12);
0084   se->registerSubsystem(ctbIHCal);
0085 
0086   // Calo Trigger Emulator
0087   CaloTriggerEmulator *te = new CaloTriggerEmulator("CALOTRIGGEREMULATOR_JET");
0088   te->Verbosity(verbosity);
0089   // need to set trigger type 
0090   // "JET" -- Full Jet algorithm
0091   // "PHOTON" -- only 8x8 patch photon right now
0092   // "PAIR" -- not implemented
0093   te->setTriggerType("JET");
0094 
0095   // need number of calo readout samples
0096   te->setNSamples(12);
0097   
0098   // which sample was used (reference to the Calo readout)
0099   te->setTriggerSample(9);
0100   // subrtraction delay of the post and pre sample
0101   te->setTriggerDelay(6);
0102 
0103   // If specific thresholds arent set (below, this one is used)
0104   te->setThreshold(1);
0105   // Threshold for Jet Trigger uses 4 separate ones. (same as the four we have in the real
0106   // te->setThreshold(int t1, int t2, int t3, int t4);
0107 
0108 
0109   se->registerSubsystem(te);
0110 
0111   Fun4AllInputManager *in = new Fun4AllPrdfInputManager("in");
0112   in->fileopen(fname1);
0113   se->registerInputManager(in);
0114 
0115   char outfile[100];
0116   sprintf(outfile, "/sphenix/user/dlis/Projects/CaloTriggerEmulator/outputs/cosmicjet-%d.root", runnumber);
0117 
0118   char outfile2[100];
0119   sprintf(outfile2, "/sphenix/user/dlis/Projects/CaloTriggerEmulator/outputs/histos-%d.root", runnumber);
0120 
0121   CaloEmulatorTreeMaker *tt1 = new CaloEmulatorTreeMaker("CaloEmulatorTreemaker",outfile);
0122   tt1->UseCaloTowerBuilder(true);
0123   tt1->Verbosity(verbosity);
0124   se->registerSubsystem(tt1);
0125 
0126   TriggerValid *tt2 = new TriggerValid("TriggerValid",outfile2);
0127   se->registerSubsystem(tt2);
0128 
0129 
0130 
0131 // Fun4All
0132 //  se->skip();
0133   se->run(10);
0134   se->End();
0135 }