EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_TrackingService.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_TrackingService.C
1 #ifndef MACRO_G4TrackingService_C
2 #define MACRO_G4TrackingService_C
3 
4 #include <GlobalVariables.C>
5 #include <QA.C>
6 
9 #include <g4main/PHG4Reco.h>
10 
11 #include <qa_modules/QAG4SimulationMvtx.h>
12 
13 #include <fun4all/Fun4AllServer.h>
14 
15 #include <boost/format.hpp>
16 #include <cmath>
17 #include <iostream>
18 #include <string>
19 #include <vector>
20 
21 //sPHENIX Tracking Services
22 
23 using namespace std;
24 
26 {
27  public:
29 
30  explicit ServiceStructure(const string &name,
31  const float &thickness_copper,
32  const float &thickness_water,
33  const float &thickness_plastic,
34  const float &thickness_carbon,
35  const float &zSouth,
36  const float &zNorth,
37  const float &rSouth,
38  const float &rNorth);
39 
40  virtual ~ServiceStructure(){};
41 
42  const string get_name();
43  const float get_thickness_copper();
44  const float get_thickness_water();
45  const float get_thickness_plastic();
46  const float get_thickness_carbon();
47  const float get_zSouth();
48  const float get_zNorth();
49  const float get_rSouth();
50  const float get_rNorth();
51 
52  private:
53  const string m_name = "service";
54  const float m_thickness_copper = 0.0;
55  const float m_thickness_water = 0.0;
56  const float m_thickness_plastic = 0.0;
57  const float m_thickness_carbon = 0.0;
58  const float m_zSouth = 0.0;
59  const float m_zNorth = 0.0;
60  const float m_rSouth = 0.0;
61  const float m_rNorth = 0.0;
62 };
63 
65  const float &thickness_copper,
66  const float &thickness_water,
67  const float &thickness_plastic,
68  const float &thickness_carbon,
69  const float &zSouth,
70  const float &zNorth,
71  const float &rSouth,
72  const float &rNorth)
73  : m_name(name)
74  , m_thickness_copper(thickness_copper)
75  , m_thickness_water(thickness_water)
76  , m_thickness_plastic(thickness_plastic)
77  , m_thickness_carbon(thickness_carbon)
78  , m_zSouth(zSouth)
79  , m_zNorth(zNorth)
80  , m_rSouth(rSouth)
81  , m_rNorth(rNorth)
82 {
83 }
84 
85 const string ServiceStructure::get_name() { return m_name; }
90 const float ServiceStructure::get_zSouth() { return m_zSouth; }
91 const float ServiceStructure::get_zNorth() { return m_zNorth; }
92 const float ServiceStructure::get_rSouth() { return m_rSouth; }
93 const float ServiceStructure::get_rNorth() { return m_rNorth; }
94 
95 namespace Enable
96 {
97  bool TrackingService = false;
101 
102 } // namespace Enable
103 
104 namespace G4TrackingService
105 { //List materials and radiation length in cm
106  string materials[] = {"G4_Cu", "G4_WATER", "G4_POLYETHYLENE", "PEEK"};
107  const int nMaterials = sizeof(materials)/sizeof(materials[0]);
108 
109  float GlobalOffset = -15.0;
110  float BarrelOffset = 18.679;
111  float BarrelRadius = 10.33; //Inner radious of service barrel
112  float BarrelThickness = 0.436; //Thickness in cm
113  float BarrelLength = 121.24; //Length of cylinder in cm
114  float LayerThickness = 0.1; //
115  float CYSSConeThickness = 0.216;
116  float CYSSRibThickness = 0.170;
117  int subsysID = 0;
118  std::vector<float> grey = {0.4, 0.4, 0.4};
119 } // namespace G4TrackingService
120 
121 using namespace G4TrackingService;
122 
123 vector<float> get_thickness(ServiceStructure *object)
124 {
125  vector<float> thickness = { object->get_thickness_copper()
126  , object->get_thickness_water()
127  , object->get_thickness_plastic()
128  , object->get_thickness_carbon()};
129  return thickness;
130 }
131 
133 {
134  double serviceRad = BarrelRadius + BarrelThickness;
135  double serviceMinZ = GlobalOffset - BarrelOffset - BarrelLength;
136  double serviceMaxZ = GlobalOffset;
140 }
141 
142 float TrackingServiceCone(ServiceStructure *object, PHG4Reco *g4Reco, float radius)
143 {
144  bool AbsorberActive = Enable::ABSORBER || Enable::TrackingService_ABSORBER;
147 
148  PHG4ConeSubsystem *cone;
149 
150  float innerRadiusSouth = object->get_rSouth();
151  float innerRadiusNorth = object->get_rNorth();
152  float length = abs(object->get_zNorth() - object->get_zSouth());
153  vector<float> thickness = get_thickness(object);
154 
155  for (int i = 0; i < nMaterials; ++i)
156  {
157  if (thickness[i] == 0) continue;
158  cone = new PHG4ConeSubsystem(object->get_name(), subsysID);
159  cone->Verbosity(verbosity);
160  cone->SetR1(innerRadiusSouth, innerRadiusSouth + thickness[i]);
161  cone->SetR2(innerRadiusNorth, innerRadiusNorth + thickness[i]);
162  cone->SetPlaceZ(object->get_zSouth() + length / 2 + GlobalOffset);
163  cone->SetZlength(length / 2);
164  cone->SetMaterial(materials[i]);
165  cone->SuperDetector("TrackingService");
166  if (materials[i] == "PEEK") cone->set_color(grey[0], grey[1], grey[2], 1.);
167  if (AbsorberActive) cone->SetActive();
168  cone->OverlapCheck(OverlapCheck);
169  g4Reco->registerSubsystem(cone);
170  ++subsysID;
171  innerRadiusSouth += thickness[i] + 5e-7;
172  innerRadiusNorth += thickness[i] + 5e-7;
173  }
174  radius = max(innerRadiusSouth, innerRadiusNorth);
175 
176  return radius;
177 }
178 
180 {
181  bool AbsorberActive = Enable::ABSORBER || Enable::TrackingService_ABSORBER;
184 
186 
187  float innerRadius = object->get_rSouth();
188  float length = abs(object->get_zNorth() - object->get_zSouth());
189  vector<float> thickness = get_thickness(object);
190 
191  for (int i = 0; i < nMaterials; ++i)
192  {
193  if (thickness[i] == 0) continue;
194  cyl = new PHG4CylinderSubsystem(object->get_name(), subsysID);
195  cyl->Verbosity(verbosity);
196  cyl->set_double_param("place_z", object->get_zSouth() + length / 2 + GlobalOffset);
197  cyl->set_double_param("radius", innerRadius);
198  cyl->set_double_param("length", length);
199  cyl->set_string_param("material", materials[i]);
200  cyl->set_double_param("thickness", thickness[i]);
201  cyl->SuperDetector("TrackingService");
202  if (materials[i] == "PEEK") cyl->set_color(grey[0], grey[1], grey[2], 1.);
203  if (AbsorberActive) cyl->SetActive();
204  cyl->OverlapCheck(OverlapCheck);
205  g4Reco->registerSubsystem(cyl);
206  ++subsysID;
207  innerRadius += thickness[i] + 5e-7;
208  }
209  radius = innerRadius;
210 
211  return radius;
212 }
213 
214 float TrackingService(PHG4Reco *g4Reco, float radius)
215 {
216  vector<ServiceStructure *> cylinders, cones;
217 
218  //Service Barrel
219  cylinders.push_back(new ServiceStructure("MVTXServiceBarrel_0", 0.05, 0.007, 0.313, BarrelThickness, -1. * (BarrelLength + BarrelOffset), -27.0, BarrelRadius, 0));
220  cylinders.push_back(new ServiceStructure("MVTXServiceBarrel_1", 0, 0, 0, BarrelThickness, -27.0, -1. * BarrelOffset, 10.70 + CYSSConeThickness, 0));
221 
222  cones.push_back(new ServiceStructure("connectL0", 0.005, 0., 0.066, 0, -26.9, -18.680, 10.10, 5.050));
223  cones.push_back(new ServiceStructure("connectL1", 0.004, 0., 0.061, 0, -26.9, -18.000, 10.20, 7.338));
224  cones.push_back(new ServiceStructure("connectL2", 0.004, 0., 0.058, 0, -26.9, -22.300, 10.30, 9.580));
225 
226  //MVTX Layers
227  cylinders.push_back(new ServiceStructure("L0_0", 0.005, 0., 0.066, LayerThickness, -18.680, -16.579, 5.050, 0));
228  cones.push_back(new ServiceStructure("L0_1", 0.006, 0., 0.088, LayerThickness, -16.578, -9.186, 5.050, 2.997));
229  cylinders.push_back(new ServiceStructure("L0_2", 0.008, 0., 0.110, LayerThickness, -9.185, 0, 2.997, 0));
230 
231  cylinders.push_back(new ServiceStructure("L1_0", 0.004, 0., 0.061, LayerThickness, -17.970, -15.851, 7.338, 0));
232  cones.push_back(new ServiceStructure("L1_1", 0.006, 0., 0.085, LayerThickness, -15.850, -8.938, 7.338, 3.799));
233  cylinders.push_back(new ServiceStructure("L1_2", 0.008, 0., 0.116, LayerThickness, -8.937, 0, 3.799, 0));
234 
235  cylinders.push_back(new ServiceStructure("L2_0", 0.004, 0., 0.058, LayerThickness, -22.300, -15.206, 9.580, 0));
236  cones.push_back(new ServiceStructure("L2_1", 0.006, 0., 0.09, LayerThickness, -15.205, -8.538, 9.650, 4.574));
237  cylinders.push_back(new ServiceStructure("L2_2", 0.009, 0., 0.121, LayerThickness, -8.537, 0, 4.574, 0));
238 
239  //CYSS
240  cylinders.push_back(new ServiceStructure("CYSS_Cone_0", 0, 0, 0, CYSSConeThickness, -26.208, -15.68, 10.55, 0));
241  cones.push_back(new ServiceStructure("CYSS_Cone_1", 0, 0, 0, CYSSConeThickness, -15.679, -8.619, 10.55, 5.302));
242  cylinders.push_back(new ServiceStructure("CYSS_Cone_2", 0, 0, 0, CYSSConeThickness, -8.618, -6.18, 5.302, 0));
243 
244  cylinders.push_back(new ServiceStructure("CYSS_Rib_0", 0, 0, 0, CYSSRibThickness, -21.719, -20.949, 9.762, 0));
245  cones.push_back(new ServiceStructure("CYSS_Rib_1", 0, 0, 0, CYSSRibThickness, -20.948, -20.159, 9.762, 10.36));
246  cylinders.push_back(new ServiceStructure("CYSS_Rib_2", 0, 0, 0, CYSSRibThickness, -20.158, -17.749, 10.36, 0));
247  cones.push_back(new ServiceStructure("CYSS_Rib_3", 0, 0, 0, CYSSRibThickness, -17.748, -16.959, 10.36, 9.762));
248  cylinders.push_back(new ServiceStructure("CYSS_Rib_4", 0, 0, 0, CYSSRibThickness, -16.958, -16.196, 9.762, 0));
249 
250  cylinders.push_back(new ServiceStructure("CYSS_Cylinder", 0, 0, 0, 0.112, -8.619, 36.153, 5.15, 0));
251 
252  for (ServiceStructure *cylinder : cylinders) radius += TrackingServiceCylinder(cylinder, g4Reco, radius);
253  for (ServiceStructure *cone : cones) radius += TrackingServiceCone(cone, g4Reco, radius);
254 
255  return radius;
256 }
257 
258 #endif