Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef MACRO_FUN4ALL_MBD_PRDF_C
0002 #define MACRO_FUN4ALL_MBD_PRDF_C
0003 
0004 #include <globalvertex/GlobalVertexReco.h>
0005 
0006 #include <mbd/MbdReco.h>
0007 
0008 #include <ffamodules/CDBInterface.h>
0009 #include <ffamodules/FlagHandler.h>
0010 #include <ffamodules/HeadReco.h>
0011 #include <ffamodules/SyncReco.h>
0012 
0013 #include <fun4all/Fun4AllServer.h>
0014 #include <fun4all/Fun4AllUtils.h>
0015 #include <fun4all/Fun4AllInputManager.h>
0016 
0017 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0018 #include <fun4all/Fun4AllOutputManager.h>
0019 #include <fun4all/Fun4AllDstOutputManager.h>
0020 #include <fun4allraw/Fun4AllEventOutputManager.h>
0021 
0022 #include <phool/recoConsts.h>
0023 
0024 #include <Rtypes.h> // defines R__LOAD_LIBRARY macro for clang-tidy
0025 #include <TString.h>
0026 #include <TSystem.h>
0027 
0028 #include <filesystem>
0029 
0030 R__LOAD_LIBRARY(libfun4all.so)
0031 R__LOAD_LIBRARY(libfun4allraw.so)
0032 R__LOAD_LIBRARY(libffamodules.so)
0033 R__LOAD_LIBRARY(libphool.so)
0034 R__LOAD_LIBRARY(libmbd.so)
0035 R__LOAD_LIBRARY(libglobalvertex.so)
0036 
0037 void Fun4All_MBD_Prdf(const std::string &input_file = "beam/beam_seb18-000020868-0000.prdf", const int nEvents = 0, const int nskip = 0, const std::string& cdbtag = "")
0038 {
0039   
0040   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(input_file);
0041   int run_number = runseg.first;
0042   int seg = runseg.second;
0043   std::cout << "RUN\t" << run_number << "\t" << seg << std::endl;
0044 
0045   recoConsts *rc = recoConsts::instance();
0046   rc->set_uint64Flag("TIMESTAMP", run_number);
0047 
0048   if ( !cdbtag.empty() )
0049   {
0050     rc->set_StringFlag("CDB_GLOBALTAG",cdbtag); 
0051     //rc->set_StringFlag("CDB_GLOBALTAG","newcdbtag"); 
0052 
0053     std::cout << "Using CDB_GLOBALTAG " << cdbtag << std::endl;
0054   }
0055   else
0056   {
0057     // For local calibrations
0058     TString bdir = "./results/";
0059     bdir += run_number;
0060     std::cout << bdir << std::endl;
0061     rc->set_StringFlag("MBD_CALDIR",bdir.Data()); 
0062 
0063     std::cout << "Using MBD_CALDIR " << bdir << std::endl;
0064   }
0065 
0066   Fun4AllServer *se = Fun4AllServer::instance();
0067   //se->Verbosity(1);
0068 
0069   // Sync Headers and Flags
0070   SyncReco *sync = new SyncReco();
0071   se->registerSubsystem(sync);
0072 
0073   HeadReco *head = new HeadReco();
0074   se->registerSubsystem(head);
0075 
0076   FlagHandler *flag = new FlagHandler();
0077   se->registerSubsystem(flag);
0078 
0079   // MBD/BBC Reconstruction
0080   MbdReco *mbdreco = new MbdReco();
0081   se->registerSubsystem(mbdreco);
0082 
0083   // Official vertex storage
0084   GlobalVertexReco *gvertex = new GlobalVertexReco();
0085   se->registerSubsystem(gvertex);
0086 
0087   Fun4AllInputManager *in = new Fun4AllPrdfInputManager("PRDFin");
0088   in->fileopen(input_file);
0089   //in->Verbosity(1);
0090   se->registerInputManager(in);
0091 
0092   std::filesystem::path filePath(input_file);
0093   TString outfile = filePath.filename().string();
0094   outfile.ReplaceAll(".prdf",".root");
0095   std::cout << outfile << std::endl;
0096   Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outfile.Data());
0097   se->registerOutputManager(out);
0098 
0099   se->skip(nskip);
0100   se->run(nEvents);
0101 
0102   se->End();
0103   delete se;
0104   gSystem->Exit(0);
0105 
0106   std::cout << "Finished" << std::endl;
0107 }
0108 
0109 #endif
0110