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 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);
599 fDEDX[4] = CookdEdxAnalytical(low,up,useTot ,row0,row2, 0); // full OROC truncated mean
601 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
602 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
603 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
604 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
606 fNCDEDX[0] = TMath::Nint(GetTPCClustInfo(2, 1, i1 , i2));
607 fNCDEDX[1] = TMath::Nint(GetTPCClustInfo(2, 1, 0 , row0));
608 fNCDEDX[2] = TMath::Nint(GetTPCClustInfo(2, 1, row0, row1));
609 fNCDEDX[3] = TMath::Nint(GetTPCClustInfo(2, 1, row1, row2));
611 fNCDEDXInclThres[0] = TMath::Nint(GetTPCClustInfo(2, 2, i1 , i2));
612 fNCDEDXInclThres[1] = TMath::Nint(GetTPCClustInfo(2, 2, 0 , row0));
613 fNCDEDXInclThres[2] = TMath::Nint(GetTPCClustInfo(2, 2, row0, row1));
614 fNCDEDXInclThres[3] = TMath::Nint(GetTPCClustInfo(2, 2, row1, row2));
619 // return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
623 // Float_t angular[200];
624 // Float_t weight[200];
627 // Float_t meanlog = 100.;
629 // Float_t mean[4] = {0,0,0,0};
630 // Float_t sigma[4] = {1000,1000,1000,1000};
631 // Int_t nc[4] = {0,0,0,0};
632 // Float_t norm[4] = {1000,1000,1000,1000};
637 // Float_t gainGG = 1;
638 // if (AliTPCcalibDB::Instance()->GetParameters()){
639 // gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
643 // for (Int_t of =0; of<4; of++){
644 // for (Int_t i=of+i1;i<i2;i+=4)
646 // Int_t clindex = fIndex[i];
647 // if (clindex<0||clindex&0x8000) continue;
649 // //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
650 // AliTPCTrackerPoint * point = GetTrackPoint(i);
651 // //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
652 // //AliTPCTrackerPoint * pointp = 0;
653 // //if (i<159) pointp = GetTrackPoint(i+1);
655 // if (point==0) continue;
656 // AliTPCclusterMI * cl = fClusterPointer[i];
657 // if (cl==0) continue;
658 // if (onlyused && (!cl->IsUsed(10))) continue;
659 // if (cl->IsUsed(11)) {
663 // Int_t type = cl->GetType();
664 // //if (point->fIsShared){
669 // // if (pointm->fIsShared) continue;
671 // // if (pointp->fIsShared) continue;
673 // if (type<0) continue;
674 // //if (type>10) continue;
675 // //if (point->GetErrY()==0) continue;
676 // //if (point->GetErrZ()==0) continue;
678 // //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
679 // //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
680 // //if ((ddy*ddy+ddz*ddz)>10) continue;
683 // // if (point->GetCPoint().GetMax()<5) continue;
684 // if (cl->GetMax()<5) continue;
685 // Float_t angley = point->GetAngleY();
686 // Float_t anglez = point->GetAngleZ();
688 // Float_t rsigmay2 = point->GetSigmaY();
689 // Float_t rsigmaz2 = point->GetSigmaZ();
693 // rsigmay += pointm->GetTPoint().GetSigmaY();
694 // rsigmaz += pointm->GetTPoint().GetSigmaZ();
698 // rsigmay += pointp->GetTPoint().GetSigmaY();
699 // rsigmaz += pointp->GetTPoint().GetSigmaZ();
706 // Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
708 // Float_t ampc = 0; // normalization to the number of electrons
710 // // ampc = 1.*point->GetCPoint().GetMax();
711 // ampc = 1.*cl->GetMax();
712 // //ampc = 1.*point->GetCPoint().GetQ();
713 // // AliTPCClusterPoint & p = point->GetCPoint();
714 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
715 // // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
717 // // TMath::Abs( Int_t(iz) - iz + 0.5);
718 // //ampc *= 1.15*(1-0.3*dy);
719 // //ampc *= 1.15*(1-0.3*dz);
720 // // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
724 // //ampc = 1.0*point->GetCPoint().GetMax();
725 // ampc = 1.0*cl->GetMax();
726 // //ampc = 1.0*point->GetCPoint().GetQ();
727 // //AliTPCClusterPoint & p = point->GetCPoint();
728 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
729 // //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
731 // // 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 = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
739 // ampc *= 2.0; // put mean value to channel 50
740 // //ampc *= 0.58; // put mean value to channel 50
742 // // if (type>0) w = 1./(type/2.-0.5);
743 // // Float_t z = TMath::Abs(cl->GetZ());
746 // //ampc /= (1+0.0008*z);
750 // //ampc /= (1+0.0008*z);
752 // //ampc /= (1+0.0008*z);
755 // if (type<0) { //amp at the border - lower weight
760 // if (rsigma>1.5) ampc/=1.3; // if big backround
761 // amp[nc[of]] = ampc;
762 // amp[nc[of]] /=gainGG;
763 // angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
764 // weight[nc[of]] = w;
768 // TMath::Sort(nc[of],amp,index,kFALSE);
770 // Float_t sumamp2=0;
772 // //meanlog = amp[index[Int_t(nc[of]*0.33)]];
774 // for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
775 // Float_t ampl = amp[index[i]]/angular[index[i]];
776 // ampl = meanlog*TMath::Log(1.+ampl/meanlog);
778 // sumw += weight[index[i]];
779 // sumamp += weight[index[i]]*ampl;
780 // sumamp2 += weight[index[i]]*ampl*ampl;
781 // norm[of] += angular[index[i]]*weight[index[i]];
788 // mean[of] = sumamp/sumw;
789 // sigma[of] = sumamp2/sumw-mean[of]*mean[of];
790 // if (sigma[of]>0.1)
791 // sigma[of] = TMath::Sqrt(sigma[of]);
795 // mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
796 // //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
797 // //mean *=(1-0.1*(norm-1.));
804 // // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
805 // // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
808 // // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
809 // // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
813 // for (Int_t i =0;i<4;i++){
814 // if (nc[i]>2&&nc[i]<1000){
815 // dedx += mean[i] *nc[i];
816 // fSdEdx += sigma[i]*(nc[i]-2);
817 // fMAngular += norm[i] *nc[i];
821 // fDEDX[i] = mean[i];
822 // fSDEDX[i] = sigma[i];
823 // fNCDEDX[i]= nc[i];
835 // // Float_t dedx1 =dedx;
838 // for (Int_t i =0;i<4;i++){
839 // if (nc[i]>2&&nc[i]<1000){
840 // mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
841 // dedx += mean[i] *nc[i];
843 // fDEDX[i] = mean[i];
853 void AliTPCseed::CookPID()
856 // cook PID information according dEdx
858 Double_t fRange = 10.;
862 Int_t ns=AliPID::kSPECIES;
864 for (Int_t j=0; j<ns; j++) {
865 Double_t mass=AliPID::ParticleMass(j);
867 Double_t dedx=fdEdx/fMIP;
868 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
869 Double_t sigma=fRes*bethe;
871 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
872 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
876 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
884 for (Int_t j=0; j<ns; j++) {
885 fTPCr[j]/=sumr; //normalize
889 Double_t AliTPCseed::GetYat(Double_t xk) const {
890 //-----------------------------------------------------------------
891 // This function calculates the Y-coordinate of a track at the plane x=xk.
892 //-----------------------------------------------------------------
893 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
894 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
895 Double_t c2=c1+GetC()*(xk-GetX());
896 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
897 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
898 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
903 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){
906 // calculates dedx using the cluster
907 // low - up specify trunc mean range - default form 0-0.7
908 // type - 1 - max charge or 0- total charge in cluster
909 // //2- max no corr 3- total+ correction
910 // i1-i2 - the pad-row range used for calculation
911 // shapeNorm - kTRUE -taken from OCDB
913 // posNorm - usage of pos normalization
914 // padNorm - pad type normalization
915 // returnVal - 0 return mean
917 // - 2 return number of clusters
919 // normalization parametrization taken from AliTPCClusterParam
921 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
922 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
923 if (!parcl) return 0;
924 if (!param) return 0;
925 Int_t row0 = param->GetNRowLow();
926 Int_t row1 = row0+param->GetNRowUp1();
933 Float_t gainGG = 1; // gas gain factor -always enabled
934 Float_t gainPad = 1; // gain map - used always
935 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
936 Float_t corrPos = 1; // local position correction - if posNorm enabled
937 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
938 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
942 if (AliTPCcalibDB::Instance()->GetParameters()){
943 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
946 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
947 const Float_t kedgey =3.;
950 for (Int_t irow=i1; irow<i2; irow++){
951 AliTPCclusterMI* cluster = GetClusterPointer(irow);
952 if (!cluster) continue;
953 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
954 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
956 if (irow>=row0) ipad=1;
957 if (irow>=row1) ipad=2;
961 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
964 // Get gainPad - pad by pad calibration
967 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
968 if (irow < row0) { // IROC
969 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
971 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
973 if (factor>0.5) gainPad=factor;
976 //do position and angular normalization
981 AliTPCTrackerPoint * point = GetTrackPoint(irow);
982 Float_t ty = TMath::Abs(point->GetAngleY());
983 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
985 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
986 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
992 // Do position normalization - relative distance to
993 // center of pad- time bin
995 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
996 // cluster->GetTimeBin(), cluster->GetZ(),
997 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
998 // cluster->GetMax(),cluster->GetQ());
999 // scaled response function
1000 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1001 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1004 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1005 Float_t ty = TMath::Abs(point->GetAngleY());
1006 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1008 if (type==1) corrPos =
1009 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1010 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
1011 if (type==0) corrPos =
1012 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1013 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1015 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1016 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1017 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1018 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1019 if (corrHis>0) corrPos*=corrHis;
1026 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1027 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
1031 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1032 //use hardwired - temp fix
1033 if (type==0) corrNorm=3.;
1034 if (type==1) corrNorm=1.;
1040 amp[ncl]/=corrShape;
1041 amp[ncl]/=corrPadType;
1048 if (type>3) return ncl;
1049 TMath::Sort(ncl,amp, indexes, kFALSE);
1051 if (ncl<10) return 0;
1056 Int_t icl0=TMath::Nint(ncl*low);
1057 Int_t icl1=TMath::Nint(ncl*up);
1058 for (Int_t icl=icl0; icl<icl1;icl++){
1059 suma+=amp[indexes[icl]];
1060 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1063 Float_t mean =suma/sumn;
1064 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1066 // do time-dependent correction for pressure and temperature variations
1067 UInt_t runNumber = 1;
1068 Float_t corrTimeGain = 1;
1069 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1070 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1071 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
1072 runNumber = trans->GetCurrentRunNumber();
1073 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1074 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1075 if (timeGainSplines) {
1076 UInt_t time = trans->GetCurrentTimeStamp();
1077 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1078 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1080 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
1082 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
1086 mean /= corrTimeGain;
1087 rms /= corrTimeGain;
1089 if (returnVal==1) return rms;
1090 if (returnVal==2) return ncl;
1094 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){
1097 // calculates dedx using the cluster
1098 // low - up specify trunc mean range - default form 0-0.7
1099 // type - 1 - max charge or 0- total charge in cluster
1100 // //2- max no corr 3- total+ correction
1101 // i1-i2 - the pad-row range used for calculation
1103 // posNorm - usage of pos normalization
1104 // returnVal - 0 return mean
1106 // - 2 return number of clusters
1108 // - 4 mean upper half
1109 // - 5 mean - lower half
1111 // mode - 0 - linear
1112 // - 1 - logatithmic
1113 // rowThres - number of rows before and after given pad row to check for clusters below threshold
1115 // normalization parametrization taken from AliTPCClusterParam
1117 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1118 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1119 if (!parcl) return 0;
1120 if (!param) return 0;
1121 Int_t row0 = param->GetNRowLow();
1122 Int_t row1 = row0+param->GetNRowUp1();
1127 Int_t nclBelowThr = 0; // counts number of clusters below threshold
1130 Float_t gainGG = 1; // gas gain factor -always enabled
1131 Float_t gainPad = 1; // gain map - used always
1132 Float_t corrPos = 1; // local position correction - if posNorm enabled
1136 if (AliTPCcalibDB::Instance()->GetParameters()){
1137 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1140 // extract time-dependent correction for pressure and temperature variations
1142 UInt_t runNumber = 1;
1143 Float_t corrTimeGain = 1;
1144 TObjArray * timeGainSplines = 0x0;
1145 TGraphErrors * grPadEqual = 0x0;
1147 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1148 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1150 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1153 runNumber = trans->GetCurrentRunNumber();
1154 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1155 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1156 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1157 UInt_t time = trans->GetCurrentTimeStamp();
1158 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1159 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1161 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
1163 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1166 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1167 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
1171 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1172 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1173 const Float_t kedgey =3.;
1176 for (Int_t irow=i1; irow<i2; irow++){
1177 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1178 if (!cluster && irow > 1 && irow < 157) {
1179 Bool_t isClBefore = kFALSE;
1180 Bool_t isClAfter = kFALSE;
1181 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1182 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1183 if (clusterBefore) isClBefore = kTRUE;
1184 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1185 if (clusterAfter) isClAfter = kTRUE;
1187 if (isClBefore && isClAfter) nclBelowThr++;
1189 if (!cluster) continue;
1192 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1194 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1195 if (point==0) continue;
1196 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1197 if (rsigmay > kClusterShapeCut) continue;
1199 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1201 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1203 if (irow>=row0) ipad=1;
1204 if (irow>=row1) ipad=2;
1208 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1211 // Get gainPad - pad by pad calibration
1214 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1215 if (irow < row0) { // IROC
1216 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1218 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1220 if (factor>0.3) gainPad=factor;
1223 // Do position normalization - relative distance to
1224 // center of pad- time bin
1226 Float_t ty = TMath::Abs(point->GetAngleY());
1227 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1228 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1229 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1231 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1232 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1233 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1234 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1237 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1238 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1239 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1240 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1241 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1242 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1243 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1247 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1248 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1249 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1251 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1252 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1253 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1254 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1258 // pad region equalization outside of cluster param
1260 Float_t gainEqualPadRegion = 1;
1261 if (grPadEqual) gainEqualPadRegion = grPadEqual->Eval(ipad);
1267 amp[ncl]/=gainEqualPadRegion;
1272 if (type==2) return ncl;
1273 TMath::Sort(ncl,amp, indexes, kFALSE);
1275 if (ncl<10) return 0;
1277 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1278 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1279 if (iCl < nclBelowThr) {
1280 ampWithBelow[iCl] = amp[indexes[0]];
1282 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1285 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1292 // upper,and lower part statistic
1293 Float_t sumL=0, sumL2=0, sumLN=0;
1294 Float_t sumD=0, sumD2=0, sumDN=0;
1296 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1297 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
1298 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1300 for (Int_t icl=icl0; icl<icl1;icl++){
1301 if (ampWithBelow[icl]<0.1) continue;
1302 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1303 if (mode==1) camp= TMath::Log(camp);
1307 suma3+=camp*camp*camp;
1308 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
1325 Float_t meanD = 0; // lower half mean
1326 if (sumn > 1e-30) mean =suma/sumn;
1327 if (sumLN > 1e-30) meanL =sumL/sumLN;
1328 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1330 Float_t mean =suma/sumn;
1331 Float_t meanL = sumL/sumLN;
1332 Float_t meanD =(sumD/sumDN); // lower half mean
1341 rms = TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1347 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1348 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1349 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
1351 if (mode==1) mean=TMath::Exp(mean);
1352 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1353 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1355 delete [] ampWithBelow;
1359 if (returnVal==1) return rms;
1360 if (returnVal==2) return ncl;
1361 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1362 if (returnVal==4) return meanL;
1363 if (returnVal==5) return meanD;
1364 if (returnVal==6) return mean2;
1365 if (returnVal==7) return mean3;
1366 if (returnVal==8) return meanS;
1373 Float_t AliTPCseed::CookShape(Int_t type){
1377 //-----------------------------------------------------------------
1378 // This funtion calculates dE/dX within the "low" and "up" cuts.
1379 //-----------------------------------------------------------------
1382 for (Int_t i =0; i<160;i++) {
1383 AliTPCTrackerPoint * point = GetTrackPoint(i);
1384 if (point==0) continue;
1386 AliTPCclusterMI * cl = fClusterPointer[i];
1387 if (cl==0) continue;
1389 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1390 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1391 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1392 if (type==0) means+=rsigma;
1393 if (type==1) means+=rsigmay;
1394 if (type==2) means+=rsigmaz;
1397 Float_t mean = (meanc>0)? means/meanc:0;
1403 Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1406 // return value - number of used clusters
1409 const Int_t kMinNcl =10;
1410 AliTPCseed *track=new AliTPCseed(*seed);
1415 for (Int_t i=0;i<15;i++) covar[i]=0;
1418 covar[5]=10.*10./(64.*64.);
1419 covar[9]=10.*10./(64.*64.);
1423 Float_t xmin=1000, xmax=-10000;
1424 Int_t imin=158, imax=0;
1425 for (Int_t i=0;i<160;i++) {
1426 AliTPCclusterMI *c=track->GetClusterPointer(i);
1428 if (sector<0) sector = c->GetDetector();
1429 if (c->GetX()<xmin) xmin=c->GetX();
1430 if (c->GetX()>xmax) xmax=c->GetX();
1434 if(imax-imin<kMinNcl) {
1438 // Not succes to rotate
1439 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1445 // fit from inner to outer row
1447 AliExternalTrackParam paramIn;
1448 AliExternalTrackParam paramOut;
1454 for (Int_t i=imin; i<=imax; i++){
1455 AliTPCclusterMI *c=track->GetClusterPointer(i);
1457 // if (RejectCluster(c,track)) continue;
1458 sector = (c->GetDetector()%18);
1459 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1462 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1463 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1464 if (!track->PropagateTo(r[0])) {
1467 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1469 if (!isOK) { delete track; return 0;}
1470 track->AddCovariance(covar);
1474 for (Int_t i=imax; i>=imin; i--){
1475 AliTPCclusterMI *c=track->GetClusterPointer(i);
1477 //if (RejectCluster(c,track)) continue;
1478 sector = (c->GetDetector()%18);
1479 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1482 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1483 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1484 if (!track->PropagateTo(r[0])) {
1487 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1489 //if (!isOK) { delete track; return 0;}
1491 track->AddCovariance(covar);
1494 for (Int_t i=imin; i<=imax; i++){
1495 AliTPCclusterMI *c=track->GetClusterPointer(i);
1497 sector = (c->GetDetector()%18);
1498 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1502 //if (RejectCluster(c,track)) continue;
1503 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1504 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1505 if (!track->PropagateTo(r[0])) {
1508 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1510 //if (!isOK) { delete track; return 0;}
1515 if (parin) (*parin)=paramIn;
1516 if (parout) (*parout)=paramOut;
1523 Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1535 void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1536 Double_t& erry, Double_t &errz)
1539 // Get cluster error at given position
1541 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1543 Double_t snp1=param->GetSnp();
1544 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1546 Double_t tgl1=param->GetTgl();
1547 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1549 Int_t padSize = 0; // short pads
1550 if (cluster->GetDetector() >= 36) {
1551 padSize = 1; // medium pads
1552 if (cluster->GetRow() > 63) padSize = 2; // long pads
1555 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1556 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1560 void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1561 Double_t& rmsy, Double_t &rmsz)
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 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1581 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1586 Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1588 //ty - tangent in local y direction
1591 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1595 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*/){
1599 // return value = Q Normalization factor
1600 // Normalization - 1 - shape factor part for full drift
1601 // 1 - electron attachment for 0 drift
1603 // Input parameters:
1605 // ipad - 0 short pad
1612 //z - z position (-250,250 cm)
1613 //ty - tangent in local y direction
1617 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1618 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1620 if (!paramCl) return 1;
1622 Double_t dr = 250.-TMath::Abs(z);
1623 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1624 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1625 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1626 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1628 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1631 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1632 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1635 if (type==0) return sfactorMax*attProb;
1643 //_______________________________________________________________________
1644 Float_t AliTPCseed::GetTPCClustInfo(Int_t nNeighbours, Int_t type, Int_t row0, Int_t row1)
1647 // TPC cluster information
1648 // type 0: get fraction of found/findable clusters with neighbourhood definition
1649 // 1: found clusters
1650 // 2: findable (number of clusters above and below threshold)
1652 // definition of findable clusters:
1653 // a cluster is defined as findable if there is another cluster
1654 // within +- nNeighbours pad rows. The idea is to overcome threshold
1655 // effects with a very simple algorithm.
1658 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1659 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1660 const Float_t kedgey =3.;
1663 Float_t nclBelowThr = 0; // counts number of clusters below threshold
1665 for (Int_t irow=row0; irow<row1; irow++){
1666 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1668 if (!cluster && irow > 1 && irow < 157) {
1669 Bool_t isClBefore = kFALSE;
1670 Bool_t isClAfter = kFALSE;
1671 for(Int_t ithres = 1; ithres <= nNeighbours; ithres++) {
1672 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1673 if (clusterBefore) isClBefore = kTRUE;
1674 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1675 if (clusterAfter) isClAfter = kTRUE;
1677 if (isClBefore && isClAfter) nclBelowThr++;
1679 if (!cluster) continue;
1682 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1684 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1685 if (point==0) continue;
1686 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1687 if (rsigmay > kClusterShapeCut) continue;
1689 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1696 if(nclBelowThr+ncl>0)
1697 return ncl/(nclBelowThr+ncl);
1701 return ncl+nclBelowThr;
1705 //_______________________________________________________________________
1706 void AliTPCseed::Clear(Option_t*)
1708 // formally seed may allocate memory for clusters (althought this should not happen for
1709 // the seeds in the pool). Hence we need this method for fwd. compatibility
1710 if (fClusterOwner) for (int i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i] = 0;}