EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_GEM.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_GEM.C
1 #ifndef MACRO_G4GEM_C
2 #define MACRO_G4GEM_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);
16 
17  namespace Enable
18 {
19  bool EGEM = true;
20  bool FGEM = true;
21 } // namespace Enable
22 // ======================================================================================================================
23 void EGEM_Init(){
24  //BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 80.);
25  // extends only to -z
26  //BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -160.);
27 }
28 // ======================================================================================================================
29 void FGEM_Init(){
30  //BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 150.);
31  //BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, 282.);
32 }
33 // ======================================================================================================================
34 void EGEMSetup(PHG4Reco *g4Reco){
35  /* Careful with dimensions! If GEM station volumes overlap, e.g. with TPC volume, they will be drawn in event display but will NOT register any hits.
36  * Geometric constraints:
37  * TPC length = 211 cm --> from z = -105.5 to z = +105.5
38  */
39  float thickness = 3.;
40  make_GEM_station("EGEM", g4Reco, -180.0 , -1.15 , -3.9);
41 }
42 // ======================================================================================================================
43 void FGEMSetup(PHG4Reco *g4Reco){
44  float thickness = 3.;
45  make_GEM_station("FGEM", g4Reco, 300.0 , 1.4, 7);
46 }
47 // ======================================================================================================================
49  float z_pos = 130.0;
50 
51  // This is a mockup calorimeter in the forward (hadron-going) direction
52  PHG4CylinderSubsystem *cyl_f = new PHG4CylinderSubsystem("CALO_FORWARD_PASSIVE",0);
53  cyl_f->set_double_param("length", 5); // Length in z direction in cm
54  cyl_f->set_double_param("radius", z_pos*0.0503-0.180808); // beampipe needs to fit here
55  cyl_f->set_double_param("thickness", 43); //
56  cyl_f->set_string_param("material", "G4_Al");
57  cyl_f->set_double_param("place_z", z_pos);
58  //cyl_f->SetActive(1);
59  cyl_f->SuperDetector("passive_F");
60  //cyl_f->set_color(0,1,1,0.3); //reddish
61  g4Reco->registerSubsystem(cyl_f);
62 
63 
64  // This is a mockup calorimeter in the backward (electron-going) direction
65  PHG4CylinderSubsystem * cyl_b = new PHG4CylinderSubsystem("CALO_BACKWARD_PASSIVE",0);
66  cyl_b->set_double_param("length", 5); // Length in z direction in cm
67  cyl_b->set_double_param("radius",abs(-z_pos*0.030-0.806)); // beampipe needs to fit here
68  cyl_b->set_double_param("thickness", 43); //
69  cyl_b->set_string_param("material", "G4_Al");
70  cyl_b->set_double_param("place_z", -z_pos);
71  //cyl_b->SetActive(1);
72  cyl_b->SuperDetector("passive_B");
73  //cyl_b->set_color(0,1,1,0.3); //reddish
74  g4Reco->registerSubsystem(cyl_b);
75 
76 }
77 // ======================================================================================================================
78 int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin,
79  double etamax, const int N_Sector = 8)
80 {
81  double polar_angle = 0;
82 
83  if (zpos < 0){
84  zpos = -zpos;
85  polar_angle = M_PI;
86  }
87  if (etamax < etamin){
88  double t = etamax;
89  etamax = etamin;
90  etamin = t;
91  }
92 
94  gem = new PHG4SectorSubsystem(name);
95 
96  gem->SuperDetector(name);
97 
98  gem->get_geometry().set_normal_polar_angle(polar_angle);
104  gem->get_geometry().set_N_Sector(N_Sector);
105  gem->get_geometry().set_material("G4_METHANE");
106  //gem->OverlapCheck(Enable::OVERLAPCHECK);
107 
110  g4Reco->registerSubsystem(gem);
111  return 0;
112 }
113 // ======================================================================================================================
116 {
117  assert(gem);
118 
119  const double cm = PHG4Sector::Sector_Geometry::Unit_cm();
120  const double mm = 0.1 * cm;
121  const double um = 1e-3 * mm;
122 
123  // const int N_Layers = 70; // used for mini-drift TPC timing digitalization
124  const int N_Layers = 1; // simplified setup
125  const double thickness = 2 * cm;
126 
127  gem->get_geometry().AddLayer("EntranceWindow", "G4_MYLAR", 25 * um, false, 100);
128  gem->get_geometry().AddLayer("Cathode", "G4_GRAPHITE", 10 * um, false, 100);
129 
130  for (int d = 1; d <= N_Layers; d++)
131  {
132  ostringstream s;
133  s << "DriftLayer_";
134  s << d;
135 
136  gem->get_geometry().AddLayer(s.str(), "G4_METHANE", thickness / N_Layers, true);
137  }
138 }
139 #endif