fixed warning
[u/mrichter/AliRoot.git] / macros / plotField.C
CommitLineData
0ae46e2d 1void plotField(Int_t iField = 0)
2{
3//
0ae46e2d 4//
5// load necessary libraries
88cb7938 6 gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libminicern");
0ae46e2d 7 gSystem->Load("$(ROOTSYS)/lib/libPhysics");
8 gSystem->Load("$(ROOTSYS)/lib/libEG");
9 gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTEER");
10
11//
12//
13// create field map
14
4642ac4b 15 AliMagF* field = new AliMagF("Maps","Maps", 1., 1., AliMagF::k5kG);
0ae46e2d 16
17// field-SetL3ConstField(1);
18
19//
20// get parameters
21 Float_t xMin, xMax, yMin, yMax, zMin, zMax;
22 Float_t dX, dY, dZ;
23 xMin = -350.;
24 xMax = 350.;
25 dX = (field->FieldMap(0))->DelX();
26 yMin = -350.;
27 yMax = 350.;
28 dY = (field->FieldMap(0))->DelY();
29 zMin = 250.;
30 zMax = 1450.;
31 dZ = (field->FieldMap(0))->DelZ();
32 Int_t nx = (xMax-xMin)/dX;
33 Int_t ny = (yMax-yMin)/dY;
34 Int_t nz = (zMax-zMin)/dZ;
35
36
37//
38// create histogram
39 TH2F* hMap = new TH2F("hMap", "Field Map y-z",
40 nz, zMin, zMax, ny, yMin, yMax);
41 TH2F* hMap1 = new TH2F("hMap1", "Field Map y-z",
42 nz, zMin, zMax, ny, yMin, yMax);
43 TH1F* hZ = new TH1F("hZ", "Field along Z",
44 nz, zMin, zMax);
45
46 TH2F* hVec = new TH2F("hVec", "Field Map y-z",
47 nz, zMin, zMax, ny, yMin, yMax);
48
49 TH2F* hCir = new TH2F("hCir", "Field Map y-z",
50 nz, zMin, zMax, ny, yMin, yMax);
51 Float_t bMax = 0.;
52 for (Int_t i = 0; i < nz; i++) {
53 for (Int_t j = 0; j < ny; j++) {
54 Float_t x[3];
55 Float_t b[3];
56
57 x[2] = zMin + i * dZ;
58 x[1] = yMin + j * dY;
59 x[0] = 0.;
60 field->Field(x, b);
61 Float_t bb = TMath::Sqrt(b[0]*b[0]+b[1]*b[1]+b[2]*b[2]);
62 if (bb > bMax) bMax = bb;
63 hMap->Fill(x[2], x[1], bb);
64 }
65 }
66
67 for (Int_t i = 0; i < nz; i++) {
68 for (Int_t j = 0; j < ny; j++) {
69 x[2] = zMin + i * dZ;
70 x[1] = yMin + j * dY;
71 x[0] = 0.;
72 field->Field(x, b);
73 Float_t bb = TMath::Sqrt(b[0]*b[0]+b[1]*b[1]+b[2]*b[2]);
74 Float_t db = (bMax-bb)/bMax*100.;
75
76 hMap1->Fill(x[2], x[1], db);
77 }
78 }
79
80 for (Int_t i = 0; i < nz; i++) {
81 x[2] = zMin + i * dZ +dZ/2.;
82 x[1] = 0.;
83 x[0] = 0.;
84 field->Field(x, b);
85 Float_t bb = TMath::Sqrt(b[0]*b[0]+b[1]*b[1]+b[2]*b[2]);
86 hZ->Fill(x[2], bb);
87 }
88
89 TCanvas *c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
90 hMap->Draw();
91 TCanvas *c2 = new TCanvas("c2","Canvas 2",400,10,600,700);
92 hZ->Draw();
93 TCanvas *c3 = new TCanvas("c3","Canvas 3",400,10,600,700);
94 hVec->Draw();
95
96 Float_t scale1 = 0.9*TMath::Sqrt(dZ*dZ+dY*dY)/bMax/2.;
97 Float_t scale2 = 0.005/bMax;
98 TArrow* arrow;
99
100
101 for (Int_t i = 0; i < nz; i++) {
102 for (Int_t j = 0; j < nx; j++) {
103 x[2] = zMin + i * dZ + dZ/2.;
104 x[0] = xMin + j * dX + dX/2.;
105 x[1] = 0.;
106 field->Field(x, b);
107 Float_t bb = TMath::Sqrt(b[0]*b[0]+b[1]*b[1]+b[2]*b[2]);
108 b[2] *= scale1;
109 b[0] *= scale1;
110 Float_t width = 0.005+scale2*b[1];
111 arrow = new TArrow(x[2], x[0], x[2]+b[2], x[0]+b[0], width,"|>");
112 arrow->SetFillColor(1);
113 arrow->SetFillStyle(1001);
114 arrow->Draw();
115 c3->Modified();
116 c3->cd();
117 }
118 }
119
120 TCanvas *c4 = new TCanvas("c4","Canvas 4",400,10,600,700);
121 hCir->Draw();
122 for (Int_t i = 0; i < nz; i++) {
123 for (Int_t j = 0; j < ny; j++) {
124 x[2] = zMin + i * dZ + dZ/2.;
125 x[1] = yMin + j * dY + dY/2.;
126 x[0] = 0.;
127 field->Field(x, b);
128 Float_t bb = TMath::Sqrt(b[0]*b[0]+b[1]*b[1]+b[2]*b[2]);
129 TEllipse *ellipse;
130 ellipse= new TEllipse(x[2], x[1], b[1]*scale1/4., b[1]*scale1/4.,0,360,0);
131 ellipse->Draw();
132 c4->Modified();
133 c4->cd();
134 }
135 }
136}
137
138
139