1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // TPC cluster error, shape and charge parameterization as function
20 // of drift length, and inclination angle //
22 // Following notation is used in following
23 // Int_t dim 0 - y direction
26 // Int_t type 0 - short pads
29 // Float_t z - drift length
31 // Float_t angle - tangent of inclination angle at given dimension
33 // Implemented parameterization
36 // 1. Resolution as function of drift length and inclination angle
37 // 1.a) GetError0(Int_t dim, Int_t type, Float_t z, Float_t angle)
38 // Simple error parameterization as derived from analytical formula
39 // only linear term in drift length and angle^2
40 // The formula is valid only with precission +-5%
41 // Separate parameterization for differnt pad geometry
43 // Parabolic term correction - better precision
45 // 1.c) GetError1 - JUST FOR Study
46 // Similar to GetError1
47 // The angular and diffusion effect is scaling with pad length
48 // common parameterization for different pad length
50 // 2. Error parameterization using charge
53 // adding 1/Q component to diffusion and angluar part
56 // adding 1/Q component to diffusion and angluar part
57 // 2.c) GetErrorQParScaled - Just for study
58 // One parameterization for all pad shapes
59 // Smaller precission as previous one
62 // Example how to retrieve the paramterization:
64 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
65 AliCDBManager::Instance()->SetRun(0)
66 AliTPCClusterParam * param = AliTPCcalibDB::Instance()->GetClusterParam();
70 AliTPCClusterParam::SetInstance(param);
71 TF1 f1("f1","AliTPCClusterParam::SGetError0Par(1,0,x,0)",0,250);
74 // EXAMPLE hot to create parameterization
76 // Note resol is the resolution tree created by AliTPCcalibTracks
78 AliTPCClusterParam *param = new AliTPCClusterParam;
79 param->FitData(Resol);
80 AliTPCClusterParam::SetInstance(param);
86 ///////////////////////////////////////////////////////////////////////////////
87 #include "AliTPCClusterParam.h"
92 #include <TLinearFitter.h>
94 #include <TProfile2D.h>
96 #include <TObjArray.h>
97 #include "AliTPCcalibDB.h"
98 #include "AliTPCParam.h"
100 ClassImp(AliTPCClusterParam)
103 AliTPCClusterParam* AliTPCClusterParam::fgInstance = 0;
107 Example usage fitting parameterization:
108 TFile fres("resol.root"); //tree with resolution and shape
109 TTree * treeRes =(TTree*)fres.Get("Resol");
111 AliTPCClusterParam param;
112 param.SetInstance(¶m);
113 param.FitResol(treeRes);
114 param.FitRMS(treeRes);
115 TFile fparam("TPCClusterParam.root","recreate");
116 param.Write("Param");
119 TFile fparam("TPCClusterParam.root");
120 AliTPCClusterParam *param2 = (AliTPCClusterParam *) fparam.Get("Param");
121 param2->SetInstance(param2);
122 param2->Test(treeRes);
125 treeRes->Draw("(Resol-AliTPCClusterParam::SGetError0(Dim,Pad,Zm,AngleM))/Resol","Dim==0&&QMean<0")
132 //_ singleton implementation __________________________________________________
133 AliTPCClusterParam* AliTPCClusterParam::Instance()
136 // Singleton implementation
137 // Returns an instance of this class, it is created if neccessary
139 if (fgInstance == 0){
140 fgInstance = new AliTPCClusterParam();
146 AliTPCClusterParam::AliTPCClusterParam():
150 fQpadTnorm(0), // q pad normalization - Total charge
151 fQpadMnorm(0) // q pad normalization - Max charge
155 // Default constructor
157 fPosQTnorm[0] = 0; fPosQTnorm[1] = 0; fPosQTnorm[2] = 0;
158 fPosQMnorm[0] = 0; fPosQMnorm[1] = 0; fPosQMnorm[2] = 0;
160 fPosYcor[0] = 0; fPosYcor[1] = 0; fPosYcor[2] = 0;
161 fPosZcor[0] = 0; fPosZcor[1] = 0; fPosZcor[2] = 0;
164 AliTPCClusterParam::AliTPCClusterParam(const AliTPCClusterParam& param):
168 fQpadTnorm(new TVectorD(*(param.fQpadTnorm))), // q pad normalization - Total charge
169 fQpadMnorm(new TVectorD(*(param.fQpadMnorm))) // q pad normalization - Max charge
175 memcpy(this, ¶m,sizeof(AliTPCClusterParam));
176 if (param.fQNorm) fQNorm = (TObjArray*) param.fQNorm->Clone();
178 if (param.fPosQTnorm[0]){
179 fPosQTnorm[0] = new TVectorD(*(param.fPosQTnorm[0]));
180 fPosQTnorm[1] = new TVectorD(*(param.fPosQTnorm[1]));
181 fPosQTnorm[2] = new TVectorD(*(param.fPosQTnorm[2]));
183 fPosQMnorm[0] = new TVectorD(*(param.fPosQMnorm[0]));
184 fPosQMnorm[1] = new TVectorD(*(param.fPosQMnorm[1]));
185 fPosQMnorm[2] = new TVectorD(*(param.fPosQMnorm[2]));
187 if (param.fPosYcor[0]){
188 fPosYcor[0] = new TVectorD(*(param.fPosYcor[0]));
189 fPosYcor[1] = new TVectorD(*(param.fPosYcor[1]));
190 fPosYcor[2] = new TVectorD(*(param.fPosYcor[2]));
192 fPosZcor[0] = new TVectorD(*(param.fPosZcor[0]));
193 fPosZcor[1] = new TVectorD(*(param.fPosZcor[1]));
194 fPosZcor[2] = new TVectorD(*(param.fPosZcor[2]));
200 AliTPCClusterParam & AliTPCClusterParam::operator=(const AliTPCClusterParam& param){
202 // Assignment operator
204 if (this != ¶m) {
205 memcpy(this, ¶m,sizeof(AliTPCClusterParam));
206 if (param.fQNorm) fQNorm = (TObjArray*) param.fQNorm->Clone();
207 if (param.fPosQTnorm[0]){
208 fPosQTnorm[0] = new TVectorD(*(param.fPosQTnorm[0]));
209 fPosQTnorm[1] = new TVectorD(*(param.fPosQTnorm[1]));
210 fPosQTnorm[2] = new TVectorD(*(param.fPosQTnorm[2]));
212 fPosQMnorm[0] = new TVectorD(*(param.fPosQMnorm[0]));
213 fPosQMnorm[1] = new TVectorD(*(param.fPosQMnorm[1]));
214 fPosQMnorm[2] = new TVectorD(*(param.fPosQMnorm[2]));
216 if (param.fPosYcor[0]){
217 fPosYcor[0] = new TVectorD(*(param.fPosYcor[0]));
218 fPosYcor[1] = new TVectorD(*(param.fPosYcor[1]));
219 fPosYcor[2] = new TVectorD(*(param.fPosYcor[2]));
221 fPosZcor[0] = new TVectorD(*(param.fPosZcor[0]));
222 fPosZcor[1] = new TVectorD(*(param.fPosZcor[1]));
223 fPosZcor[2] = new TVectorD(*(param.fPosZcor[2]));
230 AliTPCClusterParam::~AliTPCClusterParam(){
234 if (fQNorm) fQNorm->Delete();
237 delete fPosQTnorm[0];
238 delete fPosQTnorm[1];
239 delete fPosQTnorm[2];
241 delete fPosQMnorm[0];
242 delete fPosQMnorm[1];
243 delete fPosQMnorm[2];
257 void AliTPCClusterParam::FitResol0(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
259 // Fit z - angular dependence of resolution
261 // Int_t dim=0, type=0;
263 sprintf(varVal,"Resol:AngleM:Zm");
265 sprintf(varErr,"Sigma:AngleS:Zs");
267 sprintf(varCut,"Dim==%d&&Pad==%d&&QMean<0",dim,type);
269 Int_t entries = tree->Draw(varVal,varCut);
270 Float_t px[10000], py[10000], pz[10000];
271 Float_t ex[10000], ey[10000], ez[10000];
273 tree->Draw(varErr,varCut);
274 for (Int_t ipoint=0; ipoint<entries; ipoint++){
275 ex[ipoint]= tree->GetV3()[ipoint];
276 ey[ipoint]= tree->GetV2()[ipoint];
277 ez[ipoint]= tree->GetV1()[ipoint];
279 tree->Draw(varVal,varCut);
280 for (Int_t ipoint=0; ipoint<entries; ipoint++){
281 px[ipoint]= tree->GetV3()[ipoint];
282 py[ipoint]= tree->GetV2()[ipoint];
283 pz[ipoint]= tree->GetV1()[ipoint];
287 TLinearFitter fitter(3,"hyp2");
288 for (Int_t ipoint=0; ipoint<entries; ipoint++){
289 Float_t val = pz[ipoint]*pz[ipoint];
290 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
293 x[1] = py[ipoint]*py[ipoint];
294 fitter.AddPoint(x,val,err);
298 fitter.GetParameters(param);
299 param0[0] = param[0];
300 param0[1] = param[1];
301 param0[2] = param[2];
302 Float_t chi2 = fitter.GetChisquare()/entries;
304 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
305 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
306 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
310 void AliTPCClusterParam::FitResol0Par(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
312 // Fit z - angular dependence of resolution
314 // Int_t dim=0, type=0;
316 sprintf(varVal,"Resol:AngleM:Zm");
318 sprintf(varErr,"Sigma:AngleS:Zs");
320 sprintf(varCut,"Dim==%d&&Pad==%d&&QMean<0",dim,type);
322 Int_t entries = tree->Draw(varVal,varCut);
323 Float_t px[10000], py[10000], pz[10000];
324 Float_t ex[10000], ey[10000], ez[10000];
326 tree->Draw(varErr,varCut);
327 for (Int_t ipoint=0; ipoint<entries; ipoint++){
328 ex[ipoint]= tree->GetV3()[ipoint];
329 ey[ipoint]= tree->GetV2()[ipoint];
330 ez[ipoint]= tree->GetV1()[ipoint];
332 tree->Draw(varVal,varCut);
333 for (Int_t ipoint=0; ipoint<entries; ipoint++){
334 px[ipoint]= tree->GetV3()[ipoint];
335 py[ipoint]= tree->GetV2()[ipoint];
336 pz[ipoint]= tree->GetV1()[ipoint];
340 TLinearFitter fitter(6,"hyp5");
341 for (Int_t ipoint=0; ipoint<entries; ipoint++){
342 Float_t val = pz[ipoint]*pz[ipoint];
343 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
346 x[1] = py[ipoint]*py[ipoint];
350 fitter.AddPoint(x,val,err);
354 fitter.GetParameters(param);
355 param0[0] = param[0];
356 param0[1] = param[1];
357 param0[2] = param[2];
358 param0[3] = param[3];
359 param0[4] = param[4];
360 param0[5] = param[5];
361 Float_t chi2 = fitter.GetChisquare()/entries;
363 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
364 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
365 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
366 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
367 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
368 error[5] = (fitter.GetParError(5)*TMath::Sqrt(chi2));
375 void AliTPCClusterParam::FitResol1(TTree * tree, Int_t dim, Float_t *param0, Float_t *error){
377 // Fit z - angular dependence of resolution - pad length scaling
379 // Int_t dim=0, type=0;
381 sprintf(varVal,"Resol:AngleM*sqrt(Length):Zm/Length");
383 sprintf(varErr,"Sigma:AngleS:Zs");
385 sprintf(varCut,"Dim==%d&&QMean<0",dim);
387 Int_t entries = tree->Draw(varVal,varCut);
388 Float_t px[10000], py[10000], pz[10000];
389 Float_t ex[10000], ey[10000], ez[10000];
391 tree->Draw(varErr,varCut);
392 for (Int_t ipoint=0; ipoint<entries; ipoint++){
393 ex[ipoint]= tree->GetV3()[ipoint];
394 ey[ipoint]= tree->GetV2()[ipoint];
395 ez[ipoint]= tree->GetV1()[ipoint];
397 tree->Draw(varVal,varCut);
398 for (Int_t ipoint=0; ipoint<entries; ipoint++){
399 px[ipoint]= tree->GetV3()[ipoint];
400 py[ipoint]= tree->GetV2()[ipoint];
401 pz[ipoint]= tree->GetV1()[ipoint];
405 TLinearFitter fitter(3,"hyp2");
406 for (Int_t ipoint=0; ipoint<entries; ipoint++){
407 Float_t val = pz[ipoint]*pz[ipoint];
408 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
411 x[1] = py[ipoint]*py[ipoint];
412 fitter.AddPoint(x,val,err);
416 fitter.GetParameters(param);
417 param0[0] = param[0];
418 param0[1] = param[1];
419 param0[2] = param[2];
420 Float_t chi2 = fitter.GetChisquare()/entries;
422 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
423 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
424 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
427 void AliTPCClusterParam::FitResolQ(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
429 // Fit z - angular dependence of resolution - Q scaling
431 // Int_t dim=0, type=0;
433 sprintf(varVal,"Resol:AngleM/sqrt(QMean):Zm/QMean");
435 sprintf(varVal0,"Resol:AngleM:Zm");
438 sprintf(varErr,"Sigma:AngleS:Zs");
440 sprintf(varCut,"Dim==%d&&Pad==%d&&QMean>0",dim,type);
442 Int_t entries = tree->Draw(varVal,varCut);
443 Float_t px[20000], py[20000], pz[20000], pu[20000], pt[20000];
444 Float_t ex[20000], ey[20000], ez[20000];
446 tree->Draw(varErr,varCut);
447 for (Int_t ipoint=0; ipoint<entries; ipoint++){
448 ex[ipoint]= tree->GetV3()[ipoint];
449 ey[ipoint]= tree->GetV2()[ipoint];
450 ez[ipoint]= tree->GetV1()[ipoint];
452 tree->Draw(varVal,varCut);
453 for (Int_t ipoint=0; ipoint<entries; ipoint++){
454 px[ipoint]= tree->GetV3()[ipoint];
455 py[ipoint]= tree->GetV2()[ipoint];
456 pz[ipoint]= tree->GetV1()[ipoint];
458 tree->Draw(varVal0,varCut);
459 for (Int_t ipoint=0; ipoint<entries; ipoint++){
460 pu[ipoint]= tree->GetV3()[ipoint];
461 pt[ipoint]= tree->GetV2()[ipoint];
465 TLinearFitter fitter(5,"hyp4");
466 for (Int_t ipoint=0; ipoint<entries; ipoint++){
467 Float_t val = pz[ipoint]*pz[ipoint];
468 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
471 x[1] = pt[ipoint]*pt[ipoint];
473 x[3] = py[ipoint]*py[ipoint];
474 fitter.AddPoint(x,val,err);
479 fitter.GetParameters(param);
480 param0[0] = param[0];
481 param0[1] = param[1];
482 param0[2] = param[2];
483 param0[3] = param[3];
484 param0[4] = param[4];
485 Float_t chi2 = fitter.GetChisquare()/entries;
487 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
488 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
489 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
490 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
491 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
494 void AliTPCClusterParam::FitResolQPar(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
496 // Fit z - angular dependence of resolution - Q scaling - parabolic correction
498 // Int_t dim=0, type=0;
500 sprintf(varVal,"Resol:AngleM/sqrt(QMean):Zm/QMean");
502 sprintf(varVal0,"Resol:AngleM:Zm");
505 sprintf(varErr,"Sigma:AngleS:Zs");
507 sprintf(varCut,"Dim==%d&&Pad==%d&&QMean>0",dim,type);
509 Int_t entries = tree->Draw(varVal,varCut);
510 Float_t px[20000], py[20000], pz[20000], pu[20000], pt[20000];
511 Float_t ex[20000], ey[20000], ez[20000];
513 tree->Draw(varErr,varCut);
514 for (Int_t ipoint=0; ipoint<entries; ipoint++){
515 ex[ipoint]= tree->GetV3()[ipoint];
516 ey[ipoint]= tree->GetV2()[ipoint];
517 ez[ipoint]= tree->GetV1()[ipoint];
519 tree->Draw(varVal,varCut);
520 for (Int_t ipoint=0; ipoint<entries; ipoint++){
521 px[ipoint]= tree->GetV3()[ipoint];
522 py[ipoint]= tree->GetV2()[ipoint];
523 pz[ipoint]= tree->GetV1()[ipoint];
525 tree->Draw(varVal0,varCut);
526 for (Int_t ipoint=0; ipoint<entries; ipoint++){
527 pu[ipoint]= tree->GetV3()[ipoint];
528 pt[ipoint]= tree->GetV2()[ipoint];
532 TLinearFitter fitter(8,"hyp7");
533 for (Int_t ipoint=0; ipoint<entries; ipoint++){
534 Float_t val = pz[ipoint]*pz[ipoint];
535 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
538 x[1] = pt[ipoint]*pt[ipoint];
543 x[6] = py[ipoint]*py[ipoint];
545 fitter.AddPoint(x,val,err);
550 fitter.GetParameters(param);
551 param0[0] = param[0];
552 param0[1] = param[1];
553 param0[2] = param[2];
554 param0[3] = param[3];
555 param0[4] = param[4];
556 param0[5] = param[5];
557 param0[6] = param[6];
558 param0[7] = param[7];
560 Float_t chi2 = fitter.GetChisquare()/entries;
562 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
563 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
564 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
565 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
566 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
567 error[5] = (fitter.GetParError(5)*TMath::Sqrt(chi2));
568 error[6] = (fitter.GetParError(6)*TMath::Sqrt(chi2));
569 error[7] = (fitter.GetParError(7)*TMath::Sqrt(chi2));
574 void AliTPCClusterParam::FitRMS0(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
576 // Fit z - angular dependence of resolution
578 // Int_t dim=0, type=0;
580 sprintf(varVal,"RMSm:AngleM:Zm");
582 sprintf(varErr,"sqrt((1./(100.*sqrt(12.))^2)+RMSe0^2):AngleS:Zs");
584 sprintf(varCut,"Dim==%d&&Pad==%d&&QMean<0",dim,type);
586 Int_t entries = tree->Draw(varVal,varCut);
587 Float_t px[10000], py[10000], pz[10000];
588 Float_t ex[10000], ey[10000], ez[10000];
590 tree->Draw(varErr,varCut);
591 for (Int_t ipoint=0; ipoint<entries; ipoint++){
592 ex[ipoint]= tree->GetV3()[ipoint];
593 ey[ipoint]= tree->GetV2()[ipoint];
594 ez[ipoint]= tree->GetV1()[ipoint];
596 tree->Draw(varVal,varCut);
597 for (Int_t ipoint=0; ipoint<entries; ipoint++){
598 px[ipoint]= tree->GetV3()[ipoint];
599 py[ipoint]= tree->GetV2()[ipoint];
600 pz[ipoint]= tree->GetV1()[ipoint];
604 TLinearFitter fitter(3,"hyp2");
605 for (Int_t ipoint=0; ipoint<entries; ipoint++){
606 Float_t val = pz[ipoint]*pz[ipoint];
607 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
610 x[1] = py[ipoint]*py[ipoint];
611 fitter.AddPoint(x,val,err);
615 fitter.GetParameters(param);
616 param0[0] = param[0];
617 param0[1] = param[1];
618 param0[2] = param[2];
619 Float_t chi2 = fitter.GetChisquare()/entries;
621 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
622 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
623 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
626 void AliTPCClusterParam::FitRMS1(TTree * tree, Int_t dim, Float_t *param0, Float_t *error){
628 // Fit z - angular dependence of resolution - pad length scaling
630 // Int_t dim=0, type=0;
632 sprintf(varVal,"RMSm:AngleM*Length:Zm");
634 sprintf(varErr,"sqrt((1./(100.*sqrt(12.))^2)+RMSe0^2):AngleS:Pad");
636 sprintf(varCut,"Dim==%d&&QMean<0",dim);
638 Int_t entries = tree->Draw(varVal,varCut);
639 Float_t px[10000], py[10000], pz[10000];
640 Float_t type[10000], ey[10000], ez[10000];
642 tree->Draw(varErr,varCut);
643 for (Int_t ipoint=0; ipoint<entries; ipoint++){
644 type[ipoint] = tree->GetV3()[ipoint];
645 ey[ipoint] = tree->GetV2()[ipoint];
646 ez[ipoint] = tree->GetV1()[ipoint];
648 tree->Draw(varVal,varCut);
649 for (Int_t ipoint=0; ipoint<entries; ipoint++){
650 px[ipoint]= tree->GetV3()[ipoint];
651 py[ipoint]= tree->GetV2()[ipoint];
652 pz[ipoint]= tree->GetV1()[ipoint];
656 TLinearFitter fitter(4,"hyp3");
657 for (Int_t ipoint=0; ipoint<entries; ipoint++){
658 Float_t val = pz[ipoint]*pz[ipoint];
659 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
661 x[0] = (type[ipoint]<0.5)? 0.:1.;
663 x[2] = py[ipoint]*py[ipoint];
664 fitter.AddPoint(x,val,err);
668 fitter.GetParameters(param);
669 param0[0] = param[0];
670 param0[1] = param[0]+param[1];
671 param0[2] = param[2];
672 param0[3] = param[3];
673 Float_t chi2 = fitter.GetChisquare()/entries;
675 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
676 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
677 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
678 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
681 void AliTPCClusterParam::FitRMSQ(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
683 // Fit z - angular dependence of resolution - Q scaling
685 // Int_t dim=0, type=0;
687 sprintf(varVal,"RMSm:AngleM/sqrt(QMean):Zm/QMean");
689 sprintf(varVal0,"RMSm:AngleM:Zm");
692 sprintf(varErr,"sqrt((1./(100.*sqrt(12.))^2)+RMSe0^2):AngleS:Zs");
694 sprintf(varCut,"Dim==%d&&Pad==%d&&QMean>0",dim,type);
696 Int_t entries = tree->Draw(varVal,varCut);
697 Float_t px[20000], py[20000], pz[20000], pu[20000], pt[20000];
698 Float_t ex[20000], ey[20000], ez[20000];
700 tree->Draw(varErr,varCut);
701 for (Int_t ipoint=0; ipoint<entries; ipoint++){
702 ex[ipoint]= tree->GetV3()[ipoint];
703 ey[ipoint]= tree->GetV2()[ipoint];
704 ez[ipoint]= tree->GetV1()[ipoint];
706 tree->Draw(varVal,varCut);
707 for (Int_t ipoint=0; ipoint<entries; ipoint++){
708 px[ipoint]= tree->GetV3()[ipoint];
709 py[ipoint]= tree->GetV2()[ipoint];
710 pz[ipoint]= tree->GetV1()[ipoint];
712 tree->Draw(varVal0,varCut);
713 for (Int_t ipoint=0; ipoint<entries; ipoint++){
714 pu[ipoint]= tree->GetV3()[ipoint];
715 pt[ipoint]= tree->GetV2()[ipoint];
719 TLinearFitter fitter(5,"hyp4");
720 for (Int_t ipoint=0; ipoint<entries; ipoint++){
721 Float_t val = pz[ipoint]*pz[ipoint];
722 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
725 x[1] = pt[ipoint]*pt[ipoint];
727 x[3] = py[ipoint]*py[ipoint];
728 fitter.AddPoint(x,val,err);
733 fitter.GetParameters(param);
734 param0[0] = param[0];
735 param0[1] = param[1];
736 param0[2] = param[2];
737 param0[3] = param[3];
738 param0[4] = param[4];
739 Float_t chi2 = fitter.GetChisquare()/entries;
741 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
742 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
743 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
744 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
745 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
749 void AliTPCClusterParam::FitRMSSigma(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t */*error*/){
751 // Fit z - angular dependence of resolution - Q scaling
753 // Int_t dim=0, type=0;
755 sprintf(varVal,"RMSs:RMSm");
758 sprintf(varCut,"Dim==%d&&Pad==%d&&QMean<0",dim,type);
760 Int_t entries = tree->Draw(varVal,varCut);
761 Float_t px[20000], py[20000];
763 tree->Draw(varVal,varCut);
764 for (Int_t ipoint=0; ipoint<entries; ipoint++){
765 px[ipoint]= tree->GetV2()[ipoint];
766 py[ipoint]= tree->GetV1()[ipoint];
768 TLinearFitter fitter(2,"pol1");
769 for (Int_t ipoint=0; ipoint<entries; ipoint++){
770 Float_t val = py[ipoint];
771 Float_t err = fRatio*px[ipoint];
774 if (err>0) fitter.AddPoint(x,val,err);
777 param0[0]= fitter.GetParameter(0);
778 param0[1]= fitter.GetParameter(1);
783 Float_t AliTPCClusterParam::GetError0(Int_t dim, Int_t type, Float_t z, Float_t angle){
788 value += fParamS0[dim][type][0];
789 value += fParamS0[dim][type][1]*z;
790 value += fParamS0[dim][type][2]*angle*angle;
791 value = TMath::Sqrt(TMath::Abs(value));
796 Float_t AliTPCClusterParam::GetError0Par(Int_t dim, Int_t type, Float_t z, Float_t angle){
801 value += fParamS0Par[dim][type][0];
802 value += fParamS0Par[dim][type][1]*z;
803 value += fParamS0Par[dim][type][2]*angle*angle;
804 value += fParamS0Par[dim][type][3]*z*z;
805 value += fParamS0Par[dim][type][4]*angle*angle*angle*angle;
806 value += fParamS0Par[dim][type][5]*z*angle*angle;
807 value = TMath::Sqrt(TMath::Abs(value));
813 Float_t AliTPCClusterParam::GetError1(Int_t dim, Int_t type, Float_t z, Float_t angle){
819 if (type==1) length=1;
820 if (type==2) length=1.5;
821 value += fParamS1[dim][0];
822 value += fParamS1[dim][1]*z/length;
823 value += fParamS1[dim][2]*angle*angle*length;
824 value = TMath::Sqrt(TMath::Abs(value));
828 Float_t AliTPCClusterParam::GetErrorQ(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean){
833 value += fParamSQ[dim][type][0];
834 value += fParamSQ[dim][type][1]*z;
835 value += fParamSQ[dim][type][2]*angle*angle;
836 value += fParamSQ[dim][type][3]*z/Qmean;
837 value += fParamSQ[dim][type][4]*angle*angle/Qmean;
838 value = TMath::Sqrt(TMath::Abs(value));
844 Float_t AliTPCClusterParam::GetErrorQPar(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean){
849 value += fParamSQPar[dim][type][0];
850 value += fParamSQPar[dim][type][1]*z;
851 value += fParamSQPar[dim][type][2]*angle*angle;
852 value += fParamSQPar[dim][type][3]*z*z;
853 value += fParamSQPar[dim][type][4]*angle*angle*angle*angle;
854 value += fParamSQPar[dim][type][5]*z*angle*angle;
855 value += fParamSQPar[dim][type][6]*z/Qmean;
856 value += fParamSQPar[dim][type][7]*angle*angle/Qmean;
857 value = TMath::Sqrt(TMath::Abs(value));
863 Float_t AliTPCClusterParam::GetErrorQParScaled(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean){
868 value += fParamSQPar[dim][type][0];
869 value += fParamSQPar[dim][type][1]*z;
870 value += fParamSQPar[dim][type][2]*angle*angle;
871 value += fParamSQPar[dim][type][3]*z*z;
872 value += fParamSQPar[dim][type][4]*angle*angle*angle*angle;
873 value += fParamSQPar[dim][type][5]*z*angle*angle;
874 value += fParamSQPar[dim][type][6]*z/Qmean;
875 value += fParamSQPar[dim][type][7]*angle*angle/Qmean;
876 Float_t valueMean = GetError0Par(dim,type,z,angle);
877 value -= 0.35*0.35*valueMean*valueMean;
878 value = TMath::Sqrt(TMath::Abs(value));
884 Float_t AliTPCClusterParam::GetRMS0(Int_t dim, Int_t type, Float_t z, Float_t angle){
886 // calculate mean RMS of cluster - z,angle - parameters for each pad and dimension separatelly
889 value += fParamRMS0[dim][type][0];
890 value += fParamRMS0[dim][type][1]*z;
891 value += fParamRMS0[dim][type][2]*angle*angle;
892 value = TMath::Sqrt(TMath::Abs(value));
896 Float_t AliTPCClusterParam::GetRMS1(Int_t dim, Int_t type, Float_t z, Float_t angle){
898 // calculate mean RMS of cluster - z,angle - pad length scalling
902 if (type==1) length=1;
903 if (type==2) length=1.5;
905 value += fParamRMS1[dim][0];
907 value += fParamRMS1[dim][1];
909 value += fParamRMS1[dim][2]*z;
910 value += fParamRMS1[dim][3]*angle*angle*length*length;
911 value = TMath::Sqrt(TMath::Abs(value));
915 Float_t AliTPCClusterParam::GetRMSQ(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean){
917 // calculate mean RMS of cluster - z,angle, Q dependence
920 value += fParamRMSQ[dim][type][0];
921 value += fParamRMSQ[dim][type][1]*z;
922 value += fParamRMSQ[dim][type][2]*angle*angle;
923 value += fParamRMSQ[dim][type][3]*z/Qmean;
924 value += fParamRMSQ[dim][type][4]*angle*angle/Qmean;
925 value = TMath::Sqrt(TMath::Abs(value));
929 Float_t AliTPCClusterParam::GetRMSSigma(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean){
931 // calculates RMS of signal shape fluctuation
933 Float_t mean = GetRMSQ(dim,type,z,angle,Qmean);
934 Float_t value = fRMSSigmaFit[dim][type][0];
935 value+= fRMSSigmaFit[dim][type][1]*mean;
939 Float_t AliTPCClusterParam::GetShapeFactor(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean, Float_t rmsL, Float_t rmsM){
941 // calculates vallue - sigma distortion contribution
945 Float_t rmsMeanQ = GetRMSQ(dim,type,z,angle,Qmean);
946 if (rmsL<rmsMeanQ) return value;
948 Float_t rmsSigma = GetRMSSigma(dim,type,z,angle,Qmean);
950 if ((rmsM-rmsMeanQ)>2.0*(rmsSigma+fErrorRMSSys[dim])){
951 //1.5 sigma cut on mean
952 value+= rmsL*rmsL+2*rmsM*rmsM-3*rmsMeanQ*rmsMeanQ;
954 if ((rmsL-rmsMeanQ)>3.*(rmsSigma+fErrorRMSSys[dim])){
955 //3 sigma cut on local
956 value+= rmsL*rmsL-rmsMeanQ*rmsMeanQ;
959 return TMath::Sqrt(TMath::Abs(value));
964 void AliTPCClusterParam::FitData(TTree * tree){
966 // make fits for error param and shape param
973 void AliTPCClusterParam::FitResol(TTree * tree){
976 for (Int_t idir=0;idir<2; idir++){
977 for (Int_t itype=0; itype<3; itype++){
981 FitResol0(tree, idir, itype,param0,error0);
982 printf("\nResol\t%d\t%d\tchi2=%f\n",idir,itype,param0[3]);
983 printf("%f\t%f\t%f\n", param0[0],param0[1],param0[2]);
984 printf("%f\t%f\t%f\n", error0[0],error0[1],error0[2]);
985 for (Int_t ipar=0;ipar<4; ipar++){
986 fParamS0[idir][itype][ipar] = param0[ipar];
987 fErrorS0[idir][itype][ipar] = param0[ipar];
989 // error param with parabolic correction
990 FitResol0Par(tree, idir, itype,param0,error0);
991 printf("\nResolPar\t%d\t%d\tchi2=%f\n",idir,itype,param0[6]);
992 printf("%f\t%f\t%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2],param0[3],param0[4],param0[5]);
993 printf("%f\t%f\t%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2],error0[3],error0[4],error0[5]);
994 for (Int_t ipar=0;ipar<7; ipar++){
995 fParamS0Par[idir][itype][ipar] = param0[ipar];
996 fErrorS0Par[idir][itype][ipar] = param0[ipar];
999 FitResolQ(tree, idir, itype,param0,error0);
1000 printf("\nResolQ\t%d\t%d\tchi2=%f\n",idir,itype,param0[5]);
1001 printf("%f\t%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2],param0[3],param0[4]);
1002 printf("%f\t%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2],error0[3],error0[4]);
1003 for (Int_t ipar=0;ipar<6; ipar++){
1004 fParamSQ[idir][itype][ipar] = param0[ipar];
1005 fErrorSQ[idir][itype][ipar] = param0[ipar];
1008 FitResolQPar(tree, idir, itype,param0,error0);
1009 printf("\nResolQ\t%d\t%d\tchi2=%f\n",idir,itype,param0[8]);
1010 printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2],param0[3],param0[4],param0[5],param0[6],param0[7]);
1011 printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2],error0[3],error0[4],error0[5],error0[6],error0[7]);
1012 for (Int_t ipar=0;ipar<9; ipar++){
1013 fParamSQPar[idir][itype][ipar] = param0[ipar];
1014 fErrorSQPar[idir][itype][ipar] = param0[ipar];
1019 printf("Resol z-scaled\n");
1020 for (Int_t idir=0;idir<2; idir++){
1023 FitResol1(tree, idir,param0,error0);
1024 printf("\nResol\t%d\tchi2=%f\n",idir,param0[3]);
1025 printf("%f\t%f\t%f\n", param0[0],param0[1],param0[2]);
1026 printf("%f\t%f\t%f\n", error0[0],error0[1],error0[2]);
1027 for (Int_t ipar=0;ipar<4; ipar++){
1028 fParamS1[idir][ipar] = param0[ipar];
1029 fErrorS1[idir][ipar] = param0[ipar];
1033 for (Int_t idir=0;idir<2; idir++){
1034 printf("\nDirection %d\n",idir);
1035 printf("%d\t%f\t%f\t%f\n", -1,fParamS1[idir][0],fParamS1[idir][1],fParamS1[idir][2]);
1036 for (Int_t itype=0; itype<3; itype++){
1037 Float_t length=0.75;
1038 if (itype==1) length=1;
1039 if (itype==2) length=1.5;
1040 printf("%d\t%f\t%f\t%f\n", itype,fParamS0[idir][itype][0],fParamS0[idir][itype][1]*TMath::Sqrt(length),fParamS0[idir][itype][2]/TMath::Sqrt(length));
1047 void AliTPCClusterParam::FitRMS(TTree * tree){
1050 for (Int_t idir=0;idir<2; idir++){
1051 for (Int_t itype=0; itype<3; itype++){
1054 FitRMS0(tree, idir, itype,param0,error0);
1055 printf("\nRMS\t%d\t%d\tchi2=%f\n",idir,itype,param0[3]);
1056 printf("%f\t%f\t%f\n", param0[0],param0[1],param0[2]);
1057 printf("%f\t%f\t%f\n", error0[0],error0[1],error0[2]);
1058 for (Int_t ipar=0;ipar<4; ipar++){
1059 fParamRMS0[idir][itype][ipar] = param0[ipar];
1060 fErrorRMS0[idir][itype][ipar] = param0[ipar];
1062 FitRMSQ(tree, idir, itype,param0,error0);
1063 printf("\nRMSQ\t%d\t%d\tchi2=%f\n",idir,itype,param0[5]);
1064 printf("%f\t%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2],param0[3],param0[4]);
1065 printf("%f\t%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2],error0[3],error0[4]);
1066 for (Int_t ipar=0;ipar<6; ipar++){
1067 fParamRMSQ[idir][itype][ipar] = param0[ipar];
1068 fErrorRMSQ[idir][itype][ipar] = param0[ipar];
1073 printf("RMS z-scaled\n");
1074 for (Int_t idir=0;idir<2; idir++){
1077 FitRMS1(tree, idir,param0,error0);
1078 printf("\nRMS\t%d\tchi2=%f\n",idir,param0[4]);
1079 printf("%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2], param0[3]);
1080 printf("%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2], error0[3]);
1081 for (Int_t ipar=0;ipar<5; ipar++){
1082 fParamRMS1[idir][ipar] = param0[ipar];
1083 fErrorRMS1[idir][ipar] = param0[ipar];
1087 for (Int_t idir=0;idir<2; idir++){
1088 printf("\nDirection %d\n",idir);
1089 printf("%d\t%f\t%f\t%f\t%f\n", -1,fParamRMS1[idir][0],fParamRMS1[idir][1],fParamRMS1[idir][2], fParamRMS1[idir][3]);
1090 for (Int_t itype=0; itype<3; itype++){
1091 Float_t length=0.75;
1092 if (itype==1) length=1;
1093 if (itype==2) length=1.5;
1094 if (itype==0) printf("%d\t%f\t\t\t%f\t%f\n", itype,fParamRMS0[idir][itype][0],fParamRMS0[idir][itype][1],fParamRMS0[idir][itype][2]/length);
1095 if (itype>0) printf("%d\t\t\t%f\t%f\t%f\n", itype,fParamRMS0[idir][itype][0],fParamRMS0[idir][itype][1],fParamRMS0[idir][itype][2]/length);
1101 printf("RMS fluctuation parameterization \n");
1102 for (Int_t idir=0;idir<2; idir++){
1103 for (Int_t itype=0; itype<3; itype++){
1106 FitRMSSigma(tree, idir,itype,param0,error0);
1107 printf("\t%d\t%d\t%f\t%f\n", idir, itype, param0[0],param0[1]);
1108 for (Int_t ipar=0;ipar<2; ipar++){
1109 fRMSSigmaFit[idir][itype][ipar] = param0[ipar];
1114 // store systematic error end RMS fluctuation parameterization
1116 TH1F hratio("hratio","hratio",100,-0.1,0.1);
1117 tree->Draw("(RMSm-AliTPCClusterParam::SGetRMSQ(Dim,Pad,Zm,AngleM,QMean))/RMSm>>hratio","Dim==0&&QMean>0");
1118 fErrorRMSSys[0] = hratio.GetRMS();
1119 tree->Draw("(RMSm-AliTPCClusterParam::SGetRMSQ(Dim,Pad,Zm,AngleM,QMean))/RMSm>>hratio","Dim==1&&QMean>0");
1120 fErrorRMSSys[1] = hratio.GetRMS();
1121 TH1F hratioR("hratioR","hratioR",100,0,0.2);
1122 tree->Draw("RMSs/RMSm>>hratioR","Dim==0&&QMean>0");
1123 fRMSSigmaRatio[0][0]=hratioR.GetMean();
1124 fRMSSigmaRatio[0][1]=hratioR.GetRMS();
1125 tree->Draw("RMSs/RMSm>>hratioR","Dim==1&&QMean>0");
1126 fRMSSigmaRatio[1][0]=hratioR.GetMean();
1127 fRMSSigmaRatio[1][1]=hratioR.GetRMS();
1130 void AliTPCClusterParam::Test(TTree * tree, const char *output){
1132 // Draw standard quality histograms to output file
1135 TFile f(output,"recreate");
1138 // 1D histograms - resolution
1140 for (Int_t idim=0; idim<2; idim++){
1141 for (Int_t ipad=0; ipad<3; ipad++){
1146 sprintf(hname1,"Delta0 Dir %d Pad %d",idim,ipad);
1147 sprintf(hcut1,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1148 sprintf(hexp1,"(Resol-AliTPCClusterParam::SGetError0(Dim,Pad,Zm,AngleM))/Resol>>%s",hname1);
1149 TH1F his1DRel0(hname1, hname1, 100,-0.2, 0.2);
1150 sprintf(hname1,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1151 tree->Draw(hexp1,hcut1,"");
1154 sprintf(hname1,"Delta0Par Dir %d Pad %d",idim,ipad);
1155 sprintf(hcut1,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1156 sprintf(hexp1,"(Resol-AliTPCClusterParam::SGetError0Par(Dim,Pad,Zm,AngleM))/Resol>>%s",hname1);
1157 TH1F his1DRel0Par(hname1, hname1, 100,-0.2, 0.2);
1158 sprintf(hname1,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1159 tree->Draw(hexp1,hcut1,"");
1160 his1DRel0Par.Write();
1165 // 2D histograms - resolution
1167 for (Int_t idim=0; idim<2; idim++){
1168 for (Int_t ipad=0; ipad<3; ipad++){
1173 sprintf(hname1,"2DDelta0 Dir %d Pad %d",idim,ipad);
1174 sprintf(hcut1,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1175 sprintf(hexp1,"(Resol-AliTPCClusterParam::SGetError0(Dim,Pad,Zm,AngleM))/Resol:AngleM:Zm>>%s",hname1);
1176 TProfile2D profDRel0(hname1, hname1, 6,0,250,6,0,1);
1177 sprintf(hname1,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1178 tree->Draw(hexp1,hcut1,"");
1181 sprintf(hname1,"2DDelta0Par Dir %d Pad %d",idim,ipad);
1182 sprintf(hcut1,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1183 sprintf(hexp1,"(Resol-AliTPCClusterParam::SGetError0Par(Dim,Pad,Zm,AngleM))/Resol:AngleM:Zm>>%s",hname1);
1184 TProfile2D profDRel0Par(hname1, hname1,6,0,250,6,0,1);
1185 sprintf(hname1,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1186 tree->Draw(hexp1,hcut1,"");
1187 profDRel0Par.Write();
1195 void AliTPCClusterParam::Print(Option_t* /*option*/) const{
1197 // Print param Information
1201 // Error parameterization
1203 printf("\nResolution Scaled factors\n");
1204 printf("Dir\tPad\tP0\t\tP1\t\tP2\t\tchi2\n");
1205 printf("Y\tall\t%f\t%f\t%f\t%f\n", TMath::Sqrt(TMath::Abs(fParamS1[0][0])),TMath::Sqrt(TMath::Abs(fParamS1[0][1])),
1206 TMath::Sqrt(TMath::Abs(fParamS1[0][2])),TMath::Sqrt(TMath::Abs(fParamS1[0][3])));
1207 for (Int_t ipad=0; ipad<3; ipad++){
1208 Float_t length=0.75;
1209 if (ipad==1) length=1;
1210 if (ipad==2) length=1.5;
1211 printf("\t%d\t%f\t%f\t%f\t%f\n", ipad,
1212 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][0])),
1213 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][1]*length)),
1214 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][2]/length)),
1215 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][3])));
1217 for (Int_t ipad=0; ipad<3; ipad++){
1218 Float_t length=0.75;
1219 if (ipad==1) length=1;
1220 if (ipad==2) length=1.5;
1221 printf("\t%dPar\t%f\t%f\t%f\t%f\n", ipad,
1222 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][0])),
1223 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][1]*length)),
1224 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][2]/length)),
1225 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][6])));
1227 printf("Z\tall\t%f\t%f\t%f\t%f\n", TMath::Sqrt(TMath::Abs(fParamS1[1][0])),TMath::Sqrt(fParamS1[1][1]),
1228 TMath::Sqrt(fParamS1[1][2]), TMath::Sqrt(fParamS1[1][3]));
1230 for (Int_t ipad=0; ipad<3; ipad++){
1231 Float_t length=0.75;
1232 if (ipad==1) length=1;
1233 if (ipad==2) length=1.5;
1234 printf("\t%d\t%f\t%f\t%f\t%f\n", ipad,
1235 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][0])),
1236 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][1]*length)),
1237 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][2]/length)),
1238 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][3])));
1240 for (Int_t ipad=0; ipad<3; ipad++){
1241 Float_t length=0.75;
1242 if (ipad==1) length=1;
1243 if (ipad==2) length=1.5;
1244 printf("\t%dPar\t%f\t%f\t%f\t%f\n", ipad,
1245 TMath::Sqrt(TMath::Abs(TMath::Abs(fParamS0Par[1][ipad][0]))),
1246 TMath::Sqrt(TMath::Abs(fParamS0Par[1][ipad][1]*length)),
1247 TMath::Sqrt(TMath::Abs(fParamS0Par[1][ipad][2]/length)),
1248 TMath::Sqrt(TMath::Abs(fParamS0Par[1][ipad][6])));
1255 printf("\nRMS Scaled factors\n");
1256 printf("Dir\tPad\tP00\t\tP01\t\tP1\t\tP2\t\tchi2\n");
1257 printf("Y\tall\t%f\t%f\t%f\t%f\t%f\n",
1258 TMath::Sqrt(TMath::Abs(fParamRMS1[0][0])),
1259 TMath::Sqrt(TMath::Abs(fParamRMS1[0][1])),
1260 TMath::Sqrt(TMath::Abs(fParamRMS1[0][2])),
1261 TMath::Sqrt(TMath::Abs(fParamRMS1[0][3])),
1262 TMath::Sqrt(TMath::Abs(fParamRMS1[0][4])));
1263 for (Int_t ipad=0; ipad<3; ipad++){
1264 Float_t length=0.75;
1265 if (ipad==1) length=1;
1266 if (ipad==2) length=1.5;
1268 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1269 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][0])),
1271 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][1])),
1272 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][2]/(length*length))),
1273 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][3])));
1275 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1277 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][0])),
1278 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][1])),
1279 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][2]/(length*length))),
1280 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][3])));
1284 printf("Z\tall\t%f\t%f\t%f\t%f\t%f\n",
1285 TMath::Sqrt(TMath::Abs(fParamRMS1[1][0])),
1286 TMath::Sqrt(TMath::Abs(fParamRMS1[1][1])),
1287 TMath::Sqrt(TMath::Abs(fParamRMS1[1][2])),
1288 TMath::Sqrt(TMath::Abs(fParamRMS1[1][3])),
1289 TMath::Sqrt(TMath::Abs(fParamRMS1[1][4])));
1290 for (Int_t ipad=0; ipad<3; ipad++){
1291 Float_t length=0.75;
1292 if (ipad==1) length=1;
1293 if (ipad==2) length=1.5;
1295 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1296 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][0])),
1298 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][1])),
1299 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][2]/(length*length))),
1300 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][3])));
1302 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1304 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][0])),
1305 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][1])),
1306 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][2]/(length*length))),
1307 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][3])));
1316 Float_t AliTPCClusterParam::Qnorm(Int_t ipad, Int_t itype, Float_t dr, Float_t ty, Float_t tz){
1317 // get Q normalization
1318 // type - 0 Qtot 1 Qmax
1319 // ipad - 0 (0.75 cm) ,1 (1 cm), 2 (1.5 cm)
1321 //expession formula - TString *strq0 = toolkit.FitPlane(chain,"dedxQ.fElements[2]","dr++ty++tz++dr*ty++dr*tz++ty*tz++ty^2++tz^2","IPad==0",chi2,npoints,param,covar,0,100000);
1323 if (fQNorm==0) return 0;
1324 TVectorD * norm = (TVectorD*)fQNorm->At(3*itype+ipad);
1325 if (!norm) return 0;
1326 TVectorD &no = *norm;
1344 void AliTPCClusterParam::SetQnorm(Int_t ipad, Int_t itype, TVectorD * norm){
1346 // set normalization
1348 // type - 0 Qtot 1 Qmax
1349 // ipad - 0 (0.75 cm) ,1 (1 cm), 2 (1.5 cm)
1352 if (fQNorm==0) fQNorm = new TObjArray(6);
1353 fQNorm->AddAt(new TVectorD(*norm), itype*3+ipad);
1356 Float_t AliTPCClusterParam::QnormPos(Int_t ipad,Bool_t isMax, Float_t pad, Float_t time, Float_t z, Float_t sy2, Float_t sz2, Float_t qm, Float_t qt){
1358 // Make Q normalization as function of following parameters
1359 // Fit parameters to be used in corresponding correction function extracted in the AliTPCclaibTracksGain - Taylor expansion
1360 // 1 - dp - relative pad position
1361 // 2 - dt - relative time position
1362 // 3 - di - drift length (norm to 1);
1363 // 4 - dq0 - Tot/Max charge
1364 // 5 - dq1 - Max/Tot charge
1365 // 6 - sy - sigma y - shape
1366 // 7 - sz - sigma z - shape
1369 //The results can be visualized using the debug streamer information of the AliTPCcalibTracksGain -
1370 // Following variable used - correspondance to the our variable conventions
1371 //chain0->SetAlias("dp","((Cl.fPad-int(Cl.fPad)-0.5)/0.5)");
1372 Double_t dp = ((pad-int(pad)-0.5)*2.);
1373 //chain0->SetAlias("dt","((Cl.fTimeBin-int(Cl.fTimeBin)-0.5)/0.5)");
1374 Double_t dt = ((time-int(time)-0.5)*2.);
1375 //chain0->SetAlias("di","(sqrt(1.-abs(Cl.fZ)/250.))");
1376 Double_t di = TMath::Sqrt(1-TMath::Abs(z)/250.);
1377 //chain0->SetAlias("dq0","(0.2*(Cl.fQ+2)/(Cl.fMax+2))");
1378 Double_t dq0 = 0.2*(qt+2.)/(qm+2.);
1379 //chain0->SetAlias("dq1","(5*(Cl.fMax+2)/(Cl.fQ+2))");
1380 Double_t dq1 = 5.*(qm+2.)/(qt+2.);
1381 //chain0->SetAlias("sy","(0.32/sqrt(0.01^2+Cl.fSigmaY2))");
1382 Double_t sy = 0.32/TMath::Sqrt(0.01*0.01+sy2);
1383 //chain0->SetAlias("sz","(0.32/sqrt(0.01^2+Cl.fSigmaZ2))");
1384 Double_t sz = 0.32/TMath::Sqrt(0.01*0.01+sz2);
1388 TVectorD * pvec = 0;
1390 pvec = fPosQMnorm[ipad];
1392 pvec = fPosQTnorm[ipad];
1394 TVectorD ¶m = *pvec;
1396 // Eval part - in correspondance with fit part from debug streamer
1398 Double_t result=param[0];
1401 result+=dp*param[index++]; //1
1402 result+=dt*param[index++]; //2
1403 result+=dp*dp*param[index++]; //3
1404 result+=dt*dt*param[index++]; //4
1405 result+=dt*dt*dt*param[index++]; //5
1406 result+=dp*dt*param[index++]; //6
1407 result+=dp*dt*dt*param[index++]; //7
1408 result+=(dq0)*param[index++]; //8
1409 result+=(dq1)*param[index++]; //9
1412 result+=dp*dp*(di)*param[index++]; //10
1413 result+=dt*dt*(di)*param[index++]; //11
1414 result+=dp*dp*sy*param[index++]; //12
1415 result+=dt*sz*param[index++]; //13
1416 result+=dt*dt*sz*param[index++]; //14
1417 result+=dt*dt*dt*sz*param[index++]; //15
1419 result+=dp*dp*1*sy*sz*param[index++]; //16
1420 result+=dt*sy*sz*param[index++]; //17
1421 result+=dt*dt*sy*sz*param[index++]; //18
1422 result+=dt*dt*dt*sy*sz*param[index++]; //19
1424 result+=dp*dp*(dq0)*param[index++]; //20
1425 result+=dt*1*(dq0)*param[index++]; //21
1426 result+=dt*dt*(dq0)*param[index++]; //22
1427 result+=dt*dt*dt*(dq0)*param[index++]; //23
1429 result+=dp*dp*(dq1)*param[index++]; //24
1430 result+=dt*(dq1)*param[index++]; //25
1431 result+=dt*dt*(dq1)*param[index++]; //26
1432 result+=dt*dt*dt*(dq1)*param[index++]; //27
1434 if (result<0.75) result=0.75;
1435 if (result>1.25) result=1.25;
1445 Float_t AliTPCClusterParam::PosCorrection(Int_t type, Int_t ipad, Float_t pad, Float_t time, Float_t z, Float_t /*sy2*/, Float_t /*sz2*/, Float_t /*qm*/){
1448 // Make postion correction
1449 // type - 0 - y correction
1451 // ipad - 0, 1, 2 - short, medium long pads
1452 // pad - float pad number
1453 // time - float time bin number
1454 // z - z of the cluster
1457 //chainres->SetAlias("dp","(-1+(Cl.fZ>0)*2)*((Cl.fPad-int(Cl.fPad))-0.5)");
1458 //chainres->SetAlias("dt","(-1+(Cl.fZ>0)*2)*((Cl.fTimeBin-0.66-int(Cl.fTimeBin-0.66))-0.5)");
1459 //chainres->SetAlias("sp","(sin(dp*pi)-dp*pi)");
1460 //chainres->SetAlias("st","(sin(dt)-dt)");
1462 //chainres->SetAlias("di","sqrt(1.-abs(Cl.fZ/250.))");
1465 // Derived variables
1467 Double_t dp = (-1+(z>0)*2)*((pad-int(pad))-0.5);
1468 Double_t dt = (-1+(z>0)*2)*((time-0.66-int(time-0.66))-0.5);
1469 Double_t sp = (TMath::Sin(dp*TMath::Pi())-dp*TMath::Pi());
1470 Double_t st = (TMath::Sin(dt)-dt);
1472 Double_t di = TMath::Sqrt(TMath::Abs(1.-TMath::Abs(z/250.)));
1476 TVectorD * pvec = 0;
1478 pvec = fPosYcor[ipad];
1480 pvec = fPosZcor[ipad];
1482 TVectorD ¶m = *pvec;
1489 result+=(dp)*param[index++]; //1
1490 result+=(dp)*di*param[index++]; //2
1492 result+=(sp)*param[index++]; //3
1493 result+=(sp)*di*param[index++]; //4
1496 result+=(dt)*param[index++]; //1
1497 result+=(dt)*di*param[index++]; //2
1499 result+=(st)*param[index++]; //3
1500 result+=(st)*di*param[index++]; //4
1502 if (TMath::Abs(result)>0.05) return 0;
1508 Double_t AliTPCClusterParam::GaussConvolution(Double_t x0, Double_t x1, Double_t k0, Double_t k1, Double_t s0, Double_t s1){
1510 // 2 D gaus convoluted with angular effect
1511 // See in mathematica:
1512 //Simplify[Integrate[Exp[-(x0-k0*xd)*(x0-k0*xd)/(2*s0*s0)-(x1-k1*xd)*(x1-k1*xd)/(2*s1*s1)]/(s0*s1),{xd,-1/2,1/2}]]
1514 //TF1 f1("f1","AliTPCClusterParam::GaussConvolution(x,0,1,0,0.1,0.1)",-2,2)
1515 //TF2 f2("f2","AliTPCClusterParam::GaussConvolution(x,y,1,1,0.1,0.1)",-2,2,-2,2)
1517 const Float_t kEpsilon = 0.0001;
1518 if ((TMath::Abs(k0)+TMath::Abs(k1))<kEpsilon*(s0+s1)){
1519 // small angular effect
1520 Double_t val = (TMath::Gaus(x0,0,s0)*TMath::Gaus(x1,0,s1))/(s0*s1*2.*TMath::Pi());
1523 Double_t sigma2 = k1*k1*s0*s0+k0*k0*s1*s1;
1524 Double_t exp0 = TMath::Exp(-(k1*x0-k0*x1)*(k1*x0-k0*x1)/(2*sigma2));
1526 Double_t sigmaErf = 2*s0*s1*TMath::Sqrt(2*sigma2);
1527 Double_t erf0 = TMath::Erf( (k0*s1*s1*(k0-2*x0)+k1*s0*s0*(k1-2*x1))/sigmaErf);
1528 Double_t erf1 = TMath::Erf( (k0*s1*s1*(k0+2*x0)+k1*s0*s0*(k1+2*x1))/sigmaErf);
1529 Double_t norm = 1./TMath::Sqrt(sigma2);
1530 norm/=2.*TMath::Sqrt(2.*TMath::Pi());
1531 Double_t val = norm*exp0*(erf0+erf1);
1536 Double_t AliTPCClusterParam::GaussConvolutionTail(Double_t x0, Double_t x1, Double_t k0, Double_t k1, Double_t s0, Double_t s1, Double_t tau){
1538 // 2 D gaus convoluted with angular effect and exponential tail in z-direction
1539 // tail integrated numerically
1540 // Integral normalized to one
1543 // TF1 f1t("f1t","AliTPCClusterParam::GaussConvolutionTail(0,x,0,0,0.5,0.5,0.9)",-5,5)
1544 Double_t sum =1, mean=0;
1545 // the COG of exponent
1546 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1547 mean+=iexp*TMath::Exp(-iexp/tau);
1548 sum +=TMath::Exp(-iexp/tau);
1553 Double_t val = GaussConvolution(x0,x1+mean, k0, k1 , s0,s1);
1554 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1555 val+=GaussConvolution(x0,x1+mean-iexp, k0, k1 , s0,s1)*TMath::Exp(-iexp/tau);
1556 sum+=TMath::Exp(-iexp/tau);
1561 Double_t AliTPCClusterParam::GaussConvolutionGamma4(Double_t x0, Double_t x1, Double_t k0, Double_t k1, Double_t s0, Double_t s1, Double_t tau){
1563 // 2 D gaus convoluted with angular effect and exponential tail in z-direction
1564 // tail integrated numerically
1565 // Integral normalized to one
1568 // TF1 f1g4("f1g4","AliTPCClusterParam::GaussConvolutionGamma4(0,x,0,0,0.5,0.2,1.6)",-5,5)
1569 // TF2 f2g4("f2g4","AliTPCClusterParam::GaussConvolutionGamma4(y,x,0,0,0.5,0.2,1.6)",-5,5,-5,5)
1570 Double_t sum =0, mean=0;
1572 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1573 Double_t g4 = TMath::Exp(-4.*iexp/tau)*TMath::Power(iexp/tau,4.);
1581 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1582 Double_t g4 = TMath::Exp(-4.*iexp/tau)*TMath::Power(iexp/tau,4.);
1583 val+=GaussConvolution(x0,x1+mean-iexp, k0, k1 , s0,s1)*g4;
1589 Double_t AliTPCClusterParam::QmaxCorrection(Int_t sector, Int_t row, Float_t cpad, Float_t ctime, Float_t ky, Float_t kz, Float_t rmsy0, Float_t rmsz0, Float_t tau){
1592 // cpad - pad (y) coordinate
1593 // ctime - time(z) coordinate
1596 // rmsy0 - RF width in pad units
1597 // rmsz0 - RF width in pad units
1598 // tau - correction for the assymetric TRF shape - decay length
1600 // Response function aproximated by convolution of gaussian with angular effect (integral=1)
1602 // Gaus width sy and sz is determined by RF width and diffusion
1603 // Integral of Q is equal 1
1604 // Q max is calculated at position cpad, ctime
1605 // Example function:
1606 // TF1 f1("f1", "AliTPCClusterParam::QmaxCorrection(0,0.5,x,0,0,0.5,0.6)",0,1000)
1608 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1609 Double_t padLength= param->GetPadPitchLength(sector,row);
1610 Double_t padWidth = param->GetPadPitchWidth(sector);
1611 // diffusion in pad units
1612 Double_t diffT=TMath::Sqrt(ctime*param->GetZWidth())*param->GetDiffT()/padWidth;
1613 Double_t diffL=TMath::Sqrt(ctime*param->GetZWidth())*param->GetDiffL()/padWidth;
1615 // transform angular effect to pad units
1616 Double_t pky = ky*padLength/padWidth;
1617 Double_t pkz = kz*padLength/padWidth;
1618 // position in pad unit
1619 Double_t py = (cpad+0.5)-TMath::Nint(cpad+0.5);
1620 Double_t pz = (ctime+0.5)-TMath::Nint(ctime+0.5);
1623 Double_t sy = TMath::Sqrt(rmsy0*rmsy0+diffT*diffT);
1624 Double_t sz = TMath::Sqrt(rmsz0*rmsz0+diffL*diffL);
1625 return GaussConvolutionGamma4(py,pz, pky,pkz,sy,sz,tau);
1628 Double_t AliTPCClusterParam::QtotCorrection(Int_t sector, Int_t row, Float_t cpad, Float_t ctime, Float_t ky, Float_t kz, Float_t rmsy0, Float_t rmsz0, Float_t qtot, Float_t thr, Float_t tau){
1631 // cpad - pad (y) coordinate
1632 // ctime - time(z) coordinate
1635 // rmsy0 - RF width in pad units
1636 // rmsz0 - RF width in pad units
1637 // qtot - the sum of signal in cluster - without thr correction
1639 // tau - correction for the assymetric TRF shape - decay length
1641 // Response function aproximated by convolution of gaussian with angular effect (integral=1)
1643 // Gaus width sy and sz is determined by RF width and diffusion
1644 // Integral of Q is equal 1
1645 // Q max is calculated at position cpad, ctime
1649 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1650 Double_t padLength= param->GetPadPitchLength(sector,row);
1651 Double_t padWidth = param->GetPadPitchWidth(sector);
1653 // diffusion in pad units
1654 Double_t diffT=TMath::Sqrt(ctime*param->GetZWidth())*param->GetDiffT()/padWidth;
1655 Double_t diffL=TMath::Sqrt(ctime*param->GetZWidth())*param->GetDiffL()/padWidth;
1657 // transform angular effect to pad units
1658 Double_t pky = ky*padLength/padWidth;
1659 Double_t pkz = kz*padLength/padWidth;
1660 // position in pad unit
1662 Double_t py = (cpad+0.5)-TMath::Nint(cpad+0.5);
1663 Double_t pz = (ctime+0.5)-TMath::Nint(ctime+0.5);
1665 Double_t sy = TMath::Sqrt(rmsy0*rmsy0+diffT*diffT);
1666 Double_t sz = TMath::Sqrt(rmsz0*rmsz0+diffL*diffL);
1670 Double_t sumAll=0,sumThr=0;
1673 Double_t qnorm=qtot;
1674 for (Float_t iy=-2;iy<=2;iy++)
1675 for (Float_t iz=-2;iz<=2;iz++){
1676 Double_t val = GaussConvolutionGamma4(py-iy,pz-iz, pky,pkz, sy,sz,tau);
1677 Double_t qlocal =qnorm*val;
1678 if (TMath::Abs(iy)<2&&TMath::Abs(iz)<2){
1679 sumThr+=qlocal; // using Virtual charge in cluster finder
1682 if (qlocal>thr) sumThr+=qlocal;
1686 if (sumAll>0&&sumThr>0) corr=(sumThr)/sumAll;