Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:06

0001 #include <QA.C>
0002 
0003 #include <rawbcolumi/Fun4AllStreamingLumiCountingInputManager.h>
0004 #include <rawbcolumi/SingleGl1PoolInputv2.h>
0005 #include <rawbcolumi/SingleStreamingInputv2.h>
0006 
0007 
0008 #include <ffarawmodules/InttCheck.h>
0009 #include <ffarawmodules/StreamingCheck.h>
0010 #include <ffarawmodules/TpcCheck.h>
0011 
0012 #include <ffamodules/FlagHandler.h>
0013 #include <ffamodules/HeadReco.h>
0014 #include <ffamodules/SyncReco.h>
0015 
0016 #include <fun4all/Fun4AllDstOutputManager.h>
0017 #include <fun4all/Fun4AllInputManager.h>
0018 #include <fun4all/Fun4AllOutputManager.h>
0019 #include <fun4all/Fun4AllServer.h>
0020 
0021 #include <phool/recoConsts.h>
0022 
0023 #include <TSystem.h>
0024 
0025 #include <format>
0026 #include <fstream>
0027 
0028 R__LOAD_LIBRARY(libfun4all.so)
0029 R__LOAD_LIBRARY(libffamodules.so)
0030 R__LOAD_LIBRARY(librawbcolumi.so)
0031 R__LOAD_LIBRARY(libffarawmodules.so)
0032 
0033 bool isGood(const std::string &infile);
0034 
0035 void Fun4All_SingleStream_Combiner_lumi(int nEvents = 200,
0036                                         const int  /*runnumber*/ = 52050,
0037                                         const std::string &output_file = "output_streaming",
0038                                         //                 const std::string &outdir = "/sphenix/user/xuzhiwan/luminosity/streaming-macro/fun4alllumi/macro/output/",
0039                                         const std::string & /*type*/ = "streaming",
0040                                         const std::string &input_gl1file = "gl1daq.list")
0041 {
0042   // GL1 which provides the beam clock reference (if we ran with GL1)
0043 
0044   std::vector<std::string> gl1_infile;
0045   gl1_infile.push_back(input_gl1file);
0046 
0047   Fun4AllServer *se = Fun4AllServer::instance();
0048   se->Verbosity(1);
0049 //  recoConsts *rc = recoConsts::instance();
0050   // Fun4AllStreamingInputManager *in = new Fun4AllStreamingInputManager("Comb");
0051   Fun4AllStreamingLumiCountingInputManager *in = new Fun4AllStreamingLumiCountingInputManager("Comb");
0052   //  in->Verbosity(3);
0053   in->SetOutputFileName(output_file);
0054 
0055   // create and register input managers
0056   int i = 0;
0057 
0058 
0059   for (const auto& iter : gl1_infile)
0060   {
0061     if (isGood(iter))
0062     {
0063       SingleGl1PoolInputv2 *gl1_sngl = new SingleGl1PoolInputv2("GL1_" + std::to_string(i));
0064       //    gl1_sngl->Verbosity(3);
0065       gl1_sngl->AddListFile(iter);
0066       gl1_sngl->SetNegativeWindow(20);
0067       gl1_sngl->SetPositiveWindow(325);  // 325
0068       gl1_sngl->SetTotalEvent(nEvents);
0069       in->registerStreamingInput(gl1_sngl, InputManagerType::GL1);
0070       i++;
0071     }
0072   }
0073   se->registerInputManager(in);
0074 
0075   SyncReco *sync = new SyncReco();
0076   se->registerSubsystem(sync);
0077 
0078   HeadReco *head = new HeadReco();
0079   se->registerSubsystem(head);
0080 
0081   FlagHandler *flag = new FlagHandler();
0082   se->registerSubsystem(flag);
0083 
0084   // std::string readoutNumber = "Events-" + std::to_string(nEvents) + "-";
0085 
0086   // std::string outfile = std::format("./{}-{}_lumi.root",type, readoutNumber);
0087 
0088   // Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out",outfile);
0089   // se->registerOutputManager(out);
0090 
0091   if (nEvents < 0)
0092   {
0093     return;
0094   }
0095   se->run(nEvents);
0096   se->End();
0097 
0098   /*  char histoutfile[500];
0099     sprintf(histoutfile,"./Lumi_%s-%s-%08i-%05i-%s",type.c_str(),readoutNumber.c_str(),runnumber,0,output_file.c_str());
0100     QAHistManagerDef::saveQARootFile(histoutfile);
0101   */
0102 
0103   delete se;
0104   std::cout << "all done" << std::endl;
0105   gSystem->Exit(0);
0106 }
0107 
0108 bool isGood(const std::string &infile)
0109 {
0110   std::ifstream intest;
0111   intest.open(infile);
0112   bool goodfile = false;
0113   if (intest.is_open())
0114   {
0115     if (intest.peek() != std::ifstream::traits_type::eof())  // is it non zero?
0116     {
0117       goodfile = true;
0118     }
0119     intest.close();
0120   }
0121   return goodfile;
0122 }