FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MyMagnet.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 // -------------------------------------------------------------------------
10 // ----- MyMagnet file -----
11 // ----- Created 26/03/14 by M. Al-Turany -----
12 // -------------------------------------------------------------------------
13 
14 #include "MyMagnet.h"
15 
16 #include "FairRun.h" // for FairRun
17 #include "FairRuntimeDb.h" // for FairRuntimeDb
18 
19 #include <TGeoBBox.h>
20 #include <TGeoCompositeShape.h>
21 #include <TGeoElement.h>
22 #include <TGeoManager.h>
23 #include <TGeoMaterial.h>
24 #include <TGeoMedium.h>
25 #include <TGeoTube.h>
26 #include <TList.h> // for TListIter, TList (ptr only)
27 #include <TObjArray.h> // for TObjArray
28 #include <TString.h> // for TString
29 #include <iosfwd> // for ostream
30 #include <iostream> // for operator<<, basic_ostream, etc
31 #include <stddef.h> // for NULL
32 
35  : FairModule("MyMagnet", "")
36 {}
37 
38 MyMagnet::MyMagnet(const char *name, const char *Title)
39  : FairModule(name, Title)
40 {}
41 
42 MyMagnet::MyMagnet(const MyMagnet &right)
43  : FairModule(right)
44 {}
45 
47 {
48 
49  TGeoVolume *top = gGeoManager->GetTopVolume();
50 
51  // define some materials
52  TGeoMaterial *matFe = new TGeoMaterial("Fe", 55.84, 26, 7.9);
53 
54  // define some media
55  TGeoMedium *Fe = new TGeoMedium("Fe", 5, matFe);
56 
57  // magnet yoke
58  TGeoBBox *magyoke1 = new TGeoBBox("magyoke1", 350, 350, 125);
59  TGeoBBox *magyoke2 = new TGeoBBox("magyoke2", 250, 250, 126);
60 
61  TGeoCompositeShape *magyokec = new TGeoCompositeShape("magyokec", "magyoke1-magyoke2");
62  TGeoVolume *magyoke = new TGeoVolume("magyoke", magyokec, Fe);
63  magyoke->SetLineColor(kBlue);
64  // magyoke->SetTransparency(50);
65  top->AddNode(magyoke, 1, new TGeoTranslation(0, 0, 0));
66 
67  // magnet
68  TGeoTubeSeg *magnet1a = new TGeoTubeSeg("magnet1a", 250, 300, 35, 45, 135);
69  TGeoTubeSeg *magnet1b = new TGeoTubeSeg("magnet1b", 250, 300, 35, 45, 135);
70  TGeoTubeSeg *magnet1c = new TGeoTubeSeg("magnet1c", 250, 270, 125, 45, 60);
71  TGeoTubeSeg *magnet1d = new TGeoTubeSeg("magnet1d", 250, 270, 125, 120, 135);
72 
73  // magnet composite shape matrices
74  TGeoTranslation *m1 = new TGeoTranslation(0, 0, 160);
75  m1->SetName("m1");
76  m1->RegisterYourself();
77  TGeoTranslation *m2 = new TGeoTranslation(0, 0, -160);
78  m2->SetName("m2");
79  m2->RegisterYourself();
80 
81  TGeoCompositeShape *magcomp1 = new TGeoCompositeShape("magcomp1", "magnet1a:m1+magnet1b:m2+magnet1c+magnet1d");
82  TGeoVolume *magnet1 = new TGeoVolume("magnet1", magcomp1, Fe);
83  magnet1->SetLineColor(kYellow);
84  top->AddNode(magnet1, 1, new TGeoTranslation(0, 0, 0));
85 
86  TGeoRotation m3;
87  m3.SetAngles(180, 0, 0);
88  TGeoTranslation m4(0, 0, 0);
89  TGeoCombiTrans m5(m4, m3);
90  TGeoHMatrix *m6 = new TGeoHMatrix(m5);
91  top->AddNode(magnet1, 2, m6);
92 }
93 
94 FairModule *MyMagnet::CloneModule() const { return new MyMagnet(*this); }
95 
void ConstructGeometry()
Definition: MyMagnet.cxx:46
ClassImp(FairEventBuilder)
virtual FairModule * CloneModule() const
Definition: MyMagnet.cxx:94
virtual ~MyMagnet()
Definition: MyMagnet.cxx:33
MyMagnet()
Definition: MyMagnet.cxx:34