Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:24:03

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