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),
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++) {
84 fNCDEDXInclThres[i] = 0;
87 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
90 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
93 fClusterOwner(clusterOwner),
99 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
100 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
101 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
102 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
105 fCurrentCluster(0x0),
106 fCurrentClusterIndex1(-1),
119 //---------------------
120 // dummy copy constructor
121 //-------------------------
122 for (Int_t i=0;i<160;i++) {
123 fClusterPointer[i]=0;
125 if (s.fClusterPointer[i])
126 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
128 fClusterPointer[i] = s.fClusterPointer[i];
130 fTrackPoints[i] = s.fTrackPoints[i];
132 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
133 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
134 for (Int_t i=0;i<4;i++) {
135 fDEDX[i] = s.fDEDX[i];
136 fSDEDX[i] = s.fSDEDX[i];
137 fNCDEDX[i] = s.fNCDEDX[i];
138 fNCDEDXInclThres[i] = s.fNCDEDXInclThres[i];
140 fDEDX[4] = s.fDEDX[4];
141 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
146 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
149 fClusterOwner(kFALSE),
155 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
156 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
157 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
158 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
161 fCurrentCluster(0x0),
162 fCurrentClusterIndex1(-1),
176 // Constructor from AliTPCtrack
179 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
180 for (Int_t i=0;i<160;i++) {
181 fClusterPointer[i] = 0;
182 Int_t index = t.GetClusterIndex(i);
184 SetClusterIndex2(i,index);
187 SetClusterIndex2(i,-3);
190 for (Int_t i=0;i<4;i++) {
194 fNCDEDXInclThres[i] = 0;
197 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
200 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
201 const Double_t cc[15], Int_t index):
202 AliTPCtrack(xr, alpha, xx, cc, index),
204 fClusterOwner(kFALSE),
210 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
211 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
212 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
213 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
216 fCurrentCluster(0x0),
217 fCurrentClusterIndex1(-1),
234 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
235 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
236 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
237 for (Int_t i=0;i<4;i++) {
241 fNCDEDXInclThres[i] = 0;
244 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
247 AliTPCseed::~AliTPCseed(){
252 for (Int_t icluster=0; icluster<160; icluster++){
253 delete fClusterPointer[icluster];
258 //_________________________________________________
259 AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
262 // assignment operator
263 // don't touch pool ID
266 AliTPCtrack::operator=(param);
268 fClusterOwner = param.fClusterOwner;
269 if (!fClusterOwner) for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i];
270 else for(Int_t i = 0;i<160;++i) {
271 delete fClusterPointer[i];
272 fClusterPointer[i] = new AliTPCclusterMI(*(param.fClusterPointer[i]));
274 // leave out fPoint, they are also not copied in the copy ctor...
275 // but deleted in the dtor... strange...
277 fSector = param.fSector;
278 fRelativeSector = param.fRelativeSector;
279 fCurrentSigmaY2 = param.fCurrentSigmaY2;
280 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
281 fErrorY2 = param.fErrorY2;
282 fErrorZ2 = param.fErrorZ2;
283 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
284 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
285 fInDead = param.fInDead;
286 fIsSeeding = param.fIsSeeding;
287 fNoCluster = param.fNoCluster;
289 fBSigned = param.fBSigned;
290 for(Int_t i = 0;i<4;++i){
291 fDEDX[i] = param.fDEDX[i];
292 fSDEDX[i] = param.fSDEDX[i];
293 fNCDEDX[i] = param.fNCDEDX[i];
294 fNCDEDXInclThres[i] = param.fNCDEDXInclThres[i];
296 fDEDX[4] = param.fDEDX[4];
297 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
299 fSeedType = param.fSeedType;
300 fSeed1 = param.fSeed1;
301 fSeed2 = param.fSeed2;
302 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
303 fMAngular = param.fMAngular;
304 fCircular = param.fCircular;
305 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
309 //____________________________________________________
310 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
314 return &fTrackPoints[i];
319 Double_t AliTPCseed::GetDensityFirst(Int_t n)
323 // return cluster for n rows bellow first point
324 Int_t nfoundable = 1;
326 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
327 Int_t index = GetClusterIndex2(i);
328 if (index!=-1) nfoundable++;
329 if (index>0) nfound++;
331 if (nfoundable<n) return 0;
332 return Double_t(nfound)/Double_t(nfoundable);
337 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
339 // get cluster stat. on given region
344 for (Int_t i=first;i<last; i++){
345 Int_t index = GetClusterIndex2(i);
346 if (index!=-1) foundable++;
347 if (index&0x8000) continue;
348 if (fClusterPointer[i]) {
354 if (fClusterPointer[i]->IsUsed(10)) {
358 if (!plus2) continue; //take also neighborhoud
360 if ( (i>0) && fClusterPointer[i-1]){
361 if (fClusterPointer[i-1]->IsUsed(10)) {
366 if ( fClusterPointer[i+1]){
367 if (fClusterPointer[i+1]->IsUsed(10)) {
375 //Error("AliTPCseed::GetClusterStatistic","problem\n");
383 void AliTPCseed::Reset(Bool_t all)
387 SetNumberOfClusters(0);
390 ResetCovariance(10.);
393 for (Int_t i=0;i<8;i++){
394 delete [] fTrackPoints[i];
402 for (Int_t i=200;i--;) SetClusterIndex2(i,-3);
403 if (!fClusterOwner) for (Int_t i=160;i--;) fClusterPointer[i]=0;
404 else for (Int_t i=160;i--;) {delete fClusterPointer[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 AliTPCclusterMI cl(*(AliTPCclusterMI*)c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
547 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
549 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
552 Int_t padSize = 0; // short pads
553 if (cl.GetDetector() >= 36) {
554 padSize = 1; // medium pads
555 if (cl.GetRow() > 63) padSize = 2; // long pads
557 Float_t waveCorr = parcl->GetWaveCorrection( padSize, cl.GetZ(), cl.GetMax(),cl.GetPad(), ty );
558 cl.SetY( cl.GetY() - waveCorr );
561 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
562 if (TMath::Abs(dx)>0){
564 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
565 cl.SetY(cl.GetY()-dy);
566 cl.SetZ(cl.GetZ()-dz);
570 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
572 if (fCMeanSigmaY2p30<0){
573 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
574 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
575 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
576 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
579 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
580 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
581 if (fCurrentSigmaY2>0){
582 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
583 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
587 SetClusterIndex(n,idx); // restore the current cluster index
593 //_____________________________________________________________________________
594 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
595 //-----------------------------------------------------------------
596 // This funtion calculates dE/dX within the "low" and "up" cuts.
597 //-----------------------------------------------------------------
598 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
599 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
601 Int_t row0 = param->GetNRowLow();
602 Int_t row1 = row0+param->GetNRowUp1();
603 Int_t row2 = row1+param->GetNRowUp2();
604 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
606 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
610 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
611 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
612 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
613 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
614 fDEDX[4] = CookdEdxAnalytical(low,up,useTot ,row0,row2, 0); // full OROC truncated mean
616 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
617 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
618 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
619 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
621 fNCDEDX[0] = TMath::Nint(GetTPCClustInfo(2, 1, i1 , i2));
622 fNCDEDX[1] = TMath::Nint(GetTPCClustInfo(2, 1, 0 , row0));
623 fNCDEDX[2] = TMath::Nint(GetTPCClustInfo(2, 1, row0, row1));
624 fNCDEDX[3] = TMath::Nint(GetTPCClustInfo(2, 1, row1, row2));
626 fNCDEDXInclThres[0] = TMath::Nint(GetTPCClustInfo(2, 2, i1 , i2));
627 fNCDEDXInclThres[1] = TMath::Nint(GetTPCClustInfo(2, 2, 0 , row0));
628 fNCDEDXInclThres[2] = TMath::Nint(GetTPCClustInfo(2, 2, row0, row1));
629 fNCDEDXInclThres[3] = TMath::Nint(GetTPCClustInfo(2, 2, row1, row2));
634 // return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
638 // Float_t angular[200];
639 // Float_t weight[200];
642 // Float_t meanlog = 100.;
644 // Float_t mean[4] = {0,0,0,0};
645 // Float_t sigma[4] = {1000,1000,1000,1000};
646 // Int_t nc[4] = {0,0,0,0};
647 // Float_t norm[4] = {1000,1000,1000,1000};
652 // Float_t gainGG = 1;
653 // if (AliTPCcalibDB::Instance()->GetParameters()){
654 // gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
658 // for (Int_t of =0; of<4; of++){
659 // for (Int_t i=of+i1;i<i2;i+=4)
661 // Int_t clindex = fIndex[i];
662 // if (clindex<0||clindex&0x8000) continue;
664 // //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
665 // AliTPCTrackerPoint * point = GetTrackPoint(i);
666 // //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
667 // //AliTPCTrackerPoint * pointp = 0;
668 // //if (i<159) pointp = GetTrackPoint(i+1);
670 // if (point==0) continue;
671 // AliTPCclusterMI * cl = fClusterPointer[i];
672 // if (cl==0) continue;
673 // if (onlyused && (!cl->IsUsed(10))) continue;
674 // if (cl->IsUsed(11)) {
678 // Int_t type = cl->GetType();
679 // //if (point->fIsShared){
684 // // if (pointm->fIsShared) continue;
686 // // if (pointp->fIsShared) continue;
688 // if (type<0) continue;
689 // //if (type>10) continue;
690 // //if (point->GetErrY()==0) continue;
691 // //if (point->GetErrZ()==0) continue;
693 // //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
694 // //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
695 // //if ((ddy*ddy+ddz*ddz)>10) continue;
698 // // if (point->GetCPoint().GetMax()<5) continue;
699 // if (cl->GetMax()<5) continue;
700 // Float_t angley = point->GetAngleY();
701 // Float_t anglez = point->GetAngleZ();
703 // Float_t rsigmay2 = point->GetSigmaY();
704 // Float_t rsigmaz2 = point->GetSigmaZ();
708 // rsigmay += pointm->GetTPoint().GetSigmaY();
709 // rsigmaz += pointm->GetTPoint().GetSigmaZ();
713 // rsigmay += pointp->GetTPoint().GetSigmaY();
714 // rsigmaz += pointp->GetTPoint().GetSigmaZ();
721 // Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
723 // Float_t ampc = 0; // normalization to the number of electrons
725 // // ampc = 1.*point->GetCPoint().GetMax();
726 // ampc = 1.*cl->GetMax();
727 // //ampc = 1.*point->GetCPoint().GetQ();
728 // // AliTPCClusterPoint & p = point->GetCPoint();
729 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
730 // // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
732 // // TMath::Abs( Int_t(iz) - iz + 0.5);
733 // //ampc *= 1.15*(1-0.3*dy);
734 // //ampc *= 1.15*(1-0.3*dz);
735 // // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
739 // //ampc = 1.0*point->GetCPoint().GetMax();
740 // ampc = 1.0*cl->GetMax();
741 // //ampc = 1.0*point->GetCPoint().GetQ();
742 // //AliTPCClusterPoint & p = point->GetCPoint();
743 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
744 // //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
746 // // TMath::Abs( Int_t(iz) - iz + 0.5);
748 // //ampc *= 1.15*(1-0.3*dy);
749 // //ampc *= 1.15*(1-0.3*dz);
750 // // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
754 // ampc *= 2.0; // put mean value to channel 50
755 // //ampc *= 0.58; // put mean value to channel 50
757 // // if (type>0) w = 1./(type/2.-0.5);
758 // // Float_t z = TMath::Abs(cl->GetZ());
761 // //ampc /= (1+0.0008*z);
765 // //ampc /= (1+0.0008*z);
767 // //ampc /= (1+0.0008*z);
770 // if (type<0) { //amp at the border - lower weight
775 // if (rsigma>1.5) ampc/=1.3; // if big backround
776 // amp[nc[of]] = ampc;
777 // amp[nc[of]] /=gainGG;
778 // angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
779 // weight[nc[of]] = w;
783 // TMath::Sort(nc[of],amp,index,kFALSE);
785 // Float_t sumamp2=0;
787 // //meanlog = amp[index[Int_t(nc[of]*0.33)]];
789 // for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
790 // Float_t ampl = amp[index[i]]/angular[index[i]];
791 // ampl = meanlog*TMath::Log(1.+ampl/meanlog);
793 // sumw += weight[index[i]];
794 // sumamp += weight[index[i]]*ampl;
795 // sumamp2 += weight[index[i]]*ampl*ampl;
796 // norm[of] += angular[index[i]]*weight[index[i]];
803 // mean[of] = sumamp/sumw;
804 // sigma[of] = sumamp2/sumw-mean[of]*mean[of];
805 // if (sigma[of]>0.1)
806 // sigma[of] = TMath::Sqrt(sigma[of]);
810 // mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
811 // //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
812 // //mean *=(1-0.1*(norm-1.));
819 // // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
820 // // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
823 // // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
824 // // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
828 // for (Int_t i =0;i<4;i++){
829 // if (nc[i]>2&&nc[i]<1000){
830 // dedx += mean[i] *nc[i];
831 // fSdEdx += sigma[i]*(nc[i]-2);
832 // fMAngular += norm[i] *nc[i];
836 // fDEDX[i] = mean[i];
837 // fSDEDX[i] = sigma[i];
838 // fNCDEDX[i]= nc[i];
850 // // Float_t dedx1 =dedx;
853 // for (Int_t i =0;i<4;i++){
854 // if (nc[i]>2&&nc[i]<1000){
855 // mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
856 // dedx += mean[i] *nc[i];
858 // fDEDX[i] = mean[i];
868 void AliTPCseed::CookPID()
871 // cook PID information according dEdx
873 Double_t fRange = 10.;
877 Int_t ns=AliPID::kSPECIES;
879 for (Int_t j=0; j<ns; j++) {
880 Double_t mass=AliPID::ParticleMass(j);
882 Double_t dedx=fdEdx/fMIP;
883 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
884 Double_t sigma=fRes*bethe;
886 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
887 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
891 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
899 for (Int_t j=0; j<ns; j++) {
900 fTPCr[j]/=sumr; //normalize
904 Double_t AliTPCseed::GetYat(Double_t xk) const {
905 //-----------------------------------------------------------------
906 // This function calculates the Y-coordinate of a track at the plane x=xk.
907 //-----------------------------------------------------------------
908 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
909 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
910 Double_t c2=c1+GetC()*(xk-GetX());
911 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
912 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
913 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
918 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){
921 // calculates dedx using the cluster
922 // low - up specify trunc mean range - default form 0-0.7
923 // type - 1 - max charge or 0- total charge in cluster
924 // //2- max no corr 3- total+ correction
925 // i1-i2 - the pad-row range used for calculation
926 // shapeNorm - kTRUE -taken from OCDB
928 // posNorm - usage of pos normalization
929 // padNorm - pad type normalization
930 // returnVal - 0 return mean
932 // - 2 return number of clusters
934 // normalization parametrization taken from AliTPCClusterParam
936 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
937 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
938 if (!parcl) return 0;
939 if (!param) return 0;
940 Int_t row0 = param->GetNRowLow();
941 Int_t row1 = row0+param->GetNRowUp1();
948 Float_t gainGG = 1; // gas gain factor -always enabled
949 Float_t gainPad = 1; // gain map - used always
950 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
951 Float_t corrPos = 1; // local position correction - if posNorm enabled
952 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
953 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
957 if (AliTPCcalibDB::Instance()->GetParameters()){
958 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
961 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
962 const Float_t kedgey =3.;
965 for (Int_t irow=i1; irow<i2; irow++){
966 AliTPCclusterMI* cluster = GetClusterPointer(irow);
967 if (!cluster) continue;
968 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
969 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
971 if (irow>=row0) ipad=1;
972 if (irow>=row1) ipad=2;
976 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
979 // Get gainPad - pad by pad calibration
982 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
983 if (irow < row0) { // IROC
984 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
986 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
988 if (factor>0.5) gainPad=factor;
991 //do position and angular normalization
996 AliTPCTrackerPoint * point = GetTrackPoint(irow);
997 Float_t ty = TMath::Abs(point->GetAngleY());
998 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1000 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1001 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
1007 // Do position normalization - relative distance to
1008 // center of pad- time bin
1010 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
1011 // cluster->GetTimeBin(), cluster->GetZ(),
1012 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
1013 // cluster->GetMax(),cluster->GetQ());
1014 // scaled response function
1015 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1016 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1019 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1020 Float_t ty = TMath::Abs(point->GetAngleY());
1021 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1023 if (type==1) corrPos =
1024 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1025 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
1026 if (type==0) corrPos =
1027 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1028 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1030 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1031 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1032 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1033 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1034 if (corrHis>0) corrPos*=corrHis;
1041 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1042 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
1046 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1047 //use hardwired - temp fix
1048 if (type==0) corrNorm=3.;
1049 if (type==1) corrNorm=1.;
1055 amp[ncl]/=corrShape;
1056 amp[ncl]/=corrPadType;
1063 if (type>3) return ncl;
1064 TMath::Sort(ncl,amp, indexes, kFALSE);
1066 if (ncl<10) return 0;
1071 Int_t icl0=TMath::Nint(ncl*low);
1072 Int_t icl1=TMath::Nint(ncl*up);
1073 for (Int_t icl=icl0; icl<icl1;icl++){
1074 suma+=amp[indexes[icl]];
1075 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1078 Float_t mean =suma/sumn;
1079 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1081 // do time-dependent correction for pressure and temperature variations
1082 UInt_t runNumber = 1;
1083 Float_t corrTimeGain = 1;
1084 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1085 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1086 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
1087 runNumber = trans->GetCurrentRunNumber();
1088 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1089 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1090 if (timeGainSplines) {
1091 UInt_t time = trans->GetCurrentTimeStamp();
1092 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1093 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1095 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
1097 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
1101 mean /= corrTimeGain;
1102 rms /= corrTimeGain;
1104 if (returnVal==1) return rms;
1105 if (returnVal==2) return ncl;
1109 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){
1112 // calculates dedx using the cluster
1113 // low - up specify trunc mean range - default form 0-0.7
1114 // type - 1 - max charge or 0- total charge in cluster
1115 // //2- max no corr 3- total+ correction
1116 // i1-i2 - the pad-row range used for calculation
1118 // posNorm - usage of pos normalization
1119 // returnVal - 0 return mean
1121 // - 2 return number of clusters
1123 // - 4 mean upper half
1124 // - 5 mean - lower half
1126 // mode - 0 - linear
1127 // - 1 - logatithmic
1128 // rowThres - number of rows before and after given pad row to check for clusters below threshold
1130 // normalization parametrization taken from AliTPCClusterParam
1132 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1133 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1134 if (!parcl) return 0;
1135 if (!param) return 0;
1136 Int_t row0 = param->GetNRowLow();
1137 Int_t row1 = row0+param->GetNRowUp1();
1142 Int_t nclBelowThr = 0; // counts number of clusters below threshold
1145 Float_t gainGG = 1; // gas gain factor -always enabled
1146 Float_t gainPad = 1; // gain map - used always
1147 Float_t corrPos = 1; // local position correction - if posNorm enabled
1151 if (AliTPCcalibDB::Instance()->GetParameters()){
1152 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1155 // extract time-dependent correction for pressure and temperature variations
1157 UInt_t runNumber = 1;
1158 Float_t corrTimeGain = 1;
1159 TObjArray * timeGainSplines = 0x0;
1160 TGraphErrors * grPadEqual = 0x0;
1161 TGraphErrors* grChamberGain[3]={0x0,0x0,0x0};
1163 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1164 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1166 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1169 runNumber = trans->GetCurrentRunNumber();
1170 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1171 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1172 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1173 UInt_t time = trans->GetCurrentTimeStamp();
1174 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1175 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1177 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
1179 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1182 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1183 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
1184 const char* names[3]={"SHORT","MEDIUM","LONG"};
1185 for (Int_t iPadRegion=0; iPadRegion<3; ++iPadRegion)
1186 grChamberGain[iPadRegion]=(TGraphErrors*)timeGainSplines->FindObject(Form("TGRAPHERRORS_MEAN_CHAMBERGAIN_%s_BEAM_ALL",names[iPadRegion]));
1190 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1191 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1192 const Float_t kedgey =3.;
1195 for (Int_t irow=i1; irow<i2; irow++){
1196 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1197 if (!cluster && irow > 1 && irow < 157) {
1198 Bool_t isClBefore = kFALSE;
1199 Bool_t isClAfter = kFALSE;
1200 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1201 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1202 if (clusterBefore) isClBefore = kTRUE;
1203 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1204 if (clusterAfter) isClAfter = kTRUE;
1206 if (isClBefore && isClAfter) nclBelowThr++;
1208 if (!cluster) continue;
1211 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1213 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1214 if (point==0) continue;
1215 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1216 if (rsigmay > kClusterShapeCut) continue;
1218 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1220 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1222 if (irow>=row0) ipad=1;
1223 if (irow>=row1) ipad=2;
1227 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1230 // Get gainPad - pad by pad calibration
1233 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1234 if (irow < row0) { // IROC
1235 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1237 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1239 if (factor>0.3) gainPad=factor;
1242 // Do position normalization - relative distance to
1243 // center of pad- time bin
1245 Float_t ty = TMath::Abs(point->GetAngleY());
1246 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1247 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1248 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1250 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1251 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1252 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1253 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1256 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1257 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1258 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1259 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1260 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1261 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1262 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1266 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1267 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1268 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1270 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1271 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1272 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1273 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1277 // pad region equalization outside of cluster param
1279 Float_t gainEqualPadRegion = 1;
1280 if (grPadEqual && recoParam->GetUseGainCorrectionTime()>0) gainEqualPadRegion = grPadEqual->Eval(ipad);
1282 // chamber-by-chamber equalization outside gain map
1284 Float_t gainChamber = 1;
1285 if (grChamberGain[ipad] && recoParam->GetUseGainCorrectionTime()>0) gainChamber = grChamberGain[ipad]->Eval(cluster->GetDetector());
1291 amp[ncl]/=gainEqualPadRegion;
1292 amp[ncl]/=gainChamber;
1297 if (type==2) return ncl;
1298 TMath::Sort(ncl,amp, indexes, kFALSE);
1300 if (ncl<10) return 0;
1302 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1303 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1304 if (iCl < nclBelowThr) {
1305 ampWithBelow[iCl] = amp[indexes[0]];
1307 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1310 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1317 // upper,and lower part statistic
1318 Float_t sumL=0, sumL2=0, sumLN=0;
1319 Float_t sumD=0, sumD2=0, sumDN=0;
1321 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1322 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
1323 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1325 for (Int_t icl=icl0; icl<icl1;icl++){
1326 if (ampWithBelow[icl]<0.1) continue;
1327 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1328 if (mode==1) camp= TMath::Log(camp);
1332 suma3+=camp*camp*camp;
1333 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
1350 Float_t meanD = 0; // lower half mean
1351 if (sumn > 1e-30) mean =suma/sumn;
1352 if (sumLN > 1e-30) meanL =sumL/sumLN;
1353 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1355 Float_t mean =suma/sumn;
1356 Float_t meanL = sumL/sumLN;
1357 Float_t meanD =(sumD/sumDN); // lower half mean
1366 rms = TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1372 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1373 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1374 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
1376 if (mode==1) mean=TMath::Exp(mean);
1377 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1378 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1380 delete [] ampWithBelow;
1384 if (returnVal==1) return rms;
1385 if (returnVal==2) return ncl;
1386 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1387 if (returnVal==4) return meanL;
1388 if (returnVal==5) return meanD;
1389 if (returnVal==6) return mean2;
1390 if (returnVal==7) return mean3;
1391 if (returnVal==8) return meanS;
1398 Float_t AliTPCseed::CookShape(Int_t type){
1402 //-----------------------------------------------------------------
1403 // This funtion calculates dE/dX within the "low" and "up" cuts.
1404 //-----------------------------------------------------------------
1407 for (Int_t i =0; i<160;i++) {
1408 AliTPCTrackerPoint * point = GetTrackPoint(i);
1409 if (point==0) continue;
1411 AliTPCclusterMI * cl = fClusterPointer[i];
1412 if (cl==0) continue;
1414 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1415 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1416 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1417 if (type==0) means+=rsigma;
1418 if (type==1) means+=rsigmay;
1419 if (type==2) means+=rsigmaz;
1422 Float_t mean = (meanc>0)? means/meanc:0;
1428 Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1431 // return value - number of used clusters
1434 const Int_t kMinNcl =10;
1435 AliTPCseed *track=new AliTPCseed(*seed);
1440 for (Int_t i=0;i<15;i++) covar[i]=0;
1443 covar[5]=10.*10./(64.*64.);
1444 covar[9]=10.*10./(64.*64.);
1448 Float_t xmin=1000, xmax=-10000;
1449 Int_t imin=158, imax=0;
1450 for (Int_t i=0;i<160;i++) {
1451 AliTPCclusterMI *c=track->GetClusterPointer(i);
1452 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
1453 if (sector<0) sector = c->GetDetector();
1454 if (c->GetX()<xmin) xmin=c->GetX();
1455 if (c->GetX()>xmax) xmax=c->GetX();
1459 if(imax-imin<kMinNcl) {
1463 // Not succes to rotate
1464 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1470 // fit from inner to outer row
1472 AliExternalTrackParam paramIn;
1473 AliExternalTrackParam paramOut;
1479 for (Int_t i=imin; i<=imax; i++){
1480 AliTPCclusterMI *c=track->GetClusterPointer(i);
1481 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
1482 // if (RejectCluster(c,track)) continue;
1483 sector = (c->GetDetector()%18);
1484 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1487 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1488 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1489 if (!track->PropagateTo(r[0])) {
1492 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1494 if (!isOK) { delete track; return 0;}
1495 track->AddCovariance(covar);
1499 for (Int_t i=imax; i>=imin; i--){
1500 AliTPCclusterMI *c=track->GetClusterPointer(i);
1501 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
1502 //if (RejectCluster(c,track)) continue;
1503 sector = (c->GetDetector()%18);
1504 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
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;}
1516 track->AddCovariance(covar);
1519 for (Int_t i=imin; i<=imax; i++){
1520 AliTPCclusterMI *c=track->GetClusterPointer(i);
1521 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
1522 sector = (c->GetDetector()%18);
1523 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1527 //if (RejectCluster(c,track)) continue;
1528 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1529 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1530 if (!track->PropagateTo(r[0])) {
1533 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1535 //if (!isOK) { delete track; return 0;}
1540 if (parin) (*parin)=paramIn;
1541 if (parout) (*parout)=paramOut;
1548 Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1560 void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1561 Double_t& erry, Double_t &errz)
1564 // Get cluster error at given position
1566 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1568 Double_t snp1=param->GetSnp();
1569 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1571 Double_t tgl1=param->GetTgl();
1572 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1574 Int_t padSize = 0; // short pads
1575 if (cluster->GetDetector() >= 36) {
1576 padSize = 1; // medium pads
1577 if (cluster->GetRow() > 63) padSize = 2; // long pads
1580 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1581 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1585 void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1586 Double_t& rmsy, Double_t &rmsz)
1589 // Get cluster error at given position
1591 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1593 Double_t snp1=param->GetSnp();
1594 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1596 Double_t tgl1=param->GetTgl();
1597 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1599 Int_t padSize = 0; // short pads
1600 if (cluster->GetDetector() >= 36) {
1601 padSize = 1; // medium pads
1602 if (cluster->GetRow() > 63) padSize = 2; // long pads
1605 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1606 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1611 Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1613 //ty - tangent in local y direction
1616 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1620 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*/){
1624 // return value = Q Normalization factor
1625 // Normalization - 1 - shape factor part for full drift
1626 // 1 - electron attachment for 0 drift
1628 // Input parameters:
1630 // ipad - 0 short pad
1637 //z - z position (-250,250 cm)
1638 //ty - tangent in local y direction
1642 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1643 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1645 if (!paramCl) return 1;
1647 Double_t dr = 250.-TMath::Abs(z);
1648 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1649 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1650 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1651 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1653 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1656 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1657 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1660 if (type==0) return sfactorMax*attProb;
1668 //_______________________________________________________________________
1669 Float_t AliTPCseed::GetTPCClustInfo(Int_t nNeighbours, Int_t type, Int_t row0, Int_t row1)
1672 // TPC cluster information
1673 // type 0: get fraction of found/findable clusters with neighbourhood definition
1674 // 1: found clusters
1675 // 2: findable (number of clusters above and below threshold)
1677 // definition of findable clusters:
1678 // a cluster is defined as findable if there is another cluster
1679 // within +- nNeighbours pad rows. The idea is to overcome threshold
1680 // effects with a very simple algorithm.
1683 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1684 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1685 const Float_t kedgey =3.;
1688 Float_t nclBelowThr = 0; // counts number of clusters below threshold
1690 for (Int_t irow=row0; irow<row1; irow++){
1691 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1693 if (!cluster && irow > 1 && irow < 157) {
1694 Bool_t isClBefore = kFALSE;
1695 Bool_t isClAfter = kFALSE;
1696 for(Int_t ithres = 1; ithres <= nNeighbours; ithres++) {
1697 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1698 if (clusterBefore) isClBefore = kTRUE;
1699 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1700 if (clusterAfter) isClAfter = kTRUE;
1702 if (isClBefore && isClAfter) nclBelowThr++;
1704 if (!cluster) continue;
1707 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1709 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1710 if (point==0) continue;
1711 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1712 if (rsigmay > kClusterShapeCut) continue;
1714 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1721 if(nclBelowThr+ncl>0)
1722 return ncl/(nclBelowThr+ncl);
1726 return ncl+nclBelowThr;
1729 //_______________________________________________________________________
1730 Int_t AliTPCseed::GetNumberOfClustersIndices() {
1732 for (int i=0; i < 160; i++) {
1733 if ((fIndex[i] & 0x8000) == 0)
1739 //_______________________________________________________________________
1740 void AliTPCseed::Clear(Option_t*)
1742 // formally seed may allocate memory for clusters (althought this should not happen for
1743 // the seeds in the pool). Hence we need this method for fwd. compatibility
1744 if (fClusterOwner) for (int i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i] = 0;}