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
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 "TClonesArray.h"
37#include "TGeoArb8.h"
38#include "TGeoBBox.h"
39#include "TGeoBoolNode.h"
40#include "TGeoCompositeShape.h"
41#include "TGeoCone.h"
42#include "TGeoEltu.h"
43#include "TGeoManager.h"
44#include "TGeoMaterial.h"
45#include "TGeoShapeAssembly.h"
46#include "TGeoSphere.h"
47#include "TGeoTube.h"
48#include "TMath.h"
49#include "TParticle.h"
50#include "TVirtualMC.h"
51#include "vetoPoint.h"
52
53Double_t cm = 1; // cm
54Double_t m = 100 * cm; // m
55Double_t mm = 0.1 * cm; // mm
56
64 : SHiP::Detector<vetoPoint>("Veto", kTRUE, kVETO),
65 fFastMuon(kFALSE),
66 fFollowMuon(kFALSE) {
67 fUseSupport = 1;
68 fLiquidVeto = 1;
69}
70
71TGeoVolume* veto::GeoTrapezoid(TString xname, Double_t z_thick,
72 Double_t x_thick_start, Double_t x_thick_end,
73 Double_t y_thick_start, Double_t y_thick_end,
74 Int_t color, TGeoMedium* material,
75 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(TString xname, double dz, double a1, double b1,
172 double a2, double b2, double dA, double dB,
173 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(TString xname, double dz, bool isClockwise,
201 double a1, double a2, double b1, double b2,
202 double dA, double dB, Int_t color,
203 TGeoMedium* material, Bool_t sens = kFALSE) {
204 TGeoArb8* T1 = new TGeoArb8(dz);
205
206 if (isClockwise) {
207 T1->SetVertex(0, 0, 0);
208 T1->SetVertex(1, 0, b1);
209 T1->SetVertex(2, a1 + b1, b1);
210 T1->SetVertex(3, a1, 0);
211
212 T1->SetVertex(4, dA, dB);
213 T1->SetVertex(5, dA, dB + b2);
214 T1->SetVertex(6, dA + a2 + b2, dB + b2);
215 T1->SetVertex(7, dA + a2, dB);
216 } else {
217 T1->SetVertex(0, 0, 0);
218 T1->SetVertex(1, -a1, 0);
219 T1->SetVertex(2, -(a1 + b1), b1);
220 T1->SetVertex(3, 0, b1);
221
222 T1->SetVertex(4, -dA, dB);
223 T1->SetVertex(5, -(dA + a2), dB);
224 T1->SetVertex(6, -(dA + a2 + b2), dB + b2);
225 T1->SetVertex(7, -dA, dB + b2);
226 }
227
228 TGeoVolume* T = new TGeoVolume(xname, T1, material);
229 T->SetLineColor(color);
230 // and make the volumes sensitive..
231 if (sens) {
232 AddSensitiveVolume(T);
233 }
234 return T;
235}
236
237TGeoVolume* veto::GeoCornerLiSc2(TString xname, double dz, bool isClockwise,
238 double a1, double a2, double b1, double b2,
239 double dA, double dB, Int_t color,
240 TGeoMedium* material, Bool_t sens = kFALSE) {
241 TGeoArb8* T1 = new TGeoArb8(dz);
242
243 if (isClockwise) {
244 T1->SetVertex(0, 0, 0);
245 T1->SetVertex(1, 0, a1);
246 T1->SetVertex(2, b1, a1 + b1);
247 T1->SetVertex(3, b1, 0);
248
249 T1->SetVertex(4, dB, dA);
250 T1->SetVertex(5, dB, dA + a2);
251 T1->SetVertex(6, dB + b2, dA + a2 + b2);
252 T1->SetVertex(7, dB + b2, dA);
253 } else {
254 T1->SetVertex(0, 0, 0);
255 T1->SetVertex(1, b1, 0);
256 T1->SetVertex(2, b1, -(a1 + b1));
257 T1->SetVertex(3, 0, -a1);
258
259 T1->SetVertex(4, dB, -dA);
260 T1->SetVertex(5, dB + b2, -dA);
261 T1->SetVertex(6, dB + b2, -(dA + a2 + b2));
262 T1->SetVertex(7, dB, -(dA + a2));
263 }
264
265 TGeoVolume* T = new TGeoVolume(xname, T1, material);
266 T->SetLineColor(color);
267 // and make the volumes sensitive.
268 if (sens) {
269 AddSensitiveVolume(T);
270 }
271 return T;
272}
273
274TGeoVolumeAssembly* veto::GeoCornerRib(TString xname, double ribThick,
275 double lt1, double lt2, double dz,
276 double slopeX, double slopeY,
277 Int_t color, TGeoMedium* material,
278 Bool_t sens = kFALSE) {
279 Double_t wz = dz * 2;
280 double d = ribThick * sqrt(2) / 2;
281 double dx = slopeX * wz;
282 double dy = slopeY * wz;
283
284 TGeoArb8* T1 = new TGeoArb8(dz);
285 T1->SetVertex(0, lt1, lt1 - d);
286 T1->SetVertex(1, 0, -d);
287 T1->SetVertex(2, 0, 0);
288 T1->SetVertex(3, lt1, lt1);
289
290 T1->SetVertex(4, dx + lt2, dy + lt2 - d);
291 T1->SetVertex(5, dx, dy - d);
292 T1->SetVertex(6, dx, dy);
293 T1->SetVertex(7, dx + lt2, dy + lt2);
294
295 TGeoArb8* T2 = new TGeoArb8(dz);
296 T2->SetVertex(0, lt1 - d, lt1);
297 T2->SetVertex(1, lt1, lt1);
298 T2->SetVertex(2, 0, 0);
299 T2->SetVertex(3, -d, 0);
300
301 T2->SetVertex(4, dx + lt2 - d, dy + lt2);
302 T2->SetVertex(5, dx + lt2, dy + lt2);
303 T2->SetVertex(6, dx, dy);
304 T2->SetVertex(7, dx - d, dy);
305
306 TGeoVolume* T1v = new TGeoVolume("part", T1, material);
307 TGeoVolume* T2v = new TGeoVolume("part", T2, material);
308 T1v->SetLineColor(color);
309 T2v->SetLineColor(color);
310 if (sens) {
311 AddSensitiveVolume(T1v);
312 }
313 if (sens) {
314 AddSensitiveVolume(T2v);
315 }
316
317 TGeoVolumeAssembly* T = new TGeoVolumeAssembly(xname);
318 T->AddNode(T1v, 1, new TGeoTranslation(0, 0, 0));
319 T->AddNode(T2v, 2, new TGeoTranslation(0, 0, 0));
320 return T;
321}
322
323int veto::makeId(double z, double x, double y) {
324 double Z = z / 10;
325 double r = sqrt(x * x + y * y);
326 double phi = 999;
327 if (y >= 0)
328 phi = acos(x / r);
329 else
330 phi = -acos(x / r) + 2 * TMath::Pi();
331
332 phi = phi * 180 / TMath::Pi();
333 return static_cast<int>(Z) * 1000000 + static_cast<int>(r) * 1000 +
334 static_cast<int>(phi);
335}
336
337int veto::liscId(TString ShapeTypeName, int blockNr, int Zlayer, int number,
338 int position) {
339 int id = 999999;
340 int ShapeType = -1;
341
342 if (ShapeTypeName == "LiScX")
343 ShapeType = 1;
344 else if (ShapeTypeName == "LiScY")
345 ShapeType = 2;
346 else if (ShapeTypeName == "LiSc_S3")
347 ShapeType = 3;
348 else if (ShapeTypeName == "LiSc_S4")
349 ShapeType = 4;
350 else if (ShapeTypeName == "LiSc_S5")
351 ShapeType = 5;
352 else if (ShapeTypeName == "LiSc_S6")
353 ShapeType = 6;
354
355 if (ShapeType < 0)
356 id = 999999;
357 else
358 id = ShapeType * 100000 + blockNr * 10000 + Zlayer * 100 + number * 10 +
359 position;
360
361 return id;
362}
363
364void veto::AddBlock(TGeoVolumeAssembly* tInnerWall,
365 TGeoVolumeAssembly* tDecayVacuum,
366 TGeoVolumeAssembly* tOuterWall,
367 TGeoVolumeAssembly* tLongitRib,
368 TGeoVolumeAssembly* tVerticalRib,
369 TGeoVolumeAssembly* ttLiSc, int& liScCounter, int blockNr,
370 int nx, int ny, double z1, double z2, double Zshift,
371 double cell_thickness_z, double wallThick,
372 double liscThick1, double liscThick2, double ribThick) {
373 TString blockName = "block";
374 blockName += blockNr;
375
376 int ribColor = 15;
377
378 double wz = (z2 - z1);
379 double slX = (wx(z2) - wx(z1)) / 2 / wz;
380 double slY = (wy(z2) - wy(z1)) / 2 / wz;
381
382 double dZ = (cell_thickness_z - ribThick) / 2; // half space between ribs
383
384 double tX = 0;
385 double tY = 0;
386 double tZ = 0;
387 TString name("");
388
390 TString nameInnerWall = (TString)tInnerWall->GetName() + "_" + blockName;
391 TGeoVolume* TIW =
392 GeoTrapezoidHollow(nameInnerWall, wallThick, wz, wx(z1), wx(z2), wy(z1),
393 wy(z2), ribColor, supportMedIn);
394 tInnerWall->AddNode(TIW, 0, new TGeoTranslation(0, 0, Zshift));
395
397 TString nameDecayVacuum = (TString)tDecayVacuum->GetName() + "_" + blockName;
398 TGeoVolume* TDV = GeoTrapezoid(nameDecayVacuum, wz, wx(z1), wx(z2), wy(z1),
399 wy(z2), 1, decayVolumeMed);
400 TDV->SetVisibility(kFALSE);
401 tDecayVacuum->AddNode(TDV, 0, new TGeoTranslation(0, 0, Zshift));
402
404 TString nameOuterWall = (TString)tOuterWall->GetName() + "_" + blockName;
405 TGeoVolume* TOW = GeoTrapezoidHollow(
406 nameOuterWall, wallThick, wz, wx(z1) + 2 * (wallThick + liscThick1),
407 wx(z2) + 2 * (wallThick + liscThick2),
408 wy(z1) + 2 * (wallThick + liscThick1),
409 wy(z2) + 2 * (wallThick + liscThick2), ribColor, supportMedIn);
410 tOuterWall->AddNode(TOW, 0, new TGeoTranslation(0, 0, Zshift));
411
413
414 std::vector<TGeoVolume*> vLongitRibX(nx);
415 std::vector<TGeoVolume*> vLongitRibY(ny);
416
417 double z1_x_thickness_1 = wx(z1 + ribThick) + 2 * (wallThick + liscThick1);
418 double z1_x_thickness_2 =
419 wx(z1 + cell_thickness_z) + 2 * (wallThick + liscThick1);
420
421 double z1_x1_Step = (z1_x_thickness_1 - nx * ribThick) / (nx + 1);
422 double z1_x2_Step = (z1_x_thickness_2 - nx * ribThick) / (nx + 1);
423
424 double z1_y_thickness_1 = wy(z1 + ribThick) + 2 * (wallThick + liscThick1);
425 double z1_y_thickness_2 =
426 wy(z1 + cell_thickness_z) + 2 * (wallThick + liscThick1);
427
428 double z1_y1_Step = (z1_y_thickness_1 - ny * ribThick) / (ny + 1);
429 double z1_y2_Step = (z1_y_thickness_2 - ny * ribThick) / (ny + 1);
430
431 double z1_x1, z1_x2, z1_y1, z1_y2;
432
433 z1_x1 = z1_x_thickness_1 / 2;
434 z1_x2 = z1_x_thickness_2 / 2;
435
436 z1_y1 = z1_y_thickness_1 / 2 - liscThick1;
437 z1_y2 = z1_y_thickness_2 / 2 - liscThick2;
438
439 for (int i = 0; i < nx; i++) {
440 z1_x1 = z1_x1 - z1_x1_Step;
441 z1_x2 = z1_x2 - z1_x2_Step;
442
443 name = "";
444 name.Form("vLongitRibX_%s_phi%d", blockName.Data(),
445 makeId(0, z1_x1, z1_y1));
446 vLongitRibX.at(i) =
447 GeoSideObj(name, dZ, ribThick, liscThick1, ribThick, liscThick2,
448 z1_x2 - z1_x1, z1_y2 - z1_y1, ribColor, supportMedIn);
449
450 z1_x1 = z1_x1 - ribThick;
451 z1_x2 = z1_x2 - ribThick;
452 }
453
454 z1_y1 = z1_y_thickness_1 / 2;
455 z1_y2 = z1_y_thickness_2 / 2;
456
457 z1_x1 = z1_x_thickness_1 / 2 - liscThick1;
458 z1_x2 = z1_x_thickness_2 / 2 - liscThick2;
459
460 for (int i = 0; i < ny; i++) {
461 z1_y1 = z1_y1 - z1_y1_Step;
462 z1_y2 = z1_y2 - z1_y2_Step;
463
464 name = "";
465 name.Form("vLongitRibY_%s_phi%d", blockName.Data(),
466 makeId(0, z1_x1, z1_y1));
467 vLongitRibY.at(i) =
468 GeoSideObj(name, dZ, liscThick1, ribThick, liscThick2, ribThick,
469 z1_x2 - z1_x1, z1_y2 - z1_y1, ribColor, supportMedIn);
470 z1_y1 = z1_y1 - ribThick;
471 z1_y2 = z1_y2 - ribThick;
472 }
473
475
476 name = "CornerRib_L_" + blockName + "_id";
477 TGeoVolumeAssembly* CornerRib_L =
478 GeoCornerRib(name, ribThick, liscThick1, liscThick2, dZ, slX, slY,
479 ribColor, supportMedIn);
480 name = "CornerRib_R_" + blockName + "_id";
481 TGeoVolumeAssembly* CornerRib_R =
482 GeoCornerRib(name, ribThick, liscThick1, liscThick2, dZ, slY, slX,
483 ribColor, supportMedIn);
484
485 for (double zi = z1; zi < z2; zi += cell_thickness_z) {
486 int Zlayer = static_cast<int>(zi) / cell_thickness_z + 1;
487
489 TString nameVR("");
490 nameVR.Form("VetoVerticalRib_z%d", static_cast<int>(zi));
491 TGeoVolume* TVR = GeoTrapezoidHollow(
492 nameVR, liscThick1, ribThick, wx(zi) + 2 * wallThick,
493 wx(zi + ribThick) + 2 * wallThick, wy(zi) + 2 * wallThick,
494 wy(zi + ribThick) + 2 * wallThick, ribColor, supportMedIn);
495 tZ = Zshift - wz / 2 + zi - z1 + ribThick / 2;
496
497 tVerticalRib->AddNode(TVR, 0, new TGeoTranslation(0, 0, tZ));
498
499 if (z2 - zi < cell_thickness_z) continue;
500
501 tX = wx(zi + ribThick) / 2 + wallThick;
502 tY = wy(zi + ribThick) / 2 + wallThick;
503 tZ = tZ + cell_thickness_z / 2;
504
506 tLongitRib->AddNode(
507 CornerRib_L, makeId(zi, tX, tY),
508 new TGeoCombiTrans(tX, tY, tZ, new TGeoRotation("r", 0, 0, 0)));
509 tLongitRib->AddNode(
510 CornerRib_L, makeId(zi, -tX, -tY),
511 new TGeoCombiTrans(-tX, -tY, tZ, new TGeoRotation("r", 0, 0, 180)));
512 tLongitRib->AddNode(
513 CornerRib_R, makeId(zi, -tX, tY),
514 new TGeoCombiTrans(-tX, tY, tZ, new TGeoRotation("r", 0, 0, 90)));
515 tLongitRib->AddNode(
516 CornerRib_R, makeId(zi, tX, -tY),
517 new TGeoCombiTrans(tX, -tY, tZ, new TGeoRotation("r", 0, 0, 270)));
518
519 double zi_x_thickness_1 = wx(zi + ribThick) + 2 * (wallThick + liscThick1);
520 double zi_x_thickness_2 =
521 wx(zi + cell_thickness_z) + 2 * (wallThick + liscThick1);
522
523 double zi_x1_Step = (zi_x_thickness_1 - nx * ribThick) / (nx + 1);
524 double zi_x2_Step = (zi_x_thickness_2 - nx * ribThick) / (nx + 1);
525
526 double zi_y_thickness_1 = wy(zi + ribThick) + 2 * (wallThick + liscThick1);
527 double zi_y_thickness_2 =
528 wy(zi + cell_thickness_z) + 2 * (wallThick + liscThick1);
529
530 double zi_y1_Step = (zi_y_thickness_1 - ny * ribThick) / (ny + 1);
531 double zi_y2_Step = (zi_y_thickness_2 - ny * ribThick) / (ny + 1);
532
533 double zi_x1, zi_x2, zi_y1, zi_y2;
534
535 zi_x1 = zi_x_thickness_1 / 2 - liscThick1;
536 zi_x2 = zi_x_thickness_2 / 2 - liscThick1;
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", blockNr, Zlayer, 0, 0));
543 TGeoVolume* LiSc_S4 = GeoCornerLiSc2(
544 name, dZ, 0, zi_y1_Step - liscThick1, zi_y2_Step - liscThick2,
545 liscThick1, liscThick2, zi_y2_Step - zi_y1_Step, zi_x2 - zi_x1,
546 kMagenta - 10, vetoMed, true);
547 ttLiSc->AddNode(LiSc_S4, liscId("LiSc_S4", blockNr, Zlayer, 0, 1),
548 new TGeoCombiTrans(zi_x1, -(zi_y1 - zi_y1_Step), tZ,
549 new TGeoRotation("r", 0, 0, 0)));
550 ttLiSc->AddNode(LiSc_S4, liscId("LiSc_S4", blockNr, Zlayer, 0, 2),
551 new TGeoCombiTrans(-zi_x1, (zi_y1 - zi_y1_Step), tZ,
552 new TGeoRotation("r", 0, 0, 180)));
553
554 name = "";
555 name.Form("LiSc_S6_%d", liscId("LiSc_S6", blockNr, Zlayer, ny, 0));
556 TGeoVolume* LiSc_S6 = GeoCornerLiSc2(
557 name, dZ, 1, zi_y1_Step - liscThick1, zi_y2_Step - liscThick2,
558 liscThick1, liscThick2, zi_y2_Step - zi_y1_Step, zi_x2 - zi_x1,
559 kMagenta - 10, vetoMed, true);
560 ttLiSc->AddNode(LiSc_S6, liscId("LiSc_S6", blockNr, Zlayer, ny, 1),
561 new TGeoCombiTrans(zi_x1, (zi_y1 - zi_y1_Step), tZ,
562 new TGeoRotation("r", 0, 0, 0)));
563 ttLiSc->AddNode(LiSc_S6, liscId("LiSc_S6", blockNr, Zlayer, ny, 2),
564 new TGeoCombiTrans(-zi_x1, -(zi_y1 - zi_y1_Step), tZ,
565 new TGeoRotation("r", 0, 0, 180)));
566
567 for (int i = 0; i < ny; i++) {
568 zi_y1 = zi_y1 - zi_y1_Step;
569 zi_y2 = zi_y2 - zi_y2_Step;
570
571 tLongitRib->AddNode(vLongitRibY.at(i), makeId(zi, zi_x1, zi_y1),
572 new TGeoCombiTrans(zi_x1, (zi_y1 - ribThick), tZ,
573 new TGeoRotation("r", 0, 0, 0)));
574 tLongitRib->AddNode(vLongitRibY.at(i), makeId(zi, -zi_x1, -zi_y1),
575 new TGeoCombiTrans(-zi_x1, -(zi_y1 - ribThick), tZ,
576 new TGeoRotation("r", 0, 0, 180)));
577
578 if (i > 0) {
579 name = "";
580 name.Form("LiScY_%d", liscId("LiScY", blockNr, Zlayer, i, 0));
581 TGeoVolume* LiScY = GeoSideObj(
582 name, dZ, liscThick1, zi_y1_Step, liscThick2, zi_y2_Step,
583 zi_x2 - zi_x1, zi_y2 - zi_y1, kMagenta - 10, vetoMed, true);
584 ttLiSc->AddNode(LiScY, liscId("LiScY", blockNr, Zlayer, i, 1),
585 new TGeoCombiTrans(zi_x1, zi_y1, tZ,
586 new TGeoRotation("r", 0, 0, 0)));
587 ttLiSc->AddNode(LiScY, liscId("LiScY", blockNr, Zlayer, i, 2),
588 new TGeoCombiTrans(-zi_x1, -zi_y1, tZ,
589 new TGeoRotation("r", 0, 0, 180)));
590 }
591
592 zi_y1 = zi_y1 - ribThick;
593 zi_y2 = zi_y2 - ribThick;
594 }
595
596 zi_x1 = zi_x_thickness_1 / 2;
597 zi_x2 = zi_x_thickness_2 / 2;
598
599 zi_y1 = zi_y_thickness_1 / 2 - liscThick1;
600 zi_y2 = zi_y_thickness_2 / 2 - liscThick1;
601
602 name = "";
603 name.Form("LiSc_S3_%d", liscId("LiSc_S3", blockNr, Zlayer, 0, 0));
604
605 TGeoVolume* LiSc_S3 = GeoCornerLiSc1(
606 name, dZ, 0, zi_x1_Step - liscThick1 - ribThick / sqrt(2),
607 zi_x2_Step - liscThick2 - ribThick / sqrt(2), liscThick1, liscThick2,
608 zi_x2_Step - zi_x1_Step - ribThick / 2, zi_y2 - zi_y1, kMagenta - 10,
609 vetoMed, true);
610 ttLiSc->AddNode(LiSc_S3, liscId("LiSc_S3", blockNr, Zlayer, 0, 1),
611 new TGeoCombiTrans(-(zi_x1 - zi_x1_Step), zi_y1, tZ,
612 new TGeoRotation("r", 0, 0, 0)));
613 ttLiSc->AddNode(LiSc_S3, liscId("LiSc_S3", blockNr, Zlayer, 0, 2),
614 new TGeoCombiTrans((zi_x1 - zi_x1_Step), -zi_y1, tZ,
615 new TGeoRotation("r", 0, 0, 180)));
616
617 name = "";
618 name.Form("LiSc_S5_%d", liscId("LiSc_S5", blockNr, Zlayer, nx, 0));
619
620 TGeoVolume* LiSc_S5 = GeoCornerLiSc1(
621 name, dZ, 1, zi_x1_Step - liscThick1 - ribThick / sqrt(2),
622 zi_x2_Step - liscThick2 - ribThick / sqrt(2), liscThick1, liscThick2,
623 zi_x2_Step - zi_x1_Step - ribThick / 2, zi_y2 - zi_y1, kMagenta - 10,
624 vetoMed, true);
625 ttLiSc->AddNode(LiSc_S5, liscId("LiSc_S5", blockNr, Zlayer, nx, 1),
626 new TGeoCombiTrans((zi_x1 - zi_x1_Step), zi_y1, tZ,
627 new TGeoRotation("r", 0, 0, 0)));
628 ttLiSc->AddNode(LiSc_S5, liscId("LiSc_S5", blockNr, Zlayer, nx, 2),
629 new TGeoCombiTrans(-(zi_x1 - zi_x1_Step), -zi_y1, tZ,
630 new TGeoRotation("r", 0, 0, 180)));
631
632 for (int i = 0; i < nx; i++) {
633 zi_x1 = zi_x1 - zi_x1_Step;
634 zi_x2 = zi_x2 - zi_x2_Step;
635
636 tLongitRib->AddNode(vLongitRibX.at(i), makeId(zi, zi_x1, zi_y1),
637 new TGeoCombiTrans((zi_x1 - ribThick), zi_y1, tZ,
638 new TGeoRotation("r", 0, 0, 0)));
639 tLongitRib->AddNode(vLongitRibX.at(i), makeId(zi, -zi_x1, -zi_y1),
640 new TGeoCombiTrans(-(zi_x1 - ribThick), -zi_y1, tZ,
641 new TGeoRotation("r", 0, 0, 180)));
642
643 if (i > 0) {
644 name = "";
645 name.Form("LiScX_%d", liscId("LiScX", blockNr, Zlayer, i, 0));
646 TGeoVolume* LiScX = GeoSideObj(
647 name, dZ, zi_x1_Step, liscThick1, zi_x2_Step, liscThick2,
648 zi_x2 - zi_x1, zi_y2 - zi_y1, kMagenta - 10, vetoMed, true);
649 ttLiSc->AddNode(LiScX, liscId("LiScX", blockNr, Zlayer, i, 1),
650 new TGeoCombiTrans(zi_x1, zi_y1, tZ,
651 new TGeoRotation("r", 0, 0, 0)));
652 ttLiSc->AddNode(LiScX, liscId("LiScX", blockNr, Zlayer, i, 2),
653 new TGeoCombiTrans(-zi_x1, -zi_y1, tZ,
654 new TGeoRotation("r", 0, 0, 180)));
655 }
656
657 zi_x1 = zi_x1 - ribThick;
658 zi_x2 = zi_x2 - ribThick;
659 }
660 }
661}
662
663TGeoVolume* veto::MakeSegments() {
664 TGeoVolumeAssembly* tTankVol = new TGeoVolumeAssembly("T2");
665
666 Double_t cell_thickness_z0 =
667 800 * mm; // length of the first cell along z (800mm) 2024 version
668 Double_t cell_thickness_z =
669 820 * mm; // length of the cell along z (820mm) 2024 version
670
671 TString nameInnerWall = "VetoInnerWall";
672 TGeoVolumeAssembly* tInnerWall = new TGeoVolumeAssembly(nameInnerWall);
673
674 TString nameDecayVacuum = "DecayVacuum";
675 TGeoVolumeAssembly* tDecayVacuum = new TGeoVolumeAssembly(nameDecayVacuum);
676
677 TString nameOuterWall = "VetoOuterWall";
678 TGeoVolumeAssembly* tOuterWall = new TGeoVolumeAssembly(nameOuterWall);
679
680 TString nameLongitRib = "VetoLongitRib";
681 TGeoVolumeAssembly* tLongitRib = new TGeoVolumeAssembly(nameLongitRib);
682
683 TString nameVerticalRib = "VetoVerticalRib";
684 TGeoVolumeAssembly* tVerticalRib = new TGeoVolumeAssembly(nameVerticalRib);
685
686 TString nameLiSc = "VetoLiSc";
687 TGeoVolumeAssembly* ttLiSc = new TGeoVolumeAssembly(nameLiSc);
688 int liScCounter = 0;
689
690 int nx = 2; // number of Longitudinal ribs on X
691 int ny = 3; // number of Longitudinal ribs on Y
692
693 double wallThick = f_InnerSupportThickness;
694 double liscThick = f_VetoThickness;
695 double ribThick = f_RibThickness;
696
697 //******************************** Block1
698 //**************************************
699 double z1 = 0 * m;
700 double z2 = 800 * mm;
701 double wz = (z2 - z1);
702
703 double Zshift = wz / 2; // calibration of Z position
704
705 AddBlock(tInnerWall, tDecayVacuum, tOuterWall, tLongitRib, tVerticalRib,
706 ttLiSc, liScCounter, 1, nx, ny, z1, z2, Zshift, cell_thickness_z0,
707 wallThick, liscThick, liscThick, ribThick);
708
709 //******************************** Block2
710 //**************************************
711
712 Zshift += wz / 2;
713
714 z1 = 800 * mm;
715 z2 = 50.0 * m;
716 wz = (z2 - z1);
717
718 Zshift += wz / 2;
719
720 AddBlock(tInnerWall, tDecayVacuum, tOuterWall, tLongitRib, tVerticalRib,
721 ttLiSc, liScCounter, 2, nx, ny, z1, z2, Zshift, cell_thickness_z,
722 wallThick, liscThick, liscThick, ribThick);
723
724 double zi = z2;
725
726 TString nameVR("");
727 nameVR.Form("VetoVerticalRib_z%d", static_cast<int>(zi));
728 TGeoVolume* TVR = GeoTrapezoidHollow(
729 nameVR, liscThick, ribThick, wx(zi) + 2 * wallThick,
730 wx(zi + ribThick) + 2 * wallThick, wy(zi) + 2 * wallThick,
731 wy(zi + ribThick) + 2 * wallThick, 15, supportMedIn);
732 double tZ = Zshift - wz / 2 + zi - z1 + ribThick / 2;
733
734 tVerticalRib->AddNode(TVR, 0, new TGeoTranslation(0, 0, tZ));
735
736 tTankVol->AddNode(tInnerWall, 0, new TGeoTranslation(0, 0, 0));
737 tTankVol->AddNode(tDecayVacuum, 0, new TGeoTranslation(0, 0, 0));
738 tTankVol->AddNode(tOuterWall, 0, new TGeoTranslation(0, 0, 0));
739 tTankVol->AddNode(tVerticalRib, 0, new TGeoTranslation(0, 0, 0));
740 tTankVol->AddNode(tLongitRib, 0, new TGeoTranslation(0, 0, 0));
741 tTankVol->AddNode(ttLiSc, 0, new TGeoTranslation(0, 0, 0));
742
743 return tTankVol;
744}
745
746// -------------------------------------------------------------------------
760Bool_t veto::ProcessHits(FairVolume* vol) {
762 // Set parameters at entrance of volume. Reset ELoss.
763 if (gMC->IsTrackEntering()) {
764 fELoss = 0.;
765 fTime = gMC->TrackTime() * 1.0e09;
766 fLength = gMC->TrackLength();
767 gMC->TrackPosition(fPos);
768 gMC->TrackMomentum(fMom);
769 }
770 // Sum energy loss for all steps in the active volume
771 fELoss += gMC->Edep();
772
773 // Create vetoPoint at exit of active volume
774 if (gMC->IsTrackExiting() || gMC->IsTrackStop() ||
775 gMC->IsTrackDisappeared()) {
776 if (fELoss == 0.) {
777 return kFALSE;
778 }
779
780 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
781 fEventID = gMC->CurrentEvent();
782 Int_t veto_uniqueId;
783 gMC->CurrentVolID(veto_uniqueId);
784 TParticle* p = gMC->GetStack()->GetCurrentTrack();
785 Int_t pdgCode = p->GetPdgCode();
786 TLorentzVector pos;
787 gMC->TrackPosition(pos);
788 TLorentzVector Mom;
789 gMC->TrackMomentum(Mom);
790 Double_t xmean = (fPos.X() + pos.X()) / 2.;
791 Double_t ymean = (fPos.Y() + pos.Y()) / 2.;
792 Double_t zmean = (fPos.Z() + pos.Z()) / 2.;
793 AddHit(fEventID, fTrackID, veto_uniqueId, TVector3(xmean, ymean, zmean),
794 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss,
795 pdgCode, TVector3(pos.X(), pos.Y(), pos.Z()),
796 TVector3(Mom.Px(), Mom.Py(), Mom.Pz()));
797
798 // Increment number of veto det points in TParticle
799 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
800 stack->AddPoint(kVETO);
801 }
802
803 return kTRUE;
804}
805
807 if (!fFastMuon) {
808 return;
809 }
810 if (TMath::Abs(gMC->TrackPid()) != 13) {
811 gMC->StopTrack();
812 }
813}
814
824 TGeoVolume* top = gGeoManager->GetTopVolume();
825
826 ShipGeo::InitMedium("vacuums");
827 ShipGeo::InitMedium("Aluminum");
828 ShipGeo::InitMedium("helium");
829 ShipGeo::InitMedium("Scintillator");
830 ShipGeo::InitMedium("steel");
831
832 gGeoManager->SetNsegments(100);
833
834 vetoMed = gGeoManager->GetMedium(
835 vetoMed_name);
836 supportMedIn = gGeoManager->GetMedium(
838 supportMedOut = gGeoManager->GetMedium(
840 decayVolumeMed = gGeoManager->GetMedium(
841 decayVolumeMed_name); // decay volume, air/helium/vacuum
842 LOG(info) << "veto: Decay Volume medium set as: " << decayVolumeMed_name;
843 TGeoVolume* tDecayVol = new TGeoVolumeAssembly("DecayVolume");
844
845 TGeoVolume* seg = MakeSegments();
846 tDecayVol->AddNode(seg, 1, new TGeoTranslation(0, 0, 0));
847 top->AddNode(tDecayVol, 1, new TGeoTranslation(0, 0, zStartDecayVol)); //));
848
849 // only for fastMuon simulation, otherwise output becomes too big
850 if (fFastMuon && fFollowMuon) {
851 const char* Vol = "TGeoVolume";
852 const char* Cavern = "Cavern";
853 const char* Ain = "AbsorberAdd";
854 const char* Aout = "AbsorberAddCore";
855 TObjArray* volumelist = gGeoManager->GetListOfVolumes();
856 int lastvolume = volumelist->GetLast();
857 int volumeiterator = 0;
858 while (volumeiterator <= lastvolume) {
859 const char* volumename = volumelist->At(volumeiterator)->GetName();
860 const char* classname = volumelist->At(volumeiterator)->ClassName();
861 if (strstr(classname, Vol)) {
862 if (strstr(volumename, Cavern) || strstr(volumename, Ain) ||
863 strstr(volumename, Aout)) {
864 AddSensitiveVolume(gGeoManager->GetVolume(volumename));
865 LOG(info) << "veto: made sensitive for following muons: "
866 << volumename;
867 }
868 }
869 volumeiterator++;
870 }
871 }
872}
Double_t m
Double_t mm
@ kVETO
Int_t fTrackID
event index
Definition: Detector.h:85
TLorentzVector fPos
volume id
Definition: Detector.h:87
Double_t fTime
momentum at entrance
Definition: Detector.h:89
Double_t fELoss
length
Definition: Detector.h:91
vetoPoint * AddHit(Args &&... args)
Definition: Detector.h:38
TLorentzVector fMom
position at entrance
Definition: Detector.h:88
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 = Aluminum).
Definition: veto.h:103
int liscId(TString ShapeTypeName, int blockNr, int Zlayer, int number, int position)
Definition: veto.cxx:337
TString decayVolumeMed_name
medium of decay volume(Default= helium).
Definition: veto.h:107
Int_t fUseSupport
Definition: veto.h:126
Bool_t ProcessHits(FairVolume *v=0) override
Processes a hit in the veto detector.
Definition: veto.cxx:760
int makeId(double z, double x, double y)
Definition: veto.cxx:323
Bool_t fFollowMuon
Definition: veto.h:89
TGeoMedium * vetoMed
Definition: veto.h:109
TGeoMedium * supportMedOut
Definition: veto.h:111
TGeoMedium * decayVolumeMed
Definition: veto.h:112
TGeoVolume * GeoCornerLiSc2(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:237
TGeoVolume * MakeSegments()
Definition: veto.cxx:663
Float_t VetoStartInnerX
Width of the Vessel along X at the start.
Definition: veto.h:115
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:119
TGeoVolume * GeoSideObj(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
void PreTrack() override
Definition: veto.cxx:806
TGeoVolumeAssembly * GeoCornerRib(TString xname, double ribThick, double lt1, double lt2, double dz, double slopeX, double slopeY, Int_t color, TGeoMedium *material, Bool_t sens)
Definition: veto.cxx:274
Float_t f_VetoThickness
Thickness of the liquid scintillator along z(Default = 20cm).
Definition: veto.h:97
void AddBlock(TGeoVolumeAssembly *tInnerWall, TGeoVolumeAssembly *tDecayVacuum, TGeoVolumeAssembly *tOuterWall, TGeoVolumeAssembly *tLongitRib, TGeoVolumeAssembly *tVerticalRib, TGeoVolumeAssembly *ttLiSc, int &liScCounter, int blockNr, int nx, int ny, double z1, double z2, double Zshift, double dist, double wallThick, double liscThick1, double liscThick2, double ribThick)
Definition: veto.cxx:364
Float_t VetoEndInnerY
Length of the Vessel along Y at the end.
Definition: veto.h:121
TGeoVolume * GeoCornerLiSc1(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 zStartDecayVol
z Position of the Decay Volume start in the global coordinate system
Definition: veto.h:124
TGeoMedium * supportMedIn
Definition: veto.h:110
TString supportMedOut_name
medium of external support structure(Default = Aluminum).
Definition: veto.h:105
Bool_t fFastMuon
Definition: veto.h:89
Float_t f_InnerSupportThickness
Definition: veto.h:91
TGeoVolume * GeoTrapezoid(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:71
void ConstructGeometry() override
Constructs the detector geometry.
Definition: veto.cxx:823
TString vetoMed_name
medium of veto counter, liquid or plastic scintillator
Definition: veto.h:101
double wx(double z)
slope along the width (x)
Definition: veto.cxx:151
Float_t f_RibThickness
Definition: veto.h:98
veto()
Constructor for the Veto class.
Definition: veto.cxx:63
Float_t VetoStartInnerY
Length of the Vessel along Y at the start.
Definition: veto.h:117
Int_t fLiquidVeto
Flag option for Liquid Scintillator (Default=True).
Definition: veto.h:128
Definition: Detector.h:18
Int_t InitMedium(const char *name)
Definition: ShipGeoUtil.h:20
Double_t cm
for FairLogger, MESSAGE_ORIGIN
Definition: veto.cxx:53
Double_t m
Definition: veto.cxx:54
Double_t mm
Definition: veto.cxx:55