ECCE @ 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 Au_coating_thickness = 2e-4; // 2um Au coating
32  double be_pipe_thickness = 3.1762 - be_pipe_radius; // 760 um for sPHENIX
33  double be_pipe_length_plus = 66.8; // +z beam pipe extend.
34  double be_pipe_length_neg = -79.8; // -z beam pipe extend.
35  bool use_forward_pipes = true;
36 } // namespace G4PIPE
37 
38 void PipeInit()
39 {
41  {
45  }
46  else
47  {
51  }
52 }
53 
55 double Pipe(PHG4Reco* g4Reco,
56  double radius)
57 {
58  bool AbsorberActive = Enable::ABSORBER || Enable::PIPE_ABSORBER;
59  bool OverlapCheck = Enable::PIPE_OVERLAPCHECK or Enable::OVERLAPCHECK; // || to suppress GDML validation messages
61  // process pipe extentions?
62  const bool do_pipe_hadron_forward_extension = G4PIPE::use_forward_pipes && true;
63  const bool do_pipe_electron_forward_extension = G4PIPE::use_forward_pipes && true;
64 
66  const double be_pipe_center = 0.5 * (G4PIPE::be_pipe_length_plus + G4PIPE::be_pipe_length_neg);
67 
68  if (radius > G4PIPE::be_pipe_radius)
69  {
70  cout << "inconsistency: radius: " << radius
71  << " larger than pipe inner radius: " << G4PIPE::be_pipe_radius << endl;
72  gSystem->Exit(-1);
73  }
74 
75  // mid-rapidity beryillium pipe
76  PHG4CylinderSubsystem* cyl = new PHG4CylinderSubsystem("VAC_BE_PIPE", 0);
77  cyl->set_double_param("radius", 0.0);
78  cyl->set_int_param("lengthviarapidity", 0);
79  cyl->set_double_param("length", be_pipe_length);
80  cyl->set_double_param("place_z", be_pipe_center);
81  cyl->set_string_param("material", "G4_Galactic");
83  cyl->SuperDetector("PIPE");
84  cyl->OverlapCheck(OverlapCheck);
85  g4Reco->registerSubsystem(cyl);
86 
87  // 2um Au coating for X-ray absorption
88  cyl = new PHG4CylinderSubsystem("Au_PIPE", 2);
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_Au");
95  cyl->SuperDetector("PIPE");
96  cyl->OverlapCheck(OverlapCheck);
97  if (AbsorberActive) cyl->SetActive();
98  g4Reco->registerSubsystem(cyl);
99 
100  cyl = new PHG4CylinderSubsystem("BE_PIPE", 1);
102  cyl->set_int_param("lengthviarapidity", 0);
103  cyl->set_double_param("length", be_pipe_length);
104  cyl->set_double_param("place_z", be_pipe_center);
105  cyl->set_string_param("material", "G4_Be");
106  cyl->set_double_param("thickness", G4PIPE::be_pipe_thickness);
107  cyl->SuperDetector("PIPE");
108  cyl->OverlapCheck(OverlapCheck);
109  if (AbsorberActive) cyl->SetActive();
110  g4Reco->registerSubsystem(cyl);
111 
113 
114  radius += no_overlapp;
115 
116  if (do_pipe_electron_forward_extension)
117  {
118  if (Enable::IP6)
119  {
120  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("ElectronForwardChamber");
121  gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/ConstructSimplifiedBeamChamber.gdml");
122  gdml->set_string_param("TopVolName", "ElectronForwardChamber");
123  gdml->OverlapCheck(OverlapCheck);
124  g4Reco->registerSubsystem(gdml);
125  }
126  if (Enable::IP8)
127  {
128  cout <<__PRETTY_FUNCTION__<<" IP8 beam chamber not defined yet! Consider disable G4PIPE::use_forward_pipes"<<endl;
129  exit(1);
130  }
131  }
132 
133  if (do_pipe_hadron_forward_extension)
134  {
135  if (Enable::IP6)
136  {
137  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("HadronForwardChamber");
138  gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/ConstructSimplifiedBeamChamber.gdml");
139  gdml->set_string_param("TopVolName", "HadronForwardChamber");
140  gdml->OverlapCheck(OverlapCheck);
141  g4Reco->registerSubsystem(gdml);
142  }
143  if (Enable::IP8)
144  {
145  cout <<__PRETTY_FUNCTION__<<" IP8 beam chamber not defined yet! Consider disable G4PIPE::use_forward_pipes"<<endl;
146  exit(1);
147  }
148  }
149 
150  return radius;
151 }
152 #endif