Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-06 08:08:20

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 <fun4all/Fun4AllUtils.h>
0010 #include <ffamodules/CDBInterface.h>
0011 #include <ffamodules/FlagHandler.h>
0012 //#include <calotrigger/CaloTriggerEmulator.h>
0013 #include <triggeremulator/CaloTriggerEmulatorAnNeutral.h>
0014 #include <phool/recoConsts.h>
0015 
0016 #include <regex>
0017 
0018 R__LOAD_LIBRARY(libcalotrigger.so)
0019 R__LOAD_LIBRARY(libfun4allraw.so)
0020 R__LOAD_LIBRARY(libfun4all.so)
0021 R__LOAD_LIBRARY(libtriggeremulator.so)
0022 #endif
0023 
0024 void Fun4All_Calo_Emulator(int nEvents = 120,
0025                            const std::string& dst_event_filename = "DST_PHOTON_TRIGGER_LIST_run2pp_ana502_nocdbtag_v001-00053686-00000.root",
0026                            const std::string& dst_triggered_event_filename = "DST_TRIGGERED_EVENT_seb00_run2pp_ana502_nocdbtag_v001-00053686-00000.root",
0027                            const std::string& dst_outname = "DST_TRIGGER_EMULATOR_run2pp_ana502_nocdbtag_v001-00053686-00000.root")
0028 { 
0029   pair<int, int> runseg = Fun4AllUtils::GetRunSegment(dst_event_filename);
0030   int runnumber = runseg.first;
0031 
0032   std::cout << "runnumber = " << runnumber << std::endl;
0033   
0034   Fun4AllServer *se = Fun4AllServer::instance();
0035 
0036   recoConsts *rc = recoConsts::instance();
0037 
0038   //===============
0039   // conditions DB flags
0040   //===============
0041 
0042   //CDB to grab Lookup tables
0043   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0044   rc->set_uint64Flag("TIMESTAMP", runnumber);
0045   rc->set_IntFlag("RUNNUMBER", runnumber);
0046   
0047   int verbosity = 0;
0048   se->Verbosity(verbosity);
0049 
0050   // Read micro-DSTs
0051   // To treat fewer events
0052   Fun4AllDstInputManager *in = nullptr;
0053   in = new Fun4AllDstInputManager("in_micro");
0054   in->AddFile(dst_event_filename);
0055   se->registerInputManager(in);
0056 
0057   // Read Calo Packets
0058   std::string dst_file;
0059   std::string inputname = "";
0060   std::string seb_string = "seb00";
0061   std::stringstream seb_stringstream;
0062   for (int iseb = 0; iseb < 16; iseb++) // i.e. all EMCal sebs
0063   {
0064     seb_stringstream.str("");
0065     seb_stringstream << "seb" << std::setfill('0') << std::setw(2) << iseb;
0066     seb_string = seb_stringstream.str();
0067     dst_file =std::regex_replace(dst_triggered_event_filename, std::regex("seb00"), seb_string);
0068     inputname = "in_" + std::to_string(iseb);
0069     in = new Fun4AllDstInputManager(inputname);
0070     in->AddFile(dst_file);
0071     se->registerInputManager(in);
0072   }
0073 
0074   CaloTriggerEmulatorAnNeutral *te = new CaloTriggerEmulatorAnNeutral("CALOTRIGGEREMULATOR");
0075   te->Verbosity(10);
0076   te->setTriggerType("PHOTON"); // photon trigger
0077   te->setNSamples(12);
0078   te->setTriggerSample(6);
0079   //te->setJetThreshold(8, 13, 17, 22);
0080   te->setPhotonThreshold(8, 13, 17, 22); // Actually 8, 13, 17, 22
0081   // subtraction delay of the post and pre sample
0082   te->setTriggerDelay(5);
0083   te->SetIsData(true);
0084   te->SetUseOffline(true);
0085   te->Verbosity(0);
0086   std::stringstream OptMaskFilename;
0087   OptMaskFilename << "/sphenix/user/dlis/Projects/macros/CDBTest/ll1config/optmask_" << runnumber << ".root";
0088   std::stringstream EmcalLUTFilename;
0089   EmcalLUTFilename << "/sphenix/user/dlis/Projects/macros/CDBTest/adc_lut_root/emcal_luts_run" << runnumber << ".root";
0090   te->setOptMaskFile(OptMaskFilename.str().c_str());
0091   te->setEmcalLUTFile(EmcalLUTFilename.str().c_str());
0092   //te->setEmcalLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/emcal_ll1_lut_0.50tr_new.root");
0093   //te->setHcalinLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/hcalin_ll1_lut_0.50tr_new.root");
0094   //te->setHcaloutLUTFile("/sphenix/user/dlis/Projects/macros/CDBTest/hcalout_ll1_lut_0.50tr_new.root");
0095   se->registerSubsystem(te);
0096 
0097   Fun4AllOutputManager *out = new Fun4AllDstOutputManager("TriggerOut", dst_outname);
0098   out->SplitLevel(99);
0099   // Only keep TRIGGERTILE in output DST
0100   out->StripNode("14001"); // GL1 Packet
0101   for (int ipacket = 6001; ipacket <= 6128; ipacket++)
0102   {
0103     out->StripNode(std::to_string(ipacket));
0104   }
0105   out->StripNode("EventHeader");
0106   out->StripNode("LL1OUT_PHOTON");
0107   out->StripNode("LL1OUT_JET");
0108   out->StripNode("LL1OUT_PAIR");
0109   out->StripNode("TRIGGERPRIMITIVES_PHOTON");
0110   out->StripNode("TRIGGERPRIMITIVES_JET");
0111   out->StripNode("TRIGGERPRIMITIVES_PAIR");
0112   out->StripNode("TRIGGERPRIMITIVES_EMCAL");
0113   out->StripNode("TRIGGERPRIMITIVES_EMCAL_LL1");
0114   out->StripNode("TRIGGERPRIMITIVES_EMCAL_2x2_LL1");
0115   out->StripNode("TRIGGERPRIMITIVES_HCALOUT");
0116   out->StripNode("TRIGGERPRIMITIVES_HCAL_LL1");
0117   out->StripNode("TRIGGERPRIMITIVES_HCALIN");
0118   out->StripRunNode("RunHeader");
0119   out->StripRunNode("Flags");
0120   out->StripRunNode("CdbUrl");
0121   out->StripRunNode("TriggerRunInfo");
0122   
0123   se->registerOutputManager(out);
0124   
0125 
0126   // Fun4All
0127   se->Print("NODETREE");
0128   se->run(nEvents);
0129   se->End();
0130   se->PrintTimer();
0131   gSystem->Exit(0);
0132 }