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():AliTPCtrack(){
36 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
37 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
38 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
39 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
55 fCircular = 0; // not curling track
57 AliTPCseed::AliTPCseed(const AliTPCseed &s):AliTPCtrack(s){
58 //---------------------
59 // dummy copy constructor
60 //-------------------------
61 for (Int_t i=0;i<160;i++) fClusterPointer[i] = s.fClusterPointer[i];
62 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
69 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
78 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=t.GetKinkIndex(i);
79 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
80 for (Int_t i=0;i<160;i++) {
81 fClusterPointer[i] = 0;
82 Int_t index = t.GetClusterIndex(i);
84 SetClusterIndex2(i,index);
87 SetClusterIndex2(i,-3);
102 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
103 Double_t xr, Double_t alpha):
104 AliTPCtrack(index, xx, cc, xr, alpha) {
109 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
110 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
111 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
112 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
122 // fHelixIn = new TClonesArray("AliHelix",0);
123 //fHelixOut = new TClonesArray("AliHelix",0);
134 AliTPCseed::~AliTPCseed(){
137 if (fPoints) delete fPoints;
139 if (fEPoints) delete fEPoints;
144 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
148 return &fTrackPoints[i];
151 void AliTPCseed::RebuildSeed()
154 // rebuild seed to be ready for storing
155 AliTPCclusterMI cldummy;
157 AliTPCTrackPoint pdummy;
158 pdummy.GetTPoint().fIsShared = 10;
159 for (Int_t i=0;i<160;i++){
160 AliTPCclusterMI * cl0 = fClusterPointer[i];
161 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
163 trpoint->GetTPoint() = *(GetTrackPoint(i));
164 trpoint->GetCPoint() = *cl0;
165 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
169 trpoint->GetCPoint()= cldummy;
177 Double_t AliTPCseed::GetDensityFirst(Int_t n)
181 // return cluster for n rows bellow first point
182 Int_t nfoundable = 1;
184 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
185 Int_t index = GetClusterIndex2(i);
186 if (index!=-1) nfoundable++;
187 if (index>0) nfound++;
189 if (nfoundable<n) return 0;
190 return Double_t(nfound)/Double_t(nfoundable);
195 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
197 // get cluster stat. on given region
202 for (Int_t i=first;i<last; i++){
203 Int_t index = GetClusterIndex2(i);
204 if (index!=-1) foundable++;
205 if (fClusterPointer[i]) {
211 if (fClusterPointer[i]->IsUsed(10)) {
215 if (!plus2) continue; //take also neighborhoud
217 if ( (i>0) && fClusterPointer[i-1]){
218 if (fClusterPointer[i-1]->IsUsed(10)) {
223 if ( fClusterPointer[i+1]){
224 if (fClusterPointer[i+1]->IsUsed(10)) {
232 //Error("AliTPCseed::GetClusterStatistic","problem\n");
240 void AliTPCseed::Reset(Bool_t all)
244 SetNumberOfClusters(0);
250 for (Int_t i=0;i<8;i++){
251 delete [] fTrackPoints[i];
259 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
260 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
266 void AliTPCseed::Modify(Double_t factor)
269 //------------------------------------------------------------------
270 //This function makes a track forget its history :)
271 //------------------------------------------------------------------
277 fC10*=0; fC11*=factor;
278 fC20*=0; fC21*=0; fC22*=factor;
279 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
280 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
281 SetNumberOfClusters(0);
285 fCurrentSigmaY2 = 0.000005;
286 fCurrentSigmaZ2 = 0.000005;
295 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
297 //-----------------------------------------------------------------
298 // This function find proloncation of a track to a reference plane x=xk.
299 // doesn't change internal state of the track
300 //-----------------------------------------------------------------
302 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
304 if (TMath::Abs(fP4*xk - fP2) >= AliTPCReconstructor::GetMaxSnpTrack()) {
308 // Double_t y1=fP0, z1=fP1;
309 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
310 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
314 //y += dx*(c1+c2)/(r1+r2);
315 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
317 Double_t dy = dx*(c1+c2)/(r1+r2);
320 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
322 if (TMath::Abs(delta)>0.0001){
323 dz = fP3*TMath::ASin(delta)/fP4;
325 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
328 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
329 dz = fP3*TMath::ASin(delta)/fP4;
339 //_____________________________________________________________________________
340 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
342 //-----------------------------------------------------------------
343 // This function calculates a predicted chi2 increment.
344 //-----------------------------------------------------------------
345 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
346 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
347 r00+=fC00; r01+=fC10; r11+=fC11;
349 Double_t det=r00*r11 - r01*r01;
350 if (TMath::Abs(det) < 1.e-10) {
351 //Int_t n=GetNumberOfClusters();
352 //if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
355 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
357 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
359 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
363 //_________________________________________________________________________________________
366 Int_t AliTPCseed::Compare(const TObject *o) const {
367 //-----------------------------------------------------------------
368 // This function compares tracks according to the sector - for given sector according z
369 //-----------------------------------------------------------------
370 AliTPCseed *t=(AliTPCseed*)o;
373 if (t->fRelativeSector>fRelativeSector) return -1;
374 if (t->fRelativeSector<fRelativeSector) return 1;
375 Double_t z2 = t->GetZ();
376 Double_t z1 = GetZ();
378 if (z2<z1) return -1;
383 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
384 if (t->fBConstrain) f2=1.2;
387 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
389 if (fBConstrain) f1=1.2;
391 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
399 //_____________________________________________________________________________
400 Int_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, UInt_t /*index*/) {
401 //-----------------------------------------------------------------
402 // This function associates a cluster with this track.
403 //-----------------------------------------------------------------
404 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
406 r00+=fC00; r01+=fC10; r11+=fC11;
407 Double_t det=r00*r11 - r01*r01;
408 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
410 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
411 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
412 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
413 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
414 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
416 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
417 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
418 if (TMath::Abs(cur*fX-eta) >= AliTPCReconstructor::GetMaxSnpTrack()) {
422 fP0 += k00*dy + k01*dz;
423 fP1 += k10*dy + k11*dz;
425 fP3 += k30*dy + k31*dz;
428 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
429 Double_t c12=fC21, c13=fC31, c14=fC41;
431 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
432 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
433 fC40-=k00*c04+k01*c14;
435 fC11-=k10*c01+k11*fC11;
436 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
437 fC41-=k10*c04+k11*c14;
439 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
440 fC42-=k20*c04+k21*c14;
442 fC33-=k30*c03+k31*c13;
443 fC43-=k40*c03+k41*c13;
445 fC44-=k40*c04+k41*c14;
447 Int_t n=GetNumberOfClusters();
449 SetNumberOfClusters(n+1);
450 SetChi2(GetChi2()+chisq);
457 //_____________________________________________________________________________
458 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
459 //-----------------------------------------------------------------
460 // This funtion calculates dE/dX within the "low" and "up" cuts.
461 //-----------------------------------------------------------------
464 Float_t angular[200];
468 // TClonesArray & arr = *fPoints;
469 Float_t meanlog = 100.;
471 Float_t mean[4] = {0,0,0,0};
472 Float_t sigma[4] = {1000,1000,1000,1000};
473 Int_t nc[4] = {0,0,0,0};
474 Float_t norm[4] = {1000,1000,1000,1000};
479 for (Int_t of =0; of<4; of++){
480 for (Int_t i=of+i1;i<i2;i+=4)
482 Int_t index = fIndex[i];
483 if (index<0||index&0x8000) continue;
485 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
486 AliTPCTrackerPoint * point = GetTrackPoint(i);
487 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
488 //AliTPCTrackerPoint * pointp = 0;
489 //if (i<159) pointp = GetTrackPoint(i+1);
491 if (point==0) continue;
492 AliTPCclusterMI * cl = fClusterPointer[i];
494 if (onlyused && (!cl->IsUsed(10))) continue;
495 if (cl->IsUsed(11)) {
499 Int_t type = cl->GetType();
500 //if (point->fIsShared){
505 // if (pointm->fIsShared) continue;
507 // if (pointp->fIsShared) continue;
509 if (type<0) continue;
510 //if (type>10) continue;
511 //if (point->GetErrY()==0) continue;
512 //if (point->GetErrZ()==0) continue;
514 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
515 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
516 //if ((ddy*ddy+ddz*ddz)>10) continue;
519 // if (point->GetCPoint().GetMax()<5) continue;
520 if (cl->GetMax()<5) continue;
521 Float_t angley = point->GetAngleY();
522 Float_t anglez = point->GetAngleZ();
524 Float_t rsigmay2 = point->GetSigmaY();
525 Float_t rsigmaz2 = point->GetSigmaZ();
529 rsigmay += pointm->GetTPoint().GetSigmaY();
530 rsigmaz += pointm->GetTPoint().GetSigmaZ();
534 rsigmay += pointp->GetTPoint().GetSigmaY();
535 rsigmaz += pointp->GetTPoint().GetSigmaZ();
542 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
544 Float_t ampc = 0; // normalization to the number of electrons
546 // ampc = 1.*point->GetCPoint().GetMax();
547 ampc = 1.*cl->GetMax();
548 //ampc = 1.*point->GetCPoint().GetQ();
549 // AliTPCClusterPoint & p = point->GetCPoint();
550 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
551 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
553 // TMath::Abs( Int_t(iz) - iz + 0.5);
554 //ampc *= 1.15*(1-0.3*dy);
555 //ampc *= 1.15*(1-0.3*dz);
556 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
560 //ampc = 1.0*point->GetCPoint().GetMax();
561 ampc = 1.0*cl->GetMax();
562 //ampc = 1.0*point->GetCPoint().GetQ();
563 //AliTPCClusterPoint & p = point->GetCPoint();
564 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
565 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
567 // TMath::Abs( Int_t(iz) - iz + 0.5);
569 //ampc *= 1.15*(1-0.3*dy);
570 //ampc *= 1.15*(1-0.3*dz);
571 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
575 ampc *= 2.0; // put mean value to channel 50
576 //ampc *= 0.58; // put mean value to channel 50
578 // if (type>0) w = 1./(type/2.-0.5);
579 // Float_t z = TMath::Abs(cl->GetZ());
582 //ampc /= (1+0.0008*z);
586 //ampc /= (1+0.0008*z);
588 //ampc /= (1+0.0008*z);
591 if (type<0) { //amp at the border - lower weight
596 if (rsigma>1.5) ampc/=1.3; // if big backround
598 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
603 TMath::Sort(nc[of],amp,index,kFALSE);
607 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
609 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
610 Float_t ampl = amp[index[i]]/angular[index[i]];
611 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
613 sumw += weight[index[i]];
614 sumamp += weight[index[i]]*ampl;
615 sumamp2 += weight[index[i]]*ampl*ampl;
616 norm[of] += angular[index[i]]*weight[index[i]];
623 mean[of] = sumamp/sumw;
624 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
626 sigma[of] = TMath::Sqrt(sigma[of]);
630 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
631 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
632 //mean *=(1-0.1*(norm-1.));
639 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
640 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
643 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
644 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
648 for (Int_t i =0;i<4;i++){
649 if (nc[i]>2&&nc[i]<1000){
650 dedx += mean[i] *nc[i];
651 fSdEdx += sigma[i]*(nc[i]-2);
652 fMAngular += norm[i] *nc[i];
657 fSDEDX[i] = sigma[i];
670 // Float_t dedx1 =dedx;
673 for (Int_t i =0;i<4;i++){
674 if (nc[i]>2&&nc[i]<1000){
675 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
676 dedx += mean[i] *nc[i];
687 Double_t AliTPCseed::Bethe(Double_t bg){
689 // This is the Bethe-Bloch function normalised to 1 at the minimum
694 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
695 else // Density effect ( approximately :)
696 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
700 void AliTPCseed::CookPID()
703 // cook PID information according dEdx
705 Double_t fRange = 10.;
709 Int_t ns=AliPID::kSPECIES;
711 for (Int_t j=0; j<ns; j++) {
712 Double_t mass=AliPID::ParticleMass(j);
714 Double_t dedx=fdEdx/fMIP;
715 Double_t bethe=Bethe(mom/mass);
716 Double_t sigma=fRes*bethe;
718 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
719 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
723 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
731 for (Int_t j=0; j<ns; j++) {
732 fTPCr[j]/=sumr; //normalize
737 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
738 //-----------------------------------------------------------------
739 // This funtion calculates dE/dX within the "low" and "up" cuts.
740 //-----------------------------------------------------------------
743 Float_t angular[200];
747 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
748 for (Int_t i=0;i<200;i++) amp[i]=10000;
749 for (Int_t i=0;i<200;i++) angular[i]= 1;;
753 Float_t meanlog = 100.;
754 Int_t indexde[4]={0,64,128,160};
761 Float_t mean[4] = {0,0,0,0};
762 Float_t sigma[4] = {1000,1000,1000,1000};
763 Int_t nc[4] = {0,0,0,0};
764 Float_t norm[4] = {1000,1000,1000,1000};
769 // for (Int_t of =0; of<3; of++){
770 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
771 for (Int_t i =0; i<160;i++)
773 AliTPCTrackPoint * point = GetTrackPoint(i);
774 if (point==0) continue;
775 if (point->fIsShared){
779 Int_t type = point->GetCPoint().GetType();
780 if (type<0) continue;
781 if (point->GetCPoint().GetMax()<5) continue;
782 Float_t angley = point->GetTPoint().GetAngleY();
783 Float_t anglez = point->GetTPoint().GetAngleZ();
784 Float_t rsigmay = point->GetCPoint().GetSigmaY();
785 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
786 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
788 Float_t ampc = 0; // normalization to the number of electrons
790 ampc = point->GetCPoint().GetMax();
793 ampc = point->GetCPoint().GetMax();
795 ampc *= 2.0; // put mean value to channel 50
796 // ampc *= 0.565; // put mean value to channel 50
799 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
806 if (type<0) { //amp at the border - lower weight
809 if (rsigma>1.5) ampc/=1.3; // if big backround
810 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
811 amp[i] = ampc/angular[i];
816 TMath::Sort(159,amp,index,kFALSE);
817 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
818 inlimit[index[i]] = kTRUE; // take all clusters
821 // meanlog = amp[index[Int_t(anc*0.3)]];
823 for (Int_t of =0; of<3; of++){
827 for (Int_t i=indexde[of];i<indexde[of+1];i++)
829 if (inlimit[i]==kFALSE) continue;
830 Float_t ampl = amp[i];
832 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
835 sumamp += weight[i]*ampl;
836 sumamp2 += weight[i]*ampl*ampl;
837 norm[of] += angular[i]*weight[i];
845 mean[of] = sumamp/sumw;
846 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
848 sigma[of] = TMath::Sqrt(sigma[of]);
851 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
861 Float_t www[3] = {12.,14.,17.};
862 //Float_t www[3] = {1.,1.,1.};
864 for (Int_t i =0;i<3;i++){
865 if (nc[i]>2&&nc[i]<1000){
866 dedx += mean[i] *nc[i]*www[i]/sigma[i];
867 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
868 fMAngular += norm[i] *nc[i];
869 norm2 += nc[i]*www[i]/sigma[i];
870 norm3 += (nc[i]-2)*www[i]/sigma[i];
873 fSDEDX[i] = sigma[i];
886 // Float_t dedx1 =dedx;
890 for (Int_t i =0;i<3;i++){
891 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
892 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
893 dedx += mean[i] *(nc[i])/(sigma[i]);
894 norm4 += (nc[i])/(sigma[i]);
898 if (norm4>0) dedx /= norm4;