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>
34 #include "AliComplexCluster.h"
39 #include "AliRunLoader.h"
40 #include "AliTPCClustersRow.h"
41 #include "AliTPCParam.h"
42 #include "AliTPCReconstructor.h"
43 #include "AliTPCclusterMI.h"
44 #include "AliTPCpolyTrack.h"
45 #include "AliTPCreco.h"
46 #include "AliTPCseed.h"
47 #include "AliTPCtrackerMI.h"
48 #include "TStopwatch.h"
49 #include "AliTPCReconstructor.h"
51 #include "TTreeStream.h"
52 #include "AliAlignObj.h"
53 #include "AliTrackPointArray.h"
57 ClassImp(AliTPCtrackerMI)
60 class AliTPCFastMath {
63 static Double_t FastAsin(Double_t x);
65 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
68 Double_t AliTPCFastMath::fgFastAsin[20000];
69 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
71 AliTPCFastMath::AliTPCFastMath(){
73 // initialized lookup table;
74 for (Int_t i=0;i<10000;i++){
75 fgFastAsin[2*i] = TMath::ASin(i/10000.);
76 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
80 Double_t AliTPCFastMath::FastAsin(Double_t x){
82 // return asin using lookup table
84 Int_t index = int(x*10000);
85 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
88 Int_t index = int(x*10000);
89 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
95 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
97 //update track information using current cluster - track->fCurrentCluster
100 AliTPCclusterMI* c =track->fCurrentCluster;
101 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
103 UInt_t i = track->fCurrentClusterIndex1;
105 Int_t sec=(i&0xff000000)>>24;
106 //Int_t row = (i&0x00ff0000)>>16;
107 track->fRow=(i&0x00ff0000)>>16;
108 track->fSector = sec;
109 // Int_t index = i&0xFFFF;
110 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
111 track->SetClusterIndex2(track->fRow, i);
112 //track->fFirstPoint = row;
113 //if ( track->fLastPoint<row) track->fLastPoint =row;
114 // if (track->fRow<0 || track->fRow>160) {
115 // printf("problem\n");
117 if (track->fFirstPoint>track->fRow)
118 track->fFirstPoint = track->fRow;
119 if (track->fLastPoint<track->fRow)
120 track->fLastPoint = track->fRow;
123 track->fClusterPointer[track->fRow] = c;
126 Double_t angle2 = track->GetSnp()*track->GetSnp();
128 //SET NEW Track Point
130 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
132 angle2 = TMath::Sqrt(angle2/(1-angle2));
133 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
135 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
136 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
137 point.SetErrY(sqrt(track->fErrorY2));
138 point.SetErrZ(sqrt(track->fErrorZ2));
140 point.SetX(track->GetX());
141 point.SetY(track->GetY());
142 point.SetZ(track->GetZ());
143 point.SetAngleY(angle2);
144 point.SetAngleZ(track->GetTgl());
145 if (point.fIsShared){
146 track->fErrorY2 *= 4;
147 track->fErrorZ2 *= 4;
151 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
153 track->fErrorY2 *= 1.3;
154 track->fErrorY2 += 0.01;
155 track->fErrorZ2 *= 1.3;
156 track->fErrorZ2 += 0.005;
158 if (accept>0) return 0;
159 if (track->GetNumberOfClusters()%20==0){
160 // if (track->fHelixIn){
161 // TClonesArray & larr = *(track->fHelixIn);
162 // Int_t ihelix = larr.GetEntriesFast();
163 // new(larr[ihelix]) AliHelix(*track) ;
166 track->fNoCluster =0;
167 return track->Update(c,chi2,i);
172 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
173 Float_t cory, Float_t corz)
176 // decide according desired precision to accept given
177 // cluster for tracking
178 Double_t sy2=ErrY2(seed,cluster)*cory;
179 Double_t sz2=ErrZ2(seed,cluster)*corz;
180 //sy2=ErrY2(seed,cluster)*cory;
181 //sz2=ErrZ2(seed,cluster)*cory;
183 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
184 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
186 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
187 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
188 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
189 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
191 Double_t rdistance2 = rdistancey2+rdistancez2;
194 if (rdistance2>16) return 3;
197 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
198 return 2; //suspisiouce - will be changed
200 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
201 // strict cut on overlaped cluster
202 return 2; //suspisiouce - will be changed
204 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
205 && cluster->GetType()<0){
215 //_____________________________________________________________________________
216 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
217 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
219 //---------------------------------------------------------------------
220 // The main TPC tracker constructor
221 //---------------------------------------------------------------------
222 fInnerSec=new AliTPCSector[fkNIS];
223 fOuterSec=new AliTPCSector[fkNOS];
226 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
227 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
234 Int_t nrowlow = par->GetNRowLow();
235 Int_t nrowup = par->GetNRowUp();
238 for (Int_t i=0;i<nrowlow;i++){
239 fXRow[i] = par->GetPadRowRadiiLow(i);
240 fPadLength[i]= par->GetPadPitchLength(0,i);
241 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
245 for (Int_t i=0;i<nrowup;i++){
246 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
247 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
248 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
259 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
261 //________________________________________________________________________
262 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
267 //------------------------------------
268 // dummy copy constructor
269 //------------------------------------------------------------------
271 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
272 //------------------------------
274 //--------------------------------------------------------------
277 //_____________________________________________________________________________
278 AliTPCtrackerMI::~AliTPCtrackerMI() {
279 //------------------------------------------------------------------
280 // TPC tracker destructor
281 //------------------------------------------------------------------
288 if (fDebugStreamer) delete fDebugStreamer;
291 void AliTPCtrackerMI::SetIO()
295 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
297 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
299 AliTPCtrack *iotrack= new AliTPCtrack;
300 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
306 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
322 AliTPCtrack *iotrack= new AliTPCtrack;
323 // iotrack->fHelixIn = new TClonesArray("AliHelix");
324 //iotrack->fHelixOut = new TClonesArray("AliHelix");
325 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
328 if (output && (fDebug&2)){
329 //write the full seed information if specified in debug mode
331 fSeedTree = new TTree("Seeds","Seeds");
332 AliTPCseed * vseed = new AliTPCseed;
334 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
335 arrtr->ExpandCreateFast(160);
336 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
338 vseed->fPoints = arrtr;
339 vseed->fEPoints = arre;
340 // vseed->fClusterPoints = arrcl;
341 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
344 fTreeDebug = new TTree("trackDebug","trackDebug");
345 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
346 fTreeDebug->Branch("debug",&arrd,32000,99);
354 void AliTPCtrackerMI::FillESD(TObjArray* arr)
358 //fill esds using updated tracks
360 // write tracks to the event
361 // store index of the track
362 Int_t nseed=arr->GetEntriesFast();
363 //FindKinks(arr,fEvent);
364 for (Int_t i=0; i<nseed; i++) {
365 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
368 // pt->PropagateTo(fParam->GetInnerRadiusLow());
369 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
370 pt->PropagateTo(fParam->GetInnerRadiusLow());
373 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
375 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
376 iotrack.SetTPCPoints(pt->GetPoints());
377 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
378 iotrack.SetV0Indexes(pt->GetV0Indexes());
379 // iotrack.SetTPCpid(pt->fTPCr);
380 //iotrack.SetTPCindex(i);
381 fEvent->AddTrack(&iotrack);
385 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
387 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
388 iotrack.SetTPCPoints(pt->GetPoints());
389 //iotrack.SetTPCindex(i);
390 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
391 iotrack.SetV0Indexes(pt->GetV0Indexes());
392 // iotrack.SetTPCpid(pt->fTPCr);
393 fEvent->AddTrack(&iotrack);
397 // short tracks - maybe decays
399 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
400 Int_t found,foundable,shared;
401 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
402 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
404 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
405 //iotrack.SetTPCindex(i);
406 iotrack.SetTPCPoints(pt->GetPoints());
407 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
408 iotrack.SetV0Indexes(pt->GetV0Indexes());
409 //iotrack.SetTPCpid(pt->fTPCr);
410 fEvent->AddTrack(&iotrack);
415 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
416 Int_t found,foundable,shared;
417 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
418 if (found<20) continue;
419 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
422 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
423 iotrack.SetTPCPoints(pt->GetPoints());
424 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
425 iotrack.SetV0Indexes(pt->GetV0Indexes());
426 //iotrack.SetTPCpid(pt->fTPCr);
427 //iotrack.SetTPCindex(i);
428 fEvent->AddTrack(&iotrack);
431 // short tracks - secondaties
433 if ( (pt->GetNumberOfClusters()>30) ) {
434 Int_t found,foundable,shared;
435 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
436 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
438 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
439 iotrack.SetTPCPoints(pt->GetPoints());
440 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
441 iotrack.SetV0Indexes(pt->GetV0Indexes());
442 //iotrack.SetTPCpid(pt->fTPCr);
443 //iotrack.SetTPCindex(i);
444 fEvent->AddTrack(&iotrack);
449 if ( (pt->GetNumberOfClusters()>15)) {
450 Int_t found,foundable,shared;
451 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
452 if (found<15) continue;
453 if (foundable<=0) continue;
454 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
455 if (float(found)/float(foundable)<0.8) continue;
458 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
459 iotrack.SetTPCPoints(pt->GetPoints());
460 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
461 iotrack.SetV0Indexes(pt->GetV0Indexes());
462 // iotrack.SetTPCpid(pt->fTPCr);
463 //iotrack.SetTPCindex(i);
464 fEvent->AddTrack(&iotrack);
469 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
472 void AliTPCtrackerMI::WriteTracks(TTree * tree)
475 // write tracks from seed array to selected tree
479 AliTPCtrack *iotrack= new AliTPCtrack;
480 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
485 void AliTPCtrackerMI::WriteTracks()
488 // write tracks to the given output tree -
489 // output specified with SetIO routine
496 AliTPCtrack *iotrack= 0;
497 Int_t nseed=fSeeds->GetEntriesFast();
498 //for (Int_t i=0; i<nseed; i++) {
499 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
500 // if (iotrack) break;
502 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
503 TBranch * br = fOutput->GetBranch("tracks");
504 br->SetAddress(&iotrack);
506 for (Int_t i=0; i<nseed; i++) {
507 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
509 AliTPCtrack * track = new AliTPCtrack(*pt);
512 // br->SetAddress(&iotrack);
517 //fOutput->GetDirectory()->cd();
523 //write the full seed information if specified in debug mode
525 AliTPCseed * vseed = new AliTPCseed;
527 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
528 arrtr->ExpandCreateFast(160);
529 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
530 //arrcl->ExpandCreateFast(160);
531 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
533 vseed->fPoints = arrtr;
534 vseed->fEPoints = arre;
535 // vseed->fClusterPoints = arrcl;
536 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
537 TBranch * brseed = fSeedTree->GetBranch("seeds");
539 Int_t nseed=fSeeds->GetEntriesFast();
541 for (Int_t i=0; i<nseed; i++) {
542 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
545 // pt->fClusterPoints = arrcl;
549 brseed->SetAddress(&vseed);
553 // pt->fClusterPoints = 0;
556 if (fTreeDebug) fTreeDebug->Write();
564 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
567 //seed->SetErrorY2(0.1);
569 //calculate look-up table at the beginning
570 static Bool_t ginit = kFALSE;
571 static Float_t gnoise1,gnoise2,gnoise3;
572 static Float_t ggg1[10000];
573 static Float_t ggg2[10000];
574 static Float_t ggg3[10000];
575 static Float_t glandau1[10000];
576 static Float_t glandau2[10000];
577 static Float_t glandau3[10000];
579 static Float_t gcor01[500];
580 static Float_t gcor02[500];
581 static Float_t gcorp[500];
586 for (Int_t i=1;i<500;i++){
587 Float_t rsigma = float(i)/100.;
588 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
589 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
590 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
594 for (Int_t i=3;i<10000;i++){
598 Float_t amp = float(i);
599 Float_t padlength =0.75;
600 gnoise1 = 0.0004/padlength;
601 Float_t nel = 0.268*amp;
602 Float_t nprim = 0.155*amp;
603 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
604 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
605 if (glandau1[i]>1) glandau1[i]=1;
606 glandau1[i]*=padlength*padlength/12.;
610 gnoise2 = 0.0004/padlength;
613 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
614 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
615 if (glandau2[i]>1) glandau2[i]=1;
616 glandau2[i]*=padlength*padlength/12.;
621 gnoise3 = 0.0004/padlength;
624 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
625 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
626 if (glandau3[i]>1) glandau3[i]=1;
627 glandau3[i]*=padlength*padlength/12.;
635 Int_t amp = int(TMath::Abs(cl->GetQ()));
637 seed->SetErrorY2(1.);
641 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
642 Int_t ctype = cl->GetType();
643 Float_t padlength= GetPadPitchLength(seed->fRow);
644 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
645 angle2 = angle2/(1-angle2);
648 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
651 if (fSectors==fInnerSec){
653 res = ggg1[amp]*z+glandau1[amp]*angle2;
654 if (ctype==0) res *= gcor01[rsigmay];
657 res*= gcorp[rsigmay];
663 res = ggg2[amp]*z+glandau2[amp]*angle2;
664 if (ctype==0) res *= gcor02[rsigmay];
667 res*= gcorp[rsigmay];
672 res = ggg3[amp]*z+glandau3[amp]*angle2;
673 if (ctype==0) res *= gcor02[rsigmay];
676 res*= gcorp[rsigmay];
683 res*=2.4; // overestimate error 2 times
690 seed->SetErrorY2(res);
698 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
701 //seed->SetErrorY2(0.1);
703 //calculate look-up table at the beginning
704 static Bool_t ginit = kFALSE;
705 static Float_t gnoise1,gnoise2,gnoise3;
706 static Float_t ggg1[10000];
707 static Float_t ggg2[10000];
708 static Float_t ggg3[10000];
709 static Float_t glandau1[10000];
710 static Float_t glandau2[10000];
711 static Float_t glandau3[10000];
713 static Float_t gcor01[1000];
714 static Float_t gcor02[1000];
715 static Float_t gcorp[1000];
720 for (Int_t i=1;i<1000;i++){
721 Float_t rsigma = float(i)/100.;
722 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
723 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
724 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
728 for (Int_t i=3;i<10000;i++){
732 Float_t amp = float(i);
733 Float_t padlength =0.75;
734 gnoise1 = 0.0004/padlength;
735 Float_t nel = 0.268*amp;
736 Float_t nprim = 0.155*amp;
737 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
738 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
739 if (glandau1[i]>1) glandau1[i]=1;
740 glandau1[i]*=padlength*padlength/12.;
744 gnoise2 = 0.0004/padlength;
747 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
748 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
749 if (glandau2[i]>1) glandau2[i]=1;
750 glandau2[i]*=padlength*padlength/12.;
755 gnoise3 = 0.0004/padlength;
758 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
759 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
760 if (glandau3[i]>1) glandau3[i]=1;
761 glandau3[i]*=padlength*padlength/12.;
769 Int_t amp = int(TMath::Abs(cl->GetQ()));
771 seed->SetErrorY2(1.);
775 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
776 Int_t ctype = cl->GetType();
777 Float_t padlength= GetPadPitchLength(seed->fRow);
779 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
780 // if (angle2<0.6) angle2 = 0.6;
781 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
784 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
787 if (fSectors==fInnerSec){
789 res = ggg1[amp]*z+glandau1[amp]*angle2;
790 if (ctype==0) res *= gcor01[rsigmaz];
793 res*= gcorp[rsigmaz];
799 res = ggg2[amp]*z+glandau2[amp]*angle2;
800 if (ctype==0) res *= gcor02[rsigmaz];
803 res*= gcorp[rsigmaz];
808 res = ggg3[amp]*z+glandau3[amp]*angle2;
809 if (ctype==0) res *= gcor02[rsigmaz];
812 res*= gcorp[rsigmaz];
821 if ((ctype<0) &&<70){
829 seed->SetErrorZ2(res);
836 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
839 //seed->SetErrorZ2(0.1);
843 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
845 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
846 Int_t ctype = cl->GetType();
847 Float_t amp = TMath::Abs(cl->GetQ());
852 Float_t landau=2 ; //landau fluctuation part
853 Float_t gg=2; // gg fluctuation part
854 Float_t padlength= GetPadPitchLength(seed->GetX());
856 if (fSectors==fInnerSec){
857 snoise2 = 0.0004/padlength;
860 gg = (2+0.001*nel/(padlength*padlength))/nel;
861 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
862 if (landau>1) landau=1;
865 snoise2 = 0.0004/padlength;
868 gg = (2+0.0008*nel/(padlength*padlength))/nel;
869 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
870 if (landau>1) landau=1;
872 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
875 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
876 angle2 = TMath::Sqrt((1-angle2));
877 if (angle2<0.6) angle2 = 0.6;
880 Float_t angle = seed->GetTgl()/angle2;
881 Float_t angular = landau*angle*angle*padlength*padlength/12.;
882 Float_t res = sdiff + angular;
885 if ((ctype==0) && (fSectors ==fOuterSec))
886 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
888 if ((ctype==0) && (fSectors ==fInnerSec))
889 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
893 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
899 if ((ctype<0) &&<70){
907 seed->SetErrorZ2(res);
915 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
917 //rotate to track "local coordinata
918 Float_t x = seed->GetX();
919 Float_t y = seed->GetY();
920 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
923 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
924 if (!seed->Rotate(fSectors->GetAlpha()))
926 } else if (y <-ymax) {
927 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
928 if (!seed->Rotate(-fSectors->GetAlpha()))
936 //_____________________________________________________________________________
937 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
938 Double_t x2,Double_t y2,
939 Double_t x3,Double_t y3)
941 //-----------------------------------------------------------------
942 // Initial approximation of the track curvature
943 //-----------------------------------------------------------------
944 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
945 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
946 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
947 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
948 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
950 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
951 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
952 return -xr*yr/sqrt(xr*xr+yr*yr);
957 //_____________________________________________________________________________
958 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
959 Double_t x2,Double_t y2,
960 Double_t x3,Double_t y3)
962 //-----------------------------------------------------------------
963 // Initial approximation of the track curvature
964 //-----------------------------------------------------------------
970 Double_t det = x3*y2-x2*y3;
975 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
976 Double_t x0 = x3*0.5-y3*u;
977 Double_t y0 = y3*0.5+x3*u;
978 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
984 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
985 Double_t x2,Double_t y2,
986 Double_t x3,Double_t y3)
988 //-----------------------------------------------------------------
989 // Initial approximation of the track curvature
990 //-----------------------------------------------------------------
996 Double_t det = x3*y2-x2*y3;
1001 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1002 Double_t x0 = x3*0.5-y3*u;
1003 Double_t y0 = y3*0.5+x3*u;
1004 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1013 //_____________________________________________________________________________
1014 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1015 Double_t x2,Double_t y2,
1016 Double_t x3,Double_t y3)
1018 //-----------------------------------------------------------------
1019 // Initial approximation of the track curvature times center of curvature
1020 //-----------------------------------------------------------------
1021 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1022 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1023 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1024 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1025 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1027 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1029 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1032 //_____________________________________________________________________________
1033 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1034 Double_t x2,Double_t y2,
1035 Double_t z1,Double_t z2)
1037 //-----------------------------------------------------------------
1038 // Initial approximation of the tangent of the track dip angle
1039 //-----------------------------------------------------------------
1040 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1044 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1045 Double_t x2,Double_t y2,
1046 Double_t z1,Double_t z2, Double_t c)
1048 //-----------------------------------------------------------------
1049 // Initial approximation of the tangent of the track dip angle
1050 //-----------------------------------------------------------------
1054 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1056 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1057 if (TMath::Abs(d*c*0.5)>1) return 0;
1058 // Double_t angle2 = TMath::ASin(d*c*0.5);
1059 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1060 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1062 angle2 = (z1-z2)*c/(angle2*2.);
1066 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1067 {//-----------------------------------------------------------------
1068 // This function find proloncation of a track to a reference plane x=x2.
1069 //-----------------------------------------------------------------
1073 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1077 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1078 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1082 Double_t dy = dx*(c1+c2)/(r1+r2);
1085 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1087 if (TMath::Abs(delta)>0.01){
1088 dz = x[3]*TMath::ASin(delta)/x[4];
1090 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1093 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1101 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1106 return LoadClusters();
1109 Int_t AliTPCtrackerMI::LoadClusters()
1112 // load clusters to the memory
1113 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1114 clrow->SetClass("AliTPCclusterMI");
1116 clrow->GetArray()->ExpandCreateFast(10000);
1118 // TTree * tree = fClustersArray.GetTree();
1120 TTree * tree = fInput;
1121 TBranch * br = tree->GetBranch("Segment");
1122 br->SetAddress(&clrow);
1124 Int_t j=Int_t(tree->GetEntries());
1125 for (Int_t i=0; i<j; i++) {
1129 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1130 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1131 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1134 AliTPCRow * tpcrow=0;
1137 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1141 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1142 left = (sec-fkNIS*2)/fkNOS;
1145 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1146 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1147 for (Int_t i=0;i<tpcrow->fN1;i++)
1148 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1151 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1152 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1153 for (Int_t i=0;i<tpcrow->fN2;i++)
1154 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1165 void AliTPCtrackerMI::UnloadClusters()
1168 // unload clusters from the memory
1170 Int_t nrows = fOuterSec->GetNRows();
1171 for (Int_t sec = 0;sec<fkNOS;sec++)
1172 for (Int_t row = 0;row<nrows;row++){
1173 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1175 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1176 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1178 tpcrow->ResetClusters();
1181 nrows = fInnerSec->GetNRows();
1182 for (Int_t sec = 0;sec<fkNIS;sec++)
1183 for (Int_t row = 0;row<nrows;row++){
1184 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1186 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1187 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1189 tpcrow->ResetClusters();
1195 void AliTPCtrackerMI::Transform(AliCluster * cluster){
1199 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1200 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1202 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1204 //mat.LocalToMaster(pos,posC);
1205 mat->LocalToMaster(pos,posC);
1206 cluster->SetX(posC[0]);
1207 cluster->SetY(posC[1]);
1208 cluster->SetZ(posC[2]);
1211 //_____________________________________________________________________________
1212 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1213 //-----------------------------------------------------------------
1214 // This function fills outer TPC sectors with clusters.
1215 //-----------------------------------------------------------------
1216 Int_t nrows = fOuterSec->GetNRows();
1218 for (Int_t sec = 0;sec<fkNOS;sec++)
1219 for (Int_t row = 0;row<nrows;row++){
1220 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1221 Int_t sec2 = sec+2*fkNIS;
1223 Int_t ncl = tpcrow->fN1;
1225 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1226 index=(((sec2<<8)+row)<<16)+ncl;
1227 tpcrow->InsertCluster(c,index);
1232 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1233 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1234 tpcrow->InsertCluster(c,index);
1237 // write indexes for fast acces
1239 for (Int_t i=0;i<510;i++)
1240 tpcrow->fFastCluster[i]=-1;
1241 for (Int_t i=0;i<tpcrow->GetN();i++){
1242 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1243 tpcrow->fFastCluster[zi]=i; // write index
1246 for (Int_t i=0;i<510;i++){
1247 if (tpcrow->fFastCluster[i]<0)
1248 tpcrow->fFastCluster[i] = last;
1250 last = tpcrow->fFastCluster[i];
1259 //_____________________________________________________________________________
1260 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1261 //-----------------------------------------------------------------
1262 // This function fills inner TPC sectors with clusters.
1263 //-----------------------------------------------------------------
1264 Int_t nrows = fInnerSec->GetNRows();
1266 for (Int_t sec = 0;sec<fkNIS;sec++)
1267 for (Int_t row = 0;row<nrows;row++){
1268 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1271 Int_t ncl = tpcrow->fN1;
1273 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1274 index=(((sec<<8)+row)<<16)+ncl;
1275 tpcrow->InsertCluster(c,index);
1280 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1281 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1282 tpcrow->InsertCluster(c,index);
1285 // write indexes for fast acces
1287 for (Int_t i=0;i<510;i++)
1288 tpcrow->fFastCluster[i]=-1;
1289 for (Int_t i=0;i<tpcrow->GetN();i++){
1290 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1291 tpcrow->fFastCluster[zi]=i; // write index
1294 for (Int_t i=0;i<510;i++){
1295 if (tpcrow->fFastCluster[i]<0)
1296 tpcrow->fFastCluster[i] = last;
1298 last = tpcrow->fFastCluster[i];
1310 //_________________________________________________________________________
1311 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1312 //--------------------------------------------------------------------
1313 // Return pointer to a given cluster
1314 //--------------------------------------------------------------------
1315 if (index<0) return 0; // no cluster
1316 Int_t sec=(index&0xff000000)>>24;
1317 Int_t row=(index&0x00ff0000)>>16;
1318 Int_t ncl=(index&0x00007fff)>>00;
1320 const AliTPCRow * tpcrow=0;
1321 AliTPCclusterMI * clrow =0;
1323 if (sec<0 || sec>=fkNIS*4) {
1324 AliWarning(Form("Wrong sector %d",sec));
1329 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1330 if (tpcrow==0) return 0;
1333 if (tpcrow->fN1<=ncl) return 0;
1334 clrow = tpcrow->fClusters1;
1337 if (tpcrow->fN2<=ncl) return 0;
1338 clrow = tpcrow->fClusters2;
1342 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1343 if (tpcrow==0) return 0;
1345 if (sec-2*fkNIS<fkNOS) {
1346 if (tpcrow->fN1<=ncl) return 0;
1347 clrow = tpcrow->fClusters1;
1350 if (tpcrow->fN2<=ncl) return 0;
1351 clrow = tpcrow->fClusters2;
1355 return &(clrow[ncl]);
1361 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1362 //-----------------------------------------------------------------
1363 // This function tries to find a track prolongation to next pad row
1364 //-----------------------------------------------------------------
1366 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1367 AliTPCclusterMI *cl=0;
1368 Int_t tpcindex= t.GetClusterIndex2(nr);
1370 // update current shape info every 5 pad-row
1371 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1375 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1377 if (tpcindex==-1) return 0; //track in dead zone
1379 cl = t.fClusterPointer[nr];
1380 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1381 t.fCurrentClusterIndex1 = tpcindex;
1384 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1385 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1387 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1388 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1390 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1391 Double_t rotation = angle-t.GetAlpha();
1392 t.fRelativeSector= relativesector;
1393 if (!t.Rotate(rotation)) return 0;
1395 if (!t.PropagateTo(x)) return 0;
1397 t.fCurrentCluster = cl;
1399 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1400 if ((tpcindex&0x8000)==0) accept =0;
1402 //if founded cluster is acceptible
1403 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1410 UpdateTrack(&t,accept);
1415 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1417 // not look for new cluster during refitting
1423 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1424 Double_t y=t.GetYat(x);
1425 if (TMath::Abs(y)>ymax){
1427 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1428 if (!t.Rotate(fSectors->GetAlpha()))
1430 } else if (y <-ymax) {
1431 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1432 if (!t.Rotate(-fSectors->GetAlpha()))
1438 if (!t.PropagateTo(x)) {
1439 if (fIteration==0) t.fRemoval = 10;
1443 Double_t z=t.GetZ();
1445 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1446 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1448 Double_t roadz = 1.;
1450 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1452 t.SetClusterIndex2(nr,-1);
1457 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1464 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1465 cl = krow.FindNearest2(y,z,roady,roadz,index);
1466 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1469 t.fCurrentCluster = cl;
1471 if (fIteration==2&&cl->IsUsed(10)) return 0;
1472 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1473 if (fIteration==2&&cl->IsUsed(11)) {
1480 if (t.fCurrentCluster->IsUsed(10)){
1485 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1491 if (accept<3) UpdateTrack(&t,accept);
1494 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1500 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1501 //-----------------------------------------------------------------
1502 // This function tries to find a track prolongation to next pad row
1503 //-----------------------------------------------------------------
1505 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1507 if (!t.GetProlongation(x,y,z)) {
1513 if (TMath::Abs(y)>ymax){
1516 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1517 if (!t.Rotate(fSectors->GetAlpha()))
1519 } else if (y <-ymax) {
1520 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1521 if (!t.Rotate(-fSectors->GetAlpha()))
1524 if (!t.PropagateTo(x)) {
1527 t.GetProlongation(x,y,z);
1530 // update current shape info every 3 pad-row
1531 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1532 // t.fCurrentSigmaY = GetSigmaY(&t);
1533 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1537 AliTPCclusterMI *cl=0;
1542 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1543 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1545 Double_t roadz = 1.;
1548 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1550 t.SetClusterIndex2(row,-1);
1555 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1559 if ((cl==0)&&(krow)) {
1560 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1561 cl = krow.FindNearest2(y,z,roady,roadz,index);
1563 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1567 t.fCurrentCluster = cl;
1568 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1570 t.SetClusterIndex2(row,index);
1571 t.fClusterPointer[row] = cl;
1579 //_________________________________________________________________________
1580 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1582 // Get track space point by index
1583 // return false in case the cluster doesn't exist
1584 AliTPCclusterMI *cl = GetClusterMI(index);
1585 if (!cl) return kFALSE;
1586 Int_t sector = (index&0xff000000)>>24;
1587 // Int_t row = (index&0x00ff0000)>>16;
1589 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1590 xyz[0] = cl->GetX();
1591 xyz[1] = cl->GetY();
1592 xyz[2] = cl->GetZ();
1594 fParam->AdjustCosSin(sector,cos,sin);
1595 Float_t x = cos*xyz[0]-sin*xyz[1];
1596 Float_t y = cos*xyz[1]+sin*xyz[0];
1598 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1599 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1600 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1601 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1602 cov[0] = sin*sin*sigmaY2;
1603 cov[1] = -sin*cos*sigmaY2;
1605 cov[3] = cos*cos*sigmaY2;
1608 p.SetXYZ(x,y,xyz[2],cov);
1609 AliAlignObj::ELayerID iLayer;
1611 if (sector < fParam->GetNInnerSector()) {
1612 iLayer = AliAlignObj::kTPC1;
1616 iLayer = AliAlignObj::kTPC2;
1617 idet = sector - fParam->GetNInnerSector();
1619 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1620 p.SetVolumeID(volid);
1626 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1627 //-----------------------------------------------------------------
1628 // This function tries to find a track prolongation to next pad row
1629 //-----------------------------------------------------------------
1630 t.fCurrentCluster = 0;
1631 t.fCurrentClusterIndex1 = 0;
1633 Double_t xt=t.GetX();
1634 Int_t row = GetRowNumber(xt)-1;
1635 Double_t ymax= GetMaxY(nr);
1637 if (row < nr) return 1; // don't prolongate if not information until now -
1638 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1640 // return 0; // not prolongate strongly inclined tracks
1642 // if (TMath::Abs(t.GetSnp())>0.95) {
1644 // return 0; // not prolongate strongly inclined tracks
1645 // }// patch 28 fev 06
1647 Double_t x= GetXrow(nr);
1649 //t.PropagateTo(x+0.02);
1650 //t.PropagateTo(x+0.01);
1651 if (!t.PropagateTo(x)){
1658 if (TMath::Abs(y)>ymax){
1660 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1661 if (!t.Rotate(fSectors->GetAlpha()))
1663 } else if (y <-ymax) {
1664 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1665 if (!t.Rotate(-fSectors->GetAlpha()))
1668 // if (!t.PropagateTo(x)){
1675 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1676 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1678 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1680 t.SetClusterIndex2(nr,-1);
1685 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.fNFoundable++;
1691 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1692 // t.fCurrentSigmaY = GetSigmaY(&t);
1693 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1697 AliTPCclusterMI *cl=0;
1700 Double_t roady = 1.;
1701 Double_t roadz = 1.;
1705 index = t.GetClusterIndex2(nr);
1706 if ( (index>0) && (index&0x8000)==0){
1707 cl = t.fClusterPointer[nr];
1708 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1709 t.fCurrentClusterIndex1 = index;
1711 t.fCurrentCluster = cl;
1717 // if (index<0) return 0;
1718 UInt_t uindex = TMath::Abs(index);
1721 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1722 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1725 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1726 t.fCurrentCluster = cl;
1732 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1733 //-----------------------------------------------------------------
1734 // This function tries to find a track prolongation to next pad row
1735 //-----------------------------------------------------------------
1737 //update error according neighborhoud
1739 if (t.fCurrentCluster) {
1741 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1743 if (t.fCurrentCluster->IsUsed(10)){
1749 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1754 if (fIteration>0) accept = 0;
1755 if (accept<3) UpdateTrack(&t,accept);
1759 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1760 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1762 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1770 //_____________________________________________________________________________
1771 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1772 //-----------------------------------------------------------------
1773 // This function tries to find a track prolongation.
1774 //-----------------------------------------------------------------
1775 Double_t xt=t.GetX();
1777 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1778 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1779 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1781 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1783 Int_t first = GetRowNumber(xt)-1;
1784 for (Int_t nr= first; nr>=rf; nr-=step) {
1786 if (t.GetKinkIndexes()[0]>0){
1787 for (Int_t i=0;i<3;i++){
1788 Int_t index = t.GetKinkIndexes()[i];
1789 if (index==0) break;
1790 if (index<0) continue;
1792 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1794 printf("PROBLEM\n");
1797 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1799 AliExternalTrackParam paramd(t);
1800 kink->SetDaughter(paramd);
1801 kink->SetStatus(2,5);
1808 if (nr==80) t.UpdateReference();
1809 if (nr<fInnerSec->GetNRows())
1810 fSectors = fInnerSec;
1812 fSectors = fOuterSec;
1813 if (FollowToNext(t,nr)==0)
1822 //_____________________________________________________________________________
1823 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1824 //-----------------------------------------------------------------
1825 // This function tries to find a track prolongation.
1826 //-----------------------------------------------------------------
1827 Double_t xt=t.GetX();
1829 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1830 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1831 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1832 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1834 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1836 if (FollowToNextFast(t,nr)==0)
1837 if (!t.IsActive()) return 0;
1847 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1848 //-----------------------------------------------------------------
1849 // This function tries to find a track prolongation.
1850 //-----------------------------------------------------------------
1852 Double_t xt=t.GetX();
1853 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1854 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1855 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1856 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1858 Int_t first = t.fFirstPoint;
1859 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1861 if (first<0) first=0;
1862 for (Int_t nr=first; nr<=rf; nr++) {
1863 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1864 if (t.GetKinkIndexes()[0]<0){
1865 for (Int_t i=0;i<3;i++){
1866 Int_t index = t.GetKinkIndexes()[i];
1867 if (index==0) break;
1868 if (index>0) continue;
1869 index = TMath::Abs(index);
1870 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1872 printf("PROBLEM\n");
1875 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1877 AliExternalTrackParam paramm(t);
1878 kink->SetMother(paramm);
1879 kink->SetStatus(2,1);
1886 if (nr<fInnerSec->GetNRows())
1887 fSectors = fInnerSec;
1889 fSectors = fOuterSec;
1899 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1907 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1910 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1912 Float_t distance = TMath::Sqrt(dz2+dy2);
1913 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1916 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1917 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1922 if (firstpoint>lastpoint) {
1923 firstpoint =lastpoint;
1928 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1929 if (s1->GetClusterIndex2(i)>0) sum1++;
1930 if (s2->GetClusterIndex2(i)>0) sum2++;
1931 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1935 if (sum<5) return 0;
1937 Float_t summin = TMath::Min(sum1+1,sum2+1);
1938 Float_t ratio = (sum+1)/Float_t(summin);
1942 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1946 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1947 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1949 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1951 Float_t dy2 =(s1->GetY() - s2->GetY());
1953 Float_t distance = dz2+dy2;
1954 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1959 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1960 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1962 if (firstpoint>=lastpoint-5) return;;
1964 for (Int_t i=firstpoint;i<lastpoint;i++){
1965 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1966 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1973 for (Int_t i=firstpoint;i<lastpoint;i++){
1974 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1975 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1976 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1977 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1978 if (s1->IsActive()&&s2->IsActive()){
1979 p1->fIsShared = kTRUE;
1980 p2->fIsShared = kTRUE;
1987 for (Int_t i=0;i<4;i++){
1988 if (s1->fOverlapLabels[3*i]==0){
1989 s1->fOverlapLabels[3*i] = s2->GetLabel();
1990 s1->fOverlapLabels[3*i+1] = sumshared;
1991 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1995 for (Int_t i=0;i<4;i++){
1996 if (s2->fOverlapLabels[3*i]==0){
1997 s2->fOverlapLabels[3*i] = s1->GetLabel();
1998 s2->fOverlapLabels[3*i+1] = sumshared;
1999 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2007 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2010 //sort trackss according sectors
2012 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2013 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2015 //if (pt) RotateToLocal(pt);
2019 arr->Sort(); // sorting according z
2020 arr->Expand(arr->GetEntries());
2023 Int_t nseed=arr->GetEntriesFast();
2024 for (Int_t i=0; i<nseed; i++) {
2025 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2027 for (Int_t j=0;j<=12;j++){
2028 pt->fOverlapLabels[j] =0;
2031 for (Int_t i=0; i<nseed; i++) {
2032 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2034 if (pt->fRemoval>10) continue;
2035 for (Int_t j=i+1; j<nseed; j++){
2036 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2038 if (pt2->fRemoval<=10) {
2039 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2046 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2049 //sort trackss according sectors
2052 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2055 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2056 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2061 arr->Sort(); // sorting according z
2062 arr->Expand(arr->GetEntries());
2064 //reset overlap labels
2066 Int_t nseed=arr->GetEntriesFast();
2067 for (Int_t i=0; i<nseed; i++) {
2068 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2071 for (Int_t j=0;j<=12;j++){
2072 pt->fOverlapLabels[j] =0;
2076 //sign shared tracks
2077 for (Int_t i=0; i<nseed; i++) {
2078 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2080 if (pt->fRemoval>10) continue;
2081 Float_t deltac = pt->GetC()*0.1;
2082 for (Int_t j=i+1; j<nseed; j++){
2083 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2085 if (pt2->fRemoval<=10) {
2086 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2087 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2088 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2095 // remove highly shared tracks
2096 for (Int_t i=0; i<nseed; i++) {
2097 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2099 if (pt->fRemoval>10) continue;
2102 for (Int_t j=0;j<4;j++){
2103 sumshared = pt->fOverlapLabels[j*3+1];
2105 Float_t factor = factor1;
2106 if (pt->fRemoval>0) factor = factor2;
2107 if (sumshared/pt->GetNumberOfClusters()>factor){
2108 for (Int_t j=0;j<4;j++){
2109 if (pt->fOverlapLabels[3*j]==0) continue;
2110 if (pt->fOverlapLabels[3*j+1]<5) continue;
2111 if (pt->fRemoval==removalindex) continue;
2112 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2114 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2115 // pt->fRemoval = removalindex;
2116 delete arr->RemoveAt(i);
2124 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2133 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2136 //sort tracks in array according mode criteria
2137 Int_t nseed = arr->GetEntriesFast();
2138 for (Int_t i=0; i<nseed; i++) {
2139 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2149 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2152 //Loop over all tracks and remove "overlaps"
2155 Int_t nseed = arr->GetEntriesFast();
2158 for (Int_t i=0; i<nseed; i++) {
2159 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2161 delete arr->RemoveAt(i);
2165 pt->fBSigned = kFALSE;
2169 nseed = arr->GetEntriesFast();
2176 for (Int_t i=0; i<nseed; i++) {
2177 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2181 Int_t found,foundable,shared;
2183 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2185 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2187 Double_t factor = factor2;
2188 if (pt->fBConstrain) factor = factor1;
2190 if ((Float_t(shared)/Float_t(found))>factor){
2191 pt->Desactivate(removalindex);
2196 for (Int_t i=0; i<160; i++) {
2197 Int_t index=pt->GetClusterIndex2(i);
2198 if (index<0 || index&0x8000 ) continue;
2199 AliTPCclusterMI *c= pt->fClusterPointer[i];
2201 // if (!c->IsUsed(10)) c->Use(10);
2202 //if (pt->IsActive())
2211 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2216 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2219 //Loop over all tracks and remove "overlaps"
2224 Int_t nseed = arr->GetEntriesFast();
2225 Float_t * quality = new Float_t[nseed];
2226 Int_t * indexes = new Int_t[nseed];
2230 for (Int_t i=0; i<nseed; i++) {
2231 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2236 pt->UpdatePoints(); //select first last max dens points
2237 Float_t * points = pt->GetPoints();
2238 if (points[3]<0.8) quality[i] =-1;
2240 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2242 TMath::Sort(nseed,quality,indexes);
2245 for (Int_t itrack=0; itrack<nseed; itrack++) {
2246 Int_t trackindex = indexes[itrack];
2247 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2248 if (quality[trackindex]<0){
2250 delete arr->RemoveAt(trackindex);
2253 arr->RemoveAt(trackindex);
2258 Int_t first = Int_t(pt->GetPoints()[0]);
2259 Int_t last = Int_t(pt->GetPoints()[2]);
2260 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2262 Int_t found,foundable,shared;
2263 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2264 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2265 Bool_t itsgold =kFALSE;
2268 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
2272 if (Float_t(shared+1)/Float_t(found+1)>factor){
2273 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2274 delete arr->RemoveAt(trackindex);
2277 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2278 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2279 delete arr->RemoveAt(trackindex);
2285 if (sharedfactor>0.4) continue;
2286 if (pt->GetKinkIndexes()[0]>0) continue;
2287 for (Int_t i=first; i<last; i++) {
2288 Int_t index=pt->GetClusterIndex2(i);
2289 // if (index<0 || index&0x8000 ) continue;
2290 if (index<0 || index&0x8000 ) continue;
2291 AliTPCclusterMI *c= pt->fClusterPointer[i];
2298 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2304 void AliTPCtrackerMI::UnsignClusters()
2307 // loop over all clusters and unsign them
2310 for (Int_t sec=0;sec<fkNIS;sec++){
2311 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2312 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2313 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2314 // if (cl[icl].IsUsed(10))
2316 cl = fInnerSec[sec][row].fClusters2;
2317 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2318 //if (cl[icl].IsUsed(10))
2323 for (Int_t sec=0;sec<fkNOS;sec++){
2324 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2325 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2326 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2327 //if (cl[icl].IsUsed(10))
2329 cl = fOuterSec[sec][row].fClusters2;
2330 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2331 //if (cl[icl].IsUsed(10))
2340 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2343 //sign clusters to be "used"
2345 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2346 // loop over "primaries"
2360 Int_t nseed = arr->GetEntriesFast();
2361 for (Int_t i=0; i<nseed; i++) {
2362 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2366 if (!(pt->IsActive())) continue;
2367 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2368 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2370 sumdens2+= dens*dens;
2371 sumn += pt->GetNumberOfClusters();
2372 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2373 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2376 sumchi2 +=chi2*chi2;
2381 Float_t mdensity = 0.9;
2382 Float_t meann = 130;
2383 Float_t meanchi = 1;
2384 Float_t sdensity = 0.1;
2385 Float_t smeann = 10;
2386 Float_t smeanchi =0.4;
2390 mdensity = sumdens/sum;
2392 meanchi = sumchi/sum;
2394 sdensity = sumdens2/sum-mdensity*mdensity;
2395 sdensity = TMath::Sqrt(sdensity);
2397 smeann = sumn2/sum-meann*meann;
2398 smeann = TMath::Sqrt(smeann);
2400 smeanchi = sumchi2/sum - meanchi*meanchi;
2401 smeanchi = TMath::Sqrt(smeanchi);
2405 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2407 for (Int_t i=0; i<nseed; i++) {
2408 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2412 if (pt->fBSigned) continue;
2413 if (pt->fBConstrain) continue;
2414 //if (!(pt->IsActive())) continue;
2416 Int_t found,foundable,shared;
2417 pt->GetClusterStatistic(0,160,found, foundable,shared);
2418 if (shared/float(found)>0.3) {
2419 if (shared/float(found)>0.9 ){
2420 //delete arr->RemoveAt(i);
2425 Bool_t isok =kFALSE;
2426 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2428 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2430 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2432 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2436 for (Int_t i=0; i<160; i++) {
2437 Int_t index=pt->GetClusterIndex2(i);
2438 if (index<0) continue;
2439 AliTPCclusterMI *c= pt->fClusterPointer[i];
2441 //if (!(c->IsUsed(10))) c->Use();
2448 Double_t maxchi = meanchi+2.*smeanchi;
2450 for (Int_t i=0; i<nseed; i++) {
2451 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2455 //if (!(pt->IsActive())) continue;
2456 if (pt->fBSigned) continue;
2457 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2458 if (chi>maxchi) continue;
2461 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2463 //sign only tracks with enoug big density at the beginning
2465 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2468 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2469 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2471 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2472 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2475 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2476 //Int_t noc=pt->GetNumberOfClusters();
2477 pt->fBSigned = kTRUE;
2478 for (Int_t i=0; i<160; i++) {
2480 Int_t index=pt->GetClusterIndex2(i);
2481 if (index<0) continue;
2482 AliTPCclusterMI *c= pt->fClusterPointer[i];
2484 // if (!(c->IsUsed(10))) c->Use();
2489 // gLastCheck = nseed;
2497 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2499 // stop not active tracks
2500 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2501 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2502 Int_t nseed = arr->GetEntriesFast();
2504 for (Int_t i=0; i<nseed; i++) {
2505 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2509 if (!(pt->IsActive())) continue;
2510 StopNotActive(pt,row0,th0, th1,th2);
2516 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2519 // stop not active tracks
2520 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2521 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2524 Int_t foundable = 0;
2525 Int_t maxindex = seed->fLastPoint; //last foundable row
2526 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2527 seed->Desactivate(10) ;
2531 for (Int_t i=row0; i<maxindex; i++){
2532 Int_t index = seed->GetClusterIndex2(i);
2533 if (index!=-1) foundable++;
2535 if (foundable<=30) sumgood1++;
2536 if (foundable<=50) {
2543 if (foundable>=30.){
2544 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2547 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2551 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2554 // back propagation of ESD tracks
2560 //PrepareForProlongation(fSeeds,1);
2561 PropagateForward2(fSeeds);
2564 Int_t nseed = fSeeds->GetEntriesFast();
2565 for (Int_t i=0;i<nseed;i++){
2566 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2567 if (!seed) continue;
2568 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2570 seed->PropagateTo(fParam->GetInnerRadiusLow());
2571 seed->UpdatePoints();
2572 AliESDtrack *esd=event->GetTrack(i);
2573 seed->CookdEdx(0.02,0.6);
2574 CookLabel(seed,0.1); //For comparison only
2576 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2577 TTreeSRedirector &cstream = *fDebugStreamer;
2583 if (seed->GetNumberOfClusters()>15){
2584 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2585 esd->SetTPCPoints(seed->GetPoints());
2586 esd->SetTPCPointsF(seed->fNFoundable);
2587 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2588 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2589 Float_t dedx = seed->GetdEdx();
2590 esd->SetTPCsignal(dedx, sdedx, ndedx);
2592 // add seed to the esd track in Calib level
2594 if (AliTPCReconstructor::StreamLevel()>0){
2595 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2596 esd->AddCalibObject(seedCopy);
2601 //printf("problem\n");
2604 //FindKinks(fSeeds,event);
2605 Info("RefitInward","Number of refitted tracks %d",ntracks);
2612 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2615 // back propagation of ESD tracks
2621 PropagateBack(fSeeds);
2622 RemoveUsed2(fSeeds,0.4,0.4,20);
2624 Int_t nseed = fSeeds->GetEntriesFast();
2626 for (Int_t i=0;i<nseed;i++){
2627 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2628 if (!seed) continue;
2629 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2630 seed->UpdatePoints();
2631 AliESDtrack *esd=event->GetTrack(i);
2632 seed->CookdEdx(0.02,0.6);
2633 CookLabel(seed,0.1); //For comparison only
2634 if (seed->GetNumberOfClusters()>15){
2635 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2636 esd->SetTPCPoints(seed->GetPoints());
2637 esd->SetTPCPointsF(seed->fNFoundable);
2638 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2639 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2640 Float_t dedx = seed->GetdEdx();
2641 esd->SetTPCsignal(dedx, sdedx, ndedx);
2643 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2644 (*fDebugStreamer)<<"Cback"<<
2646 "EventNr="<<eventnumber<<
2647 "\n"; // patch 28 fev 06
2650 //FindKinks(fSeeds,event);
2651 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2659 void AliTPCtrackerMI::DeleteSeeds()
2664 Int_t nseed = fSeeds->GetEntriesFast();
2665 for (Int_t i=0;i<nseed;i++){
2666 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2667 if (seed) delete fSeeds->RemoveAt(i);
2674 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2677 //read seeds from the event
2679 Int_t nentr=event->GetNumberOfTracks();
2681 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2686 fSeeds = new TObjArray(nentr);
2690 for (Int_t i=0; i<nentr; i++) {
2691 AliESDtrack *esd=event->GetTrack(i);
2692 ULong_t status=esd->GetStatus();
2693 if (!(status&AliESDtrack::kTPCin)) continue;
2694 AliTPCtrack t(*esd);
2695 t.SetNumberOfClusters(0);
2696 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2697 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2698 for (Int_t ikink=0;ikink<3;ikink++) {
2699 Int_t index = esd->GetKinkIndex(ikink);
2700 seed->GetKinkIndexes()[ikink] = index;
2701 if (index==0) continue;
2702 index = TMath::Abs(index);
2703 AliESDkink * kink = fEvent->GetKink(index-1);
2704 if (kink&&esd->GetKinkIndex(ikink)<0){
2705 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2706 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2708 if (kink&&esd->GetKinkIndex(ikink)>0){
2709 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2710 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2714 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance(10.);
2715 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance(10.);
2716 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2721 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2722 Double_t par0[5],par1[5],alpha,x;
2723 esd->GetInnerExternalParameters(alpha,x,par0);
2724 esd->GetExternalParameters(x,par1);
2725 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2726 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2728 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2729 //reset covariance if suspicious
2730 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2731 seed->ResetCovariance(10.);
2736 // rotate to the local coordinate system
2738 fSectors=fInnerSec; fN=fkNIS;
2739 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2740 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2741 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2742 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2743 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2744 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2745 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2746 alpha-=seed->GetAlpha();
2747 if (!seed->Rotate(alpha)) {
2753 if (esd->GetKinkIndex(0)<=0){
2754 for (Int_t irow=0;irow<160;irow++){
2755 Int_t index = seed->GetClusterIndex2(irow);
2758 AliTPCclusterMI * cl = GetClusterMI(index);
2759 seed->fClusterPointer[irow] = cl;
2761 if ((index & 0x8000)==0){
2762 cl->Use(10); // accepted cluster
2764 cl->Use(6); // close cluster not accepted
2767 Info("ReadSeeds","Not found cluster");
2772 fSeeds->AddAt(seed,i);
2778 //_____________________________________________________________________________
2779 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2780 Float_t deltay, Int_t ddsec) {
2781 //-----------------------------------------------------------------
2782 // This function creates track seeds.
2783 // SEEDING WITH VERTEX CONSTRAIN
2784 //-----------------------------------------------------------------
2785 // cuts[0] - fP4 cut
2786 // cuts[1] - tan(phi) cut
2787 // cuts[2] - zvertex cut
2788 // cuts[3] - fP3 cut
2796 Double_t x[5], c[15];
2797 // Int_t di = i1-i2;
2799 AliTPCseed * seed = new AliTPCseed;
2800 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2801 Double_t cs=cos(alpha), sn=sin(alpha);
2803 // Double_t x1 =fOuterSec->GetX(i1);
2804 //Double_t xx2=fOuterSec->GetX(i2);
2806 Double_t x1 =GetXrow(i1);
2807 Double_t xx2=GetXrow(i2);
2809 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2811 Int_t imiddle = (i2+i1)/2; //middle pad row index
2812 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2813 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2817 const AliTPCRow& kr1=GetRow(ns,i1);
2818 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2819 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2822 // change cut on curvature if it can't reach this layer
2823 // maximal curvature set to reach it
2824 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2825 if (dvertexmax*0.5*cuts[0]>0.85){
2826 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2828 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2831 if (deltay>0) ddsec = 0;
2832 // loop over clusters
2833 for (Int_t is=0; is < kr1; is++) {
2835 if (kr1[is]->IsUsed(10)) continue;
2836 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2837 //if (TMath::Abs(y1)>ymax) continue;
2839 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2841 // find possible directions
2842 Float_t anglez = (z1-z3)/(x1-x3);
2843 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2846 //find rotation angles relative to line given by vertex and point 1
2847 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2848 Double_t dvertex = TMath::Sqrt(dvertex2);
2849 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2850 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2853 // loop over 2 sectors
2859 Double_t dddz1=0; // direction of delta inclination in z axis
2866 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2867 Int_t sec2 = sec + dsec;
2869 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2870 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2871 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2872 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2873 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2874 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2876 // rotation angles to p1-p3
2877 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2878 Double_t x2, y2, z2;
2880 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2883 Double_t dxx0 = (xx2-x3)*cs13r;
2884 Double_t dyy0 = (xx2-x3)*sn13r;
2885 for (Int_t js=index1; js < index2; js++) {
2886 const AliTPCclusterMI *kcl = kr2[js];
2887 if (kcl->IsUsed(10)) continue;
2889 //calcutate parameters
2891 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2893 if (TMath::Abs(yy0)<0.000001) continue;
2894 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2895 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2896 Double_t r02 = (0.25+y0*y0)*dvertex2;
2897 //curvature (radius) cut
2898 if (r02<r2min) continue;
2902 Double_t c0 = 1/TMath::Sqrt(r02);
2906 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2907 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2908 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2909 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2912 Double_t z0 = kcl->GetZ();
2913 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2914 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2917 Double_t dip = (z1-z0)*c0/dfi1;
2918 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2929 x2= xx2*cs-y2*sn*dsec;
2930 y2=+xx2*sn*dsec+y2*cs;
2940 // do we have cluster at the middle ?
2942 GetProlongation(x1,xm,x,ym,zm);
2944 AliTPCclusterMI * cm=0;
2945 if (TMath::Abs(ym)-ymaxm<0){
2946 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2947 if ((!cm) || (cm->IsUsed(10))) {
2952 // rotate y1 to system 0
2953 // get state vector in rotated system
2954 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2955 Double_t xr2 = x0*cs+yr1*sn*dsec;
2956 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2958 GetProlongation(xx2,xm,xr,ym,zm);
2959 if (TMath::Abs(ym)-ymaxm<0){
2960 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2961 if ((!cm) || (cm->IsUsed(10))) {
2971 dym = ym - cm->GetY();
2972 dzm = zm - cm->GetZ();
2979 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2980 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2981 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2982 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2983 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2985 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2986 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2987 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2988 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2989 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2990 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2992 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2993 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2994 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2995 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2999 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3000 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3001 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3002 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3003 c[13]=f30*sy1*f40+f32*sy2*f42;
3004 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3006 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3008 UInt_t index=kr1.GetIndex(is);
3009 AliTPCseed *track=new(seed) AliTPCseed(x1, ns*alpha+shift, x, c, index);
3011 track->fIsSeeding = kTRUE;
3018 FollowProlongation(*track, (i1+i2)/2,1);
3019 Int_t foundable,found,shared;
3020 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3021 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3023 seed->~AliTPCseed();
3029 FollowProlongation(*track, i2,1);
3033 track->fBConstrain =1;
3034 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3035 track->fLastPoint = i1; // first cluster in track position
3036 track->fFirstPoint = track->fLastPoint;
3038 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3039 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3040 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3042 seed->~AliTPCseed();
3046 // Z VERTEX CONDITION
3048 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3049 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3050 if (TMath::Abs(zv-z3)>cuts[2]) {
3051 FollowProlongation(*track, TMath::Max(i2-20,0));
3052 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3053 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3054 if (TMath::Abs(zv-z3)>cuts[2]){
3055 FollowProlongation(*track, TMath::Max(i2-40,0));
3056 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3057 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3058 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3059 // make seed without constrain
3060 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3061 FollowProlongation(*track2, i2,1);
3062 track2->fBConstrain = kFALSE;
3063 track2->fSeedType = 1;
3064 arr->AddLast(track2);
3066 seed->~AliTPCseed();
3071 seed->~AliTPCseed();
3078 track->fSeedType =0;
3079 arr->AddLast(track);
3080 seed = new AliTPCseed;
3082 // don't consider other combinations
3083 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3089 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3095 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3100 //-----------------------------------------------------------------
3101 // This function creates track seeds.
3102 //-----------------------------------------------------------------
3103 // cuts[0] - fP4 cut
3104 // cuts[1] - tan(phi) cut
3105 // cuts[2] - zvertex cut
3106 // cuts[3] - fP3 cut
3116 Double_t x[5], c[15];
3118 // make temporary seed
3119 AliTPCseed * seed = new AliTPCseed;
3120 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3121 // Double_t cs=cos(alpha), sn=sin(alpha);
3126 Double_t x1 = GetXrow(i1-1);
3127 const AliTPCRow& kr1=GetRow(sec,i1-1);
3128 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3130 Double_t x1p = GetXrow(i1);
3131 const AliTPCRow& kr1p=GetRow(sec,i1);
3133 Double_t x1m = GetXrow(i1-2);
3134 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3137 //last 3 padrow for seeding
3138 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3139 Double_t x3 = GetXrow(i1-7);
3140 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3142 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3143 Double_t x3p = GetXrow(i1-6);
3145 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3146 Double_t x3m = GetXrow(i1-8);
3151 Int_t im = i1-4; //middle pad row index
3152 Double_t xm = GetXrow(im); // radius of middle pad-row
3153 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3154 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3157 Double_t deltax = x1-x3;
3158 Double_t dymax = deltax*cuts[1];
3159 Double_t dzmax = deltax*cuts[3];
3161 // loop over clusters
3162 for (Int_t is=0; is < kr1; is++) {
3164 if (kr1[is]->IsUsed(10)) continue;
3165 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3167 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3169 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3170 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3176 for (Int_t js=index1; js < index2; js++) {
3177 const AliTPCclusterMI *kcl = kr3[js];
3178 if (kcl->IsUsed(10)) continue;
3180 // apply angular cuts
3181 if (TMath::Abs(y1-y3)>dymax) continue;
3184 if (TMath::Abs(z1-z3)>dzmax) continue;
3186 Double_t angley = (y1-y3)/(x1-x3);
3187 Double_t anglez = (z1-z3)/(x1-x3);
3189 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3190 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3192 Double_t yyym = angley*(xm-x1)+y1;
3193 Double_t zzzm = anglez*(xm-x1)+z1;
3195 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3197 if (kcm->IsUsed(10)) continue;
3199 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3200 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3207 // look around first
3208 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3214 if (kc1m->IsUsed(10)) used++;
3216 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3222 if (kc1p->IsUsed(10)) used++;
3224 if (used>1) continue;
3225 if (found<1) continue;
3229 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3235 if (kc3m->IsUsed(10)) used++;
3239 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3245 if (kc3p->IsUsed(10)) used++;
3249 if (used>1) continue;
3250 if (found<3) continue;
3260 x[4]=F1(x1,y1,x2,y2,x3,y3);
3261 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3264 x[2]=F2(x1,y1,x2,y2,x3,y3);
3267 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3268 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3272 Double_t sy1=0.1, sz1=0.1;
3273 Double_t sy2=0.1, sz2=0.1;
3274 Double_t sy3=0.1, sy=0.1, sz=0.1;
3276 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3277 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3278 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3279 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3280 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3281 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3283 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3284 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3285 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3286 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3290 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3291 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3292 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3293 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3294 c[13]=f30*sy1*f40+f32*sy2*f42;
3295 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3297 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3299 UInt_t index=kr1.GetIndex(is);
3300 AliTPCseed *track=new(seed) AliTPCseed(x1, sec*alpha+shift, x, c, index);
3302 track->fIsSeeding = kTRUE;
3305 FollowProlongation(*track, i1-7,1);
3306 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3307 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3309 seed->~AliTPCseed();
3315 FollowProlongation(*track, i2,1);
3316 track->fBConstrain =0;
3317 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3318 track->fFirstPoint = track->fLastPoint;
3320 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3321 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3322 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3324 seed->~AliTPCseed();
3329 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3330 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3331 FollowProlongation(*track2, i2,1);
3332 track2->fBConstrain = kFALSE;
3333 track2->fSeedType = 4;
3334 arr->AddLast(track2);
3336 seed->~AliTPCseed();
3340 //arr->AddLast(track);
3341 //seed = new AliTPCseed;
3347 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3353 //_____________________________________________________________________________
3354 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3355 Float_t deltay, Bool_t /*bconstrain*/) {
3356 //-----------------------------------------------------------------
3357 // This function creates track seeds - without vertex constraint
3358 //-----------------------------------------------------------------
3359 // cuts[0] - fP4 cut - not applied
3360 // cuts[1] - tan(phi) cut
3361 // cuts[2] - zvertex cut - not applied
3362 // cuts[3] - fP3 cut
3372 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3373 // Double_t cs=cos(alpha), sn=sin(alpha);
3374 Int_t row0 = (i1+i2)/2;
3375 Int_t drow = (i1-i2)/2;
3376 const AliTPCRow& kr0=fSectors[sec][row0];
3379 AliTPCpolyTrack polytrack;
3380 Int_t nclusters=fSectors[sec][row0];
3381 AliTPCseed * seed = new AliTPCseed;
3386 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3388 Int_t nfoundable =0;
3389 for (Int_t iter =1; iter<2; iter++){ //iterations
3390 const AliTPCRow& krm=fSectors[sec][row0-iter];
3391 const AliTPCRow& krp=fSectors[sec][row0+iter];
3392 const AliTPCclusterMI * cl= kr0[is];
3394 if (cl->IsUsed(10)) {
3400 Double_t x = kr0.GetX();
3401 // Initialization of the polytrack
3406 Double_t y0= cl->GetY();
3407 Double_t z0= cl->GetZ();
3411 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3412 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3414 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3415 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3416 polytrack.AddPoint(x,y0,z0,erry, errz);
3419 if (cl->IsUsed(10)) sumused++;
3422 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3423 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3426 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3427 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3428 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3429 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3430 if (cl1->IsUsed(10)) sumused++;
3431 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3435 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3437 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3438 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3439 if (cl2->IsUsed(10)) sumused++;
3440 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3443 if (sumused>0) continue;
3445 polytrack.UpdateParameters();
3451 nfoundable = polytrack.GetN();
3452 nfound = nfoundable;
3454 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3455 Float_t maxdist = 0.8*(1.+3./(ddrow));
3456 for (Int_t delta = -1;delta<=1;delta+=2){
3457 Int_t row = row0+ddrow*delta;
3458 kr = &(fSectors[sec][row]);
3459 Double_t xn = kr->GetX();
3460 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3461 polytrack.GetFitPoint(xn,yn,zn);
3462 if (TMath::Abs(yn)>ymax) continue;
3464 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3466 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3469 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3470 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3471 if (cln->IsUsed(10)) {
3472 // printf("used\n");
3480 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3485 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3486 polytrack.UpdateParameters();
3489 if ( (sumused>3) || (sumused>0.5*nfound)) {
3490 //printf("sumused %d\n",sumused);
3495 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3496 AliTPCpolyTrack track2;
3498 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3499 if (track2.GetN()<0.5*nfoundable) continue;
3502 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3504 // test seed with and without constrain
3505 for (Int_t constrain=0; constrain<=0;constrain++){
3506 // add polytrack candidate
3508 Double_t x[5], c[15];
3509 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3510 track2.GetBoundaries(x3,x1);
3512 track2.GetFitPoint(x1,y1,z1);
3513 track2.GetFitPoint(x2,y2,z2);
3514 track2.GetFitPoint(x3,y3,z3);
3516 //is track pointing to the vertex ?
3519 polytrack.GetFitPoint(x0,y0,z0);
3532 x[4]=F1(x1,y1,x2,y2,x3,y3);
3534 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3535 x[2]=F2(x1,y1,x2,y2,x3,y3);
3537 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3538 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3539 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3540 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3543 Double_t sy =0.1, sz =0.1;
3544 Double_t sy1=0.02, sz1=0.02;
3545 Double_t sy2=0.02, sz2=0.02;
3549 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3552 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3553 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3554 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3555 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3556 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3557 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3559 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3560 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3561 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3562 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3567 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3568 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3569 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3570 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3571 c[13]=f30*sy1*f40+f32*sy2*f42;
3572 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3574 //Int_t row1 = fSectors->GetRowNumber(x1);
3575 Int_t row1 = GetRowNumber(x1);
3579 AliTPCseed *track=new (seed) AliTPCseed(x1,sec*alpha+shift,x,c,index);
3580 track->fIsSeeding = kTRUE;
3581 Int_t rc=FollowProlongation(*track, i2);
3582 if (constrain) track->fBConstrain =1;
3584 track->fBConstrain =0;
3585 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3586 track->fFirstPoint = track->fLastPoint;
3588 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3589 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3590 track->fNShared>0.4*track->GetNumberOfClusters()) {
3593 seed->~AliTPCseed();
3596 arr->AddLast(track);
3597 seed = new AliTPCseed;
3601 } // if accepted seed
3604 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3610 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3614 //reseed using track points
3615 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3616 Int_t p1 = int(r1*track->GetNumberOfClusters());
3617 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3619 Double_t x0[3],x1[3],x2[3];
3620 for (Int_t i=0;i<3;i++){
3626 // find track position at given ratio of the length
3627 Int_t sec0=0, sec1=0, sec2=0;
3630 for (Int_t i=0;i<160;i++){
3631 if (track->fClusterPointer[i]){
3633 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3634 if ( (index<p0) || x0[0]<0 ){
3635 if (trpoint->GetX()>1){
3636 clindex = track->GetClusterIndex2(i);
3638 x0[0] = trpoint->GetX();
3639 x0[1] = trpoint->GetY();
3640 x0[2] = trpoint->GetZ();
3641 sec0 = ((clindex&0xff000000)>>24)%18;
3646 if ( (index<p1) &&(trpoint->GetX()>1)){
3647 clindex = track->GetClusterIndex2(i);
3649 x1[0] = trpoint->GetX();
3650 x1[1] = trpoint->GetY();
3651 x1[2] = trpoint->GetZ();
3652 sec1 = ((clindex&0xff000000)>>24)%18;
3655 if ( (index<p2) &&(trpoint->GetX()>1)){
3656 clindex = track->GetClusterIndex2(i);
3658 x2[0] = trpoint->GetX();
3659 x2[1] = trpoint->GetY();
3660 x2[2] = trpoint->GetZ();
3661 sec2 = ((clindex&0xff000000)>>24)%18;
3668 Double_t alpha, cs,sn, xx2,yy2;
3670 alpha = (sec1-sec2)*fSectors->GetAlpha();
3671 cs = TMath::Cos(alpha);
3672 sn = TMath::Sin(alpha);
3673 xx2= x1[0]*cs-x1[1]*sn;
3674 yy2= x1[0]*sn+x1[1]*cs;
3678 alpha = (sec0-sec2)*fSectors->GetAlpha();
3679 cs = TMath::Cos(alpha);
3680 sn = TMath::Sin(alpha);
3681 xx2= x0[0]*cs-x0[1]*sn;
3682 yy2= x0[0]*sn+x0[1]*cs;
3688 Double_t x[5],c[15];
3692 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3693 // if (x[4]>1) return 0;
3694 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3695 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3696 //if (TMath::Abs(x[3]) > 2.2) return 0;
3697 //if (TMath::Abs(x[2]) > 1.99) return 0;
3699 Double_t sy =0.1, sz =0.1;
3701 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3702 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3703 Double_t sy3=0.01+track->GetSigmaY2();
3705 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3706 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3707 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3708 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3709 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3710 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3712 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3713 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3714 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3715 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3720 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3721 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3722 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3723 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3724 c[13]=f30*sy1*f40+f32*sy2*f42;
3725 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3727 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3728 AliTPCseed *seed=new AliTPCseed(x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3729 // Double_t y0,z0,y1,z1, y2,z2;
3730 //seed->GetProlongation(x0[0],y0,z0);
3731 // seed->GetProlongation(x1[0],y1,z1);
3732 //seed->GetProlongation(x2[0],y2,z2);
3734 seed->fLastPoint = pp2;
3735 seed->fFirstPoint = pp2;
3742 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3746 //reseed using founded clusters
3748 // Find the number of clusters
3749 Int_t nclusters = 0;
3750 for (Int_t irow=0;irow<160;irow++){
3751 if (track->GetClusterIndex(irow)>0) nclusters++;
3755 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3756 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3757 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3761 Int_t row[3],sec[3]={0,0,0};
3763 // find track row position at given ratio of the length
3765 for (Int_t irow=0;irow<160;irow++){
3766 if (track->GetClusterIndex2(irow)<0) continue;
3768 for (Int_t ipoint=0;ipoint<3;ipoint++){
3769 if (index<=ipos[ipoint]) row[ipoint] = irow;
3773 //Get cluster and sector position
3774 for (Int_t ipoint=0;ipoint<3;ipoint++){
3775 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3776 AliTPCclusterMI * cl = GetClusterMI(clindex);
3779 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3782 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3783 xyz[ipoint][0] = GetXrow(row[ipoint]);
3784 xyz[ipoint][1] = cl->GetY();
3785 xyz[ipoint][2] = cl->GetZ();
3789 // Calculate seed state vector and covariance matrix
3791 Double_t alpha, cs,sn, xx2,yy2;
3793 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3794 cs = TMath::Cos(alpha);
3795 sn = TMath::Sin(alpha);
3796 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3797 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3801 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3802 cs = TMath::Cos(alpha);
3803 sn = TMath::Sin(alpha);
3804 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3805 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3811 Double_t x[5],c[15];
3815 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3816 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3817 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3819 Double_t sy =0.1, sz =0.1;
3821 Double_t sy1=0.2, sz1=0.2;
3822 Double_t sy2=0.2, sz2=0.2;
3825 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;
3826 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;
3827 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;
3828 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;
3829 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;
3830 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;
3832 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;
3833 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;
3834 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;
3835 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;
3840 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3841 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3842 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3843 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3844 c[13]=f30*sy1*f40+f32*sy2*f42;
3845 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3847 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3848 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3849 seed->fLastPoint = row[2];
3850 seed->fFirstPoint = row[2];
3855 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3859 //reseed using founded clusters
3862 Int_t row[3]={0,0,0};
3863 Int_t sec[3]={0,0,0};
3865 // forward direction
3867 for (Int_t irow=r0;irow<160;irow++){
3868 if (track->GetClusterIndex(irow)>0){
3873 for (Int_t irow=160;irow>r0;irow--){
3874 if (track->GetClusterIndex(irow)>0){
3879 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3880 if (track->GetClusterIndex(irow)>0){
3888 for (Int_t irow=0;irow<r0;irow++){
3889 if (track->GetClusterIndex(irow)>0){
3894 for (Int_t irow=r0;irow>0;irow--){
3895 if (track->GetClusterIndex(irow)>0){
3900 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3901 if (track->GetClusterIndex(irow)>0){
3908 if ((row[2]-row[0])<20) return 0;
3909 if (row[1]==0) return 0;
3912 //Get cluster and sector position
3913 for (Int_t ipoint=0;ipoint<3;ipoint++){
3914 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3915 AliTPCclusterMI * cl = GetClusterMI(clindex);
3918 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3921 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3922 xyz[ipoint][0] = GetXrow(row[ipoint]);
3923 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3924 if (point&&ipoint<2){
3926 xyz[ipoint][1] = point->GetY();
3927 xyz[ipoint][2] = point->GetZ();
3930 xyz[ipoint][1] = cl->GetY();
3931 xyz[ipoint][2] = cl->GetZ();
3938 // Calculate seed state vector and covariance matrix
3940 Double_t alpha, cs,sn, xx2,yy2;
3942 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3943 cs = TMath::Cos(alpha);
3944 sn = TMath::Sin(alpha);
3945 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3946 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3950 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3951 cs = TMath::Cos(alpha);
3952 sn = TMath::Sin(alpha);
3953 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3954 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3960 Double_t x[5],c[15];
3964 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3965 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3966 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3968 Double_t sy =0.1, sz =0.1;
3970 Double_t sy1=0.2, sz1=0.2;
3971 Double_t sy2=0.2, sz2=0.2;
3974 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;
3975 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;
3976 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;
3977 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;
3978 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;
3979 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;
3981 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;
3982 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;
3983 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;
3984 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;
3989 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3990 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3991 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3992 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3993 c[13]=f30*sy1*f40+f32*sy2*f42;
3994 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3996 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3997 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3998 seed->fLastPoint = row[2];
3999 seed->fFirstPoint = row[2];
4000 for (Int_t i=row[0];i<row[2];i++){
4001 seed->fIndex[i] = track->fIndex[i];
4007 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4014 TObjArray *kinks= new TObjArray(10000);
4015 // TObjArray *v0s= new TObjArray(10000);
4016 Int_t nentries = array->GetEntriesFast();
4017 AliHelix *helixes = new AliHelix[nentries];
4018 Int_t *sign = new Int_t[nentries];
4019 Int_t *nclusters = new Int_t[nentries];
4020 Float_t *alpha = new Float_t[nentries];
4021 AliKink *kink = new AliKink();
4022 Int_t * usage = new Int_t[nentries];
4023 Float_t *zm = new Float_t[nentries];
4024 Float_t *z0 = new Float_t[nentries];
4025 Float_t *fim = new Float_t[nentries];
4026 Float_t *shared = new Float_t[nentries];
4027 Bool_t *circular = new Bool_t[nentries];
4028 Float_t *dca = new Float_t[nentries];
4029 //const AliESDVertex * primvertex = esd->GetVertex();
4031 // nentries = array->GetEntriesFast();
4036 for (Int_t i=0;i<nentries;i++){
4039 AliTPCseed* track = (AliTPCseed*)array->At(i);
4040 if (!track) continue;
4041 track->fCircular =0;
4043 track->UpdatePoints();
4044 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4046 nclusters[i]=track->GetNumberOfClusters();
4047 alpha[i] = track->GetAlpha();
4048 new (&helixes[i]) AliHelix(*track);
4050 helixes[i].Evaluate(0,xyz);
4051 sign[i] = (track->GetC()>0) ? -1:1;
4054 if (track->GetProlongation(x,y,z)){
4056 fim[i] = alpha[i]+TMath::ATan2(y,x);
4059 zm[i] = track->GetZ();
4063 circular[i]= kFALSE;
4064 if (track->GetProlongation(0,y,z)) z0[i] = z;
4065 dca[i] = track->GetD(0,0);
4071 Int_t ncandidates =0;
4074 Double_t phase[2][2],radius[2];
4077 // Find circling track
4078 TTreeSRedirector &cstream = *fDebugStreamer;
4080 for (Int_t i0=0;i0<nentries;i0++){
4081 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4082 if (!track0) continue;
4083 if (track0->fN<40) continue;
4084 if (TMath::Abs(1./track0->GetC())>200) continue;
4085 for (Int_t i1=i0+1;i1<nentries;i1++){
4086 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4087 if (!track1) continue;
4088 if (track1->fN<40) continue;
4089 if ( TMath::Abs(track1->GetTgl()+track0->GetTgl())>0.1) continue;
4090 if (track0->fBConstrain&&track1->fBConstrain) continue;
4091 if (TMath::Abs(1./track1->GetC())>200) continue;
4092 if (track1->Get1Pt()*track0->Get1Pt()>0) continue;
4093 if (track1->GetTgl()*track0->GetTgl()>0) continue;
4094 if (max(TMath::Abs(1./track0->GetC()),TMath::Abs(1./track1->GetC()))>190) continue;
4095 if (track0->fBConstrain&&TMath::Abs(track1->Get1Pt())<TMath::Abs(track0->Get1Pt())) continue; //returning - lower momenta
4096 if (track1->fBConstrain&&TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())) continue; //returning - lower momenta
4098 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4099 if (mindcar<5) continue;
4100 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4101 if (mindcaz<5) continue;
4102 if (mindcar+mindcaz<20) continue;
4105 Float_t xc0 = helixes[i0].GetHelix(6);
4106 Float_t yc0 = helixes[i0].GetHelix(7);
4107 Float_t r0 = helixes[i0].GetHelix(8);
4108 Float_t xc1 = helixes[i1].GetHelix(6);
4109 Float_t yc1 = helixes[i1].GetHelix(7);
4110 Float_t r1 = helixes[i1].GetHelix(8);
4112 Float_t rmean = (r0+r1)*0.5;
4113 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4114 //if (delta>30) continue;
4115 if (delta>rmean*0.25) continue;
4116 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4118 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4119 if (npoints==0) continue;
4120 helixes[i0].GetClosestPhases(helixes[i1], phase);
4124 Double_t hangles[3];
4125 helixes[i0].Evaluate(phase[0][0],xyz0);
4126 helixes[i1].Evaluate(phase[0][1],xyz1);
4128 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4129 Double_t deltah[2],deltabest;
4130 if (hangles[2]<2.8) continue;
4132 cstream<<"C"<<track0->fLab<<track1->fLab<<
4133 track0->fP3<<track1->fP3<<
4134 track0->fP4<<track1->fP4<<
4135 delta<<rmean<<npoints<<
4136 hangles[0]<<hangles[2]<<
4137 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4141 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4143 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4144 if (deltah[1]<deltah[0]) ibest=1;
4146 deltabest = TMath::Sqrt(deltah[ibest]);
4147 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4148 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4149 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4150 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4152 if (deltabest>6) continue;
4153 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4154 Bool_t sign =kFALSE;
4155 if (hangles[2]>3.06) sign =kTRUE;
4158 circular[i0] = kTRUE;
4159 circular[i1] = kTRUE;
4160 if (TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())){
4161 track0->fCircular += 1;
4162 track1->fCircular += 2;
4165 track1->fCircular += 1;
4166 track0->fCircular += 2;
4169 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4171 cstream<<"Curling"<<
4172 "lab0="<<track0->fLab<<
4173 "lab1="<<track1->fLab<<
4178 "mindcar="<<mindcar<<
4179 "mindcaz="<<mindcaz<<
4182 "npoints="<<npoints<<
4183 "hangles0="<<hangles[0]<<
4184 "hangles2="<<hangles[2]<<
4189 "radius="<<radiusbest<<
4190 "deltabest="<<deltabest<<
4191 "phase0="<<phase[ibest][0]<<
4192 "phase1="<<phase[ibest][1]<<
4202 for (Int_t i =0;i<nentries;i++){
4203 if (sign[i]==0) continue;
4204 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4207 Double_t cradius0 = 40*40;
4208 Double_t cradius1 = 270*270;
4211 Double_t cdist3=0.55;
4212 for (Int_t j =i+1;j<nentries;j++){
4214 if (sign[j]*sign[i]<1) continue;
4215 if ( (nclusters[i]+nclusters[j])>200) continue;
4216 if ( (nclusters[i]+nclusters[j])<80) continue;
4217 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4218 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4219 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4220 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4221 if (npoints<1) continue;
4224 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4227 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4230 Double_t delta1=10000,delta2=10000;
4231 // cuts on the intersection radius
4232 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4233 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4234 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4236 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4237 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4238 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4241 Double_t distance1 = TMath::Min(delta1,delta2);
4242 if (distance1>cdist1) continue; // cut on DCA linear approximation
4244 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4245 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4246 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4247 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4250 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4251 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4252 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4254 distance1 = TMath::Min(delta1,delta2);
4257 rkink = TMath::Sqrt(radius[0]);
4260 rkink = TMath::Sqrt(radius[1]);
4262 if (distance1>cdist2) continue;
4265 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4268 Int_t row0 = GetRowNumber(rkink);
4269 if (row0<10) continue;
4270 if (row0>150) continue;
4273 Float_t dens00=-1,dens01=-1;
4274 Float_t dens10=-1,dens11=-1;
4276 Int_t found,foundable,shared;
4277 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4278 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4279 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4280 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4282 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4283 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4284 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4285 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4287 if (dens00<dens10 && dens01<dens11) continue;
4288 if (dens00>dens10 && dens01>dens11) continue;
4289 if (TMath::Max(dens00,dens10)<0.1) continue;
4290 if (TMath::Max(dens01,dens11)<0.3) continue;
4292 if (TMath::Min(dens00,dens10)>0.6) continue;
4293 if (TMath::Min(dens01,dens11)>0.6) continue;
4296 AliTPCseed * ktrack0, *ktrack1;
4305 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4306 AliExternalTrackParam paramm(*ktrack0);
4307 AliExternalTrackParam paramd(*ktrack1);
4308 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4311 kink->SetMother(paramm);
4312 kink->SetDaughter(paramd);
4315 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4317 fParam->Transform0to1(x,index);
4318 fParam->Transform1to2(x,index);
4319 row0 = GetRowNumber(x[0]);
4321 if (kink->GetR()<100) continue;
4322 if (kink->GetR()>240) continue;
4323 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4324 if (kink->GetDistance()>cdist3) continue;
4325 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4326 if (dird<0) continue;
4328 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4329 if (dirm<0) continue;
4330 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4331 if (mpt<0.2) continue;
4334 //for high momenta momentum not defined well in first iteration
4335 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->GetP();
4336 if (qt>0.35) continue;
4339 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4340 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4342 kink->SetTPCDensity(dens00,0,0);
4343 kink->SetTPCDensity(dens01,0,1);
4344 kink->SetTPCDensity(dens10,1,0);
4345 kink->SetTPCDensity(dens11,1,1);
4346 kink->SetIndex(i,0);
4347 kink->SetIndex(j,1);
4350 kink->SetTPCDensity(dens10,0,0);
4351 kink->SetTPCDensity(dens11,0,1);
4352 kink->SetTPCDensity(dens00,1,0);
4353 kink->SetTPCDensity(dens01,1,1);
4354 kink->SetIndex(j,0);
4355 kink->SetIndex(i,1);
4358 if (mpt<1||kink->GetAngle(2)>0.1){
4359 // angle and densities not defined yet
4360 if (kink->GetTPCDensityFactor()<0.8) continue;
4361 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4362 if (kink->GetAngle(2)*ktrack0->GetP()<0.003) continue; //too small angle
4363 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4364 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4366 Float_t criticalangle = track0->GetSigmaSnp2()+track0->GetSigmaTgl2();
4367 criticalangle+= track1->GetSigmaSnp2()+track1->GetSigmaTgl2();
4368 criticalangle= 3*TMath::Sqrt(criticalangle);
4369 if (criticalangle>0.02) criticalangle=0.02;
4370 if (kink->GetAngle(2)<criticalangle) continue;
4373 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4374 Float_t shapesum =0;
4376 for ( Int_t row = row0-drow; row<row0+drow;row++){
4377 if (row<0) continue;
4378 if (row>155) continue;
4379 if (ktrack0->fClusterPointer[row]){
4380 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4381 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4384 if (ktrack1->fClusterPointer[row]){
4385 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4386 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4391 kink->SetShapeFactor(-1.);
4394 kink->SetShapeFactor(shapesum/sum);
4396 // esd->AddKink(kink);
4397 kinks->AddLast(kink);
4403 // sort the kinks according quality - and refit them towards vertex
4405 Int_t nkinks = kinks->GetEntriesFast();
4406 Float_t *quality = new Float_t[nkinks];
4407 Int_t *indexes = new Int_t[nkinks];
4408 AliTPCseed *mothers = new AliTPCseed[nkinks];
4409 AliTPCseed *daughters = new AliTPCseed[nkinks];
4412 for (Int_t i=0;i<nkinks;i++){
4414 AliKink *kink = (AliKink*)kinks->At(i);
4416 // refit kinks towards vertex
4418 Int_t index0 = kink->GetIndex(0);
4419 Int_t index1 = kink->GetIndex(1);
4420 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4421 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4423 Int_t sumn=ktrack0->fN+ktrack1->fN;
4425 // Refit Kink under if too small angle
4427 if (kink->GetAngle(2)<0.05){
4428 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4429 Int_t row0 = kink->GetTPCRow0();
4430 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4433 Int_t last = row0-drow;
4434 if (last<40) last=40;
4435 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4436 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4439 Int_t first = row0+drow;
4440 if (first>130) first=130;
4441 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4442 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4444 if (seed0 && seed1){
4445 kink->SetStatus(1,8);
4446 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4447 row0 = GetRowNumber(kink->GetR());
4448 sumn = seed0->fN+seed1->fN;
4449 new (&mothers[i]) AliTPCseed(*seed0);
4450 new (&daughters[i]) AliTPCseed(*seed1);
4453 delete kinks->RemoveAt(i);
4454 if (seed0) delete seed0;
4455 if (seed1) delete seed1;
4458 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4459 delete kinks->RemoveAt(i);
4460 if (seed0) delete seed0;
4461 if (seed1) delete seed1;
4469 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4471 TMath::Sort(nkinks,quality,indexes,kFALSE);
4473 //remove double find kinks
4475 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4476 AliKink * kink0 = (AliKink*) kinks->At(indexes[ikink0]);
4477 if (!kink0) continue;
4479 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4480 if (!kink0) continue;
4481 AliKink * kink1 = (AliKink*) kinks->At(indexes[ikink1]);
4482 if (!kink1) continue;
4483 // if not close kink continue
4484 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4485 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4486 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4488 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4489 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4490 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4491 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4492 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4501 for (Int_t i=0;i<row0;i++){
4502 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4505 if (mother0.fIndex[i]==mother1.fIndex[i]){
4512 for (Int_t i=row0;i<158;i++){
4513 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4516 if (mother0.fIndex[i]==mother1.fIndex[i]){
4522 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4523 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4524 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4525 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4526 Int_t sum0 = mother0.fN+daughter0.fN;
4527 Int_t sum1 = mother1.fN+daughter1.fN;
4529 shared[kink0->GetIndex(0)]= kTRUE;
4530 shared[kink0->GetIndex(1)]= kTRUE;
4531 delete kinks->RemoveAt(indexes[ikink0]);
4534 shared[kink1->GetIndex(0)]= kTRUE;
4535 shared[kink1->GetIndex(1)]= kTRUE;
4536 delete kinks->RemoveAt(indexes[ikink1]);
4543 for (Int_t i=0;i<nkinks;i++){
4544 AliKink * kink = (AliKink*) kinks->At(indexes[i]);
4545 if (!kink) continue;
4546 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4547 Int_t index0 = kink->GetIndex(0);
4548 Int_t index1 = kink->GetIndex(1);
4549 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4550 kink->SetMultiple(usage[index0],0);
4551 kink->SetMultiple(usage[index1],1);
4552 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4553 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4554 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4555 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4557 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4558 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4559 if (!ktrack0 || !ktrack1) continue;
4560 Int_t index = esd->AddKink(kink);
4563 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4564 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4565 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4566 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4570 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4571 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4576 // Remove tracks corresponding to shared kink's
4578 for (Int_t i=0;i<nentries;i++){
4579 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4580 if (!track0) continue;
4581 if (track0->fKinkIndexes[0]!=0) continue;
4582 if (shared[i]) delete array->RemoveAt(i);
4587 RemoveUsed2(array,0.5,0.4,30);
4589 for (Int_t i=0;i<nentries;i++){
4590 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4591 if (!track0) continue;
4592 track0->CookdEdx(0.02,0.6);
4596 for (Int_t i=0;i<nentries;i++){
4597 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4598 if (!track0) continue;
4599 if (track0->GetPt()<1.4) continue;
4600 //remove double high momenta tracks - overlapped with kink candidates
4603 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4604 if (track0->fClusterPointer[icl]!=0){
4606 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4609 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4610 delete array->RemoveAt(i);
4614 if (track0->fKinkIndexes[0]!=0) continue;
4615 if (track0->GetNumberOfClusters()<80) continue;
4617 AliTPCseed *pmother = new AliTPCseed();
4618 AliTPCseed *pdaughter = new AliTPCseed();
4619 AliKink *pkink = new AliKink;
4621 AliTPCseed & mother = *pmother;
4622 AliTPCseed & daughter = *pdaughter;
4623 AliKink & kink = *pkink;
4624 if (CheckKinkPoint(track0,mother,daughter, kink)){
4625 if (mother.fN<30||daughter.fN<20) {
4629 continue; //too short tracks
4631 if (mother.GetPt()<1.4) {
4637 Int_t row0= kink.GetTPCRow0();
4638 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4645 Int_t index = esd->AddKink(&kink);
4646 mother.fKinkIndexes[0] = -(index+1);
4647 daughter.fKinkIndexes[0] = index+1;
4649 delete array->RemoveAt(i);
4650 array->AddAt(new AliTPCseed(mother),i);
4653 array->AddLast(new AliTPCseed(mother));
4655 array->AddLast(new AliTPCseed(daughter));
4656 for (Int_t icl=0;icl<row0;icl++) {
4657 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4660 for (Int_t icl=row0;icl<158;icl++) {
4661 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4670 delete [] daughters;
4692 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4696 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4702 TObjArray *tpcv0s = new TObjArray(100000);
4703 Int_t nentries = array->GetEntriesFast();
4704 AliHelix *helixes = new AliHelix[nentries];
4705 Int_t *sign = new Int_t[nentries];
4706 Float_t *alpha = new Float_t[nentries];
4707 Float_t *z0 = new Float_t[nentries];
4708 Float_t *dca = new Float_t[nentries];
4709 Float_t *sdcar = new Float_t[nentries];
4710 Float_t *cdcar = new Float_t[nentries];
4711 Float_t *pulldcar = new Float_t[nentries];
4712 Float_t *pulldcaz = new Float_t[nentries];
4713 Float_t *pulldca = new Float_t[nentries];
4714 Bool_t *isPrim = new Bool_t[nentries];
4715 const AliESDVertex * primvertex = esd->GetVertex();
4716 Double_t zvertex = primvertex->GetZv();
4718 // nentries = array->GetEntriesFast();
4720 for (Int_t i=0;i<nentries;i++){
4723 AliTPCseed* track = (AliTPCseed*)array->At(i);
4724 if (!track) continue;
4725 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4726 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4727 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4729 alpha[i] = track->GetAlpha();
4730 new (&helixes[i]) AliHelix(*track);
4732 helixes[i].Evaluate(0,xyz);
4733 sign[i] = (track->GetC()>0) ? -1:1;
4737 if (track->GetProlongation(0,y,z)) z0[i] = z;
4738 dca[i] = track->GetD(0,0);
4740 // dca error parrameterezation + pulls
4742 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->GetC())*(100*track->GetC()));
4743 if (TMath::Abs(track->GetTgl())>1) sdcar[i]*=2.5;
4744 cdcar[i] = TMath::Exp((TMath::Abs(track->GetC())-0.0106)*525.3);
4745 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4746 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4747 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4748 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4749 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4751 if (track->fTPCr[4]>0.5) {
4752 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4754 if (track->fTPCr[0]>0.4) {
4755 isPrim[i]=kFALSE; //electron no sigma cut
4762 Int_t ncandidates =0;
4765 Double_t phase[2][2],radius[2];
4771 TTreeSRedirector &cstream = *fDebugStreamer;
4772 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4774 Double_t cradius0 = 10*10;
4775 Double_t cradius1 = 200*200;
4778 Double_t cpointAngle = 0.95;
4780 Double_t delta[2]={10000,10000};
4781 for (Int_t i =0;i<nentries;i++){
4782 if (sign[i]==0) continue;
4783 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4784 if (!track0) continue;
4785 if (AliTPCReconstructor::StreamLevel()>0){
4790 "zvertex="<<zvertex<<
4791 "sdcar0="<<sdcar[i]<<
4792 "cdcar0="<<cdcar[i]<<
4793 "pulldcar0="<<pulldcar[i]<<
4794 "pulldcaz0="<<pulldcaz[i]<<
4795 "pulldca0="<<pulldca[i]<<
4796 "isPrim="<<isPrim[i]<<
4800 if (track0->Get1Pt()<0) continue;
4801 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4803 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4808 for (Int_t j =0;j<nentries;j++){
4809 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4810 if (!track1) continue;
4811 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4812 if (sign[j]*sign[i]>0) continue;
4813 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4814 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4817 // DCA to prim vertex cut
4823 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4824 if (npoints<1) continue;
4828 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4829 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4830 if (delta[0]>cdist1) continue;
4833 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4834 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4835 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4836 if (delta[1]<delta[0]) iclosest=1;
4837 if (delta[iclosest]>cdist1) continue;
4839 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4840 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4842 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4843 if (pointAngle<cpointAngle) continue;
4845 Bool_t isGamma = kFALSE;
4846 vertex.SetP(*track0); //track0 - plus
4847 vertex.SetM(*track1); //track1 - minus
4848 vertex.Update(fprimvertex);
4849 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4850 Double_t pointAngle2 = vertex.GetPointAngle();
4852 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4853 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4854 Float_t sigmae = 0.15*0.15;
4855 if (vertex.GetRr()<80)
4856 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4857 sigmae+= TMath::Sqrt(sigmae);
4858 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4859 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4860 Int_t row0 = GetRowNumber(vertex.GetRr());
4862 if (vertex.GetDist2()>0.2) continue;
4863 densb0 = track0->Density2(0,row0-5);
4864 densb1 = track1->Density2(0,row0-5);
4865 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4866 densa0 = track0->Density2(row0+5,row0+40);
4867 densa1 = track1->Density2(row0+5,row0+40);
4868 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4871 densa0 = track0->Density2(0,40); //cluster density
4872 densa1 = track1->Density2(0,40); //cluster density
4873 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4875 vertex.SetLab(0,track0->GetLabel());
4876 vertex.SetLab(1,track1->GetLabel());
4877 vertex.SetChi2After((densa0+densa1)*0.5);
4878 vertex.SetChi2Before((densb0+densb1)*0.5);
4879 vertex.SetIndex(0,i);
4880 vertex.SetIndex(1,j);
4881 vertex.SetStatus(1); // TPC v0 candidate
4882 vertex.SetRp(track0->fTPCr);
4883 vertex.SetRm(track1->fTPCr);
4884 tpcv0s->AddLast(new AliESDV0MI(vertex));
4887 Int_t eventNr = esd->GetEventNumber();
4888 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4889 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4890 if (AliTPCReconstructor::StreamLevel()>0)
4893 "vertex.="<<&vertex<<
4895 "lab0="<<track0->fLab<<
4896 "Helix0.="<<&helixes[i]<<
4898 "lab1="<<track1->fLab<<
4899 "Helix1.="<<&helixes[j]<<
4900 "pointAngle="<<pointAngle<<
4901 "pointAngle2="<<pointAngle2<<
4906 "zvertex="<<zvertex<<
4907 "circular0="<<track0->fCircular<<
4908 "circular1="<<track1->fCircular<<
4909 "npoints="<<npoints<<
4910 "radius0="<<radius[0]<<
4911 "delta0="<<delta[0]<<
4912 "radius1="<<radius[1]<<
4913 "delta1="<<delta[1]<<
4914 "radiusm="<<radiusm<<
4916 "sdcar0="<<sdcar[i]<<
4917 "sdcar1="<<sdcar[j]<<
4918 "cdcar0="<<cdcar[i]<<
4919 "cdcar1="<<cdcar[j]<<
4920 "pulldcar0="<<pulldcar[i]<<
4921 "pulldcar1="<<pulldcar[j]<<
4922 "pulldcaz0="<<pulldcaz[i]<<
4923 "pulldcaz1="<<pulldcaz[j]<<
4924 "pulldca0="<<pulldca[i]<<
4925 "pulldca1="<<pulldca[j]<<
4935 Float_t *quality = new Float_t[ncandidates];
4936 Int_t *indexes = new Int_t[ncandidates];
4938 for (Int_t i=0;i<ncandidates;i++){
4940 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4941 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4942 // quality[i] /= (0.5+v0->GetDist2());
4943 // quality[i] *= v0->GetChi2After(); //density factor
4944 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4945 Int_t index0 = v0->GetIndex(0);
4946 Int_t index1 = v0->GetIndex(1);
4947 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4948 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4949 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4950 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4953 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4956 for (Int_t i=0;i<ncandidates;i++){
4957 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4959 Int_t index0 = v0->GetIndex(0);
4960 Int_t index1 = v0->GetIndex(1);
4961 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4962 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4963 if (!track0||!track1) {
4967 Bool_t accept =kTRUE; //default accept
4968 Int_t *v0indexes0 = track0->GetV0Indexes();
4969 Int_t *v0indexes1 = track1->GetV0Indexes();
4971 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4972 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4973 if (v0indexes0[1]!=0) order0 =2;
4974 if (v0indexes1[1]!=0) order1 =2;
4976 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4977 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4979 AliESDV0MI * v02 = v0;
4981 v0->SetOrder(0,order0);
4982 v0->SetOrder(1,order1);
4983 v0->SetOrder(1,order0+order1);
4984 Int_t index = esd->AddV0MI(v0);
4985 v02 = esd->GetV0MI(index);
4986 v0indexes0[order0]=index;
4987 v0indexes1[order1]=index;
4991 Int_t eventNr = esd->GetEventNumber();
4992 if (AliTPCReconstructor::StreamLevel()>0)
4998 "lab0="<<track0->fLab<<
5000 "lab1="<<track1->fLab<<
5001 "dca0="<<dca[index0]<<
5002 "dca1="<<dca[index1]<<
5006 "quality="<<quality[i]<<
5007 "pulldca0="<<pulldca[index0]<<
5008 "pulldca1="<<pulldca[index1]<<
5032 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5036 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5039 // refit kink towards to the vertex
5042 AliKink &kink=(AliKink &)knk;
5044 Int_t row0 = GetRowNumber(kink.GetR());
5045 FollowProlongation(mother,0);
5046 mother.Reset(kFALSE);
5048 FollowProlongation(daughter,row0);
5049 daughter.Reset(kFALSE);
5050 FollowBackProlongation(daughter,158);
5051 daughter.Reset(kFALSE);
5052 Int_t first = TMath::Max(row0-20,30);
5053 Int_t last = TMath::Min(row0+20,140);
5055 const Int_t kNdiv =5;
5056 AliTPCseed param0[kNdiv]; // parameters along the track
5057 AliTPCseed param1[kNdiv]; // parameters along the track
5058 AliKink kinks[kNdiv]; // corresponding kink parameters
5061 for (Int_t irow=0; irow<kNdiv;irow++){
5062 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5064 // store parameters along the track
5066 for (Int_t irow=0;irow<kNdiv;irow++){
5067 FollowBackProlongation(mother, rows[irow]);
5068 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5069 new(¶m0[irow]) AliTPCseed(mother);
5070 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5074 for (Int_t irow=0; irow<kNdiv-1;irow++){
5075 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5076 kinks[irow].SetMother(param0[irow]);
5077 kinks[irow].SetDaughter(param1[irow]);
5078 kinks[irow].Update();
5081 // choose kink with best "quality"
5083 Double_t mindist = 10000;
5084 for (Int_t irow=0;irow<kNdiv;irow++){
5085 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5086 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5087 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5089 Float_t normdist = TMath::Abs(param0[irow].GetX()-kinks[irow].GetR())*(0.1+kink.GetDistance());
5090 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5091 if (normdist < mindist){
5097 if (index==-1) return 0;
5100 param0[index].Reset(kTRUE);
5101 FollowProlongation(param0[index],0);
5103 new (&mother) AliTPCseed(param0[index]);
5104 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5106 kink.SetMother(mother);
5107 kink.SetDaughter(daughter);
5109 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5110 kink.SetTPCncls(param0[index].fN,0);
5111 kink.SetTPCncls(param1[index].fN,1);
5112 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5113 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5114 mother.SetLabel(kink.GetLabel(0));
5115 daughter.SetLabel(kink.GetLabel(1));
5121 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5123 // update Kink quality information for mother after back propagation
5125 if (seed->GetKinkIndex(0)>=0) return;
5126 for (Int_t ikink=0;ikink<3;ikink++){
5127 Int_t index = seed->GetKinkIndex(ikink);
5128 if (index>=0) break;
5129 index = TMath::Abs(index)-1;
5130 AliESDkink * kink = fEvent->GetKink(index);
5131 //kink->fTPCdensity2[0][0]=-1;
5132 //kink->fTPCdensity2[0][1]=-1;
5133 kink->SetTPCDensity2(-1,0,0);
5134 kink->SetTPCDensity2(1,0,1);
5136 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5137 if (row0<15) row0=15;
5139 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5140 if (row1>145) row1=145;
5142 Int_t found,foundable,shared;
5143 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5144 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5145 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5146 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5151 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5153 // update Kink quality information for daughter after refit
5155 if (seed->GetKinkIndex(0)<=0) return;
5156 for (Int_t ikink=0;ikink<3;ikink++){
5157 Int_t index = seed->GetKinkIndex(ikink);
5158 if (index<=0) break;
5159 index = TMath::Abs(index)-1;
5160 AliESDkink * kink = fEvent->GetKink(index);
5161 kink->SetTPCDensity2(-1,1,0);
5162 kink->SetTPCDensity2(-1,1,1);
5164 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5165 if (row0<15) row0=15;
5167 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5168 if (row1>145) row1=145;
5170 Int_t found,foundable,shared;
5171 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5172 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5173 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5174 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5180 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5183 // check kink point for given track
5184 // if return value=0 kink point not found
5185 // otherwise seed0 correspond to mother particle
5186 // seed1 correspond to daughter particle
5187 // kink parameter of kink point
5188 AliKink &kink=(AliKink &)knk;
5190 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5191 Int_t first = seed->fFirstPoint;
5192 Int_t last = seed->fLastPoint;
5193 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5196 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5197 if (!seed1) return 0;
5198 FollowProlongation(*seed1,seed->fLastPoint-20);
5199 seed1->Reset(kTRUE);
5200 FollowProlongation(*seed1,158);
5201 seed1->Reset(kTRUE);
5202 last = seed1->fLastPoint;
5204 AliTPCseed *seed0 = new AliTPCseed(*seed);
5205 seed0->Reset(kFALSE);
5208 AliTPCseed param0[20]; // parameters along the track
5209 AliTPCseed param1[20]; // parameters along the track
5210 AliKink kinks[20]; // corresponding kink parameters
5212 for (Int_t irow=0; irow<20;irow++){
5213 rows[irow] = first +((last-first)*irow)/19;
5215 // store parameters along the track
5217 for (Int_t irow=0;irow<20;irow++){
5218 FollowBackProlongation(*seed0, rows[irow]);
5219 FollowProlongation(*seed1,rows[19-irow]);
5220 new(¶m0[irow]) AliTPCseed(*seed0);
5221 new(¶m1[19-irow]) AliTPCseed(*seed1);
5225 for (Int_t irow=0; irow<19;irow++){
5226 kinks[irow].SetMother(param0[irow]);
5227 kinks[irow].SetDaughter(param1[irow]);
5228 kinks[irow].Update();
5231 // choose kink with biggest change of angle
5233 Double_t maxchange= 0;
5234 for (Int_t irow=1;irow<19;irow++){
5235 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5236 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5237 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5238 if ( quality > maxchange){
5239 maxchange = quality;
5246 if (index<0) return 0;
5248 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5249 seed0 = new AliTPCseed(param0[index]);
5250 seed1 = new AliTPCseed(param1[index]);
5251 seed0->Reset(kFALSE);
5252 seed1->Reset(kFALSE);
5253 seed0->ResetCovariance(10.);
5254 seed1->ResetCovariance(10.);
5255 FollowProlongation(*seed0,0);
5256 FollowBackProlongation(*seed1,158);
5257 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5258 seed0->Reset(kFALSE);
5259 seed1->Reset(kFALSE);
5260 seed0->ResetCovariance(10.);
5261 seed1->ResetCovariance(10.);
5263 first = TMath::Max(row0-20,0);
5264 last = TMath::Min(row0+20,158);
5266 for (Int_t irow=0; irow<20;irow++){
5267 rows[irow] = first +((last-first)*irow)/19;
5269 // store parameters along the track
5271 for (Int_t irow=0;irow<20;irow++){
5272 FollowBackProlongation(*seed0, rows[irow]);
5273 FollowProlongation(*seed1,rows[19-irow]);
5274 new(¶m0[irow]) AliTPCseed(*seed0);
5275 new(¶m1[19-irow]) AliTPCseed(*seed1);
5279 for (Int_t irow=0; irow<19;irow++){
5280 kinks[irow].SetMother(param0[irow]);
5281 kinks[irow].SetDaughter(param1[irow]);
5282 // param0[irow].Dump();
5283 //param1[irow].Dump();
5284 kinks[irow].Update();
5287 // choose kink with biggest change of angle
5290 for (Int_t irow=0;irow<20;irow++){
5291 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5292 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5293 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5294 if ( quality > maxchange){
5295 maxchange = quality;
5302 if (index==-1 || param0[index].fN+param1[index].fN<100){
5307 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5309 kink.SetMother(param0[index]);
5310 kink.SetDaughter(param1[index]);
5312 row0 = GetRowNumber(kink.GetR());
5313 kink.SetTPCRow0(row0);
5314 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5315 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5316 kink.SetIndex(-10,0);
5317 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5318 kink.SetTPCncls(param0[index].fN,0);
5319 kink.SetTPCncls(param1[index].fN,1);
5322 // new (&mother) AliTPCseed(param0[index]);
5323 new (&daughter) AliTPCseed(param1[index]);
5324 daughter.SetLabel(kink.GetLabel(1));
5325 param0[index].Reset(kTRUE);
5326 FollowProlongation(param0[index],0);
5327 new (&mother) AliTPCseed(param0[index]);
5328 mother.SetLabel(kink.GetLabel(0));
5338 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5341 // reseed - refit - track
5344 // Int_t last = fSectors->GetNRows()-1;
5346 if (fSectors == fOuterSec){
5347 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5351 first = t->fFirstPoint;
5353 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5354 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5356 FollowProlongation(*t,first);
5366 //_____________________________________________________________________________
5367 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5368 //-----------------------------------------------------------------
5369 // This function reades track seeds.
5370 //-----------------------------------------------------------------
5371 TDirectory *savedir=gDirectory;
5373 TFile *in=(TFile*)inp;
5374 if (!in->IsOpen()) {
5375 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5380 TTree *seedTree=(TTree*)in->Get("Seeds");
5382 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5383 cerr<<"can't get a tree with track seeds !\n";
5386 AliTPCtrack *seed=new AliTPCtrack;
5387 seedTree->SetBranchAddress("tracks",&seed);
5389 if (fSeeds==0) fSeeds=new TObjArray(15000);
5391 Int_t n=(Int_t)seedTree->GetEntries();
5392 for (Int_t i=0; i<n; i++) {
5393 seedTree->GetEvent(i);
5394 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5403 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5406 if (fSeeds) DeleteSeeds();
5409 if (!fSeeds) return 1;
5416 //_____________________________________________________________________________
5417 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5418 //-----------------------------------------------------------------
5419 // This is a track finder.
5420 //-----------------------------------------------------------------
5421 TDirectory *savedir=gDirectory;
5425 fSeeds = Tracking();
5428 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5430 //activate again some tracks
5431 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5432 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5434 Int_t nc=t.GetNumberOfClusters();
5436 delete fSeeds->RemoveAt(i);
5440 if (pt->fRemoval==10) {
5441 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5442 pt->Desactivate(10); // make track again active
5444 pt->Desactivate(20);
5445 delete fSeeds->RemoveAt(i);
5450 RemoveUsed2(fSeeds,0.85,0.85,0);
5451 FindKinks(fSeeds,fEvent);
5452 RemoveUsed2(fSeeds,0.5,0.4,20);
5454 // // refit short tracks
5456 Int_t nseed=fSeeds->GetEntriesFast();
5457 // for (Int_t i=0; i<nseed; i++) {
5458 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5459 // if (!pt) continue;
5460 // Int_t nc=t.GetNumberOfClusters();
5462 // delete fSeeds->RemoveAt(i);
5465 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5466 // if (nc>100) continue; // hopefully, enough for ITS
5467 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5468 // //seed2->Reset(kFALSE);
5469 // //pt->ResetCovariance();
5470 // seed2->Modify(1);
5471 // FollowBackProlongation(*seed2,158);
5472 // //seed2->Reset(kFALSE);
5473 // seed2->Modify(10);
5474 // FollowProlongation(*seed2,0);
5475 // TTreeSRedirector &cstream = *fDebugStreamer;
5476 // cstream<<"Crefit"<<
5480 // if (seed2->fN>pt->fN){
5481 // delete fSeeds->RemoveAt(i);
5482 // fSeeds->AddAt(seed2,i);
5487 // RemoveUsed2(fSeeds,0.6,0.6,50);
5489 // FindV0s(fSeeds,fEvent);
5490 //RemoveDouble(fSeeds,0.2,0.6,11);
5494 for (Int_t i=0; i<nseed; i++) {
5495 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5497 Int_t nc=t.GetNumberOfClusters();
5499 delete fSeeds->RemoveAt(i);
5502 CookLabel(pt,0.1); //For comparison only
5503 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5504 if ((pt->IsActive() || (pt->fRemoval==10) )){
5506 if (fDebug>0) cerr<<found<<'\r';
5510 delete fSeeds->RemoveAt(i);
5514 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5516 //RemoveUsed(fSeeds,0.9,0.9,6);
5518 nseed=fSeeds->GetEntriesFast();
5520 for (Int_t i=0; i<nseed; i++) {
5521 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5523 Int_t nc=t.GetNumberOfClusters();
5525 delete fSeeds->RemoveAt(i);
5529 t.CookdEdx(0.02,0.6);
5530 // CheckKinkPoint(&t,0.05);
5531 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5532 if ((pt->IsActive() || (pt->fRemoval==10) )){
5540 delete fSeeds->RemoveAt(i);
5541 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5543 // FollowProlongation(*seed1,0);
5544 // Int_t n = seed1->GetNumberOfClusters();
5545 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5546 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5549 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5553 SortTracks(fSeeds, 1);
5557 PrepareForBackProlongation(fSeeds,5.);
5558 PropagateBack(fSeeds);
5559 printf("Time for back propagation: \t");timer.Print();timer.Start();
5563 PrepareForProlongation(fSeeds,5.);
5564 PropagateForward2(fSeeds);
5566 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5567 // RemoveUsed(fSeeds,0.7,0.7,6);
5568 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5570 nseed=fSeeds->GetEntriesFast();
5572 for (Int_t i=0; i<nseed; i++) {
5573 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5575 Int_t nc=t.GetNumberOfClusters();
5577 delete fSeeds->RemoveAt(i);
5580 t.CookdEdx(0.02,0.6);
5581 // CookLabel(pt,0.1); //For comparison only
5582 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5583 if ((pt->IsActive() || (pt->fRemoval==10) )){
5584 cerr<<found++<<'\r';
5587 delete fSeeds->RemoveAt(i);
5592 // fNTracks = found;
5594 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5597 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5598 Info("Clusters2Tracks","Number of found tracks %d",found);
5600 // UnloadClusters();
5605 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5608 // tracking of the seeds
5611 fSectors = fOuterSec;
5612 ParallelTracking(arr,150,63);
5613 fSectors = fOuterSec;
5614 ParallelTracking(arr,63,0);
5617 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5622 TObjArray * arr = new TObjArray;
5624 fSectors = fOuterSec;
5627 for (Int_t sec=0;sec<fkNOS;sec++){
5628 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5629 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5630 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5633 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5645 TObjArray * AliTPCtrackerMI::Tracking()
5651 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5653 TObjArray * seeds = new TObjArray;
5662 Float_t fnumber = 3.0;
5663 Float_t fdensity = 3.0;
5668 for (Int_t delta = 0; delta<18; delta+=6){
5672 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5673 SumTracks(seeds,arr);
5674 SignClusters(seeds,fnumber,fdensity);
5676 for (Int_t i=2;i<6;i+=2){
5677 // seed high pt tracks
5680 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5681 SumTracks(seeds,arr);
5682 SignClusters(seeds,fnumber,fdensity);
5687 // RemoveUsed(seeds,0.9,0.9,1);
5688 // UnsignClusters();
5689 // SignClusters(seeds,fnumber,fdensity);
5693 for (Int_t delta = 20; delta<120; delta+=10){
5695 // seed high pt tracks
5699 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5700 SumTracks(seeds,arr);
5701 SignClusters(seeds,fnumber,fdensity);
5706 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5707 SumTracks(seeds,arr);
5708 SignClusters(seeds,fnumber,fdensity);
5719 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5723 // RemoveUsed(seeds,0.75,0.75,1);
5725 //SignClusters(seeds,fnumber,fdensity);
5734 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5735 SumTracks(seeds,arr);
5736 SignClusters(seeds,fnumber,fdensity);
5738 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5739 SumTracks(seeds,arr);
5740 SignClusters(seeds,fnumber,fdensity);
5742 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5743 SumTracks(seeds,arr);
5744 SignClusters(seeds,fnumber,fdensity);
5748 for (Int_t delta = 3; delta<30; delta+=5){
5754 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5755 SumTracks(seeds,arr);
5756 SignClusters(seeds,fnumber,fdensity);
5758 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5759 SumTracks(seeds,arr);
5760 SignClusters(seeds,fnumber,fdensity);
5772 for (Int_t delta = 30; delta<90; delta+=10){
5778 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5779 SumTracks(seeds,arr);
5780 SignClusters(seeds,fnumber,fdensity);
5782 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5783 SumTracks(seeds,arr);
5784 SignClusters(seeds,fnumber,fdensity);
5788 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5799 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5802 //sum tracks to common container
5803 //remove suspicious tracks
5804 Int_t nseed = arr2->GetEntriesFast();
5805 for (Int_t i=0;i<nseed;i++){
5806 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5808 // REMOVE VERY SHORT TRACKS
5809 if (pt->GetNumberOfClusters()<20){
5810 delete arr2->RemoveAt(i);
5813 // NORMAL ACTIVE TRACK
5814 if (pt->IsActive()){
5815 arr1->AddLast(arr2->RemoveAt(i));
5818 //remove not usable tracks
5819 if (pt->fRemoval!=10){
5820 delete arr2->RemoveAt(i);
5824 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5825 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5826 arr1->AddLast(arr2->RemoveAt(i));
5828 delete arr2->RemoveAt(i);
5837 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5840 // try to track in parralel
5842 Int_t nseed=arr->GetEntriesFast();
5843 //prepare seeds for tracking
5844 for (Int_t i=0; i<nseed; i++) {
5845 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5847 if (!t.IsActive()) continue;
5848 // follow prolongation to the first layer
5849 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5850 FollowProlongation(t, rfirst+1);
5855 for (Int_t nr=rfirst; nr>=rlast; nr--){
5856 if (nr<fInnerSec->GetNRows())
5857 fSectors = fInnerSec;
5859 fSectors = fOuterSec;
5860 // make indexes with the cluster tracks for given
5862 // find nearest cluster
5863 for (Int_t i=0; i<nseed; i++) {
5864 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5866 if (nr==80) pt->UpdateReference();
5867 if (!pt->IsActive()) continue;
5868 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5869 if (pt->fRelativeSector>17) {
5872 UpdateClusters(t,nr);
5874 // prolonagate to the nearest cluster - if founded
5875 for (Int_t i=0; i<nseed; i++) {
5876 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5878 if (!pt->IsActive()) continue;
5879 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5880 if (pt->fRelativeSector>17) {
5883 FollowToNextCluster(*pt,nr);
5888 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5892 // if we use TPC track itself we have to "update" covariance
5894 Int_t nseed= arr->GetEntriesFast();
5895 for (Int_t i=0;i<nseed;i++){
5896 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5900 //rotate to current local system at first accepted point
5901 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5902 Int_t sec = (index&0xff000000)>>24;
5904 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5905 if (angle1>TMath::Pi())
5906 angle1-=2.*TMath::Pi();
5907 Float_t angle2 = pt->GetAlpha();
5909 if (TMath::Abs(angle1-angle2)>0.001){
5910 pt->Rotate(angle1-angle2);
5911 //angle2 = pt->GetAlpha();
5912 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5913 //if (pt->GetAlpha()<0)
5914 // pt->fRelativeSector+=18;
5915 //sec = pt->fRelativeSector;
5924 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5928 // if we use TPC track itself we have to "update" covariance
5930 Int_t nseed= arr->GetEntriesFast();
5931 for (Int_t i=0;i<nseed;i++){
5932 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5935 pt->fFirstPoint = pt->fLastPoint;
5943 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5946 // make back propagation
5948 Int_t nseed= arr->GetEntriesFast();
5949 for (Int_t i=0;i<nseed;i++){
5950 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5951 if (pt&& pt->GetKinkIndex(0)<=0) {
5952 //AliTPCseed *pt2 = new AliTPCseed(*pt);
5953 fSectors = fInnerSec;
5954 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5955 //fSectors = fOuterSec;
5956 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5957 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
5958 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
5959 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5962 if (pt&& pt->GetKinkIndex(0)>0) {
5963 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
5964 pt->fFirstPoint = kink->GetTPCRow0();
5965 fSectors = fInnerSec;
5966 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5974 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5977 // make forward propagation
5979 Int_t nseed= arr->GetEntriesFast();
5981 for (Int_t i=0;i<nseed;i++){
5982 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5984 FollowProlongation(*pt,0);
5991 Int_t AliTPCtrackerMI::PropagateForward()
5994 // propagate track forward
5996 Int_t nseed = fSeeds->GetEntriesFast();
5997 for (Int_t i=0;i<nseed;i++){
5998 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
6000 AliTPCseed &t = *pt;
6001 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
6002 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
6003 if (alpha < 0. ) alpha += 2.*TMath::Pi();
6004 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
6008 fSectors = fOuterSec;
6009 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
6010 fSectors = fInnerSec;
6011 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
6021 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6024 // make back propagation, in between row0 and row1
6028 fSectors = fInnerSec;
6031 if (row1<fSectors->GetNRows())
6034 r1 = fSectors->GetNRows()-1;
6036 if (row0<fSectors->GetNRows()&& r1>0 )
6037 FollowBackProlongation(*pt,r1);
6038 if (row1<=fSectors->GetNRows())
6041 r1 = row1 - fSectors->GetNRows();
6042 if (r1<=0) return 0;
6043 if (r1>=fOuterSec->GetNRows()) return 0;
6044 fSectors = fOuterSec;
6045 return FollowBackProlongation(*pt,r1);
6053 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6057 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6058 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6059 Float_t padlength = GetPadPitchLength(row);
6061 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6062 Double_t angulary = seed->GetSnp();
6063 angulary = angulary*angulary/(1-angulary*angulary);
6064 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6066 Float_t sresz = fParam->GetZSigma();
6067 Float_t angularz = seed->GetTgl();
6068 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6070 Float_t wy = GetSigmaY(seed);
6071 Float_t wz = GetSigmaZ(seed);
6074 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6075 printf("problem\n");
6081 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6085 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6086 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6087 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6088 Float_t angular = seed->GetSnp();
6089 angular = angular*angular/(1-angular*angular);
6090 // angular*=angular;
6091 //angular = TMath::Sqrt(angular/(1-angular));
6092 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6095 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6099 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6100 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6101 Float_t sres = fParam->GetZSigma();
6102 Float_t angular = seed->GetTgl();
6103 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6108 //__________________________________________________________________________
6109 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6110 //--------------------------------------------------------------------
6111 //This function "cooks" a track label. If label<0, this track is fake.
6112 //--------------------------------------------------------------------
6113 AliTPCseed * t = (AliTPCseed*)tk;
6114 Int_t noc=t->GetNumberOfClusters();
6116 //printf("\nnot founded prolongation\n\n\n");
6122 AliTPCclusterMI *clusters[160];
6124 for (Int_t i=0;i<160;i++) {
6131 for (i=0; i<160 && current<noc; i++) {
6133 Int_t index=t->GetClusterIndex2(i);
6134 if (index<=0) continue;
6135 if (index&0x8000) continue;
6137 //clusters[current]=GetClusterMI(index);
6138 if (t->fClusterPointer[i]){
6139 clusters[current]=t->fClusterPointer[i];
6145 Int_t lab=123456789;
6146 for (i=0; i<noc; i++) {
6147 AliTPCclusterMI *c=clusters[i];
6149 lab=TMath::Abs(c->GetLabel(0));
6151 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6157 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6159 for (i=0; i<noc; i++) {
6160 AliTPCclusterMI *c=clusters[i];
6162 if (TMath::Abs(c->GetLabel(1)) == lab ||
6163 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6166 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6169 Int_t tail=Int_t(0.10*noc);
6172 for (i=1; i<=160&&ind<tail; i++) {
6173 // AliTPCclusterMI *c=clusters[noc-i];
6174 AliTPCclusterMI *c=clusters[i];
6176 if (lab == TMath::Abs(c->GetLabel(0)) ||
6177 lab == TMath::Abs(c->GetLabel(1)) ||
6178 lab == TMath::Abs(c->GetLabel(2))) max++;
6181 if (max < Int_t(0.5*tail)) lab=-lab;
6188 //delete[] clusters;
6192 //__________________________________________________________________________
6193 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6194 //--------------------------------------------------------------------
6195 //This function "cooks" a track label. If label<0, this track is fake.
6196 //--------------------------------------------------------------------
6197 Int_t noc=t->GetNumberOfClusters();
6199 //printf("\nnot founded prolongation\n\n\n");
6205 AliTPCclusterMI *clusters[160];
6207 for (Int_t i=0;i<160;i++) {
6214 for (i=0; i<160 && current<noc; i++) {
6215 if (i<first) continue;
6216 if (i>last) continue;
6217 Int_t index=t->GetClusterIndex2(i);
6218 if (index<=0) continue;
6219 if (index&0x8000) continue;
6221 //clusters[current]=GetClusterMI(index);
6222 if (t->fClusterPointer[i]){
6223 clusters[current]=t->fClusterPointer[i];
6228 if (noc<5) return -1;
6229 Int_t lab=123456789;
6230 for (i=0; i<noc; i++) {
6231 AliTPCclusterMI *c=clusters[i];
6233 lab=TMath::Abs(c->GetLabel(0));
6235 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6241 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6243 for (i=0; i<noc; i++) {
6244 AliTPCclusterMI *c=clusters[i];
6246 if (TMath::Abs(c->GetLabel(1)) == lab ||
6247 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6250 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6253 Int_t tail=Int_t(0.10*noc);
6256 for (i=1; i<=160&&ind<tail; i++) {
6257 // AliTPCclusterMI *c=clusters[noc-i];
6258 AliTPCclusterMI *c=clusters[i];
6260 if (lab == TMath::Abs(c->GetLabel(0)) ||
6261 lab == TMath::Abs(c->GetLabel(1)) ||
6262 lab == TMath::Abs(c->GetLabel(2))) max++;
6265 if (max < Int_t(0.5*tail)) lab=-lab;
6268 // t->SetLabel(lab);
6272 //delete[] clusters;
6276 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6278 //return pad row number for this x
6281 r=fRow[fN-1].GetX();
6282 if (x > r) return fN;
6284 if (x < r) return -1;
6285 return Int_t((x-r)/fPadPitchLength + 0.5);}
6287 r=fRow[fN-1].GetX();
6288 if (x > r) return fN;
6290 if (x < r) return -1;
6291 Double_t r1=fRow[64].GetX();
6293 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6295 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6299 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6301 //return pad row number for given x vector
6302 Float_t phi = TMath::ATan2(x[1],x[0]);
6303 if(phi<0) phi=2.*TMath::Pi()+phi;
6304 // Get the local angle in the sector philoc
6305 const Float_t kRaddeg = 180/3.14159265358979312;
6306 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6307 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6308 return GetRowNumber(localx);
6311 //_________________________________________________________________________
6312 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6313 //-----------------------------------------------------------------------
6314 // Setup inner sector
6315 //-----------------------------------------------------------------------
6317 fAlpha=par->GetInnerAngle();
6318 fAlphaShift=par->GetInnerAngleShift();
6319 fPadPitchWidth=par->GetInnerPadPitchWidth();
6320 fPadPitchLength=par->GetInnerPadPitchLength();
6321 fN=par->GetNRowLow();
6322 fRow=new AliTPCRow[fN];
6323 for (Int_t i=0; i<fN; i++) {
6324 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6325 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6328 fAlpha=par->GetOuterAngle();
6329 fAlphaShift=par->GetOuterAngleShift();
6330 fPadPitchWidth = par->GetOuterPadPitchWidth();
6331 fPadPitchLength = par->GetOuter1PadPitchLength();
6332 f1PadPitchLength = par->GetOuter1PadPitchLength();
6333 f2PadPitchLength = par->GetOuter2PadPitchLength();
6335 fN=par->GetNRowUp();
6336 fRow=new AliTPCRow[fN];
6337 for (Int_t i=0; i<fN; i++) {
6338 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6339 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6344 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6346 // default constructor
6354 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6361 //_________________________________________________________________________
6363 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6364 //-----------------------------------------------------------------------
6365 // Insert a cluster into this pad row in accordence with its y-coordinate
6366 //-----------------------------------------------------------------------
6367 if (fN==kMaxClusterPerRow) {
6368 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6370 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6371 Int_t i=Find(c->GetZ());
6372 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6373 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6374 fIndex[i]=index; fClusters[i]=c; fN++;
6377 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6383 //delete[] fClusterArray;
6384 if (fClusters1) delete []fClusters1;
6385 if (fClusters2) delete []fClusters2;
6392 //___________________________________________________________________
6393 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6394 //-----------------------------------------------------------------------
6395 // Return the index of the nearest cluster
6396 //-----------------------------------------------------------------------
6397 if (fN==0) return 0;
6398 if (z <= fClusters[0]->GetZ()) return 0;
6399 if (z > fClusters[fN-1]->GetZ()) return fN;
6400 Int_t b=0, e=fN-1, m=(b+e)/2;
6401 for (; b<e; m=(b+e)/2) {
6402 if (z > fClusters[m]->GetZ()) b=m+1;
6410 //___________________________________________________________________
6411 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6412 //-----------------------------------------------------------------------
6413 // Return the index of the nearest cluster in z y
6414 //-----------------------------------------------------------------------
6415 Float_t maxdistance = roady*roady + roadz*roadz;
6417 AliTPCclusterMI *cl =0;
6418 for (Int_t i=Find(z-roadz); i<fN; i++) {
6419 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6420 if (c->GetZ() > z+roadz) break;
6421 if ( (c->GetY()-y) > roady ) continue;
6422 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6423 if (maxdistance>distance) {
6424 maxdistance = distance;
6431 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6433 //-----------------------------------------------------------------------
6434 // Return the index of the nearest cluster in z y
6435 //-----------------------------------------------------------------------
6436 Float_t maxdistance = roady*roady + roadz*roadz;
6437 AliTPCclusterMI *cl =0;
6439 //PH Check boundaries. 510 is the size of fFastCluster
6440 Int_t iz1 = Int_t(z-roadz+254.5);
6441 if (iz1<0 || iz1>=510) return cl;
6442 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6443 Int_t iz2 = Int_t(z+roadz+255.5);
6444 if (iz2<0 || iz2>=510) return cl;
6445 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6447 //FindNearest3(y,z,roady,roadz,index);
6448 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6449 for (Int_t i=iz1; i<iz2; i++) {
6450 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6451 if (c->GetZ() > z+roadz) break;
6452 if ( c->GetY()-y > roady ) continue;
6453 if ( y-c->GetY() > roady ) continue;
6454 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6455 if (maxdistance>distance) {
6456 maxdistance = distance;
6459 //roady = TMath::Sqrt(maxdistance);
6467 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6469 //-----------------------------------------------------------------------
6470 // Return the index of the nearest cluster in z y
6471 //-----------------------------------------------------------------------
6472 Float_t maxdistance = roady*roady + roadz*roadz;
6473 // Int_t iz = Int_t(z+255.);
6474 AliTPCclusterMI *cl =0;
6475 for (Int_t i=Find(z-roadz); i<fN; i++) {
6476 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6477 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6478 if (c->GetZ() > z+roadz) break;
6479 if ( c->GetY()-y > roady ) continue;
6480 if ( y-c->GetY() > roady ) continue;
6481 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6482 if (maxdistance>distance) {
6483 maxdistance = distance;
6486 //roady = TMath::Sqrt(maxdistance);
6496 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6500 // return &fTrackPoints[i];