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 //-------------------------------------------------------
35 #include "Riostream.h"
36 #include <TClonesArray.h>
38 #include <TObjArray.h>
41 #include "AliComplexCluster.h"
44 #include "AliRunLoader.h"
45 #include "AliTPCClustersRow.h"
46 #include "AliTPCParam.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCtrackerMI.h"
51 #include "TStopwatch.h"
53 #include "AliTPCReconstructor.h"
57 ClassImp(AliTPCtrackerMI)
60 class AliTPCFastMath {
63 static Double_t FastAsin(Double_t x);
65 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
68 Double_t AliTPCFastMath::fgFastAsin[20000];
69 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
71 AliTPCFastMath::AliTPCFastMath(){
73 // initialized lookup table;
74 for (Int_t i=0;i<10000;i++){
75 fgFastAsin[2*i] = TMath::ASin(i/10000.);
76 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
80 Double_t AliTPCFastMath::FastAsin(Double_t x){
82 // return asin using lookup table
84 Int_t index = int(x*10000);
85 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
88 Int_t index = int(x*10000);
89 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
95 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
97 //update track information using current cluster - track->fCurrentCluster
100 AliTPCclusterMI* c =track->fCurrentCluster;
101 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
103 UInt_t i = track->fCurrentClusterIndex1;
105 Int_t sec=(i&0xff000000)>>24;
106 //Int_t row = (i&0x00ff0000)>>16;
107 track->fRow=(i&0x00ff0000)>>16;
108 track->fSector = sec;
109 // Int_t index = i&0xFFFF;
110 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
111 track->SetClusterIndex2(track->fRow, i);
112 //track->fFirstPoint = row;
113 //if ( track->fLastPoint<row) track->fLastPoint =row;
114 // if (track->fRow<0 || track->fRow>160) {
115 // printf("problem\n");
117 if (track->fFirstPoint>track->fRow)
118 track->fFirstPoint = track->fRow;
119 if (track->fLastPoint<track->fRow)
120 track->fLastPoint = track->fRow;
123 track->fClusterPointer[track->fRow] = c;
126 Float_t angle2 = track->GetSnp()*track->GetSnp();
127 angle2 = TMath::Sqrt(angle2/(1-angle2));
129 //SET NEW Track Point
133 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
135 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
136 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
137 point.SetErrY(sqrt(track->fErrorY2));
138 point.SetErrZ(sqrt(track->fErrorZ2));
140 point.SetX(track->GetX());
141 point.SetY(track->GetY());
142 point.SetZ(track->GetZ());
143 point.SetAngleY(angle2);
144 point.SetAngleZ(track->GetTgl());
145 if (point.fIsShared){
146 track->fErrorY2 *= 4;
147 track->fErrorZ2 *= 4;
151 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
153 track->fErrorY2 *= 1.3;
154 track->fErrorY2 += 0.01;
155 track->fErrorZ2 *= 1.3;
156 track->fErrorZ2 += 0.005;
158 if (accept>0) return 0;
159 if (track->GetNumberOfClusters()%20==0){
160 // if (track->fHelixIn){
161 // TClonesArray & larr = *(track->fHelixIn);
162 // Int_t ihelix = larr.GetEntriesFast();
163 // new(larr[ihelix]) AliHelix(*track) ;
166 track->fNoCluster =0;
167 return track->Update(c,chi2,i);
172 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
173 Float_t cory, Float_t corz)
176 // decide according desired precision to accept given
177 // cluster for tracking
178 Double_t sy2=ErrY2(seed,cluster)*cory;
179 Double_t sz2=ErrZ2(seed,cluster)*corz;
180 //sy2=ErrY2(seed,cluster)*cory;
181 //sz2=ErrZ2(seed,cluster)*cory;
183 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
184 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
186 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
187 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
188 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
189 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
191 Double_t rdistance2 = rdistancey2+rdistancez2;
194 if (rdistance2>16) return 3;
197 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
198 return 2; //suspisiouce - will be changed
200 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
201 // strict cut on overlaped cluster
202 return 2; //suspisiouce - will be changed
204 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
205 && cluster->GetType()<0){
215 //_____________________________________________________________________________
216 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
217 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
219 //---------------------------------------------------------------------
220 // The main TPC tracker constructor
221 //---------------------------------------------------------------------
222 fInnerSec=new AliTPCSector[fkNIS];
223 fOuterSec=new AliTPCSector[fkNOS];
226 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
227 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
234 Int_t nrowlow = par->GetNRowLow();
235 Int_t nrowup = par->GetNRowUp();
238 for (Int_t i=0;i<nrowlow;i++){
239 fXRow[i] = par->GetPadRowRadiiLow(i);
240 fPadLength[i]= par->GetPadPitchLength(0,i);
241 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
245 for (Int_t i=0;i<nrowup;i++){
246 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
247 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
248 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
260 //________________________________________________________________________
261 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
266 //------------------------------------
267 // dummy copy constructor
268 //------------------------------------------------------------------
270 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
271 //------------------------------
273 //--------------------------------------------------------------
276 //_____________________________________________________________________________
277 AliTPCtrackerMI::~AliTPCtrackerMI() {
278 //------------------------------------------------------------------
279 // TPC tracker destructor
280 //------------------------------------------------------------------
289 void AliTPCtrackerMI::SetIO()
293 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
295 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
297 AliTPCtrack *iotrack= new AliTPCtrack;
298 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
304 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
320 AliTPCtrack *iotrack= new AliTPCtrack;
321 // iotrack->fHelixIn = new TClonesArray("AliHelix");
322 //iotrack->fHelixOut = new TClonesArray("AliHelix");
323 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
326 if (output && (fDebug&2)){
327 //write the full seed information if specified in debug mode
329 fSeedTree = new TTree("Seeds","Seeds");
330 AliTPCseed * vseed = new AliTPCseed;
332 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
333 arrtr->ExpandCreateFast(160);
334 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
336 vseed->fPoints = arrtr;
337 vseed->fEPoints = arre;
338 // vseed->fClusterPoints = arrcl;
339 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
342 fTreeDebug = new TTree("trackDebug","trackDebug");
343 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
344 fTreeDebug->Branch("debug",&arrd,32000,99);
352 void AliTPCtrackerMI::FillESD(TObjArray* arr)
356 //fill esds using updated tracks
358 // write tracks to the event
359 // store index of the track
360 Int_t nseed=arr->GetEntriesFast();
361 for (Int_t i=0; i<nseed; i++) {
362 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
364 pt->PropagateTo(fParam->GetInnerRadiusLow());
365 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
367 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
368 //iotrack.SetTPCindex(i);
369 fEvent->AddTrack(&iotrack);
375 void AliTPCtrackerMI::WriteTracks(TTree * tree)
378 // write tracks from seed array to selected tree
382 AliTPCtrack *iotrack= new AliTPCtrack;
383 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
388 void AliTPCtrackerMI::WriteTracks()
391 // write tracks to the given output tree -
392 // output specified with SetIO routine
399 AliTPCtrack *iotrack= 0;
400 Int_t nseed=fSeeds->GetEntriesFast();
401 //for (Int_t i=0; i<nseed; i++) {
402 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
403 // if (iotrack) break;
405 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
406 TBranch * br = fOutput->GetBranch("tracks");
407 br->SetAddress(&iotrack);
409 for (Int_t i=0; i<nseed; i++) {
410 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
412 AliTPCtrack * track = new AliTPCtrack(*pt);
415 // br->SetAddress(&iotrack);
420 //fOutput->GetDirectory()->cd();
426 //write the full seed information if specified in debug mode
428 AliTPCseed * vseed = new AliTPCseed;
430 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
431 arrtr->ExpandCreateFast(160);
432 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
433 //arrcl->ExpandCreateFast(160);
434 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
436 vseed->fPoints = arrtr;
437 vseed->fEPoints = arre;
438 // vseed->fClusterPoints = arrcl;
439 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
440 TBranch * brseed = fSeedTree->GetBranch("seeds");
442 Int_t nseed=fSeeds->GetEntriesFast();
444 for (Int_t i=0; i<nseed; i++) {
445 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
448 // pt->fClusterPoints = arrcl;
452 brseed->SetAddress(&vseed);
456 // pt->fClusterPoints = 0;
459 if (fTreeDebug) fTreeDebug->Write();
467 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
470 //seed->SetErrorY2(0.1);
472 //calculate look-up table at the beginning
473 static Bool_t ginit = kFALSE;
474 static Float_t gnoise1,gnoise2,gnoise3;
475 static Float_t ggg1[10000];
476 static Float_t ggg2[10000];
477 static Float_t ggg3[10000];
478 static Float_t glandau1[10000];
479 static Float_t glandau2[10000];
480 static Float_t glandau3[10000];
482 static Float_t gcor01[500];
483 static Float_t gcor02[500];
484 static Float_t gcorp[500];
489 for (Int_t i=1;i<500;i++){
490 Float_t rsigma = float(i)/100.;
491 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
492 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
493 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
497 for (Int_t i=3;i<10000;i++){
501 Float_t amp = float(i);
502 Float_t padlength =0.75;
503 gnoise1 = 0.0004/padlength;
504 Float_t nel = 0.268*amp;
505 Float_t nprim = 0.155*amp;
506 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
507 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
508 if (glandau1[i]>1) glandau1[i]=1;
509 glandau1[i]*=padlength*padlength/12.;
513 gnoise2 = 0.0004/padlength;
516 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
517 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
518 if (glandau2[i]>1) glandau2[i]=1;
519 glandau2[i]*=padlength*padlength/12.;
524 gnoise3 = 0.0004/padlength;
527 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
528 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
529 if (glandau3[i]>1) glandau3[i]=1;
530 glandau3[i]*=padlength*padlength/12.;
538 Int_t amp = int(TMath::Abs(cl->GetQ()));
540 seed->SetErrorY2(1.);
544 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
545 Int_t ctype = cl->GetType();
546 Float_t padlength= GetPadPitchLength(seed->fRow);
547 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
548 angle2 = angle2/(1-angle2);
551 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
554 if (fSectors==fInnerSec){
556 res = ggg1[amp]*z+glandau1[amp]*angle2;
557 if (ctype==0) res *= gcor01[rsigmay];
560 res*= gcorp[rsigmay];
566 res = ggg2[amp]*z+glandau2[amp]*angle2;
567 if (ctype==0) res *= gcor02[rsigmay];
570 res*= gcorp[rsigmay];
575 res = ggg3[amp]*z+glandau3[amp]*angle2;
576 if (ctype==0) res *= gcor02[rsigmay];
579 res*= gcorp[rsigmay];
586 res*=2.4; // overestimate error 2 times
593 seed->SetErrorY2(res);
601 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
604 //seed->SetErrorY2(0.1);
606 //calculate look-up table at the beginning
607 static Bool_t ginit = kFALSE;
608 static Float_t gnoise1,gnoise2,gnoise3;
609 static Float_t ggg1[10000];
610 static Float_t ggg2[10000];
611 static Float_t ggg3[10000];
612 static Float_t glandau1[10000];
613 static Float_t glandau2[10000];
614 static Float_t glandau3[10000];
616 static Float_t gcor01[1000];
617 static Float_t gcor02[1000];
618 static Float_t gcorp[1000];
623 for (Int_t i=1;i<1000;i++){
624 Float_t rsigma = float(i)/100.;
625 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
626 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
627 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
631 for (Int_t i=3;i<10000;i++){
635 Float_t amp = float(i);
636 Float_t padlength =0.75;
637 gnoise1 = 0.0004/padlength;
638 Float_t nel = 0.268*amp;
639 Float_t nprim = 0.155*amp;
640 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
641 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
642 if (glandau1[i]>1) glandau1[i]=1;
643 glandau1[i]*=padlength*padlength/12.;
647 gnoise2 = 0.0004/padlength;
650 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
651 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
652 if (glandau2[i]>1) glandau2[i]=1;
653 glandau2[i]*=padlength*padlength/12.;
658 gnoise3 = 0.0004/padlength;
661 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
662 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
663 if (glandau3[i]>1) glandau3[i]=1;
664 glandau3[i]*=padlength*padlength/12.;
672 Int_t amp = int(TMath::Abs(cl->GetQ()));
674 seed->SetErrorY2(1.);
678 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
679 Int_t ctype = cl->GetType();
680 Float_t padlength= GetPadPitchLength(seed->fRow);
682 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
683 // if (angle2<0.6) angle2 = 0.6;
684 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
687 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
690 if (fSectors==fInnerSec){
692 res = ggg1[amp]*z+glandau1[amp]*angle2;
693 if (ctype==0) res *= gcor01[rsigmaz];
696 res*= gcorp[rsigmaz];
702 res = ggg2[amp]*z+glandau2[amp]*angle2;
703 if (ctype==0) res *= gcor02[rsigmaz];
706 res*= gcorp[rsigmaz];
711 res = ggg3[amp]*z+glandau3[amp]*angle2;
712 if (ctype==0) res *= gcor02[rsigmaz];
715 res*= gcorp[rsigmaz];
724 if ((ctype<0) &&<70){
732 seed->SetErrorZ2(res);
739 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
742 //seed->SetErrorZ2(0.1);
746 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
748 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
749 Int_t ctype = cl->GetType();
750 Float_t amp = TMath::Abs(cl->GetQ());
755 Float_t landau=2 ; //landau fluctuation part
756 Float_t gg=2; // gg fluctuation part
757 Float_t padlength= GetPadPitchLength(seed->GetX());
759 if (fSectors==fInnerSec){
760 snoise2 = 0.0004/padlength;
763 gg = (2+0.001*nel/(padlength*padlength))/nel;
764 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
765 if (landau>1) landau=1;
768 snoise2 = 0.0004/padlength;
771 gg = (2+0.0008*nel/(padlength*padlength))/nel;
772 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
773 if (landau>1) landau=1;
775 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
778 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
779 angle2 = TMath::Sqrt((1-angle2));
780 if (angle2<0.6) angle2 = 0.6;
783 Float_t angle = seed->GetTgl()/angle2;
784 Float_t angular = landau*angle*angle*padlength*padlength/12.;
785 Float_t res = sdiff + angular;
788 if ((ctype==0) && (fSectors ==fOuterSec))
789 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
791 if ((ctype==0) && (fSectors ==fInnerSec))
792 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
796 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
802 if ((ctype<0) &&<70){
810 seed->SetErrorZ2(res);
817 void AliTPCseed::Reset(Bool_t all)
821 SetNumberOfClusters(0);
827 for (Int_t i=0;i<8;i++){
828 delete [] fTrackPoints[i];
836 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
837 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
843 void AliTPCseed::Modify(Double_t factor)
846 //------------------------------------------------------------------
847 //This function makes a track forget its history :)
848 //------------------------------------------------------------------
854 fC10*=0; fC11*=factor;
855 fC20*=0; fC21*=0; fC22*=factor;
856 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
857 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
858 SetNumberOfClusters(0);
862 fCurrentSigmaY2 = 0.000005;
863 fCurrentSigmaZ2 = 0.000005;
872 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
874 //-----------------------------------------------------------------
875 // This function find proloncation of a track to a reference plane x=xk.
876 // doesn't change internal state of the track
877 //-----------------------------------------------------------------
879 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
881 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
885 // Double_t y1=fP0, z1=fP1;
886 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
887 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
891 //y += dx*(c1+c2)/(r1+r2);
892 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
894 Double_t dy = dx*(c1+c2)/(r1+r2);
897 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
899 if (TMath::Abs(delta)>0.0001){
900 dz = fP3*TMath::ASin(delta)/fP4;
902 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
905 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
915 //_____________________________________________________________________________
916 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
918 //-----------------------------------------------------------------
919 // This function calculates a predicted chi2 increment.
920 //-----------------------------------------------------------------
921 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
922 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
923 r00+=fC00; r01+=fC10; r11+=fC11;
925 Double_t det=r00*r11 - r01*r01;
926 if (TMath::Abs(det) < 1.e-10) {
927 Int_t n=GetNumberOfClusters();
928 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
931 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
933 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
935 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
939 //_________________________________________________________________________________________
942 Int_t AliTPCseed::Compare(const TObject *o) const {
943 //-----------------------------------------------------------------
944 // This function compares tracks according to the sector - for given sector according z
945 //-----------------------------------------------------------------
946 AliTPCseed *t=(AliTPCseed*)o;
949 if (t->fRelativeSector>fRelativeSector) return -1;
950 if (t->fRelativeSector<fRelativeSector) return 1;
951 Double_t z2 = t->GetZ();
952 Double_t z1 = GetZ();
954 if (z2<z1) return -1;
959 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
960 if (t->fBConstrain) f2=1.2;
963 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
965 if (fBConstrain) f1=1.2;
967 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
972 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
974 //rotate to track "local coordinata
975 Float_t x = seed->GetX();
976 Float_t y = seed->GetY();
977 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
980 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
981 if (!seed->Rotate(fSectors->GetAlpha()))
983 } else if (y <-ymax) {
984 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
985 if (!seed->Rotate(-fSectors->GetAlpha()))
994 //_____________________________________________________________________________
995 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
996 //-----------------------------------------------------------------
997 // This function associates a cluster with this track.
998 //-----------------------------------------------------------------
999 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
1001 r00+=fC00; r01+=fC10; r11+=fC11;
1002 Double_t det=r00*r11 - r01*r01;
1003 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
1005 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
1006 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
1007 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
1008 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
1009 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
1011 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
1012 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
1013 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1017 fP0 += k00*dy + k01*dz;
1018 fP1 += k10*dy + k11*dz;
1020 fP3 += k30*dy + k31*dz;
1023 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1024 Double_t c12=fC21, c13=fC31, c14=fC41;
1026 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1027 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1028 fC40-=k00*c04+k01*c14;
1030 fC11-=k10*c01+k11*fC11;
1031 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1032 fC41-=k10*c04+k11*c14;
1034 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1035 fC42-=k20*c04+k21*c14;
1037 fC33-=k30*c03+k31*c13;
1038 fC43-=k40*c03+k41*c13;
1040 fC44-=k40*c04+k41*c14;
1042 Int_t n=GetNumberOfClusters();
1044 SetNumberOfClusters(n+1);
1045 SetChi2(GetChi2()+chisq);
1052 //_____________________________________________________________________________
1053 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1054 Double_t x2,Double_t y2,
1055 Double_t x3,Double_t y3)
1057 //-----------------------------------------------------------------
1058 // Initial approximation of the track curvature
1059 //-----------------------------------------------------------------
1060 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1061 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1062 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1063 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1064 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1066 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1067 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1068 return -xr*yr/sqrt(xr*xr+yr*yr);
1073 //_____________________________________________________________________________
1074 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1075 Double_t x2,Double_t y2,
1076 Double_t x3,Double_t y3)
1078 //-----------------------------------------------------------------
1079 // Initial approximation of the track curvature
1080 //-----------------------------------------------------------------
1086 Double_t det = x3*y2-x2*y3;
1091 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1092 Double_t x0 = x3*0.5-y3*u;
1093 Double_t y0 = y3*0.5+x3*u;
1094 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1100 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1101 Double_t x2,Double_t y2,
1102 Double_t x3,Double_t y3)
1104 //-----------------------------------------------------------------
1105 // Initial approximation of the track curvature
1106 //-----------------------------------------------------------------
1112 Double_t det = x3*y2-x2*y3;
1117 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1118 Double_t x0 = x3*0.5-y3*u;
1119 Double_t y0 = y3*0.5+x3*u;
1120 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1129 //_____________________________________________________________________________
1130 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1131 Double_t x2,Double_t y2,
1132 Double_t x3,Double_t y3)
1134 //-----------------------------------------------------------------
1135 // Initial approximation of the track curvature times center of curvature
1136 //-----------------------------------------------------------------
1137 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1138 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1139 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1140 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1141 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1143 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1145 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1148 //_____________________________________________________________________________
1149 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1150 Double_t x2,Double_t y2,
1151 Double_t z1,Double_t z2)
1153 //-----------------------------------------------------------------
1154 // Initial approximation of the tangent of the track dip angle
1155 //-----------------------------------------------------------------
1156 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1160 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1161 Double_t x2,Double_t y2,
1162 Double_t z1,Double_t z2, Double_t c)
1164 //-----------------------------------------------------------------
1165 // Initial approximation of the tangent of the track dip angle
1166 //-----------------------------------------------------------------
1170 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1172 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1173 if (TMath::Abs(d*c*0.5)>1) return 0;
1174 // Double_t angle2 = TMath::ASin(d*c*0.5);
1175 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1176 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1178 angle2 = (z1-z2)*c/(angle2*2.);
1182 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1183 {//-----------------------------------------------------------------
1184 // This function find proloncation of a track to a reference plane x=x2.
1185 //-----------------------------------------------------------------
1189 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1193 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1194 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1198 Double_t dy = dx*(c1+c2)/(r1+r2);
1201 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1203 if (TMath::Abs(delta)>0.01){
1204 dz = x[3]*TMath::ASin(delta)/x[4];
1206 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1209 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1217 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1222 return LoadClusters();
1225 Int_t AliTPCtrackerMI::LoadClusters()
1228 // load clusters to the memory
1229 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1230 clrow->SetClass("AliTPCclusterMI");
1232 clrow->GetArray()->ExpandCreateFast(10000);
1234 // TTree * tree = fClustersArray.GetTree();
1236 TTree * tree = fInput;
1237 TBranch * br = tree->GetBranch("Segment");
1238 br->SetAddress(&clrow);
1240 Int_t j=Int_t(tree->GetEntries());
1241 for (Int_t i=0; i<j; i++) {
1245 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1247 AliTPCRow * tpcrow=0;
1250 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1254 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1255 left = (sec-fkNIS*2)/fkNOS;
1258 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1259 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1260 for (Int_t i=0;i<tpcrow->fN1;i++)
1261 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1264 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1265 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1266 for (Int_t i=0;i<tpcrow->fN2;i++)
1267 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1278 void AliTPCtrackerMI::UnloadClusters()
1281 // unload clusters from the memory
1283 Int_t nrows = fOuterSec->GetNRows();
1284 for (Int_t sec = 0;sec<fkNOS;sec++)
1285 for (Int_t row = 0;row<nrows;row++){
1286 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1288 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1289 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1291 tpcrow->ResetClusters();
1294 nrows = fInnerSec->GetNRows();
1295 for (Int_t sec = 0;sec<fkNIS;sec++)
1296 for (Int_t row = 0;row<nrows;row++){
1297 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1299 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1300 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1302 tpcrow->ResetClusters();
1309 //_____________________________________________________________________________
1310 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1311 //-----------------------------------------------------------------
1312 // This function fills outer TPC sectors with clusters.
1313 //-----------------------------------------------------------------
1314 Int_t nrows = fOuterSec->GetNRows();
1316 for (Int_t sec = 0;sec<fkNOS;sec++)
1317 for (Int_t row = 0;row<nrows;row++){
1318 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1319 Int_t sec2 = sec+2*fkNIS;
1321 Int_t ncl = tpcrow->fN1;
1323 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1324 index=(((sec2<<8)+row)<<16)+ncl;
1325 tpcrow->InsertCluster(c,index);
1330 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1331 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1332 tpcrow->InsertCluster(c,index);
1335 // write indexes for fast acces
1337 for (Int_t i=0;i<510;i++)
1338 tpcrow->fFastCluster[i]=-1;
1339 for (Int_t i=0;i<tpcrow->GetN();i++){
1340 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1341 tpcrow->fFastCluster[zi]=i; // write index
1344 for (Int_t i=0;i<510;i++){
1345 if (tpcrow->fFastCluster[i]<0)
1346 tpcrow->fFastCluster[i] = last;
1348 last = tpcrow->fFastCluster[i];
1357 //_____________________________________________________________________________
1358 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1359 //-----------------------------------------------------------------
1360 // This function fills inner TPC sectors with clusters.
1361 //-----------------------------------------------------------------
1362 Int_t nrows = fInnerSec->GetNRows();
1364 for (Int_t sec = 0;sec<fkNIS;sec++)
1365 for (Int_t row = 0;row<nrows;row++){
1366 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1369 Int_t ncl = tpcrow->fN1;
1371 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1372 index=(((sec<<8)+row)<<16)+ncl;
1373 tpcrow->InsertCluster(c,index);
1378 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1379 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1380 tpcrow->InsertCluster(c,index);
1383 // write indexes for fast acces
1385 for (Int_t i=0;i<510;i++)
1386 tpcrow->fFastCluster[i]=-1;
1387 for (Int_t i=0;i<tpcrow->GetN();i++){
1388 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1389 tpcrow->fFastCluster[zi]=i; // write index
1392 for (Int_t i=0;i<510;i++){
1393 if (tpcrow->fFastCluster[i]<0)
1394 tpcrow->fFastCluster[i] = last;
1396 last = tpcrow->fFastCluster[i];
1408 //_________________________________________________________________________
1409 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1410 //--------------------------------------------------------------------
1411 // Return pointer to a given cluster
1412 //--------------------------------------------------------------------
1413 Int_t sec=(index&0xff000000)>>24;
1414 Int_t row=(index&0x00ff0000)>>16;
1415 Int_t ncl=(index&0x00007fff)>>00;
1417 const AliTPCRow * tpcrow=0;
1418 AliTPCclusterMI * clrow =0;
1421 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1422 if (tpcrow==0) return 0;
1425 if (tpcrow->fN1<=ncl) return 0;
1426 clrow = tpcrow->fClusters1;
1429 if (tpcrow->fN2<=ncl) return 0;
1430 clrow = tpcrow->fClusters2;
1434 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1435 if (tpcrow==0) return 0;
1437 if (sec-2*fkNIS<fkNOS) {
1438 if (tpcrow->fN1<=ncl) return 0;
1439 clrow = tpcrow->fClusters1;
1442 if (tpcrow->fN2<=ncl) return 0;
1443 clrow = tpcrow->fClusters2;
1447 return &(clrow[ncl]);
1453 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1454 //-----------------------------------------------------------------
1455 // This function tries to find a track prolongation to next pad row
1456 //-----------------------------------------------------------------
1458 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1459 AliTPCclusterMI *cl=0;
1460 Int_t tpcindex= t.GetClusterIndex2(nr);
1462 // update current shape info every 5 pad-row
1463 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1467 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1469 if (tpcindex==-1) return 0; //track in dead zone
1471 cl = t.fClusterPointer[nr];
1472 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1473 t.fCurrentClusterIndex1 = tpcindex;
1476 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1477 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1479 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1480 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1482 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1483 Double_t rotation = angle-t.GetAlpha();
1484 t.fRelativeSector= relativesector;
1489 t.fCurrentCluster = cl;
1491 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1492 if ((tpcindex&0x8000)==0) accept =0;
1494 //if founded cluster is acceptible
1495 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1502 UpdateTrack(&t,accept);
1507 if (fIteration>1) return 0; // not look for new cluster during refitting
1510 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1511 Double_t y=t.GetYat(x);
1512 if (TMath::Abs(y)>ymax){
1514 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1515 if (!t.Rotate(fSectors->GetAlpha()))
1517 } else if (y <-ymax) {
1518 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1519 if (!t.Rotate(-fSectors->GetAlpha()))
1525 if (!t.PropagateTo(x)) {
1526 if (fIteration==0) t.fRemoval = 10;
1530 Double_t z=t.GetZ();
1532 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1533 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1535 Double_t roadz = 1.;
1537 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1539 t.SetClusterIndex2(nr,-1);
1544 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10)) t.fNFoundable++;
1550 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1551 cl = krow.FindNearest2(y,z,roady,roadz,index);
1552 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1555 t.fCurrentCluster = cl;
1557 if (fIteration==2&&cl->IsUsed(10)) return 0;
1558 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1559 if (fIteration==2&&cl->IsUsed(11)) {
1566 if (t.fCurrentCluster->IsUsed(10)){
1571 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1577 if (accept<3) UpdateTrack(&t,accept);
1580 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1586 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1587 //-----------------------------------------------------------------
1588 // This function tries to find a track prolongation to next pad row
1589 //-----------------------------------------------------------------
1591 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1593 if (!t.GetProlongation(x,y,z)) {
1599 if (TMath::Abs(y)>ymax){
1602 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1603 if (!t.Rotate(fSectors->GetAlpha()))
1605 } else if (y <-ymax) {
1606 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1607 if (!t.Rotate(-fSectors->GetAlpha()))
1610 if (!t.PropagateTo(x)) {
1613 t.GetProlongation(x,y,z);
1616 // update current shape info every 3 pad-row
1617 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1618 // t.fCurrentSigmaY = GetSigmaY(&t);
1619 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1623 AliTPCclusterMI *cl=0;
1628 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1629 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1631 Double_t roadz = 1.;
1634 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1636 t.SetClusterIndex2(row,-1);
1641 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1645 if ((cl==0)&&(krow)) {
1646 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1647 cl = krow.FindNearest2(y,z,roady,roadz,index);
1649 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1653 t.fCurrentCluster = cl;
1654 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1656 t.SetClusterIndex2(row,index);
1657 t.fClusterPointer[row] = cl;
1665 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1666 //-----------------------------------------------------------------
1667 // This function tries to find a track prolongation to next pad row
1668 //-----------------------------------------------------------------
1669 t.fCurrentCluster = 0;
1670 t.fCurrentClusterIndex1 = 0;
1672 Double_t xt=t.GetX();
1673 Int_t row = GetRowNumber(xt)-1;
1674 Double_t ymax= GetMaxY(nr);
1676 if (row < nr) return 1; // don't prolongate if not information until now -
1677 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1679 return 0; // not prolongate strongly inclined tracks
1681 if (TMath::Abs(t.GetSnp())>0.95) {
1683 return 0; // not prolongate strongly inclined tracks
1686 Double_t x= GetXrow(nr);
1688 //t.PropagateTo(x+0.02);
1689 //t.PropagateTo(x+0.01);
1690 if (!t.PropagateTo(x)){
1697 if (TMath::Abs(y)>ymax){
1699 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1700 if (!t.Rotate(fSectors->GetAlpha()))
1702 } else if (y <-ymax) {
1703 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1704 if (!t.Rotate(-fSectors->GetAlpha()))
1707 // if (!t.PropagateTo(x)){
1715 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1717 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1719 t.SetClusterIndex2(nr,-1);
1724 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1730 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1731 // t.fCurrentSigmaY = GetSigmaY(&t);
1732 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1736 AliTPCclusterMI *cl=0;
1739 Double_t roady = 1.;
1740 Double_t roadz = 1.;
1744 index = t.GetClusterIndex2(nr);
1745 if ( (index>0) && (index&0x8000)==0){
1746 cl = t.fClusterPointer[nr];
1747 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1748 t.fCurrentClusterIndex1 = index;
1750 t.fCurrentCluster = cl;
1757 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1758 cl = krow.FindNearest2(y,z,roady,roadz,index);
1761 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1762 t.fCurrentCluster = cl;
1768 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1769 //-----------------------------------------------------------------
1770 // This function tries to find a track prolongation to next pad row
1771 //-----------------------------------------------------------------
1773 //update error according neighborhoud
1775 if (t.fCurrentCluster) {
1777 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1779 if (t.fCurrentCluster->IsUsed(10)){
1785 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1790 if (fIteration>0) accept = 0;
1791 if (accept<3) UpdateTrack(&t,accept);
1795 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1796 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1798 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1806 //_____________________________________________________________________________
1807 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1808 //-----------------------------------------------------------------
1809 // This function tries to find a track prolongation.
1810 //-----------------------------------------------------------------
1811 Double_t xt=t.GetX();
1813 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1814 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1815 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1817 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1819 Int_t first = GetRowNumber(xt)-1;
1820 for (Int_t nr= first; nr>=rf; nr-=step) {
1821 if (nr<fInnerSec->GetNRows())
1822 fSectors = fInnerSec;
1824 fSectors = fOuterSec;
1825 if (FollowToNext(t,nr)==0)
1834 //_____________________________________________________________________________
1835 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1836 //-----------------------------------------------------------------
1837 // This function tries to find a track prolongation.
1838 //-----------------------------------------------------------------
1839 Double_t xt=t.GetX();
1841 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1842 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1843 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1844 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1846 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1848 if (FollowToNextFast(t,nr)==0)
1849 if (!t.IsActive()) return 0;
1859 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1860 //-----------------------------------------------------------------
1861 // This function tries to find a track prolongation.
1862 //-----------------------------------------------------------------
1863 // Double_t xt=t.GetX();
1865 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1866 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1867 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1868 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1870 Int_t first = t.fFirstPoint;
1872 if (first<0) first=0;
1873 for (Int_t nr=first; nr<=rf; nr++) {
1874 //if ( (t.GetSnp()<0.9))
1875 if (nr<fInnerSec->GetNRows())
1876 fSectors = fInnerSec;
1878 fSectors = fOuterSec;
1888 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1896 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1899 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1901 Float_t distance = TMath::Sqrt(dz2+dy2);
1902 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1905 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1906 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1911 if (firstpoint>lastpoint) {
1912 firstpoint =lastpoint;
1917 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1918 if (s1->GetClusterIndex2(i)>0) sum1++;
1919 if (s2->GetClusterIndex2(i)>0) sum2++;
1920 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1924 if (sum<5) return 0;
1926 Float_t summin = TMath::Min(sum1+1,sum2+1);
1927 Float_t ratio = (sum+1)/Float_t(summin);
1931 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1935 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1936 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1938 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1940 Float_t dy2 =(s1->GetY() - s2->GetY());
1942 Float_t distance = dz2+dy2;
1943 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1948 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1949 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1951 if (firstpoint>=lastpoint-5) return;;
1953 for (Int_t i=firstpoint;i<lastpoint;i++){
1954 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1955 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1962 for (Int_t i=firstpoint;i<lastpoint;i++){
1963 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1964 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1965 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1966 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1967 if (s1->IsActive()&&s2->IsActive()){
1968 p1->fIsShared = kTRUE;
1969 p2->fIsShared = kTRUE;
1976 for (Int_t i=0;i<4;i++){
1977 if (s1->fOverlapLabels[3*i]==0){
1978 s1->fOverlapLabels[3*i] = s2->GetLabel();
1979 s1->fOverlapLabels[3*i+1] = sumshared;
1980 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1984 for (Int_t i=0;i<4;i++){
1985 if (s2->fOverlapLabels[3*i]==0){
1986 s2->fOverlapLabels[3*i] = s1->GetLabel();
1987 s2->fOverlapLabels[3*i+1] = sumshared;
1988 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1996 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1999 //sort trackss according sectors
2001 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2002 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2004 //if (pt) RotateToLocal(pt);
2008 arr->Sort(); // sorting according z
2009 arr->Expand(arr->GetEntries());
2012 Int_t nseed=arr->GetEntriesFast();
2013 for (Int_t i=0; i<nseed; i++) {
2014 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2016 for (Int_t j=0;j<=12;j++){
2017 pt->fOverlapLabels[j] =0;
2020 for (Int_t i=0; i<nseed; i++) {
2021 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2023 if (pt->fRemoval>10) continue;
2024 for (Int_t j=i+1; j<nseed; j++){
2025 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2027 if (pt2->fRemoval<=10) {
2028 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2035 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2038 //sort trackss according sectors
2041 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2044 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2045 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2050 arr->Sort(); // sorting according z
2051 arr->Expand(arr->GetEntries());
2053 //reset overlap labels
2055 Int_t nseed=arr->GetEntriesFast();
2056 for (Int_t i=0; i<nseed; i++) {
2057 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2060 for (Int_t j=0;j<=12;j++){
2061 pt->fOverlapLabels[j] =0;
2065 //sign shared tracks
2066 for (Int_t i=0; i<nseed; i++) {
2067 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2069 if (pt->fRemoval>10) continue;
2070 Float_t deltac = pt->GetC()*0.1;
2071 for (Int_t j=i+1; j<nseed; j++){
2072 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2074 if (pt2->fRemoval<=10) {
2075 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2076 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2077 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2084 // remove highly shared tracks
2085 for (Int_t i=0; i<nseed; i++) {
2086 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2088 if (pt->fRemoval>10) continue;
2091 for (Int_t j=0;j<4;j++){
2092 sumshared = pt->fOverlapLabels[j*3+1];
2094 Float_t factor = factor1;
2095 if (pt->fRemoval>0) factor = factor2;
2096 if (sumshared/pt->GetNumberOfClusters()>factor){
2097 for (Int_t j=0;j<4;j++){
2098 if (pt->fOverlapLabels[3*j]==0) continue;
2099 if (pt->fOverlapLabels[3*j+1]<5) continue;
2100 if (pt->fRemoval==removalindex) continue;
2101 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2103 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2104 // pt->fRemoval = removalindex;
2105 delete arr->RemoveAt(i);
2113 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2122 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2125 //sort tracks in array according mode criteria
2126 Int_t nseed = arr->GetEntriesFast();
2127 for (Int_t i=0; i<nseed; i++) {
2128 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2138 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2141 //Loop over all tracks and remove "overlaps"
2144 Int_t nseed = arr->GetEntriesFast();
2147 for (Int_t i=0; i<nseed; i++) {
2148 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2150 delete arr->RemoveAt(i);
2154 pt->fBSigned = kFALSE;
2158 nseed = arr->GetEntriesFast();
2165 for (Int_t i=0; i<nseed; i++) {
2166 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2170 Int_t found,foundable,shared;
2172 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2174 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2176 Double_t factor = factor2;
2177 if (pt->fBConstrain) factor = factor1;
2179 if ((Float_t(shared)/Float_t(found))>factor){
2180 pt->Desactivate(removalindex);
2185 for (Int_t i=0; i<160; i++) {
2186 Int_t index=pt->GetClusterIndex2(i);
2187 if (index<0 || index&0x8000 ) continue;
2188 AliTPCclusterMI *c= pt->fClusterPointer[i];
2190 // if (!c->IsUsed(10)) c->Use(10);
2191 //if (pt->IsActive())
2200 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2204 void AliTPCtrackerMI::UnsignClusters()
2207 // loop over all clusters and unsign them
2210 for (Int_t sec=0;sec<fkNIS;sec++){
2211 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2212 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2213 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2214 // if (cl[icl].IsUsed(10))
2216 cl = fInnerSec[sec][row].fClusters2;
2217 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2218 //if (cl[icl].IsUsed(10))
2223 for (Int_t sec=0;sec<fkNOS;sec++){
2224 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2225 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2226 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2227 //if (cl[icl].IsUsed(10))
2229 cl = fOuterSec[sec][row].fClusters2;
2230 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2231 //if (cl[icl].IsUsed(10))
2240 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2243 //sign clusters to be "used"
2245 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2246 // loop over "primaries"
2260 Int_t nseed = arr->GetEntriesFast();
2261 for (Int_t i=0; i<nseed; i++) {
2262 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2266 if (!(pt->IsActive())) continue;
2267 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2268 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2270 sumdens2+= dens*dens;
2271 sumn += pt->GetNumberOfClusters();
2272 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2273 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2276 sumchi2 +=chi2*chi2;
2281 Float_t mdensity = 0.9;
2282 Float_t meann = 130;
2283 Float_t meanchi = 1;
2284 Float_t sdensity = 0.1;
2285 Float_t smeann = 10;
2286 Float_t smeanchi =0.4;
2290 mdensity = sumdens/sum;
2292 meanchi = sumchi/sum;
2294 sdensity = sumdens2/sum-mdensity*mdensity;
2295 sdensity = TMath::Sqrt(sdensity);
2297 smeann = sumn2/sum-meann*meann;
2298 smeann = TMath::Sqrt(smeann);
2300 smeanchi = sumchi2/sum - meanchi*meanchi;
2301 smeanchi = TMath::Sqrt(smeanchi);
2305 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2307 for (Int_t i=0; i<nseed; i++) {
2308 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2312 if (pt->fBSigned) continue;
2313 if (pt->fBConstrain) continue;
2314 //if (!(pt->IsActive())) continue;
2316 Int_t found,foundable,shared;
2317 pt->GetClusterStatistic(0,160,found, foundable,shared);
2318 if (shared/float(found)>0.3) {
2319 if (shared/float(found)>0.9 ){
2320 //delete arr->RemoveAt(i);
2325 Bool_t isok =kFALSE;
2326 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2328 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2330 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2332 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2336 for (Int_t i=0; i<160; i++) {
2337 Int_t index=pt->GetClusterIndex2(i);
2338 if (index<0) continue;
2339 AliTPCclusterMI *c= pt->fClusterPointer[i];
2341 //if (!(c->IsUsed(10))) c->Use();
2348 Double_t maxchi = meanchi+2.*smeanchi;
2350 for (Int_t i=0; i<nseed; i++) {
2351 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2355 //if (!(pt->IsActive())) continue;
2356 if (pt->fBSigned) continue;
2357 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2358 if (chi>maxchi) continue;
2361 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2363 //sign only tracks with enoug big density at the beginning
2365 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2368 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2369 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2371 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2372 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2375 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2376 //Int_t noc=pt->GetNumberOfClusters();
2377 pt->fBSigned = kTRUE;
2378 for (Int_t i=0; i<160; i++) {
2380 Int_t index=pt->GetClusterIndex2(i);
2381 if (index<0) continue;
2382 AliTPCclusterMI *c= pt->fClusterPointer[i];
2384 // if (!(c->IsUsed(10))) c->Use();
2389 // gLastCheck = nseed;
2397 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2399 // stop not active tracks
2400 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2401 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2402 Int_t nseed = arr->GetEntriesFast();
2404 for (Int_t i=0; i<nseed; i++) {
2405 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2409 if (!(pt->IsActive())) continue;
2410 StopNotActive(pt,row0,th0, th1,th2);
2416 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2419 // stop not active tracks
2420 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2421 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2424 Int_t foundable = 0;
2425 Int_t maxindex = seed->fLastPoint; //last foundable row
2426 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2427 seed->Desactivate(10) ;
2431 for (Int_t i=row0; i<maxindex; i++){
2432 Int_t index = seed->GetClusterIndex2(i);
2433 if (index!=-1) foundable++;
2435 if (foundable<=30) sumgood1++;
2436 if (foundable<=50) {
2443 if (foundable>=30.){
2444 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2447 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2451 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2454 // back propagation of ESD tracks
2460 //PrepareForProlongation(fSeeds,1);
2461 PropagateForward2(fSeeds);
2463 Int_t nseed = fSeeds->GetEntriesFast();
2464 for (Int_t i=0;i<nseed;i++){
2465 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2466 if (!seed) continue;
2467 seed->PropagateTo(fParam->GetInnerRadiusLow());
2468 AliESDtrack *esd=event->GetTrack(i);
2469 seed->CookdEdx(0.02,0.6);
2470 CookLabel(seed,0.1); //For comparison only
2471 if (seed->GetNumberOfClusters()>60){
2472 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2476 //printf("problem\n");
2479 Info("RefitInward","Number of refitted tracks %d",ntracks);
2486 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2489 // back propagation of ESD tracks
2495 PropagateBack(fSeeds);
2496 Int_t nseed = fSeeds->GetEntriesFast();
2498 for (Int_t i=0;i<nseed;i++){
2499 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2500 if (!seed) continue;
2501 AliESDtrack *esd=event->GetTrack(i);
2502 seed->CookdEdx(0.02,0.6);
2503 CookLabel(seed,0.1); //For comparison only
2504 if (seed->GetNumberOfClusters()>60){
2505 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2509 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2516 void AliTPCtrackerMI::DeleteSeeds()
2520 Int_t nseed = fSeeds->GetEntriesFast();
2521 for (Int_t i=0;i<nseed;i++){
2522 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2523 if (seed) delete fSeeds->RemoveAt(i);
2529 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2532 //read seeds from the event
2534 Int_t nentr=event->GetNumberOfTracks();
2536 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2541 fSeeds = new TObjArray(nentr);
2545 for (Int_t i=0; i<nentr; i++) {
2546 AliESDtrack *esd=event->GetTrack(i);
2547 ULong_t status=esd->GetStatus();
2548 AliTPCtrack t(*esd);
2549 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2550 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2551 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2552 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2557 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2558 Double_t par0[5],par1[5],x;
2559 esd->GetInnerExternalParameters(x,par0);
2560 esd->GetExternalParameters(x,par1);
2561 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2562 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2563 //reset covariance if suspicious
2564 if ( (delta1>0.1) || (delta2>0.006))
2565 seed->ResetCovariance();
2570 // rotate to the local coordinate system
2572 fSectors=fInnerSec; fN=fkNIS;
2574 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2575 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2576 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2577 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2578 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2579 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2580 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2581 alpha-=seed->GetAlpha();
2582 if (!seed->Rotate(alpha)) {
2588 //seed->PropagateTo(fSectors->GetX(0));
2590 // Int_t index = esd->GetTPCindex();
2591 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2592 //if (direction==2){
2593 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2601 for (Int_t irow=0;irow<160;irow++){
2602 Int_t index = seed->GetClusterIndex2(irow);
2605 AliTPCclusterMI * cl = GetClusterMI(index);
2606 seed->fClusterPointer[irow] = cl;
2608 if ((index & 0x8000)==0){
2609 cl->Use(10); // accepted cluster
2611 cl->Use(6); // close cluster not accepted
2614 Info("ReadSeeds","Not found cluster");
2618 fSeeds->AddAt(seed,i);
2624 //_____________________________________________________________________________
2625 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2626 Float_t deltay, Int_t ddsec) {
2627 //-----------------------------------------------------------------
2628 // This function creates track seeds.
2629 // SEEDING WITH VERTEX CONSTRAIN
2630 //-----------------------------------------------------------------
2631 // cuts[0] - fP4 cut
2632 // cuts[1] - tan(phi) cut
2633 // cuts[2] - zvertex cut
2634 // cuts[3] - fP3 cut
2642 Double_t x[5], c[15];
2643 // Int_t di = i1-i2;
2645 AliTPCseed * seed = new AliTPCseed;
2646 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2647 Double_t cs=cos(alpha), sn=sin(alpha);
2649 // Double_t x1 =fOuterSec->GetX(i1);
2650 //Double_t xx2=fOuterSec->GetX(i2);
2652 Double_t x1 =GetXrow(i1);
2653 Double_t xx2=GetXrow(i2);
2655 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2657 Int_t imiddle = (i2+i1)/2; //middle pad row index
2658 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2659 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2663 const AliTPCRow& kr1=GetRow(ns,i1);
2664 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2665 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2668 // change cut on curvature if it can't reach this layer
2669 // maximal curvature set to reach it
2670 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2671 if (dvertexmax*0.5*cuts[0]>0.85){
2672 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2674 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2677 if (deltay>0) ddsec = 0;
2678 // loop over clusters
2679 for (Int_t is=0; is < kr1; is++) {
2681 if (kr1[is]->IsUsed(10)) continue;
2682 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2683 //if (TMath::Abs(y1)>ymax) continue;
2685 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2687 // find possible directions
2688 Float_t anglez = (z1-z3)/(x1-x3);
2689 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2692 //find rotation angles relative to line given by vertex and point 1
2693 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2694 Double_t dvertex = TMath::Sqrt(dvertex2);
2695 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2696 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2699 // loop over 2 sectors
2705 Double_t dddz1=0; // direction of delta inclination in z axis
2712 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2713 Int_t sec2 = sec + dsec;
2715 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2716 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2717 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2718 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2719 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2720 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2722 // rotation angles to p1-p3
2723 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2724 Double_t x2, y2, z2;
2726 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2729 Double_t dxx0 = (xx2-x3)*cs13r;
2730 Double_t dyy0 = (xx2-x3)*sn13r;
2731 for (Int_t js=index1; js < index2; js++) {
2732 const AliTPCclusterMI *kcl = kr2[js];
2733 if (kcl->IsUsed(10)) continue;
2735 //calcutate parameters
2737 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2739 if (TMath::Abs(yy0)<0.000001) continue;
2740 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2741 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2742 Double_t r02 = (0.25+y0*y0)*dvertex2;
2743 //curvature (radius) cut
2744 if (r02<r2min) continue;
2748 Double_t c0 = 1/TMath::Sqrt(r02);
2752 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2753 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2754 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2755 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2758 Double_t z0 = kcl->GetZ();
2759 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2760 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2763 Double_t dip = (z1-z0)*c0/dfi1;
2764 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2775 x2= xx2*cs-y2*sn*dsec;
2776 y2=+xx2*sn*dsec+y2*cs;
2786 // do we have cluster at the middle ?
2788 GetProlongation(x1,xm,x,ym,zm);
2790 AliTPCclusterMI * cm=0;
2791 if (TMath::Abs(ym)-ymaxm<0){
2792 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2793 if ((!cm) || (cm->IsUsed(10))) {
2798 // rotate y1 to system 0
2799 // get state vector in rotated system
2800 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2801 Double_t xr2 = x0*cs+yr1*sn*dsec;
2802 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2804 GetProlongation(xx2,xm,xr,ym,zm);
2805 if (TMath::Abs(ym)-ymaxm<0){
2806 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2807 if ((!cm) || (cm->IsUsed(10))) {
2817 dym = ym - cm->GetY();
2818 dzm = zm - cm->GetZ();
2825 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2826 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2827 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2828 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2829 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2831 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2832 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2833 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2834 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2835 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2836 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2838 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2839 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2840 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2841 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2845 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2846 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2847 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2848 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2849 c[13]=f30*sy1*f40+f32*sy2*f42;
2850 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2852 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2854 UInt_t index=kr1.GetIndex(is);
2855 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2857 track->fIsSeeding = kTRUE;
2864 FollowProlongation(*track, (i1+i2)/2,1);
2865 Int_t foundable,found,shared;
2866 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2867 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2869 seed->~AliTPCseed();
2875 FollowProlongation(*track, i2,1);
2879 track->fBConstrain =1;
2880 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2881 track->fLastPoint = i1; // first cluster in track position
2882 track->fFirstPoint = track->fLastPoint;
2884 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2885 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2886 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2888 seed->~AliTPCseed();
2892 // Z VERTEX CONDITION
2894 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2895 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2896 if (TMath::Abs(zv-z3)>cuts[2]) {
2897 FollowProlongation(*track, TMath::Max(i2-20,0));
2898 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2899 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2900 if (TMath::Abs(zv-z3)>cuts[2]){
2901 FollowProlongation(*track, TMath::Max(i2-40,0));
2902 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2903 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2904 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2905 // make seed without constrain
2906 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2907 FollowProlongation(*track2, i2,1);
2908 track2->fBConstrain = kFALSE;
2909 track2->fSeedType = 1;
2910 arr->AddLast(track2);
2912 seed->~AliTPCseed();
2917 seed->~AliTPCseed();
2924 track->fSeedType =0;
2925 arr->AddLast(track);
2926 seed = new AliTPCseed;
2928 // don't consider other combinations
2929 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2935 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2941 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2946 //-----------------------------------------------------------------
2947 // This function creates track seeds.
2948 //-----------------------------------------------------------------
2949 // cuts[0] - fP4 cut
2950 // cuts[1] - tan(phi) cut
2951 // cuts[2] - zvertex cut
2952 // cuts[3] - fP3 cut
2962 Double_t x[5], c[15];
2964 // make temporary seed
2965 AliTPCseed * seed = new AliTPCseed;
2966 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2967 // Double_t cs=cos(alpha), sn=sin(alpha);
2972 Double_t x1 = GetXrow(i1-1);
2973 const AliTPCRow& kr1=GetRow(sec,i1-1);
2974 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2976 Double_t x1p = GetXrow(i1);
2977 const AliTPCRow& kr1p=GetRow(sec,i1);
2979 Double_t x1m = GetXrow(i1-2);
2980 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2983 //last 3 padrow for seeding
2984 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2985 Double_t x3 = GetXrow(i1-7);
2986 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2988 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2989 Double_t x3p = GetXrow(i1-6);
2991 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2992 Double_t x3m = GetXrow(i1-8);
2997 Int_t im = i1-4; //middle pad row index
2998 Double_t xm = GetXrow(im); // radius of middle pad-row
2999 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3000 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3003 Double_t deltax = x1-x3;
3004 Double_t dymax = deltax*cuts[1];
3005 Double_t dzmax = deltax*cuts[3];
3007 // loop over clusters
3008 for (Int_t is=0; is < kr1; is++) {
3010 if (kr1[is]->IsUsed(10)) continue;
3011 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3013 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3015 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3016 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3022 for (Int_t js=index1; js < index2; js++) {
3023 const AliTPCclusterMI *kcl = kr3[js];
3024 if (kcl->IsUsed(10)) continue;
3026 // apply angular cuts
3027 if (TMath::Abs(y1-y3)>dymax) continue;
3030 if (TMath::Abs(z1-z3)>dzmax) continue;
3032 Double_t angley = (y1-y3)/(x1-x3);
3033 Double_t anglez = (z1-z3)/(x1-x3);
3035 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3036 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3038 Double_t yyym = angley*(xm-x1)+y1;
3039 Double_t zzzm = anglez*(xm-x1)+z1;
3041 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3043 if (kcm->IsUsed(10)) continue;
3045 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3046 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3053 // look around first
3054 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3060 if (kc1m->IsUsed(10)) used++;
3062 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3068 if (kc1p->IsUsed(10)) used++;
3070 if (used>1) continue;
3071 if (found<1) continue;
3075 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3081 if (kc3m->IsUsed(10)) used++;
3085 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3091 if (kc3p->IsUsed(10)) used++;
3095 if (used>1) continue;
3096 if (found<3) continue;
3106 x[4]=F1(x1,y1,x2,y2,x3,y3);
3107 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3110 x[2]=F2(x1,y1,x2,y2,x3,y3);
3113 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3114 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3118 Double_t sy1=0.1, sz1=0.1;
3119 Double_t sy2=0.1, sz2=0.1;
3120 Double_t sy3=0.1, sy=0.1, sz=0.1;
3122 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3123 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3124 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3125 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3126 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3127 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3129 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3130 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3131 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3132 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3136 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3137 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3138 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3139 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3140 c[13]=f30*sy1*f40+f32*sy2*f42;
3141 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3143 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3145 UInt_t index=kr1.GetIndex(is);
3146 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3148 track->fIsSeeding = kTRUE;
3151 FollowProlongation(*track, i1-7,1);
3152 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3153 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3155 seed->~AliTPCseed();
3161 FollowProlongation(*track, i2,1);
3162 track->fBConstrain =0;
3163 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3164 track->fFirstPoint = track->fLastPoint;
3166 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3167 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3168 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3170 seed->~AliTPCseed();
3175 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3176 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3177 FollowProlongation(*track2, i2,1);
3178 track2->fBConstrain = kFALSE;
3179 track2->fSeedType = 4;
3180 arr->AddLast(track2);
3182 seed->~AliTPCseed();
3186 //arr->AddLast(track);
3187 //seed = new AliTPCseed;
3193 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3199 //_____________________________________________________________________________
3200 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3201 Float_t deltay, Bool_t /*bconstrain*/) {
3202 //-----------------------------------------------------------------
3203 // This function creates track seeds - without vertex constraint
3204 //-----------------------------------------------------------------
3205 // cuts[0] - fP4 cut - not applied
3206 // cuts[1] - tan(phi) cut
3207 // cuts[2] - zvertex cut - not applied
3208 // cuts[3] - fP3 cut
3218 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3219 // Double_t cs=cos(alpha), sn=sin(alpha);
3220 Int_t row0 = (i1+i2)/2;
3221 Int_t drow = (i1-i2)/2;
3222 const AliTPCRow& kr0=fSectors[sec][row0];
3225 AliTPCpolyTrack polytrack;
3226 Int_t nclusters=fSectors[sec][row0];
3227 AliTPCseed * seed = new AliTPCseed;
3232 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3234 Int_t nfoundable =0;
3235 for (Int_t iter =1; iter<2; iter++){ //iterations
3236 const AliTPCRow& krm=fSectors[sec][row0-iter];
3237 const AliTPCRow& krp=fSectors[sec][row0+iter];
3238 const AliTPCclusterMI * cl= kr0[is];
3240 if (cl->IsUsed(10)) {
3246 Double_t x = kr0.GetX();
3247 // Initialization of the polytrack
3252 Double_t y0= cl->GetY();
3253 Double_t z0= cl->GetZ();
3257 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3258 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3260 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3261 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3262 polytrack.AddPoint(x,y0,z0,erry, errz);
3265 if (cl->IsUsed(10)) sumused++;
3268 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3269 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3272 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3273 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3274 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3275 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3276 if (cl1->IsUsed(10)) sumused++;
3277 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3281 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3283 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3284 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3285 if (cl2->IsUsed(10)) sumused++;
3286 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3289 if (sumused>0) continue;
3291 polytrack.UpdateParameters();
3297 nfoundable = polytrack.GetN();
3298 nfound = nfoundable;
3300 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3301 Float_t maxdist = 0.8*(1.+3./(ddrow));
3302 for (Int_t delta = -1;delta<=1;delta+=2){
3303 Int_t row = row0+ddrow*delta;
3304 kr = &(fSectors[sec][row]);
3305 Double_t xn = kr->GetX();
3306 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3307 polytrack.GetFitPoint(xn,yn,zn);
3308 if (TMath::Abs(yn)>ymax) continue;
3310 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3312 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3315 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3316 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3317 if (cln->IsUsed(10)) {
3318 // printf("used\n");
3326 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3331 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3332 polytrack.UpdateParameters();
3335 if ( (sumused>3) || (sumused>0.5*nfound)) {
3336 //printf("sumused %d\n",sumused);
3341 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3342 AliTPCpolyTrack track2;
3344 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3345 if (track2.GetN()<0.5*nfoundable) continue;
3348 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3350 // test seed with and without constrain
3351 for (Int_t constrain=0; constrain<=0;constrain++){
3352 // add polytrack candidate
3354 Double_t x[5], c[15];
3355 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3356 track2.GetBoundaries(x3,x1);
3358 track2.GetFitPoint(x1,y1,z1);
3359 track2.GetFitPoint(x2,y2,z2);
3360 track2.GetFitPoint(x3,y3,z3);
3362 //is track pointing to the vertex ?
3365 polytrack.GetFitPoint(x0,y0,z0);
3378 x[4]=F1(x1,y1,x2,y2,x3,y3);
3380 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3381 x[2]=F2(x1,y1,x2,y2,x3,y3);
3383 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3384 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3385 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3386 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3389 Double_t sy =0.1, sz =0.1;
3390 Double_t sy1=0.02, sz1=0.02;
3391 Double_t sy2=0.02, sz2=0.02;
3395 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3398 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3399 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3400 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3401 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3402 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3403 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3405 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3406 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3407 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3408 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3413 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3414 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3415 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3416 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3417 c[13]=f30*sy1*f40+f32*sy2*f42;
3418 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3420 //Int_t row1 = fSectors->GetRowNumber(x1);
3421 Int_t row1 = GetRowNumber(x1);
3425 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3426 track->fIsSeeding = kTRUE;
3427 Int_t rc=FollowProlongation(*track, i2);
3428 if (constrain) track->fBConstrain =1;
3430 track->fBConstrain =0;
3431 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3432 track->fFirstPoint = track->fLastPoint;
3434 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3435 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3436 track->fNShared>0.4*track->GetNumberOfClusters()) {
3439 seed->~AliTPCseed();
3442 arr->AddLast(track);
3443 seed = new AliTPCseed;
3447 } // if accepted seed
3450 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3456 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3460 //reseed using track points
3461 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3462 Int_t p1 = int(r1*track->GetNumberOfClusters());
3463 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3465 Double_t x0[3],x1[3],x2[3];
3470 // find track position at given ratio of the length
3471 Int_t sec0, sec1, sec2;
3477 for (Int_t i=0;i<160;i++){
3478 if (track->fClusterPointer[i]){
3480 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3481 if ( (index<p0) || x0[0]<0 ){
3482 if (trpoint->GetX()>1){
3483 clindex = track->GetClusterIndex2(i);
3485 x0[0] = trpoint->GetX();
3486 x0[1] = trpoint->GetY();
3487 x0[2] = trpoint->GetZ();
3488 sec0 = ((clindex&0xff000000)>>24)%18;
3493 if ( (index<p1) &&(trpoint->GetX()>1)){
3494 clindex = track->GetClusterIndex2(i);
3496 x1[0] = trpoint->GetX();
3497 x1[1] = trpoint->GetY();
3498 x1[2] = trpoint->GetZ();
3499 sec1 = ((clindex&0xff000000)>>24)%18;
3502 if ( (index<p2) &&(trpoint->GetX()>1)){
3503 clindex = track->GetClusterIndex2(i);
3505 x2[0] = trpoint->GetX();
3506 x2[1] = trpoint->GetY();
3507 x2[2] = trpoint->GetZ();
3508 sec2 = ((clindex&0xff000000)>>24)%18;
3515 Double_t alpha, cs,sn, xx2,yy2;
3517 alpha = (sec1-sec2)*fSectors->GetAlpha();
3518 cs = TMath::Cos(alpha);
3519 sn = TMath::Sin(alpha);
3520 xx2= x1[0]*cs-x1[1]*sn;
3521 yy2= x1[0]*sn+x1[1]*cs;
3525 alpha = (sec0-sec2)*fSectors->GetAlpha();
3526 cs = TMath::Cos(alpha);
3527 sn = TMath::Sin(alpha);
3528 xx2= x0[0]*cs-x0[1]*sn;
3529 yy2= x0[0]*sn+x0[1]*cs;
3535 Double_t x[5],c[15];
3539 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3540 // if (x[4]>1) return 0;
3541 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3542 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3543 //if (TMath::Abs(x[3]) > 2.2) return 0;
3544 //if (TMath::Abs(x[2]) > 1.99) return 0;
3546 Double_t sy =0.1, sz =0.1;
3548 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3549 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3550 Double_t sy3=0.01+track->GetSigmaY2();
3552 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3553 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3554 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3555 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3556 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3557 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3559 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3560 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3561 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3562 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3567 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3568 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3569 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3570 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3571 c[13]=f30*sy1*f40+f32*sy2*f42;
3572 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3574 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3575 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3576 // Double_t y0,z0,y1,z1, y2,z2;
3577 //seed->GetProlongation(x0[0],y0,z0);
3578 // seed->GetProlongation(x1[0],y1,z1);
3579 //seed->GetProlongation(x2[0],y2,z2);
3581 seed->fLastPoint = pp2;
3582 seed->fFirstPoint = pp2;
3589 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3593 //reseed using founded clusters
3595 // Find the number of clusters
3596 Int_t nclusters = 0;
3597 for (Int_t irow=0;irow<160;irow++){
3598 if (track->GetClusterIndex(irow)>0) nclusters++;
3602 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3603 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3604 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3608 Int_t row[3],sec[3]={0,0,0};
3610 // find track row position at given ratio of the length
3612 for (Int_t irow=0;irow<160;irow++){
3613 if (track->GetClusterIndex2(irow)<0) continue;
3615 for (Int_t ipoint=0;ipoint<3;ipoint++){
3616 if (index<=ipos[ipoint]) row[ipoint] = irow;
3620 //Get cluster and sector position
3621 for (Int_t ipoint=0;ipoint<3;ipoint++){
3622 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3623 AliTPCclusterMI * cl = GetClusterMI(clindex);
3626 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3629 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3630 xyz[ipoint][0] = GetXrow(row[ipoint]);
3631 xyz[ipoint][1] = cl->GetY();
3632 xyz[ipoint][2] = cl->GetZ();
3636 // Calculate seed state vector and covariance matrix
3638 Double_t alpha, cs,sn, xx2,yy2;
3640 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3641 cs = TMath::Cos(alpha);
3642 sn = TMath::Sin(alpha);
3643 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3644 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3648 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3649 cs = TMath::Cos(alpha);