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 **************************************************************************/
18 Revision 1.9.4.3 2003/06/23 14:47:10 hristov
21 Revision 1.9.4.2 2003/06/23 10:06:13 hristov
22 Updated information about the overlapping clusters (M.Ivanov)
24 Revision 1.9.4.1 2003/06/19 06:59:58 hristov
25 Updated version of parallel tracking (M.Ivanov)
27 Revision 1.9 2003/03/19 17:14:11 hristov
28 Load/UnloadClusters added to the base class and the derived classes changed correspondingly. Possibility to give 2 input files for ITS and TPC tracks in PropagateBack. TRD tracker uses fEventN from the base class (T.Kuhr)
30 Revision 1.8 2003/03/05 11:16:15 kowal2
42 AliTPC parallel tracker -
44 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
45 run AliTPCFindTracksMI.C macro - to find tracks
46 tracks are written to AliTPCtracks.root file
47 for comparison also seeds are written to the same file - to special branch
50 //-------------------------------------------------------
51 // Implementation of the TPC tracker
53 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
55 //-------------------------------------------------------
56 #include <TObjArray.h>
59 #include "Riostream.h"
61 #include "AliTPCtrackerMI.h"
62 #include "AliTPCclusterMI.h"
63 #include "AliTPCParam.h"
64 #include "AliTPCClustersRow.h"
65 #include "AliComplexCluster.h"
66 #include "AliTPCpolyTrack.h"
67 #include "TStopwatch.h"
72 #include "AliRunLoader.h"
77 ClassImp(AliTPCtrackerMI)
83 static Double_t FastAsin(Double_t x);
85 static Double_t fgFastAsin[20000];
88 Double_t TPCFastMath::fgFastAsin[20000];
90 TPCFastMath::TPCFastMath(){
91 for (Int_t i=0;i<10000;i++){
92 fgFastAsin[2*i] = TMath::ASin(i/10000.);
93 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
97 Double_t TPCFastMath::FastAsin(Double_t x){
99 Int_t index = int(x*10000);
100 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
103 Int_t index = int(x*10000);
104 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
107 TPCFastMath gTPCMath;
111 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
113 AliTPCclusterMI* c =track->fCurrentCluster;
114 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
116 UInt_t i = track->fCurrentClusterIndex1;
118 Int_t sec=(i&0xff000000)>>24;
119 //Int_t row = (i&0x00ff0000)>>16;
120 track->fRow=(i&0x00ff0000)>>16;
121 track->fSector = sec;
122 // Int_t index = i&0xFFFF;
123 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
124 track->SetClusterIndex2(track->fRow, i);
126 //track->fFirstPoint = row;
127 //if ( track->fLastPoint<row) track->fLastPoint =row;
128 // if (track->fRow<0 || track->fRow>160) {
129 // printf("problem\n");
131 if (track->fFirstPoint>track->fRow)
132 track->fFirstPoint = track->fRow;
133 if (track->fLastPoint<track->fRow)
134 track->fLastPoint = track->fRow;
137 track->fClusterPointer[track->fRow] = c;
140 Float_t angle2 = track->GetSnp()*track->GetSnp();
141 angle2 = TMath::Sqrt(angle2/(1-angle2));
143 //SET NEW Track Point
147 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
149 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
150 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
151 point.SetErrY(sqrt(track->fErrorY2));
152 point.SetErrZ(sqrt(track->fErrorZ2));
154 point.SetX(track->GetX());
155 point.SetY(track->GetY());
156 point.SetZ(track->GetZ());
157 point.SetAngleY(angle2);
158 point.SetAngleZ(track->GetTgl());
159 if (point.fIsShared){
160 track->fErrorY2 *= 4;
161 track->fErrorZ2 *= 4;
165 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
167 track->fErrorY2 *= 1.3;
168 track->fErrorY2 += 0.01;
169 track->fErrorZ2 *= 1.3;
170 track->fErrorZ2 += 0.005;
172 if (accept>0) return 0;
173 if (track->GetNumberOfClusters()%20==0){
174 // if (track->fHelixIn){
175 // TClonesArray & larr = *(track->fHelixIn);
176 // Int_t ihelix = larr.GetEntriesFast();
177 // new(larr[ihelix]) AliHelix(*track) ;
180 track->fNoCluster =0;
181 return track->Update(c,chi2,i);
186 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
187 Float_t cory, Float_t corz)
190 // decide according desired precision to accept given
191 // cluster for tracking
192 Double_t sy2=ErrY2(seed,cluster)*cory;
193 Double_t sz2=ErrZ2(seed,cluster)*corz;
194 //sy2=ErrY2(seed,cluster)*cory;
195 //sz2=ErrZ2(seed,cluster)*cory;
197 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
198 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
200 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
201 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
202 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
203 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
205 Double_t rdistance2 = rdistancey2+rdistancez2;
208 if (rdistance2>16) return 3;
211 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
212 return 2; //suspisiouce - will be changed
214 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
215 // strict cut on overlaped cluster
216 return 2; //suspisiouce - will be changed
218 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
219 && cluster->GetType()<0){
229 //_____________________________________________________________________________
230 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
231 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
233 //---------------------------------------------------------------------
234 // The main TPC tracker constructor
235 //---------------------------------------------------------------------
236 fInnerSec=new AliTPCSector[fkNIS];
237 fOuterSec=new AliTPCSector[fkNOS];
240 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
241 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
248 Int_t nrowlow = par->GetNRowLow();
249 Int_t nrowup = par->GetNRowUp();
252 for (Int_t i=0;i<nrowlow;i++){
253 fXRow[i] = par->GetPadRowRadiiLow(i);
254 fPadLength[i]= par->GetPadPitchLength(0,i);
255 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
259 for (Int_t i=0;i<nrowup;i++){
260 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
261 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
262 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
275 //_____________________________________________________________________________
276 AliTPCtrackerMI::~AliTPCtrackerMI() {
277 //------------------------------------------------------------------
278 // TPC tracker destructor
279 //------------------------------------------------------------------
288 void AliTPCtrackerMI::SetIO()
292 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
293 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
294 AliTPCtrack *iotrack= new AliTPCtrack;
295 // iotrack->fHelixIn = new TClonesArray("AliHelix");
296 //iotrack->fHelixOut = new TClonesArray("AliHelix");
297 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
301 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
317 AliTPCtrack *iotrack= new AliTPCtrack;
318 // iotrack->fHelixIn = new TClonesArray("AliHelix");
319 //iotrack->fHelixOut = new TClonesArray("AliHelix");
320 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
323 if (output && (fDebug&2)){
324 //write the full seed information if specified in debug mode
326 fSeedTree = new TTree("Seeds","Seeds");
327 AliTPCseed * vseed = new AliTPCseed;
329 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
330 arrtr->ExpandCreateFast(160);
331 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
333 vseed->fPoints = arrtr;
334 vseed->fEPoints = arre;
335 // vseed->fClusterPoints = arrcl;
336 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
339 fTreeDebug = new TTree("trackDebug","trackDebug");
340 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
341 fTreeDebug->Branch("debug",&arrd,32000,99);
349 void AliTPCtrackerMI::WriteTracks()
352 // write tracks to the given output tree -
353 // output specified with SetIO routine
356 // write tracks to the event
357 // store index of the track
358 Int_t nseed=fSeeds->GetEntriesFast();
359 for (Int_t i=0; i<nseed; i++) {
360 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
363 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
364 //iotrack.SetTPCindex(i);
365 fEvent->AddTrack(&iotrack);
371 AliTPCtrack *iotrack= 0;
372 Int_t nseed=fSeeds->GetEntriesFast();
373 for (Int_t i=0; i<nseed; i++) {
374 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
378 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
379 TBranch * br = fOutput->GetBranch("tracks");
380 br->SetAddress(&iotrack);
382 for (Int_t i=0; i<nseed; i++) {
383 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
387 // br->SetAddress(&iotrack);
395 //write the full seed information if specified in debug mode
397 AliTPCseed * vseed = new AliTPCseed;
399 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
400 arrtr->ExpandCreateFast(160);
401 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
402 //arrcl->ExpandCreateFast(160);
403 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
405 vseed->fPoints = arrtr;
406 vseed->fEPoints = arre;
407 // vseed->fClusterPoints = arrcl;
408 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
409 TBranch * brseed = fSeedTree->GetBranch("seeds");
411 Int_t nseed=fSeeds->GetEntriesFast();
413 for (Int_t i=0; i<nseed; i++) {
414 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
417 // pt->fClusterPoints = arrcl;
421 brseed->SetAddress(&vseed);
425 // pt->fClusterPoints = 0;
428 if (fTreeDebug) fTreeDebug->Write();
436 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
439 //seed->SetErrorY2(0.1);
441 //calculate look-up table at the beginning
442 static Bool_t ginit = kFALSE;
443 static Float_t gnoise1,gnoise2,gnoise3;
444 static Float_t ggg1[10000];
445 static Float_t ggg2[10000];
446 static Float_t ggg3[10000];
447 static Float_t glandau1[10000];
448 static Float_t glandau2[10000];
449 static Float_t glandau3[10000];
451 static Float_t gcor01[500];
452 static Float_t gcor02[500];
453 static Float_t gcorp[500];
458 for (Int_t i=1;i<500;i++){
459 Float_t rsigma = float(i)/100.;
460 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
461 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
462 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
466 for (Int_t i=3;i<10000;i++){
470 Float_t amp = float(i);
471 Float_t padlength =0.75;
472 gnoise1 = 0.0004/padlength;
473 Float_t nel = 0.268*amp;
474 Float_t nprim = 0.155*amp;
475 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
476 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
477 if (glandau1[i]>1) glandau1[i]=1;
478 glandau1[i]*=padlength*padlength/12.;
482 gnoise2 = 0.0004/padlength;
485 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
486 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
487 if (glandau2[i]>1) glandau2[i]=1;
488 glandau2[i]*=padlength*padlength/12.;
493 gnoise3 = 0.0004/padlength;
496 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
497 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
498 if (glandau3[i]>1) glandau3[i]=1;
499 glandau3[i]*=padlength*padlength/12.;
507 Int_t amp = int(TMath::Abs(cl->GetQ()));
509 seed->SetErrorY2(1.);
513 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
514 Int_t ctype = cl->GetType();
515 Float_t padlength= GetPadPitchLength(seed->fRow);
516 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
517 angle2 = angle2/(1-angle2);
520 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
523 if (fSectors==fInnerSec){
525 res = ggg1[amp]*z+glandau1[amp]*angle2;
526 if (ctype==0) res *= gcor01[rsigmay];
529 res*= gcorp[rsigmay];
535 res = ggg2[amp]*z+glandau2[amp]*angle2;
536 if (ctype==0) res *= gcor02[rsigmay];
539 res*= gcorp[rsigmay];
544 res = ggg3[amp]*z+glandau3[amp]*angle2;
545 if (ctype==0) res *= gcor02[rsigmay];
548 res*= gcorp[rsigmay];
555 res*=2.4; // overestimate error 2 times
562 seed->SetErrorY2(res);
570 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
573 //seed->SetErrorY2(0.1);
575 //calculate look-up table at the beginning
576 static Bool_t ginit = kFALSE;
577 static Float_t gnoise1,gnoise2,gnoise3;
578 static Float_t ggg1[10000];
579 static Float_t ggg2[10000];
580 static Float_t ggg3[10000];
581 static Float_t glandau1[10000];
582 static Float_t glandau2[10000];
583 static Float_t glandau3[10000];
585 static Float_t gcor01[1000];
586 static Float_t gcor02[1000];
587 static Float_t gcorp[1000];
592 for (Int_t i=1;i<1000;i++){
593 Float_t rsigma = float(i)/100.;
594 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
595 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
596 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
600 for (Int_t i=3;i<10000;i++){
604 Float_t amp = float(i);
605 Float_t padlength =0.75;
606 gnoise1 = 0.0004/padlength;
607 Float_t nel = 0.268*amp;
608 Float_t nprim = 0.155*amp;
609 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
610 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
611 if (glandau1[i]>1) glandau1[i]=1;
612 glandau1[i]*=padlength*padlength/12.;
616 gnoise2 = 0.0004/padlength;
619 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
620 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
621 if (glandau2[i]>1) glandau2[i]=1;
622 glandau2[i]*=padlength*padlength/12.;
627 gnoise3 = 0.0004/padlength;
630 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
631 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
632 if (glandau3[i]>1) glandau3[i]=1;
633 glandau3[i]*=padlength*padlength/12.;
641 Int_t amp = int(TMath::Abs(cl->GetQ()));
643 seed->SetErrorY2(1.);
647 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
648 Int_t ctype = cl->GetType();
649 Float_t padlength= GetPadPitchLength(seed->fRow);
651 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
652 // if (angle2<0.6) angle2 = 0.6;
653 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
656 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
659 if (fSectors==fInnerSec){
661 res = ggg1[amp]*z+glandau1[amp]*angle2;
662 if (ctype==0) res *= gcor01[rsigmaz];
665 res*= gcorp[rsigmaz];
671 res = ggg2[amp]*z+glandau2[amp]*angle2;
672 if (ctype==0) res *= gcor02[rsigmaz];
675 res*= gcorp[rsigmaz];
680 res = ggg3[amp]*z+glandau3[amp]*angle2;
681 if (ctype==0) res *= gcor02[rsigmaz];
684 res*= gcorp[rsigmaz];
693 if ((ctype<0) &&<70){
701 seed->SetErrorZ2(res);
708 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
711 //seed->SetErrorZ2(0.1);
715 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
717 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
718 Int_t ctype = cl->GetType();
719 Float_t amp = TMath::Abs(cl->GetQ());
724 Float_t landau=2 ; //landau fluctuation part
725 Float_t gg=2; // gg fluctuation part
726 Float_t padlength= GetPadPitchLength(seed->GetX());
728 if (fSectors==fInnerSec){
729 snoise2 = 0.0004/padlength;
732 gg = (2+0.001*nel/(padlength*padlength))/nel;
733 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
734 if (landau>1) landau=1;
737 snoise2 = 0.0004/padlength;
740 gg = (2+0.0008*nel/(padlength*padlength))/nel;
741 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
742 if (landau>1) landau=1;
744 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
747 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
748 angle2 = TMath::Sqrt((1-angle2));
749 if (angle2<0.6) angle2 = 0.6;
752 Float_t angle = seed->GetTgl()/angle2;
753 Float_t angular = landau*angle*angle*padlength*padlength/12.;
754 Float_t res = sdiff + angular;
757 if ((ctype==0) && (fSectors ==fOuterSec))
758 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
760 if ((ctype==0) && (fSectors ==fInnerSec))
761 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
765 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
771 if ((ctype<0) &&<70){
779 seed->SetErrorZ2(res);
786 void AliTPCseed::Reset(Bool_t all)
790 SetNumberOfClusters(0);
796 for (Int_t i=0;i<8;i++){
797 delete [] fTrackPoints[i];
805 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
806 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
812 void AliTPCseed::Modify(Double_t factor)
815 //------------------------------------------------------------------
816 //This function makes a track forget its history :)
817 //------------------------------------------------------------------
823 fC10*=factor; fC11*=factor;
824 fC20*=factor; fC21*=factor; fC22*=factor;
825 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
826 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
827 SetNumberOfClusters(0);
831 fCurrentSigmaY2 = 0.000005;
832 fCurrentSigmaZ2 = 0.000005;
841 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
843 //-----------------------------------------------------------------
844 // This function find proloncation of a track to a reference plane x=xk.
845 // doesn't change internal state of the track
846 //-----------------------------------------------------------------
848 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
850 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
854 // Double_t y1=fP0, z1=fP1;
855 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
856 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
860 //y += dx*(c1+c2)/(r1+r2);
861 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
863 Double_t dy = dx*(c1+c2)/(r1+r2);
866 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
868 if (TMath::Abs(delta)>0.0001){
869 dz = fP3*TMath::ASin(delta)/fP4;
871 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
874 dz = fP3*TPCFastMath::FastAsin(delta)/fP4;
884 //_____________________________________________________________________________
885 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
887 //-----------------------------------------------------------------
888 // This function calculates a predicted chi2 increment.
889 //-----------------------------------------------------------------
890 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
891 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
892 r00+=fC00; r01+=fC10; r11+=fC11;
894 Double_t det=r00*r11 - r01*r01;
895 if (TMath::Abs(det) < 1.e-10) {
896 Int_t n=GetNumberOfClusters();
897 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
900 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
902 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
904 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
908 //_________________________________________________________________________________________
911 Int_t AliTPCseed::Compare(const TObject *o) const {
912 //-----------------------------------------------------------------
913 // This function compares tracks according to the sector - for given sector according z
914 //-----------------------------------------------------------------
915 AliTPCseed *t=(AliTPCseed*)o;
918 if (t->fRelativeSector>fRelativeSector) return -1;
919 if (t->fRelativeSector<fRelativeSector) return 1;
920 Double_t z2 = t->GetZ();
921 Double_t z1 = GetZ();
923 if (z2<z1) return -1;
928 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
929 if (t->fBConstrain) f2=1.2;
932 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
934 if (fBConstrain) f1=1.2;
936 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
941 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
943 //rotate to track "local coordinata
944 Float_t x = seed->GetX();
945 Float_t y = seed->GetY();
946 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
949 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
950 if (!seed->Rotate(fSectors->GetAlpha()))
952 } else if (y <-ymax) {
953 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
954 if (!seed->Rotate(-fSectors->GetAlpha()))
963 //_____________________________________________________________________________
964 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t index) {
965 //-----------------------------------------------------------------
966 // This function associates a cluster with this track.
967 //-----------------------------------------------------------------
968 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
970 r00+=fC00; r01+=fC10; r11+=fC11;
971 Double_t det=r00*r11 - r01*r01;
972 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
974 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
975 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
976 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
977 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
978 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
980 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
981 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
982 if (TMath::Abs(cur*fX-eta) >= 0.9) {
986 fP0 += k00*dy + k01*dz;
987 fP1 += k10*dy + k11*dz;
989 fP3 += k30*dy + k31*dz;
992 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
993 Double_t c12=fC21, c13=fC31, c14=fC41;
995 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
996 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
997 fC40-=k00*c04+k01*c14;
999 fC11-=k10*c01+k11*fC11;
1000 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1001 fC41-=k10*c04+k11*c14;
1003 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1004 fC42-=k20*c04+k21*c14;
1006 fC33-=k30*c03+k31*c13;
1007 fC43-=k40*c03+k41*c13;
1009 fC44-=k40*c04+k41*c14;
1011 Int_t n=GetNumberOfClusters();
1013 SetNumberOfClusters(n+1);
1014 SetChi2(GetChi2()+chisq);
1021 //_____________________________________________________________________________
1022 Double_t AliTPCtrackerMI::f1old(Double_t x1,Double_t y1,
1023 Double_t x2,Double_t y2,
1024 Double_t x3,Double_t y3)
1026 //-----------------------------------------------------------------
1027 // Initial approximation of the track curvature
1028 //-----------------------------------------------------------------
1029 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1030 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1031 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1032 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1033 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1035 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1036 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1037 return -xr*yr/sqrt(xr*xr+yr*yr);
1042 //_____________________________________________________________________________
1043 Double_t AliTPCtrackerMI::f1(Double_t x1,Double_t y1,
1044 Double_t x2,Double_t y2,
1045 Double_t x3,Double_t y3)
1047 //-----------------------------------------------------------------
1048 // Initial approximation of the track curvature
1049 //-----------------------------------------------------------------
1055 Double_t det = x3*y2-x2*y3;
1060 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1061 Double_t x0 = x3*0.5-y3*u;
1062 Double_t y0 = y3*0.5+x3*u;
1063 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1069 Double_t AliTPCtrackerMI::f2(Double_t x1,Double_t y1,
1070 Double_t x2,Double_t y2,
1071 Double_t x3,Double_t y3)
1073 //-----------------------------------------------------------------
1074 // Initial approximation of the track curvature
1075 //-----------------------------------------------------------------
1081 Double_t det = x3*y2-x2*y3;
1086 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1087 Double_t x0 = x3*0.5-y3*u;
1088 Double_t y0 = y3*0.5+x3*u;
1089 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1098 //_____________________________________________________________________________
1099 Double_t AliTPCtrackerMI::f2old(Double_t x1,Double_t y1,
1100 Double_t x2,Double_t y2,
1101 Double_t x3,Double_t y3)
1103 //-----------------------------------------------------------------
1104 // Initial approximation of the track curvature times center of curvature
1105 //-----------------------------------------------------------------
1106 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1107 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1108 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1109 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1110 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1112 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1114 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1117 //_____________________________________________________________________________
1118 Double_t AliTPCtrackerMI::f3(Double_t x1,Double_t y1,
1119 Double_t x2,Double_t y2,
1120 Double_t z1,Double_t z2)
1122 //-----------------------------------------------------------------
1123 // Initial approximation of the tangent of the track dip angle
1124 //-----------------------------------------------------------------
1125 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1129 Double_t AliTPCtrackerMI::f3n(Double_t x1,Double_t y1,
1130 Double_t x2,Double_t y2,
1131 Double_t z1,Double_t z2, Double_t c)
1133 //-----------------------------------------------------------------
1134 // Initial approximation of the tangent of the track dip angle
1135 //-----------------------------------------------------------------
1139 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1141 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1142 if (TMath::Abs(d*c*0.5)>1) return 0;
1143 // Double_t angle2 = TMath::ASin(d*c*0.5);
1144 // Double_t angle2 = TPCFastMath::FastAsin(d*c*0.5);
1145 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): TPCFastMath::FastAsin(d*c*0.5);
1147 angle2 = (z1-z2)*c/(angle2*2.);
1151 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1152 {//-----------------------------------------------------------------
1153 // This function find proloncation of a track to a reference plane x=x2.
1154 //-----------------------------------------------------------------
1158 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1162 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1163 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1167 Double_t dy = dx*(c1+c2)/(r1+r2);
1170 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1172 if (TMath::Abs(delta)>0.01){
1173 dz = x[3]*TMath::ASin(delta)/x[4];
1175 dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1178 //dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1188 Int_t AliTPCtrackerMI::LoadClusters()
1191 // load clusters to the memory
1192 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1193 clrow->SetClass("AliTPCclusterMI");
1195 clrow->GetArray()->ExpandCreateFast(10000);
1197 // TTree * tree = fClustersArray.GetTree();
1199 TTree * tree = fInput;
1200 TBranch * br = tree->GetBranch("Segment");
1201 br->SetAddress(&clrow);
1203 Int_t j=Int_t(tree->GetEntries());
1204 for (Int_t i=0; i<j; i++) {
1208 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1210 AliTPCRow * tpcrow=0;
1213 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1217 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1218 left = (sec-fkNIS*2)/fkNOS;
1221 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1222 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1223 for (Int_t i=0;i<tpcrow->fN1;i++)
1224 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1227 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1228 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1229 for (Int_t i=0;i<tpcrow->fN2;i++)
1230 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1241 void AliTPCtrackerMI::UnloadClusters()
1244 // unload clusters from the memory
1246 Int_t nrows = fOuterSec->GetNRows();
1247 for (Int_t sec = 0;sec<fkNOS;sec++)
1248 for (Int_t row = 0;row<nrows;row++){
1249 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1251 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1252 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1256 nrows = fInnerSec->GetNRows();
1257 for (Int_t sec = 0;sec<fkNIS;sec++)
1258 for (Int_t row = 0;row<nrows;row++){
1259 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1261 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1262 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1270 //_____________________________________________________________________________
1271 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1272 //-----------------------------------------------------------------
1273 // This function fills outer TPC sectors with clusters.
1274 //-----------------------------------------------------------------
1275 Int_t nrows = fOuterSec->GetNRows();
1277 for (Int_t sec = 0;sec<fkNOS;sec++)
1278 for (Int_t row = 0;row<nrows;row++){
1279 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1280 Int_t sec2 = sec+2*fkNIS;
1282 Int_t ncl = tpcrow->fN1;
1284 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1285 index=(((sec2<<8)+row)<<16)+ncl;
1286 tpcrow->InsertCluster(c,index);
1291 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1292 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1293 tpcrow->InsertCluster(c,index);
1296 // write indexes for fast acces
1298 for (Int_t i=0;i<510;i++)
1299 tpcrow->fFastCluster[i]=-1;
1300 for (Int_t i=0;i<tpcrow->GetN();i++){
1301 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1302 tpcrow->fFastCluster[zi]=i; // write index
1305 for (Int_t i=0;i<510;i++){
1306 if (tpcrow->fFastCluster[i]<0)
1307 tpcrow->fFastCluster[i] = last;
1309 last = tpcrow->fFastCluster[i];
1318 //_____________________________________________________________________________
1319 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1320 //-----------------------------------------------------------------
1321 // This function fills inner TPC sectors with clusters.
1322 //-----------------------------------------------------------------
1323 Int_t nrows = fInnerSec->GetNRows();
1325 for (Int_t sec = 0;sec<fkNIS;sec++)
1326 for (Int_t row = 0;row<nrows;row++){
1327 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1330 Int_t ncl = tpcrow->fN1;
1332 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1333 index=(((sec<<8)+row)<<16)+ncl;
1334 tpcrow->InsertCluster(c,index);
1339 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1340 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1341 tpcrow->InsertCluster(c,index);
1344 // write indexes for fast acces
1346 for (Int_t i=0;i<510;i++)
1347 tpcrow->fFastCluster[i]=-1;
1348 for (Int_t i=0;i<tpcrow->GetN();i++){
1349 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1350 tpcrow->fFastCluster[zi]=i; // write index
1353 for (Int_t i=0;i<510;i++){
1354 if (tpcrow->fFastCluster[i]<0)
1355 tpcrow->fFastCluster[i] = last;
1357 last = tpcrow->fFastCluster[i];
1369 //_________________________________________________________________________
1370 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1371 //--------------------------------------------------------------------
1372 // Return pointer to a given cluster
1373 //--------------------------------------------------------------------
1374 Int_t sec=(index&0xff000000)>>24;
1375 Int_t row=(index&0x00ff0000)>>16;
1376 Int_t ncl=(index&0x0000ffff)>>00;
1378 const AliTPCRow * tpcrow=0;
1379 AliTPCclusterMI * clrow =0;
1381 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1383 clrow = tpcrow->fClusters1;
1385 clrow = tpcrow->fClusters2;
1388 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1389 if (sec-2*fkNIS<fkNOS)
1390 clrow = tpcrow->fClusters1;
1392 clrow = tpcrow->fClusters2;
1394 if (tpcrow==0) return 0;
1395 if (tpcrow->GetN()<=ncl) return 0;
1396 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1397 return &(clrow[ncl]);
1403 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1404 //-----------------------------------------------------------------
1405 // This function tries to find a track prolongation to next pad row
1406 //-----------------------------------------------------------------
1408 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1410 // if (t.GetRadius()>x+10 ) return 0;
1411 // t.PropagateTo(x+0.02);
1412 //t.PropagateTo(x+0.01);
1413 if (!t.PropagateTo(x)) {
1418 Double_t y=t.GetY(), z=t.GetZ();
1419 if (TMath::Abs(y)>ymax){
1421 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1422 if (!t.Rotate(fSectors->GetAlpha()))
1424 } else if (y <-ymax) {
1425 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1426 if (!t.Rotate(-fSectors->GetAlpha()))
1429 if (!t.PropagateTo(x)) {
1435 // update current shape info every 3 pad-row
1436 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1437 //t.fCurrentSigmaY = GetSigmaY(&t);
1438 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1442 AliTPCclusterMI *cl=0;
1447 if (t.GetClusterIndex2(nr)>0){
1449 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1450 index = t.GetClusterIndex2(nr);
1451 cl = t.fClusterPointer[nr];
1452 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1453 t.fCurrentClusterIndex1 = index;
1456 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1457 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1459 Double_t roadz = 1.;
1461 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1463 t.SetClusterIndex2(nr,-1);
1468 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1474 t.fCurrentCluster = cl;
1476 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1478 //if founded cluster is acceptible
1479 UpdateTrack(&t,accept);
1485 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1486 cl = krow.FindNearest2(y,z,roady,roadz,index);
1487 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1492 t.fCurrentCluster = cl;
1494 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1496 if (t.fCurrentCluster->IsUsed(10)){
1501 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1507 if (accept<3) UpdateTrack(&t,accept);
1510 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1516 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1517 //-----------------------------------------------------------------
1518 // This function tries to find a track prolongation to next pad row
1519 //-----------------------------------------------------------------
1521 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1523 if (!t.GetProlongation(x,y,z)) {
1529 if (TMath::Abs(y)>ymax){
1533 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1534 if (!t.Rotate(fSectors->GetAlpha()))
1536 } else if (y <-ymax) {
1537 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1538 if (!t.Rotate(-fSectors->GetAlpha()))
1541 if (!t.PropagateTo(x)) {
1544 t.GetProlongation(x,y,z);
1547 // update current shape info every 3 pad-row
1548 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1549 // t.fCurrentSigmaY = GetSigmaY(&t);
1550 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1554 AliTPCclusterMI *cl=0;
1559 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1560 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1562 Double_t roadz = 1.;
1565 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1567 t.SetClusterIndex2(row,-1);
1572 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1576 if ((cl==0)&&(krow)) {
1577 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1578 cl = krow.FindNearest2(y,z,roady,roadz,index);
1580 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1584 t.fCurrentCluster = cl;
1585 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1587 t.SetClusterIndex2(row,index);
1588 t.fClusterPointer[row] = cl;
1596 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1597 //-----------------------------------------------------------------
1598 // This function tries to find a track prolongation to next pad row
1599 //-----------------------------------------------------------------
1600 t.fCurrentCluster = 0;
1601 t.fCurrentClusterIndex1 = 0;
1603 Double_t xt=t.GetX();
1604 Int_t row = GetRowNumber(xt)-1;
1605 Double_t ymax= GetMaxY(nr);
1607 if (row < nr) return 1; // don't prolongate if not information until now -
1608 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1610 return 0; // not prolongate strongly inclined tracks
1612 if (TMath::Abs(t.GetSnp())>0.95) {
1614 return 0; // not prolongate strongly inclined tracks
1617 Double_t x= GetXrow(nr);
1619 //t.PropagateTo(x+0.02);
1620 //t.PropagateTo(x+0.01);
1621 if (!t.PropagateTo(x)){
1628 if (TMath::Abs(y)>ymax){
1630 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1631 if (!t.Rotate(fSectors->GetAlpha()))
1633 } else if (y <-ymax) {
1634 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1635 if (!t.Rotate(-fSectors->GetAlpha()))
1638 if (!t.PropagateTo(x)){
1645 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1647 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1649 t.SetClusterIndex2(nr,-1);
1654 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1660 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1661 // t.fCurrentSigmaY = GetSigmaY(&t);
1662 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1666 AliTPCclusterMI *cl=0;
1669 Double_t roady = 1.;
1670 Double_t roadz = 1.;
1673 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1674 cl = krow.FindNearest2(y,z,roady,roadz,index);
1676 t.fCurrentCluster = cl;
1677 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1682 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1683 //-----------------------------------------------------------------
1684 // This function tries to find a track prolongation to next pad row
1685 //-----------------------------------------------------------------
1687 //update error according neighborhoud
1689 if (t.fCurrentCluster) {
1691 Bool_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1693 if (t.fCurrentCluster->IsUsed(10)){
1699 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1705 if (accept<3) UpdateTrack(&t,accept);
1709 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1710 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1712 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1720 //_____________________________________________________________________________
1721 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1722 //-----------------------------------------------------------------
1723 // This function tries to find a track prolongation.
1724 //-----------------------------------------------------------------
1725 Double_t xt=t.GetX();
1727 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1728 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1729 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1731 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1733 Int_t first = GetRowNumber(xt)-1;
1734 for (Int_t nr= first; nr>=rf; nr-=step) {
1735 if (FollowToNext(t,nr)==0)
1736 if (!t.IsActive()) return 0;
1743 //_____________________________________________________________________________
1744 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1745 //-----------------------------------------------------------------
1746 // This function tries to find a track prolongation.
1747 //-----------------------------------------------------------------
1748 Double_t xt=t.GetX();
1750 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1751 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1752 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1753 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1755 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1757 if (FollowToNextFast(t,nr)==0)
1758 if (!t.IsActive()) return 0;
1768 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1769 //-----------------------------------------------------------------
1770 // This function tries to find a track prolongation.
1771 //-----------------------------------------------------------------
1772 // Double_t xt=t.GetX();
1774 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1775 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1776 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1777 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1780 first = t.fFirstPoint+3;
1782 if (first<0) first=0;
1783 for (Int_t nr=first+1; nr<=rf; nr++) {
1784 //if ( (t.GetSnp()<0.9))
1794 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1802 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1805 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1807 Float_t distance = TMath::Sqrt(dz2+dy2);
1808 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1811 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1812 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1817 if (firstpoint>lastpoint) {
1818 firstpoint =lastpoint;
1823 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1824 if (s1->GetClusterIndex2(i)>0) sum1++;
1825 if (s2->GetClusterIndex2(i)>0) sum2++;
1826 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1830 if (sum<5) return 0;
1832 Float_t summin = TMath::Min(sum1+1,sum2+1);
1833 Float_t ratio = (sum+1)/Float_t(summin);
1837 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1841 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1842 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1844 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1846 Float_t dy2 =(s1->GetY() - s2->GetY());
1848 Float_t distance = dz2+dy2;
1849 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1854 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1855 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1857 if (firstpoint>=lastpoint-5) return;;
1859 for (Int_t i=firstpoint;i<lastpoint;i++){
1860 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1861 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1868 for (Int_t i=firstpoint;i<lastpoint;i++){
1869 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1870 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1871 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1872 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1873 if (s1->IsActive()&&s2->IsActive()){
1874 p1->fIsShared = kTRUE;
1875 p2->fIsShared = kTRUE;
1882 for (Int_t i=0;i<4;i++){
1883 if (s1->fOverlapLabels[3*i]==0){
1884 s1->fOverlapLabels[3*i] = s2->GetLabel();
1885 s1->fOverlapLabels[3*i+1] = sumshared;
1886 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1890 for (Int_t i=0;i<4;i++){
1891 if (s2->fOverlapLabels[3*i]==0){
1892 s2->fOverlapLabels[3*i] = s1->GetLabel();
1893 s2->fOverlapLabels[3*i+1] = sumshared;
1894 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1902 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1905 //sort trackss according sectors
1907 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1908 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1910 //if (pt) RotateToLocal(pt);
1914 arr->Sort(); // sorting according z
1915 arr->Expand(arr->GetEntries());
1918 Int_t nseed=arr->GetEntriesFast();
1919 for (Int_t i=0; i<nseed; i++) {
1920 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1922 for (Int_t j=0;j<=12;j++){
1923 pt->fOverlapLabels[j] =0;
1926 for (Int_t i=0; i<nseed; i++) {
1927 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1929 if (pt->fRemoval>10) continue;
1930 for (Int_t j=i+1; j<nseed; j++){
1931 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1933 if (pt2->fRemoval<=10) {
1934 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1941 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1944 //sort trackss according sectors
1947 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1950 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1951 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1956 arr->Sort(); // sorting according z
1957 arr->Expand(arr->GetEntries());
1959 //reset overlap labels
1961 Int_t nseed=arr->GetEntriesFast();
1962 for (Int_t i=0; i<nseed; i++) {
1963 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1966 for (Int_t j=0;j<=12;j++){
1967 pt->fOverlapLabels[j] =0;
1971 //sign shared tracks
1972 for (Int_t i=0; i<nseed; i++) {
1973 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1975 if (pt->fRemoval>10) continue;
1976 Float_t deltac = pt->GetC()*0.1;
1977 for (Int_t j=i+1; j<nseed; j++){
1978 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1980 if (pt2->fRemoval<=10) {
1981 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1982 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
1983 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
1990 // remove highly shared tracks
1991 for (Int_t i=0; i<nseed; i++) {
1992 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1994 if (pt->fRemoval>10) continue;
1997 for (Int_t j=0;j<4;j++){
1998 sumshared = pt->fOverlapLabels[j*3+1];
2000 Float_t factor = factor1;
2001 if (pt->fRemoval>0) factor = factor2;
2002 if (sumshared/pt->GetNumberOfClusters()>factor){
2003 for (Int_t j=0;j<4;j++){
2004 if (pt->fOverlapLabels[3*j]==0) continue;
2005 if (pt->fOverlapLabels[3*j+1]<5) continue;
2006 if (pt->fRemoval==removalindex) continue;
2007 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2009 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2010 // pt->fRemoval = removalindex;
2011 delete arr->RemoveAt(i);
2019 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2028 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode)
2031 //sort tracks in array according mode criteria
2032 Int_t nseed = arr->GetEntriesFast();
2033 for (Int_t i=0; i<nseed; i++) {
2034 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2044 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2047 //Loop over all tracks and remove "overlaps"
2050 Int_t nseed = arr->GetEntriesFast();
2053 for (Int_t i=0; i<nseed; i++) {
2054 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2056 delete arr->RemoveAt(i);
2060 pt->fBSigned = kFALSE;
2064 nseed = arr->GetEntriesFast();
2071 for (Int_t i=0; i<nseed; i++) {
2072 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2076 Int_t found,foundable,shared;
2078 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2080 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2082 Double_t factor = factor2;
2083 if (pt->fBConstrain) factor = factor1;
2085 if ((Float_t(shared)/Float_t(found))>factor){
2086 pt->Desactivate(removalindex);
2091 for (Int_t i=0; i<160; i++) {
2092 Int_t index=pt->GetClusterIndex2(i);
2093 if (index<0 || index&0x8000 ) continue;
2094 AliTPCclusterMI *c= pt->fClusterPointer[i];
2096 // if (!c->IsUsed(10)) c->Use(10);
2097 //if (pt->IsActive())
2106 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2109 void AliTPCtrackerMI::UnsignClusters()
2112 // loop over all clusters and unsign them
2115 for (Int_t sec=0;sec<fkNIS;sec++){
2116 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2117 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2118 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2119 // if (cl[icl].IsUsed(10))
2121 cl = fInnerSec[sec][row].fClusters2;
2122 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2123 //if (cl[icl].IsUsed(10))
2128 for (Int_t sec=0;sec<fkNOS;sec++){
2129 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2130 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2131 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2132 //if (cl[icl].IsUsed(10))
2134 cl = fOuterSec[sec][row].fClusters2;
2135 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2136 //if (cl[icl].IsUsed(10))
2145 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber=3., Float_t fdensity=2.)
2148 //sign clusters to be "used"
2150 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2151 // loop over "primaries"
2165 Int_t nseed = arr->GetEntriesFast();
2166 for (Int_t i=0; i<nseed; i++) {
2167 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2171 if (!(pt->IsActive())) continue;
2172 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2173 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2175 sumdens2+= dens*dens;
2176 sumn += pt->GetNumberOfClusters();
2177 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2178 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2181 sumchi2 +=chi2*chi2;
2186 Float_t mdensity = 0.9;
2187 Float_t meann = 130;
2188 Float_t meanchi = 1;
2189 Float_t sdensity = 0.1;
2190 Float_t smeann = 10;
2191 Float_t smeanchi =0.4;
2195 mdensity = sumdens/sum;
2197 meanchi = sumchi/sum;
2199 sdensity = sumdens2/sum-mdensity*mdensity;
2200 sdensity = TMath::Sqrt(sdensity);
2202 smeann = sumn2/sum-meann*meann;
2203 smeann = TMath::Sqrt(smeann);
2205 smeanchi = sumchi2/sum - meanchi*meanchi;
2206 smeanchi = TMath::Sqrt(smeanchi);
2210 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2212 for (Int_t i=0; i<nseed; i++) {
2213 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2217 if (pt->fBSigned) continue;
2218 if (pt->fBConstrain) continue;
2219 //if (!(pt->IsActive())) continue;
2221 Int_t found,foundable,shared;
2222 pt->GetClusterStatistic(0,160,found, foundable,shared);
2223 if (shared/float(found)>0.3) {
2224 if (shared/float(found)>0.9 ){
2225 //delete arr->RemoveAt(i);
2230 Bool_t isok =kFALSE;
2231 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2233 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2235 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2237 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2241 for (Int_t i=0; i<160; i++) {
2242 Int_t index=pt->GetClusterIndex2(i);
2243 if (index<0) continue;
2244 AliTPCclusterMI *c= pt->fClusterPointer[i];
2246 //if (!(c->IsUsed(10))) c->Use();
2253 Double_t maxchi = meanchi+2.*smeanchi;
2255 for (Int_t i=0; i<nseed; i++) {
2256 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2260 //if (!(pt->IsActive())) continue;
2261 if (pt->fBSigned) continue;
2262 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2263 if (chi>maxchi) continue;
2266 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2268 //sign only tracks with enoug big density at the beginning
2270 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2273 Double_t mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2274 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2276 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2277 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2280 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2281 //Int_t noc=pt->GetNumberOfClusters();
2282 pt->fBSigned = kTRUE;
2283 for (Int_t i=0; i<160; i++) {
2285 Int_t index=pt->GetClusterIndex2(i);
2286 if (index<0) continue;
2287 AliTPCclusterMI *c= pt->fClusterPointer[i];
2289 // if (!(c->IsUsed(10))) c->Use();
2294 // gLastCheck = nseed;
2302 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2)
2304 // stop not active tracks
2305 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2306 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2307 Int_t nseed = arr->GetEntriesFast();
2309 for (Int_t i=0; i<nseed; i++) {
2310 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2314 if (!(pt->IsActive())) continue;
2315 StopNotActive(pt,row0,th0, th1,th2);
2321 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2324 // stop not active tracks
2325 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2326 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2329 Int_t foundable = 0;
2330 Int_t maxindex = seed->fLastPoint; //last foundable row
2331 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2332 seed->Desactivate(10) ;
2336 for (Int_t i=row0; i++;i<maxindex){
2337 Int_t index = seed->GetClusterIndex2(i);
2338 if (index!=-1) foundable++;
2340 if (foundable<=30) sumgood1++;
2341 if (foundable<=50) {
2348 if (foundable>=30.){
2349 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2352 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2357 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2360 // back propagation of ESD tracks
2365 PropagateBack(fSeeds);
2366 Int_t nseed = fSeeds->GetEntriesFast();
2367 for (Int_t i=0;i<nseed;i++){
2368 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2369 AliESDtrack *esd=event->GetTrack(i);
2370 seed->CookdEdx(0.02,0.06);
2371 CookLabel(seed,0.1); //For comparison only
2372 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2380 void AliTPCtrackerMI::DeleteSeeds()
2382 Int_t nseed = fSeeds->GetEntriesFast();
2383 for (Int_t i=0;i<nseed;i++){
2384 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2385 if (seed) delete fSeeds->RemoveAt(i);
2391 void AliTPCtrackerMI::ReadSeeds(AliESD *event)
2394 //read seeds from the event
2396 Int_t nentr=event->GetNumberOfTracks();
2397 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2401 fSeeds = new TObjArray;
2405 for (Int_t i=0; i<nentr; i++) {
2406 AliESDtrack *esd=event->GetTrack(i);
2407 ULong_t status=esd->GetStatus();
2408 const AliTPCtrack t(*esd);
2409 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2410 if (status==AliESDtrack::kTPCin) seed->Modify(0.8);
2413 // rotate to the local coordinate system
2415 fSectors=fInnerSec; fN=fkNIS;
2417 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2418 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2419 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2420 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2421 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2422 alpha-=seed->GetAlpha();
2423 if (!seed->Rotate(alpha)) continue;
2425 seed->PropagateTo(fSectors->GetX(0));
2427 // Int_t index = esd->GetTPCindex();
2428 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2430 fSeeds->AddLast(seed);
2436 //_____________________________________________________________________________
2437 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2438 Float_t deltay, Int_t ddsec) {
2439 //-----------------------------------------------------------------
2440 // This function creates track seeds.
2441 // SEEDING WITH VERTEX CONSTRAIN
2442 //-----------------------------------------------------------------
2443 // cuts[0] - fP4 cut
2444 // cuts[1] - tan(phi) cut
2445 // cuts[2] - zvertex cut
2446 // cuts[3] - fP3 cut
2454 Double_t x[5], c[15];
2455 // Int_t di = i1-i2;
2457 AliTPCseed * seed = new AliTPCseed;
2458 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2459 Double_t cs=cos(alpha), sn=sin(alpha);
2461 // Double_t x1 =fOuterSec->GetX(i1);
2462 //Double_t xx2=fOuterSec->GetX(i2);
2464 Double_t x1 =GetXrow(i1);
2465 Double_t xx2=GetXrow(i2);
2467 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2469 Int_t imiddle = (i2+i1)/2; //middle pad row index
2470 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2471 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2475 const AliTPCRow& kr1=GetRow(ns,i1);
2476 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2477 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2480 // change cut on curvature if it can't reach this layer
2481 // maximal curvature set to reach it
2482 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2483 if (dvertexmax*0.5*cuts[0]>0.85){
2484 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2486 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2489 if (deltay>0) ddsec = 0;
2490 // loop over clusters
2491 for (Int_t is=0; is < kr1; is++) {
2493 if (kr1[is]->IsUsed(10)) continue;
2494 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2495 //if (TMath::Abs(y1)>ymax) continue;
2497 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2499 // find possible directions
2500 Float_t anglez = (z1-z3)/(x1-x3);
2501 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2504 //find rotation angles relative to line given by vertex and point 1
2505 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2506 Double_t dvertex = TMath::Sqrt(dvertex2);
2507 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2508 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2511 // loop over 2 sectors
2517 Double_t dddz1=0; // direction of delta inclination in z axis
2524 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2525 Int_t sec2 = sec + dsec;
2527 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2528 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2529 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2530 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2531 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2532 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2534 // rotation angles to p1-p3
2535 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2536 Double_t x2, y2, z2;
2538 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2541 Double_t dxx0 = (xx2-x3)*cs13r;
2542 Double_t dyy0 = (xx2-x3)*sn13r;
2543 for (Int_t js=index1; js < index2; js++) {
2544 const AliTPCclusterMI *kcl = kr2[js];
2545 if (kcl->IsUsed(10)) continue;
2547 //calcutate parameters
2549 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2551 if (TMath::Abs(yy0)<0.000001) continue;
2552 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2553 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2554 Double_t r02 = (0.25+y0*y0)*dvertex2;
2555 //curvature (radius) cut
2556 if (r02<r2min) continue;
2560 Double_t c0 = 1/TMath::Sqrt(r02);
2564 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2565 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2566 Double_t dfi0 = 2.*TPCFastMath::FastAsin(dvertex*c0*0.5);
2567 Double_t dfi1 = 2.*TPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2570 Double_t z0 = kcl->GetZ();
2571 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2572 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2575 Double_t dip = (z1-z0)*c0/dfi1;
2576 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2587 x2= xx2*cs-y2*sn*dsec;
2588 y2=+xx2*sn*dsec+y2*cs;
2598 // do we have cluster at the middle ?
2600 GetProlongation(x1,xm,x,ym,zm);
2602 AliTPCclusterMI * cm=0;
2603 if (TMath::Abs(ym)-ymaxm<0){
2604 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2605 if ((!cm) || (cm->IsUsed(10))) {
2610 // rotate y1 to system 0
2611 // get state vector in rotated system
2612 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2613 Double_t xr2 = x0*cs+yr1*sn*dsec;
2614 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2616 GetProlongation(xx2,xm,xr,ym,zm);
2617 if (TMath::Abs(ym)-ymaxm<0){
2618 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2619 if ((!cm) || (cm->IsUsed(10))) {
2629 dym = ym - cm->GetY();
2630 dzm = zm - cm->GetZ();
2637 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2638 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2639 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2640 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2641 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2643 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2644 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2645 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2646 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2647 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2648 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2650 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2651 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2652 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2653 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2657 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2658 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2659 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2660 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2661 c[13]=f30*sy1*f40+f32*sy2*f42;
2662 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2664 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2666 UInt_t index=kr1.GetIndex(is);
2667 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2669 track->fIsSeeding = kTRUE;
2676 FollowProlongation(*track, (i1+i2)/2,1);
2677 Int_t foundable,found,shared;
2678 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2679 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2681 seed->~AliTPCseed();
2687 FollowProlongation(*track, i2,1);
2691 track->fBConstrain =1;
2692 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2693 track->fLastPoint = i1; // first cluster in track position
2694 track->fFirstPoint = track->fLastPoint;
2696 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2697 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2698 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2700 seed->~AliTPCseed();
2704 // Z VERTEX CONDITION
2706 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2707 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2708 if (TMath::Abs(zv-z3)>cuts[2]) {
2709 FollowProlongation(*track, TMath::Max(i2-20,0));
2710 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2711 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2712 if (TMath::Abs(zv-z3)>cuts[2]){
2713 FollowProlongation(*track, TMath::Max(i2-40,0));
2714 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2715 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2716 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2717 // make seed without constrain
2718 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2719 FollowProlongation(*track2, i2,1);
2720 track2->fBConstrain = kFALSE;
2721 track2->fSeedType = 1;
2722 arr->AddLast(track2);
2724 seed->~AliTPCseed();
2729 seed->~AliTPCseed();
2736 track->fSeedType =0;
2737 arr->AddLast(track);
2738 seed = new AliTPCseed;
2740 // don't consider other combinations
2741 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2747 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2753 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2758 //-----------------------------------------------------------------
2759 // This function creates track seeds.
2760 //-----------------------------------------------------------------
2761 // cuts[0] - fP4 cut
2762 // cuts[1] - tan(phi) cut
2763 // cuts[2] - zvertex cut
2764 // cuts[3] - fP3 cut
2774 Double_t x[5], c[15];
2776 // make temporary seed
2777 AliTPCseed * seed = new AliTPCseed;
2778 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2779 // Double_t cs=cos(alpha), sn=sin(alpha);
2784 Double_t x1 = GetXrow(i1-1);
2785 const AliTPCRow& kr1=GetRow(sec,i1-1);
2786 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2788 Double_t x1p = GetXrow(i1);
2789 const AliTPCRow& kr1p=GetRow(sec,i1);
2791 Double_t x1m = GetXrow(i1-2);
2792 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2795 //last 3 padrow for seeding
2796 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2797 Double_t x3 = GetXrow(i1-7);
2798 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2800 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2801 Double_t x3p = GetXrow(i1-6);
2803 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2804 Double_t x3m = GetXrow(i1-8);
2809 Int_t im = i1-4; //middle pad row index
2810 Double_t xm = GetXrow(im); // radius of middle pad-row
2811 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2812 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2815 Double_t deltax = x1-x3;
2816 Double_t dymax = deltax*cuts[1];
2817 Double_t dzmax = deltax*cuts[3];
2819 // loop over clusters
2820 for (Int_t is=0; is < kr1; is++) {
2822 if (kr1[is]->IsUsed(10)) continue;
2823 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2825 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2827 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2828 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2834 for (Int_t js=index1; js < index2; js++) {
2835 const AliTPCclusterMI *kcl = kr3[js];
2836 if (kcl->IsUsed(10)) continue;
2838 // apply angular cuts
2839 if (TMath::Abs(y1-y3)>dymax) continue;
2842 if (TMath::Abs(z1-z3)>dzmax) continue;
2844 Double_t angley = (y1-y3)/(x1-x3);
2845 Double_t anglez = (z1-z3)/(x1-x3);
2847 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2848 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2850 Double_t yyym = angley*(xm-x1)+y1;
2851 Double_t zzzm = anglez*(xm-x1)+z1;
2853 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2855 if (kcm->IsUsed(10)) continue;
2857 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2858 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2865 // look around first
2866 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2872 if (kc1m->IsUsed(10)) used++;
2874 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2880 if (kc1p->IsUsed(10)) used++;
2882 if (used>1) continue;
2883 if (found<1) continue;
2887 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2893 if (kc3m->IsUsed(10)) used++;
2897 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2903 if (kc3p->IsUsed(10)) used++;
2907 if (used>1) continue;
2908 if (found<3) continue;
2918 x[4]=f1(x1,y1,x2,y2,x3,y3);
2919 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
2922 x[2]=f2(x1,y1,x2,y2,x3,y3);
2925 x[3]=f3n(x1,y1,x2,y2,z1,z2,x[4]);
2926 //if (TMath::Abs(x[3]) > cuts[3]) continue;
2930 Double_t sy1=0.1, sz1=0.1;
2931 Double_t sy2=0.1, sz2=0.1;
2932 Double_t sy3=0.1, sy=0.1, sz=0.1;
2934 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2935 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2936 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2937 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2938 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2939 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2941 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2942 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2943 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2944 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2948 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2949 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2950 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2951 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2952 c[13]=f30*sy1*f40+f32*sy2*f42;
2953 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2955 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2957 UInt_t index=kr1.GetIndex(is);
2958 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
2960 track->fIsSeeding = kTRUE;
2963 FollowProlongation(*track, i1-7,1);
2964 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
2965 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
2967 seed->~AliTPCseed();
2973 FollowProlongation(*track, i2,1);
2974 track->fBConstrain =0;
2975 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2976 track->fFirstPoint = track->fLastPoint;
2978 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2979 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
2980 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
2982 seed->~AliTPCseed();
2987 FollowProlongation(*track, TMath::Max(i2-10,0),1);
2988 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
2989 FollowProlongation(*track2, i2,1);
2990 track2->fBConstrain = kFALSE;
2991 track2->fSeedType = 4;
2992 arr->AddLast(track2);
2994 seed->~AliTPCseed();
2998 //arr->AddLast(track);
2999 //seed = new AliTPCseed;
3005 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3011 //_____________________________________________________________________________
3012 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3013 Float_t deltay, Bool_t bconstrain) {
3014 //-----------------------------------------------------------------
3015 // This function creates track seeds - without vertex constraint
3016 //-----------------------------------------------------------------
3017 // cuts[0] - fP4 cut - not applied
3018 // cuts[1] - tan(phi) cut
3019 // cuts[2] - zvertex cut - not applied
3020 // cuts[3] - fP3 cut
3030 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3031 // Double_t cs=cos(alpha), sn=sin(alpha);
3032 Int_t row0 = (i1+i2)/2;
3033 Int_t drow = (i1-i2)/2;
3034 const AliTPCRow& kr0=fSectors[sec][row0];
3037 AliTPCpolyTrack polytrack;
3038 Int_t nclusters=fSectors[sec][row0];
3039 AliTPCseed * seed = new AliTPCseed;
3044 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3046 Int_t nfoundable =0;
3047 for (Int_t iter =1; iter<2; iter++){ //iterations
3048 const AliTPCRow& krm=fSectors[sec][row0-iter];
3049 const AliTPCRow& krp=fSectors[sec][row0+iter];
3050 const AliTPCclusterMI * cl= kr0[is];
3052 if (cl->IsUsed(10)) {
3058 Double_t x = kr0.GetX();
3059 // Initialization of the polytrack
3064 Double_t y0= cl->GetY();
3065 Double_t z0= cl->GetZ();
3069 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3070 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3072 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3073 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3074 polytrack.AddPoint(x,y0,z0,erry, errz);
3077 if (cl->IsUsed(10)) sumused++;
3080 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3081 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3084 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3085 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3086 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3087 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3088 if (cl1->IsUsed(10)) sumused++;
3089 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3093 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3095 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3096 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3097 if (cl2->IsUsed(10)) sumused++;
3098 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3101 if (sumused>0) continue;
3103 polytrack.UpdateParameters();
3109 nfoundable = polytrack.GetN();
3110 nfound = nfoundable;
3112 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3113 Float_t maxdist = 0.8*(1.+3./(ddrow));
3114 for (Int_t delta = -1;delta<=1;delta+=2){
3115 Int_t row = row0+ddrow*delta;
3116 kr = &(fSectors[sec][row]);
3117 Double_t xn = kr->GetX();
3118 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3119 polytrack.GetFitPoint(xn,yn,zn);
3120 if (TMath::Abs(yn)>ymax) continue;
3122 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3124 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3127 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3128 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3129 if (cln->IsUsed(10)) {
3130 // printf("used\n");
3138 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3143 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3144 polytrack.UpdateParameters();
3147 if ( (sumused>3) || (sumused>0.5*nfound)) {
3148 //printf("sumused %d\n",sumused);
3153 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3154 AliTPCpolyTrack track2;
3156 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3157 if (track2.GetN()<0.5*nfoundable) continue;
3160 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3162 // test seed with and without constrain
3163 for (Int_t constrain=0; constrain<=0;constrain++){
3164 // add polytrack candidate
3166 Double_t x[5], c[15];
3167 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3168 track2.GetBoundaries(x3,x1);
3170 track2.GetFitPoint(x1,y1,z1);
3171 track2.GetFitPoint(x2,y2,z2);
3172 track2.GetFitPoint(x3,y3,z3);
3174 //is track pointing to the vertex ?
3177 polytrack.GetFitPoint(x0,y0,z0);
3190 x[4]=f1(x1,y1,x2,y2,x3,y3);
3192 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3193 x[2]=f2(x1,y1,x2,y2,x3,y3);
3195 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3196 //x[3]=f3(x1,y1,x2,y2,z1,z2);
3197 x[3]=f3n(x1,y1,x3,y3,z1,z3,x[4]);
3198 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3201 Double_t sy =0.1, sz =0.1;
3202 Double_t sy1=0.02, sz1=0.02;
3203 Double_t sy2=0.02, sz2=0.02;
3207 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3210 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3211 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3212 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3213 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3214 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3215 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3217 Double_t f30=(f3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3218 Double_t f31=(f3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3219 Double_t f32=(f3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3220 Double_t f34=(f3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3225 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3226 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3227 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3228 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3229 c[13]=f30*sy1*f40+f32*sy2*f42;
3230 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3232 //Int_t row1 = fSectors->GetRowNumber(x1);
3233 Int_t row1 = GetRowNumber(x1);
3237 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3238 track->fIsSeeding = kTRUE;
3239 Int_t rc=FollowProlongation(*track, i2);
3240 if (constrain) track->fBConstrain =1;
3242 track->fBConstrain =0;
3243 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3244 track->fFirstPoint = track->fLastPoint;
3246 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3247 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3248 track->fNShared>0.4*track->GetNumberOfClusters()) {
3251 seed->~AliTPCseed();
3254 arr->AddLast(track);
3255 seed = new AliTPCseed;
3259 } // if accepted seed
3262 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3268 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3273 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3274 Int_t p1 = int(r1*track->GetNumberOfClusters());
3275 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3277 Double_t x0[3],x1[3],x2[3];
3282 // find track position at given ratio of the length
3283 Int_t sec0, sec1, sec2;
3286 for (Int_t i=0;i<160;i++){
3287 if (track->fClusterPointer[i]){
3289 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3290 if ( (index<p0) || x0[0]<0 ){
3291 if (trpoint->GetX()>1){
3292 clindex = track->GetClusterIndex2(i);
3294 x0[0] = trpoint->GetX();
3295 x0[1] = trpoint->GetY();
3296 x0[2] = trpoint->GetZ();
3297 sec0 = ((clindex&0xff000000)>>24)%18;
3302 if ( (index<p1) &&(trpoint->GetX()>1)){
3303 clindex = track->GetClusterIndex2(i);
3305 x1[0] = trpoint->GetX();
3306 x1[1] = trpoint->GetY();
3307 x1[2] = trpoint->GetZ();
3308 sec1 = ((clindex&0xff000000)>>24)%18;
3311 if ( (index<p2) &&(trpoint->GetX()>1)){
3312 clindex = track->GetClusterIndex2(i);
3314 x2[0] = trpoint->GetX();
3315 x2[1] = trpoint->GetY();
3316 x2[2] = trpoint->GetZ();
3317 sec2 = ((clindex&0xff000000)>>24)%18;
3324 Double_t alpha, cs,sn, xx2,yy2;
3326 alpha = (sec1-sec2)*fSectors->GetAlpha();
3327 cs = TMath::Cos(alpha);
3328 sn = TMath::Sin(alpha);
3329 xx2= x1[0]*cs-x1[1]*sn;
3330 yy2= x1[0]*sn+x1[1]*cs;
3334 alpha = (sec0-sec2)*fSectors->GetAlpha();
3335 cs = TMath::Cos(alpha);
3336 sn = TMath::Sin(alpha);
3337 xx2= x0[0]*cs-x0[1]*sn;
3338 yy2= x0[0]*sn+x0[1]*cs;
3344 Double_t x[5],c[15];
3348 x[4]=f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3349 // if (x[4]>1) return 0;
3350 x[2]=f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3351 x[3]=f3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3352 //if (TMath::Abs(x[3]) > 2.2) return 0;
3353 //if (TMath::Abs(x[2]) > 1.99) return 0;
3355 Double_t sy =0.1, sz =0.1;
3357 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3358 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3359 Double_t sy3=0.01+track->GetSigmaY2();
3361 Double_t f40=(f1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3362 Double_t f42=(f1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3363 Double_t f43=(f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3364 Double_t f20=(f2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3365 Double_t f22=(f2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3366 Double_t f23=(f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3368 Double_t f30=(f3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3369 Double_t f31=(f3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3370 Double_t f32=(f3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3371 Double_t f34=(f3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3376 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3377 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3378 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3379 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3380 c[13]=f30*sy1*f40+f32*sy2*f42;
3381 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3383 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3384 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3385 // Double_t y0,z0,y1,z1, y2,z2;
3386 //seed->GetProlongation(x0[0],y0,z0);
3387 // seed->GetProlongation(x1[0],y1,z1);
3388 //seed->GetProlongation(x2[0],y2,z2);
3390 seed->fLastPoint = pp2;
3391 seed->fFirstPoint = pp2;
3397 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3402 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3404 if (TMath::Abs(seed->GetC())>0.01) return 0;
3407 Float_t x[160], y[160], erry[160], z[160], errz[160];
3409 Float_t xt[160], yt[160], zt[160];
3414 Int_t middle = seed->GetNumberOfClusters()/2;
3417 // find central sector, get local cooordinates
3419 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3420 sec[i]= seed->GetClusterSector(i)%18;
3423 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3424 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3431 if (i>i2) i2 = i; //last point with cluster
3432 if (i2<i1) i1 = i; //first point with cluster
3435 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3437 yt[i] = point->GetY();
3438 zt[i] = point->GetZ();
3440 if (point->GetX()>0){
3441 erry[i] = point->GetErrY();
3442 errz[i] = point->GetErrZ();
3447 secm = sec[i]; //central sector
3448 padm = i; //middle point with cluster
3453 // rotate position to global coordinate system connected to sector at last the point
3455 for (Int_t i=i1;i<=i2;i++){
3457 if (sec[i]<0) continue;
3458 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3459 Double_t cs = TMath::Cos(alpha);
3460 Double_t sn = TMath::Sin(alpha);
3461 Float_t xx2= x[i]*cs+y[i]*sn;
3462 Float_t yy2= -x[i]*sn+y[i]*cs;
3466 xx2= xt[i]*cs+yt[i]*sn;
3467 yy2= -xt[i]*sn+yt[i]*cs;
3472 //get "state" vector
3473 Double_t xh[5],xm = x[padm];
3476 xh[4]=f1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3477 xh[2]=f2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3478 xh[3]=f3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3481 for (Int_t i=i1;i<=i2;i++){
3483 if (sec[i]<0) continue;
3484 GetProlongation(x[i2], x[i],xh,yy,zz);
3485 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3487 //xxh[4]=f1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3488 //xxh[2]=f2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3489 printf("problem\n");
3494 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3495 Float_t yup[160], ydown[160], zup[160], zdown[160];
3497 AliTPCpolyTrack ptrack1,ptrack2;
3500 for (Int_t i=i1;i<=i2;i++){
3501 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3503 if (cl->GetType()<0) continue;
3504 if (cl->GetType()>10) continue;
3507 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3509 if (ptrack1.GetN()>4.){
3510 ptrack1.UpdateParameters();
3512 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3514 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3523 dyup[i]=0.; //not enough points
3528 for (Int_t i=i2;i>=i1;i--){
3529 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3531 if (cl->GetType()<0) continue;
3532 if (cl->GetType()>10) continue;
3534 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3536 if (ptrack2.GetN()>4){
3537 ptrack2.UpdateParameters();
3539 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3541 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3549 dydown[i]=0.; //not enough points
3554 // find maximal difference of the derivation
3555 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3558 for (Int_t i=i1+10;i<i2-10;i++){
3559 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3560 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3562 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3563 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3564 if ( (ddy+ddz)> th){
3565 seed->fKinkPoint[0] = i;
3566 seed->fKinkPoint[1] = ddy;
3567 seed->fKinkPoint[2] = ddz;
3574 //write information to the debug tree
3575 TBranch * br = fTreeDebug->GetBranch("debug");
3576 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3577 arr->ExpandCreateFast(i2-i1);
3578 br->SetAddress(&arr);
3580 AliTPCclusterMI cldummy;
3582 AliTPCTrackPoint2 pdummy;
3583 pdummy.GetTPoint().fIsShared = 10;
3585 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3586 Double_t cs = TMath::Cos(alpha);
3587 Double_t sn = TMath::Sin(alpha);
3589 for (Int_t i=i1;i<i2;i++){
3590 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3592 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3594 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3597 Double_t x = GetXrow(i);
3598 trpoint->GetTPoint() = *point;
3599 trpoint->GetCPoint() = *cl0;
3600 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3601 trpoint->fID = seed->GetUniqueID();
3602 trpoint->fLab = seed->GetLabel();
3604 trpoint->fGX = cs *x + sn*point->GetY();
3605 trpoint->fGY = -sn *x + cs*point->GetY() ;
3606 trpoint->fGZ = point->GetZ();
3608 trpoint->fDY = y[i];
3609 trpoint->fDZ = z[i];
3611 trpoint->fDYU = dyup[i];
3612 trpoint->fDZU = dzup[i];
3614 trpoint->fDYD = dydown[i];
3615 trpoint->fDZD = dzdown[i];
3617 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3618 trpoint->fDDY = dydown[i]-dyup[i];
3619 trpoint->fDDZ = dzdown[i]-dzup[i];
3627 trpoint->GetCPoint()= cldummy;
3644 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3647 // reseed - refit - track
3650 // Int_t last = fSectors->GetNRows()-1;
3652 if (fSectors == fOuterSec){
3653 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3657 first = t->fFirstPoint;
3659 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3660 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3662 FollowProlongation(*t,first);
3672 //_____________________________________________________________________________
3673 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3674 //-----------------------------------------------------------------
3675 // This function reades track seeds.
3676 //-----------------------------------------------------------------
3677 TDirectory *savedir=gDirectory;
3679 TFile *in=(TFile*)inp;
3680 if (!in->IsOpen()) {
3681 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3686 TTree *seedTree=(TTree*)in->Get("Seeds");
3688 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3689 cerr<<"can't get a tree with track seeds !\n";
3692 AliTPCtrack *seed=new AliTPCtrack;
3693 seedTree->SetBranchAddress("tracks",&seed);
3695 if (fSeeds==0) fSeeds=new TObjArray(15000);
3697 Int_t n=(Int_t)seedTree->GetEntries();
3698 for (Int_t i=0; i<n; i++) {
3699 seedTree->GetEvent(i);
3700 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3709 //_____________________________________________________________________________
3710 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3711 //-----------------------------------------------------------------
3712 // This is a track finder.
3713 //-----------------------------------------------------------------
3714 TDirectory *savedir=gDirectory;
3717 if (!fInput) SetIO(); //set default IO using loaders
3719 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
3725 fSeeds = Tracking();
3728 printf("Time for tracking: \t");timer.Print();timer.Start();
3730 //activate again some tracks
3731 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3732 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3734 Int_t nc=t.GetNumberOfClusters();
3736 delete fSeeds->RemoveAt(i);
3739 if (pt->fRemoval==10) {
3740 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3741 pt->Desactivate(10); // make track again active
3743 pt->Desactivate(20);
3744 delete fSeeds->RemoveAt(i);
3748 RemoveDouble(fSeeds,0.2,0.6,11);
3749 //RemoveUsed(fSeeds,0.9,0.9,6);
3750 //RemoveUsed(fSeeds,0.8,0.8,6);
3751 //RemoveUsed(fSeeds,0.7,0.7,6);
3752 RemoveUsed(fSeeds,0.5,0.5,6);
3755 Int_t nseed=fSeeds->GetEntriesFast();
3757 for (Int_t i=0; i<nseed; i++) {
3758 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3760 Int_t nc=t.GetNumberOfClusters();
3762 delete fSeeds->RemoveAt(i);
3765 CookLabel(pt,0.1); //For comparison only
3766 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3767 if ((pt->IsActive() || (pt->fRemoval==10) )){
3768 cerr<<found++<<'\r';
3771 delete fSeeds->RemoveAt(i);
3776 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3778 //RemoveUsed(fSeeds,0.9,0.9,6);
3780 nseed=fSeeds->GetEntriesFast();
3782 for (Int_t i=0; i<nseed; i++) {
3783 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3785 Int_t nc=t.GetNumberOfClusters();
3787 delete fSeeds->RemoveAt(i);
3791 t.CookdEdx(0.02,0.6);
3792 // CheckKinkPoint(&t,0.05);
3793 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3794 if ((pt->IsActive() || (pt->fRemoval==10) )){
3795 cerr<<found++<<'\r';
3798 delete fSeeds->RemoveAt(i);
3802 SortTracks(fSeeds, 1);
3806 PrepareForBackProlongation(fSeeds,0.5);
3807 PropagateBack(fSeeds);
3808 printf("Time for back propagation: \t");timer.Print();timer.Start();
3812 PrepareForProlongation(fSeeds,1.);
3815 fSectors = fOuterSec;
3816 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3817 fSectors = fInnerSec;
3818 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3819 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
3820 // RemoveUsed(fSeeds,0.7,0.7,6);
3821 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
3823 nseed=fSeeds->GetEntriesFast();
3825 for (Int_t i=0; i<nseed; i++) {
3826 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3828 Int_t nc=t.GetNumberOfClusters();
3830 delete fSeeds->RemoveAt(i);
3833 t.CookdEdx(0.02,0.6);
3834 // CookLabel(pt,0.1); //For comparison only
3835 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3836 if ((pt->IsActive() || (pt->fRemoval==10) )){
3837 cerr<<found++<<'\r';
3840 delete fSeeds->RemoveAt(i);
3845 // fNTracks = found;
3846 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
3851 if (!fNewIO) fOutput->Write();
3853 AliRunLoader::GetDetectorLoader("TPC",AliConfig::fgkDefaultEventFolderName)->WriteTracks("OVERWRITE");
3856 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
3858 //if (seedtree) delete seedtree;
3859 // UnloadClusters();
3860 //printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
3865 void AliTPCtrackerMI::Tracking(TObjArray * arr)
3868 // tracking of the seeds
3871 fSectors = fOuterSec;
3872 ParallelTracking(arr,150,63);
3873 fSectors = fOuterSec;
3874 ParallelTracking(arr,63,0);
3877 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
3882 TObjArray * arr = new TObjArray;
3884 fSectors = fOuterSec;
3887 for (Int_t sec=0;sec<fkNOS;sec++){
3888 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
3889 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
3890 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
3893 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
3905 TObjArray * AliTPCtrackerMI::Tracking()
3911 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
3913 TObjArray * seeds = new TObjArray;
3922 Float_t fnumber = 3.0;
3923 Float_t fdensity = 3.0;
3928 for (Int_t delta = 0; delta<18; delta+=6){
3932 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
3933 SumTracks(seeds,arr);
3934 SignClusters(seeds,fnumber,fdensity);
3936 for (Int_t i=2;i<6;i+=2){
3937 // seed high pt tracks
3940 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
3941 SumTracks(seeds,arr);
3942 SignClusters(seeds,fnumber,fdensity);
3947 // RemoveUsed(seeds,0.9,0.9,1);
3948 // UnsignClusters();
3949 // SignClusters(seeds,fnumber,fdensity);
3953 for (Int_t delta = 20; delta<120; delta+=10){
3955 // seed high pt tracks
3959 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
3960 SumTracks(seeds,arr);
3961 SignClusters(seeds,fnumber,fdensity);
3966 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
3967 SumTracks(seeds,arr);
3968 SignClusters(seeds,fnumber,fdensity);
3979 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
3983 // RemoveUsed(seeds,0.75,0.75,1);
3985 //SignClusters(seeds,fnumber,fdensity);
3994 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
3995 SumTracks(seeds,arr);
3996 SignClusters(seeds,fnumber,fdensity);
3998 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
3999 SumTracks(seeds,arr);
4000 SignClusters(seeds,fnumber,fdensity);
4002 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4003 SumTracks(seeds,arr);
4004 SignClusters(seeds,fnumber,fdensity);
4008 for (Int_t delta = 3; delta<30; delta+=5){
4014 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4015 SumTracks(seeds,arr);
4016 SignClusters(seeds,fnumber,fdensity);
4018 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4019 SumTracks(seeds,arr);
4020 SignClusters(seeds,fnumber,fdensity);
4032 for (Int_t delta = 30; delta<70; delta+=10){
4038 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4039 SumTracks(seeds,arr);
4040 SignClusters(seeds,fnumber,fdensity);
4042 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4043 SumTracks(seeds,arr);
4044 SignClusters(seeds,fnumber,fdensity);
4048 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4059 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2)
4062 //sum tracks to common container
4063 //remove suspicious tracks
4064 Int_t nseed = arr2->GetEntriesFast();
4065 for (Int_t i=0;i<nseed;i++){
4066 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4069 // NORMAL ACTIVE TRACK
4070 if (pt->IsActive()){
4071 arr1->AddLast(arr2->RemoveAt(i));
4074 //remove not usable tracks
4075 if (pt->fRemoval!=10){
4076 delete arr2->RemoveAt(i);
4079 // REMOVE VERY SHORT TRACKS
4080 if (pt->GetNumberOfClusters()<20){
4081 delete arr2->RemoveAt(i);
4084 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4085 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4086 arr1->AddLast(arr2->RemoveAt(i));
4088 delete arr2->RemoveAt(i);
4097 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4100 // try to track in parralel
4102 Int_t nseed=arr->GetEntriesFast();
4103 //prepare seeds for tracking
4104 for (Int_t i=0; i<nseed; i++) {
4105 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4107 if (!t.IsActive()) continue;
4108 // follow prolongation to the first layer
4109 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4110 FollowProlongation(t, rfirst+1);
4115 for (Int_t nr=rfirst; nr>=rlast; nr--){
4116 // make indexes with the cluster tracks for given
4118 // find nearest cluster
4119 for (Int_t i=0; i<nseed; i++) {
4120 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4122 if (!pt->IsActive()) continue;
4123 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4124 if (pt->fRelativeSector>17) {
4127 UpdateClusters(t,nr);
4129 // prolonagate to the nearest cluster - if founded
4130 for (Int_t i=0; i<nseed; i++) {
4131 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4133 if (!pt->IsActive()) continue;
4134 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4135 if (pt->fRelativeSector>17) {
4138 FollowToNextCluster(*pt,nr);
4143 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac)
4147 // if we use TPC track itself we have to "update" covariance
4149 Int_t nseed= arr->GetEntriesFast();
4150 for (Int_t i=0;i<nseed;i++){
4151 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4155 //rotate to current local system at first accepted point
4156 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4157 Int_t sec = (index&0xff000000)>>24;
4159 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4160 if (angle1>TMath::Pi())
4161 angle1-=2.*TMath::Pi();
4162 Float_t angle2 = pt->GetAlpha();
4164 if (TMath::Abs(angle1-angle2)>0.001){
4165 pt->Rotate(angle1-angle2);
4166 //angle2 = pt->GetAlpha();
4167 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4168 //if (pt->GetAlpha()<0)
4169 // pt->fRelativeSector+=18;
4170 //sec = pt->fRelativeSector;
4179 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac)
4183 // if we use TPC track itself we have to "update" covariance
4185 Int_t nseed= arr->GetEntriesFast();
4186 for (Int_t i=0;i<nseed;i++){
4187 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4190 pt->fFirstPoint = pt->fLastPoint;
4198 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4201 // make back propagation
4203 Int_t nseed= arr->GetEntriesFast();
4204 for (Int_t i=0;i<nseed;i++){
4205 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4207 AliTPCseed *pt2 = new AliTPCseed(*pt);
4208 fSectors = fInnerSec;
4209 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4210 fSectors = fOuterSec;
4211 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4212 fSectors = fOuterSec;
4213 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4214 printf("\n%d",pt->GetLabel());
4215 fSectors = fInnerSec;
4216 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4217 fSectors = fOuterSec;
4218 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4219 fSectors = fOuterSec;
4227 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4230 // make forward propagation
4232 Int_t nseed= arr->GetEntriesFast();
4233 for (Int_t i=0;i<nseed;i++){
4234 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4236 AliTPCseed *pt2 = new AliTPCseed(*pt);
4237 fSectors = fOuterSec;
4238 FollowProlongation(*pt,0);
4239 fSectors = fOuterSec;
4240 FollowProlongation(*pt,0);
4241 fSectors = fInnerSec;
4242 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4243 printf("\n%d",pt->GetLabel());
4244 fSectors = fOuterSec;
4245 FollowProlongation(*pt2,0);
4246 fSectors = fOuterSec;
4247 FollowProlongation(*pt2,0);
4248 fSectors = fOuterSec;
4256 Int_t AliTPCtrackerMI::PropagateForward()
4258 fSectors = fOuterSec;
4259 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4260 fSectors = fInnerSec;
4261 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4271 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4274 // make back propagation, in between row0 and row1
4278 fSectors = fInnerSec;
4281 if (row1<fSectors->GetNRows())
4284 r1 = fSectors->GetNRows()-1;
4286 if (row0<fSectors->GetNRows()&& r1>0 )
4287 FollowBackProlongation(*pt,r1);
4288 if (row1<=fSectors->GetNRows())
4291 r1 = row1 - fSectors->GetNRows();
4292 if (r1<=0) return 0;
4293 if (r1>=fOuterSec->GetNRows()) return 0;
4294 fSectors = fOuterSec;
4295 return FollowBackProlongation(*pt,r1);
4303 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4307 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4308 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4309 Float_t padlength = GetPadPitchLength(row);
4311 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4312 Float_t angulary = seed->GetSnp();
4313 angulary = angulary*angulary/(1-angulary*angulary);
4314 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4316 Float_t sresz = fParam->GetZSigma();
4317 Float_t angularz = seed->GetTgl();
4318 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4320 Float_t wy = GetSigmaY(seed);
4321 Float_t wz = GetSigmaZ(seed);
4324 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4325 printf("problem\n");