EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Mvtx.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Mvtx.C
1 #ifndef MACRO_G4MVTX_C
2 #define MACRO_G4MVTX_C
3 
4 #include <GlobalVariables.C>
5 #include <QA.C>
6 
8 #include <g4mvtx/PHG4MvtxDefs.h>
10 #include <g4mvtx/PHG4MvtxHitReco.h>
12 
13 #include <g4main/PHG4Reco.h>
14 
15 #include <mvtx/MvtxClusterizer.h>
16 #include <qa_modules/QAG4SimulationMvtx.h>
17 
18 #include <fun4all/Fun4AllServer.h>
19 
20 #include <cmath>
21 #include <vector>
22 
23 R__LOAD_LIBRARY(libg4mvtx.so)
24 R__LOAD_LIBRARY(libmvtx.so)
25 R__LOAD_LIBRARY(libqa_modules.so)
26 
27 namespace Enable
28 {
29  bool MVTX = false;
30  bool MVTX_OVERLAPCHECK = false;
31  bool MVTX_CELL = false;
32  bool MVTX_CLUSTER = false;
33  bool MVTX_QA = false;
34  bool MVTX_ABSORBER = false;
35  int MVTX_VERBOSITY = 0;
36 
37 } // namespace Enable
38 
39 namespace G4MVTX
40 {
41  int n_maps_layer = 3; // must be 0-3, setting it to zero removes Mvtx completely, n < 3 gives the first n layers
42  double radius_offset = 0.7; // clearance around radius
43 } // namespace G4MVTX
44 
45 namespace G4MVTXAlignment
46 {
47  std::string alignment_path = string(getenv("CALIBRATIONROOT")) + "/Tracking/MVTX/alignment";
48  double z_offset[] = {0.0, 0.0, 200.0};
49 }
50 
51 void MvtxInit()
52 {
53  //BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 5);
54  //BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -20);
55  //BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, 25.);
56 }
57 
58 double Mvtx(PHG4Reco* g4Reco, double radius,
59  const int absorberactive = 0)
60 {
61  bool maps_overlapcheck = Enable::OVERLAPCHECK || Enable::MVTX_OVERLAPCHECK;
63 
64  PHG4MvtxSubsystem* mvtx = new PHG4MvtxSubsystem("MVTX");
65  mvtx->Verbosity(verbosity);
66 
67  for (int ilayer = 0; ilayer < G4MVTX::n_maps_layer; ilayer++)
68  {
69  double radius_lyr = PHG4MvtxDefs::mvtxdat[ilayer][PHG4MvtxDefs::kRmd];
70  mvtx->set_double_param(ilayer, "layer_z_offset", G4MVTXAlignment::z_offset[ilayer]);
71  if (verbosity)
72  {
73  cout << "Create Maps layer " << ilayer << " with radius " << radius_lyr << " mm." << endl;
74  }
75  radius = radius_lyr / 10.;
76  }
78  mvtx->set_string_param(PHG4MvtxDefs::GLOBAL, "stave_geometry_file", string(getenv("CALIBRATIONROOT")) + string("/Tracking/geometry/mvtx_stave_v1.gdml"));
79 
80  mvtx->SetActive();
81  mvtx->OverlapCheck(maps_overlapcheck);
82  g4Reco->registerSubsystem(mvtx);
83  radius += G4MVTX::radius_offset;
84  return radius;
85 }
86 
87 // Central detector cell reco is disabled as EIC setup use the fast tracking sim for now
88 void Mvtx_Cells()
89 {
92  // new storage containers
93  PHG4MvtxHitReco* maps_hits = new PHG4MvtxHitReco("MVTX");
94  maps_hits->Verbosity(verbosity);
95  for (int ilayer = 0; ilayer < G4MVTX::n_maps_layer; ilayer++)
96  {
97  // override the default timing window for this layer - default is +/- 5000 ns
98  maps_hits->set_timing_window(ilayer, -5000, 5000);
99  }
100  se->registerSubsystem(maps_hits);
101 
102  PHG4MvtxDigitizer* digimvtx = new PHG4MvtxDigitizer();
103  digimvtx->Verbosity(verbosity);
104  // energy deposit in 25 microns = 9.6 KeV = 1000 electrons collected after recombination
105  //digimvtx->set_adc_scale(0.95e-6); // default set in code is 0.95e-06, which is 99 electrons
106  se->registerSubsystem(digimvtx);
107 
108  return;
109 }
110 
112 {
115 
116  // For the Mvtx layers
117  //================
118  MvtxClusterizer* mvtxclusterizer = new MvtxClusterizer("MvtxClusterizer");
119  mvtxclusterizer->Verbosity(verbosity);
120  se->registerSubsystem(mvtxclusterizer);
121 }
122 
123 void Mvtx_QA()
124 {
126 
129  qa->Verbosity(verbosity);
130  se->registerSubsystem(qa);
131 }
132 
133 #endif