Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef MACRO_G4MBD_C
0002 #define MACRO_G4MBD_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <g4detectors/PHG4BbcSubsystem.h>
0007 
0008 #include <g4mbd/MbdDigitization.h>
0009 #include <g4mbd/MbdVertexFastSimReco.h>
0010 #include <mbd/MbdReco.h>
0011 
0012 #include <g4main/PHG4Reco.h>
0013 
0014 #include <fun4all/Fun4AllServer.h>
0015 
0016 R__LOAD_LIBRARY(libg4mbd.so)
0017 R__LOAD_LIBRARY(libg4detectors.so)
0018 R__LOAD_LIBRARY(libmbd.so)
0019 
0020 namespace Enable
0021 {
0022   bool MBD = false;          // Actual MBD detector
0023   bool MBD_SUPPORT = false;  // MBD Supports
0024   bool MBDRECO = false;      // run Mbd reconstruction
0025   bool MBDFAKE = false;      // Just generate fake mbd vtx, t0
0026   int MBD_VERBOSITY = 0;
0027 }  // namespace Enable
0028 
0029 namespace G4MBD
0030 {
0031   double z_smearing = 0.;    // should be 6 mm, temporarily perfect for TPC initial vertexing
0032   double t_smearing = 0.02;  // 20ps timing resolution
0033 }  // namespace G4MBD
0034 
0035 void MbdInit()
0036 {
0037   if (Enable::MBD && Enable::MBDFAKE)
0038   {
0039     cout << "Enable::MBD and Enable::MBDFAKE cannot be true at the same time" << endl;
0040     gSystem->Exit(1);
0041   }
0042   // Set boundary of tracked particles to include MBD (values in cm)
0043   if (Enable::MBD)
0044   {
0045     BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, 300.);
0046     BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -300.);
0047     BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 125.0);
0048   }
0049 }
0050 
0051 void Mbd(PHG4Reco* g4Reco)
0052 {
0053   bool SupportActive = Enable::SUPPORT || Enable::MBD_SUPPORT;
0054   if (Enable::MBD)
0055   {
0056     PHG4BbcSubsystem* mbd = new PHG4BbcSubsystem("BBC");
0057     mbd->SuperDetector("BBC");
0058     mbd->OverlapCheck(Enable::OVERLAPCHECK);
0059     mbd->SetActive();
0060     if (SupportActive)
0061     {
0062       mbd->SetSupportActive(SupportActive);
0063     }
0064     g4Reco->registerSubsystem(mbd);
0065   }
0066   return;
0067 }
0068 
0069 void Mbd_Reco()
0070 {
0071   int verbosity = std::max(Enable::VERBOSITY, Enable::MBD_VERBOSITY);
0072 
0073   //---------------
0074   // Fun4All server
0075   //---------------
0076 
0077   Fun4AllServer* se = Fun4AllServer::instance();
0078 
0079   if (Enable::MBDFAKE && Enable::MBDRECO)
0080   {
0081     cout << "Enable::MBDFAKE and Enable::MBDRECO cannot be enabled together" << endl;
0082     gSystem->Exit(1);
0083   }
0084 
0085   if (Enable::MBDFAKE)
0086   {
0087     if (verbosity > 0)
0088     {
0089       cout << "MBDFAKE: Using smeared vtx and t0 resolutions of "
0090            << G4MBD::z_smearing << " cm and " << G4MBD::t_smearing * 1000 << " ps" << endl;
0091     }
0092     MbdVertexFastSimReco* mbdvertex = new MbdVertexFastSimReco();
0093     mbdvertex->set_z_smearing(G4MBD::z_smearing);
0094     mbdvertex->set_t_smearing(G4MBD::t_smearing);
0095     mbdvertex->Verbosity(verbosity);
0096 
0097     se->registerSubsystem(mbdvertex);
0098   }
0099   if (Enable::MBDRECO)
0100   {
0101     auto mbddigi = new MbdDigitization();
0102     mbddigi->Verbosity(verbosity);
0103     se->registerSubsystem(mbddigi);
0104 
0105     auto mbdreco = new MbdReco();
0106     mbdreco->Verbosity(verbosity);
0107     se->registerSubsystem(mbdreco);
0108   }
0109   return;
0110 }
0111 #endif