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 #pragma once
2 
3 #include "GlobalVariables.C"
4 
7 
8 #include <g4main/PHG4Reco.h>
9 
10 #include <TSystem.h>
11 
12 R__LOAD_LIBRARY(libg4detectors.so)
13 
14  // This creates the Enable Flag to be used in the main steering macro
15  namespace Enable
16 {
17  bool PIPE = false;
18  bool PIPE_ABSORBER = false;
19  bool PIPE_OVERLAPCHECK = false;
20  int PIPE_VERBOSITY = 0;
21 }
22 
23 namespace G4PIPE
24 {
25  // Central pipe dimension
26  // Extracted via mechanical model: Detector chamber 3-20-20
27  // directly implimenting the central Be section in G4 cylinder for max speed simulation in the detector region.
28  // The jointer lip structure of the pipe R = 3.2cm x L=5mm is ignored here
29  double be_pipe_radius = 3.1000;
30  double be_pipe_thickness = 3.1762 - be_pipe_radius; // 760 um for sPHENIX
31  double be_pipe_length_plus = 66.8; // +z beam pipe extend.
32  double be_pipe_length_neg = -79.8; // -z beam pipe extend.
33  bool use_forward_pipes = true; // This loads the conical sections of the beampipe
34 } // namespace G4PIPE
35 
36 void PipeInit()
37 {
39  {
43  }
44  else
45  {
49  }
50 }
51 
53 double Pipe(PHG4Reco* g4Reco,
54  double radius)
55 {
56  bool AbsorberActive = Enable::ABSORBER || Enable::PIPE_ABSORBER;
57  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::PIPE_OVERLAPCHECK;
59  // process pipe extentions?
60  const bool do_pipe_hadron_forward_extension = G4PIPE::use_forward_pipes && true;
61  const bool do_pipe_electron_forward_extension = G4PIPE::use_forward_pipes && true;
62 
64  const double be_pipe_center = 0.5 * (G4PIPE::be_pipe_length_plus + G4PIPE::be_pipe_length_neg);
65 
66  if (radius > G4PIPE::be_pipe_radius)
67  {
68  cout << "inconsistency: radius: " << radius << " larger than pipe inner radius: " << G4PIPE::be_pipe_radius << endl;
69  gSystem->Exit(-1);
70  }
71 
72  // vacuum inside mid-rapidity beryllium beampipe
73  PHG4CylinderSubsystem* cyl = new PHG4CylinderSubsystem("VAC_BE_PIPE", 0);
74  cyl->set_double_param("radius", 0.0);
75  cyl->set_int_param("lengthviarapidity", 0);
76  cyl->set_double_param("length", be_pipe_length);
77  cyl->set_double_param("place_z", be_pipe_center);
78  cyl->set_string_param("material", "G4_Galactic");
79  cyl->set_double_param("thickness", G4PIPE::be_pipe_radius);
80  cyl->SuperDetector("PIPE");
81  cyl->OverlapCheck(OverlapCheck);
82  if (AbsorberActive) cyl->SetActive();
83  g4Reco->registerSubsystem(cyl);
84 
85  // mid-rapidity beryllium pipe
86  cyl = new PHG4CylinderSubsystem("BE_PIPE", 1);
88  cyl->set_int_param("lengthviarapidity", 0);
89  cyl->set_double_param("length", be_pipe_length);
90  cyl->set_double_param("place_z", be_pipe_center);
91  cyl->set_string_param("material", "G4_Be");
93  cyl->SuperDetector("PIPE");
94  cyl->OverlapCheck(OverlapCheck);
95  if (AbsorberActive) cyl->SetActive();
96  g4Reco->registerSubsystem(cyl);
97 
99 
100  radius += no_overlapp;
101 
102  // electron-going section of the beampipe
103  if (do_pipe_electron_forward_extension)
104  {
105  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("ElectronForwardEnvelope");
106  //gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/Detector chamber 3-20-20.G4Import.gdml");
107  gdml->set_string_param("GDMPath","detector/Detector_chamber_3-20-20.G4Import.gdml");
108  gdml->set_string_param("TopVolName", "ElectronForwardEnvelope");
109  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
110  gdml->OverlapCheck(OverlapCheck);
111  g4Reco->registerSubsystem(gdml);
112  }
113 
114  // Hadron-going section of the beampipe
115  if (do_pipe_hadron_forward_extension)
116  {
117  PHG4GDMLSubsystem* gdml = new PHG4GDMLSubsystem("HadronForwardEnvelope");
118  //gdml->set_string_param("GDMPath", string(getenv("CALIBRATIONROOT")) + "/Beam/Detector chamber 3-20-20.G4Import.gdml");
119  gdml->set_string_param("GDMPath","detector/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 }