EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Pipe_EIC_simple.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Pipe_EIC_simple.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 = true;
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::PIPE_OVERLAPCHECK; // detach from Enable::OVERLAPCHECK || to suppress GDML validation messages
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  // mid-rapidity beryillium pipe
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  cyl = new PHG4CylinderSubsystem("BE_PIPE", 1);
89  cyl->set_int_param("lengthviarapidity", 0);
90  cyl->set_double_param("length", be_pipe_length);
91  cyl->set_double_param("place_z", be_pipe_center);
92  cyl->set_string_param("material", "G4_Be");
94  cyl->SuperDetector("PIPE");
95  cyl->OverlapCheck(OverlapCheck);
96  if (AbsorberActive) cyl->SetActive();
97  g4Reco->registerSubsystem(cyl);
98 
100 
101  radius += no_overlapp;
102 
103  if (do_pipe_electron_forward_extension)
104  {
105  if (Enable::IP6)
106  {
107  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("ElectronForwardEnvelope");
108  gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/Detector_chamber_3-20-20.G4Import.v2.gdml");
109  gdml->set_string_param("TopVolName", "ElectronForwardEnvelope");
110  gdml->set_double_param("rot_z", 180); // flip crossing sign convension after July-2021
111  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
112  gdml->OverlapCheck(OverlapCheck);
113  g4Reco->registerSubsystem(gdml);
114  }
115  if (Enable::IP8)
116  {
117  cout <<__PRETTY_FUNCTION__<<" IP8 beam chamber not defined yet! Consider disable G4PIPE::use_forward_pipes"<<endl;
118  exit(1);
119  }
120  }
121 
122  if (do_pipe_hadron_forward_extension)
123  {
124  if (Enable::IP6)
125  {
126  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("HadronForwardEnvelope");
127  gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/Detector_chamber_3-20-20.G4Import.v2.gdml");
128  gdml->set_string_param("TopVolName", "HadronForwardEnvelope");
129  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
130  gdml->set_double_param("rot_z", 180); // flip crossing sign convension after July-2021
131  gdml->OverlapCheck(OverlapCheck);
132  g4Reco->registerSubsystem(gdml);
133  }
134  if (Enable::IP8)
135  {
136  cout <<__PRETTY_FUNCTION__<<" IP8 beam chamber not defined yet! Consider disable G4PIPE::use_forward_pipes"<<endl;
137  exit(1);
138  }
139  }
140 
141  return radius;
142 }
143 #endif