]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCPRF2D.cxx
Reoved useless file.
[u/mrichter/AliRoot.git] / TPC / AliTPCPRF2D.cxx
CommitLineData
8c555625 1///////////////////////////////////////////////////////////////////////////////
2// AliTPCPRF2D - //
3// Pad response function object in two dimesions //
4// This class contains the basic functions for the //
5// calculation of PRF according generic charge distribution //
6// In Update function object calculate table of response function //
7// in discrete x and y position //
8// This table is used for interpolation od response function in any position //
9// (function GetPRF) //
10// //
11// Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk //
12// //
13///////////////////////////////////////////////////////////////////////////////
14#include "TMath.h"
15#include "AliTPCPRF2D.h"
16#include "TF2.h"
17#include <iostream.h>
18#include <string.h>
19#include "TCanvas.h"
20#include "TPad.h"
21#include "TStyle.h"
22#include "TH1.h"
23#include "TH2.h"
24#include "TPaveText.h"
25#include "TText.h"
26
27extern TStyle * gStyle;
28
29static const Float_t sqrt12=3.46;
30static const Int_t NPRF = 100;
31
32
33static Double_t funGauss2D(Double_t *x, Double_t * par)
34{
35 return ( TMath::Exp(-(x[0]*x[0])/(2*par[0]*par[0]))*
36 TMath::Exp(-(x[1]*x[1])/(2*par[1]*par[1])));
37
38}
39
40static Double_t funCosh2D(Double_t *x, Double_t * par)
41{
42 return ( 1/(TMath::CosH(3.14159*x[0]/(2*par[0]))*
43 TMath::CosH(3.14159*x[1]/(2*par[1]))));
44}
45
46static Double_t funGati2D(Double_t *x, Double_t * par)
47{
48 //par[1] = is equal to k3X
49 //par[0] is equal to pad wire distance
50 Float_t K3=par[1];
51 Float_t K3R=TMath::Sqrt(K3);
52 Float_t K2=(TMath::Pi()/2)*(1-K3R/2.);
53 Float_t K1=K2*K3R/(4*TMath::ATan(K3R));
54 Float_t l=x[0]/par[0];
55 Float_t tan2=TMath::TanH(K2*l);
56 tan2*=tan2;
57 Float_t res = K1*(1-tan2)/(1+K3*tan2);
58 //par[4] = is equal to k3Y
59 K3=par[4];
60 K3R=TMath::Sqrt(K3);
61 K2=(TMath::Pi()/2)*(1-K3R/2.);
62 K1=K2*K3R/(4*TMath::ATan(K3R));
63 l=x[1]/par[0];
64 tan2=TMath::TanH(K2*l);
65 tan2*=tan2;
66 res = res*K1*(1-tan2)/(1+K3*tan2);
67 return res;
68}
69
70
71///////////////////////////////////////////////////////////////////////////
72///////////////////////////////////////////////////////////////////////////
73///////////////////////////////////////////////////////////////////////////
74///////////////////////////////////////////////////////////////////////////
75
76ClassImp(AliTPCPRF2D)
77
78AliTPCPRF2D::AliTPCPRF2D()
79{
80 ffcharge = 0;
81 fNPRF =NPRF ;
82 fSigmaX = 0;
83
84 fGRF = 0;
85 fkNorm = 1;
86 forigsigmaY=0;
87 forigsigmaX=0;
88 fNdiv = 5;
89 //chewron default values
90 SetPad(0.8,0.8);
91 SetChevron(0.2,0.0,1.0);
92 SetY(-0.2,0.2,2);
93 // SetGauss(0.22,0.22,1);
94}
95
96AliTPCPRF2D::~AliTPCPRF2D()
97{
98 if (ffcharge!=0) delete [] ffcharge;
99 if (fGRF !=0 ) fGRF->Delete();
100}
101
102void AliTPCPRF2D::SetY(Float_t y1, Float_t y2, Int_t nYdiv)
103{
104 //
105 //set virtual line position
106 //first and last line and number of lines
107 fNYdiv = nYdiv;
108 if (ffcharge!=0) delete [] ffcharge;
109 ffcharge = new Float_t[fNPRF*fNYdiv];
110 fY1=y1;
111 fY2=y2;
112}
113
114void AliTPCPRF2D::SetPad(Float_t width, Float_t height)
115{
116 //set base chevron parameters
117 fHeightFull=height;
118 fWidth=width;
119}
120void AliTPCPRF2D::SetChevron(Float_t hstep,
121 Float_t shifty,
122 Float_t fac)
123{
124 //set shaping of chewron parameters
125 fHeightS=hstep;
126 fShiftY=shifty;
127 fK=fWidth*fac/hstep;
128}
129
130void AliTPCPRF2D::SetChParam(Float_t width, Float_t height,
131 Float_t hstep, Float_t shifty, Float_t fac)
132{
133 SetPad(width,height);
134 SetChevron(hstep,shifty,fac);
135}
136
137
138Float_t AliTPCPRF2D::GetPRF(Float_t xin, Float_t yin, Bool_t inter)
139{
140 if (ffcharge==0) return 0;
141 // Float_t y=Float_t(fNYdiv-1)*(yin-fY1)/(fY2-fY1);
142 //transform position to "wire position"
143 Float_t y=fDYtoWire*(yin-fY1);
144 if (fNYdiv == 1) y=fY1;
145 //normaly it find nearest line charge
146 if (inter ==kFALSE){
147 Int_t i=Int_t(0.5+y);
148 if (y<0) i=Int_t(-0.5+y);
149 if ((i<0) || (i>=fNYdiv) ) return 0;
150 fcharge = &(ffcharge[i*fNPRF]);
151 return GetPRFActiv(xin);
152 }
153 else{
154 //make interpolation from more fore lines
155 Int_t i= Int_t(y);
156 if ((i<0) || (i>=fNYdiv) ) return 0;
157 Float_t z0=0;
158 Float_t z1=0;
159 Float_t z2=0;
160 Float_t z3=0;
161 if (i>0) {
162 fcharge =&(ffcharge[(i-1)*fNPRF]);
163 z0 = GetPRFActiv(xin);
164 }
165 fcharge =&(ffcharge[i*fNPRF]);
166 z1=GetPRFActiv(xin);
167 if ((i+1)<fNYdiv){
168 fcharge =&(ffcharge[(i+1)*fNPRF]);
169 z2 = GetPRFActiv(xin);
170 }
171 if ((i+2)<fNYdiv){
172 fcharge =&(ffcharge[(i+2)*fNPRF]);
173 z3 = GetPRFActiv(xin);
174 }
175 Float_t a,b,c,d,K,L;
176 a=z1;
177 b=(z2-z0)/2.;
178 K=z2-a-b;
179 L=(z3-z1)/2.-b;
180 d=L-2*K;
181 c=K-d;
182 Float_t dy=y-Float_t(i);
183 Float_t res = a+b*dy+c*dy*dy+d*dy*dy*dy;
184 //Float_t res = z1*(1-dy)+z2*dy;
185 return res;
186 }
187 return 0.;
188}
189
190
191Float_t AliTPCPRF2D::GetPRFActiv(Float_t xin)
192{
193 //x xin DStep unit
194 //return splaine aproximaton
195 Float_t x = (xin*fDStepM1)+fNPRF/2;
196 Int_t i = Int_t(x);
197
198 if ( (i>0) && ((i+2)<fNPRF)) {
199 Float_t a,b,c,d,K,L;
200 a = fcharge[i];
201 b = (fcharge[i+1]-fcharge[i-1])*0.5;
202 K = fcharge[i+1]-a-b;
203 L = (fcharge[i+2]-fcharge[i])*0.5-b;
204 d=L-2.*K;
205 c=K-d;
206 Float_t dx=x-Float_t(i);
207 Float_t res = a+b*dx+c*dx*dx+d*dx*dx*dx;
208 return res;
209 }
210 else return 0;
211}
212
213
214Float_t AliTPCPRF2D::GetGRF(Float_t xin, Float_t yin)
215{
216 if (fGRF != 0 )
217 return fkNorm*fGRF->Eval(xin,yin)/fInteg;
218 else
219 return 0.;
220}
221
222
223void AliTPCPRF2D::SetParam( TF2 * GRF, Float_t kNorm,
224 Float_t sigmaX, Float_t sigmaY)
225{
226 if (fGRF !=0 ) fGRF->Delete();
227 fGRF = GRF;
228 fkNorm = kNorm;
229 if (sigmaX ==0) sigmaX=(fWidth+fK*fHeightS)/sqrt12;
230 if (sigmaY ==0) sigmaY=(fWidth+fK*fHeightS)/sqrt12;
231 forigsigmaX=sigmaX;
232 forigsigmaY=sigmaY;
233 fDStep = TMath::Sqrt(sigmaX*sigmaX+fWidth*fWidth/6.)/10.;
234 // Update();
235 sprintf(fType,"User");
236}
237
238
239void AliTPCPRF2D::SetGauss(Float_t sigmaX, Float_t sigmaY,
240 Float_t kNorm)
241{
242 fkNorm = kNorm;
243 if (fGRF !=0 ) fGRF->Delete();
244 fGRF = new TF2("fun",funGauss2D,-5.,5.,-5.,5.,4);
245 funParam[0]=sigmaX;
246 funParam[1]=sigmaY;
247 funParam[2]=fK;
248 funParam[3]=fHeightS;
249 forigsigmaX=sigmaX;
250 forigsigmaY=sigmaY;
251 fGRF->SetParameters(funParam);
252 fDStep = TMath::Sqrt(sigmaX*sigmaX+fWidth*fWidth/6.)/10.;
253 //by default I set the step as one tenth of sigma
254 //Update();
255 sprintf(fType,"Gauss");
256}
257
258void AliTPCPRF2D::SetCosh(Float_t sigmaX, Float_t sigmaY,
259 Float_t kNorm)
260{
261 fkNorm = kNorm;
262 if (fGRF !=0 ) fGRF->Delete();
263 fGRF = new TF2("fun", funCosh2D,-5.,5.,-5.,5.,4);
264 funParam[0]=sigmaX;
265 funParam[1]=sigmaY;
266 funParam[2]=fK;
267 funParam[3]=fHeightS;
268 fGRF->SetParameters(funParam);
269 forigsigmaX=sigmaX;
270 forigsigmaY=sigmaY;
271 fDStep = TMath::Sqrt(sigmaX*sigmaX+fWidth*fWidth/6.)/10.;
272 //by default I set the step as one tenth of sigma
273 //Update();
274 sprintf(fType,"Cosh");
275}
276
277void AliTPCPRF2D::SetGati(Float_t K3X, Float_t K3Y,
278 Float_t padDistance,
279 Float_t kNorm)
280{
281 fkNorm = kNorm;
282 if (fGRF !=0 ) fGRF->Delete();
283 fGRF = new TF2("fun", funGati2D,-5.,5.,-5.,5.,5);
284 fK3X=K3X;
285 fK3Y=K3Y;
286 fPadDistance=padDistance;
287 funParam[0]=padDistance;
288 funParam[1]=K3X;
289 funParam[2]=fK;
290 funParam[3]=fHeightS;
291 funParam[4]=K3Y;
292 fGRF->SetParameters(funParam);
293 forigsigmaX=padDistance;
294 forigsigmaY=padDistance;
295 fDStep = TMath::Sqrt(padDistance*padDistance+fWidth*fWidth/6.)/10.;
296 //by default I set the step as one tenth of sigma
297 //Update();
298 sprintf(fType,"Gati");
299}
300
301
302
303void AliTPCPRF2D::Update()
304{
305 for (Int_t i=0; i<fNYdiv; i++){
306 if (fNYdiv == 1) fActualY = fY1;
307 else
308 fActualY = fY1+Float_t(i)*(fY2-fY1)/Float_t(fNYdiv-1);
309 fcharge = &(ffcharge[i*fNPRF]);
310 Update1();
311 }
312}
313
314
315
316void AliTPCPRF2D::Update1()
317{
318 //initialize to 0
319
320
321 Int_t i;
322 Float_t x;
323 for (i =0; i<fNPRF;i++) fcharge[i] = 0;
324 if ( fGRF == 0 ) return;
325 ////////////////////////////////////////////////////////
326 //I'm waiting for normal integral
327 //in this moment only sum
328 Float_t x2= 4*forigsigmaX;
329 Float_t y2= 4*forigsigmaY;
330 Float_t dx = forigsigmaX/Float_t(fNdiv*6);
331 Float_t dy = forigsigmaY/Float_t(fNdiv*6);
332 fInteg = 0;
333 for (x=0.;x<x2;x+=dx)
334 for (Float_t y=0;y<y2;y+=dy) fInteg+=fGRF->Eval(x,y)*dx*dy;
335 fInteg*=4;
336 /////////////////////////////////////////////////////
337
338
339 if ( fInteg == 0 ) fInteg = 1;
340
341 //integrate charge over pad for different distance of pad
342 for (i =0; i<fNPRF;i++)
343 { //x in cm fWidth in cm
344 //calculate integral
345 Float_t xch = fDStep * (Float_t)(i-fNPRF/2);
346 Float_t k=1;
347 fcharge[i]=0;
348 for (Float_t y=-fHeightFull/2.-fShiftY;
349 y<fHeightFull/2.;y+=fHeightS){
350 Float_t y2=TMath::Min((y+fHeightS),Float_t(fHeightFull/2.));
351 Float_t y1=TMath::Max((y),Float_t(-fHeightFull/2.));
352 Float_t x1;
353
354 if (k>0)
355 x1 = (y2-y1)*fK-(fWidth+fK*fHeightS)/2.;
356 else
357 x1 =-(fWidth+fK*fHeightS)/2. ;
358 Float_t x2=x1+fWidth;
359
360 if (y2>y1) {
361
362 if ((x2-x1)*fNdiv<forigsigmaX) dx=(x2-x1);
363 else{
364 dx= forigsigmaX/Float_t(fNdiv);
365 dx = (x2-x1)/Float_t(Int_t(3+(x2-x1)/dx));
366 }
367 Float_t dy;
368 if ((y2-y1)*fNdiv<forigsigmaY) dy=(y2-y1);
369 else{
370 dy= forigsigmaY/Float_t(fNdiv);
371 dy = (y2-y1)/Float_t(Int_t(3+(y2-y1)/dy));
372 }
373
374 for (x=x1;x<x2;x+=dx)
375 for (Float_t y=y1;y<y2;y+=dy){
376 if ( (y>(fActualY-(4.0*forigsigmaY))) &&
377 (y<(fActualY+(4.0*forigsigmaY)))){
378 Float_t xt=x-k*fK*(y-y1);
379 if ((TMath::Abs(xch-xt)<4*forigsigmaX)){
380
381 Float_t z0=fGRF->Eval(xch-(xt+dx/2.),fActualY-(y+dy/2.));
382
383 Float_t z1=fGRF->Eval(xch-(xt+dx/2.),fActualY-y);
384 Float_t z2=fGRF->Eval(xch-xt,fActualY-(y+dy/2.));
385 Float_t z3=fGRF->Eval(xch-(xt-dx/2.),fActualY-y);
386 Float_t z4=fGRF->Eval(xch-xt,fActualY-(y-dy/2.));
387 if (z0<0) z0=0;
388 if (z1<0) z1=0;
389 if (z2<0) z2=0;
390 if (z3<0) z3=0;
391 if (z4<0) z4=0;
392
393 // Float_t a=(z1-z3)/2;
394 // Float_t b=(z2-z4)/2;
395 Float_t c= (z3+z1-2*z0)/2.;
396 Float_t d= (z2+z4-2*z0)/2.;
397 Float_t z= (z0+c/12.+d/12.);
398
399 //Float_t z= fGRF->Eval(xch-xt,fActualY-y);
400 if (z>0.) fcharge[i]+=z*dx*dy/fInteg;
401 }
402 }
403 }
404 }
405 k*=-1;
406 }
407 };
408
409 fSigmaX = 0;
410 Float_t sum =0;
411 Float_t mean=0;
412 for (x =-fNPRF*fDStep; x<fNPRF*fDStep;x+=fDStep)
413 { //x in cm fWidth in cm
414 Float_t weight = GetPRFActiv(x);
415 fSigmaX+=x*x*weight;
416 mean+=x*weight;
417 sum+=weight;
418 };
419 if (sum>0){
420 mean/=sum;
421 fSigmaX = TMath::Sqrt(fSigmaX/sum-mean*mean);
422 }
423 else fSigmaX=0;
424 //calculate conversion coefitient to convert position to virtual wire
425 fDYtoWire=Float_t(fNYdiv-1)/(fY2-fY1);
426 fDStepM1=1/fDStep;
427}
428
429void AliTPCPRF2D::Streamer(TBuffer &R__b)
430{
431 // Stream an object of class AliTPCPRF2D
432
433 if (R__b.IsReading()) {
434 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
435 TObject::Streamer(R__b);
436 //read chewron parameters
437 R__b >> fSigmaX;
438 R__b >> fHeightFull;
439 R__b >> fHeightS;
440 R__b >> fShiftY;
441 R__b >> fWidth;
442 R__b >> fK;
443 R__b >> fActualY;
444 //read charge parameters
445 R__b >> fType[0];
446 R__b >> fType[1];
447 R__b >> fType[2];
448 R__b >> fType[3];
449 R__b >> fType[4];
450 R__b >> forigsigmaX;
451 R__b >> forigsigmaY;
452 R__b >> fkNorm;
453 R__b >> fK3X;
454 R__b >> fK3Y;
455 R__b >> fPadDistance;
456 R__b >> fInteg;
457
458 //read functions
459 if (fGRF!=0) {
460 delete [] fGRF;
461 fGRF=0;
462 }
463 if (strncmp(fType,"User",3)==0){
464 fGRF= new TF2;
465 R__b>>fGRF;
466 }
467 if (strncmp(fType,"Gauss",3)==0)
468 fGRF = new TF2("fun",funGauss2D,-5.,5.,-5.,5.,4);
469 if (strncmp(fType,"Cosh",3)==0)
470 fGRF = new TF2("fun",funCosh2D,-5.,5.,-5.,5.,4);
471 if (strncmp(fType,"Gati",3)==0)
472 fGRF = new TF2("fun",funGati2D,-5.,5.,-5.,5.,5);
473
474 //read interpolation parameters
475 R__b >>fY1;
476 R__b >>fY2;
477 R__b >>fNYdiv;
478 R__b >>fDStep;
479 R__b >>fNPRF;
480 if (ffcharge!=0) delete [] ffcharge;
481 ffcharge = new Float_t[fNPRF*fNYdiv];
482 R__b.ReadFastArray(ffcharge,fNPRF*fNYdiv);
483 R__b.ReadFastArray(funParam,5);
484 if (fGRF!=0) fGRF->SetParameters(funParam);
485 //calculate conversion coefitient to convert position to virtual wire
486 fDYtoWire=Float_t(fNYdiv-1)/(fY2-fY1);
487 fDStepM1=1/fDStep;
488 } else {
489 R__b.WriteVersion(AliTPCPRF2D::IsA());
490 TObject::Streamer(R__b);
491 //write chewron parameters
492 R__b << fSigmaX;
493 R__b << fHeightFull;
494 R__b << fHeightS;
495 R__b << fShiftY;
496 R__b << fWidth;
497 R__b << fK;
498 R__b << fActualY;
499 //write charge parameters
500 R__b << fType[0];
501 R__b << fType[1];
502 R__b << fType[2];
503 R__b << fType[3];
504 R__b << fType[4];
505
506 R__b << forigsigmaX;
507 R__b << forigsigmaY;
508 R__b << fkNorm;
509 R__b << fK3X;
510 R__b << fK3Y;
511 R__b << fPadDistance;
512 R__b << fInteg;
513
514 if (strncmp(fType,"User",3)==0) R__b <<fGRF;
515 //write interpolation parameters
516 R__b <<fY1;
517 R__b <<fY2;
518 R__b <<fNYdiv;
519 R__b <<fDStep;
520 R__b <<fNPRF;
521 R__b.WriteFastArray(ffcharge,fNPRF*fNYdiv);
522 R__b.WriteFastArray(funParam,5);
523 }
524}
525
526
527
528
529void AliTPCPRF2D::DrawX(Float_t x1 ,Float_t x2,Float_t y, Bool_t inter)
530{
531 if (fGRF==0) return ;
532 const Int_t N=100;
533 char s[100];
534 TCanvas * c1 = new TCanvas("canPRF","Pad response function",700,900);
535 c1->cd();
536 TPad * pad1 = new TPad("pad1PRF","",0.05,0.61,0.95,0.97,21);
537 pad1->Draw();
538 TPad * pad2 = new TPad("pad2PRF","",0.05,0.22,0.95,0.60,21);
539 pad2->Draw();
540
541 // pad1->cd();
542 //pad2->cd();
543 gStyle->SetOptFit(1);
544 gStyle->SetOptStat(0);
545 sprintf(s,"PRF response function for chevron pad");
546 TH1F * hPRFc = new TH1F("hPRFc",s,N+1,x1,x2);
547 Float_t x=x1;
548 Float_t y1;
549 // Float_t y2;
550
551 for (Float_t i = 0;i<N+1;i++)
552 {
553 x+=(x2-x1)/Float_t(N);
554 y1 = GetPRF(x,y,inter);
555 hPRFc->Fill(x,y1);
556 };
557
558 pad1->cd();
559 fGRF->SetRange(x1,x1,x2,x2);
560 fGRF->SetNpx(25);
561 fGRF->SetNpy(25);
562 fGRF->Draw("lego2");
563 // hPRFo->Fit("gaus");
564 gStyle->SetOptStat(1);
565 pad2->cd();
566 hPRFc->Fit("gaus");
567 c1->cd();
568 TPaveText * comment = new TPaveText(0.05,0.02,0.95,0.20,"NDC");
569 comment->SetTextAlign(12);
570 comment->SetFillColor(42);
571 TText *title = comment->AddText("Chevron pad parameters:");
572 title->SetTextSize(0.03);
573 sprintf(s,"Full height of pad: %2.2f",fHeightFull);
574 comment->AddText(s);
575 sprintf(s,"Height of one chevron unit h: %2.2f cm",2*fHeightS);
576 comment->AddText(s);
577 sprintf(s,"Width of one chevron unit w: %2.2f cm",fWidth);
578 comment->AddText(s);
579 sprintf(s,"Overlap factor: %2.2f",fK*fHeightS/fWidth);
580 comment->AddText(s);
581 sprintf(s,"Y position: %2.2f ",y);
582 comment->AddText(s);
583 sprintf(s,"Sigma x of original distribution: %2.2f ",forigsigmaX);
584 comment->AddText(s);
585 sprintf(s,"Sigma y of original distribution: %2.2f ",forigsigmaY);
586 comment->AddText(s);
587 sprintf(s,"Type of original distribution: %s ",fType);
588 comment->AddText(s);
589 comment->Draw();
590}
591
592
593
594void AliTPCPRF2D::Draw(Float_t x1 ,Float_t x2,Float_t y1, Float_t y2,
595 Bool_t inter, Int_t Nx, Int_t Ny)
596{
597 char s[100];
598 if (fGRF==0) return ;
599 TCanvas * c1 = new TCanvas("canPRF","Pad response function",700,900);
600 c1->cd();
601 TPad * pad1 = new TPad("pad1PRF","",0.05,0.61,0.95,0.97,21);
602 pad1->Draw();
603 TPad * pad2 = new TPad("pad2PRF","",0.05,0.22,0.95,0.60,21);
604 pad2->Draw();
605
606 // pad1->cd();
607 //pad2->cd();
608 gStyle->SetOptFit(1);
609 gStyle->SetOptStat(0);
610 sprintf(s,"PRF response function for chevron pad");
611 TH2F * hPRFc = new TH2F("hPRFc",s,Nx+1,x1,x2,Ny+1,y1,y2);
612 Float_t dx=(x2-x1)/Float_t(Nx);
613 Float_t dy=(y2-y1)/Float_t(Ny) ;
614 Float_t x,y,z;
615 // Float_t y2;
616 for ( x = x1;x<=x2;x+=dx){
617 for(y = y1;y<=y2;y+=dy)
618 {
619 z = GetPRF(x,y,inter);
620 hPRFc->Fill(x,y,z);
621 };
622 }
623 pad1->cd();
624 fGRF->SetRange(x1,y1,x2,y2);
625 fGRF->SetNpx(25);
626 fGRF->SetNpy(25);
627 fGRF->Draw("lego2");
628 // hPRFo->Fit("gaus");
629 gStyle->SetOptStat(1);
630 pad2->cd();
631 hPRFc->Draw("lego2");
632 c1->cd();
633 TPaveText * comment = new TPaveText(0.05,0.02,0.95,0.20,"NDC");
634 comment->SetTextAlign(12);
635 comment->SetFillColor(42);
636 TText *title = comment->AddText("Chevron pad parameters:");
637 title->SetTextSize(0.03);
638 sprintf(s,"Full height of pad: %2.2f",fHeightFull);
639 comment->AddText(s);
640 sprintf(s,"Height of one chevron unit h: %2.2f cm",2*fHeightS);
641 comment->AddText(s);
642 sprintf(s,"Width of one chevron unit w: %2.2f cm",fWidth);
643 comment->AddText(s);
644 sprintf(s,"Overlap factor: %2.2f",fK*fHeightS/fWidth);
645 comment->AddText(s);
646 sprintf(s,"Sigma x of original distribution: %2.2f ",forigsigmaX);
647 comment->AddText(s);
648 sprintf(s,"Sigma y of original distribution: %2.2f ",forigsigmaY);
649 comment->AddText(s);
650 sprintf(s,"Type of original distribution: %s ",fType);
651 comment->AddText(s);
652 comment->Draw();
653}
654
655void AliTPCPRF2D::DrawDist(Float_t x1 ,Float_t x2,Float_t y1, Float_t y2,
656 Bool_t inter, Int_t Nx, Int_t Ny, Float_t thr)
657{
658 const Float_t minth=0.00001;
659 if (thr<minth) thr=minth;
660 char s[100];
661 if (fGRF==0) return ;
662 TCanvas * c1 = new TCanvas("padDistortion","COG distortion",700,900);
663 c1->cd();
664 TPad * pad1 = new TPad("CHARGE","",0.05,0.61,0.95,0.97,21);
665 pad1->Draw();
666 TPad * pad2 = new TPad("dist","",0.05,0.22,0.95,0.60,21);
667 pad2->Draw();
668
669 // pad1->cd();
670 //pad2->cd();
671 gStyle->SetOptFit(1);
672 gStyle->SetOptStat(0);
673 sprintf(s,"COG distortion (threshold=%2.2f)",thr);
674 TH2F * hPRFDist = new TH2F("hDistortion",s,Nx+1,x1,x2,Ny+1,y1,y2);
675 Float_t dx=(x2-x1)/Float_t(Nx);
676 Float_t dy=(y2-y1)/Float_t(Ny) ;
677 Float_t x,y,z,ddx;
678 // Float_t y2;
679 for ( x = x1;x<(x2+dx/2.);x+=dx)
680 for(y = y1;y<=(y2+dx/2.);y+=dy)
681 {
682 Float_t sumx=0;
683 Float_t sum=0;
684 for (Float_t padx=-fWidth;padx<(fWidth*1.1);padx+=fWidth)
685 {
686 z = GetPRF(x-padx,y,inter);
687 if (z>thr){
688 sum+=z;
689 sumx+=z*padx;
690 }
691 };
692 if (sum>minth)
693 {
694 ddx = (x-(sumx/sum));
695 }
696 else ddx=-1;
697 if (TMath::Abs(ddx)<10) hPRFDist->Fill(x,y,ddx);
698 }
699 pad1->cd();
700 fGRF->SetRange(x1,y1,x2,y2);
701 fGRF->SetNpx(25);
702 fGRF->SetNpy(25);
703 fGRF->Draw("lego2");
704 // hPRFo->Fit("gaus");
705 // gStyle->SetOptStat(1);
706 pad2->cd();
707 hPRFDist->Draw("lego2");
708
709 c1->cd();
710 TPaveText * comment = new TPaveText(0.05,0.02,0.95,0.20,"NDC");
711 comment->SetTextAlign(12);
712 comment->SetFillColor(42);
713 // TText *title = comment->AddText("Distortion of COG method");
714 // title->SetTextSize(0.03);
715 TText * title = comment->AddText("Chevron pad parameters:");
716 title->SetTextSize(0.03);
717 sprintf(s,"Full height of pad: %2.2f",fHeightFull);
718 comment->AddText(s);
719 sprintf(s,"Height of one chevron unit h: %2.2f cm",2*fHeightS);
720 comment->AddText(s);
721 sprintf(s,"Width of one chevron unit w: %2.2f cm",fWidth);
722 comment->AddText(s);
723 sprintf(s,"Overlap factor: %2.2f",fK*fHeightS/fWidth);
724 comment->AddText(s);
725 sprintf(s,"Sigma x of original distribution: %2.2f ",forigsigmaX);
726 comment->AddText(s);
727 sprintf(s,"Sigma y of original distribution: %2.2f ",forigsigmaY);
728 comment->AddText(s);
729 sprintf(s,"Type of original distribution: %s ",fType);
730 comment->AddText(s);
731 comment->Draw();
732
733}
734