EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Piston.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Piston.C
1 #ifndef MACRO_G4PISTON_C
2 #define MACRO_G4PISTON_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <G4_Pipe.C>
7 
10 
11 #include <g4main/PHG4Reco.h>
12 
13 R__LOAD_LIBRARY(libg4detectors.so)
14 
15 namespace Enable
16 {
17  bool PISTON = false;
18  bool PISTON_ABSORBER = false;
19  bool PISTON_OVERLAPCHECK = false;
21 } // namespace Enable
22 
23 namespace G4PISTON
24 {
25  double zpos1 = 305. - 20.; // front of forward ECal/MPC
26  double zpos2 = 335.9 - 10.2 / 2.; // front of the forward field endcap
27  double calorimeter_hole_diameter = 9.92331 * 2; // side length of the middle hole of MPC that
28 } // namespace G4PISTON
29 
30 void PistonInit()
31 {
34 }
35 
36 void Piston(PHG4Reco *g4Reco,
37  const int absorberactive = 0)
38 {
39  bool AbsorberActive = Enable::ABSORBER || Enable::PISTON_ABSORBER || absorberactive;
42 
43  string name = "magpiston";
44  const double zpos0 = G4PIPE::al_pipe_length + G4PIPE::be_pipe_length * 0.5; // first large GEM station
45 
46  const double beampipe_radius = G4PIPE::be_pipe_radius;
47 
48  // teeth cone section specific
49  const double number_of_wteeth = 100;
50  const double teeth_thickness = 0.3504 * 2; //2 X0
51  const double eta_inner = -log(tan(atan((beampipe_radius + 0.1) / zpos0) / 2));
52  const double eta_outter = 4.2;
53  const double eta_teeth_outter = 4.05;
54  double pos = zpos0 + (G4PISTON::zpos1 - zpos0) / 2;
55  // cout << "MAGNETIC PISTON:" << eta_inner << " " << eta_outter << " " << pos
56  // << endl;
57 
58  PHG4ConeSubsystem *magpiston = new PHG4ConeSubsystem("Piston", 0);
59  magpiston->SetZlength((G4PISTON::zpos1 - zpos0) / 2);
60  magpiston->SetPlaceZ((G4PISTON::zpos1 + zpos0) / 2);
61  magpiston->SetR1(beampipe_radius,
62  tan(PHG4Sector::Sector_Geometry::eta_to_polar_angle(eta_outter)) * zpos0);
63  magpiston->SetR2(beampipe_radius,
65  magpiston->SetMaterial("G4_Fe");
66  magpiston->OverlapCheck(OverlapCheck);
67  g4Reco->registerSubsystem(magpiston);
68 
69  // PHG4ConeSubsystem *magpiston = new PHG4ConeSubsystem(name, 1);
70  // magpiston->SetZlength((G4PISTON::zpos1 - zpos0) / 2);
71  // magpiston->SetPlaceZ(pos);
72  // magpiston->Set_eta_range(eta_outter, eta_inner);
73  // magpiston->SetMaterial("G4_Fe");
74  // magpiston->SuperDetector(name);
75  // magpiston->SetActive(false);
76  // g4Reco->registerSubsystem(magpiston);
77 
78  pos = zpos0 + 1.0 + teeth_thickness / 2;
79  for (int i = 0; i < number_of_wteeth; i++)
80  {
81  stringstream s;
82  s << name;
83  s << "_teeth_";
84  s << i;
85 
86  magpiston = new PHG4ConeSubsystem(s.str(), i);
87  magpiston->SuperDetector(name);
88  magpiston->SetZlength(teeth_thickness / 2);
89  magpiston->SetPlaceZ(pos);
90  magpiston->SetR1(
91  //
92  tan(PHG4Sector::Sector_Geometry::eta_to_polar_angle(eta_outter - .01)) * (pos - teeth_thickness / 2), //
93  tan(PHG4Sector::Sector_Geometry::eta_to_polar_angle(eta_teeth_outter)) * (pos - teeth_thickness / 2) //
94  );
95  magpiston->SetR2(
96  //
97  tan(PHG4Sector::Sector_Geometry::eta_to_polar_angle(eta_outter - .01)) * (pos + teeth_thickness / 2), //
98  tan(PHG4Sector::Sector_Geometry::eta_to_polar_angle(eta_outter - .01)) * (pos + teeth_thickness / 2) + .1 //
99  );
100  magpiston->SetMaterial("G4_W");
101  magpiston->SuperDetector(name);
102  if (AbsorberActive) magpiston->SetActive();
103  magpiston->OverlapCheck(OverlapCheck);
104  g4Reco->registerSubsystem(magpiston);
105  pos += ((G4PISTON::zpos1 - zpos0 - 10) / number_of_wteeth);
106  }
107 
108  // last piece connect to the field return
109  PHG4CylinderSubsystem *magpiston2 = new PHG4CylinderSubsystem("Piston_EndSection", 0);
110  magpiston2->set_double_param("length", G4PISTON::zpos2 - G4PISTON::zpos1);
111  magpiston2->set_double_param("place_z", (G4PISTON::zpos2 + G4PISTON::zpos1) / 2.);
112  magpiston2->set_double_param("radius", beampipe_radius);
113  magpiston2->set_double_param("thickness", G4PISTON::calorimeter_hole_diameter / 2. - beampipe_radius);
114  magpiston2->set_string_param("material", "G4_Fe");
115  magpiston2->SuperDetector(name);
116  if (AbsorberActive) magpiston2->SetActive();
117  magpiston2->OverlapCheck(OverlapCheck);
118  g4Reco->registerSubsystem(magpiston2);
119 
120  return;
121 }
122 #endif