Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:29

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