1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker -
24 // run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 // run AliTPCFindTracksMI.C macro - to find tracks
26 // tracks are written to AliTPCtracks.root file
27 // for comparison also seeds are written to the same file - to special branch
28 //-------------------------------------------------------
33 #include "Riostream.h"
34 #include <TClonesArray.h>
36 #include <TObjArray.h>
39 #include "AliComplexCluster.h"
41 #include "AliESDkink.h"
43 #include "AliRunLoader.h"
44 #include "AliTPCClustersRow.h"
45 #include "AliTPCParam.h"
46 #include "AliTPCReconstructor.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCseed.h"
51 #include "AliTPCtrackerMI.h"
52 #include "TStopwatch.h"
53 #include "AliTPCReconstructor.h"
54 #include "AliESDkink.h"
56 #include "TTreeStream.h"
59 ClassImp(AliTPCtrackerMI)
62 class AliTPCFastMath {
65 static Double_t FastAsin(Double_t x);
67 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
70 Double_t AliTPCFastMath::fgFastAsin[20000];
71 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
73 AliTPCFastMath::AliTPCFastMath(){
75 // initialized lookup table;
76 for (Int_t i=0;i<10000;i++){
77 fgFastAsin[2*i] = TMath::ASin(i/10000.);
78 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
82 Double_t AliTPCFastMath::FastAsin(Double_t x){
84 // return asin using lookup table
86 Int_t index = int(x*10000);
87 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
90 Int_t index = int(x*10000);
91 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
97 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
99 //update track information using current cluster - track->fCurrentCluster
102 AliTPCclusterMI* c =track->fCurrentCluster;
103 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
105 UInt_t i = track->fCurrentClusterIndex1;
107 Int_t sec=(i&0xff000000)>>24;
108 //Int_t row = (i&0x00ff0000)>>16;
109 track->fRow=(i&0x00ff0000)>>16;
110 track->fSector = sec;
111 // Int_t index = i&0xFFFF;
112 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
113 track->SetClusterIndex2(track->fRow, i);
114 //track->fFirstPoint = row;
115 //if ( track->fLastPoint<row) track->fLastPoint =row;
116 // if (track->fRow<0 || track->fRow>160) {
117 // printf("problem\n");
119 if (track->fFirstPoint>track->fRow)
120 track->fFirstPoint = track->fRow;
121 if (track->fLastPoint<track->fRow)
122 track->fLastPoint = track->fRow;
125 track->fClusterPointer[track->fRow] = c;
128 Float_t angle2 = track->GetSnp()*track->GetSnp();
129 angle2 = TMath::Sqrt(angle2/(1-angle2));
131 //SET NEW Track Point
135 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
137 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
138 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
139 point.SetErrY(sqrt(track->fErrorY2));
140 point.SetErrZ(sqrt(track->fErrorZ2));
142 point.SetX(track->GetX());
143 point.SetY(track->GetY());
144 point.SetZ(track->GetZ());
145 point.SetAngleY(angle2);
146 point.SetAngleZ(track->GetTgl());
147 if (point.fIsShared){
148 track->fErrorY2 *= 4;
149 track->fErrorZ2 *= 4;
153 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
155 track->fErrorY2 *= 1.3;
156 track->fErrorY2 += 0.01;
157 track->fErrorZ2 *= 1.3;
158 track->fErrorZ2 += 0.005;
160 if (accept>0) return 0;
161 if (track->GetNumberOfClusters()%20==0){
162 // if (track->fHelixIn){
163 // TClonesArray & larr = *(track->fHelixIn);
164 // Int_t ihelix = larr.GetEntriesFast();
165 // new(larr[ihelix]) AliHelix(*track) ;
168 track->fNoCluster =0;
169 return track->Update(c,chi2,i);
174 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
175 Float_t cory, Float_t corz)
178 // decide according desired precision to accept given
179 // cluster for tracking
180 Double_t sy2=ErrY2(seed,cluster)*cory;
181 Double_t sz2=ErrZ2(seed,cluster)*corz;
182 //sy2=ErrY2(seed,cluster)*cory;
183 //sz2=ErrZ2(seed,cluster)*cory;
185 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
186 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
188 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
189 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
190 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
191 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
193 Double_t rdistance2 = rdistancey2+rdistancez2;
196 if (rdistance2>16) return 3;
199 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
200 return 2; //suspisiouce - will be changed
202 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
203 // strict cut on overlaped cluster
204 return 2; //suspisiouce - will be changed
206 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
207 && cluster->GetType()<0){
217 //_____________________________________________________________________________
218 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
219 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
221 //---------------------------------------------------------------------
222 // The main TPC tracker constructor
223 //---------------------------------------------------------------------
224 fInnerSec=new AliTPCSector[fkNIS];
225 fOuterSec=new AliTPCSector[fkNOS];
228 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
229 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
236 Int_t nrowlow = par->GetNRowLow();
237 Int_t nrowup = par->GetNRowUp();
240 for (Int_t i=0;i<nrowlow;i++){
241 fXRow[i] = par->GetPadRowRadiiLow(i);
242 fPadLength[i]= par->GetPadPitchLength(0,i);
243 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
247 for (Int_t i=0;i<nrowup;i++){
248 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
249 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
250 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
261 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
263 //________________________________________________________________________
264 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
269 //------------------------------------
270 // dummy copy constructor
271 //------------------------------------------------------------------
273 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
274 //------------------------------
276 //--------------------------------------------------------------
279 //_____________________________________________________________________________
280 AliTPCtrackerMI::~AliTPCtrackerMI() {
281 //------------------------------------------------------------------
282 // TPC tracker destructor
283 //------------------------------------------------------------------
290 if (fDebugStreamer) delete fDebugStreamer;
293 void AliTPCtrackerMI::SetIO()
297 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
299 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
301 AliTPCtrack *iotrack= new AliTPCtrack;
302 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
308 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
324 AliTPCtrack *iotrack= new AliTPCtrack;
325 // iotrack->fHelixIn = new TClonesArray("AliHelix");
326 //iotrack->fHelixOut = new TClonesArray("AliHelix");
327 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
330 if (output && (fDebug&2)){
331 //write the full seed information if specified in debug mode
333 fSeedTree = new TTree("Seeds","Seeds");
334 AliTPCseed * vseed = new AliTPCseed;
336 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
337 arrtr->ExpandCreateFast(160);
338 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
340 vseed->fPoints = arrtr;
341 vseed->fEPoints = arre;
342 // vseed->fClusterPoints = arrcl;
343 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
346 fTreeDebug = new TTree("trackDebug","trackDebug");
347 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
348 fTreeDebug->Branch("debug",&arrd,32000,99);
356 void AliTPCtrackerMI::FillESD(TObjArray* arr)
360 //fill esds using updated tracks
362 // write tracks to the event
363 // store index of the track
364 Int_t nseed=arr->GetEntriesFast();
365 //FindKinks(arr,fEvent);
366 for (Int_t i=0; i<nseed; i++) {
367 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
370 // pt->PropagateTo(fParam->GetInnerRadiusLow());
371 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
372 pt->PropagateTo(fParam->GetInnerRadiusLow());
375 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
377 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
378 iotrack.SetTPCPoints(pt->GetPoints());
379 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
380 iotrack.SetV0Indexes(pt->GetV0Indexes());
381 // iotrack.SetTPCpid(pt->fTPCr);
382 //iotrack.SetTPCindex(i);
383 fEvent->AddTrack(&iotrack);
387 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
389 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
390 iotrack.SetTPCPoints(pt->GetPoints());
391 //iotrack.SetTPCindex(i);
392 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
393 iotrack.SetV0Indexes(pt->GetV0Indexes());
394 // iotrack.SetTPCpid(pt->fTPCr);
395 fEvent->AddTrack(&iotrack);
399 // short tracks - maybe decays
401 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
402 Int_t found,foundable,shared;
403 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
404 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
406 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
407 //iotrack.SetTPCindex(i);
408 iotrack.SetTPCPoints(pt->GetPoints());
409 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
410 iotrack.SetV0Indexes(pt->GetV0Indexes());
411 //iotrack.SetTPCpid(pt->fTPCr);
412 fEvent->AddTrack(&iotrack);
417 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
418 Int_t found,foundable,shared;
419 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
420 if (found<20) continue;
421 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
424 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
425 iotrack.SetTPCPoints(pt->GetPoints());
426 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
427 iotrack.SetV0Indexes(pt->GetV0Indexes());
428 //iotrack.SetTPCpid(pt->fTPCr);
429 //iotrack.SetTPCindex(i);
430 fEvent->AddTrack(&iotrack);
433 // short tracks - secondaties
435 if ( (pt->GetNumberOfClusters()>30) ) {
436 Int_t found,foundable,shared;
437 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
438 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
440 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
441 iotrack.SetTPCPoints(pt->GetPoints());
442 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
443 iotrack.SetV0Indexes(pt->GetV0Indexes());
444 //iotrack.SetTPCpid(pt->fTPCr);
445 //iotrack.SetTPCindex(i);
446 fEvent->AddTrack(&iotrack);
451 if ( (pt->GetNumberOfClusters()>15)) {
452 Int_t found,foundable,shared;
453 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
454 if (found<15) continue;
455 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
456 if (float(found)/float(foundable)<0.8) continue;
459 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
460 iotrack.SetTPCPoints(pt->GetPoints());
461 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
462 iotrack.SetV0Indexes(pt->GetV0Indexes());
463 // iotrack.SetTPCpid(pt->fTPCr);
464 //iotrack.SetTPCindex(i);
465 fEvent->AddTrack(&iotrack);
470 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
473 void AliTPCtrackerMI::WriteTracks(TTree * tree)
476 // write tracks from seed array to selected tree
480 AliTPCtrack *iotrack= new AliTPCtrack;
481 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
486 void AliTPCtrackerMI::WriteTracks()
489 // write tracks to the given output tree -
490 // output specified with SetIO routine
497 AliTPCtrack *iotrack= 0;
498 Int_t nseed=fSeeds->GetEntriesFast();
499 //for (Int_t i=0; i<nseed; i++) {
500 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
501 // if (iotrack) break;
503 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
504 TBranch * br = fOutput->GetBranch("tracks");
505 br->SetAddress(&iotrack);
507 for (Int_t i=0; i<nseed; i++) {
508 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
510 AliTPCtrack * track = new AliTPCtrack(*pt);
513 // br->SetAddress(&iotrack);
518 //fOutput->GetDirectory()->cd();
524 //write the full seed information if specified in debug mode
526 AliTPCseed * vseed = new AliTPCseed;
528 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
529 arrtr->ExpandCreateFast(160);
530 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
531 //arrcl->ExpandCreateFast(160);
532 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
534 vseed->fPoints = arrtr;
535 vseed->fEPoints = arre;
536 // vseed->fClusterPoints = arrcl;
537 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
538 TBranch * brseed = fSeedTree->GetBranch("seeds");
540 Int_t nseed=fSeeds->GetEntriesFast();
542 for (Int_t i=0; i<nseed; i++) {
543 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
546 // pt->fClusterPoints = arrcl;
550 brseed->SetAddress(&vseed);
554 // pt->fClusterPoints = 0;
557 if (fTreeDebug) fTreeDebug->Write();
565 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
568 //seed->SetErrorY2(0.1);
570 //calculate look-up table at the beginning
571 static Bool_t ginit = kFALSE;
572 static Float_t gnoise1,gnoise2,gnoise3;
573 static Float_t ggg1[10000];
574 static Float_t ggg2[10000];
575 static Float_t ggg3[10000];
576 static Float_t glandau1[10000];
577 static Float_t glandau2[10000];
578 static Float_t glandau3[10000];
580 static Float_t gcor01[500];
581 static Float_t gcor02[500];
582 static Float_t gcorp[500];
587 for (Int_t i=1;i<500;i++){
588 Float_t rsigma = float(i)/100.;
589 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
590 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
591 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
595 for (Int_t i=3;i<10000;i++){
599 Float_t amp = float(i);
600 Float_t padlength =0.75;
601 gnoise1 = 0.0004/padlength;
602 Float_t nel = 0.268*amp;
603 Float_t nprim = 0.155*amp;
604 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
605 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
606 if (glandau1[i]>1) glandau1[i]=1;
607 glandau1[i]*=padlength*padlength/12.;
611 gnoise2 = 0.0004/padlength;
614 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
615 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
616 if (glandau2[i]>1) glandau2[i]=1;
617 glandau2[i]*=padlength*padlength/12.;
622 gnoise3 = 0.0004/padlength;
625 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
626 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
627 if (glandau3[i]>1) glandau3[i]=1;
628 glandau3[i]*=padlength*padlength/12.;
636 Int_t amp = int(TMath::Abs(cl->GetQ()));
638 seed->SetErrorY2(1.);
642 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
643 Int_t ctype = cl->GetType();
644 Float_t padlength= GetPadPitchLength(seed->fRow);
645 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
646 angle2 = angle2/(1-angle2);
649 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
652 if (fSectors==fInnerSec){
654 res = ggg1[amp]*z+glandau1[amp]*angle2;
655 if (ctype==0) res *= gcor01[rsigmay];
658 res*= gcorp[rsigmay];
664 res = ggg2[amp]*z+glandau2[amp]*angle2;
665 if (ctype==0) res *= gcor02[rsigmay];
668 res*= gcorp[rsigmay];
673 res = ggg3[amp]*z+glandau3[amp]*angle2;
674 if (ctype==0) res *= gcor02[rsigmay];
677 res*= gcorp[rsigmay];
684 res*=2.4; // overestimate error 2 times
691 seed->SetErrorY2(res);
699 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
702 //seed->SetErrorY2(0.1);
704 //calculate look-up table at the beginning
705 static Bool_t ginit = kFALSE;
706 static Float_t gnoise1,gnoise2,gnoise3;
707 static Float_t ggg1[10000];
708 static Float_t ggg2[10000];
709 static Float_t ggg3[10000];
710 static Float_t glandau1[10000];
711 static Float_t glandau2[10000];
712 static Float_t glandau3[10000];
714 static Float_t gcor01[1000];
715 static Float_t gcor02[1000];
716 static Float_t gcorp[1000];
721 for (Int_t i=1;i<1000;i++){
722 Float_t rsigma = float(i)/100.;
723 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
724 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
725 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
729 for (Int_t i=3;i<10000;i++){
733 Float_t amp = float(i);
734 Float_t padlength =0.75;
735 gnoise1 = 0.0004/padlength;
736 Float_t nel = 0.268*amp;
737 Float_t nprim = 0.155*amp;
738 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
739 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
740 if (glandau1[i]>1) glandau1[i]=1;
741 glandau1[i]*=padlength*padlength/12.;
745 gnoise2 = 0.0004/padlength;
748 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
749 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
750 if (glandau2[i]>1) glandau2[i]=1;
751 glandau2[i]*=padlength*padlength/12.;
756 gnoise3 = 0.0004/padlength;
759 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
760 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
761 if (glandau3[i]>1) glandau3[i]=1;
762 glandau3[i]*=padlength*padlength/12.;
770 Int_t amp = int(TMath::Abs(cl->GetQ()));
772 seed->SetErrorY2(1.);
776 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
777 Int_t ctype = cl->GetType();
778 Float_t padlength= GetPadPitchLength(seed->fRow);
780 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
781 // if (angle2<0.6) angle2 = 0.6;
782 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
785 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
788 if (fSectors==fInnerSec){
790 res = ggg1[amp]*z+glandau1[amp]*angle2;
791 if (ctype==0) res *= gcor01[rsigmaz];
794 res*= gcorp[rsigmaz];
800 res = ggg2[amp]*z+glandau2[amp]*angle2;
801 if (ctype==0) res *= gcor02[rsigmaz];
804 res*= gcorp[rsigmaz];
809 res = ggg3[amp]*z+glandau3[amp]*angle2;
810 if (ctype==0) res *= gcor02[rsigmaz];
813 res*= gcorp[rsigmaz];
822 if ((ctype<0) &&<70){
830 seed->SetErrorZ2(res);
837 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
840 //seed->SetErrorZ2(0.1);
844 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
846 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
847 Int_t ctype = cl->GetType();
848 Float_t amp = TMath::Abs(cl->GetQ());
853 Float_t landau=2 ; //landau fluctuation part
854 Float_t gg=2; // gg fluctuation part
855 Float_t padlength= GetPadPitchLength(seed->GetX());
857 if (fSectors==fInnerSec){
858 snoise2 = 0.0004/padlength;
861 gg = (2+0.001*nel/(padlength*padlength))/nel;
862 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
863 if (landau>1) landau=1;
866 snoise2 = 0.0004/padlength;
869 gg = (2+0.0008*nel/(padlength*padlength))/nel;
870 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
871 if (landau>1) landau=1;
873 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
876 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
877 angle2 = TMath::Sqrt((1-angle2));
878 if (angle2<0.6) angle2 = 0.6;
881 Float_t angle = seed->GetTgl()/angle2;
882 Float_t angular = landau*angle*angle*padlength*padlength/12.;
883 Float_t res = sdiff + angular;
886 if ((ctype==0) && (fSectors ==fOuterSec))
887 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
889 if ((ctype==0) && (fSectors ==fInnerSec))
890 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
894 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
900 if ((ctype<0) &&<70){
908 seed->SetErrorZ2(res);
916 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
918 //rotate to track "local coordinata
919 Float_t x = seed->GetX();
920 Float_t y = seed->GetY();
921 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
924 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
925 if (!seed->Rotate(fSectors->GetAlpha()))
927 } else if (y <-ymax) {
928 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
929 if (!seed->Rotate(-fSectors->GetAlpha()))
937 //_____________________________________________________________________________
938 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
939 Double_t x2,Double_t y2,
940 Double_t x3,Double_t y3)
942 //-----------------------------------------------------------------
943 // Initial approximation of the track curvature
944 //-----------------------------------------------------------------
945 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
946 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
947 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
948 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
949 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
951 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
952 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
953 return -xr*yr/sqrt(xr*xr+yr*yr);
958 //_____________________________________________________________________________
959 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
960 Double_t x2,Double_t y2,
961 Double_t x3,Double_t y3)
963 //-----------------------------------------------------------------
964 // Initial approximation of the track curvature
965 //-----------------------------------------------------------------
971 Double_t det = x3*y2-x2*y3;
976 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
977 Double_t x0 = x3*0.5-y3*u;
978 Double_t y0 = y3*0.5+x3*u;
979 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
985 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
986 Double_t x2,Double_t y2,
987 Double_t x3,Double_t y3)
989 //-----------------------------------------------------------------
990 // Initial approximation of the track curvature
991 //-----------------------------------------------------------------
997 Double_t det = x3*y2-x2*y3;
1002 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1003 Double_t x0 = x3*0.5-y3*u;
1004 Double_t y0 = y3*0.5+x3*u;
1005 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1014 //_____________________________________________________________________________
1015 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1016 Double_t x2,Double_t y2,
1017 Double_t x3,Double_t y3)
1019 //-----------------------------------------------------------------
1020 // Initial approximation of the track curvature times center of curvature
1021 //-----------------------------------------------------------------
1022 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1023 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1024 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1025 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1026 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1028 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1030 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1033 //_____________________________________________________________________________
1034 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1035 Double_t x2,Double_t y2,
1036 Double_t z1,Double_t z2)
1038 //-----------------------------------------------------------------
1039 // Initial approximation of the tangent of the track dip angle
1040 //-----------------------------------------------------------------
1041 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1045 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1046 Double_t x2,Double_t y2,
1047 Double_t z1,Double_t z2, Double_t c)
1049 //-----------------------------------------------------------------
1050 // Initial approximation of the tangent of the track dip angle
1051 //-----------------------------------------------------------------
1055 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1057 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1058 if (TMath::Abs(d*c*0.5)>1) return 0;
1059 // Double_t angle2 = TMath::ASin(d*c*0.5);
1060 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1061 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1063 angle2 = (z1-z2)*c/(angle2*2.);
1067 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1068 {//-----------------------------------------------------------------
1069 // This function find proloncation of a track to a reference plane x=x2.
1070 //-----------------------------------------------------------------
1074 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1078 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1079 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1083 Double_t dy = dx*(c1+c2)/(r1+r2);
1086 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1088 if (TMath::Abs(delta)>0.01){
1089 dz = x[3]*TMath::ASin(delta)/x[4];
1091 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1094 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1102 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1107 return LoadClusters();
1110 Int_t AliTPCtrackerMI::LoadClusters()
1113 // load clusters to the memory
1114 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1115 clrow->SetClass("AliTPCclusterMI");
1117 clrow->GetArray()->ExpandCreateFast(10000);
1119 // TTree * tree = fClustersArray.GetTree();
1121 TTree * tree = fInput;
1122 TBranch * br = tree->GetBranch("Segment");
1123 br->SetAddress(&clrow);
1125 Int_t j=Int_t(tree->GetEntries());
1126 for (Int_t i=0; i<j; i++) {
1130 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1132 AliTPCRow * tpcrow=0;
1135 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1139 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1140 left = (sec-fkNIS*2)/fkNOS;
1143 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1144 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1145 for (Int_t i=0;i<tpcrow->fN1;i++)
1146 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1149 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1150 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1151 for (Int_t i=0;i<tpcrow->fN2;i++)
1152 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1163 void AliTPCtrackerMI::UnloadClusters()
1166 // unload clusters from the memory
1168 Int_t nrows = fOuterSec->GetNRows();
1169 for (Int_t sec = 0;sec<fkNOS;sec++)
1170 for (Int_t row = 0;row<nrows;row++){
1171 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1173 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1174 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1176 tpcrow->ResetClusters();
1179 nrows = fInnerSec->GetNRows();
1180 for (Int_t sec = 0;sec<fkNIS;sec++)
1181 for (Int_t row = 0;row<nrows;row++){
1182 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1184 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1185 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1187 tpcrow->ResetClusters();
1194 //_____________________________________________________________________________
1195 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1196 //-----------------------------------------------------------------
1197 // This function fills outer TPC sectors with clusters.
1198 //-----------------------------------------------------------------
1199 Int_t nrows = fOuterSec->GetNRows();
1201 for (Int_t sec = 0;sec<fkNOS;sec++)
1202 for (Int_t row = 0;row<nrows;row++){
1203 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1204 Int_t sec2 = sec+2*fkNIS;
1206 Int_t ncl = tpcrow->fN1;
1208 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1209 index=(((sec2<<8)+row)<<16)+ncl;
1210 tpcrow->InsertCluster(c,index);
1215 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1216 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1217 tpcrow->InsertCluster(c,index);
1220 // write indexes for fast acces
1222 for (Int_t i=0;i<510;i++)
1223 tpcrow->fFastCluster[i]=-1;
1224 for (Int_t i=0;i<tpcrow->GetN();i++){
1225 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1226 tpcrow->fFastCluster[zi]=i; // write index
1229 for (Int_t i=0;i<510;i++){
1230 if (tpcrow->fFastCluster[i]<0)
1231 tpcrow->fFastCluster[i] = last;
1233 last = tpcrow->fFastCluster[i];
1242 //_____________________________________________________________________________
1243 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1244 //-----------------------------------------------------------------
1245 // This function fills inner TPC sectors with clusters.
1246 //-----------------------------------------------------------------
1247 Int_t nrows = fInnerSec->GetNRows();
1249 for (Int_t sec = 0;sec<fkNIS;sec++)
1250 for (Int_t row = 0;row<nrows;row++){
1251 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1254 Int_t ncl = tpcrow->fN1;
1256 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1257 index=(((sec<<8)+row)<<16)+ncl;
1258 tpcrow->InsertCluster(c,index);
1263 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1264 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1265 tpcrow->InsertCluster(c,index);
1268 // write indexes for fast acces
1270 for (Int_t i=0;i<510;i++)
1271 tpcrow->fFastCluster[i]=-1;
1272 for (Int_t i=0;i<tpcrow->GetN();i++){
1273 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1274 tpcrow->fFastCluster[zi]=i; // write index
1277 for (Int_t i=0;i<510;i++){
1278 if (tpcrow->fFastCluster[i]<0)
1279 tpcrow->fFastCluster[i] = last;
1281 last = tpcrow->fFastCluster[i];
1293 //_________________________________________________________________________
1294 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1295 //--------------------------------------------------------------------
1296 // Return pointer to a given cluster
1297 //--------------------------------------------------------------------
1298 Int_t sec=(index&0xff000000)>>24;
1299 Int_t row=(index&0x00ff0000)>>16;
1300 Int_t ncl=(index&0x00007fff)>>00;
1302 const AliTPCRow * tpcrow=0;
1303 AliTPCclusterMI * clrow =0;
1306 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1307 if (tpcrow==0) return 0;
1310 if (tpcrow->fN1<=ncl) return 0;
1311 clrow = tpcrow->fClusters1;
1314 if (tpcrow->fN2<=ncl) return 0;
1315 clrow = tpcrow->fClusters2;
1319 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1320 if (tpcrow==0) return 0;
1322 if (sec-2*fkNIS<fkNOS) {
1323 if (tpcrow->fN1<=ncl) return 0;
1324 clrow = tpcrow->fClusters1;
1327 if (tpcrow->fN2<=ncl) return 0;
1328 clrow = tpcrow->fClusters2;
1332 return &(clrow[ncl]);
1338 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1339 //-----------------------------------------------------------------
1340 // This function tries to find a track prolongation to next pad row
1341 //-----------------------------------------------------------------
1343 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1344 AliTPCclusterMI *cl=0;
1345 Int_t tpcindex= t.GetClusterIndex2(nr);
1347 // update current shape info every 5 pad-row
1348 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1352 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1354 if (tpcindex==-1) return 0; //track in dead zone
1356 cl = t.fClusterPointer[nr];
1357 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1358 t.fCurrentClusterIndex1 = tpcindex;
1361 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1362 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1364 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1365 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1367 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1368 Double_t rotation = angle-t.GetAlpha();
1369 t.fRelativeSector= relativesector;
1374 t.fCurrentCluster = cl;
1376 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1377 if ((tpcindex&0x8000)==0) accept =0;
1379 //if founded cluster is acceptible
1380 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1387 UpdateTrack(&t,accept);
1392 if (fIteration>1) return 0; // not look for new cluster during refitting
1395 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1396 Double_t y=t.GetYat(x);
1397 if (TMath::Abs(y)>ymax){
1399 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1400 if (!t.Rotate(fSectors->GetAlpha()))
1402 } else if (y <-ymax) {
1403 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1404 if (!t.Rotate(-fSectors->GetAlpha()))
1410 if (!t.PropagateTo(x)) {
1411 if (fIteration==0) t.fRemoval = 10;
1415 Double_t z=t.GetZ();
1417 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1418 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1420 Double_t roadz = 1.;
1422 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1424 t.SetClusterIndex2(nr,-1);
1429 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10)) t.fNFoundable++;
1435 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1436 cl = krow.FindNearest2(y,z,roady,roadz,index);
1437 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1440 t.fCurrentCluster = cl;
1442 if (fIteration==2&&cl->IsUsed(10)) return 0;
1443 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1444 if (fIteration==2&&cl->IsUsed(11)) {
1451 if (t.fCurrentCluster->IsUsed(10)){
1456 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1462 if (accept<3) UpdateTrack(&t,accept);
1465 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1471 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1472 //-----------------------------------------------------------------
1473 // This function tries to find a track prolongation to next pad row
1474 //-----------------------------------------------------------------
1476 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1478 if (!t.GetProlongation(x,y,z)) {
1484 if (TMath::Abs(y)>ymax){
1487 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1488 if (!t.Rotate(fSectors->GetAlpha()))
1490 } else if (y <-ymax) {
1491 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1492 if (!t.Rotate(-fSectors->GetAlpha()))
1495 if (!t.PropagateTo(x)) {
1498 t.GetProlongation(x,y,z);
1501 // update current shape info every 3 pad-row
1502 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1503 // t.fCurrentSigmaY = GetSigmaY(&t);
1504 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1508 AliTPCclusterMI *cl=0;
1513 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1514 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1516 Double_t roadz = 1.;
1519 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1521 t.SetClusterIndex2(row,-1);
1526 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1530 if ((cl==0)&&(krow)) {
1531 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1532 cl = krow.FindNearest2(y,z,roady,roadz,index);
1534 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1538 t.fCurrentCluster = cl;
1539 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1541 t.SetClusterIndex2(row,index);
1542 t.fClusterPointer[row] = cl;
1550 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1551 //-----------------------------------------------------------------
1552 // This function tries to find a track prolongation to next pad row
1553 //-----------------------------------------------------------------
1554 t.fCurrentCluster = 0;
1555 t.fCurrentClusterIndex1 = 0;
1557 Double_t xt=t.GetX();
1558 Int_t row = GetRowNumber(xt)-1;
1559 Double_t ymax= GetMaxY(nr);
1561 if (row < nr) return 1; // don't prolongate if not information until now -
1562 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1564 return 0; // not prolongate strongly inclined tracks
1566 if (TMath::Abs(t.GetSnp())>0.95) {
1568 return 0; // not prolongate strongly inclined tracks
1571 Double_t x= GetXrow(nr);
1573 //t.PropagateTo(x+0.02);
1574 //t.PropagateTo(x+0.01);
1575 if (!t.PropagateTo(x)){
1582 if (TMath::Abs(y)>ymax){
1584 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1585 if (!t.Rotate(fSectors->GetAlpha()))
1587 } else if (y <-ymax) {
1588 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1589 if (!t.Rotate(-fSectors->GetAlpha()))
1592 // if (!t.PropagateTo(x)){
1600 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1602 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1604 t.SetClusterIndex2(nr,-1);
1609 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1615 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1616 // t.fCurrentSigmaY = GetSigmaY(&t);
1617 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1621 AliTPCclusterMI *cl=0;
1624 Double_t roady = 1.;
1625 Double_t roadz = 1.;
1629 index = t.GetClusterIndex2(nr);
1630 if ( (index>0) && (index&0x8000)==0){
1631 cl = t.fClusterPointer[nr];
1632 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1633 t.fCurrentClusterIndex1 = index;
1635 t.fCurrentCluster = cl;
1642 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1643 cl = krow.FindNearest2(y,z,roady,roadz,index);
1646 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1647 t.fCurrentCluster = cl;
1653 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1654 //-----------------------------------------------------------------
1655 // This function tries to find a track prolongation to next pad row
1656 //-----------------------------------------------------------------
1658 //update error according neighborhoud
1660 if (t.fCurrentCluster) {
1662 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1664 if (t.fCurrentCluster->IsUsed(10)){
1670 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1675 if (fIteration>0) accept = 0;
1676 if (accept<3) UpdateTrack(&t,accept);
1680 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1681 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1683 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1691 //_____________________________________________________________________________
1692 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1693 //-----------------------------------------------------------------
1694 // This function tries to find a track prolongation.
1695 //-----------------------------------------------------------------
1696 Double_t xt=t.GetX();
1698 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1699 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1700 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1702 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1704 Int_t first = GetRowNumber(xt)-1;
1705 for (Int_t nr= first; nr>=rf; nr-=step) {
1707 if (t.GetKinkIndexes()[0]>0){
1708 for (Int_t i=0;i<3;i++){
1709 Int_t index = t.GetKinkIndexes()[i];
1710 if (index==0) break;
1711 if (index<0) continue;
1713 AliESDkink * kink = fEvent->GetKink(index-1);
1715 printf("PROBLEM\n");
1718 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1720 AliExternalTrackParam paramd(t);
1721 kink->SetDaughter(paramd);
1722 kink->SetStatus(2,5);
1729 if (nr==80) t.UpdateReference();
1730 if (nr<fInnerSec->GetNRows())
1731 fSectors = fInnerSec;
1733 fSectors = fOuterSec;
1734 if (FollowToNext(t,nr)==0)
1743 //_____________________________________________________________________________
1744 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1745 //-----------------------------------------------------------------
1746 // This function tries to find a track prolongation.
1747 //-----------------------------------------------------------------
1748 Double_t xt=t.GetX();
1750 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1751 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1752 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1753 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1755 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1757 if (FollowToNextFast(t,nr)==0)
1758 if (!t.IsActive()) return 0;
1768 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1769 //-----------------------------------------------------------------
1770 // This function tries to find a track prolongation.
1771 //-----------------------------------------------------------------
1773 Double_t xt=t.GetX();
1774 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1775 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1776 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1777 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1779 Int_t first = t.fFirstPoint;
1780 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1782 if (first<0) first=0;
1783 for (Int_t nr=first; nr<=rf; nr++) {
1784 //if ( (t.GetSnp()<0.9))
1785 if (t.GetKinkIndexes()[0]<0){
1786 for (Int_t i=0;i<3;i++){
1787 Int_t index = t.GetKinkIndexes()[i];
1788 if (index==0) break;
1789 if (index>0) continue;
1790 index = TMath::Abs(index);
1791 AliESDkink * kink = fEvent->GetKink(index-1);
1793 printf("PROBLEM\n");
1796 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1798 AliExternalTrackParam paramm(t);
1799 kink->SetMother(paramm);
1800 kink->SetStatus(2,1);
1807 if (nr<fInnerSec->GetNRows())
1808 fSectors = fInnerSec;
1810 fSectors = fOuterSec;
1820 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1828 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1831 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1833 Float_t distance = TMath::Sqrt(dz2+dy2);
1834 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1837 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1838 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1843 if (firstpoint>lastpoint) {
1844 firstpoint =lastpoint;
1849 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1850 if (s1->GetClusterIndex2(i)>0) sum1++;
1851 if (s2->GetClusterIndex2(i)>0) sum2++;
1852 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1856 if (sum<5) return 0;
1858 Float_t summin = TMath::Min(sum1+1,sum2+1);
1859 Float_t ratio = (sum+1)/Float_t(summin);
1863 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1867 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1868 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1870 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1872 Float_t dy2 =(s1->GetY() - s2->GetY());
1874 Float_t distance = dz2+dy2;
1875 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1880 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1881 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1883 if (firstpoint>=lastpoint-5) return;;
1885 for (Int_t i=firstpoint;i<lastpoint;i++){
1886 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1887 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1894 for (Int_t i=firstpoint;i<lastpoint;i++){
1895 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1896 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1897 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1898 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1899 if (s1->IsActive()&&s2->IsActive()){
1900 p1->fIsShared = kTRUE;
1901 p2->fIsShared = kTRUE;
1908 for (Int_t i=0;i<4;i++){
1909 if (s1->fOverlapLabels[3*i]==0){
1910 s1->fOverlapLabels[3*i] = s2->GetLabel();
1911 s1->fOverlapLabels[3*i+1] = sumshared;
1912 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1916 for (Int_t i=0;i<4;i++){
1917 if (s2->fOverlapLabels[3*i]==0){
1918 s2->fOverlapLabels[3*i] = s1->GetLabel();
1919 s2->fOverlapLabels[3*i+1] = sumshared;
1920 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1928 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1931 //sort trackss according sectors
1933 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1934 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1936 //if (pt) RotateToLocal(pt);
1940 arr->Sort(); // sorting according z
1941 arr->Expand(arr->GetEntries());
1944 Int_t nseed=arr->GetEntriesFast();
1945 for (Int_t i=0; i<nseed; i++) {
1946 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1948 for (Int_t j=0;j<=12;j++){
1949 pt->fOverlapLabels[j] =0;
1952 for (Int_t i=0; i<nseed; i++) {
1953 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1955 if (pt->fRemoval>10) continue;
1956 for (Int_t j=i+1; j<nseed; j++){
1957 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1959 if (pt2->fRemoval<=10) {
1960 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1967 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1970 //sort trackss according sectors
1973 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
1976 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1977 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1982 arr->Sort(); // sorting according z
1983 arr->Expand(arr->GetEntries());
1985 //reset overlap labels
1987 Int_t nseed=arr->GetEntriesFast();
1988 for (Int_t i=0; i<nseed; i++) {
1989 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1992 for (Int_t j=0;j<=12;j++){
1993 pt->fOverlapLabels[j] =0;
1997 //sign shared tracks
1998 for (Int_t i=0; i<nseed; i++) {
1999 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2001 if (pt->fRemoval>10) continue;
2002 Float_t deltac = pt->GetC()*0.1;
2003 for (Int_t j=i+1; j<nseed; j++){
2004 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2006 if (pt2->fRemoval<=10) {
2007 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2008 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2009 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2016 // remove highly shared tracks
2017 for (Int_t i=0; i<nseed; i++) {
2018 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2020 if (pt->fRemoval>10) continue;
2023 for (Int_t j=0;j<4;j++){
2024 sumshared = pt->fOverlapLabels[j*3+1];
2026 Float_t factor = factor1;
2027 if (pt->fRemoval>0) factor = factor2;
2028 if (sumshared/pt->GetNumberOfClusters()>factor){
2029 for (Int_t j=0;j<4;j++){
2030 if (pt->fOverlapLabels[3*j]==0) continue;
2031 if (pt->fOverlapLabels[3*j+1]<5) continue;
2032 if (pt->fRemoval==removalindex) continue;
2033 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2035 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2036 // pt->fRemoval = removalindex;
2037 delete arr->RemoveAt(i);
2045 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2054 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2057 //sort tracks in array according mode criteria
2058 Int_t nseed = arr->GetEntriesFast();
2059 for (Int_t i=0; i<nseed; i++) {
2060 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2070 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2073 //Loop over all tracks and remove "overlaps"
2076 Int_t nseed = arr->GetEntriesFast();
2079 for (Int_t i=0; i<nseed; i++) {
2080 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2082 delete arr->RemoveAt(i);
2086 pt->fBSigned = kFALSE;
2090 nseed = arr->GetEntriesFast();
2097 for (Int_t i=0; i<nseed; i++) {
2098 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2102 Int_t found,foundable,shared;
2104 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2106 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2108 Double_t factor = factor2;
2109 if (pt->fBConstrain) factor = factor1;
2111 if ((Float_t(shared)/Float_t(found))>factor){
2112 pt->Desactivate(removalindex);
2117 for (Int_t i=0; i<160; i++) {
2118 Int_t index=pt->GetClusterIndex2(i);
2119 if (index<0 || index&0x8000 ) continue;
2120 AliTPCclusterMI *c= pt->fClusterPointer[i];
2122 // if (!c->IsUsed(10)) c->Use(10);
2123 //if (pt->IsActive())
2132 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2137 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2140 //Loop over all tracks and remove "overlaps"
2145 Int_t nseed = arr->GetEntriesFast();
2146 Float_t * quality = new Float_t[nseed];
2147 Int_t * indexes = new Int_t[nseed];
2151 for (Int_t i=0; i<nseed; i++) {
2152 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2157 pt->UpdatePoints(); //select first last max dens points
2158 Float_t * points = pt->GetPoints();
2159 if (points[3]<0.8) quality[i] =-1;
2161 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2163 TMath::Sort(nseed,quality,indexes);
2166 for (Int_t itrack=0; itrack<nseed; itrack++) {
2167 Int_t trackindex = indexes[itrack];
2168 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2169 if (quality[trackindex]<0){
2171 delete arr->RemoveAt(trackindex);
2174 arr->RemoveAt(trackindex);
2179 Int_t first = Int_t(pt->GetPoints()[0]);
2180 Int_t last = Int_t(pt->GetPoints()[2]);
2181 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2183 Int_t found,foundable,shared;
2184 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2185 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2187 if (Float_t(shared+1)/Float_t(found+1)>factor){
2188 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2189 delete arr->RemoveAt(trackindex);
2193 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2194 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2195 delete arr->RemoveAt(trackindex);
2200 if (sharedfactor>0.4) continue;
2201 for (Int_t i=first; i<last; i++) {
2202 Int_t index=pt->GetClusterIndex2(i);
2203 // if (index<0 || index&0x8000 ) continue;
2204 if (index<0 || index&0x8000 ) continue;
2205 AliTPCclusterMI *c= pt->fClusterPointer[i];
2212 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2218 void AliTPCtrackerMI::UnsignClusters()
2221 // loop over all clusters and unsign them
2224 for (Int_t sec=0;sec<fkNIS;sec++){
2225 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2226 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2227 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2228 // if (cl[icl].IsUsed(10))
2230 cl = fInnerSec[sec][row].fClusters2;
2231 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2232 //if (cl[icl].IsUsed(10))
2237 for (Int_t sec=0;sec<fkNOS;sec++){
2238 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2239 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2240 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2241 //if (cl[icl].IsUsed(10))
2243 cl = fOuterSec[sec][row].fClusters2;
2244 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2245 //if (cl[icl].IsUsed(10))
2254 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2257 //sign clusters to be "used"
2259 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2260 // loop over "primaries"
2274 Int_t nseed = arr->GetEntriesFast();
2275 for (Int_t i=0; i<nseed; i++) {
2276 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2280 if (!(pt->IsActive())) continue;
2281 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2282 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2284 sumdens2+= dens*dens;
2285 sumn += pt->GetNumberOfClusters();
2286 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2287 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2290 sumchi2 +=chi2*chi2;
2295 Float_t mdensity = 0.9;
2296 Float_t meann = 130;
2297 Float_t meanchi = 1;
2298 Float_t sdensity = 0.1;
2299 Float_t smeann = 10;
2300 Float_t smeanchi =0.4;
2304 mdensity = sumdens/sum;
2306 meanchi = sumchi/sum;
2308 sdensity = sumdens2/sum-mdensity*mdensity;
2309 sdensity = TMath::Sqrt(sdensity);
2311 smeann = sumn2/sum-meann*meann;
2312 smeann = TMath::Sqrt(smeann);
2314 smeanchi = sumchi2/sum - meanchi*meanchi;
2315 smeanchi = TMath::Sqrt(smeanchi);
2319 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2321 for (Int_t i=0; i<nseed; i++) {
2322 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2326 if (pt->fBSigned) continue;
2327 if (pt->fBConstrain) continue;
2328 //if (!(pt->IsActive())) continue;
2330 Int_t found,foundable,shared;
2331 pt->GetClusterStatistic(0,160,found, foundable,shared);
2332 if (shared/float(found)>0.3) {
2333 if (shared/float(found)>0.9 ){
2334 //delete arr->RemoveAt(i);
2339 Bool_t isok =kFALSE;
2340 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2342 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2344 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2346 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2350 for (Int_t i=0; i<160; i++) {
2351 Int_t index=pt->GetClusterIndex2(i);
2352 if (index<0) continue;
2353 AliTPCclusterMI *c= pt->fClusterPointer[i];
2355 //if (!(c->IsUsed(10))) c->Use();
2362 Double_t maxchi = meanchi+2.*smeanchi;
2364 for (Int_t i=0; i<nseed; i++) {
2365 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2369 //if (!(pt->IsActive())) continue;
2370 if (pt->fBSigned) continue;
2371 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2372 if (chi>maxchi) continue;
2375 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2377 //sign only tracks with enoug big density at the beginning
2379 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2382 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2383 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2385 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2386 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2389 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2390 //Int_t noc=pt->GetNumberOfClusters();
2391 pt->fBSigned = kTRUE;
2392 for (Int_t i=0; i<160; i++) {
2394 Int_t index=pt->GetClusterIndex2(i);
2395 if (index<0) continue;
2396 AliTPCclusterMI *c= pt->fClusterPointer[i];
2398 // if (!(c->IsUsed(10))) c->Use();
2403 // gLastCheck = nseed;
2411 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2413 // stop not active tracks
2414 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2415 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2416 Int_t nseed = arr->GetEntriesFast();
2418 for (Int_t i=0; i<nseed; i++) {
2419 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2423 if (!(pt->IsActive())) continue;
2424 StopNotActive(pt,row0,th0, th1,th2);
2430 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2433 // stop not active tracks
2434 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2435 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2438 Int_t foundable = 0;
2439 Int_t maxindex = seed->fLastPoint; //last foundable row
2440 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2441 seed->Desactivate(10) ;
2445 for (Int_t i=row0; i<maxindex; i++){
2446 Int_t index = seed->GetClusterIndex2(i);
2447 if (index!=-1) foundable++;
2449 if (foundable<=30) sumgood1++;
2450 if (foundable<=50) {
2457 if (foundable>=30.){
2458 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2461 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2465 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2468 // back propagation of ESD tracks
2474 //PrepareForProlongation(fSeeds,1);
2475 PropagateForward2(fSeeds);
2477 Int_t nseed = fSeeds->GetEntriesFast();
2478 for (Int_t i=0;i<nseed;i++){
2479 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2480 if (!seed) continue;
2481 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2483 seed->PropagateTo(fParam->GetInnerRadiusLow());
2484 seed->UpdatePoints();
2485 AliESDtrack *esd=event->GetTrack(i);
2486 seed->CookdEdx(0.02,0.6);
2487 CookLabel(seed,0.1); //For comparison only
2488 if (seed->GetNumberOfClusters()>15){
2489 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2490 esd->SetTPCPoints(seed->GetPoints());
2494 //printf("problem\n");
2497 //FindKinks(fSeeds,event);
2498 Info("RefitInward","Number of refitted tracks %d",ntracks);
2505 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2508 // back propagation of ESD tracks
2514 PropagateBack(fSeeds);
2515 Int_t nseed = fSeeds->GetEntriesFast();
2517 for (Int_t i=0;i<nseed;i++){
2518 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2519 if (!seed) continue;
2520 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2521 seed->UpdatePoints();
2522 AliESDtrack *esd=event->GetTrack(i);
2523 seed->CookdEdx(0.02,0.6);
2524 CookLabel(seed,0.1); //For comparison only
2525 if (seed->GetNumberOfClusters()>15){
2526 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2527 esd->SetTPCPoints(seed->GetPoints());
2531 //FindKinks(fSeeds,event);
2532 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2539 void AliTPCtrackerMI::DeleteSeeds()
2543 Int_t nseed = fSeeds->GetEntriesFast();
2544 for (Int_t i=0;i<nseed;i++){
2545 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2546 if (seed) delete fSeeds->RemoveAt(i);
2552 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2555 //read seeds from the event
2557 Int_t nentr=event->GetNumberOfTracks();
2559 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2564 fSeeds = new TObjArray(nentr);
2568 for (Int_t i=0; i<nentr; i++) {
2569 AliESDtrack *esd=event->GetTrack(i);
2570 ULong_t status=esd->GetStatus();
2571 if (!(status&AliESDtrack::kTPCin)) continue;
2572 AliTPCtrack t(*esd);
2573 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2574 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2575 for (Int_t ikink=0;ikink<3;ikink++) {
2576 Int_t index = esd->GetKinkIndex(ikink);
2577 seed->GetKinkIndexes()[ikink] = index;
2578 if (index==0) continue;
2579 index = TMath::Abs(index);
2580 AliESDkink * kink = fEvent->GetKink(index-1);
2581 if (kink&&esd->GetKinkIndex(ikink)<0){
2582 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2583 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2585 if (kink&&esd->GetKinkIndex(ikink)>0){
2586 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2587 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2591 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2592 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2593 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2598 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2599 Double_t par0[5],par1[5],x;
2600 esd->GetInnerExternalParameters(x,par0);
2601 esd->GetExternalParameters(x,par1);
2602 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2603 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2605 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2606 //reset covariance if suspicious
2607 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2608 seed->ResetCovariance();
2613 // rotate to the local coordinate system
2615 fSectors=fInnerSec; fN=fkNIS;
2616 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2617 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2618 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2619 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2620 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2621 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2622 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2623 alpha-=seed->GetAlpha();
2624 if (!seed->Rotate(alpha)) {
2630 for (Int_t irow=0;irow<160;irow++){
2631 Int_t index = seed->GetClusterIndex2(irow);
2634 AliTPCclusterMI * cl = GetClusterMI(index);
2635 seed->fClusterPointer[irow] = cl;
2637 if ((index & 0x8000)==0){
2638 cl->Use(10); // accepted cluster
2640 cl->Use(6); // close cluster not accepted
2643 Info("ReadSeeds","Not found cluster");
2647 fSeeds->AddAt(seed,i);
2653 //_____________________________________________________________________________
2654 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2655 Float_t deltay, Int_t ddsec) {
2656 //-----------------------------------------------------------------
2657 // This function creates track seeds.
2658 // SEEDING WITH VERTEX CONSTRAIN
2659 //-----------------------------------------------------------------
2660 // cuts[0] - fP4 cut
2661 // cuts[1] - tan(phi) cut
2662 // cuts[2] - zvertex cut
2663 // cuts[3] - fP3 cut
2671 Double_t x[5], c[15];
2672 // Int_t di = i1-i2;
2674 AliTPCseed * seed = new AliTPCseed;
2675 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2676 Double_t cs=cos(alpha), sn=sin(alpha);
2678 // Double_t x1 =fOuterSec->GetX(i1);
2679 //Double_t xx2=fOuterSec->GetX(i2);
2681 Double_t x1 =GetXrow(i1);
2682 Double_t xx2=GetXrow(i2);
2684 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2686 Int_t imiddle = (i2+i1)/2; //middle pad row index
2687 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2688 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2692 const AliTPCRow& kr1=GetRow(ns,i1);
2693 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2694 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2697 // change cut on curvature if it can't reach this layer
2698 // maximal curvature set to reach it
2699 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2700 if (dvertexmax*0.5*cuts[0]>0.85){
2701 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2703 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2706 if (deltay>0) ddsec = 0;
2707 // loop over clusters
2708 for (Int_t is=0; is < kr1; is++) {
2710 if (kr1[is]->IsUsed(10)) continue;
2711 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2712 //if (TMath::Abs(y1)>ymax) continue;
2714 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2716 // find possible directions
2717 Float_t anglez = (z1-z3)/(x1-x3);
2718 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2721 //find rotation angles relative to line given by vertex and point 1
2722 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2723 Double_t dvertex = TMath::Sqrt(dvertex2);
2724 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2725 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2728 // loop over 2 sectors
2734 Double_t dddz1=0; // direction of delta inclination in z axis
2741 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2742 Int_t sec2 = sec + dsec;
2744 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2745 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2746 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2747 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2748 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2749 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2751 // rotation angles to p1-p3
2752 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2753 Double_t x2, y2, z2;
2755 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2758 Double_t dxx0 = (xx2-x3)*cs13r;
2759 Double_t dyy0 = (xx2-x3)*sn13r;
2760 for (Int_t js=index1; js < index2; js++) {
2761 const AliTPCclusterMI *kcl = kr2[js];
2762 if (kcl->IsUsed(10)) continue;
2764 //calcutate parameters
2766 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2768 if (TMath::Abs(yy0)<0.000001) continue;
2769 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2770 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2771 Double_t r02 = (0.25+y0*y0)*dvertex2;
2772 //curvature (radius) cut
2773 if (r02<r2min) continue;
2777 Double_t c0 = 1/TMath::Sqrt(r02);
2781 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2782 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2783 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2784 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2787 Double_t z0 = kcl->GetZ();
2788 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2789 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2792 Double_t dip = (z1-z0)*c0/dfi1;
2793 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2804 x2= xx2*cs-y2*sn*dsec;
2805 y2=+xx2*sn*dsec+y2*cs;
2815 // do we have cluster at the middle ?
2817 GetProlongation(x1,xm,x,ym,zm);
2819 AliTPCclusterMI * cm=0;
2820 if (TMath::Abs(ym)-ymaxm<0){
2821 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2822 if ((!cm) || (cm->IsUsed(10))) {
2827 // rotate y1 to system 0
2828 // get state vector in rotated system
2829 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2830 Double_t xr2 = x0*cs+yr1*sn*dsec;
2831 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2833 GetProlongation(xx2,xm,xr,ym,zm);
2834 if (TMath::Abs(ym)-ymaxm<0){
2835 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2836 if ((!cm) || (cm->IsUsed(10))) {
2846 dym = ym - cm->GetY();
2847 dzm = zm - cm->GetZ();
2854 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2855 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2856 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2857 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2858 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2860 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2861 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2862 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2863 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2864 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2865 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2867 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2868 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2869 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2870 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2874 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2875 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2876 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2877 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2878 c[13]=f30*sy1*f40+f32*sy2*f42;
2879 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2881 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2883 UInt_t index=kr1.GetIndex(is);
2884 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2886 track->fIsSeeding = kTRUE;
2893 FollowProlongation(*track, (i1+i2)/2,1);
2894 Int_t foundable,found,shared;
2895 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2896 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2898 seed->~AliTPCseed();
2904 FollowProlongation(*track, i2,1);
2908 track->fBConstrain =1;
2909 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2910 track->fLastPoint = i1; // first cluster in track position
2911 track->fFirstPoint = track->fLastPoint;
2913 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2914 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2915 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2917 seed->~AliTPCseed();
2921 // Z VERTEX CONDITION
2923 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2924 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2925 if (TMath::Abs(zv-z3)>cuts[2]) {
2926 FollowProlongation(*track, TMath::Max(i2-20,0));
2927 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2928 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2929 if (TMath::Abs(zv-z3)>cuts[2]){
2930 FollowProlongation(*track, TMath::Max(i2-40,0));
2931 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2932 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2933 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2934 // make seed without constrain
2935 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2936 FollowProlongation(*track2, i2,1);
2937 track2->fBConstrain = kFALSE;
2938 track2->fSeedType = 1;
2939 arr->AddLast(track2);
2941 seed->~AliTPCseed();
2946 seed->~AliTPCseed();
2953 track->fSeedType =0;
2954 arr->AddLast(track);
2955 seed = new AliTPCseed;
2957 // don't consider other combinations
2958 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2964 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2970 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2975 //-----------------------------------------------------------------
2976 // This function creates track seeds.
2977 //-----------------------------------------------------------------
2978 // cuts[0] - fP4 cut
2979 // cuts[1] - tan(phi) cut
2980 // cuts[2] - zvertex cut
2981 // cuts[3] - fP3 cut
2991 Double_t x[5], c[15];
2993 // make temporary seed
2994 AliTPCseed * seed = new AliTPCseed;
2995 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2996 // Double_t cs=cos(alpha), sn=sin(alpha);
3001 Double_t x1 = GetXrow(i1-1);
3002 const AliTPCRow& kr1=GetRow(sec,i1-1);
3003 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3005 Double_t x1p = GetXrow(i1);
3006 const AliTPCRow& kr1p=GetRow(sec,i1);
3008 Double_t x1m = GetXrow(i1-2);
3009 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3012 //last 3 padrow for seeding
3013 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3014 Double_t x3 = GetXrow(i1-7);
3015 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3017 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3018 Double_t x3p = GetXrow(i1-6);
3020 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3021 Double_t x3m = GetXrow(i1-8);
3026 Int_t im = i1-4; //middle pad row index
3027 Double_t xm = GetXrow(im); // radius of middle pad-row
3028 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3029 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3032 Double_t deltax = x1-x3;
3033 Double_t dymax = deltax*cuts[1];
3034 Double_t dzmax = deltax*cuts[3];
3036 // loop over clusters
3037 for (Int_t is=0; is < kr1; is++) {
3039 if (kr1[is]->IsUsed(10)) continue;
3040 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3042 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3044 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3045 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3051 for (Int_t js=index1; js < index2; js++) {
3052 const AliTPCclusterMI *kcl = kr3[js];
3053 if (kcl->IsUsed(10)) continue;
3055 // apply angular cuts
3056 if (TMath::Abs(y1-y3)>dymax) continue;
3059 if (TMath::Abs(z1-z3)>dzmax) continue;
3061 Double_t angley = (y1-y3)/(x1-x3);
3062 Double_t anglez = (z1-z3)/(x1-x3);
3064 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3065 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3067 Double_t yyym = angley*(xm-x1)+y1;
3068 Double_t zzzm = anglez*(xm-x1)+z1;
3070 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3072 if (kcm->IsUsed(10)) continue;
3074 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3075 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3082 // look around first
3083 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3089 if (kc1m->IsUsed(10)) used++;
3091 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3097 if (kc1p->IsUsed(10)) used++;
3099 if (used>1) continue;
3100 if (found<1) continue;
3104 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3110 if (kc3m->IsUsed(10)) used++;
3114 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3120 if (kc3p->IsUsed(10)) used++;
3124 if (used>1) continue;
3125 if (found<3) continue;
3135 x[4]=F1(x1,y1,x2,y2,x3,y3);
3136 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3139 x[2]=F2(x1,y1,x2,y2,x3,y3);
3142 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3143 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3147 Double_t sy1=0.1, sz1=0.1;
3148 Double_t sy2=0.1, sz2=0.1;
3149 Double_t sy3=0.1, sy=0.1, sz=0.1;
3151 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3152 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3153 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3154 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3155 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3156 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3158 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3159 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3160 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3161 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3165 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3166 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3167 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3168 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3169 c[13]=f30*sy1*f40+f32*sy2*f42;
3170 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3172 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3174 UInt_t index=kr1.GetIndex(is);
3175 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3177 track->fIsSeeding = kTRUE;
3180 FollowProlongation(*track, i1-7,1);
3181 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3182 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3184 seed->~AliTPCseed();
3190 FollowProlongation(*track, i2,1);
3191 track->fBConstrain =0;
3192 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3193 track->fFirstPoint = track->fLastPoint;
3195 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3196 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3197 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3199 seed->~AliTPCseed();
3204 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3205 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3206 FollowProlongation(*track2, i2,1);
3207 track2->fBConstrain = kFALSE;
3208 track2->fSeedType = 4;
3209 arr->AddLast(track2);
3211 seed->~AliTPCseed();
3215 //arr->AddLast(track);
3216 //seed = new AliTPCseed;
3222 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3228 //_____________________________________________________________________________
3229 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3230 Float_t deltay, Bool_t /*bconstrain*/) {
3231 //-----------------------------------------------------------------
3232 // This function creates track seeds - without vertex constraint
3233 //-----------------------------------------------------------------
3234 // cuts[0] - fP4 cut - not applied
3235 // cuts[1] - tan(phi) cut
3236 // cuts[2] - zvertex cut - not applied
3237 // cuts[3] - fP3 cut
3247 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3248 // Double_t cs=cos(alpha), sn=sin(alpha);
3249 Int_t row0 = (i1+i2)/2;
3250 Int_t drow = (i1-i2)/2;
3251 const AliTPCRow& kr0=fSectors[sec][row0];
3254 AliTPCpolyTrack polytrack;
3255 Int_t nclusters=fSectors[sec][row0];
3256 AliTPCseed * seed = new AliTPCseed;
3261 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3263 Int_t nfoundable =0;
3264 for (Int_t iter =1; iter<2; iter++){ //iterations
3265 const AliTPCRow& krm=fSectors[sec][row0-iter];
3266 const AliTPCRow& krp=fSectors[sec][row0+iter];
3267 const AliTPCclusterMI * cl= kr0[is];
3269 if (cl->IsUsed(10)) {
3275 Double_t x = kr0.GetX();
3276 // Initialization of the polytrack
3281 Double_t y0= cl->GetY();
3282 Double_t z0= cl->GetZ();
3286 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3287 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3289 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3290 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3291 polytrack.AddPoint(x,y0,z0,erry, errz);
3294 if (cl->IsUsed(10)) sumused++;
3297 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3298 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3301 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3302 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3303 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3304 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3305 if (cl1->IsUsed(10)) sumused++;
3306 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3310 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3312 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3313 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3314 if (cl2->IsUsed(10)) sumused++;
3315 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3318 if (sumused>0) continue;
3320 polytrack.UpdateParameters();
3326 nfoundable = polytrack.GetN();
3327 nfound = nfoundable;
3329 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3330 Float_t maxdist = 0.8*(1.+3./(ddrow));
3331 for (Int_t delta = -1;delta<=1;delta+=2){
3332 Int_t row = row0+ddrow*delta;
3333 kr = &(fSectors[sec][row]);
3334 Double_t xn = kr->GetX();
3335 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3336 polytrack.GetFitPoint(xn,yn,zn);
3337 if (TMath::Abs(yn)>ymax) continue;
3339 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3341 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3344 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3345 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3346 if (cln->IsUsed(10)) {
3347 // printf("used\n");
3355 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3360 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3361 polytrack.UpdateParameters();
3364 if ( (sumused>3) || (sumused>0.5*nfound)) {
3365 //printf("sumused %d\n",sumused);
3370 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3371 AliTPCpolyTrack track2;
3373 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3374 if (track2.GetN()<0.5*nfoundable) continue;
3377 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3379 // test seed with and without constrain
3380 for (Int_t constrain=0; constrain<=0;constrain++){
3381 // add polytrack candidate
3383 Double_t x[5], c[15];
3384 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3385 track2.GetBoundaries(x3,x1);
3387 track2.GetFitPoint(x1,y1,z1);
3388 track2.GetFitPoint(x2,y2,z2);
3389 track2.GetFitPoint(x3,y3,z3);
3391 //is track pointing to the vertex ?
3394 polytrack.GetFitPoint(x0,y0,z0);
3407 x[4]=F1(x1,y1,x2,y2,x3,y3);
3409 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3410 x[2]=F2(x1,y1,x2,y2,x3,y3);
3412 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3413 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3414 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3415 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3418 Double_t sy =0.1, sz =0.1;
3419 Double_t sy1=0.02, sz1=0.02;
3420 Double_t sy2=0.02, sz2=0.02;
3424 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3427 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3428 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3429 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3430 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3431 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3432 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3434 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3435 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3436 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3437 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3442 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3443 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3444 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3445 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3446 c[13]=f30*sy1*f40+f32*sy2*f42;
3447 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3449 //Int_t row1 = fSectors->GetRowNumber(x1);
3450 Int_t row1 = GetRowNumber(x1);
3454 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3455 track->fIsSeeding = kTRUE;
3456 Int_t rc=FollowProlongation(*track, i2);
3457 if (constrain) track->fBConstrain =1;
3459 track->fBConstrain =0;
3460 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3461 track->fFirstPoint = track->fLastPoint;
3463 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3464 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3465 track->fNShared>0.4*track->GetNumberOfClusters()) {
3468 seed->~AliTPCseed();
3471 arr->AddLast(track);
3472 seed = new AliTPCseed;
3476 } // if accepted seed
3479 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3485 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3489 //reseed using track points
3490 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3491 Int_t p1 = int(r1*track->GetNumberOfClusters());
3492 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3494 Double_t x0[3],x1[3],x2[3];
3499 // find track position at given ratio of the length
3500 Int_t sec0, sec1, sec2;
3506 for (Int_t i=0;i<160;i++){
3507 if (track->fClusterPointer[i]){
3509 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3510 if ( (index<p0) || x0[0]<0 ){
3511 if (trpoint->GetX()>1){
3512 clindex = track->GetClusterIndex2(i);
3514 x0[0] = trpoint->GetX();
3515 x0[1] = trpoint->GetY();
3516 x0[2] = trpoint->GetZ();
3517 sec0 = ((clindex&0xff000000)>>24)%18;
3522 if ( (index<p1) &&(trpoint->GetX()>1)){
3523 clindex = track->GetClusterIndex2(i);
3525 x1[0] = trpoint->GetX();
3526 x1[1] = trpoint->GetY();
3527 x1[2] = trpoint->GetZ();
3528 sec1 = ((clindex&0xff000000)>>24)%18;
3531 if ( (index<p2) &&(trpoint->GetX()>1)){
3532 clindex = track->GetClusterIndex2(i);
3534 x2[0] = trpoint->GetX();
3535 x2[1] = trpoint->GetY();
3536 x2[2] = trpoint->GetZ();
3537 sec2 = ((clindex&0xff000000)>>24)%18;
3544 Double_t alpha, cs,sn, xx2,yy2;
3546 alpha = (sec1-sec2)*fSectors->GetAlpha();
3547 cs = TMath::Cos(alpha);
3548 sn = TMath::Sin(alpha);
3549 xx2= x1[0]*cs-x1[1]*sn;
3550 yy2= x1[0]*sn+x1[1]*cs;
3554 alpha = (sec0-sec2)*fSectors->GetAlpha();
3555 cs = TMath::Cos(alpha);
3556 sn = TMath::Sin(alpha);
3557 xx2= x0[0]*cs-x0[1]*sn;
3558 yy2= x0[0]*sn+x0[1]*cs;
3564 Double_t x[5],c[15];
3568 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3569 // if (x[4]>1) return 0;
3570 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3571 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3572 //if (TMath::Abs(x[3]) > 2.2) return 0;
3573 //if (TMath::Abs(x[2]) > 1.99) return 0;
3575 Double_t sy =0.1, sz =0.1;
3577 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3578 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3579 Double_t sy3=0.01+track->GetSigmaY2();
3581 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3582 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3583 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3584 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3585 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3586 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3588 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3589 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3590 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3591 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3596 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3597 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3598 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3599 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3600 c[13]=f30*sy1*f40+f32*sy2*f42;
3601 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3603 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3604 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3605 // Double_t y0,z0,y1,z1, y2,z2;
3606 //seed->GetProlongation(x0[0],y0,z0);
3607 // seed->GetProlongation(x1[0],y1,z1);
3608 //seed->GetProlongation(x2[0],y2,z2);
3610 seed->fLastPoint = pp2;
3611 seed->fFirstPoint = pp2;
3618 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)