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