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 **************************************************************************/
22 AliTPC parallel tracker -
24 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 run AliTPCFindTracksMI.C macro - to find tracks
26 tracks are written to AliTPCtracks.root file
27 for comparison also seeds are written to the same file - to special branch
30 //-------------------------------------------------------
31 // Implementation of the TPC tracker
33 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
35 //-------------------------------------------------------
37 #include <TObjArray.h>
40 #include "Riostream.h"
42 #include "AliTPCtrackerMI.h"
43 #include "AliTPCclusterMI.h"
44 #include "AliTPCParam.h"
45 #include "AliTPCClustersRow.h"
46 #include "AliComplexCluster.h"
47 #include "AliTPCpolyTrack.h"
48 #include "TStopwatch.h"
53 AliTPCclusterTracks::AliTPCclusterTracks(){
54 // class for storing overlaping info
67 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, AliTPCclusterMI* c, Double_t chi2, UInt_t i){
69 Int_t sec=(i&0xff000000)>>24;
70 Int_t row = (i&0x00ff0000)>>16;
71 track->fRow=(i&0x00ff0000)>>16;
73 // Int_t index = i&0xFFFF;
74 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
75 track->fClusterIndex[track->fRow] = i;
76 track->fFirstPoint = row;
79 AliTPCTrackPoint *trpoint =track->GetTrackPoint(track->fRow);
80 Float_t angle2 = track->GetSnp()*track->GetSnp();
81 angle2 = TMath::Sqrt(angle2/(1-angle2));
86 //if we have a cluster
87 trpoint->GetCPoint().SetY(c->GetY());
88 trpoint->GetCPoint().SetZ(c->GetZ());
90 trpoint->GetCPoint().SetSigmaY(c->GetSigmaY2()/(track->fCurrentSigmaY*track->fCurrentSigmaY));
91 trpoint->GetCPoint().SetSigmaZ(c->GetSigmaZ2()/(track->fCurrentSigmaZ*track->fCurrentSigmaZ));
93 trpoint->GetCPoint().SetType(c->GetType());
94 trpoint->GetCPoint().SetQ(c->GetQ());
95 trpoint->GetCPoint().SetMax(c->GetMax());
97 trpoint->GetCPoint().SetErrY(TMath::Sqrt(track->fErrorY2));
98 trpoint->GetCPoint().SetErrZ(TMath::Sqrt(track->fErrorZ2));
101 trpoint->GetTPoint().SetX(track->GetX());
102 trpoint->GetTPoint().SetY(track->GetY());
103 trpoint->GetTPoint().SetZ(track->GetZ());
105 trpoint->GetTPoint().SetAngleY(angle2);
106 trpoint->GetTPoint().SetAngleZ(track->GetTgl());
111 // printf("suspicious chi2 %f\n",chi2);
113 // if (track->fIsSeeding){
114 track->fErrorY2 *= 1.2;
115 track->fErrorY2 += 0.0064;
116 track->fErrorZ2 *= 1.2;
117 track->fErrorY2 += 0.005;
121 return track->Update(c,chi2,i);
124 //_____________________________________________________________________________
125 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par, Int_t eventn):
126 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
128 //---------------------------------------------------------------------
129 // The main TPC tracker constructor
130 //---------------------------------------------------------------------
131 fInnerSec=new AliTPCSector[fkNIS];
132 fOuterSec=new AliTPCSector[fkNOS];
135 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
136 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
140 fClustersArray.Setup(par);
141 fClustersArray.SetClusterType("AliTPCclusterMI");
145 sprintf(cname,"TreeC_TPC");
148 sprintf(cname,"TreeC_TPC_%d",eventn);
151 fClustersArray.ConnectTree(cname);
159 //_____________________________________________________________________________
160 AliTPCtrackerMI::~AliTPCtrackerMI() {
161 //------------------------------------------------------------------
162 // TPC tracker destructor
163 //------------------------------------------------------------------
173 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
177 Float_t z = fParam->GetZLength()-TMath::Abs(seed->GetZ());
183 //standard if we don't have cluster - take MIP
184 const Float_t chmip = 50.;
185 Float_t amp = chmip/0.3;
190 rsigmay = cl->GetSigmaY2()/(seed->fCurrentSigmaY*seed->fCurrentSigmaY);
191 ctype = cl->GetType();
195 Float_t landau=2 ; //landau fluctuation part
196 Float_t gg=2; // gg fluctuation part
197 Float_t padlength= fSectors->GetPadPitchLength(seed->GetX());
200 if (fSectors==fInnerSec){
204 gg = (2+0.0002*amp)/nel;
205 landau = (2.+0.12*nprim)*0.5*(amp*amp/40000.+2)/nprim;
206 if (landau>1) landau=1;
212 gg = (2+0.0002*amp)/nel;
213 landau = (2.+0.12*nprim)*0.5*(amp*amp/40000.+2)/nprim;
214 if (landau>1) landau=1;
218 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
219 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
220 angle2 = angle2/(1-angle2);
221 Float_t angular = landau*angle2*padlength*padlength/12.;
222 Float_t res = sdiff + angular;
225 if ((ctype==0) && (fSectors ==fOuterSec))
226 res *= 0.78 +TMath::Exp(7.4*(rsigmay-1.2));
228 if ((ctype==0) && (fSectors ==fInnerSec))
229 res *= 0.72 +TMath::Exp(3.36*(rsigmay-1.2));
233 res*= TMath::Power((rsigmay+0.5),1.5)+0.0064;
236 res*=2.4; // overestimate error 2 times
243 seed->SetErrorY2(res);
250 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
254 Float_t z = fParam->GetZLength()-TMath::Abs(seed->GetZ());
259 const Float_t chmip = 50.;
260 Float_t amp = chmip/0.3;
265 rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ*seed->fCurrentSigmaZ);
266 ctype = cl->GetType();
270 Float_t landau=2 ; //landau fluctuation part
271 Float_t gg=2; // gg fluctuation part
272 Float_t padlength= fSectors->GetPadPitchLength(seed->GetX());
274 if (fSectors==fInnerSec){
278 gg = (2+0.0002*amp)/nel;
279 landau = (2.+0.12*nprim)*0.5*(amp*amp/40000.+2)/nprim;
280 if (landau>1) landau=1;
286 gg = (2+0.0002*amp)/nel;
287 landau = (2.+0.12*nprim)*0.5*(amp*amp/40000.+2)/nprim;
288 if (landau>1) landau=1;
290 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
292 Float_t angle = seed->GetTgl();
293 Float_t angular = landau*angle*angle*padlength*padlength/12.;
294 Float_t res = sdiff + angular;
296 if ((ctype==0) && (fSectors ==fOuterSec))
297 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
299 if ((ctype==0) && (fSectors ==fInnerSec))
300 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
302 res*= TMath::Power(rsigmaz+0.5,1.5)+0.0064; //0.31+0.147*ctype;
305 if ((ctype<0) &&<70)
312 seed->SetErrorZ2(res);
317 void AliTPCseed::Reset()
324 for (Int_t i=0;i<200;i++) fClusterIndex[i]=-1;
328 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
330 //-----------------------------------------------------------------
331 // This function find proloncation of a track to a reference plane x=xk.
332 // doesn't change internal state of the track
333 //-----------------------------------------------------------------
335 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
336 // Double_t y1=fP0, z1=fP1;
337 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
338 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
342 y += dx*(c1+c2)/(r1+r2);
343 z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
348 //_____________________________________________________________________________
349 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
351 //-----------------------------------------------------------------
352 // This function calculates a predicted chi2 increment.
353 //-----------------------------------------------------------------
354 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
355 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
356 r00+=fC00; r01+=fC10; r11+=fC11;
358 Double_t det=r00*r11 - r01*r01;
359 if (TMath::Abs(det) < 1.e-10) {
360 Int_t n=GetNumberOfClusters();
361 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
364 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
366 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
368 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
372 //_________________________________________________________________________________________
375 Int_t AliTPCseed::Compare(const TObject *o) const {
376 //-----------------------------------------------------------------
377 // This function compares tracks according to the sector - for given sector according z
378 //-----------------------------------------------------------------
379 AliTPCseed *t=(AliTPCseed*)o;
380 if (t->fSector>fSector) return -1;
381 if (t->fSector<fSector) return 1;
383 Double_t z2 = t->GetZ();
384 Double_t z1 = GetZ();
386 if (z2<z1) return -1;
395 //_____________________________________________________________________________
396 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t index) {
397 //-----------------------------------------------------------------
398 // This function associates a cluster with this track.
399 //-----------------------------------------------------------------
400 // Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
401 //Double_t r00=sigmay2, r01=0., r11=sigmaz2;
402 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
404 r00+=fC00; r01+=fC10; r11+=fC11;
405 Double_t det=r00*r11 - r01*r01;
406 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
408 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
409 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
410 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
411 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
412 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
414 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
415 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
416 if (TMath::Abs(cur*fX-eta) >= 0.9) {
417 // Int_t n=GetNumberOfClusters();
418 //if (n>4) cerr<<n<<" AliTPCtrack warning: Filtering failed !\n";
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 Double_t AliTPCtrackerMI::f1(Double_t x1,Double_t y1,
459 Double_t x2,Double_t y2,
460 Double_t x3,Double_t y3)
462 //-----------------------------------------------------------------
463 // Initial approximation of the track curvature
464 //-----------------------------------------------------------------
465 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
466 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
467 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
468 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
469 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
471 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
473 return -xr*yr/sqrt(xr*xr+yr*yr);
477 //_____________________________________________________________________________
478 Double_t AliTPCtrackerMI::f2(Double_t x1,Double_t y1,
479 Double_t x2,Double_t y2,
480 Double_t x3,Double_t y3)
482 //-----------------------------------------------------------------
483 // Initial approximation of the track curvature times center of curvature
484 //-----------------------------------------------------------------
485 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
486 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
487 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
488 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
489 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
491 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
493 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
496 //_____________________________________________________________________________
497 Double_t AliTPCtrackerMI::f3(Double_t x1,Double_t y1,
498 Double_t x2,Double_t y2,
499 Double_t z1,Double_t z2)
501 //-----------------------------------------------------------------
502 // Initial approximation of the tangent of the track dip angle
503 //-----------------------------------------------------------------
504 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
508 void AliTPCtrackerMI::LoadClusters()
511 // load clusters to the memory
512 Int_t j=Int_t(fClustersArray.GetTree()->GetEntries());
513 for (Int_t i=0; i<j; i++) {
514 fClustersArray.LoadEntry(i);
518 void AliTPCtrackerMI::UnloadClusters()
521 // load clusters to the memory
522 Int_t j=Int_t(fClustersArray.GetTree()->GetEntries());
523 for (Int_t i=0; i<j; i++) {
524 fClustersArray.ClearSegment(i);
530 //_____________________________________________________________________________
531 void AliTPCtrackerMI::LoadOuterSectors() {
532 //-----------------------------------------------------------------
533 // This function fills outer TPC sectors with clusters.
534 //-----------------------------------------------------------------
536 //Int_t j=Int_t(fClustersArray.GetTree()->GetEntries());
537 Int_t j = ((AliTPCParam*)fParam)->GetNRowsTotal();
538 for (Int_t i=0; i<j; i++) {
539 // AliSegmentID *s=fClustersArray.LoadEntry(i);
540 AliSegmentID *s= const_cast<AliSegmentID*>(fClustersArray.At(i));
543 AliTPCParam *par=(AliTPCParam*)fClustersArray.GetParam();
544 par->AdjustSectorRow(s->GetID(),sec,row);
545 if (sec<fkNIS*2) continue;
546 AliTPCClustersRow *clrow=fClustersArray.GetRow(sec,row);
547 Int_t ncl=clrow->GetArray()->GetEntriesFast();
549 AliTPCclusterMI *c=(AliTPCclusterMI*)(*clrow)[ncl];
550 index=(((sec<<8)+row)<<16)+ncl;
551 fOuterSec[(sec-fkNIS*2)%fkNOS][row].InsertCluster(c,index);
559 //_____________________________________________________________________________
560 void AliTPCtrackerMI::LoadInnerSectors() {
561 //-----------------------------------------------------------------
562 // This function fills inner TPC sectors with clusters.
563 //-----------------------------------------------------------------
565 //Int_t j=Int_t(fClustersArray.GetTree()->GetEntries());
566 Int_t j = ((AliTPCParam*)fParam)->GetNRowsTotal();
567 for (Int_t i=0; i<j; i++) {
568 // AliSegmentID *s=fClustersArray.LoadEntry(i);
569 AliSegmentID *s=const_cast<AliSegmentID*>(fClustersArray.At(i));
572 AliTPCParam *par=(AliTPCParam*)fClustersArray.GetParam();
573 par->AdjustSectorRow(s->GetID(),sec,row);
574 if (sec>=fkNIS*2) continue;
575 AliTPCClustersRow *clrow=fClustersArray.GetRow(sec,row);
576 Int_t ncl=clrow->GetArray()->GetEntriesFast();
578 AliTPCclusterMI *c=(AliTPCclusterMI*)(*clrow)[ncl];
579 index=(((sec<<8)+row)<<16)+ncl;
580 fInnerSec[sec%fkNIS][row].InsertCluster(c,index);
588 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
589 //-----------------------------------------------------------------
590 // This function tries to find a track prolongation to next pad row
591 //-----------------------------------------------------------------
592 // Double_t xt=t.GetX();
593 // Int_t row = fSectors->GetRowNumber(xt)-1;
594 // if (row < nr) return 1; // don't prolongate if not information until now -
596 Double_t x=fSectors->GetX(nr), ymax=fSectors->GetMaxY(nr);
597 // if (t.GetRadius()>x+10 ) return 0;
599 if (!t.PropagateTo(x)) {
604 t.fCurrentSigmaY = GetSigmaY(&t);
605 t.fCurrentSigmaZ = GetSigmaZ(&t);
607 AliTPCclusterMI *cl=0;
609 const AliTPCRow &krow=fSectors[t.fRelativeSector][nr];
610 Double_t sy2=ErrY2(&t)*2;
611 Double_t sz2=ErrZ2(&t)*2;
614 Double_t roady =3.*sqrt(t.GetSigmaY2() + sy2);
615 Double_t roadz = 3 *sqrt(t.GetSigmaZ2() + sz2);
616 Double_t y=t.GetY(), z=t.GetZ();
618 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
624 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
629 Float_t maxdistance = roady*roady + roadz*roadz;
631 for (Int_t i=krow.Find(z-roadz); i<krow; i++) {
632 AliTPCclusterMI *c=(AliTPCclusterMI*)(krow[i]);
633 if (c->GetZ() > z+roadz) break;
634 if ( (c->GetY()-y) > roady ) continue;
635 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
636 if (maxdistance>distance) {
637 maxdistance = distance;
639 index=krow.GetIndex(i);
648 Double_t chi2= t.GetPredictedChi2(cl);
649 UpdateTrack(&t,cl,chi2,index);
652 t.fRelativeSector= (t.fRelativeSector+1) % fN;
653 if (!t.Rotate(fSectors->GetAlpha()))
655 } else if (y <-ymax) {
656 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
657 if (!t.Rotate(-fSectors->GetAlpha()))
665 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t,Int_t trindex, Int_t nr) {
666 //-----------------------------------------------------------------
667 // This function tries to find a track prolongation to next pad row
668 //-----------------------------------------------------------------
669 t.fCurrentCluster = 0;
670 t.fCurrentClusterIndex1 = 0;
671 t.fCurrentClusterIndex2 = 0;
673 Double_t xt=t.GetX();
674 Int_t row = fSectors->GetRowNumber(xt)-1;
675 if (row < nr) return 1; // don't prolongate if not information until now -
676 Double_t x=fSectors->GetX(nr);
677 // if (t.fStopped) return 0;
678 // if (t.GetRadius()>x+10 ) return 0;
679 if (!t.PropagateTo(x)){
684 t.fCurrentSigmaY = GetSigmaY(&t);
685 t.fCurrentSigmaZ = GetSigmaZ(&t);
687 AliTPCclusterMI *cl=0;
689 AliTPCRow &krow=fSectors[t.fRelativeSector][nr];
691 Double_t y=t.GetY(), z=t.GetZ();
692 Double_t roady = 3.* TMath::Sqrt(t.GetSigmaY2() + t.fCurrentSigmaY*t.fCurrentSigmaY);
693 Double_t roadz = 3.* TMath::Sqrt(t.GetSigmaZ2() + t.fCurrentSigmaZ*t.fCurrentSigmaZ);
696 Float_t maxdistance = 1000000;
698 for (Int_t i=krow.Find(z-roadz); i<krow; i++) {
699 AliTPCclusterMI *c=(AliTPCclusterMI*)(krow[i]);
700 if (c->GetZ() > z+roadz) break;
701 if (TMath::Abs(c->GetY()-y)>roady) continue;
703 //krow.UpdateClusterTrack(i,trindex,&t);
705 Float_t dy2 = (c->GetY()- t.GetY());
707 Float_t dz2 = (c->GetZ()- t.GetZ());
710 Float_t distance = dy2+dz2;
712 if (distance > maxdistance) continue;
713 maxdistance = distance;
718 t.fCurrentCluster = cl;
719 t.fCurrentClusterIndex1 = krow.GetIndex(index);
720 t.fCurrentClusterIndex2 = index;
725 Int_t AliTPCtrackerMI::FollowToNextCluster(Int_t trindex, Int_t nr) {
726 //-----------------------------------------------------------------
727 // This function tries to find a track prolongation to next pad row
728 //-----------------------------------------------------------------
729 AliTPCseed & t = *((AliTPCseed*)(fSeeds->At(trindex)));
730 AliTPCRow &krow=fSectors[t.fRelativeSector][nr];
731 // Double_t pt=t.GetConvConst()/(100/0.299792458/0.2)/t.Get1Pt();
733 Double_t ymax=fSectors->GetMaxY(nr);
735 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
741 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
746 if (t.fCurrentCluster) {
747 // Float_t l=fSectors->GetPadPitchLength();
748 // AliTPCclusterTracks * cltrack = krow.GetClusterTracks(t.fCurrentClusterIndex1);
750 Double_t sy2=ErrY2(&t,t.fCurrentCluster);
751 Double_t sz2=ErrZ2(&t,t.fCurrentCluster);
754 Double_t sdistancey = TMath::Sqrt(sy2+t.GetSigmaY2());
755 Double_t sdistancez = TMath::Sqrt(sz2+t.GetSigmaZ2());
757 Double_t rdistancey = TMath::Abs(t.fCurrentCluster->GetY()-t.GetY());
758 Double_t rdistancez = TMath::Abs(t.fCurrentCluster->GetZ()-t.GetZ());
760 Double_t rdistance = TMath::Sqrt(TMath::Power(rdistancey/sdistancey,2)+TMath::Power(rdistancez/sdistancez,2));
763 // printf("\t%f\t%f\t%f\n",rdistancey/sdistancey,rdistancez/sdistancez,rdistance);
764 if ( (rdistancey>1) || (rdistancez>1)) return 0;
765 if (rdistance>4) return 0;
767 if ((rdistancey/sdistancey>2.5 || rdistancez/sdistancez>2.5) && t.fCurrentCluster->GetType()==0)
768 return 0; //suspisiouce - will be changed
770 if ((rdistancey/sdistancey>2. || rdistancez/sdistancez>2.0) && t.fCurrentCluster->GetType()>0)
771 // strict cut on overlaped cluster
772 return 0; //suspisiouce - will be changed
774 if ( (rdistancey/sdistancey>1. || rdistancez/sdistancez>2.5 ||t.fCurrentCluster->GetQ()<70 )
775 && t.fCurrentCluster->GetType()<0)
778 // t.SetSampledEdx(0.3*t.fCurrentCluster->GetQ()/l,t.GetNumberOfClusters(), GetSigmaY(&t), GetSigmaZ(&t));
779 UpdateTrack(&t,t.fCurrentCluster,t.GetPredictedChi2(t.fCurrentCluster),t.fCurrentClusterIndex1);
783 t.fRelativeSector= (t.fRelativeSector+1) % fN;
784 if (!t.Rotate(fSectors->GetAlpha()))
786 } else if (y <-ymax) {
787 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
788 if (!t.Rotate(-fSectors->GetAlpha()))
799 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t step)
801 //-----------------------------------------------------------------
802 // fast prolongation mathod -
803 // don't update track only after step clusters
804 //-----------------------------------------------------------------
805 Double_t xt=t.GetX();
807 Double_t alpha=t.GetAlpha();
808 alpha =- fSectors->GetAlphaShift();
809 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
810 if (alpha < 0. ) alpha += 2.*TMath::Pi();
811 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha())%fN;
812 Int_t row0 = fSectors->GetRowNumber(xt);
813 Double_t x = fSectors->GetX(row0);
814 Double_t ymax = fSectors->GetMaxY(row0);
816 Double_t sy2=ErrY2(&t)*2;
817 Double_t sz2=ErrZ2(&t)*2;
818 Double_t roady =3.*sqrt(t.GetSigmaY2() + sy2);
819 Double_t roadz = 3 *sqrt(t.GetSigmaZ2() + sz2);
820 Float_t maxdistance = roady*roady + roadz*roadz;
821 t.fCurrentSigmaY = GetSigmaY(&t);
822 t.fCurrentSigmaZ = GetSigmaZ(&t);
827 Double_t yy[200]; //track prolongation
829 Double_t cy[200]; // founded cluster position
831 Double_t sy[200]; // founded cluster error
833 Bool_t hitted[200]; // indication of cluster presence
837 for (Int_t drow = step; drow>=0; drow--) {
838 Int_t row = row0-drow;
840 Double_t x = fSectors->GetX(row);
841 Double_t ymax = fSectors->GetMaxY(row);
842 t.GetProlongation(x,y,z);
845 const AliTPCRow &krow=fSectors[t.fRelativeSector][row];
846 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
855 //find nearest cluster
856 AliTPCclusterMI *cl= 0;
858 for (Int_t i=krow.Find(z-roadz); i<krow; i++) {
859 AliTPCclusterMI *c=(AliTPCclusterMI*)(krow[i]);
860 if (c->GetZ() > z+roadz) break;
861 if ( (c->GetY()-y) > roady ) continue;
862 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
863 if (maxdistance>distance) {
864 maxdistance = distance;
866 // index=krow.GetIndex(i);
870 //update cluster information
872 cy[drow] = cl->GetY();
873 cz[drow] = cl->GetZ();
874 sy[drow] = ErrY2(&t,cl);
875 sz[drow] = ErrZ2(&t,cl);
876 hitted[drow] = kTRUE;
880 hitted[drow] = kFALSE;
882 //if we have information - update track
889 for (Int_t i=0;i<step;i++)
894 sumyw+= (cy[i]-yy[i])/sy[i];
895 sumzw+= (cz[i]-zz[i])/sz[i];
898 Float_t dy = sumyw/sumyw0;
899 Float_t dz = sumzw/sumzw0;
900 Float_t mrow = sumrow/nclusters+row0;
901 Float_t x = fSectors->GetX(mrow);
903 AliTPCclusterMI cvirtual;
904 cvirtual.SetZ(dz+t.GetZ());
905 cvirtual.SetY(dy+t.GetY());
906 t.SetErrorY2(1.2*t.fErrorY2/TMath::Sqrt(Float_t(nclusters)));
907 t.SetErrorZ2(1.2*t.fErrorZ2/TMath::Sqrt(Float_t(nclusters)));
908 Float_t chi2 = t.GetPredictedChi2(&cvirtual);
909 t.Update(&cvirtual,chi2,0);
910 Int_t ncl = t.GetNumberOfClusters();
911 ncl = ncl-1+nclusters;
918 //_____________________________________________________________________________
919 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf) {
920 //-----------------------------------------------------------------
921 // This function tries to find a track prolongation.
922 //-----------------------------------------------------------------
923 Double_t xt=t.GetX();
925 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
926 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
927 if (alpha < 0. ) alpha += 2.*TMath::Pi();
928 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha())%fN;
930 for (Int_t nr=fSectors->GetRowNumber(xt)-1; nr>=rf; nr--) {
932 if (FollowToNext(t,nr)==0) {
939 //_____________________________________________________________________________
940 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
941 //-----------------------------------------------------------------
942 // This function tries to find a track prolongation.
943 //-----------------------------------------------------------------
944 Double_t xt=t.GetX();
946 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
947 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
948 if (alpha < 0. ) alpha += 2.*TMath::Pi();
949 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha())%fN;
951 for (Int_t nr=fSectors->GetRowNumber(xt)+1; nr<=rf; nr++) {
962 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
969 if (s1->fSector!=s2->fSector) return 0;
971 Float_t dz2 =(s1->GetZ() - s2->GetZ());
973 Float_t dy2 =(s1->GetY() - s2->GetY());
975 Float_t distance = TMath::Sqrt(dz2+dy2);
976 if (distance>5.) return 0; // if there are far away - not overlap - to reduce combinatorics
978 for (Int_t i=0;i<160;i++){
979 if (s1->fClusterIndex[i]>0) sum1++;
980 if (s2->fClusterIndex[i]>0) sum2++;
981 if (s1->fClusterIndex[i]==s2->fClusterIndex[i] && s1->fClusterIndex[i]>0) {
986 Float_t summin = TMath::Min(sum1+1,sum2+1);
987 Float_t ratio = (sum+1)/Float_t(summin);
991 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
995 if (s1->fSector!=s2->fSector) return;
997 Float_t dz2 =(s1->GetZ() - s2->GetZ());
999 Float_t dy2 =(s1->GetY() - s2->GetY());
1001 Float_t distance = TMath::Sqrt(dz2+dy2);
1002 if (distance>15.) return ; // if there are far away - not overlap - to reduce combinatorics
1003 //trpoint = new (pointarray[track->fRow]) AliTPCTrackPoint;
1004 // TClonesArray &pointarray1 = *(s1->fPoints);
1005 //TClonesArray &pointarray2 = *(s2->fPoints);
1007 for (Int_t i=0;i<160;i++){
1008 if (s1->fClusterIndex[i]==s2->fClusterIndex[i] && s1->fClusterIndex[i]>0) {
1009 // AliTPCTrackPoint *p1 = (AliTPCTrackPoint *)(pointarray1.UncheckedAt(i));
1010 //AliTPCTrackPoint *p2 = (AliTPCTrackPoint *)(pointarray2.UncheckedAt(i));
1011 AliTPCTrackPoint *p1 = s1->GetTrackPoint(i);
1012 AliTPCTrackPoint *p2 = s2->GetTrackPoint(i);;
1013 p1->fIsShared = kTRUE;
1014 p2->fIsShared = kTRUE;
1022 void AliTPCtrackerMI::RemoveOverlap(TObjArray * arr, Float_t factor, Int_t removalindex , Bool_t shared){
1027 // remove overlap - used removal factor - removal index stored in the track
1028 arr->Sort(); // sorting according z
1029 arr->Expand(arr->GetEntries());
1030 Int_t nseed=arr->GetEntriesFast();
1031 // printf("seeds \t%p \t%d\n",arr, nseed);
1032 // arr->Expand(arr->GetEntries()); //remove 0 pointers
1033 nseed = arr->GetEntriesFast();
1035 for (Int_t i=0; i<nseed; i++) {
1036 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1040 if (!(pt->IsActive())) continue;
1041 for (Int_t j=i+1; j<nseed; j++){
1042 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1043 if ((pt2) && pt2->IsActive())
1044 if (pt->fSector == pt2->fSector)
1045 if (TMath::Abs(pt2->GetZ()-pt->GetZ())<2){
1047 Float_t ratio = OverlapFactor(pt,pt2,sum1,sum2);
1049 // pt->Desactivate(removalindex); // arr->RemoveAt(i);
1053 // if (pt->GetChi2()<pt2->GetChi2()) pt2->Desactivate(removalindex); // arr->RemoveAt(j);
1054 Float_t ratio2 = (pt->GetChi2()*sum2)/(pt2->GetChi2()*sum1);
1055 Float_t ratio3 = Float_t(sum1-sum2)/Float_t(sum1+sum2);
1057 if (TMath::Abs(ratio3)>0.025){ // if much more points
1058 if (sum1>sum2) pt2->Desactivate(removalindex);
1060 pt->Desactivate(removalindex); // arr->RemoveAt(i);
1064 else{ //decide on mean chi2
1066 pt2->Desactivate(removalindex);
1068 pt->Desactivate(removalindex); // arr->RemoveAt(i);
1073 } // if suspicious ratio
1079 // printf("removed\t%d\n",removed);
1081 for (Int_t i=0; i<nseed; i++) {
1082 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1084 if (pt->GetNumberOfClusters() < pt->fNFoundable*0.5) {
1085 //desactivate tracks with small number of points
1086 // printf("%d\t%d\t%f\n", pt->GetNumberOfClusters(), pt->fNFoundable,pt->GetNumberOfClusters()/Float_t(pt->fNFoundable));
1087 pt->Desactivate(10); //desactivate - small muber of points
1089 if (!(pt->IsActive())) continue;
1095 for (Int_t i=0; i<nseed; i++) {
1096 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1098 if (!(pt->IsActive())) continue;
1099 for (Int_t j=i+1; j<nseed; j++){
1100 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1101 if ((pt2) && pt2->IsActive()) {
1102 if ( TMath::Abs(pt->fSector-pt2->fSector)>1) break;
1108 printf("\n*****\nNumber of good tracks after overlap removal\t%d\n",fNtracks);
1112 void AliTPCtrackerMI::MakeSeedsAll()
1114 if (fSeeds == 0) fSeeds = new TObjArray;
1116 for (Int_t sec=0;sec<fkNOS;sec+=3){
1117 arr = MakeSeedsSectors(sec,sec+3);
1118 Int_t nseed = arr->GetEntriesFast();
1119 for (Int_t i=0;i<nseed;i++)
1120 fSeeds->AddLast(arr->RemoveAt(i));
1122 // fSeeds = MakeSeedsSectors(0,fkNOS);
1125 TObjArray * AliTPCtrackerMI::MakeSeedsSectors(Int_t sec1, Int_t sec2)
1128 // loop over all sectors and make seed
1131 Int_t nup=fOuterSec->GetNRows(), nlow=fInnerSec->GetNRows();
1132 Int_t nrows=nlow+nup;
1133 Int_t gap=Int_t(0.125*nrows), shift=Int_t(0.5*gap);
1134 // if (fSeeds==0) fSeeds = new TObjArray;
1135 TObjArray * arr = new TObjArray;
1137 for (Int_t sec=sec1; sec<sec2;sec++){
1138 MakeSeeds(arr, sec, nup-1, nup-1-gap);
1139 MakeSeeds(arr, sec, nup-1-shift, nup-1-shift-gap);
1141 gap = Int_t(0.3* nrows);
1142 for (Int_t sec=sec1; sec<sec2;sec++){
1144 MakeSeeds2(arr, sec, nup-1, nup-1-gap);
1145 MakeSeeds2(arr, sec, nup-1-shift, nup-1-shift-gap);
1146 MakeSeeds2(arr, sec, nup-1-2*shift, nup-1-2*shift-gap);
1147 //MakeSeeds2(arr, sec, nup-1-3*shift, nup-1-3*shift-gap);
1148 MakeSeeds2(arr, sec, 30, 0);
1151 Int_t nseed=arr->GetEntriesFast();
1152 gap=Int_t(0.3*nrows);
1155 for (i=0; i<nseed; i++) {
1156 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
1158 if (FollowProlongation(t,nup-gap)) {
1159 pt->fIsSeeding =kFALSE;
1162 delete arr->RemoveAt(i);
1166 //remove seeds which overlaps
1167 RemoveOverlap(arr,0.6,1);
1168 //delete seeds - which were sign
1169 nseed=arr->GetEntriesFast();
1170 for (i=0; i<nseed; i++) {
1171 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1174 if ((pt->IsActive()) && pt->GetNumberOfClusters() > pt->fNFoundable*0.5 ) {
1176 //FollowBackProlongation(*pt,nup-1);
1177 //if ( pt->GetNumberOfClusters() < pt->fNFoundable*0.5 || pt->GetNumberOfClusters()<10 )
1178 //delete arr->RemoveAt(i);
1183 delete arr->RemoveAt(i);
1185 //RemoveOverlap(arr,0.6,1);
1191 //_____________________________________________________________________________
1192 void AliTPCtrackerMI::MakeSeeds(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2) {
1193 //-----------------------------------------------------------------
1194 // This function creates track seeds.
1195 //-----------------------------------------------------------------
1196 // if (fSeeds==0) fSeeds=new TObjArray(15000);
1198 Double_t x[5], c[15];
1200 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
1201 Double_t cs=cos(alpha), sn=sin(alpha);
1203 Double_t x1 =fOuterSec->GetX(i1);
1204 Double_t xx2=fOuterSec->GetX(i2);
1206 // for (Int_t ns=0; ns<fkNOS; ns++)
1209 Int_t nl=fOuterSec[(ns-1+fkNOS)%fkNOS][i2];
1210 Int_t nm=fOuterSec[ns][i2];
1211 Int_t nu=fOuterSec[(ns+1)%fkNOS][i2];
1212 const AliTPCRow& kr1=fOuterSec[ns][i1];
1213 AliTPCRow& kr21 = fOuterSec[(ns-1+fkNOS)%fkNOS][i2];
1214 AliTPCRow& kr22 = fOuterSec[(ns)%fkNOS][i2];
1215 AliTPCRow& kr23 = fOuterSec[(ns+1)%fkNOS][i2];
1217 for (Int_t is=0; is < kr1; is++) {
1218 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
1219 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
1221 Float_t anglez = (z1-z3)/(x1-x3);
1222 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
1224 for (Int_t js=0; js < nl+nm+nu; js++) {
1225 const AliTPCclusterMI *kcl;
1226 Double_t x2, y2, z2;
1229 js = kr21.Find(extraz-15.);
1230 if (js>=nl) continue;
1234 if ((extraz-z2)>10) continue;
1235 if ((extraz-z2)<-10) {
1245 js = nl+kr22.Find(extraz-15.);
1246 if (js>=nl+nm) continue;
1250 if ((extraz-z2)>10) continue;
1251 if ((extraz-z2)<-10) {
1255 x2=xx2; y2=kcl->GetY();
1257 //const AliTPCRow& kr2=fOuterSec[(ns+1)%fkNOS][i2];
1259 js = nl+nm+kr23.Find(extraz-15.);
1260 if (js>=nl+nm+nu) break;
1264 if ((extraz-z2)>10) continue;
1265 if ((extraz-z2)<-10) {
1273 Double_t zz=z1 - anglez*(x1-x2);
1274 if (TMath::Abs(zz-z2)>10.) continue;
1276 Double_t d=(x2-x1)*(0.-y2)-(0.-x2)*(y2-y1);
1277 if (d==0.) {cerr<<"MakeSeeds warning: Straight seed !\n"; continue;}
1281 x[4]=f1(x1,y1,x2,y2,x3,y3);
1282 if (TMath::Abs(x[4]) >= 0.0066) continue;
1283 x[2]=f2(x1,y1,x2,y2,x3,y3);
1284 //if (TMath::Abs(x[4]*x1-x[2]) >= 0.99999) continue;
1285 x[3]=f3(x1,y1,x2,y2,z1,z2);
1286 if (TMath::Abs(x[3]) > 1.2) continue;
1287 Double_t a=asin(x[2]);
1288 Double_t zv=z1 - x[3]/x[4]*(a+asin(x[4]*x1-x[2]));
1289 if (TMath::Abs(zv-z3)>10.) continue;
1291 Double_t sy1=kr1[is]->GetSigmaY2()*2, sz1=kr1[is]->GetSigmaZ2()*4;
1292 Double_t sy2=kcl->GetSigmaY2()*2, sz2=kcl->GetSigmaZ2()*4;
1293 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
1294 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
1295 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
1297 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
1298 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
1299 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
1300 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
1301 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
1302 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
1303 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
1304 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
1305 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
1306 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1310 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
1311 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
1312 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
1313 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
1314 c[13]=f30*sy1*f40+f32*sy2*f42;
1315 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
1317 UInt_t index=kr1.GetIndex(is);
1318 AliTPCseed *track=new AliTPCseed(index, x, c, x1, ns*alpha+shift);
1319 track->fIsSeeding = kTRUE;
1320 Int_t rc=FollowProlongation(*track, i2);
1321 //FollowProlongationFast(*track, 5);
1322 //FollowProlongationFast(*track, 5);
1323 //FollowProlongationFast(*track, 5);
1324 //FollowProlongationFast(*track, 5);
1327 track->fLastPoint = i1; // first cluster in track position
1328 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)/4 || track->GetNumberOfClusters() < track->fNFoundable/2. ) delete track;
1329 else arr->AddLast(track);
1336 //_____________________________________________________________________________
1337 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2) {
1338 //-----------------------------------------------------------------
1339 // This function creates track seeds - without vertex constraint
1340 //-----------------------------------------------------------------
1342 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
1343 // Double_t cs=cos(alpha), sn=sin(alpha);
1344 Int_t row0 = (i1+i2)/2;
1345 Int_t drow = (i1-i2)/2;
1346 const AliTPCRow& kr0=fSectors[sec][row0];
1347 const AliTPCRow& krm=fSectors[sec][row0-1];
1348 const AliTPCRow& krp=fSectors[sec][row0+1];
1351 AliTPCpolyTrack polytrack;
1352 Int_t nclusters=fSectors[sec][row0];
1354 for (Int_t is=0; is < nclusters; is++) {
1355 const AliTPCclusterMI * cl= kr0[is];
1356 Double_t x = kr0.GetX();
1358 // Initialization of the polytrack
1361 Double_t y0= cl->GetY();
1362 Double_t z0= cl->GetZ();
1363 polytrack.AddPoint(x,y0,z0);
1364 Float_t roady = 5*TMath::Sqrt(cl->GetSigmaY2()+0.2);
1365 Float_t roadz = 5*TMath::Sqrt(cl->GetSigmaZ2()+0.2);
1368 cl = krm.FindNearest(y0,z0,roady,roadz);
1369 if (cl) polytrack.AddPoint(x,cl->GetY(),cl->GetZ(),roady,roadz);
1372 cl = krp.FindNearest(y0,z0,roady,roadz);
1373 if (cl) polytrack.AddPoint(x,cl->GetY(),cl->GetZ(),cl->GetSigmaY2()+0.05,cl->GetSigmaZ2()+0.05);
1375 polytrack.UpdateParameters();
1381 Int_t nfoundable = polytrack.GetN();
1382 Int_t nfound = nfoundable;
1383 for (Int_t ddrow = 2; ddrow<drow;ddrow++){
1384 for (Int_t delta = -1;delta<=1;delta+=2){
1385 Int_t row = row0+ddrow*delta;
1386 kr = &(fSectors[sec][row]);
1387 Double_t xn = kr->GetX();
1388 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone;
1389 polytrack.GetFitPoint(xn,yn,zn);
1390 if (TMath::Abs(yn)>ymax) continue;
1392 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
1394 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),cln->GetSigmaY2()+0.05,cln->GetSigmaZ2()+0.05);
1398 polytrack.UpdateParameters();
1400 if ((nfound>0.5*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
1401 // add polytrack candidate
1402 Double_t x[5], c[15];
1403 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
1404 polytrack.GetBoundaries(x3,x1);
1406 polytrack.GetFitPoint(x1,y1,z1);
1407 polytrack.GetFitPoint(x2,y2,z2);
1408 polytrack.GetFitPoint(x3,y3,z3);
1410 //is track pointing to the vertex ?
1413 polytrack.GetFitPoint(x0,y0,z0);
1414 if ( (TMath::Abs(z0-GetZ())<10) && (TMath::Abs(y0-GetY())<5)){ //if yes apply vertex constraint
1422 x[4]=f1(x1,y1,x2,y2,x3,y3);
1423 if (TMath::Abs(x[4]) >= 0.0066) continue;
1424 x[2]=f2(x1,y1,x2,y2,x3,y3);
1425 //if (TMath::Abs(x[4]*x1-x[2]) >= 0.99999) continue;
1426 x[3]=f3(x1,y1,x2,y2,z1,z2);
1427 if (TMath::Abs(x[3]) > 1.2) continue;
1428 if (TMath::Abs(x[2]) > 0.99) continue;
1429 // Double_t a=asin(x[2]);
1432 Double_t sy=1.5, sz=1.5;
1433 Double_t sy1=1.5, sz1=1.5;
1434 Double_t sy2=1.3, sz2=1.3;
1437 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
1438 // Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
1439 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
1441 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
1442 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
1443 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
1444 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
1445 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
1446 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
1447 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
1448 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
1449 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
1450 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1454 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
1455 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
1456 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
1457 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
1458 c[13]=f30*sy1*f40+f32*sy2*f42;
1459 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
1463 AliTPCseed *track=new AliTPCseed(index, x, c, x1, sec*alpha+shift);
1464 track->fStopped =kFALSE;
1465 track->fIsSeeding = kTRUE;
1466 Int_t rc=FollowProlongation(*track, i2);
1467 track->fLastPoint = i1; // first cluster in track position
1468 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)/4 || track->GetNumberOfClusters() < track->fNFoundable/2. ) delete track;
1469 else arr->AddLast(track);
1481 //_____________________________________________________________________________
1482 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
1483 //-----------------------------------------------------------------
1484 // This function reades track seeds.
1485 //-----------------------------------------------------------------
1486 TDirectory *savedir=gDirectory;
1488 TFile *in=(TFile*)inp;
1489 if (!in->IsOpen()) {
1490 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
1495 TTree *seedTree=(TTree*)in->Get("Seeds");
1497 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
1498 cerr<<"can't get a tree with track seeds !\n";
1501 AliTPCtrack *seed=new AliTPCtrack;
1502 seedTree->SetBranchAddress("tracks",&seed);
1504 if (fSeeds==0) fSeeds=new TObjArray(15000);
1506 Int_t n=(Int_t)seedTree->GetEntries();
1507 for (Int_t i=0; i<n; i++) {
1508 seedTree->GetEvent(i);
1509 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
1518 //_____________________________________________________________________________
1519 Int_t AliTPCtrackerMI::Clusters2Tracks(const TFile *inp, TFile *out) {
1520 //-----------------------------------------------------------------
1521 // This is a track finder.
1522 //-----------------------------------------------------------------
1523 TDirectory *savedir=gDirectory;
1526 TFile *in=(TFile*)inp;
1527 if (!in->IsOpen()) {
1528 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
1533 if (!out->IsOpen()) {
1534 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): output file is not open !\n";
1541 sprintf(tname,"TreeT_TPC_%d",fEventN);
1542 TTree tracktree(tname,"Tree with TPC tracks");
1543 TTree seedtree("Seeds","Seeds");
1544 AliTPCtrack *iotrack=0;
1545 AliTPCseed *ioseed=0;
1546 tracktree.Branch("tracks","AliTPCtrack",&iotrack,32000,0);
1549 printf("Loading clusters \n");
1551 printf("Time for loading clusters: \t");timer.Print();timer.Start();
1553 printf("Loading outer sectors\n");
1555 printf("Time for loading outer sectors: \t");timer.Print();timer.Start();
1557 printf("Loading inner sectors\n");
1559 printf("Time for loading inner sectors: \t");timer.Print();timer.Start();
1560 fSectors = fOuterSec;
1566 printf("Time for seeding: \t"); timer.Print();timer.Start();
1567 Int_t nup=fOuterSec->GetNRows(), nlow=fInnerSec->GetNRows();
1568 Int_t nrows=nlow+nup;
1570 Int_t gap=Int_t(0.3*nrows);
1572 //RemoveOverlap(fSeeds,0.6,2);
1573 Int_t nseed=fSeeds->GetEntriesFast();
1574 // outer sectors parallel tracking
1575 ParallelTracking(fSectors->GetNRows()-gap-1,0);
1576 //ParallelTracking(fSectors->GetNRows()-1,0);
1577 //RemoveOverlap(fSeeds, 0.6,3);
1578 // ParallelTracking(49,0);
1579 printf("Time for parralel tracking outer sectors: \t"); timer.Print();timer.Start();
1581 RemoveOverlap(fSeeds, 0.6,3);
1582 printf("Time for removal overlap- outer sectors: \t");timer.Print();timer.Start();
1584 fSectors = fInnerSec;
1586 ParallelTracking(fSectors->GetNRows()-1,0);
1587 printf("Number of tracks after inner tracking %d\n",fNtracks);
1588 printf("Time for parralel tracking inner sectors: \t"); timer.Print();timer.Start();
1590 RemoveOverlap(fSeeds,0.6,5,kTRUE); // remove overlap - shared points signed
1591 printf("Time for removal overlap- inner sectors: \t"); timer.Print();timer.Start();
1595 ioseed = (AliTPCseed*)(fSeeds->UncheckedAt(0));
1596 AliTPCseed * vseed = new AliTPCseed;
1597 vseed->fPoints = new TClonesArray("AliTPCTrackPoint",1);
1598 vseed->fEPoints = new TClonesArray("AliTPCExactPoint",1);
1599 vseed->fPoints->ExpandCreateFast(2);
1601 TBranch * seedbranch = seedtree.Branch("seeds","AliTPCseed",&vseed,32000,99);
1603 nseed=fSeeds->GetEntriesFast();
1606 for (i=0; i<nseed; i++) {
1607 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
1609 Int_t nc=t.GetNumberOfClusters();
1610 if (nc<20) continue;
1611 t.CookdEdx(0.02,0.6);
1612 CookLabel(pt,0.1); //For comparison only
1613 // if ((pt->IsActive()) && (nc>Int_t(0.4*nrows))){
1614 if ((pt->IsActive()) && (nc>Int_t(0.5*t.fNFoundable) && (t.fNFoundable>Int_t(0.3*nrows)))){
1617 cerr<<found++<<'\r';
1620 if ( (pt->IsActive())) fNtracks--;
1622 seedbranch->SetAddress(&pt);
1625 for (Int_t j=0;j<160;j++){
1626 delete pt->fPoints->RemoveAt(j);
1630 delete fSeeds->RemoveAt(i);
1632 printf("Time for track writing and dedx cooking: \t"); timer.Print();timer.Start();
1635 printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
1639 cerr<<"Number of found tracks : "<<fNtracks<<"\t"<<found<<endl;
1647 void AliTPCtrackerMI::ParallelTracking(Int_t rfirst, Int_t rlast)
1650 // try to track in parralel
1652 Int_t nseed=fSeeds->GetEntriesFast();
1653 //prepare seeds for tracking
1654 for (Int_t i=0; i<nseed; i++) {
1655 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
1657 if (!t.IsActive()) continue;
1658 // follow prolongation to the first layer
1659 FollowProlongation(t, rfirst+1);
1664 for (Int_t nr=rfirst; nr>=rlast; nr--){
1665 // make indexes with the cluster tracks for given
1666 // for (Int_t i = 0;i<fN;i++)
1667 // fSectors[i][nr].MakeClusterTracks();
1669 // find nearest cluster
1670 for (Int_t i=0; i<nseed; i++) {
1671 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
1673 if (!pt->IsActive()) continue;
1674 if (pt->fRelativeSector>17) {
1677 UpdateClusters(t,i,nr);
1679 // prolonagate to the nearest cluster - if founded
1680 for (Int_t i=0; i<nseed; i++) {
1681 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
1683 if (!pt->IsActive()) continue;
1684 if (pt->fRelativeSector>17) {
1687 FollowToNextCluster(i,nr);
1689 // for (Int_t i= 0;i<fN;i++)
1690 // fSectors[i][nr].ClearClusterTracks();
1695 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
1699 Float_t sd2 = (fParam->GetZLength()-TMath::Abs(seed->GetZ()))*fParam->GetDiffL()*fParam->GetDiffL();
1700 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
1701 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
1702 Float_t angular = seed->GetSnp();
1703 angular = angular*angular/(1-angular*angular);
1704 // angular*=angular;
1705 //angular = TMath::Sqrt(angular/(1-angular));
1706 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
1709 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
1713 Float_t sd2 = (fParam->GetZLength()-TMath::Abs(seed->GetZ()))*fParam->GetDiffL()*fParam->GetDiffL();
1714 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
1715 Float_t sres = fParam->GetZSigma();
1716 Float_t angular = seed->GetTgl();
1717 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
1723 //_________________________________________________________________________
1724 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1725 //--------------------------------------------------------------------
1726 // Return pointer to a given cluster
1727 //--------------------------------------------------------------------
1728 Int_t sec=(index&0xff000000)>>24;
1729 Int_t row=(index&0x00ff0000)>>16;
1730 Int_t ncl=(index&0x0000ffff)>>00;
1732 AliTPCClustersRow *clrow=((AliTPCtrackerMI *) this)->fClustersArray.GetRow(sec,row);
1733 if (!clrow) return 0;
1734 return (AliTPCclusterMI*)(*clrow)[ncl];
1737 //__________________________________________________________________________
1738 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
1739 //--------------------------------------------------------------------
1740 //This function "cooks" a track label. If label<0, this track is fake.
1741 //--------------------------------------------------------------------
1742 Int_t noc=t->GetNumberOfClusters();
1743 Int_t *lb=new Int_t[noc];
1744 Int_t *mx=new Int_t[noc];
1745 AliTPCclusterMI **clusters=new AliTPCclusterMI*[noc];
1748 for (i=0; i<noc; i++) {
1750 Int_t index=t->GetClusterIndex(i);
1751 clusters[i]=GetClusterMI(index);
1754 Int_t lab=123456789;
1755 for (i=0; i<noc; i++) {
1756 AliTPCclusterMI *c=clusters[i];
1757 if (!clusters[i]) continue;
1758 lab=TMath::Abs(c->GetLabel(0));
1760 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
1766 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
1768 for (i=0; i<noc; i++) {
1769 AliTPCclusterMI *c=clusters[i];
1770 if (!clusters[i]) continue;
1771 if (TMath::Abs(c->GetLabel(1)) == lab ||
1772 TMath::Abs(c->GetLabel(2)) == lab ) max++;
1775 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
1778 Int_t tail=Int_t(0.10*noc);
1780 for (i=1; i<=tail; i++) {
1781 AliTPCclusterMI *c=clusters[noc-i];
1782 if (!clusters[i]) continue;
1783 if (lab == TMath::Abs(c->GetLabel(0)) ||
1784 lab == TMath::Abs(c->GetLabel(1)) ||
1785 lab == TMath::Abs(c->GetLabel(2))) max++;
1787 if (max < Int_t(0.5*tail)) lab=-lab;
1797 //_________________________________________________________________________
1798 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
1799 //-----------------------------------------------------------------------
1800 // Setup inner sector
1801 //-----------------------------------------------------------------------
1803 fAlpha=par->GetInnerAngle();
1804 fAlphaShift=par->GetInnerAngleShift();
1805 fPadPitchWidth=par->GetInnerPadPitchWidth();
1806 fPadPitchLength=par->GetInnerPadPitchLength();
1807 fN=par->GetNRowLow();
1808 fRow=new AliTPCRow[fN];
1809 for (Int_t i=0; i<fN; i++) {
1810 fRow[i].SetX(par->GetPadRowRadiiLow(i));
1811 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
1814 fAlpha=par->GetOuterAngle();
1815 fAlphaShift=par->GetOuterAngleShift();
1816 fPadPitchWidth = par->GetOuterPadPitchWidth();
1817 fPadPitchLength = par->GetOuter1PadPitchLength();
1818 f1PadPitchLength = par->GetOuter1PadPitchLength();
1819 f2PadPitchLength = par->GetOuter2PadPitchLength();
1821 fN=par->GetNRowUp();
1822 fRow=new AliTPCRow[fN];
1823 for (Int_t i=0; i<fN; i++) {
1824 fRow[i].SetX(par->GetPadRowRadiiUp(i));
1825 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
1831 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
1833 if (fClusterTracks) delete [] fClusterTracks;
1837 void AliTPCtrackerMI::AliTPCRow::MakeClusterTracks(){
1838 //create cluster tracks
1840 fClusterTracks = new AliTPCclusterTracks[fN];
1843 void AliTPCtrackerMI::AliTPCRow::ClearClusterTracks(){
1844 if (fClusterTracks) delete[] fClusterTracks;
1850 void AliTPCtrackerMI::AliTPCRow::UpdateClusterTrack(Int_t clindex, Int_t trindex, AliTPCseed * seed){
1853 // update information of the cluster tracks - if track is nearer then other tracks to the
1855 const AliTPCclusterMI * cl = (*this)[clindex];
1856 AliTPCclusterTracks * cltracks = GetClusterTracks(clindex);
1857 // find the distance of the cluster to the track
1858 Float_t dy2 = (cl->GetY()- seed->GetY());
1860 Float_t dz2 = (cl->GetZ()- seed->GetZ());
1863 Float_t distance = TMath::Sqrt(dy2+dz2);
1865 return; // MI - to be changed - AliTPCtrackerParam
1867 if ( distance < cltracks->fDistance[0]){
1868 cltracks->fDistance[2] =cltracks->fDistance[1];
1869 cltracks->fDistance[1] =cltracks->fDistance[0];
1870 cltracks->fDistance[0] =distance;
1871 cltracks->fTrackIndex[2] =cltracks->fTrackIndex[1];
1872 cltracks->fTrackIndex[1] =cltracks->fTrackIndex[0];
1873 cltracks->fTrackIndex[0] =trindex;
1876 if ( distance < cltracks->fDistance[1]){
1877 cltracks->fDistance[2] =cltracks->fDistance[1];
1878 cltracks->fDistance[1] =distance;
1879 cltracks->fTrackIndex[2] =cltracks->fTrackIndex[1];
1880 cltracks->fTrackIndex[1] =trindex;
1882 if (distance < cltracks->fDistance[2]){
1883 cltracks->fDistance[2] =distance;
1884 cltracks->fTrackIndex[2] =trindex;
1889 //_________________________________________________________________________
1891 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
1892 //-----------------------------------------------------------------------
1893 // Insert a cluster into this pad row in accordence with its y-coordinate
1894 //-----------------------------------------------------------------------
1895 if (fN==kMaxClusterPerRow) {
1896 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
1898 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
1899 Int_t i=Find(c->GetZ());
1900 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
1901 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
1902 fIndex[i]=index; fClusters[i]=c; fN++;
1905 //___________________________________________________________________
1906 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
1907 //-----------------------------------------------------------------------
1908 // Return the index of the nearest cluster
1909 //-----------------------------------------------------------------------
1910 if (fN==0) return 0;
1911 if (z <= fClusters[0]->GetZ()) return 0;
1912 if (z > fClusters[fN-1]->GetZ()) return fN;
1913 Int_t b=0, e=fN-1, m=(b+e)/2;
1914 for (; b<e; m=(b+e)/2) {
1915 if (z > fClusters[m]->GetZ()) b=m+1;
1923 //___________________________________________________________________
1924 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
1925 //-----------------------------------------------------------------------
1926 // Return the index of the nearest cluster in z y
1927 //-----------------------------------------------------------------------
1928 Float_t maxdistance = roady*roady + roadz*roadz;
1930 AliTPCclusterMI *cl =0;
1931 for (Int_t i=Find(z-roadz); i<fN; i++) {
1932 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
1933 if (c->GetZ() > z+roadz) break;
1934 if ( (c->GetY()-y) > roady ) continue;
1935 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
1936 if (maxdistance>distance) {
1937 maxdistance = distance;
1948 AliTPCseed::AliTPCseed():AliTPCtrack(){
1952 memset(fClusterIndex,0,sizeof(Int_t)*200);
1961 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
1969 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
1971 memset(fClusterIndex,0,sizeof(Int_t)*200);
1980 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
1981 Double_t xr, Double_t alpha):
1982 AliTPCtrack(index, xx, cc, xr, alpha) {
1986 memset(fClusterIndex,0,sizeof(Int_t)*200);
1995 AliTPCseed::~AliTPCseed(){
1996 if (fPoints) delete fPoints;
2000 for (Int_t i=0;i<8;i++){
2001 delete [] fTrackPoints[i];
2003 delete fTrackPoints;
2009 AliTPCTrackPoint * AliTPCseed::GetTrackPoint(Int_t i)
2013 if (!fTrackPoints) {
2014 fTrackPoints = new AliTPCTrackPoint*[8];
2015 for ( Int_t i=0;i<8;i++)
2018 Int_t index1 = i/20;
2019 if (!fTrackPoints[index1]) fTrackPoints[index1] = new AliTPCTrackPoint[20];
2020 return &(fTrackPoints[index1][i%20]);
2023 void AliTPCseed::RebuildSeed()
2026 // rebuild seed to be ready for storing
2027 fPoints = new TClonesArray("AliTPCTrackPoint",160);
2028 fPoints->ExpandCreateFast(160);
2029 fEPoints = new TClonesArray("AliTPCExactPoint",1);
2030 for (Int_t i=0;i<160;i++){
2031 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
2032 *trpoint = *(GetTrackPoint(i));
2037 //_____________________________________________________________________________
2038 void AliTPCseed::CookdEdx(Double_t low, Double_t up) {
2039 //-----------------------------------------------------------------
2040 // This funtion calculates dE/dX within the "low" and "up" cuts.
2041 //-----------------------------------------------------------------
2044 Float_t angular[200];
2045 Float_t weight[200];
2048 // TClonesArray & arr = *fPoints;
2049 Float_t meanlog = 100.;
2051 Float_t mean[4] = {0,0,0,0};
2052 Float_t sigma[4] = {1000,1000,1000,1000};
2053 Int_t nc[4] = {0,0,0,0};
2054 Float_t norm[4] = {1000,1000,1000,1000};
2059 for (Int_t of =0; of<4; of++){
2060 for (Int_t i=of;i<160;i+=4)
2062 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
2063 AliTPCTrackPoint * point = GetTrackPoint(i);
2064 if (point==0) continue;
2065 if (point->fIsShared){
2069 if (point->GetCPoint().GetMax()<5) continue;
2070 Float_t angley = point->GetTPoint().GetAngleY();
2071 Float_t anglez = point->GetTPoint().GetAngleZ();
2072 Int_t type = point->GetCPoint().GetType();
2073 Float_t rsigmay = point->GetCPoint().GetSigmaY();
2074 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
2075 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
2077 Float_t ampc = 0; // normalization to the number of electrons
2079 ampc = 1.*point->GetCPoint().GetMax();
2080 //ampc = 1.*point->GetCPoint().GetQ();
2081 // AliTPCClusterPoint & p = point->GetCPoint();
2082 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
2083 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
2085 // TMath::Abs( Int_t(iz) - iz + 0.5);
2086 //ampc *= 1.15*(1-0.3*dy);
2087 //ampc *= 1.15*(1-0.3*dz);
2088 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
2092 ampc = 1.0*point->GetCPoint().GetMax();
2093 //ampc = 1.0*point->GetCPoint().GetQ();
2094 //AliTPCClusterPoint & p = point->GetCPoint();
2095 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
2096 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
2098 // TMath::Abs( Int_t(iz) - iz + 0.5);
2100 //ampc *= 1.15*(1-0.3*dy);
2101 //ampc *= 1.15*(1-0.3*dz);
2102 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
2106 ampc *= 2.0; // put mean value to channel 50
2107 //ampc *= 0.58; // put mean value to channel 50
2109 // if (type>0) w = 1./(type/2.-0.5);
2110 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
2113 //ampc /= (1+0.0008*z);
2117 //ampc /= (1+0.0008*z);
2119 //ampc /= (1+0.0008*z);
2122 if (type<0) { //amp at the border - lower weight
2127 if (rsigma>1.5) ampc/=1.3; // if big backround
2129 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
2134 TMath::Sort(nc[of],amp,index,kFALSE);
2138 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
2140 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
2141 Float_t ampl = amp[index[i]]/angular[index[i]];
2142 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
2144 sumw += weight[index[i]];
2145 sumamp += weight[index[i]]*ampl;
2146 sumamp2 += weight[index[i]]*ampl*ampl;
2147 norm[of] += angular[index[i]]*weight[index[i]];
2154 mean[of] = sumamp/sumw;
2155 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
2157 sigma[of] = TMath::Sqrt(sigma[of]);
2161 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
2162 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
2163 //mean *=(1-0.1*(norm-1.));
2170 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
2171 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
2174 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
2175 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
2179 for (Int_t i =0;i<4;i++){
2180 if (nc[i]>2&&nc[i]<1000){
2181 dedx += mean[i] *nc[i];
2182 fSdEdx += sigma[i]*(nc[i]-2);
2183 fMAngular += norm[i] *nc[i];
2188 fSDEDX[i] = sigma[i];
2201 // Float_t dedx1 =dedx;
2204 for (Int_t i =0;i<4;i++){
2205 if (nc[i]>2&&nc[i]<1000){
2206 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
2207 dedx += mean[i] *nc[i];
2222 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
2225 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
2226 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
2227 SetMass(0.93827); return;
2231 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
2232 SetMass(0.93827); return;
2235 SetMass(0.13957); return;