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 **************************************************************************/
19 //-----------------------------------------------------------------
21 // Implementation of the TPC seed class
22 // This class is used by the AliTPCtrackerMI class
23 // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
24 //-----------------------------------------------------------------
25 #include "TClonesArray.h"
26 #include "TGraphErrors.h"
27 #include "AliTPCseed.h"
28 #include "AliTPCReconstructor.h"
29 #include "AliTPCClusterParam.h"
30 #include "AliTPCCalPad.h"
31 #include "AliTPCCalROC.h"
32 #include "AliTPCcalibDB.h"
33 #include "AliTPCParam.h"
34 #include "AliMathBase.h"
35 #include "AliTPCTransform.h"
36 #include "AliSplineFit.h"
37 #include "AliCDBManager.h"
38 #include "AliTPCcalibDButil.h"
45 AliTPCseed::AliTPCseed():
48 fClusterOwner(kFALSE),
52 fCurrentSigmaY2(1e10),
53 fCurrentSigmaZ2(1e10),
54 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
55 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
56 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
57 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
62 fCurrentClusterIndex1(-1),
75 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
76 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
77 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
78 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
79 for (Int_t i=0;i<4;i++) {
84 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
87 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
90 fClusterOwner(clusterOwner),
96 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
97 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
98 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
99 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
102 fCurrentCluster(0x0),
103 fCurrentClusterIndex1(-1),
115 //---------------------
116 // dummy copy constructor
117 //-------------------------
118 for (Int_t i=0;i<160;i++) {
119 fClusterPointer[i]=0;
121 if (s.fClusterPointer[i])
122 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
124 fClusterPointer[i] = s.fClusterPointer[i];
126 fTrackPoints[i] = s.fTrackPoints[i];
128 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
129 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
130 for (Int_t i=0;i<4;i++) {
131 fDEDX[i] = s.fDEDX[i];
132 fSDEDX[i] = s.fSDEDX[i];
133 fNCDEDX[i] = s.fNCDEDX[i];
135 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
140 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
143 fClusterOwner(kFALSE),
149 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
150 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
151 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
152 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
155 fCurrentCluster(0x0),
156 fCurrentClusterIndex1(-1),
169 // Constructor from AliTPCtrack
172 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
173 for (Int_t i=0;i<160;i++) {
174 fClusterPointer[i] = 0;
175 Int_t index = t.GetClusterIndex(i);
177 SetClusterIndex2(i,index);
180 SetClusterIndex2(i,-3);
183 for (Int_t i=0;i<4;i++) {
188 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
191 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
192 const Double_t cc[15], Int_t index):
193 AliTPCtrack(xr, alpha, xx, cc, index),
195 fClusterOwner(kFALSE),
201 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
202 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
203 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
204 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
207 fCurrentCluster(0x0),
208 fCurrentClusterIndex1(-1),
224 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
225 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
226 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
227 for (Int_t i=0;i<4;i++) {
232 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
235 AliTPCseed::~AliTPCseed(){
240 for (Int_t icluster=0; icluster<160; icluster++){
241 delete fClusterPointer[icluster];
246 //_________________________________________________
247 AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
250 // assignment operator
253 AliTPCtrack::operator=(param);
255 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
256 fClusterOwner = param.fClusterOwner;
257 // leave out fPoint, they are also not copied in the copy ctor...
258 // but deleted in the dtor... strange...
260 fSector = param.fSector;
261 fRelativeSector = param.fRelativeSector;
262 fCurrentSigmaY2 = param.fCurrentSigmaY2;
263 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
264 fErrorY2 = param.fErrorY2;
265 fErrorZ2 = param.fErrorZ2;
266 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
267 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
268 fInDead = param.fInDead;
269 fIsSeeding = param.fIsSeeding;
270 fNoCluster = param.fNoCluster;
272 fBSigned = param.fBSigned;
273 for(Int_t i = 0;i<4;++i){
274 fDEDX[i] = param.fDEDX[i];
275 fSDEDX[i] = param.fSDEDX[i];
276 fNCDEDX[i] = param.fNCDEDX[i];
278 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
280 fSeedType = param.fSeedType;
281 fSeed1 = param.fSeed1;
282 fSeed2 = param.fSeed2;
283 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
284 fMAngular = param.fMAngular;
285 fCircular = param.fCircular;
286 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
290 //____________________________________________________
291 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
295 return &fTrackPoints[i];
300 Double_t AliTPCseed::GetDensityFirst(Int_t n)
304 // return cluster for n rows bellow first point
305 Int_t nfoundable = 1;
307 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
308 Int_t index = GetClusterIndex2(i);
309 if (index!=-1) nfoundable++;
310 if (index>0) nfound++;
312 if (nfoundable<n) return 0;
313 return Double_t(nfound)/Double_t(nfoundable);
318 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
320 // get cluster stat. on given region
325 for (Int_t i=first;i<last; i++){
326 Int_t index = GetClusterIndex2(i);
327 if (index!=-1) foundable++;
328 if (index&0x8000) continue;
329 if (fClusterPointer[i]) {
335 if (fClusterPointer[i]->IsUsed(10)) {
339 if (!plus2) continue; //take also neighborhoud
341 if ( (i>0) && fClusterPointer[i-1]){
342 if (fClusterPointer[i-1]->IsUsed(10)) {
347 if ( fClusterPointer[i+1]){
348 if (fClusterPointer[i+1]->IsUsed(10)) {
356 //Error("AliTPCseed::GetClusterStatistic","problem\n");
364 void AliTPCseed::Reset(Bool_t all)
368 SetNumberOfClusters(0);
371 ResetCovariance(10.);
374 for (Int_t i=0;i<8;i++){
375 delete [] fTrackPoints[i];
383 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
384 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
390 void AliTPCseed::Modify(Double_t factor)
393 //------------------------------------------------------------------
394 //This function makes a track forget its history :)
395 //------------------------------------------------------------------
397 ResetCovariance(10.);
400 ResetCovariance(factor);
402 SetNumberOfClusters(0);
406 fCurrentSigmaY2 = 0.000005;
407 fCurrentSigmaZ2 = 0.000005;
416 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
418 //-----------------------------------------------------------------
419 // This function find proloncation of a track to a reference plane x=xk.
420 // doesn't change internal state of the track
421 //-----------------------------------------------------------------
423 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
425 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
429 // Double_t y1=fP0, z1=fP1;
430 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
431 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
435 //y += dx*(c1+c2)/(r1+r2);
436 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
438 Double_t dy = dx*(c1+c2)/(r1+r2);
441 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
443 if (TMath::Abs(delta)>0.0001){
444 dz = fP3*TMath::ASin(delta)/fP4;
446 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
449 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
450 dz = GetTgl()*TMath::ASin(delta)/GetC();
460 //_____________________________________________________________________________
461 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
463 //-----------------------------------------------------------------
464 // This function calculates a predicted chi2 increment.
465 //-----------------------------------------------------------------
466 Double_t p[2]={c->GetY(), c->GetZ()};
467 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
469 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
470 if (TMath::Abs(dx)>0){
471 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
473 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
477 return AliExternalTrackParam::GetPredictedChi2(p,cov);
480 //_________________________________________________________________________________________
483 Int_t AliTPCseed::Compare(const TObject *o) const {
484 //-----------------------------------------------------------------
485 // This function compares tracks according to the sector - for given sector according z
486 //-----------------------------------------------------------------
487 AliTPCseed *t=(AliTPCseed*)o;
490 if (t->fRelativeSector>fRelativeSector) return -1;
491 if (t->fRelativeSector<fRelativeSector) return 1;
492 Double_t z2 = t->GetZ();
493 Double_t z1 = GetZ();
495 if (z2<z1) return -1;
500 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
501 if (t->fBConstrain) f2=1.2;
504 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
506 if (fBConstrain) f1=1.2;
508 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
516 //_____________________________________________________________________________
517 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
519 //-----------------------------------------------------------------
520 // This function associates a cluster with this track.
521 //-----------------------------------------------------------------
522 Int_t n=GetNumberOfClusters();
523 Int_t idx=GetClusterIndex(n); // save the current cluster index
525 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
526 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
527 if (TMath::Abs(dx)>0){
528 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
530 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
531 cl.SetY(c->GetY()-dy);
532 cl.SetZ(c->GetZ()-dz);
535 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
537 if (fCMeanSigmaY2p30<0){
538 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
539 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
540 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
541 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
544 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
545 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
546 if (fCurrentSigmaY2>0){
547 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
548 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
552 SetClusterIndex(n,idx); // restore the current cluster index
558 //_____________________________________________________________________________
559 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
560 //-----------------------------------------------------------------
561 // This funtion calculates dE/dX within the "low" and "up" cuts.
562 //-----------------------------------------------------------------
563 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
564 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
566 Int_t row0 = param->GetNRowLow();
567 Int_t row1 = row0+param->GetNRowUp1();
568 Int_t row2 = row1+param->GetNRowUp2();
569 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
571 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
575 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
576 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
577 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
578 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
580 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
581 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
582 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
583 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
585 fNCDEDX[0] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 2));
586 fNCDEDX[1] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,0 ,row0, 2));
587 fNCDEDX[2] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,row0,row1, 2));
588 fNCDEDX[3] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,row1,row2, 2));
593 // return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
597 // Float_t angular[200];
598 // Float_t weight[200];
601 // Float_t meanlog = 100.;
603 // Float_t mean[4] = {0,0,0,0};
604 // Float_t sigma[4] = {1000,1000,1000,1000};
605 // Int_t nc[4] = {0,0,0,0};
606 // Float_t norm[4] = {1000,1000,1000,1000};
611 // Float_t gainGG = 1;
612 // if (AliTPCcalibDB::Instance()->GetParameters()){
613 // gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
617 // for (Int_t of =0; of<4; of++){
618 // for (Int_t i=of+i1;i<i2;i+=4)
620 // Int_t clindex = fIndex[i];
621 // if (clindex<0||clindex&0x8000) continue;
623 // //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
624 // AliTPCTrackerPoint * point = GetTrackPoint(i);
625 // //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
626 // //AliTPCTrackerPoint * pointp = 0;
627 // //if (i<159) pointp = GetTrackPoint(i+1);
629 // if (point==0) continue;
630 // AliTPCclusterMI * cl = fClusterPointer[i];
631 // if (cl==0) continue;
632 // if (onlyused && (!cl->IsUsed(10))) continue;
633 // if (cl->IsUsed(11)) {
637 // Int_t type = cl->GetType();
638 // //if (point->fIsShared){
643 // // if (pointm->fIsShared) continue;
645 // // if (pointp->fIsShared) continue;
647 // if (type<0) continue;
648 // //if (type>10) continue;
649 // //if (point->GetErrY()==0) continue;
650 // //if (point->GetErrZ()==0) continue;
652 // //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
653 // //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
654 // //if ((ddy*ddy+ddz*ddz)>10) continue;
657 // // if (point->GetCPoint().GetMax()<5) continue;
658 // if (cl->GetMax()<5) continue;
659 // Float_t angley = point->GetAngleY();
660 // Float_t anglez = point->GetAngleZ();
662 // Float_t rsigmay2 = point->GetSigmaY();
663 // Float_t rsigmaz2 = point->GetSigmaZ();
667 // rsigmay += pointm->GetTPoint().GetSigmaY();
668 // rsigmaz += pointm->GetTPoint().GetSigmaZ();
672 // rsigmay += pointp->GetTPoint().GetSigmaY();
673 // rsigmaz += pointp->GetTPoint().GetSigmaZ();
680 // Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
682 // Float_t ampc = 0; // normalization to the number of electrons
684 // // ampc = 1.*point->GetCPoint().GetMax();
685 // ampc = 1.*cl->GetMax();
686 // //ampc = 1.*point->GetCPoint().GetQ();
687 // // AliTPCClusterPoint & p = point->GetCPoint();
688 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
689 // // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
691 // // TMath::Abs( Int_t(iz) - iz + 0.5);
692 // //ampc *= 1.15*(1-0.3*dy);
693 // //ampc *= 1.15*(1-0.3*dz);
694 // // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
698 // //ampc = 1.0*point->GetCPoint().GetMax();
699 // ampc = 1.0*cl->GetMax();
700 // //ampc = 1.0*point->GetCPoint().GetQ();
701 // //AliTPCClusterPoint & p = point->GetCPoint();
702 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
703 // //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
705 // // TMath::Abs( Int_t(iz) - iz + 0.5);
707 // //ampc *= 1.15*(1-0.3*dy);
708 // //ampc *= 1.15*(1-0.3*dz);
709 // // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
713 // ampc *= 2.0; // put mean value to channel 50
714 // //ampc *= 0.58; // put mean value to channel 50
716 // // if (type>0) w = 1./(type/2.-0.5);
717 // // Float_t z = TMath::Abs(cl->GetZ());
720 // //ampc /= (1+0.0008*z);
724 // //ampc /= (1+0.0008*z);
726 // //ampc /= (1+0.0008*z);
729 // if (type<0) { //amp at the border - lower weight
734 // if (rsigma>1.5) ampc/=1.3; // if big backround
735 // amp[nc[of]] = ampc;
736 // amp[nc[of]] /=gainGG;
737 // angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
738 // weight[nc[of]] = w;
742 // TMath::Sort(nc[of],amp,index,kFALSE);
744 // Float_t sumamp2=0;
746 // //meanlog = amp[index[Int_t(nc[of]*0.33)]];
748 // for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
749 // Float_t ampl = amp[index[i]]/angular[index[i]];
750 // ampl = meanlog*TMath::Log(1.+ampl/meanlog);
752 // sumw += weight[index[i]];
753 // sumamp += weight[index[i]]*ampl;
754 // sumamp2 += weight[index[i]]*ampl*ampl;
755 // norm[of] += angular[index[i]]*weight[index[i]];
762 // mean[of] = sumamp/sumw;
763 // sigma[of] = sumamp2/sumw-mean[of]*mean[of];
764 // if (sigma[of]>0.1)
765 // sigma[of] = TMath::Sqrt(sigma[of]);
769 // mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
770 // //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
771 // //mean *=(1-0.1*(norm-1.));
778 // // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
779 // // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
782 // // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
783 // // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
787 // for (Int_t i =0;i<4;i++){
788 // if (nc[i]>2&&nc[i]<1000){
789 // dedx += mean[i] *nc[i];
790 // fSdEdx += sigma[i]*(nc[i]-2);
791 // fMAngular += norm[i] *nc[i];
795 // fDEDX[i] = mean[i];
796 // fSDEDX[i] = sigma[i];
797 // fNCDEDX[i]= nc[i];
809 // // Float_t dedx1 =dedx;
812 // for (Int_t i =0;i<4;i++){
813 // if (nc[i]>2&&nc[i]<1000){
814 // mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
815 // dedx += mean[i] *nc[i];
817 // fDEDX[i] = mean[i];
827 void AliTPCseed::CookPID()
830 // cook PID information according dEdx
832 Double_t fRange = 10.;
836 Int_t ns=AliPID::kSPECIES;
838 for (Int_t j=0; j<ns; j++) {
839 Double_t mass=AliPID::ParticleMass(j);
841 Double_t dedx=fdEdx/fMIP;
842 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
843 Double_t sigma=fRes*bethe;
845 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
846 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
850 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
858 for (Int_t j=0; j<ns; j++) {
859 fTPCr[j]/=sumr; //normalize
863 Double_t AliTPCseed::GetYat(Double_t xk) const {
864 //-----------------------------------------------------------------
865 // This function calculates the Y-coordinate of a track at the plane x=xk.
866 //-----------------------------------------------------------------
867 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
868 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
869 Double_t c2=c1+GetC()*(xk-GetX());
870 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
871 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
872 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
877 Float_t AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Bool_t shapeNorm,Int_t posNorm, Int_t padNorm, Int_t returnVal){
880 // calculates dedx using the cluster
881 // low - up specify trunc mean range - default form 0-0.7
882 // type - 1 - max charge or 0- total charge in cluster
883 // //2- max no corr 3- total+ correction
884 // i1-i2 - the pad-row range used for calculation
885 // shapeNorm - kTRUE -taken from OCDB
887 // posNorm - usage of pos normalization
888 // padNorm - pad type normalization
889 // returnVal - 0 return mean
891 // - 2 return number of clusters
893 // normalization parametrization taken from AliTPCClusterParam
895 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
896 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
897 if (!parcl) return 0;
898 if (!param) return 0;
899 Int_t row0 = param->GetNRowLow();
900 Int_t row1 = row0+param->GetNRowUp1();
907 Float_t gainGG = 1; // gas gain factor -always enabled
908 Float_t gainPad = 1; // gain map - used always
909 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
910 Float_t corrPos = 1; // local position correction - if posNorm enabled
911 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
912 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
916 if (AliTPCcalibDB::Instance()->GetParameters()){
917 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
920 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
921 const Float_t kedgey =3.;
924 for (Int_t irow=i1; irow<i2; irow++){
925 AliTPCclusterMI* cluster = GetClusterPointer(irow);
926 if (!cluster) continue;
927 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
928 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
930 if (irow>=row0) ipad=1;
931 if (irow>=row1) ipad=2;
935 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
938 // Get gainPad - pad by pad calibration
941 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
942 if (irow < row0) { // IROC
943 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
945 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
947 if (factor>0.5) gainPad=factor;
950 //do position and angular normalization
955 AliTPCTrackerPoint * point = GetTrackPoint(irow);
956 Float_t ty = TMath::Abs(point->GetAngleY());
957 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
959 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
960 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
966 // Do position normalization - relative distance to
967 // center of pad- time bin
969 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
970 // cluster->GetTimeBin(), cluster->GetZ(),
971 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
972 // cluster->GetMax(),cluster->GetQ());
973 // scaled response function
974 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
975 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
978 AliTPCTrackerPoint * point = GetTrackPoint(irow);
979 Float_t ty = TMath::Abs(point->GetAngleY());
980 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
982 if (type==1) corrPos =
983 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
984 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
985 if (type==0) corrPos =
986 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
987 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
989 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
990 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
991 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
992 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
993 if (corrHis>0) corrPos*=corrHis;
1000 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1001 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
1005 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1006 //use hardwired - temp fix
1007 if (type==0) corrNorm=3.;
1008 if (type==1) corrNorm=1.;
1014 amp[ncl]/=corrShape;
1015 amp[ncl]/=corrPadType;
1022 if (type>3) return ncl;
1023 TMath::Sort(ncl,amp, indexes, kFALSE);
1025 if (ncl<10) return 0;
1030 Int_t icl0=TMath::Nint(ncl*low);
1031 Int_t icl1=TMath::Nint(ncl*up);
1032 for (Int_t icl=icl0; icl<icl1;icl++){
1033 suma+=amp[indexes[icl]];
1034 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1037 Float_t mean =suma/sumn;
1038 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1040 // do time-dependent correction for pressure and temperature variations
1041 UInt_t runNumber = 1;
1042 Float_t corrTimeGain = 1;
1043 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1044 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1045 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
1046 runNumber = trans->GetCurrentRunNumber();
1047 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1048 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1049 if (timeGainSplines) {
1050 UInt_t time = trans->GetCurrentTimeStamp();
1051 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1052 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1054 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
1056 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
1060 mean /= corrTimeGain;
1061 rms /= corrTimeGain;
1063 if (returnVal==1) return rms;
1064 if (returnVal==2) return ncl;
1068 Float_t AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal, Int_t rowThres, Int_t mode){
1071 // calculates dedx using the cluster
1072 // low - up specify trunc mean range - default form 0-0.7
1073 // type - 1 - max charge or 0- total charge in cluster
1074 // //2- max no corr 3- total+ correction
1075 // i1-i2 - the pad-row range used for calculation
1077 // posNorm - usage of pos normalization
1078 // returnVal - 0 return mean
1080 // - 2 return number of clusters
1082 // - 4 mean upper half
1083 // - 5 mean - lower half
1085 // mode - 0 - linear
1086 // - 1 - logatithmic
1087 // rowThres - number of rows before and after given pad row to check for clusters below threshold
1089 // normalization parametrization taken from AliTPCClusterParam
1091 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1092 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1093 if (!parcl) return 0;
1094 if (!param) return 0;
1095 Int_t row0 = param->GetNRowLow();
1096 Int_t row1 = row0+param->GetNRowUp1();
1101 Int_t nclBelowThr = 0; // counts number of clusters below threshold
1104 Float_t gainGG = 1; // gas gain factor -always enabled
1105 Float_t gainPad = 1; // gain map - used always
1106 Float_t corrPos = 1; // local position correction - if posNorm enabled
1110 if (AliTPCcalibDB::Instance()->GetParameters()){
1111 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1114 // extract time-dependent correction for pressure and temperature variations
1116 UInt_t runNumber = 1;
1117 Float_t corrTimeGain = 1;
1118 TObjArray * timeGainSplines = 0x0;
1119 TGraphErrors * grPadEqual = 0x0;
1121 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1122 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1124 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1127 runNumber = trans->GetCurrentRunNumber();
1128 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1129 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1130 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1131 UInt_t time = trans->GetCurrentTimeStamp();
1132 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1133 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1135 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
1137 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1140 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1141 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
1145 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1146 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1147 const Float_t kedgey =3.;
1150 for (Int_t irow=i1; irow<i2; irow++){
1151 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1152 if (!cluster && irow > 1 && irow < 157) {
1153 Bool_t isClBefore = kFALSE;
1154 Bool_t isClAfter = kFALSE;
1155 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1156 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1157 if (clusterBefore) isClBefore = kTRUE;
1158 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1159 if (clusterAfter) isClAfter = kTRUE;
1161 if (isClBefore && isClAfter) nclBelowThr++;
1163 if (!cluster) continue;
1166 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1168 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1169 if (point==0) continue;
1170 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1171 if (rsigmay > kClusterShapeCut) continue;
1173 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1175 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1177 if (irow>=row0) ipad=1;
1178 if (irow>=row1) ipad=2;
1182 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1185 // Get gainPad - pad by pad calibration
1188 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1189 if (irow < row0) { // IROC
1190 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1192 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1194 if (factor>0.3) gainPad=factor;
1197 // Do position normalization - relative distance to
1198 // center of pad- time bin
1200 Float_t ty = TMath::Abs(point->GetAngleY());
1201 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1202 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1203 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1205 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1206 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1207 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1208 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1211 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1212 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1213 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1214 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1215 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1216 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1217 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1221 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1222 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1223 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1225 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1226 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1227 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1228 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1232 // pad region equalization outside of cluster param
1234 Float_t gainEqualPadRegion = 1;
1235 if (grPadEqual) gainEqualPadRegion = grPadEqual->Eval(ipad);
1241 amp[ncl]/=gainEqualPadRegion;
1246 if (type==2) return ncl;
1247 TMath::Sort(ncl,amp, indexes, kFALSE);
1249 if (ncl<10) return 0;
1251 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1252 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1253 if (iCl < nclBelowThr) {
1254 ampWithBelow[iCl] = amp[indexes[0]];
1256 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1259 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1266 // upper,and lower part statistic
1267 Float_t sumL=0, sumL2=0, sumLN=0;
1268 Float_t sumD=0, sumD2=0, sumDN=0;
1270 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1271 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
1272 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1274 for (Int_t icl=icl0; icl<icl1;icl++){
1275 if (ampWithBelow[icl]<0.1) continue;
1276 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1277 if (mode==1) camp= TMath::Log(camp);
1281 suma3+=camp*camp*camp;
1282 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
1299 Float_t meanD = 0; // lower half mean
1300 if (sumn > 1e-30) mean =suma/sumn;
1301 if (sumLN > 1e-30) meanL =sumL/sumLN;
1302 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1304 Float_t mean =suma/sumn;
1305 Float_t meanL = sumL/sumLN;
1306 Float_t meanD =(sumD/sumDN); // lower half mean
1315 rms = TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1321 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1322 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1323 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
1325 if (mode==1) mean=TMath::Exp(mean);
1326 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1327 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1329 delete [] ampWithBelow;
1333 if (returnVal==1) return rms;
1334 if (returnVal==2) return ncl;
1335 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1336 if (returnVal==4) return meanL;
1337 if (returnVal==5) return meanD;
1338 if (returnVal==6) return mean2;
1339 if (returnVal==7) return mean3;
1340 if (returnVal==8) return meanS;
1347 Float_t AliTPCseed::CookShape(Int_t type){
1351 //-----------------------------------------------------------------
1352 // This funtion calculates dE/dX within the "low" and "up" cuts.
1353 //-----------------------------------------------------------------
1356 for (Int_t i =0; i<160;i++) {
1357 AliTPCTrackerPoint * point = GetTrackPoint(i);
1358 if (point==0) continue;
1360 AliTPCclusterMI * cl = fClusterPointer[i];
1361 if (cl==0) continue;
1363 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1364 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1365 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1366 if (type==0) means+=rsigma;
1367 if (type==1) means+=rsigmay;
1368 if (type==2) means+=rsigmaz;
1371 Float_t mean = (meanc>0)? means/meanc:0;
1377 Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1380 // return value - number of used clusters
1383 const Int_t kMinNcl =10;
1384 AliTPCseed *track=new AliTPCseed(*seed);
1389 for (Int_t i=0;i<15;i++) covar[i]=0;
1392 covar[5]=10.*10./(64.*64.);
1393 covar[9]=10.*10./(64.*64.);
1397 Float_t xmin=1000, xmax=-10000;
1398 Int_t imin=158, imax=0;
1399 for (Int_t i=0;i<160;i++) {
1400 AliTPCclusterMI *c=track->GetClusterPointer(i);
1402 if (sector<0) sector = c->GetDetector();
1403 if (c->GetX()<xmin) xmin=c->GetX();
1404 if (c->GetX()>xmax) xmax=c->GetX();
1408 if(imax-imin<kMinNcl) {
1412 // Not succes to rotate
1413 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1419 // fit from inner to outer row
1421 AliExternalTrackParam paramIn;
1422 AliExternalTrackParam paramOut;
1428 for (Int_t i=imin; i<=imax; i++){
1429 AliTPCclusterMI *c=track->GetClusterPointer(i);
1431 // if (RejectCluster(c,track)) continue;
1432 sector = (c->GetDetector()%18);
1433 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1436 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1437 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1438 if (!track->PropagateTo(r[0])) {
1441 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1443 if (!isOK) { delete track; return 0;}
1444 track->AddCovariance(covar);
1448 for (Int_t i=imax; i>=imin; i--){
1449 AliTPCclusterMI *c=track->GetClusterPointer(i);
1451 //if (RejectCluster(c,track)) continue;
1452 sector = (c->GetDetector()%18);
1453 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1456 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1457 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1458 if (!track->PropagateTo(r[0])) {
1461 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1463 //if (!isOK) { delete track; return 0;}
1465 track->AddCovariance(covar);
1468 for (Int_t i=imin; i<=imax; i++){
1469 AliTPCclusterMI *c=track->GetClusterPointer(i);
1471 sector = (c->GetDetector()%18);
1472 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1476 //if (RejectCluster(c,track)) continue;
1477 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1478 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1479 if (!track->PropagateTo(r[0])) {
1482 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1484 //if (!isOK) { delete track; return 0;}
1489 if (parin) (*parin)=paramIn;
1490 if (parout) (*parout)=paramOut;
1497 Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1509 void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1510 Double_t& erry, Double_t &errz)
1513 // Get cluster error at given position
1515 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1517 Double_t snp1=param->GetSnp();
1518 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1520 Double_t tgl1=param->GetTgl();
1521 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1523 Int_t padSize = 0; // short pads
1524 if (cluster->GetDetector() >= 36) {
1525 padSize = 1; // medium pads
1526 if (cluster->GetRow() > 63) padSize = 2; // long pads
1529 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1530 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1534 void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1535 Double_t& rmsy, Double_t &rmsz)
1538 // Get cluster error at given position
1540 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1542 Double_t snp1=param->GetSnp();
1543 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1545 Double_t tgl1=param->GetTgl();
1546 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1548 Int_t padSize = 0; // short pads
1549 if (cluster->GetDetector() >= 36) {
1550 padSize = 1; // medium pads
1551 if (cluster->GetRow() > 63) padSize = 2; // long pads
1554 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1555 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1560 Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1562 //ty - tangent in local y direction
1565 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1569 Double_t AliTPCseed::GetQCorrShape(Int_t ipad, Int_t type,Float_t z, Float_t ty, Float_t tz, Float_t /*q*/, Float_t /*thr*/){
1573 // return value = Q Normalization factor
1574 // Normalization - 1 - shape factor part for full drift
1575 // 1 - electron attachment for 0 drift
1577 // Input parameters:
1579 // ipad - 0 short pad
1586 //z - z position (-250,250 cm)
1587 //ty - tangent in local y direction
1591 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1592 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1594 if (!paramCl) return 1;
1596 Double_t dr = 250.-TMath::Abs(z);
1597 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1598 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1599 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1600 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1602 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1605 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1606 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1609 if (type==0) return sfactorMax*attProb;