Create detector geometry.
72 {
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150 double stepMax = 5.0 * Unit::mm;
151 int flag_limitStep = int(m_config.getParameter("LimitStepLength"));
152
153 const double unitFactor = Unit::cm / Unit::mm;
154
155 double crossingAngleHER = m_config.getParameter("CrossingAngle.HER", 0.0415);
156 double crossingAngleLER = m_config.getParameter("CrossingAngle.LER", -0.0415);
157
158 G4Transform3D transform_HER = G4Translate3D(0., 0., 0.);
159 transform_HER = transform_HER * G4RotateY3D(crossingAngleHER);
160
161 G4Transform3D transform_LER = G4Translate3D(0., 0., 0.);
162 transform_LER = transform_LER * G4RotateY3D(crossingAngleLER);
163
164 map<string, CryostatElement> elements;
165
166
167
168
169
170
171
172
173 CryostatElement tubeR;
174 std::string prep = "TubeR.";
175
176 const int TubeR_N = int(m_config.getParameter(prep + "N"));
177
178 std::vector<double> TubeR_Z(TubeR_N);
179 std::vector<double> TubeR_R(TubeR_N);
180 std::vector<double> TubeR_r(TubeR_N);
181
182 for (int i = 0; i < TubeR_N; ++i) {
183 ostringstream ossZID;
184 ossZID << "Z" << i;
185
186 ostringstream ossRID;
187 ossRID << "R" << i;
188
189 ostringstream ossrID;
190 ossrID << "r" << i;
191
192 TubeR_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
193 TubeR_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
194 TubeR_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
195 }
196
197 tubeR.transform = G4Translate3D(0., 0., 0.);
198 tubeR.geo = new G4Polycone("geo_TubeR_name", 0, 2 * M_PI, TubeR_N, &(TubeR_Z[0]), &(TubeR_r[0]), &(TubeR_R[0]));
199 tubeR.logi = NULL;
200 elements["TubeR"] = tubeR;
201
202
203 CryostatElement tubeR2;
204 prep = "TubeR2.";
205 const int TubeR2_N = int(m_config.getParameter(prep + "N"));
206
207 std::vector<double> TubeR2_Z(TubeR2_N);
208 std::vector<double> TubeR2_R(TubeR2_N);
209 std::vector<double> TubeR2_r(TubeR2_N);
210
211 for (int i = 0; i < TubeR2_N; ++i) {
212 ostringstream ossZID;
213 ossZID << "Z" << i;
214
215 ostringstream ossRID;
216 ossRID << "R" << i;
217
218 ostringstream ossrID;
219 ossrID << "r" << i;
220
221 TubeR2_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
222 TubeR2_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
223 TubeR2_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
224 }
225
226 tubeR2.transform = G4Translate3D(0., 0., 0.);
227 tubeR2.geo = new G4Polycone("geo_TubeR2_name", 0, 2 * M_PI, TubeR2_N, &(TubeR2_Z[0]), &(TubeR2_r[0]), &(TubeR2_R[0]));
228 tubeR2.logi = NULL;
229 elements["TubeR2"] = tubeR2;
230
231
232 CryostatElement tubeL;
233 prep = "TubeL.";
234 const int TubeL_N = int(m_config.getParameter(prep + "N"));
235
236 std::vector<double> TubeL_Z(TubeL_N);
237 std::vector<double> TubeL_R(TubeL_N);
238 std::vector<double> TubeL_r(TubeL_N);
239
240 for (int i = 0; i < TubeL_N; ++i) {
241 ostringstream ossZID;
242 ossZID << "Z" << i;
243
244 ostringstream ossRID;
245 ossRID << "R" << i;
246
247 ostringstream ossrID;
248 ossrID << "r" << i;
249
250 TubeL_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
251 TubeL_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
252 TubeL_r[i] = m_config.getParameter(prep + ossrID.str()) * unitFactor;
253 }
254
255 tubeL.transform = G4Translate3D(0., 0., 0.);
256 tubeL.geo = new G4Polycone("geo_TubeL_name", 0, 2 * M_PI, TubeL_N, &(TubeL_Z[0]), &(TubeL_r[0]), &(TubeL_R[0]));
257 tubeL.logi = NULL;
258 elements["TubeL"] = tubeL;
259
260
261
262
263
264
265
266
267 CryostatElement A1spc1;
268 prep = "A1spc1.";
269 const int A1spc1_N = int(m_config.getParameter(prep + "N"));
270
271 std::vector<double> A1spc1_Z(A1spc1_N);
272 std::vector<double> A1spc1_r(A1spc1_N);
273 std::vector<double> A1spc1_R(A1spc1_N);
274
275 for (int i = 0; i < A1spc1_N; ++i) {
276 ostringstream ossZID;
277 ossZID << "Z" << i;
278
279 ostringstream ossRID;
280 ossRID << "R" << i;
281
282 ostringstream ossrID;
283 ossrID << "r" << i;
284
285 A1spc1_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
286 A1spc1_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
287 A1spc1_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
288 }
289
290 A1spc1.transform = transform_HER;
291 G4Polycone* geo_A1spc1xx = new G4Polycone("geo_A1spc1xx_name", 0, 2 * M_PI, A1spc1_N, &(A1spc1_Z[0]), &(A1spc1_r[0]),
292 &(A1spc1_R[0]));
293
294
295 CryostatElement A1spc2;
296 prep = "A1spc2.";
297 const int A1spc2_N = int(m_config.getParameter(prep + "N"));
298
299 std::vector<double> A1spc2_Z(A1spc2_N);
300 std::vector<double> A1spc2_R(A1spc2_N);
301 std::vector<double> A1spc2_r(A1spc2_N);
302
303 for (int i = 0; i < A1spc2_N; ++i) {
304 ostringstream ossZID;
305 ossZID << "Z" << i;
306
307 ostringstream ossRID;
308 ossRID << "R" << i;
309
310 ostringstream ossrID;
311 ossrID << "r" << i;
312
313 A1spc2_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
314 A1spc2_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
315 A1spc2_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
316 }
317
318 A1spc2.transform = transform_HER;
319 G4Polycone* geo_A1spc2xx = new G4Polycone("geo_A1spc2xx_name", 0, 2 * M_PI, A1spc2_N, &(A1spc2_Z[0]), &(A1spc2_r[0]),
320 &(A1spc2_R[0]));
321
322
323 CryostatElement B1spc1;
324 prep = "B1spc1.";
325 const int B1spc1_N = int(m_config.getParameter(prep + "N"));
326
327 std::vector<double> B1spc1_Z(B1spc1_N);
328 std::vector<double> B1spc1_R(B1spc1_N);
329 std::vector<double> B1spc1_r(B1spc1_N);
330
331 for (int i = 0; i < B1spc1_N; ++i) {
332 ostringstream ossZID;
333 ossZID << "Z" << i;
334
335 ostringstream ossRID;
336 ossRID << "R" << i;
337
338 ostringstream ossrID;
339 ossrID << "r" << i;
340
341 B1spc1_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
342 B1spc1_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
343 B1spc1_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
344 }
345
346 B1spc1.transform = transform_LER;
347 G4Polycone* geo_B1spc1xx = new G4Polycone("geo_B1spc1xx_name", 0, 2 * M_PI, B1spc1_N, &(B1spc1_Z[0]), &(B1spc1_r[0]),
348 &(B1spc1_R[0]));
349
350
351 CryostatElement B1spc2;
352 prep = "B1spc2.";
353 const int B1spc2_N = int(m_config.getParameter(prep + "N"));
354
355 std::vector<double> B1spc2_Z(B1spc2_N);
356 std::vector<double> B1spc2_R(B1spc2_N);
357 std::vector<double> B1spc2_r(B1spc2_N);
358
359 for (int i = 0; i < B1spc2_N; ++i) {
360 ostringstream ossZID;
361 ossZID << "Z" << i;
362
363 ostringstream ossRID;
364 ossRID << "R" << i;
365
366 ostringstream ossrID;
367 ossrID << "r" << i;
368
369 B1spc2_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
370 B1spc2_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
371 B1spc2_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
372 }
373
374 B1spc2.transform = transform_LER;
375 G4Polycone* geo_B1spc2xx = new G4Polycone("geo_B1spc2xx_name", 0, 2 * M_PI, B1spc2_N, &(B1spc2_Z[0]), &(B1spc2_r[0]),
376 &(B1spc2_R[0]));
377
378
379 B1spc2.geo = new G4IntersectionSolid("geo_B1spc2_name", geo_B1spc2xx, elements["TubeR2"].geo, B1spc2.transform.inverse());
380 B1spc2.logi = NULL;
381
382 G4IntersectionSolid* geo_B1spc1x = new G4IntersectionSolid("geo_B1spc1x_name", geo_B1spc1xx, elements["TubeR"].geo,
383 B1spc1.transform.inverse());
384 B1spc1.geo = new G4UnionSolid("geo_B1spc1_name", geo_B1spc1x, B1spc2.geo);
385
386 A1spc2.geo = new G4IntersectionSolid("geo_A1spc2_name", geo_A1spc2xx, elements["TubeR2"].geo, A1spc2.transform.inverse());
387 A1spc2.logi = NULL;
388
389 G4IntersectionSolid* geo_A1spc1xy = new G4IntersectionSolid("geo_A1spc1xy_name", geo_A1spc1xx, elements["TubeR"].geo,
390 A1spc1.transform.inverse());
391 G4UnionSolid* geo_A1spc1x = new G4UnionSolid("geo_A1spc1x_name", geo_A1spc1xy, A1spc2.geo);
392 A1spc1.geo = new G4SubtractionSolid("geo_A1spc1_name", geo_A1spc1x, B1spc1.geo, A1spc1.transform.inverse()*B1spc1.transform);
393
394 string strMat_A1spc1 = m_config.getParameterStr("A1spc1.Material");
395 G4Material* mat_A1spc1 = Materials::get(strMat_A1spc1);
396 A1spc1.logi = new G4LogicalVolume(A1spc1.geo, mat_A1spc1, "logi_A1spc1_name");
397 if (flag_limitStep)
398 A1spc1.logi->SetUserLimits(new G4UserLimits(stepMax));
399
400
402
403 new G4PVPlacement(A1spc1.transform, A1spc1.logi, "phys_A1spc1_name", &topVolume, false, 0);
404
405 string strMat_B1spc1 = m_config.getParameterStr("B1spc1.Material");
406 G4Material* mat_B1spc1 = Materials::get(strMat_B1spc1);
407 B1spc1.logi = new G4LogicalVolume(B1spc1.geo, mat_B1spc1, "logi_B1spc1_name");
408 if (flag_limitStep)
409 B1spc1.logi->SetUserLimits(new G4UserLimits(stepMax));
410
411
413
414 new G4PVPlacement(B1spc1.transform, B1spc1.logi, "phys_B1spc1_name", &topVolume, false, 0);
415
416 elements["A1spc1"] = A1spc1;
417 elements["A1spc2"] = A1spc2;
418 elements["B1spc1"] = B1spc1;
419 elements["B1spc2"] = B1spc2;
420
421
422
423
424
425 CryostatElement C1wal1;
426 prep = "C1wal1.";
427 const int C1wal1_N = m_config.getParameter(prep + "N");
428
429 std::vector<double> C1wal1_Z(C1wal1_N);
430 std::vector<double> C1wal1_R(C1wal1_N);
431 std::vector<double> C1wal1_r(C1wal1_N);
432
433 for (int i = 0; i < C1wal1_N; ++i) {
434 ostringstream ossZID;
435 ossZID << "Z" << i;
436
437 ostringstream ossRID;
438 ossRID << "R" << i;
439
440 ostringstream ossrID;
441 ossrID << "r" << i;
442
443 C1wal1_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
444 C1wal1_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
445 C1wal1_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
446 }
447
448 C1wal1.transform = G4Translate3D(0., 0., 0.);
449
450
451 G4Polycone* geo_C1wal1xxx = new G4Polycone("geo_C1wal1xxx_name", 0, 2 * M_PI, C1wal1_N, &(C1wal1_Z[0]), &(C1wal1_r[0]),
452 &(C1wal1_R[0]));
453 G4IntersectionSolid* geo_C1wal1xx = new G4IntersectionSolid("geo_C1wal1xx_name", geo_C1wal1xxx, elements["TubeR"].geo,
454 elements["TubeR"].transform);
455 G4SubtractionSolid* geo_C1wal1x = new G4SubtractionSolid("geo_C1wal1x_name", geo_C1wal1xx, elements["A1spc1"].geo,
456 elements["A1spc1"].transform);
457 C1wal1.geo = new G4SubtractionSolid("geo_C1wal1_name", geo_C1wal1x, elements["B1spc1"].geo, elements["B1spc1"].transform);
458
459 string strMat_C1wal1 = m_config.getParameterStr(prep + "Material");
460 G4Material* mat_C1wal1 = Materials::get(strMat_C1wal1);
461 C1wal1.logi = new G4LogicalVolume(C1wal1.geo, mat_C1wal1, "logi_C1wal1_name");
462
463
465
466 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), C1wal1.logi, "phys_C1wal1_name", &topVolume, false, 0);
467
468 elements["C1wal1"] = C1wal1;
469
470
471
472
473
474 CryostatElement D1spc1;
475 prep = "D1spc1.";
476 const int D1spc1_N = m_config.getParameter(prep + "N");
477
478 std::vector<double> D1spc1_Z(D1spc1_N);
479 std::vector<double> D1spc1_r(D1spc1_N);
480 std::vector<double> D1spc1_R(D1spc1_N);
481
482 for (int i = 0; i < D1spc1_N; ++i) {
483 ostringstream ossZID;
484 ossZID << "Z" << i;
485
486 ostringstream ossRID;
487 ossRID << "R" << i;
488
489 ostringstream ossrID;
490 ossrID << "r" << i;
491
492 D1spc1_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
493 D1spc1_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
494 D1spc1_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
495 }
496
497 D1spc1.transform = transform_HER;
498 G4Polycone* geo_D1spc1xx = new G4Polycone("geo_D1spc1xx_name", 0, 2 * M_PI, D1spc1_N, &(D1spc1_Z[0]), &(D1spc1_r[0]),
499 &(D1spc1_R[0]));
500
501
502 CryostatElement E1spc1;
503 prep = "E1spc1.";
504 const int E1spc1_N = int(m_config.getParameter(prep + "N"));
505
506 std::vector<double> E1spc1_Z(E1spc1_N);
507 std::vector<double> E1spc1_R(E1spc1_N);
508 std::vector<double> E1spc1_r(E1spc1_N);
509
510 for (int i = 0; i < E1spc1_N; ++i) {
511 ostringstream ossZID;
512 ossZID << "Z" << i;
513
514 ostringstream ossRID;
515 ossRID << "R" << i;
516
517 ostringstream ossrID;
518 ossrID << "r" << i;
519
520 E1spc1_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
521 E1spc1_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
522 E1spc1_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
523 }
524
525 E1spc1.transform = transform_LER;
526 G4Polycone* geo_E1spc1xx = new G4Polycone("geo_E1spc1xx_name", 0, 2 * M_PI, E1spc1_N, &(E1spc1_Z[0]), &(E1spc1_r[0]),
527 &(E1spc1_R[0]));
528
529
530 G4IntersectionSolid* geo_D1spc1x = new G4IntersectionSolid("geo_D1spc1x_name", geo_D1spc1xx, elements["TubeL"].geo,
531 D1spc1.transform.inverse());
532 E1spc1.geo = new G4IntersectionSolid("geo_E1spc1_name", geo_E1spc1xx, elements["TubeL"].geo, E1spc1.transform.inverse());
533 D1spc1.geo = new G4SubtractionSolid("geo_D1spc1_name", geo_D1spc1x, E1spc1.geo, D1spc1.transform.inverse()*E1spc1.transform);
534
535 string strMat_D1spc1 = m_config.getParameterStr("D1spc1.Material");
536 G4Material* mat_D1spc1 = Materials::get(strMat_D1spc1);
537 D1spc1.logi = new G4LogicalVolume(D1spc1.geo, mat_D1spc1, "logi_D1spc1_name");
538 if (flag_limitStep)
539 D1spc1.logi->SetUserLimits(new G4UserLimits(stepMax));
540
541
543
544 new G4PVPlacement(D1spc1.transform, D1spc1.logi, "phys_D1spc1_name", &topVolume, false, 0);
545
546 string strMat_E1spc1 = m_config.getParameterStr(prep + "Material");
547 G4Material* mat_E1spc1 = Materials::get(strMat_E1spc1);
548 E1spc1.logi = new G4LogicalVolume(E1spc1.geo, mat_E1spc1, "logi_E1spc1_name");
549 if (flag_limitStep)
550 E1spc1.logi->SetUserLimits(new G4UserLimits(stepMax));
551
552
554
555 new G4PVPlacement(E1spc1.transform, E1spc1.logi, "phys_E1spc1_name", &topVolume, false, 0);
556
557 elements["E1spc1"] = E1spc1;
558 elements["D1spc1"] = D1spc1;
559
560
561
562
563
564
565 CryostatElement F1wal1;
566 prep = "F1wal1.";
567 const int F1wal1_N = int(m_config.getParameter(prep + "N"));
568
569 std::vector<double> F1wal1_Z(F1wal1_N);
570 std::vector<double> F1wal1_R(F1wal1_N);
571 std::vector<double> F1wal1_r(F1wal1_N);
572
573 for (int i = 0; i < F1wal1_N; ++i) {
574 ostringstream ossZID;
575 ossZID << "Z" << i;
576
577 ostringstream ossRID;
578 ossRID << "R" << i;
579
580 ostringstream ossrID;
581 ossrID << "r" << i;
582
583 F1wal1_Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
584 F1wal1_R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
585 F1wal1_r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
586 }
587
588 F1wal1.transform = G4Translate3D(0., 0., 0.);
589
590
591 G4Polycone* geo_F1wal1xxx = new G4Polycone("geo_F1wal1xxx_name", 0, 2 * M_PI, F1wal1_N, &(F1wal1_Z[0]), &(F1wal1_r[0]),
592 &(F1wal1_R[0]));
593 G4IntersectionSolid* geo_F1wal1xx = new G4IntersectionSolid("geo_F1wal1xx_name", geo_F1wal1xxx, elements["TubeL"].geo,
594 elements["TubeL"].transform);
595 G4SubtractionSolid* geo_F1wal1x = new G4SubtractionSolid("geo_F1wal1x_name", geo_F1wal1xx, elements["D1spc1"].geo,
596 elements["D1spc1"].transform);
597 F1wal1.geo = new G4SubtractionSolid("geo_F1wal1_name", geo_F1wal1x, elements["E1spc1"].geo, elements["E1spc1"].transform);
598
599 string strMat_F1wal1 = m_config.getParameterStr(prep + "Material");
600 G4Material* mat_F1wal1 = Materials::get(strMat_F1wal1);
601 F1wal1.logi = new G4LogicalVolume(F1wal1.geo, mat_F1wal1, "logi_F1wal1_name");
602
603
605
606 new G4PVPlacement(F1wal1.transform, F1wal1.logi, "phys_F1wal1_name", &topVolume, false, 0);
607
608 elements["F1wal1"] = F1wal1;
609
610
611
612
613
614 std::vector<std::string> supports;
615 boost::split(supports, m_config.getParameterStr("Support"), boost::is_any_of(" "));
616 for (const auto& name : supports) {
617
618 CryostatElement sup;
619 prep = name + ".";
620
621 double box_W = m_config.getParameter(prep + "W") * unitFactor;
622 double box_H = m_config.getParameter(prep + "H") * unitFactor;
623 double box_L = m_config.getParameter(prep + "L") * unitFactor;
624 double box_X0 = m_config.getParameter(prep + "X0") * unitFactor;
625 double box_Y0 = m_config.getParameter(prep + "Y0") * unitFactor;
626 double box_Z0 = m_config.getParameter(prep + "Z0") * unitFactor;
627
628 double trd_W1 = m_config.getParameter(prep + "trdW1") * unitFactor;
629 double trd_W2 = m_config.getParameter(prep + "trdW2") * unitFactor;
630 double trd_L = m_config.getParameter(prep + "trdL") * unitFactor;
631 double trd_H = m_config.getParameter(prep + "trdH") * unitFactor;
632 double trd_X0 = m_config.getParameter(prep + "trdX0") * unitFactor;
633 double trd_Y0 = m_config.getParameter(prep + "trdY0") * unitFactor;
634 double trd_Z0 = m_config.getParameter(prep + "trdZ0") * unitFactor;
635
636 double sup_PHI = m_config.getParameter(prep + "PHI");
637
638 int sup_cut_N = int(m_config.getParameter(prep + "N", 0));
639
640
641 G4Transform3D transform_box = G4Translate3D(box_X0, box_Y0, box_Z0);
642 transform_box = transform_box * G4RotateY3D(sup_PHI / Unit::rad);
643
644 G4Transform3D transform_trd = G4Translate3D(trd_X0, trd_Y0, trd_Z0);
645 transform_trd = transform_trd * G4RotateY3D(sup_PHI / Unit::rad) * G4RotateX3D(M_PI / 2.0 / Unit::rad);
646
647
648 string geo_box_name = "geo_" + name + "_box_name";
649 string geo_trd_name = "geo_" + name + "_trd_name";
650
651 string geo_sup_name;
652 if (sup_cut_N == 0) {
653 geo_sup_name = "geo_" + name + "_name";
654 } else {
655 geo_sup_name = "geo_" + name + "_x_name";
656 }
657
658 G4Box* geo_box = new G4Box(geo_box_name, box_W / 2.0, box_H / 2.0, box_L / 2.0);
659 G4Trd* geo_trd = new G4Trd(geo_trd_name, trd_W1 / 2.0, trd_W2 / 2.0, trd_L / 2.0, trd_L / 2.0, trd_H / 2.0);
660
661 G4VSolid* geo_sup = new G4UnionSolid(geo_sup_name, geo_box, geo_trd, transform_box.inverse() * transform_trd);
662
663
664 for (int i = 0; i < sup_cut_N; ++i) {
665 ostringstream oss_block_num;
666 oss_block_num << i;
667
668 double cut_type = m_config.getParameter(prep + "cutType" + oss_block_num.str());
669 if (i == sup_cut_N - 1) {
670 geo_sup_name = "geo_" + name + "_name";
671 } else {
672 geo_sup_name = "geo_" + name + "_x" + oss_block_num.str() + "_name";
673 }
674 string geo_cut_name = "geo_" + name + "_cut" + oss_block_num.str() + "_name";
675
676 G4VSolid* geo_cut;
677
678 if (cut_type == 0.0) {
679 double cut_L = m_config.getParameter(prep + "cutL" + oss_block_num.str()) * unitFactor;
680 double cut_W = m_config.getParameter(prep + "cutW" + oss_block_num.str()) * unitFactor;
681 double cut_H = m_config.getParameter(prep + "cutH" + oss_block_num.str()) * unitFactor;
682
683 geo_cut = new G4Box(geo_cut_name, cut_W / 2.0, cut_H / 2.0, cut_L / 2.0);
684 } else {
685 double cut_L = m_config.getParameter(prep + "cutL" + oss_block_num.str()) * unitFactor;
686 double cut_R = m_config.getParameter(prep + "cutR" + oss_block_num.str()) * unitFactor;
687
688 geo_cut = new G4Tubs(geo_cut_name, 0.0, cut_R, cut_L / 2.0, 0.0, 2.0 * M_PI);
689 }
690
691 double cut_X0 = m_config.getParameter(prep + "cutDX" + oss_block_num.str()) * unitFactor;
692 double cut_Y0 = m_config.getParameter(prep + "cutDY" + oss_block_num.str()) * unitFactor;
693 double cut_Z0 = m_config.getParameter(prep + "cutDZ" + oss_block_num.str()) * unitFactor;
694 double cut_PHI = m_config.getParameter(prep + "cutPHI" + oss_block_num.str(), 0.0);
695 double cut_TH = m_config.getParameter(prep + "cutTH" + oss_block_num.str(), 0.0);
696
697 G4Transform3D cut_transform = G4Translate3D(cut_X0, cut_Y0, cut_Z0);
698 cut_transform = cut_transform * G4RotateX3D(cut_PHI / Unit::rad);
699 cut_transform = cut_transform * G4RotateZ3D(cut_TH / Unit::rad);
700
701 geo_sup = new G4SubtractionSolid(geo_sup_name, geo_sup, geo_cut, cut_transform);
702 }
703
704 sup.geo = geo_sup;
705 sup.transform = transform_box;
706
707 string strMat_sup = m_config.getParameterStr(prep + "Material");
708 G4Material* mat_sup = Materials::get(strMat_sup);
709
710 string logi_sup_name = "logi_" + name + "_name";
711 G4LogicalVolume* logi_sup = new G4LogicalVolume(sup.geo, mat_sup, logi_sup_name);
712
713 sup.logi = logi_sup;
714
715
717
718 string phys_sup_name = "phys_" + name + "_name";
719 new G4PVPlacement(sup.transform, sup.logi, phys_sup_name, &topVolume, false, 0);
720
721 elements[name] = sup;
722 }
723
724
725
726 prep = "BellowsShield.";
727 double BS_fwdZ0 = m_config.getParameter(prep + "fwdZ0") * unitFactor;
728 double BS_fwdZ1 = m_config.getParameter(prep + "fwdZ1") * unitFactor;
729 double BS_fwdZ2 = m_config.getParameter(prep + "fwdZ2") * unitFactor;
730 double BS_fwdZ3 = m_config.getParameter(prep + "fwdZ3") * unitFactor;
731 double BS_fwdZ4 = m_config.getParameter(prep + "fwdZ4") * unitFactor;
732 double BS_bwdZ0 = m_config.getParameter(prep + "bwdZ0") * unitFactor;
733 double BS_bwdZ1 = m_config.getParameter(prep + "bwdZ1") * unitFactor;
734 double BS_bwdZ2 = m_config.getParameter(prep + "bwdZ2") * unitFactor;
735 double BS_bwdZ3 = m_config.getParameter(prep + "bwdZ3") * unitFactor;
736
737
738 string strMat_BS = m_config.getParameterStr(prep + "Material");
739 G4Material* mat_BS = Materials::get(strMat_BS);
740
741
742 double BS_fwdP0_R = m_config.getParameter(prep + "fwdP0_R") * unitFactor;
743 double BS_fwdP0_Yout = m_config.getParameter(prep + "fwdP0_Yout") * unitFactor;
744 double BS_fwdP0_Yin = m_config.getParameter(prep + "fwdP0_Yin") * unitFactor;
745 double BS_fwdP0_Xin = m_config.getParameter(prep + "fwdP0_Xin") * unitFactor;
746 double BS_fwdP0_Yedge = m_config.getParameter(prep + "fwdP0_Yedge") * unitFactor;
747 double BS_fwdP0_Xedge = m_config.getParameter(prep + "fwdP0_Xedge") * unitFactor;
748 double BS_fwdP0_Yside = m_config.getParameter(prep + "fwdP0_Yside") * unitFactor;
749 double BS_fwdP0_Xside = m_config.getParameter(prep + "fwdP0_Xside") * unitFactor;
750
751 double BS_fwdP0_DHalf = (BS_fwdZ2 - BS_fwdZ0) / 2;
752 G4VSolid* geo_BS_fwdP0_B0 = new G4Tubs("geo_BS_fwdP0_B0", 0, BS_fwdP0_R, BS_fwdP0_DHalf, 0, 2 * M_PI);
753 G4Transform3D tfm_BS_fwdP0_B0 = G4Translate3D(0, 0, BS_fwdP0_DHalf);
754
755 G4VSolid* geo_BS_fwdP0_V0T = new G4Tubs("geo_BS_fwdP0_V0T", 0, BS_fwdP0_Yin, BS_fwdP0_DHalf, 0.25 * M_PI, 0.5 * M_PI);
756 G4VSolid* geo_BS_fwdP0_V0B = new G4Tubs("geo_BS_fwdP0_V0B", 0, BS_fwdP0_Yin, BS_fwdP0_DHalf, 1.25 * M_PI, 0.5 * M_PI);
757 G4Transform3D tfm_BS_fwdP0_V0L = G4Translate3D(-BS_fwdP0_Xin, 0, BS_fwdP0_DHalf);
758 G4Transform3D tfm_BS_fwdP0_V0R = G4Translate3D(+BS_fwdP0_Xin, 0, BS_fwdP0_DHalf);
759
760 G4VSolid* geo_BS_fwdP0_V1 = new G4Box("geo_BS_fwdP0_V1", BS_fwdP0_Xside, BS_fwdP0_Yedge, BS_fwdP0_DHalf);
761 G4Transform3D tfm_BS_fwdP0_V1 = G4Translate3D(0, 0, BS_fwdP0_DHalf);
762
763 G4VSolid* geo_BS_fwdP0_V2 = new G4Box("geo_BS_fwdP0_V2", 100, 100, BS_fwdP0_DHalf);
764 G4Transform3D tfm_BS_fwdP0_V2TR = G4Translate3D(+(100 + BS_fwdP0_Xedge), +(100 + BS_fwdP0_Yside), BS_fwdP0_DHalf);
765 G4Transform3D tfm_BS_fwdP0_V2TL = G4Translate3D(-(100 + BS_fwdP0_Xedge), +(100 + BS_fwdP0_Yside), BS_fwdP0_DHalf);
766 G4Transform3D tfm_BS_fwdP0_V2BR = G4Translate3D(+(100 + BS_fwdP0_Xedge), -(100 + BS_fwdP0_Yside), BS_fwdP0_DHalf);
767 G4Transform3D tfm_BS_fwdP0_V2BL = G4Translate3D(-(100 + BS_fwdP0_Xedge), -(100 + BS_fwdP0_Yside), BS_fwdP0_DHalf);
768
769 G4VSolid* geo_BS_fwdP0_V3 = new G4Box("geo_BS_fwdP0_V3", BS_fwdP0_Xin, BS_fwdP0_Yin, BS_fwdP0_DHalf);
770 G4Transform3D tfm_BS_fwdP0_V3 = G4Translate3D(0, 0, BS_fwdP0_DHalf);
771
772 double BS_fwdP0_C0_DHalf = (BS_fwdZ1 - BS_fwdZ0) / 2;
773 G4VSolid* geo_BS_fwdP0_V4 = new G4Box("geo_BS_fwdP0_V4", 100, 100, BS_fwdP0_C0_DHalf);
774 G4Transform3D tfm_BS_fwdP0_V4T = G4Translate3D(0, +(100 + BS_fwdP0_Yout), BS_fwdP0_C0_DHalf);
775 G4Transform3D tfm_BS_fwdP0_V4B = G4Translate3D(0, -(100 + BS_fwdP0_Yout), BS_fwdP0_C0_DHalf);
776
777 G4VSolid* geo_BS_fwdP0_Base = new G4DisplacedSolid("geo_BS_fwdP0_Base_00", geo_BS_fwdP0_B0, tfm_BS_fwdP0_B0);
778 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_01", geo_BS_fwdP0_Base, geo_BS_fwdP0_V0T, tfm_BS_fwdP0_V0L);
779 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_02", geo_BS_fwdP0_Base, geo_BS_fwdP0_V0T, tfm_BS_fwdP0_V0R);
780 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_03", geo_BS_fwdP0_Base, geo_BS_fwdP0_V0B, tfm_BS_fwdP0_V0L);
781 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_04", geo_BS_fwdP0_Base, geo_BS_fwdP0_V0B, tfm_BS_fwdP0_V0R);
782 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_05", geo_BS_fwdP0_Base, geo_BS_fwdP0_V1, tfm_BS_fwdP0_V1);
783 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_06", geo_BS_fwdP0_Base, geo_BS_fwdP0_V2, tfm_BS_fwdP0_V2TR);
784 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_07", geo_BS_fwdP0_Base, geo_BS_fwdP0_V2, tfm_BS_fwdP0_V2TL);
785 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_08", geo_BS_fwdP0_Base, geo_BS_fwdP0_V2, tfm_BS_fwdP0_V2BR);
786 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_09", geo_BS_fwdP0_Base, geo_BS_fwdP0_V2, tfm_BS_fwdP0_V2BL);
787 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_10", geo_BS_fwdP0_Base, geo_BS_fwdP0_V3, tfm_BS_fwdP0_V3);
788 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_11", geo_BS_fwdP0_Base, geo_BS_fwdP0_V4, tfm_BS_fwdP0_V4T);
789 geo_BS_fwdP0_Base = new G4SubtractionSolid("geo_BS_fwdP0_Base_12", geo_BS_fwdP0_Base, geo_BS_fwdP0_V4, tfm_BS_fwdP0_V4B);
790
791
792 double BS_bwdP0_R0 = m_config.getParameter(prep + "bwdP0_R0") * unitFactor;
793 double BS_bwdP0_R1 = m_config.getParameter(prep + "bwdP0_R1") * unitFactor;
794 double BS_bwdP0_Yin = m_config.getParameter(prep + "bwdP0_Yin") * unitFactor;
795 double BS_bwdP0_Xin = m_config.getParameter(prep + "bwdP0_Xin") * unitFactor;
796
797 double BS_bwdP0a_DHalf = (BS_bwdZ0 - BS_bwdZ1) / 2;
798 G4VSolid* geo_BS_bwdP0_B0 = new G4Tubs("geo_BS_bwdP0_B0", 0, BS_bwdP0_R0, BS_bwdP0a_DHalf, 0, 2 * M_PI);
799 G4Transform3D tfm_BS_bwdP0_B0 = G4Translate3D(0, 0, -BS_bwdP0a_DHalf);
800
801 double BS_bwdP0b_DHalf = (BS_bwdZ1 - BS_bwdZ2) / 2;
802 G4VSolid* geo_BS_bwdP0_B1 = new G4Tubs("geo_BS_bwdP0_B1", 0, BS_bwdP0_R1, BS_bwdP0b_DHalf, 0.5 * M_PI, M_PI);
803 G4Transform3D tfm_BS_bwdP0_B1 = G4Translate3D(-BS_bwdP0_Xin, 0, -BS_bwdP0b_DHalf - 2 * BS_bwdP0a_DHalf);
804
805 G4VSolid* geo_BS_bwdP0_B2 = new G4Tubs("geo_BS_bwdP0_B2", 0, BS_bwdP0_R1, BS_bwdP0b_DHalf, 1.5 * M_PI, M_PI);
806 G4Transform3D tfm_BS_bwdP0_B2 = G4Translate3D(+BS_bwdP0_Xin, 0, -BS_bwdP0b_DHalf - 2 * BS_bwdP0a_DHalf);
807
808 G4VSolid* geo_BS_bwdP0_B3 = new G4Box("geo_BS_bwdP0_B3", BS_bwdP0_Xin, BS_bwdP0_R1, BS_bwdP0b_DHalf);
809 G4Transform3D tfm_BS_bwdP0_B3 = G4Translate3D(0, 0, -BS_bwdP0b_DHalf - 2 * BS_bwdP0a_DHalf);
810
811 double BS_bwdP0c_DHalf = (BS_bwdZ0 - BS_bwdZ2) / 2;
812 G4VSolid* geo_BS_bwdP0_V0 = new G4Tubs("geo_BS_bwdP0_V0", 0, BS_bwdP0_Yin, BS_bwdP0c_DHalf, 0.5 * M_PI, M_PI);
813 G4Transform3D tfm_BS_bwdP0_V0 = G4Translate3D(-BS_bwdP0_Xin, 0, -BS_bwdP0c_DHalf);
814
815 G4VSolid* geo_BS_bwdP0_V1 = new G4Tubs("geo_BS_bwdP0_V1", 0, BS_bwdP0_Yin, BS_bwdP0c_DHalf, 1.5 * M_PI, M_PI);
816 G4Transform3D tfm_BS_bwdP0_V1 = G4Translate3D(+BS_bwdP0_Xin, 0, -BS_bwdP0c_DHalf);
817
818 G4VSolid* geo_BS_bwdP0_V2 = new G4Box("geo_BS_bwdP0_V2", BS_bwdP0_Xin, BS_bwdP0_Yin, BS_bwdP0c_DHalf);
819 G4Transform3D tfm_BS_bwdP0_V2 = G4Translate3D(0, 0, -BS_bwdP0c_DHalf);
820
821 G4VSolid* geo_BS_bwdP0_Base = new G4DisplacedSolid("geo_BS_bwdP0_Base_00", geo_BS_bwdP0_B0, tfm_BS_bwdP0_B0);
822 geo_BS_bwdP0_Base = new G4UnionSolid("geo_BS_bwdP0_Base_01", geo_BS_bwdP0_Base, geo_BS_bwdP0_B1, tfm_BS_bwdP0_B1);
823 geo_BS_bwdP0_Base = new G4UnionSolid("geo_BS_bwdP0_Base_02", geo_BS_bwdP0_Base, geo_BS_bwdP0_B2, tfm_BS_bwdP0_B2);
824 geo_BS_bwdP0_Base = new G4UnionSolid("geo_BS_bwdP0_Base_03", geo_BS_bwdP0_Base, geo_BS_bwdP0_B3, tfm_BS_bwdP0_B3);
825 geo_BS_bwdP0_Base = new G4SubtractionSolid("geo_BS_bwdP0_Base_04", geo_BS_bwdP0_Base, geo_BS_bwdP0_V0, tfm_BS_bwdP0_V0);
826 geo_BS_bwdP0_Base = new G4SubtractionSolid("geo_BS_bwdP0_Base_05", geo_BS_bwdP0_Base, geo_BS_bwdP0_V1, tfm_BS_bwdP0_V1);
827 geo_BS_bwdP0_Base = new G4SubtractionSolid("geo_BS_bwdP0_Base_06", geo_BS_bwdP0_Base, geo_BS_bwdP0_V2, tfm_BS_bwdP0_V2);
828
829
830 double BS_P1_Yout = m_config.getParameter(prep + "P1_Yout") * unitFactor;
831 double BS_P1_Yin = m_config.getParameter(prep + "P1_Yin") * unitFactor;
832 double BS_P1_Rout = m_config.getParameter(prep + "P1_Rout") * unitFactor;
833 double BS_P1_Rin = m_config.getParameter(prep + "P1_Rin") * unitFactor;
834 double BS_P1_Aout = m_config.getParameter(prep + "P1_Aout");
835 double BS_P1_Ain = m_config.getParameter(prep + "P1_Ain");
836 double BS_P1_RX = m_config.getParameter(prep + "P1_RX") * unitFactor;
837 double BS_fwdZhole = m_config.getParameter(prep + "fwdZhole") * unitFactor;
838 double BS_bwdZhole = m_config.getParameter(prep + "bwdZhole") * unitFactor;
839 double BS_P1_Rhole = m_config.getParameter(prep + "P1_Rhole") * unitFactor;
840 double BS_P1_Rbump = m_config.getParameter(prep + "P1_Rbump") * unitFactor;
841 double BS_P1_Yhole = m_config.getParameter(prep + "P1_Yhole") * unitFactor;
842 double BS_P1_MillD1 = m_config.getParameter(prep + "P1_MillD1") * unitFactor;
843 double BS_P1_MillD2 = m_config.getParameter(prep + "P1_MillD2") * unitFactor;
844 double BS_P1_MillX = m_config.getParameter(prep + "P1_MillX") * unitFactor;
845 double BS_P1_MillW = m_config.getParameter(prep + "P1_MillW") * unitFactor;
846 double BS_fwdZcut = m_config.getParameter(prep + "fwdZcut") * unitFactor;
847 double BS_bwdZcut = m_config.getParameter(prep + "bwdZcut") * unitFactor;
848 double BS_P1_XcutTL = m_config.getParameter(prep + "P1_XcutTL") * unitFactor;
849 double BS_P1_XcutTR = m_config.getParameter(prep + "P1_XcutTR") * unitFactor;
850 double BS_P1_XcutBL = m_config.getParameter(prep + "P1_XcutBL") * unitFactor;
851 double BS_P1_XcutBR = m_config.getParameter(prep + "P1_XcutBR") * unitFactor;
852
853 double BS_P1_Xout = BS_P1_Rout * cos(BS_P1_Aout) + BS_P1_RX;
854 double BS_P1_Xin = BS_P1_Rin * cos(BS_P1_Ain) + BS_P1_RX;
855
856 double BS_P1fwd_DHalf = (BS_fwdZ3 - BS_fwdZ2) / 2;
857 G4VSolid* geo_BS_P1fwd_B0 = new G4Box("geo_BS_P1fwd_B0", BS_P1_Xout, BS_P1_Yout, BS_P1fwd_DHalf);
858 G4Transform3D tfm_BS_P1fwd_B0 = G4Translate3D(0, 0, BS_P1fwd_DHalf);
859
860 G4VSolid* geo_BS_P1fwd_B1 = new G4Tubs("geo_BS_P1fwd_B1", 0, BS_P1_Rout, BS_P1fwd_DHalf, M_PI - BS_P1_Aout, 2 * BS_P1_Aout);
861 G4Transform3D tfm_BS_P1fwd_B1 = G4Translate3D(-BS_P1_RX, 0, BS_P1fwd_DHalf);
862
863 G4VSolid* geo_BS_P1fwd_B2 = new G4Tubs("geo_BS_P1fwd_B2", 0, BS_P1_Rout, BS_P1fwd_DHalf, 2 * M_PI - BS_P1_Aout, 2 * BS_P1_Aout);
864 G4Transform3D tfm_BS_P1fwd_B2 = G4Translate3D(+BS_P1_RX, 0, BS_P1fwd_DHalf);
865
866 G4VSolid* geo_BS_P1fwd_B3 = new G4Tubs("geo_BS_P1fwd_B3", 0, BS_P1_Rbump, BS_P1fwd_DHalf, 0, 2 * M_PI);
867 G4Transform3D tfm_BS_P1fwd_B3T = G4Translate3D(0, +BS_P1_Yhole, BS_P1fwd_DHalf);
868 G4Transform3D tfm_BS_P1fwd_B3B = G4Translate3D(0, -BS_P1_Yhole, BS_P1fwd_DHalf);
869
870 G4VSolid* geo_BS_P1fwd_V0 = new G4Box("geo_BS_P1fwd_V0", BS_P1_Xin, BS_P1_Yin, BS_P1fwd_DHalf);
871 G4Transform3D tfm_BS_P1fwd_V0 = G4Translate3D(0, 0, BS_P1fwd_DHalf);
872
873 G4VSolid* geo_BS_P1fwd_V1 = new G4Tubs("geo_BS_P1fwd_V1", 0, BS_P1_Rin, BS_P1fwd_DHalf, M_PI - BS_P1_Ain, 2 * BS_P1_Ain);
874 G4Transform3D tfm_BS_P1fwd_V1 = G4Translate3D(-BS_P1_RX, 0, BS_P1fwd_DHalf);
875
876 G4VSolid* geo_BS_P1fwd_V2 = new G4Tubs("geo_BS_P1fwd_V2", 0, BS_P1_Rin, BS_P1fwd_DHalf, 2 * M_PI - BS_P1_Ain, 2 * BS_P1_Ain);
877 G4Transform3D tfm_BS_P1fwd_V2 = G4Translate3D(+BS_P1_RX, 0, BS_P1fwd_DHalf);
878
879 double BS_P1fwd_V3_DHalf = (BS_fwdZ3 - BS_fwdZhole) / 2;
880 G4VSolid* geo_BS_P1fwd_V3 = new G4Tubs("geo_BS_P1fwd_V3", 0, BS_P1_Rhole, BS_P1fwd_V3_DHalf, 0, 2 * M_PI);
881 G4Transform3D tfm_BS_P1fwd_V3T = G4Translate3D(0, +BS_P1_Yhole, -BS_P1fwd_V3_DHalf + 2 * BS_P1fwd_DHalf);
882 G4Transform3D tfm_BS_P1fwd_V3B = G4Translate3D(0, -BS_P1_Yhole, -BS_P1fwd_V3_DHalf + 2 * BS_P1fwd_DHalf);
883
884 G4VSolid* geo_BS_P1fwd_V4 = new G4Box("geo_BS_P1fwd_V4", BS_P1_MillW / 2, 100, BS_P1_MillD1 / 2);
885 G4Transform3D tfm_BS_P1fwd_V4a = G4Translate3D(-BS_P1_MillX, 0, BS_P1_MillD1 / 2) * G4RotateZ3D(0.25 * M_PI);
886 G4Transform3D tfm_BS_P1fwd_V4b = G4Translate3D(-BS_P1_MillX, 0, BS_P1_MillD1 / 2) * G4RotateZ3D(0.75 * M_PI);
887
888 G4VSolid* geo_BS_P1fwd_V5 = new G4Box("geo_BS_P1fwd_V5", BS_P1_MillW / 2, 100, BS_P1_MillD2 / 2);
889 G4Transform3D tfm_BS_P1fwd_V5a = G4Translate3D(+BS_P1_MillX, 0, BS_P1_MillD2 / 2) * G4RotateZ3D(0.25 * M_PI);
890 G4Transform3D tfm_BS_P1fwd_V5b = G4Translate3D(+BS_P1_MillX, 0, BS_P1_MillD2 / 2) * G4RotateZ3D(0.75 * M_PI);
891
892 double BS_P1fwd_V67_DHalf = (BS_fwdZ3 - BS_fwdZcut) / 2;
893 double BS_P1fwd_V67_Pos = (BS_fwdZcut - BS_fwdZ2);
894 G4VSolid* geo_BS_P1fwd_V6 = new G4Box("geo_BS_P1fwd_V6", (BS_P1_XcutTR - BS_P1_XcutTL) / 2, 100, BS_P1fwd_V67_DHalf);
895 G4Transform3D tfm_BS_P1fwd_V6 = G4Translate3D((BS_P1_XcutTR + BS_P1_XcutTL) / 2, +100, BS_P1fwd_V67_DHalf + BS_P1fwd_V67_Pos);
896
897 G4VSolid* geo_BS_P1fwd_V7 = new G4Box("geo_BS_P1fwd_V7", (BS_P1_XcutBR - BS_P1_XcutBL) / 2, 100, BS_P1fwd_V67_DHalf);
898 G4Transform3D tfm_BS_P1fwd_V7 = G4Translate3D((BS_P1_XcutBR + BS_P1_XcutBL) / 2, -100, BS_P1fwd_V67_DHalf + BS_P1fwd_V67_Pos);
899
900
901 G4VSolid* geo_BS_P1fwd_Base = new G4DisplacedSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_B0, tfm_BS_P1fwd_B0);
902 geo_BS_P1fwd_Base = new G4UnionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_B1, tfm_BS_P1fwd_B1);
903 geo_BS_P1fwd_Base = new G4UnionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_B2, tfm_BS_P1fwd_B2);
904 geo_BS_P1fwd_Base = new G4UnionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_B3, tfm_BS_P1fwd_B3T);
905 geo_BS_P1fwd_Base = new G4UnionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_B3, tfm_BS_P1fwd_B3B);
906 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V0, tfm_BS_P1fwd_V0);
907 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V1, tfm_BS_P1fwd_V1);
908 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V2, tfm_BS_P1fwd_V2);
909 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V3, tfm_BS_P1fwd_V3T);
910 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V3, tfm_BS_P1fwd_V3B);
911 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V4, tfm_BS_P1fwd_V4a);
912 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V4, tfm_BS_P1fwd_V4b);
913 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V5, tfm_BS_P1fwd_V5a);
914 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V5, tfm_BS_P1fwd_V5b);
915 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V6, tfm_BS_P1fwd_V6);
916 geo_BS_P1fwd_Base = new G4SubtractionSolid("geo_BS_P1fwd_Base", geo_BS_P1fwd_Base, geo_BS_P1fwd_V7, tfm_BS_P1fwd_V7);
917
918 double BS_P1bwd_DHalf = -(BS_bwdZ3 - BS_bwdZ2) / 2;
919 G4VSolid* geo_BS_P1bwd_B0 = new G4Box("geo_BS_P1bwd_B0", BS_P1_Xout, BS_P1_Yout, BS_P1bwd_DHalf);
920 G4Transform3D tfm_BS_P1bwd_B0 = G4Translate3D(0, 0, BS_P1bwd_DHalf);
921
922 G4VSolid* geo_BS_P1bwd_B1 = new G4Tubs("geo_BS_P1bwd_B1", 0, BS_P1_Rout, BS_P1bwd_DHalf, M_PI - BS_P1_Aout, 2 * BS_P1_Aout);
923 G4Transform3D tfm_BS_P1bwd_B1 = G4Translate3D(-BS_P1_RX, 0, BS_P1bwd_DHalf);
924
925 G4VSolid* geo_BS_P1bwd_B2 = new G4Tubs("geo_BS_P1bwd_B2", 0, BS_P1_Rout, BS_P1bwd_DHalf, 2 * M_PI - BS_P1_Aout, 2 * BS_P1_Aout);
926 G4Transform3D tfm_BS_P1bwd_B2 = G4Translate3D(+BS_P1_RX, 0, BS_P1bwd_DHalf);
927
928 G4VSolid* geo_BS_P1bwd_B3 = new G4Tubs("geo_BS_P1bwd_B3", 0, BS_P1_Rbump, BS_P1bwd_DHalf, 0, 2 * M_PI);
929 G4Transform3D tfm_BS_P1bwd_B3T = G4Translate3D(0, +BS_P1_Yhole, BS_P1bwd_DHalf);
930 G4Transform3D tfm_BS_P1bwd_B3B = G4Translate3D(0, -BS_P1_Yhole, BS_P1bwd_DHalf);
931
932 G4VSolid* geo_BS_P1bwd_V0 = new G4Box("geo_BS_P1bwd_V0", BS_P1_Xin, BS_P1_Yin, BS_P1bwd_DHalf);
933 G4Transform3D tfm_BS_P1bwd_V0 = G4Translate3D(0, 0, BS_P1bwd_DHalf);
934
935 G4VSolid* geo_BS_P1bwd_V1 = new G4Tubs("geo_BS_P1bwd_V1", 0, BS_P1_Rin, BS_P1bwd_DHalf, M_PI - BS_P1_Ain, 2 * BS_P1_Ain);
936 G4Transform3D tfm_BS_P1bwd_V1 = G4Translate3D(-BS_P1_RX, 0, BS_P1bwd_DHalf);
937
938 G4VSolid* geo_BS_P1bwd_V2 = new G4Tubs("geo_BS_P1bwd_V2", 0, BS_P1_Rin, BS_P1bwd_DHalf, 2 * M_PI - BS_P1_Ain, 2 * BS_P1_Ain);
939 G4Transform3D tfm_BS_P1bwd_V2 = G4Translate3D(+BS_P1_RX, 0, BS_P1bwd_DHalf);
940
941 double BS_P1bwd_V3_DHalf = -(BS_bwdZ3 - BS_bwdZhole) / 2;
942 G4VSolid* geo_BS_P1bwd_V3 = new G4Tubs("geo_BS_P1bwd_V3", 0, BS_P1_Rhole, BS_P1bwd_V3_DHalf, 0, 2 * M_PI);
943 G4Transform3D tfm_BS_P1bwd_V3T = G4Translate3D(0, +BS_P1_Yhole, -BS_P1bwd_V3_DHalf + 2 * BS_P1bwd_DHalf);
944 G4Transform3D tfm_BS_P1bwd_V3B = G4Translate3D(0, -BS_P1_Yhole, -BS_P1bwd_V3_DHalf + 2 * BS_P1bwd_DHalf);
945
946 G4VSolid* geo_BS_P1bwd_V4 = new G4Box("geo_BS_P1bwd_V4", BS_P1_MillW / 2, 100, BS_P1_MillD1 / 2);
947 G4Transform3D tfm_BS_P1bwd_V4a = G4Translate3D(-BS_P1_MillX, 0, BS_P1_MillD1 / 2) * G4RotateZ3D(0.25 * M_PI);
948 G4Transform3D tfm_BS_P1bwd_V4b = G4Translate3D(-BS_P1_MillX, 0, BS_P1_MillD1 / 2) * G4RotateZ3D(0.75 * M_PI);
949
950 G4VSolid* geo_BS_P1bwd_V5 = new G4Box("geo_BS_P1bwd_V5", BS_P1_MillW / 2, 100, BS_P1_MillD2 / 2);
951 G4Transform3D tfm_BS_P1bwd_V5a = G4Translate3D(+BS_P1_MillX, 0, BS_P1_MillD2 / 2) * G4RotateZ3D(0.25 * M_PI);
952 G4Transform3D tfm_BS_P1bwd_V5b = G4Translate3D(+BS_P1_MillX, 0, BS_P1_MillD2 / 2) * G4RotateZ3D(0.75 * M_PI);
953
954 double BS_P1bwd_V67_DHalf = -(BS_bwdZ3 - BS_bwdZcut) / 2;
955 double BS_P1bwd_V67_Pos = -(BS_bwdZcut - BS_bwdZ2);
956 G4VSolid* geo_BS_P1bwd_V6 = new G4Box("geo_BS_P1bwd_V6", (BS_P1_XcutTR - BS_P1_XcutTL) / 2, 100, BS_P1bwd_V67_DHalf);
957 G4Transform3D tfm_BS_P1bwd_V6 = G4Translate3D((BS_P1_XcutTR + BS_P1_XcutTL) / 2, +100, BS_P1bwd_V67_DHalf + BS_P1bwd_V67_Pos);
958
959 G4VSolid* geo_BS_P1bwd_V7 = new G4Box("geo_BS_P1bwd_V7", (BS_P1_XcutBR - BS_P1_XcutBL) / 2, 100, BS_P1bwd_V67_DHalf);
960 G4Transform3D tfm_BS_P1bwd_V7 = G4Translate3D((BS_P1_XcutBR + BS_P1_XcutBL) / 2, -100, BS_P1bwd_V67_DHalf + BS_P1bwd_V67_Pos);
961
962
963 G4VSolid* geo_BS_P1bwd_Base = new G4DisplacedSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_B0, tfm_BS_P1bwd_B0);
964 geo_BS_P1bwd_Base = new G4UnionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_B1, tfm_BS_P1bwd_B1);
965 geo_BS_P1bwd_Base = new G4UnionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_B2, tfm_BS_P1bwd_B2);
966 geo_BS_P1bwd_Base = new G4UnionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_B3, tfm_BS_P1bwd_B3T);
967 geo_BS_P1bwd_Base = new G4UnionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_B3, tfm_BS_P1bwd_B3B);
968 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V0, tfm_BS_P1bwd_V0);
969 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V1, tfm_BS_P1bwd_V1);
970 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V2, tfm_BS_P1bwd_V2);
971 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V3, tfm_BS_P1bwd_V3T);
972 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V3, tfm_BS_P1bwd_V3B);
973 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V4, tfm_BS_P1bwd_V4a);
974 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V4, tfm_BS_P1bwd_V4b);
975 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V5, tfm_BS_P1bwd_V5a);
976 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V5, tfm_BS_P1bwd_V5b);
977 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V6, tfm_BS_P1bwd_V6);
978 geo_BS_P1bwd_Base = new G4SubtractionSolid("geo_BS_P1bwd_Base", geo_BS_P1bwd_Base, geo_BS_P1bwd_V7, tfm_BS_P1bwd_V7);
979
980
981 double BS_P2_Rout = m_config.getParameter(prep + "P2_Rout") * unitFactor;
982 double BS_P2_Rin = m_config.getParameter(prep + "P2_Rin") * unitFactor;
983 double BS_P2_Xin = m_config.getParameter(prep + "P2_Xin") * unitFactor;
984 double BS_P2_Rhole = m_config.getParameter(prep + "P2_Rhole") * unitFactor;
985 double BS_P2_Yhole = m_config.getParameter(prep + "P2_Yhole") * unitFactor;
986 double BS_P2_XcutTL = m_config.getParameter(prep + "P2_XcutTL") * unitFactor;
987 double BS_P2_XcutTR = m_config.getParameter(prep + "P2_XcutTR") * unitFactor;
988 double BS_P2_XcutBL = m_config.getParameter(prep + "P2_XcutBL") * unitFactor;
989 double BS_P2_XcutBR = m_config.getParameter(prep + "P2_XcutBR") * unitFactor;
990
991 double BS_P2fwd_DHalf = (BS_fwdZ4 - BS_fwdZ3) / 2;
992 G4VSolid* geo_BS_P2fwd_B0 = new G4Tubs("geo_BS_P2fwd_B0", 0, BS_P2_Rout, BS_P2fwd_DHalf, 0, 2 * M_PI);
993 G4Transform3D tfm_BS_P2fwd_B0 = G4Translate3D(0, 0, BS_P2fwd_DHalf);
994
995 G4VSolid* geo_BS_P2fwd_V0 = new G4Box("geo_BS_P2fwd_V0", BS_P2_Xin, BS_P2_Rin, BS_P2fwd_DHalf);
996 G4Transform3D tfm_BS_P2fwd_V0 = G4Translate3D(0, 0, BS_P2fwd_DHalf);
997
998 G4VSolid* geo_BS_P2fwd_V1 = new G4Tubs("geo_BS_P2fwd_V1", 0, BS_P2_Rin, BS_P2fwd_DHalf, 0, 2 * M_PI);
999 G4Transform3D tfm_BS_P2fwd_V1L = G4Translate3D(-BS_P2_Xin, 0, BS_P2fwd_DHalf);
1000 G4Transform3D tfm_BS_P2fwd_V1R = G4Translate3D(+BS_P2_Xin, 0, BS_P2fwd_DHalf);
1001
1002 G4VSolid* geo_BS_P2fwd_V2 = new G4Tubs("geo_BS_P2fwd_V2", 0, BS_P2_Rhole, BS_P2fwd_DHalf, 0, 2 * M_PI);
1003 G4Transform3D tfm_BS_P2fwd_V2T = G4Translate3D(0, +BS_P2_Yhole, BS_P2fwd_DHalf);
1004 G4Transform3D tfm_BS_P2fwd_V2B = G4Translate3D(0, -BS_P2_Yhole, BS_P2fwd_DHalf);
1005
1006 G4VSolid* geo_BS_P2fwd_V3 = new G4Box("geo_BS_P2fwd_V3", (BS_P2_XcutTR - BS_P2_XcutTL) / 2, 100, BS_P2fwd_DHalf);
1007 G4Transform3D tfm_BS_P2fwd_V3 = G4Translate3D((BS_P2_XcutTR + BS_P2_XcutTL) / 2, +100, BS_P2fwd_DHalf);
1008
1009 G4VSolid* geo_BS_P2fwd_V4 = new G4Box("geo_BS_P2fwd_V4", (BS_P2_XcutBR - BS_P2_XcutBL) / 2, 100, BS_P2fwd_DHalf);
1010 G4Transform3D tfm_BS_P2fwd_V4 = G4Translate3D((BS_P2_XcutBR + BS_P2_XcutBL) / 2, -100, BS_P2fwd_DHalf);
1011
1012 G4VSolid* geo_BS_P2fwd_Base = new G4DisplacedSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_B0, tfm_BS_P2fwd_B0);
1013 geo_BS_P2fwd_Base = new G4SubtractionSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_Base, geo_BS_P2fwd_V0, tfm_BS_P2fwd_V0);
1014 geo_BS_P2fwd_Base = new G4SubtractionSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_Base, geo_BS_P2fwd_V1, tfm_BS_P2fwd_V1L);
1015 geo_BS_P2fwd_Base = new G4SubtractionSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_Base, geo_BS_P2fwd_V1, tfm_BS_P2fwd_V1R);
1016 geo_BS_P2fwd_Base = new G4SubtractionSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_Base, geo_BS_P2fwd_V2, tfm_BS_P2fwd_V2T);
1017 geo_BS_P2fwd_Base = new G4SubtractionSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_Base, geo_BS_P2fwd_V2, tfm_BS_P2fwd_V2B);
1018 geo_BS_P2fwd_Base = new G4SubtractionSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_Base, geo_BS_P2fwd_V3, tfm_BS_P2fwd_V3);
1019 geo_BS_P2fwd_Base = new G4SubtractionSolid("geo_BS_P2fwd_Base", geo_BS_P2fwd_Base, geo_BS_P2fwd_V4, tfm_BS_P2fwd_V4);
1020
1021
1022
1023 G4Transform3D tfm_BS_fwdP1 = G4Translate3D(0, 0, BS_fwdZ2 - BS_fwdZ0);
1024 G4Transform3D tfm_BS_fwdP2 = G4Translate3D(0, 0, BS_fwdZ3 - BS_fwdZ0);
1025
1026 G4VSolid* geo_BS_fwd = geo_BS_fwdP0_Base;
1027 geo_BS_fwd = new G4UnionSolid("geo_BS_fwd", geo_BS_fwd, geo_BS_P1fwd_Base, tfm_BS_fwdP1);
1028 geo_BS_fwd = new G4UnionSolid("geo_BS_fwd", geo_BS_fwd, geo_BS_P2fwd_Base, tfm_BS_fwdP2);
1029
1030 G4LogicalVolume* logi_BS_fwd = new G4LogicalVolume(geo_BS_fwd, mat_BS, "logi_BS_fwd");
1031
1032 G4Transform3D tfm_BS_fwd = G4Translate3D(0, 0, BS_fwdZ0);
1033 new G4PVPlacement(tfm_BS_fwd, logi_BS_fwd, "phys_BS_fwd", &topVolume, false, 0);
1034
1035
1036
1037 G4Transform3D tfm_BS_bwdP1 = G4Translate3D(0, 0, BS_bwdZ2 - BS_bwdZ0) * G4RotateY3D(M_PI);
1038
1039 G4VSolid* geo_BS_bwd = geo_BS_bwdP0_Base;
1040 geo_BS_bwd = new G4UnionSolid("geo_BS_bwd", geo_BS_bwd, geo_BS_P1bwd_Base, tfm_BS_bwdP1);
1041
1042 G4LogicalVolume* logi_BS_bwd = new G4LogicalVolume(geo_BS_bwd, mat_BS, "logi_BS_bwd");
1043
1044 G4Transform3D tfm_BS_bwd = G4Translate3D(0, 0, BS_bwdZ0);
1045 new G4PVPlacement(tfm_BS_bwd, logi_BS_bwd, "phys_BS_bwd", &topVolume, false, 0);
1046
1047
1048
1049
1050
1051
1052 std::vector<std::string> straightSections;
1053 boost::split(straightSections, m_config.getParameterStr("Straight"), boost::is_any_of(" "));
1054 for (const auto& name : straightSections) {
1055 prep = name + ".";
1056
1057 CryostatElement polycone;
1058
1059 int N = int(m_config.getParameter(prep + "N"));
1060
1061 std::vector<double> Z(N);
1062 std::vector<double>
R(N);
1063 std::vector<double> r(N);
1064
1065 for (int i = 0; i < N; ++i) {
1066 ostringstream ossZID;
1067 ossZID << "Z" << i;
1068
1069 ostringstream ossRID;
1070 ossRID << "R" << i;
1071
1072 ostringstream ossrID;
1073 ossrID << "r" << i;
1074
1075 Z[i] = m_config.getParameter(prep + ossZID.str()) * unitFactor;
1076 R[i] = m_config.getParameter(prep + ossRID.str()) * unitFactor;
1077 r[i] = m_config.getParameter(prep + ossrID.str(), 0.0) * unitFactor;
1078 }
1079
1080 polycone.transform = G4Translate3D(0.0, 0.0, 0.0);
1081
1082
1083 string motherVolume = m_config.getParameterStr(prep + "MotherVolume");
1084 string subtract = m_config.getParameterStr(prep + "Subtract", "");
1085 string intersect = m_config.getParameterStr(prep +
"Intersect",
"");
1086
1087 string geo_polyconexx_name = "geo_" + name + "xx_name";
1088 string geo_polyconex_name = "geo_" + name + "x_name";
1089 string geo_polycone_name = "geo_" + name + "_name";
1090
1091 G4VSolid* geo_polyconexx, *geo_polycone;
1092
1093 if (subtract != "" && intersect != "") {
1094 geo_polyconexx =
new G4Polycone(geo_polyconexx_name, 0.0, 2 * M_PI, N, &(Z[0]), &(r[0]), &(
R[0]));
1095 G4VSolid* geo_polyconex = new G4SubtractionSolid(geo_polyconex_name, geo_polyconexx, elements[subtract].geo,
1096 elements[motherVolume].transform.inverse()*polycone.transform.inverse()*elements[subtract].transform);
1097 geo_polycone = new G4IntersectionSolid(geo_polycone_name, geo_polyconex, elements[intersect].geo,
1098 elements[motherVolume].transform.inverse()*polycone.transform.inverse()*elements[intersect].transform);
1099 } else if (subtract != "") {
1100 geo_polyconexx =
new G4Polycone(geo_polyconexx_name, 0.0, 2 * M_PI, N, &(Z[0]), &(r[0]), &(
R[0]));
1101 geo_polycone = new G4SubtractionSolid(geo_polycone_name, geo_polyconexx, elements[subtract].geo,
1102 elements[motherVolume].transform.inverse()*polycone.transform.inverse()*elements[subtract].transform);
1103 } else if (intersect != "") {
1104 geo_polyconexx =
new G4Polycone(geo_polyconexx_name, 0.0, 2 * M_PI, N, &(Z[0]), &(r[0]), &(
R[0]));
1105 geo_polycone = new G4IntersectionSolid(geo_polycone_name, geo_polyconexx, elements[intersect].geo,
1106 elements[motherVolume].transform.inverse()*polycone.transform.inverse()*elements[intersect].transform);
1107 } else
1108 geo_polycone =
new G4Polycone(geo_polycone_name, 0.0, 2 * M_PI, N, &(Z[0]), &(r[0]), &(
R[0]));
1109
1110 polycone.geo = geo_polycone;
1111
1112
1113 string strMat_polycone = m_config.getParameterStr(prep + "Material");
1114 G4Material* mat_polycone = Materials::get(strMat_polycone);
1115 string logi_polycone_name = "logi_" + name + "_name";
1116 polycone.logi = new G4LogicalVolume(polycone.geo, mat_polycone, logi_polycone_name);
1117 setColor(*polycone.logi,
"#CC0000");
1119
1120
1121 string phys_polycone_name = "phys_" + name + "_name";
1122 new G4PVPlacement(polycone.transform, polycone.logi, phys_polycone_name, elements[motherVolume].logi, false, 0);
1123
1124
1125 polycone.transform = polycone.transform * elements[motherVolume].transform;
1126
1127 elements[name] = polycone;
1128 }
1129
1130
1131
1132
1133
1134 std::vector<std::string> shields;
1135 boost::split(shields, m_config.getParameterStr("Shield"), boost::is_any_of(" "));
1136 for (const auto& name : shields) {
1137 prep = name + ".";
1138
1139
1140
1141 double shield_W = m_config.getParameter(prep + "W") * unitFactor;
1142 double shield_H = m_config.getParameter(prep + "H") * unitFactor;
1143 double shield_L = m_config.getParameter(prep + "L") * unitFactor;
1144 double shield_X0 = m_config.getParameter(prep + "X0") * unitFactor;
1145 double shield_Y0 = m_config.getParameter(prep + "Y0") * unitFactor;
1146 double shield_Z0 = m_config.getParameter(prep + "Z0") * unitFactor;
1147
1148 double shield_hole_W = m_config.getParameter(prep + "holeW", 0) * unitFactor;
1149 double shield_hole_H = m_config.getParameter(prep + "holeH", 0) * unitFactor;
1150 double shield_hole_L = m_config.getParameter(prep + "holeL", 0) * unitFactor;
1151 double shield_hole_dX = m_config.getParameter(prep + "holeDX", 0) * unitFactor;
1152 double shield_hole_dY = m_config.getParameter(prep + "holeDY", 0) * unitFactor;
1153 double shield_hole_dZ = m_config.getParameter(prep + "holeDZ", 0) * unitFactor;
1154
1155 double shield_PHI = m_config.getParameter(prep + "PHI");
1156
1157
1158 CryostatElement shield;
1159
1160 shield.transform = G4Translate3D(shield_X0, shield_Y0, shield_Z0);
1161 shield.transform = shield.transform * G4RotateY3D(shield_PHI / Unit::rad);
1162
1163 G4Transform3D transform_shield_hole = G4Translate3D(shield_hole_dX, shield_hole_dY, shield_hole_dZ);
1164
1165
1166 string geo_shieldx_name = "geo_" + name + "x_name";
1167 string geo_shield_hole_name = "geo_" + name + "_hole_name";
1168 string geo_shield_name = "geo_" + name + "_name";
1169
1170 if (shield_hole_W == 0 || shield_hole_H == 0 || shield_hole_L == 0) {
1171 G4Box* geo_shield = new G4Box(geo_shield_name, shield_W / 2.0, shield_H / 2.0, shield_L / 2.0);
1172
1173 shield.geo = geo_shield;
1174 } else {
1175 G4Box* geo_shieldx = new G4Box(geo_shieldx_name, shield_W / 2.0, shield_H / 2.0, shield_L / 2.0);
1176 G4Box* geo_shield_hole = new G4Box(geo_shield_hole_name, shield_hole_W / 2.0, shield_hole_H / 2.0, shield_hole_L / 2.0);
1177 G4SubtractionSolid* geo_shield = new G4SubtractionSolid(geo_shield_name, geo_shieldx, geo_shield_hole,
1178 transform_shield_hole);
1179
1180 shield.geo = geo_shield;
1181 }
1182
1183 string strMat_shield = m_config.getParameterStr(prep + "Material");
1184 G4Material* mat_shield = Materials::get(strMat_shield);
1185
1186 string logi_shield_name = "logi_" + name + "_name";
1187 G4LogicalVolume* logi_shield = new G4LogicalVolume(shield.geo, mat_shield, logi_shield_name);
1188
1189 shield.logi = logi_shield;
1190
1191
1193
1194 string phys_shield_name = "phys_" + name + "_name";
1195 new G4PVPlacement(shield.transform, shield.logi, phys_shield_name, &topVolume, false, 0);
1196
1197 elements[name] = shield;
1198 }
1199
1200
1201
1202 G4Tubs* geo_rvcR = new G4Tubs("geo_rvcR", 60, 60 + 60, (620 - 560) / 2., 0, 2 * M_PI);
1203 G4LogicalVolume* logi_rvcR = new G4LogicalVolume(geo_rvcR, Materials::get("SUS316L"), "logi_rvcR_name");
1204 new G4PVPlacement(0, G4ThreeVector(0, 0, (620 + 560) / 2.), logi_rvcR, "phys_rvcR_name", &topVolume, false, 0);
1205
1206 G4Tubs* geo_rvcL = new G4Tubs("geo_rvcL", 60, 60 + 60, (-560 - (-620)) / 2., 0, 2 * M_PI);
1207 G4LogicalVolume* logi_rvcL = new G4LogicalVolume(geo_rvcL, Materials::get("SUS316L"), "logi_rvcL_name");
1208 new G4PVPlacement(0, G4ThreeVector(0, 0, (-620 - 560) / 2.), logi_rvcL, "phys_rvcL_name", &topVolume, false, 0);
1209
1210
1211
1212 G4EllipticalTube* geo_elp_QC1LEx = new G4EllipticalTube("geo_elp_QC1LEx", 10.5, 13.5, (-675 - (-1225)) / 2.);
1213 G4IntersectionSolid* geo_elp_QC1LE = new G4IntersectionSolid("geo_elp_QC1LE", elements["D2wal1"].geo, geo_elp_QC1LEx,
1214 G4Translate3D(0, 0, (-675 - 1225) / 2.));
1215 G4LogicalVolume* logi_elp_QC1LE = new G4LogicalVolume(geo_elp_QC1LE, Materials::get("Vacuum"), "logi_elp_QC1LE_name");
1216 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logi_elp_QC1LE, "phys_elp_QC1LE_name", elements["D2wal1"].logi, false, 0);
1217
1218 G4EllipticalTube* geo_elp_QC1LPx = new G4EllipticalTube("geo_elp_QC1LPx", 10.5, 13.5, (-675 - (-1225)) / 2.);
1219 G4IntersectionSolid* geo_elp_QC1LP = new G4IntersectionSolid("geo_elp_QC1LP", elements["E2wal1"].geo, geo_elp_QC1LPx,
1220 G4Translate3D(0, 0, (-675 - 1225) / 2.));
1221 G4LogicalVolume* logi_elp_QC1LP = new G4LogicalVolume(geo_elp_QC1LP, Materials::get("Vacuum"), "logi_elp_QC1LP_name");
1222 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logi_elp_QC1LP, "phys_elp_QC1LP_name", elements["E2wal1"].logi, false, 0);
1223
1224 G4EllipticalTube* geo_elp_QC1REx = new G4EllipticalTube("geo_elp_QC1REx", 10.5, 13.5, (1225 - 675) / 2.);
1225 G4IntersectionSolid* geo_elp_QC1RE = new G4IntersectionSolid("geo_elp_QC1RE", elements["A2wal1"].geo, geo_elp_QC1REx,
1226 G4Translate3D(0, 0, (1225 + 675) / 2.));
1227 G4LogicalVolume* logi_elp_QC1RE = new G4LogicalVolume(geo_elp_QC1RE, Materials::get("Vacuum"), "logi_elp_QC1RE_name");
1228 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logi_elp_QC1RE, "phys_elp_QC1RE_name", elements["A2wal1"].logi, false, 0);
1229
1230 G4EllipticalTube* geo_elp_QC1RPx = new G4EllipticalTube("geo_elp_QC1RPx", 10.5, 13.5, (1225 - 675) / 2.);
1231 G4IntersectionSolid* geo_elp_QC1RP = new G4IntersectionSolid("geo_elp_QC1RP", elements["B2wal1"].geo, geo_elp_QC1RPx,
1232 G4Translate3D(0, 0, (1225 + 675) / 2.));
1233 G4LogicalVolume* logi_elp_QC1RP = new G4LogicalVolume(geo_elp_QC1RP, Materials::get("Vacuum"), "logi_elp_QC1RP_name");
1234 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logi_elp_QC1RP, "phys_elp_QC1RP_name", elements["B2wal1"].logi, false, 0);
1235
1236
1237
1238
1239
1240
1241
1242 if (m_config.getParameter("polyBlock-R-L1.L", -1) > 0) {
1243
1244
1245 std::vector<std::string> polyBlocks;
1246 boost::split(polyBlocks, m_config.getParameterStr("PolyBlock"), boost::is_any_of(" "));
1247 for (const auto& name : polyBlocks) {
1248 prep = name + ".";
1249
1250
1251 double block_L = m_config.getParameter(prep + "L") * unitFactor;
1252 double block_R = m_config.getParameter(prep + "R") * unitFactor;
1253 double block_r = m_config.getParameter(prep + "r") * unitFactor;
1254 double block_W = m_config.getParameter(prep + "W") * unitFactor;
1255 double block_w = m_config.getParameter(prep + "w") * unitFactor;
1256 double block_t = m_config.getParameter(prep + "t") * unitFactor;
1257 double block_Z0 = m_config.getParameter(prep + "Z0") * unitFactor;
1258 double block_dr = m_config.getParameter(prep + "dr", 0.0) * unitFactor;
1259
1260 int block_N = int(m_config.getParameter(prep + "N"));
1261
1262 std::vector<double> block_PHIs(block_N);
1263 for (int i = 0; i < block_N; ++i) {
1264 ostringstream oss_block_num;
1265 oss_block_num << i;
1266 block_PHIs[i] = m_config.getParameter(prep + "PHI" + oss_block_num.str());
1267 }
1268
1269
1270 double block_cut_L0 = m_config.getParameter(prep + "cutL0", 0.0) * unitFactor;
1271 double block_cut_L1 = m_config.getParameter(prep + "cutL1", 0.0) * unitFactor;
1272 int block_cut_N = 0;
1273 if (block_cut_L0 != 0.0 && block_cut_L1 != 0.0) {
1274 block_cut_N = 2;
1275 } else if (block_cut_L0 != 0.0 || block_cut_L1 != 0.0) {
1276 block_cut_N = 1;
1277 } else {
1278 block_cut_N = 0;
1279 }
1280
1281
1282 string geo_block_name;
1283 if (block_cut_N == 0) {
1284 geo_block_name = "geo_" + name + "_name";
1285 } else {
1286 geo_block_name = "geo_" + name + "_x_name";
1287 }
1288
1289 double block_T =
sqrt((block_R - block_r) * (block_R - block_r) + (block_W - block_w) * (block_W - block_w) / 4.0);
1290
1291 int nSect = 5;
1292 std::vector<G4TwoVector> xy(nSect);
1293 xy[0].set(0.0, 0.0);
1294 xy[1].set(-block_T, (block_W - block_w) / 2.0);
1295 xy[2].set(-block_t, block_W / 2.0);
1296 xy[3].set(-block_T, (block_w + block_W) / 2.0);
1297 xy[4].set(0.0, block_W);
1298
1299 G4TwoVector offset1(block_dr, 0.0), offset2(0.0, 0.0);
1300 G4double scale1 = 1.0, scale2 = 1.0;
1301
1302 G4VSolid* geo_block = new G4ExtrudedSolid(geo_block_name, xy, block_L / 2.0, offset1, scale1, offset2, scale2);
1303
1304 for (int i = 0; i < block_cut_N; ++i) {
1305 ostringstream oss_block_num;
1306 oss_block_num << i;
1307
1308 if (i == block_cut_N - 1) {
1309 geo_block_name = "geo_" + name + "_name";
1310 } else {
1311 geo_block_name = "geo_" + name + "_x" + oss_block_num.str() + "_name";
1312 }
1313 string geo_cut_name = "geo_" + name + "_cut" + oss_block_num.str() + "_name";
1314
1315 double cut_L = m_config.getParameter(prep + "cutL" + oss_block_num.str()) * unitFactor;
1316 double cut_W = m_config.getParameter(prep + "cutW" + oss_block_num.str()) * unitFactor;
1317 double cut_H = m_config.getParameter(prep + "cutH" + oss_block_num.str()) * unitFactor;
1318
1319 G4VSolid* geo_cut = new G4Box(geo_cut_name, cut_W / 2.0, cut_H / 2.0, cut_L / 2.0);
1320
1321 double cut_X0 = m_config.getParameter(prep + "cutX0" + oss_block_num.str()) * unitFactor;
1322 double cut_Y0 = m_config.getParameter(prep + "cutY0" + oss_block_num.str()) * unitFactor;
1323 double cut_Z0 = m_config.getParameter(prep + "cutZ0" + oss_block_num.str()) * unitFactor;
1324 double cut_PHI = m_config.getParameter(prep + "cutPHI" + oss_block_num.str());
1325
1326 G4Transform3D cut_transform = G4Translate3D(cut_X0, cut_Y0, cut_Z0);
1327 cut_transform = cut_transform * G4RotateY3D(cut_PHI / Unit::rad);
1328
1329 geo_block = new G4SubtractionSolid(geo_block_name, geo_block, geo_cut, cut_transform);
1330
1331 }
1332
1333
1334 string strMat_block = m_config.getParameterStr(prep + "Material");
1335 G4Material* mat_block = Materials::get(strMat_block);
1336
1337 string logi_block_name = "logi_" + name + "_name";
1338 G4LogicalVolume* logi_block = new G4LogicalVolume(geo_block, mat_block, logi_block_name);
1339
1340
1342
1343
1344 for (int i = 0; i < block_N; ++i) {
1345
1346 CryostatElement block;
1347 block.geo = geo_block;
1348 block.logi = logi_block;
1349
1350 double block_PHI = block_PHIs[i];
1351 double block_X0 = block_R * cos(block_PHI);
1352 double block_Y0 = block_R * sin(block_PHI);
1353 double block_dPHI = asin(block_W / block_R / 2.0);
1354
1355 block.transform = G4Translate3D(block_X0, block_Y0, block_Z0);
1356 block.transform = block.transform * G4RotateZ3D((block_PHI + block_dPHI) / Unit::rad);
1357
1358 ostringstream oss_block_num;
1359 oss_block_num << i;
1360 string phys_block_name = "phys_" + name + "-" + oss_block_num.str() + "_name";
1361 new G4PVPlacement(block.transform, block.logi, phys_block_name, &topVolume, false, 0);
1362
1363 elements[name] = block;
1364 }
1365 }
1366
1367 std::vector<std::string> SWXLayers;
1368 boost::split(SWXLayers, m_config.getParameterStr("SWXLayer"), boost::is_any_of(" "));
1369 for (const auto& name : SWXLayers) {
1370 prep = name + ".";
1371
1372
1373
1374 CryostatElement layer;
1375
1376 double layer_L = m_config.getParameter(prep + "L") * unitFactor;
1377 double layer_r1 = m_config.getParameter(prep + "r1") * unitFactor;
1378 double layer_r2 = m_config.getParameter(prep + "r2") * unitFactor;
1379 double layer_t = m_config.getParameter(prep + "t") * unitFactor;
1380 double layer_Z0 = m_config.getParameter(prep + "Z0") * unitFactor;
1381 int layer_cut_N = int(m_config.getParameter(prep + "N", 0));
1382
1383 layer.transform = G4Translate3D(0.0, 0.0, layer_Z0);
1384
1385
1386 string geo_layer_name;
1387 if (layer_cut_N == 0) {
1388 geo_layer_name = "geo_" + name + "_name";
1389 } else {
1390 geo_layer_name = "geo_" + name + "_x_name";
1391 }
1392
1393 G4VSolid* geo_layer = new G4Cons(geo_layer_name, layer_r1, layer_r1 + layer_t, layer_r2, layer_r2 + layer_t, layer_L / 2.0, 0.0,
1394 2.0 * M_PI);
1395
1396 for (int i = 0; i < layer_cut_N; ++i) {
1397 ostringstream oss_block_num;
1398 oss_block_num << i;
1399
1400
1401 double cut_type = m_config.getParameter(prep + "cutType" + oss_block_num.str());
1402 if (i == layer_cut_N - 1) {
1403 geo_layer_name = "geo_" + name + "_name";
1404 } else {
1405 geo_layer_name = "geo_" + name + "_x" + oss_block_num.str() + "_name";
1406 }
1407 string geo_cut_name = "geo_" + name + "_cut" + oss_block_num.str() + "_name";
1408
1409 G4VSolid* geo_cut;
1410
1411 if (cut_type == 0.0) {
1412 double cut_L = m_config.getParameter(prep + "cutL" + oss_block_num.str()) * unitFactor;
1413 double cut_W = m_config.getParameter(prep + "cutW" + oss_block_num.str()) * unitFactor;
1414 double cut_H = m_config.getParameter(prep + "cutH" + oss_block_num.str()) * unitFactor;
1415
1416 geo_cut = new G4Box(geo_cut_name, cut_W / 2.0, cut_H / 2.0, cut_L / 2.0);
1417 } else {
1418 double cut_L = m_config.getParameter(prep + "cutL" + oss_block_num.str()) * unitFactor;
1419 double cut_R = m_config.getParameter(prep + "cutR" + oss_block_num.str()) * unitFactor;
1420
1421 geo_cut = new G4Tubs(geo_cut_name, 0.0, cut_R, cut_L / 2.0, 0.0, 2.0 * M_PI);
1422 }
1423
1424 double cut_X0 = m_config.getParameter(prep + "cutX0" + oss_block_num.str()) * unitFactor;
1425 double cut_Y0 = m_config.getParameter(prep + "cutY0" + oss_block_num.str()) * unitFactor;
1426 double cut_Z0 = m_config.getParameter(prep + "cutZ0" + oss_block_num.str()) * unitFactor;
1427 double cut_PHI = m_config.getParameter(prep + "cutPHI" + oss_block_num.str());
1428 double cut_TH = m_config.getParameter(prep + "cutTH" + oss_block_num.str());
1429
1430 G4Transform3D cut_transform = G4Translate3D(cut_X0, cut_Y0, cut_Z0);
1431 cut_transform = cut_transform * G4RotateY3D(cut_PHI / Unit::rad);
1432 cut_transform = cut_transform * G4RotateX3D(cut_TH / Unit::rad);
1433
1434 geo_layer = new G4SubtractionSolid(geo_layer_name, geo_layer, geo_cut, layer.transform.inverse()*cut_transform);
1435
1436 }
1437
1438 layer.geo = geo_layer;
1439
1440
1441 string strMat_layer = m_config.getParameterStr(prep + "Material");
1442 G4Material* mat_layer = Materials::get(strMat_layer);
1443
1444 string logi_layer_name = "logi_" + name + "_name";
1445 G4LogicalVolume* logi_layer = new G4LogicalVolume(layer.geo, mat_layer, logi_layer_name);
1446 layer.logi = logi_layer;
1447
1448
1450
1451
1452 string phys_layer_name = "phys_" + name + "_name";
1453 new G4PVPlacement(layer.transform, layer.logi, phys_layer_name, &topVolume, false, 0);
1454
1455
1456 elements[name] = layer;
1457 }
1458 }
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569 }
double sqrt(double a)
sqrt for double
int intersect(const TRGCDCLpar &lp1, const TRGCDCLpar &lp2, CLHEP::HepVector &v1, CLHEP::HepVector &v2)
intersection
void setVisibility(G4LogicalVolume &volume, bool visible)
Helper function to quickly set the visibility of a given volume.
void setColor(G4LogicalVolume &volume, const std::string &color)
Set the color of a logical volume.