EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Pipe_EIC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Pipe_EIC.C
1 #ifndef MACRO_G4PIPEEIC_C
2 #define MACRO_G4PIPEEIC_C
3 
4 #include <GlobalVariables.C>
5 
8 
9 #include <g4main/PHG4Reco.h>
10 
11 #include <TSystem.h>
12 
13 R__LOAD_LIBRARY(libg4detectors.so)
14 
15 // This creates the Enable Flag to be used in the main steering macro
16 namespace Enable
17 {
18  bool PIPE = false;
19  bool PIPE_ABSORBER = false;
20  bool PIPE_OVERLAPCHECK = false;
21  int PIPE_VERBOSITY = 0;
22 } // namespace Enable
23 
24 namespace G4PIPE
25 {
26  // Central pipe dimension
27  // Extracted via mechanical model: Detector chamber 3-20-20
28  // directly implimenting the central Be section in G4 cylinder for max speed simulation in the detector region.
29  // The jointer lip structure of the pipe R = 3.2cm x L=5mm is ignored here
30  double be_pipe_radius = 3.1000;
31  double be_pipe_thickness = 3.1762 - be_pipe_radius; // 760 um for sPHENIX
32  double be_pipe_length_plus = 66.8; // +z beam pipe extend.
33  double be_pipe_length_neg = -79.8; // -z beam pipe extend.
34  bool use_forward_pipes = false;
35 } // namespace G4PIPE
36 
37 void PipeInit()
38 {
40  {
44  }
45  else
46  {
50  }
51 }
52 
54 double Pipe(PHG4Reco* g4Reco,
55  double radius)
56 {
57  bool AbsorberActive = Enable::ABSORBER || Enable::PIPE_ABSORBER;
58  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::PIPE_OVERLAPCHECK;
60  // process pipe extentions?
61  const bool do_pipe_hadron_forward_extension = G4PIPE::use_forward_pipes && true;
62  const bool do_pipe_electron_forward_extension = G4PIPE::use_forward_pipes && true;
63 
65  const double be_pipe_center = 0.5 * (G4PIPE::be_pipe_length_plus + G4PIPE::be_pipe_length_neg);
66 
67  if (radius > G4PIPE::be_pipe_radius)
68  {
69  cout << "inconsistency: radius: " << radius
70  << " larger than pipe inner radius: " << G4PIPE::be_pipe_radius << endl;
71  gSystem->Exit(-1);
72  }
73 
74  // vacuum inside mid-rapidity beryllium beampipe
75  PHG4CylinderSubsystem* cyl = new PHG4CylinderSubsystem("VAC_BE_PIPE", 0);
76  cyl->set_double_param("radius", 0.0);
77  cyl->set_int_param("lengthviarapidity", 0);
78  cyl->set_double_param("length", be_pipe_length);
79  cyl->set_double_param("place_z", be_pipe_center);
80  cyl->set_string_param("material", "G4_Galactic");
81  cyl->set_double_param("thickness", G4PIPE::be_pipe_radius);
82  cyl->SuperDetector("PIPE");
83  cyl->OverlapCheck(OverlapCheck);
84  if (AbsorberActive) cyl->SetActive();
85  g4Reco->registerSubsystem(cyl);
86 
87  // mid-rapidity beryllium beam-pipe
88  cyl = new PHG4CylinderSubsystem("BE_PIPE", 1);
90  cyl->set_int_param("lengthviarapidity", 0);
91  cyl->set_double_param("length", be_pipe_length);
92  cyl->set_double_param("place_z", be_pipe_center);
93  cyl->set_string_param("material", "G4_Be");
95  cyl->SuperDetector("PIPE");
96  cyl->OverlapCheck(OverlapCheck);
97  if (AbsorberActive) cyl->SetActive();
98  g4Reco->registerSubsystem(cyl);
99 
101 
102  radius += no_overlapp;
103 
104  // electron-going section of the beampipe
105  if (do_pipe_electron_forward_extension)
106  {
107  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("ElectronForwardEnvelope");
108  gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/Detector_chamber_3-20-20.G4Import.gdml");
109  gdml->set_string_param("TopVolName", "ElectronForwardEnvelope");
110  gdml->set_int_param("skip_DST_geometry_export", 1); // do not export extended beam pipe as it is not supported by TGeo and outside Kalman filter acceptance
111  gdml->OverlapCheck(OverlapCheck);
112  g4Reco->registerSubsystem(gdml);
113  }
114 
115  // hadron-going section of the beampipe
116  if (do_pipe_hadron_forward_extension)
117  {
118  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("HadronForwardEnvelope");
119  gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/Detector_chamber_3-20-20.G4Import.gdml");
120  gdml->set_string_param("TopVolName", "HadronForwardEnvelope");
121  gdml->set_int_param("skip_DST_geometry_export", 1); // do not export extended beam pipe as it is not supported by TGeo and outside Kalman filter acceptance
122  gdml->OverlapCheck(OverlapCheck);
123  g4Reco->registerSubsystem(gdml);
124  }
125 
126  return radius;
127 }
128 #endif