SND@LHC Software
Loading...
Searching...
No Matches
EmulsionMagnet.cxx
Go to the documentation of this file.
1#include "EmulsionMagnet.h"
2
3#include "TGeoManager.h"
4#include "FairRun.h" // for FairRun
5#include "FairRuntimeDb.h" // for FairRuntimeDb
6#include <iosfwd> // for ostream
7#include "TList.h" // for TListIter, TList (ptr only)
8#include "TObjArray.h" // for TObjArray
9#include "TString.h" // for TString
10
11#include "TGeoBBox.h"
12#include "TGeoTrd1.h"
13#include "TGeoSphere.h"
14#include "TGeoCompositeShape.h"
15#include "TGeoTube.h"
16#include "TGeoMaterial.h"
17#include "TGeoMedium.h"
18#include "TGeoTrd1.h"
19#include "TGeoArb8.h"
20
21#include "FairVolume.h"
22#include "FairGeoVolume.h"
23#include "FairGeoNode.h"
24#include "FairRootManager.h"
25#include "FairGeoLoader.h"
26#include "FairGeoInterface.h"
27#include "FairGeoTransform.h"
28#include "FairGeoMedia.h"
29#include "FairGeoMedium.h"
30#include "FairGeoBuilder.h"
31#include "FairRun.h"
32#include "FairRuntimeDb.h"
33
34#include "ShipDetectorList.h"
35#include "ShipUnit.h"
36#include "ShipStack.h"
37
38#include "TGeoTrd2.h"
39#include "TGeoCompositeShape.h"
40
41#include "TGeoUniformMagField.h"
42#include "TVector3.h"
43#include <stddef.h> // for NULL
44#include <iostream> // for operator<<, basic_ostream,etc
45#include <string.h>
46
47using std::cout;
48using std::endl;
49
50using namespace ShipUnit;
51
54
55EmulsionMagnet::EmulsionMagnet():FairModule("EmulsionMagnet","")
56{}
57
58EmulsionMagnet::EmulsionMagnet(const char* name, const Double_t zC,const char* Title):FairModule(name, Title)
59{
60 fCenterZ = zC;
61}
62
63void EmulsionMagnet::SetDesign(Int_t Design)
64{
65 fDesign = Design;
66 Info("Chosen TP Design (0 no, 1 yes) "," %i", fDesign);
67}
68
69void EmulsionMagnet::SetGaps(Double_t Up, Double_t Down)
70{
71 fGapUpstream = Up;
72 fGapDownstream = Down;
73}
74
75void EmulsionMagnet::SetMagnetSizes(Double_t X, Double_t Y, Double_t Z)
76{
77 fMagnetX=X;
78 fMagnetY=Y;
79 fMagnetZ=Z;
80}
81
82void EmulsionMagnet::SetMagnetColumn(Double_t ColX, Double_t ColY, Double_t ColZ)
83{
84 fColumnX=ColX;
85 fColumnY=ColY;
86 fColumnZ=ColZ;
87}
88
89void EmulsionMagnet::SetBaseDim(Double_t BaseX, Double_t BaseY, Double_t BaseZ)
90{
91 fBaseX = BaseX;
92 fBaseY = BaseY;
93 fBaseZ = BaseZ;
94}
95
96
97void EmulsionMagnet::SetCoilParameters(Double_t Radius, Double_t height1, Double_t height2, Double_t Distance)
98{
99 fCoilR = Radius;
100 fCoilH1 = height1; //upper(left)
101 fCoilH2 = height2; //lowe(right)
102 fCoilDist = Distance;
103}
104
105void EmulsionMagnet::SetCoilParameters(Double_t X, Double_t Y, Double_t height1, Double_t height2, Double_t Thickness)
106{
107 fCoilX = X;
108 fCoilY = Y;
109 // cout << "fCoilX = "<< fCoilX<< " fCoilY = "<<fCoilY<<endl;
110 fCoilH1 = height1; //upper(left)
111 fCoilH2 = height2; //lowe(right)
112 fCoilThickness = Thickness;
113}
114
116{
117 fField=B;
118}
119
120void EmulsionMagnet::SetPillarDimensions(Double_t X, Double_t Y, Double_t Z)
121{
122 fPillarX=X;
123 fPillarY=Y;
124 fPillarZ=Z;
125}
126
127void EmulsionMagnet::SetCutDimensions(Double_t CutLength, Double_t CutHeight)
128{
129 fCutLength = CutLength;
130 fCutHeight = CutHeight;
131}
132
133void EmulsionMagnet::SetConstantField(Bool_t EmuMagnetConstField)
134{
135 fConstField = EmuMagnetConstField;
136}
137
138Int_t EmulsionMagnet::InitMedium(const char* name)
139{
140 static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
141 static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
142 static FairGeoMedia *media=geoFace->getMedia();
143 static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
144
145 FairGeoMedium *ShipMedium=media->getMedium(name);
146
147 if (!ShipMedium)
148 {
149 Fatal("InitMedium","Material %s not defined in media file.", name);
150 return -1111;
151 }
152 TGeoMedium* medium=gGeoManager->GetMedium(name);
153 if (medium!=NULL)
154 return ShipMedium->getMediumIndex();
155 return geoBuild->createMedium(ShipMedium);
156}
157
159{
160 TGeoVolume *top=gGeoManager->GetTopVolume();
161
162 InitMedium("air");
163 TGeoMedium *air =gGeoManager->GetMedium("air");
164
165 InitMedium("iron");
166 TGeoMedium *Fe =gGeoManager->GetMedium("iron");
167
168 InitMedium("CoilAluminium");
169 TGeoMedium *Al = gGeoManager->GetMedium("CoilAluminium");
170
171 InitMedium("CoilCopper");
172 TGeoMedium *Cu = gGeoManager->GetMedium("CoilCopper");
173
174 InitMedium("steel");
175 TGeoMedium *Steel = gGeoManager->GetMedium("steel");
176
177 gGeoManager->SetVisLevel(10);
178
179 TGeoVolume *tTauNuDet = gGeoManager->GetVolume("tTauNuDet");
180 cout<< "Tau Nu Detector fDesign: "<< fDesign<<endl;
181
182 if(fDesign==0)//OLD, TP
183 {
184 TGeoUniformMagField *magField1 = new TGeoUniformMagField(0.,-fField,0.); //magnetic field in Magnet pillars
185 TGeoUniformMagField *magField2 = new TGeoUniformMagField(0.,fField,0.); //magnetic field in target
186
187 TGeoVolumeAssembly *MagnetVol = new TGeoVolumeAssembly("Goliath");
188 tTauNuDet->AddNode(MagnetVol,1,new TGeoTranslation(0,0,fCenterZ));
189
190 //Iron basis on which the coils are placed
191 TGeoBBox *Base = new TGeoBBox(fBaseX/2,fBaseY/2,fBaseZ/2);
192 TGeoVolume *volBase = new TGeoVolume("volBase",Base,Fe);
193 volBase->SetLineColor(kRed);
194 MagnetVol->AddNode(volBase,1,new TGeoTranslation(0, fMagnetY/2 - fBaseY/2, 0)); //upper part
195 MagnetVol->AddNode(volBase,2,new TGeoTranslation(0, -fMagnetY/2 + fBaseY/2, 0)); //lower part
196
197 //Coils Description: 2 volumes must be defined being the upper coil in Cu and the lower one in Al and also heghts are different
198 TGeoTube *CoilBoxU = new TGeoTube("C",0,fCoilR,fCoilH1/2);
199 TGeoVolume *CoilVolUp = new TGeoVolume("CoilVolUp",CoilBoxU, Cu);
200 CoilVolUp->SetLineColor(kGreen);
201 TGeoTube *CoilBoxD = new TGeoTube("C",0,fCoilR,fCoilH2/2);
202 TGeoVolume *CoilVolDown = new TGeoVolume("CoilVolDown",CoilBoxD, Al);
203 CoilVolDown->SetLineColor(kGreen);
204
205 TGeoRotation *r1 = new TGeoRotation();
206 r1->SetAngles(0,90,0);
207 TGeoCombiTrans tUp(0, fMagnetY/2 - fBaseY - fCoilH1/2, 0,r1);
208 TGeoHMatrix *mUp = new TGeoHMatrix(tUp);
209 TGeoCombiTrans tDown(0, -fMagnetY/2 + fBaseY + fCoilH2/2, 0,r1);
210 TGeoHMatrix *mDown = new TGeoHMatrix(tDown);
211
212 MagnetVol->AddNode(CoilVolUp,1,mUp);
213 MagnetVol->AddNode(CoilVolDown,1,mDown);
214
215 //********************* Columns ****************************
216
217 //Each column is made of a longer pillar (rectangle + trapezoid) and on top a shorter pillar (rectangle + trapezoid again)
218
219 Double_t base1 = 135, base2 = 78; //basis of the trapezoid
220 Double_t side1 = 33, side2 = 125, side3 = 57, side4 = 90; //Sides of the columns
221
222 //***** SIDE Left Front ****
223
224 //Shorter Pillar: rectangle
225 TGeoBBox *LateralS1 = new TGeoBBox("LateralS1",side1/2,fCoilH1/2,base1/2);
226 TGeoTranslation *tr1 = new TGeoTranslation(-fMagnetX/2 + side1/2, fMagnetY/2 - fBaseY - fCoilH1/2, -fMagnetZ/2 + base1/2);
227 TGeoVolume *volLateralS1 = new TGeoVolume("volLateralS1",LateralS1,Fe);
228 volLateralS1->SetLineColor(kRed);
229 volLateralS1->SetField(magField1);
230 MagnetVol->AddNode(volLateralS1, 1, tr1);
231
232 //Shorter Pillar: trapezoid
233
234 TGeoArb8 *LateralS2 = new TGeoArb8("LateralS2",fCoilH1/2);
235 LateralS2->SetVertex(0, side4, 0);
236 LateralS2->SetVertex(1, side1, 0);
237 LateralS2->SetVertex(2, side1, base1);
238 LateralS2->SetVertex(3, side4, base2);
239 LateralS2->SetVertex(4, side4, 0);
240 LateralS2->SetVertex(5, side1, 0);
241 LateralS2->SetVertex(6, side1, base1);
242 LateralS2->SetVertex(7, side4, base2);
243
244 TGeoVolume *volLateralS2 = new TGeoVolume("volLateralS2",LateralS2,Fe);
245 volLateralS2->SetLineColor(kRed);
246 volLateralS2->SetField(magField1);
247
248 TGeoRotation *r2 = new TGeoRotation();
249 r2->SetAngles(0,90,0);
250 TGeoCombiTrans tr3(-fMagnetX/2, fMagnetY/2 - fBaseY - fCoilH1/2, -fMagnetZ/2,r2);
251 TGeoHMatrix *m3_a = new TGeoHMatrix(tr3);
252 MagnetVol->AddNode(volLateralS2, 1, m3_a);
253
254 //LOWER LATERAL SURFACE
255
256 //LONGER RECTANGLE
257 TGeoBBox *LateralSurface1low = new TGeoBBox("LateralSurface1low",side1/2,(fCoilDist + fCoilH2)/2,side2/2);
258 TGeoVolume *volLateralSurface1low = new TGeoVolume("volLateralSurface1low",LateralSurface1low,Fe);
259 volLateralSurface1low->SetLineColor(kRed);
260 volLateralSurface1low->SetField(magField1);
261 TGeoTranslation *tr1low = new TGeoTranslation(-fMagnetX/2 +side1/2, fMagnetY/2 - fBaseY - fCoilH1 - (fCoilDist + fCoilH2)/2, -fMagnetZ/2 + side2/2);
262 MagnetVol->AddNode(volLateralSurface1low, 1, tr1low);;
263
264
265 //SHORTER RECTANGLE
266 TGeoBBox *LateralSurface2low = new TGeoBBox("LateralSurface2low",side3/2,(fCoilDist + fCoilH2)/2,base2/2);
267 TGeoVolume *volLateralSurface2low = new TGeoVolume("volLateralSurface2low",LateralSurface2low,Fe);
268 volLateralSurface2low->SetLineColor(kRed);
269 TGeoTranslation *tr2low = new TGeoTranslation(-fMagnetX/2 +side1 + side3/2, fMagnetY/2 - fBaseY -fCoilH1 - (fCoilDist + fCoilH2)/2, -fMagnetZ/2 + base2/2);
270 MagnetVol->AddNode(volLateralSurface2low, 1, tr2low);
271 volLateralSurface2low->SetField(magField1);
272
273 //***** SIDE Right Front ****
274
275 //LONGER RECTANGLE
276 TGeoTranslation *tr1_b = new TGeoTranslation(-fMagnetX/2 + side1/2, fMagnetY/2 - fBaseY - fCoilH1/2, fMagnetZ/2 - base1/2);
277 TGeoVolume *volLateralS1_b = new TGeoVolume("volLateralS1_b",LateralS1,Fe);
278 volLateralS1_b->SetLineColor(kRed);
279 volLateralS1_b->SetField(magField1);
280 MagnetVol->AddNode(volLateralS1_b, 1, tr1_b);
281
282 //TRAPEZOID
283 TGeoArb8 *LateralS2_b = new TGeoArb8("LateralS2_b",fCoilH1/2);
284 LateralS2_b ->SetVertex(0, side4, 0);
285 LateralS2_b ->SetVertex(1, side1, 0);
286 LateralS2_b ->SetVertex(2, side1, base1);
287 LateralS2_b ->SetVertex(3, side4, base2);
288 LateralS2_b ->SetVertex(4, side4, 0);
289 LateralS2_b ->SetVertex(5, side1, 0);
290 LateralS2_b ->SetVertex(6, side1, base1);
291 LateralS2_b ->SetVertex(7, side4, base2);
292
293 TGeoVolume *volLateralS2_b = new TGeoVolume("volLateralS2_b",LateralS2_b,Fe);
294 volLateralS2_b->SetLineColor(kRed);
295 volLateralS2_b->SetField(magField1);
296
297 TGeoRotation *r2_b = new TGeoRotation();
298 r2_b->SetAngles(0,270,0);
299 TGeoCombiTrans tr2_b(-fMagnetX/2 , fMagnetY/2 - fBaseY - fCoilH1/2, fMagnetZ/2,r2_b);
300 TGeoHMatrix *m3_b = new TGeoHMatrix(tr2_b);
301 MagnetVol->AddNode(volLateralS2_b, 1, m3_b);
302
303
304 //LOWER LATERAL SURFACE
305
306 //LONGER RECTANGLE
307 TGeoVolume *volLateralSurface1blow = new TGeoVolume("volLateralSurface1blow",LateralSurface1low,Fe);
308 volLateralSurface1blow->SetLineColor(kRed);
309 volLateralSurface1blow->SetField(magField1);
310 TGeoTranslation *tr1blow = new TGeoTranslation(-fMagnetX/2 +side1/2, fMagnetY/2 - fBaseY - fCoilH1 - (fCoilDist + fCoilH2)/2, fMagnetZ/2 - side2/2);
311 MagnetVol->AddNode(volLateralSurface1blow, 1, tr1blow);;
312
313
314 //SHORTER RECTANGLE
315 TGeoVolume *volLateralSurface2blow = new TGeoVolume("volLateralSurface2blow",LateralSurface2low,Fe);
316 volLateralSurface2blow->SetLineColor(kRed);
317 volLateralSurface2blow->SetField(magField1);
318 TGeoTranslation *tr2blow = new TGeoTranslation(-fMagnetX/2 +side1 + side3/2, fMagnetY/2 - fBaseY - fCoilH1 - (fCoilDist + fCoilH2)/2, fMagnetZ/2 - base2/2);
319 MagnetVol->AddNode(volLateralSurface2blow, 1, tr2blow);
320
321
322 //***** SIDE left Back ****
323
324
325 //LONGER RECTANGLE
326 TGeoBBox *LateralS1_d = new TGeoBBox("LateralS1_d",side1/2,(fCoilH1 + fCoilH2 + fCoilDist)/2,base1/2);
327 TGeoTranslation *tr1_d = new TGeoTranslation(fMagnetX/2 - side1/2, fMagnetY/2 - fBaseY - (fCoilH1 + fCoilH2 + fCoilDist)/2, -fMagnetZ/2 + base1/2);
328 TGeoVolume *volLateralS1_d = new TGeoVolume("volLateralS1_d",LateralS1_d,Fe);
329 volLateralS1_d->SetLineColor(kRed);
330 volLateralS1_d->SetField(magField1);
331 MagnetVol->AddNode(volLateralS1_d, 1, tr1_d);
332
333 //TRAPEZOID
334
335 TGeoArb8 *LateralS2_d = new TGeoArb8("LateralS2_d",(fCoilH1 + fCoilH2 + fCoilDist)/2);
336 LateralS2_d->SetVertex(0, side4, 0);
337 LateralS2_d->SetVertex(1, side1, 0);
338 LateralS2_d->SetVertex(2, side1, base1);
339 LateralS2_d->SetVertex(3, side4, base2);
340 LateralS2_d->SetVertex(4, side4, 0);
341 LateralS2_d->SetVertex(5, side1, 0);
342 LateralS2_d->SetVertex(6, side1, base1);
343 LateralS2_d->SetVertex(7, side4, base2);
344
345
346 TGeoVolume *volLateralS2_d = new TGeoVolume("volLateralS2_d",LateralS2_d,Fe);
347 volLateralS2_d->SetLineColor(kRed);
348 volLateralS2_d->SetField(magField1);
349
350 TGeoRotation *r2_d = new TGeoRotation();
351 r2_d->SetAngles(0,270,180);
352 TGeoCombiTrans tr2_d(fMagnetX/2 , fMagnetY/2 - fBaseY - (fCoilH1 + fCoilH2 + fCoilDist)/2, -fMagnetZ/2,r2_d);
353 TGeoHMatrix *m3_d = new TGeoHMatrix(tr2_d);
354 MagnetVol->AddNode(volLateralS2_d, 1, m3_d);
355
356//***** SIDE right Back ****
357
358
359 //LONGER RECTANGLE
360 TGeoBBox *LateralS1_c = new TGeoBBox("LateralS1_c",side1/2,(fCoilH1 + fCoilH2 + fCoilDist)/2,base1/2);
361 TGeoTranslation *tr1_c = new TGeoTranslation(fMagnetX/2 - side1/2, fMagnetY/2 - fBaseY - (fCoilH1 + fCoilH2 + fCoilDist)/2, fMagnetZ/2 - base1/2);
362 TGeoVolume *volLateralS1_c = new TGeoVolume("volLateralS1_c",LateralS1_c,Fe);
363 volLateralS1_c->SetLineColor(kRed);
364 volLateralS1_c->SetField(magField1);
365 MagnetVol->AddNode(volLateralS1_c, 1, tr1_c);
366
367 //TRAPEZOID
368
369 TGeoArb8 *LateralS2_c = new TGeoArb8("LateralS2_c",(fCoilH1 + fCoilH2 + fCoilDist)/2);
370 LateralS2_c ->SetVertex(0, side4, 0);
371 LateralS2_c ->SetVertex(1, side1, 0);
372 LateralS2_c ->SetVertex(2, side1, base1);
373 LateralS2_c ->SetVertex(3, side4, base2);
374 LateralS2_c ->SetVertex(4, side4, 0);
375 LateralS2_c ->SetVertex(5, side1, 0);
376 LateralS2_c ->SetVertex(6, side1, base1);
377 LateralS2_c ->SetVertex(7, side4, base2);
378
379 TGeoVolume *volLateralS2_c = new TGeoVolume("volLateralS2_c",LateralS2_c,Fe);
380 volLateralS2_c->SetLineColor(kRed);
381 volLateralS2_c->SetField(magField1);
382
383 TGeoRotation *r2_c = new TGeoRotation();
384 r2_c->SetAngles(0,90,180);
385 TGeoCombiTrans tr2_c(fMagnetX/2 , fMagnetY/2 - fBaseY - (fCoilH1 + fCoilH2 + fCoilDist)/2, fMagnetZ/2,r2_c);
386 TGeoHMatrix *m3_c = new TGeoHMatrix(tr2_c);
387 MagnetVol->AddNode(volLateralS2_c, 1, m3_c);
388
389
390 }
391
392 if(fDesign==1) //NEW with magnet
393 {
394 TGeoUniformMagField *magField1 = new TGeoUniformMagField(-fField,0.,0.); //magnetic field in Magnet pillars
395 TGeoUniformMagField *magField2 = new TGeoUniformMagField(fField,0.,0.); //magnetic field in target
396
397 TGeoVolumeAssembly *MagnetVol = new TGeoVolumeAssembly("Davide");
398 tTauNuDet->AddNode(MagnetVol,1,new TGeoTranslation(0,0,fCenterZ));
399
400 //The -0.01*mm is only for drawing reasons
401 TGeoBBox *LateralBox = new TGeoBBox("LB",fBaseZ/2,fBaseY/2,(fBaseX-0.01*mm)/2);
402 TGeoTube *CoilBox = new TGeoTube("C",0,fCoilR,fCoilH1/2);
403
404 TGeoCompositeShape *LateralSurf = new TGeoCompositeShape("LS","LB-C");
405
406 TGeoVolume *CoilVol = new TGeoVolume("CoilVol",CoilBox, Cu);
407 CoilVol->SetLineColor(kGreen);
408 TGeoVolume *LateralSurfVol = new TGeoVolume("LateralSurfVol",LateralSurf, Fe);
409 LateralSurfVol->SetLineColor(kRed);
410
411 TGeoRotation *r1 = new TGeoRotation();
412 r1->RotateY(90);
413 //r1->RotateY(90);
414 //r1->RotateY(90);
415 r1->RegisterYourself();
416 TGeoTranslation *t1r = new TGeoTranslation(-fMagnetX/2+fBaseX/2,0,0);
417 TGeoTranslation *t1l = new TGeoTranslation(fMagnetX/2-fBaseX/2,0,0);
418
419 TGeoCombiTrans *trans1r = new TGeoCombiTrans(-fMagnetX/2+fBaseX/2,0,0,r1);
420 TGeoCombiTrans *trans1l = new TGeoCombiTrans(fMagnetX/2-fBaseX/2,0,0,r1);
421 TGeoHMatrix *m1_r = new TGeoHMatrix("m1_r");
422 *m1_r = trans1r;
423 TGeoHMatrix *m1_l = new TGeoHMatrix("m1_l");
424 *m1_l = trans1l;
425
426 MagnetVol->AddNode(CoilVol,1, m1_r);
427 MagnetVol->AddNode(LateralSurfVol,1,m1_r);
428 MagnetVol->AddNode(CoilVol,2, m1_l);
429 MagnetVol->AddNode(LateralSurfVol,2,m1_l);
430
431 TGeoBBox *ColumnBox = new TGeoBBox(fColumnX/2, fColumnY/2, fColumnZ/2);
432 TGeoVolume *ColumnVol = new TGeoVolume("ColumnVol",ColumnBox,Fe);
433 ColumnVol->SetField(magField1);
434 ColumnVol->SetLineColor(kRed);
435 MagnetVol->AddNode(ColumnVol,1,new TGeoTranslation(0,fMagnetY/2-fColumnY/2, -fMagnetZ/2+fColumnZ/2));
436 MagnetVol->AddNode(ColumnVol,2,new TGeoTranslation(0,fMagnetY/2-fColumnY/2, fMagnetZ/2-fColumnZ/2));
437 MagnetVol->AddNode(ColumnVol,3,new TGeoTranslation(0,-fMagnetY/2+fColumnY/2, -fMagnetZ/2+fColumnZ/2));
438 MagnetVol->AddNode(ColumnVol,4,new TGeoTranslation(0,-fMagnetY/2+fColumnY/2, fMagnetZ/2-fColumnZ/2));
439
440 TGeoBBox *BaseBox = new TGeoBBox(fCoilDist/2,fColumnY/2, fBaseZ/2);
441 TGeoVolume *BaseVol = new TGeoVolume("BaseVol",BaseBox,Fe);
442 BaseVol->SetLineColor(kRed);
443 MagnetVol->AddNode(BaseVol,1, new TGeoTranslation(0,-fMagnetY/2+fColumnY/2,0));
444
445 TGeoBBox *PillarBox = new TGeoBBox(fPillarX/2,fPillarY/2, fPillarZ/2);
446 TGeoVolume *PillarVol = new TGeoVolume("PillarVol",PillarBox,Steel);
447 PillarVol->SetLineColor(kGreen+3);
448 tTauNuDet->AddNode(PillarVol,1, new TGeoTranslation(-fMagnetX/2+fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ-fMagnetZ/2+fPillarZ/2));
449 tTauNuDet->AddNode(PillarVol,2, new TGeoTranslation(fMagnetX/2-fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ-fMagnetZ/2+fPillarZ/2));
450 tTauNuDet->AddNode(PillarVol,3, new TGeoTranslation(-fMagnetX/2+fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ+fMagnetZ/2-fPillarZ/2));
451 tTauNuDet->AddNode(PillarVol,4, new TGeoTranslation(fMagnetX/2-fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ+fMagnetZ/2-fPillarZ/2));
452 }
453
454 if(fDesign==3) //NEW with magnet
455 {
456 //Box for Magnet
457 TGeoVolumeAssembly *MagnetVol = new TGeoVolumeAssembly("NudetMagnet");
458 tTauNuDet->AddNode(MagnetVol,1,new TGeoTranslation(0,0,fCenterZ));
459
460 TGeoBBox *BaseBox = new TGeoBBox(fBaseX/2,fBaseY/2,fBaseZ/2);
461 TGeoVolume *BaseVol = new TGeoVolume("BaseVol",BaseBox,Fe);
462 BaseVol->SetLineColor(kRed);
463 TGeoBBox *LateralBox = new TGeoBBox(fColumnX/2,fColumnY/2,fColumnZ/2);
464
465 //prepare for triangolar cuts
466 LateralBox->SetName("L");
467 Double_t delta = 0.1; //to avoid border effects in the cuts (cut is not visualized in viewer, I do not know if it can affect simulation)
468 TGeoTrd2 * Model= new TGeoTrd2("Model",fCutHeight/2,0, (fColumnZ+delta)/2,(fColumnZ+delta)/2,(fCutLength+delta)/2); //length and height are not x and y here, because it will be rotated!
469 Model->SetName("T");
470
471 const Double_t SemiLateralBoxHeight =(fColumnY - fCutHeight)/2;
472
473 //we need different volumes to place different magnetic fields
474 TGeoBBox *SemiLateralBox = new TGeoBBox("SemiLateralBox",(fColumnX)/2, SemiLateralBoxHeight /2, fColumnZ/2);
475 TGeoVolume *volUpLateral = new TGeoVolume("volUpLateral",SemiLateralBox,Fe); //up and down refer to the magnetic field verse
476
477 TGeoVolume *volDownLateral = new TGeoVolume("volDownLateral",SemiLateralBox,Fe);
478 SemiLateralBox->SetName("S");
479 volUpLateral->SetLineColor(kRed);
480 volDownLateral->SetLineColor(kRed);
481
482 const Double_t MidBoxHeight = fCutHeight/2;
483
484 TGeoBBox *MidLateralBox = new TGeoBBox("MidLateralBox",fColumnX/2, MidBoxHeight/2, fColumnZ/2);
485 MidLateralBox->SetName("M");
486
487 //some boolean operations for triangular cuts
488
489 TGeoRotation rot("rot",90,90,0);
490 TGeoRotation rot1("rot1",-90,90,0);
491 const TGeoTranslation trans("trans",-fColumnX/2.+ fCutLength/2,0,0);
492 TGeoCombiTrans* comb = new TGeoCombiTrans(trans,rot);
493 comb->SetName("comb");
494 comb->RegisterYourself();
495 TGeoCompositeShape *cut = new TGeoCompositeShape("CUT", "L-T:comb");
496
497
498 TGeoTranslation* transcuttop = new TGeoTranslation("transcuttop",0, fCutHeight/2 + SemiLateralBoxHeight/2 ,0); //top and bottom refer to their geometrical positions
499 TGeoTranslation* transcuttop1 = new TGeoTranslation("transcuttop1",0, MidBoxHeight/2 ,0);
500 TGeoTranslation* transcutbottom = new TGeoTranslation("transcutbottom",0, - fCutHeight/2 - SemiLateralBoxHeight/2 ,0);
501 TGeoTranslation* transcutbottom1 = new TGeoTranslation("transcutbottom1",0, -MidBoxHeight/2 ,0);
502
503 transcuttop->RegisterYourself();
504 transcuttop1->RegisterYourself();
505 transcutbottom->RegisterYourself();
506 transcutbottom1->RegisterYourself();
507
508 TGeoCompositeShape *cuttop = new TGeoCompositeShape("CUTTOP", "CUT - (S:transcuttop) - (S:transcutbottom)"); //triangular cut in the right lateral wall
509 TGeoVolume *volcuttop = new TGeoVolume("volcuttop", cuttop, Fe);
510 volcuttop->SetLineColor(kRed);
511
512 const TGeoTranslation transleft("transleft",+fColumnX/2.- fCutLength/2,0,0);
513 TGeoCombiTrans* combleft = new TGeoCombiTrans(transleft,rot1);
514 combleft->SetName("combleft");
515 combleft->RegisterYourself();
516 TGeoCompositeShape *cutleft;
517 cutleft = new TGeoCompositeShape("CUTLEFT", "L-T:combleft");
518 TGeoCompositeShape *cuttopleft = new TGeoCompositeShape("CUTTOPLEFT", "CUTLEFT - (S:transcuttop) - (S:transcutbottom)"); //triangular cut in the left lateral wall
519 TGeoVolume *volcuttopleft = new TGeoVolume("volcuttopleft", cuttopleft, Fe);
520 volcuttopleft->SetLineColor(kRed);
521
522 //composite coil
523 TGeoBBox *OutcoilBox = new TGeoBBox("OC", fCoilX/2, fCoilH1/2,fMagnetZ/2-fCoilH1/2);
524 TGeoBBox *IncoilBox = new TGeoBBox("IC", fCoilX/2,fCoilH2/2,(fMagnetZ-fCoilH1)/2);
525
526 //circular arcs (first two options are radii, not half radii!)
527 Double_t OuterRadius = fCoilY + fCoilThickness;
528
529 TGeoTubeSeg *Coillateraltuberightdown = new TGeoTubeSeg("Coillateraltuberightdown",fCoilThickness,OuterRadius, fCoilX/2,90,180);
530 TGeoTubeSeg *Coillateraltuberighttup = new TGeoTubeSeg("Coillateraltuberightup",fCoilThickness,OuterRadius, fCoilX/2,0,90);
531 TGeoTubeSeg *Coillateraltubeleftup = new TGeoTubeSeg("Coillateraltubeleftup",fCoilThickness,OuterRadius, fCoilX/2,270,360);
532 TGeoTubeSeg *Coillateraltubeleftdown = new TGeoTubeSeg("Coillateraltubeleftdown",fCoilThickness,OuterRadius, fCoilX/2,180,270);
533
534 TGeoBBox *Coillateralcenter = new TGeoBBox("Coillateralcenter",fCoilX/2., (fCoilH2-2*fCoilThickness)/2, fCoilY/2.);
535
536 TGeoRotation rottube("rottube",90,90,0);
537 //transformations to combine them
538 const TGeoTranslation transtube("transtube",0.,-(fCoilH2-2*fCoilThickness)/2, -fCoilThickness-fCoilY/2);
539 const TGeoTranslation transtube1("transtube1",0.,(fCoilH2-2*fCoilThickness)/2, -fCoilThickness-fCoilY/2);
540 const TGeoTranslation transtube2("transtube2",0.,-(fCoilH2-2*fCoilThickness)/2,+fCoilThickness+fCoilY/2);
541 const TGeoTranslation transtube3("transtube3",0.,(fCoilH2-2*fCoilThickness)/2,+fCoilThickness+fCoilY/2);
542 TGeoCombiTrans* combination = new TGeoCombiTrans(transtube,rottube);
543 TGeoCombiTrans* combination1 = new TGeoCombiTrans(transtube1,rottube);
544 TGeoCombiTrans* combination2 = new TGeoCombiTrans(transtube2,rottube);
545 TGeoCombiTrans* combination3 = new TGeoCombiTrans(transtube3,rottube);
546
547 combination->SetName("combination");
548 combination->RegisterYourself();
549 combination1->SetName("combination1");
550 combination1->RegisterYourself();
551 combination2->SetName("combination2");
552 combination2->RegisterYourself();
553 combination3->SetName("combination3");
554 combination3->RegisterYourself();
555 //adding the shapes and making the volumes
556 TGeoCompositeShape * CoilRight = new TGeoCompositeShape("CoilRight","Coillateraltuberightdown:combination+Coillateraltuberightup:combination1+Coillateralcenter");
557 TGeoVolume *CoilVolright = new TGeoVolume("CoilVolright",CoilRight,Cu);
558
559 TGeoCompositeShape * CoilLeft = new TGeoCompositeShape("CoilLeft","Coillateraltubeleftdown:combination2+Coillateraltubeleftup:combination3+Coillateralcenter");
560 TGeoVolume *CoilVolleft = new TGeoVolume("CoilVolleft",CoilLeft,Cu);
561
562
563
564 TGeoBBox *Coil = new TGeoBBox("Coil", fCoilX/2,fCoilY/2, (fMagnetZ-2*OuterRadius)/2); //two times the external radius
565 TGeoVolume *CoilVol = new TGeoVolume("CoilVol",Coil, Cu);
566
567 //adding obtained volumes
568
569 MagnetVol->AddNode(BaseVol,1, new TGeoTranslation(0,-fMagnetY/2+fBaseY/2,0));
570 MagnetVol->AddNode(BaseVol,2, new TGeoTranslation(0,fMagnetY/2-fBaseY/2,0));
571
572 MagnetVol->AddNode(volUpLateral, 1, new TGeoTranslation(-fMagnetX/2+fColumnX/2, (fCutHeight + (fColumnY - fCutHeight)/2)/2 ,0));
573 MagnetVol->AddNode(volDownLateral, 1, new TGeoTranslation(-fMagnetX/2+fColumnX/2, (-fCutHeight - (fColumnY - fCutHeight)/2)/2,0));
574 MagnetVol->AddNode(volcuttop, 1, new TGeoTranslation(-fMagnetX/2+fColumnX/2, 0, 0));
575
576 MagnetVol->AddNode(volUpLateral, 2, new TGeoTranslation(fMagnetX/2-fColumnX/2, (-fCutHeight - (fColumnY - fCutHeight)/2)/2 ,0));
577 MagnetVol->AddNode(volDownLateral, 2, new TGeoTranslation(fMagnetX/2-fColumnX/2, (+fCutHeight + (fColumnY - fCutHeight)/2)/2,0));
578 MagnetVol->AddNode(volcuttopleft,2, new TGeoTranslation(fMagnetX/2-fColumnX/2,0,0));
579
580 CoilVolleft->SetLineColor(kGreen);
581 MagnetVol->AddNode(CoilVolleft,1,new TGeoTranslation(0,0,-fMagnetZ/2.+fCoilY/2.));
582 CoilVolright->SetLineColor(kGreen);
583 MagnetVol->AddNode(CoilVolright,1,new TGeoTranslation(0,0,+fMagnetZ/2.-fCoilY/2.));
584 CoilVol->SetLineColor(kGreen);
585 MagnetVol->AddNode(CoilVol,1,new TGeoTranslation(0,(fCoilH1+fCoilH2)/4,0));
586 MagnetVol->AddNode(CoilVol,2,new TGeoTranslation(0,-(fCoilH1+fCoilH2)/4,0));
587
588 //magnetized region
589
590 TGeoVolume *volMagRegion = new TGeoVolume("volMagRegion",IncoilBox, air);
591 MagnetVol->AddNode(volMagRegion, 1, new TGeoTranslation(0,0,0));
592
593 //pillars for the magnet
594 TGeoBBox *PillarBox = new TGeoBBox(fPillarX/2,fPillarY/2, fPillarZ/2);
595 TGeoVolume *PillarVol = new TGeoVolume("PillarVol",PillarBox,Steel);
596 PillarVol->SetLineColor(kGreen+3);
597 tTauNuDet->AddNode(PillarVol,1, new TGeoTranslation(-fMagnetX/2+fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ-fMagnetZ/2+fPillarZ/2));
598 tTauNuDet->AddNode(PillarVol,2, new TGeoTranslation(fMagnetX/2-fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ-fMagnetZ/2+fPillarZ/2));
599 tTauNuDet->AddNode(PillarVol,3, new TGeoTranslation(-fMagnetX/2+fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ+fMagnetZ/2-fPillarZ/2));
600 tTauNuDet->AddNode(PillarVol,4, new TGeoTranslation(fMagnetX/2-fPillarX/2,-fMagnetY/2-fPillarY/2, fCenterZ+fMagnetZ/2-fPillarZ/2));
601
602
603 if (fConstField){ //adding magnetic field if not implemented from nudet field map
604 TGeoUniformMagField *magField1 = new TGeoUniformMagField(-fField,0.,0.); //magnetic field in Magnet pillars
605 TGeoUniformMagField *magField2 = new TGeoUniformMagField(fField,0.,0.); //magnetic field in target
606 TGeoUniformMagField *magField1y = new TGeoUniformMagField(0.,-fField,0.); //down return magnetic field along y
607 TGeoUniformMagField *magField2y = new TGeoUniformMagField(0.,fField,0.); //up return magnetic field along y
608
609 BaseVol->SetField(magField1);
610 volUpLateral->SetField(magField2y);
611 volDownLateral->SetField(magField1y);
612 volMagRegion->SetField(magField2);
613 }
614 }
615}
616
617
Double_t mm
Double_t fCutHeight
Double_t fGapUpstream
Double_t fCutLength
Int_t InitMedium(const char *name)
void SetCoilParameters(Double_t radius, Double_t height1, Double_t height2, Double_t Distance)
Double_t fCoilThickness
void SetMagneticField(Double_t B)
Double_t fGapDownstream
void SetBaseDim(Double_t BaseX, Double_t BaseY, Double_t BaseZ)
void SetGaps(Double_t Up, Double_t Down)
void SetMagnetColumn(Double_t ColX, Double_t ColY, Double_t ColZ)
void SetCutDimensions(Double_t CutLength, Double_t CutHeight)
void SetMagnetSizes(Double_t X, Double_t Y, Double_t Z)
void SetConstantField(Bool_t EmuMagnetConstField)
void SetPillarDimensions(Double_t X, Double_t Y, Double_t Z)
void SetDesign(Int_t Design)
ClassImp(ecalContFact) ecalContFact