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
23 //-------------------------------------------------------
28 #include "Riostream.h"
29 #include <TClonesArray.h>
31 #include <TObjArray.h>
35 #include "AliComplexCluster.h"
40 #include "AliRunLoader.h"
41 #include "AliTPCClustersRow.h"
42 #include "AliTPCParam.h"
43 #include "AliTPCReconstructor.h"
44 #include "AliTPCclusterMI.h"
45 #include "AliTPCpolyTrack.h"
46 #include "AliTPCreco.h"
47 #include "AliTPCseed.h"
48 #include "AliTPCtrackerMI.h"
49 #include "TStopwatch.h"
50 #include "AliTPCReconstructor.h"
52 #include "TTreeStream.h"
53 #include "AliAlignObj.h"
54 #include "AliTrackPointArray.h"
58 ClassImp(AliTPCtrackerMI)
61 class AliTPCFastMath {
64 static Double_t FastAsin(Double_t x);
66 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
69 Double_t AliTPCFastMath::fgFastAsin[20000];
70 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
72 AliTPCFastMath::AliTPCFastMath(){
74 // initialized lookup table;
75 for (Int_t i=0;i<10000;i++){
76 fgFastAsin[2*i] = TMath::ASin(i/10000.);
77 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
81 Double_t AliTPCFastMath::FastAsin(Double_t x){
83 // return asin using lookup table
85 Int_t index = int(x*10000);
86 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
89 Int_t index = int(x*10000);
90 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
96 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
98 //update track information using current cluster - track->fCurrentCluster
101 AliTPCclusterMI* c =track->fCurrentCluster;
102 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
104 UInt_t i = track->fCurrentClusterIndex1;
106 Int_t sec=(i&0xff000000)>>24;
107 //Int_t row = (i&0x00ff0000)>>16;
108 track->fRow=(i&0x00ff0000)>>16;
109 track->fSector = sec;
110 // Int_t index = i&0xFFFF;
111 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
112 track->SetClusterIndex2(track->fRow, i);
113 //track->fFirstPoint = row;
114 //if ( track->fLastPoint<row) track->fLastPoint =row;
115 // if (track->fRow<0 || track->fRow>160) {
116 // printf("problem\n");
118 if (track->fFirstPoint>track->fRow)
119 track->fFirstPoint = track->fRow;
120 if (track->fLastPoint<track->fRow)
121 track->fLastPoint = track->fRow;
124 track->fClusterPointer[track->fRow] = c;
127 Double_t angle2 = track->GetSnp()*track->GetSnp();
129 //SET NEW Track Point
131 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
133 angle2 = TMath::Sqrt(angle2/(1-angle2));
134 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
136 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
137 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
138 point.SetErrY(sqrt(track->fErrorY2));
139 point.SetErrZ(sqrt(track->fErrorZ2));
141 point.SetX(track->GetX());
142 point.SetY(track->GetY());
143 point.SetZ(track->GetZ());
144 point.SetAngleY(angle2);
145 point.SetAngleZ(track->GetTgl());
146 if (point.fIsShared){
147 track->fErrorY2 *= 4;
148 track->fErrorZ2 *= 4;
152 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
154 track->fErrorY2 *= 1.3;
155 track->fErrorY2 += 0.01;
156 track->fErrorZ2 *= 1.3;
157 track->fErrorZ2 += 0.005;
159 if (accept>0) return 0;
160 if (track->GetNumberOfClusters()%20==0){
161 // if (track->fHelixIn){
162 // TClonesArray & larr = *(track->fHelixIn);
163 // Int_t ihelix = larr.GetEntriesFast();
164 // new(larr[ihelix]) AliHelix(*track) ;
167 track->fNoCluster =0;
168 return track->Update(c,chi2,i);
173 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
174 Float_t cory, Float_t corz)
177 // decide according desired precision to accept given
178 // cluster for tracking
179 Double_t sy2=ErrY2(seed,cluster)*cory;
180 Double_t sz2=ErrZ2(seed,cluster)*corz;
181 //sy2=ErrY2(seed,cluster)*cory;
182 //sz2=ErrZ2(seed,cluster)*cory;
184 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
185 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
187 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
188 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
189 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
190 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
192 Double_t rdistance2 = rdistancey2+rdistancez2;
195 if (rdistance2>16) return 3;
198 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
199 return 2; //suspisiouce - will be changed
201 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
202 // strict cut on overlaped cluster
203 return 2; //suspisiouce - will be changed
205 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
206 && cluster->GetType()<0){
216 //_____________________________________________________________________________
217 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
218 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
220 //---------------------------------------------------------------------
221 // The main TPC tracker constructor
222 //---------------------------------------------------------------------
223 fInnerSec=new AliTPCSector[fkNIS];
224 fOuterSec=new AliTPCSector[fkNOS];
227 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
228 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
235 Int_t nrowlow = par->GetNRowLow();
236 Int_t nrowup = par->GetNRowUp();
239 for (Int_t i=0;i<nrowlow;i++){
240 fXRow[i] = par->GetPadRowRadiiLow(i);
241 fPadLength[i]= par->GetPadPitchLength(0,i);
242 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
246 for (Int_t i=0;i<nrowup;i++){
247 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
248 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
249 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
260 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
262 //________________________________________________________________________
263 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
268 //------------------------------------
269 // dummy copy constructor
270 //------------------------------------------------------------------
272 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
273 //------------------------------
275 //--------------------------------------------------------------
278 //_____________________________________________________________________________
279 AliTPCtrackerMI::~AliTPCtrackerMI() {
280 //------------------------------------------------------------------
281 // TPC tracker destructor
282 //------------------------------------------------------------------
289 if (fDebugStreamer) delete fDebugStreamer;
292 void AliTPCtrackerMI::SetIO()
296 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
298 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
300 AliTPCtrack *iotrack= new AliTPCtrack;
301 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
307 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
323 AliTPCtrack *iotrack= new AliTPCtrack;
324 // iotrack->fHelixIn = new TClonesArray("AliHelix");
325 //iotrack->fHelixOut = new TClonesArray("AliHelix");
326 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
329 if (output && (fDebug&2)){
330 //write the full seed information if specified in debug mode
332 fSeedTree = new TTree("Seeds","Seeds");
333 AliTPCseed * vseed = new AliTPCseed;
335 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
336 arrtr->ExpandCreateFast(160);
337 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
339 vseed->fPoints = arrtr;
340 vseed->fEPoints = arre;
341 // vseed->fClusterPoints = arrcl;
342 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
345 fTreeDebug = new TTree("trackDebug","trackDebug");
346 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
347 fTreeDebug->Branch("debug",&arrd,32000,99);
355 void AliTPCtrackerMI::FillESD(TObjArray* arr)
359 //fill esds using updated tracks
361 // write tracks to the event
362 // store index of the track
363 Int_t nseed=arr->GetEntriesFast();
364 //FindKinks(arr,fEvent);
365 for (Int_t i=0; i<nseed; i++) {
366 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
369 // pt->PropagateTo(fParam->GetInnerRadiusLow());
370 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
371 pt->PropagateTo(fParam->GetInnerRadiusLow());
374 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
376 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
377 iotrack.SetTPCPoints(pt->GetPoints());
378 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
379 iotrack.SetV0Indexes(pt->GetV0Indexes());
380 // iotrack.SetTPCpid(pt->fTPCr);
381 //iotrack.SetTPCindex(i);
382 fEvent->AddTrack(&iotrack);
386 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
388 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
389 iotrack.SetTPCPoints(pt->GetPoints());
390 //iotrack.SetTPCindex(i);
391 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
392 iotrack.SetV0Indexes(pt->GetV0Indexes());
393 // iotrack.SetTPCpid(pt->fTPCr);
394 fEvent->AddTrack(&iotrack);
398 // short tracks - maybe decays
400 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
401 Int_t found,foundable,shared;
402 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
403 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
405 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
406 //iotrack.SetTPCindex(i);
407 iotrack.SetTPCPoints(pt->GetPoints());
408 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
409 iotrack.SetV0Indexes(pt->GetV0Indexes());
410 //iotrack.SetTPCpid(pt->fTPCr);
411 fEvent->AddTrack(&iotrack);
416 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
417 Int_t found,foundable,shared;
418 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
419 if (found<20) continue;
420 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
423 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
424 iotrack.SetTPCPoints(pt->GetPoints());
425 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
426 iotrack.SetV0Indexes(pt->GetV0Indexes());
427 //iotrack.SetTPCpid(pt->fTPCr);
428 //iotrack.SetTPCindex(i);
429 fEvent->AddTrack(&iotrack);
432 // short tracks - secondaties
434 if ( (pt->GetNumberOfClusters()>30) ) {
435 Int_t found,foundable,shared;
436 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
437 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
439 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
440 iotrack.SetTPCPoints(pt->GetPoints());
441 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
442 iotrack.SetV0Indexes(pt->GetV0Indexes());
443 //iotrack.SetTPCpid(pt->fTPCr);
444 //iotrack.SetTPCindex(i);
445 fEvent->AddTrack(&iotrack);
450 if ( (pt->GetNumberOfClusters()>15)) {
451 Int_t found,foundable,shared;
452 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
453 if (found<15) continue;
454 if (foundable<=0) 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 Double_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 Double_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);
1131 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1132 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1135 AliTPCRow * tpcrow=0;
1138 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1142 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1143 left = (sec-fkNIS*2)/fkNOS;
1146 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1147 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1148 for (Int_t i=0;i<tpcrow->fN1;i++)
1149 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1152 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1153 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1154 for (Int_t i=0;i<tpcrow->fN2;i++)
1155 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1166 void AliTPCtrackerMI::UnloadClusters()
1169 // unload clusters from the memory
1171 Int_t nrows = fOuterSec->GetNRows();
1172 for (Int_t sec = 0;sec<fkNOS;sec++)
1173 for (Int_t row = 0;row<nrows;row++){
1174 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1176 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1177 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1179 tpcrow->ResetClusters();
1182 nrows = fInnerSec->GetNRows();
1183 for (Int_t sec = 0;sec<fkNIS;sec++)
1184 for (Int_t row = 0;row<nrows;row++){
1185 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1187 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1188 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1190 tpcrow->ResetClusters();
1196 void AliTPCtrackerMI::Transform(AliCluster * cluster){
1200 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1201 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1203 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1205 //mat.LocalToMaster(pos,posC);
1206 mat->LocalToMaster(pos,posC);
1207 cluster->SetX(posC[0]);
1208 cluster->SetY(posC[1]);
1209 cluster->SetZ(posC[2]);
1212 //_____________________________________________________________________________
1213 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1214 //-----------------------------------------------------------------
1215 // This function fills outer TPC sectors with clusters.
1216 //-----------------------------------------------------------------
1217 Int_t nrows = fOuterSec->GetNRows();
1219 for (Int_t sec = 0;sec<fkNOS;sec++)
1220 for (Int_t row = 0;row<nrows;row++){
1221 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1222 Int_t sec2 = sec+2*fkNIS;
1224 Int_t ncl = tpcrow->fN1;
1226 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1227 index=(((sec2<<8)+row)<<16)+ncl;
1228 tpcrow->InsertCluster(c,index);
1233 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1234 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1235 tpcrow->InsertCluster(c,index);
1238 // write indexes for fast acces
1240 for (Int_t i=0;i<510;i++)
1241 tpcrow->fFastCluster[i]=-1;
1242 for (Int_t i=0;i<tpcrow->GetN();i++){
1243 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1244 tpcrow->fFastCluster[zi]=i; // write index
1247 for (Int_t i=0;i<510;i++){
1248 if (tpcrow->fFastCluster[i]<0)
1249 tpcrow->fFastCluster[i] = last;
1251 last = tpcrow->fFastCluster[i];
1260 //_____________________________________________________________________________
1261 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1262 //-----------------------------------------------------------------
1263 // This function fills inner TPC sectors with clusters.
1264 //-----------------------------------------------------------------
1265 Int_t nrows = fInnerSec->GetNRows();
1267 for (Int_t sec = 0;sec<fkNIS;sec++)
1268 for (Int_t row = 0;row<nrows;row++){
1269 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1272 Int_t ncl = tpcrow->fN1;
1274 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1275 index=(((sec<<8)+row)<<16)+ncl;
1276 tpcrow->InsertCluster(c,index);
1281 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1282 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1283 tpcrow->InsertCluster(c,index);
1286 // write indexes for fast acces
1288 for (Int_t i=0;i<510;i++)
1289 tpcrow->fFastCluster[i]=-1;
1290 for (Int_t i=0;i<tpcrow->GetN();i++){
1291 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1292 tpcrow->fFastCluster[zi]=i; // write index
1295 for (Int_t i=0;i<510;i++){
1296 if (tpcrow->fFastCluster[i]<0)
1297 tpcrow->fFastCluster[i] = last;
1299 last = tpcrow->fFastCluster[i];
1311 //_________________________________________________________________________
1312 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1313 //--------------------------------------------------------------------
1314 // Return pointer to a given cluster
1315 //--------------------------------------------------------------------
1316 if (index<0) return 0; // no cluster
1317 Int_t sec=(index&0xff000000)>>24;
1318 Int_t row=(index&0x00ff0000)>>16;
1319 Int_t ncl=(index&0x00007fff)>>00;
1321 const AliTPCRow * tpcrow=0;
1322 AliTPCclusterMI * clrow =0;
1324 if (sec<0 || sec>=fkNIS*4) {
1325 AliWarning(Form("Wrong sector %d",sec));
1330 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1331 if (tpcrow==0) return 0;
1334 if (tpcrow->fN1<=ncl) return 0;
1335 clrow = tpcrow->fClusters1;
1338 if (tpcrow->fN2<=ncl) return 0;
1339 clrow = tpcrow->fClusters2;
1343 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1344 if (tpcrow==0) return 0;
1346 if (sec-2*fkNIS<fkNOS) {
1347 if (tpcrow->fN1<=ncl) return 0;
1348 clrow = tpcrow->fClusters1;
1351 if (tpcrow->fN2<=ncl) return 0;
1352 clrow = tpcrow->fClusters2;
1356 return &(clrow[ncl]);
1362 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1363 //-----------------------------------------------------------------
1364 // This function tries to find a track prolongation to next pad row
1365 //-----------------------------------------------------------------
1367 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1368 AliTPCclusterMI *cl=0;
1369 Int_t tpcindex= t.GetClusterIndex2(nr);
1371 // update current shape info every 5 pad-row
1372 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1376 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1378 if (tpcindex==-1) return 0; //track in dead zone
1380 cl = t.fClusterPointer[nr];
1381 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1382 t.fCurrentClusterIndex1 = tpcindex;
1385 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1386 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1388 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1389 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1391 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1392 Double_t rotation = angle-t.GetAlpha();
1393 t.fRelativeSector= relativesector;
1394 if (!t.Rotate(rotation)) return 0;
1396 if (!t.PropagateTo(x)) return 0;
1398 t.fCurrentCluster = cl;
1400 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1401 if ((tpcindex&0x8000)==0) accept =0;
1403 //if founded cluster is acceptible
1404 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1411 UpdateTrack(&t,accept);
1416 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1418 // not look for new cluster during refitting
1424 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1425 Double_t y=t.GetYat(x);
1426 if (TMath::Abs(y)>ymax){
1428 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1429 if (!t.Rotate(fSectors->GetAlpha()))
1431 } else if (y <-ymax) {
1432 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1433 if (!t.Rotate(-fSectors->GetAlpha()))
1439 if (!t.PropagateTo(x)) {
1440 if (fIteration==0) t.fRemoval = 10;
1444 Double_t z=t.GetZ();
1447 if (!IsActive(t.fRelativeSector,nr)) {
1449 t.SetClusterIndex2(nr,-1);
1452 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1453 Bool_t isActive = IsActive(t.fRelativeSector,nr);
1454 Bool_t isActive2 = (nr>=fInnerSec->GetNRows()) ? fOuterSec[t.fRelativeSector][nr-fInnerSec->GetNRows()].GetN()>0:fInnerSec[t.fRelativeSector][nr].GetN()>0;
1456 if (!isActive || !isActive2) return 0;
1458 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1459 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1461 Double_t roadz = 1.;
1463 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1465 t.SetClusterIndex2(nr,-1);
1470 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1477 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1478 cl = krow.FindNearest2(y,z,roady,roadz,index);
1479 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1482 t.fCurrentCluster = cl;
1484 if (fIteration==2&&cl->IsUsed(10)) return 0;
1485 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1486 if (fIteration==2&&cl->IsUsed(11)) {
1493 if (t.fCurrentCluster->IsUsed(10)){
1498 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1504 if (accept<3) UpdateTrack(&t,accept);
1507 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1513 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1514 //-----------------------------------------------------------------
1515 // This function tries to find a track prolongation to next pad row
1516 //-----------------------------------------------------------------
1518 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1520 if (!t.GetProlongation(x,y,z)) {
1526 if (TMath::Abs(y)>ymax){
1529 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1530 if (!t.Rotate(fSectors->GetAlpha()))
1532 } else if (y <-ymax) {
1533 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1534 if (!t.Rotate(-fSectors->GetAlpha()))
1537 if (!t.PropagateTo(x)) {
1540 t.GetProlongation(x,y,z);
1543 // update current shape info every 3 pad-row
1544 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1545 // t.fCurrentSigmaY = GetSigmaY(&t);
1546 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1550 AliTPCclusterMI *cl=0;
1555 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1556 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1558 Double_t roadz = 1.;
1561 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1563 t.SetClusterIndex2(row,-1);
1568 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1572 if ((cl==0)&&(krow)) {
1573 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1574 cl = krow.FindNearest2(y,z,roady,roadz,index);
1576 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1580 t.fCurrentCluster = cl;
1581 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1583 t.SetClusterIndex2(row,index);
1584 t.fClusterPointer[row] = cl;
1592 //_________________________________________________________________________
1593 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1595 // Get track space point by index
1596 // return false in case the cluster doesn't exist
1597 AliTPCclusterMI *cl = GetClusterMI(index);
1598 if (!cl) return kFALSE;
1599 Int_t sector = (index&0xff000000)>>24;
1600 // Int_t row = (index&0x00ff0000)>>16;
1602 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1603 xyz[0] = cl->GetX();
1604 xyz[1] = cl->GetY();
1605 xyz[2] = cl->GetZ();
1607 fParam->AdjustCosSin(sector,cos,sin);
1608 Float_t x = cos*xyz[0]-sin*xyz[1];
1609 Float_t y = cos*xyz[1]+sin*xyz[0];
1611 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1612 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1613 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1614 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1615 cov[0] = sin*sin*sigmaY2;
1616 cov[1] = -sin*cos*sigmaY2;
1618 cov[3] = cos*cos*sigmaY2;
1621 p.SetXYZ(x,y,xyz[2],cov);
1622 AliAlignObj::ELayerID iLayer;
1624 if (sector < fParam->GetNInnerSector()) {
1625 iLayer = AliAlignObj::kTPC1;
1629 iLayer = AliAlignObj::kTPC2;
1630 idet = sector - fParam->GetNInnerSector();
1632 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1633 p.SetVolumeID(volid);
1639 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1640 //-----------------------------------------------------------------
1641 // This function tries to find a track prolongation to next pad row
1642 //-----------------------------------------------------------------
1643 t.fCurrentCluster = 0;
1644 t.fCurrentClusterIndex1 = 0;
1646 Double_t xt=t.GetX();
1647 Int_t row = GetRowNumber(xt)-1;
1648 Double_t ymax= GetMaxY(nr);
1650 if (row < nr) return 1; // don't prolongate if not information until now -
1651 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1653 // return 0; // not prolongate strongly inclined tracks
1655 // if (TMath::Abs(t.GetSnp())>0.95) {
1657 // return 0; // not prolongate strongly inclined tracks
1658 // }// patch 28 fev 06
1660 Double_t x= GetXrow(nr);
1662 //t.PropagateTo(x+0.02);
1663 //t.PropagateTo(x+0.01);
1664 if (!t.PropagateTo(x)){
1671 if (TMath::Abs(y)>ymax){
1673 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1674 if (!t.Rotate(fSectors->GetAlpha()))
1676 } else if (y <-ymax) {
1677 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1678 if (!t.Rotate(-fSectors->GetAlpha()))
1681 // if (!t.PropagateTo(x)){
1688 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1690 if (!IsActive(t.fRelativeSector,nr)) {
1692 t.SetClusterIndex2(nr,-1);
1695 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1697 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1699 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1701 t.SetClusterIndex2(nr,-1);
1706 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.fNFoundable++;
1712 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1713 // t.fCurrentSigmaY = GetSigmaY(&t);
1714 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1718 AliTPCclusterMI *cl=0;
1721 Double_t roady = 1.;
1722 Double_t roadz = 1.;
1726 index = t.GetClusterIndex2(nr);
1727 if ( (index>0) && (index&0x8000)==0){
1728 cl = t.fClusterPointer[nr];
1729 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1730 t.fCurrentClusterIndex1 = index;
1732 t.fCurrentCluster = cl;
1738 // if (index<0) return 0;
1739 UInt_t uindex = TMath::Abs(index);
1742 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1743 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1746 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1747 t.fCurrentCluster = cl;
1753 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1754 //-----------------------------------------------------------------
1755 // This function tries to find a track prolongation to next pad row
1756 //-----------------------------------------------------------------
1758 //update error according neighborhoud
1760 if (t.fCurrentCluster) {
1762 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1764 if (t.fCurrentCluster->IsUsed(10)){
1770 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1775 if (fIteration>0) accept = 0;
1776 if (accept<3) UpdateTrack(&t,accept);
1780 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1781 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1783 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1791 //_____________________________________________________________________________
1792 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1793 //-----------------------------------------------------------------
1794 // This function tries to find a track prolongation.
1795 //-----------------------------------------------------------------
1796 Double_t xt=t.GetX();
1798 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1799 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1800 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1802 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1804 Int_t first = GetRowNumber(xt)-1;
1805 for (Int_t nr= first; nr>=rf; nr-=step) {
1807 if (t.GetKinkIndexes()[0]>0){
1808 for (Int_t i=0;i<3;i++){
1809 Int_t index = t.GetKinkIndexes()[i];
1810 if (index==0) break;
1811 if (index<0) continue;
1813 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1815 printf("PROBLEM\n");
1818 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1820 AliExternalTrackParam paramd(t);
1821 kink->SetDaughter(paramd);
1822 kink->SetStatus(2,5);
1829 if (nr==80) t.UpdateReference();
1830 if (nr<fInnerSec->GetNRows())
1831 fSectors = fInnerSec;
1833 fSectors = fOuterSec;
1834 if (FollowToNext(t,nr)==0)
1843 //_____________________________________________________________________________
1844 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1845 //-----------------------------------------------------------------
1846 // This function tries to find a track prolongation.
1847 //-----------------------------------------------------------------
1848 Double_t xt=t.GetX();
1850 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1851 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1852 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1853 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1855 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1857 if (FollowToNextFast(t,nr)==0)
1858 if (!t.IsActive()) return 0;
1868 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1869 //-----------------------------------------------------------------
1870 // This function tries to find a track prolongation.
1871 //-----------------------------------------------------------------
1873 Double_t xt=t.GetX();
1874 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1875 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1876 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1877 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1879 Int_t first = t.fFirstPoint;
1880 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1882 if (first<0) first=0;
1883 for (Int_t nr=first; nr<=rf; nr++) {
1884 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1885 if (t.GetKinkIndexes()[0]<0){
1886 for (Int_t i=0;i<3;i++){
1887 Int_t index = t.GetKinkIndexes()[i];
1888 if (index==0) break;
1889 if (index>0) continue;
1890 index = TMath::Abs(index);
1891 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1893 printf("PROBLEM\n");
1896 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1898 AliExternalTrackParam paramm(t);
1899 kink->SetMother(paramm);
1900 kink->SetStatus(2,1);
1907 if (nr<fInnerSec->GetNRows())
1908 fSectors = fInnerSec;
1910 fSectors = fOuterSec;
1921 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1929 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1932 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1934 Float_t distance = TMath::Sqrt(dz2+dy2);
1935 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1938 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1939 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1944 if (firstpoint>lastpoint) {
1945 firstpoint =lastpoint;
1950 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1951 if (s1->GetClusterIndex2(i)>0) sum1++;
1952 if (s2->GetClusterIndex2(i)>0) sum2++;
1953 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1957 if (sum<5) return 0;
1959 Float_t summin = TMath::Min(sum1+1,sum2+1);
1960 Float_t ratio = (sum+1)/Float_t(summin);
1964 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1968 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1969 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1971 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1973 Float_t dy2 =(s1->GetY() - s2->GetY());
1975 Float_t distance = dz2+dy2;
1976 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1981 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1982 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1984 if (firstpoint>=lastpoint-5) return;;
1986 for (Int_t i=firstpoint;i<lastpoint;i++){
1987 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1988 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1995 for (Int_t i=firstpoint;i<lastpoint;i++){
1996 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1997 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1998 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1999 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
2000 if (s1->IsActive()&&s2->IsActive()){
2001 p1->fIsShared = kTRUE;
2002 p2->fIsShared = kTRUE;
2009 for (Int_t i=0;i<4;i++){
2010 if (s1->fOverlapLabels[3*i]==0){
2011 s1->fOverlapLabels[3*i] = s2->GetLabel();
2012 s1->fOverlapLabels[3*i+1] = sumshared;
2013 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
2017 for (Int_t i=0;i<4;i++){
2018 if (s2->fOverlapLabels[3*i]==0){
2019 s2->fOverlapLabels[3*i] = s1->GetLabel();
2020 s2->fOverlapLabels[3*i+1] = sumshared;
2021 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2029 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2032 //sort trackss according sectors
2034 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2035 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2037 //if (pt) RotateToLocal(pt);
2041 arr->Sort(); // sorting according z
2042 arr->Expand(arr->GetEntries());
2045 Int_t nseed=arr->GetEntriesFast();
2046 for (Int_t i=0; i<nseed; i++) {
2047 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2049 for (Int_t j=0;j<=12;j++){
2050 pt->fOverlapLabels[j] =0;
2053 for (Int_t i=0; i<nseed; i++) {
2054 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2056 if (pt->fRemoval>10) continue;
2057 for (Int_t j=i+1; j<nseed; j++){
2058 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2060 if (pt2->fRemoval<=10) {
2061 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2068 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2071 //sort trackss according sectors
2074 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2077 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2078 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2083 arr->Sort(); // sorting according z
2084 arr->Expand(arr->GetEntries());
2086 //reset overlap labels
2088 Int_t nseed=arr->GetEntriesFast();
2089 for (Int_t i=0; i<nseed; i++) {
2090 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2093 for (Int_t j=0;j<=12;j++){
2094 pt->fOverlapLabels[j] =0;
2098 //sign shared tracks
2099 for (Int_t i=0; i<nseed; i++) {
2100 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2102 if (pt->fRemoval>10) continue;
2103 Float_t deltac = pt->GetC()*0.1;
2104 for (Int_t j=i+1; j<nseed; j++){
2105 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2107 if (pt2->fRemoval<=10) {
2108 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2109 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2110 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2117 // remove highly shared tracks
2118 for (Int_t i=0; i<nseed; i++) {
2119 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2121 if (pt->fRemoval>10) continue;
2124 for (Int_t j=0;j<4;j++){
2125 sumshared = pt->fOverlapLabels[j*3+1];
2127 Float_t factor = factor1;
2128 if (pt->fRemoval>0) factor = factor2;
2129 if (sumshared/pt->GetNumberOfClusters()>factor){
2130 for (Int_t j=0;j<4;j++){
2131 if (pt->fOverlapLabels[3*j]==0) continue;
2132 if (pt->fOverlapLabels[3*j+1]<5) continue;
2133 if (pt->fRemoval==removalindex) continue;
2134 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2136 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2137 // pt->fRemoval = removalindex;
2138 delete arr->RemoveAt(i);
2146 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2155 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2158 //sort tracks in array according mode criteria
2159 Int_t nseed = arr->GetEntriesFast();
2160 for (Int_t i=0; i<nseed; i++) {
2161 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2171 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2174 //Loop over all tracks and remove "overlaps"
2177 Int_t nseed = arr->GetEntriesFast();
2180 for (Int_t i=0; i<nseed; i++) {
2181 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2183 delete arr->RemoveAt(i);
2187 pt->fBSigned = kFALSE;
2191 nseed = arr->GetEntriesFast();
2198 for (Int_t i=0; i<nseed; i++) {
2199 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2203 Int_t found,foundable,shared;
2205 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2207 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2209 Double_t factor = factor2;
2210 if (pt->fBConstrain) factor = factor1;
2212 if ((Float_t(shared)/Float_t(found))>factor){
2213 pt->Desactivate(removalindex);
2218 for (Int_t i=0; i<160; i++) {
2219 Int_t index=pt->GetClusterIndex2(i);
2220 if (index<0 || index&0x8000 ) continue;
2221 AliTPCclusterMI *c= pt->fClusterPointer[i];
2223 // if (!c->IsUsed(10)) c->Use(10);
2224 //if (pt->IsActive())
2233 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2238 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2241 //Loop over all tracks and remove "overlaps"
2246 Int_t nseed = arr->GetEntriesFast();
2247 Float_t * quality = new Float_t[nseed];
2248 Int_t * indexes = new Int_t[nseed];
2252 for (Int_t i=0; i<nseed; i++) {
2253 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2258 pt->UpdatePoints(); //select first last max dens points
2259 Float_t * points = pt->GetPoints();
2260 if (points[3]<0.8) quality[i] =-1;
2262 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2264 TMath::Sort(nseed,quality,indexes);
2267 for (Int_t itrack=0; itrack<nseed; itrack++) {
2268 Int_t trackindex = indexes[itrack];
2269 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2270 if (quality[trackindex]<0){
2272 delete arr->RemoveAt(trackindex);
2275 arr->RemoveAt(trackindex);
2280 Int_t first = Int_t(pt->GetPoints()[0]);
2281 Int_t last = Int_t(pt->GetPoints()[2]);
2282 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2284 Int_t found,foundable,shared;
2285 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2286 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2287 Bool_t itsgold =kFALSE;
2290 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
2294 if (Float_t(shared+1)/Float_t(found+1)>factor){
2295 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2296 delete arr->RemoveAt(trackindex);
2299 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2300 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2301 delete arr->RemoveAt(trackindex);
2307 if (sharedfactor>0.4) continue;
2308 if (pt->GetKinkIndexes()[0]>0) continue;
2309 for (Int_t i=first; i<last; i++) {
2310 Int_t index=pt->GetClusterIndex2(i);
2311 // if (index<0 || index&0x8000 ) continue;
2312 if (index<0 || index&0x8000 ) continue;
2313 AliTPCclusterMI *c= pt->fClusterPointer[i];
2320 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2326 void AliTPCtrackerMI::UnsignClusters()
2329 // loop over all clusters and unsign them
2332 for (Int_t sec=0;sec<fkNIS;sec++){
2333 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2334 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2335 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2336 // if (cl[icl].IsUsed(10))
2338 cl = fInnerSec[sec][row].fClusters2;
2339 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2340 //if (cl[icl].IsUsed(10))
2345 for (Int_t sec=0;sec<fkNOS;sec++){
2346 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2347 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2348 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2349 //if (cl[icl].IsUsed(10))
2351 cl = fOuterSec[sec][row].fClusters2;
2352 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2353 //if (cl[icl].IsUsed(10))
2362 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2365 //sign clusters to be "used"
2367 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2368 // loop over "primaries"
2382 Int_t nseed = arr->GetEntriesFast();
2383 for (Int_t i=0; i<nseed; i++) {
2384 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2388 if (!(pt->IsActive())) continue;
2389 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2390 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2392 sumdens2+= dens*dens;
2393 sumn += pt->GetNumberOfClusters();
2394 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2395 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2398 sumchi2 +=chi2*chi2;
2403 Float_t mdensity = 0.9;
2404 Float_t meann = 130;
2405 Float_t meanchi = 1;
2406 Float_t sdensity = 0.1;
2407 Float_t smeann = 10;
2408 Float_t smeanchi =0.4;
2412 mdensity = sumdens/sum;
2414 meanchi = sumchi/sum;
2416 sdensity = sumdens2/sum-mdensity*mdensity;
2417 sdensity = TMath::Sqrt(sdensity);
2419 smeann = sumn2/sum-meann*meann;
2420 smeann = TMath::Sqrt(smeann);
2422 smeanchi = sumchi2/sum - meanchi*meanchi;
2423 smeanchi = TMath::Sqrt(smeanchi);
2427 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2429 for (Int_t i=0; i<nseed; i++) {
2430 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2434 if (pt->fBSigned) continue;
2435 if (pt->fBConstrain) continue;
2436 //if (!(pt->IsActive())) continue;
2438 Int_t found,foundable,shared;
2439 pt->GetClusterStatistic(0,160,found, foundable,shared);
2440 if (shared/float(found)>0.3) {
2441 if (shared/float(found)>0.9 ){
2442 //delete arr->RemoveAt(i);
2447 Bool_t isok =kFALSE;
2448 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2450 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2452 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2454 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2458 for (Int_t i=0; i<160; i++) {
2459 Int_t index=pt->GetClusterIndex2(i);
2460 if (index<0) continue;
2461 AliTPCclusterMI *c= pt->fClusterPointer[i];
2463 //if (!(c->IsUsed(10))) c->Use();
2470 Double_t maxchi = meanchi+2.*smeanchi;
2472 for (Int_t i=0; i<nseed; i++) {
2473 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2477 //if (!(pt->IsActive())) continue;
2478 if (pt->fBSigned) continue;
2479 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2480 if (chi>maxchi) continue;
2483 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2485 //sign only tracks with enoug big density at the beginning
2487 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2490 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2491 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2493 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2494 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2497 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2498 //Int_t noc=pt->GetNumberOfClusters();
2499 pt->fBSigned = kTRUE;
2500 for (Int_t i=0; i<160; i++) {
2502 Int_t index=pt->GetClusterIndex2(i);
2503 if (index<0) continue;
2504 AliTPCclusterMI *c= pt->fClusterPointer[i];
2506 // if (!(c->IsUsed(10))) c->Use();
2511 // gLastCheck = nseed;
2519 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2521 // stop not active tracks
2522 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2523 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2524 Int_t nseed = arr->GetEntriesFast();
2526 for (Int_t i=0; i<nseed; i++) {
2527 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2531 if (!(pt->IsActive())) continue;
2532 StopNotActive(pt,row0,th0, th1,th2);
2538 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2541 // stop not active tracks
2542 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2543 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2546 Int_t foundable = 0;
2547 Int_t maxindex = seed->fLastPoint; //last foundable row
2548 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2549 seed->Desactivate(10) ;
2553 for (Int_t i=row0; i<maxindex; i++){
2554 Int_t index = seed->GetClusterIndex2(i);
2555 if (index!=-1) foundable++;
2557 if (foundable<=30) sumgood1++;
2558 if (foundable<=50) {
2565 if (foundable>=30.){
2566 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2569 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2573 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2576 // back propagation of ESD tracks
2582 //PrepareForProlongation(fSeeds,1);
2583 PropagateForward2(fSeeds);
2586 Int_t nseed = fSeeds->GetEntriesFast();
2587 for (Int_t i=0;i<nseed;i++){
2588 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2589 if (!seed) continue;
2590 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2592 seed->PropagateTo(fParam->GetInnerRadiusLow());
2593 seed->UpdatePoints();
2594 AliESDtrack *esd=event->GetTrack(i);
2595 seed->CookdEdx(0.02,0.6);
2596 CookLabel(seed,0.1); //For comparison only
2598 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2599 TTreeSRedirector &cstream = *fDebugStreamer;
2606 if (seed->GetNumberOfClusters()>15){
2607 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2608 esd->SetTPCPoints(seed->GetPoints());
2609 esd->SetTPCPointsF(seed->fNFoundable);
2610 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2611 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2612 Float_t dedx = seed->GetdEdx();
2613 esd->SetTPCsignal(dedx, sdedx, ndedx);
2615 // add seed to the esd track in Calib level
2617 if (AliTPCReconstructor::StreamLevel()>0){
2618 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2619 esd->AddCalibObject(seedCopy);
2624 //printf("problem\n");
2627 //FindKinks(fSeeds,event);
2628 Info("RefitInward","Number of refitted tracks %d",ntracks);
2635 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2638 // back propagation of ESD tracks
2644 PropagateBack(fSeeds);
2645 RemoveUsed2(fSeeds,0.4,0.4,20);
2647 Int_t nseed = fSeeds->GetEntriesFast();
2649 for (Int_t i=0;i<nseed;i++){
2650 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2651 if (!seed) continue;
2652 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2653 seed->UpdatePoints();
2654 AliESDtrack *esd=event->GetTrack(i);
2655 seed->CookdEdx(0.02,0.6);
2656 CookLabel(seed,0.1); //For comparison only
2657 if (seed->GetNumberOfClusters()>15){
2658 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2659 esd->SetTPCPoints(seed->GetPoints());
2660 esd->SetTPCPointsF(seed->fNFoundable);
2661 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2662 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2663 Float_t dedx = seed->GetdEdx();
2664 esd->SetTPCsignal(dedx, sdedx, ndedx);
2666 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2667 (*fDebugStreamer)<<"Cback"<<
2669 "EventNr="<<eventnumber<<
2670 "\n"; // patch 28 fev 06
2673 //FindKinks(fSeeds,event);
2674 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2682 void AliTPCtrackerMI::DeleteSeeds()
2687 Int_t nseed = fSeeds->GetEntriesFast();
2688 for (Int_t i=0;i<nseed;i++){
2689 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2690 if (seed) delete fSeeds->RemoveAt(i);
2697 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2700 //read seeds from the event
2702 Int_t nentr=event->GetNumberOfTracks();
2704 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2709 fSeeds = new TObjArray(nentr);
2713 for (Int_t i=0; i<nentr; i++) {
2714 AliESDtrack *esd=event->GetTrack(i);
2715 ULong_t status=esd->GetStatus();
2716 if (!(status&AliESDtrack::kTPCin)) continue;
2717 AliTPCtrack t(*esd);
2718 t.SetNumberOfClusters(0);
2719 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2720 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2721 for (Int_t ikink=0;ikink<3;ikink++) {
2722 Int_t index = esd->GetKinkIndex(ikink);
2723 seed->GetKinkIndexes()[ikink] = index;
2724 if (index==0) continue;
2725 index = TMath::Abs(index);
2726 AliESDkink * kink = fEvent->GetKink(index-1);
2727 if (kink&&esd->GetKinkIndex(ikink)<0){
2728 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2729 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2731 if (kink&&esd->GetKinkIndex(ikink)>0){
2732 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2733 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2737 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance(10.);
2738 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance(10.);
2739 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2744 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2745 Double_t par0[5],par1[5],alpha,x;
2746 esd->GetInnerExternalParameters(alpha,x,par0);
2747 esd->GetExternalParameters(x,par1);
2748 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2749 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2751 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2752 //reset covariance if suspicious
2753 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2754 seed->ResetCovariance(10.);
2759 // rotate to the local coordinate system
2761 fSectors=fInnerSec; fN=fkNIS;
2762 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2763 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2764 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2765 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2766 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2767 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2768 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2769 alpha-=seed->GetAlpha();
2770 if (!seed->Rotate(alpha)) {
2776 if (esd->GetKinkIndex(0)<=0){
2777 for (Int_t irow=0;irow<160;irow++){
2778 Int_t index = seed->GetClusterIndex2(irow);
2781 AliTPCclusterMI * cl = GetClusterMI(index);
2782 seed->fClusterPointer[irow] = cl;
2784 if ((index & 0x8000)==0){
2785 cl->Use(10); // accepted cluster
2787 cl->Use(6); // close cluster not accepted
2790 Info("ReadSeeds","Not found cluster");
2795 fSeeds->AddAt(seed,i);
2801 //_____________________________________________________________________________
2802 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2803 Float_t deltay, Int_t ddsec) {
2804 //-----------------------------------------------------------------
2805 // This function creates track seeds.
2806 // SEEDING WITH VERTEX CONSTRAIN
2807 //-----------------------------------------------------------------
2808 // cuts[0] - fP4 cut
2809 // cuts[1] - tan(phi) cut
2810 // cuts[2] - zvertex cut
2811 // cuts[3] - fP3 cut
2819 Double_t x[5], c[15];
2820 // Int_t di = i1-i2;
2822 AliTPCseed * seed = new AliTPCseed;
2823 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2824 Double_t cs=cos(alpha), sn=sin(alpha);
2826 // Double_t x1 =fOuterSec->GetX(i1);
2827 //Double_t xx2=fOuterSec->GetX(i2);
2829 Double_t x1 =GetXrow(i1);
2830 Double_t xx2=GetXrow(i2);
2832 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2834 Int_t imiddle = (i2+i1)/2; //middle pad row index
2835 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2836 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2840 const AliTPCRow& kr1=GetRow(ns,i1);
2841 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2842 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2845 // change cut on curvature if it can't reach this layer
2846 // maximal curvature set to reach it
2847 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2848 if (dvertexmax*0.5*cuts[0]>0.85){
2849 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2851 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2854 if (deltay>0) ddsec = 0;
2855 // loop over clusters
2856 for (Int_t is=0; is < kr1; is++) {
2858 if (kr1[is]->IsUsed(10)) continue;
2859 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2860 //if (TMath::Abs(y1)>ymax) continue;
2862 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2864 // find possible directions
2865 Float_t anglez = (z1-z3)/(x1-x3);
2866 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2869 //find rotation angles relative to line given by vertex and point 1
2870 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2871 Double_t dvertex = TMath::Sqrt(dvertex2);
2872 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2873 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2876 // loop over 2 sectors
2882 Double_t dddz1=0; // direction of delta inclination in z axis
2889 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2890 Int_t sec2 = sec + dsec;
2892 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2893 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2894 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2895 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2896 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2897 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2899 // rotation angles to p1-p3
2900 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2901 Double_t x2, y2, z2;
2903 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2906 Double_t dxx0 = (xx2-x3)*cs13r;
2907 Double_t dyy0 = (xx2-x3)*sn13r;
2908 for (Int_t js=index1; js < index2; js++) {
2909 const AliTPCclusterMI *kcl = kr2[js];
2910 if (kcl->IsUsed(10)) continue;
2912 //calcutate parameters
2914 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2916 if (TMath::Abs(yy0)<0.000001) continue;
2917 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2918 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2919 Double_t r02 = (0.25+y0*y0)*dvertex2;
2920 //curvature (radius) cut
2921 if (r02<r2min) continue;
2925 Double_t c0 = 1/TMath::Sqrt(r02);
2929 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2930 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2931 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2932 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2935 Double_t z0 = kcl->GetZ();
2936 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2937 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2940 Double_t dip = (z1-z0)*c0/dfi1;
2941 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2952 x2= xx2*cs-y2*sn*dsec;
2953 y2=+xx2*sn*dsec+y2*cs;
2963 // do we have cluster at the middle ?
2965 GetProlongation(x1,xm,x,ym,zm);
2967 AliTPCclusterMI * cm=0;
2968 if (TMath::Abs(ym)-ymaxm<0){
2969 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2970 if ((!cm) || (cm->IsUsed(10))) {
2975 // rotate y1 to system 0
2976 // get state vector in rotated system
2977 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2978 Double_t xr2 = x0*cs+yr1*sn*dsec;
2979 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2981 GetProlongation(xx2,xm,xr,ym,zm);
2982 if (TMath::Abs(ym)-ymaxm<0){
2983 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2984 if ((!cm) || (cm->IsUsed(10))) {
2994 dym = ym - cm->GetY();
2995 dzm = zm - cm->GetZ();
3002 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
3003 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
3004 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
3005 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3006 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
3008 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3009 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3010 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3011 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3012 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3013 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3015 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3016 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3017 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3018 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3022 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3023 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3024 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3025 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3026 c[13]=f30*sy1*f40+f32*sy2*f42;
3027 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3029 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3031 UInt_t index=kr1.GetIndex(is);
3032 AliTPCseed *track=new(seed) AliTPCseed(x1, ns*alpha+shift, x, c, index);
3034 track->fIsSeeding = kTRUE;
3041 FollowProlongation(*track, (i1+i2)/2,1);
3042 Int_t foundable,found,shared;
3043 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3044 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3046 seed->~AliTPCseed();
3052 FollowProlongation(*track, i2,1);
3056 track->fBConstrain =1;
3057 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3058 track->fLastPoint = i1; // first cluster in track position
3059 track->fFirstPoint = track->fLastPoint;
3061 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3062 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3063 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3065 seed->~AliTPCseed();
3069 // Z VERTEX CONDITION
3070 Double_t zv, bz=GetBz();
3071 if ( !track->GetZAt(0.,bz,zv) ) continue;
3072 if (TMath::Abs(zv-z3)>cuts[2]) {
3073 FollowProlongation(*track, TMath::Max(i2-20,0));
3074 if ( !track->GetZAt(0.,bz,zv) ) continue;
3075 if (TMath::Abs(zv-z3)>cuts[2]){
3076 FollowProlongation(*track, TMath::Max(i2-40,0));
3077 if ( !track->GetZAt(0.,bz,zv) ) continue;
3078 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3079 // make seed without constrain
3080 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3081 FollowProlongation(*track2, i2,1);
3082 track2->fBConstrain = kFALSE;
3083 track2->fSeedType = 1;
3084 arr->AddLast(track2);
3086 seed->~AliTPCseed();
3091 seed->~AliTPCseed();
3098 track->fSeedType =0;
3099 arr->AddLast(track);
3100 seed = new AliTPCseed;
3102 // don't consider other combinations
3103 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3109 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3115 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3120 //-----------------------------------------------------------------
3121 // This function creates track seeds.
3122 //-----------------------------------------------------------------
3123 // cuts[0] - fP4 cut
3124 // cuts[1] - tan(phi) cut
3125 // cuts[2] - zvertex cut
3126 // cuts[3] - fP3 cut
3136 Double_t x[5], c[15];
3138 // make temporary seed
3139 AliTPCseed * seed = new AliTPCseed;
3140 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3141 // Double_t cs=cos(alpha), sn=sin(alpha);
3146 Double_t x1 = GetXrow(i1-1);
3147 const AliTPCRow& kr1=GetRow(sec,i1-1);
3148 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3150 Double_t x1p = GetXrow(i1);
3151 const AliTPCRow& kr1p=GetRow(sec,i1);
3153 Double_t x1m = GetXrow(i1-2);
3154 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3157 //last 3 padrow for seeding
3158 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3159 Double_t x3 = GetXrow(i1-7);
3160 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3162 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3163 Double_t x3p = GetXrow(i1-6);
3165 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3166 Double_t x3m = GetXrow(i1-8);
3171 Int_t im = i1-4; //middle pad row index
3172 Double_t xm = GetXrow(im); // radius of middle pad-row
3173 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3174 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3177 Double_t deltax = x1-x3;
3178 Double_t dymax = deltax*cuts[1];
3179 Double_t dzmax = deltax*cuts[3];
3181 // loop over clusters
3182 for (Int_t is=0; is < kr1; is++) {
3184 if (kr1[is]->IsUsed(10)) continue;
3185 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3187 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3189 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3190 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3196 for (Int_t js=index1; js < index2; js++) {
3197 const AliTPCclusterMI *kcl = kr3[js];
3198 if (kcl->IsUsed(10)) continue;
3200 // apply angular cuts
3201 if (TMath::Abs(y1-y3)>dymax) continue;
3204 if (TMath::Abs(z1-z3)>dzmax) continue;
3206 Double_t angley = (y1-y3)/(x1-x3);
3207 Double_t anglez = (z1-z3)/(x1-x3);
3209 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3210 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3212 Double_t yyym = angley*(xm-x1)+y1;
3213 Double_t zzzm = anglez*(xm-x1)+z1;
3215 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3217 if (kcm->IsUsed(10)) continue;
3219 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3220 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3227 // look around first
3228 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3234 if (kc1m->IsUsed(10)) used++;
3236 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3242 if (kc1p->IsUsed(10)) used++;
3244 if (used>1) continue;
3245 if (found<1) continue;
3249 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3255 if (kc3m->IsUsed(10)) used++;
3259 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3265 if (kc3p->IsUsed(10)) used++;
3269 if (used>1) continue;
3270 if (found<3) continue;
3280 x[4]=F1(x1,y1,x2,y2,x3,y3);
3281 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3284 x[2]=F2(x1,y1,x2,y2,x3,y3);
3287 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3288 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3292 Double_t sy1=0.1, sz1=0.1;
3293 Double_t sy2=0.1, sz2=0.1;
3294 Double_t sy3=0.1, sy=0.1, sz=0.1;
3296 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3297 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3298 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3299 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3300 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3301 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3303 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3304 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3305 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3306 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3310 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3311 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3312 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3313 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3314 c[13]=f30*sy1*f40+f32*sy2*f42;
3315 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3317 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3319 UInt_t index=kr1.GetIndex(is);
3320 AliTPCseed *track=new(seed) AliTPCseed(x1, sec*alpha+shift, x, c, index);
3322 track->fIsSeeding = kTRUE;
3325 FollowProlongation(*track, i1-7,1);
3326 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3327 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3329 seed->~AliTPCseed();
3335 FollowProlongation(*track, i2,1);
3336 track->fBConstrain =0;
3337 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3338 track->fFirstPoint = track->fLastPoint;
3340 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3341 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3342 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3344 seed->~AliTPCseed();
3349 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3350 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3351 FollowProlongation(*track2, i2,1);
3352 track2->fBConstrain = kFALSE;
3353 track2->fSeedType = 4;
3354 arr->AddLast(track2);
3356 seed->~AliTPCseed();
3360 //arr->AddLast(track);
3361 //seed = new AliTPCseed;
3367 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3373 //_____________________________________________________________________________
3374 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3375 Float_t deltay, Bool_t /*bconstrain*/) {
3376 //-----------------------------------------------------------------
3377 // This function creates track seeds - without vertex constraint
3378 //-----------------------------------------------------------------
3379 // cuts[0] - fP4 cut - not applied
3380 // cuts[1] - tan(phi) cut
3381 // cuts[2] - zvertex cut - not applied
3382 // cuts[3] - fP3 cut
3392 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3393 // Double_t cs=cos(alpha), sn=sin(alpha);
3394 Int_t row0 = (i1+i2)/2;
3395 Int_t drow = (i1-i2)/2;
3396 const AliTPCRow& kr0=fSectors[sec][row0];
3399 AliTPCpolyTrack polytrack;
3400 Int_t nclusters=fSectors[sec][row0];
3401 AliTPCseed * seed = new AliTPCseed;
3406 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3408 Int_t nfoundable =0;
3409 for (Int_t iter =1; iter<2; iter++){ //iterations
3410 const AliTPCRow& krm=fSectors[sec][row0-iter];
3411 const AliTPCRow& krp=fSectors[sec][row0+iter];
3412 const AliTPCclusterMI * cl= kr0[is];
3414 if (cl->IsUsed(10)) {
3420 Double_t x = kr0.GetX();
3421 // Initialization of the polytrack
3426 Double_t y0= cl->GetY();
3427 Double_t z0= cl->GetZ();
3431 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3432 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3434 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3435 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3436 polytrack.AddPoint(x,y0,z0,erry, errz);
3439 if (cl->IsUsed(10)) sumused++;
3442 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3443 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3446 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3447 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3448 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3449 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3450 if (cl1->IsUsed(10)) sumused++;
3451 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3455 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3457 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3458 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3459 if (cl2->IsUsed(10)) sumused++;
3460 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3463 if (sumused>0) continue;
3465 polytrack.UpdateParameters();
3471 nfoundable = polytrack.GetN();
3472 nfound = nfoundable;
3474 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3475 Float_t maxdist = 0.8*(1.+3./(ddrow));
3476 for (Int_t delta = -1;delta<=1;delta+=2){
3477 Int_t row = row0+ddrow*delta;
3478 kr = &(fSectors[sec][row]);
3479 Double_t xn = kr->GetX();
3480 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3481 polytrack.GetFitPoint(xn,yn,zn);
3482 if (TMath::Abs(yn)>ymax) continue;
3484 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3486 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3489 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3490 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3491 if (cln->IsUsed(10)) {
3492 // printf("used\n");
3500 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3505 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3506 polytrack.UpdateParameters();
3509 if ( (sumused>3) || (sumused>0.5*nfound)) {
3510 //printf("sumused %d\n",sumused);
3515 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3516 AliTPCpolyTrack track2;
3518 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3519 if (track2.GetN()<0.5*nfoundable) continue;
3522 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3524 // test seed with and without constrain
3525 for (Int_t constrain=0; constrain<=0;constrain++){
3526 // add polytrack candidate
3528 Double_t x[5], c[15];
3529 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3530 track2.GetBoundaries(x3,x1);
3532 track2.GetFitPoint(x1,y1,z1);
3533 track2.GetFitPoint(x2,y2,z2);
3534 track2.GetFitPoint(x3,y3,z3);
3536 //is track pointing to the vertex ?
3539 polytrack.GetFitPoint(x0,y0,z0);
3552 x[4]=F1(x1,y1,x2,y2,x3,y3);
3554 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3555 x[2]=F2(x1,y1,x2,y2,x3,y3);
3557 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3558 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3559 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3560 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3563 Double_t sy =0.1, sz =0.1;
3564 Double_t sy1=0.02, sz1=0.02;
3565 Double_t sy2=0.02, sz2=0.02;
3569 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3572 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3573 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3574 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3575 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3576 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3577 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3579 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3580 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3581 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3582 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3587 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3588 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3589 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3590 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3591 c[13]=f30*sy1*f40+f32*sy2*f42;
3592 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3594 //Int_t row1 = fSectors->GetRowNumber(x1);
3595 Int_t row1 = GetRowNumber(x1);
3599 AliTPCseed *track=new (seed) AliTPCseed(x1,sec*alpha+shift,x,c,index);
3600 track->fIsSeeding = kTRUE;
3601 Int_t rc=FollowProlongation(*track, i2);
3602 if (constrain) track->fBConstrain =1;
3604 track->fBConstrain =0;
3605 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3606 track->fFirstPoint = track->fLastPoint;
3608 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3609 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3610 track->fNShared>0.4*track->GetNumberOfClusters()) {
3613 seed->~AliTPCseed();
3616 arr->AddLast(track);
3617 seed = new AliTPCseed;
3621 } // if accepted seed
3624 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3630 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3634 //reseed using track points
3635 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3636 Int_t p1 = int(r1*track->GetNumberOfClusters());
3637 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3639 Double_t x0[3],x1[3],x2[3];
3640 for (Int_t i=0;i<3;i++){
3646 // find track position at given ratio of the length
3647 Int_t sec0=0, sec1=0, sec2=0;
3650 for (Int_t i=0;i<160;i++){
3651 if (track->fClusterPointer[i]){
3653 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3654 if ( (index<p0) || x0[0]<0 ){
3655 if (trpoint->GetX()>1){
3656 clindex = track->GetClusterIndex2(i);
3658 x0[0] = trpoint->GetX();
3659 x0[1] = trpoint->GetY();
3660 x0[2] = trpoint->GetZ();
3661 sec0 = ((clindex&0xff000000)>>24)%18;
3666 if ( (index<p1) &&(trpoint->GetX()>1)){
3667 clindex = track->GetClusterIndex2(i);
3669 x1[0] = trpoint->GetX();
3670 x1[1] = trpoint->GetY();
3671 x1[2] = trpoint->GetZ();
3672 sec1 = ((clindex&0xff000000)>>24)%18;
3675 if ( (index<p2) &&(trpoint->GetX()>1)){
3676 clindex = track->GetClusterIndex2(i);
3678 x2[0] = trpoint->GetX();
3679 x2[1] = trpoint->GetY();
3680 x2[2] = trpoint->GetZ();
3681 sec2 = ((clindex&0xff000000)>>24)%18;
3688 Double_t alpha, cs,sn, xx2,yy2;
3690 alpha = (sec1-sec2)*fSectors->GetAlpha();
3691 cs = TMath::Cos(alpha);
3692 sn = TMath::Sin(alpha);
3693 xx2= x1[0]*cs-x1[1]*sn;
3694 yy2= x1[0]*sn+x1[1]*cs;
3698 alpha = (sec0-sec2)*fSectors->GetAlpha();
3699 cs = TMath::Cos(alpha);
3700 sn = TMath::Sin(alpha);
3701 xx2= x0[0]*cs-x0[1]*sn;
3702 yy2= x0[0]*sn+x0[1]*cs;
3708 Double_t x[5],c[15];
3712 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3713 // if (x[4]>1) return 0;
3714 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3715 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3716 //if (TMath::Abs(x[3]) > 2.2) return 0;
3717 //if (TMath::Abs(x[2]) > 1.99) return 0;
3719 Double_t sy =0.1, sz =0.1;
3721 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3722 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3723 Double_t sy3=0.01+track->GetSigmaY2();
3725 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3726 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3727 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3728 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3729 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3730 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3732 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3733 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3734 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3735 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3740 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3741 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3742 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3743 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3744 c[13]=f30*sy1*f40+f32*sy2*f42;
3745 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3747 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3748 AliTPCseed *seed=new AliTPCseed(x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3749 // Double_t y0,z0,y1,z1, y2,z2;
3750 //seed->GetProlongation(x0[0],y0,z0);
3751 // seed->GetProlongation(x1[0],y1,z1);
3752 //seed->GetProlongation(x2[0],y2,z2);
3754 seed->fLastPoint = pp2;
3755 seed->fFirstPoint = pp2;
3762 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3766 //reseed using founded clusters
3768 // Find the number of clusters
3769 Int_t nclusters = 0;
3770 for (Int_t irow=0;irow<160;irow++){
3771 if (track->GetClusterIndex(irow)>0) nclusters++;
3775 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3776 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3777 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3781 Int_t row[3],sec[3]={0,0,0};
3783 // find track row position at given ratio of the length
3785 for (Int_t irow=0;irow<160;irow++){
3786 if (track->GetClusterIndex2(irow)<0) continue;
3788 for (Int_t ipoint=0;ipoint<3;ipoint++){
3789 if (index<=ipos[ipoint]) row[ipoint] = irow;
3793 //Get cluster and sector position
3794 for (Int_t ipoint=0;ipoint<3;ipoint++){
3795 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3796 AliTPCclusterMI * cl = GetClusterMI(clindex);
3799 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3802 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3803 xyz[ipoint][0] = GetXrow(row[ipoint]);
3804 xyz[ipoint][1] = cl->GetY();
3805 xyz[ipoint][2] = cl->GetZ();
3809 // Calculate seed state vector and covariance matrix
3811 Double_t alpha, cs,sn, xx2,yy2;
3813 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3814 cs = TMath::Cos(alpha);
3815 sn = TMath::Sin(alpha);
3816 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3817 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3821 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3822 cs = TMath::Cos(alpha);
3823 sn = TMath::Sin(alpha);
3824 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3825 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3831 Double_t x[5],c[15];
3835 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3836 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3837 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3839 Double_t sy =0.1, sz =0.1;
3841 Double_t sy1=0.2, sz1=0.2;
3842 Double_t sy2=0.2, sz2=0.2;
3845 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;
3846 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;
3847 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;
3848 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;
3849 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;
3850 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;
3852 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;
3853 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;
3854 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;
3855 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;
3860 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3861 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3862 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3863 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3864 c[13]=f30*sy1*f40+f32*sy2*f42;
3865 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3867 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3868 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3869 seed->fLastPoint = row[2];
3870 seed->fFirstPoint = row[2];
3875 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3879 //reseed using founded clusters
3882 Int_t row[3]={0,0,0};
3883 Int_t sec[3]={0,0,0};
3885 // forward direction
3887 for (Int_t irow=r0;irow<160;irow++){
3888 if (track->GetClusterIndex(irow)>0){
3893 for (Int_t irow=160;irow>r0;irow--){
3894 if (track->GetClusterIndex(irow)>0){
3899 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3900 if (track->GetClusterIndex(irow)>0){
3908 for (Int_t irow=0;irow<r0;irow++){
3909 if (track->GetClusterIndex(irow)>0){
3914 for (Int_t irow=r0;irow>0;irow--){
3915 if (track->GetClusterIndex(irow)>0){
3920 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3921 if (track->GetClusterIndex(irow)>0){
3928 if ((row[2]-row[0])<20) return 0;
3929 if (row[1]==0) return 0;
3932 //Get cluster and sector position
3933 for (Int_t ipoint=0;ipoint<3;ipoint++){
3934 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3935 AliTPCclusterMI * cl = GetClusterMI(clindex);
3938 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3941 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3942 xyz[ipoint][0] = GetXrow(row[ipoint]);
3943 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3944 if (point&&ipoint<2){
3946 xyz[ipoint][1] = point->GetY();
3947 xyz[ipoint][2] = point->GetZ();
3950 xyz[ipoint][1] = cl->GetY();
3951 xyz[ipoint][2] = cl->GetZ();
3958 // Calculate seed state vector and covariance matrix
3960 Double_t alpha, cs,sn, xx2,yy2;
3962 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3963 cs = TMath::Cos(alpha);
3964 sn = TMath::Sin(alpha);
3965 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3966 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3970 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3971 cs = TMath::Cos(alpha);
3972 sn = TMath::Sin(alpha);
3973 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3974 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3980 Double_t x[5],c[15];
3984 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3985 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3986 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3988 Double_t sy =0.1, sz =0.1;
3990 Double_t sy1=0.2, sz1=0.2;
3991 Double_t sy2=0.2, sz2=0.2;
3994 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;
3995 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;
3996 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;
3997 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;
3998 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;
3999 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;
4001 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;
4002 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;
4003 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;
4004 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;
4009 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
4010 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
4011 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
4012 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
4013 c[13]=f30*sy1*f40+f32*sy2*f42;
4014 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
4016 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
4017 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
4018 seed->fLastPoint = row[2];
4019 seed->fFirstPoint = row[2];
4020 for (Int_t i=row[0];i<row[2];i++){
4021 seed->fIndex[i] = track->fIndex[i];
4027 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4034 TObjArray *kinks= new TObjArray(10000);
4035 // TObjArray *v0s= new TObjArray(10000);
4036 Int_t nentries = array->GetEntriesFast();
4037 AliHelix *helixes = new AliHelix[nentries];
4038 Int_t *sign = new Int_t[nentries];
4039 Int_t *nclusters = new Int_t[nentries];
4040 Float_t *alpha = new Float_t[nentries];
4041 AliKink *kink = new AliKink();
4042 Int_t * usage = new Int_t[nentries];
4043 Float_t *zm = new Float_t[nentries];
4044 Float_t *z0 = new Float_t[nentries];
4045 Float_t *fim = new Float_t[nentries];
4046 Float_t *shared = new Float_t[nentries];
4047 Bool_t *circular = new Bool_t[nentries];
4048 Float_t *dca = new Float_t[nentries];
4049 //const AliESDVertex * primvertex = esd->GetVertex();
4051 // nentries = array->GetEntriesFast();
4056 for (Int_t i=0;i<nentries;i++){
4059 AliTPCseed* track = (AliTPCseed*)array->At(i);
4060 if (!track) continue;
4061 track->fCircular =0;
4063 track->UpdatePoints();
4064 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4066 nclusters[i]=track->GetNumberOfClusters();
4067 alpha[i] = track->GetAlpha();
4068 new (&helixes[i]) AliHelix(*track);
4070 helixes[i].Evaluate(0,xyz);
4071 sign[i] = (track->GetC()>0) ? -1:1;
4074 if (track->GetProlongation(x,y,z)){
4076 fim[i] = alpha[i]+TMath::ATan2(y,x);
4079 zm[i] = track->GetZ();
4083 circular[i]= kFALSE;
4084 if (track->GetProlongation(0,y,z)) z0[i] = z;
4085 dca[i] = track->GetD(0,0);
4091 Int_t ncandidates =0;
4094 Double_t phase[2][2],radius[2];
4097 // Find circling track
4098 TTreeSRedirector &cstream = *fDebugStreamer;
4100 for (Int_t i0=0;i0<nentries;i0++){
4101 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4102 if (!track0) continue;
4103 if (track0->fN<40) continue;
4104 if (TMath::Abs(1./track0->GetC())>200) continue;
4105 for (Int_t i1=i0+1;i1<nentries;i1++){
4106 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4107 if (!track1) continue;
4108 if (track1->fN<40) continue;
4109 if ( TMath::Abs(track1->GetTgl()+track0->GetTgl())>0.1) continue;
4110 if (track0->fBConstrain&&track1->fBConstrain) continue;
4111 if (TMath::Abs(1./track1->GetC())>200) continue;
4112 if (track1->Get1Pt()*track0->Get1Pt()>0) continue;
4113 if (track1->GetTgl()*track0->GetTgl()>0) continue;
4114 if (max(TMath::Abs(1./track0->GetC()),TMath::Abs(1./track1->GetC()))>190) continue;
4115 if (track0->fBConstrain&&TMath::Abs(track1->Get1Pt())<TMath::Abs(track0->Get1Pt())) continue; //returning - lower momenta
4116 if (track1->fBConstrain&&TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())) continue; //returning - lower momenta
4118 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4119 if (mindcar<5) continue;
4120 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4121 if (mindcaz<5) continue;
4122 if (mindcar+mindcaz<20) continue;
4125 Float_t xc0 = helixes[i0].GetHelix(6);
4126 Float_t yc0 = helixes[i0].GetHelix(7);
4127 Float_t r0 = helixes[i0].GetHelix(8);
4128 Float_t xc1 = helixes[i1].GetHelix(6);
4129 Float_t yc1 = helixes[i1].GetHelix(7);
4130 Float_t r1 = helixes[i1].GetHelix(8);
4132 Float_t rmean = (r0+r1)*0.5;
4133 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4134 //if (delta>30) continue;
4135 if (delta>rmean*0.25) continue;
4136 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4138 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4139 if (npoints==0) continue;
4140 helixes[i0].GetClosestPhases(helixes[i1], phase);
4144 Double_t hangles[3];
4145 helixes[i0].Evaluate(phase[0][0],xyz0);
4146 helixes[i1].Evaluate(phase[0][1],xyz1);
4148 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4149 Double_t deltah[2],deltabest;
4150 if (hangles[2]<2.8) continue;
4152 cstream<<"C"<<track0->fLab<<track1->fLab<<
4153 track0->fP3<<track1->fP3<<
4154 track0->fP4<<track1->fP4<<
4155 delta<<rmean<<npoints<<
4156 hangles[0]<<hangles[2]<<
4157 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4161 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4163 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4164 if (deltah[1]<deltah[0]) ibest=1;
4166 deltabest = TMath::Sqrt(deltah[ibest]);
4167 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4168 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4169 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4170 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4172 if (deltabest>6) continue;
4173 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4174 Bool_t sign =kFALSE;
4175 if (hangles[2]>3.06) sign =kTRUE;
4178 circular[i0] = kTRUE;
4179 circular[i1] = kTRUE;
4180 if (TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())){
4181 track0->fCircular += 1;
4182 track1->fCircular += 2;
4185 track1->fCircular += 1;
4186 track0->fCircular += 2;
4189 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4191 cstream<<"Curling"<<
4192 "lab0="<<track0->fLab<<
4193 "lab1="<<track1->fLab<<
4198 "mindcar="<<mindcar<<
4199 "mindcaz="<<mindcaz<<
4202 "npoints="<<npoints<<
4203 "hangles0="<<hangles[0]<<
4204 "hangles2="<<hangles[2]<<
4209 "radius="<<radiusbest<<
4210 "deltabest="<<deltabest<<
4211 "phase0="<<phase[ibest][0]<<
4212 "phase1="<<phase[ibest][1]<<
4222 for (Int_t i =0;i<nentries;i++){
4223 if (sign[i]==0) continue;
4224 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4227 Double_t cradius0 = 40*40;
4228 Double_t cradius1 = 270*270;
4231 Double_t cdist3=0.55;
4232 for (Int_t j =i+1;j<nentries;j++){
4234 if (sign[j]*sign[i]<1) continue;
4235 if ( (nclusters[i]+nclusters[j])>200) continue;
4236 if ( (nclusters[i]+nclusters[j])<80) continue;
4237 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4238 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4239 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4240 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4241 if (npoints<1) continue;
4244 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4247 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4250 Double_t delta1=10000,delta2=10000;
4251 // cuts on the intersection radius
4252 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4253 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4254 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4256 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4257 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4258 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4261 Double_t distance1 = TMath::Min(delta1,delta2);
4262 if (distance1>cdist1) continue; // cut on DCA linear approximation
4264 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4265 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4266 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4267 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4270 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4271 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4272 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4274 distance1 = TMath::Min(delta1,delta2);
4277 rkink = TMath::Sqrt(radius[0]);
4280 rkink = TMath::Sqrt(radius[1]);
4282 if (distance1>cdist2) continue;
4285 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4288 Int_t row0 = GetRowNumber(rkink);
4289 if (row0<10) continue;
4290 if (row0>150) continue;
4293 Float_t dens00=-1,dens01=-1;
4294 Float_t dens10=-1,dens11=-1;
4296 Int_t found,foundable,shared;
4297 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4298 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4299 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4300 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4302 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4303 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4304 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4305 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4307 if (dens00<dens10 && dens01<dens11) continue;
4308 if (dens00>dens10 && dens01>dens11) continue;
4309 if (TMath::Max(dens00,dens10)<0.1) continue;
4310 if (TMath::Max(dens01,dens11)<0.3) continue;
4312 if (TMath::Min(dens00,dens10)>0.6) continue;
4313 if (TMath::Min(dens01,dens11)>0.6) continue;
4316 AliTPCseed * ktrack0, *ktrack1;
4325 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4326 AliExternalTrackParam paramm(*ktrack0);
4327 AliExternalTrackParam paramd(*ktrack1);
4328 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4331 kink->SetMother(paramm);
4332 kink->SetDaughter(paramd);
4335 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4337 fParam->Transform0to1(x,index);
4338 fParam->Transform1to2(x,index);
4339 row0 = GetRowNumber(x[0]);
4341 if (kink->GetR()<100) continue;
4342 if (kink->GetR()>240) continue;
4343 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4344 if (kink->GetDistance()>cdist3) continue;
4345 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4346 if (dird<0) continue;
4348 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4349 if (dirm<0) continue;
4350 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4351 if (mpt<0.2) continue;
4354 //for high momenta momentum not defined well in first iteration
4355 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->GetP();
4356 if (qt>0.35) continue;
4359 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4360 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4362 kink->SetTPCDensity(dens00,0,0);
4363 kink->SetTPCDensity(dens01,0,1);
4364 kink->SetTPCDensity(dens10,1,0);
4365 kink->SetTPCDensity(dens11,1,1);
4366 kink->SetIndex(i,0);
4367 kink->SetIndex(j,1);
4370 kink->SetTPCDensity(dens10,0,0);
4371 kink->SetTPCDensity(dens11,0,1);
4372 kink->SetTPCDensity(dens00,1,0);
4373 kink->SetTPCDensity(dens01,1,1);
4374 kink->SetIndex(j,0);
4375 kink->SetIndex(i,1);
4378 if (mpt<1||kink->GetAngle(2)>0.1){
4379 // angle and densities not defined yet
4380 if (kink->GetTPCDensityFactor()<0.8) continue;
4381 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4382 if (kink->GetAngle(2)*ktrack0->GetP()<0.003) continue; //too small angle
4383 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4384 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4386 Float_t criticalangle = track0->GetSigmaSnp2()+track0->GetSigmaTgl2();
4387 criticalangle+= track1->GetSigmaSnp2()+track1->GetSigmaTgl2();
4388 criticalangle= 3*TMath::Sqrt(criticalangle);
4389 if (criticalangle>0.02) criticalangle=0.02;
4390 if (kink->GetAngle(2)<criticalangle) continue;
4393 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4394 Float_t shapesum =0;
4396 for ( Int_t row = row0-drow; row<row0+drow;row++){
4397 if (row<0) continue;
4398 if (row>155) continue;
4399 if (ktrack0->fClusterPointer[row]){
4400 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4401 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4404 if (ktrack1->fClusterPointer[row]){
4405 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4406 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4411 kink->SetShapeFactor(-1.);
4414 kink->SetShapeFactor(shapesum/sum);
4416 // esd->AddKink(kink);
4417 kinks->AddLast(kink);
4423 // sort the kinks according quality - and refit them towards vertex
4425 Int_t nkinks = kinks->GetEntriesFast();
4426 Float_t *quality = new Float_t[nkinks];
4427 Int_t *indexes = new Int_t[nkinks];
4428 AliTPCseed *mothers = new AliTPCseed[nkinks];
4429 AliTPCseed *daughters = new AliTPCseed[nkinks];
4432 for (Int_t i=0;i<nkinks;i++){
4434 AliKink *kink = (AliKink*)kinks->At(i);
4436 // refit kinks towards vertex
4438 Int_t index0 = kink->GetIndex(0);
4439 Int_t index1 = kink->GetIndex(1);
4440 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4441 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4443 Int_t sumn=ktrack0->fN+ktrack1->fN;
4445 // Refit Kink under if too small angle
4447 if (kink->GetAngle(2)<0.05){
4448 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4449 Int_t row0 = kink->GetTPCRow0();
4450 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4453 Int_t last = row0-drow;
4454 if (last<40) last=40;
4455 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4456 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4459 Int_t first = row0+drow;
4460 if (first>130) first=130;
4461 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4462 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4464 if (seed0 && seed1){
4465 kink->SetStatus(1,8);
4466 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4467 row0 = GetRowNumber(kink->GetR());
4468 sumn = seed0->fN+seed1->fN;
4469 new (&mothers[i]) AliTPCseed(*seed0);
4470 new (&daughters[i]) AliTPCseed(*seed1);
4473 delete kinks->RemoveAt(i);
4474 if (seed0) delete seed0;
4475 if (seed1) delete seed1;
4478 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4479 delete kinks->RemoveAt(i);
4480 if (seed0) delete seed0;
4481 if (seed1) delete seed1;
4489 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4491 TMath::Sort(nkinks,quality,indexes,kFALSE);
4493 //remove double find kinks
4495 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4496 AliKink * kink0 = (AliKink*) kinks->At(indexes[ikink0]);
4497 if (!kink0) continue;
4499 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4500 if (!kink0) continue;
4501 AliKink * kink1 = (AliKink*) kinks->At(indexes[ikink1]);
4502 if (!kink1) continue;
4503 // if not close kink continue
4504 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4505 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4506 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4508 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4509 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4510 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4511 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4512 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4521 for (Int_t i=0;i<row0;i++){
4522 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4525 if (mother0.fIndex[i]==mother1.fIndex[i]){
4532 for (Int_t i=row0;i<158;i++){
4533 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4536 if (mother0.fIndex[i]==mother1.fIndex[i]){
4542 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4543 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4544 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4545 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4546 Int_t sum0 = mother0.fN+daughter0.fN;
4547 Int_t sum1 = mother1.fN+daughter1.fN;
4549 shared[kink0->GetIndex(0)]= kTRUE;
4550 shared[kink0->GetIndex(1)]= kTRUE;
4551 delete kinks->RemoveAt(indexes[ikink0]);
4554 shared[kink1->GetIndex(0)]= kTRUE;
4555 shared[kink1->GetIndex(1)]= kTRUE;
4556 delete kinks->RemoveAt(indexes[ikink1]);
4563 for (Int_t i=0;i<nkinks;i++){
4564 AliKink * kink = (AliKink*) kinks->At(indexes[i]);
4565 if (!kink) continue;
4566 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4567 Int_t index0 = kink->GetIndex(0);
4568 Int_t index1 = kink->GetIndex(1);
4569 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4570 kink->SetMultiple(usage[index0],0);
4571 kink->SetMultiple(usage[index1],1);
4572 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4573 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4574 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4575 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4577 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4578 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4579 if (!ktrack0 || !ktrack1) continue;
4580 Int_t index = esd->AddKink(kink);
4583 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4584 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4585 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4586 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4590 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4591 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4596 // Remove tracks corresponding to shared kink's
4598 for (Int_t i=0;i<nentries;i++){
4599 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4600 if (!track0) continue;
4601 if (track0->fKinkIndexes[0]!=0) continue;
4602 if (shared[i]) delete array->RemoveAt(i);
4607 RemoveUsed2(array,0.5,0.4,30);
4609 for (Int_t i=0;i<nentries;i++){
4610 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4611 if (!track0) continue;
4612 track0->CookdEdx(0.02,0.6);
4616 for (Int_t i=0;i<nentries;i++){
4617 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4618 if (!track0) continue;
4619 if (track0->GetPt()<1.4) continue;
4620 //remove double high momenta tracks - overlapped with kink candidates
4623 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4624 if (track0->fClusterPointer[icl]!=0){
4626 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4629 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4630 delete array->RemoveAt(i);
4634 if (track0->fKinkIndexes[0]!=0) continue;
4635 if (track0->GetNumberOfClusters()<80) continue;
4637 AliTPCseed *pmother = new AliTPCseed();
4638 AliTPCseed *pdaughter = new AliTPCseed();
4639 AliKink *pkink = new AliKink;
4641 AliTPCseed & mother = *pmother;
4642 AliTPCseed & daughter = *pdaughter;
4643 AliKink & kink = *pkink;
4644 if (CheckKinkPoint(track0,mother,daughter, kink)){
4645 if (mother.fN<30||daughter.fN<20) {
4649 continue; //too short tracks
4651 if (mother.GetPt()<1.4) {
4657 Int_t row0= kink.GetTPCRow0();
4658 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4665 Int_t index = esd->AddKink(&kink);
4666 mother.fKinkIndexes[0] = -(index+1);
4667 daughter.fKinkIndexes[0] = index+1;
4669 delete array->RemoveAt(i);
4670 array->AddAt(new AliTPCseed(mother),i);
4673 array->AddLast(new AliTPCseed(mother));
4675 array->AddLast(new AliTPCseed(daughter));
4676 for (Int_t icl=0;icl<row0;icl++) {
4677 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4680 for (Int_t icl=row0;icl<158;icl++) {
4681 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4690 delete [] daughters;
4712 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4716 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4722 TObjArray *tpcv0s = new TObjArray(100000);
4723 Int_t nentries = array->GetEntriesFast();
4724 AliHelix *helixes = new AliHelix[nentries];
4725 Int_t *sign = new Int_t[nentries];
4726 Float_t *alpha = new Float_t[nentries];
4727 Float_t *z0 = new Float_t[nentries];
4728 Float_t *dca = new Float_t[nentries];
4729 Float_t *sdcar = new Float_t[nentries];
4730 Float_t *cdcar = new Float_t[nentries];
4731 Float_t *pulldcar = new Float_t[nentries];
4732 Float_t *pulldcaz = new Float_t[nentries];
4733 Float_t *pulldca = new Float_t[nentries];
4734 Bool_t *isPrim = new Bool_t[nentries];
4735 const AliESDVertex * primvertex = esd->GetVertex();
4736 Double_t zvertex = primvertex->GetZv();
4738 // nentries = array->GetEntriesFast();
4740 for (Int_t i=0;i<nentries;i++){
4743 AliTPCseed* track = (AliTPCseed*)array->At(i);
4744 if (!track) continue;
4745 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4746 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4747 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4749 alpha[i] = track->GetAlpha();
4750 new (&helixes[i]) AliHelix(*track);
4752 helixes[i].Evaluate(0,xyz);
4753 sign[i] = (track->GetC()>0) ? -1:1;
4757 if (track->GetProlongation(0,y,z)) z0[i] = z;
4758 dca[i] = track->GetD(0,0);
4760 // dca error parrameterezation + pulls
4762 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->GetC())*(100*track->GetC()));
4763 if (TMath::Abs(track->GetTgl())>1) sdcar[i]*=2.5;
4764 cdcar[i] = TMath::Exp((TMath::Abs(track->GetC())-0.0106)*525.3);
4765 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4766 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4767 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4768 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4769 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4771 if (track->fTPCr[4]>0.5) {
4772 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4774 if (track->fTPCr[0]>0.4) {
4775 isPrim[i]=kFALSE; //electron no sigma cut
4782 Int_t ncandidates =0;
4785 Double_t phase[2][2],radius[2];
4791 TTreeSRedirector &cstream = *fDebugStreamer;
4792 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4794 Double_t cradius0 = 10*10;
4795 Double_t cradius1 = 200*200;
4798 Double_t cpointAngle = 0.95;
4800 Double_t delta[2]={10000,10000};
4801 for (Int_t i =0;i<nentries;i++){
4802 if (sign[i]==0) continue;
4803 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4804 if (!track0) continue;
4805 if (AliTPCReconstructor::StreamLevel()>0){
4810 "zvertex="<<zvertex<<
4811 "sdcar0="<<sdcar[i]<<
4812 "cdcar0="<<cdcar[i]<<
4813 "pulldcar0="<<pulldcar[i]<<
4814 "pulldcaz0="<<pulldcaz[i]<<
4815 "pulldca0="<<pulldca[i]<<
4816 "isPrim="<<isPrim[i]<<
4820 if (track0->Get1Pt()<0) continue;
4821 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4823 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4828 for (Int_t j =0;j<nentries;j++){
4829 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4830 if (!track1) continue;
4831 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4832 if (sign[j]*sign[i]>0) continue;
4833 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4834 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4837 // DCA to prim vertex cut
4843 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4844 if (npoints<1) continue;
4848 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4849 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4850 if (delta[0]>cdist1) continue;
4853 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4854 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4855 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4856 if (delta[1]<delta[0]) iclosest=1;
4857 if (delta[iclosest]>cdist1) continue;
4859 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4860 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4862 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4863 if (pointAngle<cpointAngle) continue;
4865 Bool_t isGamma = kFALSE;
4866 vertex.SetP(*track0); //track0 - plus
4867 vertex.SetM(*track1); //track1 - minus
4868 vertex.Update(fprimvertex);
4869 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4870 Double_t pointAngle2 = vertex.GetPointAngle();
4872 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4873 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4874 Float_t sigmae = 0.15*0.15;
4875 if (vertex.GetRr()<80)
4876 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4877 sigmae+= TMath::Sqrt(sigmae);
4878 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4879 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4880 Int_t row0 = GetRowNumber(vertex.GetRr());
4882 if (vertex.GetDist2()>0.2) continue;
4883 densb0 = track0->Density2(0,row0-5);
4884 densb1 = track1->Density2(0,row0-5);
4885 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4886 densa0 = track0->Density2(row0+5,row0+40);
4887 densa1 = track1->Density2(row0+5,row0+40);
4888 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4891 densa0 = track0->Density2(0,40); //cluster density
4892 densa1 = track1->Density2(0,40); //cluster density
4893 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4895 vertex.SetLab(0,track0->GetLabel());
4896 vertex.SetLab(1,track1->GetLabel());
4897 vertex.SetChi2After((densa0+densa1)*0.5);
4898 vertex.SetChi2Before((densb0+densb1)*0.5);
4899 vertex.SetIndex(0,i);
4900 vertex.SetIndex(1,j);
4901 vertex.SetStatus(1); // TPC v0 candidate
4902 vertex.SetRp(track0->fTPCr);
4903 vertex.SetRm(track1->fTPCr);
4904 tpcv0s->AddLast(new AliESDv0(vertex));
4907 Int_t eventNr = esd->GetEventNumber();
4908 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4909 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4910 if (AliTPCReconstructor::StreamLevel()>0)
4913 "vertex.="<<&vertex<<
4915 "lab0="<<track0->fLab<<
4916 "Helix0.="<<&helixes[i]<<
4918 "lab1="<<track1->fLab<<
4919 "Helix1.="<<&helixes[j]<<
4920 "pointAngle="<<pointAngle<<
4921 "pointAngle2="<<pointAngle2<<
4926 "zvertex="<<zvertex<<
4927 "circular0="<<track0->fCircular<<
4928 "circular1="<<track1->fCircular<<
4929 "npoints="<<npoints<<
4930 "radius0="<<radius[0]<<
4931 "delta0="<<delta[0]<<
4932 "radius1="<<radius[1]<<
4933 "delta1="<<delta[1]<<
4934 "radiusm="<<radiusm<<
4936 "sdcar0="<<sdcar[i]<<
4937 "sdcar1="<<sdcar[j]<<
4938 "cdcar0="<<cdcar[i]<<
4939 "cdcar1="<<cdcar[j]<<
4940 "pulldcar0="<<pulldcar[i]<<
4941 "pulldcar1="<<pulldcar[j]<<
4942 "pulldcaz0="<<pulldcaz[i]<<
4943 "pulldcaz1="<<pulldcaz[j]<<
4944 "pulldca0="<<pulldca[i]<<
4945 "pulldca1="<<pulldca[j]<<
4955 Float_t *quality = new Float_t[ncandidates];
4956 Int_t *indexes = new Int_t[ncandidates];
4958 for (Int_t i=0;i<ncandidates;i++){
4960 AliESDv0 *v0 = (AliESDv0*)tpcv0s->At(i);
4961 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4962 // quality[i] /= (0.5+v0->GetDist2());
4963 // quality[i] *= v0->GetChi2After(); //density factor
4964 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4965 Int_t index0 = v0->GetIndex(0);
4966 Int_t index1 = v0->GetIndex(1);
4967 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4968 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4969 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4970 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4973 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4976 for (Int_t i=0;i<ncandidates;i++){
4977 AliESDv0 * v0 = (AliESDv0*)tpcv0s->At(indexes[i]);
4979 Int_t index0 = v0->GetIndex(0);
4980 Int_t index1 = v0->GetIndex(1);
4981 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4982 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4983 if (!track0||!track1) {
4987 Bool_t accept =kTRUE; //default accept
4988 Int_t *v0indexes0 = track0->GetV0Indexes();
4989 Int_t *v0indexes1 = track1->GetV0Indexes();
4991 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4992 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4993 if (v0indexes0[1]!=0) order0 =2;
4994 if (v0indexes1[1]!=0) order1 =2;
4996 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4997 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4999 AliESDv0 * v02 = v0;
5001 v0->SetOrder(0,order0);
5002 v0->SetOrder(1,order1);
5003 v0->SetOrder(1,order0+order1);
5004 v0->SetOnFlyStatus(kTRUE);
5005 Int_t index = esd->AddV0(v0);
5006 v02 = esd->GetV0(index);
5007 v0indexes0[order0]=index;
5008 v0indexes1[order1]=index;
5012 Int_t eventNr = esd->GetEventNumber();
5013 if (AliTPCReconstructor::StreamLevel()>0)
5019 "lab0="<<track0->fLab<<
5021 "lab1="<<track1->fLab<<
5022 "dca0="<<dca[index0]<<
5023 "dca1="<<dca[index1]<<
5027 "quality="<<quality[i]<<
5028 "pulldca0="<<pulldca[index0]<<
5029 "pulldca1="<<pulldca[index1]<<
5053 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5057 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5060 // refit kink towards to the vertex
5063 AliKink &kink=(AliKink &)knk;
5065 Int_t row0 = GetRowNumber(kink.GetR());
5066 FollowProlongation(mother,0);
5067 mother.Reset(kFALSE);
5069 FollowProlongation(daughter,row0);
5070 daughter.Reset(kFALSE);
5071 FollowBackProlongation(daughter,158);
5072 daughter.Reset(kFALSE);
5073 Int_t first = TMath::Max(row0-20,30);
5074 Int_t last = TMath::Min(row0+20,140);
5076 const Int_t kNdiv =5;
5077 AliTPCseed param0[kNdiv]; // parameters along the track
5078 AliTPCseed param1[kNdiv]; // parameters along the track
5079 AliKink kinks[kNdiv]; // corresponding kink parameters
5082 for (Int_t irow=0; irow<kNdiv;irow++){
5083 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5085 // store parameters along the track
5087 for (Int_t irow=0;irow<kNdiv;irow++){
5088 FollowBackProlongation(mother, rows[irow]);
5089 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5090 new(¶m0[irow]) AliTPCseed(mother);
5091 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5095 for (Int_t irow=0; irow<kNdiv-1;irow++){
5096 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5097 kinks[irow].SetMother(param0[irow]);
5098 kinks[irow].SetDaughter(param1[irow]);
5099 kinks[irow].Update();
5102 // choose kink with best "quality"
5104 Double_t mindist = 10000;
5105 for (Int_t irow=0;irow<kNdiv;irow++){
5106 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5107 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5108 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5110 Float_t normdist = TMath::Abs(param0[irow].GetX()-kinks[irow].GetR())*(0.1+kink.GetDistance());
5111 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5112 if (normdist < mindist){
5118 if (index==-1) return 0;
5121 param0[index].Reset(kTRUE);
5122 FollowProlongation(param0[index],0);
5124 new (&mother) AliTPCseed(param0[index]);
5125 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5127 kink.SetMother(mother);
5128 kink.SetDaughter(daughter);
5130 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5131 kink.SetTPCncls(param0[index].fN,0);
5132 kink.SetTPCncls(param1[index].fN,1);
5133 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5134 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5135 mother.SetLabel(kink.GetLabel(0));
5136 daughter.SetLabel(kink.GetLabel(1));
5142 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5144 // update Kink quality information for mother after back propagation
5146 if (seed->GetKinkIndex(0)>=0) return;
5147 for (Int_t ikink=0;ikink<3;ikink++){
5148 Int_t index = seed->GetKinkIndex(ikink);
5149 if (index>=0) break;
5150 index = TMath::Abs(index)-1;
5151 AliESDkink * kink = fEvent->GetKink(index);
5152 //kink->fTPCdensity2[0][0]=-1;
5153 //kink->fTPCdensity2[0][1]=-1;
5154 kink->SetTPCDensity2(-1,0,0);
5155 kink->SetTPCDensity2(1,0,1);
5157 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5158 if (row0<15) row0=15;
5160 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5161 if (row1>145) row1=145;
5163 Int_t found,foundable,shared;
5164 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5165 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5166 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5167 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5172 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5174 // update Kink quality information for daughter after refit
5176 if (seed->GetKinkIndex(0)<=0) return;
5177 for (Int_t ikink=0;ikink<3;ikink++){
5178 Int_t index = seed->GetKinkIndex(ikink);
5179 if (index<=0) break;
5180 index = TMath::Abs(index)-1;
5181 AliESDkink * kink = fEvent->GetKink(index);
5182 kink->SetTPCDensity2(-1,1,0);
5183 kink->SetTPCDensity2(-1,1,1);
5185 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5186 if (row0<15) row0=15;
5188 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5189 if (row1>145) row1=145;
5191 Int_t found,foundable,shared;
5192 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5193 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5194 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5195 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5201 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5204 // check kink point for given track
5205 // if return value=0 kink point not found
5206 // otherwise seed0 correspond to mother particle
5207 // seed1 correspond to daughter particle
5208 // kink parameter of kink point
5209 AliKink &kink=(AliKink &)knk;
5211 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5212 Int_t first = seed->fFirstPoint;
5213 Int_t last = seed->fLastPoint;
5214 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5217 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5218 if (!seed1) return 0;
5219 FollowProlongation(*seed1,seed->fLastPoint-20);
5220 seed1->Reset(kTRUE);
5221 FollowProlongation(*seed1,158);
5222 seed1->Reset(kTRUE);
5223 last = seed1->fLastPoint;
5225 AliTPCseed *seed0 = new AliTPCseed(*seed);
5226 seed0->Reset(kFALSE);
5229 AliTPCseed param0[20]; // parameters along the track
5230 AliTPCseed param1[20]; // parameters along the track
5231 AliKink kinks[20]; // corresponding kink parameters
5233 for (Int_t irow=0; irow<20;irow++){
5234 rows[irow] = first +((last-first)*irow)/19;
5236 // store parameters along the track
5238 for (Int_t irow=0;irow<20;irow++){
5239 FollowBackProlongation(*seed0, rows[irow]);
5240 FollowProlongation(*seed1,rows[19-irow]);
5241 new(¶m0[irow]) AliTPCseed(*seed0);
5242 new(¶m1[19-irow]) AliTPCseed(*seed1);
5246 for (Int_t irow=0; irow<19;irow++){
5247 kinks[irow].SetMother(param0[irow]);
5248 kinks[irow].SetDaughter(param1[irow]);
5249 kinks[irow].Update();
5252 // choose kink with biggest change of angle
5254 Double_t maxchange= 0;
5255 for (Int_t irow=1;irow<19;irow++){
5256 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5257 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5258 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5259 if ( quality > maxchange){
5260 maxchange = quality;
5267 if (index<0) return 0;
5269 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5270 seed0 = new AliTPCseed(param0[index]);
5271 seed1 = new AliTPCseed(param1[index]);
5272 seed0->Reset(kFALSE);
5273 seed1->Reset(kFALSE);
5274 seed0->ResetCovariance(10.);
5275 seed1->ResetCovariance(10.);
5276 FollowProlongation(*seed0,0);
5277 FollowBackProlongation(*seed1,158);
5278 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5279 seed0->Reset(kFALSE);
5280 seed1->Reset(kFALSE);
5281 seed0->ResetCovariance(10.);
5282 seed1->ResetCovariance(10.);
5284 first = TMath::Max(row0-20,0);
5285 last = TMath::Min(row0+20,158);
5287 for (Int_t irow=0; irow<20;irow++){
5288 rows[irow] = first +((last-first)*irow)/19;
5290 // store parameters along the track
5292 for (Int_t irow=0;irow<20;irow++){
5293 FollowBackProlongation(*seed0, rows[irow]);
5294 FollowProlongation(*seed1,rows[19-irow]);
5295 new(¶m0[irow]) AliTPCseed(*seed0);
5296 new(¶m1[19-irow]) AliTPCseed(*seed1);
5300 for (Int_t irow=0; irow<19;irow++){
5301 kinks[irow].SetMother(param0[irow]);
5302 kinks[irow].SetDaughter(param1[irow]);
5303 // param0[irow].Dump();
5304 //param1[irow].Dump();
5305 kinks[irow].Update();
5308 // choose kink with biggest change of angle
5311 for (Int_t irow=0;irow<20;irow++){
5312 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5313 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5314 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5315 if ( quality > maxchange){
5316 maxchange = quality;
5323 if (index==-1 || param0[index].fN+param1[index].fN<100){
5328 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5330 kink.SetMother(param0[index]);
5331 kink.SetDaughter(param1[index]);
5333 row0 = GetRowNumber(kink.GetR());
5334 kink.SetTPCRow0(row0);
5335 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5336 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5337 kink.SetIndex(-10,0);
5338 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5339 kink.SetTPCncls(param0[index].fN,0);
5340 kink.SetTPCncls(param1[index].fN,1);
5343 // new (&mother) AliTPCseed(param0[index]);
5344 new (&daughter) AliTPCseed(param1[index]);
5345 daughter.SetLabel(kink.GetLabel(1));
5346 param0[index].Reset(kTRUE);
5347 FollowProlongation(param0[index],0);
5348 new (&mother) AliTPCseed(param0[index]);
5349 mother.SetLabel(kink.GetLabel(0));
5359 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5362 // reseed - refit - track
5365 // Int_t last = fSectors->GetNRows()-1;
5367 if (fSectors == fOuterSec){
5368 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5372 first = t->fFirstPoint;
5374 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5375 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5377 FollowProlongation(*t,first);
5387 //_____________________________________________________________________________
5388 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5389 //-----------------------------------------------------------------
5390 // This function reades track seeds.
5391 //-----------------------------------------------------------------
5392 TDirectory *savedir=gDirectory;
5394 TFile *in=(TFile*)inp;
5395 if (!in->IsOpen()) {
5396 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5401 TTree *seedTree=(TTree*)in->Get("Seeds");
5403 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5404 cerr<<"can't get a tree with track seeds !\n";
5407 AliTPCtrack *seed=new AliTPCtrack;
5408 seedTree->SetBranchAddress("tracks",&seed);
5410 if (fSeeds==0) fSeeds=new TObjArray(15000);
5412 Int_t n=(Int_t)seedTree->GetEntries();
5413 for (Int_t i=0; i<n; i++) {
5414 seedTree->GetEvent(i);
5415 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5424 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5427 if (fSeeds) DeleteSeeds();
5430 if (!fSeeds) return 1;
5437 //_____________________________________________________________________________
5438 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5439 //-----------------------------------------------------------------
5440 // This is a track finder.
5441 //-----------------------------------------------------------------
5442 TDirectory *savedir=gDirectory;
5446 fSeeds = Tracking();
5449 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5451 //activate again some tracks
5452 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5453 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5455 Int_t nc=t.GetNumberOfClusters();
5457 delete fSeeds->RemoveAt(i);
5461 if (pt->fRemoval==10) {
5462 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5463 pt->Desactivate(10); // make track again active
5465 pt->Desactivate(20);
5466 delete fSeeds->RemoveAt(i);
5471 RemoveUsed2(fSeeds,0.85,0.85,0);
5472 if (AliTPCReconstructor::GetRecoParam()->GetDoKinks()) FindKinks(fSeeds,fEvent);
5473 RemoveUsed2(fSeeds,0.5,0.4,20);
5475 // // refit short tracks
5477 Int_t nseed=fSeeds->GetEntriesFast();
5478 // for (Int_t i=0; i<nseed; i++) {
5479 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5480 // if (!pt) continue;
5481 // Int_t nc=t.GetNumberOfClusters();
5483 // delete fSeeds->RemoveAt(i);
5486 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5487 // if (nc>100) continue; // hopefully, enough for ITS
5488 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5489 // //seed2->Reset(kFALSE);
5490 // //pt->ResetCovariance();
5491 // seed2->Modify(1);
5492 // FollowBackProlongation(*seed2,158);
5493 // //seed2->Reset(kFALSE);
5494 // seed2->Modify(10);
5495 // FollowProlongation(*seed2,0);
5496 // TTreeSRedirector &cstream = *fDebugStreamer;
5497 // cstream<<"Crefit"<<
5501 // if (seed2->fN>pt->fN){
5502 // delete fSeeds->RemoveAt(i);
5503 // fSeeds->AddAt(seed2,i);
5508 // RemoveUsed2(fSeeds,0.6,0.6,50);
5510 // FindV0s(fSeeds,fEvent);
5511 //RemoveDouble(fSeeds,0.2,0.6,11);
5515 for (Int_t i=0; i<nseed; i++) {
5516 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5518 Int_t nc=t.GetNumberOfClusters();
5520 delete fSeeds->RemoveAt(i);
5523 CookLabel(pt,0.1); //For comparison only
5524 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5525 if ((pt->IsActive() || (pt->fRemoval==10) )){
5527 if (fDebug>0) cerr<<found<<'\r';
5531 delete fSeeds->RemoveAt(i);
5535 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5537 //RemoveUsed(fSeeds,0.9,0.9,6);
5539 nseed=fSeeds->GetEntriesFast();
5541 for (Int_t i=0; i<nseed; i++) {
5542 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5544 Int_t nc=t.GetNumberOfClusters();
5546 delete fSeeds->RemoveAt(i);
5550 t.CookdEdx(0.02,0.6);
5551 // CheckKinkPoint(&t,0.05);
5552 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5553 if ((pt->IsActive() || (pt->fRemoval==10) )){
5561 delete fSeeds->RemoveAt(i);
5562 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5564 // FollowProlongation(*seed1,0);
5565 // Int_t n = seed1->GetNumberOfClusters();
5566 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5567 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5570 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5574 SortTracks(fSeeds, 1);
5578 PrepareForBackProlongation(fSeeds,5.);
5579 PropagateBack(fSeeds);
5580 printf("Time for back propagation: \t");timer.Print();timer.Start();
5584 PrepareForProlongation(fSeeds,5.);
5585 PropagateForward2(fSeeds);
5587 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5588 // RemoveUsed(fSeeds,0.7,0.7,6);
5589 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5591 nseed=fSeeds->GetEntriesFast();
5593 for (Int_t i=0; i<nseed; i++) {
5594 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5596 Int_t nc=t.GetNumberOfClusters();
5598 delete fSeeds->RemoveAt(i);
5601 t.CookdEdx(0.02,0.6);
5602 // CookLabel(pt,0.1); //For comparison only
5603 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5604 if ((pt->IsActive() || (pt->fRemoval==10) )){
5605 cerr<<found++<<'\r';
5608 delete fSeeds->RemoveAt(i);
5613 // fNTracks = found;
5615 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5618 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5619 Info("Clusters2Tracks","Number of found tracks %d",found);
5621 // UnloadClusters();
5626 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5629 // tracking of the seeds
5632 fSectors = fOuterSec;
5633 ParallelTracking(arr,150,63);
5634 fSectors = fOuterSec;
5635 ParallelTracking(arr,63,0);
5638 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5643 TObjArray * arr = new TObjArray;
5645 fSectors = fOuterSec;
5648 for (Int_t sec=0;sec<fkNOS;sec++){
5649 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5650 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5651 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5654 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5666 TObjArray * AliTPCtrackerMI::Tracking()
5670 if (AliTPCReconstructor::GetRecoParam()->GetSpecialSeeding()) return TrackingSpecial();
5673 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5675 TObjArray * seeds = new TObjArray;
5684 Float_t fnumber = 3.0;
5685 Float_t fdensity = 3.0;
5690 for (Int_t delta = 0; delta<18; delta+=6){
5694 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5695 SumTracks(seeds,arr);
5696 SignClusters(seeds,fnumber,fdensity);
5698 for (Int_t i=2;i<6;i+=2){
5699 // seed high pt tracks
5702 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5703 SumTracks(seeds,arr);
5704 SignClusters(seeds,fnumber,fdensity);
5709 // RemoveUsed(seeds,0.9,0.9,1);
5710 // UnsignClusters();
5711 // SignClusters(seeds,fnumber,fdensity);
5715 for (Int_t delta = 20; delta<120; delta+=10){
5717 // seed high pt tracks
5721 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5722 SumTracks(seeds,arr);
5723 SignClusters(seeds,fnumber,fdensity);
5728 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5729 SumTracks(seeds,arr);
5730 SignClusters(seeds,fnumber,fdensity);
5741 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5745 // RemoveUsed(seeds,0.75,0.75,1);
5747 //SignClusters(seeds,fnumber,fdensity);
5756 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5757 SumTracks(seeds,arr);
5758 SignClusters(seeds,fnumber,fdensity);
5760 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5761 SumTracks(seeds,arr);
5762 SignClusters(seeds,fnumber,fdensity);
5764 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5765 SumTracks(seeds,arr);
5766 SignClusters(seeds,fnumber,fdensity);
5770 for (Int_t delta = 3; delta<30; delta+=5){
5776 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5777 SumTracks(seeds,arr);
5778 SignClusters(seeds,fnumber,fdensity);
5780 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5781 SumTracks(seeds,arr);
5782 SignClusters(seeds,fnumber,fdensity);
5794 for (Int_t delta = 30; delta<90; delta+=10){
5800 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5801 SumTracks(seeds,arr);
5802 SignClusters(seeds,fnumber,fdensity);
5804 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5805 SumTracks(seeds,arr);
5806 SignClusters(seeds,fnumber,fdensity);
5810 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5821 TObjArray * AliTPCtrackerMI::TrackingSpecial()
5824 // seeding adjusted for laser and cosmic tests - short tracks with big inclination angle
5825 // no primary vertex seeding tried
5829 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5831 TObjArray * seeds = new TObjArray;
5836 Float_t fnumber = 3.0;
5837 Float_t fdensity = 3.0;
5840 cuts[0] = AliTPCReconstructor::GetRecoParam()->GetMaxC(); // max curvature
5841 cuts[1] = 3.5; // max tan(phi) angle for seeding
5842 cuts[2] = 3.; // not used (cut on z primary vertex)
5843 cuts[3] = 3.5; // max tan(theta) angle for seeding
5845 for (Int_t delta = 0; nup-delta-gap-1>0; delta+=3){
5847 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5848 SumTracks(seeds,arr);
5849 SignClusters(seeds,fnumber,fdensity);
5853 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5864 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5867 //sum tracks to common container
5868 //remove suspicious tracks
5869 Int_t nseed = arr2->GetEntriesFast();
5870 for (Int_t i=0;i<nseed;i++){
5871 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5874 // remove tracks with too big curvature
5876 if (TMath::Abs(pt->GetC())>AliTPCReconstructor::GetRecoParam()->GetMaxC()){
5877 delete arr2->RemoveAt(i);
5880 // REMOVE VERY SHORT TRACKS
5881 if (pt->GetNumberOfClusters()<20){
5882 delete arr2->RemoveAt(i);
5885 // NORMAL ACTIVE TRACK
5886 if (pt->IsActive()){
5887 arr1->AddLast(arr2->RemoveAt(i));
5890 //remove not usable tracks
5891 if (pt->fRemoval!=10){
5892 delete arr2->RemoveAt(i);
5896 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5897 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5898 arr1->AddLast(arr2->RemoveAt(i));
5900 delete arr2->RemoveAt(i);
5909 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5912 // try to track in parralel
5914 Int_t nseed=arr->GetEntriesFast();
5915 //prepare seeds for tracking
5916 for (Int_t i=0; i<nseed; i++) {
5917 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5919 if (!t.IsActive()) continue;
5920 // follow prolongation to the first layer
5921 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5922 FollowProlongation(t, rfirst+1);
5927 for (Int_t nr=rfirst; nr>=rlast; nr--){
5928 if (nr<fInnerSec->GetNRows())
5929 fSectors = fInnerSec;
5931 fSectors = fOuterSec;
5932 // make indexes with the cluster tracks for given
5934 // find nearest cluster
5935 for (Int_t i=0; i<nseed; i++) {
5936 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5938 if (nr==80) pt->UpdateReference();
5939 if (!pt->IsActive()) continue;
5940 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5941 if (pt->fRelativeSector>17) {
5944 UpdateClusters(t,nr);
5946 // prolonagate to the nearest cluster - if founded
5947 for (Int_t i=0; i<nseed; i++) {
5948 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5950 if (!pt->IsActive()) continue;
5951 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5952 if (pt->fRelativeSector>17) {
5955 FollowToNextCluster(*pt,nr);
5960 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5964 // if we use TPC track itself we have to "update" covariance
5966 Int_t nseed= arr->GetEntriesFast();
5967 for (Int_t i=0;i<nseed;i++){
5968 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5972 //rotate to current local system at first accepted point
5973 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5974 Int_t sec = (index&0xff000000)>>24;
5976 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5977 if (angle1>TMath::Pi())
5978 angle1-=2.*TMath::Pi();
5979 Float_t angle2 = pt->GetAlpha();
5981 if (TMath::Abs(angle1-angle2)>0.001){
5982 pt->Rotate(angle1-angle2);
5983 //angle2 = pt->GetAlpha();
5984 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5985 //if (pt->GetAlpha()<0)
5986 // pt->fRelativeSector+=18;
5987 //sec = pt->fRelativeSector;
5996 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
6000 // if we use TPC track itself we have to "update" covariance
6002 Int_t nseed= arr->GetEntriesFast();
6003 for (Int_t i=0;i<nseed;i++){
6004 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6007 pt->fFirstPoint = pt->fLastPoint;
6015 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
6018 // make back propagation
6020 Int_t nseed= arr->GetEntriesFast();
6021 for (Int_t i=0;i<nseed;i++){
6022 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6023 if (pt&& pt->GetKinkIndex(0)<=0) {
6024 //AliTPCseed *pt2 = new AliTPCseed(*pt);
6025 fSectors = fInnerSec;
6026 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
6027 //fSectors = fOuterSec;
6028 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6029 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
6030 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
6031 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6034 if (pt&& pt->GetKinkIndex(0)>0) {
6035 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
6036 pt->fFirstPoint = kink->GetTPCRow0();
6037 fSectors = fInnerSec;
6038 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6046 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
6049 // make forward propagation
6051 Int_t nseed= arr->GetEntriesFast();
6053 for (Int_t i=0;i<nseed;i++){
6054 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6056 FollowProlongation(*pt,0);
6063 Int_t AliTPCtrackerMI::PropagateForward()
6066 // propagate track forward
6068 Int_t nseed = fSeeds->GetEntriesFast();
6069 for (Int_t i=0;i<nseed;i++){
6070 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
6072 AliTPCseed &t = *pt;
6073 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
6074 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
6075 if (alpha < 0. ) alpha += 2.*TMath::Pi();
6076 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
6080 fSectors = fOuterSec;
6081 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
6082 fSectors = fInnerSec;
6083 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
6093 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6096 // make back propagation, in between row0 and row1
6100 fSectors = fInnerSec;
6103 if (row1<fSectors->GetNRows())
6106 r1 = fSectors->GetNRows()-1;
6108 if (row0<fSectors->GetNRows()&& r1>0 )
6109 FollowBackProlongation(*pt,r1);
6110 if (row1<=fSectors->GetNRows())
6113 r1 = row1 - fSectors->GetNRows();
6114 if (r1<=0) return 0;
6115 if (r1>=fOuterSec->GetNRows()) return 0;
6116 fSectors = fOuterSec;
6117 return FollowBackProlongation(*pt,r1);
6125 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6129 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6130 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6131 Float_t padlength = GetPadPitchLength(row);
6133 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6134 Double_t angulary = seed->GetSnp();
6135 angulary = angulary*angulary/(1-angulary*angulary);
6136 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6138 Float_t sresz = fParam->GetZSigma();
6139 Float_t angularz = seed->GetTgl();
6140 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6142 Float_t wy = GetSigmaY(seed);
6143 Float_t wz = GetSigmaZ(seed);
6146 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6147 printf("problem\n");
6153 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6157 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6158 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6159 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6160 Float_t angular = seed->GetSnp();
6161 angular = angular*angular/(1-angular*angular);
6162 // angular*=angular;
6163 //angular = TMath::Sqrt(angular/(1-angular));
6164 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6167 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6171 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6172 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6173 Float_t sres = fParam->GetZSigma();
6174 Float_t angular = seed->GetTgl();
6175 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6180 //__________________________________________________________________________
6181 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6182 //--------------------------------------------------------------------
6183 //This function "cooks" a track label. If label<0, this track is fake.
6184 //--------------------------------------------------------------------
6185 AliTPCseed * t = (AliTPCseed*)tk;
6186 Int_t noc=t->GetNumberOfClusters();
6188 //printf("\nnot founded prolongation\n\n\n");
6194 AliTPCclusterMI *clusters[160];
6196 for (Int_t i=0;i<160;i++) {
6203 for (i=0; i<160 && current<noc; i++) {
6205 Int_t index=t->GetClusterIndex2(i);
6206 if (index<=0) continue;
6207 if (index&0x8000) continue;
6209 //clusters[current]=GetClusterMI(index);
6210 if (t->fClusterPointer[i]){
6211 clusters[current]=t->fClusterPointer[i];
6217 Int_t lab=123456789;
6218 for (i=0; i<noc; i++) {
6219 AliTPCclusterMI *c=clusters[i];
6221 lab=TMath::Abs(c->GetLabel(0));
6223 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6229 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6231 for (i=0; i<noc; i++) {
6232 AliTPCclusterMI *c=clusters[i];
6234 if (TMath::Abs(c->GetLabel(1)) == lab ||
6235 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6238 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6241 Int_t tail=Int_t(0.10*noc);
6244 for (i=1; i<=160&&ind<tail; i++) {
6245 // AliTPCclusterMI *c=clusters[noc-i];
6246 AliTPCclusterMI *c=clusters[i];
6248 if (lab == TMath::Abs(c->GetLabel(0)) ||
6249 lab == TMath::Abs(c->GetLabel(1)) ||
6250 lab == TMath::Abs(c->GetLabel(2))) max++;
6253 if (max < Int_t(0.5*tail)) lab=-lab;
6260 //delete[] clusters;
6264 //__________________________________________________________________________
6265 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6266 //--------------------------------------------------------------------
6267 //This function "cooks" a track label. If label<0, this track is fake.
6268 //--------------------------------------------------------------------
6269 Int_t noc=t->GetNumberOfClusters();
6271 //printf("\nnot founded prolongation\n\n\n");
6277 AliTPCclusterMI *clusters[160];
6279 for (Int_t i=0;i<160;i++) {
6286 for (i=0; i<160 && current<noc; i++) {
6287 if (i<first) continue;
6288 if (i>last) continue;
6289 Int_t index=t->GetClusterIndex2(i);
6290 if (index<=0) continue;
6291 if (index&0x8000) continue;
6293 //clusters[current]=GetClusterMI(index);
6294 if (t->fClusterPointer[i]){
6295 clusters[current]=t->fClusterPointer[i];
6300 if (noc<5) return -1;
6301 Int_t lab=123456789;
6302 for (i=0; i<noc; i++) {
6303 AliTPCclusterMI *c=clusters[i];
6305 lab=TMath::Abs(c->GetLabel(0));
6307 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6313 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6315 for (i=0; i<noc; i++) {
6316 AliTPCclusterMI *c=clusters[i];
6318 if (TMath::Abs(c->GetLabel(1)) == lab ||
6319 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6322 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6325 Int_t tail=Int_t(0.10*noc);
6328 for (i=1; i<=160&&ind<tail; i++) {
6329 // AliTPCclusterMI *c=clusters[noc-i];
6330 AliTPCclusterMI *c=clusters[i];
6332 if (lab == TMath::Abs(c->GetLabel(0)) ||
6333 lab == TMath::Abs(c->GetLabel(1)) ||
6334 lab == TMath::Abs(c->GetLabel(2))) max++;
6337 if (max < Int_t(0.5*tail)) lab=-lab;
6340 // t->SetLabel(lab);
6344 //delete[] clusters;
6348 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6350 //return pad row number for this x
6353 r=fRow[fN-1].GetX();
6354 if (x > r) return fN;
6356 if (x < r) return -1;
6357 return Int_t((x-r)/fPadPitchLength + 0.5);}
6359 r=fRow[fN-1].GetX();
6360 if (x > r) return fN;
6362 if (x < r) return -1;
6363 Double_t r1=fRow[64].GetX();
6365 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6367 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6371 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6373 //return pad row number for given x vector
6374 Float_t phi = TMath::ATan2(x[1],x[0]);
6375 if(phi<0) phi=2.*TMath::Pi()+phi;
6376 // Get the local angle in the sector philoc
6377 const Float_t kRaddeg = 180/3.14159265358979312;
6378 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6379 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6380 return GetRowNumber(localx);
6383 //_________________________________________________________________________
6384 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6385 //-----------------------------------------------------------------------
6386 // Setup inner sector
6387 //-----------------------------------------------------------------------
6389 fAlpha=par->GetInnerAngle();
6390 fAlphaShift=par->GetInnerAngleShift();
6391 fPadPitchWidth=par->GetInnerPadPitchWidth();
6392 fPadPitchLength=par->GetInnerPadPitchLength();
6393 fN=par->GetNRowLow();
6394 fRow=new AliTPCRow[fN];
6395 for (Int_t i=0; i<fN; i++) {
6396 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6397 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6400 fAlpha=par->GetOuterAngle();
6401 fAlphaShift=par->GetOuterAngleShift();
6402 fPadPitchWidth = par->GetOuterPadPitchWidth();
6403 fPadPitchLength = par->GetOuter1PadPitchLength();
6404 f1PadPitchLength = par->GetOuter1PadPitchLength();
6405 f2PadPitchLength = par->GetOuter2PadPitchLength();
6407 fN=par->GetNRowUp();
6408 fRow=new AliTPCRow[fN];
6409 for (Int_t i=0; i<fN; i++) {
6410 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6411 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6416 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6418 // default constructor
6426 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6433 //_________________________________________________________________________
6435 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6436 //-----------------------------------------------------------------------
6437 // Insert a cluster into this pad row in accordence with its y-coordinate
6438 //-----------------------------------------------------------------------
6439 if (fN==kMaxClusterPerRow) {
6440 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6442 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6443 Int_t i=Find(c->GetZ());
6444 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6445 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6446 fIndex[i]=index; fClusters[i]=c; fN++;
6449 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6455 //delete[] fClusterArray;
6456 if (fClusters1) delete []fClusters1;
6457 if (fClusters2) delete []fClusters2;
6464 //___________________________________________________________________
6465 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6466 //-----------------------------------------------------------------------
6467 // Return the index of the nearest cluster
6468 //-----------------------------------------------------------------------
6469 if (fN==0) return 0;
6470 if (z <= fClusters[0]->GetZ()) return 0;
6471 if (z > fClusters[fN-1]->GetZ()) return fN;
6472 Int_t b=0, e=fN-1, m=(b+e)/2;
6473 for (; b<e; m=(b+e)/2) {
6474 if (z > fClusters[m]->GetZ()) b=m+1;
6482 //___________________________________________________________________
6483 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6484 //-----------------------------------------------------------------------
6485 // Return the index of the nearest cluster in z y
6486 //-----------------------------------------------------------------------
6487 Float_t maxdistance = roady*roady + roadz*roadz;
6489 AliTPCclusterMI *cl =0;
6490 for (Int_t i=Find(z-roadz); i<fN; i++) {
6491 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6492 if (c->GetZ() > z+roadz) break;
6493 if ( (c->GetY()-y) > roady ) continue;
6494 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6495 if (maxdistance>distance) {
6496 maxdistance = distance;
6503 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6505 //-----------------------------------------------------------------------
6506 // Return the index of the nearest cluster in z y
6507 //-----------------------------------------------------------------------
6508 Float_t maxdistance = roady*roady + roadz*roadz;
6509 AliTPCclusterMI *cl =0;
6511 //PH Check boundaries. 510 is the size of fFastCluster
6512 Int_t iz1 = Int_t(z-roadz+254.5);
6513 if (iz1<0 || iz1>=510) return cl;
6514 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6515 Int_t iz2 = Int_t(z+roadz+255.5);
6516 if (iz2<0 || iz2>=510) return cl;
6517 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6519 //FindNearest3(y,z,roady,roadz,index);
6520 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6521 for (Int_t i=iz1; i<iz2; i++) {
6522 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6523 if (c->GetZ() > z+roadz) break;
6524 if ( c->GetY()-y > roady ) continue;
6525 if ( y-c->GetY() > roady ) continue;
6526 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6527 if (maxdistance>distance) {
6528 maxdistance = distance;
6531 //roady = TMath::Sqrt(maxdistance);
6539 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6541 //-----------------------------------------------------------------------
6542 // Return the index of the nearest cluster in z y
6543 //-----------------------------------------------------------------------
6544 Float_t maxdistance = roady*roady + roadz*roadz;
6545 // Int_t iz = Int_t(z+255.);
6546 AliTPCclusterMI *cl =0;
6547 for (Int_t i=Find(z-roadz); i<fN; i++) {
6548 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6549 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6550 if (c->GetZ() > z+roadz) break;
6551 if ( c->GetY()-y > roady ) continue;
6552 if ( y-c->GetY() > roady ) continue;
6553 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6554 if (maxdistance>distance) {
6555 maxdistance = distance;
6558 //roady = TMath::Sqrt(maxdistance);
6568 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6572 // return &fTrackPoints[i];