ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ECAPToFDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ECAPToFDetector.cc
1 #include "PHG4ECAPToFDetector.h"
2 #include <g4main/PHG4Detector.h> // for PHG4Detector
3 #include <phparameter/PHParameters.h>
4 
5 #include <Geant4/G4Colour.hh>
6 #include <Geant4/G4Element.hh>
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4Material.hh>
9 #include <Geant4/G4PVDivision.hh>
10 #include <Geant4/G4PVPlacement.hh>
11 #include <Geant4/G4RotationMatrix.hh>
12 #include <Geant4/G4SystemOfUnits.hh>
13 #include <Geant4/G4ThreeVector.hh> // for G4ThreeVector
14 #include <Geant4/G4Tubs.hh>
15 #include <Geant4/G4VPhysicalVolume.hh> // for G4VPhysicalVolume
16 #include <Geant4/G4VisAttributes.hh>
17 
18 #include <cmath>
19 #include <iostream> // for operator<<, std::endl, bas...
20 #include <sstream>
21 #include <string>
22 
23 class PHCompositeNode;
24 class PHG4Subsystem;
25 
26 PHG4ECAPToFDetector::PHG4ECAPToFDetector(PHG4Subsystem *subsys, PHCompositeNode *Node, PHParameters *parameters, const std::string &dnam, const int lyr)
27  : PHG4Detector(subsys, Node, dnam)
28  , m_Params(parameters)
29  , Phys(nullptr)
30  , fhc_phys(nullptr)
31  , fpcb_phys(nullptr)
32  , fpcbcu_phys(nullptr)
33  , fmylar_phys(nullptr)
34  , fcarbon_phys(nullptr)
35  , fglass_phys()
36  , fgas_phys()
37  , mcarbon_phys(nullptr)
38  , mmylar_phys(nullptr)
39  , mpcbcu_phys(nullptr)
40  , mpcb_phys(nullptr)
41  , mpcbcu2_phys(nullptr)
42  , mmylar2_phys(nullptr)
43  , mcarbon2_phys(nullptr)
44  , bglass_phys()
45  , bgas_phys()
46  , bhc_phys(nullptr)
47  , bpcb_phys(nullptr)
48  , bpcbcu_phys(nullptr)
49  , bmylar_phys(nullptr)
50  , bcarbon_phys(nullptr)
51  , m_Active(m_Params->get_int_param("active"))
52  , m_Layer(lyr)
53 {
54 }
55 
57 {
58  if (m_Active)
59  {
60  for (int i = 0; i < 6; i++) // neeed to define # of gas layers
61  {
62  if (volume == fgas_phys[i] || volume == bgas_phys[i])
63  {
64  return 1;
65  }
66  }
67  }
68  return 0;
69 }
70 
72 {
73  //gaps and thickness
74  int n_fgas_layer = m_Params->get_int_param("n_fgas_layer");
75  int n_bgas_layer = m_Params->get_int_param("n_bgas_layer");
76  double gas_gap = m_Params->get_double_param("gas_gap") * cm;
77  double glass_thick = m_Params->get_double_param("glass_thick") * cm;
78  double carbon_thick = m_Params->get_double_param("Carbon_thick") * cm;
79  double pcb_thick = m_Params->get_double_param("pcb_thick") * cm;
80  double cu_thick = m_Params->get_double_param("cu_thick") * cm;
81  double honeycomb_thick = m_Params->get_double_param("honeycomb_thick") * cm;
82  double mylar_thick = m_Params->get_double_param("mylar_thick") * cm;
83  double Rin = m_Params->get_double_param("Rin") * cm;
84  double Rout = m_Params->get_double_param("Rout") * cm;
85  double z_begin = m_Params->get_double_param("z_begin") * cm;
86 
87  if (Verbosity() > 1)
88  {
89  std::cout << " passed on parameters from macros :: " << std::endl;
90  std::cout << "n_fgas_layer :" << n_fgas_layer << std::endl;
91  std::cout << "n_bgas_layer : " << n_bgas_layer << std::endl;
92  std::cout << "gas_gap : " << gas_gap << std::endl;
93  std::cout << "glass_thick : " << glass_thick << std::endl;
94  std::cout << "carbon_thick : " << carbon_thick << std::endl;
95  std::cout << "pcb_thick : " << pcb_thick << std::endl;
96  std::cout << "cu_thick : " << cu_thick << std::endl;
97  std::cout << "honeycomb_thick : " << honeycomb_thick << std::endl;
98  std::cout << "mylar_thick : " << mylar_thick << std::endl;
99  std::cout << "Rin : " << Rin << std::endl;
100  std::cout << "Rout : " << Rout << std::endl;
101  std::cout << "z_begin : " << z_begin << std::endl;
102  }
103 
104  double tot_thick = (n_fgas_layer + n_bgas_layer) * gas_gap + (n_fgas_layer + n_bgas_layer + 2) * glass_thick + 4. * carbon_thick + 3. * pcb_thick + 4. * cu_thick + 4 * mylar_thick + 2. * honeycomb_thick;
105  double posz = z_begin + 0.5 * tot_thick;
106 
107  if (Verbosity() > 1)
108  {
109  std::cout << "Mother vol dimensions : " << std::endl;
110  std::cout << " z begin :" << z_begin << std::endl;
111  std::cout << " tot_thick :" << tot_thick << std::endl;
112  std::cout << " mid pos :" << posz << std::endl;
113  }
114  G4Material *tof_mother_mat = GetDetectorMaterial(m_Params->get_string_param("material"));
115 
116  G4Tubs *Solid = new G4Tubs("ToF_GVol_Solid", Rin, Rout, tot_thick / 2., 0., 360. * deg);
117  G4LogicalVolume *Logic = new G4LogicalVolume(Solid, tof_mother_mat, "ToF_GVol_Logic", 0, 0, 0);
118  G4VisAttributes *attr_ToF_GVol = new G4VisAttributes(G4Color(0.3, 0.5, 0.9, 0.9));
119  //attr_ToF_GVol->SetColor(G4Color::Green());
120  attr_ToF_GVol->SetForceSolid(true);
121  Logic->SetVisAttributes(attr_ToF_GVol);
122  Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, posz), Logic, "E_CAP_ToF_Physics", logicWorld, 0, false, OverlapCheck());
123 
124  G4Material *G4_O = GetDetectorMaterial("G4_O");
125  G4Material *G4_Si = GetDetectorMaterial("G4_Si");
126  G4Material *G4_Na = GetDetectorMaterial("G4_Na");
127  G4Material *G4_Ca = GetDetectorMaterial("G4_Ca");
128  G4Material *G4_Cu = GetDetectorMaterial("G4_Cu");
129  G4Material *G4_FR4 = GetDetectorMaterial("FR4");
130  G4Material *G4_Nomex = GetDetectorMaterial("NOMEX");
131  G4Material *G4_Mylar = GetDetectorMaterial("G4_MYLAR");
132  G4Material *G4_gas = GetDetectorMaterial("G4_Ar");
133 
134  //Plate Glass material
135  G4Material *plateglass = new G4Material("plateglass", 2.4 * g / cm3, 4, kStateSolid);
136  plateglass->AddMaterial(G4_O, 0.4598);
137  plateglass->AddMaterial(G4_Na, 0.096441);
138  plateglass->AddMaterial(G4_Si, 0.336553);
139  plateglass->AddMaterial(G4_Ca, 0.107205);
140 
141  //Now define various elements from front of ToF
142 
143  //Front Honeycomb
144  G4Tubs *fhc_solid = new G4Tubs("front_honeycomb_solid", Rin, Rout, 0.5 * honeycomb_thick, 0., 360 * deg);
145  G4LogicalVolume *fhc_logic = new G4LogicalVolume(fhc_solid, G4_Nomex, "front_honeycomb_Logic", 0, 0, 0);
146 
147  G4VisAttributes *tof_hc_att = new G4VisAttributes();
148  tof_hc_att->SetColour(G4Colour::Yellow());
149  tof_hc_att->SetVisibility(true);
150  tof_hc_att->SetForceSolid(true);
151  fhc_logic->SetVisAttributes(tof_hc_att);
152  double fhc_pos = -0.5 * tot_thick + 0.5 * honeycomb_thick;
153 
154  fhc_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, fhc_pos), fhc_logic, "front_hc_phys", Logic, 0, false, OverlapCheck());
155 
156  if (Verbosity() > 1) std::cout << " Front HC mid pos :" << fhc_pos << std::endl;
157  //Front PCB
158 
159  G4Tubs *fpcb_solid = new G4Tubs("front_pcb_solid", Rin, Rout, 0.5 * pcb_thick, 0., 360 * deg);
160  G4LogicalVolume *fpcb_logic = new G4LogicalVolume(fpcb_solid, G4_FR4, "front_PCB_Logic", 0, 0, 0);
161 
162  G4VisAttributes *tof_pcb_att = new G4VisAttributes();
163  tof_pcb_att->SetColour(G4Colour::Green());
164  tof_pcb_att->SetVisibility(true);
165  tof_pcb_att->SetForceSolid(true);
166  fpcb_logic->SetVisAttributes(tof_pcb_att);
167  double fpcb_pos = fhc_pos + 0.5 * honeycomb_thick + 0.5 * pcb_thick;
168 
169  fpcb_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, fpcb_pos), fpcb_logic, "front_pcb_phys", Logic, 0, false, OverlapCheck());
170 
171  if (Verbosity() > 1) std::cout << " Front PCB mid pos : " << fpcb_pos << std::endl;
172 
173  //Front PCB Cu
174  G4Tubs *fpcbcu_solid = new G4Tubs("front_pcbcu_solid", Rin, Rout, 0.5 * cu_thick, 0., 360 * deg);
175  G4LogicalVolume *fpcbcu_logic = new G4LogicalVolume(fpcbcu_solid, G4_Cu, "front_PCBCu_Logic", 0, 0, 0);
176 
177  G4VisAttributes *cu_att = new G4VisAttributes();
178  cu_att->SetColour(G4Colour::Yellow());
179  cu_att->SetVisibility(true);
180  cu_att->SetForceSolid(true);
181  fpcbcu_logic->SetVisAttributes(cu_att);
182  double fpcbcu_pos = fpcb_pos + 0.5 * pcb_thick + 0.5 * cu_thick;
183 
184  fpcbcu_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, fpcbcu_pos), fpcbcu_logic, "front_pcbcu_phys", Logic, 0, false, OverlapCheck());
185 
186  if (Verbosity() > 1) std::cout << " Front PCB Cu pos : " << fpcbcu_pos << std::endl;
187 
188  //Front Mylar
189  G4Tubs *fmylar_solid = new G4Tubs("front_mylar_solid", Rin, Rout, 0.5 * mylar_thick, 0., 360 * deg);
190  G4LogicalVolume *fmylar_logic = new G4LogicalVolume(fmylar_solid, G4_Mylar, "front_Mylar_Logic", 0, 0, 0);
191 
192  G4VisAttributes *mylar_att = new G4VisAttributes();
193  mylar_att->SetColour(G4Colour::White());
194  mylar_att->SetVisibility(true);
195  mylar_att->SetForceSolid(true);
196  fmylar_logic->SetVisAttributes(mylar_att);
197  double fmylar_pos = fpcbcu_pos + 0.5 * cu_thick + 0.5 * mylar_thick;
198 
199  fmylar_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, fmylar_pos), fmylar_logic, "front_mylar_phys", Logic, 0, false, OverlapCheck());
200 
201  if (Verbosity() > 1) std::cout << " Front mylar pos :" << fmylar_pos << std::endl;
202  //Carbon layer
203  G4Tubs *fcarbon_solid = new G4Tubs("front_carbon_solid", Rin, Rout, 0.5 * carbon_thick, 0., 360 * deg);
204  G4LogicalVolume *fcarbon_logic = new G4LogicalVolume(fcarbon_solid, G4_Ca, "front_Carbon_Logic", 0, 0, 0);
205 
206  G4VisAttributes *carbon_att = new G4VisAttributes();
207  carbon_att->SetColour(G4Colour::Black());
208  carbon_att->SetVisibility(true);
209  carbon_att->SetForceSolid(true);
210  fcarbon_logic->SetVisAttributes(carbon_att);
211  double fcarbon_pos = fmylar_pos + 0.5 * mylar_thick + 0.5 * carbon_thick;
212 
213  fcarbon_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, fcarbon_pos), fcarbon_logic, "front_carbon_phys", Logic, 0, false, OverlapCheck());
214 
215  if (Verbosity() > 1) std::cout << " front Carbon pos :" << fcarbon_pos << std::endl;
216  //mrpc and gas layers
217  double glass_begin_pos = fcarbon_pos + 0.5 * carbon_thick;
218  double glass_mid_pos = 0.;
219  double gas_begin_pos = glass_begin_pos + glass_thick;
220  double gas_mid_pos = 0.;
221 
222  G4VisAttributes *glass_att = new G4VisAttributes();
223  glass_att->SetColor(G4Colour::Magenta());
224  glass_att->SetVisibility(true);
225  glass_att->SetForceSolid(true);
226 
227  G4VisAttributes *gas_att = new G4VisAttributes();
228  gas_att->SetColor(G4Colour::Blue());
229  gas_att->SetVisibility(true);
230  gas_att->SetForceSolid(true);
231 
232  G4Tubs *fglass_solid[n_fgas_layer + 1];
233  G4LogicalVolume *fglass_logic[n_fgas_layer + 1];
234  G4Tubs *fgas_solid[n_fgas_layer];
235  G4LogicalVolume *fgas_logic[n_fgas_layer];
236 
237  for (int l = 0; l < n_fgas_layer + 1; l++)
238  {
239  /*
240  fglass_solid[l] = new G4Tubs(Form("front_glass_solid_%d", l), Rin, Rout, 0.5*glass_thick, 0, 360.*deg);
241  fglass_logic[l] = new G4LogicalVolume(fglass_solid[l], plateglass, Form("front_glass_Logic_%d", l),0 , 0,0);
242 
243  fglass_solid[l] = new G4Tubs("front_glass_solid_%d", Rin, Rout, 0.5*glass_thick, 0, 360.*deg);
244  fglass_logic[l] = new G4LogicalVolume(fglass_solid[l], plateglass,"front_glass_Logic_%d",0 , 0,0);
245  */
246 
247  std::string gl_solid_name = "fglass_solid_" + std::to_string(l);
248  std::string gl_logic_name = "fglass_logic_" + std::to_string(l);
249  std::string gl_phys_name = "fglass_phys_" + std::to_string(l);
250 
251  fglass_solid[l] = new G4Tubs(gl_solid_name, Rin, Rout, 0.5 * glass_thick, 0, 360. * deg);
252  fglass_logic[l] = new G4LogicalVolume(fglass_solid[l], plateglass, gl_logic_name, 0, 0, 0);
253  fglass_logic[l]->SetVisAttributes(glass_att);
254  glass_mid_pos = glass_begin_pos + (l + 0.5) * glass_thick + l * gas_gap;
255 
256  //fglass_phys[l] = new G4PVPlacement(0, G4ThreeVector(0, 0, glass_mid_pos), fglass_logic[l], sprintf("MRPC_layer_phys_%d",l), Logic, 0, false, OverlapCheck());
257  fglass_phys[l] = new G4PVPlacement(0, G4ThreeVector(0, 0, glass_mid_pos), fglass_logic[l], gl_phys_name, Logic, 0, false, OverlapCheck());
258 
259  if (l < n_fgas_layer)
260  {
261  /*
262  fgas_solid[l] = new G4Tubs(sprintf("front_gas_solid_%d", l), Rin, Rout, 0.5*gas_gap, 0, 360.*deg);
263  fgas_logic[l] = new G4LogicalVolume(fgas_solid[l], G4_gas, sprintf("front_gas_Logic_%d", l),0 , 0,0);
264 
265  fgas_solid[l] = new G4Tubs("front_gas_solid_%d", Rin, Rout, 0.5*gas_gap, 0, 360.*deg);
266  fgas_logic[l] = new G4LogicalVolume(fgas_solid[l], G4_gas,"front_gas_Logic_%d",0 , 0,0);
267  */
268 
269  std::string gas_solid_name = "fgas_solid_" + std::to_string(l);
270  std::string gas_logic_name = "fgas_logic_" + std::to_string(l);
271  std::string gas_phys_name = "fgas_phys_" + std::to_string(l);
272 
273  fgas_solid[l] = new G4Tubs(gas_solid_name, Rin, Rout, 0.5 * gas_gap, 0, 360. * deg);
274  fgas_logic[l] = new G4LogicalVolume(fgas_solid[l], G4_gas, gas_logic_name, 0, 0, 0);
275  fgas_logic[l]->SetVisAttributes(gas_att);
276  gas_mid_pos = gas_begin_pos + (l + 0.5) * gas_gap + l * glass_thick;
277 
278  //fgas_phys[l] = new G4PVPlacement(0, G4ThreeVector(0, 0, gas_mid_pos), fgas_logic[l], sprintf("Gas_layer_phys_%d",l), Logic, 0, false, OverlapCheck());
279  fgas_phys[l] = new G4PVPlacement(0, G4ThreeVector(0, 0, gas_mid_pos), fgas_logic[l], gas_phys_name, Logic, 0, false, OverlapCheck());
280  }
281  if (Verbosity() > 1)
282  {
283  std::cout << " Front glass layer : " << l << " glass mid : " << glass_mid_pos << std::endl;
284  std::cout << "Front gas layer : " << l << " gas mid : " << gas_mid_pos << std::endl;
285  }
286  }
287 
288  //Middle Carbon layer
289 
290  G4Tubs *mcarbon_solid = new G4Tubs("mid_carbon_solid", Rin, Rout, 0.5 * carbon_thick, 0., 360 * deg);
291  G4LogicalVolume *mcarbon_logic = new G4LogicalVolume(mcarbon_solid, G4_Ca, "mid_Carbon_Logic", 0, 0, 0);
292  mcarbon_logic->SetVisAttributes(carbon_att);
293  double mcarbon_pos = glass_mid_pos + 0.5 * glass_thick + 0.5 * carbon_thick;
294  mcarbon_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mcarbon_pos), mcarbon_logic, "mid_carbon_phys", Logic, 0, false, OverlapCheck());
295 
296  if (Verbosity() > 1) std::cout << " Middle Carbon pos :" << mcarbon_pos << std::endl;
297 
298  //Middle Mylar
299  G4Tubs *mmylar_solid = new G4Tubs("middle_mylar_solid", Rin, Rout, 0.5 * mylar_thick, 0., 360 * deg);
300  G4LogicalVolume *mmylar_logic = new G4LogicalVolume(mmylar_solid, G4_Mylar, "middle_Mylar_Logic", 0, 0, 0);
301  mmylar_logic->SetVisAttributes(mylar_att);
302  double mmylar_pos = mcarbon_pos + 0.5 * carbon_thick + 0.5 * mylar_thick;
303 
304  mmylar_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mmylar_pos), mmylar_logic, "middle_mylar_phys", Logic, 0, false, OverlapCheck());
305 
306  if (Verbosity() > 1) std::cout << " Middle mylar pos :" << mmylar_pos << std::endl;
307 
308  //Middle PCB front Cu
309  G4Tubs *mpcbcu_solid = new G4Tubs("middle_pcbcu_solid", Rin, Rout, 0.5 * cu_thick, 0., 360 * deg);
310  G4LogicalVolume *mpcbcu_logic = new G4LogicalVolume(mpcbcu_solid, G4_Cu, "middle_PCBCu_Logic", 0, 0, 0);
311  mpcbcu_logic->SetVisAttributes(cu_att);
312  double mpcbcu_pos = mmylar_pos + 0.5 * mylar_thick + 0.5 * cu_thick;
313 
314  mpcbcu_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mpcbcu_pos), mpcbcu_logic, "middle_pcbcu_phys", Logic, 0, false, OverlapCheck());
315 
316  if (Verbosity() > 1) std::cout << " Middle PCB Cu pos :" << mpcbcu_pos << std::endl;
317 
318  //Middle PCB
319  G4Tubs *mpcb_solid = new G4Tubs("middle_pcb_solid", Rin, Rout, 0.5 * pcb_thick, 0., 360 * deg);
320  G4LogicalVolume *mpcb_logic = new G4LogicalVolume(mpcb_solid, G4_FR4, "middle_PCB_Logic", 0, 0, 0);
321  mpcb_logic->SetVisAttributes(tof_pcb_att);
322  double mpcb_pos = mpcbcu_pos + 0.5 * cu_thick + 0.5 * pcb_thick;
323 
324  mpcb_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mpcb_pos), mpcb_logic, "middle_pcb_phys", Logic, 0, false, OverlapCheck());
325 
326  if (Verbosity() > 1) std::cout << " Middle PCB pos :" << mpcb_pos << std::endl;
327 
328  //Middle PCB back Cu
329  G4Tubs *mpcbcu2_solid = new G4Tubs("middle_pcbcu2_solid", Rin, Rout, 0.5 * cu_thick, 0., 360 * deg);
330  G4LogicalVolume *mpcbcu2_logic = new G4LogicalVolume(mpcbcu2_solid, G4_Cu, "middle_Pcbcu2_Logic", 0, 0, 0);
331  mpcbcu2_logic->SetVisAttributes(cu_att);
332  double mpcbcu2_pos = mpcb_pos + 0.5 * pcb_thick + 0.5 * cu_thick;
333 
334  mpcbcu2_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mpcbcu2_pos), mpcbcu2_logic, "middle_pcbcu2_phys", Logic, 0, false, OverlapCheck());
335  if (Verbosity() > 1) std::cout << " Middle PCB Cu pos :" << mpcbcu2_pos << std::endl;
336 
337  G4Tubs *mmylar2_solid = new G4Tubs("middle_mylar2_solid", Rin, Rout, 0.5 * mylar_thick, 0., 360 * deg);
338  G4LogicalVolume *mmylar2_logic = new G4LogicalVolume(mmylar2_solid, G4_Mylar, "middle_Mylar2_Logic", 0, 0, 0);
339  mmylar2_logic->SetVisAttributes(mylar_att);
340  double mmylar2_pos = mpcbcu2_pos + 0.5 * cu_thick + 0.5 * mylar_thick;
341 
342  mmylar2_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mmylar2_pos), mmylar2_logic, "middle_mylar2_phys", Logic, 0, false, OverlapCheck());
343 
344  if (Verbosity() > 1) std::cout << " Middle mylar pos :" << mmylar2_pos << std::endl;
345 
346  //Middle PCB carbon
347  G4Tubs *mcarbon2_solid = new G4Tubs("mid_carbon2_solid", Rin, Rout, 0.5 * carbon_thick, 0., 360 * deg);
348  G4LogicalVolume *mcarbon2_logic = new G4LogicalVolume(mcarbon2_solid, G4_Ca, "mid_Carbon2_Logic", 0, 0, 0);
349  mcarbon2_logic->SetVisAttributes(carbon_att);
350  double mcarbon2_pos = mmylar2_pos + 0.5 * mylar_thick + 0.5 * carbon_thick;
351  mcarbon2_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mcarbon2_pos), mcarbon2_logic, "mid_carbon2_phys", Logic, 0, false, OverlapCheck());
352  if (Verbosity() > 1) std::cout << " Middle PCB back Carbon pos :" << mcarbon2_pos << std::endl;
353 
354  //Back gas and mrpc layers
355  double bglass_begin_pos = mcarbon2_pos + 0.5 * carbon_thick;
356  double bglass_mid_pos = 0.;
357  double bgas_begin_pos = bglass_begin_pos + glass_thick;
358  double bgas_mid_pos = 0.;
359 
360  if (Verbosity() > 1)
361  {
362  std::cout << " Back glass begin pos : " << bglass_begin_pos << std::endl;
363  std::cout << " Back gas begin pos : " << bgas_begin_pos << std::endl;
364  }
365 
366  G4Tubs *bglass_solid[n_bgas_layer + 1];
367  G4LogicalVolume *bglass_logic[n_bgas_layer + 1];
368  G4Tubs *bgas_solid[n_bgas_layer];
369  G4LogicalVolume *bgas_logic[n_bgas_layer];
370 
371  for (int l = 0; l < n_bgas_layer + 1; l++)
372  {
373  /*
374  bglass_solid[l] = new G4Tubs(sprintf("back_glass_solid_%d", l), Rin, Rout, 0.5*glass_thick, 0, 360.*deg);
375  bglass_logic[l] = new G4LogicalVolume(bglass_solid[l], plateglass, sprintf("back_glass_Logic_%d", l),0 , 0,0);
376 
377  bglass_solid[l] = new G4Tubs("back_glass_solid", Rin, Rout, 0.5*glass_thick, 0, 360.*deg);
378  bglass_logic[l] = new G4LogicalVolume(bglass_solid[l], plateglass, "back_glass_Logic",0 , 0,0);
379  */
380  std::string bgl_solid_name = "bglass_solid_" + std::to_string(l);
381  std::string bgl_logic_name = "bglass_logic_" + std::to_string(l);
382  std::string bgl_phys_name = "bglass_phys_" + std::to_string(l);
383 
384  bglass_solid[l] = new G4Tubs(bgl_solid_name, Rin, Rout, 0.5 * glass_thick, 0, 360. * deg);
385  bglass_logic[l] = new G4LogicalVolume(bglass_solid[l], plateglass, bgl_logic_name, 0, 0, 0);
386  bglass_logic[l]->SetVisAttributes(glass_att);
387  bglass_mid_pos = bglass_begin_pos + (l + 0.5) * glass_thick + l * gas_gap;
388  bglass_phys[l] = new G4PVPlacement(0, G4ThreeVector(0, 0, bglass_mid_pos), bglass_logic[l], bgl_phys_name, Logic, 0, false, OverlapCheck());
389 
390  if (l < n_bgas_layer)
391  {
392  /*
393  bgas_solid[l] = new G4Tubs(sprintf("front_gas_solid_%d", l), Rin, Rout, 0.5*gas_gap, 0, 360.*deg);
394  bgas_logic[l] = new G4LogicalVolume(bgas_solid[l], G4_gas, sprintf("back_gas_Logic_%d", l),0 , 0,0);
395 
396  bgas_solid[l] = new G4Tubs("front_gas_solid", Rin, Rout, 0.5*gas_gap, 0, 360.*deg);
397  bgas_logic[l] = new G4LogicalVolume(bgas_solid[l], G4_gas, "back_gas_Logic",0 , 0,0);
398  */
399  std::string bgas_solid_name = "bgas_solid_" + std::to_string(l);
400  std::string bgas_logic_name = "bgas_logic_" + std::to_string(l);
401  std::string bgas_phys_name = "bgas_phys_" + std::to_string(l);
402 
403  bgas_solid[l] = new G4Tubs(bgas_solid_name, Rin, Rout, 0.5 * gas_gap, 0, 360. * deg);
404  bgas_logic[l] = new G4LogicalVolume(bgas_solid[l], G4_gas, bgas_logic_name, 0, 0, 0);
405  bgas_logic[l]->SetVisAttributes(gas_att);
406  bgas_mid_pos = bgas_begin_pos + (l + 0.5) * gas_gap + l * glass_thick;
407  // bgas_phys[l] = new G4PVPlacement(0, G4ThreeVector(0, 0, bgas_mid_pos), bgas_logic[l], sprintf("Gasback_layer_phys_%d",l), Logic, 0, false, OverlapCheck());
408  bgas_phys[l] = new G4PVPlacement(0, G4ThreeVector(0, 0, bgas_mid_pos), bgas_logic[l], bgas_phys_name, Logic, 0, false, OverlapCheck());
409  }
410  if (Verbosity() > 1)
411  {
412  std::cout << " Back glass layer : " << l << " glass mid : " << bglass_mid_pos << std::endl;
413  std::cout << "Back gas layer : " << l << " gas mid : " << bgas_mid_pos << std::endl;
414  }
415  }
416 
417  //Back carbon layer
418  G4Tubs *bcarbon_solid = new G4Tubs("mid_carbon2_solid", Rin, Rout, 0.5 * carbon_thick, 0., 360 * deg);
419  G4LogicalVolume *bcarbon_logic = new G4LogicalVolume(bcarbon_solid, G4_Ca, "bach_Carbon_Logic", 0, 0, 0);
420  bcarbon_logic->SetVisAttributes(carbon_att);
421  double bcarbon_pos = bglass_mid_pos + 0.5 * glass_thick + 0.5 * carbon_thick;
422  bcarbon_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, bcarbon_pos), bcarbon_logic, "back_carbon_phys", Logic, 0, false, OverlapCheck());
423 
424  if (Verbosity() > 1) std::cout << " back carbon mid :" << bcarbon_pos << std::endl;
425 
426  //Back mylar layer
427  G4Tubs *bmylar_solid = new G4Tubs("back_mylar_solid", Rin, Rout, 0.5 * mylar_thick, 0., 360 * deg);
428  G4LogicalVolume *bmylar_logic = new G4LogicalVolume(bmylar_solid, G4_Mylar, "back_Mylar_Logic", 0, 0, 0);
429  bmylar_logic->SetVisAttributes(mylar_att);
430  double bmylar_pos = bcarbon_pos + 0.5 * carbon_thick + 0.5 * mylar_thick;
431 
432  bmylar_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, bmylar_pos), bmylar_logic, "back_mylar_phys", Logic, 0, false, OverlapCheck());
433 
434  if (Verbosity() > 1) std::cout << " Back mylar pos :" << bmylar_pos << std::endl;
435 
436  //Back PCB Cu layer
437  G4Tubs *bpcbcu_solid = new G4Tubs("back_pcbcu_solid", Rin, Rout, 0.5 * cu_thick, 0., 360 * deg);
438  G4LogicalVolume *bpcbcu_logic = new G4LogicalVolume(bpcbcu_solid, G4_Cu, "back_PCBCu_Logic", 0, 0, 0);
439  bpcbcu_logic->SetVisAttributes(cu_att);
440  double bpcbcu_pos = bmylar_pos + 0.5 * mylar_thick + 0.5 * cu_thick;
441 
442  bpcbcu_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, bpcbcu_pos), bpcbcu_logic, "middle_pcbcu_phys", Logic, 0, false, OverlapCheck());
443 
444  if (Verbosity() > 1) std::cout << " Middle PCB back Cu pos :" << bpcbcu_pos << std::endl;
445 
446  //Back PCB
447  G4Tubs *bpcb_solid = new G4Tubs("back_pcb_solid", Rin, Rout, 0.5 * pcb_thick, 0., 360 * deg);
448  G4LogicalVolume *bpcb_logic = new G4LogicalVolume(bpcb_solid, G4_FR4, "back_PCB_Logic", 0, 0, 0);
449  bpcb_logic->SetVisAttributes(tof_pcb_att);
450  double bpcb_pos = bpcbcu_pos + 0.5 * cu_thick + 0.5 * pcb_thick;
451 
452  bpcb_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, bpcb_pos), bpcb_logic, "back_pcb_phys", Logic, 0, false, OverlapCheck());
453 
454  if (Verbosity() > 1) std::cout << " Back PCB pos :" << bpcb_pos << std::endl;
455 
456  //Back Honeycomb
457  G4Tubs *bhc_solid = new G4Tubs("front_honeycomb_solid", Rin, Rout, 0.5 * honeycomb_thick, 0., 360 * deg);
458  G4LogicalVolume *bhc_logic = new G4LogicalVolume(bhc_solid, G4_Nomex, "front_honeycomb_Logic", 0, 0, 0);
459  bhc_logic->SetVisAttributes(tof_hc_att);
460  double bhc_pos = bpcb_pos + 0.5 * pcb_thick + 0.5 * honeycomb_thick;
461 
462  bhc_phys = new G4PVPlacement(0, G4ThreeVector(0, 0, bhc_pos), bhc_logic, "front_hc_phys", Logic, 0, false, OverlapCheck());
463 
464  if (Verbosity() > 1) std::cout << " Front HC mid pos :" << bhc_pos << std::endl;
465 }