3 .L $ALICE_ROOT/TPC/macros/AliMagFDraw.cxx+
5 draw.RegisterField(0,new AliMagWrapCheb("Maps","Maps", 2, 1., 10., AliMagWrapCheb::k5kG));
6 draw.RegisterField(1,new AliMagFMaps("Maps","Maps", 2, 1., 10., 2));
8 TF2 fbz_rz_0pi("fbz_rz_0pi","AliMagFDraw::GetBz(x,0*pi,y)",0,250,-250,250);
9 fbz_rz_0pi->Draw("surf2");
11 TF1 fbz_z_90_00pi("fbz_z_90_00pi","AliMagFDraw::GetBz(90,0*pi,x)",-250,250);
12 TF1 fbz_z_90_05pi("fbz_z_90_05pi","AliMagFDraw::GetBz(90,0.5*pi,x)",-250,250);
13 TF1 fbz_z_90_10pi("fbz_z_90_10pi","AliMagFDraw::GetBz(90,1.0*pi,x)",-250,250);
14 TF1 fbz_z_90_15pi("fbz_z_90_15pi","AliMagFDraw::GetBz(90,1.5*pi,x)",-250,250);
15 fbz_z_90_00pi->SetLineColor(2);
16 fbz_z_90_05pi->SetLineColor(3);
17 fbz_z_90_10pi->SetLineColor(4);
18 fbz_z_90_15pi->SetLineColor(5);
20 fbz_z_90_05pi->Draw("same")
21 fbz_z_90_15pi->Draw("same")
22 fbz_z_90_10pi->Draw("same")
25 TF1 fbr_z_90_00pi("fbz_z_90_00pi","AliMagFDraw::GetBr(90,0*pi,x)",-250,250);
26 TF1 fbr_z_90_05pi("fbz_z_90_05pi","AliMagFDraw::GetBr(90,0.5*pi,x)",-250,250);
27 TF1 fbr_z_90_10pi("fbz_z_90_10pi","AliMagFDraw::GetBr(90,1.0*pi,x)",-250,250);
28 TF1 fbr_z_90_15pi("fbz_z_90_15pi","AliMagFDraw::GetBr(90,1.5*pi,x)",-250,250);
29 fbr_z_90_00pi->SetLineColor(2);
30 fbr_z_90_05pi->SetLineColor(3);
31 fbr_z_90_10pi->SetLineColor(4);
32 fbr_z_90_15pi->SetLineColor(5);
34 fbr_z_90_05pi->Draw("same")
35 fbr_z_90_15pi->Draw("same")
36 fbr_z_90_10pi->Draw("same")
39 TF2 fbz_xy_0z("fbz_xy_0z","AliMagFDraw::GetBz(sqrt(x^2+y^2),atan2(y,x),0)",-250,250,-250,250);
40 fbz_xy_0z.SetNpy(100);
41 fbz_xy_0z.SetNpx(100);
42 fbz_xy_0z->Draw("colz");
44 TF2 fbz_xy_250z("fbz_xy_250z","AliMagFDraw::GetBz(sqrt(x^2+y^2),atan2(y,x),250)",-250,250,-250,250);
45 fbz_xy_250z.SetNpy(100);
46 fbz_xy_250z.SetNpx(100)
47 fbz_xy_250z->Draw("colz");
49 TF2 fbz_xy_m250z("fbz_xy_m250z","AliMagFDraw::GetBz(sqrt(x^2+y^2),atan2(y,x),-250)",-250,250,-250,250);
50 fbz_xy_m250z.SetNpy(100);
51 fbz_xy_m250z.SetNpx(100)
52 fbz_xy_m250z->Draw("colz");
57 #include "TObjArray.h"
60 #include "TLinearFitter.h"
63 class AliMagFDraw : public AliMagF
66 AliMagFDraw():AliMagF(){}
67 static void RegisterField(Int_t index, AliMagF * magf);
68 static Double_t GetBx(Double_t r, Double_t phi, Double_t z,Int_t index=0);
69 static Double_t GetBy(Double_t r, Double_t phi, Double_t z,Int_t index=0);
70 static Double_t GetBz(Double_t r, Double_t phi, Double_t z,Int_t index=0);
71 static Double_t GetBr(Double_t r, Double_t phi, Double_t z,Int_t index=0);
72 static Double_t GetBrfi(Double_t r, Double_t phi, Double_t z,Int_t index=0);
73 //static Double_t GetBr2(Double_t r, Double_t phi, Double_t z,Int_t index=0);
74 //static Double_t GetBrfi2(Double_t r, Double_t phi, Double_t z,Int_t index=0);
75 static TObjArray *Fit(const char *formula, Int_t index=0);
77 static TObjArray fgArray;
78 ClassDef(AliMagFDraw,2)
85 TObjArray AliMagFDraw::fgArray;
87 void AliMagFDraw::RegisterField(Int_t index, AliMagF * magf){
89 // add the filed to the list
91 fgArray.AddAt(magf,index);
94 Double_t AliMagFDraw::GetBz(Double_t r, Double_t phi, Double_t z,Int_t index){
98 AliMagF *mag = (AliMagF*)fgArray.At(index);
100 Float_t xyz[3]={r*TMath::Cos(phi),r*TMath::Sin(phi),z};
103 mag->Field(xyz,bxyz);
107 Double_t AliMagFDraw::GetBy(Double_t r, Double_t phi, Double_t z,Int_t index){
111 AliMagF *mag = (AliMagF*)fgArray.At(index);
113 Float_t xyz[3]={r*TMath::Cos(phi),r*TMath::Sin(phi),z};
116 mag->Field(xyz,bxyz);
121 Double_t AliMagFDraw::GetBx(Double_t r, Double_t phi, Double_t z,Int_t index){
125 AliMagF *mag = (AliMagF*)fgArray.At(index);
127 Float_t xyz[3]={r*TMath::Cos(phi),r*TMath::Sin(phi),z};
130 mag->Field(xyz,bxyz);
137 Double_t AliMagFDraw::GetBr(Double_t r, Double_t phi, Double_t z,Int_t index){
141 AliMagF *mag = (AliMagF*)fgArray.At(index);
143 Float_t xyz[3]={r*TMath::Cos(phi),r*TMath::Sin(phi),z};
146 mag->Field(xyz,bxyz);
148 Float_t br = bxyz[0]*xyz[0]/r+bxyz[1]*xyz[1]/r;
152 Double_t AliMagFDraw::GetBrfi(Double_t r, Double_t phi, Double_t z,Int_t index){
156 AliMagF *mag = (AliMagF*)fgArray.At(index);
158 Float_t xyz[3]={r*TMath::Cos(phi),r*TMath::Sin(phi),z};
161 mag->Field(xyz,bxyz);
163 Float_t br = -bxyz[0]*xyz[1]/r+bxyz[1]*xyz[0]/r;
168 TObjArray * AliMagFDraw::Fit(const char *formula, Int_t index){
171 formula="1++x+x^2++cos(y)++cos(y)^2++z++z^2"
175 TObjArray *fstrings = TString(formula).Tokenize("++");
176 Int_t ndim = fstrings->GetEntries();
177 TObjArray *formulas = new TObjArray(ndim);
178 for (Int_t i=0;i<ndim;i++){
179 formulas->AddAt(new TFormula(Form("fff_%d",i),fstrings->At(i)->GetName()),i);
181 TLinearFitter * fitR = new TLinearFitter(ndim+1,Form("hyp%d",ndim));
182 TLinearFitter * fitRFI = new TLinearFitter(ndim+1,Form("hyp%d",ndim));
183 TLinearFitter * fitZ = new TLinearFitter(ndim+1,Form("hyp%d",ndim));
185 for (Float_t r=20; r<250;r+=20){
186 for (Float_t fi=0; fi<TMath::Pi()*2;fi+=0.2){
187 for (Float_t z=-250; z<250;z+=20){
188 for (Int_t ifor=0;ifor<ndim;ifor++){
189 x[ifor]= ((TFormula*)formulas->At(ifor))->Eval(r/250.,fi,z/250.);
191 fitR->AddPoint(x,AliMagFDraw::GetBr(r,fi,z,index));
192 fitRFI->AddPoint(x,AliMagFDraw::GetBrfi(r,fi,z,index));
193 fitZ->AddPoint(x,AliMagFDraw::GetBz(r,fi,z,index));
200 TObjArray *res = new TObjArray;
202 res->AddAt(fitRFI,1);
204 printf("\tchi2\tn\tRMS\n");
205 printf("\t%f\t%d\t%f\n",fitR->GetChisquare(),fitR->GetNpoints(),TMath::Sqrt(fitR->GetChisquare()/fitR->GetNpoints()));
206 printf("\t%f\t%d\t%f\n",fitRFI->GetChisquare(),fitRFI->GetNpoints(),TMath::Sqrt(fitRFI->GetChisquare()/fitRFI->GetNpoints()));
207 printf("\t%f\t%d\t%f\n",fitZ->GetChisquare(),fitZ->GetNpoints(),TMath::Sqrt(fitZ->GetChisquare()/fitZ->GetNpoints()));
209 TFormula * funBZ = new TFormula("funBZ",formula);
210 TFormula * funBR = new TFormula("funBR",formula);
211 TFormula * funBRFI = new TFormula("funBRFI",formula);
213 fitR->GetParameters(vec);
214 funBR->SetParameters(vec.GetMatrixArray());
215 fitRFI->GetParameters(vec);
216 funBRFI->SetParameters(vec.GetMatrixArray());
217 fitZ->GetParameters(vec);
218 funBZ->SetParameters(vec.GetMatrixArray());
224 TString MakeString(){
228 for (Int_t ix=0;ix<3;ix++)
229 for (Int_t iz=0;iz<3;iz++){
231 str+=Form("x^%d*z^%d++",ix,iz);
232 printf("x^%d*z^%d++\n",ix,iz);
234 for (Int_t iy=1;iy<4;iy++){
235 if (ix+iz+iy==0) continue;
236 str+=Form("x^%d*z^%d*sin(y*%d)++",ix,iz,iy);
237 str+=Form("x^%d*z^%d*cos(y*%d)++",ix,iz,iy);
238 printf( "x^%d*z^%d*sin(y*%d)++\n",ix,iz,iy);
239 printf( "x^%d*z^%d*cos(y*%d)++\n",ix,iz,iy);
243 str[str.Length()-2]=0;
252 TObjArray * array = AliMagFDraw::Fit("x",0)
255 15.534116 9600 0.040226
256 4.422160 9600 0.021463
257 8.378622 9600 0.029543
259 TObjArray * array = AliMagFDraw::Fit("x++z++z^2++x*sin(y)++x*cos(y)++z*x*sin(y)++z*x*cos(y)++z^2*x*sin(y)++z^2*x*cos(y)++z^2*x*sin(y)^2++z^2*x*cos(y)^2++z^3*x*sin(y)^2++z^3*x*cos(y)^2",0);
261 1.842443 9600 0.013854
262 0.957056 9600 0.009985
263 0.097799 9600 0.003192
265 TObjArray * array = AliMagFDraw::Fit("x++z++z^2++x*sin(y)++x*cos(y)++z*x*sin(y)++z*x*cos(y)++z^2*x*sin(y)++z^2*x*cos(y)++z^2*x*sin(y)^2++z^2*x*cos(y)^2++z^3*x*sin(y)^2++z^3*x*cos(y)++z^3*sin(y)++z^3*cos(y)++z^3*x*cos(y)++z^2*sin(y)++z^2*cos(y)++z*sin(y)++z*cos(y)++sin(y)++cos(y)",0);
268 1.564687 9600 0.012767
269 0.002291 9600 0.000489
270 0.097063 9600 0.003180
273 TObjArray * array = AliMagFDraw::Fit(MakeString(),0);
276 0.000303 9600 0.000178
277 0.000066 9600 0.000083
278 0.003110 9600 0.000569