Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:12:43

0001 #pragma once
0002 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0003 #include <fun4all/SubsysReco.h>
0004 #include <fun4all/Fun4AllServer.h>
0005 #include <fun4all/Fun4AllInputManager.h>
0006 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0007 #include <fun4all/Fun4AllDstInputManager.h>
0008 #include <fun4all/Fun4AllDstOutputManager.h>
0009 #include <ffamodules/CDBInterface.h>
0010 #include <phool/recoConsts.h>
0011 #include <fun4all/Fun4AllUtils.h>
0012 
0013 #include <sepdwaveform/sEPDWaveform.h>
0014 
0015 R__LOAD_LIBRARY(libfun4all.so)
0016 R__LOAD_LIBRARY(libfun4allraw.so)
0017 R__LOAD_LIBRARY(libffarawobjects.so)
0018 R__LOAD_LIBRARY(libsEPDWaveform.so)
0019 #endif
0020 
0021 void Fun4All_sEPDWaveform(
0022     const std::string &input_file = "",
0023     int nEvents = 10000,
0024     const std::string &outputFile = "sEPD_templates",
0025     int runnumber = 0,
0026     int nsamples = 12,
0027     bool use_dst_input = false)
0028 {
0029   if (input_file.empty())
0030   {
0031     std::cout << "ERROR: no input_file given" << std::endl;
0032     gSystem->Exit(1);
0033   }
0034 
0035   Fun4AllServer *se = Fun4AllServer::instance();
0036   se->Verbosity(0);
0037 
0038   if (runnumber == 0)
0039   {
0040     runnumber = Fun4AllUtils::GetRunSegment(input_file).first;
0041   }
0042 
0043   recoConsts *rc = recoConsts::instance();
0044   rc->set_StringFlag("CDB_GLOBALTAG", "2025p001");
0045   rc->set_uint64Flag("TIMESTAMP", runnumber);
0046   std::cout << "sEPD template generation: run " << runnumber
0047             << ", CDB tag 2025p001, " << nsamples << " samples" << std::endl;
0048 
0049   sEPDWaveform *sepdWaveform = new sEPDWaveform("sEPDWaveform");
0050   sepdWaveform->SetDetector("SEPD");
0051   sepdWaveform->SetPacketRange(9001, 9006);
0052   sepdWaveform->SetNSamples(nsamples);
0053   sepdWaveform->SetOutputFileName(outputFile + ".root");
0054 
0055   sepdWaveform->SetFillGeometryHistograms(false);
0056   sepdWaveform->SetFillGlobalHistograms(true);
0057 
0058   sepdWaveform->SetShowProgress(true);
0059   sepdWaveform->SetProgressInterval(100);
0060 
0061   se->registerSubsystem(sepdWaveform);
0062 
0063   bool is_list = input_file.find(".list") != std::string::npos
0064               || input_file.find(".txt") != std::string::npos;
0065   bool is_dst  = is_list || use_dst_input || input_file.find(".root") != std::string::npos;
0066 
0067   sepdWaveform->SetUseOfflinePackets(is_dst);
0068 
0069   Fun4AllInputManager *in = nullptr;
0070   if (is_dst)
0071   {
0072     std::cout << "Using DST input manager for: " << input_file << std::endl;
0073     in = new Fun4AllDstInputManager("DSTIN");
0074   }
0075   else
0076   {
0077     std::cout << "Using PRDF input manager for: " << input_file << std::endl;
0078     in = new Fun4AllPrdfInputManager("PRDFIN");
0079   }
0080   if (is_list)
0081   {
0082     in->AddListFile(input_file);
0083   }
0084   else
0085   {
0086     in->fileopen(input_file);
0087   }
0088   se->registerInputManager(in);
0089 
0090   se->run(nEvents);
0091 
0092   se->End();
0093 
0094   delete se;
0095   gSystem->Exit(0);
0096 }