Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Mbd.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Mbd.C
1 #ifndef MACRO_G4MBD_C
2 #define MACRO_G4MBD_C
3 
4 #include <GlobalVariables.C>
5 
7 
8 #include <g4mbd/MbdDigitization.h>
9 #include <g4mbd/MbdVertexFastSimReco.h>
10 #include <mbd/MbdReco.h>
11 
12 #include <g4main/PHG4Reco.h>
13 
14 #include <fun4all/Fun4AllServer.h>
15 
16 R__LOAD_LIBRARY(libg4mbd.so)
17 R__LOAD_LIBRARY(libg4detectors.so)
18 R__LOAD_LIBRARY(libmbd.so)
19 
20 namespace Enable
21 {
22  bool MBD = false; // Actual MBD detector
23  bool MBD_SUPPORT = false; // MBD Supports
24  bool MBDRECO = false; // run Mbd reconstruction
25  bool MBDFAKE = false; // Just generate fake mbd vtx, t0
26  int MBD_VERBOSITY = 0;
27 } // namespace Enable
28 
29 namespace G4MBD
30 {
31  double z_smearing = 0.; // should be 6 mm, temporarily perfect for TPC initial vertexing
32  double t_smearing = 0.02; // 20ps timing resolution
33 } // namespace G4MBD
34 
35 void MbdInit()
36 {
38  {
39  cout << "Enable::MBD and Enable::MBDFAKE cannot be true at the same time" << endl;
40  gSystem->Exit(1);
41  }
42  // Set boundary of tracked particles to include MBD (values in cm)
43  if (Enable::MBD)
44  {
48  }
49 }
50 
51 void Mbd(PHG4Reco* g4Reco)
52 {
53  bool SupportActive = Enable::SUPPORT || Enable::MBD_SUPPORT;
54  if (Enable::MBD)
55  {
56  PHG4BbcSubsystem* mbd = new PHG4BbcSubsystem("BBC");
57  mbd->SuperDetector("BBC");
59  mbd->SetActive();
60  if (SupportActive)
61  {
62  mbd->SetSupportActive(SupportActive);
63  }
64  g4Reco->registerSubsystem(mbd);
65  }
66  return;
67 }
68 
69 void Mbd_Reco()
70 {
72 
73  //---------------
74  // Fun4All server
75  //---------------
76 
78 
80  {
81  cout << "Enable::MBDFAKE and Enable::MBDRECO cannot be enabled together" << endl;
82  gSystem->Exit(1);
83  }
84 
85  if (Enable::MBDFAKE)
86  {
87  if (verbosity > 0)
88  {
89  cout << "MBDFAKE: Using smeared vtx and t0 resolutions of "
90  << G4MBD::z_smearing << " cm and " << G4MBD::t_smearing * 1000 << " ps" << endl;
91  }
92  MbdVertexFastSimReco* mbdvertex = new MbdVertexFastSimReco();
95  mbdvertex->Verbosity(verbosity);
96 
97  se->registerSubsystem(mbdvertex);
98  }
99  if (Enable::MBDRECO)
100  {
101  auto mbddigi = new MbdDigitization();
102  mbddigi->Verbosity(verbosity);
103  se->registerSubsystem(mbddigi);
104 
105  auto mbdreco = new MbdReco();
106  mbdreco->Verbosity(verbosity);
107  se->registerSubsystem(mbdreco);
108  }
109  return;
110 }
111 #endif