Back to home page

sPhenix code displayed by LXR

 
 

    


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

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