Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:23:57

0001 #include <GlobalVariables.C>
0002 
0003 #include <inttcalib/InttCalib.h>
0004 
0005 #include <ffamodules/FlagHandler.h>
0006 
0007 #include <fun4all/Fun4AllDstOutputManager.h>
0008 #include <fun4all/Fun4AllInputManager.h>
0009 #include <fun4all/Fun4AllOutputManager.h>
0010 #include <fun4all/Fun4AllServer.h>
0011 
0012 #include <fun4allraw/Fun4AllStreamingInputManager.h>
0013 #include <fun4allraw/InputManagerType.h>
0014 #include <fun4allraw/SingleGl1PoolInput.h>
0015 #include <fun4allraw/SingleInttPoolInput.h>
0016 
0017 #include <phool/recoConsts.h>
0018 
0019 #include <Rtypes.h>  // resolves R__LOAD_LIBRARY for clang-tidy
0020 #include <TSystem.h>
0021 
0022 #include <fstream>
0023 
0024 R__LOAD_LIBRARY(libinttcalib.so)
0025 R__LOAD_LIBRARY(libintt.so)
0026 
0027 R__LOAD_LIBRARY(libfun4all.so)
0028 R__LOAD_LIBRARY(libffamodules.so)
0029 R__LOAD_LIBRARY(libfun4allraw.so)
0030 R__LOAD_LIBRARY(libffarawmodules.so)
0031 
0032 bool isGood(const std::string &infile);
0033 
0034 void Fun4All_Intt_Calib_Raw(
0035     int num_evt = 400000,
0036     int run_num = 0,
0037     const std::string &hotmap_cdb_file = "hotmap.root",
0038     const std::string &hotmap_png_file = "hotmap.png",
0039     const std::string &bcomap_cdb_file = "bcomap.root",
0040     const std::string &bcomap_png_file = "bcomap.png",
0041     const std::string &input_gl1file = "gl1daq.list",
0042     const std::string &input_inttfile00 = "intt0.list",
0043     const std::string &input_inttfile01 = "intt1.list",
0044     const std::string &input_inttfile02 = "intt2.list",
0045     const std::string &input_inttfile03 = "intt3.list",
0046     const std::string &input_inttfile04 = "intt4.list",
0047     const std::string &input_inttfile05 = "intt5.list",
0048     const std::string &input_inttfile06 = "intt6.list",
0049     const std::string &input_inttfile07 = "intt7.list",
0050 
0051     bool isStreaming = true)
0052 {
0053   // GL1 which provides the beam clock reference (if we ran with GL1)
0054   std::vector<std::string> gl1_infile;
0055   gl1_infile.push_back(input_gl1file);
0056 
0057   // INTT
0058   std::vector<std::string> intt_infile;
0059   intt_infile.push_back(input_inttfile00);
0060   intt_infile.push_back(input_inttfile01);
0061   intt_infile.push_back(input_inttfile02);
0062   intt_infile.push_back(input_inttfile03);
0063   intt_infile.push_back(input_inttfile04);
0064   intt_infile.push_back(input_inttfile05);
0065   intt_infile.push_back(input_inttfile06);
0066   intt_infile.push_back(input_inttfile07);
0067 
0068   Fun4AllServer *se = Fun4AllServer::instance();
0069   //  se->Verbosity(1);
0070   // Input Manager
0071   recoConsts *rc = recoConsts::instance();
0072   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0073   rc->set_uint64Flag("TIMESTAMP", run_num);
0074 
0075   Fun4AllStreamingInputManager *in = new Fun4AllStreamingInputManager("Comb");
0076   int i = 0;
0077   for (const auto& iter : gl1_infile)
0078   {
0079     if (isGood(iter))
0080     {
0081       SingleGl1PoolInput *gl1_sngl = new SingleGl1PoolInput("GL1_" + std::to_string(i));
0082       //    gl1_sngl->Verbosity(3);
0083       gl1_sngl->AddListFile(iter);
0084       in->registerStreamingInput(gl1_sngl, InputManagerType::GL1);
0085       i++;
0086     }
0087   }
0088   i = 0;
0089   for (const auto& iter : intt_infile)
0090   {
0091     if (isGood(iter))
0092     {
0093       std::cout << "opening file " << iter << std::endl;
0094       SingleInttPoolInput *intt_sngl = new SingleInttPoolInput("INTT_" + std::to_string(i));
0095       //    intt_sngl->Verbosity(3);
0096       intt_sngl->SetNegativeBco(120 - 23);
0097       intt_sngl->SetBcoRange(500);
0098       intt_sngl->AddListFile(iter);
0099       in->registerStreamingInput(intt_sngl, InputManagerType::INTT);
0100       i++;
0101     }
0102   }
0103   se->registerInputManager(in);
0104 
0105   InttCalib *inttcalib = new InttCalib();
0106   inttcalib->Verbosity(0);
0107 
0108   // Construct file paths
0109   inttcalib->SetHotMapCdbFile(hotmap_cdb_file);
0110   inttcalib->SetHotMapPngFile(hotmap_png_file);
0111   inttcalib->SetBcoMapCdbFile(bcomap_cdb_file);
0112   inttcalib->SetBcoMapPngFile(bcomap_png_file);
0113   inttcalib->SetBcoMaximumEvent(num_evt);  // default = 50k
0114   inttcalib->SetStreamingMode(isStreaming);
0115   inttcalib->SetRunNumber(run_num);
0116 
0117   inttcalib->SetHotMapCdbFile(hotmap_cdb_file);
0118   // inttcalib->SetHotMapPngFile(hotmap_save_file);
0119   inttcalib->SetBcoMapCdbFile(bcomap_cdb_file);
0120   // inttcalib->SetBcoMapPngFile(bcomap_save_file);
0121 
0122   se->registerSubsystem(inttcalib);
0123   se->run(num_evt);
0124 
0125   se->End();
0126   delete se;
0127   std::cout << "all done" << std::endl;
0128   gSystem->Exit(0);
0129 }
0130 
0131 bool isGood(const std::string &infile)
0132 {
0133   std::ifstream intest;
0134   intest.open(infile);
0135   bool goodfile = false;
0136   if (intest.is_open())
0137   {
0138     if (intest.peek() != std::ifstream::traits_type::eof())  // is it non zero?
0139     {
0140       goodfile = true;
0141     }
0142     intest.close();
0143   }
0144   return goodfile;
0145 }