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 //-----------------------------------------------------------------
20 // Implementation of the TPC seed class
21 // This class is used by the AliTPCtrackerMI class
22 // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
23 //-----------------------------------------------------------------
24 #include "TClonesArray.h"
25 #include "TGraphErrors.h"
26 #include "AliTPCseed.h"
27 #include "AliTPCReconstructor.h"
28 #include "AliTPCClusterParam.h"
29 #include "AliTPCCalPad.h"
30 #include "AliTPCCalROC.h"
31 #include "AliTPCcalibDB.h"
32 #include "AliTPCParam.h"
33 #include "AliMathBase.h"
34 #include "AliTPCTransform.h"
35 #include "AliSplineFit.h"
36 #include "AliCDBManager.h"
37 #include "AliTPCcalibDButil.h"
44 AliTPCseed::AliTPCseed():
47 fClusterOwner(kFALSE),
51 fCurrentSigmaY2(1e10),
52 fCurrentSigmaZ2(1e10),
53 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
54 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
55 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
56 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
61 fCurrentClusterIndex1(-1),
76 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
77 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
78 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
79 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
80 for (Int_t i=0;i<4;i++) {
85 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
86 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
87 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
88 fClusterMap.ResetAllBits(kFALSE);
89 fSharedMap.ResetAllBits(kFALSE);
93 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
96 fClusterOwner(clusterOwner),
102 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
103 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
104 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
105 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
108 fCurrentCluster(0x0),
109 fCurrentClusterIndex1(-1),
120 fClusterMap(s.fClusterMap),
121 fSharedMap(s.fSharedMap)
123 //---------------------
124 // dummy copy constructor
125 //-------------------------
126 for (Int_t i=0;i<160;i++) {
127 fClusterPointer[i]=0;
129 if (s.fClusterPointer[i])
130 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
132 fClusterPointer[i] = s.fClusterPointer[i];
134 fTrackPoints[i] = s.fTrackPoints[i];
136 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
137 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
138 for (Int_t i=0;i<4;i++) {
139 fDEDX[i] = s.fDEDX[i];
140 fSDEDX[i] = s.fSDEDX[i];
141 fNCDEDX[i] = s.fNCDEDX[i];
143 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
148 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
151 fClusterOwner(kFALSE),
157 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
158 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
159 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
160 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
163 fCurrentCluster(0x0),
164 fCurrentClusterIndex1(-1),
179 // Constructor from AliTPCtrack
182 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
183 for (Int_t i=0;i<160;i++) {
184 fClusterPointer[i] = 0;
185 Int_t index = t.GetClusterIndex(i);
187 SetClusterIndex2(i,index);
190 SetClusterIndex2(i,-3);
193 for (Int_t i=0;i<4;i++) {
198 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
200 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
201 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
202 fClusterMap.ResetAllBits(kFALSE);
203 fSharedMap.ResetAllBits(kFALSE);
207 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
208 const Double_t cc[15], Int_t index):
209 AliTPCtrack(xr, alpha, xx, cc, index),
211 fClusterOwner(kFALSE),
217 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
218 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
219 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
220 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
223 fCurrentCluster(0x0),
224 fCurrentClusterIndex1(-1),
242 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
243 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
244 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
245 for (Int_t i=0;i<4;i++) {
250 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
253 AliTPCseed::~AliTPCseed(){
258 for (Int_t icluster=0; icluster<160; icluster++){
259 delete fClusterPointer[icluster];
264 //_________________________________________________
265 AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
268 // assignment operator
271 AliTPCtrack::operator=(param);
273 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
274 fClusterOwner = param.fClusterOwner;
275 // leave out fPoint, they are also not copied in the copy ctor...
276 // but deleted in the dtor... strange...
278 fSector = param.fSector;
279 fRelativeSector = param.fRelativeSector;
280 fCurrentSigmaY2 = param.fCurrentSigmaY2;
281 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
282 fErrorY2 = param.fErrorY2;
283 fErrorZ2 = param.fErrorZ2;
284 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
285 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
286 fInDead = param.fInDead;
287 fIsSeeding = param.fIsSeeding;
288 fNoCluster = param.fNoCluster;
290 fBSigned = param.fBSigned;
291 for(Int_t i = 0;i<4;++i){
292 fDEDX[i] = param.fDEDX[i];
293 fSDEDX[i] = param.fSDEDX[i];
294 fNCDEDX[i] = param.fNCDEDX[i];
296 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
298 fSeedType = param.fSeedType;
299 fSeed1 = param.fSeed1;
300 fSeed2 = param.fSeed2;
301 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
302 fMAngular = param.fMAngular;
303 fCircular = param.fCircular;
304 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
305 fClusterMap = param.fClusterMap;
306 fSharedMap = param.fSharedMap;
310 //____________________________________________________
311 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
315 return &fTrackPoints[i];
320 Double_t AliTPCseed::GetDensityFirst(Int_t n)
324 // return cluster for n rows bellow first point
325 Int_t nfoundable = 1;
327 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
328 Int_t index = GetClusterIndex2(i);
329 if (index!=-1) nfoundable++;
330 if (index>0) nfound++;
332 if (nfoundable<n) return 0;
333 return Double_t(nfound)/Double_t(nfoundable);
338 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
340 // get cluster stat. on given region
345 for (Int_t i=first;i<last; i++){
346 Int_t index = GetClusterIndex2(i);
347 if (index!=-1) foundable++;
348 if (index&0x8000) continue;
349 if (fClusterPointer[i]) {
355 if (fClusterPointer[i]->IsUsed(10)) {
359 if (!plus2) continue; //take also neighborhoud
361 if ( (i>0) && fClusterPointer[i-1]){
362 if (fClusterPointer[i-1]->IsUsed(10)) {
367 if ( fClusterPointer[i+1]){
368 if (fClusterPointer[i+1]->IsUsed(10)) {
376 //Error("AliTPCseed::GetClusterStatistic","problem\n");
384 void AliTPCseed::Reset(Bool_t all)
388 SetNumberOfClusters(0);
391 ResetCovariance(10.);
394 for (Int_t i=0;i<8;i++){
395 delete [] fTrackPoints[i];
403 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
404 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
410 void AliTPCseed::Modify(Double_t factor)
413 //------------------------------------------------------------------
414 //This function makes a track forget its history :)
415 //------------------------------------------------------------------
417 ResetCovariance(10.);
420 ResetCovariance(factor);
422 SetNumberOfClusters(0);
426 fCurrentSigmaY2 = 0.000005;
427 fCurrentSigmaZ2 = 0.000005;
436 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
438 //-----------------------------------------------------------------
439 // This function find proloncation of a track to a reference plane x=xk.
440 // doesn't change internal state of the track
441 //-----------------------------------------------------------------
443 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
445 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
449 // Double_t y1=fP0, z1=fP1;
450 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
451 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
455 //y += dx*(c1+c2)/(r1+r2);
456 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
458 Double_t dy = dx*(c1+c2)/(r1+r2);
461 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
463 if (TMath::Abs(delta)>0.0001){
464 dz = fP3*TMath::ASin(delta)/fP4;
466 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
469 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
470 dz = GetTgl()*TMath::ASin(delta)/GetC();
480 //_____________________________________________________________________________
481 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
483 //-----------------------------------------------------------------
484 // This function calculates a predicted chi2 increment.
485 //-----------------------------------------------------------------
486 Double_t p[2]={c->GetY(), c->GetZ()};
487 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
489 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
490 if (TMath::Abs(dx)>0){
491 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
493 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
497 return AliExternalTrackParam::GetPredictedChi2(p,cov);
500 //_________________________________________________________________________________________
503 Int_t AliTPCseed::Compare(const TObject *o) const {
504 //-----------------------------------------------------------------
505 // This function compares tracks according to the sector - for given sector according z
506 //-----------------------------------------------------------------
507 AliTPCseed *t=(AliTPCseed*)o;
510 if (t->fRelativeSector>fRelativeSector) return -1;
511 if (t->fRelativeSector<fRelativeSector) return 1;
512 Double_t z2 = t->GetZ();
513 Double_t z1 = GetZ();
515 if (z2<z1) return -1;
520 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
521 if (t->fBConstrain) f2=1.2;
524 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
526 if (fBConstrain) f1=1.2;
528 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
536 //_____________________________________________________________________________
537 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
539 //-----------------------------------------------------------------
540 // This function associates a cluster with this track.
541 //-----------------------------------------------------------------
542 Int_t n=GetNumberOfClusters();
543 Int_t idx=GetClusterIndex(n); // save the current cluster index
545 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
546 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
547 if (TMath::Abs(dx)>0){
548 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
550 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
551 cl.SetY(c->GetY()-dy);
552 cl.SetZ(c->GetZ()-dz);
555 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
557 if (fCMeanSigmaY2p30<0){
558 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
559 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
560 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
561 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
564 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
565 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
566 if (fCurrentSigmaY2>0){
567 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
568 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
572 SetClusterIndex(n,idx); // restore the current cluster index
578 //_____________________________________________________________________________
579 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
580 //-----------------------------------------------------------------
581 // This funtion calculates dE/dX within the "low" and "up" cuts.
582 //-----------------------------------------------------------------
583 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
584 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
586 Int_t row0 = param->GetNRowLow();
587 Int_t row1 = row0+param->GetNRowUp1();
588 Int_t row2 = row1+param->GetNRowUp2();
589 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
591 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
595 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
596 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
597 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
598 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
600 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
601 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
602 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
603 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
605 fNCDEDX[0] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 2));
606 fNCDEDX[1] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,0 ,row0, 2));
607 fNCDEDX[2] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,row0,row1, 2));
608 fNCDEDX[3] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,row1,row2, 2));
613 // return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
617 // Float_t angular[200];
618 // Float_t weight[200];
621 // Float_t meanlog = 100.;
623 // Float_t mean[4] = {0,0,0,0};
624 // Float_t sigma[4] = {1000,1000,1000,1000};
625 // Int_t nc[4] = {0,0,0,0};
626 // Float_t norm[4] = {1000,1000,1000,1000};
631 // Float_t gainGG = 1;
632 // if (AliTPCcalibDB::Instance()->GetParameters()){
633 // gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
637 // for (Int_t of =0; of<4; of++){
638 // for (Int_t i=of+i1;i<i2;i+=4)
640 // Int_t clindex = fIndex[i];
641 // if (clindex<0||clindex&0x8000) continue;
643 // //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
644 // AliTPCTrackerPoint * point = GetTrackPoint(i);
645 // //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
646 // //AliTPCTrackerPoint * pointp = 0;
647 // //if (i<159) pointp = GetTrackPoint(i+1);
649 // if (point==0) continue;
650 // AliTPCclusterMI * cl = fClusterPointer[i];
651 // if (cl==0) continue;
652 // if (onlyused && (!cl->IsUsed(10))) continue;
653 // if (cl->IsUsed(11)) {
657 // Int_t type = cl->GetType();
658 // //if (point->fIsShared){
663 // // if (pointm->fIsShared) continue;
665 // // if (pointp->fIsShared) continue;
667 // if (type<0) continue;
668 // //if (type>10) continue;
669 // //if (point->GetErrY()==0) continue;
670 // //if (point->GetErrZ()==0) continue;
672 // //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
673 // //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
674 // //if ((ddy*ddy+ddz*ddz)>10) continue;
677 // // if (point->GetCPoint().GetMax()<5) continue;
678 // if (cl->GetMax()<5) continue;
679 // Float_t angley = point->GetAngleY();
680 // Float_t anglez = point->GetAngleZ();
682 // Float_t rsigmay2 = point->GetSigmaY();
683 // Float_t rsigmaz2 = point->GetSigmaZ();
687 // rsigmay += pointm->GetTPoint().GetSigmaY();
688 // rsigmaz += pointm->GetTPoint().GetSigmaZ();
692 // rsigmay += pointp->GetTPoint().GetSigmaY();
693 // rsigmaz += pointp->GetTPoint().GetSigmaZ();
700 // Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
702 // Float_t ampc = 0; // normalization to the number of electrons
704 // // ampc = 1.*point->GetCPoint().GetMax();
705 // ampc = 1.*cl->GetMax();
706 // //ampc = 1.*point->GetCPoint().GetQ();
707 // // AliTPCClusterPoint & p = point->GetCPoint();
708 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
709 // // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
711 // // TMath::Abs( Int_t(iz) - iz + 0.5);
712 // //ampc *= 1.15*(1-0.3*dy);
713 // //ampc *= 1.15*(1-0.3*dz);
714 // // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
718 // //ampc = 1.0*point->GetCPoint().GetMax();
719 // ampc = 1.0*cl->GetMax();
720 // //ampc = 1.0*point->GetCPoint().GetQ();
721 // //AliTPCClusterPoint & p = point->GetCPoint();
722 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
723 // //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
725 // // TMath::Abs( Int_t(iz) - iz + 0.5);
727 // //ampc *= 1.15*(1-0.3*dy);
728 // //ampc *= 1.15*(1-0.3*dz);
729 // // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
733 // ampc *= 2.0; // put mean value to channel 50
734 // //ampc *= 0.58; // put mean value to channel 50
736 // // if (type>0) w = 1./(type/2.-0.5);
737 // // Float_t z = TMath::Abs(cl->GetZ());
740 // //ampc /= (1+0.0008*z);
744 // //ampc /= (1+0.0008*z);
746 // //ampc /= (1+0.0008*z);
749 // if (type<0) { //amp at the border - lower weight
754 // if (rsigma>1.5) ampc/=1.3; // if big backround
755 // amp[nc[of]] = ampc;
756 // amp[nc[of]] /=gainGG;
757 // angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
758 // weight[nc[of]] = w;
762 // TMath::Sort(nc[of],amp,index,kFALSE);
764 // Float_t sumamp2=0;
766 // //meanlog = amp[index[Int_t(nc[of]*0.33)]];
768 // for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
769 // Float_t ampl = amp[index[i]]/angular[index[i]];
770 // ampl = meanlog*TMath::Log(1.+ampl/meanlog);
772 // sumw += weight[index[i]];
773 // sumamp += weight[index[i]]*ampl;
774 // sumamp2 += weight[index[i]]*ampl*ampl;
775 // norm[of] += angular[index[i]]*weight[index[i]];
782 // mean[of] = sumamp/sumw;
783 // sigma[of] = sumamp2/sumw-mean[of]*mean[of];
784 // if (sigma[of]>0.1)
785 // sigma[of] = TMath::Sqrt(sigma[of]);
789 // mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
790 // //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
791 // //mean *=(1-0.1*(norm-1.));
798 // // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
799 // // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
802 // // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
803 // // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
807 // for (Int_t i =0;i<4;i++){
808 // if (nc[i]>2&&nc[i]<1000){
809 // dedx += mean[i] *nc[i];
810 // fSdEdx += sigma[i]*(nc[i]-2);
811 // fMAngular += norm[i] *nc[i];
815 // fDEDX[i] = mean[i];
816 // fSDEDX[i] = sigma[i];
817 // fNCDEDX[i]= nc[i];
829 // // Float_t dedx1 =dedx;
832 // for (Int_t i =0;i<4;i++){
833 // if (nc[i]>2&&nc[i]<1000){
834 // mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
835 // dedx += mean[i] *nc[i];
837 // fDEDX[i] = mean[i];
847 void AliTPCseed::CookPID()
850 // cook PID information according dEdx
852 Double_t fRange = 10.;
856 Int_t ns=AliPID::kSPECIES;
858 for (Int_t j=0; j<ns; j++) {
859 Double_t mass=AliPID::ParticleMass(j);
861 Double_t dedx=fdEdx/fMIP;
862 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
863 Double_t sigma=fRes*bethe;
865 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
866 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
870 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
878 for (Int_t j=0; j<ns; j++) {
879 fTPCr[j]/=sumr; //normalize
883 Double_t AliTPCseed::GetYat(Double_t xk) const {
884 //-----------------------------------------------------------------
885 // This function calculates the Y-coordinate of a track at the plane x=xk.
886 //-----------------------------------------------------------------
887 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
888 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
889 Double_t c2=c1+GetC()*(xk-GetX());
890 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
891 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
892 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
895 void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
897 fClusterMap[ibit] = state;
899 Bool_t AliTPCseed::GetClusterMapBit(int ibit)
901 return fClusterMap[ibit];
903 void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
905 fSharedMap[ibit] = state;
907 Bool_t AliTPCseed::GetSharedMapBit(int ibit)
909 return fSharedMap[ibit];
916 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){
919 // calculates dedx using the cluster
920 // low - up specify trunc mean range - default form 0-0.7
921 // type - 1 - max charge or 0- total charge in cluster
922 // //2- max no corr 3- total+ correction
923 // i1-i2 - the pad-row range used for calculation
924 // shapeNorm - kTRUE -taken from OCDB
926 // posNorm - usage of pos normalization
927 // padNorm - pad type normalization
928 // returnVal - 0 return mean
930 // - 2 return number of clusters
932 // normalization parametrization taken from AliTPCClusterParam
934 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
935 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
936 if (!parcl) return 0;
937 if (!param) return 0;
938 Int_t row0 = param->GetNRowLow();
939 Int_t row1 = row0+param->GetNRowUp1();
946 Float_t gainGG = 1; // gas gain factor -always enabled
947 Float_t gainPad = 1; // gain map - used always
948 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
949 Float_t corrPos = 1; // local position correction - if posNorm enabled
950 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
951 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
955 if (AliTPCcalibDB::Instance()->GetParameters()){
956 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
959 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
960 const Float_t kedgey =3.;
963 for (Int_t irow=i1; irow<i2; irow++){
964 AliTPCclusterMI* cluster = GetClusterPointer(irow);
965 if (!cluster) continue;
966 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
967 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
969 if (irow>=row0) ipad=1;
970 if (irow>=row1) ipad=2;
974 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
977 // Get gainPad - pad by pad calibration
980 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
981 if (irow < row0) { // IROC
982 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
984 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
986 if (factor>0.5) gainPad=factor;
989 //do position and angular normalization
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 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
999 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
1005 // Do position normalization - relative distance to
1006 // center of pad- time bin
1008 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
1009 // cluster->GetTimeBin(), cluster->GetZ(),
1010 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
1011 // cluster->GetMax(),cluster->GetQ());
1012 // scaled response function
1013 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1014 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1017 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1018 Float_t ty = TMath::Abs(point->GetAngleY());
1019 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1021 if (type==1) corrPos =
1022 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1023 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
1024 if (type==0) corrPos =
1025 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1026 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1028 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1029 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1030 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1031 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1032 if (corrHis>0) corrPos*=corrHis;
1039 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1040 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
1044 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1045 //use hardwired - temp fix
1046 if (type==0) corrNorm=3.;
1047 if (type==1) corrNorm=1.;
1053 amp[ncl]/=corrShape;
1054 amp[ncl]/=corrPadType;
1061 if (type>3) return ncl;
1062 TMath::Sort(ncl,amp, indexes, kFALSE);
1064 if (ncl<10) return 0;
1069 Int_t icl0=TMath::Nint(ncl*low);
1070 Int_t icl1=TMath::Nint(ncl*up);
1071 for (Int_t icl=icl0; icl<icl1;icl++){
1072 suma+=amp[indexes[icl]];
1073 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1076 Float_t mean =suma/sumn;
1077 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1079 // do time-dependent correction for pressure and temperature variations
1080 UInt_t runNumber = 1;
1081 Float_t corrTimeGain = 1;
1082 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1083 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1084 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
1085 runNumber = trans->GetCurrentRunNumber();
1086 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1087 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1088 if (timeGainSplines) {
1089 UInt_t time = trans->GetCurrentTimeStamp();
1090 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1091 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1093 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
1095 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
1099 mean /= corrTimeGain;
1100 rms /= corrTimeGain;
1102 if (returnVal==1) return rms;
1103 if (returnVal==2) return ncl;
1107 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){
1110 // calculates dedx using the cluster
1111 // low - up specify trunc mean range - default form 0-0.7
1112 // type - 1 - max charge or 0- total charge in cluster
1113 // //2- max no corr 3- total+ correction
1114 // i1-i2 - the pad-row range used for calculation
1116 // posNorm - usage of pos normalization
1117 // returnVal - 0 return mean
1119 // - 2 return number of clusters
1121 // - 4 mean upper half
1122 // - 5 mean - lower half
1124 // mode - 0 - linear
1125 // - 1 - logatithmic
1126 // rowThres - number of rows before and after given pad row to check for clusters below threshold
1128 // normalization parametrization taken from AliTPCClusterParam
1130 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1131 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1132 if (!parcl) return 0;
1133 if (!param) return 0;
1134 Int_t row0 = param->GetNRowLow();
1135 Int_t row1 = row0+param->GetNRowUp1();
1140 Int_t nclBelowThr = 0; // counts number of clusters below threshold
1143 Float_t gainGG = 1; // gas gain factor -always enabled
1144 Float_t gainPad = 1; // gain map - used always
1145 Float_t corrPos = 1; // local position correction - if posNorm enabled
1149 if (AliTPCcalibDB::Instance()->GetParameters()){
1150 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1153 // extract time-dependent correction for pressure and temperature variations
1155 UInt_t runNumber = 1;
1156 Float_t corrTimeGain = 1;
1157 TObjArray * timeGainSplines = 0x0;
1158 TGraphErrors * grPadEqual = 0x0;
1160 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1161 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1163 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1166 runNumber = trans->GetCurrentRunNumber();
1167 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1168 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1169 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1170 UInt_t time = trans->GetCurrentTimeStamp();
1171 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1172 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1174 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
1176 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1179 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1180 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
1184 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1185 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1186 const Float_t kedgey =3.;
1189 for (Int_t irow=i1; irow<i2; irow++){
1190 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1191 if (!cluster && irow > 1 && irow < 157) {
1192 Bool_t isClBefore = kFALSE;
1193 Bool_t isClAfter = kFALSE;
1194 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1195 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1196 if (clusterBefore) isClBefore = kTRUE;
1197 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1198 if (clusterAfter) isClAfter = kTRUE;
1200 if (isClBefore && isClAfter) nclBelowThr++;
1202 if (!cluster) continue;
1205 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1207 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1208 if (point==0) continue;
1209 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1210 if (rsigmay > kClusterShapeCut) continue;
1212 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1214 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1216 if (irow>=row0) ipad=1;
1217 if (irow>=row1) ipad=2;
1221 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1224 // Get gainPad - pad by pad calibration
1227 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1228 if (irow < row0) { // IROC
1229 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1231 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1233 if (factor>0.3) gainPad=factor;
1236 // Do position normalization - relative distance to
1237 // center of pad- time bin
1239 Float_t ty = TMath::Abs(point->GetAngleY());
1240 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1241 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1242 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1244 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1245 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1246 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1247 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1250 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1251 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1252 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1253 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1254 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1255 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1256 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1260 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1261 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1262 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1264 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1265 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1266 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1267 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1271 // pad region equalization outside of cluster param
1273 Float_t gainEqualPadRegion = 1;
1274 if (grPadEqual) gainEqualPadRegion = grPadEqual->Eval(ipad);
1280 amp[ncl]/=gainEqualPadRegion;
1285 if (type==2) return ncl;
1286 TMath::Sort(ncl,amp, indexes, kFALSE);
1288 if (ncl<10) return 0;
1290 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1291 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1292 if (iCl < nclBelowThr) {
1293 ampWithBelow[iCl] = amp[indexes[0]];
1295 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1298 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1305 // upper,and lower part statistic
1306 Float_t sumL=0, sumL2=0, sumLN=0;
1307 Float_t sumD=0, sumD2=0, sumDN=0;
1309 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1310 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
1311 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1313 for (Int_t icl=icl0; icl<icl1;icl++){
1314 if (ampWithBelow[icl]<0.1) continue;
1315 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1316 if (mode==1) camp= TMath::Log(camp);
1320 suma3+=camp*camp*camp;
1321 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
1338 Float_t meanD = 0; // lower half mean
1339 if (sumn > 1e-30) mean =suma/sumn;
1340 if (sumLN > 1e-30) meanL =sumL/sumLN;
1341 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1343 Float_t mean =suma/sumn;
1344 Float_t meanL = sumL/sumLN;
1345 Float_t meanD =(sumD/sumDN); // lower half mean
1347 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1348 Float_t mean2=suma2/sumn;
1349 Float_t mean3=suma3/sumn;
1350 Float_t meanS=sumaS/sumn;
1351 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1352 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1353 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
1355 if (mode==1) mean=TMath::Exp(mean);
1356 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1357 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1359 delete [] ampWithBelow;
1363 if (returnVal==1) return rms;
1364 if (returnVal==2) return ncl;
1365 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1366 if (returnVal==4) return meanL;
1367 if (returnVal==5) return meanD;
1368 if (returnVal==6) return mean2;
1369 if (returnVal==7) return mean3;
1370 if (returnVal==8) return meanS;
1377 Float_t AliTPCseed::CookShape(Int_t type){
1381 //-----------------------------------------------------------------
1382 // This funtion calculates dE/dX within the "low" and "up" cuts.
1383 //-----------------------------------------------------------------
1386 for (Int_t i =0; i<160;i++) {
1387 AliTPCTrackerPoint * point = GetTrackPoint(i);
1388 if (point==0) continue;
1390 AliTPCclusterMI * cl = fClusterPointer[i];
1391 if (cl==0) continue;
1393 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1394 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1395 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1396 if (type==0) means+=rsigma;
1397 if (type==1) means+=rsigmay;
1398 if (type==2) means+=rsigmaz;
1401 Float_t mean = (meanc>0)? means/meanc:0;
1407 Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1410 // return value - number of used clusters
1413 const Int_t kMinNcl =10;
1414 AliTPCseed *track=new AliTPCseed(*seed);
1419 for (Int_t i=0;i<15;i++) covar[i]=0;
1422 covar[5]=10.*10./(64.*64.);
1423 covar[9]=10.*10./(64.*64.);
1427 Float_t xmin=1000, xmax=-10000;
1428 Int_t imin=158, imax=0;
1429 for (Int_t i=0;i<160;i++) {
1430 AliTPCclusterMI *c=track->GetClusterPointer(i);
1432 if (sector<0) sector = c->GetDetector();
1433 if (c->GetX()<xmin) xmin=c->GetX();
1434 if (c->GetX()>xmax) xmax=c->GetX();
1438 if(imax-imin<kMinNcl) {
1442 // Not succes to rotate
1443 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1449 // fit from inner to outer row
1451 AliExternalTrackParam paramIn;
1452 AliExternalTrackParam paramOut;
1458 for (Int_t i=imin; i<=imax; i++){
1459 AliTPCclusterMI *c=track->GetClusterPointer(i);
1461 // if (RejectCluster(c,track)) continue;
1462 sector = (c->GetDetector()%18);
1463 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1466 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1467 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1468 if (!track->PropagateTo(r[0])) {
1471 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1473 if (!isOK) { delete track; return 0;}
1474 track->AddCovariance(covar);
1478 for (Int_t i=imax; i>=imin; i--){
1479 AliTPCclusterMI *c=track->GetClusterPointer(i);
1481 //if (RejectCluster(c,track)) continue;
1482 sector = (c->GetDetector()%18);
1483 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1486 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1487 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1488 if (!track->PropagateTo(r[0])) {
1491 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1493 //if (!isOK) { delete track; return 0;}
1495 track->AddCovariance(covar);
1498 for (Int_t i=imin; i<=imax; i++){
1499 AliTPCclusterMI *c=track->GetClusterPointer(i);
1501 sector = (c->GetDetector()%18);
1502 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1506 //if (RejectCluster(c,track)) continue;
1507 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1508 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1509 if (!track->PropagateTo(r[0])) {
1512 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1514 //if (!isOK) { delete track; return 0;}
1519 if (parin) (*parin)=paramIn;
1520 if (parout) (*parout)=paramOut;
1527 Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1539 void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1540 Double_t& erry, Double_t &errz)
1543 // Get cluster error at given position
1545 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1547 Double_t snp1=param->GetSnp();
1548 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1550 Double_t tgl1=param->GetTgl();
1551 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1553 Int_t padSize = 0; // short pads
1554 if (cluster->GetDetector() >= 36) {
1555 padSize = 1; // medium pads
1556 if (cluster->GetRow() > 63) padSize = 2; // long pads
1559 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1560 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1564 void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1565 Double_t& rmsy, Double_t &rmsz)
1568 // Get cluster error at given position
1570 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1572 Double_t snp1=param->GetSnp();
1573 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1575 Double_t tgl1=param->GetTgl();
1576 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1578 Int_t padSize = 0; // short pads
1579 if (cluster->GetDetector() >= 36) {
1580 padSize = 1; // medium pads
1581 if (cluster->GetRow() > 63) padSize = 2; // long pads
1584 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1585 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1590 Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1592 //ty - tangent in local y direction
1595 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1599 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*/){
1603 // return value = Q Normalization factor
1604 // Normalization - 1 - shape factor part for full drift
1605 // 1 - electron attachment for 0 drift
1607 // Input parameters:
1609 // ipad - 0 short pad
1616 //z - z position (-250,250 cm)
1617 //ty - tangent in local y direction
1621 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1622 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1624 if (!paramCl) return 1;
1626 Double_t dr = 250.-TMath::Abs(z);
1627 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1628 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1629 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1630 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1632 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1635 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1636 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1639 if (type==0) return sfactorMax*attProb;