1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker -
24 // run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 // run AliTPCFindTracksMI.C macro - to find tracks
26 // tracks are written to AliTPCtracks.root file
27 // for comparison also seeds are written to the same file - to special branch
28 //-------------------------------------------------------
33 #include "Riostream.h"
34 #include <TClonesArray.h>
36 #include <TObjArray.h>
39 #include "AliComplexCluster.h"
41 #include "AliESDkink.h"
43 #include "AliRunLoader.h"
44 #include "AliTPCClustersRow.h"
45 #include "AliTPCParam.h"
46 #include "AliTPCReconstructor.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCseed.h"
51 #include "AliTPCtrackerMI.h"
52 #include "TStopwatch.h"
53 #include "AliTPCReconstructor.h"
54 #include "AliESDkink.h"
56 #include "TTreeStream.h"
57 #include "AliAlignObj.h"
58 #include "AliTrackPointArray.h"
62 ClassImp(AliTPCtrackerMI)
65 class AliTPCFastMath {
68 static Double_t FastAsin(Double_t x);
70 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
73 Double_t AliTPCFastMath::fgFastAsin[20000];
74 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
76 AliTPCFastMath::AliTPCFastMath(){
78 // initialized lookup table;
79 for (Int_t i=0;i<10000;i++){
80 fgFastAsin[2*i] = TMath::ASin(i/10000.);
81 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
85 Double_t AliTPCFastMath::FastAsin(Double_t x){
87 // return asin using lookup table
89 Int_t index = int(x*10000);
90 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
93 Int_t index = int(x*10000);
94 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
100 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
102 //update track information using current cluster - track->fCurrentCluster
105 AliTPCclusterMI* c =track->fCurrentCluster;
106 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
108 UInt_t i = track->fCurrentClusterIndex1;
110 Int_t sec=(i&0xff000000)>>24;
111 //Int_t row = (i&0x00ff0000)>>16;
112 track->fRow=(i&0x00ff0000)>>16;
113 track->fSector = sec;
114 // Int_t index = i&0xFFFF;
115 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
116 track->SetClusterIndex2(track->fRow, i);
117 //track->fFirstPoint = row;
118 //if ( track->fLastPoint<row) track->fLastPoint =row;
119 // if (track->fRow<0 || track->fRow>160) {
120 // printf("problem\n");
122 if (track->fFirstPoint>track->fRow)
123 track->fFirstPoint = track->fRow;
124 if (track->fLastPoint<track->fRow)
125 track->fLastPoint = track->fRow;
128 track->fClusterPointer[track->fRow] = c;
131 Float_t angle2 = track->GetSnp()*track->GetSnp();
132 angle2 = TMath::Sqrt(angle2/(1-angle2));
134 //SET NEW Track Point
138 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
140 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
141 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
142 point.SetErrY(sqrt(track->fErrorY2));
143 point.SetErrZ(sqrt(track->fErrorZ2));
145 point.SetX(track->GetX());
146 point.SetY(track->GetY());
147 point.SetZ(track->GetZ());
148 point.SetAngleY(angle2);
149 point.SetAngleZ(track->GetTgl());
150 if (point.fIsShared){
151 track->fErrorY2 *= 4;
152 track->fErrorZ2 *= 4;
156 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
158 track->fErrorY2 *= 1.3;
159 track->fErrorY2 += 0.01;
160 track->fErrorZ2 *= 1.3;
161 track->fErrorZ2 += 0.005;
163 if (accept>0) return 0;
164 if (track->GetNumberOfClusters()%20==0){
165 // if (track->fHelixIn){
166 // TClonesArray & larr = *(track->fHelixIn);
167 // Int_t ihelix = larr.GetEntriesFast();
168 // new(larr[ihelix]) AliHelix(*track) ;
171 track->fNoCluster =0;
172 return track->Update(c,chi2,i);
177 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
178 Float_t cory, Float_t corz)
181 // decide according desired precision to accept given
182 // cluster for tracking
183 Double_t sy2=ErrY2(seed,cluster)*cory;
184 Double_t sz2=ErrZ2(seed,cluster)*corz;
185 //sy2=ErrY2(seed,cluster)*cory;
186 //sz2=ErrZ2(seed,cluster)*cory;
188 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
189 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
191 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
192 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
193 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
194 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
196 Double_t rdistance2 = rdistancey2+rdistancez2;
199 if (rdistance2>16) return 3;
202 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
203 return 2; //suspisiouce - will be changed
205 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
206 // strict cut on overlaped cluster
207 return 2; //suspisiouce - will be changed
209 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
210 && cluster->GetType()<0){
220 //_____________________________________________________________________________
221 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
222 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
224 //---------------------------------------------------------------------
225 // The main TPC tracker constructor
226 //---------------------------------------------------------------------
227 fInnerSec=new AliTPCSector[fkNIS];
228 fOuterSec=new AliTPCSector[fkNOS];
231 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
232 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
239 Int_t nrowlow = par->GetNRowLow();
240 Int_t nrowup = par->GetNRowUp();
243 for (Int_t i=0;i<nrowlow;i++){
244 fXRow[i] = par->GetPadRowRadiiLow(i);
245 fPadLength[i]= par->GetPadPitchLength(0,i);
246 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
250 for (Int_t i=0;i<nrowup;i++){
251 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
252 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
253 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
264 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
266 //________________________________________________________________________
267 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
272 //------------------------------------
273 // dummy copy constructor
274 //------------------------------------------------------------------
276 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
277 //------------------------------
279 //--------------------------------------------------------------
282 //_____________________________________________________________________________
283 AliTPCtrackerMI::~AliTPCtrackerMI() {
284 //------------------------------------------------------------------
285 // TPC tracker destructor
286 //------------------------------------------------------------------
293 if (fDebugStreamer) delete fDebugStreamer;
296 void AliTPCtrackerMI::SetIO()
300 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
302 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
304 AliTPCtrack *iotrack= new AliTPCtrack;
305 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
311 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
327 AliTPCtrack *iotrack= new AliTPCtrack;
328 // iotrack->fHelixIn = new TClonesArray("AliHelix");
329 //iotrack->fHelixOut = new TClonesArray("AliHelix");
330 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
333 if (output && (fDebug&2)){
334 //write the full seed information if specified in debug mode
336 fSeedTree = new TTree("Seeds","Seeds");
337 AliTPCseed * vseed = new AliTPCseed;
339 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
340 arrtr->ExpandCreateFast(160);
341 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
343 vseed->fPoints = arrtr;
344 vseed->fEPoints = arre;
345 // vseed->fClusterPoints = arrcl;
346 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
349 fTreeDebug = new TTree("trackDebug","trackDebug");
350 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
351 fTreeDebug->Branch("debug",&arrd,32000,99);
359 void AliTPCtrackerMI::FillESD(TObjArray* arr)
363 //fill esds using updated tracks
365 // write tracks to the event
366 // store index of the track
367 Int_t nseed=arr->GetEntriesFast();
368 //FindKinks(arr,fEvent);
369 for (Int_t i=0; i<nseed; i++) {
370 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
373 // pt->PropagateTo(fParam->GetInnerRadiusLow());
374 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
375 pt->PropagateTo(fParam->GetInnerRadiusLow());
378 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
380 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
381 iotrack.SetTPCPoints(pt->GetPoints());
382 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
383 iotrack.SetV0Indexes(pt->GetV0Indexes());
384 // iotrack.SetTPCpid(pt->fTPCr);
385 //iotrack.SetTPCindex(i);
386 fEvent->AddTrack(&iotrack);
390 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
392 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
393 iotrack.SetTPCPoints(pt->GetPoints());
394 //iotrack.SetTPCindex(i);
395 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
396 iotrack.SetV0Indexes(pt->GetV0Indexes());
397 // iotrack.SetTPCpid(pt->fTPCr);
398 fEvent->AddTrack(&iotrack);
402 // short tracks - maybe decays
404 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
405 Int_t found,foundable,shared;
406 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
407 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
409 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
410 //iotrack.SetTPCindex(i);
411 iotrack.SetTPCPoints(pt->GetPoints());
412 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
413 iotrack.SetV0Indexes(pt->GetV0Indexes());
414 //iotrack.SetTPCpid(pt->fTPCr);
415 fEvent->AddTrack(&iotrack);
420 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
421 Int_t found,foundable,shared;
422 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
423 if (found<20) continue;
424 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
427 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
428 iotrack.SetTPCPoints(pt->GetPoints());
429 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
430 iotrack.SetV0Indexes(pt->GetV0Indexes());
431 //iotrack.SetTPCpid(pt->fTPCr);
432 //iotrack.SetTPCindex(i);
433 fEvent->AddTrack(&iotrack);
436 // short tracks - secondaties
438 if ( (pt->GetNumberOfClusters()>30) ) {
439 Int_t found,foundable,shared;
440 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
441 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
443 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
444 iotrack.SetTPCPoints(pt->GetPoints());
445 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
446 iotrack.SetV0Indexes(pt->GetV0Indexes());
447 //iotrack.SetTPCpid(pt->fTPCr);
448 //iotrack.SetTPCindex(i);
449 fEvent->AddTrack(&iotrack);
454 if ( (pt->GetNumberOfClusters()>15)) {
455 Int_t found,foundable,shared;
456 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
457 if (found<15) continue;
458 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
459 if (float(found)/float(foundable)<0.8) continue;
462 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
463 iotrack.SetTPCPoints(pt->GetPoints());
464 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
465 iotrack.SetV0Indexes(pt->GetV0Indexes());
466 // iotrack.SetTPCpid(pt->fTPCr);
467 //iotrack.SetTPCindex(i);
468 fEvent->AddTrack(&iotrack);
473 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
476 void AliTPCtrackerMI::WriteTracks(TTree * tree)
479 // write tracks from seed array to selected tree
483 AliTPCtrack *iotrack= new AliTPCtrack;
484 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
489 void AliTPCtrackerMI::WriteTracks()
492 // write tracks to the given output tree -
493 // output specified with SetIO routine
500 AliTPCtrack *iotrack= 0;
501 Int_t nseed=fSeeds->GetEntriesFast();
502 //for (Int_t i=0; i<nseed; i++) {
503 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
504 // if (iotrack) break;
506 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
507 TBranch * br = fOutput->GetBranch("tracks");
508 br->SetAddress(&iotrack);
510 for (Int_t i=0; i<nseed; i++) {
511 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
513 AliTPCtrack * track = new AliTPCtrack(*pt);
516 // br->SetAddress(&iotrack);
521 //fOutput->GetDirectory()->cd();
527 //write the full seed information if specified in debug mode
529 AliTPCseed * vseed = new AliTPCseed;
531 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
532 arrtr->ExpandCreateFast(160);
533 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
534 //arrcl->ExpandCreateFast(160);
535 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
537 vseed->fPoints = arrtr;
538 vseed->fEPoints = arre;
539 // vseed->fClusterPoints = arrcl;
540 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
541 TBranch * brseed = fSeedTree->GetBranch("seeds");
543 Int_t nseed=fSeeds->GetEntriesFast();
545 for (Int_t i=0; i<nseed; i++) {
546 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
549 // pt->fClusterPoints = arrcl;
553 brseed->SetAddress(&vseed);
557 // pt->fClusterPoints = 0;
560 if (fTreeDebug) fTreeDebug->Write();
568 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
571 //seed->SetErrorY2(0.1);
573 //calculate look-up table at the beginning
574 static Bool_t ginit = kFALSE;
575 static Float_t gnoise1,gnoise2,gnoise3;
576 static Float_t ggg1[10000];
577 static Float_t ggg2[10000];
578 static Float_t ggg3[10000];
579 static Float_t glandau1[10000];
580 static Float_t glandau2[10000];
581 static Float_t glandau3[10000];
583 static Float_t gcor01[500];
584 static Float_t gcor02[500];
585 static Float_t gcorp[500];
590 for (Int_t i=1;i<500;i++){
591 Float_t rsigma = float(i)/100.;
592 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
593 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
594 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
598 for (Int_t i=3;i<10000;i++){
602 Float_t amp = float(i);
603 Float_t padlength =0.75;
604 gnoise1 = 0.0004/padlength;
605 Float_t nel = 0.268*amp;
606 Float_t nprim = 0.155*amp;
607 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
608 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
609 if (glandau1[i]>1) glandau1[i]=1;
610 glandau1[i]*=padlength*padlength/12.;
614 gnoise2 = 0.0004/padlength;
617 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
618 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
619 if (glandau2[i]>1) glandau2[i]=1;
620 glandau2[i]*=padlength*padlength/12.;
625 gnoise3 = 0.0004/padlength;
628 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
629 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
630 if (glandau3[i]>1) glandau3[i]=1;
631 glandau3[i]*=padlength*padlength/12.;
639 Int_t amp = int(TMath::Abs(cl->GetQ()));
641 seed->SetErrorY2(1.);
645 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
646 Int_t ctype = cl->GetType();
647 Float_t padlength= GetPadPitchLength(seed->fRow);
648 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
649 angle2 = angle2/(1-angle2);
652 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
655 if (fSectors==fInnerSec){
657 res = ggg1[amp]*z+glandau1[amp]*angle2;
658 if (ctype==0) res *= gcor01[rsigmay];
661 res*= gcorp[rsigmay];
667 res = ggg2[amp]*z+glandau2[amp]*angle2;
668 if (ctype==0) res *= gcor02[rsigmay];
671 res*= gcorp[rsigmay];
676 res = ggg3[amp]*z+glandau3[amp]*angle2;
677 if (ctype==0) res *= gcor02[rsigmay];
680 res*= gcorp[rsigmay];
687 res*=2.4; // overestimate error 2 times
694 seed->SetErrorY2(res);
702 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
705 //seed->SetErrorY2(0.1);
707 //calculate look-up table at the beginning
708 static Bool_t ginit = kFALSE;
709 static Float_t gnoise1,gnoise2,gnoise3;
710 static Float_t ggg1[10000];
711 static Float_t ggg2[10000];
712 static Float_t ggg3[10000];
713 static Float_t glandau1[10000];
714 static Float_t glandau2[10000];
715 static Float_t glandau3[10000];
717 static Float_t gcor01[1000];
718 static Float_t gcor02[1000];
719 static Float_t gcorp[1000];
724 for (Int_t i=1;i<1000;i++){
725 Float_t rsigma = float(i)/100.;
726 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
727 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
728 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
732 for (Int_t i=3;i<10000;i++){
736 Float_t amp = float(i);
737 Float_t padlength =0.75;
738 gnoise1 = 0.0004/padlength;
739 Float_t nel = 0.268*amp;
740 Float_t nprim = 0.155*amp;
741 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
742 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
743 if (glandau1[i]>1) glandau1[i]=1;
744 glandau1[i]*=padlength*padlength/12.;
748 gnoise2 = 0.0004/padlength;
751 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
752 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
753 if (glandau2[i]>1) glandau2[i]=1;
754 glandau2[i]*=padlength*padlength/12.;
759 gnoise3 = 0.0004/padlength;
762 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
763 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
764 if (glandau3[i]>1) glandau3[i]=1;
765 glandau3[i]*=padlength*padlength/12.;
773 Int_t amp = int(TMath::Abs(cl->GetQ()));
775 seed->SetErrorY2(1.);
779 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
780 Int_t ctype = cl->GetType();
781 Float_t padlength= GetPadPitchLength(seed->fRow);
783 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
784 // if (angle2<0.6) angle2 = 0.6;
785 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
788 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
791 if (fSectors==fInnerSec){
793 res = ggg1[amp]*z+glandau1[amp]*angle2;
794 if (ctype==0) res *= gcor01[rsigmaz];
797 res*= gcorp[rsigmaz];
803 res = ggg2[amp]*z+glandau2[amp]*angle2;
804 if (ctype==0) res *= gcor02[rsigmaz];
807 res*= gcorp[rsigmaz];
812 res = ggg3[amp]*z+glandau3[amp]*angle2;
813 if (ctype==0) res *= gcor02[rsigmaz];
816 res*= gcorp[rsigmaz];
825 if ((ctype<0) &&<70){
833 seed->SetErrorZ2(res);
840 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
843 //seed->SetErrorZ2(0.1);
847 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
849 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
850 Int_t ctype = cl->GetType();
851 Float_t amp = TMath::Abs(cl->GetQ());
856 Float_t landau=2 ; //landau fluctuation part
857 Float_t gg=2; // gg fluctuation part
858 Float_t padlength= GetPadPitchLength(seed->GetX());
860 if (fSectors==fInnerSec){
861 snoise2 = 0.0004/padlength;
864 gg = (2+0.001*nel/(padlength*padlength))/nel;
865 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
866 if (landau>1) landau=1;
869 snoise2 = 0.0004/padlength;
872 gg = (2+0.0008*nel/(padlength*padlength))/nel;
873 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
874 if (landau>1) landau=1;
876 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
879 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
880 angle2 = TMath::Sqrt((1-angle2));
881 if (angle2<0.6) angle2 = 0.6;
884 Float_t angle = seed->GetTgl()/angle2;
885 Float_t angular = landau*angle*angle*padlength*padlength/12.;
886 Float_t res = sdiff + angular;
889 if ((ctype==0) && (fSectors ==fOuterSec))
890 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
892 if ((ctype==0) && (fSectors ==fInnerSec))
893 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
897 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
903 if ((ctype<0) &&<70){
911 seed->SetErrorZ2(res);
919 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
921 //rotate to track "local coordinata
922 Float_t x = seed->GetX();
923 Float_t y = seed->GetY();
924 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
927 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
928 if (!seed->Rotate(fSectors->GetAlpha()))
930 } else if (y <-ymax) {
931 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
932 if (!seed->Rotate(-fSectors->GetAlpha()))
940 //_____________________________________________________________________________
941 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
942 Double_t x2,Double_t y2,
943 Double_t x3,Double_t y3)
945 //-----------------------------------------------------------------
946 // Initial approximation of the track curvature
947 //-----------------------------------------------------------------
948 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
949 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
950 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
951 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
952 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
954 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
955 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
956 return -xr*yr/sqrt(xr*xr+yr*yr);
961 //_____________________________________________________________________________
962 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
963 Double_t x2,Double_t y2,
964 Double_t x3,Double_t y3)
966 //-----------------------------------------------------------------
967 // Initial approximation of the track curvature
968 //-----------------------------------------------------------------
974 Double_t det = x3*y2-x2*y3;
979 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
980 Double_t x0 = x3*0.5-y3*u;
981 Double_t y0 = y3*0.5+x3*u;
982 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
988 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
989 Double_t x2,Double_t y2,
990 Double_t x3,Double_t y3)
992 //-----------------------------------------------------------------
993 // Initial approximation of the track curvature
994 //-----------------------------------------------------------------
1000 Double_t det = x3*y2-x2*y3;
1005 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1006 Double_t x0 = x3*0.5-y3*u;
1007 Double_t y0 = y3*0.5+x3*u;
1008 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1017 //_____________________________________________________________________________
1018 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1019 Double_t x2,Double_t y2,
1020 Double_t x3,Double_t y3)
1022 //-----------------------------------------------------------------
1023 // Initial approximation of the track curvature times center of curvature
1024 //-----------------------------------------------------------------
1025 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1026 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1027 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1028 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1029 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1031 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1033 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1036 //_____________________________________________________________________________
1037 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1038 Double_t x2,Double_t y2,
1039 Double_t z1,Double_t z2)
1041 //-----------------------------------------------------------------
1042 // Initial approximation of the tangent of the track dip angle
1043 //-----------------------------------------------------------------
1044 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1048 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1049 Double_t x2,Double_t y2,
1050 Double_t z1,Double_t z2, Double_t c)
1052 //-----------------------------------------------------------------
1053 // Initial approximation of the tangent of the track dip angle
1054 //-----------------------------------------------------------------
1058 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1060 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1061 if (TMath::Abs(d*c*0.5)>1) return 0;
1062 // Double_t angle2 = TMath::ASin(d*c*0.5);
1063 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1064 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1066 angle2 = (z1-z2)*c/(angle2*2.);
1070 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1071 {//-----------------------------------------------------------------
1072 // This function find proloncation of a track to a reference plane x=x2.
1073 //-----------------------------------------------------------------
1077 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1081 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1082 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1086 Double_t dy = dx*(c1+c2)/(r1+r2);
1089 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1091 if (TMath::Abs(delta)>0.01){
1092 dz = x[3]*TMath::ASin(delta)/x[4];
1094 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1097 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1105 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1110 return LoadClusters();
1113 Int_t AliTPCtrackerMI::LoadClusters()
1116 // load clusters to the memory
1117 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1118 clrow->SetClass("AliTPCclusterMI");
1120 clrow->GetArray()->ExpandCreateFast(10000);
1122 // TTree * tree = fClustersArray.GetTree();
1124 TTree * tree = fInput;
1125 TBranch * br = tree->GetBranch("Segment");
1126 br->SetAddress(&clrow);
1128 Int_t j=Int_t(tree->GetEntries());
1129 for (Int_t i=0; i<j; i++) {
1133 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1135 AliTPCRow * tpcrow=0;
1138 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1142 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1143 left = (sec-fkNIS*2)/fkNOS;
1146 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1147 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1148 for (Int_t i=0;i<tpcrow->fN1;i++)
1149 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1152 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1153 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1154 for (Int_t i=0;i<tpcrow->fN2;i++)
1155 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1166 void AliTPCtrackerMI::UnloadClusters()
1169 // unload clusters from the memory
1171 Int_t nrows = fOuterSec->GetNRows();
1172 for (Int_t sec = 0;sec<fkNOS;sec++)
1173 for (Int_t row = 0;row<nrows;row++){
1174 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1176 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1177 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1179 tpcrow->ResetClusters();
1182 nrows = fInnerSec->GetNRows();
1183 for (Int_t sec = 0;sec<fkNIS;sec++)
1184 for (Int_t row = 0;row<nrows;row++){
1185 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1187 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1188 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1190 tpcrow->ResetClusters();
1197 //_____________________________________________________________________________
1198 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1199 //-----------------------------------------------------------------
1200 // This function fills outer TPC sectors with clusters.
1201 //-----------------------------------------------------------------
1202 Int_t nrows = fOuterSec->GetNRows();
1204 for (Int_t sec = 0;sec<fkNOS;sec++)
1205 for (Int_t row = 0;row<nrows;row++){
1206 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1207 Int_t sec2 = sec+2*fkNIS;
1209 Int_t ncl = tpcrow->fN1;
1211 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1212 index=(((sec2<<8)+row)<<16)+ncl;
1213 tpcrow->InsertCluster(c,index);
1218 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1219 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1220 tpcrow->InsertCluster(c,index);
1223 // write indexes for fast acces
1225 for (Int_t i=0;i<510;i++)
1226 tpcrow->fFastCluster[i]=-1;
1227 for (Int_t i=0;i<tpcrow->GetN();i++){
1228 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1229 tpcrow->fFastCluster[zi]=i; // write index
1232 for (Int_t i=0;i<510;i++){
1233 if (tpcrow->fFastCluster[i]<0)
1234 tpcrow->fFastCluster[i] = last;
1236 last = tpcrow->fFastCluster[i];
1245 //_____________________________________________________________________________
1246 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1247 //-----------------------------------------------------------------
1248 // This function fills inner TPC sectors with clusters.
1249 //-----------------------------------------------------------------
1250 Int_t nrows = fInnerSec->GetNRows();
1252 for (Int_t sec = 0;sec<fkNIS;sec++)
1253 for (Int_t row = 0;row<nrows;row++){
1254 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1257 Int_t ncl = tpcrow->fN1;
1259 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1260 index=(((sec<<8)+row)<<16)+ncl;
1261 tpcrow->InsertCluster(c,index);
1266 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1267 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1268 tpcrow->InsertCluster(c,index);
1271 // write indexes for fast acces
1273 for (Int_t i=0;i<510;i++)
1274 tpcrow->fFastCluster[i]=-1;
1275 for (Int_t i=0;i<tpcrow->GetN();i++){
1276 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1277 tpcrow->fFastCluster[zi]=i; // write index
1280 for (Int_t i=0;i<510;i++){
1281 if (tpcrow->fFastCluster[i]<0)
1282 tpcrow->fFastCluster[i] = last;
1284 last = tpcrow->fFastCluster[i];
1296 //_________________________________________________________________________
1297 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1298 //--------------------------------------------------------------------
1299 // Return pointer to a given cluster
1300 //--------------------------------------------------------------------
1301 Int_t sec=(index&0xff000000)>>24;
1302 Int_t row=(index&0x00ff0000)>>16;
1303 Int_t ncl=(index&0x00007fff)>>00;
1305 const AliTPCRow * tpcrow=0;
1306 AliTPCclusterMI * clrow =0;
1309 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1310 if (tpcrow==0) return 0;
1313 if (tpcrow->fN1<=ncl) return 0;
1314 clrow = tpcrow->fClusters1;
1317 if (tpcrow->fN2<=ncl) return 0;
1318 clrow = tpcrow->fClusters2;
1322 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1323 if (tpcrow==0) return 0;
1325 if (sec-2*fkNIS<fkNOS) {
1326 if (tpcrow->fN1<=ncl) return 0;
1327 clrow = tpcrow->fClusters1;
1330 if (tpcrow->fN2<=ncl) return 0;
1331 clrow = tpcrow->fClusters2;
1335 return &(clrow[ncl]);
1341 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1342 //-----------------------------------------------------------------
1343 // This function tries to find a track prolongation to next pad row
1344 //-----------------------------------------------------------------
1346 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1347 AliTPCclusterMI *cl=0;
1348 Int_t tpcindex= t.GetClusterIndex2(nr);
1350 // update current shape info every 5 pad-row
1351 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1355 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1357 if (tpcindex==-1) return 0; //track in dead zone
1359 cl = t.fClusterPointer[nr];
1360 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1361 t.fCurrentClusterIndex1 = tpcindex;
1364 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1365 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1367 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1368 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1370 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1371 Double_t rotation = angle-t.GetAlpha();
1372 t.fRelativeSector= relativesector;
1377 t.fCurrentCluster = cl;
1379 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1380 if ((tpcindex&0x8000)==0) accept =0;
1382 //if founded cluster is acceptible
1383 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1390 UpdateTrack(&t,accept);
1395 if (fIteration>1) {t.fNFoundable++; return 0;} // not look for new cluster during refitting
1398 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1399 Double_t y=t.GetYat(x);
1400 if (TMath::Abs(y)>ymax){
1402 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1403 if (!t.Rotate(fSectors->GetAlpha()))
1405 } else if (y <-ymax) {
1406 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1407 if (!t.Rotate(-fSectors->GetAlpha()))
1413 if (!t.PropagateTo(x)) {
1414 if (fIteration==0) t.fRemoval = 10;
1418 Double_t z=t.GetZ();
1420 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1421 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1423 Double_t roadz = 1.;
1425 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1427 t.SetClusterIndex2(nr,-1);
1432 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() ) t.fNFoundable++;
1438 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1439 cl = krow.FindNearest2(y,z,roady,roadz,index);
1440 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1443 t.fCurrentCluster = cl;
1445 if (fIteration==2&&cl->IsUsed(10)) return 0;
1446 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1447 if (fIteration==2&&cl->IsUsed(11)) {
1454 if (t.fCurrentCluster->IsUsed(10)){
1459 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1465 if (accept<3) UpdateTrack(&t,accept);
1468 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1474 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1475 //-----------------------------------------------------------------
1476 // This function tries to find a track prolongation to next pad row
1477 //-----------------------------------------------------------------
1479 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1481 if (!t.GetProlongation(x,y,z)) {
1487 if (TMath::Abs(y)>ymax){
1490 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1491 if (!t.Rotate(fSectors->GetAlpha()))
1493 } else if (y <-ymax) {
1494 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1495 if (!t.Rotate(-fSectors->GetAlpha()))
1498 if (!t.PropagateTo(x)) {
1501 t.GetProlongation(x,y,z);
1504 // update current shape info every 3 pad-row
1505 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1506 // t.fCurrentSigmaY = GetSigmaY(&t);
1507 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1511 AliTPCclusterMI *cl=0;
1516 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1517 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1519 Double_t roadz = 1.;
1522 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1524 t.SetClusterIndex2(row,-1);
1529 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1533 if ((cl==0)&&(krow)) {
1534 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1535 cl = krow.FindNearest2(y,z,roady,roadz,index);
1537 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1541 t.fCurrentCluster = cl;
1542 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1544 t.SetClusterIndex2(row,index);
1545 t.fClusterPointer[row] = cl;
1553 //_________________________________________________________________________
1554 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1556 // Get track space point by index
1557 // return false in case the cluster doesn't exist
1558 AliTPCclusterMI *cl = GetClusterMI(index);
1559 if (!cl) return kFALSE;
1560 Int_t sector = (index&0xff000000)>>24;
1561 Int_t row = (index&0x00ff0000)>>16;
1563 xyz[0] = fParam->GetPadRowRadii(sector,row);
1564 xyz[1] = cl->GetY();
1565 xyz[2] = cl->GetZ();
1567 fParam->AdjustCosSin(sector,cos,sin);
1568 Float_t x = cos*xyz[0]-sin*xyz[1];
1569 Float_t y = cos*xyz[1]+sin*xyz[0];
1571 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1572 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1573 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1574 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1575 cov[0] = sin*sin*sigmaY2;
1576 cov[1] = -sin*cos*sigmaY2;
1578 cov[3] = cos*cos*sigmaY2;
1581 p.SetXYZ(x,y,xyz[2],cov);
1582 AliAlignObj::ELayerID iLayer;
1584 if (sector < fParam->GetNInnerSector()) {
1585 iLayer = AliAlignObj::kTPC1;
1589 iLayer = AliAlignObj::kTPC2;
1590 idet = sector - fParam->GetNInnerSector();
1592 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1593 p.SetVolumeID(volid);
1599 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1600 //-----------------------------------------------------------------
1601 // This function tries to find a track prolongation to next pad row
1602 //-----------------------------------------------------------------
1603 t.fCurrentCluster = 0;
1604 t.fCurrentClusterIndex1 = 0;
1606 Double_t xt=t.GetX();
1607 Int_t row = GetRowNumber(xt)-1;
1608 Double_t ymax= GetMaxY(nr);
1610 if (row < nr) return 1; // don't prolongate if not information until now -
1611 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1613 return 0; // not prolongate strongly inclined tracks
1615 if (TMath::Abs(t.GetSnp())>0.95) {
1617 return 0; // not prolongate strongly inclined tracks
1620 Double_t x= GetXrow(nr);
1622 //t.PropagateTo(x+0.02);
1623 //t.PropagateTo(x+0.01);
1624 if (!t.PropagateTo(x)){
1631 if (TMath::Abs(y)>ymax){
1633 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1634 if (!t.Rotate(fSectors->GetAlpha()))
1636 } else if (y <-ymax) {
1637 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1638 if (!t.Rotate(-fSectors->GetAlpha()))
1641 // if (!t.PropagateTo(x)){
1649 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1651 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1653 t.SetClusterIndex2(nr,-1);
1658 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1664 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1665 // t.fCurrentSigmaY = GetSigmaY(&t);
1666 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1670 AliTPCclusterMI *cl=0;
1673 Double_t roady = 1.;
1674 Double_t roadz = 1.;
1678 index = t.GetClusterIndex2(nr);
1679 if ( (index>0) && (index&0x8000)==0){
1680 cl = t.fClusterPointer[nr];
1681 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1682 t.fCurrentClusterIndex1 = index;
1684 t.fCurrentCluster = cl;
1690 // if (index<0) return 0;
1691 UInt_t uindex = TMath::Abs(index);
1694 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1695 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1698 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1699 t.fCurrentCluster = cl;
1705 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1706 //-----------------------------------------------------------------
1707 // This function tries to find a track prolongation to next pad row
1708 //-----------------------------------------------------------------
1710 //update error according neighborhoud
1712 if (t.fCurrentCluster) {
1714 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1716 if (t.fCurrentCluster->IsUsed(10)){
1722 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1727 if (fIteration>0) accept = 0;
1728 if (accept<3) UpdateTrack(&t,accept);
1732 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1733 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1735 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1743 //_____________________________________________________________________________
1744 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1745 //-----------------------------------------------------------------
1746 // This function tries to find a track prolongation.
1747 //-----------------------------------------------------------------
1748 Double_t xt=t.GetX();
1750 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1751 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1752 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1754 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1756 Int_t first = GetRowNumber(xt)-1;
1757 for (Int_t nr= first; nr>=rf; nr-=step) {
1759 if (t.GetKinkIndexes()[0]>0){
1760 for (Int_t i=0;i<3;i++){
1761 Int_t index = t.GetKinkIndexes()[i];
1762 if (index==0) break;
1763 if (index<0) continue;
1765 AliESDkink * kink = fEvent->GetKink(index-1);
1767 printf("PROBLEM\n");
1770 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1772 AliExternalTrackParam paramd(t);
1773 kink->SetDaughter(paramd);
1774 kink->SetStatus(2,5);
1781 if (nr==80) t.UpdateReference();
1782 if (nr<fInnerSec->GetNRows())
1783 fSectors = fInnerSec;
1785 fSectors = fOuterSec;
1786 if (FollowToNext(t,nr)==0)
1795 //_____________________________________________________________________________
1796 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1797 //-----------------------------------------------------------------
1798 // This function tries to find a track prolongation.
1799 //-----------------------------------------------------------------
1800 Double_t xt=t.GetX();
1802 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1803 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1804 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1805 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1807 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1809 if (FollowToNextFast(t,nr)==0)
1810 if (!t.IsActive()) return 0;
1820 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1821 //-----------------------------------------------------------------
1822 // This function tries to find a track prolongation.
1823 //-----------------------------------------------------------------
1825 Double_t xt=t.GetX();
1826 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1827 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1828 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1829 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1831 Int_t first = t.fFirstPoint;
1832 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1834 if (first<0) first=0;
1835 for (Int_t nr=first; nr<=rf; nr++) {
1836 if ( (TMath::Abs(t.GetSnp())>0.95)) break;
1837 if (t.GetKinkIndexes()[0]<0){
1838 for (Int_t i=0;i<3;i++){
1839 Int_t index = t.GetKinkIndexes()[i];
1840 if (index==0) break;
1841 if (index>0) continue;
1842 index = TMath::Abs(index);
1843 AliESDkink * kink = fEvent->GetKink(index-1);
1845 printf("PROBLEM\n");
1848 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1850 AliExternalTrackParam paramm(t);
1851 kink->SetMother(paramm);
1852 kink->SetStatus(2,1);
1859 if (nr<fInnerSec->GetNRows())
1860 fSectors = fInnerSec;
1862 fSectors = fOuterSec;
1872 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1880 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1883 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1885 Float_t distance = TMath::Sqrt(dz2+dy2);
1886 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1889 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1890 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1895 if (firstpoint>lastpoint) {
1896 firstpoint =lastpoint;
1901 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1902 if (s1->GetClusterIndex2(i)>0) sum1++;
1903 if (s2->GetClusterIndex2(i)>0) sum2++;
1904 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1908 if (sum<5) return 0;
1910 Float_t summin = TMath::Min(sum1+1,sum2+1);
1911 Float_t ratio = (sum+1)/Float_t(summin);
1915 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1919 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1920 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1922 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1924 Float_t dy2 =(s1->GetY() - s2->GetY());
1926 Float_t distance = dz2+dy2;
1927 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1932 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1933 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1935 if (firstpoint>=lastpoint-5) return;;
1937 for (Int_t i=firstpoint;i<lastpoint;i++){
1938 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1939 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1946 for (Int_t i=firstpoint;i<lastpoint;i++){
1947 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1948 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1949 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1950 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1951 if (s1->IsActive()&&s2->IsActive()){
1952 p1->fIsShared = kTRUE;
1953 p2->fIsShared = kTRUE;
1960 for (Int_t i=0;i<4;i++){
1961 if (s1->fOverlapLabels[3*i]==0){
1962 s1->fOverlapLabels[3*i] = s2->GetLabel();
1963 s1->fOverlapLabels[3*i+1] = sumshared;
1964 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1968 for (Int_t i=0;i<4;i++){
1969 if (s2->fOverlapLabels[3*i]==0){
1970 s2->fOverlapLabels[3*i] = s1->GetLabel();
1971 s2->fOverlapLabels[3*i+1] = sumshared;
1972 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1980 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1983 //sort trackss according sectors
1985 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1986 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1988 //if (pt) RotateToLocal(pt);
1992 arr->Sort(); // sorting according z
1993 arr->Expand(arr->GetEntries());
1996 Int_t nseed=arr->GetEntriesFast();
1997 for (Int_t i=0; i<nseed; i++) {
1998 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2000 for (Int_t j=0;j<=12;j++){
2001 pt->fOverlapLabels[j] =0;
2004 for (Int_t i=0; i<nseed; i++) {
2005 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2007 if (pt->fRemoval>10) continue;
2008 for (Int_t j=i+1; j<nseed; j++){
2009 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2011 if (pt2->fRemoval<=10) {
2012 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2019 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2022 //sort trackss according sectors
2025 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2028 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2029 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2034 arr->Sort(); // sorting according z
2035 arr->Expand(arr->GetEntries());
2037 //reset overlap labels
2039 Int_t nseed=arr->GetEntriesFast();
2040 for (Int_t i=0; i<nseed; i++) {
2041 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2044 for (Int_t j=0;j<=12;j++){
2045 pt->fOverlapLabels[j] =0;
2049 //sign shared tracks
2050 for (Int_t i=0; i<nseed; i++) {
2051 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2053 if (pt->fRemoval>10) continue;
2054 Float_t deltac = pt->GetC()*0.1;
2055 for (Int_t j=i+1; j<nseed; j++){
2056 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2058 if (pt2->fRemoval<=10) {
2059 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2060 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2061 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2068 // remove highly shared tracks
2069 for (Int_t i=0; i<nseed; i++) {
2070 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2072 if (pt->fRemoval>10) continue;
2075 for (Int_t j=0;j<4;j++){
2076 sumshared = pt->fOverlapLabels[j*3+1];
2078 Float_t factor = factor1;
2079 if (pt->fRemoval>0) factor = factor2;
2080 if (sumshared/pt->GetNumberOfClusters()>factor){
2081 for (Int_t j=0;j<4;j++){
2082 if (pt->fOverlapLabels[3*j]==0) continue;
2083 if (pt->fOverlapLabels[3*j+1]<5) continue;
2084 if (pt->fRemoval==removalindex) continue;
2085 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2087 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2088 // pt->fRemoval = removalindex;
2089 delete arr->RemoveAt(i);
2097 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2106 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2109 //sort tracks in array according mode criteria
2110 Int_t nseed = arr->GetEntriesFast();
2111 for (Int_t i=0; i<nseed; i++) {
2112 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2122 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2125 //Loop over all tracks and remove "overlaps"
2128 Int_t nseed = arr->GetEntriesFast();
2131 for (Int_t i=0; i<nseed; i++) {
2132 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2134 delete arr->RemoveAt(i);
2138 pt->fBSigned = kFALSE;
2142 nseed = arr->GetEntriesFast();
2149 for (Int_t i=0; i<nseed; i++) {
2150 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2154 Int_t found,foundable,shared;
2156 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2158 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2160 Double_t factor = factor2;
2161 if (pt->fBConstrain) factor = factor1;
2163 if ((Float_t(shared)/Float_t(found))>factor){
2164 pt->Desactivate(removalindex);
2169 for (Int_t i=0; i<160; i++) {
2170 Int_t index=pt->GetClusterIndex2(i);
2171 if (index<0 || index&0x8000 ) continue;
2172 AliTPCclusterMI *c= pt->fClusterPointer[i];
2174 // if (!c->IsUsed(10)) c->Use(10);
2175 //if (pt->IsActive())
2184 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2189 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2192 //Loop over all tracks and remove "overlaps"
2197 Int_t nseed = arr->GetEntriesFast();
2198 Float_t * quality = new Float_t[nseed];
2199 Int_t * indexes = new Int_t[nseed];
2203 for (Int_t i=0; i<nseed; i++) {
2204 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2209 pt->UpdatePoints(); //select first last max dens points
2210 Float_t * points = pt->GetPoints();
2211 if (points[3]<0.8) quality[i] =-1;
2213 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2215 TMath::Sort(nseed,quality,indexes);
2218 for (Int_t itrack=0; itrack<nseed; itrack++) {
2219 Int_t trackindex = indexes[itrack];
2220 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2221 if (quality[trackindex]<0){
2223 delete arr->RemoveAt(trackindex);
2226 arr->RemoveAt(trackindex);
2231 Int_t first = Int_t(pt->GetPoints()[0]);
2232 Int_t last = Int_t(pt->GetPoints()[2]);
2233 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2235 Int_t found,foundable,shared;
2236 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2237 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2238 Bool_t itsgold =kFALSE;
2241 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
2245 if (Float_t(shared+1)/Float_t(found+1)>factor){
2246 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2247 delete arr->RemoveAt(trackindex);
2250 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2251 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2252 delete arr->RemoveAt(trackindex);
2258 if (sharedfactor>0.4) continue;
2259 if (pt->GetKinkIndexes()[0]>0) continue;
2260 for (Int_t i=first; i<last; i++) {
2261 Int_t index=pt->GetClusterIndex2(i);
2262 // if (index<0 || index&0x8000 ) continue;
2263 if (index<0 || index&0x8000 ) continue;
2264 AliTPCclusterMI *c= pt->fClusterPointer[i];
2271 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2277 void AliTPCtrackerMI::UnsignClusters()
2280 // loop over all clusters and unsign them
2283 for (Int_t sec=0;sec<fkNIS;sec++){
2284 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2285 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2286 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2287 // if (cl[icl].IsUsed(10))
2289 cl = fInnerSec[sec][row].fClusters2;
2290 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2291 //if (cl[icl].IsUsed(10))
2296 for (Int_t sec=0;sec<fkNOS;sec++){
2297 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2298 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2299 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2300 //if (cl[icl].IsUsed(10))
2302 cl = fOuterSec[sec][row].fClusters2;
2303 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2304 //if (cl[icl].IsUsed(10))
2313 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2316 //sign clusters to be "used"
2318 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2319 // loop over "primaries"
2333 Int_t nseed = arr->GetEntriesFast();
2334 for (Int_t i=0; i<nseed; i++) {
2335 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2339 if (!(pt->IsActive())) continue;
2340 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2341 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2343 sumdens2+= dens*dens;
2344 sumn += pt->GetNumberOfClusters();
2345 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2346 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2349 sumchi2 +=chi2*chi2;
2354 Float_t mdensity = 0.9;
2355 Float_t meann = 130;
2356 Float_t meanchi = 1;
2357 Float_t sdensity = 0.1;
2358 Float_t smeann = 10;
2359 Float_t smeanchi =0.4;
2363 mdensity = sumdens/sum;
2365 meanchi = sumchi/sum;
2367 sdensity = sumdens2/sum-mdensity*mdensity;
2368 sdensity = TMath::Sqrt(sdensity);
2370 smeann = sumn2/sum-meann*meann;
2371 smeann = TMath::Sqrt(smeann);
2373 smeanchi = sumchi2/sum - meanchi*meanchi;
2374 smeanchi = TMath::Sqrt(smeanchi);
2378 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2380 for (Int_t i=0; i<nseed; i++) {
2381 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2385 if (pt->fBSigned) continue;
2386 if (pt->fBConstrain) continue;
2387 //if (!(pt->IsActive())) continue;
2389 Int_t found,foundable,shared;
2390 pt->GetClusterStatistic(0,160,found, foundable,shared);
2391 if (shared/float(found)>0.3) {
2392 if (shared/float(found)>0.9 ){
2393 //delete arr->RemoveAt(i);
2398 Bool_t isok =kFALSE;
2399 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2401 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2403 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2405 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2409 for (Int_t i=0; i<160; i++) {
2410 Int_t index=pt->GetClusterIndex2(i);
2411 if (index<0) continue;
2412 AliTPCclusterMI *c= pt->fClusterPointer[i];
2414 //if (!(c->IsUsed(10))) c->Use();
2421 Double_t maxchi = meanchi+2.*smeanchi;
2423 for (Int_t i=0; i<nseed; i++) {
2424 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2428 //if (!(pt->IsActive())) continue;
2429 if (pt->fBSigned) continue;
2430 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2431 if (chi>maxchi) continue;
2434 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2436 //sign only tracks with enoug big density at the beginning
2438 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2441 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2442 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2444 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2445 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2448 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2449 //Int_t noc=pt->GetNumberOfClusters();
2450 pt->fBSigned = kTRUE;
2451 for (Int_t i=0; i<160; i++) {
2453 Int_t index=pt->GetClusterIndex2(i);
2454 if (index<0) continue;
2455 AliTPCclusterMI *c= pt->fClusterPointer[i];
2457 // if (!(c->IsUsed(10))) c->Use();
2462 // gLastCheck = nseed;
2470 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2472 // stop not active tracks
2473 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2474 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2475 Int_t nseed = arr->GetEntriesFast();
2477 for (Int_t i=0; i<nseed; i++) {
2478 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2482 if (!(pt->IsActive())) continue;
2483 StopNotActive(pt,row0,th0, th1,th2);
2489 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2492 // stop not active tracks
2493 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2494 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2497 Int_t foundable = 0;
2498 Int_t maxindex = seed->fLastPoint; //last foundable row
2499 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2500 seed->Desactivate(10) ;
2504 for (Int_t i=row0; i<maxindex; i++){
2505 Int_t index = seed->GetClusterIndex2(i);
2506 if (index!=-1) foundable++;
2508 if (foundable<=30) sumgood1++;
2509 if (foundable<=50) {
2516 if (foundable>=30.){
2517 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2520 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2524 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2527 // back propagation of ESD tracks
2533 //PrepareForProlongation(fSeeds,1);
2534 PropagateForward2(fSeeds);
2537 Int_t nseed = fSeeds->GetEntriesFast();
2538 for (Int_t i=0;i<nseed;i++){
2539 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2540 if (!seed) continue;
2541 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2543 seed->PropagateTo(fParam->GetInnerRadiusLow());
2544 seed->UpdatePoints();
2545 AliESDtrack *esd=event->GetTrack(i);
2546 seed->CookdEdx(0.02,0.6);
2547 CookLabel(seed,0.1); //For comparison only
2549 if (0 && seed!=0&&esd!=0) {
2550 TTreeSRedirector &cstream = *fDebugStreamer;
2556 if (seed->GetNumberOfClusters()>15){
2557 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2558 esd->SetTPCPoints(seed->GetPoints());
2559 esd->SetTPCPointsF(seed->fNFoundable);
2560 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2561 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2562 Float_t dedx = seed->GetdEdx();
2563 esd->SetTPCsignal(dedx, sdedx, ndedx);
2567 //printf("problem\n");
2570 //FindKinks(fSeeds,event);
2571 Info("RefitInward","Number of refitted tracks %d",ntracks);
2578 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2581 // back propagation of ESD tracks
2587 PropagateBack(fSeeds);
2588 RemoveUsed2(fSeeds,0.4,0.4,20);
2590 Int_t nseed = fSeeds->GetEntriesFast();
2592 for (Int_t i=0;i<nseed;i++){
2593 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2594 if (!seed) continue;
2595 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2596 seed->UpdatePoints();
2597 AliESDtrack *esd=event->GetTrack(i);
2598 seed->CookdEdx(0.02,0.6);
2599 CookLabel(seed,0.1); //For comparison only
2600 if (seed->GetNumberOfClusters()>15){
2601 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2602 esd->SetTPCPoints(seed->GetPoints());
2603 esd->SetTPCPointsF(seed->fNFoundable);
2604 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2605 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2606 Float_t dedx = seed->GetdEdx();
2607 esd->SetTPCsignal(dedx, sdedx, ndedx);
2611 //FindKinks(fSeeds,event);
2612 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2619 void AliTPCtrackerMI::DeleteSeeds()
2623 Int_t nseed = fSeeds->GetEntriesFast();
2624 for (Int_t i=0;i<nseed;i++){
2625 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2626 if (seed) delete fSeeds->RemoveAt(i);
2632 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2635 //read seeds from the event
2637 Int_t nentr=event->GetNumberOfTracks();
2639 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2644 fSeeds = new TObjArray(nentr);
2648 for (Int_t i=0; i<nentr; i++) {
2649 AliESDtrack *esd=event->GetTrack(i);
2650 ULong_t status=esd->GetStatus();
2651 if (!(status&AliESDtrack::kTPCin)) continue;
2652 AliTPCtrack t(*esd);
2653 t.SetNumberOfClusters(0);
2654 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2655 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2656 for (Int_t ikink=0;ikink<3;ikink++) {
2657 Int_t index = esd->GetKinkIndex(ikink);
2658 seed->GetKinkIndexes()[ikink] = index;
2659 if (index==0) continue;
2660 index = TMath::Abs(index);
2661 AliESDkink * kink = fEvent->GetKink(index-1);
2662 if (kink&&esd->GetKinkIndex(ikink)<0){
2663 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2664 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2666 if (kink&&esd->GetKinkIndex(ikink)>0){
2667 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2668 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2672 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance();
2673 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2674 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2679 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2680 Double_t par0[5],par1[5],alpha,x;
2681 esd->GetInnerExternalParameters(alpha,x,par0);
2682 esd->GetExternalParameters(x,par1);
2683 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2684 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2686 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2687 //reset covariance if suspicious
2688 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2689 seed->ResetCovariance();
2694 // rotate to the local coordinate system
2696 fSectors=fInnerSec; fN=fkNIS;
2697 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2698 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2699 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2700 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2701 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2702 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2703 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2704 alpha-=seed->GetAlpha();
2705 if (!seed->Rotate(alpha)) {
2711 if (esd->GetKinkIndex(0)<=0){
2712 for (Int_t irow=0;irow<160;irow++){
2713 Int_t index = seed->GetClusterIndex2(irow);
2716 AliTPCclusterMI * cl = GetClusterMI(index);
2717 seed->fClusterPointer[irow] = cl;
2719 if ((index & 0x8000)==0){
2720 cl->Use(10); // accepted cluster
2722 cl->Use(6); // close cluster not accepted
2725 Info("ReadSeeds","Not found cluster");
2730 fSeeds->AddAt(seed,i);
2736 //_____________________________________________________________________________
2737 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2738 Float_t deltay, Int_t ddsec) {
2739 //-----------------------------------------------------------------
2740 // This function creates track seeds.
2741 // SEEDING WITH VERTEX CONSTRAIN
2742 //-----------------------------------------------------------------
2743 // cuts[0] - fP4 cut
2744 // cuts[1] - tan(phi) cut
2745 // cuts[2] - zvertex cut
2746 // cuts[3] - fP3 cut
2754 Double_t x[5], c[15];
2755 // Int_t di = i1-i2;
2757 AliTPCseed * seed = new AliTPCseed;
2758 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2759 Double_t cs=cos(alpha), sn=sin(alpha);
2761 // Double_t x1 =fOuterSec->GetX(i1);
2762 //Double_t xx2=fOuterSec->GetX(i2);
2764 Double_t x1 =GetXrow(i1);
2765 Double_t xx2=GetXrow(i2);
2767 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2769 Int_t imiddle = (i2+i1)/2; //middle pad row index
2770 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2771 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2775 const AliTPCRow& kr1=GetRow(ns,i1);
2776 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2777 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2780 // change cut on curvature if it can't reach this layer
2781 // maximal curvature set to reach it
2782 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2783 if (dvertexmax*0.5*cuts[0]>0.85){
2784 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2786 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2789 if (deltay>0) ddsec = 0;
2790 // loop over clusters
2791 for (Int_t is=0; is < kr1; is++) {
2793 if (kr1[is]->IsUsed(10)) continue;
2794 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2795 //if (TMath::Abs(y1)>ymax) continue;
2797 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2799 // find possible directions
2800 Float_t anglez = (z1-z3)/(x1-x3);
2801 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2804 //find rotation angles relative to line given by vertex and point 1
2805 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2806 Double_t dvertex = TMath::Sqrt(dvertex2);
2807 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2808 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2811 // loop over 2 sectors
2817 Double_t dddz1=0; // direction of delta inclination in z axis
2824 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2825 Int_t sec2 = sec + dsec;
2827 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2828 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2829 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2830 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2831 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2832 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2834 // rotation angles to p1-p3
2835 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2836 Double_t x2, y2, z2;
2838 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2841 Double_t dxx0 = (xx2-x3)*cs13r;
2842 Double_t dyy0 = (xx2-x3)*sn13r;
2843 for (Int_t js=index1; js < index2; js++) {
2844 const AliTPCclusterMI *kcl = kr2[js];
2845 if (kcl->IsUsed(10)) continue;
2847 //calcutate parameters
2849 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2851 if (TMath::Abs(yy0)<0.000001) continue;
2852 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2853 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2854 Double_t r02 = (0.25+y0*y0)*dvertex2;
2855 //curvature (radius) cut
2856 if (r02<r2min) continue;
2860 Double_t c0 = 1/TMath::Sqrt(r02);
2864 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2865 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2866 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2867 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2870 Double_t z0 = kcl->GetZ();
2871 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2872 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2875 Double_t dip = (z1-z0)*c0/dfi1;
2876 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2887 x2= xx2*cs-y2*sn*dsec;
2888 y2=+xx2*sn*dsec+y2*cs;
2898 // do we have cluster at the middle ?
2900 GetProlongation(x1,xm,x,ym,zm);
2902 AliTPCclusterMI * cm=0;
2903 if (TMath::Abs(ym)-ymaxm<0){
2904 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2905 if ((!cm) || (cm->IsUsed(10))) {
2910 // rotate y1 to system 0
2911 // get state vector in rotated system
2912 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2913 Double_t xr2 = x0*cs+yr1*sn*dsec;
2914 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2916 GetProlongation(xx2,xm,xr,ym,zm);
2917 if (TMath::Abs(ym)-ymaxm<0){
2918 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2919 if ((!cm) || (cm->IsUsed(10))) {
2929 dym = ym - cm->GetY();
2930 dzm = zm - cm->GetZ();
2937 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2938 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2939 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2940 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2941 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2943 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2944 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2945 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2946 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2947 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2948 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2950 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2951 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2952 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2953 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2957 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2958 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2959 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2960 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2961 c[13]=f30*sy1*f40+f32*sy2*f42;
2962 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2964 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2966 UInt_t index=kr1.GetIndex(is);
2967 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2969 track->fIsSeeding = kTRUE;
2976 FollowProlongation(*track, (i1+i2)/2,1);
2977 Int_t foundable,found,shared;
2978 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2979 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2981 seed->~AliTPCseed();
2987 FollowProlongation(*track, i2,1);
2991 track->fBConstrain =1;
2992 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2993 track->fLastPoint = i1; // first cluster in track position
2994 track->fFirstPoint = track->fLastPoint;
2996 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2997 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2998 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3000 seed->~AliTPCseed();
3004 // Z VERTEX CONDITION
3006 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3007 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3008 if (TMath::Abs(zv-z3)>cuts[2]) {
3009 FollowProlongation(*track, TMath::Max(i2-20,0));
3010 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3011 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3012 if (TMath::Abs(zv-z3)>cuts[2]){
3013 FollowProlongation(*track, TMath::Max(i2-40,0));
3014 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3015 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3016 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3017 // make seed without constrain
3018 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3019 FollowProlongation(*track2, i2,1);
3020 track2->fBConstrain = kFALSE;
3021 track2->fSeedType = 1;
3022 arr->AddLast(track2);
3024 seed->~AliTPCseed();
3029 seed->~AliTPCseed();
3036 track->fSeedType =0;
3037 arr->AddLast(track);
3038 seed = new AliTPCseed;
3040 // don't consider other combinations
3041 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3047 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3053 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3058 //-----------------------------------------------------------------
3059 // This function creates track seeds.
3060 //-----------------------------------------------------------------
3061 // cuts[0] - fP4 cut
3062 // cuts[1] - tan(phi) cut
3063 // cuts[2] - zvertex cut
3064 // cuts[3] - fP3 cut
3074 Double_t x[5], c[15];
3076 // make temporary seed
3077 AliTPCseed * seed = new AliTPCseed;
3078 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3079 // Double_t cs=cos(alpha), sn=sin(alpha);
3084 Double_t x1 = GetXrow(i1-1);
3085 const AliTPCRow& kr1=GetRow(sec,i1-1);
3086 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3088 Double_t x1p = GetXrow(i1);
3089 const AliTPCRow& kr1p=GetRow(sec,i1);
3091 Double_t x1m = GetXrow(i1-2);
3092 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3095 //last 3 padrow for seeding
3096 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3097 Double_t x3 = GetXrow(i1-7);
3098 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3100 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3101 Double_t x3p = GetXrow(i1-6);
3103 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3104 Double_t x3m = GetXrow(i1-8);
3109 Int_t im = i1-4; //middle pad row index
3110 Double_t xm = GetXrow(im); // radius of middle pad-row
3111 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3112 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3115 Double_t deltax = x1-x3;
3116 Double_t dymax = deltax*cuts[1];
3117 Double_t dzmax = deltax*cuts[3];
3119 // loop over clusters
3120 for (Int_t is=0; is < kr1; is++) {
3122 if (kr1[is]->IsUsed(10)) continue;
3123 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3125 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3127 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3128 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3134 for (Int_t js=index1; js < index2; js++) {
3135 const AliTPCclusterMI *kcl = kr3[js];
3136 if (kcl->IsUsed(10)) continue;
3138 // apply angular cuts
3139 if (TMath::Abs(y1-y3)>dymax) continue;
3142 if (TMath::Abs(z1-z3)>dzmax) continue;
3144 Double_t angley = (y1-y3)/(x1-x3);
3145 Double_t anglez = (z1-z3)/(x1-x3);
3147 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3148 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3150 Double_t yyym = angley*(xm-x1)+y1;
3151 Double_t zzzm = anglez*(xm-x1)+z1;
3153 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3155 if (kcm->IsUsed(10)) continue;
3157 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3158 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3165 // look around first
3166 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3172 if (kc1m->IsUsed(10)) used++;
3174 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3180 if (kc1p->IsUsed(10)) used++;
3182 if (used>1) continue;
3183 if (found<1) continue;
3187 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3193 if (kc3m->IsUsed(10)) used++;
3197 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3203 if (kc3p->IsUsed(10)) used++;
3207 if (used>1) continue;
3208 if (found<3) continue;
3218 x[4]=F1(x1,y1,x2,y2,x3,y3);
3219 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3222 x[2]=F2(x1,y1,x2,y2,x3,y3);
3225 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3226 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3230 Double_t sy1=0.1, sz1=0.1;
3231 Double_t sy2=0.1, sz2=0.1;
3232 Double_t sy3=0.1, sy=0.1, sz=0.1;
3234 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3235 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3236 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3237 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3238 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3239 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3241 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3242 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3243 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3244 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3248 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3249 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3250 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3251 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3252 c[13]=f30*sy1*f40+f32*sy2*f42;
3253 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3255 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3257 UInt_t index=kr1.GetIndex(is);
3258 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3260 track->fIsSeeding = kTRUE;
3263 FollowProlongation(*track, i1-7,1);
3264 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3265 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3267 seed->~AliTPCseed();
3273 FollowProlongation(*track, i2,1);
3274 track->fBConstrain =0;
3275 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3276 track->fFirstPoint = track->fLastPoint;
3278 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3279 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3280 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3282 seed->~AliTPCseed();
3287 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3288 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3289 FollowProlongation(*track2, i2,1);
3290 track2->fBConstrain = kFALSE;
3291 track2->fSeedType = 4;
3292 arr->AddLast(track2);
3294 seed->~AliTPCseed();
3298 //arr->AddLast(track);
3299 //seed = new AliTPCseed;
3305 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3311 //_____________________________________________________________________________
3312 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3313 Float_t deltay, Bool_t /*bconstrain*/) {
3314 //-----------------------------------------------------------------
3315 // This function creates track seeds - without vertex constraint
3316 //-----------------------------------------------------------------
3317 // cuts[0] - fP4 cut - not applied
3318 // cuts[1] - tan(phi) cut
3319 // cuts[2] - zvertex cut - not applied
3320 // cuts[3] - fP3 cut
3330 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3331 // Double_t cs=cos(alpha), sn=sin(alpha);
3332 Int_t row0 = (i1+i2)/2;
3333 Int_t drow = (i1-i2)/2;
3334 const AliTPCRow& kr0=fSectors[sec][row0];
3337 AliTPCpolyTrack polytrack;
3338 Int_t nclusters=fSectors[sec][row0];
3339 AliTPCseed * seed = new AliTPCseed;
3344 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3346 Int_t nfoundable =0;
3347 for (Int_t iter =1; iter<2; iter++){ //iterations
3348 const AliTPCRow& krm=fSectors[sec][row0-iter];
3349 const AliTPCRow& krp=fSectors[sec][row0+iter];
3350 const AliTPCclusterMI * cl= kr0[is];
3352 if (cl->IsUsed(10)) {
3358 Double_t x = kr0.GetX();
3359 // Initialization of the polytrack
3364 Double_t y0= cl->GetY();
3365 Double_t z0= cl->GetZ();
3369 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3370 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3372 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3373 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3374 polytrack.AddPoint(x,y0,z0,erry, errz);
3377 if (cl->IsUsed(10)) sumused++;
3380 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3381 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3384 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3385 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3386 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3387 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3388 if (cl1->IsUsed(10)) sumused++;
3389 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3393 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3395 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3396 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3397 if (cl2->IsUsed(10)) sumused++;
3398 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3401 if (sumused>0) continue;
3403 polytrack.UpdateParameters();
3409 nfoundable = polytrack.GetN();
3410 nfound = nfoundable;
3412 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3413 Float_t maxdist = 0.8*(1.+3./(ddrow));
3414 for (Int_t delta = -1;delta<=1;delta+=2){
3415 Int_t row = row0+ddrow*delta;
3416 kr = &(fSectors[sec][row]);
3417 Double_t xn = kr->GetX();
3418 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3419 polytrack.GetFitPoint(xn,yn,zn);
3420 if (TMath::Abs(yn)>ymax) continue;
3422 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3424 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3427 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3428 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3429 if (cln->IsUsed(10)) {
3430 // printf("used\n");
3438 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3443 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3444 polytrack.UpdateParameters();
3447 if ( (sumused>3) || (sumused>0.5*nfound)) {
3448 //printf("sumused %d\n",sumused);
3453 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3454 AliTPCpolyTrack track2;
3456 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3457 if (track2.GetN()<0.5*nfoundable) continue;
3460 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3462 // test seed with and without constrain
3463 for (Int_t constrain=0; constrain<=0;constrain++){
3464 // add polytrack candidate
3466 Double_t x[5], c[15];
3467 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3468 track2.GetBoundaries(x3,x1);
3470 track2.GetFitPoint(x1,y1,z1);
3471 track2.GetFitPoint(x2,y2,z2);
3472 track2.GetFitPoint(x3,y3,z3);
3474 //is track pointing to the vertex ?
3477 polytrack.GetFitPoint(x0,y0,z0);
3490 x[4]=F1(x1,y1,x2,y2,x3,y3);
3492 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3493 x[2]=F2(x1,y1,x2,y2,x3,y3);
3495 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3496 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3497 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3498 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3501 Double_t sy =0.1, sz =0.1;
3502 Double_t sy1=0.02, sz1=0.02;
3503 Double_t sy2=0.02, sz2=0.02;
3507 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3510 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3511 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3512 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3513 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3514 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3515 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3517 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3518 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3519 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3520 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3525 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3526 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3527 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3528 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3529 c[13]=f30*sy1*f40+f32*sy2*f42;
3530 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3532 //Int_t row1 = fSectors->GetRowNumber(x1);
3533 Int_t row1 = GetRowNumber(x1);
3537 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3538 track->fIsSeeding = kTRUE;
3539 Int_t rc=FollowProlongation(*track, i2);
3540 if (constrain) track->fBConstrain =1;
3542 track->fBConstrain =0;
3543 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3544 track->fFirstPoint = track->fLastPoint;
3546 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3547 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3548 track->fNShared>0.4*track->GetNumberOfClusters()) {
3551 seed->~AliTPCseed();
3554 arr->AddLast(track);
3555 seed = new AliTPCseed;
3559 } // if accepted seed
3562 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3568 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3572 //reseed using track points
3573 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3574 Int_t p1 = int(r1*track->GetNumberOfClusters());
3575 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3577 Double_t x0[3],x1[3],x2[3];
3578 for (Int_t i=0;i<3;i++){
3584 // find track position at given ratio of the length
3585 Int_t sec0=0, sec1=0, sec2=0;
3588 for (Int_t i=0;i<160;i++){
3589 if (track->fClusterPointer[i]){
3591 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3592 if ( (index<p0) || x0[0]<0 ){
3593 if (trpoint->GetX()>1){
3594 clindex = track->GetClusterIndex2(i);
3596 x0[0] = trpoint->GetX();
3597 x0[1] = trpoint->GetY();
3598 x0[2] = trpoint->GetZ();
3599 sec0 = ((clindex&0xff000000)>>24)%18;
3604 if ( (index<p1) &&(trpoint->GetX()>1)){
3605 clindex = track->GetClusterIndex2(i);
3607 x1[0] = trpoint->GetX();
3608 x1[1] = trpoint->GetY();
3609 x1[2] = trpoint->GetZ();
3610 sec1 = ((clindex&0xff000000)>>24)%18;
3613 if ( (index<p2) &&(trpoint->GetX()>1)){
3614 clindex = track->GetClusterIndex2(i);
3616 x2[0] = trpoint->GetX();
3617 x2[1] = trpoint->GetY();
3618 x2[2] = trpoint->GetZ();
3619 sec2 = ((clindex&0xff000000)>>24)%18;
3626 Double_t alpha, cs,sn, xx2,yy2;
3628 alpha = (sec1-sec2)*fSectors->GetAlpha();
3629 cs = TMath::Cos(alpha);
3630 sn = TMath::Sin(alpha);
3631 xx2= x1[0]*cs-x1[1]*sn;
3632 yy2= x1[0]*sn+x1[1]*cs;
3636 alpha = (sec0-sec2)*fSectors->GetAlpha();
3637 cs = TMath::Cos(alpha);
3638 sn = TMath::Sin(alpha);
3639 xx2= x0[0]*cs-x0[1]*sn;
3640 yy2= x0[0]*sn+x0[1]*cs;
3646 Double_t x[5],c[15];
3650 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3651 // if (x[4]>1) return 0;
3652 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3653 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3654 //if (TMath::Abs(x[3]) > 2.2) return 0;
3655 //if (TMath::Abs(x[2]) > 1.99) return 0;
3657 Double_t sy =0.1, sz =0.1;
3659 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3660 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3661 Double_t sy3=0.01+track->GetSigmaY2();
3663 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3664 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3665 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3666 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3667 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3668 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3670 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3671 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3672 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3673 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3678 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3679 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3680 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3681 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3682 c[13]=f30*sy1*f40+f32*sy2*f42;
3683 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3685 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3686 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3687 // Double_t y0,z0,y1,z1, y2,z2;
3688 //seed->GetProlongation(x0[0],y0,z0);
3689 // seed->GetProlongation(x1[0],y1,z1);
3690 //seed->GetProlongation(x2[0],y2,z2);
3692 seed->fLastPoint = pp2;
3693 seed->fFirstPoint = pp2;
3700 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3704 //reseed using founded clusters
3706 // Find the number of clusters
3707 Int_t nclusters = 0;
3708 for (Int_t irow=0;irow<160;irow++){
3709 if (track->GetClusterIndex(irow)>0) nclusters++;
3713 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3714 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3715 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3719 Int_t row[3],sec[3]={0,0,0};
3721 // find track row position at given ratio of the length
3723 for (Int_t irow=0;irow<160;irow++){
3724 if (track->GetClusterIndex2(irow)<0) continue;
3726 for (Int_t ipoint=0;ipoint<3;ipoint++){
3727 if (index<=ipos[ipoint]) row[ipoint] = irow;
3731 //Get cluster and sector position
3732 for (Int_t ipoint=0;ipoint<3;ipoint++){
3733 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3734 AliTPCclusterMI * cl = GetClusterMI(clindex);
3737 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3740 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3741 xyz[ipoint][0] = GetXrow(row[ipoint]);
3742 xyz[ipoint][1] = cl->GetY();
3743 xyz[ipoint][2] = cl->GetZ();
3747 // Calculate seed state vector and covariance matrix
3749 Double_t alpha, cs,sn, xx2,yy2;
3751 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3752 cs = TMath::Cos(alpha);
3753 sn = TMath::Sin(alpha);
3754 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3755 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3759 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3760 cs = TMath::Cos(alpha);
3761 sn = TMath::Sin(alpha);
3762 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3763 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3769 Double_t x[5],c[15];
3773 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3774 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3775 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3777 Double_t sy =0.1, sz =0.1;
3779 Double_t sy1=0.2, sz1=0.2;
3780 Double_t sy2=0.2, sz2=0.2;
3783 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;
3784 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;
3785 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;
3786 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;
3787 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;
3788 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;
3790 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;
3791 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;
3792 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;
3793 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;
3798 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3799 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3800 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3801 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3802 c[13]=f30*sy1*f40+f32*sy2*f42;
3803 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3805 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3806 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3807 seed->fLastPoint = row[2];
3808 seed->fFirstPoint = row[2];
3813 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3817 //reseed using founded clusters
3820 Int_t row[3]={0,0,0};
3821 Int_t sec[3]={0,0,0};
3823 // forward direction
3825 for (Int_t irow=r0;irow<160;irow++){
3826 if (track->GetClusterIndex(irow)>0){
3831 for (Int_t irow=160;irow>r0;irow--){
3832 if (track->GetClusterIndex(irow)>0){
3837 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3838 if (track->GetClusterIndex(irow)>0){
3846 for (Int_t irow=0;irow<r0;irow++){
3847 if (track->GetClusterIndex(irow)>0){
3852 for (Int_t irow=r0;irow>0;irow--){
3853 if (track->GetClusterIndex(irow)>0){
3858 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3859 if (track->GetClusterIndex(irow)>0){
3866 if ((row[2]-row[0])<20) return 0;
3867 if (row[1]==0) return 0;
3870 //Get cluster and sector position
3871 for (Int_t ipoint=0;ipoint<3;ipoint++){
3872 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3873 AliTPCclusterMI * cl = GetClusterMI(clindex);
3876 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3879 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3880 xyz[ipoint][0] = GetXrow(row[ipoint]);
3881 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3882 if (point&&ipoint<2){
3884 xyz[ipoint][1] = point->GetY();
3885 xyz[ipoint][2] = point->GetZ();
3888 xyz[ipoint][1] = cl->GetY();
3889 xyz[ipoint][2] = cl->GetZ();
3896 // Calculate seed state vector and covariance matrix
3898 Double_t alpha, cs,sn, xx2,yy2;
3900 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3901 cs = TMath::Cos(alpha);
3902 sn = TMath::Sin(alpha);
3903 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3904 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3908 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3909 cs = TMath::Cos(alpha);
3910 sn = TMath::Sin(alpha);
3911 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3912 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3918 Double_t x[5],c[15];
3922 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3923 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3924 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3926 Double_t sy =0.1, sz =0.1;
3928 Double_t sy1=0.2, sz1=0.2;
3929 Double_t sy2=0.2, sz2=0.2;
3932 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;
3933 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;
3934 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;
3935 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;
3936 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;
3937 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;
3939 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;
3940 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;
3941 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;
3942 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;
3947 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3948 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3949 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3950 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3951 c[13]=f30*sy1*f40+f32*sy2*f42;
3952 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3954 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3955 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3956 seed->fLastPoint = row[2];
3957 seed->fFirstPoint = row[2];
3958 for (Int_t i=row[0];i<row[2];i++){
3959 seed->fIndex[i] = track->fIndex[i];
3965 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
3972 TObjArray *kinks= new TObjArray(10000);
3973 // TObjArray *v0s= new TObjArray(10000);
3974 Int_t nentries = array->GetEntriesFast();
3975 AliHelix *helixes = new AliHelix[nentries];
3976 Int_t *sign = new Int_t[nentries];
3977 Int_t *nclusters = new Int_t[nentries];
3978 Float_t *alpha = new Float_t[nentries];
3979 AliESDkink * kink = new AliESDkink();
3980 Int_t * usage = new Int_t[nentries];
3981 Float_t *zm = new Float_t[nentries];
3982 Float_t *z0 = new Float_t[nentries];
3983 Float_t *fim = new Float_t[nentries];
3984 Float_t *shared = new Float_t[nentries];
3985 Bool_t *circular = new Bool_t[nentries];
3986 Float_t *dca = new Float_t[nentries];
3987 //const AliESDVertex * primvertex = esd->GetVertex();
3989 // nentries = array->GetEntriesFast();
3994 for (Int_t i=0;i<nentries;i++){
3997 AliTPCseed* track = (AliTPCseed*)array->At(i);
3998 if (!track) continue;
3999 track->fCircular =0;
4001 track->UpdatePoints();
4002 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4004 nclusters[i]=track->GetNumberOfClusters();
4005 alpha[i] = track->GetAlpha();
4006 new (&helixes[i]) AliHelix(*track);
4008 helixes[i].Evaluate(0,xyz);
4009 sign[i] = (track->GetC()>0) ? -1:1;
4012 if (track->GetProlongation(x,y,z)){
4014 fim[i] = alpha[i]+TMath::ATan2(y,x);
4017 zm[i] = track->GetZ();
4021 circular[i]= kFALSE;
4022 if (track->GetProlongation(0,y,z)) z0[i] = z;
4023 dca[i] = track->GetD(0,0);
4029 Int_t ncandidates =0;
4032 Double_t phase[2][2],radius[2];
4035 // Find circling track
4036 TTreeSRedirector &cstream = *fDebugStreamer;
4038 for (Int_t i0=0;i0<nentries;i0++){
4039 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4040 if (!track0) continue;
4041 if (track0->fN<40) continue;
4042 if (TMath::Abs(1./track0->fP4)>200) continue;
4043 for (Int_t i1=i0+1;i1<nentries;i1++){
4044 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4045 if (!track1) continue;
4046 if (track1->fN<40) continue;
4047 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
4048 if (track0->fBConstrain&&track1->fBConstrain) continue;
4049 if (TMath::Abs(1./track1->fP4)>200) continue;
4050 if (track1->fP4*track0->fP4>0) continue;
4051 if (track1->fP3*track0->fP3>0) continue;
4052 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
4053 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
4054 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
4056 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4057 if (mindcar<5) continue;
4058 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4059 if (mindcaz<5) continue;
4060 if (mindcar+mindcaz<20) continue;
4063 Float_t xc0 = helixes[i0].GetHelix(6);
4064 Float_t yc0 = helixes[i0].GetHelix(7);
4065 Float_t r0 = helixes[i0].GetHelix(8);
4066 Float_t xc1 = helixes[i1].GetHelix(6);
4067 Float_t yc1 = helixes[i1].GetHelix(7);
4068 Float_t r1 = helixes[i1].GetHelix(8);
4070 Float_t rmean = (r0+r1)*0.5;
4071 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4072 //if (delta>30) continue;
4073 if (delta>rmean*0.25) continue;
4074 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4076 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4077 if (npoints==0) continue;
4078 helixes[i0].GetClosestPhases(helixes[i1], phase);
4082 Double_t hangles[3];
4083 helixes[i0].Evaluate(phase[0][0],xyz0);
4084 helixes[i1].Evaluate(phase[0][1],xyz1);
4086 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4087 Double_t deltah[2],deltabest;
4088 if (hangles[2]<2.8) continue;
4090 cstream<<"C"<<track0->fLab<<track1->fLab<<
4091 track0->fP3<<track1->fP3<<
4092 track0->fP4<<track1->fP4<<
4093 delta<<rmean<<npoints<<
4094 hangles[0]<<hangles[2]<<
4095 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4099 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4101 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4102 if (deltah[1]<deltah[0]) ibest=1;
4104 deltabest = TMath::Sqrt(deltah[ibest]);
4105 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4106 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4107 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4108 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4110 if (deltabest>6) continue;
4111 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4112 Bool_t sign =kFALSE;
4113 if (hangles[2]>3.06) sign =kTRUE;
4116 circular[i0] = kTRUE;
4117 circular[i1] = kTRUE;
4118 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4119 track0->fCircular += 1;
4120 track1->fCircular += 2;
4123 track1->fCircular += 1;
4124 track0->fCircular += 2;
4129 cstream<<"Curling"<<
4130 "lab0="<<track0->fLab<<
4131 "lab1="<<track1->fLab<<
4136 "mindcar="<<mindcar<<
4137 "mindcaz="<<mindcaz<<
4140 "npoints="<<npoints<<
4141 "hangles0="<<hangles[0]<<
4142 "hangles2="<<hangles[2]<<
4147 "radius="<<radiusbest<<
4148 "deltabest="<<deltabest<<
4149 "phase0="<<phase[ibest][0]<<
4150 "phase1="<<phase[ibest][1]<<
4160 for (Int_t i =0;i<nentries;i++){
4161 if (sign[i]==0) continue;
4162 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4165 Double_t cradius0 = 40*40;
4166 Double_t cradius1 = 270*270;
4169 Double_t cdist3=0.55;
4170 for (Int_t j =i+1;j<nentries;j++){
4172 if (sign[j]*sign[i]<1) continue;
4173 if ( (nclusters[i]+nclusters[j])>200) continue;
4174 if ( (nclusters[i]+nclusters[j])<80) continue;
4175 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4176 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4177 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4178 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4179 if (npoints<1) continue;
4182 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4185 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4188 Double_t delta1=10000,delta2=10000;
4189 // cuts on the intersection radius
4190 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4191 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4192 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4194 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4195 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4196 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4199 Double_t distance1 = TMath::Min(delta1,delta2);
4200 if (distance1>cdist1) continue; // cut on DCA linear approximation
4202 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4203 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4204 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4205 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4208 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4209 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4210 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4212 distance1 = TMath::Min(delta1,delta2);
4215 rkink = TMath::Sqrt(radius[0]);
4218 rkink = TMath::Sqrt(radius[1]);
4220 if (distance1>cdist2) continue;
4223 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4226 Int_t row0 = GetRowNumber(rkink);
4227 if (row0<10) continue;
4228 if (row0>150) continue;
4231 Float_t dens00=-1,dens01=-1;
4232 Float_t dens10=-1,dens11=-1;
4234 Int_t found,foundable,shared;
4235 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4236 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4237 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4238 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4240 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4241 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4242 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4243 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4245 if (dens00<dens10 && dens01<dens11) continue;
4246 if (dens00>dens10 && dens01>dens11) continue;
4247 if (TMath::Max(dens00,dens10)<0.1) continue;
4248 if (TMath::Max(dens01,dens11)<0.3) continue;
4250 if (TMath::Min(dens00,dens10)>0.6) continue;
4251 if (TMath::Min(dens01,dens11)>0.6) continue;
4254 AliTPCseed * ktrack0, *ktrack1;
4263 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4264 AliExternalTrackParam paramm(*ktrack0);
4265 AliExternalTrackParam paramd(*ktrack1);
4266 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4269 kink->SetMother(paramm);
4270 kink->SetDaughter(paramd);
4273 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4275 fParam->Transform0to1(x,index);
4276 fParam->Transform1to2(x,index);
4277 row0 = GetRowNumber(x[0]);
4279 if (kink->GetR()<100) continue;
4280 if (kink->GetR()>240) continue;
4281 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4282 if (kink->GetDistance()>cdist3) continue;
4283 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4284 if (dird<0) continue;
4286 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4287 if (dirm<0) continue;
4288 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4289 if (mpt<0.2) continue;
4292 //for high momenta momentum not defined well in first iteration
4293 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4294 if (qt>0.35) continue;
4297 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4298 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4300 kink->SetTPCDensity(dens00,0,0);
4301 kink->SetTPCDensity(dens01,0,1);
4302 kink->SetTPCDensity(dens10,1,0);
4303 kink->SetTPCDensity(dens11,1,1);
4304 kink->SetIndex(i,0);
4305 kink->SetIndex(j,1);
4308 kink->SetTPCDensity(dens10,0,0);
4309 kink->SetTPCDensity(dens11,0,1);
4310 kink->SetTPCDensity(dens00,1,0);
4311 kink->SetTPCDensity(dens01,1,1);
4312 kink->SetIndex(j,0);
4313 kink->SetIndex(i,1);
4316 if (mpt<1||kink->GetAngle(2)>0.1){
4317 // angle and densities not defined yet
4318 if (kink->GetTPCDensityFactor()<0.8) continue;
4319 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4320 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4321 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4322 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4324 Float_t criticalangle = track0->fC22+track0->fC33;
4325 criticalangle+= track1->fC22+track1->fC33;
4326 criticalangle= 3*TMath::Sqrt(criticalangle);
4327 if (criticalangle>0.02) criticalangle=0.02;
4328 if (kink->GetAngle(2)<criticalangle) continue;
4331 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4332 Float_t shapesum =0;
4334 for ( Int_t row = row0-drow; row<row0+drow;row++){
4335 if (row<0) continue;
4336 if (row>155) continue;
4337 if (ktrack0->fClusterPointer[row]){
4338 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4339 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4342 if (ktrack1->fClusterPointer[row]){
4343 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4344 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4349 kink->SetShapeFactor(-1.);
4352 kink->SetShapeFactor(shapesum/sum);
4354 // esd->AddKink(kink);
4355 kinks->AddLast(kink);
4356 kink = new AliESDkink;
4361 // sort the kinks according quality - and refit them towards vertex
4363 Int_t nkinks = kinks->GetEntriesFast();
4364 Float_t *quality = new Float_t[nkinks];
4365 Int_t *indexes = new Int_t[nkinks];
4366 AliTPCseed *mothers = new AliTPCseed[nkinks];
4367 AliTPCseed *daughters = new AliTPCseed[nkinks];
4370 for (Int_t i=0;i<nkinks;i++){
4372 AliESDkink *kink = (AliESDkink*)kinks->At(i);
4374 // refit kinks towards vertex
4376 Int_t index0 = kink->GetIndex(0);
4377 Int_t index1 = kink->GetIndex(1);
4378 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4379 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4381 Int_t sumn=ktrack0->fN+ktrack1->fN;
4383 // Refit Kink under if too small angle
4385 if (kink->GetAngle(2)<0.05){
4386 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4387 Int_t row0 = kink->GetTPCRow0();
4388 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4391 Int_t last = row0-drow;
4392 if (last<40) last=40;
4393 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4394 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4397 Int_t first = row0+drow;
4398 if (first>130) first=130;
4399 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4400 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4402 if (seed0 && seed1){
4403 kink->SetStatus(1,8);
4404 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4405 row0 = GetRowNumber(kink->GetR());
4406 sumn = seed0->fN+seed1->fN;
4407 new (&mothers[i]) AliTPCseed(*seed0);
4408 new (&daughters[i]) AliTPCseed(*seed1);
4411 delete kinks->RemoveAt(i);
4412 if (seed0) delete seed0;
4413 if (seed1) delete seed1;
4416 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4417 delete kinks->RemoveAt(i);
4418 if (seed0) delete seed0;
4419 if (seed1) delete seed1;
4427 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4429 TMath::Sort(nkinks,quality,indexes,kFALSE);
4431 //remove double find kinks
4433 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4434 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4435 if (!kink0) continue;
4437 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4438 if (!kink0) continue;
4439 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4440 if (!kink1) continue;
4441 // if not close kink continue
4442 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4443 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4444 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4446 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4447 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4448 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4449 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4450 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4459 for (Int_t i=0;i<row0;i++){
4460 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4463 if (mother0.fIndex[i]==mother1.fIndex[i]){
4470 for (Int_t i=row0;i<158;i++){
4471 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4474 if (mother0.fIndex[i]==mother1.fIndex[i]){
4480 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4481 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4482 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4483 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4484 Int_t sum0 = mother0.fN+daughter0.fN;
4485 Int_t sum1 = mother1.fN+daughter1.fN;
4487 shared[kink0->GetIndex(0)]= kTRUE;
4488 shared[kink0->GetIndex(1)]= kTRUE;
4489 delete kinks->RemoveAt(indexes[ikink0]);
4492 shared[kink1->GetIndex(0)]= kTRUE;
4493 shared[kink1->GetIndex(1)]= kTRUE;
4494 delete kinks->RemoveAt(indexes[ikink1]);
4501 for (Int_t i=0;i<nkinks;i++){
4502 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
4503 if (!kink) continue;
4504 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4505 Int_t index0 = kink->GetIndex(0);
4506 Int_t index1 = kink->GetIndex(1);
4507 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4508 kink->SetMultiple(usage[index0],0);
4509 kink->SetMultiple(usage[index1],1);
4510 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4511 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4512 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4513 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4515 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4516 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4517 if (!ktrack0 || !ktrack1) continue;
4518 Int_t index = esd->AddKink(kink);
4521 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4522 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4523 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4524 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4528 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4529 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4534 // Remove tracks corresponding to shared kink's
4536 for (Int_t i=0;i<nentries;i++){
4537 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4538 if (!track0) continue;
4539 if (track0->fKinkIndexes[0]!=0) continue;
4540 if (shared[i]) delete array->RemoveAt(i);
4545 RemoveUsed2(array,0.5,0.4,30);
4547 for (Int_t i=0;i<nentries;i++){
4548 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4549 if (!track0) continue;
4550 track0->CookdEdx(0.02,0.6);
4554 for (Int_t i=0;i<nentries;i++){
4555 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4556 if (!track0) continue;
4557 if (track0->Pt()<1.4) continue;
4558 //remove double high momenta tracks - overlapped with kink candidates
4561 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4562 if (track0->fClusterPointer[icl]!=0){
4564 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4567 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4568 delete array->RemoveAt(i);
4571 if (track0->fKinkIndexes[0]!=0) continue;
4572 if (track0->GetNumberOfClusters()<80) continue;
4574 AliTPCseed *pmother = new AliTPCseed();
4575 AliTPCseed *pdaughter = new AliTPCseed();
4576 AliESDkink *pkink = new AliESDkink;
4578 AliTPCseed & mother = *pmother;
4579 AliTPCseed & daughter = *pdaughter;
4580 AliESDkink & kink = *pkink;
4581 if (CheckKinkPoint(track0,mother,daughter, kink)){
4582 if (mother.fN<30||daughter.fN<20) {
4586 continue; //too short tracks
4588 if (mother.Pt()<1.4) {
4594 Int_t row0= kink.GetTPCRow0();
4595 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4602 Int_t index = esd->AddKink(&kink);
4603 mother.fKinkIndexes[0] = -(index+1);
4604 daughter.fKinkIndexes[0] = index+1;
4606 delete array->RemoveAt(i);
4607 array->AddAt(new AliTPCseed(mother),i);
4610 array->AddLast(new AliTPCseed(mother));
4612 array->AddLast(new AliTPCseed(daughter));
4613 for (Int_t icl=0;icl<row0;icl++) {
4614 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4617 for (Int_t icl=row0;icl<158;icl++) {
4618 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4627 delete [] daughters;
4649 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4653 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4659 TObjArray *tpcv0s = new TObjArray(100000);
4660 Int_t nentries = array->GetEntriesFast();
4661 AliHelix *helixes = new AliHelix[nentries];
4662 Int_t *sign = new Int_t[nentries];
4663 Float_t *alpha = new Float_t[nentries];
4664 Float_t *z0 = new Float_t[nentries];
4665 Float_t *dca = new Float_t[nentries];
4666 Float_t *sdcar = new Float_t[nentries];
4667 Float_t *cdcar = new Float_t[nentries];
4668 Float_t *pulldcar = new Float_t[nentries];
4669 Float_t *pulldcaz = new Float_t[nentries];
4670 Float_t *pulldca = new Float_t[nentries];
4671 Bool_t *isPrim = new Bool_t[nentries];
4672 const AliESDVertex * primvertex = esd->GetVertex();
4673 Double_t zvertex = primvertex->GetZv();
4675 // nentries = array->GetEntriesFast();
4677 for (Int_t i=0;i<nentries;i++){
4680 AliTPCseed* track = (AliTPCseed*)array->At(i);
4681 if (!track) continue;
4682 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4683 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4684 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4686 alpha[i] = track->GetAlpha();
4687 new (&helixes[i]) AliHelix(*track);
4689 helixes[i].Evaluate(0,xyz);
4690 sign[i] = (track->GetC()>0) ? -1:1;
4694 if (track->GetProlongation(0,y,z)) z0[i] = z;
4695 dca[i] = track->GetD(0,0);
4697 // dca error parrameterezation + pulls
4699 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4700 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4701 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4702 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4703 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4704 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4705 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4706 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4708 if (track->fTPCr[4]>0.5) {
4709 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4711 if (track->fTPCr[0]>0.4) {
4712 isPrim[i]=kFALSE; //electron no sigma cut
4719 Int_t ncandidates =0;
4722 Double_t phase[2][2],radius[2];
4728 TTreeSRedirector &cstream = *fDebugStreamer;
4729 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4731 Double_t cradius0 = 10*10;
4732 Double_t cradius1 = 200*200;
4735 Double_t cpointAngle = 0.95;
4737 Double_t delta[2]={10000,10000};
4738 for (Int_t i =0;i<nentries;i++){
4739 if (sign[i]==0) continue;
4740 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4741 if (!track0) continue;
4746 "zvertex="<<zvertex<<
4747 "sdcar0="<<sdcar[i]<<
4748 "cdcar0="<<cdcar[i]<<
4749 "pulldcar0="<<pulldcar[i]<<
4750 "pulldcaz0="<<pulldcaz[i]<<
4751 "pulldca0="<<pulldca[i]<<
4752 "isPrim="<<isPrim[i]<<
4755 if (track0->fP4<0) continue;
4756 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4758 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4763 for (Int_t j =0;j<nentries;j++){
4764 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4765 if (!track1) continue;
4766 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4767 if (sign[j]*sign[i]>0) continue;
4768 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4769 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4772 // DCA to prim vertex cut
4778 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4779 if (npoints<1) continue;
4783 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4784 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4785 if (delta[0]>cdist1) continue;
4788 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4789 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4790 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4791 if (delta[1]<delta[0]) iclosest=1;
4792 if (delta[iclosest]>cdist1) continue;
4794 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4795 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4797 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4798 if (pointAngle<cpointAngle) continue;
4800 Bool_t isGamma = kFALSE;
4801 vertex.SetP(*track0); //track0 - plus
4802 vertex.SetM(*track1); //track1 - minus
4803 vertex.Update(fprimvertex);
4804 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4805 Double_t pointAngle2 = vertex.GetPointAngle();
4807 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4808 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4809 Float_t sigmae = 0.15*0.15;
4810 if (vertex.GetRr()<80)
4811 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4812 sigmae+= TMath::Sqrt(sigmae);
4813 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4814 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4815 Int_t row0 = GetRowNumber(vertex.GetRr());
4817 if (vertex.GetDist2()>0.2) continue;
4818 densb0 = track0->Density2(0,row0-5);
4819 densb1 = track1->Density2(0,row0-5);
4820 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4821 densa0 = track0->Density2(row0+5,row0+40);
4822 densa1 = track1->Density2(row0+5,row0+40);
4823 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4826 densa0 = track0->Density2(0,40); //cluster density
4827 densa1 = track1->Density2(0,40); //cluster density
4828 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4830 vertex.SetLab(0,track0->GetLabel());
4831 vertex.SetLab(1,track1->GetLabel());
4832 vertex.SetChi2After((densa0+densa1)*0.5);
4833 vertex.SetChi2Before((densb0+densb1)*0.5);
4834 vertex.SetIndex(0,i);
4835 vertex.SetIndex(1,j);
4836 vertex.SetStatus(1); // TPC v0 candidate
4837 vertex.SetRp(track0->fTPCr);
4838 vertex.SetRm(track1->fTPCr);
4839 tpcv0s->AddLast(new AliESDV0MI(vertex));
4842 Int_t eventNr = esd->GetEventNumber();
4843 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4844 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4847 "vertex.="<<&vertex<<
4849 "lab0="<<track0->fLab<<
4850 "Helix0.="<<&helixes[i]<<
4852 "lab1="<<track1->fLab<<
4853 "Helix1.="<<&helixes[j]<<
4854 "pointAngle="<<pointAngle<<
4855 "pointAngle2="<<pointAngle2<<
4860 "zvertex="<<zvertex<<
4861 "circular0="<<track0->fCircular<<
4862 "circular1="<<track1->fCircular<<
4863 "npoints="<<npoints<<
4864 "radius0="<<radius[0]<<
4865 "delta0="<<delta[0]<<
4866 "radius1="<<radius[1]<<
4867 "delta1="<<delta[1]<<
4868 "radiusm="<<radiusm<<
4870 "sdcar0="<<sdcar[i]<<
4871 "sdcar1="<<sdcar[j]<<
4872 "cdcar0="<<cdcar[i]<<
4873 "cdcar1="<<cdcar[j]<<
4874 "pulldcar0="<<pulldcar[i]<<
4875 "pulldcar1="<<pulldcar[j]<<
4876 "pulldcaz0="<<pulldcaz[i]<<
4877 "pulldcaz1="<<pulldcaz[j]<<
4878 "pulldca0="<<pulldca[i]<<
4879 "pulldca1="<<pulldca[j]<<
4889 Float_t *quality = new Float_t[ncandidates];
4890 Int_t *indexes = new Int_t[ncandidates];
4892 for (Int_t i=0;i<ncandidates;i++){
4894 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4895 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4896 // quality[i] /= (0.5+v0->GetDist2());
4897 // quality[i] *= v0->GetChi2After(); //density factor
4898 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4899 Int_t index0 = v0->GetIndex(0);
4900 Int_t index1 = v0->GetIndex(1);
4901 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4902 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4903 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4904 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4907 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4910 for (Int_t i=0;i<ncandidates;i++){
4911 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4913 Int_t index0 = v0->GetIndex(0);
4914 Int_t index1 = v0->GetIndex(1);
4915 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4916 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4917 if (!track0||!track1) {
4921 Bool_t accept =kTRUE; //default accept
4922 Int_t *v0indexes0 = track0->GetV0Indexes();
4923 Int_t *v0indexes1 = track1->GetV0Indexes();
4925 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4926 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4927 if (v0indexes0[1]!=0) order0 =2;
4928 if (v0indexes1[1]!=0) order1 =2;
4930 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4931 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4933 AliESDV0MI * v02 = v0;
4935 v0->SetOrder(0,order0);
4936 v0->SetOrder(1,order1);
4937 v0->SetOrder(1,order0+order1);
4938 Int_t index = esd->AddV0MI(v0);
4939 v02 = esd->GetV0MI(index);
4940 v0indexes0[order0]=index;
4941 v0indexes1[order1]=index;
4945 Int_t eventNr = esd->GetEventNumber();
4951 "lab0="<<track0->fLab<<
4953 "lab1="<<track1->fLab<<
4954 "dca0="<<dca[index0]<<
4955 "dca1="<<dca[index1]<<
4959 "quality="<<quality[i]<<
4960 "pulldca0="<<pulldca[index0]<<
4961 "pulldca1="<<pulldca[index1]<<
4985 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
4989 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
4992 // refit kink towards to the vertex
4995 Int_t row0 = GetRowNumber(kink.GetR());
4996 FollowProlongation(mother,0);
4997 mother.Reset(kFALSE);
4999 FollowProlongation(daughter,row0);
5000 daughter.Reset(kFALSE);
5001 FollowBackProlongation(daughter,158);
5002 daughter.Reset(kFALSE);
5003 Int_t first = TMath::Max(row0-20,30);
5004 Int_t last = TMath::Min(row0+20,140);
5006 const Int_t kNdiv =5;
5007 AliTPCseed param0[kNdiv]; // parameters along the track
5008 AliTPCseed param1[kNdiv]; // parameters along the track
5009 AliESDkink kinks[kNdiv]; // corresponding kink parameters
5012 for (Int_t irow=0; irow<kNdiv;irow++){
5013 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5015 // store parameters along the track
5017 for (Int_t irow=0;irow<kNdiv;irow++){
5018 FollowBackProlongation(mother, rows[irow]);
5019 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5020 new(¶m0[irow]) AliTPCseed(mother);
5021 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5025 for (Int_t irow=0; irow<kNdiv-1;irow++){
5026 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5027 kinks[irow].SetMother(param0[irow]);
5028 kinks[irow].SetDaughter(param1[irow]);
5029 kinks[irow].Update();
5032 // choose kink with best "quality"
5034 Double_t mindist = 10000;
5035 for (Int_t irow=0;irow<kNdiv;irow++){
5036 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5037 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5038 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5040 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
5041 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5042 if (normdist < mindist){
5048 if (index==-1) return 0;
5051 param0[index].Reset(kTRUE);
5052 FollowProlongation(param0[index],0);
5054 new (&mother) AliTPCseed(param0[index]);
5055 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5057 kink.SetMother(mother);
5058 kink.SetDaughter(daughter);
5060 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5061 kink.SetTPCncls(param0[index].fN,0);
5062 kink.SetTPCncls(param1[index].fN,1);
5063 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5064 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5065 mother.SetLabel(kink.GetLabel(0));
5066 daughter.SetLabel(kink.GetLabel(1));
5072 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5074 // update Kink quality information for mother after back propagation
5076 if (seed->GetKinkIndex(0)>=0) return;
5077 for (Int_t ikink=0;ikink<3;ikink++){
5078 Int_t index = seed->GetKinkIndex(ikink);
5079 if (index>=0) break;
5080 index = TMath::Abs(index)-1;
5081 AliESDkink * kink = fEvent->GetKink(index);
5082 //kink->fTPCdensity2[0][0]=-1;
5083 //kink->fTPCdensity2[0][1]=-1;
5084 kink->SetTPCDensity2(-1,0,0);
5085 kink->SetTPCDensity2(1,0,1);
5087 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5088 if (row0<15) row0=15;
5090 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5091 if (row1>145) row1=145;
5093 Int_t found,foundable,shared;
5094 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5095 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5096 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5097 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5102 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5104 // update Kink quality information for daughter after refit
5106 if (seed->GetKinkIndex(0)<=0) return;
5107 for (Int_t ikink=0;ikink<3;ikink++){
5108 Int_t index = seed->GetKinkIndex(ikink);
5109 if (index<=0) break;
5110 index = TMath::Abs(index)-1;
5111 AliESDkink * kink = fEvent->GetKink(index);
5112 kink->SetTPCDensity2(-1,1,0);
5113 kink->SetTPCDensity2(-1,1,1);
5115 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5116 if (row0<15) row0=15;
5118 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5119 if (row1>145) row1=145;
5121 Int_t found,foundable,shared;
5122 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5123 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5124 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5125 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5131 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5134 // check kink point for given track
5135 // if return value=0 kink point not found
5136 // otherwise seed0 correspond to mother particle
5137 // seed1 correspond to daughter particle
5138 // kink parameter of kink point
5140 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5141 Int_t first = seed->fFirstPoint;
5142 Int_t last = seed->fLastPoint;
5143 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5146 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5147 if (!seed1) return 0;
5148 FollowProlongation(*seed1,seed->fLastPoint-20);
5149 seed1->Reset(kTRUE);
5150 FollowProlongation(*seed1,158);
5151 seed1->Reset(kTRUE);
5152 last = seed1->fLastPoint;
5154 AliTPCseed *seed0 = new AliTPCseed(*seed);
5155 seed0->Reset(kFALSE);
5158 AliTPCseed param0[20]; // parameters along the track
5159 AliTPCseed param1[20]; // parameters along the track
5160 AliESDkink kinks[20]; // corresponding kink parameters
5162 for (Int_t irow=0; irow<20;irow++){
5163 rows[irow] = first +((last-first)*irow)/19;
5165 // store parameters along the track
5167 for (Int_t irow=0;irow<20;irow++){
5168 FollowBackProlongation(*seed0, rows[irow]);
5169 FollowProlongation(*seed1,rows[19-irow]);
5170 new(¶m0[irow]) AliTPCseed(*seed0);
5171 new(¶m1[19-irow]) AliTPCseed(*seed1);
5175 for (Int_t irow=0; irow<19;irow++){
5176 kinks[irow].SetMother(param0[irow]);
5177 kinks[irow].SetDaughter(param1[irow]);
5178 kinks[irow].Update();
5181 // choose kink with biggest change of angle
5183 Double_t maxchange= 0;
5184 for (Int_t irow=1;irow<19;irow++){
5185 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5186 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5187 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5188 if ( quality > maxchange){
5189 maxchange = quality;
5196 if (index<0) return 0;
5198 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5199 seed0 = new AliTPCseed(param0[index]);
5200 seed1 = new AliTPCseed(param1[index]);
5201 seed0->Reset(kFALSE);
5202 seed1->Reset(kFALSE);
5203 seed0->ResetCovariance();
5204 seed1->ResetCovariance();
5205 FollowProlongation(*seed0,0);
5206 FollowBackProlongation(*seed1,158);
5207 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5208 seed0->Reset(kFALSE);
5209 seed1->Reset(kFALSE);
5210 seed0->ResetCovariance();
5211 seed1->ResetCovariance();
5213 first = TMath::Max(row0-20,0);
5214 last = TMath::Min(row0+20,158);
5216 for (Int_t irow=0; irow<20;irow++){
5217 rows[irow] = first +((last-first)*irow)/19;
5219 // store parameters along the track
5221 for (Int_t irow=0;irow<20;irow++){
5222 FollowBackProlongation(*seed0, rows[irow]);
5223 FollowProlongation(*seed1,rows[19-irow]);
5224 new(¶m0[irow]) AliTPCseed(*seed0);
5225 new(¶m1[19-irow]) AliTPCseed(*seed1);
5229 for (Int_t irow=0; irow<19;irow++){
5230 kinks[irow].SetMother(param0[irow]);
5231 kinks[irow].SetDaughter(param1[irow]);
5232 // param0[irow].Dump();
5233 //param1[irow].Dump();
5234 kinks[irow].Update();
5237 // choose kink with biggest change of angle
5240 for (Int_t irow=0;irow<20;irow++){
5241 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5242 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5243 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5244 if ( quality > maxchange){
5245 maxchange = quality;
5252 if (index==-1 || param0[index].fN+param1[index].fN<100){
5257 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5259 kink.SetMother(param0[index]);
5260 kink.SetDaughter(param1[index]);
5262 row0 = GetRowNumber(kink.GetR());
5263 kink.SetTPCRow0(row0);
5264 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5265 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5266 kink.SetIndex(-10,0);
5267 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5268 kink.SetTPCncls(param0[index].fN,0);
5269 kink.SetTPCncls(param1[index].fN,1);
5272 // new (&mother) AliTPCseed(param0[index]);
5273 new (&daughter) AliTPCseed(param1[index]);
5274 daughter.SetLabel(kink.GetLabel(1));
5275 param0[index].Reset(kTRUE);
5276 FollowProlongation(param0[index],0);
5277 new (&mother) AliTPCseed(param0[index]);
5278 mother.SetLabel(kink.GetLabel(0));
5288 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5291 // reseed - refit - track
5294 // Int_t last = fSectors->GetNRows()-1;
5296 if (fSectors == fOuterSec){
5297 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5301 first = t->fFirstPoint;
5303 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5304 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5306 FollowProlongation(*t,first);
5316 //_____________________________________________________________________________
5317 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5318 //-----------------------------------------------------------------
5319 // This function reades track seeds.
5320 //-----------------------------------------------------------------
5321 TDirectory *savedir=gDirectory;
5323 TFile *in=(TFile*)inp;
5324 if (!in->IsOpen()) {
5325 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5330 TTree *seedTree=(TTree*)in->Get("Seeds");
5332 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5333 cerr<<"can't get a tree with track seeds !\n";
5336 AliTPCtrack *seed=new AliTPCtrack;
5337 seedTree->SetBranchAddress("tracks",&seed);
5339 if (fSeeds==0) fSeeds=new TObjArray(15000);
5341 Int_t n=(Int_t)seedTree->GetEntries();
5342 for (Int_t i=0; i<n; i++) {
5343 seedTree->GetEvent(i);
5344 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5353 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5356 if (fSeeds) DeleteSeeds();
5359 if (!fSeeds) return 1;
5366 //_____________________________________________________________________________
5367 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5368 //-----------------------------------------------------------------
5369 // This is a track finder.
5370 //-----------------------------------------------------------------
5371 TDirectory *savedir=gDirectory;
5375 fSeeds = Tracking();
5378 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5380 //activate again some tracks
5381 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5382 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5384 Int_t nc=t.GetNumberOfClusters();
5386 delete fSeeds->RemoveAt(i);
5390 if (pt->fRemoval==10) {
5391 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5392 pt->Desactivate(10); // make track again active
5394 pt->Desactivate(20);
5395 delete fSeeds->RemoveAt(i);
5400 RemoveUsed2(fSeeds,0.85,0.85,0);
5401 FindKinks(fSeeds,fEvent);
5402 RemoveUsed2(fSeeds,0.5,0.4,20);
5404 // // refit short tracks
5406 Int_t nseed=fSeeds->GetEntriesFast();
5407 // for (Int_t i=0; i<nseed; i++) {
5408 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5409 // if (!pt) continue;
5410 // Int_t nc=t.GetNumberOfClusters();
5412 // delete fSeeds->RemoveAt(i);
5415 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5416 // if (nc>100) continue; // hopefully, enough for ITS
5417 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5418 // //seed2->Reset(kFALSE);
5419 // //pt->ResetCovariance();
5420 // seed2->Modify(1);
5421 // FollowBackProlongation(*seed2,158);
5422 // //seed2->Reset(kFALSE);
5423 // seed2->Modify(10);
5424 // FollowProlongation(*seed2,0);
5425 // TTreeSRedirector &cstream = *fDebugStreamer;
5426 // cstream<<"Crefit"<<
5430 // if (seed2->fN>pt->fN){
5431 // delete fSeeds->RemoveAt(i);
5432 // fSeeds->AddAt(seed2,i);
5437 // RemoveUsed2(fSeeds,0.6,0.6,50);
5439 // FindV0s(fSeeds,fEvent);
5440 //RemoveDouble(fSeeds,0.2,0.6,11);
5444 for (Int_t i=0; i<nseed; i++) {
5445 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5447 Int_t nc=t.GetNumberOfClusters();
5449 delete fSeeds->RemoveAt(i);
5452 CookLabel(pt,0.1); //For comparison only
5453 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5454 if ((pt->IsActive() || (pt->fRemoval==10) )){
5456 if (fDebug>0) cerr<<found<<'\r';
5460 delete fSeeds->RemoveAt(i);
5464 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5466 //RemoveUsed(fSeeds,0.9,0.9,6);
5468 nseed=fSeeds->GetEntriesFast();
5470 for (Int_t i=0; i<nseed; i++) {
5471 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5473 Int_t nc=t.GetNumberOfClusters();
5475 delete fSeeds->RemoveAt(i);
5479 t.CookdEdx(0.02,0.6);
5480 // CheckKinkPoint(&t,0.05);
5481 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5482 if ((pt->IsActive() || (pt->fRemoval==10) )){
5490 delete fSeeds->RemoveAt(i);
5491 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5493 // FollowProlongation(*seed1,0);
5494 // Int_t n = seed1->GetNumberOfClusters();
5495 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5496 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5499 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5503 SortTracks(fSeeds, 1);
5507 PrepareForBackProlongation(fSeeds,5.);
5508 PropagateBack(fSeeds);
5509 printf("Time for back propagation: \t");timer.Print();timer.Start();
5513 PrepareForProlongation(fSeeds,5.);
5514 PropagateForward2(fSeeds);
5516 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5517 // RemoveUsed(fSeeds,0.7,0.7,6);
5518 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5520 nseed=fSeeds->GetEntriesFast();
5522 for (Int_t i=0; i<nseed; i++) {
5523 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5525 Int_t nc=t.GetNumberOfClusters();
5527 delete fSeeds->RemoveAt(i);
5530 t.CookdEdx(0.02,0.6);
5531 // CookLabel(pt,0.1); //For comparison only
5532 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5533 if ((pt->IsActive() || (pt->fRemoval==10) )){
5534 cerr<<found++<<'\r';
5537 delete fSeeds->RemoveAt(i);
5542 // fNTracks = found;
5544 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5547 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5548 Info("Clusters2Tracks","Number of found tracks %d",found);
5550 // UnloadClusters();
5555 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5558 // tracking of the seeds
5561 fSectors = fOuterSec;
5562 ParallelTracking(arr,150,63);
5563 fSectors = fOuterSec;
5564 ParallelTracking(arr,63,0);
5567 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5572 TObjArray * arr = new TObjArray;
5574 fSectors = fOuterSec;
5577 for (Int_t sec=0;sec<fkNOS;sec++){
5578 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5579 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5580 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5583 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5595 TObjArray * AliTPCtrackerMI::Tracking()
5601 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5603 TObjArray * seeds = new TObjArray;
5612 Float_t fnumber = 3.0;
5613 Float_t fdensity = 3.0;
5618 for (Int_t delta = 0; delta<18; delta+=6){
5622 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5623 SumTracks(seeds,arr);
5624 SignClusters(seeds,fnumber,fdensity);
5626 for (Int_t i=2;i<6;i+=2){
5627 // seed high pt tracks
5630 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5631 SumTracks(seeds,arr);
5632 SignClusters(seeds,fnumber,fdensity);
5637 // RemoveUsed(seeds,0.9,0.9,1);
5638 // UnsignClusters();
5639 // SignClusters(seeds,fnumber,fdensity);
5643 for (Int_t delta = 20; delta<120; delta+=10){
5645 // seed high pt tracks
5649 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5650 SumTracks(seeds,arr);
5651 SignClusters(seeds,fnumber,fdensity);
5656 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5657 SumTracks(seeds,arr);
5658 SignClusters(seeds,fnumber,fdensity);
5669 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5673 // RemoveUsed(seeds,0.75,0.75,1);
5675 //SignClusters(seeds,fnumber,fdensity);
5684 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5685 SumTracks(seeds,arr);
5686 SignClusters(seeds,fnumber,fdensity);
5688 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5689 SumTracks(seeds,arr);
5690 SignClusters(seeds,fnumber,fdensity);
5692 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5693 SumTracks(seeds,arr);
5694 SignClusters(seeds,fnumber,fdensity);
5698 for (Int_t delta = 3; delta<30; delta+=5){
5704 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5705 SumTracks(seeds,arr);
5706 SignClusters(seeds,fnumber,fdensity);
5708 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5709 SumTracks(seeds,arr);
5710 SignClusters(seeds,fnumber,fdensity);
5722 for (Int_t delta = 30; delta<90; delta+=10){
5728 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5729 SumTracks(seeds,arr);
5730 SignClusters(seeds,fnumber,fdensity);
5732 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5733 SumTracks(seeds,arr);
5734 SignClusters(seeds,fnumber,fdensity);
5738 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5749 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5752 //sum tracks to common container
5753 //remove suspicious tracks
5754 Int_t nseed = arr2->GetEntriesFast();
5755 for (Int_t i=0;i<nseed;i++){
5756 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5759 // NORMAL ACTIVE TRACK
5760 if (pt->IsActive()){
5761 arr1->AddLast(arr2->RemoveAt(i));
5764 //remove not usable tracks
5765 if (pt->fRemoval!=10){
5766 delete arr2->RemoveAt(i);
5769 // REMOVE VERY SHORT TRACKS
5770 if (pt->GetNumberOfClusters()<20){
5771 delete arr2->RemoveAt(i);
5774 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5775 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5776 arr1->AddLast(arr2->RemoveAt(i));
5778 delete arr2->RemoveAt(i);
5787 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5790 // try to track in parralel
5792 Int_t nseed=arr->GetEntriesFast();
5793 //prepare seeds for tracking
5794 for (Int_t i=0; i<nseed; i++) {
5795 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5797 if (!t.IsActive()) continue;
5798 // follow prolongation to the first layer
5799 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5800 FollowProlongation(t, rfirst+1);
5805 for (Int_t nr=rfirst; nr>=rlast; nr--){
5806 if (nr<fInnerSec->GetNRows())
5807 fSectors = fInnerSec;
5809 fSectors = fOuterSec;
5810 // make indexes with the cluster tracks for given
5812 // find nearest cluster
5813 for (Int_t i=0; i<nseed; i++) {
5814 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5816 if (nr==80) pt->UpdateReference();
5817 if (!pt->IsActive()) continue;
5818 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5819 if (pt->fRelativeSector>17) {
5822 UpdateClusters(t,nr);
5824 // prolonagate to the nearest cluster - if founded
5825 for (Int_t i=0; i<nseed; i++) {
5826 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5828 if (!pt->IsActive()) continue;
5829 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5830 if (pt->fRelativeSector>17) {
5833 FollowToNextCluster(*pt,nr);
5838 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5842 // if we use TPC track itself we have to "update" covariance
5844 Int_t nseed= arr->GetEntriesFast();
5845 for (Int_t i=0;i<nseed;i++){
5846 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5850 //rotate to current local system at first accepted point
5851 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5852 Int_t sec = (index&0xff000000)>>24;
5854 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5855 if (angle1>TMath::Pi())
5856 angle1-=2.*TMath::Pi();
5857 Float_t angle2 = pt->GetAlpha();
5859 if (TMath::Abs(angle1-angle2)>0.001){
5860 pt->Rotate(angle1-angle2);
5861 //angle2 = pt->GetAlpha();
5862 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5863 //if (pt->GetAlpha()<0)
5864 // pt->fRelativeSector+=18;
5865 //sec = pt->fRelativeSector;
5874 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5878 // if we use TPC track itself we have to "update" covariance
5880 Int_t nseed= arr->GetEntriesFast();
5881 for (Int_t i=0;i<nseed;i++){
5882 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5885 pt->fFirstPoint = pt->fLastPoint;
5893 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5896 // make back propagation
5898 Int_t nseed= arr->GetEntriesFast();
5899 for (Int_t i=0;i<nseed;i++){
5900 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5901 if (pt&& pt->GetKinkIndex(0)<=0) {
5902 //AliTPCseed *pt2 = new AliTPCseed(*pt);
5903 fSectors = fInnerSec;
5904 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5905 //fSectors = fOuterSec;
5906 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5907 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
5908 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
5909 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5912 if (pt&& pt->GetKinkIndex(0)>0) {
5913 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
5914 pt->fFirstPoint = kink->GetTPCRow0();
5915 fSectors = fInnerSec;
5916 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5924 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5927 // make forward propagation
5929 Int_t nseed= arr->GetEntriesFast();
5931 for (Int_t i=0;i<nseed;i++){
5932 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5934 FollowProlongation(*pt,0);
5941 Int_t AliTPCtrackerMI::PropagateForward()
5944 // propagate track forward
5946 Int_t nseed = fSeeds->GetEntriesFast();
5947 for (Int_t i=0;i<nseed;i++){
5948 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5950 AliTPCseed &t = *pt;
5951 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5952 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5953 if (alpha < 0. ) alpha += 2.*TMath::Pi();
5954 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
5958 fSectors = fOuterSec;
5959 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
5960 fSectors = fInnerSec;
5961 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
5971 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
5974 // make back propagation, in between row0 and row1
5978 fSectors = fInnerSec;
5981 if (row1<fSectors->GetNRows())
5984 r1 = fSectors->GetNRows()-1;
5986 if (row0<fSectors->GetNRows()&& r1>0 )
5987 FollowBackProlongation(*pt,r1);
5988 if (row1<=fSectors->GetNRows())
5991 r1 = row1 - fSectors->GetNRows();
5992 if (r1<=0) return 0;
5993 if (r1>=fOuterSec->GetNRows()) return 0;
5994 fSectors = fOuterSec;
5995 return FollowBackProlongation(*pt,r1);
6003 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6007 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6008 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6009 Float_t padlength = GetPadPitchLength(row);
6011 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6012 Float_t angulary = seed->GetSnp();
6013 angulary = angulary*angulary/(1-angulary*angulary);
6014 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6016 Float_t sresz = fParam->GetZSigma();
6017 Float_t angularz = seed->GetTgl();
6018 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6020 Float_t wy = GetSigmaY(seed);
6021 Float_t wz = GetSigmaZ(seed);
6024 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6025 printf("problem\n");
6031 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6035 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6036 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6037 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6038 Float_t angular = seed->GetSnp();
6039 angular = angular*angular/(1-angular*angular);
6040 // angular*=angular;
6041 //angular = TMath::Sqrt(angular/(1-angular));
6042 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6045 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6049 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6050 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6051 Float_t sres = fParam->GetZSigma();
6052 Float_t angular = seed->GetTgl();
6053 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6058 //__________________________________________________________________________
6059 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6060 //--------------------------------------------------------------------
6061 //This function "cooks" a track label. If label<0, this track is fake.
6062 //--------------------------------------------------------------------
6063 AliTPCseed * t = (AliTPCseed*)tk;
6064 Int_t noc=t->GetNumberOfClusters();
6066 //printf("\nnot founded prolongation\n\n\n");
6072 AliTPCclusterMI *clusters[160];
6074 for (Int_t i=0;i<160;i++) {
6081 for (i=0; i<160 && current<noc; i++) {
6083 Int_t index=t->GetClusterIndex2(i);
6084 if (index<=0) continue;
6085 if (index&0x8000) continue;
6087 //clusters[current]=GetClusterMI(index);
6088 if (t->fClusterPointer[i]){
6089 clusters[current]=t->fClusterPointer[i];
6095 Int_t lab=123456789;
6096 for (i=0; i<noc; i++) {
6097 AliTPCclusterMI *c=clusters[i];
6099 lab=TMath::Abs(c->GetLabel(0));
6101 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6107 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6109 for (i=0; i<noc; i++) {
6110 AliTPCclusterMI *c=clusters[i];
6112 if (TMath::Abs(c->GetLabel(1)) == lab ||
6113 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6116 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6119 Int_t tail=Int_t(0.10*noc);
6122 for (i=1; i<=160&&ind<tail; i++) {
6123 // AliTPCclusterMI *c=clusters[noc-i];
6124 AliTPCclusterMI *c=clusters[i];
6126 if (lab == TMath::Abs(c->GetLabel(0)) ||
6127 lab == TMath::Abs(c->GetLabel(1)) ||
6128 lab == TMath::Abs(c->GetLabel(2))) max++;
6131 if (max < Int_t(0.5*tail)) lab=-lab;
6138 //delete[] clusters;
6142 //__________________________________________________________________________
6143 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6144 //--------------------------------------------------------------------
6145 //This function "cooks" a track label. If label<0, this track is fake.
6146 //--------------------------------------------------------------------
6147 Int_t noc=t->GetNumberOfClusters();
6149 //printf("\nnot founded prolongation\n\n\n");
6155 AliTPCclusterMI *clusters[160];
6157 for (Int_t i=0;i<160;i++) {
6164 for (i=0; i<160 && current<noc; i++) {
6165 if (i<first) continue;
6166 if (i>last) continue;
6167 Int_t index=t->GetClusterIndex2(i);
6168 if (index<=0) continue;
6169 if (index&0x8000) continue;
6171 //clusters[current]=GetClusterMI(index);
6172 if (t->fClusterPointer[i]){
6173 clusters[current]=t->fClusterPointer[i];
6178 if (noc<5) return -1;
6179 Int_t lab=123456789;
6180 for (i=0; i<noc; i++) {
6181 AliTPCclusterMI *c=clusters[i];
6183 lab=TMath::Abs(c->GetLabel(0));
6185 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6191 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6193 for (i=0; i<noc; i++) {
6194 AliTPCclusterMI *c=clusters[i];
6196 if (TMath::Abs(c->GetLabel(1)) == lab ||
6197 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6200 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6203 Int_t tail=Int_t(0.10*noc);
6206 for (i=1; i<=160&&ind<tail; i++) {
6207 // AliTPCclusterMI *c=clusters[noc-i];
6208 AliTPCclusterMI *c=clusters[i];
6210 if (lab == TMath::Abs(c->GetLabel(0)) ||
6211 lab == TMath::Abs(c->GetLabel(1)) ||
6212 lab == TMath::Abs(c->GetLabel(2))) max++;
6215 if (max < Int_t(0.5*tail)) lab=-lab;
6218 // t->SetLabel(lab);
6222 //delete[] clusters;
6226 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6228 //return pad row number for this x
6231 r=fRow[fN-1].GetX();
6232 if (x > r) return fN;
6234 if (x < r) return -1;
6235 return Int_t((x-r)/fPadPitchLength + 0.5);}
6237 r=fRow[fN-1].GetX();
6238 if (x > r) return fN;
6240 if (x < r) return -1;
6241 Double_t r1=fRow[64].GetX();
6243 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6245 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6249 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6251 //return pad row number for given x vector
6252 Float_t phi = TMath::ATan2(x[1],x[0]);
6253 if(phi<0) phi=2.*TMath::Pi()+phi;
6254 // Get the local angle in the sector philoc
6255 const Float_t kRaddeg = 180/3.14159265358979312;
6256 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6257 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6258 return GetRowNumber(localx);
6261 //_________________________________________________________________________
6262 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6263 //-----------------------------------------------------------------------
6264 // Setup inner sector
6265 //-----------------------------------------------------------------------
6267 fAlpha=par->GetInnerAngle();
6268 fAlphaShift=par->GetInnerAngleShift();
6269 fPadPitchWidth=par->GetInnerPadPitchWidth();
6270 fPadPitchLength=par->GetInnerPadPitchLength();
6271 fN=par->GetNRowLow();
6272 fRow=new AliTPCRow[fN];
6273 for (Int_t i=0; i<fN; i++) {
6274 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6275 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6278 fAlpha=par->GetOuterAngle();
6279 fAlphaShift=par->GetOuterAngleShift();
6280 fPadPitchWidth = par->GetOuterPadPitchWidth();
6281 fPadPitchLength = par->GetOuter1PadPitchLength();
6282 f1PadPitchLength = par->GetOuter1PadPitchLength();
6283 f2PadPitchLength = par->GetOuter2PadPitchLength();
6285 fN=par->GetNRowUp();
6286 fRow=new AliTPCRow[fN];
6287 for (Int_t i=0; i<fN; i++) {
6288 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6289 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6294 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6296 // default constructor
6304 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6311 //_________________________________________________________________________
6313 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6314 //-----------------------------------------------------------------------
6315 // Insert a cluster into this pad row in accordence with its y-coordinate
6316 //-----------------------------------------------------------------------
6317 if (fN==kMaxClusterPerRow) {
6318 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6320 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6321 Int_t i=Find(c->GetZ());
6322 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6323 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6324 fIndex[i]=index; fClusters[i]=c; fN++;
6327 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6333 //delete[] fClusterArray;
6334 if (fClusters1) delete []fClusters1;
6335 if (fClusters2) delete []fClusters2;
6342 //___________________________________________________________________
6343 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6344 //-----------------------------------------------------------------------
6345 // Return the index of the nearest cluster
6346 //-----------------------------------------------------------------------
6347 if (fN==0) return 0;
6348 if (z <= fClusters[0]->GetZ()) return 0;
6349 if (z > fClusters[fN-1]->GetZ()) return fN;
6350 Int_t b=0, e=fN-1, m=(b+e)/2;
6351 for (; b<e; m=(b+e)/2) {
6352 if (z > fClusters[m]->GetZ()) b=m+1;
6360 //___________________________________________________________________
6361 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6362 //-----------------------------------------------------------------------
6363 // Return the index of the nearest cluster in z y
6364 //-----------------------------------------------------------------------
6365 Float_t maxdistance = roady*roady + roadz*roadz;
6367 AliTPCclusterMI *cl =0;
6368 for (Int_t i=Find(z-roadz); i<fN; i++) {
6369 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6370 if (c->GetZ() > z+roadz) break;
6371 if ( (c->GetY()-y) > roady ) continue;
6372 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6373 if (maxdistance>distance) {
6374 maxdistance = distance;
6381 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6383 //-----------------------------------------------------------------------
6384 // Return the index of the nearest cluster in z y
6385 //-----------------------------------------------------------------------
6386 Float_t maxdistance = roady*roady + roadz*roadz;
6387 AliTPCclusterMI *cl =0;
6389 //PH Check boundaries. 510 is the size of fFastCluster
6390 Int_t iz1 = Int_t(z-roadz+254.5);
6391 if (iz1<0 || iz1>=510) return cl;
6392 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6393 Int_t iz2 = Int_t(z+roadz+255.5);
6394 if (iz2<0 || iz2>=510) return cl;
6395 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6397 //FindNearest3(y,z,roady,roadz,index);
6398 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6399 for (Int_t i=iz1; i<iz2; i++) {
6400 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6401 if (c->GetZ() > z+roadz) break;
6402 if ( c->GetY()-y > roady ) continue;
6403 if ( y-c->GetY() > roady ) continue;
6404 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6405 if (maxdistance>distance) {
6406 maxdistance = distance;
6409 //roady = TMath::Sqrt(maxdistance);
6417 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6419 //-----------------------------------------------------------------------
6420 // Return the index of the nearest cluster in z y
6421 //-----------------------------------------------------------------------
6422 Float_t maxdistance = roady*roady + roadz*roadz;
6423 // Int_t iz = Int_t(z+255.);
6424 AliTPCclusterMI *cl =0;
6425 for (Int_t i=Find(z-roadz); i<fN; i++) {
6426 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6427 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6428 if (c->GetZ() > z+roadz) break;
6429 if ( c->GetY()-y > roady ) continue;
6430 if ( y-c->GetY() > roady ) continue;
6431 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6432 if (maxdistance>distance) {
6433 maxdistance = distance;
6436 //roady = TMath::Sqrt(maxdistance);
6446 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6450 // return &fTrackPoints[i];