Belle II Software  release-05-01-25
Ph1bpipeCreator.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter, Igal Jaegle,Yuri Soloviev *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <beast/ph1bpipe/geometry/Ph1bpipeCreator.h>
12 #include <beast/ph1bpipe/simulation/SensitiveDetector.h>
13 
14 #include <geometry/Materials.h>
15 #include <geometry/CreatorFactory.h>
16 #include <framework/gearbox/GearDir.h>
17 
18 #include <cmath>
19 #include <boost/format.hpp>
20 #include <boost/foreach.hpp>
21 #include <boost/algorithm/string.hpp>
22 
23 #include <G4LogicalVolume.hh>
24 #include <G4PVPlacement.hh>
25 #include <G4VisAttributes.hh>
26 
27 //Shapes
28 #include <G4Box.hh>
29 #include <G4EllipticalTube.hh>
30 #include "G4UnionSolid.hh"
31 #include "G4SubtractionSolid.hh"
32 #include "G4IntersectionSolid.hh"
33 #include <G4UserLimits.hh>
34 #include "G4Tubs.hh"
35 #include "G4Trd.hh"
36 
37 using namespace std;
38 using namespace boost;
39 
40 namespace Belle2 {
47  namespace ph1bpipe {
48 
49  // Register the creator
51  geometry::CreatorFactory<Ph1bpipeCreator> Ph1bpipeFactory("PH1BPIPECreator");
52 
53  Ph1bpipeCreator::Ph1bpipeCreator(): m_sensitive(0)
54  {
56  }
57 
58  Ph1bpipeCreator::~Ph1bpipeCreator()
59  {
60  if (m_sensitive) delete m_sensitive;
61  }
62 
63  void Ph1bpipeCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */)
64  {
65  //Beam pipes 6 pillars
66  double pillar_height = 61.9 * CLHEP::cm / 2.;
67  double pillar_length = 3. * CLHEP::cm;
68  double pillar_width = pillar_length;
69  G4VSolid* s_bppillar = new G4Box("s_bppillar", pillar_length, pillar_height, pillar_width);
70  G4LogicalVolume* l_bppillar = new G4LogicalVolume(s_bppillar, geometry::Materials::get("Al") , "l_bppillar", 0, 0);
71  G4VisAttributes* white = new G4VisAttributes(G4Colour(1, 1, 1));
72  white->SetForceAuxEdgeVisible(true);
73  l_bppillar->SetVisAttributes(white);
74  double y_offset = -76. * CLHEP::cm + pillar_height;
75  G4ThreeVector Pillarpos = G4ThreeVector(0, y_offset, -154.0 * CLHEP::cm);
76  new G4PVPlacement(0, Pillarpos, l_bppillar, "p_bppilar1", &topVolume, false, 1);
77  Pillarpos = G4ThreeVector(0, y_offset, 154.0 * CLHEP::cm);
78  new G4PVPlacement(0, Pillarpos, l_bppillar, "p_bppilar2", &topVolume, false, 1);
79  Pillarpos = G4ThreeVector(11.4175236299 * CLHEP::cm, y_offset, -227.758203051 * CLHEP::cm);
80  new G4PVPlacement(0, Pillarpos, l_bppillar, "p_bppilar3", &topVolume, false, 1);
81  Pillarpos = G4ThreeVector(-10.4976636985 * CLHEP::cm, y_offset, 227.758203051 * CLHEP::cm);
82  new G4PVPlacement(0, Pillarpos, l_bppillar, "p_bppilar4", &topVolume, false, 1);
83  Pillarpos = G4ThreeVector(-8.71250756316 * CLHEP::cm , y_offset, -209.819190072 * CLHEP::cm);
84  new G4PVPlacement(0, Pillarpos, l_bppillar, "p_bppilar5", &topVolume, false, 1);
85  Pillarpos = G4ThreeVector(8.71248973173 * CLHEP::cm, y_offset, 209.819190072 * CLHEP::cm);
86  new G4PVPlacement(0, Pillarpos, l_bppillar, "p_bppilar6", &topVolume, false, 1);
87 
88  //Central beam pipe reinforcement
89  double x_reih = 2. * CLHEP::cm / 2.;
90  double y_reih = 2.3 * CLHEP::cm / 2.;
91  double z_reih = 48. * CLHEP::cm / 2.;
92  G4VSolid* s_reih = new G4Box("s_reih", x_reih, y_reih, z_reih);
93  G4LogicalVolume* l_reih = new G4LogicalVolume(s_reih, geometry::Materials::get("Al") , "l_reih", 0, 0);
94  l_reih->SetVisAttributes(white);
95  G4ThreeVector Reihpos = G4ThreeVector(72.8780869619 * CLHEP::mm, 0, 1.35841468498 * CLHEP::mm);
96  new G4PVPlacement(0, Reihpos, l_reih, "p_Reih1", &topVolume, false, 1);
97  Reihpos = G4ThreeVector(-72.8780869619 * CLHEP::mm, 0, 1.35841468498 * CLHEP::mm);
98  new G4PVPlacement(0, Reihpos, l_reih, "p_Reih2", &topVolume, false, 1);
99 
100  double x_reiv = 2. * CLHEP::cm / 2.;
101  double y_reiv = 5.2 * CLHEP::cm / 2.;
102  double z_reiv = 140. * CLHEP::cm / 2.;
103  G4VSolid* s_reiv = new G4Box("s_reiv", x_reiv, y_reiv, z_reiv);
104  G4LogicalVolume* l_reiv = new G4LogicalVolume(s_reiv, geometry::Materials::get("Al") , "l_reiv", 0, 0);
105  l_reiv->SetVisAttributes(white);
106  //G4ThreeVector Reivpos = G4ThreeVector(0, -77.5018052955 * CLHEP::mm, 0);
107  G4ThreeVector Reivpos = G4ThreeVector(0, -83.0 * CLHEP::mm, 0);
108  new G4PVPlacement(0, Reivpos, l_reiv, "p_Reiv1", &topVolume, false, 1);
109  //Reivpos = G4ThreeVector(0, 77.4981947045 * CLHEP::mm,0 );
110  Reivpos = G4ThreeVector(0, 83.0 * CLHEP::mm, 0);
111  new G4PVPlacement(0, Reivpos, l_reiv, "p_Reiv2", &topVolume, false, 1);
112 
113  /*
114  Central beampipe +- pipe_hz = 20cm
115  Flanges of centra BP endcap_hz = 2.2cm thick
116  Distance of the end of xshape from IP xpipe_hz1 = 200cm
117  Length of far beampipe backward xpipePOS_hz = 168.1cm
118  Length of far beampipe backward xpipeMIN_hz = 141.3cm
119  */
120 
121  //lets get the stepsize parameter with a default value of 5 µm
122  double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
123 // flag_limitStep = true for SynRad simulation
124  double stepMax = 50. *CLHEP::mm;
125  //cout << " stepMax = " << stepMax << endl;
126  bool flag_limitStep = false;
127 // bool flag_limitStep = true;
128 
130  double SafetyLength = 0.1 * CLHEP ::cm;
131 
132  double xpipe_hz1 = content.getLength("xpipe_hz1") * CLHEP::cm;
133  double pipe_hz = content.getLength("pipe_hz") * CLHEP::cm;
134  double pipe_outerRadius_x = content.getLength("pipe_outerRadius_x") * CLHEP::cm;
135  double pipe_outerRadius_y = content.getLength("pipe_outerRadius_y") * CLHEP::cm;
136  double pipe_innerRadius_x = content.getLength("pipe_innerRadius_x") * CLHEP::cm;
137  double pipe_innerRadius_y = content.getLength("pipe_innerRadius_y") * CLHEP::cm;
138  double xpipe_innerRadius = content.getLength("xpipe_innerRadius") * CLHEP::cm;
139  double xpipe_outerRadius = content.getLength("xpipe_outerRadius") * CLHEP::cm;
140  double pipe_innerRadiusTiN_x = content.getLength("pipe_innerRadiusTiN_x") * CLHEP::cm;
141  double pipe_innerRadiusTiN_y = content.getLength("pipe_innerRadiusTiN_y") * CLHEP::cm;
142  double xpipe_innerRadiusTiN = content.getLength("xpipe_innerRadiusTiN") * CLHEP::cm;
143  double endcap_hz = content.getLength("endcap_hz") * CLHEP::cm;
144  double endcap_outerRadius = content.getLength("endcap_outerRadius") * CLHEP::cm;
145  double xpipePOS_hz = content.getLength("xpipePOS_hz") * CLHEP::cm;
146  double xpipeMIN_hz = content.getLength("xpipeMIN_hz") * CLHEP::cm;
147 
148  //create ph1bpipe volume
149  double startAngle = 0.*CLHEP::deg;
150  double spanningAngle = 360.*CLHEP::deg;
151  double A1 = 0.0415 * CLHEP::rad;
152 // //cout << " A1 = " << A1 << endl;
153  double OBtemp = sqrt(pow(xpipe_hz1, 2) + pow(xpipe_innerRadius / 2., 2));
154  // cout << " OBtemp = " << OBtemp << endl;
155  double BCtemp = OBtemp * sin(A1);
156  // cout << " BCtemp = " << BCtemp << endl;
157  double ABtemp = sqrt(pow(pipe_hz, 2) + pow(OBtemp, 2) - 2 * pipe_hz * OBtemp * cos(A1));
158  // cout << " ABtemp = " << ABtemp << endl;
159  double A2 = asin(BCtemp / ABtemp) * CLHEP::rad;
160  // cout << " A2 = " << A2 << endl;
161  double xpipe_hz = ABtemp - 2 * endcap_hz / cos(A2); // Length of xshape pipe
162  // cout << " xpipe_hz = " << xpipe_hz << endl;
163  double xcont2 = BCtemp + xpipe_outerRadius; // +Z size of AluCont_f trapezoid
164  double xcont1 = xpipe_outerRadius + 2 * endcap_hz * tan(A2); //-Z size of AluCont_f trapezoid
165  double xcont3 = xcont2 + xpipePOS_hz * sin(A1); // +Z size of AluCont_fp trapezoid
166  double xcont4 = xcont3 - 2 * xpipe_outerRadius; // +Z size of AluCont_fps trapezoid
167  double xcont5 = xcont2 - 2 * xpipe_outerRadius; // -Z size of AluCont_fps trapezoid
168  double xcont3M = xcont2 + xpipeMIN_hz * sin(A1); // +Z size of AluCont_bp trapezoid
169  double xcont4M = xcont3M - 2 * xpipe_outerRadius; // +Z size of AluCont_bps trapezoid
170  // cout << " xcont2 = " << xcont2 << " xcont1 = " << xcont1 << endl;
171  // cout << " xcont3 = " << xcont3 << " xcont4 = " << xcont4 << " xcont5 = " << xcont5 << endl;
172  // cout << " xcont3M = " << xcont3M << " xcont4M = " << xcont4M << endl;
173  double dxtr = 0.5 * (ABtemp + 2 * endcap_hz / cos(A2)) * sin(2 * A2);
174  double dztr = (ABtemp + 2 * endcap_hz / cos(A2)) * sin(A2) * sin(A2);
175  // cout << "dxtr = " << dxtr << " dztr = " << dztr << endl;
176 
177  string matPipe = content.getString("MaterialPipe");
178  string matTiN = content.getString("MaterialTiN");
179  string vacPipe = content.getString("MatVacuum");
180  G4double tubinR = 0.0 * CLHEP::cm;
181 
182  G4VSolid* s_PH1BPIPE = new G4EllipticalTube("s_PH1BPIPE",
183  pipe_outerRadius_x,
184  pipe_outerRadius_y,
185  pipe_hz);
186  G4LogicalVolume* l_PH1BPIPE = new G4LogicalVolume(s_PH1BPIPE, geometry::Materials::get(matPipe), "l_PH1BPIPE", 0, 0);
187  //Lets limit the Geant4 stepsize inside the volume
188  l_PH1BPIPE->SetUserLimits(new G4UserLimits(stepSize));
189  //position central ph1bpipe volume
190  G4ThreeVector PH1BPIPEpos = G4ThreeVector(
191  content.getLength("x_ph1bpipe") * CLHEP::cm,
192  content.getLength("y_ph1bpipe") * CLHEP::cm,
193  content.getLength("z_ph1bpipe") * CLHEP::cm
194  );
195  new G4PVPlacement(0, PH1BPIPEpos, l_PH1BPIPE, "p_PH1BPIPE", &topVolume, false, 0);
196 
197  G4VSolid* s_PH1BPIPETiN = new G4EllipticalTube("s_PH1BPIPETiN",
198  pipe_innerRadius_x,
199  pipe_innerRadius_y,
200  pipe_hz);
201  G4LogicalVolume* l_PH1BPIPETiN = new G4LogicalVolume(s_PH1BPIPETiN, geometry::Materials::get(matTiN), "l_PH1BPIPETiN", 0, 0);
202  new G4PVPlacement(0, PH1BPIPEpos, l_PH1BPIPETiN, "p_PH1BPIPETiN", l_PH1BPIPE , false, 0);
203 
204  G4VSolid* s_PH1BPIPEV = new G4EllipticalTube("s_PH1BPIPEV",
205  pipe_innerRadiusTiN_x,
206  pipe_innerRadiusTiN_y,
207  pipe_hz);
208  G4VSolid* s_PH1BPIPEVac = new G4IntersectionSolid("s_PH1BPIPEVac", s_PH1BPIPE, s_PH1BPIPEV);
209  G4LogicalVolume* l_PH1BPIPEVac = new G4LogicalVolume(s_PH1BPIPEVac, geometry::Materials::get(vacPipe), "l_PH1BPIPEVac", 0, 0);
210  if (flag_limitStep) l_PH1BPIPEVac->SetUserLimits(new G4UserLimits(stepMax));
211  new G4PVPlacement(0, PH1BPIPEpos, l_PH1BPIPEVac, "p_PH1BPIPEVac", l_PH1BPIPETiN , false, 0);
212 
213  //create central endcaps
214  G4VSolid* s_PH1BPIPEendcap = new G4Tubs("s_PH1BPIPEendcap", 0.,
215  endcap_outerRadius,
216  endcap_hz,
217  startAngle, spanningAngle);
218  G4LogicalVolume* l_PH1BPIPEendcapTop = new G4LogicalVolume(s_PH1BPIPEendcap, geometry::Materials::get(matPipe),
219  "l_PH1BPIPEendcapTop", 0, 0);
220  G4LogicalVolume* l_PH1BPIPEendcapBot = new G4LogicalVolume(s_PH1BPIPEendcap, geometry::Materials::get(matPipe),
221  "l_PH1BPIPEendcapBot", 0, 0);
222  //position central endcaps
223  G4ThreeVector PH1BPIPEendcapposTop = G4ThreeVector(
224  content.getLength("x_ph1bpipe") * CLHEP::cm,
225  content.getLength("y_ph1bpipe") * CLHEP::cm,
226  content.getLength("z_ph1bpipe") * CLHEP::cm + pipe_hz + endcap_hz
227  );
228 
229  G4ThreeVector PH1BPIPEendcapposBot = G4ThreeVector(
230  content.getLength("x_ph1bpipe") * CLHEP::cm,
231  content.getLength("y_ph1bpipe") * CLHEP::cm,
232  content.getLength("z_ph1bpipe") * CLHEP::cm - pipe_hz - endcap_hz
233  );
234  new G4PVPlacement(0, PH1BPIPEendcapposTop, l_PH1BPIPEendcapTop, "p_PH1BPIPEendcapTop", &topVolume, false, 0);
235  new G4PVPlacement(0, PH1BPIPEendcapposBot, l_PH1BPIPEendcapBot, "p_PH1BPIPEendcapBot", &topVolume, false, 0);
236 
237  G4VSolid* s_PH1BPIPEendcapTiN = new G4EllipticalTube("s_PH1BPIPEendcapTiN",
238  pipe_innerRadius_x,
239  pipe_innerRadius_y,
240  endcap_hz);
241  G4LogicalVolume* l_PH1BPIPEendcapTiNTop = new G4LogicalVolume(s_PH1BPIPEendcapTiN, geometry::Materials::get(matTiN),
242  "l_PH1BPIPEendcapTiNTop", 0, 0);
243  G4LogicalVolume* l_PH1BPIPEendcapTiNBot = new G4LogicalVolume(s_PH1BPIPEendcapTiN, geometry::Materials::get(matTiN),
244  "l_PH1BPIPEendcapTiNBot", 0, 0);
245  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_PH1BPIPEendcapTiNTop, "p_PH1BPIPEendcapTiNTop", l_PH1BPIPEendcapTop , false, 0);
246  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_PH1BPIPEendcapTiNBot, "p_PH1BPIPEendcapTiNBot", l_PH1BPIPEendcapBot , false, 0);
247 
248  G4VSolid* s_PH1BPIPEendcapV = new G4EllipticalTube("s_PH1BPIPEendcapV",
249  pipe_innerRadiusTiN_x,
250  pipe_innerRadiusTiN_y,
251  endcap_hz);
252  G4VSolid* s_PH1BPIPEendcapVac = new G4IntersectionSolid("s_PH1BPIPEendcapVac", s_PH1BPIPEendcap , s_PH1BPIPEendcapV);
253  G4LogicalVolume* l_PH1BPIPEendcapVac = new G4LogicalVolume(s_PH1BPIPEendcapVac, geometry::Materials::get(vacPipe),
254  "l_PH1BPIPEendcapVac", 0, 0);
255  if (flag_limitStep) l_PH1BPIPEendcapVac->SetUserLimits(new G4UserLimits(stepMax));
256  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_PH1BPIPEendcapVac, "p_PH1BPIPEendcapVacTop", l_PH1BPIPEendcapTiNTop, false, 0);
257  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_PH1BPIPEendcapVac, "p_PH1BPIPEendcapVacBot", l_PH1BPIPEendcapTiNBot, false, 0);
258 
259  //create x shape tubes forward
260  // Alu trapezoid containing x-shape tube
261  G4VSolid* AluCont_f = new G4Trd("AluCont_f", xcont1, xcont2, xcont1, xcont1, xpipe_hz / 2.0 * cos(A2));
262  G4LogicalVolume* logi_AluCont_f = new G4LogicalVolume(AluCont_f, geometry::Materials::get(matPipe), "logi_AluCont_f", 0 , 0);
263  new G4PVPlacement(0, G4ThreeVector(0, 0, pipe_hz + endcap_hz * 2.0 + 0.5 * xpipe_hz * cos(A2)),
264  logi_AluCont_f, "phys_AluCont_f", &topVolume, false, 0);
265 // //cout << " AluCont_f z pos = " << pipe_hz + endcap_hz*2.0 + xpipe_hz*cos(A2)/2. << endl;
266 // //cout << " AluCont_f zmax pos = " << pipe_hz + endcap_hz*2.0 + xpipe_hz*cos(A2) << endl;
267 
268  // create x part
269  G4VSolid* s_Xshapef_11 = new G4Tubs("s_Xshapef_11",
270  tubinR,
271  xpipe_innerRadius,
272  xpipe_hz,
273  startAngle, spanningAngle);
274  G4VSolid* s_Xshapef_12 = new G4Tubs("s_Xshapef_12",
275  tubinR,
276  xpipe_innerRadius * 2.0,
277  xpipe_hz / 2.0 ,
278  startAngle, spanningAngle);
279  G4VSolid* s_Xshapef_21 = new G4Tubs("s_Xshapef_21",
280  tubinR,
281  xpipe_innerRadiusTiN,
282  xpipe_hz,
283  startAngle, spanningAngle);
284  G4VSolid* s_Xshapef_22 = new G4Tubs("s_Xshapef_22",
285  tubinR,
286  xpipe_innerRadiusTiN * 2.0,
287  xpipe_hz / 2.0 ,
288  startAngle, spanningAngle);
289  //create TiN layer on
290 
291  G4VSolid* s_XshapefTiN_11 = new G4Tubs("s_XshapefTiN_11",
292  tubinR,
293  xpipe_innerRadius,
294  xpipe_hz,
295  startAngle, spanningAngle);
296  G4VSolid* s_XshapefTiN_12 = new G4Tubs("s_XshapefTiN_12",
297  tubinR,
298  xpipe_innerRadius * 2.0,
299  xpipe_hz / 2.0 ,
300  startAngle, spanningAngle);
301  G4VSolid* s_XshapefTiN_21 = new G4Tubs("s_XshapefTiN_21",
302  tubinR,
303  xpipe_innerRadius,
304  xpipe_hz,
305  startAngle, spanningAngle);
306  G4VSolid* s_XshapefTiN_22 = new G4Tubs("s_XshapefTiN_22",
307  tubinR,
308  xpipe_innerRadius * 2.0,
309  xpipe_hz / 2.0 ,
310  startAngle, spanningAngle);
311  //Slanted tube1
312  G4Transform3D transform_sXshapef_12 = G4Translate3D(0., 0., 0.);
313  transform_sXshapef_12 = transform_sXshapef_12 * G4RotateY3D(-A2);
314  G4IntersectionSolid* Xshapef1 = new G4IntersectionSolid("Xshapef1", s_Xshapef_11, s_Xshapef_12, transform_sXshapef_12);
315  //Slanted tube2
316  G4Transform3D transform_sXshapef_22 = G4Translate3D(0., 0., 0.);
317  transform_sXshapef_22 = transform_sXshapef_22 * G4RotateY3D(A2);
318  G4IntersectionSolid* Xshapef2 = new G4IntersectionSolid("Xshapef2", s_Xshapef_21, s_Xshapef_22, transform_sXshapef_22);
319  //Slanted tube1TiN
320  G4Transform3D transform_sXshapefTiN_12 = G4Translate3D(0., 0., 0.);
321  transform_sXshapefTiN_12 = transform_sXshapefTiN_12 * G4RotateY3D(-A2);
322  G4IntersectionSolid* XshapefTiN1 = new G4IntersectionSolid("XshapefTiN1", s_XshapefTiN_11, s_XshapefTiN_12,
323  transform_sXshapefTiN_12);
324  //Slanted tube2TiN
325  G4Transform3D transform_sXshapefTiN_22 = G4Translate3D(0., 0., 0.);
326  transform_sXshapefTiN_22 = transform_sXshapefTiN_22 * G4RotateY3D(A2);
327  G4IntersectionSolid* XshapefTiN2 = new G4IntersectionSolid("XshapefTiN2", s_XshapefTiN_21, s_XshapefTiN_22,
328  transform_sXshapefTiN_22);
329 
330  // (sXshapeTiN2 + sXshapeTiN1)
331  G4Transform3D transform_XshapefTiN1 = G4Translate3D(dxtr, 0. , -dztr);
332  transform_XshapefTiN1 = transform_XshapefTiN1 * G4RotateY3D(2.*A2);
333  G4UnionSolid* XshapeTiNForwx = new G4UnionSolid("XshapeTiNForwx", XshapefTiN2 , XshapefTiN1 , transform_XshapefTiN1);
334  // Place XshapeTiNForwx into logi_AluCont_f
335  G4RotationMatrix* yRot = new G4RotationMatrix;
336  yRot->rotateY(A2);
337  G4ThreeVector transform_XshapeTiNForwx(-dxtr / 2., 0., 0.);
338  G4IntersectionSolid* XshapeTiNForw = new G4IntersectionSolid("XshapeTiNForw", AluCont_f, XshapeTiNForwx, yRot,
339  transform_XshapeTiNForwx);
340  G4LogicalVolume* l_XshapeTiNForw = new G4LogicalVolume(XshapeTiNForw, geometry::Materials::get(matTiN), "l_XshapeTiNForw", 0 , 0);
341  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_XshapeTiNForw, "p_XshapeTiNForw", logi_AluCont_f , false, 0);
342 
343  // sXshape2 + sXshape1
344  G4Transform3D transform_Xshapef1 = G4Translate3D(dxtr , 0. , -dztr);
345  transform_Xshapef1 = transform_Xshapef1 * G4RotateY3D(2.*A2);
346  G4UnionSolid* XshapeForwx = new G4UnionSolid("XshapeForwx", Xshapef2 , Xshapef1 , transform_Xshapef1);
347  // Place XshapeForwx into l_XshapeTiNForw
348  G4Transform3D transform_XshapeForwx = G4Translate3D(-dxtr / 2., 0., 0.);
349  transform_XshapeForwx = transform_XshapeForwx * G4RotateY3D(-A2);
350  G4IntersectionSolid* XshapeForw = new G4IntersectionSolid("XshapeForw", AluCont_f, XshapeForwx, transform_XshapeForwx);
351  G4LogicalVolume* l_XshapeForw = new G4LogicalVolume(XshapeForw, geometry::Materials::get(vacPipe), "l_XshapeForw", 0 , 0);
352  if (flag_limitStep) l_XshapeForw ->SetUserLimits(new G4UserLimits(stepMax));
353  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_XshapeForw, "p_XshapeForw", l_XshapeTiNForw , false, 0);
354 
355  //create far forward parts
356  // Alu trapezoid containing far parts
357  G4VSolid* AluCont_fpO = new G4Trd("AluCont_fpO", xcont2, xcont3, xcont1, xcont1, xpipePOS_hz / 2.0 * cos(A1));
358  G4VSolid* AluCont_fps = new G4Trd("AluCont_fps", xcont5, xcont4, xcont1, xcont1, xpipePOS_hz / 2.0 * cos(A1));
359  G4Transform3D transform_AluCont_fps = G4Translate3D(0., 0., 0.);
360  G4SubtractionSolid* AluCont_fp = new G4SubtractionSolid("AluCont_fp", AluCont_fpO, AluCont_fps, transform_AluCont_fps);
361  G4LogicalVolume* logi_AluCont_fp = new G4LogicalVolume(AluCont_fp, geometry::Materials::get(matPipe), "logi_AluCont_fp", 0 , 0);
362  new G4PVPlacement(0, G4ThreeVector(0, 0, pipe_hz + endcap_hz * 2.0 + xpipe_hz * cos(A2) + xpipePOS_hz / 2.0 * cos(A1)),
363  logi_AluCont_fp, "phys_AluCont_fp", &topVolume, false, 0);
364  //HER far forward part
365  //slanted tubes Vacuum
366  G4VSolid* s_XshapefPOS_11 = new G4Tubs("s_XshapefPOS11",
367  tubinR,
368  xpipe_innerRadius,
369  xpipePOS_hz,
370  startAngle, spanningAngle);
371  G4VSolid* s_XshapefPOS_12 = new G4Tubs("s_XshapefPOS12",
372  tubinR,
373  xpipe_innerRadius * 2,
374  xpipePOS_hz / 2. - 0.7568202457 * SafetyLength,
375  startAngle, spanningAngle);
376  G4Transform3D transform_sXshapefPOS_12 = G4Translate3D(0., 0., 0.);
377  transform_sXshapefPOS_12 = transform_sXshapefPOS_12 * G4RotateY3D(-A1);
378  G4IntersectionSolid* XshapefPOS1 = new G4IntersectionSolid("XshapefPOS1", s_XshapefPOS_11, s_XshapefPOS_12,
379  transform_sXshapefPOS_12);
380  //put HER vacuum part in AluCont_fp
381  G4LogicalVolume* l_XshapefPOS1 = new G4LogicalVolume(XshapefPOS1, geometry::Materials::get(vacPipe), "l_XshapefPOS1", 0 , 0);
382  if (flag_limitStep) l_XshapefPOS1 ->SetUserLimits(new G4UserLimits(stepMax));
383  G4RotationMatrix* yRotP = new G4RotationMatrix;
384  yRotP->rotateY(-A1);
385  new G4PVPlacement(yRotP, G4ThreeVector(2 * endcap_hz * tan(A2) + xpipe_hz * sin(A2) + xpipePOS_hz / 2.*sin(A1), 0., 0.),
386  l_XshapefPOS1 , "p_XshapefPOS1", logi_AluCont_fp, false, 0);
387  //LER far forward part
388  //slanted tubes TiN
389  G4VSolid* s_XshapefPOS_21 = new G4Tubs("s_XshapefPOS21",
390  tubinR,
391  xpipe_innerRadius,
392  xpipePOS_hz,
393  startAngle, spanningAngle);
394  G4VSolid* s_XshapefPOS_22 = new G4Tubs("s_XshapefPOS22",
395  tubinR,
396  xpipe_innerRadius * 2,
397  xpipePOS_hz / 2. - 0.7568202457 * SafetyLength,
398  startAngle, spanningAngle);
399  G4Transform3D transform_sXshapefPOS_22 = G4Translate3D(0., 0., 0.);
400  transform_sXshapefPOS_22 = transform_sXshapefPOS_22 * G4RotateY3D(A1);
401  G4IntersectionSolid* XshapefPOS2 = new G4IntersectionSolid("XshapefPOS2", s_XshapefPOS_21, s_XshapefPOS_22,
402  transform_sXshapefPOS_22);
403  //put HER TiN part in AluCont_fp
404  G4LogicalVolume* l_XshapefPOS2 = new G4LogicalVolume(XshapefPOS2, geometry::Materials::get(matTiN), "l_XshapefPOS2", 0 , 0);
405  G4RotationMatrix* yRotM = new G4RotationMatrix;
406  yRotM->rotateY(A1);
407  new G4PVPlacement(yRotM, G4ThreeVector(-(2 * endcap_hz * tan(A2) + xpipe_hz * sin(A2) + xpipePOS_hz / 2.*sin(A1)), 0., 0.),
408  l_XshapefPOS2 , "p_XshapefPOS2", logi_AluCont_fp, false, 0);
409  //slanted tubes Vacuum
410  G4VSolid* s_XshapefPOS_31 = new G4Tubs("s_XshapefPOS31",
411  tubinR,
412  xpipe_innerRadiusTiN,
413  xpipePOS_hz,
414  startAngle, spanningAngle);
415  G4VSolid* s_XshapefPOS_32 = new G4Tubs("s_XshapefPOS32",
416  tubinR,
417  xpipe_innerRadiusTiN * 2,
418  xpipePOS_hz / 2. - 0.7568202457 * SafetyLength,
419  startAngle, spanningAngle);
420  G4Transform3D transform_sXshapefPOS_32 = G4Translate3D(0., 0., 0.);
421  transform_sXshapefPOS_32 = transform_sXshapefPOS_32 * G4RotateY3D(A1);
422  G4IntersectionSolid* XshapefPOS3 = new G4IntersectionSolid("XshapefPOS3", s_XshapefPOS_31, s_XshapefPOS_32,
423  transform_sXshapefPOS_32);
424  //put HER vacuum part into l_XshapefPOS2
425  G4LogicalVolume* l_XshapefPOS3 = new G4LogicalVolume(XshapefPOS3, geometry::Materials::get(vacPipe), "l_XshapefPOS3", 0 , 0);
426  if (flag_limitStep) l_XshapefPOS3 ->SetUserLimits(new G4UserLimits(stepMax));
427  new G4PVPlacement(0, G4ThreeVector(0. , 0., 0.), l_XshapefPOS3 , "p_XshapefPOS3", l_XshapefPOS2, false, 0);
428 
429  // create x-shape tubes backward
430  // Alu trapezoid containing x-shape tube
431  G4VSolid* AluCont_b = new G4Trd("AluCont_b", xcont2, xcont1, xcont1, xcont1, xpipe_hz / 2.0 * cos(A2));
432  G4LogicalVolume* logi_AluCont_b = new G4LogicalVolume(AluCont_b, geometry::Materials::get(matPipe), "logi_AluCont_b", 0 , 0);
433  new G4PVPlacement(0, G4ThreeVector(0, 0, -pipe_hz - endcap_hz * 2.0 - xpipe_hz * cos(A2) / 2.), logi_AluCont_b, "phys_AluCont_b",
434  &topVolume, false, 1);
435  //cout << " logi_AluCont_b z = " << -pipe_hz - endcap_hz*2.0 - xpipe_hz*cos(A2)/2. << endl;
436  //cout << " logi_AluCont_b zmax = " << -pipe_hz - endcap_hz*2.0 - xpipe_hz*cos(A2) << endl;
437 
438  // create x part
439  G4VSolid* s_Xshapeb_11 = new G4Tubs("s_Xshapeb_11",
440  tubinR,
441  xpipe_innerRadiusTiN,
442  xpipe_hz,
443  startAngle, spanningAngle);
444  G4VSolid* s_Xshapeb_12 = new G4Tubs("s_Xshapeb_12",
445  tubinR,
446  xpipe_innerRadiusTiN * 2.0,
447  xpipe_hz / 2.0,
448  startAngle, spanningAngle);
449  G4VSolid* s_Xshapeb_21 = new G4Tubs("s_Xshapeb_21",
450  tubinR,
451  xpipe_innerRadius,
452  xpipe_hz,
453  startAngle, spanningAngle);
454  G4VSolid* s_Xshapeb_22 = new G4Tubs("s_Xshapeb_22",
455  tubinR,
456  xpipe_innerRadius * 2.0,
457  xpipe_hz / 2.0,
458  startAngle, spanningAngle);
459  //create TiN layer on
460  G4VSolid* s_XshapebTiN_11 = new G4Tubs("s_XshapebTiN_11",
461  tubinR,
462  xpipe_innerRadius,
463  xpipe_hz,
464  startAngle, spanningAngle);
465  G4VSolid* s_XshapebTiN_12 = new G4Tubs("s_XshapebTiN_12",
466  tubinR,
467  xpipe_innerRadius * 2.0,
468  xpipe_hz / 2.0,
469  startAngle, spanningAngle);
470  G4VSolid* s_XshapebTiN_21 = new G4Tubs("s_XshapebTiN_21",
471  tubinR,
472  xpipe_innerRadius,
473  xpipe_hz,
474  startAngle, spanningAngle);
475  G4VSolid* s_XshapebTiN_22 = new G4Tubs("s_XshapebTiN_22",
476  tubinR,
477  xpipe_innerRadius * 2.0,
478  xpipe_hz / 2.0,
479  startAngle, spanningAngle);
480  //Slanted tube1
481  G4Transform3D transform_sXshapeb_12 = G4Translate3D(0., 0., 0.);
482  transform_sXshapeb_12 = transform_sXshapeb_12 * G4RotateY3D(A2);
483  G4IntersectionSolid* Xshapeb1 = new G4IntersectionSolid("Xshapeb1", s_Xshapeb_11, s_Xshapeb_12, transform_sXshapeb_12);
484  //Slanted tube2
485  G4Transform3D transform_sXshapeb_22 = G4Translate3D(0., 0., 0.);
486  transform_sXshapeb_22 = transform_sXshapeb_22 * G4RotateY3D(-A2);
487  G4IntersectionSolid* Xshapeb2 = new G4IntersectionSolid("Xshapeb2", s_Xshapeb_21, s_Xshapeb_22, transform_sXshapeb_22);
488  //Slanted tube1TiN
489  G4Transform3D transform_sXshapebTiN_12 = G4Translate3D(0., 0., 0.);
490  transform_sXshapebTiN_12 = transform_sXshapebTiN_12 * G4RotateY3D(A2);
491  G4IntersectionSolid* XshapebTiN1 = new G4IntersectionSolid("XshapebTiN1", s_XshapebTiN_11, s_XshapebTiN_12,
492  transform_sXshapebTiN_12);
493  //Slanted tube2TiN
494  G4Transform3D transform_sXshapebTiN_22 = G4Translate3D(0., 0., 0.);
495  transform_sXshapebTiN_22 = transform_sXshapebTiN_22 * G4RotateY3D(-A2);
496  G4IntersectionSolid* XshapebTiN2 = new G4IntersectionSolid("XshapebTiN2", s_XshapebTiN_21, s_XshapebTiN_22,
497  transform_sXshapebTiN_22);
498 
499  // (sXshapeTiN2 + sXshapeTiN1)
500  G4Transform3D transform_XshapebTiN1 = G4Translate3D(dxtr, 0. , dztr);
501  //cout << "dxtr= " << dxtr << " dztr= " << dztr << endl;;
502  transform_XshapebTiN1 = transform_XshapebTiN1 * G4RotateY3D(-2.*A2);
503  G4UnionSolid* XshapeTiNBackwx = new G4UnionSolid("XshapeTiNBackwx", XshapebTiN2 , XshapebTiN1 , transform_XshapebTiN1);
504  // Place XshapeTiNBackwx into logi_AluCont_b
505  G4Transform3D transform_XshapeTiNBackwx = G4Translate3D(-dxtr / 2., 0., 0.);
506  transform_XshapeTiNBackwx = transform_XshapeTiNBackwx * G4RotateY3D(A2);
507  G4IntersectionSolid* XshapeTiNBackw = new G4IntersectionSolid("XshapeTiNBackw", AluCont_b, XshapeTiNBackwx,
508  transform_XshapeTiNBackwx);
509  G4LogicalVolume* l_XshapeTiNBackw = new G4LogicalVolume(XshapeTiNBackw, geometry::Materials::get(matTiN), "l_XshapeTiNBackw", 0 ,
510  0);
511  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_XshapeTiNBackw, "p_XshapeTiNBackw", logi_AluCont_b , false, 0);
512 
513  // sXshape2 + sXshape1
514  G4Transform3D transform_Xshapeb1 = G4Translate3D(dxtr, 0. , dztr);
515  transform_Xshapeb1 = transform_Xshapeb1 * G4RotateY3D(-2.*A2);
516  G4UnionSolid* XshapeBackwx = new G4UnionSolid("XshapebBackwx", Xshapeb2 , Xshapeb1 , transform_Xshapeb1);
517  G4Transform3D transform_XshapeBackwx = G4Translate3D(-dxtr / 2., 0., 0.);
518  transform_XshapeBackwx = transform_XshapeBackwx * G4RotateY3D(A2);
519  G4IntersectionSolid* XshapeBackw = new G4IntersectionSolid("XshapeBackw", AluCont_b, XshapeBackwx, transform_XshapeBackwx);
520  G4LogicalVolume* l_XshapeBackw = new G4LogicalVolume(XshapeBackw, geometry::Materials::get(vacPipe), "l_XshapeBackw", 0 , 0);
521  if (flag_limitStep) l_XshapeBackw->SetUserLimits(new G4UserLimits(stepMax));
522  // Place XshapeBackw
523  new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), l_XshapeBackw, "p_XshapeBackw", l_XshapeTiNBackw , false, 0);
524 
525  //create far backward parts
526  // Alu trapezoid containing far parts
527  G4VSolid* AluCont_bpO = new G4Trd("AluCont_bpO", xcont3M, xcont2, xcont1, xcont1, xpipeMIN_hz / 2.0 * cos(A1));
528  G4VSolid* AluCont_bps = new G4Trd("AluCont_bps", xcont4M, xcont5, xcont1, xcont1, xpipeMIN_hz / 2.0 * cos(A1));
529  G4Transform3D transform_AluCont_bps = G4Translate3D(0., 0., 0.);
530  G4SubtractionSolid* AluCont_bp = new G4SubtractionSolid("AluCont_bp", AluCont_bpO, AluCont_bps, transform_AluCont_bps);
531  G4LogicalVolume* logi_AluCont_bp = new G4LogicalVolume(AluCont_bp, geometry::Materials::get(matPipe), "logi_AluCont_bp", 0 , 0);
532  new G4PVPlacement(0, G4ThreeVector(0, 0, -(pipe_hz + endcap_hz * 2.0 + xpipe_hz * cos(A2) + xpipeMIN_hz / 2.0 * cos(A1))),
533  logi_AluCont_bp, "phys_AluCont_bp", &topVolume, false, 0);
534  //HER far backward part
535  //slanted tubes Vacuum
536  G4VSolid* s_XshapebMIN_11 = new G4Tubs("s_XshapebMIN11",
537  tubinR,
538  xpipe_innerRadius,
539  xpipeMIN_hz,
540  startAngle, spanningAngle);
541  G4VSolid* s_XshapebMIN_12 = new G4Tubs("s_XshapebMIN12",
542  tubinR,
543  xpipe_innerRadius * 2,
544  xpipeMIN_hz / 2. - 0.525641366 * SafetyLength,
545  startAngle, spanningAngle);
546  G4Transform3D transform_sXshapebMIN_12 = G4Translate3D(0., 0., 0.);
547  transform_sXshapebMIN_12 = transform_sXshapebMIN_12 * G4RotateY3D(-A1);
548  G4IntersectionSolid* XshapebMIN1 = new G4IntersectionSolid("XshapebMIN1", s_XshapebMIN_11, s_XshapebMIN_12,
549  transform_sXshapebMIN_12);
550  //put HER vacuum part in AluCont_bp
551  G4LogicalVolume* l_XshapebMIN1 = new G4LogicalVolume(XshapebMIN1, geometry::Materials::get(vacPipe), "l_XshapebMIN1", 0 , 0);
552  if (flag_limitStep) l_XshapebMIN1 ->SetUserLimits(new G4UserLimits(stepMax));
553  new G4PVPlacement(yRotP, G4ThreeVector(-(2 * endcap_hz * tan(A2) + xpipe_hz * sin(A2) + xpipeMIN_hz / 2.*sin(A1)), 0., 0.),
554  l_XshapebMIN1 , "p_XshapebMIN1", logi_AluCont_bp, false, 0);
555  //LER far backward part
556  //slanted tubes TiN
557  G4VSolid* s_XshapebMIN_21 = new G4Tubs("s_XshapebMIN21",
558  tubinR,
559  xpipe_innerRadius,
560  xpipeMIN_hz,
561  startAngle, spanningAngle);
562  G4VSolid* s_XshapebMIN_22 = new G4Tubs("s_XshapebMIN22",
563  tubinR,
564  xpipe_innerRadius * 2,
565  xpipeMIN_hz / 2. - 0.525641366 * SafetyLength,
566  startAngle, spanningAngle);
567  G4Transform3D transform_sXshapebMIN_22 = G4Translate3D(0., 0., 0.);
568  transform_sXshapebMIN_22 = transform_sXshapebMIN_22 * G4RotateY3D(A1);
569  G4IntersectionSolid* XshapebMIN2 = new G4IntersectionSolid("XshapebMIN2", s_XshapebMIN_21, s_XshapebMIN_22,
570  transform_sXshapebMIN_22);
571  //put HER TiN part in AluCont_bp
572  G4LogicalVolume* l_XshapebMIN2 = new G4LogicalVolume(XshapebMIN2, geometry::Materials::get(matTiN), "l_XshapebMIN2", 0 , 0);
573  new G4PVPlacement(yRotM, G4ThreeVector(2 * endcap_hz * tan(A2) + xpipe_hz * sin(A2) + xpipeMIN_hz / 2.*sin(A1), 0., 0.),
574  l_XshapebMIN2 , "p_XshapebMIN2", logi_AluCont_bp, false, 0);
575  //slanted tubes Vacuum
576  G4VSolid* s_XshapebMIN_31 = new G4Tubs("s_XshapebMIN31",
577  tubinR,
578  xpipe_innerRadiusTiN,
579  xpipeMIN_hz,
580  startAngle, spanningAngle);
581  G4VSolid* s_XshapebMIN_32 = new G4Tubs("s_XshapebMIN32",
582  tubinR,
583  xpipe_innerRadiusTiN * 2,
584  xpipeMIN_hz / 2. - 0.525641366 * SafetyLength,
585  startAngle, spanningAngle);
586  G4Transform3D transform_sXshapebMIN_32 = G4Translate3D(0., 0., 0.);
587  transform_sXshapebMIN_32 = transform_sXshapebMIN_32 * G4RotateY3D(A1);
588  G4IntersectionSolid* XshapebMIN3 = new G4IntersectionSolid("XshapebMIN3", s_XshapebMIN_31, s_XshapebMIN_32,
589  transform_sXshapebMIN_32);
590  //put HER vacuum part in AluCont_bp
591  G4LogicalVolume* l_XshapebMIN3 = new G4LogicalVolume(XshapebMIN3, geometry::Materials::get(vacPipe), "l_XshapebMIN3", 0 , 0);
592  if (flag_limitStep) l_XshapebMIN3 ->SetUserLimits(new G4UserLimits(stepMax));
593  new G4PVPlacement(0, G4ThreeVector(0. , 0., 0.), l_XshapebMIN3 , "p_XshapebMIN3", l_XshapebMIN2, false, 0);
594 
595  }
596  } // ph1bpipe namespace
598 } // Belle2 namespace
Belle2::geometry::Materials::get
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:65
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::GearDir
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:41
Belle2::ph1bpipe::Ph1bpipeFactory
geometry::CreatorFactory< Ph1bpipeCreator > Ph1bpipeFactory("PH1BPIPECreator")
Creator creates the phase 1 beam pipe for |s| < 4 m geometry.
Belle2::ph1bpipe::Ph1bpipeCreator::m_sensitive
SensitiveDetector * m_sensitive
SensitiveDetector phase 1 beam pipe.
Definition: Ph1bpipeCreator.h:36
Belle2::ph1bpipe::Ph1bpipeCreator::create
virtual void create(const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
Function to actually create the geometry, has to be overridden by derived classes.
Definition: Ph1bpipeCreator.cc:63
Belle2::PXD::SensitiveDetector
VXD::SensitiveDetector< PXDSimHit, PXDTrueHit > SensitiveDetector
The PXD Sensitive Detector class.
Definition: SensitiveDetector.h:36
Belle2::geometry::GeometryTypes
GeometryTypes
Flag indiciating the type of geometry to be used.
Definition: GeometryManager.h:39