Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:00

0001 #include <GlobalVariables.C>
0002 #include <fun4all/Fun4AllDstOutputManager.h>
0003 #include <fun4all/Fun4AllInputManager.h>
0004 #include <fun4all/Fun4AllOutputManager.h>
0005 #include <fun4all/Fun4AllServer.h>
0006 #include <fun4allraw/Fun4AllStreamingInputManager.h>
0007 #include <fun4allraw/InputManagerType.h>
0008 #include <fun4allraw/SingleGl1PoolInput.h>
0009 #include <fun4allraw/SingleInttPoolInput.h>
0010 #include <inttcalib/InttCalib.h>
0011 R__LOAD_LIBRARY(libinttcalib.so)
0012 #include <phool/recoConsts.h>
0013 
0014 #include <ffamodules/FlagHandler.h>
0015 
0016 R__LOAD_LIBRARY(libfun4all.so)
0017 R__LOAD_LIBRARY(libffamodules.so)
0018 R__LOAD_LIBRARY(libfun4allraw.so)
0019 R__LOAD_LIBRARY(libffarawmodules.so)
0020 
0021 #include <filesystem>
0022 namespace fs = std::filesystem;
0023 
0024 void Fun4All_Calib(int nEvents = 100000, int RunNumber = 50889, bool isStreaming = true,
0025                              const string &input_gl1file = "gl1daq.list",
0026                              const string &input_inttfile00 = "intt0.list",
0027                              const string &input_inttfile01 = "intt1.list",
0028                              const string &input_inttfile02 = "intt2.list",
0029                              const string &input_inttfile03 = "intt3.list",
0030                              const string &input_inttfile04 = "intt4.list",
0031                              const string &input_inttfile05 = "intt5.list",
0032                              const string &input_inttfile06 = "intt6.list",
0033                              const string &input_inttfile07 = "intt7.list"
0034                              )
0035 {
0036 // GL1 which provides the beam clock reference (if we ran with GL1)
0037   vector<string> gl1_infile;
0038   gl1_infile.push_back(input_gl1file);
0039 
0040 // INTT
0041   vector<string> intt_infile;
0042   intt_infile.push_back(input_inttfile00);
0043   intt_infile.push_back(input_inttfile01);
0044   intt_infile.push_back(input_inttfile02);
0045   intt_infile.push_back(input_inttfile03);
0046   intt_infile.push_back(input_inttfile04);
0047   intt_infile.push_back(input_inttfile05);
0048   intt_infile.push_back(input_inttfile06);
0049   intt_infile.push_back(input_inttfile07);
0050 
0051   Fun4AllServer *se = Fun4AllServer::instance();
0052   se->Verbosity(1);
0053   recoConsts *rc = recoConsts::instance();
0054   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0055   rc->set_uint64Flag("TIMESTAMP", RunNumber);
0056   Fun4AllStreamingInputManager *in = new Fun4AllStreamingInputManager("Comb");
0057   
0058   int i = 0;
0059 
0060   if(isStreaming) // Streaming mode ; Combining with GL1
0061   {
0062     for (auto iter : gl1_infile)
0063     {
0064       SingleGl1PoolInput *gl1_sngl = new SingleGl1PoolInput("GL1_" + to_string(i));
0065       //    gl1_sngl->Verbosity(3);
0066       gl1_sngl->AddListFile(iter);
0067       in->registerStreamingInput(gl1_sngl, InputManagerType::GL1);
0068       i++;
0069       }
0070       i = 0;
0071       for (auto iter : intt_infile)
0072       {
0073         SingleInttPoolInput *intt_sngl = new SingleInttPoolInput("INTT_" + to_string(i));
0074         intt_sngl->SetNegativeBco(120-23);
0075         intt_sngl->SetBcoRange(120);
0076         intt_sngl->AddListFile(iter);
0077         std::cout<<iter<<std::endl;
0078         in->registerStreamingInput(intt_sngl, InputManagerType::INTT);
0079         i++;
0080         } 
0081         i = 0;
0082     }
0083 else // Triggered mode ; Combining without GL1
0084 {
0085 std::cout<<" Trigger mode selected " << std::endl;
0086 std::cout<< " Combining without GL1"<<std::endl;
0087  for (auto iter : intt_infile)
0088   {
0089     SingleInttPoolInput *intt_sngl = new SingleInttPoolInput("INTT_" + to_string(i));
0090     intt_sngl->SetNegativeBco(1);
0091     intt_sngl->SetBcoRange(2);
0092     intt_sngl->AddListFile(iter);
0093     std::cout<<iter<<std::endl;
0094     in->registerStreamingInput(intt_sngl, InputManagerType::INTT);
0095     i++;
0096   } 
0097   i = 0;
0098 }
0099 
0100  
0101   
0102   se->registerInputManager(in);
0103   
0104   FlagHandler *flag = new FlagHandler();
0105   se->registerSubsystem(flag);
0106 
0107   InttCalib *inttcalib = new InttCalib();
0108   inttcalib->Verbosity(0);
0109   fs::path currentPath = fs::current_path();
0110   std::string RunNumberStr = std::to_string(RunNumber);
0111 
0112   // Construct file paths
0113   std::string hotmap_cdb_file = (currentPath / "hotmap_cdb" / ("hotmap_cdb_" + RunNumberStr + ".root")).string();
0114   std::string hotmap_save_file = (currentPath / "hotmap_png" / ("hotmap_png_" + RunNumberStr + ".root")).string(); // .root .png .pdf
0115   std::string bcomap_cdb_file = (currentPath / "bcomap_cdb" / ("bcomap_cdb_" + RunNumberStr + ".root")).string();
0116   std::string bcomap_save_file = (currentPath / "bcomap_png" / ("bcomap_png_" + RunNumberStr + ".root")).string(); //.root .png .pdf
0117   
0118   inttcalib->SetHotMapCdbFile(hotmap_cdb_file);
0119   inttcalib->SetHotMapPngFile(hotmap_save_file);
0120   inttcalib->SetBcoMapCdbFile(bcomap_cdb_file);
0121   inttcalib->SetBcoMapPngFile(bcomap_save_file);
0122   se->registerSubsystem(inttcalib);
0123 
0124   if (inttcalib->Verbosity())
0125   {
0126     std::cout << "\n"
0127               << "hotmap_cdb_file: " << hotmap_cdb_file << "\n"
0128               << "hotmap_save_file: " << hotmap_save_file << "\n"
0129               << "bcomap_cdb_file: " << bcomap_cdb_file << "\n"
0130               << "bcomap_save_file: " << bcomap_save_file << "\n"
0131               << std::endl;
0132   }
0133   bool isTrkrHitOn = false;
0134   if(isTrkrHitOn) // Make DST file if needed
0135   {
0136    Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out", "streaming.root");
0137    se->registerOutputManager(out);
0138   }
0139 
0140   if (nEvents < 0)
0141   {
0142     return;
0143   }
0144   se->run(nEvents);
0145 
0146   se->End();
0147   delete se;
0148   cout << "all done" << endl;
0149   gSystem->Exit(0);
0150 }
0151