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>
95 #include <TProfile2D.h>
97 #include <TObjArray.h>
98 #include "AliTPCcalibDB.h"
99 #include "AliTPCParam.h"
102 #include "AliMathBase.h"
104 ClassImp(AliTPCClusterParam)
107 AliTPCClusterParam* AliTPCClusterParam::fgInstance = 0;
111 Example usage fitting parameterization:
112 TFile fres("resol.root"); //tree with resolution and shape
113 TTree * treeRes =(TTree*)fres.Get("Resol");
115 AliTPCClusterParam param;
116 param.SetInstance(¶m);
117 param.FitResol(treeRes);
118 param.FitRMS(treeRes);
119 TFile fparam("TPCClusterParam.root","recreate");
120 param.Write("Param");
123 TFile fparam("TPCClusterParam.root");
124 AliTPCClusterParam *param2 = (AliTPCClusterParam *) fparam.Get("Param");
125 param2->SetInstance(param2);
126 param2->Test(treeRes);
129 treeRes->Draw("(Resol-AliTPCClusterParam::SGetError0(Dim,Pad,Zm,AngleM))/Resol","Dim==0&&QMean<0")
136 //_ singleton implementation __________________________________________________
137 AliTPCClusterParam* AliTPCClusterParam::Instance()
140 // Singleton implementation
141 // Returns an instance of this class, it is created if neccessary
143 if (fgInstance == 0){
144 fgInstance = new AliTPCClusterParam();
150 AliTPCClusterParam::AliTPCClusterParam():
156 fQpadTnorm(0), // q pad normalization - Total charge
157 fQpadMnorm(0), // q pad normalization - Max charge
158 fWaveCorrectionMap(0),
159 fWaveCorrectionMirroredPad( kFALSE ),
160 fWaveCorrectionMirroredZ( kFALSE ),
161 fWaveCorrectionMirroredAngle( kFALSE ),
166 // Default constructor
168 fPosQTnorm[0] = 0; fPosQTnorm[1] = 0; fPosQTnorm[2] = 0;
169 fPosQMnorm[0] = 0; fPosQMnorm[1] = 0; fPosQMnorm[2] = 0;
171 fPosYcor[0] = 0; fPosYcor[1] = 0; fPosYcor[2] = 0;
172 fPosZcor[0] = 0; fPosZcor[1] = 0; fPosZcor[2] = 0;
173 fErrorRMSSys[0]=0; fErrorRMSSys[1]=0;
176 AliTPCClusterParam::AliTPCClusterParam(const AliTPCClusterParam& param):
182 fQpadTnorm(new TVectorD(*(param.fQpadTnorm))), // q pad normalization - Total charge
183 fQpadMnorm(new TVectorD(*(param.fQpadMnorm))), // q pad normalization - Max charge
184 fWaveCorrectionMap(0),
185 fWaveCorrectionMirroredPad( kFALSE ),
186 fWaveCorrectionMirroredZ( kFALSE ),
187 fWaveCorrectionMirroredAngle( kFALSE ),
193 if (param.fQNorm) fQNorm = (TObjArray*) param.fQNorm->Clone();
194 if (param.fQNormHis) fQNormHis = (TObjArray*) param.fQNormHis->Clone();
196 if (param.fPosQTnorm[0]){
197 fPosQTnorm[0] = new TVectorD(*(param.fPosQTnorm[0]));
198 fPosQTnorm[1] = new TVectorD(*(param.fPosQTnorm[1]));
199 fPosQTnorm[2] = new TVectorD(*(param.fPosQTnorm[2]));
201 fPosQMnorm[0] = new TVectorD(*(param.fPosQMnorm[0]));
202 fPosQMnorm[1] = new TVectorD(*(param.fPosQMnorm[1]));
203 fPosQMnorm[2] = new TVectorD(*(param.fPosQMnorm[2]));
205 if (param.fPosYcor[0]){
206 fPosYcor[0] = new TVectorD(*(param.fPosYcor[0]));
207 fPosYcor[1] = new TVectorD(*(param.fPosYcor[1]));
208 fPosYcor[2] = new TVectorD(*(param.fPosYcor[2]));
210 fPosZcor[0] = new TVectorD(*(param.fPosZcor[0]));
211 fPosZcor[1] = new TVectorD(*(param.fPosZcor[1]));
212 fPosZcor[2] = new TVectorD(*(param.fPosZcor[2]));
215 for (Int_t ii = 0; ii < 2; ++ii) {
216 for (Int_t jj = 0; jj < 3; ++jj) {
217 for (Int_t kk = 0; kk < 4; ++kk) {
218 fParamS0[ii][jj][kk] = param.fParamS0[ii][jj][kk];
219 fErrorS0[ii][jj][kk] = param.fErrorS0[ii][jj][kk];
220 fParamRMS0[ii][jj][kk] = param.fParamRMS0[ii][jj][kk];
221 fErrorRMS0[ii][jj][kk] = param.fErrorRMS0[ii][jj][kk];
223 for (Int_t kk = 0; kk < 7; ++kk) {
224 fParamS0Par[ii][jj][kk] = param.fParamS0Par[ii][jj][kk];
225 fErrorS0Par[ii][jj][kk] = param.fErrorS0Par[ii][jj][kk];
227 for (Int_t kk = 0; kk < 6; ++kk) {
228 fParamSQ[ii][jj][kk] = param.fParamSQ[ii][jj][kk];
229 fErrorSQ[ii][jj][kk] = param.fErrorSQ[ii][jj][kk];
230 fParamRMSQ[ii][jj][kk] = param.fParamRMSQ[ii][jj][kk];
231 fErrorRMSQ[ii][jj][kk] = param.fErrorRMSQ[ii][jj][kk];
233 for (Int_t kk = 0; kk < 9; ++kk) {
234 fParamSQPar[ii][jj][kk] = param.fParamSQPar[ii][jj][kk];
235 fErrorSQPar[ii][jj][kk] = param.fErrorSQPar[ii][jj][kk];
237 for (Int_t kk = 0; kk < 2; ++kk) {
238 fRMSSigmaFit[ii][jj][kk] = param.fRMSSigmaFit[ii][jj][kk];
241 for (Int_t jj = 0; jj < 4; ++jj) {
242 fParamS1[ii][jj] = param.fParamS1[ii][jj];
243 fErrorS1[ii][jj] = param.fErrorS1[ii][jj];
245 for (Int_t jj = 0; jj < 5; ++jj) {
246 fParamRMS1[ii][jj] = param.fParamRMS1[ii][jj];
247 fErrorRMS1[ii][jj] = param.fErrorRMS1[ii][jj];
249 fErrorRMSSys[ii] = param.fErrorRMSSys[ii];
250 for (Int_t jj = 0; jj < 2; ++jj){
251 fRMSSigmaRatio[ii][jj] = param.fRMSSigmaRatio[ii][jj];
255 SetWaveCorrectionMap( param.fWaveCorrectionMap );
256 SetResolutionYMap( param.fResolutionYMap );
260 AliTPCClusterParam & AliTPCClusterParam::operator=(const AliTPCClusterParam& param){
262 // Assignment operator
264 if (this != ¶m) {
265 if (param.fQNorm) fQNorm = (TObjArray*) param.fQNorm->Clone();
266 if (param.fQNormHis) fQNormHis = (TObjArray*) param.fQNormHis->Clone();
267 if (param.fPosQTnorm[0]){
268 fPosQTnorm[0] = new TVectorD(*(param.fPosQTnorm[0]));
269 fPosQTnorm[1] = new TVectorD(*(param.fPosQTnorm[1]));
270 fPosQTnorm[2] = new TVectorD(*(param.fPosQTnorm[2]));
272 fPosQMnorm[0] = new TVectorD(*(param.fPosQMnorm[0]));
273 fPosQMnorm[1] = new TVectorD(*(param.fPosQMnorm[1]));
274 fPosQMnorm[2] = new TVectorD(*(param.fPosQMnorm[2]));
276 if (param.fPosYcor[0]){
277 fPosYcor[0] = new TVectorD(*(param.fPosYcor[0]));
278 fPosYcor[1] = new TVectorD(*(param.fPosYcor[1]));
279 fPosYcor[2] = new TVectorD(*(param.fPosYcor[2]));
281 fPosZcor[0] = new TVectorD(*(param.fPosZcor[0]));
282 fPosZcor[1] = new TVectorD(*(param.fPosZcor[1]));
283 fPosZcor[2] = new TVectorD(*(param.fPosZcor[2]));
286 for (Int_t ii = 0; ii < 2; ++ii) {
287 for (Int_t jj = 0; jj < 3; ++jj) {
288 for (Int_t kk = 0; kk < 4; ++kk) {
289 fParamS0[ii][jj][kk] = param.fParamS0[ii][jj][kk];
290 fErrorS0[ii][jj][kk] = param.fErrorS0[ii][jj][kk];
291 fParamRMS0[ii][jj][kk] = param.fParamRMS0[ii][jj][kk];
292 fErrorRMS0[ii][jj][kk] = param.fErrorRMS0[ii][jj][kk];
294 for (Int_t kk = 0; kk < 7; ++kk) {
295 fParamS0Par[ii][jj][kk] = param.fParamS0Par[ii][jj][kk];
296 fErrorS0Par[ii][jj][kk] = param.fErrorS0Par[ii][jj][kk];
298 for (Int_t kk = 0; kk < 6; ++kk) {
299 fParamSQ[ii][jj][kk] = param.fParamSQ[ii][jj][kk];
300 fErrorSQ[ii][jj][kk] = param.fErrorSQ[ii][jj][kk];
301 fParamRMSQ[ii][jj][kk] = param.fParamRMSQ[ii][jj][kk];
302 fErrorRMSQ[ii][jj][kk] = param.fErrorRMSQ[ii][jj][kk];
304 for (Int_t kk = 0; kk < 9; ++kk) {
305 fParamSQPar[ii][jj][kk] = param.fParamSQPar[ii][jj][kk];
306 fErrorSQPar[ii][jj][kk] = param.fErrorSQPar[ii][jj][kk];
308 for (Int_t kk = 0; kk < 2; ++kk) {
309 fRMSSigmaFit[ii][jj][kk] = param.fRMSSigmaFit[ii][jj][kk];
312 for (Int_t jj = 0; jj < 4; ++jj) {
313 fParamS1[ii][jj] = param.fParamS1[ii][jj];
314 fErrorS1[ii][jj] = param.fErrorS1[ii][jj];
316 for (Int_t jj = 0; jj < 5; ++jj) {
317 fParamRMS1[ii][jj] = param.fParamRMS1[ii][jj];
318 fErrorRMS1[ii][jj] = param.fErrorRMS1[ii][jj];
320 fErrorRMSSys[ii] = param.fErrorRMSSys[ii];
321 for (Int_t jj = 0; jj < 2; ++jj){
322 fRMSSigmaRatio[ii][jj] = param.fRMSSigmaRatio[ii][jj];
326 SetWaveCorrectionMap( param.fWaveCorrectionMap );
327 SetResolutionYMap( param.fResolutionYMap );
333 AliTPCClusterParam::~AliTPCClusterParam(){
337 if (fQNorm) fQNorm->Delete();
338 if (fQNormCorr) delete fQNormCorr;
339 if (fQNormHis) fQNormHis->Delete();
343 delete fPosQTnorm[0];
344 delete fPosQTnorm[1];
345 delete fPosQTnorm[2];
347 delete fPosQMnorm[0];
348 delete fPosQMnorm[1];
349 delete fPosQMnorm[2];
360 delete fWaveCorrectionMap;
361 delete fResolutionYMap;
365 void AliTPCClusterParam::FitResol0(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
367 // Fit z - angular dependence of resolution
369 // Int_t dim=0, type=0;
371 varVal="Resol:AngleM:Zm";
373 varErr="Sigma:AngleS:Zs";
375 varCut=Form("Dim==%d&&Pad==%d&&QMean<0",dim,type);
377 Int_t entries = tree->Draw(varVal.Data(),varCut);
378 Float_t px[10000], py[10000], pz[10000];
379 Float_t ex[10000], ey[10000], ez[10000];
381 tree->Draw(varErr.Data(),varCut);
382 for (Int_t ipoint=0; ipoint<entries; ipoint++){
383 ex[ipoint]= tree->GetV3()[ipoint];
384 ey[ipoint]= tree->GetV2()[ipoint];
385 ez[ipoint]= tree->GetV1()[ipoint];
387 tree->Draw(varVal.Data(),varCut);
388 for (Int_t ipoint=0; ipoint<entries; ipoint++){
389 px[ipoint]= tree->GetV3()[ipoint];
390 py[ipoint]= tree->GetV2()[ipoint];
391 pz[ipoint]= tree->GetV1()[ipoint];
395 TLinearFitter fitter(3,"hyp2");
396 for (Int_t ipoint=0; ipoint<entries; ipoint++){
397 Float_t val = pz[ipoint]*pz[ipoint];
398 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
401 x[1] = py[ipoint]*py[ipoint];
402 fitter.AddPoint(x,val,err);
406 fitter.GetParameters(param);
407 param0[0] = param[0];
408 param0[1] = param[1];
409 param0[2] = param[2];
410 Float_t chi2 = fitter.GetChisquare()/entries;
412 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
413 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
414 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
418 void AliTPCClusterParam::FitResol0Par(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
420 // Fit z - angular dependence of resolution
422 // Int_t dim=0, type=0;
424 varVal="Resol:AngleM:Zm";
426 varErr="Sigma:AngleS:Zs";
428 varCut=Form("Dim==%d&&Pad==%d&&QMean<0",dim,type);
430 Int_t entries = tree->Draw(varVal.Data(),varCut);
431 Float_t px[10000], py[10000], pz[10000];
432 Float_t ex[10000], ey[10000], ez[10000];
434 tree->Draw(varErr.Data(),varCut);
435 for (Int_t ipoint=0; ipoint<entries; ipoint++){
436 ex[ipoint]= tree->GetV3()[ipoint];
437 ey[ipoint]= tree->GetV2()[ipoint];
438 ez[ipoint]= tree->GetV1()[ipoint];
440 tree->Draw(varVal.Data(),varCut);
441 for (Int_t ipoint=0; ipoint<entries; ipoint++){
442 px[ipoint]= tree->GetV3()[ipoint];
443 py[ipoint]= tree->GetV2()[ipoint];
444 pz[ipoint]= tree->GetV1()[ipoint];
448 TLinearFitter fitter(6,"hyp5");
449 for (Int_t ipoint=0; ipoint<entries; ipoint++){
450 Float_t val = pz[ipoint]*pz[ipoint];
451 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
454 x[1] = py[ipoint]*py[ipoint];
458 fitter.AddPoint(x,val,err);
462 fitter.GetParameters(param);
463 param0[0] = param[0];
464 param0[1] = param[1];
465 param0[2] = param[2];
466 param0[3] = param[3];
467 param0[4] = param[4];
468 param0[5] = param[5];
469 Float_t chi2 = fitter.GetChisquare()/entries;
471 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
472 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
473 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
474 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
475 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
476 error[5] = (fitter.GetParError(5)*TMath::Sqrt(chi2));
483 void AliTPCClusterParam::FitResol1(TTree * tree, Int_t dim, Float_t *param0, Float_t *error){
485 // Fit z - angular dependence of resolution - pad length scaling
487 // Int_t dim=0, type=0;
489 varVal="Resol:AngleM*sqrt(Length):Zm/Length";
491 varErr="Sigma:AngleS:Zs";
493 varCut=Form("Dim==%d&&QMean<0",dim);
495 Int_t entries = tree->Draw(varVal.Data(),varCut);
496 Float_t px[10000], py[10000], pz[10000];
497 Float_t ex[10000], ey[10000], ez[10000];
499 tree->Draw(varErr.Data(),varCut);
500 for (Int_t ipoint=0; ipoint<entries; ipoint++){
501 ex[ipoint]= tree->GetV3()[ipoint];
502 ey[ipoint]= tree->GetV2()[ipoint];
503 ez[ipoint]= tree->GetV1()[ipoint];
505 tree->Draw(varVal.Data(),varCut);
506 for (Int_t ipoint=0; ipoint<entries; ipoint++){
507 px[ipoint]= tree->GetV3()[ipoint];
508 py[ipoint]= tree->GetV2()[ipoint];
509 pz[ipoint]= tree->GetV1()[ipoint];
513 TLinearFitter fitter(3,"hyp2");
514 for (Int_t ipoint=0; ipoint<entries; ipoint++){
515 Float_t val = pz[ipoint]*pz[ipoint];
516 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
519 x[1] = py[ipoint]*py[ipoint];
520 fitter.AddPoint(x,val,err);
524 fitter.GetParameters(param);
525 param0[0] = param[0];
526 param0[1] = param[1];
527 param0[2] = param[2];
528 Float_t chi2 = fitter.GetChisquare()/entries;
530 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
531 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
532 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
535 void AliTPCClusterParam::FitResolQ(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
537 // Fit z - angular dependence of resolution - Q scaling
539 // Int_t dim=0, type=0;
541 varVal="Resol:AngleM/sqrt(QMean):Zm/QMean";
543 snprintf(varVal0,100,"Resol:AngleM:Zm");
546 varErr="Sigma:AngleS:Zs";
548 varCut=Form("Dim==%d&&Pad==%d&&QMean>0",dim,type);
550 Int_t entries = tree->Draw(varVal.Data(),varCut);
551 Float_t px[20000], py[20000], pz[20000], pu[20000], pt[20000];
552 Float_t ex[20000], ey[20000], ez[20000];
554 tree->Draw(varErr.Data(),varCut);
555 for (Int_t ipoint=0; ipoint<entries; ipoint++){
556 ex[ipoint]= tree->GetV3()[ipoint];
557 ey[ipoint]= tree->GetV2()[ipoint];
558 ez[ipoint]= tree->GetV1()[ipoint];
560 tree->Draw(varVal.Data(),varCut);
561 for (Int_t ipoint=0; ipoint<entries; ipoint++){
562 px[ipoint]= tree->GetV3()[ipoint];
563 py[ipoint]= tree->GetV2()[ipoint];
564 pz[ipoint]= tree->GetV1()[ipoint];
566 tree->Draw(varVal0,varCut);
567 for (Int_t ipoint=0; ipoint<entries; ipoint++){
568 pu[ipoint]= tree->GetV3()[ipoint];
569 pt[ipoint]= tree->GetV2()[ipoint];
573 TLinearFitter fitter(5,"hyp4");
574 for (Int_t ipoint=0; ipoint<entries; ipoint++){
575 Float_t val = pz[ipoint]*pz[ipoint];
576 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
579 x[1] = pt[ipoint]*pt[ipoint];
581 x[3] = py[ipoint]*py[ipoint];
582 fitter.AddPoint(x,val,err);
587 fitter.GetParameters(param);
588 param0[0] = param[0];
589 param0[1] = param[1];
590 param0[2] = param[2];
591 param0[3] = param[3];
592 param0[4] = param[4];
593 Float_t chi2 = fitter.GetChisquare()/entries;
595 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
596 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
597 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
598 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
599 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
602 void AliTPCClusterParam::FitResolQPar(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
604 // Fit z - angular dependence of resolution - Q scaling - parabolic correction
606 // Int_t dim=0, type=0;
608 varVal="Resol:AngleM/sqrt(QMean):Zm/QMean";
610 snprintf(varVal0,100,"Resol:AngleM:Zm");
613 varErr="Sigma:AngleS:Zs";
615 varCut=Form("Dim==%d&&Pad==%d&&QMean>0",dim,type);
617 Int_t entries = tree->Draw(varVal.Data(),varCut);
618 Float_t px[20000], py[20000], pz[20000], pu[20000], pt[20000];
619 Float_t ex[20000], ey[20000], ez[20000];
621 tree->Draw(varErr.Data(),varCut);
622 for (Int_t ipoint=0; ipoint<entries; ipoint++){
623 ex[ipoint]= tree->GetV3()[ipoint];
624 ey[ipoint]= tree->GetV2()[ipoint];
625 ez[ipoint]= tree->GetV1()[ipoint];
627 tree->Draw(varVal.Data(),varCut);
628 for (Int_t ipoint=0; ipoint<entries; ipoint++){
629 px[ipoint]= tree->GetV3()[ipoint];
630 py[ipoint]= tree->GetV2()[ipoint];
631 pz[ipoint]= tree->GetV1()[ipoint];
633 tree->Draw(varVal0,varCut);
634 for (Int_t ipoint=0; ipoint<entries; ipoint++){
635 pu[ipoint]= tree->GetV3()[ipoint];
636 pt[ipoint]= tree->GetV2()[ipoint];
640 TLinearFitter fitter(8,"hyp7");
641 for (Int_t ipoint=0; ipoint<entries; ipoint++){
642 Float_t val = pz[ipoint]*pz[ipoint];
643 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
646 x[1] = pt[ipoint]*pt[ipoint];
651 x[6] = py[ipoint]*py[ipoint];
653 fitter.AddPoint(x,val,err);
658 fitter.GetParameters(param);
659 param0[0] = param[0];
660 param0[1] = param[1];
661 param0[2] = param[2];
662 param0[3] = param[3];
663 param0[4] = param[4];
664 param0[5] = param[5];
665 param0[6] = param[6];
666 param0[7] = param[7];
668 Float_t chi2 = fitter.GetChisquare()/entries;
670 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
671 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
672 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
673 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
674 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
675 error[5] = (fitter.GetParError(5)*TMath::Sqrt(chi2));
676 error[6] = (fitter.GetParError(6)*TMath::Sqrt(chi2));
677 error[7] = (fitter.GetParError(7)*TMath::Sqrt(chi2));
682 void AliTPCClusterParam::FitRMS0(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
684 // Fit z - angular dependence of resolution
686 // Int_t dim=0, type=0;
688 varVal="RMSm:AngleM:Zm";
690 varErr="sqrt((1./(100.*sqrt(12.))^2)+RMSe0^2):AngleS:Zs";
692 varCut=Form("Dim==%d&&Pad==%d&&QMean<0",dim,type);
694 Int_t entries = tree->Draw(varVal.Data(),varCut);
695 Float_t px[10000], py[10000], pz[10000];
696 Float_t ex[10000], ey[10000], ez[10000];
698 tree->Draw(varErr.Data(),varCut);
699 for (Int_t ipoint=0; ipoint<entries; ipoint++){
700 ex[ipoint]= tree->GetV3()[ipoint];
701 ey[ipoint]= tree->GetV2()[ipoint];
702 ez[ipoint]= tree->GetV1()[ipoint];
704 tree->Draw(varVal.Data(),varCut);
705 for (Int_t ipoint=0; ipoint<entries; ipoint++){
706 px[ipoint]= tree->GetV3()[ipoint];
707 py[ipoint]= tree->GetV2()[ipoint];
708 pz[ipoint]= tree->GetV1()[ipoint];
712 TLinearFitter fitter(3,"hyp2");
713 for (Int_t ipoint=0; ipoint<entries; ipoint++){
714 Float_t val = pz[ipoint]*pz[ipoint];
715 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
718 x[1] = py[ipoint]*py[ipoint];
719 fitter.AddPoint(x,val,err);
723 fitter.GetParameters(param);
724 param0[0] = param[0];
725 param0[1] = param[1];
726 param0[2] = param[2];
727 Float_t chi2 = fitter.GetChisquare()/entries;
729 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
730 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
731 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
734 void AliTPCClusterParam::FitRMS1(TTree * tree, Int_t dim, Float_t *param0, Float_t *error){
736 // Fit z - angular dependence of resolution - pad length scaling
738 // Int_t dim=0, type=0;
740 varVal="RMSm:AngleM*Length:Zm";
742 varErr="sqrt((1./(100.*sqrt(12.))^2)+RMSe0^2):AngleS:Pad";
744 varCut=Form("Dim==%d&&QMean<0",dim);
746 Int_t entries = tree->Draw(varVal.Data(),varCut);
747 Float_t px[10000], py[10000], pz[10000];
748 Float_t type[10000], ey[10000], ez[10000];
750 tree->Draw(varErr.Data(),varCut);
751 for (Int_t ipoint=0; ipoint<entries; ipoint++){
752 type[ipoint] = tree->GetV3()[ipoint];
753 ey[ipoint] = tree->GetV2()[ipoint];
754 ez[ipoint] = tree->GetV1()[ipoint];
756 tree->Draw(varVal.Data(),varCut);
757 for (Int_t ipoint=0; ipoint<entries; ipoint++){
758 px[ipoint]= tree->GetV3()[ipoint];
759 py[ipoint]= tree->GetV2()[ipoint];
760 pz[ipoint]= tree->GetV1()[ipoint];
764 TLinearFitter fitter(4,"hyp3");
765 for (Int_t ipoint=0; ipoint<entries; ipoint++){
766 Float_t val = pz[ipoint]*pz[ipoint];
767 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
769 x[0] = (type[ipoint]<0.5)? 0.:1.;
771 x[2] = py[ipoint]*py[ipoint];
772 fitter.AddPoint(x,val,err);
776 fitter.GetParameters(param);
777 param0[0] = param[0];
778 param0[1] = param[0]+param[1];
779 param0[2] = param[2];
780 param0[3] = param[3];
781 Float_t chi2 = fitter.GetChisquare()/entries;
783 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
784 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
785 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
786 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
789 void AliTPCClusterParam::FitRMSQ(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t *error){
791 // Fit z - angular dependence of resolution - Q scaling
793 // Int_t dim=0, type=0;
795 varVal="RMSm:AngleM/sqrt(QMean):Zm/QMean";
797 snprintf(varVal0,100,"RMSm:AngleM:Zm");
800 varErr="sqrt((1./(100.*sqrt(12.))^2)+RMSe0^2):AngleS:Zs";
802 varCut=Form("Dim==%d&&Pad==%d&&QMean>0",dim,type);
804 Int_t entries = tree->Draw(varVal.Data(),varCut);
805 Float_t px[20000], py[20000], pz[20000], pu[20000], pt[20000];
806 Float_t ex[20000], ey[20000], ez[20000];
808 tree->Draw(varErr.Data(),varCut);
809 for (Int_t ipoint=0; ipoint<entries; ipoint++){
810 ex[ipoint]= tree->GetV3()[ipoint];
811 ey[ipoint]= tree->GetV2()[ipoint];
812 ez[ipoint]= tree->GetV1()[ipoint];
814 tree->Draw(varVal.Data(),varCut);
815 for (Int_t ipoint=0; ipoint<entries; ipoint++){
816 px[ipoint]= tree->GetV3()[ipoint];
817 py[ipoint]= tree->GetV2()[ipoint];
818 pz[ipoint]= tree->GetV1()[ipoint];
820 tree->Draw(varVal0,varCut);
821 for (Int_t ipoint=0; ipoint<entries; ipoint++){
822 pu[ipoint]= tree->GetV3()[ipoint];
823 pt[ipoint]= tree->GetV2()[ipoint];
827 TLinearFitter fitter(5,"hyp4");
828 for (Int_t ipoint=0; ipoint<entries; ipoint++){
829 Float_t val = pz[ipoint]*pz[ipoint];
830 Float_t err = 2*pz[ipoint]*TMath::Sqrt(ez[ipoint]*ez[ipoint]+fRatio*fRatio*pz[ipoint]*pz[ipoint]);
833 x[1] = pt[ipoint]*pt[ipoint];
835 x[3] = py[ipoint]*py[ipoint];
836 fitter.AddPoint(x,val,err);
841 fitter.GetParameters(param);
842 param0[0] = param[0];
843 param0[1] = param[1];
844 param0[2] = param[2];
845 param0[3] = param[3];
846 param0[4] = param[4];
847 Float_t chi2 = fitter.GetChisquare()/entries;
849 error[0] = (fitter.GetParError(0)*TMath::Sqrt(chi2));
850 error[1] = (fitter.GetParError(1)*TMath::Sqrt(chi2));
851 error[2] = (fitter.GetParError(2)*TMath::Sqrt(chi2));
852 error[3] = (fitter.GetParError(3)*TMath::Sqrt(chi2));
853 error[4] = (fitter.GetParError(4)*TMath::Sqrt(chi2));
857 void AliTPCClusterParam::FitRMSSigma(TTree * tree, Int_t dim, Int_t type, Float_t *param0, Float_t */*error*/){
859 // Fit z - angular dependence of resolution - Q scaling
861 // Int_t dim=0, type=0;
866 varCut=Form("Dim==%d&&Pad==%d&&QMean<0",dim,type);
868 Int_t entries = tree->Draw(varVal.Data(),varCut);
869 Float_t px[20000], py[20000];
871 tree->Draw(varVal.Data(),varCut);
872 for (Int_t ipoint=0; ipoint<entries; ipoint++){
873 px[ipoint]= tree->GetV2()[ipoint];
874 py[ipoint]= tree->GetV1()[ipoint];
876 TLinearFitter fitter(2,"pol1");
877 for (Int_t ipoint=0; ipoint<entries; ipoint++){
878 Float_t val = py[ipoint];
879 Float_t err = fRatio*px[ipoint];
882 if (err>0) fitter.AddPoint(x,val,err);
885 param0[0]= fitter.GetParameter(0);
886 param0[1]= fitter.GetParameter(1);
891 Float_t AliTPCClusterParam::GetError0(Int_t dim, Int_t type, Float_t z, Float_t angle) const {
896 value += fParamS0[dim][type][0];
897 value += fParamS0[dim][type][1]*z;
898 value += fParamS0[dim][type][2]*angle*angle;
899 value = TMath::Sqrt(TMath::Abs(value));
904 Float_t AliTPCClusterParam::GetError0Par(Int_t dim, Int_t type, Float_t z, Float_t angle) const {
909 value += fParamS0Par[dim][type][0];
910 value += fParamS0Par[dim][type][1]*z;
911 value += fParamS0Par[dim][type][2]*angle*angle;
912 value += fParamS0Par[dim][type][3]*z*z;
913 value += fParamS0Par[dim][type][4]*angle*angle*angle*angle;
914 value += fParamS0Par[dim][type][5]*z*angle*angle;
915 value = TMath::Sqrt(TMath::Abs(value));
921 Float_t AliTPCClusterParam::GetError1(Int_t dim, Int_t type, Float_t z, Float_t angle) const {
927 if (type==1) length=1;
928 if (type==2) length=1.5;
929 value += fParamS1[dim][0];
930 value += fParamS1[dim][1]*z/length;
931 value += fParamS1[dim][2]*angle*angle*length;
932 value = TMath::Sqrt(TMath::Abs(value));
936 Float_t AliTPCClusterParam::GetErrorQ(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean) const {
941 value += fParamSQ[dim][type][0];
942 value += fParamSQ[dim][type][1]*z;
943 value += fParamSQ[dim][type][2]*angle*angle;
944 value += fParamSQ[dim][type][3]*z/Qmean;
945 value += fParamSQ[dim][type][4]*angle*angle/Qmean;
946 value = TMath::Sqrt(TMath::Abs(value));
952 Float_t AliTPCClusterParam::GetErrorQPar(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean) const {
957 value += fParamSQPar[dim][type][0];
958 value += fParamSQPar[dim][type][1]*z;
959 value += fParamSQPar[dim][type][2]*angle*angle;
960 value += fParamSQPar[dim][type][3]*z*z;
961 value += fParamSQPar[dim][type][4]*angle*angle*angle*angle;
962 value += fParamSQPar[dim][type][5]*z*angle*angle;
963 value += fParamSQPar[dim][type][6]*z/Qmean;
964 value += fParamSQPar[dim][type][7]*angle*angle/Qmean;
965 value = TMath::Sqrt(TMath::Abs(value));
971 Float_t AliTPCClusterParam::GetErrorQParScaled(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean) const {
976 value += fParamSQPar[dim][type][0];
977 value += fParamSQPar[dim][type][1]*z;
978 value += fParamSQPar[dim][type][2]*angle*angle;
979 value += fParamSQPar[dim][type][3]*z*z;
980 value += fParamSQPar[dim][type][4]*angle*angle*angle*angle;
981 value += fParamSQPar[dim][type][5]*z*angle*angle;
982 value += fParamSQPar[dim][type][6]*z/Qmean;
983 value += fParamSQPar[dim][type][7]*angle*angle/Qmean;
984 Float_t valueMean = GetError0Par(dim,type,z,angle);
985 value -= 0.35*0.35*valueMean*valueMean;
986 value = TMath::Sqrt(TMath::Abs(value));
992 Float_t AliTPCClusterParam::GetRMS0(Int_t dim, Int_t type, Float_t z, Float_t angle) const {
994 // calculate mean RMS of cluster - z,angle - parameters for each pad and dimension separatelly
997 value += fParamRMS0[dim][type][0];
998 value += fParamRMS0[dim][type][1]*z;
999 value += fParamRMS0[dim][type][2]*angle*angle;
1000 value = TMath::Sqrt(TMath::Abs(value));
1004 Float_t AliTPCClusterParam::GetRMS1(Int_t dim, Int_t type, Float_t z, Float_t angle) const {
1006 // calculate mean RMS of cluster - z,angle - pad length scalling
1009 Float_t length=0.75;
1010 if (type==1) length=1;
1011 if (type==2) length=1.5;
1013 value += fParamRMS1[dim][0];
1015 value += fParamRMS1[dim][1];
1017 value += fParamRMS1[dim][2]*z;
1018 value += fParamRMS1[dim][3]*angle*angle*length*length;
1019 value = TMath::Sqrt(TMath::Abs(value));
1023 Float_t AliTPCClusterParam::GetRMSQ(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean) const {
1025 // calculate mean RMS of cluster - z,angle, Q dependence
1028 value += fParamRMSQ[dim][type][0];
1029 value += fParamRMSQ[dim][type][1]*z;
1030 value += fParamRMSQ[dim][type][2]*angle*angle;
1031 value += fParamRMSQ[dim][type][3]*z/Qmean;
1032 value += fParamRMSQ[dim][type][4]*angle*angle/Qmean;
1033 value = TMath::Sqrt(TMath::Abs(value));
1037 Float_t AliTPCClusterParam::GetRMSSigma(Int_t dim, Int_t type, Float_t z, Float_t angle, Float_t Qmean) const {
1039 // calculates RMS of signal shape fluctuation
1041 Float_t mean = GetRMSQ(dim,type,z,angle,Qmean);
1042 Float_t value = fRMSSigmaFit[dim][type][0];
1043 value+= fRMSSigmaFit[dim][type][1]*mean;
1047 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) const {
1049 // calculates vallue - sigma distortion contribution
1053 Float_t rmsMeanQ = GetRMSQ(dim,type,z,angle,Qmean);
1054 if (rmsL<rmsMeanQ) return value;
1056 Float_t rmsSigma = GetRMSSigma(dim,type,z,angle,Qmean);
1058 if ((rmsM-rmsMeanQ)>2.0*(rmsSigma+fErrorRMSSys[dim])){
1059 //1.5 sigma cut on mean
1060 value+= rmsL*rmsL+2*rmsM*rmsM-3*rmsMeanQ*rmsMeanQ;
1062 if ((rmsL-rmsMeanQ)>3.*(rmsSigma+fErrorRMSSys[dim])){
1063 //3 sigma cut on local
1064 value+= rmsL*rmsL-rmsMeanQ*rmsMeanQ;
1067 return TMath::Sqrt(TMath::Abs(value));
1072 void AliTPCClusterParam::FitData(TTree * tree){
1074 // make fits for error param and shape param
1081 void AliTPCClusterParam::FitResol(TTree * tree){
1084 for (Int_t idir=0;idir<2; idir++){
1085 for (Int_t itype=0; itype<3; itype++){
1088 // model error param
1089 FitResol0(tree, idir, itype,param0,error0);
1090 printf("\nResol\t%d\t%d\tchi2=%f\n",idir,itype,param0[3]);
1091 printf("%f\t%f\t%f\n", param0[0],param0[1],param0[2]);
1092 printf("%f\t%f\t%f\n", error0[0],error0[1],error0[2]);
1093 for (Int_t ipar=0;ipar<4; ipar++){
1094 fParamS0[idir][itype][ipar] = param0[ipar];
1095 fErrorS0[idir][itype][ipar] = param0[ipar];
1097 // error param with parabolic correction
1098 FitResol0Par(tree, idir, itype,param0,error0);
1099 printf("\nResolPar\t%d\t%d\tchi2=%f\n",idir,itype,param0[6]);
1100 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]);
1101 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]);
1102 for (Int_t ipar=0;ipar<7; ipar++){
1103 fParamS0Par[idir][itype][ipar] = param0[ipar];
1104 fErrorS0Par[idir][itype][ipar] = param0[ipar];
1107 FitResolQ(tree, idir, itype,param0,error0);
1108 printf("\nResolQ\t%d\t%d\tchi2=%f\n",idir,itype,param0[5]);
1109 printf("%f\t%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2],param0[3],param0[4]);
1110 printf("%f\t%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2],error0[3],error0[4]);
1111 for (Int_t ipar=0;ipar<6; ipar++){
1112 fParamSQ[idir][itype][ipar] = param0[ipar];
1113 fErrorSQ[idir][itype][ipar] = param0[ipar];
1116 FitResolQPar(tree, idir, itype,param0,error0);
1117 printf("\nResolQ\t%d\t%d\tchi2=%f\n",idir,itype,param0[8]);
1118 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]);
1119 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]);
1120 for (Int_t ipar=0;ipar<9; ipar++){
1121 fParamSQPar[idir][itype][ipar] = param0[ipar];
1122 fErrorSQPar[idir][itype][ipar] = param0[ipar];
1127 printf("Resol z-scaled\n");
1128 for (Int_t idir=0;idir<2; idir++){
1131 FitResol1(tree, idir,param0,error0);
1132 printf("\nResol\t%d\tchi2=%f\n",idir,param0[3]);
1133 printf("%f\t%f\t%f\n", param0[0],param0[1],param0[2]);
1134 printf("%f\t%f\t%f\n", error0[0],error0[1],error0[2]);
1135 for (Int_t ipar=0;ipar<4; ipar++){
1136 fParamS1[idir][ipar] = param0[ipar];
1137 fErrorS1[idir][ipar] = param0[ipar];
1141 for (Int_t idir=0;idir<2; idir++){
1142 printf("\nDirection %d\n",idir);
1143 printf("%d\t%f\t%f\t%f\n", -1,fParamS1[idir][0],fParamS1[idir][1],fParamS1[idir][2]);
1144 for (Int_t itype=0; itype<3; itype++){
1145 Float_t length=0.75;
1146 if (itype==1) length=1;
1147 if (itype==2) length=1.5;
1148 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));
1155 void AliTPCClusterParam::FitRMS(TTree * tree){
1158 for (Int_t idir=0;idir<2; idir++){
1159 for (Int_t itype=0; itype<3; itype++){
1162 FitRMS0(tree, idir, itype,param0,error0);
1163 printf("\nRMS\t%d\t%d\tchi2=%f\n",idir,itype,param0[3]);
1164 printf("%f\t%f\t%f\n", param0[0],param0[1],param0[2]);
1165 printf("%f\t%f\t%f\n", error0[0],error0[1],error0[2]);
1166 for (Int_t ipar=0;ipar<4; ipar++){
1167 fParamRMS0[idir][itype][ipar] = param0[ipar];
1168 fErrorRMS0[idir][itype][ipar] = param0[ipar];
1170 FitRMSQ(tree, idir, itype,param0,error0);
1171 printf("\nRMSQ\t%d\t%d\tchi2=%f\n",idir,itype,param0[5]);
1172 printf("%f\t%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2],param0[3],param0[4]);
1173 printf("%f\t%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2],error0[3],error0[4]);
1174 for (Int_t ipar=0;ipar<6; ipar++){
1175 fParamRMSQ[idir][itype][ipar] = param0[ipar];
1176 fErrorRMSQ[idir][itype][ipar] = param0[ipar];
1181 printf("RMS z-scaled\n");
1182 for (Int_t idir=0;idir<2; idir++){
1185 FitRMS1(tree, idir,param0,error0);
1186 printf("\nRMS\t%d\tchi2=%f\n",idir,param0[4]);
1187 printf("%f\t%f\t%f\t%f\n", param0[0],param0[1],param0[2], param0[3]);
1188 printf("%f\t%f\t%f\t%f\n", error0[0],error0[1],error0[2], error0[3]);
1189 for (Int_t ipar=0;ipar<5; ipar++){
1190 fParamRMS1[idir][ipar] = param0[ipar];
1191 fErrorRMS1[idir][ipar] = param0[ipar];
1195 for (Int_t idir=0;idir<2; idir++){
1196 printf("\nDirection %d\n",idir);
1197 printf("%d\t%f\t%f\t%f\t%f\n", -1,fParamRMS1[idir][0],fParamRMS1[idir][1],fParamRMS1[idir][2], fParamRMS1[idir][3]);
1198 for (Int_t itype=0; itype<3; itype++){
1199 Float_t length=0.75;
1200 if (itype==1) length=1;
1201 if (itype==2) length=1.5;
1202 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);
1203 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);
1209 printf("RMS fluctuation parameterization \n");
1210 for (Int_t idir=0;idir<2; idir++){
1211 for (Int_t itype=0; itype<3; itype++){
1214 FitRMSSigma(tree, idir,itype,param0,error0);
1215 printf("\t%d\t%d\t%f\t%f\n", idir, itype, param0[0],param0[1]);
1216 for (Int_t ipar=0;ipar<2; ipar++){
1217 fRMSSigmaFit[idir][itype][ipar] = param0[ipar];
1222 // store systematic error end RMS fluctuation parameterization
1224 TH1F hratio("hratio","hratio",100,-0.1,0.1);
1225 tree->Draw("(RMSm-AliTPCClusterParam::SGetRMSQ(Dim,Pad,Zm,AngleM,QMean))/RMSm>>hratio","Dim==0&&QMean>0");
1226 fErrorRMSSys[0] = hratio.GetRMS();
1227 tree->Draw("(RMSm-AliTPCClusterParam::SGetRMSQ(Dim,Pad,Zm,AngleM,QMean))/RMSm>>hratio","Dim==1&&QMean>0");
1228 fErrorRMSSys[1] = hratio.GetRMS();
1229 TH1F hratioR("hratioR","hratioR",100,0,0.2);
1230 tree->Draw("RMSs/RMSm>>hratioR","Dim==0&&QMean>0");
1231 fRMSSigmaRatio[0][0]=hratioR.GetMean();
1232 fRMSSigmaRatio[0][1]=hratioR.GetRMS();
1233 tree->Draw("RMSs/RMSm>>hratioR","Dim==1&&QMean>0");
1234 fRMSSigmaRatio[1][0]=hratioR.GetMean();
1235 fRMSSigmaRatio[1][1]=hratioR.GetRMS();
1238 void AliTPCClusterParam::Test(TTree * tree, const char *output){
1240 // Draw standard quality histograms to output file
1243 TFile f(output,"recreate");
1246 // 1D histograms - resolution
1248 for (Int_t idim=0; idim<2; idim++){
1249 for (Int_t ipad=0; ipad<3; ipad++){
1254 snprintf(hname1,300,"Delta0 Dir %d Pad %d",idim,ipad);
1255 snprintf(hcut1,300,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1256 snprintf(hexp1,300,"(Resol-AliTPCClusterParam::SGetError0(Dim,Pad,Zm,AngleM))/Resol>>%s",hname1);
1257 TH1F his1DRel0(hname1, hname1, 100,-0.2, 0.2);
1258 snprintf(hname1,300,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1259 tree->Draw(hexp1,hcut1,"");
1262 snprintf(hname1,300,"Delta0Par Dir %d Pad %d",idim,ipad);
1263 snprintf(hcut1,300,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1264 snprintf(hexp1,300,"(Resol-AliTPCClusterParam::SGetError0Par(Dim,Pad,Zm,AngleM))/Resol>>%s",hname1);
1265 TH1F his1DRel0Par(hname1, hname1, 100,-0.2, 0.2);
1266 snprintf(hname1,300,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1267 tree->Draw(hexp1,hcut1,"");
1268 his1DRel0Par.Write();
1273 // 2D histograms - resolution
1275 for (Int_t idim=0; idim<2; idim++){
1276 for (Int_t ipad=0; ipad<3; ipad++){
1281 snprintf(hname1,300,"2DDelta0 Dir %d Pad %d",idim,ipad);
1282 snprintf(hcut1,300,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1283 snprintf(hexp1,300,"(Resol-AliTPCClusterParam::SGetError0(Dim,Pad,Zm,AngleM))/Resol:AngleM:Zm>>%s",hname1);
1284 TProfile2D profDRel0(hname1, hname1, 6,0,250,6,0,1);
1285 snprintf(hname1,300,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1286 tree->Draw(hexp1,hcut1,"");
1289 snprintf(hname1,300,"2DDelta0Par Dir %d Pad %d",idim,ipad);
1290 snprintf(hcut1,300,"Dim==%d&&QMean<0&&Pad==%d",idim,ipad);
1291 snprintf(hexp1,300,"(Resol-AliTPCClusterParam::SGetError0Par(Dim,Pad,Zm,AngleM))/Resol:AngleM:Zm>>%s",hname1);
1292 TProfile2D profDRel0Par(hname1, hname1,6,0,250,6,0,1);
1293 snprintf(hname1,300,"Dim==%d&&QMean<0&&Pad=%d",idim,ipad);
1294 tree->Draw(hexp1,hcut1,"");
1295 profDRel0Par.Write();
1303 void AliTPCClusterParam::Print(Option_t* /*option*/) const{
1305 // Print param Information
1309 // Error parameterization
1311 printf("\nResolution Scaled factors\n");
1312 printf("Dir\tPad\tP0\t\tP1\t\tP2\t\tchi2\n");
1313 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])),
1314 TMath::Sqrt(TMath::Abs(fParamS1[0][2])),TMath::Sqrt(TMath::Abs(fParamS1[0][3])));
1315 for (Int_t ipad=0; ipad<3; ipad++){
1316 Float_t length=0.75;
1317 if (ipad==1) length=1;
1318 if (ipad==2) length=1.5;
1319 printf("\t%d\t%f\t%f\t%f\t%f\n", ipad,
1320 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][0])),
1321 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][1]*length)),
1322 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][2]/length)),
1323 TMath::Sqrt(TMath::Abs(fParamS0[0][ipad][3])));
1325 for (Int_t ipad=0; ipad<3; ipad++){
1326 Float_t length=0.75;
1327 if (ipad==1) length=1;
1328 if (ipad==2) length=1.5;
1329 printf("\t%dPar\t%f\t%f\t%f\t%f\n", ipad,
1330 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][0])),
1331 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][1]*length)),
1332 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][2]/length)),
1333 TMath::Sqrt(TMath::Abs(fParamS0Par[0][ipad][6])));
1335 printf("Z\tall\t%f\t%f\t%f\t%f\n", TMath::Sqrt(TMath::Abs(fParamS1[1][0])),TMath::Sqrt(fParamS1[1][1]),
1336 TMath::Sqrt(fParamS1[1][2]), TMath::Sqrt(fParamS1[1][3]));
1338 for (Int_t ipad=0; ipad<3; ipad++){
1339 Float_t length=0.75;
1340 if (ipad==1) length=1;
1341 if (ipad==2) length=1.5;
1342 printf("\t%d\t%f\t%f\t%f\t%f\n", ipad,
1343 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][0])),
1344 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][1]*length)),
1345 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][2]/length)),
1346 TMath::Sqrt(TMath::Abs(fParamS0[1][ipad][3])));
1348 for (Int_t ipad=0; ipad<3; ipad++){
1349 Float_t length=0.75;
1350 if (ipad==1) length=1;
1351 if (ipad==2) length=1.5;
1352 printf("\t%dPar\t%f\t%f\t%f\t%f\n", ipad,
1353 TMath::Sqrt(TMath::Abs(TMath::Abs(fParamS0Par[1][ipad][0]))),
1354 TMath::Sqrt(TMath::Abs(fParamS0Par[1][ipad][1]*length)),
1355 TMath::Sqrt(TMath::Abs(fParamS0Par[1][ipad][2]/length)),
1356 TMath::Sqrt(TMath::Abs(fParamS0Par[1][ipad][6])));
1363 printf("\nRMS Scaled factors\n");
1364 printf("Dir\tPad\tP00\t\tP01\t\tP1\t\tP2\t\tchi2\n");
1365 printf("Y\tall\t%f\t%f\t%f\t%f\t%f\n",
1366 TMath::Sqrt(TMath::Abs(fParamRMS1[0][0])),
1367 TMath::Sqrt(TMath::Abs(fParamRMS1[0][1])),
1368 TMath::Sqrt(TMath::Abs(fParamRMS1[0][2])),
1369 TMath::Sqrt(TMath::Abs(fParamRMS1[0][3])),
1370 TMath::Sqrt(TMath::Abs(fParamRMS1[0][4])));
1371 for (Int_t ipad=0; ipad<3; ipad++){
1372 Float_t length=0.75;
1373 if (ipad==1) length=1;
1374 if (ipad==2) length=1.5;
1376 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1377 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][0])),
1379 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][1])),
1380 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][2]/(length*length))),
1381 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][3])));
1383 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1385 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][0])),
1386 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][1])),
1387 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][2]/(length*length))),
1388 TMath::Sqrt(TMath::Abs(fParamRMS0[0][ipad][3])));
1392 printf("Z\tall\t%f\t%f\t%f\t%f\t%f\n",
1393 TMath::Sqrt(TMath::Abs(fParamRMS1[1][0])),
1394 TMath::Sqrt(TMath::Abs(fParamRMS1[1][1])),
1395 TMath::Sqrt(TMath::Abs(fParamRMS1[1][2])),
1396 TMath::Sqrt(TMath::Abs(fParamRMS1[1][3])),
1397 TMath::Sqrt(TMath::Abs(fParamRMS1[1][4])));
1398 for (Int_t ipad=0; ipad<3; ipad++){
1399 Float_t length=0.75;
1400 if (ipad==1) length=1;
1401 if (ipad==2) length=1.5;
1403 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1404 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][0])),
1406 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][1])),
1407 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][2]/(length*length))),
1408 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][3])));
1410 printf("\t%d\t%f\t%f\t%f\t%f\t%f\n", ipad,
1412 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][0])),
1413 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][1])),
1414 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][2]/(length*length))),
1415 TMath::Sqrt(TMath::Abs(fParamRMS0[1][ipad][3])));
1418 printf("\ndEdx correction matrix used in GetQnormCorr\n");
1419 fQNormCorr->Print();
1427 Float_t AliTPCClusterParam::Qnorm(Int_t ipad, Int_t itype, Float_t dr, Float_t ty, Float_t tz){
1428 // get Q normalization
1429 // type - 0 Qtot 1 Qmax
1430 // ipad - 0 (0.75 cm) ,1 (1 cm), 2 (1.5 cm)
1432 //expession formula - TString *strq0 = toolkit.FitPlane(chain,"dedxQ.fElements[2]","dr++ty++tz++dr*ty++dr*tz++++dr*dr++ty*tz++ty^2++tz^2","IPad==0",chi2,npoints,param,covar,0,100000);
1434 if (fQNorm==0) return 0;
1435 TVectorD * norm = (TVectorD*)fQNorm->At(3*itype+ipad);
1436 if (!norm) return 0;
1437 TVectorD &no = *norm;
1455 Float_t AliTPCClusterParam::QnormHis(Int_t ipad, Int_t itype, Float_t dr, Float_t p2, Float_t p3){
1456 // get Q normalization
1457 // type - 0 Qtot 1 Qmax
1458 // ipad - 0 (0.75 cm) ,1 (1 cm), 2 (1.5 cm)
1461 if (fQNormHis==0) return 0;
1462 TH3F * norm = (TH3F*)fQNormHis->At(4*itype+ipad);
1463 if (!norm) return 1;
1465 dr=TMath::Min(dr,Float_t(norm->GetXaxis()->GetXmax()-norm->GetXaxis()->GetBinWidth(0)));
1466 dr=TMath::Max(dr,Float_t(norm->GetXaxis()->GetXmin()+norm->GetXaxis()->GetBinWidth(0)));
1468 p2=TMath::Min(p2,Float_t(norm->GetYaxis()->GetXmax()-norm->GetYaxis()->GetBinWidth(0)));
1469 p2=TMath::Max(p2,Float_t(norm->GetYaxis()->GetXmin()+norm->GetYaxis()->GetBinWidth(0)));
1471 p3=TMath::Min(p3,Float_t(norm->GetZaxis()->GetXmax()-norm->GetZaxis()->GetBinWidth(0)));
1472 p3=TMath::Max(p3,Float_t(norm->GetZaxis()->GetXmin()+norm->GetZaxis()->GetBinWidth(0)));
1474 Double_t res = norm->GetBinContent(norm->FindBin(dr,p2,p3));
1475 if (res==0) res = norm->GetBinContent(norm->FindBin(0.5,0.5,0.5)); // This is just hack - to be fixed entries without
1482 void AliTPCClusterParam::SetQnorm(Int_t ipad, Int_t itype, const TVectorD *const norm){
1484 // set normalization
1486 // type - 0 Qtot 1 Qmax
1487 // ipad - 0 (0.75 cm) ,1 (1 cm), 2 (1.5 cm)
1490 if (fQNorm==0) fQNorm = new TObjArray(6);
1491 fQNorm->AddAt(new TVectorD(*norm), itype*3+ipad);
1494 void AliTPCClusterParam::ResetQnormCorr(){
1498 if (!fQNormCorr) fQNormCorr= new TMatrixD(12,6);
1499 for (Int_t irow=0;irow<12; irow++)
1500 for (Int_t icol=0;icol<6; icol++){
1501 (*fQNormCorr)(irow,icol)=1.; // default - no correction
1502 if (irow>5) (*fQNormCorr)(irow,icol)=0.; // default - no correction
1506 void AliTPCClusterParam::SetQnormCorr(Int_t ipad, Int_t itype, Int_t corrType, Float_t val, Int_t mode){
1509 // itype - 0- qtot 1-qmax
1510 // corrType - 0 - s0y corr - eff. PRF corr
1511 // - 1 - s0z corr - eff. TRF corr
1512 // - 2 - d0y - eff. diffusion correction y
1513 // - 3 - d0z - eff. diffusion correction
1514 // - 4 - eff length - eff.length - wire pitch + x diffsion
1515 // - 5 - pad type normalization
1520 // eff shap parameterization matrix
1523 // itype*3+ipad - itype=0 qtot itype=1 qmax ipad=0
1526 // mode introduced in 20.07.2014 - git describe ~ vAN-20140703-48-g3449a97 - to keep back compatibility with o
1527 (*fQNormCorr)(itype*3+ipad, corrType) = val; // set value
1530 if (itype<2) (*fQNormCorr)(itype*3+ipad, corrType) *= val; // multiplicative correction
1531 if (itype>=2) (*fQNormCorr)(itype*3+ipad, corrType)+= val; // additive correction
1534 Double_t AliTPCClusterParam::GetQnormCorr(Int_t ipad, Int_t itype, Int_t corrType) const{
1536 // see AliTPCClusterParam::SetQnormCorr
1538 if (!fQNormCorr) return 0;
1539 return (*fQNormCorr)(itype*3+ipad, corrType);
1543 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){
1545 // Make Q normalization as function of following parameters
1546 // Fit parameters to be used in corresponding correction function extracted in the AliTPCclaibTracksGain - Taylor expansion
1547 // 1 - dp - relative pad position
1548 // 2 - dt - relative time position
1549 // 3 - di - drift length (norm to 1);
1550 // 4 - dq0 - Tot/Max charge
1551 // 5 - dq1 - Max/Tot charge
1552 // 6 - sy - sigma y - shape
1553 // 7 - sz - sigma z - shape
1556 //The results can be visualized using the debug streamer information of the AliTPCcalibTracksGain -
1557 // Following variable used - correspondance to the our variable conventions
1558 //chain0->SetAlias("dp","((Cl.fPad-int(Cl.fPad)-0.5)/0.5)");
1559 Double_t dp = ((pad-int(pad)-0.5)*2.);
1560 //chain0->SetAlias("dt","((Cl.fTimeBin-int(Cl.fTimeBin)-0.5)/0.5)");
1561 Double_t dt = ((time-int(time)-0.5)*2.);
1562 //chain0->SetAlias("di","(sqrt(1.-abs(Cl.fZ)/250.))");
1563 Double_t di = TMath::Sqrt(1-TMath::Abs(z)/250.);
1564 //chain0->SetAlias("dq0","(0.2*(Cl.fQ+2)/(Cl.fMax+2))");
1565 Double_t dq0 = 0.2*(qt+2.)/(qm+2.);
1566 //chain0->SetAlias("dq1","(5*(Cl.fMax+2)/(Cl.fQ+2))");
1567 Double_t dq1 = 5.*(qm+2.)/(qt+2.);
1568 //chain0->SetAlias("sy","(0.32/sqrt(0.01^2+Cl.fSigmaY2))");
1569 Double_t sy = 0.32/TMath::Sqrt(0.01*0.01+sy2);
1570 //chain0->SetAlias("sz","(0.32/sqrt(0.01^2+Cl.fSigmaZ2))");
1571 Double_t sz = 0.32/TMath::Sqrt(0.01*0.01+sz2);
1575 TVectorD * pvec = 0;
1577 pvec = fPosQMnorm[ipad];
1579 pvec = fPosQTnorm[ipad];
1581 TVectorD ¶m = *pvec;
1583 // Eval part - in correspondance with fit part from debug streamer
1585 Double_t result=param[0];
1588 result+=dp*param[index++]; //1
1589 result+=dt*param[index++]; //2
1590 result+=dp*dp*param[index++]; //3
1591 result+=dt*dt*param[index++]; //4
1592 result+=dt*dt*dt*param[index++]; //5
1593 result+=dp*dt*param[index++]; //6
1594 result+=dp*dt*dt*param[index++]; //7
1595 result+=(dq0)*param[index++]; //8
1596 result+=(dq1)*param[index++]; //9
1599 result+=dp*dp*(di)*param[index++]; //10
1600 result+=dt*dt*(di)*param[index++]; //11
1601 result+=dp*dp*sy*param[index++]; //12
1602 result+=dt*sz*param[index++]; //13
1603 result+=dt*dt*sz*param[index++]; //14
1604 result+=dt*dt*dt*sz*param[index++]; //15
1606 result+=dp*dp*1*sy*sz*param[index++]; //16
1607 result+=dt*sy*sz*param[index++]; //17
1608 result+=dt*dt*sy*sz*param[index++]; //18
1609 result+=dt*dt*dt*sy*sz*param[index++]; //19
1611 result+=dp*dp*(dq0)*param[index++]; //20
1612 result+=dt*1*(dq0)*param[index++]; //21
1613 result+=dt*dt*(dq0)*param[index++]; //22
1614 result+=dt*dt*dt*(dq0)*param[index++]; //23
1616 result+=dp*dp*(dq1)*param[index++]; //24
1617 result+=dt*(dq1)*param[index++]; //25
1618 result+=dt*dt*(dq1)*param[index++]; //26
1619 result+=dt*dt*dt*(dq1)*param[index++]; //27
1621 if (result<0.75) result=0.75;
1622 if (result>1.25) result=1.25;
1632 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*/){
1635 // Make postion correction
1636 // type - 0 - y correction
1638 // ipad - 0, 1, 2 - short, medium long pads
1639 // pad - float pad number
1640 // time - float time bin number
1641 // z - z of the cluster
1644 //chainres->SetAlias("dp","(-1+(Cl.fZ>0)*2)*((Cl.fPad-int(Cl.fPad))-0.5)");
1645 //chainres->SetAlias("dt","(-1+(Cl.fZ>0)*2)*((Cl.fTimeBin-0.66-int(Cl.fTimeBin-0.66))-0.5)");
1646 //chainres->SetAlias("sp","(sin(dp*pi)-dp*pi)");
1647 //chainres->SetAlias("st","(sin(dt)-dt)");
1649 //chainres->SetAlias("di","sqrt(1.-abs(Cl.fZ/250.))");
1652 // Derived variables
1654 Double_t dp = (-1+(z>0)*2)*((pad-int(pad))-0.5);
1655 Double_t dt = (-1+(z>0)*2)*((time-0.66-int(time-0.66))-0.5);
1656 Double_t sp = (TMath::Sin(dp*TMath::Pi())-dp*TMath::Pi());
1657 Double_t st = (TMath::Sin(dt)-dt);
1659 Double_t di = TMath::Sqrt(TMath::Abs(1.-TMath::Abs(z/250.)));
1663 TVectorD * pvec = 0;
1665 pvec = fPosYcor[ipad];
1667 pvec = fPosZcor[ipad];
1669 TVectorD ¶m = *pvec;
1676 result+=(dp)*param[index++]; //1
1677 result+=(dp)*di*param[index++]; //2
1679 result+=(sp)*param[index++]; //3
1680 result+=(sp)*di*param[index++]; //4
1683 result+=(dt)*param[index++]; //1
1684 result+=(dt)*di*param[index++]; //2
1686 result+=(st)*param[index++]; //3
1687 result+=(st)*di*param[index++]; //4
1689 if (TMath::Abs(result)>0.05) return 0;
1695 Double_t AliTPCClusterParam::GaussConvolution(Double_t x0, Double_t x1, Double_t k0, Double_t k1, Double_t s0, Double_t s1){
1697 // 2 D gaus convoluted with angular effect
1698 // See in mathematica:
1699 //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}]]
1701 //TF1 f1("f1","AliTPCClusterParam::GaussConvolution(x,0,1,0,0.1,0.1)",-2,2)
1702 //TF2 f2("f2","AliTPCClusterParam::GaussConvolution(x,y,1,1,0.1,0.1)",-2,2,-2,2)
1704 const Double_t kEpsilon = 0.0001;
1705 const Double_t twoPi = TMath::TwoPi();
1706 const Double_t hnorm = 0.5/TMath::Sqrt(twoPi);
1707 const Double_t sqtwo = TMath::Sqrt(2.);
1709 if ((TMath::Abs(k0)+TMath::Abs(k1))<kEpsilon*(s0+s1)){
1710 // small angular effect
1711 Double_t val = TMath::Gaus(x0,0,s0)*TMath::Gaus(x1,0,s1)/(s0*s1*twoPi);
1714 Double_t sigma2 = k1*k1*s0*s0+k0*k0*s1*s1;
1715 Double_t sigma = TMath::Sqrt(sigma2);
1716 Double_t exp0 = TMath::Exp(-(k1*x0-k0*x1)*(k1*x0-k0*x1)/(2.*sigma2));
1718 Double_t sigmaErf = 1./(2.*s0*s1*sqtwo*sigma);
1719 Double_t k0s1s1 = 2.*k0*s1*s1;
1720 Double_t k1s0s0 = 2.*k1*s0*s0;
1721 Double_t erf0 = AliMathBase::ErfFast((sigma2-k0s1s1*x0-k1s0s0*x1)*sigmaErf);
1722 Double_t erf1 = AliMathBase::ErfFast((sigma2+k0s1s1*x0+k1s0s0*x1)*sigmaErf);
1723 Double_t norm = hnorm/sigma;
1724 Double_t val = norm*exp0*(erf0+erf1);
1729 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){
1731 // 2 D gaus convoluted with angular effect and exponential tail in z-direction
1732 // tail integrated numerically
1733 // Integral normalized to one
1736 // TF1 f1t("f1t","AliTPCClusterParam::GaussConvolutionTail(0,x,0,0,0.5,0.5,0.9)",-5,5)
1737 Double_t sum =1, mean=0;
1738 // the COG of exponent
1739 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1740 mean+=iexp*TMath::Exp(-iexp/tau);
1741 sum +=TMath::Exp(-iexp/tau);
1746 Double_t val = GaussConvolution(x0,x1+mean, k0, k1 , s0,s1);
1747 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1748 val+=GaussConvolution(x0,x1+mean-iexp, k0, k1 , s0,s1)*TMath::Exp(-iexp/tau);
1749 sum+=TMath::Exp(-iexp/tau);
1754 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){
1756 // 2 D gaus convoluted with angular effect and exponential tail in z-direction
1757 // tail integrated numerically
1758 // Integral normalized to one
1761 // TF1 f1g4("f1g4","AliTPCClusterParam::GaussConvolutionGamma4(0,x,0,0,0.5,0.2,1.6)",-5,5)
1762 // TF2 f2g4("f2g4","AliTPCClusterParam::GaussConvolutionGamma4(y,x,0,0,0.5,0.2,1.6)",-5,5,-5,5)
1763 Double_t sum =0, mean=0;
1765 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1766 Double_t g4 = TMath::Exp(-4.*iexp/tau)*TMath::Power(iexp/tau,4.);
1774 for (Float_t iexp=0;iexp<5;iexp+=0.2){
1775 Double_t g4 = TMath::Exp(-4.*iexp/tau)*TMath::Power(iexp/tau,4.);
1776 val+=GaussConvolution(x0,x1+mean-iexp, k0, k1 , s0,s1)*g4;
1782 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 effPad, Float_t effDiff){
1785 // cpad - pad (y) coordinate
1786 // ctime - time(z) coordinate
1789 // rmsy0 - RF width in pad units
1790 // rmsz0 - RF width in time bin units
1791 // effLength - contibution of PRF and diffusion
1792 // effDiff - overwrite diffusion
1794 // Response function aproximated by convolution of gaussian with angular effect (integral=1)
1796 // Gaus width sy and sz is determined by RF width and diffusion
1797 // Integral of Q is equal 1
1798 // Q max is calculated at position cpad, ctime
1799 // Example function:
1800 // TF1 f1("f1", "AliTPCClusterParam::QmaxCorrection(0,0.5,x,0,0,0.5,0.6)",0,1000)
1802 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1803 Double_t padLength= param->GetPadPitchLength(sector,row);
1804 Double_t padWidth = param->GetPadPitchWidth(sector);
1805 Double_t zwidth = param->GetZWidth();
1806 Double_t effLength= padLength+(param->GetWWPitch(0)+TMath::Sqrt(ctime*zwidth)*param->GetDiffT())*effPad;
1808 // diffusion in pad, time bin units
1809 Double_t diffT=TMath::Sqrt(ctime*zwidth)*param->GetDiffT()/padWidth;
1810 Double_t diffL=TMath::Sqrt(ctime*zwidth)*param->GetDiffL()/zwidth;
1814 // transform angular effect to pad units
1816 Double_t pky = ky*effLength/padWidth;
1817 Double_t pkz = kz*effLength/zwidth;
1818 // position in pad unit
1819 Double_t py = (cpad+0.5)-TMath::Nint(cpad+0.5);
1820 Double_t pz = (ctime+0.5)-TMath::Nint(ctime+0.5);
1823 Double_t sy = TMath::Sqrt(rmsy0*rmsy0+diffT*diffT);
1824 Double_t sz = TMath::Sqrt(rmsz0*rmsz0+diffL*diffL);
1825 //return GaussConvolutionGamma4(py,pz, pky,pkz,sy,sz,tau);
1826 Double_t length = padLength*TMath::Sqrt(1+ky*ky+kz*kz);
1827 return GaussConvolution(py,pz, pky,pkz,sy,sz)*length;
1830 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 effPad, Float_t effDiff){
1833 // cpad - pad (y) coordinate
1834 // ctime - time(z) coordinate
1837 // rmsy0 - RF width in pad units
1838 // rmsz0 - RF width in time bin units
1839 // qtot - the sum of signal in cluster - without thr correction
1841 // effLength - contibution of PRF and diffusion
1842 // effDiff - overwrite diffusion
1844 // Response function aproximated by convolution of gaussian with angular effect (integral=1)
1846 // Gaus width sy and sz is determined by RF width and diffusion
1847 // Integral of Q is equal 1
1848 // Q max is calculated at position cpad, ctime
1852 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1853 Double_t padLength= param->GetPadPitchLength(sector,row);
1854 Double_t padWidth = param->GetPadPitchWidth(sector);
1855 Double_t zwidth = param->GetZWidth();
1856 Double_t effLength= padLength+(param->GetWWPitch(0)+TMath::Sqrt(ctime*zwidth)*param->GetDiffT())*effPad;
1858 // diffusion in pad units
1859 Double_t diffT=TMath::Sqrt(ctime*zwidth)*param->GetDiffT()/padWidth;
1860 Double_t diffL=TMath::Sqrt(ctime*zwidth)*param->GetDiffL()/zwidth;
1864 // transform angular effect to pad units
1865 Double_t pky = ky*effLength/padWidth;
1866 Double_t pkz = kz*effLength/zwidth;
1867 // position in pad unit
1869 Double_t py = (cpad+0.5)-TMath::Nint(cpad+0.5);
1870 Double_t pz = (ctime+0.5)-TMath::Nint(ctime+0.5);
1872 Double_t sy = TMath::Sqrt(rmsy0*rmsy0+diffT*diffT);
1873 Double_t sz = TMath::Sqrt(rmsz0*rmsz0+diffL*diffL);
1877 Double_t sumAll=0,sumThr=0;
1880 Double_t qnorm=qtot;
1881 for (Float_t iy=-3;iy<=3;iy+=1.)
1882 for (Float_t iz=-4;iz<=4;iz+=1.){
1883 // Double_t val = GaussConvolutionGamma4(py-iy,pz-iz, pky,pkz, sy,sz,tau);
1884 Double_t val = GaussConvolution(py-iy,pz-iz, pky,pkz, sy,sz);
1885 Double_t qlocal =qnorm*val;
1886 if (TMath::Abs(iy)<1.5&&TMath::Abs(iz)<1.5){
1887 sumThr+=qlocal; // Virtual charge used in cluster finder
1890 if (qlocal>thr && TMath::Abs(iz)<2.5&&TMath::Abs(iy)<2.5) sumThr+=qlocal;
1894 if (sumAll>0&&sumThr>0) {
1895 corr=(sumThr)/sumAll;
1898 Double_t length = padLength*TMath::Sqrt(1+ky*ky+kz*kz);
1904 void AliTPCClusterParam::SetWaveCorrectionMap( THnBase *Map)
1907 // Set Correction Map for Y
1909 delete fWaveCorrectionMap;
1910 fWaveCorrectionMap = 0;
1911 fWaveCorrectionMirroredPad = kFALSE;
1912 fWaveCorrectionMirroredZ = kFALSE;
1913 fWaveCorrectionMirroredAngle = kFALSE;
1915 fWaveCorrectionMap = dynamic_cast<THnBase*>( Map->Clone(Map->GetName()));
1916 if( fWaveCorrectionMap ){
1917 fWaveCorrectionMirroredPad = ( fWaveCorrectionMap->GetAxis(3)->FindFixBin(0.5)<=1 ); // Pad axis is mirrored at 0.5
1918 fWaveCorrectionMirroredZ = ( fWaveCorrectionMap->GetAxis(1)->FindFixBin(0)<=1); // Z axis is mirrored at 0
1919 fWaveCorrectionMirroredAngle = ( fWaveCorrectionMap->GetAxis(4)->FindFixBin(0.0)<=1 ); // Angle axis is mirrored at 0
1924 void AliTPCClusterParam::SetResolutionYMap( THnBase *Map)
1927 // Set Resolution Map for Y
1929 delete fResolutionYMap;
1930 fResolutionYMap = 0;
1932 fResolutionYMap = dynamic_cast<THnBase*>( Map->Clone(Map->GetName()));
1936 Float_t AliTPCClusterParam::GetWaveCorrection(Int_t Type, Float_t Z, Int_t QMax, Float_t Pad, Float_t angleY ) const
1939 // Correct Y cluster coordinate using a map
1942 if( !fWaveCorrectionMap ) return 0;
1943 Bool_t swapY = kFALSE;
1944 Pad = Pad-(Int_t)Pad;
1946 if( TMath::Abs(Pad-0.5)<1.e-8 ){// one pad clusters a stored in underflow bins
1949 if( fWaveCorrectionMirroredPad && (Pad<0.5) ){ // cog axis is mirrored at 0.5
1955 if( fWaveCorrectionMirroredZ && (Z<0) ){ // Z axis is mirrored at 0
1960 if( fWaveCorrectionMirroredAngle && (angleY<0) ){ // Angle axis is mirrored at 0
1963 double var[5] = { static_cast<double>(Type), Z, static_cast<double>(QMax), Pad, angleY };
1964 Long64_t bin = fWaveCorrectionMap->GetBin(var, kFALSE );
1965 if( bin<0 ) return 0;
1966 Double_t dY = fWaveCorrectionMap->GetBinContent(bin);
1967 return (swapY ?-dY :dY);