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 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker -
24 // run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 // run AliTPCFindTracksMI.C macro - to find tracks
26 // tracks are written to AliTPCtracks.root file
27 // for comparison also seeds are written to the same file - to special branch
28 //-------------------------------------------------------
33 #include "Riostream.h"
34 #include <TClonesArray.h>
36 #include <TObjArray.h>
39 #include "AliComplexCluster.h"
41 #include "AliESDkink.h"
43 #include "AliRunLoader.h"
44 #include "AliTPCClustersRow.h"
45 #include "AliTPCParam.h"
46 #include "AliTPCReconstructor.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCseed.h"
51 #include "AliTPCtrackerMI.h"
52 #include "TStopwatch.h"
53 #include "AliTPCReconstructor.h"
54 #include "AliESDkink.h"
56 #include "TTreeStream.h"
59 ClassImp(AliTPCtrackerMI)
62 class AliTPCFastMath {
65 static Double_t FastAsin(Double_t x);
67 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
70 Double_t AliTPCFastMath::fgFastAsin[20000];
71 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
73 AliTPCFastMath::AliTPCFastMath(){
75 // initialized lookup table;
76 for (Int_t i=0;i<10000;i++){
77 fgFastAsin[2*i] = TMath::ASin(i/10000.);
78 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
82 Double_t AliTPCFastMath::FastAsin(Double_t x){
84 // return asin using lookup table
86 Int_t index = int(x*10000);
87 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
90 Int_t index = int(x*10000);
91 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
97 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
99 //update track information using current cluster - track->fCurrentCluster
102 AliTPCclusterMI* c =track->fCurrentCluster;
103 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
105 UInt_t i = track->fCurrentClusterIndex1;
107 Int_t sec=(i&0xff000000)>>24;
108 //Int_t row = (i&0x00ff0000)>>16;
109 track->fRow=(i&0x00ff0000)>>16;
110 track->fSector = sec;
111 // Int_t index = i&0xFFFF;
112 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
113 track->SetClusterIndex2(track->fRow, i);
114 //track->fFirstPoint = row;
115 //if ( track->fLastPoint<row) track->fLastPoint =row;
116 // if (track->fRow<0 || track->fRow>160) {
117 // printf("problem\n");
119 if (track->fFirstPoint>track->fRow)
120 track->fFirstPoint = track->fRow;
121 if (track->fLastPoint<track->fRow)
122 track->fLastPoint = track->fRow;
125 track->fClusterPointer[track->fRow] = c;
128 Float_t angle2 = track->GetSnp()*track->GetSnp();
129 angle2 = TMath::Sqrt(angle2/(1-angle2));
131 //SET NEW Track Point
135 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
137 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
138 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
139 point.SetErrY(sqrt(track->fErrorY2));
140 point.SetErrZ(sqrt(track->fErrorZ2));
142 point.SetX(track->GetX());
143 point.SetY(track->GetY());
144 point.SetZ(track->GetZ());
145 point.SetAngleY(angle2);
146 point.SetAngleZ(track->GetTgl());
147 if (point.fIsShared){
148 track->fErrorY2 *= 4;
149 track->fErrorZ2 *= 4;
153 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
155 track->fErrorY2 *= 1.3;
156 track->fErrorY2 += 0.01;
157 track->fErrorZ2 *= 1.3;
158 track->fErrorZ2 += 0.005;
160 if (accept>0) return 0;
161 if (track->GetNumberOfClusters()%20==0){
162 // if (track->fHelixIn){
163 // TClonesArray & larr = *(track->fHelixIn);
164 // Int_t ihelix = larr.GetEntriesFast();
165 // new(larr[ihelix]) AliHelix(*track) ;
168 track->fNoCluster =0;
169 return track->Update(c,chi2,i);
174 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
175 Float_t cory, Float_t corz)
178 // decide according desired precision to accept given
179 // cluster for tracking
180 Double_t sy2=ErrY2(seed,cluster)*cory;
181 Double_t sz2=ErrZ2(seed,cluster)*corz;
182 //sy2=ErrY2(seed,cluster)*cory;
183 //sz2=ErrZ2(seed,cluster)*cory;
185 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
186 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
188 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
189 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
190 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
191 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
193 Double_t rdistance2 = rdistancey2+rdistancez2;
196 if (rdistance2>16) return 3;
199 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
200 return 2; //suspisiouce - will be changed
202 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
203 // strict cut on overlaped cluster
204 return 2; //suspisiouce - will be changed
206 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
207 && cluster->GetType()<0){
217 //_____________________________________________________________________________
218 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
219 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
221 //---------------------------------------------------------------------
222 // The main TPC tracker constructor
223 //---------------------------------------------------------------------
224 fInnerSec=new AliTPCSector[fkNIS];
225 fOuterSec=new AliTPCSector[fkNOS];
228 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
229 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
236 Int_t nrowlow = par->GetNRowLow();
237 Int_t nrowup = par->GetNRowUp();
240 for (Int_t i=0;i<nrowlow;i++){
241 fXRow[i] = par->GetPadRowRadiiLow(i);
242 fPadLength[i]= par->GetPadPitchLength(0,i);
243 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
247 for (Int_t i=0;i<nrowup;i++){
248 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
249 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
250 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
261 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
263 //________________________________________________________________________
264 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
269 //------------------------------------
270 // dummy copy constructor
271 //------------------------------------------------------------------
273 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
274 //------------------------------
276 //--------------------------------------------------------------
279 //_____________________________________________________________________________
280 AliTPCtrackerMI::~AliTPCtrackerMI() {
281 //------------------------------------------------------------------
282 // TPC tracker destructor
283 //------------------------------------------------------------------
290 if (fDebugStreamer) delete fDebugStreamer;
293 void AliTPCtrackerMI::SetIO()
297 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
299 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
301 AliTPCtrack *iotrack= new AliTPCtrack;
302 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
308 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
324 AliTPCtrack *iotrack= new AliTPCtrack;
325 // iotrack->fHelixIn = new TClonesArray("AliHelix");
326 //iotrack->fHelixOut = new TClonesArray("AliHelix");
327 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
330 if (output && (fDebug&2)){
331 //write the full seed information if specified in debug mode
333 fSeedTree = new TTree("Seeds","Seeds");
334 AliTPCseed * vseed = new AliTPCseed;
336 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
337 arrtr->ExpandCreateFast(160);
338 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
340 vseed->fPoints = arrtr;
341 vseed->fEPoints = arre;
342 // vseed->fClusterPoints = arrcl;
343 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
346 fTreeDebug = new TTree("trackDebug","trackDebug");
347 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
348 fTreeDebug->Branch("debug",&arrd,32000,99);
356 void AliTPCtrackerMI::FillESD(TObjArray* arr)
360 //fill esds using updated tracks
362 // write tracks to the event
363 // store index of the track
364 Int_t nseed=arr->GetEntriesFast();
365 //FindKinks(arr,fEvent);
366 for (Int_t i=0; i<nseed; i++) {
367 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
370 // pt->PropagateTo(fParam->GetInnerRadiusLow());
371 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
372 pt->PropagateTo(fParam->GetInnerRadiusLow());
375 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
377 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
378 iotrack.SetTPCPoints(pt->GetPoints());
379 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
380 iotrack.SetV0Indexes(pt->GetV0Indexes());
381 // iotrack.SetTPCpid(pt->fTPCr);
382 //iotrack.SetTPCindex(i);
383 fEvent->AddTrack(&iotrack);
387 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
389 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
390 iotrack.SetTPCPoints(pt->GetPoints());
391 //iotrack.SetTPCindex(i);
392 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
393 iotrack.SetV0Indexes(pt->GetV0Indexes());
394 // iotrack.SetTPCpid(pt->fTPCr);
395 fEvent->AddTrack(&iotrack);
399 // short tracks - maybe decays
401 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
402 Int_t found,foundable,shared;
403 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
404 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
406 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
407 //iotrack.SetTPCindex(i);
408 iotrack.SetTPCPoints(pt->GetPoints());
409 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
410 iotrack.SetV0Indexes(pt->GetV0Indexes());
411 //iotrack.SetTPCpid(pt->fTPCr);
412 fEvent->AddTrack(&iotrack);
417 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
418 Int_t found,foundable,shared;
419 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
420 if (found<20) continue;
421 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
424 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
425 iotrack.SetTPCPoints(pt->GetPoints());
426 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
427 iotrack.SetV0Indexes(pt->GetV0Indexes());
428 //iotrack.SetTPCpid(pt->fTPCr);
429 //iotrack.SetTPCindex(i);
430 fEvent->AddTrack(&iotrack);
433 // short tracks - secondaties
435 if ( (pt->GetNumberOfClusters()>30) ) {
436 Int_t found,foundable,shared;
437 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
438 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
440 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
441 iotrack.SetTPCPoints(pt->GetPoints());
442 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
443 iotrack.SetV0Indexes(pt->GetV0Indexes());
444 //iotrack.SetTPCpid(pt->fTPCr);
445 //iotrack.SetTPCindex(i);
446 fEvent->AddTrack(&iotrack);
451 if ( (pt->GetNumberOfClusters()>15)) {
452 Int_t found,foundable,shared;
453 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
454 if (found<15) continue;
455 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
456 if (float(found)/float(foundable)<0.8) continue;
459 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
460 iotrack.SetTPCPoints(pt->GetPoints());
461 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
462 iotrack.SetV0Indexes(pt->GetV0Indexes());
463 // iotrack.SetTPCpid(pt->fTPCr);
464 //iotrack.SetTPCindex(i);
465 fEvent->AddTrack(&iotrack);
470 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
473 void AliTPCtrackerMI::WriteTracks(TTree * tree)
476 // write tracks from seed array to selected tree
480 AliTPCtrack *iotrack= new AliTPCtrack;
481 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
486 void AliTPCtrackerMI::WriteTracks()
489 // write tracks to the given output tree -
490 // output specified with SetIO routine
497 AliTPCtrack *iotrack= 0;
498 Int_t nseed=fSeeds->GetEntriesFast();
499 //for (Int_t i=0; i<nseed; i++) {
500 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
501 // if (iotrack) break;
503 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
504 TBranch * br = fOutput->GetBranch("tracks");
505 br->SetAddress(&iotrack);
507 for (Int_t i=0; i<nseed; i++) {
508 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
510 AliTPCtrack * track = new AliTPCtrack(*pt);
513 // br->SetAddress(&iotrack);
518 //fOutput->GetDirectory()->cd();
524 //write the full seed information if specified in debug mode
526 AliTPCseed * vseed = new AliTPCseed;
528 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
529 arrtr->ExpandCreateFast(160);
530 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
531 //arrcl->ExpandCreateFast(160);
532 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
534 vseed->fPoints = arrtr;
535 vseed->fEPoints = arre;
536 // vseed->fClusterPoints = arrcl;
537 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
538 TBranch * brseed = fSeedTree->GetBranch("seeds");
540 Int_t nseed=fSeeds->GetEntriesFast();
542 for (Int_t i=0; i<nseed; i++) {
543 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
546 // pt->fClusterPoints = arrcl;
550 brseed->SetAddress(&vseed);
554 // pt->fClusterPoints = 0;
557 if (fTreeDebug) fTreeDebug->Write();
565 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
568 //seed->SetErrorY2(0.1);
570 //calculate look-up table at the beginning
571 static Bool_t ginit = kFALSE;
572 static Float_t gnoise1,gnoise2,gnoise3;
573 static Float_t ggg1[10000];
574 static Float_t ggg2[10000];
575 static Float_t ggg3[10000];
576 static Float_t glandau1[10000];
577 static Float_t glandau2[10000];
578 static Float_t glandau3[10000];
580 static Float_t gcor01[500];
581 static Float_t gcor02[500];
582 static Float_t gcorp[500];
587 for (Int_t i=1;i<500;i++){
588 Float_t rsigma = float(i)/100.;
589 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
590 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
591 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
595 for (Int_t i=3;i<10000;i++){
599 Float_t amp = float(i);
600 Float_t padlength =0.75;
601 gnoise1 = 0.0004/padlength;
602 Float_t nel = 0.268*amp;
603 Float_t nprim = 0.155*amp;
604 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
605 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
606 if (glandau1[i]>1) glandau1[i]=1;
607 glandau1[i]*=padlength*padlength/12.;
611 gnoise2 = 0.0004/padlength;
614 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
615 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
616 if (glandau2[i]>1) glandau2[i]=1;
617 glandau2[i]*=padlength*padlength/12.;
622 gnoise3 = 0.0004/padlength;
625 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
626 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
627 if (glandau3[i]>1) glandau3[i]=1;
628 glandau3[i]*=padlength*padlength/12.;
636 Int_t amp = int(TMath::Abs(cl->GetQ()));
638 seed->SetErrorY2(1.);
642 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
643 Int_t ctype = cl->GetType();
644 Float_t padlength= GetPadPitchLength(seed->fRow);
645 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
646 angle2 = angle2/(1-angle2);
649 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
652 if (fSectors==fInnerSec){
654 res = ggg1[amp]*z+glandau1[amp]*angle2;
655 if (ctype==0) res *= gcor01[rsigmay];
658 res*= gcorp[rsigmay];
664 res = ggg2[amp]*z+glandau2[amp]*angle2;
665 if (ctype==0) res *= gcor02[rsigmay];
668 res*= gcorp[rsigmay];
673 res = ggg3[amp]*z+glandau3[amp]*angle2;
674 if (ctype==0) res *= gcor02[rsigmay];
677 res*= gcorp[rsigmay];
684 res*=2.4; // overestimate error 2 times
691 seed->SetErrorY2(res);
699 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
702 //seed->SetErrorY2(0.1);
704 //calculate look-up table at the beginning
705 static Bool_t ginit = kFALSE;
706 static Float_t gnoise1,gnoise2,gnoise3;
707 static Float_t ggg1[10000];
708 static Float_t ggg2[10000];
709 static Float_t ggg3[10000];
710 static Float_t glandau1[10000];
711 static Float_t glandau2[10000];
712 static Float_t glandau3[10000];
714 static Float_t gcor01[1000];
715 static Float_t gcor02[1000];
716 static Float_t gcorp[1000];
721 for (Int_t i=1;i<1000;i++){
722 Float_t rsigma = float(i)/100.;
723 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
724 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
725 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
729 for (Int_t i=3;i<10000;i++){
733 Float_t amp = float(i);
734 Float_t padlength =0.75;
735 gnoise1 = 0.0004/padlength;
736 Float_t nel = 0.268*amp;
737 Float_t nprim = 0.155*amp;
738 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
739 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
740 if (glandau1[i]>1) glandau1[i]=1;
741 glandau1[i]*=padlength*padlength/12.;
745 gnoise2 = 0.0004/padlength;
748 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
749 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
750 if (glandau2[i]>1) glandau2[i]=1;
751 glandau2[i]*=padlength*padlength/12.;
756 gnoise3 = 0.0004/padlength;
759 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
760 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
761 if (glandau3[i]>1) glandau3[i]=1;
762 glandau3[i]*=padlength*padlength/12.;
770 Int_t amp = int(TMath::Abs(cl->GetQ()));
772 seed->SetErrorY2(1.);
776 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
777 Int_t ctype = cl->GetType();
778 Float_t padlength= GetPadPitchLength(seed->fRow);
780 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
781 // if (angle2<0.6) angle2 = 0.6;
782 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
785 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
788 if (fSectors==fInnerSec){
790 res = ggg1[amp]*z+glandau1[amp]*angle2;
791 if (ctype==0) res *= gcor01[rsigmaz];
794 res*= gcorp[rsigmaz];
800 res = ggg2[amp]*z+glandau2[amp]*angle2;
801 if (ctype==0) res *= gcor02[rsigmaz];
804 res*= gcorp[rsigmaz];
809 res = ggg3[amp]*z+glandau3[amp]*angle2;
810 if (ctype==0) res *= gcor02[rsigmaz];
813 res*= gcorp[rsigmaz];
822 if ((ctype<0) &&<70){
830 seed->SetErrorZ2(res);
837 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
840 //seed->SetErrorZ2(0.1);
844 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
846 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
847 Int_t ctype = cl->GetType();
848 Float_t amp = TMath::Abs(cl->GetQ());
853 Float_t landau=2 ; //landau fluctuation part
854 Float_t gg=2; // gg fluctuation part
855 Float_t padlength= GetPadPitchLength(seed->GetX());
857 if (fSectors==fInnerSec){
858 snoise2 = 0.0004/padlength;
861 gg = (2+0.001*nel/(padlength*padlength))/nel;
862 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
863 if (landau>1) landau=1;
866 snoise2 = 0.0004/padlength;
869 gg = (2+0.0008*nel/(padlength*padlength))/nel;
870 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
871 if (landau>1) landau=1;
873 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
876 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
877 angle2 = TMath::Sqrt((1-angle2));
878 if (angle2<0.6) angle2 = 0.6;
881 Float_t angle = seed->GetTgl()/angle2;
882 Float_t angular = landau*angle*angle*padlength*padlength/12.;
883 Float_t res = sdiff + angular;
886 if ((ctype==0) && (fSectors ==fOuterSec))
887 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
889 if ((ctype==0) && (fSectors ==fInnerSec))
890 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
894 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
900 if ((ctype<0) &&<70){
908 seed->SetErrorZ2(res);
916 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
918 //rotate to track "local coordinata
919 Float_t x = seed->GetX();
920 Float_t y = seed->GetY();
921 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
924 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
925 if (!seed->Rotate(fSectors->GetAlpha()))
927 } else if (y <-ymax) {
928 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
929 if (!seed->Rotate(-fSectors->GetAlpha()))
937 //_____________________________________________________________________________
938 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
939 Double_t x2,Double_t y2,
940 Double_t x3,Double_t y3)
942 //-----------------------------------------------------------------
943 // Initial approximation of the track curvature
944 //-----------------------------------------------------------------
945 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
946 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
947 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
948 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
949 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
951 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
952 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
953 return -xr*yr/sqrt(xr*xr+yr*yr);
958 //_____________________________________________________________________________
959 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
960 Double_t x2,Double_t y2,
961 Double_t x3,Double_t y3)
963 //-----------------------------------------------------------------
964 // Initial approximation of the track curvature
965 //-----------------------------------------------------------------
971 Double_t det = x3*y2-x2*y3;
976 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
977 Double_t x0 = x3*0.5-y3*u;
978 Double_t y0 = y3*0.5+x3*u;
979 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
985 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
986 Double_t x2,Double_t y2,
987 Double_t x3,Double_t y3)
989 //-----------------------------------------------------------------
990 // Initial approximation of the track curvature
991 //-----------------------------------------------------------------
997 Double_t det = x3*y2-x2*y3;
1002 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1003 Double_t x0 = x3*0.5-y3*u;
1004 Double_t y0 = y3*0.5+x3*u;
1005 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1014 //_____________________________________________________________________________
1015 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1016 Double_t x2,Double_t y2,
1017 Double_t x3,Double_t y3)
1019 //-----------------------------------------------------------------
1020 // Initial approximation of the track curvature times center of curvature
1021 //-----------------------------------------------------------------
1022 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1023 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1024 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1025 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1026 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1028 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1030 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1033 //_____________________________________________________________________________
1034 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1035 Double_t x2,Double_t y2,
1036 Double_t z1,Double_t z2)
1038 //-----------------------------------------------------------------
1039 // Initial approximation of the tangent of the track dip angle
1040 //-----------------------------------------------------------------
1041 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1045 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1046 Double_t x2,Double_t y2,
1047 Double_t z1,Double_t z2, Double_t c)
1049 //-----------------------------------------------------------------
1050 // Initial approximation of the tangent of the track dip angle
1051 //-----------------------------------------------------------------
1055 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1057 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1058 if (TMath::Abs(d*c*0.5)>1) return 0;
1059 // Double_t angle2 = TMath::ASin(d*c*0.5);
1060 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1061 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1063 angle2 = (z1-z2)*c/(angle2*2.);
1067 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1068 {//-----------------------------------------------------------------
1069 // This function find proloncation of a track to a reference plane x=x2.
1070 //-----------------------------------------------------------------
1074 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1078 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1079 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1083 Double_t dy = dx*(c1+c2)/(r1+r2);
1086 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1088 if (TMath::Abs(delta)>0.01){
1089 dz = x[3]*TMath::ASin(delta)/x[4];
1091 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1094 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1102 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1107 return LoadClusters();
1110 Int_t AliTPCtrackerMI::LoadClusters()
1113 // load clusters to the memory
1114 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1115 clrow->SetClass("AliTPCclusterMI");
1117 clrow->GetArray()->ExpandCreateFast(10000);
1119 // TTree * tree = fClustersArray.GetTree();
1121 TTree * tree = fInput;
1122 TBranch * br = tree->GetBranch("Segment");
1123 br->SetAddress(&clrow);
1125 Int_t j=Int_t(tree->GetEntries());
1126 for (Int_t i=0; i<j; i++) {
1130 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1132 AliTPCRow * tpcrow=0;
1135 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1139 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1140 left = (sec-fkNIS*2)/fkNOS;
1143 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1144 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1145 for (Int_t i=0;i<tpcrow->fN1;i++)
1146 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1149 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1150 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1151 for (Int_t i=0;i<tpcrow->fN2;i++)
1152 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1163 void AliTPCtrackerMI::UnloadClusters()
1166 // unload clusters from the memory
1168 Int_t nrows = fOuterSec->GetNRows();
1169 for (Int_t sec = 0;sec<fkNOS;sec++)
1170 for (Int_t row = 0;row<nrows;row++){
1171 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1173 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1174 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1176 tpcrow->ResetClusters();
1179 nrows = fInnerSec->GetNRows();
1180 for (Int_t sec = 0;sec<fkNIS;sec++)
1181 for (Int_t row = 0;row<nrows;row++){
1182 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1184 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1185 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1187 tpcrow->ResetClusters();
1194 //_____________________________________________________________________________
1195 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1196 //-----------------------------------------------------------------
1197 // This function fills outer TPC sectors with clusters.
1198 //-----------------------------------------------------------------
1199 Int_t nrows = fOuterSec->GetNRows();
1201 for (Int_t sec = 0;sec<fkNOS;sec++)
1202 for (Int_t row = 0;row<nrows;row++){
1203 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1204 Int_t sec2 = sec+2*fkNIS;
1206 Int_t ncl = tpcrow->fN1;
1208 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1209 index=(((sec2<<8)+row)<<16)+ncl;
1210 tpcrow->InsertCluster(c,index);
1215 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1216 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1217 tpcrow->InsertCluster(c,index);
1220 // write indexes for fast acces
1222 for (Int_t i=0;i<510;i++)
1223 tpcrow->fFastCluster[i]=-1;
1224 for (Int_t i=0;i<tpcrow->GetN();i++){
1225 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1226 tpcrow->fFastCluster[zi]=i; // write index
1229 for (Int_t i=0;i<510;i++){
1230 if (tpcrow->fFastCluster[i]<0)
1231 tpcrow->fFastCluster[i] = last;
1233 last = tpcrow->fFastCluster[i];
1242 //_____________________________________________________________________________
1243 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1244 //-----------------------------------------------------------------
1245 // This function fills inner TPC sectors with clusters.
1246 //-----------------------------------------------------------------
1247 Int_t nrows = fInnerSec->GetNRows();
1249 for (Int_t sec = 0;sec<fkNIS;sec++)
1250 for (Int_t row = 0;row<nrows;row++){
1251 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1254 Int_t ncl = tpcrow->fN1;
1256 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1257 index=(((sec<<8)+row)<<16)+ncl;
1258 tpcrow->InsertCluster(c,index);
1263 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1264 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1265 tpcrow->InsertCluster(c,index);
1268 // write indexes for fast acces
1270 for (Int_t i=0;i<510;i++)
1271 tpcrow->fFastCluster[i]=-1;
1272 for (Int_t i=0;i<tpcrow->GetN();i++){
1273 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1274 tpcrow->fFastCluster[zi]=i; // write index
1277 for (Int_t i=0;i<510;i++){
1278 if (tpcrow->fFastCluster[i]<0)
1279 tpcrow->fFastCluster[i] = last;
1281 last = tpcrow->fFastCluster[i];
1293 //_________________________________________________________________________
1294 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1295 //--------------------------------------------------------------------
1296 // Return pointer to a given cluster
1297 //--------------------------------------------------------------------
1298 Int_t sec=(index&0xff000000)>>24;
1299 Int_t row=(index&0x00ff0000)>>16;
1300 Int_t ncl=(index&0x00007fff)>>00;
1302 const AliTPCRow * tpcrow=0;
1303 AliTPCclusterMI * clrow =0;
1306 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1307 if (tpcrow==0) return 0;
1310 if (tpcrow->fN1<=ncl) return 0;
1311 clrow = tpcrow->fClusters1;
1314 if (tpcrow->fN2<=ncl) return 0;
1315 clrow = tpcrow->fClusters2;
1319 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1320 if (tpcrow==0) return 0;
1322 if (sec-2*fkNIS<fkNOS) {
1323 if (tpcrow->fN1<=ncl) return 0;
1324 clrow = tpcrow->fClusters1;
1327 if (tpcrow->fN2<=ncl) return 0;
1328 clrow = tpcrow->fClusters2;
1332 return &(clrow[ncl]);
1338 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1339 //-----------------------------------------------------------------
1340 // This function tries to find a track prolongation to next pad row
1341 //-----------------------------------------------------------------
1343 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1344 AliTPCclusterMI *cl=0;
1345 Int_t tpcindex= t.GetClusterIndex2(nr);
1347 // update current shape info every 5 pad-row
1348 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1352 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1354 if (tpcindex==-1) return 0; //track in dead zone
1356 cl = t.fClusterPointer[nr];
1357 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1358 t.fCurrentClusterIndex1 = tpcindex;
1361 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1362 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1364 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1365 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1367 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1368 Double_t rotation = angle-t.GetAlpha();
1369 t.fRelativeSector= relativesector;
1374 t.fCurrentCluster = cl;
1376 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1377 if ((tpcindex&0x8000)==0) accept =0;
1379 //if founded cluster is acceptible
1380 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1387 UpdateTrack(&t,accept);
1392 if (fIteration>1) return 0; // not look for new cluster during refitting
1395 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1396 Double_t y=t.GetYat(x);
1397 if (TMath::Abs(y)>ymax){
1399 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1400 if (!t.Rotate(fSectors->GetAlpha()))
1402 } else if (y <-ymax) {
1403 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1404 if (!t.Rotate(-fSectors->GetAlpha()))
1410 if (!t.PropagateTo(x)) {
1411 if (fIteration==0) t.fRemoval = 10;
1415 Double_t z=t.GetZ();
1417 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1418 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1420 Double_t roadz = 1.;
1422 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1424 t.SetClusterIndex2(nr,-1);
1429 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() ) t.fNFoundable++;
1435 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1436 cl = krow.FindNearest2(y,z,roady,roadz,index);
1437 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1440 t.fCurrentCluster = cl;
1442 if (fIteration==2&&cl->IsUsed(10)) return 0;
1443 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1444 if (fIteration==2&&cl->IsUsed(11)) {
1451 if (t.fCurrentCluster->IsUsed(10)){
1456 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1462 if (accept<3) UpdateTrack(&t,accept);
1465 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1471 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1472 //-----------------------------------------------------------------
1473 // This function tries to find a track prolongation to next pad row
1474 //-----------------------------------------------------------------
1476 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1478 if (!t.GetProlongation(x,y,z)) {
1484 if (TMath::Abs(y)>ymax){
1487 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1488 if (!t.Rotate(fSectors->GetAlpha()))
1490 } else if (y <-ymax) {
1491 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1492 if (!t.Rotate(-fSectors->GetAlpha()))
1495 if (!t.PropagateTo(x)) {
1498 t.GetProlongation(x,y,z);
1501 // update current shape info every 3 pad-row
1502 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1503 // t.fCurrentSigmaY = GetSigmaY(&t);
1504 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1508 AliTPCclusterMI *cl=0;
1513 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1514 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1516 Double_t roadz = 1.;
1519 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1521 t.SetClusterIndex2(row,-1);
1526 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1530 if ((cl==0)&&(krow)) {
1531 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1532 cl = krow.FindNearest2(y,z,roady,roadz,index);
1534 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1538 t.fCurrentCluster = cl;
1539 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1541 t.SetClusterIndex2(row,index);
1542 t.fClusterPointer[row] = cl;
1550 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1551 //-----------------------------------------------------------------
1552 // This function tries to find a track prolongation to next pad row
1553 //-----------------------------------------------------------------
1554 t.fCurrentCluster = 0;
1555 t.fCurrentClusterIndex1 = 0;
1557 Double_t xt=t.GetX();
1558 Int_t row = GetRowNumber(xt)-1;
1559 Double_t ymax= GetMaxY(nr);
1561 if (row < nr) return 1; // don't prolongate if not information until now -
1562 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1564 return 0; // not prolongate strongly inclined tracks
1566 if (TMath::Abs(t.GetSnp())>0.95) {
1568 return 0; // not prolongate strongly inclined tracks
1571 Double_t x= GetXrow(nr);
1573 //t.PropagateTo(x+0.02);
1574 //t.PropagateTo(x+0.01);
1575 if (!t.PropagateTo(x)){
1582 if (TMath::Abs(y)>ymax){
1584 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1585 if (!t.Rotate(fSectors->GetAlpha()))
1587 } else if (y <-ymax) {
1588 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1589 if (!t.Rotate(-fSectors->GetAlpha()))
1592 // if (!t.PropagateTo(x)){
1600 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1602 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1604 t.SetClusterIndex2(nr,-1);
1609 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1615 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1616 // t.fCurrentSigmaY = GetSigmaY(&t);
1617 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1621 AliTPCclusterMI *cl=0;
1624 Double_t roady = 1.;
1625 Double_t roadz = 1.;
1629 index = t.GetClusterIndex2(nr);
1630 if ( (index>0) && (index&0x8000)==0){
1631 cl = t.fClusterPointer[nr];
1632 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1633 t.fCurrentClusterIndex1 = index;
1635 t.fCurrentCluster = cl;
1641 // if (index<0) return 0;
1642 UInt_t uindex = TMath::Abs(index);
1645 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1646 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1649 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1650 t.fCurrentCluster = cl;
1656 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1657 //-----------------------------------------------------------------
1658 // This function tries to find a track prolongation to next pad row
1659 //-----------------------------------------------------------------
1661 //update error according neighborhoud
1663 if (t.fCurrentCluster) {
1665 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1667 if (t.fCurrentCluster->IsUsed(10)){
1673 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1678 if (fIteration>0) accept = 0;
1679 if (accept<3) UpdateTrack(&t,accept);
1683 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1684 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1686 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1694 //_____________________________________________________________________________
1695 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1696 //-----------------------------------------------------------------
1697 // This function tries to find a track prolongation.
1698 //-----------------------------------------------------------------
1699 Double_t xt=t.GetX();
1701 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1702 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1703 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1705 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1707 Int_t first = GetRowNumber(xt)-1;
1708 for (Int_t nr= first; nr>=rf; nr-=step) {
1710 if (t.GetKinkIndexes()[0]>0){
1711 for (Int_t i=0;i<3;i++){
1712 Int_t index = t.GetKinkIndexes()[i];
1713 if (index==0) break;
1714 if (index<0) continue;
1716 AliESDkink * kink = fEvent->GetKink(index-1);
1718 printf("PROBLEM\n");
1721 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1723 AliExternalTrackParam paramd(t);
1724 kink->SetDaughter(paramd);
1725 kink->SetStatus(2,5);
1732 if (nr==80) t.UpdateReference();
1733 if (nr<fInnerSec->GetNRows())
1734 fSectors = fInnerSec;
1736 fSectors = fOuterSec;
1737 if (FollowToNext(t,nr)==0)
1746 //_____________________________________________________________________________
1747 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1748 //-----------------------------------------------------------------
1749 // This function tries to find a track prolongation.
1750 //-----------------------------------------------------------------
1751 Double_t xt=t.GetX();
1753 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1754 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1755 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1756 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1758 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1760 if (FollowToNextFast(t,nr)==0)
1761 if (!t.IsActive()) return 0;
1771 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1772 //-----------------------------------------------------------------
1773 // This function tries to find a track prolongation.
1774 //-----------------------------------------------------------------
1776 Double_t xt=t.GetX();
1777 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1778 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1779 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1780 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1782 Int_t first = t.fFirstPoint;
1783 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1785 if (first<0) first=0;
1786 for (Int_t nr=first; nr<=rf; nr++) {
1787 if ( (TMath::Abs(t.GetSnp())>0.95)) break;
1788 if (t.GetKinkIndexes()[0]<0){
1789 for (Int_t i=0;i<3;i++){
1790 Int_t index = t.GetKinkIndexes()[i];
1791 if (index==0) break;
1792 if (index>0) continue;
1793 index = TMath::Abs(index);
1794 AliESDkink * kink = fEvent->GetKink(index-1);
1796 printf("PROBLEM\n");
1799 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1801 AliExternalTrackParam paramm(t);
1802 kink->SetMother(paramm);
1803 kink->SetStatus(2,1);
1810 if (nr<fInnerSec->GetNRows())
1811 fSectors = fInnerSec;
1813 fSectors = fOuterSec;
1823 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1831 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1834 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1836 Float_t distance = TMath::Sqrt(dz2+dy2);
1837 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1840 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1841 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1846 if (firstpoint>lastpoint) {
1847 firstpoint =lastpoint;
1852 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1853 if (s1->GetClusterIndex2(i)>0) sum1++;
1854 if (s2->GetClusterIndex2(i)>0) sum2++;
1855 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1859 if (sum<5) return 0;
1861 Float_t summin = TMath::Min(sum1+1,sum2+1);
1862 Float_t ratio = (sum+1)/Float_t(summin);
1866 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1870 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1871 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1873 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1875 Float_t dy2 =(s1->GetY() - s2->GetY());
1877 Float_t distance = dz2+dy2;
1878 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1883 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1884 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1886 if (firstpoint>=lastpoint-5) return;;
1888 for (Int_t i=firstpoint;i<lastpoint;i++){
1889 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1890 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1897 for (Int_t i=firstpoint;i<lastpoint;i++){
1898 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1899 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1900 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1901 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1902 if (s1->IsActive()&&s2->IsActive()){
1903 p1->fIsShared = kTRUE;
1904 p2->fIsShared = kTRUE;
1911 for (Int_t i=0;i<4;i++){
1912 if (s1->fOverlapLabels[3*i]==0){
1913 s1->fOverlapLabels[3*i] = s2->GetLabel();
1914 s1->fOverlapLabels[3*i+1] = sumshared;
1915 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1919 for (Int_t i=0;i<4;i++){
1920 if (s2->fOverlapLabels[3*i]==0){
1921 s2->fOverlapLabels[3*i] = s1->GetLabel();
1922 s2->fOverlapLabels[3*i+1] = sumshared;
1923 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1931 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1934 //sort trackss according sectors
1936 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1937 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1939 //if (pt) RotateToLocal(pt);
1943 arr->Sort(); // sorting according z
1944 arr->Expand(arr->GetEntries());
1947 Int_t nseed=arr->GetEntriesFast();
1948 for (Int_t i=0; i<nseed; i++) {
1949 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1951 for (Int_t j=0;j<=12;j++){
1952 pt->fOverlapLabels[j] =0;
1955 for (Int_t i=0; i<nseed; i++) {
1956 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1958 if (pt->fRemoval>10) continue;
1959 for (Int_t j=i+1; j<nseed; j++){
1960 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1962 if (pt2->fRemoval<=10) {
1963 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1970 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1973 //sort trackss according sectors
1976 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
1979 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1980 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1985 arr->Sort(); // sorting according z
1986 arr->Expand(arr->GetEntries());
1988 //reset overlap labels
1990 Int_t nseed=arr->GetEntriesFast();
1991 for (Int_t i=0; i<nseed; i++) {
1992 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1995 for (Int_t j=0;j<=12;j++){
1996 pt->fOverlapLabels[j] =0;
2000 //sign shared tracks
2001 for (Int_t i=0; i<nseed; i++) {
2002 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2004 if (pt->fRemoval>10) continue;
2005 Float_t deltac = pt->GetC()*0.1;
2006 for (Int_t j=i+1; j<nseed; j++){
2007 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2009 if (pt2->fRemoval<=10) {
2010 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2011 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2012 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2019 // remove highly shared tracks
2020 for (Int_t i=0; i<nseed; i++) {
2021 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2023 if (pt->fRemoval>10) continue;
2026 for (Int_t j=0;j<4;j++){
2027 sumshared = pt->fOverlapLabels[j*3+1];
2029 Float_t factor = factor1;
2030 if (pt->fRemoval>0) factor = factor2;
2031 if (sumshared/pt->GetNumberOfClusters()>factor){
2032 for (Int_t j=0;j<4;j++){
2033 if (pt->fOverlapLabels[3*j]==0) continue;
2034 if (pt->fOverlapLabels[3*j+1]<5) continue;
2035 if (pt->fRemoval==removalindex) continue;
2036 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2038 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2039 // pt->fRemoval = removalindex;
2040 delete arr->RemoveAt(i);
2048 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2057 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2060 //sort tracks in array according mode criteria
2061 Int_t nseed = arr->GetEntriesFast();
2062 for (Int_t i=0; i<nseed; i++) {
2063 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2073 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2076 //Loop over all tracks and remove "overlaps"
2079 Int_t nseed = arr->GetEntriesFast();
2082 for (Int_t i=0; i<nseed; i++) {
2083 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2085 delete arr->RemoveAt(i);
2089 pt->fBSigned = kFALSE;
2093 nseed = arr->GetEntriesFast();
2100 for (Int_t i=0; i<nseed; i++) {
2101 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2105 Int_t found,foundable,shared;
2107 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2109 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2111 Double_t factor = factor2;
2112 if (pt->fBConstrain) factor = factor1;
2114 if ((Float_t(shared)/Float_t(found))>factor){
2115 pt->Desactivate(removalindex);
2120 for (Int_t i=0; i<160; i++) {
2121 Int_t index=pt->GetClusterIndex2(i);
2122 if (index<0 || index&0x8000 ) continue;
2123 AliTPCclusterMI *c= pt->fClusterPointer[i];
2125 // if (!c->IsUsed(10)) c->Use(10);
2126 //if (pt->IsActive())
2135 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2140 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2143 //Loop over all tracks and remove "overlaps"
2148 Int_t nseed = arr->GetEntriesFast();
2149 Float_t * quality = new Float_t[nseed];
2150 Int_t * indexes = new Int_t[nseed];
2154 for (Int_t i=0; i<nseed; i++) {
2155 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2160 pt->UpdatePoints(); //select first last max dens points
2161 Float_t * points = pt->GetPoints();
2162 if (points[3]<0.8) quality[i] =-1;
2164 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2166 TMath::Sort(nseed,quality,indexes);
2169 for (Int_t itrack=0; itrack<nseed; itrack++) {
2170 Int_t trackindex = indexes[itrack];
2171 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2172 if (quality[trackindex]<0){
2174 delete arr->RemoveAt(trackindex);
2177 arr->RemoveAt(trackindex);
2182 Int_t first = Int_t(pt->GetPoints()[0]);
2183 Int_t last = Int_t(pt->GetPoints()[2]);
2184 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2186 Int_t found,foundable,shared;
2187 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2188 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2190 if (Float_t(shared+1)/Float_t(found+1)>factor){
2191 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2192 delete arr->RemoveAt(trackindex);
2196 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2197 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2198 delete arr->RemoveAt(trackindex);
2203 if (sharedfactor>0.4) continue;
2204 for (Int_t i=first; i<last; i++) {
2205 Int_t index=pt->GetClusterIndex2(i);
2206 // if (index<0 || index&0x8000 ) continue;
2207 if (index<0 || index&0x8000 ) continue;
2208 AliTPCclusterMI *c= pt->fClusterPointer[i];
2215 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2221 void AliTPCtrackerMI::UnsignClusters()
2224 // loop over all clusters and unsign them
2227 for (Int_t sec=0;sec<fkNIS;sec++){
2228 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2229 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2230 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2231 // if (cl[icl].IsUsed(10))
2233 cl = fInnerSec[sec][row].fClusters2;
2234 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2235 //if (cl[icl].IsUsed(10))
2240 for (Int_t sec=0;sec<fkNOS;sec++){
2241 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2242 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2243 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2244 //if (cl[icl].IsUsed(10))
2246 cl = fOuterSec[sec][row].fClusters2;
2247 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2248 //if (cl[icl].IsUsed(10))
2257 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2260 //sign clusters to be "used"
2262 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2263 // loop over "primaries"
2277 Int_t nseed = arr->GetEntriesFast();
2278 for (Int_t i=0; i<nseed; i++) {
2279 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2283 if (!(pt->IsActive())) continue;
2284 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2285 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2287 sumdens2+= dens*dens;
2288 sumn += pt->GetNumberOfClusters();
2289 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2290 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2293 sumchi2 +=chi2*chi2;
2298 Float_t mdensity = 0.9;
2299 Float_t meann = 130;
2300 Float_t meanchi = 1;
2301 Float_t sdensity = 0.1;
2302 Float_t smeann = 10;
2303 Float_t smeanchi =0.4;
2307 mdensity = sumdens/sum;
2309 meanchi = sumchi/sum;
2311 sdensity = sumdens2/sum-mdensity*mdensity;
2312 sdensity = TMath::Sqrt(sdensity);
2314 smeann = sumn2/sum-meann*meann;
2315 smeann = TMath::Sqrt(smeann);
2317 smeanchi = sumchi2/sum - meanchi*meanchi;
2318 smeanchi = TMath::Sqrt(smeanchi);
2322 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2324 for (Int_t i=0; i<nseed; i++) {
2325 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2329 if (pt->fBSigned) continue;
2330 if (pt->fBConstrain) continue;
2331 //if (!(pt->IsActive())) continue;
2333 Int_t found,foundable,shared;
2334 pt->GetClusterStatistic(0,160,found, foundable,shared);
2335 if (shared/float(found)>0.3) {
2336 if (shared/float(found)>0.9 ){
2337 //delete arr->RemoveAt(i);
2342 Bool_t isok =kFALSE;
2343 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2345 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2347 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2349 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2353 for (Int_t i=0; i<160; i++) {
2354 Int_t index=pt->GetClusterIndex2(i);
2355 if (index<0) continue;
2356 AliTPCclusterMI *c= pt->fClusterPointer[i];
2358 //if (!(c->IsUsed(10))) c->Use();
2365 Double_t maxchi = meanchi+2.*smeanchi;
2367 for (Int_t i=0; i<nseed; i++) {
2368 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2372 //if (!(pt->IsActive())) continue;
2373 if (pt->fBSigned) continue;
2374 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2375 if (chi>maxchi) continue;
2378 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2380 //sign only tracks with enoug big density at the beginning
2382 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2385 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2386 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2388 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2389 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2392 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2393 //Int_t noc=pt->GetNumberOfClusters();
2394 pt->fBSigned = kTRUE;
2395 for (Int_t i=0; i<160; i++) {
2397 Int_t index=pt->GetClusterIndex2(i);
2398 if (index<0) continue;
2399 AliTPCclusterMI *c= pt->fClusterPointer[i];
2401 // if (!(c->IsUsed(10))) c->Use();
2406 // gLastCheck = nseed;
2414 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2416 // stop not active tracks
2417 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2418 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2419 Int_t nseed = arr->GetEntriesFast();
2421 for (Int_t i=0; i<nseed; i++) {
2422 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2426 if (!(pt->IsActive())) continue;
2427 StopNotActive(pt,row0,th0, th1,th2);
2433 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2436 // stop not active tracks
2437 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2438 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2441 Int_t foundable = 0;
2442 Int_t maxindex = seed->fLastPoint; //last foundable row
2443 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2444 seed->Desactivate(10) ;
2448 for (Int_t i=row0; i<maxindex; i++){
2449 Int_t index = seed->GetClusterIndex2(i);
2450 if (index!=-1) foundable++;
2452 if (foundable<=30) sumgood1++;
2453 if (foundable<=50) {
2460 if (foundable>=30.){
2461 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2464 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2468 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2471 // back propagation of ESD tracks
2477 //PrepareForProlongation(fSeeds,1);
2478 PropagateForward2(fSeeds);
2481 Int_t nseed = fSeeds->GetEntriesFast();
2482 for (Int_t i=0;i<nseed;i++){
2483 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2484 if (!seed) continue;
2485 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2487 seed->PropagateTo(fParam->GetInnerRadiusLow());
2488 seed->UpdatePoints();
2489 AliESDtrack *esd=event->GetTrack(i);
2490 seed->CookdEdx(0.02,0.6);
2491 CookLabel(seed,0.1); //For comparison only
2493 if (0 && seed!=0&&esd!=0) {
2494 TTreeSRedirector &cstream = *fDebugStreamer;
2500 if (seed->GetNumberOfClusters()>15){
2501 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2502 esd->SetTPCPoints(seed->GetPoints());
2506 //printf("problem\n");
2509 //FindKinks(fSeeds,event);
2510 Info("RefitInward","Number of refitted tracks %d",ntracks);
2517 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2520 // back propagation of ESD tracks
2526 PropagateBack(fSeeds);
2527 Int_t nseed = fSeeds->GetEntriesFast();
2529 for (Int_t i=0;i<nseed;i++){
2530 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2531 if (!seed) continue;
2532 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2533 seed->UpdatePoints();
2534 AliESDtrack *esd=event->GetTrack(i);
2535 seed->CookdEdx(0.02,0.6);
2536 CookLabel(seed,0.1); //For comparison only
2537 if (seed->GetNumberOfClusters()>15){
2538 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2539 esd->SetTPCPoints(seed->GetPoints());
2543 //FindKinks(fSeeds,event);
2544 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2551 void AliTPCtrackerMI::DeleteSeeds()
2555 Int_t nseed = fSeeds->GetEntriesFast();
2556 for (Int_t i=0;i<nseed;i++){
2557 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2558 if (seed) delete fSeeds->RemoveAt(i);
2564 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2567 //read seeds from the event
2569 Int_t nentr=event->GetNumberOfTracks();
2571 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2576 fSeeds = new TObjArray(nentr);
2580 for (Int_t i=0; i<nentr; i++) {
2581 AliESDtrack *esd=event->GetTrack(i);
2582 ULong_t status=esd->GetStatus();
2583 if (!(status&AliESDtrack::kTPCin)) continue;
2584 AliTPCtrack t(*esd);
2585 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2586 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2587 for (Int_t ikink=0;ikink<3;ikink++) {
2588 Int_t index = esd->GetKinkIndex(ikink);
2589 seed->GetKinkIndexes()[ikink] = index;
2590 if (index==0) continue;
2591 index = TMath::Abs(index);
2592 AliESDkink * kink = fEvent->GetKink(index-1);
2593 if (kink&&esd->GetKinkIndex(ikink)<0){
2594 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2595 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2597 if (kink&&esd->GetKinkIndex(ikink)>0){
2598 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2599 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2603 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2604 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2605 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2610 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2611 Double_t par0[5],par1[5],x;
2612 esd->GetInnerExternalParameters(x,par0);
2613 esd->GetExternalParameters(x,par1);
2614 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2615 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2617 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2618 //reset covariance if suspicious
2619 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2620 seed->ResetCovariance();
2625 // rotate to the local coordinate system
2627 fSectors=fInnerSec; fN=fkNIS;
2628 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2629 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2630 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2631 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2632 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2633 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2634 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2635 alpha-=seed->GetAlpha();
2636 if (!seed->Rotate(alpha)) {
2642 for (Int_t irow=0;irow<160;irow++){
2643 Int_t index = seed->GetClusterIndex2(irow);
2646 AliTPCclusterMI * cl = GetClusterMI(index);
2647 seed->fClusterPointer[irow] = cl;
2649 if ((index & 0x8000)==0){
2650 cl->Use(10); // accepted cluster
2652 cl->Use(6); // close cluster not accepted
2655 Info("ReadSeeds","Not found cluster");
2659 fSeeds->AddAt(seed,i);
2665 //_____________________________________________________________________________
2666 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2667 Float_t deltay, Int_t ddsec) {
2668 //-----------------------------------------------------------------
2669 // This function creates track seeds.
2670 // SEEDING WITH VERTEX CONSTRAIN
2671 //-----------------------------------------------------------------
2672 // cuts[0] - fP4 cut
2673 // cuts[1] - tan(phi) cut
2674 // cuts[2] - zvertex cut
2675 // cuts[3] - fP3 cut
2683 Double_t x[5], c[15];
2684 // Int_t di = i1-i2;
2686 AliTPCseed * seed = new AliTPCseed;
2687 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2688 Double_t cs=cos(alpha), sn=sin(alpha);
2690 // Double_t x1 =fOuterSec->GetX(i1);
2691 //Double_t xx2=fOuterSec->GetX(i2);
2693 Double_t x1 =GetXrow(i1);
2694 Double_t xx2=GetXrow(i2);
2696 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2698 Int_t imiddle = (i2+i1)/2; //middle pad row index
2699 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2700 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2704 const AliTPCRow& kr1=GetRow(ns,i1);
2705 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2706 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2709 // change cut on curvature if it can't reach this layer
2710 // maximal curvature set to reach it
2711 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2712 if (dvertexmax*0.5*cuts[0]>0.85){
2713 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2715 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2718 if (deltay>0) ddsec = 0;
2719 // loop over clusters
2720 for (Int_t is=0; is < kr1; is++) {
2722 if (kr1[is]->IsUsed(10)) continue;
2723 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2724 //if (TMath::Abs(y1)>ymax) continue;
2726 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2728 // find possible directions
2729 Float_t anglez = (z1-z3)/(x1-x3);
2730 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2733 //find rotation angles relative to line given by vertex and point 1
2734 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2735 Double_t dvertex = TMath::Sqrt(dvertex2);
2736 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2737 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2740 // loop over 2 sectors
2746 Double_t dddz1=0; // direction of delta inclination in z axis
2753 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2754 Int_t sec2 = sec + dsec;
2756 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2757 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2758 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2759 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2760 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2761 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2763 // rotation angles to p1-p3
2764 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2765 Double_t x2, y2, z2;
2767 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2770 Double_t dxx0 = (xx2-x3)*cs13r;
2771 Double_t dyy0 = (xx2-x3)*sn13r;
2772 for (Int_t js=index1; js < index2; js++) {
2773 const AliTPCclusterMI *kcl = kr2[js];
2774 if (kcl->IsUsed(10)) continue;
2776 //calcutate parameters
2778 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2780 if (TMath::Abs(yy0)<0.000001) continue;
2781 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2782 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2783 Double_t r02 = (0.25+y0*y0)*dvertex2;
2784 //curvature (radius) cut
2785 if (r02<r2min) continue;
2789 Double_t c0 = 1/TMath::Sqrt(r02);
2793 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2794 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2795 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2796 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2799 Double_t z0 = kcl->GetZ();
2800 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2801 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2804 Double_t dip = (z1-z0)*c0/dfi1;
2805 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2816 x2= xx2*cs-y2*sn*dsec;
2817 y2=+xx2*sn*dsec+y2*cs;
2827 // do we have cluster at the middle ?
2829 GetProlongation(x1,xm,x,ym,zm);
2831 AliTPCclusterMI * cm=0;
2832 if (TMath::Abs(ym)-ymaxm<0){
2833 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2834 if ((!cm) || (cm->IsUsed(10))) {
2839 // rotate y1 to system 0
2840 // get state vector in rotated system
2841 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2842 Double_t xr2 = x0*cs+yr1*sn*dsec;
2843 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2845 GetProlongation(xx2,xm,xr,ym,zm);
2846 if (TMath::Abs(ym)-ymaxm<0){
2847 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2848 if ((!cm) || (cm->IsUsed(10))) {
2858 dym = ym - cm->GetY();
2859 dzm = zm - cm->GetZ();
2866 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2867 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2868 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2869 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2870 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2872 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2873 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2874 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2875 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2876 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2877 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2879 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2880 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2881 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2882 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2886 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2887 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2888 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2889 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2890 c[13]=f30*sy1*f40+f32*sy2*f42;
2891 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2893 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2895 UInt_t index=kr1.GetIndex(is);
2896 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2898 track->fIsSeeding = kTRUE;
2905 FollowProlongation(*track, (i1+i2)/2,1);
2906 Int_t foundable,found,shared;
2907 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2908 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2910 seed->~AliTPCseed();
2916 FollowProlongation(*track, i2,1);
2920 track->fBConstrain =1;
2921 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2922 track->fLastPoint = i1; // first cluster in track position
2923 track->fFirstPoint = track->fLastPoint;
2925 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2926 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2927 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2929 seed->~AliTPCseed();
2933 // Z VERTEX CONDITION
2935 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2936 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2937 if (TMath::Abs(zv-z3)>cuts[2]) {
2938 FollowProlongation(*track, TMath::Max(i2-20,0));
2939 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2940 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2941 if (TMath::Abs(zv-z3)>cuts[2]){
2942 FollowProlongation(*track, TMath::Max(i2-40,0));
2943 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2944 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2945 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2946 // make seed without constrain
2947 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2948 FollowProlongation(*track2, i2,1);
2949 track2->fBConstrain = kFALSE;
2950 track2->fSeedType = 1;
2951 arr->AddLast(track2);
2953 seed->~AliTPCseed();
2958 seed->~AliTPCseed();
2965 track->fSeedType =0;
2966 arr->AddLast(track);
2967 seed = new AliTPCseed;
2969 // don't consider other combinations
2970 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2976 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2982 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2987 //-----------------------------------------------------------------
2988 // This function creates track seeds.
2989 //-----------------------------------------------------------------
2990 // cuts[0] - fP4 cut
2991 // cuts[1] - tan(phi) cut
2992 // cuts[2] - zvertex cut
2993 // cuts[3] - fP3 cut
3003 Double_t x[5], c[15];
3005 // make temporary seed
3006 AliTPCseed * seed = new AliTPCseed;
3007 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3008 // Double_t cs=cos(alpha), sn=sin(alpha);
3013 Double_t x1 = GetXrow(i1-1);
3014 const AliTPCRow& kr1=GetRow(sec,i1-1);
3015 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3017 Double_t x1p = GetXrow(i1);
3018 const AliTPCRow& kr1p=GetRow(sec,i1);
3020 Double_t x1m = GetXrow(i1-2);
3021 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3024 //last 3 padrow for seeding
3025 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3026 Double_t x3 = GetXrow(i1-7);
3027 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3029 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3030 Double_t x3p = GetXrow(i1-6);
3032 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3033 Double_t x3m = GetXrow(i1-8);
3038 Int_t im = i1-4; //middle pad row index
3039 Double_t xm = GetXrow(im); // radius of middle pad-row
3040 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3041 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3044 Double_t deltax = x1-x3;
3045 Double_t dymax = deltax*cuts[1];
3046 Double_t dzmax = deltax*cuts[3];
3048 // loop over clusters
3049 for (Int_t is=0; is < kr1; is++) {
3051 if (kr1[is]->IsUsed(10)) continue;
3052 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3054 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3056 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3057 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3063 for (Int_t js=index1; js < index2; js++) {
3064 const AliTPCclusterMI *kcl = kr3[js];
3065 if (kcl->IsUsed(10)) continue;
3067 // apply angular cuts
3068 if (TMath::Abs(y1-y3)>dymax) continue;
3071 if (TMath::Abs(z1-z3)>dzmax) continue;
3073 Double_t angley = (y1-y3)/(x1-x3);
3074 Double_t anglez = (z1-z3)/(x1-x3);
3076 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3077 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3079 Double_t yyym = angley*(xm-x1)+y1;
3080 Double_t zzzm = anglez*(xm-x1)+z1;
3082 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3084 if (kcm->IsUsed(10)) continue;
3086 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3087 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3094 // look around first
3095 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3101 if (kc1m->IsUsed(10)) used++;
3103 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3109 if (kc1p->IsUsed(10)) used++;
3111 if (used>1) continue;
3112 if (found<1) continue;
3116 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3122 if (kc3m->IsUsed(10)) used++;
3126 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3132 if (kc3p->IsUsed(10)) used++;
3136 if (used>1) continue;
3137 if (found<3) continue;
3147 x[4]=F1(x1,y1,x2,y2,x3,y3);
3148 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3151 x[2]=F2(x1,y1,x2,y2,x3,y3);
3154 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3155 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3159 Double_t sy1=0.1, sz1=0.1;
3160 Double_t sy2=0.1, sz2=0.1;
3161 Double_t sy3=0.1, sy=0.1, sz=0.1;
3163 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3164 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3165 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3166 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3167 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3168 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3170 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3171 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3172 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3173 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3177 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3178 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3179 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3180 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3181 c[13]=f30*sy1*f40+f32*sy2*f42;
3182 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3184 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3186 UInt_t index=kr1.GetIndex(is);
3187 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3189 track->fIsSeeding = kTRUE;
3192 FollowProlongation(*track, i1-7,1);
3193 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3194 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3196 seed->~AliTPCseed();
3202 FollowProlongation(*track, i2,1);
3203 track->fBConstrain =0;
3204 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3205 track->fFirstPoint = track->fLastPoint;
3207 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3208 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3209 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3211 seed->~AliTPCseed();
3216 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3217 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3218 FollowProlongation(*track2, i2,1);
3219 track2->fBConstrain = kFALSE;
3220 track2->fSeedType = 4;
3221 arr->AddLast(track2);
3223 seed->~AliTPCseed();
3227 //arr->AddLast(track);
3228 //seed = new AliTPCseed;
3234 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3240 //_____________________________________________________________________________
3241 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3242 Float_t deltay, Bool_t /*bconstrain*/) {
3243 //-----------------------------------------------------------------
3244 // This function creates track seeds - without vertex constraint
3245 //-----------------------------------------------------------------
3246 // cuts[0] - fP4 cut - not applied
3247 // cuts[1] - tan(phi) cut
3248 // cuts[2] - zvertex cut - not applied
3249 // cuts[3] - fP3 cut
3259 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3260 // Double_t cs=cos(alpha), sn=sin(alpha);
3261 Int_t row0 = (i1+i2)/2;
3262 Int_t drow = (i1-i2)/2;
3263 const AliTPCRow& kr0=fSectors[sec][row0];
3266 AliTPCpolyTrack polytrack;
3267 Int_t nclusters=fSectors[sec][row0];
3268 AliTPCseed * seed = new AliTPCseed;
3273 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3275 Int_t nfoundable =0;
3276 for (Int_t iter =1; iter<2; iter++){ //iterations
3277 const AliTPCRow& krm=fSectors[sec][row0-iter];
3278 const AliTPCRow& krp=fSectors[sec][row0+iter];
3279 const AliTPCclusterMI * cl= kr0[is];
3281 if (cl->IsUsed(10)) {
3287 Double_t x = kr0.GetX();
3288 // Initialization of the polytrack
3293 Double_t y0= cl->GetY();
3294 Double_t z0= cl->GetZ();
3298 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3299 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3301 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3302 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3303 polytrack.AddPoint(x,y0,z0,erry, errz);
3306 if (cl->IsUsed(10)) sumused++;
3309 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3310 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3313 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3314 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3315 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3316 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3317 if (cl1->IsUsed(10)) sumused++;
3318 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3322 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3324 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3325 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3326 if (cl2->IsUsed(10)) sumused++;
3327 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3330 if (sumused>0) continue;
3332 polytrack.UpdateParameters();
3338 nfoundable = polytrack.GetN();
3339 nfound = nfoundable;
3341 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3342 Float_t maxdist = 0.8*(1.+3./(ddrow));
3343 for (Int_t delta = -1;delta<=1;delta+=2){
3344 Int_t row = row0+ddrow*delta;
3345 kr = &(fSectors[sec][row]);
3346 Double_t xn = kr->GetX();
3347 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3348 polytrack.GetFitPoint(xn,yn,zn);
3349 if (TMath::Abs(yn)>ymax) continue;
3351 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3353 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3356 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3357 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3358 if (cln->IsUsed(10)) {
3359 // printf("used\n");
3367 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3372 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3373 polytrack.UpdateParameters();
3376 if ( (sumused>3) || (sumused>0.5*nfound)) {
3377 //printf("sumused %d\n",sumused);
3382 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3383 AliTPCpolyTrack track2;
3385 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3386 if (track2.GetN()<0.5*nfoundable) continue;
3389 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3391 // test seed with and without constrain
3392 for (Int_t constrain=0; constrain<=0;constrain++){
3393 // add polytrack candidate
3395 Double_t x[5], c[15];
3396 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3397 track2.GetBoundaries(x3,x1);
3399 track2.GetFitPoint(x1,y1,z1);
3400 track2.GetFitPoint(x2,y2,z2);
3401 track2.GetFitPoint(x3,y3,z3);
3403 //is track pointing to the vertex ?
3406 polytrack.GetFitPoint(x0,y0,z0);
3419 x[4]=F1(x1,y1,x2,y2,x3,y3);
3421 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3422 x[2]=F2(x1,y1,x2,y2,x3,y3);
3424 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3425 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3426 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3427 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3430 Double_t sy =0.1, sz =0.1;
3431 Double_t sy1=0.02, sz1=0.02;
3432 Double_t sy2=0.02, sz2=0.02;
3436 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3439 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3440 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3441 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3442 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3443 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3444 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3446 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3447 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3448 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3449 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3454 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3455 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3456 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3457 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3458 c[13]=f30*sy1*f40+f32*sy2*f42;
3459 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3461 //Int_t row1 = fSectors->GetRowNumber(x1);
3462 Int_t row1 = GetRowNumber(x1);
3466 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3467 track->fIsSeeding = kTRUE;
3468 Int_t rc=FollowProlongation(*track, i2);
3469 if (constrain) track->fBConstrain =1;
3471 track->fBConstrain =0;
3472 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3473 track->fFirstPoint = track->fLastPoint;
3475 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3476 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3477 track->fNShared>0.4*track->GetNumberOfClusters()) {
3480 seed->~AliTPCseed();
3483 arr->AddLast(track);
3484 seed = new AliTPCseed;
3488 } // if accepted seed
3491 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3497 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3501 //reseed using track points
3502 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3503 Int_t p1 = int(r1*track->GetNumberOfClusters());
3504 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3506 Double_t x0[3],x1[3],x2[3];
3507 for (Int_t i=0;i<3;i++){
3513 // find track position at given ratio of the length
3514 Int_t sec0=0, sec1=0, sec2=0;
3517 for (Int_t i=0;i<160;i++){
3518 if (track->fClusterPointer[i]){
3520 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3521 if ( (index<p0) || x0[0]<0 ){
3522 if (trpoint->GetX()>1){
3523 clindex = track->GetClusterIndex2(i);
3525 x0[0] = trpoint->GetX();
3526 x0[1] = trpoint->GetY();
3527 x0[2] = trpoint->GetZ();
3528 sec0 = ((clindex&0xff000000)>>24)%18;
3533 if ( (index<p1) &&(trpoint->GetX()>1)){
3534 clindex = track->GetClusterIndex2(i);
3536 x1[0] = trpoint->GetX();
3537 x1[1] = trpoint->GetY();
3538 x1[2] = trpoint->GetZ();
3539 sec1 = ((clindex&0xff000000)>>24)%18;
3542 if ( (index<p2) &&(trpoint->GetX()>1)){
3543 clindex = track->GetClusterIndex2(i);
3545 x2[0] = trpoint->GetX();
3546 x2[1] = trpoint->GetY();
3547 x2[2] = trpoint->GetZ();
3548 sec2 = ((clindex&0xff000000)>>24)%18;
3555 Double_t alpha, cs,sn, xx2,yy2;
3557 alpha = (sec1-sec2)*fSectors->GetAlpha();
3558 cs = TMath::Cos(alpha);
3559 sn = TMath::Sin(alpha);
3560 xx2= x1[0]*cs-x1[1]*sn;
3561 yy2= x1[0]*sn+x1[1]*cs;
3565 alpha = (sec0-sec2)*fSectors->GetAlpha();
3566 cs = TMath::Cos(alpha);
3567 sn = TMath::Sin(alpha);
3568 xx2= x0[0]*cs-x0[1]*sn;
3569 yy2= x0[0]*sn+x0[1]*cs;
3575 Double_t x[5],c[15];
3579 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3580 // if (x[4]>1) return 0;
3581 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3582 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3583 //if (TMath::Abs(x[3]) > 2.2) return 0;
3584 //if (TMath::Abs(x[2]) > 1.99) return 0;
3586 Double_t sy =0.1, sz =0.1;
3588 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3589 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3590 Double_t sy3=0.01+track->GetSigmaY2();
3592 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3593 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3594 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3595 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3596 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3597 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3599 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3600 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3601 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3602 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3607 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3608 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3609 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3610 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3611 c[13]=f30*sy1*f40+f32*sy2*f42;
3612 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3614 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3615 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3616 // Double_t y0,z0,y1,z1, y2,z2;
3617 //seed->GetProlongation(x0[0],y0,z0);
3618 // seed->GetProlongation(x1[0],y1,z1);
3619 //seed->GetProlongation(x2[0],y2,z2);
3621 seed->fLastPoint = pp2;
3622 seed->fFirstPoint = pp2;
3629 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3633 //reseed using founded clusters
3635 // Find the number of clusters
3636 Int_t nclusters = 0;
3637 for (Int_t irow=0;irow<160;irow++){
3638 if (track->GetClusterIndex(irow)>0) nclusters++;
3642 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3643 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3644 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3648 Int_t row[3],sec[3]={0,0,0};
3650 // find track row position at given ratio of the length
3652 for (Int_t irow=0;irow<160;irow++){
3653 if (track->GetClusterIndex2(irow)<0) continue;
3655 for (Int_t ipoint=0;ipoint<3;ipoint++){
3656 if (index<=ipos[ipoint]) row[ipoint] = irow;
3660 //Get cluster and sector position
3661 for (Int_t ipoint=0;ipoint<3;ipoint++){
3662 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3663 AliTPCclusterMI * cl = GetClusterMI(clindex);
3666 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3669 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3670 xyz[ipoint][0] = GetXrow(row[ipoint]);
3671 xyz[ipoint][1] = cl->GetY();
3672 xyz[ipoint][2] = cl->GetZ();
3676 // Calculate seed state vector and covariance matrix
3678 Double_t alpha, cs,sn, xx2,yy2;
3680 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3681 cs = TMath::Cos(alpha);
3682 sn = TMath::Sin(alpha);
3683 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3684 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3688 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3689 cs = TMath::Cos(alpha);
3690 sn = TMath::Sin(alpha);
3691 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3692 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3698 Double_t x[5],c[15];
3702 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3703 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3704 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3706 Double_t sy =0.1, sz =0.1;
3708 Double_t sy1=0.2, sz1=0.2;
3709 Double_t sy2=0.2, sz2=0.2;
3712 Double_t f40=(F1(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[4])/sy;
3713 Double_t f42=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[4])/sy;
3714 Double_t f43=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[4])/sy;
3715 Double_t f20=(F2(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[2])/sy;
3716 Double_t f22=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[2])/sy;
3717 Double_t f23=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[2])/sy;
3719 Double_t f30=(F3(xyz[2][0],xyz[2][1]+sy,xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2])-x[3])/sy;
3720 Double_t f31=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2]+sz,xyz[0][2])-x[3])/sz;
3721 Double_t f32=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1]+sy,xyz[2][2],xyz[0][2])-x[3])/sy;
3722 Double_t f34=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2]+sz)-x[3])/sz;
3727 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3728 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3729 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3730 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3731 c[13]=f30*sy1*f40+f32*sy2*f42;
3732 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3734 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3735 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3736 seed->fLastPoint = row[2];
3737 seed->fFirstPoint = row[2];
3742 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3746 //reseed using founded clusters
3749 Int_t row[3]={0,0,0};
3750 Int_t sec[3]={0,0,0};
3752 // forward direction
3754 for (Int_t irow=r0;irow<160;irow++){
3755 if (track->GetClusterIndex(irow)>0){
3760 for (Int_t irow=160;irow>r0;irow--){
3761 if (track->GetClusterIndex(irow)>0){
3766 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3767 if (track->GetClusterIndex(irow)>0){
3775 for (Int_t irow=0;irow<r0;irow++){
3776 if (track->GetClusterIndex(irow)>0){
3781 for (Int_t irow=r0;irow>0;irow--){
3782 if (track->GetClusterIndex(irow)>0){
3787 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3788 if (track->GetClusterIndex(irow)>0){
3795 if ((row[2]-row[0])<20) return 0;
3796 if (row[1]==0) return 0;
3799 //Get cluster and sector position
3800 for (Int_t ipoint=0;ipoint<3;ipoint++){
3801 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3802 AliTPCclusterMI * cl = GetClusterMI(clindex);
3805 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3808 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3809 xyz[ipoint][0] = GetXrow(row[ipoint]);
3810 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3811 if (point&&ipoint<2){
3813 xyz[ipoint][1] = point->GetY();
3814 xyz[ipoint][2] = point->GetZ();
3817 xyz[ipoint][1] = cl->GetY();
3818 xyz[ipoint][2] = cl->GetZ();
3825 // Calculate seed state vector and covariance matrix
3827 Double_t alpha, cs,sn, xx2,yy2;
3829 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3830 cs = TMath::Cos(alpha);
3831 sn = TMath::Sin(alpha);
3832 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3833 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3837 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3838 cs = TMath::Cos(alpha);
3839 sn = TMath::Sin(alpha);
3840 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3841 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3847 Double_t x[5],c[15];
3851 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3852 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3853 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3855 Double_t sy =0.1, sz =0.1;
3857 Double_t sy1=0.2, sz1=0.2;
3858 Double_t sy2=0.2, sz2=0.2;
3861 Double_t f40=(F1(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[4])/sy;
3862 Double_t f42=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[4])/sy;
3863 Double_t f43=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[4])/sy;
3864 Double_t f20=(F2(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[2])/sy;
3865 Double_t f22=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[2])/sy;
3866 Double_t f23=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[2])/sy;
3868 Double_t f30=(F3(xyz[2][0],xyz[2][1]+sy,xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2])-x[3])/sy;
3869 Double_t f31=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2]+sz,xyz[0][2])-x[3])/sz;
3870 Double_t f32=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1]+sy,xyz[2][2],xyz[0][2])-x[3])/sy;
3871 Double_t f34=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2]+sz)-x[3])/sz;
3876 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3877 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3878 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3879 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3880 c[13]=f30*sy1*f40+f32*sy2*f42;
3881 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3883 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3884 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3885 seed->fLastPoint = row[2];
3886 seed->fFirstPoint = row[2];
3887 for (Int_t i=row[0];i<row[2];i++){
3888 seed->fIndex[i] = track->fIndex[i];
3894 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
3901 TObjArray *kinks= new TObjArray(10000);
3902 // TObjArray *v0s= new TObjArray(10000);
3903 Int_t nentries = array->GetEntriesFast();
3904 AliHelix *helixes = new AliHelix[nentries];
3905 Int_t *sign = new Int_t[nentries];
3906 Int_t *nclusters = new Int_t[nentries];
3907 Float_t *alpha = new Float_t[nentries];
3908 AliESDkink * kink = new AliESDkink();
3909 Int_t * usage = new Int_t[nentries];
3910 Float_t *zm = new Float_t[nentries];
3911 Float_t *z0 = new Float_t[nentries];
3912 Float_t *fim = new Float_t[nentries];
3913 Float_t *shared = new Float_t[nentries];
3914 Bool_t *circular = new Bool_t[nentries];
3915 Float_t *dca = new Float_t[nentries];
3916 //const AliESDVertex * primvertex = esd->GetVertex();
3918 // nentries = array->GetEntriesFast();
3923 for (Int_t i=0;i<nentries;i++){
3926 AliTPCseed* track = (AliTPCseed*)array->At(i);
3927 if (!track) continue;
3928 track->fCircular =0;
3930 track->UpdatePoints();
3931 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
3933 nclusters[i]=track->GetNumberOfClusters();
3934 alpha[i] = track->GetAlpha();
3935 new (&helixes[i]) AliHelix(*track);
3937 helixes[i].Evaluate(0,xyz);
3938 sign[i] = (track->GetC()>0) ? -1:1;
3941 if (track->GetProlongation(x,y,z)){
3943 fim[i] = alpha[i]+TMath::ATan2(y,x);
3946 zm[i] = track->GetZ();
3950 circular[i]= kFALSE;
3951 if (track->GetProlongation(0,y,z)) z0[i] = z;
3952 dca[i] = track->GetD(0,0);
3958 Int_t ncandidates =0;
3961 Double_t phase[2][2],radius[2];
3964 // Find circling track
3965 TTreeSRedirector &cstream = *fDebugStreamer;
3967 for (Int_t i0=0;i0<nentries;i0++){
3968 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
3969 if (!track0) continue;
3970 if (track0->fN<40) continue;
3971 if (TMath::Abs(1./track0->fP4)>200) continue;
3972 for (Int_t i1=i0+1;i1<nentries;i1++){
3973 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
3974 if (!track1) continue;
3975 if (track1->fN<40) continue;
3976 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
3977 if (track0->fBConstrain&&track1->fBConstrain) continue;
3978 if (TMath::Abs(1./track1->fP4)>200) continue;
3979 if (track1->fP4*track0->fP4>0) continue;
3980 if (track1->fP3*track0->fP3>0) continue;
3981 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
3982 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
3983 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
3985 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
3986 if (mindcar<5) continue;
3987 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
3988 if (mindcaz<5) continue;
3989 if (mindcar+mindcaz<20) continue;
3992 Float_t xc0 = helixes[i0].GetHelix(6);
3993 Float_t yc0 = helixes[i0].GetHelix(7);
3994 Float_t r0 = helixes[i0].GetHelix(8);
3995 Float_t xc1 = helixes[i1].GetHelix(6);
3996 Float_t yc1 = helixes[i1].GetHelix(7);
3997 Float_t r1 = helixes[i1].GetHelix(8);
3999 Float_t rmean = (r0+r1)*0.5;
4000 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4001 //if (delta>30) continue;
4002 if (delta>rmean*0.25) continue;
4003 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4005 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4006 if (npoints==0) continue;
4007 helixes[i0].GetClosestPhases(helixes[i1], phase);
4011 Double_t hangles[3];
4012 helixes[i0].Evaluate(phase[0][0],xyz0);
4013 helixes[i1].Evaluate(phase[0][1],xyz1);
4015 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4016 Double_t deltah[2],deltabest;
4017 if (hangles[2]<2.8) continue;
4019 cstream<<"C"<<track0->fLab<<track1->fLab<<
4020 track0->fP3<<track1->fP3<<
4021 track0->fP4<<track1->fP4<<
4022 delta<<rmean<<npoints<<
4023 hangles[0]<<hangles[2]<<
4024 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4028 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4030 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4031 if (deltah[1]<deltah[0]) ibest=1;
4033 deltabest = TMath::Sqrt(deltah[ibest]);
4034 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4035 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4036 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4037 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4039 if (deltabest>6) continue;
4040 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4041 Bool_t sign =kFALSE;
4042 if (hangles[2]>3.06) sign =kTRUE;
4045 circular[i0] = kTRUE;
4046 circular[i1] = kTRUE;
4047 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4048 track0->fCircular += 1;
4049 track1->fCircular += 2;
4052 track1->fCircular += 1;
4053 track0->fCircular += 2;
4058 cstream<<"Curling"<<
4059 "lab0="<<track0->fLab<<
4060 "lab1="<<track1->fLab<<
4065 "mindcar="<<mindcar<<
4066 "mindcaz="<<mindcaz<<
4069 "npoints="<<npoints<<
4070 "hangles0="<<hangles[0]<<
4071 "hangles2="<<hangles[2]<<
4076 "radius="<<radiusbest<<
4077 "deltabest="<<deltabest<<
4078 "phase0="<<phase[ibest][0]<<
4079 "phase1="<<phase[ibest][1]<<
4089 for (Int_t i =0;i<nentries;i++){
4090 if (sign[i]==0) continue;
4091 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4094 Double_t cradius0 = 40*40;
4095 Double_t cradius1 = 270*270;
4098 Double_t cdist3=0.55;
4099 for (Int_t j =i+1;j<nentries;j++){
4101 if (sign[j]*sign[i]<1) continue;
4102 if ( (nclusters[i]+nclusters[j])>200) continue;
4103 if ( (nclusters[i]+nclusters[j])<80) continue;
4104 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4105 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4106 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4107 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4108 if (npoints<1) continue;
4111 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4114 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4117 Double_t delta1=10000,delta2=10000;
4118 // cuts on the intersection radius
4119 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4120 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4121 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4123 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4124 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4125 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4128 Double_t distance1 = TMath::Min(delta1,delta2);
4129 if (distance1>cdist1) continue; // cut on DCA linear approximation
4131 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4132 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4133 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4134 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4137 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4138 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4139 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4141 distance1 = TMath::Min(delta1,delta2);
4144 rkink = TMath::Sqrt(radius[0]);
4147 rkink = TMath::Sqrt(radius[1]);
4149 if (distance1>cdist2) continue;
4152 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4155 Int_t row0 = GetRowNumber(rkink);
4156 if (row0<10) continue;
4157 if (row0>150) continue;
4160 Float_t dens00=-1,dens01=-1;
4161 Float_t dens10=-1,dens11=-1;
4163 Int_t found,foundable,shared;
4164 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4165 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4166 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4167 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4169 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4170 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4171 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4172 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4174 if (dens00<dens10 && dens01<dens11) continue;
4175 if (dens00>dens10 && dens01>dens11) continue;
4176 if (TMath::Max(dens00,dens10)<0.1) continue;
4177 if (TMath::Max(dens01,dens11)<0.3) continue;
4179 if (TMath::Min(dens00,dens10)>0.6) continue;
4180 if (TMath::Min(dens01,dens11)>0.6) continue;
4183 AliTPCseed * ktrack0, *ktrack1;
4192 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4193 AliExternalTrackParam paramm(*ktrack0);
4194 AliExternalTrackParam paramd(*ktrack1);
4195 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4198 kink->SetMother(paramm);
4199 kink->SetDaughter(paramd);
4202 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4204 fParam->Transform0to1(x,index);
4205 fParam->Transform1to2(x,index);
4206 row0 = GetRowNumber(x[0]);
4208 if (kink->GetR()<100) continue;
4209 if (kink->GetR()>240) continue;
4210 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4211 if (kink->GetDistance()>cdist3) continue;
4212 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4213 if (dird<0) continue;
4215 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4216 if (dirm<0) continue;
4217 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4218 if (mpt<0.2) continue;
4221 //for high momenta momentum not defined well in first iteration
4222 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4223 if (qt>0.35) continue;
4226 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4227 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4229 kink->SetTPCDensity(dens00,0,0);
4230 kink->SetTPCDensity(dens01,0,1);
4231 kink->SetTPCDensity(dens10,1,0);
4232 kink->SetTPCDensity(dens11,1,1);
4233 kink->SetIndex(i,0);
4234 kink->SetIndex(j,1);
4237 kink->SetTPCDensity(dens10,0,0);
4238 kink->SetTPCDensity(dens11,0,1);
4239 kink->SetTPCDensity(dens00,1,0);
4240 kink->SetTPCDensity(dens01,1,1);
4241 kink->SetIndex(j,0);
4242 kink->SetIndex(i,1);
4245 if (mpt<1||kink->GetAngle(2)>0.1){
4246 // angle and densities not defined yet
4247 if (kink->GetTPCDensityFactor()<0.8) continue;
4248 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4249 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4250 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4251 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4253 Float_t criticalangle = track0->fC22+track0->fC33;
4254 criticalangle+= track1->fC22+track1->fC33;
4255 criticalangle= 3*TMath::Sqrt(criticalangle);
4256 if (criticalangle>0.02) criticalangle=0.02;
4257 if (kink->GetAngle(2)<criticalangle) continue;
4260 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4261 Float_t shapesum =0;
4263 for ( Int_t row = row0-drow; row<row0+drow;row++){
4264 if (row<0) continue;
4265 if (row>155) continue;
4266 if (ktrack0->fClusterPointer[row]){
4267 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4268 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4271 if (ktrack1->fClusterPointer[row]){
4272 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4273 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4278 kink->SetShapeFactor(-1.);
4281 kink->SetShapeFactor(shapesum/sum);
4283 // esd->AddKink(kink);
4284 kinks->AddLast(kink);
4285 kink = new AliESDkink;
4290 // sort the kinks according quality - and refit them towards vertex
4292 Int_t nkinks = kinks->GetEntriesFast();
4293 Float_t *quality = new Float_t[nkinks];
4294 Int_t *indexes = new Int_t[nkinks];
4295 AliTPCseed *mothers = new AliTPCseed[nkinks];
4296 AliTPCseed *daughters = new AliTPCseed[nkinks];
4299 for (Int_t i=0;i<nkinks;i++){
4301 AliESDkink *kink = (AliESDkink*)kinks->At(i);
4303 // refit kinks towards vertex
4305 Int_t index0 = kink->GetIndex(0);
4306 Int_t index1 = kink->GetIndex(1);
4307 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4308 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4310 Int_t sumn=ktrack0->fN+ktrack1->fN;
4312 // Refit Kink under if too small angle
4314 if (kink->GetAngle(2)<0.05){
4315 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4316 Int_t row0 = kink->GetTPCRow0();
4317 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4320 Int_t last = row0-drow;
4321 if (last<40) last=40;
4322 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4323 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4326 Int_t first = row0+drow;
4327 if (first>130) first=130;
4328 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4329 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4331 if (seed0 && seed1){
4332 kink->SetStatus(1,8);
4333 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4334 row0 = GetRowNumber(kink->GetR());
4335 sumn = seed0->fN+seed1->fN;
4336 new (&mothers[i]) AliTPCseed(*seed0);
4337 new (&daughters[i]) AliTPCseed(*seed1);
4340 delete kinks->RemoveAt(i);
4341 if (seed0) delete seed0;
4342 if (seed1) delete seed1;
4345 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4346 delete kinks->RemoveAt(i);
4347 if (seed0) delete seed0;
4348 if (seed1) delete seed1;
4356 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4358 TMath::Sort(nkinks,quality,indexes,kFALSE);
4360 //remove double find kinks
4362 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4363 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4364 if (!kink0) continue;
4366 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4367 if (!kink0) continue;
4368 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4369 if (!kink1) continue;
4370 // if not close kink continue
4371 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4372 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4373 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4375 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4376 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4377 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4378 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4379 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4388 for (Int_t i=0;i<row0;i++){
4389 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4392 if (mother0.fIndex[i]==mother1.fIndex[i]){
4399 for (Int_t i=row0;i<158;i++){
4400 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4403 if (mother0.fIndex[i]==mother1.fIndex[i]){
4409 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4410 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4411 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4412 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4413 Int_t sum0 = mother0.fN+daughter0.fN;
4414 Int_t sum1 = mother1.fN+daughter1.fN;
4416 shared[kink0->GetIndex(0)]= kTRUE;
4417 shared[kink0->GetIndex(1)]= kTRUE;
4418 delete kinks->RemoveAt(indexes[ikink0]);
4421 shared[kink1->GetIndex(0)]= kTRUE;
4422 shared[kink1->GetIndex(1)]= kTRUE;
4423 delete kinks->RemoveAt(indexes[ikink1]);
4430 for (Int_t i=0;i<nkinks;i++){
4431 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
4432 if (!kink) continue;
4433 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4434 Int_t index0 = kink->GetIndex(0);
4435 Int_t index1 = kink->GetIndex(1);
4436 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4437 kink->SetMultiple(usage[index0],0);
4438 kink->SetMultiple(usage[index1],1);
4439 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4440 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4441 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4442 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4444 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4445 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4446 if (!ktrack0 || !ktrack1) continue;
4447 Int_t index = esd->AddKink(kink);
4450 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4451 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4452 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4453 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4457 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4458 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4463 // Remove tracks corresponding to shared kink's
4465 for (Int_t i=0;i<nentries;i++){
4466 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4467 if (!track0) continue;
4468 if (track0->fKinkIndexes[0]!=0) continue;
4469 if (shared[i]) delete array->RemoveAt(i);
4474 RemoveUsed2(array,0.5,0.4,30);
4476 for (Int_t i=0;i<nentries;i++){
4477 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4478 if (!track0) continue;
4479 track0->CookdEdx(0.02,0.6);
4483 for (Int_t i=0;i<nentries;i++){
4484 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4485 if (!track0) continue;
4486 if (track0->Pt()<1.4) continue;
4487 //remove double high momenta tracks - overlapped with kink candidates
4490 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4491 if (track0->fClusterPointer[icl]!=0){
4493 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4496 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4497 delete array->RemoveAt(i);
4500 if (track0->fKinkIndexes[0]!=0) continue;
4501 if (track0->GetNumberOfClusters()<80) continue;
4503 AliTPCseed *pmother = new AliTPCseed();
4504 AliTPCseed *pdaughter = new AliTPCseed();
4505 AliESDkink *pkink = new AliESDkink;
4507 AliTPCseed & mother = *pmother;
4508 AliTPCseed & daughter = *pdaughter;
4509 AliESDkink & kink = *pkink;
4510 if (CheckKinkPoint(track0,mother,daughter, kink)){
4511 if (mother.fN<30||daughter.fN<20) {
4515 continue; //too short tracks
4517 if (mother.Pt()<1.4) {
4523 Int_t row0= kink.GetTPCRow0();
4524 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4531 Int_t index = esd->AddKink(&kink);
4532 mother.fKinkIndexes[0] = -(index+1);
4533 daughter.fKinkIndexes[0] = index+1;
4535 delete array->RemoveAt(i);
4536 array->AddAt(new AliTPCseed(mother),i);
4539 array->AddLast(new AliTPCseed(mother));
4541 array->AddLast(new AliTPCseed(daughter));
4542 for (Int_t icl=0;icl<row0;icl++) {
4543 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4546 for (Int_t icl=row0;icl<158;icl++) {
4547 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4556 delete [] daughters;
4578 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4582 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4588 TObjArray *tpcv0s = new TObjArray(100000);
4589 Int_t nentries = array->GetEntriesFast();
4590 AliHelix *helixes = new AliHelix[nentries];
4591 Int_t *sign = new Int_t[nentries];
4592 Float_t *alpha = new Float_t[nentries];
4593 Float_t *z0 = new Float_t[nentries];
4594 Float_t *dca = new Float_t[nentries];
4595 Float_t *sdcar = new Float_t[nentries];
4596 Float_t *cdcar = new Float_t[nentries];
4597 Float_t *pulldcar = new Float_t[nentries];
4598 Float_t *pulldcaz = new Float_t[nentries];
4599 Float_t *pulldca = new Float_t[nentries];
4600 Bool_t *isPrim = new Bool_t[nentries];
4601 const AliESDVertex * primvertex = esd->GetVertex();
4602 Double_t zvertex = primvertex->GetZv();
4604 // nentries = array->GetEntriesFast();
4606 for (Int_t i=0;i<nentries;i++){
4609 AliTPCseed* track = (AliTPCseed*)array->At(i);
4610 if (!track) continue;
4611 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4612 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4613 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4615 alpha[i] = track->GetAlpha();
4616 new (&helixes[i]) AliHelix(*track);
4618 helixes[i].Evaluate(0,xyz);
4619 sign[i] = (track->GetC()>0) ? -1:1;
4623 if (track->GetProlongation(0,y,z)) z0[i] = z;
4624 dca[i] = track->GetD(0,0);
4626 // dca error parrameterezation + pulls
4628 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4629 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4630 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4631 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4632 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4633 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4634 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4635 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4637 if (track->fTPCr[4]>0.5) {
4638 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4640 if (track->fTPCr[0]>0.4) {
4641 isPrim[i]=kFALSE; //electron no sigma cut
4648 Int_t ncandidates =0;
4651 Double_t phase[2][2],radius[2];
4657 TTreeSRedirector &cstream = *fDebugStreamer;
4658 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4660 Double_t cradius0 = 10*10;
4661 Double_t cradius1 = 200*200;
4664 Double_t cpointAngle = 0.95;
4666 Double_t delta[2]={10000,10000};
4667 for (Int_t i =0;i<nentries;i++){
4668 if (sign[i]==0) continue;
4669 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4670 if (!track0) continue;
4675 "zvertex="<<zvertex<<
4676 "sdcar0="<<sdcar[i]<<
4677 "cdcar0="<<cdcar[i]<<
4678 "pulldcar0="<<pulldcar[i]<<
4679 "pulldcaz0="<<pulldcaz[i]<<
4680 "pulldca0="<<pulldca[i]<<
4681 "isPrim="<<isPrim[i]<<
4684 if (track0->fP4<0) continue;
4685 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4687 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4692 for (Int_t j =0;j<nentries;j++){
4693 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4694 if (!track1) continue;
4695 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4696 if (sign[j]*sign[i]>0) continue;
4697 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4698 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4701 // DCA to prim vertex cut
4707 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4708 if (npoints<1) continue;
4712 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4713 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4714 if (delta[0]>cdist1) continue;
4717 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4718 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4719 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4720 if (delta[1]<delta[0]) iclosest=1;
4721 if (delta[iclosest]>cdist1) continue;
4723 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4724 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4726 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4727 if (pointAngle<cpointAngle) continue;
4729 Bool_t isGamma = kFALSE;
4730 vertex.SetP(*track0); //track0 - plus
4731 vertex.SetM(*track1); //track1 - minus
4732 vertex.Update(fprimvertex);
4733 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4734 Double_t pointAngle2 = vertex.GetPointAngle();
4736 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4737 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4738 Float_t sigmae = 0.15*0.15;
4739 if (vertex.GetRr()<80)
4740 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4741 sigmae+= TMath::Sqrt(sigmae);
4742 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4743 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4744 Int_t row0 = GetRowNumber(vertex.GetRr());
4746 if (vertex.GetDist2()>0.2) continue;
4747 densb0 = track0->Density2(0,row0-5);
4748 densb1 = track1->Density2(0,row0-5);
4749 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4750 densa0 = track0->Density2(row0+5,row0+40);
4751 densa1 = track1->Density2(row0+5,row0+40);
4752 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4755 densa0 = track0->Density2(0,40); //cluster density
4756 densa1 = track1->Density2(0,40); //cluster density
4757 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4759 vertex.SetLab(0,track0->GetLabel());
4760 vertex.SetLab(1,track1->GetLabel());
4761 vertex.SetChi2After((densa0+densa1)*0.5);
4762 vertex.SetChi2Before((densb0+densb1)*0.5);
4763 vertex.SetIndex(0,i);
4764 vertex.SetIndex(1,j);
4765 vertex.SetStatus(1); // TPC v0 candidate
4766 vertex.SetRp(track0->fTPCr);
4767 vertex.SetRm(track1->fTPCr);
4768 tpcv0s->AddLast(new AliESDV0MI(vertex));
4771 Int_t eventNr = esd->GetEventNumber();
4772 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4773 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4776 "vertex.="<<&vertex<<
4778 "lab0="<<track0->fLab<<
4779 "Helix0.="<<&helixes[i]<<
4781 "lab1="<<track1->fLab<<
4782 "Helix1.="<<&helixes[j]<<
4783 "pointAngle="<<pointAngle<<
4784 "pointAngle2="<<pointAngle2<<
4789 "zvertex="<<zvertex<<
4790 "circular0="<<track0->fCircular<<
4791 "circular1="<<track1->fCircular<<
4792 "npoints="<<npoints<<
4793 "radius0="<<radius[0]<<
4794 "delta0="<<delta[0]<<
4795 "radius1="<<radius[1]<<
4796 "delta1="<<delta[1]<<
4797 "radiusm="<<radiusm<<
4799 "sdcar0="<<sdcar[i]<<
4800 "sdcar1="<<sdcar[j]<<
4801 "cdcar0="<<cdcar[i]<<
4802 "cdcar1="<<cdcar[j]<<
4803 "pulldcar0="<<pulldcar[i]<<
4804 "pulldcar1="<<pulldcar[j]<<
4805 "pulldcaz0="<<pulldcaz[i]<<
4806 "pulldcaz1="<<pulldcaz[j]<<
4807 "pulldca0="<<pulldca[i]<<
4808 "pulldca1="<<pulldca[j]<<
4818 Float_t *quality = new Float_t[ncandidates];
4819 Int_t *indexes = new Int_t[ncandidates];
4821 for (Int_t i=0;i<ncandidates;i++){
4823 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4824 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4825 // quality[i] /= (0.5+v0->GetDist2());
4826 // quality[i] *= v0->GetChi2After(); //density factor
4827 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4828 Int_t index0 = v0->GetIndex(0);
4829 Int_t index1 = v0->GetIndex(1);
4830 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4831 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4832 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4833 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4836 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4839 for (Int_t i=0;i<ncandidates;i++){
4840 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4842 Int_t index0 = v0->GetIndex(0);
4843 Int_t index1 = v0->GetIndex(1);
4844 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4845 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4846 if (!track0||!track1) {
4850 Bool_t accept =kTRUE; //default accept
4851 Int_t *v0indexes0 = track0->GetV0Indexes();
4852 Int_t *v0indexes1 = track1->GetV0Indexes();
4854 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4855 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4856 if (v0indexes0[1]!=0) order0 =2;
4857 if (v0indexes1[1]!=0) order1 =2;
4859 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4860 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4862 AliESDV0MI * v02 = v0;
4864 v0->SetOrder(0,order0);
4865 v0->SetOrder(1,order1);
4866 v0->SetOrder(1,order0+order1);
4867 Int_t index = esd->AddV0MI(v0);
4868 v02 = esd->GetV0MI(index);
4869 v0indexes0[order0]=index;
4870 v0indexes1[order1]=index;
4874 Int_t eventNr = esd->GetEventNumber();
4880 "lab0="<<track0->fLab<<
4882 "lab1="<<track1->fLab<<
4883 "dca0="<<dca[index0]<<
4884 "dca1="<<dca[index1]<<
4888 "quality="<<quality[i]<<
4889 "pulldca0="<<pulldca[index0]<<
4890 "pulldca1="<<pulldca[index1]<<
4914 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
4918 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
4921 // refit kink towards to the vertex
4924 Int_t row0 = GetRowNumber(kink.GetR());
4925 FollowProlongation(mother,0);
4926 mother.Reset(kFALSE);
4928 FollowProlongation(daughter,row0);
4929 daughter.Reset(kFALSE);
4930 FollowBackProlongation(daughter,158);
4931 daughter.Reset(kFALSE);
4932 Int_t first = TMath::Max(row0-20,30);
4933 Int_t last = TMath::Min(row0+20,140);
4935 const Int_t kNdiv =5;
4936 AliTPCseed param0[kNdiv]; // parameters along the track
4937 AliTPCseed param1[kNdiv]; // parameters along the track
4938 AliESDkink kinks[kNdiv]; // corresponding kink parameters
4941 for (Int_t irow=0; irow<kNdiv;irow++){
4942 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
4944 // store parameters along the track
4946 for (Int_t irow=0;irow<kNdiv;irow++){
4947 FollowBackProlongation(mother, rows[irow]);
4948 FollowProlongation(daughter,rows[kNdiv-1-irow]);
4949 new(¶m0[irow]) AliTPCseed(mother);
4950 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
4954 for (Int_t irow=0; irow<kNdiv-1;irow++){
4955 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
4956 kinks[irow].SetMother(param0[irow]);
4957 kinks[irow].SetDaughter(param1[irow]);
4958 kinks[irow].Update();
4961 // choose kink with best "quality"
4963 Double_t mindist = 10000;
4964 for (Int_t irow=0;irow<kNdiv;irow++){
4965 if (param0[irow].fN<20||param1[irow].fN<20) continue;
4966 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
4967 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
4969 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
4970 normdist/= (param0[irow].fN+param1[irow].fN+40.);
4971 if (normdist < mindist){
4977 if (index==-1) return 0;
4980 param0[index].Reset(kTRUE);
4981 FollowProlongation(param0[index],0);
4983 new (&mother) AliTPCseed(param0[index]);
4984 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
4986 kink.SetMother(mother);
4987 kink.SetDaughter(daughter);
4989 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
4990 kink.SetTPCncls(param0[index].fN,0);
4991 kink.SetTPCncls(param1[index].fN,1);
4992 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
4993 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
4994 mother.SetLabel(kink.GetLabel(0));
4995 daughter.SetLabel(kink.GetLabel(1));
5001 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5003 // update Kink quality information for mother after back propagation
5005 if (seed->GetKinkIndex(0)>=0) return;
5006 for (Int_t ikink=0;ikink<3;ikink++){
5007 Int_t index = seed->GetKinkIndex(ikink);
5008 if (index>=0) break;
5009 index = TMath::Abs(index)-1;
5010 AliESDkink * kink = fEvent->GetKink(index);
5011 //kink->fTPCdensity2[0][0]=-1;
5012 //kink->fTPCdensity2[0][1]=-1;
5013 kink->SetTPCDensity2(-1,0,0);
5014 kink->SetTPCDensity2(1,0,1);
5016 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5017 if (row0<15) row0=15;
5019 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5020 if (row1>145) row1=145;
5022 Int_t found,foundable,shared;
5023 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5024 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5025 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5026 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5031 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5033 // update Kink quality information for daughter after refit
5035 if (seed->GetKinkIndex(0)<=0) return;
5036 for (Int_t ikink=0;ikink<3;ikink++){
5037 Int_t index = seed->GetKinkIndex(ikink);
5038 if (index<=0) break;
5039 index = TMath::Abs(index)-1;
5040 AliESDkink * kink = fEvent->GetKink(index);
5041 kink->SetTPCDensity2(-1,1,0);
5042 kink->SetTPCDensity2(-1,1,1);
5044 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5045 if (row0<15) row0=15;
5047 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5048 if (row1>145) row1=145;
5050 Int_t found,foundable,shared;
5051 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5052 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5053 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5054 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5060 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5063 // check kink point for given track
5064 // if return value=0 kink point not found
5065 // otherwise seed0 correspond to mother particle
5066 // seed1 correspond to daughter particle
5067 // kink parameter of kink point
5069 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5070 Int_t first = seed->fFirstPoint;
5071 Int_t last = seed->fLastPoint;
5072 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5075 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5076 if (!seed1) return 0;
5077 FollowProlongation(*seed1,seed->fLastPoint-20);
5078 seed1->Reset(kTRUE);
5079 FollowProlongation(*seed1,158);
5080 seed1->Reset(kTRUE);
5081 last = seed1->fLastPoint;
5083 AliTPCseed *seed0 = new AliTPCseed(*seed);
5084 seed0->Reset(kFALSE);
5087 AliTPCseed param0[20]; // parameters along the track
5088 AliTPCseed param1[20]; // parameters along the track
5089 AliESDkink kinks[20]; // corresponding kink parameters
5091 for (Int_t irow=0; irow<20;irow++){
5092 rows[irow] = first +((last-first)*irow)/19;
5094 // store parameters along the track
5096 for (Int_t irow=0;irow<20;irow++){
5097 FollowBackProlongation(*seed0, rows[irow]);
5098 FollowProlongation(*seed1,rows[19-irow]);
5099 new(¶m0[irow]) AliTPCseed(*seed0);
5100 new(¶m1[19-irow]) AliTPCseed(*seed1);
5104 for (Int_t irow=0; irow<19;irow++){
5105 kinks[irow].SetMother(param0[irow]);
5106 kinks[irow].SetDaughter(param1[irow]);
5107 kinks[irow].Update();
5110 // choose kink with biggest change of angle
5112 Double_t maxchange= 0;
5113 for (Int_t irow=1;irow<19;irow++){
5114 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5115 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5116 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5117 if ( quality > maxchange){
5118 maxchange = quality;
5125 if (index<0) return 0;
5127 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5128 seed0 = new AliTPCseed(param0[index]);
5129 seed1 = new AliTPCseed(param1[index]);
5130 seed0->Reset(kFALSE);
5131 seed1->Reset(kFALSE);
5132 seed0->ResetCovariance();
5133 seed1->ResetCovariance();
5134 FollowProlongation(*seed0,0);
5135 FollowBackProlongation(*seed1,158);
5136 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5137 seed0->Reset(kFALSE);
5138 seed1->Reset(kFALSE);
5139 seed0->ResetCovariance();
5140 seed1->ResetCovariance();
5142 first = TMath::Max(row0-20,0);
5143 last = TMath::Min(row0+20,158);
5145 for (Int_t irow=0; irow<20;irow++){
5146 rows[irow] = first +((last-first)*irow)/19;
5148 // store parameters along the track
5150 for (Int_t irow=0;irow<20;irow++){
5151 FollowBackProlongation(*seed0, rows[irow]);
5152 FollowProlongation(*seed1,rows[19-irow]);
5153 new(¶m0[irow]) AliTPCseed(*seed0);
5154 new(¶m1[19-irow]) AliTPCseed(*seed1);
5158 for (Int_t irow=0; irow<19;irow++){
5159 kinks[irow].SetMother(param0[irow]);
5160 kinks[irow].SetDaughter(param1[irow]);
5161 // param0[irow].Dump();
5162 //param1[irow].Dump();
5163 kinks[irow].Update();
5166 // choose kink with biggest change of angle
5169 for (Int_t irow=0;irow<20;irow++){
5170 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5171 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5172 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5173 if ( quality > maxchange){
5174 maxchange = quality;
5181 if (index==-1 || param0[index].fN+param1[index].fN<100){
5186 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5188 kink.SetMother(param0[index]);
5189 kink.SetDaughter(param1[index]);
5191 row0 = GetRowNumber(kink.GetR());
5192 kink.SetTPCRow0(row0);
5193 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5194 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5195 kink.SetIndex(-10,0);
5196 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5197 kink.SetTPCncls(param0[index].fN,0);
5198 kink.SetTPCncls(param1[index].fN,1);
5201 // new (&mother) AliTPCseed(param0[index]);
5202 new (&daughter) AliTPCseed(param1[index]);
5203 daughter.SetLabel(kink.GetLabel(1));
5204 param0[index].Reset(kTRUE);
5205 FollowProlongation(param0[index],0);
5206 new (&mother) AliTPCseed(param0[index]);
5207 mother.SetLabel(kink.GetLabel(0));
5217 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5220 // reseed - refit - track
5223 // Int_t last = fSectors->GetNRows()-1;
5225 if (fSectors == fOuterSec){
5226 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5230 first = t->fFirstPoint;
5232 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5233 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5235 FollowProlongation(*t,first);
5245 //_____________________________________________________________________________
5246 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5247 //-----------------------------------------------------------------
5248 // This function reades track seeds.
5249 //-----------------------------------------------------------------
5250 TDirectory *savedir=gDirectory;
5252 TFile *in=(TFile*)inp;
5253 if (!in->IsOpen()) {
5254 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5259 TTree *seedTree=(TTree*)in->Get("Seeds");
5261 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5262 cerr<<"can't get a tree with track seeds !\n";
5265 AliTPCtrack *seed=new AliTPCtrack;
5266 seedTree->SetBranchAddress("tracks",&seed);
5268 if (fSeeds==0) fSeeds=new TObjArray(15000);
5270 Int_t n=(Int_t)seedTree->GetEntries();
5271 for (Int_t i=0; i<n; i++) {
5272 seedTree->GetEvent(i);
5273 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5282 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5285 if (fSeeds) DeleteSeeds();
5288 if (!fSeeds) return 1;
5295 //_____________________________________________________________________________
5296 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5297 //-----------------------------------------------------------------
5298 // This is a track finder.
5299 //-----------------------------------------------------------------
5300 TDirectory *savedir=gDirectory;
5304 fSeeds = Tracking();
5307 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5309 //activate again some tracks
5310 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5311 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5313 Int_t nc=t.GetNumberOfClusters();
5315 delete fSeeds->RemoveAt(i);
5319 if (pt->fRemoval==10) {
5320 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5321 pt->Desactivate(10); // make track again active
5323 pt->Desactivate(20);
5324 delete fSeeds->RemoveAt(i);
5329 RemoveUsed2(fSeeds,0.85,0.85,0);
5330 FindKinks(fSeeds,fEvent);
5331 RemoveUsed2(fSeeds,0.5,0.4,20);
5333 // // refit short tracks
5335 Int_t nseed=fSeeds->GetEntriesFast();
5336 // for (Int_t i=0; i<nseed; i++) {
5337 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5338 // if (!pt) continue;
5339 // Int_t nc=t.GetNumberOfClusters();
5341 // delete fSeeds->RemoveAt(i);
5344 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5345 // if (nc>100) continue; // hopefully, enough for ITS
5346 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5347 // //seed2->Reset(kFALSE);
5348 // //pt->ResetCovariance();
5349 // seed2->Modify(1);
5350 // FollowBackProlongation(*seed2,158);
5351 // //seed2->Reset(kFALSE);
5352 // seed2->Modify(10);
5353 // FollowProlongation(*seed2,0);
5354 // TTreeSRedirector &cstream = *fDebugStreamer;
5355 // cstream<<"Crefit"<<
5359 // if (seed2->fN>pt->fN){
5360 // delete fSeeds->RemoveAt(i);
5361 // fSeeds->AddAt(seed2,i);
5366 // RemoveUsed2(fSeeds,0.6,0.6,50);
5368 // FindV0s(fSeeds,fEvent);
5369 //RemoveDouble(fSeeds,0.2,0.6,11);
5373 for (Int_t i=0; i<nseed; i++) {
5374 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5376 Int_t nc=t.GetNumberOfClusters();
5378 delete fSeeds->RemoveAt(i);
5381 CookLabel(pt,0.1); //For comparison only
5382 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5383 if ((pt->IsActive() || (pt->fRemoval==10) )){
5385 if (fDebug>0) cerr<<found<<'\r';
5389 delete fSeeds->RemoveAt(i);
5393 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5395 //RemoveUsed(fSeeds,0.9,0.9,6);
5397 nseed=fSeeds->GetEntriesFast();
5399 for (Int_t i=0; i<nseed; i++) {
5400 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5402 Int_t nc=t.GetNumberOfClusters();
5404 delete fSeeds->RemoveAt(i);
5408 t.CookdEdx(0.02,0.6);
5409 // CheckKinkPoint(&t,0.05);
5410 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5411 if ((pt->IsActive() || (pt->fRemoval==10) )){
5419 delete fSeeds->RemoveAt(i);
5420 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5422 // FollowProlongation(*seed1,0);
5423 // Int_t n = seed1->GetNumberOfClusters();
5424 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5425 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5428 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5432 SortTracks(fSeeds, 1);
5436 PrepareForBackProlongation(fSeeds,5.);
5437 PropagateBack(fSeeds);
5438 printf("Time for back propagation: \t");timer.Print();timer.Start();
5442 PrepareForProlongation(fSeeds,5.);
5443 PropagateForward2(fSeeds);
5445 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5446 // RemoveUsed(fSeeds,0.7,0.7,6);
5447 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5449 nseed=fSeeds->GetEntriesFast();
5451 for (Int_t i=0; i<nseed; i++) {
5452 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5454 Int_t nc=t.GetNumberOfClusters();
5456 delete fSeeds->RemoveAt(i);
5459 t.CookdEdx(0.02,0.6);
5460 // CookLabel(pt,0.1); //For comparison only
5461 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5462 if ((pt->IsActive() || (pt->fRemoval==10) )){
5463 cerr<<found++<<'\r';
5466 delete fSeeds->RemoveAt(i);
5471 // fNTracks = found;
5473 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5476 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5477 Info("Clusters2Tracks","Number of found tracks %d",found);
5479 // UnloadClusters();
5484 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5487 // tracking of the seeds
5490 fSectors = fOuterSec;
5491 ParallelTracking(arr,150,63);
5492 fSectors = fOuterSec;
5493 ParallelTracking(arr,63,0);
5496 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5501 TObjArray * arr = new TObjArray;
5503 fSectors = fOuterSec;
5506 for (Int_t sec=0;sec<fkNOS;sec++){
5507 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5508 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5509 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5512 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5524 TObjArray * AliTPCtrackerMI::Tracking()
5530 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5532 TObjArray * seeds = new TObjArray;
5541 Float_t fnumber = 3.0;
5542 Float_t fdensity = 3.0;
5547 for (Int_t delta = 0; delta<18; delta+=6){
5551 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5552 SumTracks(seeds,arr);
5553 SignClusters(seeds,fnumber,fdensity);
5555 for (Int_t i=2;i<6;i+=2){
5556 // seed high pt tracks
5559 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5560 SumTracks(seeds,arr);
5561 SignClusters(seeds,fnumber,fdensity);
5566 // RemoveUsed(seeds,0.9,0.9,1);
5567 // UnsignClusters();
5568 // SignClusters(seeds,fnumber,fdensity);
5572 for (Int_t delta = 20; delta<120; delta+=10){
5574 // seed high pt tracks
5578 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5579 SumTracks(seeds,arr);
5580 SignClusters(seeds,fnumber,fdensity);
5585 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5586 SumTracks(seeds,arr);
5587 SignClusters(seeds,fnumber,fdensity);
5598 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5602 // RemoveUsed(seeds,0.75,0.75,1);
5604 //SignClusters(seeds,fnumber,fdensity);
5613 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5614 SumTracks(seeds,arr);
5615 SignClusters(seeds,fnumber,fdensity);
5617 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5618 SumTracks(seeds,arr);
5619 SignClusters(seeds,fnumber,fdensity);
5621 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5622 SumTracks(seeds,arr);
5623 SignClusters(seeds,fnumber,fdensity);
5627 for (Int_t delta = 3; delta<30; delta+=5){
5633 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5634 SumTracks(seeds,arr);
5635 SignClusters(seeds,fnumber,fdensity);
5637 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5638 SumTracks(seeds,arr);
5639 SignClusters(seeds,fnumber,fdensity);
5651 for (Int_t delta = 30; delta<90; delta+=10){
5657 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5658 SumTracks(seeds,arr);
5659 SignClusters(seeds,fnumber,fdensity);
5661 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5662 SumTracks(seeds,arr);
5663 SignClusters(seeds,fnumber,fdensity);
5667 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5678 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5681 //sum tracks to common container
5682 //remove suspicious tracks
5683 Int_t nseed = arr2->GetEntriesFast();
5684 for (Int_t i=0;i<nseed;i++){
5685 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5688 // NORMAL ACTIVE TRACK
5689 if (pt->IsActive()){
5690 arr1->AddLast(arr2->RemoveAt(i));
5693 //remove not usable tracks
5694 if (pt->fRemoval!=10){
5695 delete arr2->RemoveAt(i);
5698 // REMOVE VERY SHORT TRACKS
5699 if (pt->GetNumberOfClusters()<20){
5700 delete arr2->RemoveAt(i);
5703 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5704 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5705 arr1->AddLast(arr2->RemoveAt(i));
5707 delete arr2->RemoveAt(i);
5716 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5719 // try to track in parralel
5721 Int_t nseed=arr->GetEntriesFast();
5722 //prepare seeds for tracking
5723 for (Int_t i=0; i<nseed; i++) {
5724 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5726 if (!t.IsActive()) continue;
5727 // follow prolongation to the first layer
5728 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5729 FollowProlongation(t, rfirst+1);
5734 for (Int_t nr=rfirst; nr>=rlast; nr--){
5735 if (nr<fInnerSec->GetNRows())
5736 fSectors = fInnerSec;
5738 fSectors = fOuterSec;
5739 // make indexes with the cluster tracks for given
5741 // find nearest cluster
5742 for (Int_t i=0; i<nseed; i++) {
5743 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5745 if (nr==80) pt->UpdateReference();
5746 if (!pt->IsActive()) continue;
5747 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5748 if (pt->fRelativeSector>17) {
5751 UpdateClusters(t,nr);
5753 // prolonagate to the nearest cluster - if founded
5754 for (Int_t i=0; i<nseed; i++) {
5755 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5757 if (!pt->IsActive()) continue;
5758 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5759 if (pt->fRelativeSector>17) {
5762 FollowToNextCluster(*pt,nr);
5767 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5771 // if we use TPC track itself we have to "update" covariance
5773 Int_t nseed= arr->GetEntriesFast();
5774 for (Int_t i=0;i<nseed;i++){
5775 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5779 //rotate to current local system at first accepted point
5780 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5781 Int_t sec = (index&0xff000000)>>24;
5783 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5784 if (angle1>TMath::Pi())
5785 angle1-=2.*TMath::Pi();
5786 Float_t angle2 = pt->GetAlpha();
5788 if (TMath::Abs(angle1-angle2)>0.001){
5789 pt->Rotate(angle1-angle2);
5790 //angle2 = pt->GetAlpha();
5791 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5792 //if (pt->GetAlpha()<0)
5793 // pt->fRelativeSector+=18;
5794 //sec = pt->fRelativeSector;
5803 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5807 // if we use TPC track itself we have to "update" covariance
5809 Int_t nseed= arr->GetEntriesFast();
5810 for (Int_t i=0;i<nseed;i++){
5811 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5814 pt->fFirstPoint = pt->fLastPoint;
5822 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5825 // make back propagation
5827 Int_t nseed= arr->GetEntriesFast();
5828 for (Int_t i=0;i<nseed;i++){
5829 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5830 if (pt&& pt->GetKinkIndex(0)<=0) {
5831 //AliTPCseed *pt2 = new AliTPCseed(*pt);
5832 fSectors = fInnerSec;
5833 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5834 //fSectors = fOuterSec;
5835 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5836 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
5837 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
5838 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5841 if (pt&& pt->GetKinkIndex(0)>0) {
5842 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
5843 pt->fFirstPoint = kink->GetTPCRow0();
5844 fSectors = fInnerSec;
5845 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5853 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5856 // make forward propagation
5858 Int_t nseed= arr->GetEntriesFast();
5860 for (Int_t i=0;i<nseed;i++){
5861 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5863 FollowProlongation(*pt,0);
5870 Int_t AliTPCtrackerMI::PropagateForward()
5873 // propagate track forward
5875 Int_t nseed = fSeeds->GetEntriesFast();
5876 for (Int_t i=0;i<nseed;i++){
5877 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5879 AliTPCseed &t = *pt;
5880 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5881 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5882 if (alpha < 0. ) alpha += 2.*TMath::Pi();
5883 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
5887 fSectors = fOuterSec;
5888 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
5889 fSectors = fInnerSec;
5890 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
5900 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
5903 // make back propagation, in between row0 and row1
5907 fSectors = fInnerSec;
5910 if (row1<fSectors->GetNRows())
5913 r1 = fSectors->GetNRows()-1;
5915 if (row0<fSectors->GetNRows()&& r1>0 )
5916 FollowBackProlongation(*pt,r1);
5917 if (row1<=fSectors->GetNRows())
5920 r1 = row1 - fSectors->GetNRows();
5921 if (r1<=0) return 0;
5922 if (r1>=fOuterSec->GetNRows()) return 0;
5923 fSectors = fOuterSec;
5924 return FollowBackProlongation(*pt,r1);
5932 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
5936 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
5937 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
5938 Float_t padlength = GetPadPitchLength(row);
5940 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
5941 Float_t angulary = seed->GetSnp();
5942 angulary = angulary*angulary/(1-angulary*angulary);
5943 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
5945 Float_t sresz = fParam->GetZSigma();
5946 Float_t angularz = seed->GetTgl();
5947 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
5949 Float_t wy = GetSigmaY(seed);
5950 Float_t wz = GetSigmaZ(seed);
5953 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
5954 printf("problem\n");
5960 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
5964 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
5965 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
5966 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
5967 Float_t angular = seed->GetSnp();
5968 angular = angular*angular/(1-angular*angular);
5969 // angular*=angular;
5970 //angular = TMath::Sqrt(angular/(1-angular));
5971 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
5974 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
5978 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
5979 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
5980 Float_t sres = fParam->GetZSigma();
5981 Float_t angular = seed->GetTgl();
5982 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
5987 //__________________________________________________________________________
5988 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
5989 //--------------------------------------------------------------------
5990 //This function "cooks" a track label. If label<0, this track is fake.
5991 //--------------------------------------------------------------------
5992 AliTPCseed * t = (AliTPCseed*)tk;
5993 Int_t noc=t->GetNumberOfClusters();
5995 //printf("\nnot founded prolongation\n\n\n");
6001 AliTPCclusterMI *clusters[160];
6003 for (Int_t i=0;i<160;i++) {
6010 for (i=0; i<160 && current<noc; i++) {
6012 Int_t index=t->GetClusterIndex2(i);
6013 if (index<=0) continue;
6014 if (index&0x8000) continue;
6016 //clusters[current]=GetClusterMI(index);
6017 if (t->fClusterPointer[i]){
6018 clusters[current]=t->fClusterPointer[i];
6024 Int_t lab=123456789;
6025 for (i=0; i<noc; i++) {
6026 AliTPCclusterMI *c=clusters[i];
6028 lab=TMath::Abs(c->GetLabel(0));
6030 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6036 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6038 for (i=0; i<noc; i++) {
6039 AliTPCclusterMI *c=clusters[i];
6041 if (TMath::Abs(c->GetLabel(1)) == lab ||
6042 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6045 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6048 Int_t tail=Int_t(0.10*noc);
6051 for (i=1; i<=160&&ind<tail; i++) {
6052 // AliTPCclusterMI *c=clusters[noc-i];
6053 AliTPCclusterMI *c=clusters[i];
6055 if (lab == TMath::Abs(c->GetLabel(0)) ||
6056 lab == TMath::Abs(c->GetLabel(1)) ||
6057 lab == TMath::Abs(c->GetLabel(2))) max++;
6060 if (max < Int_t(0.5*tail)) lab=-lab;
6067 //delete[] clusters;
6071 //__________________________________________________________________________
6072 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6073 //--------------------------------------------------------------------
6074 //This function "cooks" a track label. If label<0, this track is fake.
6075 //--------------------------------------------------------------------
6076 Int_t noc=t->GetNumberOfClusters();
6078 //printf("\nnot founded prolongation\n\n\n");
6084 AliTPCclusterMI *clusters[160];
6086 for (Int_t i=0;i<160;i++) {
6093 for (i=0; i<160 && current<noc; i++) {
6094 if (i<first) continue;
6095 if (i>last) continue;
6096 Int_t index=t->GetClusterIndex2(i);
6097 if (index<=0) continue;
6098 if (index&0x8000) continue;
6100 //clusters[current]=GetClusterMI(index);
6101 if (t->fClusterPointer[i]){
6102 clusters[current]=t->fClusterPointer[i];
6107 if (noc<5) return -1;
6108 Int_t lab=123456789;
6109 for (i=0; i<noc; i++) {
6110 AliTPCclusterMI *c=clusters[i];
6112 lab=TMath::Abs(c->GetLabel(0));
6114 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6120 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6122 for (i=0; i<noc; i++) {
6123 AliTPCclusterMI *c=clusters[i];
6125 if (TMath::Abs(c->GetLabel(1)) == lab ||
6126 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6129 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6132 Int_t tail=Int_t(0.10*noc);
6135 for (i=1; i<=160&&ind<tail; i++) {
6136 // AliTPCclusterMI *c=clusters[noc-i];
6137 AliTPCclusterMI *c=clusters[i];
6139 if (lab == TMath::Abs(c->GetLabel(0)) ||
6140 lab == TMath::Abs(c->GetLabel(1)) ||
6141 lab == TMath::Abs(c->GetLabel(2))) max++;
6144 if (max < Int_t(0.5*tail)) lab=-lab;
6147 // t->SetLabel(lab);
6151 //delete[] clusters;
6155 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6157 //return pad row number for this x
6160 r=fRow[fN-1].GetX();
6161 if (x > r) return fN;
6163 if (x < r) return -1;
6164 return Int_t((x-r)/fPadPitchLength + 0.5);}
6166 r=fRow[fN-1].GetX();
6167 if (x > r) return fN;
6169 if (x < r) return -1;
6170 Double_t r1=fRow[64].GetX();
6172 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6174 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6178 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6180 //return pad row number for given x vector
6181 Float_t phi = TMath::ATan2(x[1],x[0]);
6182 if(phi<0) phi=2.*TMath::Pi()+phi;
6183 // Get the local angle in the sector philoc
6184 const Float_t kRaddeg = 180/3.14159265358979312;
6185 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6186 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6187 return GetRowNumber(localx);
6190 //_________________________________________________________________________
6191 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6192 //-----------------------------------------------------------------------
6193 // Setup inner sector
6194 //-----------------------------------------------------------------------
6196 fAlpha=par->GetInnerAngle();
6197 fAlphaShift=par->GetInnerAngleShift();
6198 fPadPitchWidth=par->GetInnerPadPitchWidth();
6199 fPadPitchLength=par->GetInnerPadPitchLength();
6200 fN=par->GetNRowLow();
6201 fRow=new AliTPCRow[fN];
6202 for (Int_t i=0; i<fN; i++) {
6203 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6204 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6207 fAlpha=par->GetOuterAngle();
6208 fAlphaShift=par->GetOuterAngleShift();
6209 fPadPitchWidth = par->GetOuterPadPitchWidth();
6210 fPadPitchLength = par->GetOuter1PadPitchLength();
6211 f1PadPitchLength = par->GetOuter1PadPitchLength();
6212 f2PadPitchLength = par->GetOuter2PadPitchLength();
6214 fN=par->GetNRowUp();
6215 fRow=new AliTPCRow[fN];
6216 for (Int_t i=0; i<fN; i++) {
6217 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6218 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6223 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6225 // default constructor
6233 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6240 //_________________________________________________________________________
6242 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6243 //-----------------------------------------------------------------------
6244 // Insert a cluster into this pad row in accordence with its y-coordinate
6245 //-----------------------------------------------------------------------
6246 if (fN==kMaxClusterPerRow) {
6247 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6249 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6250 Int_t i=Find(c->GetZ());
6251 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6252 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6253 fIndex[i]=index; fClusters[i]=c; fN++;
6256 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6262 //delete[] fClusterArray;
6263 if (fClusters1) delete []fClusters1;
6264 if (fClusters2) delete []fClusters2;
6271 //___________________________________________________________________
6272 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6273 //-----------------------------------------------------------------------
6274 // Return the index of the nearest cluster
6275 //-----------------------------------------------------------------------
6276 if (fN==0) return 0;
6277 if (z <= fClusters[0]->GetZ()) return 0;
6278 if (z > fClusters[fN-1]->GetZ()) return fN;
6279 Int_t b=0, e=fN-1, m=(b+e)/2;
6280 for (; b<e; m=(b+e)/2) {
6281 if (z > fClusters[m]->GetZ()) b=m+1;
6289 //___________________________________________________________________
6290 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6291 //-----------------------------------------------------------------------
6292 // Return the index of the nearest cluster in z y
6293 //-----------------------------------------------------------------------
6294 Float_t maxdistance = roady*roady + roadz*roadz;
6296 AliTPCclusterMI *cl =0;
6297 for (Int_t i=Find(z-roadz); i<fN; i++) {
6298 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6299 if (c->GetZ() > z+roadz) break;
6300 if ( (c->GetY()-y) > roady ) continue;
6301 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6302 if (maxdistance>distance) {
6303 maxdistance = distance;
6310 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6312 //-----------------------------------------------------------------------
6313 // Return the index of the nearest cluster in z y
6314 //-----------------------------------------------------------------------
6315 Float_t maxdistance = roady*roady + roadz*roadz;
6316 AliTPCclusterMI *cl =0;
6318 //PH Check boundaries. 510 is the size of fFastCluster
6319 Int_t iz1 = Int_t(z-roadz+254.5);
6320 if (iz1<0 || iz1>=510) return cl;
6321 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6322 Int_t iz2 = Int_t(z+roadz+255.5);
6323 if (iz2<0 || iz2>=510) return cl;
6324 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6326 //FindNearest3(y,z,roady,roadz,index);
6327 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6328 for (Int_t i=iz1; i<iz2; i++) {
6329 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6330 if (c->GetZ() > z+roadz) break;
6331 if ( c->GetY()-y > roady ) continue;
6332 if ( y-c->GetY() > roady ) continue;
6333 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6334 if (maxdistance>distance) {
6335 maxdistance = distance;
6338 //roady = TMath::Sqrt(maxdistance);
6346 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6348 //-----------------------------------------------------------------------
6349 // Return the index of the nearest cluster in z y
6350 //-----------------------------------------------------------------------
6351 Float_t maxdistance = roady*roady + roadz*roadz;
6352 // Int_t iz = Int_t(z+255.);
6353 AliTPCclusterMI *cl =0;
6354 for (Int_t i=Find(z-roadz); i<fN; i++) {
6355 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6356 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6357 if (c->GetZ() > z+roadz) break;
6358 if ( c->GetY()-y > roady ) continue;
6359 if ( y-c->GetY() > roady ) continue;
6360 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6361 if (maxdistance>distance) {
6362 maxdistance = distance;
6365 //roady = TMath::Sqrt(maxdistance);
6375 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6379 // return &fTrackPoints[i];