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 
8 #include <g4main/PHG4Reco.h>
9 
10 #include <string>
11 
12 R__LOAD_LIBRARY(libg4detectors.so)
13 
14 int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin, double etamax, const int N_Sector = 8, double tilt = 0, bool doTilt = false);
16 
17 namespace Enable
18 {
19  bool EGEM = false;
20  bool EGEM_FULL = false;
21  bool FGEM = false;
22  bool FGEM_ORIG = false;
23 } // namespace Enable
24 
25 void EGEM_Init()
26 {
28  // extends only to -z
30 }
31 
32 void FGEM_Init()
33 {
36 }
37 
38 void EGEMSetup(PHG4Reco *g4Reco)
39 {
40  /* Careful with dimensions! If GEM station volumes overlap, e.g. with TPC volume, they will be
41  * drawn in event display but will NOT register any hits.
42  *
43  * Geometric constraints:
44  * TPC length = 211 cm --> from z = -105.5 to z = +105.5
45  */
47  {
48  cout << "EGEM and EGEM_FULL cannot be enabled simultaneously" << endl;
49  }
50  float thickness = 3.;
51  if (Enable::EGEM)
52  {
53  make_GEM_station("EGEM_2", g4Reco, -137.0 + thickness, -1.4, -3.5);
54  make_GEM_station("EGEM_3", g4Reco, -160.0 + thickness, -1.5, -3.6);
55  }
57  {
58  make_GEM_station("EGEM_0", g4Reco, -20.5 + thickness, -0.94, -1.95);
59  make_GEM_station("EGEM_1", g4Reco, -69.5 + thickness, -2.07, -3.21);
60  make_GEM_station("EGEM_2", g4Reco, -137.0 + thickness, -1.4, -3.5);
61  make_GEM_station("EGEM_3", g4Reco, -160.0 + thickness, -1.5, -3.6);
62  }
63 }
64 
65 void FGEMSetup(PHG4Reco *g4Reco, const int N_Sector = 8, //
66  const double min_eta = 1.245 //
67 )
68 {
69  const double tilt = .1;
70 
71  double etamax;
72  double zpos;
74 
77  {
78  make_GEM_station("FGEM_0", g4Reco, 17.5, 0.94, 1.95, N_Sector);
79  make_GEM_station("FGEM_1", g4Reco, 66.5, 2.07, 3.20, N_Sector);
80  }
83  {
84  etamax = 3.3;
85  }
86  else
87  {
88  etamax = 2;
89  }
90  make_GEM_station("FGEM_2", g4Reco, 134.0, min_eta, etamax, N_Sector);
92  make_GEM_station("FGEM_3", g4Reco, 157.0, min_eta, 3.3, N_Sector, tilt, true);
93 
95  make_GEM_station("FGEM_4", g4Reco, 271.0, 2, 3.5, N_Sector);
96  make_GEM_station("FGEM_4_LowerEta", g4Reco, 271.0, min_eta, 2, N_Sector, tilt, true);
97 }
98 
99 // ======================================================================================================================
101 {
102  float z_pos = 130.0;
103 
104  // This is a mockup calorimeter in the forward (hadron-going) direction
105  PHG4CylinderSubsystem *cyl_f = new PHG4CylinderSubsystem("CALO_FORWARD_PASSIVE", 0);
106  cyl_f->set_double_param("length", 5); // Length in z direction in cm
107  cyl_f->set_double_param("radius", z_pos * 0.0503 - 0.180808); // beampipe needs to fit here
108  cyl_f->set_double_param("thickness", 43); //
109  cyl_f->set_string_param("material", "G4_Al");
110  cyl_f->set_double_param("place_z", z_pos);
111  //cyl_f->SetActive(1);
112  cyl_f->SuperDetector("passive_F");
113  //cyl_f->set_color(0,1,1,0.3); //reddish
114  g4Reco->registerSubsystem(cyl_f);
115 
116  // This is a mockup calorimeter in the backward (electron-going) direction
117  PHG4CylinderSubsystem *cyl_b = new PHG4CylinderSubsystem("CALO_BACKWARD_PASSIVE", 0);
118  cyl_b->set_double_param("length", 5); // Length in z direction in cm
119  cyl_b->set_double_param("radius", abs(-z_pos * 0.030 - 0.806)); // beampipe needs to fit here
120  cyl_b->set_double_param("thickness", 43); //
121  cyl_b->set_string_param("material", "G4_Al");
122  cyl_b->set_double_param("place_z", -z_pos);
123  //cyl_b->SetActive(1);
124  cyl_b->SuperDetector("passive_B");
125  //cyl_b->set_color(0,1,1,0.3); //reddish
126  g4Reco->registerSubsystem(cyl_b);
127 }
128 
131 {
132  assert(gem);
133 
134  const double cm = PHG4Sector::Sector_Geometry::Unit_cm();
135  const double mm = 0.1 * cm;
136  const double um = 1e-3 * mm;
137 
138  // const int N_Layers = 70; // used for mini-drift TPC timing digitalization
139  const int N_Layers = 1; // simplified setup
140  const double thickness = 2 * cm;
141 
142  gem->get_geometry().AddLayer("EntranceWindow", "G4_MYLAR", 25 * um, false, 100);
143  gem->get_geometry().AddLayer("Cathode", "G4_GRAPHITE", 10 * um, false, 100);
144 
145  for (int d = 1; d <= N_Layers; d++)
146  {
147  ostringstream s;
148  s << "DriftLayer_";
149  s << d;
150 
151  gem->get_geometry().AddLayer(s.str(), "G4_METHANE", thickness / N_Layers, true);
152  }
153 }
154 
155 int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin,
156  double etamax, const int N_Sector = 8, double tilt = 0, bool doTilt = false)
157 {
158  // cout
159  // << "make_GEM_station - GEM construction with PHG4SectorSubsystem - make_GEM_station_EdgeReadout of "
160  // << name << endl;
161 
162  double polar_angle = 0;
163 
164  if (doTilt)
165  {
166  zpos = zpos - (zpos * sin(tilt) + zpos * cos(tilt) * tan(PHG4Sector::Sector_Geometry::eta_to_polar_angle(2) - tilt)) * sin(tilt);
167  }
168  else
169  {
170  if (zpos < 0)
171  {
172  zpos = -zpos;
173  polar_angle = M_PI;
174  }
175  }
176  if (etamax < etamin)
177  {
178  double t = etamax;
179  etamax = etamin;
180  etamin = t;
181  }
182 
183  PHG4SectorSubsystem *gem;
184  gem = new PHG4SectorSubsystem(name);
185 
186  gem->SuperDetector(name);
187 
188  if (doTilt)
189  {
192  }
193  else
194  {
195  gem->get_geometry().set_normal_polar_angle(polar_angle);
197  }
202  gem->get_geometry().set_N_Sector(N_Sector);
203  gem->get_geometry().set_material("G4_METHANE");
205 
209  g4Reco->registerSubsystem(gem);
210 
211  return 0;
212 }
213 #endif