ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_GEM_EIC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_GEM_EIC.C
1 #ifndef MACRO_G4GEMEIC_C
2 #define MACRO_G4GEMEIC_C
3 
4 #include <GlobalVariables.C>
5 
7 
9 
10 #include <g4main/PHG4Reco.h>
11 
12 #include <string>
13 
14 R__LOAD_LIBRARY(libg4detectors.so)
15 
16 int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin, double etamax, const int N_Sector = 16, double tilt = 0, bool doTilt = false);
19 
20 namespace Enable
21 {
22  bool EGEM = false;
23  bool FGEM = false;
24  bool BGEM = false;
25 } // namespace Enable
26 
27 void EGEM_Init()
28 {
30  // extends only to -z
32 }
33 
34 void FGEM_Init()
35 {
38 }
39 
40 void BGEM_Init()
41 {
42  cout << __PRETTY_FUNCTION__ << ": BGEM not yet defined" << endl;
43  exit(1);
44 
47 }
48 
49 void EGEMSetup(PHG4Reco *g4Reco)
50 {
51  make_GEM_station("EGEM_0", g4Reco, -121.0, -1.668, -3.7);
52 }
53 
54 void FGEMSetup(PHG4Reco *g4Reco, const int N_Sector = 16)
55 {
56  make_GEM_station("FGEM_0", g4Reco, 287.0, 1.3, 3.6, N_Sector);
57 }
58 
61 {
62  assert(gem);
63 
65  const double mm = 0.1 * cm;
66  const double um = 1e-3 * mm;
67 
68  // const int N_Layers = 70; // used for mini-drift TPC timing digitalization
69  const int N_Layers = 1; // simplified setup
70  const double thickness = 2 * cm;
71 
72  gem->get_geometry().AddLayer("EntranceWindow", "G4_MYLAR", 25 * um, false, 100);
73  gem->get_geometry().AddLayer("Cathode", "G4_GRAPHITE", 10 * um, false, 100);
74 
75  for (int d = 1; d <= N_Layers; d++)
76  {
77  ostringstream s;
78  s << "DriftLayer_";
79  s << d;
80 
81  gem->get_geometry().AddLayer(s.str(), "G4_METHANE", thickness / N_Layers, true);
82  }
83 }
84 
87 {
88  assert(gem);
89 
91  const double mm = 0.1 * cm;
92  const double um = 1e-3 * mm;
93 
94  const int N_Layers = 1; // simplified setup
95  const double thickness = 3 * mm;
96 
97  gem->get_geometry().AddLayer("EntranceWindow", "G4_MYLAR", 25 * um, false, 100);
98  gem->get_geometry().AddLayer("Cathode", "G4_GRAPHITE", 10 * um, false, 100);
99 
100  for (int d = 1; d <= N_Layers; d++)
101  {
102  ostringstream s;
103  s << "DriftLayer_";
104  s << d;
105 
106  gem->get_geometry().AddLayer(s.str(), "G4_METHANE", thickness / N_Layers, true);
107  }
108 }
109 
110 int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin,
111  double etamax, const int N_Sector = 16, double tilt = 0, bool doTilt = false)
112 {
113  // cout
114  // << "make_GEM_station - GEM construction with PHG4SectorSubsystem - make_GEM_station_EdgeReadout of "
115  // << name << endl;
116 
117  double zpos_lab(zpos);
118  double polar_angle = 0;
119 
120  if (doTilt)
121  {
122  zpos = zpos - (zpos * sin(tilt) + zpos * cos(tilt) * tan(PHG4Sector::Sector_Geometry::eta_to_polar_angle(2) - tilt)) * sin(tilt);
123  }
124  else
125  {
126  if (zpos < 0)
127  {
128  zpos = -zpos;
129  polar_angle = M_PI;
130  }
131  }
132  if (etamax < etamin)
133  {
134  double t = etamax;
135  etamax = etamin;
136  etamin = t;
137  }
138 
139  PHG4SectorSubsystem *gem;
140  gem = new PHG4SectorSubsystem(name);
141 
142  gem->SuperDetector(name);
143 
144  if (doTilt)
145  {
148  }
149  else
150  {
151  gem->get_geometry().set_normal_polar_angle(polar_angle);
153  }
158  gem->get_geometry().set_N_Sector(N_Sector);
159  gem->get_geometry().set_material("G4_METHANE");
161 
162  AddLayers_GEMDrift(gem);
165  g4Reco->registerSubsystem(gem);
166 
167  // Following Nov-5 tracking meeting, update to muRwell performance of 55um resolution 2D readout
169  {
170  TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames,
171  PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
172  55e-4, // const float radres,
173  55e-4, // const float phires,
174  100e-4, // const float lonres,
175  1, // const float eff,
176  0); // const float noise
177 
179  TRACKING::ProjectionNames.insert(name);
180  }
181 
182  if (TRACKING::FastKalmanFilterInnerTrack and zpos_lab<0)
183  TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames,
184  PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
185  55e-4, // const float radres,
186  55e-4, // const float phires,
187  100e-4, // const float lonres,
188  1, // const float eff,
189  0); // const float noise
190 
191  return 0;
192 }
193 #endif
194