FairShip
Loading...
Searching...
No Matches
veto.cxx
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5// 09/07/2024
6// SBT software contact: anupama.reghunath@cern.ch
15
16#include "veto.h"
17
18#include <cmath>
19#include <iostream>
20#include <vector>
21
22#include "FairGeoBuilder.h"
23#include "FairGeoInterface.h"
24#include "FairGeoLoader.h"
25#include "FairGeoMedia.h"
26#include "FairGeoNode.h"
27#include "FairGeoVolume.h"
28#include "FairLogger.h"
29#include "FairRootManager.h"
30#include "FairRun.h"
31#include "FairRuntimeDb.h"
32#include "FairVolume.h"
33#include "ShipDetectorList.h"
34#include "ShipGeoUtil.h"
35#include "ShipStack.h"
36#include "ShipUnit.h"
37#include "TClonesArray.h"
38#include "TGeoArb8.h"
39#include "TGeoBBox.h"
40#include "TGeoBoolNode.h"
41#include "TGeoCompositeShape.h"
42#include "TGeoCone.h"
43#include "TGeoEltu.h"
44#include "TGeoManager.h"
45#include "TGeoMaterial.h"
46#include "TGeoShapeAssembly.h"
47#include "TGeoSphere.h"
48#include "TGeoTube.h"
49#include "TMath.h"
50#include "TParticle.h"
51#include "TVirtualMC.h"
52#include "vetoPoint.h"
53
54using ShipUnit::cm;
55using ShipUnit::m;
56using ShipUnit::mm;
57
65 : SHiP::Detector<vetoPoint>("Veto", kTRUE, kVETO),
66 fFastMuon(kFALSE),
67 fFollowMuon(kFALSE) {
68 fUseSupport = 1;
69 fLiquidVeto = 1;
70}
71
73 const TString& xname, Double_t z_thick, Double_t x_thick_start,
74 Double_t x_thick_end, Double_t y_thick_start, Double_t y_thick_end,
75 Int_t color, TGeoMedium* material, Bool_t sens = kFALSE) {
76 Double_t dz = z_thick / 2;
77 Double_t dx1 = x_thick_start / 2 - 1.E-6;
78 Double_t dx2 = x_thick_end / 2 - 1.E-6;
79 Double_t dy1 = y_thick_start / 2 - 1.E-6;
80 Double_t dy2 = y_thick_end / 2 - 1.E-6;
81 TGeoArb8* T1 = new TGeoArb8("T1" + xname, dz + 1.E-6);
82 T1->SetVertex(0, -dx1, -dy1);
83 T1->SetVertex(1, -dx1, dy1);
84 T1->SetVertex(2, dx1, dy1);
85 T1->SetVertex(3, dx1, -dy1);
86 T1->SetVertex(4, -dx2, -dy2);
87 T1->SetVertex(5, -dx2, dy2);
88 T1->SetVertex(6, dx2, dy2);
89 T1->SetVertex(7, dx2, -dy2);
90
91 TGeoVolume* T = new TGeoVolume(xname, T1, material);
92 T->SetLineColor(color);
93 if (sens) {
94 AddSensitiveVolume(T);
95 } // and make the volumes sensitive..
96 return T;
97}
98
100 TString xname, Double_t wallthick, Double_t z_thick, Double_t x_thick_start,
101 Double_t x_thick_end, Double_t y_thick_start, Double_t y_thick_end,
102 Int_t color, TGeoMedium* material, Bool_t sens = kFALSE) {
103 Double_t dx_start = x_thick_start / 2;
104 Double_t dy_start = y_thick_start / 2;
105 Double_t dx_end = x_thick_end / 2;
106 Double_t dy_end = y_thick_end / 2;
107 Double_t dz = z_thick / 2;
108
109 TString nm = xname.ReplaceAll(
110 "-", ""); // otherwise it will try to subtract "-" in TGeoComposteShape
111 Double_t dx1 = dx_start + wallthick;
112 Double_t dx2 = dx_end + wallthick;
113 Double_t dy1 = dy_start + wallthick;
114 Double_t dy2 = dy_end + wallthick;
115
116 TGeoArb8* T2 = new TGeoArb8("T2" + nm, dz);
117 T2->SetVertex(0, -dx1, -dy1);
118 T2->SetVertex(1, -dx1, dy1);
119 T2->SetVertex(2, dx1, dy1);
120 T2->SetVertex(3, dx1, -dy1);
121 T2->SetVertex(4, -dx2, -dy2);
122 T2->SetVertex(5, -dx2, dy2);
123 T2->SetVertex(6, dx2, dy2);
124 T2->SetVertex(7, dx2, -dy2);
125
126 Double_t tdx1 = dx_start;
127 Double_t tdx2 = dx_end;
128 Double_t tdy1 = dy_start;
129 Double_t tdy2 = dy_end;
130 TGeoArb8* T1 = new TGeoArb8("T1" + nm, dz + 1.E-6);
131 T1->SetVertex(0, -tdx1, -tdy1);
132 T1->SetVertex(1, -tdx1, tdy1);
133 T1->SetVertex(2, tdx1, tdy1);
134 T1->SetVertex(3, tdx1, -tdy1);
135 T1->SetVertex(4, -tdx2, -tdy2);
136 T1->SetVertex(5, -tdx2, tdy2);
137 T1->SetVertex(6, tdx2, tdy2);
138 T1->SetVertex(7, tdx2, -tdy2);
139
140 TGeoCompositeShape* T321 =
141 new TGeoCompositeShape("T3" + nm, "T2" + nm + "-T1" + nm);
142 TGeoVolume* T = new TGeoVolume(xname, T321, material);
143 T->SetLineColor(color);
144 // and make the volumes sensitive..
145 if (sens) {
146 AddSensitiveVolume(T);
147 }
148 return T;
149}
150
151double veto::wx(double z) { // calculate x thickness at z
152
153 double wx1 = VetoStartInnerX;
154 double wx2 = VetoEndInnerX;
155 double z1 = 0 * m;
156 double z2 = 50 * m;
157
158 return (wx1 + (z - z1) * (wx2 - wx1) / (z2 - z1));
159}
160
161double veto::wy(double z) { // calculate y thickness at z
162
163 double wy1 = VetoStartInnerY;
164 double wy2 = VetoEndInnerY;
165 double z1 = 0 * m;
166 double z2 = 50 * m;
167
168 return (wy1 + (z - z1) * (wy2 - wy1) / (z2 - z1));
169}
170
171TGeoVolume* veto::GeoSideObj(const TString& xname, double dz, double a1,
172 double b1, double a2, double b2, double dA,
173 double dB, Int_t color, TGeoMedium* material,
174 Bool_t sens = kFALSE) {
175 // a1- width in X, at the beginning
176 // b1- width in Y, at the beginning
177 // a2- width in X, at the end
178 // b2- width in Y, at the end
179
180 TGeoArb8* T1 = new TGeoArb8(dz);
181 T1->SetVertex(0, 0, 0);
182 T1->SetVertex(1, 0, b1);
183 T1->SetVertex(2, a1, b1);
184 T1->SetVertex(3, a1, 0);
185
186 T1->SetVertex(4, dA, dB);
187 T1->SetVertex(5, dA, dB + b2);
188 T1->SetVertex(6, dA + a2, dB + b2);
189 T1->SetVertex(7, dA + a2, dB);
190
191 TGeoVolume* T = new TGeoVolume(xname, T1, material);
192 T->SetLineColor(color);
193 // and make the volumes sensitive..
194 if (sens) {
195 AddSensitiveVolume(T);
196 }
197 return T;
198}
199
200TGeoVolume* veto::GeoCornerLiSc1(const TString& xname, double dz,
201 bool isClockwise, double a1, double a2,
202 double b1, double b2, double dA, double dB,
203 Int_t color, TGeoMedium* material,
204 Bool_t sens = kFALSE) {
205 TGeoArb8* T1 = new TGeoArb8(dz);
206
207 if (isClockwise) {
208 T1->SetVertex(0, 0, 0);
209 T1->SetVertex(1, 0, b1);
210 T1->SetVertex(2, a1 + b1, b1);
211 T1->SetVertex(3, a1, 0);
212
213 T1->SetVertex(4, dA, dB);
214 T1->SetVertex(5, dA, dB + b2);
215 T1->SetVertex(6, dA + a2 + b2, dB + b2);
216 T1->SetVertex(7, dA + a2, dB);
217 } else {
218 T1->SetVertex(0, 0, 0);
219 T1->SetVertex(1, -a1, 0);
220 T1->SetVertex(2, -(a1 + b1), b1);
221 T1->SetVertex(3, 0, b1);
222
223 T1->SetVertex(4, -dA, dB);
224 T1->SetVertex(5, -(dA + a2), dB);
225 T1->SetVertex(6, -(dA + a2 + b2), dB + b2);
226 T1->SetVertex(7, -dA, dB + b2);
227 }
228
229 TGeoVolume* T = new TGeoVolume(xname, T1, material);
230 T->SetLineColor(color);
231 // and make the volumes sensitive..
232 if (sens) {
233 AddSensitiveVolume(T);
234 }
235 return T;
236}
237
238TGeoVolume* veto::GeoCornerLiSc2(const TString& xname, double dz,
239 bool isClockwise, double a1, double a2,
240 double b1, double b2, double dA, double dB,
241 Int_t color, TGeoMedium* material,
242 Bool_t sens = kFALSE) {
243 TGeoArb8* T1 = new TGeoArb8(dz);
244
245 if (isClockwise) {
246 T1->SetVertex(0, 0, 0);
247 T1->SetVertex(1, 0, a1);
248 T1->SetVertex(2, b1, a1 + b1);
249 T1->SetVertex(3, b1, 0);
250
251 T1->SetVertex(4, dB, dA);
252 T1->SetVertex(5, dB, dA + a2);
253 T1->SetVertex(6, dB + b2, dA + a2 + b2);
254 T1->SetVertex(7, dB + b2, dA);
255 } else {
256 T1->SetVertex(0, 0, 0);
257 T1->SetVertex(1, b1, 0);
258 T1->SetVertex(2, b1, -(a1 + b1));
259 T1->SetVertex(3, 0, -a1);
260
261 T1->SetVertex(4, dB, -dA);
262 T1->SetVertex(5, dB + b2, -dA);
263 T1->SetVertex(6, dB + b2, -(dA + a2 + b2));
264 T1->SetVertex(7, dB, -(dA + a2));
265 }
266
267 TGeoVolume* T = new TGeoVolume(xname, T1, material);
268 T->SetLineColor(color);
269 // and make the volumes sensitive.
270 if (sens) {
271 AddSensitiveVolume(T);
272 }
273 return T;
274}
275
276TGeoVolumeAssembly* veto::GeoCornerRib(const TString& xname,
277 double rib_thickness, double lt1,
278 double lt2, double dz, double slopeX,
279 double slopeY, Int_t color,
280 TGeoMedium* material,
281 Bool_t sens = kFALSE) {
282 Double_t wz = dz * 2;
283 double d = rib_thickness * sqrt(2) / 2;
284 double dx = slopeX * wz;
285 double dy = slopeY * wz;
286
287 TGeoArb8* T1 = new TGeoArb8(dz);
288 T1->SetVertex(0, lt1, lt1 - d);
289 T1->SetVertex(1, 0, -d);
290 T1->SetVertex(2, 0, 0);
291 T1->SetVertex(3, lt1, lt1);
292
293 T1->SetVertex(4, dx + lt2, dy + lt2 - d);
294 T1->SetVertex(5, dx, dy - d);
295 T1->SetVertex(6, dx, dy);
296 T1->SetVertex(7, dx + lt2, dy + lt2);
297
298 TGeoArb8* T2 = new TGeoArb8(dz);
299 T2->SetVertex(0, lt1 - d, lt1);
300 T2->SetVertex(1, lt1, lt1);
301 T2->SetVertex(2, 0, 0);
302 T2->SetVertex(3, -d, 0);
303
304 T2->SetVertex(4, dx + lt2 - d, dy + lt2);
305 T2->SetVertex(5, dx + lt2, dy + lt2);
306 T2->SetVertex(6, dx, dy);
307 T2->SetVertex(7, dx - d, dy);
308
309 TGeoVolume* T1v = new TGeoVolume("part", T1, material);
310 TGeoVolume* T2v = new TGeoVolume("part", T2, material);
311 T1v->SetLineColor(color);
312 T2v->SetLineColor(color);
313 if (sens) {
314 AddSensitiveVolume(T1v);
315 }
316 if (sens) {
317 AddSensitiveVolume(T2v);
318 }
319
320 TGeoVolumeAssembly* T = new TGeoVolumeAssembly(xname);
321 T->AddNode(T1v, 1, new TGeoTranslation(0, 0, 0));
322 T->AddNode(T2v, 2, new TGeoTranslation(0, 0, 0));
323 return T;
324}
325
326int veto::makeId(double z, double x, double y) {
327 double Z = z / 10;
328 double r = sqrt(x * x + y * y);
329 double phi = 999;
330 if (y >= 0)
331 phi = acos(x / r);
332 else
333 phi = -acos(x / r) + 2 * TMath::Pi();
334
335 phi = phi * 180 / TMath::Pi();
336 return static_cast<int>(Z) * 1000000 + static_cast<int>(r) * 1000 +
337 static_cast<int>(phi);
338}
339
340int veto::liscId(const TString& ShapeTypeName, int block_number, int Zlayer,
341 int number, int position) {
342 int id = 999999;
343 int ShapeType = -1;
344
345 if (ShapeTypeName == "LiScX")
346 ShapeType = 1;
347 else if (ShapeTypeName == "LiScY")
348 ShapeType = 2;
349 else if (ShapeTypeName == "LiSc_S3")
350 ShapeType = 3;
351 else if (ShapeTypeName == "LiSc_S4")
352 ShapeType = 4;
353 else if (ShapeTypeName == "LiSc_S5")
354 ShapeType = 5;
355 else if (ShapeTypeName == "LiSc_S6")
356 ShapeType = 6;
357
358 if (ShapeType < 0)
359 id = 999999;
360 else
361 id = ShapeType * 100000 + block_number * 10000 + Zlayer * 100 +
362 number * 10 + position;
363
364 return id;
365}
366
367void veto::add_block(TGeoVolumeAssembly* outer_wall,
368 TGeoVolumeAssembly* longitudinal_rib,
369 TGeoVolumeAssembly* vertical_rib, TGeoVolumeAssembly* lisc,
370 int block_number, int nx, int ny, double z1, double z2,
371 double z_shift, double cell_thickness_z,
372 double wall_thickness, double lisc_thickness_start,
373 double lisc_thickness_end, double rib_thickness) {
374 TString blockName = "block";
375 blockName += block_number;
376
377 int ribColor = 15;
378
379 double wz = (z2 - z1);
380 double slX = (wx(z2) - wx(z1)) / 2 / wz;
381 double slY = (wy(z2) - wy(z1)) / 2 / wz;
382
383 double dZ =
384 (cell_thickness_z - rib_thickness) / 2; // half space between ribs
385
386 double tX = 0;
387 double tY = 0;
388 double tZ = 0;
389 TString name("");
390
392 TString nameOuterWall = (TString)outer_wall->GetName() + "_" + blockName;
393 TGeoVolume* TOW =
394 GeoTrapezoidHollow(nameOuterWall, wall_thickness, wz,
395 wx(z1) + 2 * (wall_thickness + lisc_thickness_start),
396 wx(z2) + 2 * (wall_thickness + lisc_thickness_end),
397 wy(z1) + 2 * (wall_thickness + lisc_thickness_start),
398 wy(z2) + 2 * (wall_thickness + lisc_thickness_end),
399 ribColor, supportMedIn);
400 outer_wall->AddNode(TOW, 0, new TGeoTranslation(0, 0, z_shift));
401
403 std::vector<TGeoVolume*> vLongitRibX(nx);
404 std::vector<TGeoVolume*> vLongitRibY(ny);
405
406 double z1_x_thickness_1 =
407 wx(z1 + rib_thickness) + 2 * (wall_thickness + lisc_thickness_start);
408 double z1_x_thickness_2 =
409 wx(z1 + cell_thickness_z) + 2 * (wall_thickness + lisc_thickness_start);
410
411 double z1_x1_Step = (z1_x_thickness_1 - nx * rib_thickness) / (nx + 1);
412 double z1_x2_Step = (z1_x_thickness_2 - nx * rib_thickness) / (nx + 1);
413
414 double z1_y_thickness_1 =
415 wy(z1 + rib_thickness) + 2 * (wall_thickness + lisc_thickness_start);
416 double z1_y_thickness_2 =
417 wy(z1 + cell_thickness_z) + 2 * (wall_thickness + lisc_thickness_start);
418
419 double z1_y1_Step = (z1_y_thickness_1 - ny * rib_thickness) / (ny + 1);
420 double z1_y2_Step = (z1_y_thickness_2 - ny * rib_thickness) / (ny + 1);
421
422 double z1_x1, z1_x2, z1_y1, z1_y2;
423
424 z1_x1 = z1_x_thickness_1 / 2;
425 z1_x2 = z1_x_thickness_2 / 2;
426
427 z1_y1 = z1_y_thickness_1 / 2 - lisc_thickness_start;
428 z1_y2 = z1_y_thickness_2 / 2 - lisc_thickness_end;
429
430 for (int i = 0; i < nx; i++) {
431 z1_x1 = z1_x1 - z1_x1_Step;
432 z1_x2 = z1_x2 - z1_x2_Step;
433
434 name = "";
435 name.Form("vLongitRibX_%s_phi%d", blockName.Data(),
436 makeId(0, z1_x1, z1_y1));
437 vLongitRibX.at(i) =
438 GeoSideObj(name, dZ, rib_thickness, lisc_thickness_start, rib_thickness,
439 lisc_thickness_end, z1_x2 - z1_x1, z1_y2 - z1_y1, ribColor,
441
442 z1_x1 = z1_x1 - rib_thickness;
443 z1_x2 = z1_x2 - rib_thickness;
444 }
445
446 z1_y1 = z1_y_thickness_1 / 2;
447 z1_y2 = z1_y_thickness_2 / 2;
448
449 z1_x1 = z1_x_thickness_1 / 2 - lisc_thickness_start;
450 z1_x2 = z1_x_thickness_2 / 2 - lisc_thickness_end;
451
452 for (int i = 0; i < ny; i++) {
453 z1_y1 = z1_y1 - z1_y1_Step;
454 z1_y2 = z1_y2 - z1_y2_Step;
455
456 name = "";
457 name.Form("vLongitRibY_%s_phi%d", blockName.Data(),
458 makeId(0, z1_x1, z1_y1));
459 vLongitRibY.at(i) = GeoSideObj(
460 name, dZ, lisc_thickness_start, rib_thickness, lisc_thickness_end,
461 rib_thickness, z1_x2 - z1_x1, z1_y2 - z1_y1, ribColor, supportMedIn);
462 z1_y1 = z1_y1 - rib_thickness;
463 z1_y2 = z1_y2 - rib_thickness;
464 }
465
467
468 name = "CornerRib_L_" + blockName + "_id";
469 TGeoVolumeAssembly* CornerRib_L =
470 GeoCornerRib(name, rib_thickness, lisc_thickness_start,
471 lisc_thickness_end, dZ, slX, slY, ribColor, supportMedIn);
472 name = "CornerRib_R_" + blockName + "_id";
473 TGeoVolumeAssembly* CornerRib_R =
474 GeoCornerRib(name, rib_thickness, lisc_thickness_start,
475 lisc_thickness_end, dZ, slY, slX, ribColor, supportMedIn);
476
477 const int nZSteps =
478 static_cast<int>(std::floor((z2 - z1) / cell_thickness_z)) + 1;
479 for (int iz = 0; iz < nZSteps; ++iz) {
480 const double zi = z1 + iz * cell_thickness_z;
481 if (zi >= z2) break;
482 int Zlayer = static_cast<int>(zi) / cell_thickness_z + 1;
483
485 TString nameVR("");
486 nameVR.Form("VetoVerticalRib_z%d", static_cast<int>(zi));
487 TGeoVolume* TVR = GeoTrapezoidHollow(
488 nameVR, lisc_thickness_start, rib_thickness,
489 wx(zi) + 2 * wall_thickness,
490 wx(zi + rib_thickness) + 2 * wall_thickness,
491 wy(zi) + 2 * wall_thickness,
492 wy(zi + rib_thickness) + 2 * wall_thickness, ribColor, supportMedIn);
493 tZ = z_shift - wz / 2 + zi - z1 + rib_thickness / 2;
494
495 vertical_rib->AddNode(TVR, 0, new TGeoTranslation(0, 0, tZ));
496
497 if (z2 - zi < cell_thickness_z) continue;
498
499 tX = wx(zi + rib_thickness) / 2 + wall_thickness;
500 tY = wy(zi + rib_thickness) / 2 + wall_thickness;
501 tZ = tZ + cell_thickness_z / 2;
502
504 longitudinal_rib->AddNode(
505 CornerRib_L, makeId(zi, tX, tY),
506 new TGeoCombiTrans(tX, tY, tZ, new TGeoRotation("r", 0, 0, 0)));
507 longitudinal_rib->AddNode(
508 CornerRib_L, makeId(zi, -tX, -tY),
509 new TGeoCombiTrans(-tX, -tY, tZ, new TGeoRotation("r", 0, 0, 180)));
510 longitudinal_rib->AddNode(
511 CornerRib_R, makeId(zi, -tX, tY),
512 new TGeoCombiTrans(-tX, tY, tZ, new TGeoRotation("r", 0, 0, 90)));
513 longitudinal_rib->AddNode(
514 CornerRib_R, makeId(zi, tX, -tY),
515 new TGeoCombiTrans(tX, -tY, tZ, new TGeoRotation("r", 0, 0, 270)));
516
517 double zi_x_thickness_1 =
518 wx(zi + rib_thickness) + 2 * (wall_thickness + lisc_thickness_start);
519 double zi_x_thickness_2 =
520 wx(zi + cell_thickness_z) + 2 * (wall_thickness + lisc_thickness_start);
521
522 double zi_x1_Step = (zi_x_thickness_1 - nx * rib_thickness) / (nx + 1);
523 double zi_x2_Step = (zi_x_thickness_2 - nx * rib_thickness) / (nx + 1);
524
525 double zi_y_thickness_1 =
526 wy(zi + rib_thickness) + 2 * (wall_thickness + lisc_thickness_start);
527 double zi_y_thickness_2 =
528 wy(zi + cell_thickness_z) + 2 * (wall_thickness + lisc_thickness_start);
529
530 double zi_y1_Step = (zi_y_thickness_1 - ny * rib_thickness) / (ny + 1);
531 double zi_y2_Step = (zi_y_thickness_2 - ny * rib_thickness) / (ny + 1);
532
533 double zi_x1, zi_x2, zi_y1, zi_y2;
534
535 zi_x1 = zi_x_thickness_1 / 2 - lisc_thickness_start;
536 zi_x2 = zi_x_thickness_2 / 2 - lisc_thickness_start;
537
538 zi_y1 = zi_y_thickness_1 / 2;
539 zi_y2 = zi_y_thickness_2 / 2;
540
541 name = "";
542 name.Form("LiSc_S4_%d", liscId("LiSc_S4", block_number, Zlayer, 0, 0));
543 TGeoVolume* LiSc_S4 =
544 GeoCornerLiSc2(name, dZ, 0, zi_y1_Step - lisc_thickness_start,
545 zi_y2_Step - lisc_thickness_end, lisc_thickness_start,
546 lisc_thickness_end, zi_y2_Step - zi_y1_Step,
547 zi_x2 - zi_x1, kMagenta - 10, vetoMed, true);
548 lisc->AddNode(LiSc_S4, liscId("LiSc_S4", block_number, Zlayer, 0, 1),
549 new TGeoCombiTrans(zi_x1, -(zi_y1 - zi_y1_Step), tZ,
550 new TGeoRotation("r", 0, 0, 0)));
551 lisc->AddNode(LiSc_S4, liscId("LiSc_S4", block_number, Zlayer, 0, 2),
552 new TGeoCombiTrans(-zi_x1, (zi_y1 - zi_y1_Step), tZ,
553 new TGeoRotation("r", 0, 0, 180)));
554
555 name = "";
556 name.Form("LiSc_S6_%d", liscId("LiSc_S6", block_number, Zlayer, ny, 0));
557 TGeoVolume* LiSc_S6 =
558 GeoCornerLiSc2(name, dZ, 1, zi_y1_Step - lisc_thickness_start,
559 zi_y2_Step - lisc_thickness_end, lisc_thickness_start,
560 lisc_thickness_end, zi_y2_Step - zi_y1_Step,
561 zi_x2 - zi_x1, kMagenta - 10, vetoMed, true);
562 lisc->AddNode(LiSc_S6, liscId("LiSc_S6", block_number, Zlayer, ny, 1),
563 new TGeoCombiTrans(zi_x1, (zi_y1 - zi_y1_Step), tZ,
564 new TGeoRotation("r", 0, 0, 0)));
565 lisc->AddNode(LiSc_S6, liscId("LiSc_S6", block_number, Zlayer, ny, 2),
566 new TGeoCombiTrans(-zi_x1, -(zi_y1 - zi_y1_Step), tZ,
567 new TGeoRotation("r", 0, 0, 180)));
568
569 for (int i = 0; i < ny; i++) {
570 zi_y1 = zi_y1 - zi_y1_Step;
571 zi_y2 = zi_y2 - zi_y2_Step;
572
573 longitudinal_rib->AddNode(
574 vLongitRibY.at(i), makeId(zi, zi_x1, zi_y1),
575 new TGeoCombiTrans(zi_x1, (zi_y1 - rib_thickness), tZ,
576 new TGeoRotation("r", 0, 0, 0)));
577 longitudinal_rib->AddNode(
578 vLongitRibY.at(i), makeId(zi, -zi_x1, -zi_y1),
579 new TGeoCombiTrans(-zi_x1, -(zi_y1 - rib_thickness), tZ,
580 new TGeoRotation("r", 0, 0, 180)));
581
582 if (i > 0) {
583 name = "";
584 name.Form("LiScY_%d", liscId("LiScY", block_number, Zlayer, i, 0));
585 TGeoVolume* LiScY =
586 GeoSideObj(name, dZ, lisc_thickness_start, zi_y1_Step,
587 lisc_thickness_end, zi_y2_Step, zi_x2 - zi_x1,
588 zi_y2 - zi_y1, kMagenta - 10, vetoMed, true);
589 lisc->AddNode(LiScY, liscId("LiScY", block_number, Zlayer, i, 1),
590 new TGeoCombiTrans(zi_x1, zi_y1, tZ,
591 new TGeoRotation("r", 0, 0, 0)));
592 lisc->AddNode(LiScY, liscId("LiScY", block_number, Zlayer, i, 2),
593 new TGeoCombiTrans(-zi_x1, -zi_y1, tZ,
594 new TGeoRotation("r", 0, 0, 180)));
595 }
596
597 zi_y1 = zi_y1 - rib_thickness;
598 zi_y2 = zi_y2 - rib_thickness;
599 }
600
601 zi_x1 = zi_x_thickness_1 / 2;
602 zi_x2 = zi_x_thickness_2 / 2;
603
604 zi_y1 = zi_y_thickness_1 / 2 - lisc_thickness_start;
605 zi_y2 = zi_y_thickness_2 / 2 - lisc_thickness_start;
606
607 name = "";
608 name.Form("LiSc_S3_%d", liscId("LiSc_S3", block_number, Zlayer, 0, 0));
609
610 TGeoVolume* LiSc_S3 = GeoCornerLiSc1(
611 name, dZ, 0,
612 zi_x1_Step - lisc_thickness_start - rib_thickness / sqrt(2),
613 zi_x2_Step - lisc_thickness_end - rib_thickness / sqrt(2),
614 lisc_thickness_start, lisc_thickness_end,
615 zi_x2_Step - zi_x1_Step - rib_thickness / 2, zi_y2 - zi_y1,
616 kMagenta - 10, vetoMed, true);
617 lisc->AddNode(LiSc_S3, liscId("LiSc_S3", block_number, Zlayer, 0, 1),
618 new TGeoCombiTrans(-(zi_x1 - zi_x1_Step), zi_y1, tZ,
619 new TGeoRotation("r", 0, 0, 0)));
620 lisc->AddNode(LiSc_S3, liscId("LiSc_S3", block_number, Zlayer, 0, 2),
621 new TGeoCombiTrans((zi_x1 - zi_x1_Step), -zi_y1, tZ,
622 new TGeoRotation("r", 0, 0, 180)));
623
624 name = "";
625 name.Form("LiSc_S5_%d", liscId("LiSc_S5", block_number, Zlayer, nx, 0));
626
627 TGeoVolume* LiSc_S5 = GeoCornerLiSc1(
628 name, dZ, 1,
629 zi_x1_Step - lisc_thickness_start - rib_thickness / sqrt(2),
630 zi_x2_Step - lisc_thickness_end - rib_thickness / sqrt(2),
631 lisc_thickness_start, lisc_thickness_end,
632 zi_x2_Step - zi_x1_Step - rib_thickness / 2, zi_y2 - zi_y1,
633 kMagenta - 10, vetoMed, true);
634 lisc->AddNode(LiSc_S5, liscId("LiSc_S5", block_number, Zlayer, nx, 1),
635 new TGeoCombiTrans((zi_x1 - zi_x1_Step), zi_y1, tZ,
636 new TGeoRotation("r", 0, 0, 0)));
637 lisc->AddNode(LiSc_S5, liscId("LiSc_S5", block_number, Zlayer, nx, 2),
638 new TGeoCombiTrans(-(zi_x1 - zi_x1_Step), -zi_y1, tZ,
639 new TGeoRotation("r", 0, 0, 180)));
640
641 for (int i = 0; i < nx; i++) {
642 zi_x1 = zi_x1 - zi_x1_Step;
643 zi_x2 = zi_x2 - zi_x2_Step;
644
645 longitudinal_rib->AddNode(
646 vLongitRibX.at(i), makeId(zi, zi_x1, zi_y1),
647 new TGeoCombiTrans((zi_x1 - rib_thickness), zi_y1, tZ,
648 new TGeoRotation("r", 0, 0, 0)));
649 longitudinal_rib->AddNode(
650 vLongitRibX.at(i), makeId(zi, -zi_x1, -zi_y1),
651 new TGeoCombiTrans(-(zi_x1 - rib_thickness), -zi_y1, tZ,
652 new TGeoRotation("r", 0, 0, 180)));
653
654 if (i > 0) {
655 name = "";
656 name.Form("LiScX_%d", liscId("LiScX", block_number, Zlayer, i, 0));
657 TGeoVolume* LiScX =
658 GeoSideObj(name, dZ, zi_x1_Step, lisc_thickness_start, zi_x2_Step,
659 lisc_thickness_end, zi_x2 - zi_x1, zi_y2 - zi_y1,
660 kMagenta - 10, vetoMed, true);
661 lisc->AddNode(LiScX, liscId("LiScX", block_number, Zlayer, i, 1),
662 new TGeoCombiTrans(zi_x1, zi_y1, tZ,
663 new TGeoRotation("r", 0, 0, 0)));
664 lisc->AddNode(LiScX, liscId("LiScX", block_number, Zlayer, i, 2),
665 new TGeoCombiTrans(-zi_x1, -zi_y1, tZ,
666 new TGeoRotation("r", 0, 0, 180)));
667 }
668
669 zi_x1 = zi_x1 - rib_thickness;
670 zi_x2 = zi_x2 - rib_thickness;
671 }
672 }
673}
674
675TGeoVolume* veto::make_segments() {
676 TGeoVolumeAssembly* tTankVol = new TGeoVolumeAssembly("T2");
677
678 Double_t cell_thickness_z0 =
679 800 * mm; // length of the first cell along z (800mm) 2024 version
680 Double_t cell_thickness_z =
681 820 * mm; // length of the cell along z (820mm) 2024 version
682
683 TString nameOuterWall = "VetoOuterWall";
684 TGeoVolumeAssembly* outer_wall = new TGeoVolumeAssembly(nameOuterWall);
685
686 TString nameLongitRib = "VetoLongitRib";
687 TGeoVolumeAssembly* longitudinal_rib = new TGeoVolumeAssembly(nameLongitRib);
688
689 TString nameVerticalRib = "VetoVerticalRib";
690 TGeoVolumeAssembly* vertical_rib = new TGeoVolumeAssembly(nameVerticalRib);
691
692 TString nameLiSc = "VetoLiSc";
693 TGeoVolumeAssembly* lisc = new TGeoVolumeAssembly(nameLiSc);
694
695 int nx = 2; // number of Longitudinal ribs on X
696 int ny = 3; // number of Longitudinal ribs on Y
697
698 double wall_thickness = f_InnerSupportThickness;
699 double lisc_thickness = f_VetoThickness;
700 double rib_thickness = f_RibThickness;
701
702 //******************************** Block1
703 //**************************************
704 double z1 = 0 * m;
705 double z2 = 800 * mm;
706 double wz = (z2 - z1);
707
708 double z_shift = wz / 2; // calibration of Z position
709
710 add_block(outer_wall, longitudinal_rib, vertical_rib, lisc, 1, nx, ny, z1, z2,
711 z_shift, cell_thickness_z0, wall_thickness, lisc_thickness,
712 lisc_thickness, rib_thickness);
713
714 //******************************** Block2
715 //**************************************
716
717 z_shift += wz / 2;
718
719 z1 = 800 * mm;
720 z2 = 50.0 * m;
721 wz = (z2 - z1);
722
723 z_shift += wz / 2;
724
725 add_block(outer_wall, longitudinal_rib, vertical_rib, lisc, 2, nx, ny, z1, z2,
726 z_shift, cell_thickness_z, wall_thickness, lisc_thickness,
727 lisc_thickness, rib_thickness);
728
729 double zi = z2;
730
731 TString nameVR("");
732 nameVR.Form("VetoVerticalRib_z%d", static_cast<int>(zi));
733 TGeoVolume* TVR = GeoTrapezoidHollow(
734 nameVR, lisc_thickness, rib_thickness, wx(zi) + 2 * wall_thickness,
735 wx(zi + rib_thickness) + 2 * wall_thickness, wy(zi) + 2 * wall_thickness,
736 wy(zi + rib_thickness) + 2 * wall_thickness, 15, supportMedIn);
737 double tZ = z_shift - wz / 2 + zi - z1 + rib_thickness / 2;
738
739 vertical_rib->AddNode(TVR, 0, new TGeoTranslation(0, 0, tZ));
740
745 const double z_start = 0 * m;
746 const double z_end = 50 * m;
747 const double balloon_thickness = f_he_balloon_thickness;
748 TGeoVolume* vessel = make_geo_trapezoid(
749 "VetoInnerWall", z_end - z_start, wx(z_start) + 2 * wall_thickness,
750 wx(z_end) + 2 * wall_thickness, wy(z_start) + 2 * wall_thickness,
751 wy(z_end) + 2 * wall_thickness, 15, supportMedIn);
752 TGeoVolume* decay_medium = nullptr;
753 if (balloon_thickness > 0) {
754 TGeoVolume* liner =
755 make_geo_trapezoid("HeBalloon", z_end - z_start, wx(z_start), wx(z_end),
756 wy(z_start), wy(z_end), kGreen, f_he_balloon_med);
757 decay_medium = make_geo_trapezoid(
758 "decay_medium", (z_end - z_start) - 2 * balloon_thickness,
759 wx(z_start + balloon_thickness) - 2 * balloon_thickness,
760 wx(z_end - balloon_thickness) - 2 * balloon_thickness,
761 wy(z_start + balloon_thickness) - 2 * balloon_thickness,
762 wy(z_end - balloon_thickness) - 2 * balloon_thickness, 1,
764 liner->AddNode(decay_medium, 0);
765 vessel->AddNode(liner, 0);
766 } else {
767 decay_medium = make_geo_trapezoid("decay_medium", z_end - z_start,
768 wx(z_start), wx(z_end), wy(z_start),
769 wy(z_end), 1, decayVolumeMed);
770 vessel->AddNode(decay_medium, 0);
771 }
772 decay_medium->SetVisibility(kFALSE);
773 tTankVol->AddNode(vessel, 0,
774 new TGeoTranslation(0, 0, (z_start + z_end) / 2));
775
776 tTankVol->AddNode(outer_wall, 0, new TGeoTranslation(0, 0, 0));
777 tTankVol->AddNode(vertical_rib, 0, new TGeoTranslation(0, 0, 0));
778 tTankVol->AddNode(longitudinal_rib, 0, new TGeoTranslation(0, 0, 0));
779 tTankVol->AddNode(lisc, 0, new TGeoTranslation(0, 0, 0));
780
781 return tTankVol;
782}
783
784// -------------------------------------------------------------------------
798Bool_t veto::ProcessHits(FairVolume* vol) {
800 // Set parameters at entrance of volume. Reset ELoss.
801 if (gMC->IsTrackEntering()) {
802 fELoss = 0.;
803 fTime = gMC->TrackTime() * 1.0e09;
804 fLength = gMC->TrackLength();
805 gMC->TrackPosition(fPos);
806 gMC->TrackMomentum(fMom);
807 }
808 // Sum energy loss for all steps in the active volume
809 fELoss += gMC->Edep();
810
811 // Create vetoPoint at exit of active volume
812 if (gMC->IsTrackExiting() || gMC->IsTrackStop() ||
813 gMC->IsTrackDisappeared()) {
814 if (fELoss == 0.) {
815 return kFALSE;
816 }
817
818 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
819 fEventID = gMC->CurrentEvent();
820 Int_t veto_uniqueId;
821 gMC->CurrentVolID(veto_uniqueId);
822 TParticle* p = gMC->GetStack()->GetCurrentTrack();
823 Int_t pdgCode = p->GetPdgCode();
824 TLorentzVector pos;
825 gMC->TrackPosition(pos);
826 TLorentzVector Mom;
827 gMC->TrackMomentum(Mom);
828 Double_t xmean = (fPos.X() + pos.X()) / 2.;
829 Double_t ymean = (fPos.Y() + pos.Y()) / 2.;
830 Double_t zmean = (fPos.Z() + pos.Z()) / 2.;
831 AddHit(fEventID, fTrackID, veto_uniqueId, TVector3(xmean, ymean, zmean),
832 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss,
833 pdgCode, TVector3(pos.X(), pos.Y(), pos.Z()),
834 TVector3(Mom.Px(), Mom.Py(), Mom.Pz()));
835
836 // Increment number of veto det points in TParticle
837 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
838 stack->AddPoint(kVETO);
839 }
840
841 return kTRUE;
842}
843
845 if (!fFastMuon) {
846 return;
847 }
848 if (TMath::Abs(gMC->TrackPid()) != 13) {
849 gMC->StopTrack();
850 }
851}
852
860
862 TGeoVolume* top = gGeoManager->GetTopVolume();
863
869
870 gGeoManager->SetNsegments(100);
871
872 vetoMed = gGeoManager->GetMedium(
873 vetoMed_name);
874 supportMedIn = gGeoManager->GetMedium(
876 supportMedOut = gGeoManager->GetMedium(
878 decayVolumeMed = gGeoManager->GetMedium(
879 decayVolumeMed_name); // decay volume, air/helium/vacuum
881 gGeoManager->GetMedium(f_he_balloon_med_name); // He Balloon medium, pvc
882 LOG(info) << "veto: Decay Volume medium set as: " << decayVolumeMed_name;
883 TGeoVolume* tDecayVol = new TGeoVolumeAssembly("DecayVolume");
884
885 TGeoVolume* seg = make_segments();
886 tDecayVol->AddNode(seg, 1, new TGeoTranslation(0, 0, 0));
887 top->AddNode(tDecayVol, 1, new TGeoTranslation(0, 0, zStartDecayVol)); //));
888
889 // only for fastMuon simulation, otherwise output becomes too big
890 if (fFastMuon && fFollowMuon) {
891 const char* Vol = "TGeoVolume";
892 const char* Cavern = "Cavern";
893 const char* Ain = "AbsorberAdd";
894 const char* Aout = "AbsorberAddCore";
895 TObjArray* volumelist = gGeoManager->GetListOfVolumes();
896 int lastvolume = volumelist->GetLast();
897 int volumeiterator = 0;
898 while (volumeiterator <= lastvolume) {
899 const char* volumename = volumelist->At(volumeiterator)->GetName();
900 const char* classname = volumelist->At(volumeiterator)->ClassName();
901 if (strstr(classname, Vol)) {
902 if (strstr(volumename, Cavern) || strstr(volumename, Ain) ||
903 strstr(volumename, Aout)) {
904 AddSensitiveVolume(gGeoManager->GetVolume(volumename));
905 LOG(info) << "veto: made sensitive for following muons: "
906 << volumename;
907 }
908 }
909 volumeiterator++;
910 }
911 }
912}
constexpr Double_t m
@ kVETO
vetoPoint * AddHit(Args &&... args)
Definition Detector.h:38
TGeoVolume * GeoTrapezoidHollow(TString xname, Double_t thick, Double_t wz, Double_t wX_start, Double_t wX_end, Double_t wY_start, Double_t wY_end, Int_t color, TGeoMedium *material, Bool_t sens)
Definition veto.cxx:99
TString supportMedIn_name
medium of internal support structure(Default = Aluminium).
Definition veto.h:110
TGeoVolumeAssembly * GeoCornerRib(const TString &xname, double rib_thickness, double lt1, double lt2, double dz, double slopeX, double slopeY, Int_t color, TGeoMedium *material, Bool_t sens)
Definition veto.cxx:276
TString decayVolumeMed_name
medium of decay volume(Default= helium).
Definition veto.h:114
Int_t fUseSupport
Definition veto.h:136
int makeId(double z, double x, double y)
Definition veto.cxx:326
Bool_t fFollowMuon
Definition veto.h:94
TGeoMedium * vetoMed
Definition veto.h:118
TGeoMedium * supportMedOut
Definition veto.h:120
TGeoMedium * decayVolumeMed
Definition veto.h:121
TGeoMedium * f_he_balloon_med
Definition veto.h:122
TGeoVolume * GeoCornerLiSc1(const TString &xname, double dz, bool isClockwise, double a1, double a2, double b1, double b2, double dA, double dB, Int_t color, TGeoMedium *material, Bool_t sens)
Definition veto.cxx:200
Float_t VetoStartInnerX
Width of the Vessel along X at the start.
Definition veto.h:125
double wy(double z)
slope along the length (y)
Definition veto.cxx:161
Float_t VetoEndInnerX
Width of the Vessel along X at the end.
Definition veto.h:129
TGeoVolume * make_geo_trapezoid(const TString &xname, Double_t wz, Double_t wX_start, Double_t wX_end, Double_t wY_start, Double_t wY_end, Int_t color, TGeoMedium *material, Bool_t sens)
Definition veto.cxx:72
void PreTrack() override
Definition veto.cxx:844
TGeoVolume * GeoCornerLiSc2(const TString &xname, double dz, bool isClockwise, double a1, double a2, double b1, double b2, double dA, double dB, Int_t color, TGeoMedium *material, Bool_t sens)
Definition veto.cxx:238
Float_t f_VetoThickness
Thickness of the liquid scintillator along z(Default = 20cm).
Definition veto.h:102
TGeoVolume * make_segments()
Definition veto.cxx:675
Bool_t ProcessHits(FairVolume *v=nullptr) override
Processes a hit in the veto detector.
Definition veto.cxx:798
Float_t f_he_balloon_thickness
Thickness of the He Balloon.
Definition veto.h:105
Float_t VetoEndInnerY
Length of the Vessel along Y at the end.
Definition veto.h:131
Float_t zStartDecayVol
z Position of the Decay Volume start in the global coordinate system
Definition veto.h:134
TGeoMedium * supportMedIn
Definition veto.h:119
TString supportMedOut_name
medium of external support structure(Default = Aluminium).
Definition veto.h:112
Bool_t fFastMuon
Definition veto.h:94
Float_t f_InnerSupportThickness
Definition veto.h:96
void ConstructGeometry() override
Constructs the detector geometry.
Definition veto.cxx:861
TString vetoMed_name
medium of veto counter, liquid or plastic scintillator
Definition veto.h:108
int liscId(const TString &ShapeTypeName, int block_number, int Zlayer, int number, int position)
Definition veto.cxx:340
TGeoVolume * GeoSideObj(const TString &xname, double dz, double a1, double b1, double a2, double b2, double dA, double dB, Int_t color, TGeoMedium *material, Bool_t sens)
Definition veto.cxx:171
TString f_he_balloon_med_name
medium of He Balloon(Default= PVC).
Definition veto.h:116
double wx(double z)
slope along the width (x)
Definition veto.cxx:151
Float_t f_RibThickness
Definition veto.h:103
veto()
Constructor for the Veto class.
Definition veto.cxx:64
Float_t VetoStartInnerY
Length of the Vessel along Y at the start.
Definition veto.h:127
Int_t fLiquidVeto
Flag option for Liquid Scintillator (Default=True).
Definition veto.h:138
void add_block(TGeoVolumeAssembly *outer_wall, TGeoVolumeAssembly *longitudinal_rib, TGeoVolumeAssembly *vertical_rib, TGeoVolumeAssembly *lisc, int block_number, int nx, int ny, double z1, double z2, double z_shift, double cell_thickness_z, double wall_thickness, double lisc_thickness_start, double lisc_thickness_end, double rib_thickness)
Definition veto.cxx:367
constexpr double mm
Definition ShipUnit.h:25
Int_t InitMedium(const char *name)
Definition ShipGeoUtil.h:22
constexpr double cm
Definition ShipUnit.h:23
constexpr double mm
Definition ShipUnit.h:25
constexpr double m
Definition ShipUnit.h:24