FairShip
Loading...
Searching...
No Matches
ShipMagnet.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#include "ShipMagnet.h"
6
7#include "FairRun.h" // for FairRun
8#include "FairRuntimeDb.h" // for FairRuntimeDb
9#include "ShipGeoUtil.h"
10#include "TGeoManager.h"
11// #include "FairGeoMedia.h"
12// #include "FairGeoBuilder.h"
13
14#include <iosfwd> // for ostream
15#include <iostream> // for operator<<, basic_ostream, etc
16
17#include "FairGeoBuilder.h"
18#include "FairGeoInterface.h"
19#include "FairGeoMedia.h"
20#include "TGeoBBox.h"
21#include "TGeoCompositeShape.h"
22#include "TGeoElement.h"
23#include "TGeoEltu.h"
24#include "TGeoMaterial.h"
25#include "TGeoMedium.h"
26#include "TGeoTube.h"
27#include "TList.h" // for TListIter, TList (ptr only)
28#include "TObjArray.h" // for TObjArray
29#include "TString.h" // for TString
30
31ShipMagnet::~ShipMagnet() = default;
32ShipMagnet::ShipMagnet() : FairModule("ShipMagnet", "") {}
33
34ShipMagnet::ShipMagnet(const char* name, const char* Title, Double_t z, Int_t c,
35 Double_t dx, Double_t dy, Double_t fl, Double_t YW,
36 Double_t YD, Double_t CT)
37 : FairModule(name, Title) {
38 fDesign = c;
39 fSpecMagz = z;
40 fDy = dy;
41 fDx = dx;
42 floorheight = fl;
43 YokeWidth = YW;
44 YokeDepth = YD;
45 CoilThick = CT;
46}
47
48// private method make support of magnet
49TGeoVolume* ShipMagnet::MagnetSupport(Double_t hwidth, Double_t hheight,
50 Double_t dz, Int_t colour,
51 TGeoMedium* material) {
52 [[maybe_unused]] TGeoBBox* ms = new TGeoBBox("ms", hwidth, hheight - 1., dz);
53 // try to make SHiP like logo in support
54 Double_t swidth = 30.; //
55 // 6 cutouts from the front
56 Double_t r25 = hheight - swidth / 2.;
57 Double_t r1346 = hwidth - swidth / 2;
58 Double_t alpha = atan(hheight / hwidth) * 180. / TMath::Pi();
59 [[maybe_unused]] TGeoTubeSeg* FL1 =
60 new TGeoTubeSeg("FL1", swidth, r1346, dz + 1., 5., alpha - 5.);
61 [[maybe_unused]] TGeoTubeSeg* FL3 =
62 new TGeoTubeSeg("FL3", swidth, r1346, dz + 1., 180 - alpha + 5., 175.);
63 [[maybe_unused]] TGeoTubeSeg* FL4 =
64 new TGeoTubeSeg("FL4", swidth, r1346, dz + 1., 185., 180. + alpha - 5.);
65 [[maybe_unused]] TGeoTubeSeg* FL6 =
66 new TGeoTubeSeg("FL6", swidth, r1346, dz + 1., 360. - alpha + 5., 355.);
67 [[maybe_unused]] TGeoTubeSeg* FL2 = new TGeoTubeSeg(
68 "FL2", swidth, r25, dz + 1., alpha + 5., 180 - alpha - 5.);
69 [[maybe_unused]] TGeoTubeSeg* FL5 = new TGeoTubeSeg(
70 "FL5", swidth, r25, dz + 1., 180. + alpha + 5., 360. - alpha - 5.);
71
72 // 6 cutouts from the side
73 r1346 = dz - swidth / 2;
74 alpha = atan(hheight / dz) * 180. / TMath::Pi();
75 // cout << "magsupport: "<< swidth<<", "<<r25<<", "<< r1346<<", "<<alpha
76 // <<endl;
77 [[maybe_unused]] TGeoTubeSeg* SL1 =
78 new TGeoTubeSeg("SL1", swidth, r1346, hwidth + 1., 5., alpha - 5.);
79 [[maybe_unused]] TGeoTubeSeg* SL3 = new TGeoTubeSeg(
80 "SL3", swidth, r1346, hwidth + 1., 180 - alpha + 5., 175.);
81 [[maybe_unused]] TGeoTubeSeg* SL4 = new TGeoTubeSeg(
82 "SL4", swidth, r1346, hwidth + 1., 185., 180. + alpha - 5.);
83 [[maybe_unused]] TGeoTubeSeg* SL6 = new TGeoTubeSeg(
84 "SL6", swidth, r1346, hwidth + 1., 360. - alpha + 5., 355.);
85 [[maybe_unused]] TGeoTubeSeg* SL2 = new TGeoTubeSeg(
86 "SL2", swidth, r25, hwidth + 1., alpha + 5., 180 - alpha - 5.);
87 [[maybe_unused]] TGeoTubeSeg* SL5 = new TGeoTubeSeg(
88 "SL5", swidth, r25, hwidth + 1., 180. + alpha + 5., 360. - alpha - 5.);
89 TGeoRotation* r = new TGeoRotation("r");
90 r->RotateY(90.);
91 r->RegisterYourself();
92
93 TGeoCompositeShape* TS = new TGeoCompositeShape(
94 "TS", "ms-FL1-FL2-FL3-FL4-FL5-FL6-SL1:r-SL2:r-SL3:r-SL4:r-SL5:r-SL6:r");
95
96 TGeoVolume* T = new TGeoVolume("TSUP", TS, material);
97 T->SetLineColor(colour);
98 return T;
99}
101 TGeoVolume* top = gGeoManager->GetTopVolume();
102 ShipGeo::InitMedium("iron");
103 TGeoMedium* Fe = gGeoManager->GetMedium("iron");
104 ShipGeo::InitMedium("Aluminium");
105 TGeoMedium* Al = gGeoManager->GetMedium("Aluminium");
106 TGeoVolumeAssembly* tMagnet = new TGeoVolumeAssembly("SHiPMagnet");
107 top->AddNode(tMagnet, 1, new TGeoTranslation(0, 0, 0));
108
109 Double_t cm = 1;
110 Double_t m = 100 * cm;
111 if (fDesign == 1) {
112 // magnet yoke
113 [[maybe_unused]] TGeoBBox* magyoke1 =
114 new TGeoBBox("magyoke1", 350, 350, 125);
115 [[maybe_unused]] TGeoBBox* magyoke2 =
116 new TGeoBBox("magyoke2", 250, 250, 126);
117
118 TGeoCompositeShape* magyokec =
119 new TGeoCompositeShape("magyokec", "magyoke1-magyoke2");
120 TGeoVolume* magyoke = new TGeoVolume("magyoke", magyokec, Fe);
121 magyoke->SetLineColor(kBlue);
122 // magyoke->SetTransparency(50);
123 tMagnet->AddNode(magyoke, 1, new TGeoTranslation(0, 0, 1940));
124
125 // magnet
126 [[maybe_unused]] TGeoTubeSeg* magnet1a =
127 new TGeoTubeSeg("magnet1a", 250, 300, 35, 45, 135);
128 [[maybe_unused]] TGeoTubeSeg* magnet1b =
129 new TGeoTubeSeg("magnet1b", 250, 300, 35, 45, 135);
130 [[maybe_unused]] TGeoTubeSeg* magnet1c =
131 new TGeoTubeSeg("magnet1c", 250, 270, 125, 45, 60);
132 [[maybe_unused]] TGeoTubeSeg* magnet1d =
133 new TGeoTubeSeg("magnet1d", 250, 270, 125, 120, 135);
134
135 // magnet composite shape matrices
136 TGeoTranslation* m1 = new TGeoTranslation(0, 0, 160);
137 m1->SetName("m1");
138 m1->RegisterYourself();
139 TGeoTranslation* m2 = new TGeoTranslation(0, 0, -160);
140 m2->SetName("m2");
141 m2->RegisterYourself();
142
143 TGeoCompositeShape* magcomp1 = new TGeoCompositeShape(
144 "magcomp1", "magnet1a:m1+magnet1b:m2+magnet1c+magnet1d");
145 TGeoVolume* magnet1 = new TGeoVolume("magnet1", magcomp1, Fe);
146 magnet1->SetLineColor(kYellow);
147 tMagnet->AddNode(magnet1, 1,
148 new TGeoTranslation(0, 0, fSpecMagz)); // was 1940
149
150 TGeoRotation m3;
151 m3.SetAngles(180, 0, 0);
152 TGeoTranslation m4(0, 0, fSpecMagz); // was 1940
153 TGeoCombiTrans m5(m4, m3);
154 TGeoHMatrix* m6 = new TGeoHMatrix(m5);
155 tMagnet->AddNode(magnet1, 2, m6);
156 } else if (fDesign == 2 ||
157 fDesign ==
158 3) { // fDesign==2 TP version, fDesign==3, rectangular version
159 Double_t Yokel = 1.25 * m;
160 Double_t magnetIncrease = 100. * cm;
161 // magnet yoke
162 Double_t bradius = fDy / 2.;
163 [[maybe_unused]] TGeoBBox* magyoke1 =
164 new TGeoBBox("magyoke1", fDx + 0.7 * m, bradius + 1.2 * m, Yokel);
165 [[maybe_unused]] TGeoBBox* magyoke2 = new TGeoBBox(
166 "magyoke2", fDx - 0.3 * m, bradius + 0.2 * m, Yokel + 0.01 * cm);
167
168 TGeoCompositeShape* magyokec =
169 new TGeoCompositeShape("magyokec", "magyoke1-magyoke2");
170 TGeoVolume* magyoke = new TGeoVolume("magyoke", magyokec, Fe);
171 magyoke->SetLineColor(kBlue);
172 tMagnet->AddNode(magyoke, 1, new TGeoTranslation(0, 0, fSpecMagz));
173
174 Double_t hsupport = (10. * m - (bradius + 1.2 * m) - floorheight) / 2.;
175 TGeoVolume* SMS = MagnetSupport(fDx + 0.7 * m, hsupport, Yokel, 15, Fe);
176 tMagnet->AddNode(
177 SMS, 1,
178 new TGeoTranslation(0, -bradius - 1.2 * m - hsupport, fSpecMagz));
179
180 // Attempt to make Al coils...
181 TGeoCompositeShape* MCoilc;
182 if (fDesign == 2) {
183 [[maybe_unused]] TGeoEltu* C2 = new TGeoEltu(
184 "C2", fDx, bradius + 0.5 * m, Yokel + 0.6 * m + magnetIncrease / 2.);
185 [[maybe_unused]] TGeoEltu* C1 =
186 new TGeoEltu("C1", fDx - 0.3 * m, bradius + 0.2 * m,
187 Yokel + 0.601 * m + magnetIncrease / 2.);
188 [[maybe_unused]] TGeoBBox* Box1 =
189 new TGeoBBox("Box1", 1. * m, bradius + 0.51 * m,
190 Yokel + 0.61 * m + magnetIncrease / 2.);
191 [[maybe_unused]] TGeoBBox* Box2 =
192 new TGeoBBox("Box2", fDx + 0.01 * m, bradius - 0.5 * m,
193 Yokel + 0.01 * m + magnetIncrease / 2.);
194 MCoilc = new TGeoCompositeShape("MCoilc", "C2-C1-magyokec-Box1-Box2");
195 } else {
196 [[maybe_unused]] TGeoBBox* C2 = new TGeoBBox(
197 "C2", fDx, bradius + 0.5 * m, Yokel + 0.6 * m + magnetIncrease / 2.);
198 [[maybe_unused]] TGeoBBox* C1 =
199 new TGeoBBox("C1", fDx - 0.3 * m, bradius + 0.2 * m,
200 Yokel + 0.601 * m + magnetIncrease / 2.);
201 MCoilc = new TGeoCompositeShape("MCoilc", "C2-C1-magyokec");
202 }
203 TGeoVolume* MCoil = new TGeoVolume("MCoil", MCoilc, Al);
204 MCoil->SetLineColor(kYellow);
205
206 tMagnet->AddNode(MCoil, 1, new TGeoTranslation(0, 0, fSpecMagz));
207
208 } else if (fDesign == 4) { // rectangular a la MISIS, full opening for vessel
209 // define dimensions
210 Double_t xaperture = fDx; // half apertures
211 Double_t yaperture = fDy;
212 // built the yoke
213 [[maybe_unused]] TGeoBBox* magyoke1 = new TGeoBBox(
214 "magyoke1", xaperture + YokeWidth, yaperture + YokeWidth, YokeDepth);
215 [[maybe_unused]] TGeoBBox* magyoke2 =
216 new TGeoBBox("magyoke2", xaperture, yaperture, YokeDepth + 1.);
217 TGeoCompositeShape* magyokec =
218 new TGeoCompositeShape("magyokec", "magyoke1-magyoke2");
219 // and a epsilon larger yoke to subtract while making the coils
220 [[maybe_unused]] TGeoBBox* my1 =
221 new TGeoBBox("my1", xaperture + YokeWidth, yaperture + YokeWidth,
222 YokeDepth + 0.1 * cm);
223 [[maybe_unused]] TGeoBBox* my2 = new TGeoBBox(
224 "my2", xaperture - 0.1 * cm, yaperture - 0.1 * cm, YokeDepth + 1.);
225 [[maybe_unused]] TGeoCompositeShape* myc =
226 new TGeoCompositeShape("myc", "my1-my2");
227 TGeoVolume* magyoke = new TGeoVolume("magyoke", magyokec, Fe);
228 magyoke->SetLineColor(kBlue);
229 tMagnet->AddNode(magyoke, 1, new TGeoTranslation(0, 0, fSpecMagz));
230 // and the coils: top
231 [[maybe_unused]] TGeoTubeSeg* CTop = new TGeoTubeSeg(
232 "CTop", 1. * cm, YokeWidth, YokeDepth + CoilThick + 1. * cm, 0., 180.);
233 TGeoTranslation* t1 =
234 new TGeoTranslation("t1", xaperture, yaperture - CoilThick, 0.);
235 t1->RegisterYourself();
236 TGeoTranslation* t2 =
237 new TGeoTranslation("t2", -xaperture, yaperture - CoilThick, 0.);
238 t2->RegisterYourself();
239 TGeoCompositeShape* CTop1 = new TGeoCompositeShape("CTop1", "CTop:t1-myc");
240 TGeoCompositeShape* CTop2 = new TGeoCompositeShape("CTop2", "CTop:t2-myc");
241 TGeoVolume* MCoil1 = new TGeoVolume("MCoil1", CTop1, Al);
242 TGeoVolume* MCoil2 = new TGeoVolume("MCoil2", CTop2, Al);
243 MCoil1->SetLineColor(kYellow);
244 tMagnet->AddNode(MCoil1, 1, new TGeoTranslation(0, 0, fSpecMagz));
245 MCoil2->SetLineColor(kYellow);
246 tMagnet->AddNode(MCoil2, 1, new TGeoTranslation(0, 0, fSpecMagz));
247 // coils bottom
248 [[maybe_unused]] TGeoTubeSeg* CBot =
249 new TGeoTubeSeg("CBot", 1. * cm, YokeWidth,
250 YokeDepth + CoilThick + 1. * cm, 180., 360.);
251 TGeoTranslation* b1 =
252 new TGeoTranslation("b1", xaperture, -yaperture + CoilThick, 0.);
253 b1->RegisterYourself();
254 TGeoTranslation* b2 =
255 new TGeoTranslation("b2", -xaperture, -yaperture + CoilThick, 0.);
256 b2->RegisterYourself();
257 TGeoCompositeShape* CBot1 = new TGeoCompositeShape("CBot1", "CBot:b1-myc");
258 TGeoCompositeShape* CBot2 = new TGeoCompositeShape("CBot2", "CBot:b2-myc");
259 TGeoVolume* MCoil3 = new TGeoVolume("MCoil3", CBot1, Al);
260 TGeoVolume* MCoil4 = new TGeoVolume("MCoil4", CBot2, Al);
261 MCoil3->SetLineColor(kYellow);
262 tMagnet->AddNode(MCoil3, 1, new TGeoTranslation(0, 0, fSpecMagz));
263 MCoil4->SetLineColor(kYellow);
264 tMagnet->AddNode(MCoil4, 1, new TGeoTranslation(0, 0, fSpecMagz));
265 // add vertical coils
266 TGeoBBox* CVert = new TGeoBBox("CVert", YokeWidth / 2.,
267 yaperture - CoilThick, CoilThick / 2.);
268 TGeoVolume* CV = new TGeoVolume("CV", CVert, Al);
269 CV->SetLineColor(kYellow);
270 tMagnet->AddNode(
271 CV, 1,
272 new TGeoTranslation(xaperture + YokeWidth / 2., 0,
273 fSpecMagz - YokeDepth - CoilThick / 2.));
274 tMagnet->AddNode(
275 CV, 2,
276 new TGeoTranslation(-xaperture - YokeWidth / 2., 0,
277 fSpecMagz - YokeDepth - CoilThick / 2.));
278 tMagnet->AddNode(
279 CV, 3,
280 new TGeoTranslation(xaperture + YokeWidth / 2., 0,
281 fSpecMagz + YokeDepth + CoilThick / 2.));
282 tMagnet->AddNode(
283 CV, 4,
284 new TGeoTranslation(-xaperture - YokeWidth / 2., 0,
285 fSpecMagz + YokeDepth + CoilThick / 2.));
286 }
287}
constexpr Double_t cm
constexpr Double_t m
Double_t floorheight
Definition ShipMagnet.h:30
Double_t YokeWidth
Definition ShipMagnet.h:29
Int_t fSpecMagz
Definition ShipMagnet.h:26
void ConstructGeometry() override
Double_t fDy
Definition ShipMagnet.h:27
~ShipMagnet() override
Double_t fDx
Definition ShipMagnet.h:28
Double_t CoilThick
Definition ShipMagnet.h:29
TGeoVolume * MagnetSupport(Double_t hwidth, Double_t hheight, Double_t dz, Int_t colour, TGeoMedium *material)
Int_t fDesign
Definition ShipMagnet.h:25
Double_t YokeDepth
Definition ShipMagnet.h:29
Int_t InitMedium(const char *name)
Definition ShipGeoUtil.h:22