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)fClusterPointer[i] = new AliTPCclusterMI(*(param.fClusterPointer[i]));
271 // leave out fPoint, they are also not copied in the copy ctor...
272 // but deleted in the dtor... strange...
274 fSector = param.fSector;
275 fRelativeSector = param.fRelativeSector;
276 fCurrentSigmaY2 = param.fCurrentSigmaY2;
277 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
278 fErrorY2 = param.fErrorY2;
279 fErrorZ2 = param.fErrorZ2;
280 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
281 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
282 fInDead = param.fInDead;
283 fIsSeeding = param.fIsSeeding;
284 fNoCluster = param.fNoCluster;
286 fBSigned = param.fBSigned;
287 for(Int_t i = 0;i<4;++i){
288 fDEDX[i] = param.fDEDX[i];
289 fSDEDX[i] = param.fSDEDX[i];
290 fNCDEDX[i] = param.fNCDEDX[i];
291 fNCDEDXInclThres[i] = param.fNCDEDXInclThres[i];
293 fDEDX[4] = param.fDEDX[4];
294 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
296 fSeedType = param.fSeedType;
297 fSeed1 = param.fSeed1;
298 fSeed2 = param.fSeed2;
299 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
300 fMAngular = param.fMAngular;
301 fCircular = param.fCircular;
302 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
306 //____________________________________________________
307 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
311 return &fTrackPoints[i];
316 Double_t AliTPCseed::GetDensityFirst(Int_t n)
320 // return cluster for n rows bellow first point
321 Int_t nfoundable = 1;
323 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
324 Int_t index = GetClusterIndex2(i);
325 if (index!=-1) nfoundable++;
326 if (index>0) nfound++;
328 if (nfoundable<n) return 0;
329 return Double_t(nfound)/Double_t(nfoundable);
334 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
336 // get cluster stat. on given region
341 for (Int_t i=first;i<last; i++){
342 Int_t index = GetClusterIndex2(i);
343 if (index!=-1) foundable++;
344 if (index&0x8000) continue;
345 if (fClusterPointer[i]) {
351 if (fClusterPointer[i]->IsUsed(10)) {
355 if (!plus2) continue; //take also neighborhoud
357 if ( (i>0) && fClusterPointer[i-1]){
358 if (fClusterPointer[i-1]->IsUsed(10)) {
363 if ( fClusterPointer[i+1]){
364 if (fClusterPointer[i+1]->IsUsed(10)) {
372 //Error("AliTPCseed::GetClusterStatistic","problem\n");
380 void AliTPCseed::Reset(Bool_t all)
384 SetNumberOfClusters(0);
387 ResetCovariance(10.);
390 for (Int_t i=0;i<8;i++){
391 delete [] fTrackPoints[i];
399 for (Int_t i=200;i--;) SetClusterIndex2(i,-3);
400 if (!fClusterOwner) for (Int_t i=160;i--;) fClusterPointer[i]=0;
401 else for (Int_t i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i]=0;}
407 void AliTPCseed::Modify(Double_t factor)
410 //------------------------------------------------------------------
411 //This function makes a track forget its history :)
412 //------------------------------------------------------------------
414 ResetCovariance(10.);
417 ResetCovariance(factor);
419 SetNumberOfClusters(0);
423 fCurrentSigmaY2 = 0.000005;
424 fCurrentSigmaZ2 = 0.000005;
433 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
435 //-----------------------------------------------------------------
436 // This function find proloncation of a track to a reference plane x=xk.
437 // doesn't change internal state of the track
438 //-----------------------------------------------------------------
440 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
442 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
446 // Double_t y1=fP0, z1=fP1;
447 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
448 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
452 //y += dx*(c1+c2)/(r1+r2);
453 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
455 Double_t dy = dx*(c1+c2)/(r1+r2);
458 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
460 if (TMath::Abs(delta)>0.0001){
461 dz = fP3*TMath::ASin(delta)/fP4;
463 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
466 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
467 dz = GetTgl()*TMath::ASin(delta)/GetC();
477 //_____________________________________________________________________________
478 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
480 //-----------------------------------------------------------------
481 // This function calculates a predicted chi2 increment.
482 //-----------------------------------------------------------------
483 Double_t p[2]={c->GetY(), c->GetZ()};
484 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
486 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
487 if (TMath::Abs(dx)>0){
488 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
490 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
494 return AliExternalTrackParam::GetPredictedChi2(p,cov);
497 //_________________________________________________________________________________________
500 Int_t AliTPCseed::Compare(const TObject *o) const {
501 //-----------------------------------------------------------------
502 // This function compares tracks according to the sector - for given sector according z
503 //-----------------------------------------------------------------
504 AliTPCseed *t=(AliTPCseed*)o;
507 if (t->fRelativeSector>fRelativeSector) return -1;
508 if (t->fRelativeSector<fRelativeSector) return 1;
509 Double_t z2 = t->GetZ();
510 Double_t z1 = GetZ();
512 if (z2<z1) return -1;
517 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
518 if (t->fBConstrain) f2=1.2;
521 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
523 if (fBConstrain) f1=1.2;
525 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
533 //_____________________________________________________________________________
534 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
536 //-----------------------------------------------------------------
537 // This function associates a cluster with this track.
538 //-----------------------------------------------------------------
539 Int_t n=GetNumberOfClusters();
540 Int_t idx=GetClusterIndex(n); // save the current cluster index
542 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
543 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
544 if (TMath::Abs(dx)>0){
545 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
547 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
548 cl.SetY(c->GetY()-dy);
549 cl.SetZ(c->GetZ()-dz);
552 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
554 if (fCMeanSigmaY2p30<0){
555 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
556 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
557 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
558 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
561 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
562 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
563 if (fCurrentSigmaY2>0){
564 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
565 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
569 SetClusterIndex(n,idx); // restore the current cluster index
575 //_____________________________________________________________________________
576 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
577 //-----------------------------------------------------------------
578 // This funtion calculates dE/dX within the "low" and "up" cuts.
579 //-----------------------------------------------------------------
580 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
581 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
583 Int_t row0 = param->GetNRowLow();
584 Int_t row1 = row0+param->GetNRowUp1();
585 Int_t row2 = row1+param->GetNRowUp2();
586 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
588 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
592 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
593 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
594 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
595 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
596 fDEDX[4] = CookdEdxAnalytical(low,up,useTot ,row0,row2, 0); // full OROC truncated mean
598 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
599 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
600 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
601 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
603 fNCDEDX[0] = TMath::Nint(GetTPCClustInfo(2, 1, i1 , i2));
604 fNCDEDX[1] = TMath::Nint(GetTPCClustInfo(2, 1, 0 , row0));
605 fNCDEDX[2] = TMath::Nint(GetTPCClustInfo(2, 1, row0, row1));
606 fNCDEDX[3] = TMath::Nint(GetTPCClustInfo(2, 1, row1, row2));
608 fNCDEDXInclThres[0] = TMath::Nint(GetTPCClustInfo(2, 2, i1 , i2));
609 fNCDEDXInclThres[1] = TMath::Nint(GetTPCClustInfo(2, 2, 0 , row0));
610 fNCDEDXInclThres[2] = TMath::Nint(GetTPCClustInfo(2, 2, row0, row1));
611 fNCDEDXInclThres[3] = TMath::Nint(GetTPCClustInfo(2, 2, row1, row2));
616 // return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
620 // Float_t angular[200];
621 // Float_t weight[200];
624 // Float_t meanlog = 100.;
626 // Float_t mean[4] = {0,0,0,0};
627 // Float_t sigma[4] = {1000,1000,1000,1000};
628 // Int_t nc[4] = {0,0,0,0};
629 // Float_t norm[4] = {1000,1000,1000,1000};
634 // Float_t gainGG = 1;
635 // if (AliTPCcalibDB::Instance()->GetParameters()){
636 // gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
640 // for (Int_t of =0; of<4; of++){
641 // for (Int_t i=of+i1;i<i2;i+=4)
643 // Int_t clindex = fIndex[i];
644 // if (clindex<0||clindex&0x8000) continue;
646 // //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
647 // AliTPCTrackerPoint * point = GetTrackPoint(i);
648 // //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
649 // //AliTPCTrackerPoint * pointp = 0;
650 // //if (i<159) pointp = GetTrackPoint(i+1);
652 // if (point==0) continue;
653 // AliTPCclusterMI * cl = fClusterPointer[i];
654 // if (cl==0) continue;
655 // if (onlyused && (!cl->IsUsed(10))) continue;
656 // if (cl->IsUsed(11)) {
660 // Int_t type = cl->GetType();
661 // //if (point->fIsShared){
666 // // if (pointm->fIsShared) continue;
668 // // if (pointp->fIsShared) continue;
670 // if (type<0) continue;
671 // //if (type>10) continue;
672 // //if (point->GetErrY()==0) continue;
673 // //if (point->GetErrZ()==0) continue;
675 // //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
676 // //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
677 // //if ((ddy*ddy+ddz*ddz)>10) continue;
680 // // if (point->GetCPoint().GetMax()<5) continue;
681 // if (cl->GetMax()<5) continue;
682 // Float_t angley = point->GetAngleY();
683 // Float_t anglez = point->GetAngleZ();
685 // Float_t rsigmay2 = point->GetSigmaY();
686 // Float_t rsigmaz2 = point->GetSigmaZ();
690 // rsigmay += pointm->GetTPoint().GetSigmaY();
691 // rsigmaz += pointm->GetTPoint().GetSigmaZ();
695 // rsigmay += pointp->GetTPoint().GetSigmaY();
696 // rsigmaz += pointp->GetTPoint().GetSigmaZ();
703 // Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
705 // Float_t ampc = 0; // normalization to the number of electrons
707 // // ampc = 1.*point->GetCPoint().GetMax();
708 // ampc = 1.*cl->GetMax();
709 // //ampc = 1.*point->GetCPoint().GetQ();
710 // // AliTPCClusterPoint & p = point->GetCPoint();
711 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
712 // // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
714 // // TMath::Abs( Int_t(iz) - iz + 0.5);
715 // //ampc *= 1.15*(1-0.3*dy);
716 // //ampc *= 1.15*(1-0.3*dz);
717 // // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
721 // //ampc = 1.0*point->GetCPoint().GetMax();
722 // ampc = 1.0*cl->GetMax();
723 // //ampc = 1.0*point->GetCPoint().GetQ();
724 // //AliTPCClusterPoint & p = point->GetCPoint();
725 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
726 // //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
728 // // TMath::Abs( Int_t(iz) - iz + 0.5);
730 // //ampc *= 1.15*(1-0.3*dy);
731 // //ampc *= 1.15*(1-0.3*dz);
732 // // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
736 // ampc *= 2.0; // put mean value to channel 50
737 // //ampc *= 0.58; // put mean value to channel 50
739 // // if (type>0) w = 1./(type/2.-0.5);
740 // // Float_t z = TMath::Abs(cl->GetZ());
743 // //ampc /= (1+0.0008*z);
747 // //ampc /= (1+0.0008*z);
749 // //ampc /= (1+0.0008*z);
752 // if (type<0) { //amp at the border - lower weight
757 // if (rsigma>1.5) ampc/=1.3; // if big backround
758 // amp[nc[of]] = ampc;
759 // amp[nc[of]] /=gainGG;
760 // angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
761 // weight[nc[of]] = w;
765 // TMath::Sort(nc[of],amp,index,kFALSE);
767 // Float_t sumamp2=0;
769 // //meanlog = amp[index[Int_t(nc[of]*0.33)]];
771 // for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
772 // Float_t ampl = amp[index[i]]/angular[index[i]];
773 // ampl = meanlog*TMath::Log(1.+ampl/meanlog);
775 // sumw += weight[index[i]];
776 // sumamp += weight[index[i]]*ampl;
777 // sumamp2 += weight[index[i]]*ampl*ampl;
778 // norm[of] += angular[index[i]]*weight[index[i]];
785 // mean[of] = sumamp/sumw;
786 // sigma[of] = sumamp2/sumw-mean[of]*mean[of];
787 // if (sigma[of]>0.1)
788 // sigma[of] = TMath::Sqrt(sigma[of]);
792 // mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
793 // //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
794 // //mean *=(1-0.1*(norm-1.));
801 // // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
802 // // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
805 // // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
806 // // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
810 // for (Int_t i =0;i<4;i++){
811 // if (nc[i]>2&&nc[i]<1000){
812 // dedx += mean[i] *nc[i];
813 // fSdEdx += sigma[i]*(nc[i]-2);
814 // fMAngular += norm[i] *nc[i];
818 // fDEDX[i] = mean[i];
819 // fSDEDX[i] = sigma[i];
820 // fNCDEDX[i]= nc[i];
832 // // Float_t dedx1 =dedx;
835 // for (Int_t i =0;i<4;i++){
836 // if (nc[i]>2&&nc[i]<1000){
837 // mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
838 // dedx += mean[i] *nc[i];
840 // fDEDX[i] = mean[i];
850 void AliTPCseed::CookPID()
853 // cook PID information according dEdx
855 Double_t fRange = 10.;
859 Int_t ns=AliPID::kSPECIES;
861 for (Int_t j=0; j<ns; j++) {
862 Double_t mass=AliPID::ParticleMass(j);
864 Double_t dedx=fdEdx/fMIP;
865 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
866 Double_t sigma=fRes*bethe;
868 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
869 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
873 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
881 for (Int_t j=0; j<ns; j++) {
882 fTPCr[j]/=sumr; //normalize
886 Double_t AliTPCseed::GetYat(Double_t xk) const {
887 //-----------------------------------------------------------------
888 // This function calculates the Y-coordinate of a track at the plane x=xk.
889 //-----------------------------------------------------------------
890 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
891 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
892 Double_t c2=c1+GetC()*(xk-GetX());
893 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
894 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
895 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
900 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){
903 // calculates dedx using the cluster
904 // low - up specify trunc mean range - default form 0-0.7
905 // type - 1 - max charge or 0- total charge in cluster
906 // //2- max no corr 3- total+ correction
907 // i1-i2 - the pad-row range used for calculation
908 // shapeNorm - kTRUE -taken from OCDB
910 // posNorm - usage of pos normalization
911 // padNorm - pad type normalization
912 // returnVal - 0 return mean
914 // - 2 return number of clusters
916 // normalization parametrization taken from AliTPCClusterParam
918 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
919 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
920 if (!parcl) return 0;
921 if (!param) return 0;
922 Int_t row0 = param->GetNRowLow();
923 Int_t row1 = row0+param->GetNRowUp1();
930 Float_t gainGG = 1; // gas gain factor -always enabled
931 Float_t gainPad = 1; // gain map - used always
932 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
933 Float_t corrPos = 1; // local position correction - if posNorm enabled
934 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
935 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
939 if (AliTPCcalibDB::Instance()->GetParameters()){
940 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
943 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
944 const Float_t kedgey =3.;
947 for (Int_t irow=i1; irow<i2; irow++){
948 AliTPCclusterMI* cluster = GetClusterPointer(irow);
949 if (!cluster) continue;
950 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
951 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
953 if (irow>=row0) ipad=1;
954 if (irow>=row1) ipad=2;
958 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
961 // Get gainPad - pad by pad calibration
964 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
965 if (irow < row0) { // IROC
966 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
968 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
970 if (factor>0.5) gainPad=factor;
973 //do position and angular normalization
978 AliTPCTrackerPoint * point = GetTrackPoint(irow);
979 Float_t ty = TMath::Abs(point->GetAngleY());
980 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
982 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
983 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
989 // Do position normalization - relative distance to
990 // center of pad- time bin
992 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
993 // cluster->GetTimeBin(), cluster->GetZ(),
994 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
995 // cluster->GetMax(),cluster->GetQ());
996 // scaled response function
997 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
998 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1001 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1002 Float_t ty = TMath::Abs(point->GetAngleY());
1003 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1005 if (type==1) corrPos =
1006 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1007 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
1008 if (type==0) corrPos =
1009 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1010 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1012 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1013 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1014 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1015 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1016 if (corrHis>0) corrPos*=corrHis;
1023 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1024 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
1028 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1029 //use hardwired - temp fix
1030 if (type==0) corrNorm=3.;
1031 if (type==1) corrNorm=1.;
1037 amp[ncl]/=corrShape;
1038 amp[ncl]/=corrPadType;
1045 if (type>3) return ncl;
1046 TMath::Sort(ncl,amp, indexes, kFALSE);
1048 if (ncl<10) return 0;
1053 Int_t icl0=TMath::Nint(ncl*low);
1054 Int_t icl1=TMath::Nint(ncl*up);
1055 for (Int_t icl=icl0; icl<icl1;icl++){
1056 suma+=amp[indexes[icl]];
1057 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1060 Float_t mean =suma/sumn;
1061 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1063 // do time-dependent correction for pressure and temperature variations
1064 UInt_t runNumber = 1;
1065 Float_t corrTimeGain = 1;
1066 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1067 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1068 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
1069 runNumber = trans->GetCurrentRunNumber();
1070 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1071 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1072 if (timeGainSplines) {
1073 UInt_t time = trans->GetCurrentTimeStamp();
1074 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1075 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1077 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
1079 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
1083 mean /= corrTimeGain;
1084 rms /= corrTimeGain;
1086 if (returnVal==1) return rms;
1087 if (returnVal==2) return ncl;
1091 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){
1094 // calculates dedx using the cluster
1095 // low - up specify trunc mean range - default form 0-0.7
1096 // type - 1 - max charge or 0- total charge in cluster
1097 // //2- max no corr 3- total+ correction
1098 // i1-i2 - the pad-row range used for calculation
1100 // posNorm - usage of pos normalization
1101 // returnVal - 0 return mean
1103 // - 2 return number of clusters
1105 // - 4 mean upper half
1106 // - 5 mean - lower half
1108 // mode - 0 - linear
1109 // - 1 - logatithmic
1110 // rowThres - number of rows before and after given pad row to check for clusters below threshold
1112 // normalization parametrization taken from AliTPCClusterParam
1114 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1115 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1116 if (!parcl) return 0;
1117 if (!param) return 0;
1118 Int_t row0 = param->GetNRowLow();
1119 Int_t row1 = row0+param->GetNRowUp1();
1124 Int_t nclBelowThr = 0; // counts number of clusters below threshold
1127 Float_t gainGG = 1; // gas gain factor -always enabled
1128 Float_t gainPad = 1; // gain map - used always
1129 Float_t corrPos = 1; // local position correction - if posNorm enabled
1133 if (AliTPCcalibDB::Instance()->GetParameters()){
1134 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1137 // extract time-dependent correction for pressure and temperature variations
1139 UInt_t runNumber = 1;
1140 Float_t corrTimeGain = 1;
1141 TObjArray * timeGainSplines = 0x0;
1142 TGraphErrors * grPadEqual = 0x0;
1144 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1145 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1147 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1150 runNumber = trans->GetCurrentRunNumber();
1151 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1152 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1153 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1154 UInt_t time = trans->GetCurrentTimeStamp();
1155 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1156 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1158 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
1160 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1163 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1164 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
1168 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1169 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1170 const Float_t kedgey =3.;
1173 for (Int_t irow=i1; irow<i2; irow++){
1174 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1175 if (!cluster && irow > 1 && irow < 157) {
1176 Bool_t isClBefore = kFALSE;
1177 Bool_t isClAfter = kFALSE;
1178 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1179 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1180 if (clusterBefore) isClBefore = kTRUE;
1181 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1182 if (clusterAfter) isClAfter = kTRUE;
1184 if (isClBefore && isClAfter) nclBelowThr++;
1186 if (!cluster) continue;
1189 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1191 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1192 if (point==0) continue;
1193 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1194 if (rsigmay > kClusterShapeCut) continue;
1196 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1198 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1200 if (irow>=row0) ipad=1;
1201 if (irow>=row1) ipad=2;
1205 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1208 // Get gainPad - pad by pad calibration
1211 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1212 if (irow < row0) { // IROC
1213 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1215 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1217 if (factor>0.3) gainPad=factor;
1220 // Do position normalization - relative distance to
1221 // center of pad- time bin
1223 Float_t ty = TMath::Abs(point->GetAngleY());
1224 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1225 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1226 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1228 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1229 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1230 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1231 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1234 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1235 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1236 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1237 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1238 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1239 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1240 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1244 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1245 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1246 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1248 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1249 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1250 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1251 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1255 // pad region equalization outside of cluster param
1257 Float_t gainEqualPadRegion = 1;
1258 if (grPadEqual) gainEqualPadRegion = grPadEqual->Eval(ipad);
1264 amp[ncl]/=gainEqualPadRegion;
1269 if (type==2) return ncl;
1270 TMath::Sort(ncl,amp, indexes, kFALSE);
1272 if (ncl<10) return 0;
1274 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1275 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1276 if (iCl < nclBelowThr) {
1277 ampWithBelow[iCl] = amp[indexes[0]];
1279 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1282 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1289 // upper,and lower part statistic
1290 Float_t sumL=0, sumL2=0, sumLN=0;
1291 Float_t sumD=0, sumD2=0, sumDN=0;
1293 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1294 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
1295 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1297 for (Int_t icl=icl0; icl<icl1;icl++){
1298 if (ampWithBelow[icl]<0.1) continue;
1299 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1300 if (mode==1) camp= TMath::Log(camp);
1304 suma3+=camp*camp*camp;
1305 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
1322 Float_t meanD = 0; // lower half mean
1323 if (sumn > 1e-30) mean =suma/sumn;
1324 if (sumLN > 1e-30) meanL =sumL/sumLN;
1325 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1327 Float_t mean =suma/sumn;
1328 Float_t meanL = sumL/sumLN;
1329 Float_t meanD =(sumD/sumDN); // lower half mean
1338 rms = TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1344 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1345 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1346 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
1348 if (mode==1) mean=TMath::Exp(mean);
1349 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1350 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1352 delete [] ampWithBelow;
1356 if (returnVal==1) return rms;
1357 if (returnVal==2) return ncl;
1358 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1359 if (returnVal==4) return meanL;
1360 if (returnVal==5) return meanD;
1361 if (returnVal==6) return mean2;
1362 if (returnVal==7) return mean3;
1363 if (returnVal==8) return meanS;
1370 Float_t AliTPCseed::CookShape(Int_t type){
1374 //-----------------------------------------------------------------
1375 // This funtion calculates dE/dX within the "low" and "up" cuts.
1376 //-----------------------------------------------------------------
1379 for (Int_t i =0; i<160;i++) {
1380 AliTPCTrackerPoint * point = GetTrackPoint(i);
1381 if (point==0) continue;
1383 AliTPCclusterMI * cl = fClusterPointer[i];
1384 if (cl==0) continue;
1386 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1387 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1388 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1389 if (type==0) means+=rsigma;
1390 if (type==1) means+=rsigmay;
1391 if (type==2) means+=rsigmaz;
1394 Float_t mean = (meanc>0)? means/meanc:0;
1400 Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1403 // return value - number of used clusters
1406 const Int_t kMinNcl =10;
1407 AliTPCseed *track=new AliTPCseed(*seed);
1412 for (Int_t i=0;i<15;i++) covar[i]=0;
1415 covar[5]=10.*10./(64.*64.);
1416 covar[9]=10.*10./(64.*64.);
1420 Float_t xmin=1000, xmax=-10000;
1421 Int_t imin=158, imax=0;
1422 for (Int_t i=0;i<160;i++) {
1423 AliTPCclusterMI *c=track->GetClusterPointer(i);
1425 if (sector<0) sector = c->GetDetector();
1426 if (c->GetX()<xmin) xmin=c->GetX();
1427 if (c->GetX()>xmax) xmax=c->GetX();
1431 if(imax-imin<kMinNcl) {
1435 // Not succes to rotate
1436 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1442 // fit from inner to outer row
1444 AliExternalTrackParam paramIn;
1445 AliExternalTrackParam paramOut;
1451 for (Int_t i=imin; i<=imax; i++){
1452 AliTPCclusterMI *c=track->GetClusterPointer(i);
1454 // if (RejectCluster(c,track)) continue;
1455 sector = (c->GetDetector()%18);
1456 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1459 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1460 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1461 if (!track->PropagateTo(r[0])) {
1464 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1466 if (!isOK) { delete track; return 0;}
1467 track->AddCovariance(covar);
1471 for (Int_t i=imax; i>=imin; i--){
1472 AliTPCclusterMI *c=track->GetClusterPointer(i);
1474 //if (RejectCluster(c,track)) continue;
1475 sector = (c->GetDetector()%18);
1476 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1479 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1480 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1481 if (!track->PropagateTo(r[0])) {
1484 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1486 //if (!isOK) { delete track; return 0;}
1488 track->AddCovariance(covar);
1491 for (Int_t i=imin; i<=imax; i++){
1492 AliTPCclusterMI *c=track->GetClusterPointer(i);
1494 sector = (c->GetDetector()%18);
1495 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1499 //if (RejectCluster(c,track)) continue;
1500 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1501 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1502 if (!track->PropagateTo(r[0])) {
1505 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1507 //if (!isOK) { delete track; return 0;}
1512 if (parin) (*parin)=paramIn;
1513 if (parout) (*parout)=paramOut;
1520 Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1532 void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1533 Double_t& erry, Double_t &errz)
1536 // Get cluster error at given position
1538 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1540 Double_t snp1=param->GetSnp();
1541 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1543 Double_t tgl1=param->GetTgl();
1544 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1546 Int_t padSize = 0; // short pads
1547 if (cluster->GetDetector() >= 36) {
1548 padSize = 1; // medium pads
1549 if (cluster->GetRow() > 63) padSize = 2; // long pads
1552 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1553 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1557 void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1558 Double_t& rmsy, Double_t &rmsz)
1561 // Get cluster error at given position
1563 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1565 Double_t snp1=param->GetSnp();
1566 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1568 Double_t tgl1=param->GetTgl();
1569 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1571 Int_t padSize = 0; // short pads
1572 if (cluster->GetDetector() >= 36) {
1573 padSize = 1; // medium pads
1574 if (cluster->GetRow() > 63) padSize = 2; // long pads
1577 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1578 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1583 Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1585 //ty - tangent in local y direction
1588 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1592 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*/){
1596 // return value = Q Normalization factor
1597 // Normalization - 1 - shape factor part for full drift
1598 // 1 - electron attachment for 0 drift
1600 // Input parameters:
1602 // ipad - 0 short pad
1609 //z - z position (-250,250 cm)
1610 //ty - tangent in local y direction
1614 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1615 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1617 if (!paramCl) return 1;
1619 Double_t dr = 250.-TMath::Abs(z);
1620 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1621 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1622 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1623 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1625 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1628 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1629 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1632 if (type==0) return sfactorMax*attProb;
1640 //_______________________________________________________________________
1641 Float_t AliTPCseed::GetTPCClustInfo(Int_t nNeighbours, Int_t type, Int_t row0, Int_t row1)
1644 // TPC cluster information
1645 // type 0: get fraction of found/findable clusters with neighbourhood definition
1646 // 1: found clusters
1647 // 2: findable (number of clusters above and below threshold)
1649 // definition of findable clusters:
1650 // a cluster is defined as findable if there is another cluster
1651 // within +- nNeighbours pad rows. The idea is to overcome threshold
1652 // effects with a very simple algorithm.
1655 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1656 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1657 const Float_t kedgey =3.;
1660 Float_t nclBelowThr = 0; // counts number of clusters below threshold
1662 for (Int_t irow=row0; irow<row1; irow++){
1663 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1665 if (!cluster && irow > 1 && irow < 157) {
1666 Bool_t isClBefore = kFALSE;
1667 Bool_t isClAfter = kFALSE;
1668 for(Int_t ithres = 1; ithres <= nNeighbours; ithres++) {
1669 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1670 if (clusterBefore) isClBefore = kTRUE;
1671 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1672 if (clusterAfter) isClAfter = kTRUE;
1674 if (isClBefore && isClAfter) nclBelowThr++;
1676 if (!cluster) continue;
1679 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1681 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1682 if (point==0) continue;
1683 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1684 if (rsigmay > kClusterShapeCut) continue;
1686 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1693 if(nclBelowThr+ncl>0)
1694 return ncl/(nclBelowThr+ncl);
1698 return ncl+nclBelowThr;
1702 //_______________________________________________________________________
1703 void AliTPCseed::Clear(Option_t*)
1705 // formally seed may allocate memory for clusters (althought this should not happen for
1706 // the seeds in the pool). Hence we need this method for fwd. compatibility
1707 if (fClusterOwner) for (int i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i] = 0;}