1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 //-----------------------------------------------------------------
20 // Implementation of the TPC seed class
21 // This class is used by the AliTPCtrackerMI class
22 // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
23 //-----------------------------------------------------------------
24 #include "TClonesArray.h"
25 #include "AliTPCseed.h"
26 #include "AliTPCReconstructor.h"
32 AliTPCseed::AliTPCseed():
35 fClusterOwner(kFALSE),
41 fCurrentSigmaY2(1e10),
42 fCurrentSigmaZ2(1e10),
46 fCurrentClusterIndex1(-1),
59 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
60 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
61 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
62 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
63 for (Int_t i=0;i<4;i++) {
68 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
71 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
74 fClusterOwner(clusterOwner),
80 fCurrentSigmaY2(1e10),
81 fCurrentSigmaZ2(1e10),
85 fCurrentClusterIndex1(-1),
97 //---------------------
98 // dummy copy constructor
99 //-------------------------
100 for (Int_t i=0;i<160;i++) {
101 fClusterPointer[i]=0;
103 if (s.fClusterPointer[i])
104 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
106 fClusterPointer[i] = s.fClusterPointer[i];
108 fTrackPoints[i] = s.fTrackPoints[i];
110 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
111 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
112 for (Int_t i=0;i<4;i++) {
113 fDEDX[i] = s.fDEDX[i];
114 fSDEDX[i] = s.fSDEDX[i];
115 fNCDEDX[i] = s.fNCDEDX[i];
117 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
121 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
124 fClusterOwner(kFALSE),
130 fCurrentSigmaY2(1e10),
131 fCurrentSigmaZ2(1e10),
134 fCurrentCluster(0x0),
135 fCurrentClusterIndex1(-1),
148 // Constructor from AliTPCtrack
151 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
152 for (Int_t i=0;i<160;i++) {
153 fClusterPointer[i] = 0;
154 Int_t index = t.GetClusterIndex(i);
156 SetClusterIndex2(i,index);
159 SetClusterIndex2(i,-3);
162 for (Int_t i=0;i<4;i++) {
167 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
170 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
171 const Double_t cc[15], Int_t index):
172 AliTPCtrack(xr, alpha, xx, cc, index),
174 fClusterOwner(kFALSE),
180 fCurrentSigmaY2(1e10),
181 fCurrentSigmaZ2(1e10),
184 fCurrentCluster(0x0),
185 fCurrentClusterIndex1(-1),
201 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
202 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
203 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
204 for (Int_t i=0;i<4;i++) {
209 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
212 AliTPCseed::~AliTPCseed(){
215 if (fPoints) delete fPoints;
217 if (fEPoints) delete fEPoints;
221 for (Int_t icluster=0; icluster<160; icluster++){
222 delete fClusterPointer[icluster];
227 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
231 return &fTrackPoints[i];
234 void AliTPCseed::RebuildSeed()
237 // rebuild seed to be ready for storing
238 AliTPCclusterMI cldummy;
240 AliTPCTrackPoint pdummy;
241 pdummy.GetTPoint().SetShared(10);
242 for (Int_t i=0;i<160;i++){
243 AliTPCclusterMI * cl0 = fClusterPointer[i];
244 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
246 trpoint->GetTPoint() = *(GetTrackPoint(i));
247 trpoint->GetCPoint() = *cl0;
248 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
252 trpoint->GetCPoint()= cldummy;
260 Double_t AliTPCseed::GetDensityFirst(Int_t n)
264 // return cluster for n rows bellow first point
265 Int_t nfoundable = 1;
267 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
268 Int_t index = GetClusterIndex2(i);
269 if (index!=-1) nfoundable++;
270 if (index>0) nfound++;
272 if (nfoundable<n) return 0;
273 return Double_t(nfound)/Double_t(nfoundable);
278 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
280 // get cluster stat. on given region
285 for (Int_t i=first;i<last; i++){
286 Int_t index = GetClusterIndex2(i);
287 if (index!=-1) foundable++;
288 if (fClusterPointer[i]) {
294 if (fClusterPointer[i]->IsUsed(10)) {
298 if (!plus2) continue; //take also neighborhoud
300 if ( (i>0) && fClusterPointer[i-1]){
301 if (fClusterPointer[i-1]->IsUsed(10)) {
306 if ( fClusterPointer[i+1]){
307 if (fClusterPointer[i+1]->IsUsed(10)) {
315 //Error("AliTPCseed::GetClusterStatistic","problem\n");
323 void AliTPCseed::Reset(Bool_t all)
327 SetNumberOfClusters(0);
330 ResetCovariance(10.);
333 for (Int_t i=0;i<8;i++){
334 delete [] fTrackPoints[i];
342 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
343 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
349 void AliTPCseed::Modify(Double_t factor)
352 //------------------------------------------------------------------
353 //This function makes a track forget its history :)
354 //------------------------------------------------------------------
356 ResetCovariance(10.);
359 ResetCovariance(factor);
361 SetNumberOfClusters(0);
365 fCurrentSigmaY2 = 0.000005;
366 fCurrentSigmaZ2 = 0.000005;
375 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
377 //-----------------------------------------------------------------
378 // This function find proloncation of a track to a reference plane x=xk.
379 // doesn't change internal state of the track
380 //-----------------------------------------------------------------
382 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
384 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
388 // Double_t y1=fP0, z1=fP1;
389 Double_t c1=GetSnp(), r1=sqrt(1.- c1*c1);
390 Double_t c2=c1 + GetC()*dx, r2=sqrt(1.- c2*c2);
394 //y += dx*(c1+c2)/(r1+r2);
395 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
397 Double_t dy = dx*(c1+c2)/(r1+r2);
400 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
402 if (TMath::Abs(delta)>0.0001){
403 dz = fP3*TMath::ASin(delta)/fP4;
405 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
408 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
409 dz = GetTgl()*TMath::ASin(delta)/GetC();
419 //_____________________________________________________________________________
420 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
422 //-----------------------------------------------------------------
423 // This function calculates a predicted chi2 increment.
424 //-----------------------------------------------------------------
425 Double_t p[2]={c->GetY(), c->GetZ()};
426 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
427 return AliExternalTrackParam::GetPredictedChi2(p,cov);
430 //_________________________________________________________________________________________
433 Int_t AliTPCseed::Compare(const TObject *o) const {
434 //-----------------------------------------------------------------
435 // This function compares tracks according to the sector - for given sector according z
436 //-----------------------------------------------------------------
437 AliTPCseed *t=(AliTPCseed*)o;
440 if (t->fRelativeSector>fRelativeSector) return -1;
441 if (t->fRelativeSector<fRelativeSector) return 1;
442 Double_t z2 = t->GetZ();
443 Double_t z1 = GetZ();
445 if (z2<z1) return -1;
450 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(TMath::Abs(t->Get1Pt())+0.0066);
451 if (t->fBConstrain) f2=1.2;
454 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(TMath::Abs(Get1Pt())+0.0066);
456 if (fBConstrain) f1=1.2;
458 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
466 //_____________________________________________________________________________
467 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t /*index*/)
469 //-----------------------------------------------------------------
470 // This function associates a cluster with this track.
471 //-----------------------------------------------------------------
472 Double_t p[2]={c->GetY(), c->GetZ()};
473 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
475 if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
477 Int_t n=GetNumberOfClusters();
479 SetNumberOfClusters(n+1);
480 SetChi2(GetChi2()+chisq);
487 //_____________________________________________________________________________
488 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
489 //-----------------------------------------------------------------
490 // This funtion calculates dE/dX within the "low" and "up" cuts.
491 //-----------------------------------------------------------------
494 Float_t angular[200];
498 // TClonesArray & arr = *fPoints;
499 Float_t meanlog = 100.;
501 Float_t mean[4] = {0,0,0,0};
502 Float_t sigma[4] = {1000,1000,1000,1000};
503 Int_t nc[4] = {0,0,0,0};
504 Float_t norm[4] = {1000,1000,1000,1000};
509 for (Int_t of =0; of<4; of++){
510 for (Int_t i=of+i1;i<i2;i+=4)
512 Int_t index = fIndex[i];
513 if (index<0||index&0x8000) continue;
515 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
516 AliTPCTrackerPoint * point = GetTrackPoint(i);
517 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
518 //AliTPCTrackerPoint * pointp = 0;
519 //if (i<159) pointp = GetTrackPoint(i+1);
521 if (point==0) continue;
522 AliTPCclusterMI * cl = fClusterPointer[i];
524 if (onlyused && (!cl->IsUsed(10))) continue;
525 if (cl->IsUsed(11)) {
529 Int_t type = cl->GetType();
530 //if (point->fIsShared){
535 // if (pointm->fIsShared) continue;
537 // if (pointp->fIsShared) continue;
539 if (type<0) continue;
540 //if (type>10) continue;
541 //if (point->GetErrY()==0) continue;
542 //if (point->GetErrZ()==0) continue;
544 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
545 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
546 //if ((ddy*ddy+ddz*ddz)>10) continue;
549 // if (point->GetCPoint().GetMax()<5) continue;
550 if (cl->GetMax()<5) continue;
551 Float_t angley = point->GetAngleY();
552 Float_t anglez = point->GetAngleZ();
554 Float_t rsigmay2 = point->GetSigmaY();
555 Float_t rsigmaz2 = point->GetSigmaZ();
559 rsigmay += pointm->GetTPoint().GetSigmaY();
560 rsigmaz += pointm->GetTPoint().GetSigmaZ();
564 rsigmay += pointp->GetTPoint().GetSigmaY();
565 rsigmaz += pointp->GetTPoint().GetSigmaZ();
572 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
574 Float_t ampc = 0; // normalization to the number of electrons
576 // ampc = 1.*point->GetCPoint().GetMax();
577 ampc = 1.*cl->GetMax();
578 //ampc = 1.*point->GetCPoint().GetQ();
579 // AliTPCClusterPoint & p = point->GetCPoint();
580 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
581 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
583 // TMath::Abs( Int_t(iz) - iz + 0.5);
584 //ampc *= 1.15*(1-0.3*dy);
585 //ampc *= 1.15*(1-0.3*dz);
586 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
590 //ampc = 1.0*point->GetCPoint().GetMax();
591 ampc = 1.0*cl->GetMax();
592 //ampc = 1.0*point->GetCPoint().GetQ();
593 //AliTPCClusterPoint & p = point->GetCPoint();
594 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
595 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
597 // TMath::Abs( Int_t(iz) - iz + 0.5);
599 //ampc *= 1.15*(1-0.3*dy);
600 //ampc *= 1.15*(1-0.3*dz);
601 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
605 ampc *= 2.0; // put mean value to channel 50
606 //ampc *= 0.58; // put mean value to channel 50
608 // if (type>0) w = 1./(type/2.-0.5);
609 // Float_t z = TMath::Abs(cl->GetZ());
612 //ampc /= (1+0.0008*z);
616 //ampc /= (1+0.0008*z);
618 //ampc /= (1+0.0008*z);
621 if (type<0) { //amp at the border - lower weight
626 if (rsigma>1.5) ampc/=1.3; // if big backround
628 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
633 TMath::Sort(nc[of],amp,index,kFALSE);
637 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
639 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
640 Float_t ampl = amp[index[i]]/angular[index[i]];
641 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
643 sumw += weight[index[i]];
644 sumamp += weight[index[i]]*ampl;
645 sumamp2 += weight[index[i]]*ampl*ampl;
646 norm[of] += angular[index[i]]*weight[index[i]];
653 mean[of] = sumamp/sumw;
654 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
656 sigma[of] = TMath::Sqrt(sigma[of]);
660 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
661 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
662 //mean *=(1-0.1*(norm-1.));
669 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
670 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
673 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
674 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
678 for (Int_t i =0;i<4;i++){
679 if (nc[i]>2&&nc[i]<1000){
680 dedx += mean[i] *nc[i];
681 fSdEdx += sigma[i]*(nc[i]-2);
682 fMAngular += norm[i] *nc[i];
687 fSDEDX[i] = sigma[i];
700 // Float_t dedx1 =dedx;
703 for (Int_t i =0;i<4;i++){
704 if (nc[i]>2&&nc[i]<1000){
705 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
706 dedx += mean[i] *nc[i];
717 Double_t AliTPCseed::Bethe(Double_t bg){
719 // This is the Bethe-Bloch function normalised to 1 at the minimum
724 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
725 else // Density effect ( approximately :)
726 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
730 void AliTPCseed::CookPID()
733 // cook PID information according dEdx
735 Double_t fRange = 10.;
739 Int_t ns=AliPID::kSPECIES;
741 for (Int_t j=0; j<ns; j++) {
742 Double_t mass=AliPID::ParticleMass(j);
744 Double_t dedx=fdEdx/fMIP;
745 Double_t bethe=Bethe(mom/mass);
746 Double_t sigma=fRes*bethe;
748 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
749 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
753 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
761 for (Int_t j=0; j<ns; j++) {
762 fTPCr[j]/=sumr; //normalize
767 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
768 //-----------------------------------------------------------------
769 // This funtion calculates dE/dX within the "low" and "up" cuts.
770 //-----------------------------------------------------------------
773 Float_t angular[200];
777 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
778 for (Int_t i=0;i<200;i++) amp[i]=10000;
779 for (Int_t i=0;i<200;i++) angular[i]= 1;;
783 Float_t meanlog = 100.;
784 Int_t indexde[4]={0,64,128,160};
791 Float_t mean[4] = {0,0,0,0};
792 Float_t sigma[4] = {1000,1000,1000,1000};
793 Int_t nc[4] = {0,0,0,0};
794 Float_t norm[4] = {1000,1000,1000,1000};
799 // for (Int_t of =0; of<3; of++){
800 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
801 for (Int_t i =0; i<160;i++)
803 AliTPCTrackPoint * point = GetTrackPoint(i);
804 if (point==0) continue;
805 if (point->fIsShared){
809 Int_t type = point->GetCPoint().GetType();
810 if (type<0) continue;
811 if (point->GetCPoint().GetMax()<5) continue;
812 Float_t angley = point->GetTPoint().GetAngleY();
813 Float_t anglez = point->GetTPoint().GetAngleZ();
814 Float_t rsigmay = point->GetCPoint().GetSigmaY();
815 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
816 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
818 Float_t ampc = 0; // normalization to the number of electrons
820 ampc = point->GetCPoint().GetMax();
823 ampc = point->GetCPoint().GetMax();
825 ampc *= 2.0; // put mean value to channel 50
826 // ampc *= 0.565; // put mean value to channel 50
829 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
836 if (type<0) { //amp at the border - lower weight
839 if (rsigma>1.5) ampc/=1.3; // if big backround
840 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
841 amp[i] = ampc/angular[i];
846 TMath::Sort(159,amp,index,kFALSE);
847 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
848 inlimit[index[i]] = kTRUE; // take all clusters
851 // meanlog = amp[index[Int_t(anc*0.3)]];
853 for (Int_t of =0; of<3; of++){
857 for (Int_t i=indexde[of];i<indexde[of+1];i++)
859 if (inlimit[i]==kFALSE) continue;
860 Float_t ampl = amp[i];
862 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
865 sumamp += weight[i]*ampl;
866 sumamp2 += weight[i]*ampl*ampl;
867 norm[of] += angular[i]*weight[i];
875 mean[of] = sumamp/sumw;
876 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
878 sigma[of] = TMath::Sqrt(sigma[of]);
881 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
891 Float_t www[3] = {12.,14.,17.};
892 //Float_t www[3] = {1.,1.,1.};
894 for (Int_t i =0;i<3;i++){
895 if (nc[i]>2&&nc[i]<1000){
896 dedx += mean[i] *nc[i]*www[i]/sigma[i];
897 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
898 fMAngular += norm[i] *nc[i];
899 norm2 += nc[i]*www[i]/sigma[i];
900 norm3 += (nc[i]-2)*www[i]/sigma[i];
903 fSDEDX[i] = sigma[i];
916 // Float_t dedx1 =dedx;
920 for (Int_t i =0;i<3;i++){
921 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
922 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
923 dedx += mean[i] *(nc[i])/(sigma[i]);
924 norm4 += (nc[i])/(sigma[i]);
928 if (norm4>0) dedx /= norm4;
938 Double_t AliTPCseed::GetYat(Double_t xk) const {
939 //-----------------------------------------------------------------
940 // This function calculates the Y-coordinate of a track at the plane x=xk.
941 //-----------------------------------------------------------------
942 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
943 Double_t c1=GetSnp(), r1=TMath::Sqrt(1.- c1*c1);
944 Double_t c2=c1+GetC()*(xk-GetX());
945 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
946 Double_t r2=TMath::Sqrt(1.- c2*c2);
947 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);