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++) {
83 fNCDEDXInclThres[i] = 0;
86 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
89 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
92 fClusterOwner(clusterOwner),
98 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
99 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
100 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
101 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
104 fCurrentCluster(0x0),
105 fCurrentClusterIndex1(-1),
117 //---------------------
118 // dummy copy constructor
119 //-------------------------
120 for (Int_t i=0;i<160;i++) {
121 fClusterPointer[i]=0;
123 if (s.fClusterPointer[i])
124 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
126 fClusterPointer[i] = s.fClusterPointer[i];
128 fTrackPoints[i] = s.fTrackPoints[i];
130 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
131 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
132 for (Int_t i=0;i<4;i++) {
133 fDEDX[i] = s.fDEDX[i];
134 fSDEDX[i] = s.fSDEDX[i];
135 fNCDEDX[i] = s.fNCDEDX[i];
136 fNCDEDXInclThres[i] = s.fNCDEDXInclThres[i];
138 fDEDX[4] = s.fDEDX[4];
139 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
144 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
147 fClusterOwner(kFALSE),
153 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
154 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
155 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
156 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
159 fCurrentCluster(0x0),
160 fCurrentClusterIndex1(-1),
173 // Constructor from AliTPCtrack
176 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
177 for (Int_t i=0;i<160;i++) {
178 fClusterPointer[i] = 0;
179 Int_t index = t.GetClusterIndex(i);
181 SetClusterIndex2(i,index);
184 SetClusterIndex2(i,-3);
187 for (Int_t i=0;i<4;i++) {
191 fNCDEDXInclThres[i] = 0;
194 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
197 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
198 const Double_t cc[15], Int_t index):
199 AliTPCtrack(xr, alpha, xx, cc, index),
201 fClusterOwner(kFALSE),
207 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
208 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
209 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
210 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
213 fCurrentCluster(0x0),
214 fCurrentClusterIndex1(-1),
230 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
231 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
232 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
233 for (Int_t i=0;i<4;i++) {
237 fNCDEDXInclThres[i] = 0;
240 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
243 AliTPCseed::~AliTPCseed(){
248 for (Int_t icluster=0; icluster<160; icluster++){
249 delete fClusterPointer[icluster];
254 //_________________________________________________
255 AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
258 // assignment operator
261 AliTPCtrack::operator=(param);
263 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
264 fClusterOwner = param.fClusterOwner;
265 // leave out fPoint, they are also not copied in the copy ctor...
266 // but deleted in the dtor... strange...
268 fSector = param.fSector;
269 fRelativeSector = param.fRelativeSector;
270 fCurrentSigmaY2 = param.fCurrentSigmaY2;
271 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
272 fErrorY2 = param.fErrorY2;
273 fErrorZ2 = param.fErrorZ2;
274 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
275 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
276 fInDead = param.fInDead;
277 fIsSeeding = param.fIsSeeding;
278 fNoCluster = param.fNoCluster;
280 fBSigned = param.fBSigned;
281 for(Int_t i = 0;i<4;++i){
282 fDEDX[i] = param.fDEDX[i];
283 fSDEDX[i] = param.fSDEDX[i];
284 fNCDEDX[i] = param.fNCDEDX[i];
285 fNCDEDXInclThres[i] = param.fNCDEDXInclThres[i];
287 fDEDX[4] = param.fDEDX[4];
288 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
290 fSeedType = param.fSeedType;
291 fSeed1 = param.fSeed1;
292 fSeed2 = param.fSeed2;
293 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
294 fMAngular = param.fMAngular;
295 fCircular = param.fCircular;
296 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
300 //____________________________________________________
301 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
305 return &fTrackPoints[i];
310 Double_t AliTPCseed::GetDensityFirst(Int_t n)
314 // return cluster for n rows bellow first point
315 Int_t nfoundable = 1;
317 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
318 Int_t index = GetClusterIndex2(i);
319 if (index!=-1) nfoundable++;
320 if (index>0) nfound++;
322 if (nfoundable<n) return 0;
323 return Double_t(nfound)/Double_t(nfoundable);
328 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
330 // get cluster stat. on given region
335 for (Int_t i=first;i<last; i++){
336 Int_t index = GetClusterIndex2(i);
337 if (index!=-1) foundable++;
338 if (index&0x8000) continue;
339 if (fClusterPointer[i]) {
345 if (fClusterPointer[i]->IsUsed(10)) {
349 if (!plus2) continue; //take also neighborhoud
351 if ( (i>0) && fClusterPointer[i-1]){
352 if (fClusterPointer[i-1]->IsUsed(10)) {
357 if ( fClusterPointer[i+1]){
358 if (fClusterPointer[i+1]->IsUsed(10)) {
366 //Error("AliTPCseed::GetClusterStatistic","problem\n");
374 void AliTPCseed::Reset(Bool_t all)
378 SetNumberOfClusters(0);
381 ResetCovariance(10.);
384 for (Int_t i=0;i<8;i++){
385 delete [] fTrackPoints[i];
393 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
394 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
400 void AliTPCseed::Modify(Double_t factor)
403 //------------------------------------------------------------------
404 //This function makes a track forget its history :)
405 //------------------------------------------------------------------
407 ResetCovariance(10.);
410 ResetCovariance(factor);
412 SetNumberOfClusters(0);
416 fCurrentSigmaY2 = 0.000005;
417 fCurrentSigmaZ2 = 0.000005;
426 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
428 //-----------------------------------------------------------------
429 // This function find proloncation of a track to a reference plane x=xk.
430 // doesn't change internal state of the track
431 //-----------------------------------------------------------------
433 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
435 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
439 // Double_t y1=fP0, z1=fP1;
440 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
441 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
445 //y += dx*(c1+c2)/(r1+r2);
446 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
448 Double_t dy = dx*(c1+c2)/(r1+r2);
451 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
453 if (TMath::Abs(delta)>0.0001){
454 dz = fP3*TMath::ASin(delta)/fP4;
456 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
459 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
460 dz = GetTgl()*TMath::ASin(delta)/GetC();
470 //_____________________________________________________________________________
471 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
473 //-----------------------------------------------------------------
474 // This function calculates a predicted chi2 increment.
475 //-----------------------------------------------------------------
476 Double_t p[2]={c->GetY(), c->GetZ()};
477 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
479 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
480 if (TMath::Abs(dx)>0){
481 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
483 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
487 return AliExternalTrackParam::GetPredictedChi2(p,cov);
490 //_________________________________________________________________________________________
493 Int_t AliTPCseed::Compare(const TObject *o) const {
494 //-----------------------------------------------------------------
495 // This function compares tracks according to the sector - for given sector according z
496 //-----------------------------------------------------------------
497 AliTPCseed *t=(AliTPCseed*)o;
500 if (t->fRelativeSector>fRelativeSector) return -1;
501 if (t->fRelativeSector<fRelativeSector) return 1;
502 Double_t z2 = t->GetZ();
503 Double_t z1 = GetZ();
505 if (z2<z1) return -1;
510 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
511 if (t->fBConstrain) f2=1.2;
514 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
516 if (fBConstrain) f1=1.2;
518 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
526 //_____________________________________________________________________________
527 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
529 //-----------------------------------------------------------------
530 // This function associates a cluster with this track.
531 //-----------------------------------------------------------------
532 Int_t n=GetNumberOfClusters();
533 Int_t idx=GetClusterIndex(n); // save the current cluster index
535 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
536 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
537 if (TMath::Abs(dx)>0){
538 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
540 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
541 cl.SetY(c->GetY()-dy);
542 cl.SetZ(c->GetZ()-dz);
545 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
547 if (fCMeanSigmaY2p30<0){
548 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
549 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
550 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
551 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
554 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
555 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
556 if (fCurrentSigmaY2>0){
557 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
558 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
562 SetClusterIndex(n,idx); // restore the current cluster index
568 //_____________________________________________________________________________
569 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
570 //-----------------------------------------------------------------
571 // This funtion calculates dE/dX within the "low" and "up" cuts.
572 //-----------------------------------------------------------------
573 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
574 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
576 Int_t row0 = param->GetNRowLow();
577 Int_t row1 = row0+param->GetNRowUp1();
578 Int_t row2 = row1+param->GetNRowUp2();
579 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
581 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
585 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
586 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
587 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
588 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
589 fDEDX[4] = CookdEdxAnalytical(low,up,useTot ,row0,row2, 0); // full OROC truncated mean
591 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
592 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
593 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
594 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
596 fNCDEDX[0] = TMath::Nint(GetTPCClustInfo(2, 1, i1 , i2));
597 fNCDEDX[1] = TMath::Nint(GetTPCClustInfo(2, 1, 0 , row0));
598 fNCDEDX[2] = TMath::Nint(GetTPCClustInfo(2, 1, row0, row1));
599 fNCDEDX[3] = TMath::Nint(GetTPCClustInfo(2, 1, row1, row2));
601 fNCDEDXInclThres[0] = TMath::Nint(GetTPCClustInfo(2, 2, i1 , i2));
602 fNCDEDXInclThres[1] = TMath::Nint(GetTPCClustInfo(2, 2, 0 , row0));
603 fNCDEDXInclThres[2] = TMath::Nint(GetTPCClustInfo(2, 2, row0, row1));
604 fNCDEDXInclThres[3] = TMath::Nint(GetTPCClustInfo(2, 2, row1, row2));
609 // return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
613 // Float_t angular[200];
614 // Float_t weight[200];
617 // Float_t meanlog = 100.;
619 // Float_t mean[4] = {0,0,0,0};
620 // Float_t sigma[4] = {1000,1000,1000,1000};
621 // Int_t nc[4] = {0,0,0,0};
622 // Float_t norm[4] = {1000,1000,1000,1000};
627 // Float_t gainGG = 1;
628 // if (AliTPCcalibDB::Instance()->GetParameters()){
629 // gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
633 // for (Int_t of =0; of<4; of++){
634 // for (Int_t i=of+i1;i<i2;i+=4)
636 // Int_t clindex = fIndex[i];
637 // if (clindex<0||clindex&0x8000) continue;
639 // //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
640 // AliTPCTrackerPoint * point = GetTrackPoint(i);
641 // //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
642 // //AliTPCTrackerPoint * pointp = 0;
643 // //if (i<159) pointp = GetTrackPoint(i+1);
645 // if (point==0) continue;
646 // AliTPCclusterMI * cl = fClusterPointer[i];
647 // if (cl==0) continue;
648 // if (onlyused && (!cl->IsUsed(10))) continue;
649 // if (cl->IsUsed(11)) {
653 // Int_t type = cl->GetType();
654 // //if (point->fIsShared){
659 // // if (pointm->fIsShared) continue;
661 // // if (pointp->fIsShared) continue;
663 // if (type<0) continue;
664 // //if (type>10) continue;
665 // //if (point->GetErrY()==0) continue;
666 // //if (point->GetErrZ()==0) continue;
668 // //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
669 // //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
670 // //if ((ddy*ddy+ddz*ddz)>10) continue;
673 // // if (point->GetCPoint().GetMax()<5) continue;
674 // if (cl->GetMax()<5) continue;
675 // Float_t angley = point->GetAngleY();
676 // Float_t anglez = point->GetAngleZ();
678 // Float_t rsigmay2 = point->GetSigmaY();
679 // Float_t rsigmaz2 = point->GetSigmaZ();
683 // rsigmay += pointm->GetTPoint().GetSigmaY();
684 // rsigmaz += pointm->GetTPoint().GetSigmaZ();
688 // rsigmay += pointp->GetTPoint().GetSigmaY();
689 // rsigmaz += pointp->GetTPoint().GetSigmaZ();
696 // Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
698 // Float_t ampc = 0; // normalization to the number of electrons
700 // // ampc = 1.*point->GetCPoint().GetMax();
701 // ampc = 1.*cl->GetMax();
702 // //ampc = 1.*point->GetCPoint().GetQ();
703 // // AliTPCClusterPoint & p = point->GetCPoint();
704 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
705 // // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
707 // // TMath::Abs( Int_t(iz) - iz + 0.5);
708 // //ampc *= 1.15*(1-0.3*dy);
709 // //ampc *= 1.15*(1-0.3*dz);
710 // // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
714 // //ampc = 1.0*point->GetCPoint().GetMax();
715 // ampc = 1.0*cl->GetMax();
716 // //ampc = 1.0*point->GetCPoint().GetQ();
717 // //AliTPCClusterPoint & p = point->GetCPoint();
718 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
719 // //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
721 // // TMath::Abs( Int_t(iz) - iz + 0.5);
723 // //ampc *= 1.15*(1-0.3*dy);
724 // //ampc *= 1.15*(1-0.3*dz);
725 // // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
729 // ampc *= 2.0; // put mean value to channel 50
730 // //ampc *= 0.58; // put mean value to channel 50
732 // // if (type>0) w = 1./(type/2.-0.5);
733 // // Float_t z = TMath::Abs(cl->GetZ());
736 // //ampc /= (1+0.0008*z);
740 // //ampc /= (1+0.0008*z);
742 // //ampc /= (1+0.0008*z);
745 // if (type<0) { //amp at the border - lower weight
750 // if (rsigma>1.5) ampc/=1.3; // if big backround
751 // amp[nc[of]] = ampc;
752 // amp[nc[of]] /=gainGG;
753 // angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
754 // weight[nc[of]] = w;
758 // TMath::Sort(nc[of],amp,index,kFALSE);
760 // Float_t sumamp2=0;
762 // //meanlog = amp[index[Int_t(nc[of]*0.33)]];
764 // for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
765 // Float_t ampl = amp[index[i]]/angular[index[i]];
766 // ampl = meanlog*TMath::Log(1.+ampl/meanlog);
768 // sumw += weight[index[i]];
769 // sumamp += weight[index[i]]*ampl;
770 // sumamp2 += weight[index[i]]*ampl*ampl;
771 // norm[of] += angular[index[i]]*weight[index[i]];
778 // mean[of] = sumamp/sumw;
779 // sigma[of] = sumamp2/sumw-mean[of]*mean[of];
780 // if (sigma[of]>0.1)
781 // sigma[of] = TMath::Sqrt(sigma[of]);
785 // mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
786 // //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
787 // //mean *=(1-0.1*(norm-1.));
794 // // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
795 // // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
798 // // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
799 // // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
803 // for (Int_t i =0;i<4;i++){
804 // if (nc[i]>2&&nc[i]<1000){
805 // dedx += mean[i] *nc[i];
806 // fSdEdx += sigma[i]*(nc[i]-2);
807 // fMAngular += norm[i] *nc[i];
811 // fDEDX[i] = mean[i];
812 // fSDEDX[i] = sigma[i];
813 // fNCDEDX[i]= nc[i];
825 // // Float_t dedx1 =dedx;
828 // for (Int_t i =0;i<4;i++){
829 // if (nc[i]>2&&nc[i]<1000){
830 // mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
831 // dedx += mean[i] *nc[i];
833 // fDEDX[i] = mean[i];
843 void AliTPCseed::CookPID()
846 // cook PID information according dEdx
848 Double_t fRange = 10.;
852 Int_t ns=AliPID::kSPECIES;
854 for (Int_t j=0; j<ns; j++) {
855 Double_t mass=AliPID::ParticleMass(j);
857 Double_t dedx=fdEdx/fMIP;
858 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
859 Double_t sigma=fRes*bethe;
861 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
862 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
866 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
874 for (Int_t j=0; j<ns; j++) {
875 fTPCr[j]/=sumr; //normalize
879 Double_t AliTPCseed::GetYat(Double_t xk) const {
880 //-----------------------------------------------------------------
881 // This function calculates the Y-coordinate of a track at the plane x=xk.
882 //-----------------------------------------------------------------
883 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
884 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
885 Double_t c2=c1+GetC()*(xk-GetX());
886 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
887 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
888 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
893 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){
896 // calculates dedx using the cluster
897 // low - up specify trunc mean range - default form 0-0.7
898 // type - 1 - max charge or 0- total charge in cluster
899 // //2- max no corr 3- total+ correction
900 // i1-i2 - the pad-row range used for calculation
901 // shapeNorm - kTRUE -taken from OCDB
903 // posNorm - usage of pos normalization
904 // padNorm - pad type normalization
905 // returnVal - 0 return mean
907 // - 2 return number of clusters
909 // normalization parametrization taken from AliTPCClusterParam
911 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
912 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
913 if (!parcl) return 0;
914 if (!param) return 0;
915 Int_t row0 = param->GetNRowLow();
916 Int_t row1 = row0+param->GetNRowUp1();
923 Float_t gainGG = 1; // gas gain factor -always enabled
924 Float_t gainPad = 1; // gain map - used always
925 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
926 Float_t corrPos = 1; // local position correction - if posNorm enabled
927 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
928 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
932 if (AliTPCcalibDB::Instance()->GetParameters()){
933 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
936 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
937 const Float_t kedgey =3.;
940 for (Int_t irow=i1; irow<i2; irow++){
941 AliTPCclusterMI* cluster = GetClusterPointer(irow);
942 if (!cluster) continue;
943 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
944 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
946 if (irow>=row0) ipad=1;
947 if (irow>=row1) ipad=2;
951 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
954 // Get gainPad - pad by pad calibration
957 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
958 if (irow < row0) { // IROC
959 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
961 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
963 if (factor>0.5) gainPad=factor;
966 //do position and angular normalization
971 AliTPCTrackerPoint * point = GetTrackPoint(irow);
972 Float_t ty = TMath::Abs(point->GetAngleY());
973 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
975 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
976 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
982 // Do position normalization - relative distance to
983 // center of pad- time bin
985 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
986 // cluster->GetTimeBin(), cluster->GetZ(),
987 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
988 // cluster->GetMax(),cluster->GetQ());
989 // scaled response function
990 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
991 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
994 AliTPCTrackerPoint * point = GetTrackPoint(irow);
995 Float_t ty = TMath::Abs(point->GetAngleY());
996 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
998 if (type==1) corrPos =
999 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1000 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
1001 if (type==0) corrPos =
1002 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1003 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1005 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1006 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1007 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1008 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1009 if (corrHis>0) corrPos*=corrHis;
1016 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1017 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
1021 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1022 //use hardwired - temp fix
1023 if (type==0) corrNorm=3.;
1024 if (type==1) corrNorm=1.;
1030 amp[ncl]/=corrShape;
1031 amp[ncl]/=corrPadType;
1038 if (type>3) return ncl;
1039 TMath::Sort(ncl,amp, indexes, kFALSE);
1041 if (ncl<10) return 0;
1046 Int_t icl0=TMath::Nint(ncl*low);
1047 Int_t icl1=TMath::Nint(ncl*up);
1048 for (Int_t icl=icl0; icl<icl1;icl++){
1049 suma+=amp[indexes[icl]];
1050 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1053 Float_t mean =suma/sumn;
1054 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1056 // do time-dependent correction for pressure and temperature variations
1057 UInt_t runNumber = 1;
1058 Float_t corrTimeGain = 1;
1059 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1060 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1061 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
1062 runNumber = trans->GetCurrentRunNumber();
1063 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1064 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1065 if (timeGainSplines) {
1066 UInt_t time = trans->GetCurrentTimeStamp();
1067 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1068 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1070 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
1072 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
1076 mean /= corrTimeGain;
1077 rms /= corrTimeGain;
1079 if (returnVal==1) return rms;
1080 if (returnVal==2) return ncl;
1084 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){
1087 // calculates dedx using the cluster
1088 // low - up specify trunc mean range - default form 0-0.7
1089 // type - 1 - max charge or 0- total charge in cluster
1090 // //2- max no corr 3- total+ correction
1091 // i1-i2 - the pad-row range used for calculation
1093 // posNorm - usage of pos normalization
1094 // returnVal - 0 return mean
1096 // - 2 return number of clusters
1098 // - 4 mean upper half
1099 // - 5 mean - lower half
1101 // mode - 0 - linear
1102 // - 1 - logatithmic
1103 // rowThres - number of rows before and after given pad row to check for clusters below threshold
1105 // normalization parametrization taken from AliTPCClusterParam
1107 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1108 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1109 if (!parcl) return 0;
1110 if (!param) return 0;
1111 Int_t row0 = param->GetNRowLow();
1112 Int_t row1 = row0+param->GetNRowUp1();
1117 Int_t nclBelowThr = 0; // counts number of clusters below threshold
1120 Float_t gainGG = 1; // gas gain factor -always enabled
1121 Float_t gainPad = 1; // gain map - used always
1122 Float_t corrPos = 1; // local position correction - if posNorm enabled
1126 if (AliTPCcalibDB::Instance()->GetParameters()){
1127 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1130 // extract time-dependent correction for pressure and temperature variations
1132 UInt_t runNumber = 1;
1133 Float_t corrTimeGain = 1;
1134 TObjArray * timeGainSplines = 0x0;
1135 TGraphErrors * grPadEqual = 0x0;
1137 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1138 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1140 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1143 runNumber = trans->GetCurrentRunNumber();
1144 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1145 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1146 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1147 UInt_t time = trans->GetCurrentTimeStamp();
1148 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1149 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1151 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
1153 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1156 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1157 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
1161 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1162 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1163 const Float_t kedgey =3.;
1166 for (Int_t irow=i1; irow<i2; irow++){
1167 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1168 if (!cluster && irow > 1 && irow < 157) {
1169 Bool_t isClBefore = kFALSE;
1170 Bool_t isClAfter = kFALSE;
1171 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1172 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1173 if (clusterBefore) isClBefore = kTRUE;
1174 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1175 if (clusterAfter) isClAfter = kTRUE;
1177 if (isClBefore && isClAfter) nclBelowThr++;
1179 if (!cluster) continue;
1182 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1184 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1185 if (point==0) continue;
1186 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1187 if (rsigmay > kClusterShapeCut) continue;
1189 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1191 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1193 if (irow>=row0) ipad=1;
1194 if (irow>=row1) ipad=2;
1198 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1201 // Get gainPad - pad by pad calibration
1204 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1205 if (irow < row0) { // IROC
1206 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1208 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1210 if (factor>0.3) gainPad=factor;
1213 // Do position normalization - relative distance to
1214 // center of pad- time bin
1216 Float_t ty = TMath::Abs(point->GetAngleY());
1217 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1218 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1219 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1221 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1222 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1223 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1224 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1227 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1228 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1229 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1230 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1231 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1232 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1233 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1237 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1238 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1239 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1241 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1242 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1243 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1244 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1248 // pad region equalization outside of cluster param
1250 Float_t gainEqualPadRegion = 1;
1251 if (grPadEqual) gainEqualPadRegion = grPadEqual->Eval(ipad);
1257 amp[ncl]/=gainEqualPadRegion;
1262 if (type==2) return ncl;
1263 TMath::Sort(ncl,amp, indexes, kFALSE);
1265 if (ncl<10) return 0;
1267 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1268 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1269 if (iCl < nclBelowThr) {
1270 ampWithBelow[iCl] = amp[indexes[0]];
1272 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1275 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1282 // upper,and lower part statistic
1283 Float_t sumL=0, sumL2=0, sumLN=0;
1284 Float_t sumD=0, sumD2=0, sumDN=0;
1286 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1287 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
1288 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1290 for (Int_t icl=icl0; icl<icl1;icl++){
1291 if (ampWithBelow[icl]<0.1) continue;
1292 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1293 if (mode==1) camp= TMath::Log(camp);
1297 suma3+=camp*camp*camp;
1298 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
1315 Float_t meanD = 0; // lower half mean
1316 if (sumn > 1e-30) mean =suma/sumn;
1317 if (sumLN > 1e-30) meanL =sumL/sumLN;
1318 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1320 Float_t mean =suma/sumn;
1321 Float_t meanL = sumL/sumLN;
1322 Float_t meanD =(sumD/sumDN); // lower half mean
1331 rms = TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1337 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1338 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1339 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
1341 if (mode==1) mean=TMath::Exp(mean);
1342 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1343 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1345 delete [] ampWithBelow;
1349 if (returnVal==1) return rms;
1350 if (returnVal==2) return ncl;
1351 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1352 if (returnVal==4) return meanL;
1353 if (returnVal==5) return meanD;
1354 if (returnVal==6) return mean2;
1355 if (returnVal==7) return mean3;
1356 if (returnVal==8) return meanS;
1363 Float_t AliTPCseed::CookShape(Int_t type){
1367 //-----------------------------------------------------------------
1368 // This funtion calculates dE/dX within the "low" and "up" cuts.
1369 //-----------------------------------------------------------------
1372 for (Int_t i =0; i<160;i++) {
1373 AliTPCTrackerPoint * point = GetTrackPoint(i);
1374 if (point==0) continue;
1376 AliTPCclusterMI * cl = fClusterPointer[i];
1377 if (cl==0) continue;
1379 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1380 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1381 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1382 if (type==0) means+=rsigma;
1383 if (type==1) means+=rsigmay;
1384 if (type==2) means+=rsigmaz;
1387 Float_t mean = (meanc>0)? means/meanc:0;
1393 Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1396 // return value - number of used clusters
1399 const Int_t kMinNcl =10;
1400 AliTPCseed *track=new AliTPCseed(*seed);
1405 for (Int_t i=0;i<15;i++) covar[i]=0;
1408 covar[5]=10.*10./(64.*64.);
1409 covar[9]=10.*10./(64.*64.);
1413 Float_t xmin=1000, xmax=-10000;
1414 Int_t imin=158, imax=0;
1415 for (Int_t i=0;i<160;i++) {
1416 AliTPCclusterMI *c=track->GetClusterPointer(i);
1418 if (sector<0) sector = c->GetDetector();
1419 if (c->GetX()<xmin) xmin=c->GetX();
1420 if (c->GetX()>xmax) xmax=c->GetX();
1424 if(imax-imin<kMinNcl) {
1428 // Not succes to rotate
1429 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1435 // fit from inner to outer row
1437 AliExternalTrackParam paramIn;
1438 AliExternalTrackParam paramOut;
1444 for (Int_t i=imin; i<=imax; i++){
1445 AliTPCclusterMI *c=track->GetClusterPointer(i);
1447 // if (RejectCluster(c,track)) continue;
1448 sector = (c->GetDetector()%18);
1449 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1452 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1453 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1454 if (!track->PropagateTo(r[0])) {
1457 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1459 if (!isOK) { delete track; return 0;}
1460 track->AddCovariance(covar);
1464 for (Int_t i=imax; i>=imin; i--){
1465 AliTPCclusterMI *c=track->GetClusterPointer(i);
1467 //if (RejectCluster(c,track)) continue;
1468 sector = (c->GetDetector()%18);
1469 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1472 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1473 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1474 if (!track->PropagateTo(r[0])) {
1477 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1479 //if (!isOK) { delete track; return 0;}
1481 track->AddCovariance(covar);
1484 for (Int_t i=imin; i<=imax; i++){
1485 AliTPCclusterMI *c=track->GetClusterPointer(i);
1487 sector = (c->GetDetector()%18);
1488 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1492 //if (RejectCluster(c,track)) continue;
1493 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1494 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1495 if (!track->PropagateTo(r[0])) {
1498 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1500 //if (!isOK) { delete track; return 0;}
1505 if (parin) (*parin)=paramIn;
1506 if (parout) (*parout)=paramOut;
1513 Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1525 void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1526 Double_t& erry, Double_t &errz)
1529 // Get cluster error at given position
1531 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1533 Double_t snp1=param->GetSnp();
1534 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1536 Double_t tgl1=param->GetTgl();
1537 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1539 Int_t padSize = 0; // short pads
1540 if (cluster->GetDetector() >= 36) {
1541 padSize = 1; // medium pads
1542 if (cluster->GetRow() > 63) padSize = 2; // long pads
1545 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1546 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1550 void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1551 Double_t& rmsy, Double_t &rmsz)
1554 // Get cluster error at given position
1556 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1558 Double_t snp1=param->GetSnp();
1559 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1561 Double_t tgl1=param->GetTgl();
1562 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1564 Int_t padSize = 0; // short pads
1565 if (cluster->GetDetector() >= 36) {
1566 padSize = 1; // medium pads
1567 if (cluster->GetRow() > 63) padSize = 2; // long pads
1570 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1571 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1576 Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1578 //ty - tangent in local y direction
1581 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1585 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*/){
1589 // return value = Q Normalization factor
1590 // Normalization - 1 - shape factor part for full drift
1591 // 1 - electron attachment for 0 drift
1593 // Input parameters:
1595 // ipad - 0 short pad
1602 //z - z position (-250,250 cm)
1603 //ty - tangent in local y direction
1607 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1608 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1610 if (!paramCl) return 1;
1612 Double_t dr = 250.-TMath::Abs(z);
1613 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1614 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1615 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1616 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1618 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1621 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1622 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1625 if (type==0) return sfactorMax*attProb;
1633 //_______________________________________________________________________
1634 Float_t AliTPCseed::GetTPCClustInfo(Int_t nNeighbours, Int_t type, Int_t row0, Int_t row1)
1637 // TPC cluster information
1638 // type 0: get fraction of found/findable clusters with neighbourhood definition
1639 // 1: found clusters
1640 // 2: findable (number of clusters above and below threshold)
1642 // definition of findable clusters:
1643 // a cluster is defined as findable if there is another cluster
1644 // within +- nNeighbours pad rows. The idea is to overcome threshold
1645 // effects with a very simple algorithm.
1648 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1649 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1650 const Float_t kedgey =3.;
1653 Float_t nclBelowThr = 0; // counts number of clusters below threshold
1655 for (Int_t irow=row0; irow<row1; irow++){
1656 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1658 if (!cluster && irow > 1 && irow < 157) {
1659 Bool_t isClBefore = kFALSE;
1660 Bool_t isClAfter = kFALSE;
1661 for(Int_t ithres = 1; ithres <= nNeighbours; ithres++) {
1662 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1663 if (clusterBefore) isClBefore = kTRUE;
1664 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1665 if (clusterAfter) isClAfter = kTRUE;
1667 if (isClBefore && isClAfter) nclBelowThr++;
1669 if (!cluster) continue;
1672 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1674 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1675 if (point==0) continue;
1676 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1677 if (rsigmay > kClusterShapeCut) continue;
1679 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1686 if(nclBelowThr+ncl>0)
1687 return ncl/(nclBelowThr+ncl);
1691 return ncl+nclBelowThr;