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 **************************************************************************/
18 Revision 1.18 2003/10/17 15:42:14 kowal2
19 Back to the previous version. The warning was erronously generated
22 Revision 1.17 2003/10/17 12:28:02 kowal2
23 Removed "always true" comparison
25 Revision 1.16 2003/10/17 12:01:16 kowal2
26 Removed compiler warning.
28 Revision 1.15 2003/09/29 11:56:58 kowal2
31 Revision 1.14 2003/09/29 11:39:43 kowal2
34 Revision 1.13 2003/09/29 11:28:19 kowal2
37 Revision 1.9.4.3 2003/06/23 14:47:10 hristov
40 Revision 1.9.4.2 2003/06/23 10:06:13 hristov
41 Updated information about the overlapping clusters (M.Ivanov)
43 Revision 1.9.4.1 2003/06/19 06:59:58 hristov
44 Updated version of parallel tracking (M.Ivanov)
46 Revision 1.9 2003/03/19 17:14:11 hristov
47 Load/UnloadClusters added to the base class and the derived classes changed correspondingly. Possibility to give 2 input files for ITS and TPC tracks in PropagateBack. TRD tracker uses fEventN from the base class (T.Kuhr)
49 Revision 1.8 2003/03/05 11:16:15 kowal2
61 AliTPC parallel tracker -
63 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
64 run AliTPCFindTracksMI.C macro - to find tracks
65 tracks are written to AliTPCtracks.root file
66 for comparison also seeds are written to the same file - to special branch
69 //-------------------------------------------------------
70 // Implementation of the TPC tracker
72 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
74 //-------------------------------------------------------
75 #include <TObjArray.h>
78 #include "Riostream.h"
80 #include "AliTPCtrackerMI.h"
81 #include "AliTPCclusterMI.h"
82 #include "AliTPCParam.h"
83 #include "AliTPCClustersRow.h"
84 #include "AliComplexCluster.h"
85 #include "AliTPCpolyTrack.h"
86 #include "TStopwatch.h"
91 #include "AliRunLoader.h"
96 ClassImp(AliTPCtrackerMI)
102 static Double_t FastAsin(Double_t x);
104 static Double_t fgFastAsin[20000];
107 Double_t TPCFastMath::fgFastAsin[20000];
109 TPCFastMath::TPCFastMath(){
110 for (Int_t i=0;i<10000;i++){
111 fgFastAsin[2*i] = TMath::ASin(i/10000.);
112 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
116 Double_t TPCFastMath::FastAsin(Double_t x){
118 Int_t index = int(x*10000);
119 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
122 Int_t index = int(x*10000);
123 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
126 TPCFastMath gTPCMath;
130 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
132 AliTPCclusterMI* c =track->fCurrentCluster;
133 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
135 UInt_t i = track->fCurrentClusterIndex1;
137 Int_t sec=(i&0xff000000)>>24;
138 //Int_t row = (i&0x00ff0000)>>16;
139 track->fRow=(i&0x00ff0000)>>16;
140 track->fSector = sec;
141 // Int_t index = i&0xFFFF;
142 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
143 track->SetClusterIndex2(track->fRow, i);
145 //track->fFirstPoint = row;
146 //if ( track->fLastPoint<row) track->fLastPoint =row;
147 // if (track->fRow<0 || track->fRow>160) {
148 // printf("problem\n");
150 if (track->fFirstPoint>track->fRow)
151 track->fFirstPoint = track->fRow;
152 if (track->fLastPoint<track->fRow)
153 track->fLastPoint = track->fRow;
156 track->fClusterPointer[track->fRow] = c;
159 Float_t angle2 = track->GetSnp()*track->GetSnp();
160 angle2 = TMath::Sqrt(angle2/(1-angle2));
162 //SET NEW Track Point
166 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
168 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
169 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
170 point.SetErrY(sqrt(track->fErrorY2));
171 point.SetErrZ(sqrt(track->fErrorZ2));
173 point.SetX(track->GetX());
174 point.SetY(track->GetY());
175 point.SetZ(track->GetZ());
176 point.SetAngleY(angle2);
177 point.SetAngleZ(track->GetTgl());
178 if (point.fIsShared){
179 track->fErrorY2 *= 4;
180 track->fErrorZ2 *= 4;
184 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
186 track->fErrorY2 *= 1.3;
187 track->fErrorY2 += 0.01;
188 track->fErrorZ2 *= 1.3;
189 track->fErrorZ2 += 0.005;
191 if (accept>0) return 0;
192 if (track->GetNumberOfClusters()%20==0){
193 // if (track->fHelixIn){
194 // TClonesArray & larr = *(track->fHelixIn);
195 // Int_t ihelix = larr.GetEntriesFast();
196 // new(larr[ihelix]) AliHelix(*track) ;
199 track->fNoCluster =0;
200 return track->Update(c,chi2,i);
205 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
206 Float_t cory, Float_t corz)
209 // decide according desired precision to accept given
210 // cluster for tracking
211 Double_t sy2=ErrY2(seed,cluster)*cory;
212 Double_t sz2=ErrZ2(seed,cluster)*corz;
213 //sy2=ErrY2(seed,cluster)*cory;
214 //sz2=ErrZ2(seed,cluster)*cory;
216 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
217 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
219 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
220 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
221 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
222 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
224 Double_t rdistance2 = rdistancey2+rdistancez2;
227 if (rdistance2>16) return 3;
230 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
231 return 2; //suspisiouce - will be changed
233 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
234 // strict cut on overlaped cluster
235 return 2; //suspisiouce - will be changed
237 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
238 && cluster->GetType()<0){
248 //_____________________________________________________________________________
249 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
250 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
252 //---------------------------------------------------------------------
253 // The main TPC tracker constructor
254 //---------------------------------------------------------------------
255 fInnerSec=new AliTPCSector[fkNIS];
256 fOuterSec=new AliTPCSector[fkNOS];
259 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
260 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
267 Int_t nrowlow = par->GetNRowLow();
268 Int_t nrowup = par->GetNRowUp();
271 for (Int_t i=0;i<nrowlow;i++){
272 fXRow[i] = par->GetPadRowRadiiLow(i);
273 fPadLength[i]= par->GetPadPitchLength(0,i);
274 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
278 for (Int_t i=0;i<nrowup;i++){
279 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
280 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
281 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
294 //_____________________________________________________________________________
295 AliTPCtrackerMI::~AliTPCtrackerMI() {
296 //------------------------------------------------------------------
297 // TPC tracker destructor
298 //------------------------------------------------------------------
307 void AliTPCtrackerMI::SetIO()
311 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
312 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
313 AliTPCtrack *iotrack= new AliTPCtrack;
314 // iotrack->fHelixIn = new TClonesArray("AliHelix");
315 //iotrack->fHelixOut = new TClonesArray("AliHelix");
316 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
320 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
336 AliTPCtrack *iotrack= new AliTPCtrack;
337 // iotrack->fHelixIn = new TClonesArray("AliHelix");
338 //iotrack->fHelixOut = new TClonesArray("AliHelix");
339 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
342 if (output && (fDebug&2)){
343 //write the full seed information if specified in debug mode
345 fSeedTree = new TTree("Seeds","Seeds");
346 AliTPCseed * vseed = new AliTPCseed;
348 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
349 arrtr->ExpandCreateFast(160);
350 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
352 vseed->fPoints = arrtr;
353 vseed->fEPoints = arre;
354 // vseed->fClusterPoints = arrcl;
355 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
358 fTreeDebug = new TTree("trackDebug","trackDebug");
359 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
360 fTreeDebug->Branch("debug",&arrd,32000,99);
368 void AliTPCtrackerMI::WriteTracks()
371 // write tracks to the given output tree -
372 // output specified with SetIO routine
375 // write tracks to the event
376 // store index of the track
377 Int_t nseed=fSeeds->GetEntriesFast();
378 for (Int_t i=0; i<nseed; i++) {
379 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
382 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
383 //iotrack.SetTPCindex(i);
384 fEvent->AddTrack(&iotrack);
390 AliTPCtrack *iotrack= 0;
391 Int_t nseed=fSeeds->GetEntriesFast();
392 for (Int_t i=0; i<nseed; i++) {
393 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
397 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
398 TBranch * br = fOutput->GetBranch("tracks");
399 br->SetAddress(&iotrack);
401 for (Int_t i=0; i<nseed; i++) {
402 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
406 // br->SetAddress(&iotrack);
414 //write the full seed information if specified in debug mode
416 AliTPCseed * vseed = new AliTPCseed;
418 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
419 arrtr->ExpandCreateFast(160);
420 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
421 //arrcl->ExpandCreateFast(160);
422 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
424 vseed->fPoints = arrtr;
425 vseed->fEPoints = arre;
426 // vseed->fClusterPoints = arrcl;
427 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
428 TBranch * brseed = fSeedTree->GetBranch("seeds");
430 Int_t nseed=fSeeds->GetEntriesFast();
432 for (Int_t i=0; i<nseed; i++) {
433 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
436 // pt->fClusterPoints = arrcl;
440 brseed->SetAddress(&vseed);
444 // pt->fClusterPoints = 0;
447 if (fTreeDebug) fTreeDebug->Write();
455 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
458 //seed->SetErrorY2(0.1);
460 //calculate look-up table at the beginning
461 static Bool_t ginit = kFALSE;
462 static Float_t gnoise1,gnoise2,gnoise3;
463 static Float_t ggg1[10000];
464 static Float_t ggg2[10000];
465 static Float_t ggg3[10000];
466 static Float_t glandau1[10000];
467 static Float_t glandau2[10000];
468 static Float_t glandau3[10000];
470 static Float_t gcor01[500];
471 static Float_t gcor02[500];
472 static Float_t gcorp[500];
477 for (Int_t i=1;i<500;i++){
478 Float_t rsigma = float(i)/100.;
479 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
480 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
481 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
485 for (Int_t i=3;i<10000;i++){
489 Float_t amp = float(i);
490 Float_t padlength =0.75;
491 gnoise1 = 0.0004/padlength;
492 Float_t nel = 0.268*amp;
493 Float_t nprim = 0.155*amp;
494 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
495 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
496 if (glandau1[i]>1) glandau1[i]=1;
497 glandau1[i]*=padlength*padlength/12.;
501 gnoise2 = 0.0004/padlength;
504 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
505 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
506 if (glandau2[i]>1) glandau2[i]=1;
507 glandau2[i]*=padlength*padlength/12.;
512 gnoise3 = 0.0004/padlength;
515 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
516 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
517 if (glandau3[i]>1) glandau3[i]=1;
518 glandau3[i]*=padlength*padlength/12.;
526 Int_t amp = int(TMath::Abs(cl->GetQ()));
528 seed->SetErrorY2(1.);
532 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
533 Int_t ctype = cl->GetType();
534 Float_t padlength= GetPadPitchLength(seed->fRow);
535 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
536 angle2 = angle2/(1-angle2);
539 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
542 if (fSectors==fInnerSec){
544 res = ggg1[amp]*z+glandau1[amp]*angle2;
545 if (ctype==0) res *= gcor01[rsigmay];
548 res*= gcorp[rsigmay];
554 res = ggg2[amp]*z+glandau2[amp]*angle2;
555 if (ctype==0) res *= gcor02[rsigmay];
558 res*= gcorp[rsigmay];
563 res = ggg3[amp]*z+glandau3[amp]*angle2;
564 if (ctype==0) res *= gcor02[rsigmay];
567 res*= gcorp[rsigmay];
574 res*=2.4; // overestimate error 2 times
581 seed->SetErrorY2(res);
589 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
592 //seed->SetErrorY2(0.1);
594 //calculate look-up table at the beginning
595 static Bool_t ginit = kFALSE;
596 static Float_t gnoise1,gnoise2,gnoise3;
597 static Float_t ggg1[10000];
598 static Float_t ggg2[10000];
599 static Float_t ggg3[10000];
600 static Float_t glandau1[10000];
601 static Float_t glandau2[10000];
602 static Float_t glandau3[10000];
604 static Float_t gcor01[1000];
605 static Float_t gcor02[1000];
606 static Float_t gcorp[1000];
611 for (Int_t i=1;i<1000;i++){
612 Float_t rsigma = float(i)/100.;
613 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
614 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
615 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
619 for (Int_t i=3;i<10000;i++){
623 Float_t amp = float(i);
624 Float_t padlength =0.75;
625 gnoise1 = 0.0004/padlength;
626 Float_t nel = 0.268*amp;
627 Float_t nprim = 0.155*amp;
628 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
629 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
630 if (glandau1[i]>1) glandau1[i]=1;
631 glandau1[i]*=padlength*padlength/12.;
635 gnoise2 = 0.0004/padlength;
638 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
639 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
640 if (glandau2[i]>1) glandau2[i]=1;
641 glandau2[i]*=padlength*padlength/12.;
646 gnoise3 = 0.0004/padlength;
649 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
650 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
651 if (glandau3[i]>1) glandau3[i]=1;
652 glandau3[i]*=padlength*padlength/12.;
660 Int_t amp = int(TMath::Abs(cl->GetQ()));
662 seed->SetErrorY2(1.);
666 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
667 Int_t ctype = cl->GetType();
668 Float_t padlength= GetPadPitchLength(seed->fRow);
670 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
671 // if (angle2<0.6) angle2 = 0.6;
672 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
675 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
678 if (fSectors==fInnerSec){
680 res = ggg1[amp]*z+glandau1[amp]*angle2;
681 if (ctype==0) res *= gcor01[rsigmaz];
684 res*= gcorp[rsigmaz];
690 res = ggg2[amp]*z+glandau2[amp]*angle2;
691 if (ctype==0) res *= gcor02[rsigmaz];
694 res*= gcorp[rsigmaz];
699 res = ggg3[amp]*z+glandau3[amp]*angle2;
700 if (ctype==0) res *= gcor02[rsigmaz];
703 res*= gcorp[rsigmaz];
712 if ((ctype<0) &&<70){
720 seed->SetErrorZ2(res);
727 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
730 //seed->SetErrorZ2(0.1);
734 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
736 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
737 Int_t ctype = cl->GetType();
738 Float_t amp = TMath::Abs(cl->GetQ());
743 Float_t landau=2 ; //landau fluctuation part
744 Float_t gg=2; // gg fluctuation part
745 Float_t padlength= GetPadPitchLength(seed->GetX());
747 if (fSectors==fInnerSec){
748 snoise2 = 0.0004/padlength;
751 gg = (2+0.001*nel/(padlength*padlength))/nel;
752 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
753 if (landau>1) landau=1;
756 snoise2 = 0.0004/padlength;
759 gg = (2+0.0008*nel/(padlength*padlength))/nel;
760 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
761 if (landau>1) landau=1;
763 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
766 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
767 angle2 = TMath::Sqrt((1-angle2));
768 if (angle2<0.6) angle2 = 0.6;
771 Float_t angle = seed->GetTgl()/angle2;
772 Float_t angular = landau*angle*angle*padlength*padlength/12.;
773 Float_t res = sdiff + angular;
776 if ((ctype==0) && (fSectors ==fOuterSec))
777 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
779 if ((ctype==0) && (fSectors ==fInnerSec))
780 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
784 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
790 if ((ctype<0) &&<70){
798 seed->SetErrorZ2(res);
805 void AliTPCseed::Reset(Bool_t all)
809 SetNumberOfClusters(0);
815 for (Int_t i=0;i<8;i++){
816 delete [] fTrackPoints[i];
824 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
825 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
831 void AliTPCseed::Modify(Double_t factor)
834 //------------------------------------------------------------------
835 //This function makes a track forget its history :)
836 //------------------------------------------------------------------
842 fC10*=factor; fC11*=factor;
843 fC20*=factor; fC21*=factor; fC22*=factor;
844 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
845 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
846 SetNumberOfClusters(0);
850 fCurrentSigmaY2 = 0.000005;
851 fCurrentSigmaZ2 = 0.000005;
860 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
862 //-----------------------------------------------------------------
863 // This function find proloncation of a track to a reference plane x=xk.
864 // doesn't change internal state of the track
865 //-----------------------------------------------------------------
867 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
869 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
873 // Double_t y1=fP0, z1=fP1;
874 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
875 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
879 //y += dx*(c1+c2)/(r1+r2);
880 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
882 Double_t dy = dx*(c1+c2)/(r1+r2);
885 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
887 if (TMath::Abs(delta)>0.0001){
888 dz = fP3*TMath::ASin(delta)/fP4;
890 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
893 dz = fP3*TPCFastMath::FastAsin(delta)/fP4;
903 //_____________________________________________________________________________
904 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
906 //-----------------------------------------------------------------
907 // This function calculates a predicted chi2 increment.
908 //-----------------------------------------------------------------
909 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
910 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
911 r00+=fC00; r01+=fC10; r11+=fC11;
913 Double_t det=r00*r11 - r01*r01;
914 if (TMath::Abs(det) < 1.e-10) {
915 Int_t n=GetNumberOfClusters();
916 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
919 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
921 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
923 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
927 //_________________________________________________________________________________________
930 Int_t AliTPCseed::Compare(const TObject *o) const {
931 //-----------------------------------------------------------------
932 // This function compares tracks according to the sector - for given sector according z
933 //-----------------------------------------------------------------
934 AliTPCseed *t=(AliTPCseed*)o;
937 if (t->fRelativeSector>fRelativeSector) return -1;
938 if (t->fRelativeSector<fRelativeSector) return 1;
939 Double_t z2 = t->GetZ();
940 Double_t z1 = GetZ();
942 if (z2<z1) return -1;
947 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
948 if (t->fBConstrain) f2=1.2;
951 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
953 if (fBConstrain) f1=1.2;
955 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
960 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
962 //rotate to track "local coordinata
963 Float_t x = seed->GetX();
964 Float_t y = seed->GetY();
965 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
968 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
969 if (!seed->Rotate(fSectors->GetAlpha()))
971 } else if (y <-ymax) {
972 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
973 if (!seed->Rotate(-fSectors->GetAlpha()))
982 //_____________________________________________________________________________
983 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
984 //-----------------------------------------------------------------
985 // This function associates a cluster with this track.
986 //-----------------------------------------------------------------
987 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
989 r00+=fC00; r01+=fC10; r11+=fC11;
990 Double_t det=r00*r11 - r01*r01;
991 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
993 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
994 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
995 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
996 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
997 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
999 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
1000 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
1001 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1005 fP0 += k00*dy + k01*dz;
1006 fP1 += k10*dy + k11*dz;
1008 fP3 += k30*dy + k31*dz;
1011 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1012 Double_t c12=fC21, c13=fC31, c14=fC41;
1014 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1015 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1016 fC40-=k00*c04+k01*c14;
1018 fC11-=k10*c01+k11*fC11;
1019 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1020 fC41-=k10*c04+k11*c14;
1022 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1023 fC42-=k20*c04+k21*c14;
1025 fC33-=k30*c03+k31*c13;
1026 fC43-=k40*c03+k41*c13;
1028 fC44-=k40*c04+k41*c14;
1030 Int_t n=GetNumberOfClusters();
1032 SetNumberOfClusters(n+1);
1033 SetChi2(GetChi2()+chisq);
1040 //_____________________________________________________________________________
1041 Double_t AliTPCtrackerMI::f1old(Double_t x1,Double_t y1,
1042 Double_t x2,Double_t y2,
1043 Double_t x3,Double_t y3)
1045 //-----------------------------------------------------------------
1046 // Initial approximation of the track curvature
1047 //-----------------------------------------------------------------
1048 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1049 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1050 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1051 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1052 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1054 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1055 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1056 return -xr*yr/sqrt(xr*xr+yr*yr);
1061 //_____________________________________________________________________________
1062 Double_t AliTPCtrackerMI::f1(Double_t x1,Double_t y1,
1063 Double_t x2,Double_t y2,
1064 Double_t x3,Double_t y3)
1066 //-----------------------------------------------------------------
1067 // Initial approximation of the track curvature
1068 //-----------------------------------------------------------------
1074 Double_t det = x3*y2-x2*y3;
1079 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1080 Double_t x0 = x3*0.5-y3*u;
1081 Double_t y0 = y3*0.5+x3*u;
1082 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1088 Double_t AliTPCtrackerMI::f2(Double_t x1,Double_t y1,
1089 Double_t x2,Double_t y2,
1090 Double_t x3,Double_t y3)
1092 //-----------------------------------------------------------------
1093 // Initial approximation of the track curvature
1094 //-----------------------------------------------------------------
1100 Double_t det = x3*y2-x2*y3;
1105 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1106 Double_t x0 = x3*0.5-y3*u;
1107 Double_t y0 = y3*0.5+x3*u;
1108 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1117 //_____________________________________________________________________________
1118 Double_t AliTPCtrackerMI::f2old(Double_t x1,Double_t y1,
1119 Double_t x2,Double_t y2,
1120 Double_t x3,Double_t y3)
1122 //-----------------------------------------------------------------
1123 // Initial approximation of the track curvature times center of curvature
1124 //-----------------------------------------------------------------
1125 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1126 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1127 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1128 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1129 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1131 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1133 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1136 //_____________________________________________________________________________
1137 Double_t AliTPCtrackerMI::f3(Double_t x1,Double_t y1,
1138 Double_t x2,Double_t y2,
1139 Double_t z1,Double_t z2)
1141 //-----------------------------------------------------------------
1142 // Initial approximation of the tangent of the track dip angle
1143 //-----------------------------------------------------------------
1144 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1148 Double_t AliTPCtrackerMI::f3n(Double_t x1,Double_t y1,
1149 Double_t x2,Double_t y2,
1150 Double_t z1,Double_t z2, Double_t c)
1152 //-----------------------------------------------------------------
1153 // Initial approximation of the tangent of the track dip angle
1154 //-----------------------------------------------------------------
1158 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1160 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1161 if (TMath::Abs(d*c*0.5)>1) return 0;
1162 // Double_t angle2 = TMath::ASin(d*c*0.5);
1163 // Double_t angle2 = TPCFastMath::FastAsin(d*c*0.5);
1164 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): TPCFastMath::FastAsin(d*c*0.5);
1166 angle2 = (z1-z2)*c/(angle2*2.);
1170 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1171 {//-----------------------------------------------------------------
1172 // This function find proloncation of a track to a reference plane x=x2.
1173 //-----------------------------------------------------------------
1177 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1181 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1182 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1186 Double_t dy = dx*(c1+c2)/(r1+r2);
1189 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1191 if (TMath::Abs(delta)>0.01){
1192 dz = x[3]*TMath::ASin(delta)/x[4];
1194 dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1197 //dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1207 Int_t AliTPCtrackerMI::LoadClusters()
1210 // load clusters to the memory
1211 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1212 clrow->SetClass("AliTPCclusterMI");
1214 clrow->GetArray()->ExpandCreateFast(10000);
1216 // TTree * tree = fClustersArray.GetTree();
1218 TTree * tree = fInput;
1219 TBranch * br = tree->GetBranch("Segment");
1220 br->SetAddress(&clrow);
1222 Int_t j=Int_t(tree->GetEntries());
1223 for (Int_t i=0; i<j; i++) {
1227 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1229 AliTPCRow * tpcrow=0;
1232 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1236 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1237 left = (sec-fkNIS*2)/fkNOS;
1240 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1241 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1242 for (Int_t i=0;i<tpcrow->fN1;i++)
1243 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1246 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1247 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1248 for (Int_t i=0;i<tpcrow->fN2;i++)
1249 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1260 void AliTPCtrackerMI::UnloadClusters()
1263 // unload clusters from the memory
1265 Int_t nrows = fOuterSec->GetNRows();
1266 for (Int_t sec = 0;sec<fkNOS;sec++)
1267 for (Int_t row = 0;row<nrows;row++){
1268 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1270 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1271 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1275 nrows = fInnerSec->GetNRows();
1276 for (Int_t sec = 0;sec<fkNIS;sec++)
1277 for (Int_t row = 0;row<nrows;row++){
1278 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1280 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1281 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1289 //_____________________________________________________________________________
1290 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1291 //-----------------------------------------------------------------
1292 // This function fills outer TPC sectors with clusters.
1293 //-----------------------------------------------------------------
1294 Int_t nrows = fOuterSec->GetNRows();
1296 for (Int_t sec = 0;sec<fkNOS;sec++)
1297 for (Int_t row = 0;row<nrows;row++){
1298 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1299 Int_t sec2 = sec+2*fkNIS;
1301 Int_t ncl = tpcrow->fN1;
1303 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1304 index=(((sec2<<8)+row)<<16)+ncl;
1305 tpcrow->InsertCluster(c,index);
1310 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1311 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1312 tpcrow->InsertCluster(c,index);
1315 // write indexes for fast acces
1317 for (Int_t i=0;i<510;i++)
1318 tpcrow->fFastCluster[i]=-1;
1319 for (Int_t i=0;i<tpcrow->GetN();i++){
1320 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1321 tpcrow->fFastCluster[zi]=i; // write index
1324 for (Int_t i=0;i<510;i++){
1325 if (tpcrow->fFastCluster[i]<0)
1326 tpcrow->fFastCluster[i] = last;
1328 last = tpcrow->fFastCluster[i];
1337 //_____________________________________________________________________________
1338 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1339 //-----------------------------------------------------------------
1340 // This function fills inner TPC sectors with clusters.
1341 //-----------------------------------------------------------------
1342 Int_t nrows = fInnerSec->GetNRows();
1344 for (Int_t sec = 0;sec<fkNIS;sec++)
1345 for (Int_t row = 0;row<nrows;row++){
1346 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1349 Int_t ncl = tpcrow->fN1;
1351 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1352 index=(((sec<<8)+row)<<16)+ncl;
1353 tpcrow->InsertCluster(c,index);
1358 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1359 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1360 tpcrow->InsertCluster(c,index);
1363 // write indexes for fast acces
1365 for (Int_t i=0;i<510;i++)
1366 tpcrow->fFastCluster[i]=-1;
1367 for (Int_t i=0;i<tpcrow->GetN();i++){
1368 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1369 tpcrow->fFastCluster[zi]=i; // write index
1372 for (Int_t i=0;i<510;i++){
1373 if (tpcrow->fFastCluster[i]<0)
1374 tpcrow->fFastCluster[i] = last;
1376 last = tpcrow->fFastCluster[i];
1388 //_________________________________________________________________________
1389 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1390 //--------------------------------------------------------------------
1391 // Return pointer to a given cluster
1392 //--------------------------------------------------------------------
1393 Int_t sec=(index&0xff000000)>>24;
1394 Int_t row=(index&0x00ff0000)>>16;
1395 Int_t ncl=(index&0x0000ffff)>>00;
1397 const AliTPCRow * tpcrow=0;
1398 AliTPCclusterMI * clrow =0;
1400 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1402 clrow = tpcrow->fClusters1;
1404 clrow = tpcrow->fClusters2;
1407 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1408 if (sec-2*fkNIS<fkNOS)
1409 clrow = tpcrow->fClusters1;
1411 clrow = tpcrow->fClusters2;
1413 if (tpcrow==0) return 0;
1414 if (tpcrow->GetN()<=ncl) return 0;
1415 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1416 return &(clrow[ncl]);
1422 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1423 //-----------------------------------------------------------------
1424 // This function tries to find a track prolongation to next pad row
1425 //-----------------------------------------------------------------
1427 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1429 // if (t.GetRadius()>x+10 ) return 0;
1430 // t.PropagateTo(x+0.02);
1431 //t.PropagateTo(x+0.01);
1432 if (!t.PropagateTo(x)) {
1437 Double_t y=t.GetY(), z=t.GetZ();
1438 if (TMath::Abs(y)>ymax){
1440 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1441 if (!t.Rotate(fSectors->GetAlpha()))
1443 } else if (y <-ymax) {
1444 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1445 if (!t.Rotate(-fSectors->GetAlpha()))
1448 if (!t.PropagateTo(x)) {
1454 // update current shape info every 3 pad-row
1455 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1456 //t.fCurrentSigmaY = GetSigmaY(&t);
1457 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1461 AliTPCclusterMI *cl=0;
1466 if (t.GetClusterIndex2(nr)>0){
1468 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1469 index = t.GetClusterIndex2(nr);
1470 cl = t.fClusterPointer[nr];
1471 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1472 t.fCurrentClusterIndex1 = index;
1475 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1476 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1478 Double_t roadz = 1.;
1480 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1482 t.SetClusterIndex2(nr,-1);
1487 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1493 t.fCurrentCluster = cl;
1495 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1497 //if founded cluster is acceptible
1498 UpdateTrack(&t,accept);
1504 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1505 cl = krow.FindNearest2(y,z,roady,roadz,index);
1506 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1511 t.fCurrentCluster = cl;
1513 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1515 if (t.fCurrentCluster->IsUsed(10)){
1520 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1526 if (accept<3) UpdateTrack(&t,accept);
1529 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1535 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1536 //-----------------------------------------------------------------
1537 // This function tries to find a track prolongation to next pad row
1538 //-----------------------------------------------------------------
1540 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1542 if (!t.GetProlongation(x,y,z)) {
1548 if (TMath::Abs(y)>ymax){
1552 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1553 if (!t.Rotate(fSectors->GetAlpha()))
1555 } else if (y <-ymax) {
1556 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1557 if (!t.Rotate(-fSectors->GetAlpha()))
1560 if (!t.PropagateTo(x)) {
1563 t.GetProlongation(x,y,z);
1566 // update current shape info every 3 pad-row
1567 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1568 // t.fCurrentSigmaY = GetSigmaY(&t);
1569 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1573 AliTPCclusterMI *cl=0;
1578 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1579 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1581 Double_t roadz = 1.;
1584 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1586 t.SetClusterIndex2(row,-1);
1591 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1595 if ((cl==0)&&(krow)) {
1596 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1597 cl = krow.FindNearest2(y,z,roady,roadz,index);
1599 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1603 t.fCurrentCluster = cl;
1604 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1606 t.SetClusterIndex2(row,index);
1607 t.fClusterPointer[row] = cl;
1615 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1616 //-----------------------------------------------------------------
1617 // This function tries to find a track prolongation to next pad row
1618 //-----------------------------------------------------------------
1619 t.fCurrentCluster = 0;
1620 t.fCurrentClusterIndex1 = 0;
1622 Double_t xt=t.GetX();
1623 Int_t row = GetRowNumber(xt)-1;
1624 Double_t ymax= GetMaxY(nr);
1626 if (row < nr) return 1; // don't prolongate if not information until now -
1627 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1629 return 0; // not prolongate strongly inclined tracks
1631 if (TMath::Abs(t.GetSnp())>0.95) {
1633 return 0; // not prolongate strongly inclined tracks
1636 Double_t x= GetXrow(nr);
1638 //t.PropagateTo(x+0.02);
1639 //t.PropagateTo(x+0.01);
1640 if (!t.PropagateTo(x)){
1647 if (TMath::Abs(y)>ymax){
1649 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1650 if (!t.Rotate(fSectors->GetAlpha()))
1652 } else if (y <-ymax) {
1653 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1654 if (!t.Rotate(-fSectors->GetAlpha()))
1657 if (!t.PropagateTo(x)){
1664 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1666 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1668 t.SetClusterIndex2(nr,-1);
1673 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1679 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1680 // t.fCurrentSigmaY = GetSigmaY(&t);
1681 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1685 AliTPCclusterMI *cl=0;
1688 Double_t roady = 1.;
1689 Double_t roadz = 1.;
1692 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1693 cl = krow.FindNearest2(y,z,roady,roadz,index);
1695 t.fCurrentCluster = cl;
1696 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1701 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1702 //-----------------------------------------------------------------
1703 // This function tries to find a track prolongation to next pad row
1704 //-----------------------------------------------------------------
1706 //update error according neighborhoud
1708 if (t.fCurrentCluster) {
1710 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1712 if (t.fCurrentCluster->IsUsed(10)){
1718 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1724 if (accept<3) UpdateTrack(&t,accept);
1728 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1729 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1731 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1739 //_____________________________________________________________________________
1740 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1741 //-----------------------------------------------------------------
1742 // This function tries to find a track prolongation.
1743 //-----------------------------------------------------------------
1744 Double_t xt=t.GetX();
1746 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1747 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1748 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1750 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1752 Int_t first = GetRowNumber(xt)-1;
1753 for (Int_t nr= first; nr>=rf; nr-=step) {
1754 if (FollowToNext(t,nr)==0)
1755 if (!t.IsActive()) return 0;
1762 //_____________________________________________________________________________
1763 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1764 //-----------------------------------------------------------------
1765 // This function tries to find a track prolongation.
1766 //-----------------------------------------------------------------
1767 Double_t xt=t.GetX();
1769 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1770 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1771 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1772 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1774 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1776 if (FollowToNextFast(t,nr)==0)
1777 if (!t.IsActive()) return 0;
1787 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1788 //-----------------------------------------------------------------
1789 // This function tries to find a track prolongation.
1790 //-----------------------------------------------------------------
1791 // Double_t xt=t.GetX();
1793 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1794 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1795 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1796 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1799 first = t.fFirstPoint+3;
1801 if (first<0) first=0;
1802 for (Int_t nr=first+1; nr<=rf; nr++) {
1803 //if ( (t.GetSnp()<0.9))
1813 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1821 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1824 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1826 Float_t distance = TMath::Sqrt(dz2+dy2);
1827 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1830 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1831 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1836 if (firstpoint>lastpoint) {
1837 firstpoint =lastpoint;
1842 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1843 if (s1->GetClusterIndex2(i)>0) sum1++;
1844 if (s2->GetClusterIndex2(i)>0) sum2++;
1845 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1849 if (sum<5) return 0;
1851 Float_t summin = TMath::Min(sum1+1,sum2+1);
1852 Float_t ratio = (sum+1)/Float_t(summin);
1856 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1860 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1861 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1863 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1865 Float_t dy2 =(s1->GetY() - s2->GetY());
1867 Float_t distance = dz2+dy2;
1868 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1873 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1874 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1876 if (firstpoint>=lastpoint-5) return;;
1878 for (Int_t i=firstpoint;i<lastpoint;i++){
1879 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1880 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1887 for (Int_t i=firstpoint;i<lastpoint;i++){
1888 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1889 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1890 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1891 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1892 if (s1->IsActive()&&s2->IsActive()){
1893 p1->fIsShared = kTRUE;
1894 p2->fIsShared = kTRUE;
1901 for (Int_t i=0;i<4;i++){
1902 if (s1->fOverlapLabels[3*i]==0){
1903 s1->fOverlapLabels[3*i] = s2->GetLabel();
1904 s1->fOverlapLabels[3*i+1] = sumshared;
1905 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1909 for (Int_t i=0;i<4;i++){
1910 if (s2->fOverlapLabels[3*i]==0){
1911 s2->fOverlapLabels[3*i] = s1->GetLabel();
1912 s2->fOverlapLabels[3*i+1] = sumshared;
1913 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1921 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1924 //sort trackss according sectors
1926 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1927 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1929 //if (pt) RotateToLocal(pt);
1933 arr->Sort(); // sorting according z
1934 arr->Expand(arr->GetEntries());
1937 Int_t nseed=arr->GetEntriesFast();
1938 for (Int_t i=0; i<nseed; i++) {
1939 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1941 for (Int_t j=0;j<=12;j++){
1942 pt->fOverlapLabels[j] =0;
1945 for (Int_t i=0; i<nseed; i++) {
1946 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1948 if (pt->fRemoval>10) continue;
1949 for (Int_t j=i+1; j<nseed; j++){
1950 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1952 if (pt2->fRemoval<=10) {
1953 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1960 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1963 //sort trackss according sectors
1966 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1969 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1970 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1975 arr->Sort(); // sorting according z
1976 arr->Expand(arr->GetEntries());
1978 //reset overlap labels
1980 Int_t nseed=arr->GetEntriesFast();
1981 for (Int_t i=0; i<nseed; i++) {
1982 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1985 for (Int_t j=0;j<=12;j++){
1986 pt->fOverlapLabels[j] =0;
1990 //sign shared tracks
1991 for (Int_t i=0; i<nseed; i++) {
1992 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1994 if (pt->fRemoval>10) continue;
1995 Float_t deltac = pt->GetC()*0.1;
1996 for (Int_t j=i+1; j<nseed; j++){
1997 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1999 if (pt2->fRemoval<=10) {
2000 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2001 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2002 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2009 // remove highly shared tracks
2010 for (Int_t i=0; i<nseed; i++) {
2011 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2013 if (pt->fRemoval>10) continue;
2016 for (Int_t j=0;j<4;j++){
2017 sumshared = pt->fOverlapLabels[j*3+1];
2019 Float_t factor = factor1;
2020 if (pt->fRemoval>0) factor = factor2;
2021 if (sumshared/pt->GetNumberOfClusters()>factor){
2022 for (Int_t j=0;j<4;j++){
2023 if (pt->fOverlapLabels[3*j]==0) continue;
2024 if (pt->fOverlapLabels[3*j+1]<5) continue;
2025 if (pt->fRemoval==removalindex) continue;
2026 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2028 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2029 // pt->fRemoval = removalindex;
2030 delete arr->RemoveAt(i);
2038 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2047 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode)
2050 //sort tracks in array according mode criteria
2051 Int_t nseed = arr->GetEntriesFast();
2052 for (Int_t i=0; i<nseed; i++) {
2053 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2063 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2066 //Loop over all tracks and remove "overlaps"
2069 Int_t nseed = arr->GetEntriesFast();
2072 for (Int_t i=0; i<nseed; i++) {
2073 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2075 delete arr->RemoveAt(i);
2079 pt->fBSigned = kFALSE;
2083 nseed = arr->GetEntriesFast();
2090 for (Int_t i=0; i<nseed; i++) {
2091 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2095 Int_t found,foundable,shared;
2097 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2099 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2101 Double_t factor = factor2;
2102 if (pt->fBConstrain) factor = factor1;
2104 if ((Float_t(shared)/Float_t(found))>factor){
2105 pt->Desactivate(removalindex);
2110 for (Int_t i=0; i<160; i++) {
2111 Int_t index=pt->GetClusterIndex2(i);
2112 if (index<0 || index&0x8000 ) continue;
2113 AliTPCclusterMI *c= pt->fClusterPointer[i];
2115 // if (!c->IsUsed(10)) c->Use(10);
2116 //if (pt->IsActive())
2125 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2128 void AliTPCtrackerMI::UnsignClusters()
2131 // loop over all clusters and unsign them
2134 for (Int_t sec=0;sec<fkNIS;sec++){
2135 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2136 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2137 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2138 // if (cl[icl].IsUsed(10))
2140 cl = fInnerSec[sec][row].fClusters2;
2141 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2142 //if (cl[icl].IsUsed(10))
2147 for (Int_t sec=0;sec<fkNOS;sec++){
2148 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2149 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2150 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2151 //if (cl[icl].IsUsed(10))
2153 cl = fOuterSec[sec][row].fClusters2;
2154 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2155 //if (cl[icl].IsUsed(10))
2164 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2167 //sign clusters to be "used"
2169 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2170 // loop over "primaries"
2184 Int_t nseed = arr->GetEntriesFast();
2185 for (Int_t i=0; i<nseed; i++) {
2186 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2190 if (!(pt->IsActive())) continue;
2191 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2192 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2194 sumdens2+= dens*dens;
2195 sumn += pt->GetNumberOfClusters();
2196 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2197 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2200 sumchi2 +=chi2*chi2;
2205 Float_t mdensity = 0.9;
2206 Float_t meann = 130;
2207 Float_t meanchi = 1;
2208 Float_t sdensity = 0.1;
2209 Float_t smeann = 10;
2210 Float_t smeanchi =0.4;
2214 mdensity = sumdens/sum;
2216 meanchi = sumchi/sum;
2218 sdensity = sumdens2/sum-mdensity*mdensity;
2219 sdensity = TMath::Sqrt(sdensity);
2221 smeann = sumn2/sum-meann*meann;
2222 smeann = TMath::Sqrt(smeann);
2224 smeanchi = sumchi2/sum - meanchi*meanchi;
2225 smeanchi = TMath::Sqrt(smeanchi);
2229 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2231 for (Int_t i=0; i<nseed; i++) {
2232 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2236 if (pt->fBSigned) continue;
2237 if (pt->fBConstrain) continue;
2238 //if (!(pt->IsActive())) continue;
2240 Int_t found,foundable,shared;
2241 pt->GetClusterStatistic(0,160,found, foundable,shared);
2242 if (shared/float(found)>0.3) {
2243 if (shared/float(found)>0.9 ){
2244 //delete arr->RemoveAt(i);
2249 Bool_t isok =kFALSE;
2250 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2252 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2254 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2256 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2260 for (Int_t i=0; i<160; i++) {
2261 Int_t index=pt->GetClusterIndex2(i);
2262 if (index<0) continue;
2263 AliTPCclusterMI *c= pt->fClusterPointer[i];
2265 //if (!(c->IsUsed(10))) c->Use();
2272 Double_t maxchi = meanchi+2.*smeanchi;
2274 for (Int_t i=0; i<nseed; i++) {
2275 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2279 //if (!(pt->IsActive())) continue;
2280 if (pt->fBSigned) continue;
2281 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2282 if (chi>maxchi) continue;
2285 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2287 //sign only tracks with enoug big density at the beginning
2289 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2292 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2293 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2295 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2296 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2299 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2300 //Int_t noc=pt->GetNumberOfClusters();
2301 pt->fBSigned = kTRUE;
2302 for (Int_t i=0; i<160; i++) {
2304 Int_t index=pt->GetClusterIndex2(i);
2305 if (index<0) continue;
2306 AliTPCclusterMI *c= pt->fClusterPointer[i];
2308 // if (!(c->IsUsed(10))) c->Use();
2313 // gLastCheck = nseed;
2321 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2)
2323 // stop not active tracks
2324 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2325 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2326 Int_t nseed = arr->GetEntriesFast();
2328 for (Int_t i=0; i<nseed; i++) {
2329 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2333 if (!(pt->IsActive())) continue;
2334 StopNotActive(pt,row0,th0, th1,th2);
2340 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2343 // stop not active tracks
2344 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2345 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2348 Int_t foundable = 0;
2349 Int_t maxindex = seed->fLastPoint; //last foundable row
2350 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2351 seed->Desactivate(10) ;
2355 for (Int_t i=row0; i<maxindex; i++){
2356 Int_t index = seed->GetClusterIndex2(i);
2357 if (index!=-1) foundable++;
2359 if (foundable<=30) sumgood1++;
2360 if (foundable<=50) {
2367 if (foundable>=30.){
2368 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2371 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2376 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2379 // back propagation of ESD tracks
2384 PropagateBack(fSeeds);
2385 Int_t nseed = fSeeds->GetEntriesFast();
2386 for (Int_t i=0;i<nseed;i++){
2387 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2388 AliESDtrack *esd=event->GetTrack(i);
2389 seed->CookdEdx(0.02,0.06);
2390 CookLabel(seed,0.1); //For comparison only
2391 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2399 void AliTPCtrackerMI::DeleteSeeds()
2401 Int_t nseed = fSeeds->GetEntriesFast();
2402 for (Int_t i=0;i<nseed;i++){
2403 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2404 if (seed) delete fSeeds->RemoveAt(i);
2410 void AliTPCtrackerMI::ReadSeeds(AliESD *event)
2413 //read seeds from the event
2415 Int_t nentr=event->GetNumberOfTracks();
2416 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2420 fSeeds = new TObjArray;
2424 for (Int_t i=0; i<nentr; i++) {
2425 AliESDtrack *esd=event->GetTrack(i);
2426 ULong_t status=esd->GetStatus();
2427 const AliTPCtrack t(*esd);
2428 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2429 if (status==AliESDtrack::kTPCin) seed->Modify(0.8);
2432 // rotate to the local coordinate system
2434 fSectors=fInnerSec; fN=fkNIS;
2436 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2437 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2438 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2439 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2440 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2441 alpha-=seed->GetAlpha();
2442 if (!seed->Rotate(alpha)) continue;
2444 seed->PropagateTo(fSectors->GetX(0));
2446 // Int_t index = esd->GetTPCindex();
2447 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2449 fSeeds->AddLast(seed);
2455 //_____________________________________________________________________________
2456 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2457 Float_t deltay, Int_t ddsec) {
2458 //-----------------------------------------------------------------
2459 // This function creates track seeds.
2460 // SEEDING WITH VERTEX CONSTRAIN
2461 //-----------------------------------------------------------------
2462 // cuts[0] - fP4 cut
2463 // cuts[1] - tan(phi) cut
2464 // cuts[2] - zvertex cut
2465 // cuts[3] - fP3 cut
2473 Double_t x[5], c[15];
2474 // Int_t di = i1-i2;
2476 AliTPCseed * seed = new AliTPCseed;
2477 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2478 Double_t cs=cos(alpha), sn=sin(alpha);
2480 // Double_t x1 =fOuterSec->GetX(i1);
2481 //Double_t xx2=fOuterSec->GetX(i2);
2483 Double_t x1 =GetXrow(i1);
2484 Double_t xx2=GetXrow(i2);
2486 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2488 Int_t imiddle = (i2+i1)/2; //middle pad row index
2489 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2490 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2494 const AliTPCRow& kr1=GetRow(ns,i1);
2495 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2496 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2499 // change cut on curvature if it can't reach this layer
2500 // maximal curvature set to reach it
2501 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2502 if (dvertexmax*0.5*cuts[0]>0.85){
2503 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2505 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2508 if (deltay>0) ddsec = 0;
2509 // loop over clusters
2510 for (Int_t is=0; is < kr1; is++) {
2512 if (kr1[is]->IsUsed(10)) continue;
2513 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2514 //if (TMath::Abs(y1)>ymax) continue;
2516 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2518 // find possible directions
2519 Float_t anglez = (z1-z3)/(x1-x3);
2520 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2523 //find rotation angles relative to line given by vertex and point 1
2524 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2525 Double_t dvertex = TMath::Sqrt(dvertex2);
2526 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2527 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2530 // loop over 2 sectors
2536 Double_t dddz1=0; // direction of delta inclination in z axis
2543 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2544 Int_t sec2 = sec + dsec;
2546 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2547 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2548 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2549 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2550 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2551 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2553 // rotation angles to p1-p3
2554 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2555 Double_t x2, y2, z2;
2557 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2560 Double_t dxx0 = (xx2-x3)*cs13r;
2561 Double_t dyy0 = (xx2-x3)*sn13r;
2562 for (Int_t js=index1; js < index2; js++) {
2563 const AliTPCclusterMI *kcl = kr2[js];
2564 if (kcl->IsUsed(10)) continue;
2566 //calcutate parameters
2568 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2570 if (TMath::Abs(yy0)<0.000001) continue;
2571 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2572 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2573 Double_t r02 = (0.25+y0*y0)*dvertex2;
2574 //curvature (radius) cut
2575 if (r02<r2min) continue;
2579 Double_t c0 = 1/TMath::Sqrt(r02);
2583 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2584 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2585 Double_t dfi0 = 2.*TPCFastMath::FastAsin(dvertex*c0*0.5);
2586 Double_t dfi1 = 2.*TPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2589 Double_t z0 = kcl->GetZ();
2590 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2591 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2594 Double_t dip = (z1-z0)*c0/dfi1;
2595 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2606 x2= xx2*cs-y2*sn*dsec;
2607 y2=+xx2*sn*dsec+y2*cs;
2617 // do we have cluster at the middle ?
2619 GetProlongation(x1,xm,x,ym,zm);
2621 AliTPCclusterMI * cm=0;
2622 if (TMath::Abs(ym)-ymaxm<0){
2623 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2624 if ((!cm) || (cm->IsUsed(10))) {
2629 // rotate y1 to system 0
2630 // get state vector in rotated system
2631 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2632 Double_t xr2 = x0*cs+yr1*sn*dsec;
2633 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2635 GetProlongation(xx2,xm,xr,ym,zm);
2636 if (TMath::Abs(ym)-ymaxm<0){
2637 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2638 if ((!cm) || (cm->IsUsed(10))) {
2648 dym = ym - cm->GetY();
2649 dzm = zm - cm->GetZ();
2656 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2657 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2658 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2659 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2660 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2662 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2663 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2664 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2665 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2666 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2667 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2669 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2670 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2671 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2672 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2676 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2677 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2678 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2679 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2680 c[13]=f30*sy1*f40+f32*sy2*f42;
2681 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2683 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2685 UInt_t index=kr1.GetIndex(is);
2686 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2688 track->fIsSeeding = kTRUE;
2695 FollowProlongation(*track, (i1+i2)/2,1);
2696 Int_t foundable,found,shared;
2697 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2698 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2700 seed->~AliTPCseed();
2706 FollowProlongation(*track, i2,1);
2710 track->fBConstrain =1;
2711 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2712 track->fLastPoint = i1; // first cluster in track position
2713 track->fFirstPoint = track->fLastPoint;
2715 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2716 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2717 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2719 seed->~AliTPCseed();
2723 // Z VERTEX CONDITION
2725 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2726 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2727 if (TMath::Abs(zv-z3)>cuts[2]) {
2728 FollowProlongation(*track, TMath::Max(i2-20,0));
2729 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2730 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2731 if (TMath::Abs(zv-z3)>cuts[2]){
2732 FollowProlongation(*track, TMath::Max(i2-40,0));
2733 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2734 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2735 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2736 // make seed without constrain
2737 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2738 FollowProlongation(*track2, i2,1);
2739 track2->fBConstrain = kFALSE;
2740 track2->fSeedType = 1;
2741 arr->AddLast(track2);
2743 seed->~AliTPCseed();
2748 seed->~AliTPCseed();
2755 track->fSeedType =0;
2756 arr->AddLast(track);
2757 seed = new AliTPCseed;
2759 // don't consider other combinations
2760 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2766 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2772 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2777 //-----------------------------------------------------------------
2778 // This function creates track seeds.
2779 //-----------------------------------------------------------------
2780 // cuts[0] - fP4 cut
2781 // cuts[1] - tan(phi) cut
2782 // cuts[2] - zvertex cut
2783 // cuts[3] - fP3 cut
2793 Double_t x[5], c[15];
2795 // make temporary seed
2796 AliTPCseed * seed = new AliTPCseed;
2797 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2798 // Double_t cs=cos(alpha), sn=sin(alpha);
2803 Double_t x1 = GetXrow(i1-1);
2804 const AliTPCRow& kr1=GetRow(sec,i1-1);
2805 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2807 Double_t x1p = GetXrow(i1);
2808 const AliTPCRow& kr1p=GetRow(sec,i1);
2810 Double_t x1m = GetXrow(i1-2);
2811 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2814 //last 3 padrow for seeding
2815 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2816 Double_t x3 = GetXrow(i1-7);
2817 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2819 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2820 Double_t x3p = GetXrow(i1-6);
2822 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2823 Double_t x3m = GetXrow(i1-8);
2828 Int_t im = i1-4; //middle pad row index
2829 Double_t xm = GetXrow(im); // radius of middle pad-row
2830 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2831 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2834 Double_t deltax = x1-x3;
2835 Double_t dymax = deltax*cuts[1];
2836 Double_t dzmax = deltax*cuts[3];
2838 // loop over clusters
2839 for (Int_t is=0; is < kr1; is++) {
2841 if (kr1[is]->IsUsed(10)) continue;
2842 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2844 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2846 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2847 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2853 for (Int_t js=index1; js < index2; js++) {
2854 const AliTPCclusterMI *kcl = kr3[js];
2855 if (kcl->IsUsed(10)) continue;
2857 // apply angular cuts
2858 if (TMath::Abs(y1-y3)>dymax) continue;
2861 if (TMath::Abs(z1-z3)>dzmax) continue;
2863 Double_t angley = (y1-y3)/(x1-x3);
2864 Double_t anglez = (z1-z3)/(x1-x3);
2866 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2867 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2869 Double_t yyym = angley*(xm-x1)+y1;
2870 Double_t zzzm = anglez*(xm-x1)+z1;
2872 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2874 if (kcm->IsUsed(10)) continue;
2876 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2877 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2884 // look around first
2885 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2891 if (kc1m->IsUsed(10)) used++;
2893 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2899 if (kc1p->IsUsed(10)) used++;
2901 if (used>1) continue;
2902 if (found<1) continue;
2906 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2912 if (kc3m->IsUsed(10)) used++;
2916 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2922 if (kc3p->IsUsed(10)) used++;
2926 if (used>1) continue;
2927 if (found<3) continue;
2937 x[4]=f1(x1,y1,x2,y2,x3,y3);
2938 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
2941 x[2]=f2(x1,y1,x2,y2,x3,y3);
2944 x[3]=f3n(x1,y1,x2,y2,z1,z2,x[4]);
2945 //if (TMath::Abs(x[3]) > cuts[3]) continue;
2949 Double_t sy1=0.1, sz1=0.1;
2950 Double_t sy2=0.1, sz2=0.1;
2951 Double_t sy3=0.1, sy=0.1, sz=0.1;
2953 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2954 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2955 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2956 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2957 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2958 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2960 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2961 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2962 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2963 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2967 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2968 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2969 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2970 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2971 c[13]=f30*sy1*f40+f32*sy2*f42;
2972 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2974 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2976 UInt_t index=kr1.GetIndex(is);
2977 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
2979 track->fIsSeeding = kTRUE;
2982 FollowProlongation(*track, i1-7,1);
2983 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
2984 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
2986 seed->~AliTPCseed();
2992 FollowProlongation(*track, i2,1);
2993 track->fBConstrain =0;
2994 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2995 track->fFirstPoint = track->fLastPoint;
2997 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2998 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
2999 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3001 seed->~AliTPCseed();
3006 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3007 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3008 FollowProlongation(*track2, i2,1);
3009 track2->fBConstrain = kFALSE;
3010 track2->fSeedType = 4;
3011 arr->AddLast(track2);
3013 seed->~AliTPCseed();
3017 //arr->AddLast(track);
3018 //seed = new AliTPCseed;
3024 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3030 //_____________________________________________________________________________
3031 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3032 Float_t deltay, Bool_t /*bconstrain*/) {
3033 //-----------------------------------------------------------------
3034 // This function creates track seeds - without vertex constraint
3035 //-----------------------------------------------------------------
3036 // cuts[0] - fP4 cut - not applied
3037 // cuts[1] - tan(phi) cut
3038 // cuts[2] - zvertex cut - not applied
3039 // cuts[3] - fP3 cut
3049 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3050 // Double_t cs=cos(alpha), sn=sin(alpha);
3051 Int_t row0 = (i1+i2)/2;
3052 Int_t drow = (i1-i2)/2;
3053 const AliTPCRow& kr0=fSectors[sec][row0];
3056 AliTPCpolyTrack polytrack;
3057 Int_t nclusters=fSectors[sec][row0];
3058 AliTPCseed * seed = new AliTPCseed;
3063 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3065 Int_t nfoundable =0;
3066 for (Int_t iter =1; iter<2; iter++){ //iterations
3067 const AliTPCRow& krm=fSectors[sec][row0-iter];
3068 const AliTPCRow& krp=fSectors[sec][row0+iter];
3069 const AliTPCclusterMI * cl= kr0[is];
3071 if (cl->IsUsed(10)) {
3077 Double_t x = kr0.GetX();
3078 // Initialization of the polytrack
3083 Double_t y0= cl->GetY();
3084 Double_t z0= cl->GetZ();
3088 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3089 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3091 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3092 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3093 polytrack.AddPoint(x,y0,z0,erry, errz);
3096 if (cl->IsUsed(10)) sumused++;
3099 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3100 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3103 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3104 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3105 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3106 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3107 if (cl1->IsUsed(10)) sumused++;
3108 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3112 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3114 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3115 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3116 if (cl2->IsUsed(10)) sumused++;
3117 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3120 if (sumused>0) continue;
3122 polytrack.UpdateParameters();
3128 nfoundable = polytrack.GetN();
3129 nfound = nfoundable;
3131 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3132 Float_t maxdist = 0.8*(1.+3./(ddrow));
3133 for (Int_t delta = -1;delta<=1;delta+=2){
3134 Int_t row = row0+ddrow*delta;
3135 kr = &(fSectors[sec][row]);
3136 Double_t xn = kr->GetX();
3137 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3138 polytrack.GetFitPoint(xn,yn,zn);
3139 if (TMath::Abs(yn)>ymax) continue;
3141 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3143 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3146 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3147 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3148 if (cln->IsUsed(10)) {
3149 // printf("used\n");
3157 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3162 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3163 polytrack.UpdateParameters();
3166 if ( (sumused>3) || (sumused>0.5*nfound)) {
3167 //printf("sumused %d\n",sumused);
3172 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3173 AliTPCpolyTrack track2;
3175 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3176 if (track2.GetN()<0.5*nfoundable) continue;
3179 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3181 // test seed with and without constrain
3182 for (Int_t constrain=0; constrain<=0;constrain++){
3183 // add polytrack candidate
3185 Double_t x[5], c[15];
3186 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3187 track2.GetBoundaries(x3,x1);
3189 track2.GetFitPoint(x1,y1,z1);
3190 track2.GetFitPoint(x2,y2,z2);
3191 track2.GetFitPoint(x3,y3,z3);
3193 //is track pointing to the vertex ?
3196 polytrack.GetFitPoint(x0,y0,z0);
3209 x[4]=f1(x1,y1,x2,y2,x3,y3);
3211 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3212 x[2]=f2(x1,y1,x2,y2,x3,y3);
3214 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3215 //x[3]=f3(x1,y1,x2,y2,z1,z2);
3216 x[3]=f3n(x1,y1,x3,y3,z1,z3,x[4]);
3217 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3220 Double_t sy =0.1, sz =0.1;
3221 Double_t sy1=0.02, sz1=0.02;
3222 Double_t sy2=0.02, sz2=0.02;
3226 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3229 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3230 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3231 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3232 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3233 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3234 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3236 Double_t f30=(f3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3237 Double_t f31=(f3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3238 Double_t f32=(f3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3239 Double_t f34=(f3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3244 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3245 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3246 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3247 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3248 c[13]=f30*sy1*f40+f32*sy2*f42;
3249 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3251 //Int_t row1 = fSectors->GetRowNumber(x1);
3252 Int_t row1 = GetRowNumber(x1);
3256 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3257 track->fIsSeeding = kTRUE;
3258 Int_t rc=FollowProlongation(*track, i2);
3259 if (constrain) track->fBConstrain =1;
3261 track->fBConstrain =0;
3262 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3263 track->fFirstPoint = track->fLastPoint;
3265 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3266 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3267 track->fNShared>0.4*track->GetNumberOfClusters()) {
3270 seed->~AliTPCseed();
3273 arr->AddLast(track);
3274 seed = new AliTPCseed;
3278 } // if accepted seed
3281 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3287 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3292 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3293 Int_t p1 = int(r1*track->GetNumberOfClusters());
3294 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3296 Double_t x0[3],x1[3],x2[3];
3301 // find track position at given ratio of the length
3302 Int_t sec0, sec1, sec2;
3308 for (Int_t i=0;i<160;i++){
3309 if (track->fClusterPointer[i]){
3311 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3312 if ( (index<p0) || x0[0]<0 ){
3313 if (trpoint->GetX()>1){
3314 clindex = track->GetClusterIndex2(i);
3316 x0[0] = trpoint->GetX();
3317 x0[1] = trpoint->GetY();
3318 x0[2] = trpoint->GetZ();
3319 sec0 = ((clindex&0xff000000)>>24)%18;
3324 if ( (index<p1) &&(trpoint->GetX()>1)){
3325 clindex = track->GetClusterIndex2(i);
3327 x1[0] = trpoint->GetX();
3328 x1[1] = trpoint->GetY();
3329 x1[2] = trpoint->GetZ();
3330 sec1 = ((clindex&0xff000000)>>24)%18;
3333 if ( (index<p2) &&(trpoint->GetX()>1)){
3334 clindex = track->GetClusterIndex2(i);
3336 x2[0] = trpoint->GetX();
3337 x2[1] = trpoint->GetY();
3338 x2[2] = trpoint->GetZ();
3339 sec2 = ((clindex&0xff000000)>>24)%18;
3346 Double_t alpha, cs,sn, xx2,yy2;
3348 alpha = (sec1-sec2)*fSectors->GetAlpha();
3349 cs = TMath::Cos(alpha);
3350 sn = TMath::Sin(alpha);
3351 xx2= x1[0]*cs-x1[1]*sn;
3352 yy2= x1[0]*sn+x1[1]*cs;
3356 alpha = (sec0-sec2)*fSectors->GetAlpha();
3357 cs = TMath::Cos(alpha);
3358 sn = TMath::Sin(alpha);
3359 xx2= x0[0]*cs-x0[1]*sn;
3360 yy2= x0[0]*sn+x0[1]*cs;
3366 Double_t x[5],c[15];
3370 x[4]=f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3371 // if (x[4]>1) return 0;
3372 x[2]=f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3373 x[3]=f3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3374 //if (TMath::Abs(x[3]) > 2.2) return 0;
3375 //if (TMath::Abs(x[2]) > 1.99) return 0;
3377 Double_t sy =0.1, sz =0.1;
3379 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3380 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3381 Double_t sy3=0.01+track->GetSigmaY2();
3383 Double_t f40=(f1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3384 Double_t f42=(f1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3385 Double_t f43=(f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3386 Double_t f20=(f2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3387 Double_t f22=(f2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3388 Double_t f23=(f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3390 Double_t f30=(f3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3391 Double_t f31=(f3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3392 Double_t f32=(f3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3393 Double_t f34=(f3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3398 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3399 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3400 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3401 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3402 c[13]=f30*sy1*f40+f32*sy2*f42;
3403 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3405 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3406 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3407 // Double_t y0,z0,y1,z1, y2,z2;
3408 //seed->GetProlongation(x0[0],y0,z0);
3409 // seed->GetProlongation(x1[0],y1,z1);
3410 //seed->GetProlongation(x2[0],y2,z2);
3412 seed->fLastPoint = pp2;
3413 seed->fFirstPoint = pp2;
3419 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3424 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3426 if (TMath::Abs(seed->GetC())>0.01) return 0;
3429 Float_t x[160], y[160], erry[160], z[160], errz[160];
3431 Float_t xt[160], yt[160], zt[160];
3436 Int_t middle = seed->GetNumberOfClusters()/2;
3439 // find central sector, get local cooordinates
3441 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3442 sec[i]= seed->GetClusterSector(i)%18;
3445 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3446 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3453 if (i>i2) i2 = i; //last point with cluster
3454 if (i2<i1) i1 = i; //first point with cluster
3457 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3459 yt[i] = point->GetY();
3460 zt[i] = point->GetZ();
3462 if (point->GetX()>0){
3463 erry[i] = point->GetErrY();
3464 errz[i] = point->GetErrZ();
3469 secm = sec[i]; //central sector
3470 padm = i; //middle point with cluster
3475 // rotate position to global coordinate system connected to sector at last the point
3477 for (Int_t i=i1;i<=i2;i++){
3479 if (sec[i]<0) continue;
3480 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3481 Double_t cs = TMath::Cos(alpha);
3482 Double_t sn = TMath::Sin(alpha);
3483 Float_t xx2= x[i]*cs+y[i]*sn;
3484 Float_t yy2= -x[i]*sn+y[i]*cs;
3488 xx2= xt[i]*cs+yt[i]*sn;
3489 yy2= -xt[i]*sn+yt[i]*cs;
3494 //get "state" vector
3495 Double_t xh[5],xm = x[padm];
3498 xh[4]=f1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3499 xh[2]=f2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3500 xh[3]=f3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3503 for (Int_t i=i1;i<=i2;i++){
3505 if (sec[i]<0) continue;
3506 GetProlongation(x[i2], x[i],xh,yy,zz);
3507 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3509 //xxh[4]=f1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3510 //xxh[2]=f2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3511 printf("problem\n");
3516 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3517 Float_t yup[160], ydown[160], zup[160], zdown[160];
3519 AliTPCpolyTrack ptrack1,ptrack2;
3522 for (Int_t i=i1;i<=i2;i++){
3523 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3525 if (cl->GetType()<0) continue;
3526 if (cl->GetType()>10) continue;
3529 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3531 if (ptrack1.GetN()>4.){
3532 ptrack1.UpdateParameters();
3534 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3536 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3545 dyup[i]=0.; //not enough points
3550 for (Int_t i=i2;i>=i1;i--){
3551 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3553 if (cl->GetType()<0) continue;
3554 if (cl->GetType()>10) continue;
3556 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3558 if (ptrack2.GetN()>4){
3559 ptrack2.UpdateParameters();
3561 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3563 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3571 dydown[i]=0.; //not enough points
3576 // find maximal difference of the derivation
3577 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3580 for (Int_t i=i1+10;i<i2-10;i++){
3581 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3582 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3584 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3585 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3586 if ( (ddy+ddz)> th){
3587 seed->fKinkPoint[0] = i;
3588 seed->fKinkPoint[1] = ddy;
3589 seed->fKinkPoint[2] = ddz;
3596 //write information to the debug tree
3597 TBranch * br = fTreeDebug->GetBranch("debug");
3598 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3599 arr->ExpandCreateFast(i2-i1);
3600 br->SetAddress(&arr);
3602 AliTPCclusterMI cldummy;
3604 AliTPCTrackPoint2 pdummy;
3605 pdummy.GetTPoint().fIsShared = 10;
3607 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3608 Double_t cs = TMath::Cos(alpha);
3609 Double_t sn = TMath::Sin(alpha);
3611 for (Int_t i=i1;i<i2;i++){
3612 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3614 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3616 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3619 Double_t x = GetXrow(i);
3620 trpoint->GetTPoint() = *point;
3621 trpoint->GetCPoint() = *cl0;
3622 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3623 trpoint->fID = seed->GetUniqueID();
3624 trpoint->fLab = seed->GetLabel();
3626 trpoint->fGX = cs *x + sn*point->GetY();
3627 trpoint->fGY = -sn *x + cs*point->GetY() ;
3628 trpoint->fGZ = point->GetZ();
3630 trpoint->fDY = y[i];
3631 trpoint->fDZ = z[i];
3633 trpoint->fDYU = dyup[i];
3634 trpoint->fDZU = dzup[i];
3636 trpoint->fDYD = dydown[i];
3637 trpoint->fDZD = dzdown[i];
3639 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3640 trpoint->fDDY = dydown[i]-dyup[i];
3641 trpoint->fDDZ = dzdown[i]-dzup[i];
3649 trpoint->GetCPoint()= cldummy;
3666 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3669 // reseed - refit - track
3672 // Int_t last = fSectors->GetNRows()-1;
3674 if (fSectors == fOuterSec){
3675 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3679 first = t->fFirstPoint;
3681 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3682 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3684 FollowProlongation(*t,first);
3694 //_____________________________________________________________________________
3695 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3696 //-----------------------------------------------------------------
3697 // This function reades track seeds.
3698 //-----------------------------------------------------------------
3699 TDirectory *savedir=gDirectory;
3701 TFile *in=(TFile*)inp;
3702 if (!in->IsOpen()) {
3703 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3708 TTree *seedTree=(TTree*)in->Get("Seeds");
3710 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3711 cerr<<"can't get a tree with track seeds !\n";
3714 AliTPCtrack *seed=new AliTPCtrack;
3715 seedTree->SetBranchAddress("tracks",&seed);
3717 if (fSeeds==0) fSeeds=new TObjArray(15000);
3719 Int_t n=(Int_t)seedTree->GetEntries();
3720 for (Int_t i=0; i<n; i++) {
3721 seedTree->GetEvent(i);
3722 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3731 //_____________________________________________________________________________
3732 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3733 //-----------------------------------------------------------------
3734 // This is a track finder.
3735 //-----------------------------------------------------------------
3736 TDirectory *savedir=gDirectory;
3739 if (!fInput) SetIO(); //set default IO using loaders
3741 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
3747 fSeeds = Tracking();
3750 printf("Time for tracking: \t");timer.Print();timer.Start();
3752 //activate again some tracks
3753 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3754 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3756 Int_t nc=t.GetNumberOfClusters();
3758 delete fSeeds->RemoveAt(i);
3761 if (pt->fRemoval==10) {
3762 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3763 pt->Desactivate(10); // make track again active
3765 pt->Desactivate(20);
3766 delete fSeeds->RemoveAt(i);
3770 RemoveDouble(fSeeds,0.2,0.6,11);
3771 //RemoveUsed(fSeeds,0.9,0.9,6);
3772 //RemoveUsed(fSeeds,0.8,0.8,6);
3773 //RemoveUsed(fSeeds,0.7,0.7,6);
3774 RemoveUsed(fSeeds,0.5,0.5,6);
3777 Int_t nseed=fSeeds->GetEntriesFast();
3779 for (Int_t i=0; i<nseed; i++) {
3780 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3782 Int_t nc=t.GetNumberOfClusters();
3784 delete fSeeds->RemoveAt(i);
3787 CookLabel(pt,0.1); //For comparison only
3788 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3789 if ((pt->IsActive() || (pt->fRemoval==10) )){
3790 cerr<<found++<<'\r';
3793 delete fSeeds->RemoveAt(i);
3798 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3800 //RemoveUsed(fSeeds,0.9,0.9,6);
3802 nseed=fSeeds->GetEntriesFast();
3804 for (Int_t i=0; i<nseed; i++) {
3805 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3807 Int_t nc=t.GetNumberOfClusters();
3809 delete fSeeds->RemoveAt(i);
3813 t.CookdEdx(0.02,0.6);
3814 // CheckKinkPoint(&t,0.05);
3815 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3816 if ((pt->IsActive() || (pt->fRemoval==10) )){
3817 cerr<<found++<<'\r';
3820 delete fSeeds->RemoveAt(i);
3824 SortTracks(fSeeds, 1);
3828 PrepareForBackProlongation(fSeeds,0.5);
3829 PropagateBack(fSeeds);
3830 printf("Time for back propagation: \t");timer.Print();timer.Start();
3834 PrepareForProlongation(fSeeds,1.);
3837 fSectors = fOuterSec;
3838 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3839 fSectors = fInnerSec;
3840 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3841 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
3842 // RemoveUsed(fSeeds,0.7,0.7,6);
3843 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
3845 nseed=fSeeds->GetEntriesFast();
3847 for (Int_t i=0; i<nseed; i++) {
3848 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3850 Int_t nc=t.GetNumberOfClusters();
3852 delete fSeeds->RemoveAt(i);
3855 t.CookdEdx(0.02,0.6);
3856 // CookLabel(pt,0.1); //For comparison only
3857 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3858 if ((pt->IsActive() || (pt->fRemoval==10) )){
3859 cerr<<found++<<'\r';
3862 delete fSeeds->RemoveAt(i);
3867 // fNTracks = found;
3868 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
3873 if (!fNewIO) fOutput->Write();
3875 AliRunLoader::GetDetectorLoader("TPC",AliConfig::fgkDefaultEventFolderName)->WriteTracks("OVERWRITE");
3878 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
3880 //if (seedtree) delete seedtree;
3881 // UnloadClusters();
3882 //printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
3887 void AliTPCtrackerMI::Tracking(TObjArray * arr)
3890 // tracking of the seeds
3893 fSectors = fOuterSec;
3894 ParallelTracking(arr,150,63);
3895 fSectors = fOuterSec;
3896 ParallelTracking(arr,63,0);
3899 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
3904 TObjArray * arr = new TObjArray;
3906 fSectors = fOuterSec;
3909 for (Int_t sec=0;sec<fkNOS;sec++){
3910 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
3911 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
3912 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
3915 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
3927 TObjArray * AliTPCtrackerMI::Tracking()
3933 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
3935 TObjArray * seeds = new TObjArray;
3944 Float_t fnumber = 3.0;
3945 Float_t fdensity = 3.0;
3950 for (Int_t delta = 0; delta<18; delta+=6){
3954 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
3955 SumTracks(seeds,arr);
3956 SignClusters(seeds,fnumber,fdensity);
3958 for (Int_t i=2;i<6;i+=2){
3959 // seed high pt tracks
3962 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
3963 SumTracks(seeds,arr);
3964 SignClusters(seeds,fnumber,fdensity);
3969 // RemoveUsed(seeds,0.9,0.9,1);
3970 // UnsignClusters();
3971 // SignClusters(seeds,fnumber,fdensity);
3975 for (Int_t delta = 20; delta<120; delta+=10){
3977 // seed high pt tracks
3981 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
3982 SumTracks(seeds,arr);
3983 SignClusters(seeds,fnumber,fdensity);
3988 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
3989 SumTracks(seeds,arr);
3990 SignClusters(seeds,fnumber,fdensity);
4001 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4005 // RemoveUsed(seeds,0.75,0.75,1);
4007 //SignClusters(seeds,fnumber,fdensity);
4016 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4017 SumTracks(seeds,arr);
4018 SignClusters(seeds,fnumber,fdensity);
4020 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4021 SumTracks(seeds,arr);
4022 SignClusters(seeds,fnumber,fdensity);
4024 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4025 SumTracks(seeds,arr);
4026 SignClusters(seeds,fnumber,fdensity);
4030 for (Int_t delta = 3; delta<30; delta+=5){
4036 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4037 SumTracks(seeds,arr);
4038 SignClusters(seeds,fnumber,fdensity);
4040 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4041 SumTracks(seeds,arr);
4042 SignClusters(seeds,fnumber,fdensity);
4054 for (Int_t delta = 30; delta<70; delta+=10){
4060 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4061 SumTracks(seeds,arr);
4062 SignClusters(seeds,fnumber,fdensity);
4064 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4065 SumTracks(seeds,arr);
4066 SignClusters(seeds,fnumber,fdensity);
4070 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4081 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2)
4084 //sum tracks to common container
4085 //remove suspicious tracks
4086 Int_t nseed = arr2->GetEntriesFast();
4087 for (Int_t i=0;i<nseed;i++){
4088 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4091 // NORMAL ACTIVE TRACK
4092 if (pt->IsActive()){
4093 arr1->AddLast(arr2->RemoveAt(i));
4096 //remove not usable tracks
4097 if (pt->fRemoval!=10){
4098 delete arr2->RemoveAt(i);
4101 // REMOVE VERY SHORT TRACKS
4102 if (pt->GetNumberOfClusters()<20){
4103 delete arr2->RemoveAt(i);
4106 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4107 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4108 arr1->AddLast(arr2->RemoveAt(i));
4110 delete arr2->RemoveAt(i);
4119 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4122 // try to track in parralel
4124 Int_t nseed=arr->GetEntriesFast();
4125 //prepare seeds for tracking
4126 for (Int_t i=0; i<nseed; i++) {
4127 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4129 if (!t.IsActive()) continue;
4130 // follow prolongation to the first layer
4131 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4132 FollowProlongation(t, rfirst+1);
4137 for (Int_t nr=rfirst; nr>=rlast; nr--){
4138 // make indexes with the cluster tracks for given
4140 // find nearest cluster
4141 for (Int_t i=0; i<nseed; i++) {
4142 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4144 if (!pt->IsActive()) continue;
4145 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4146 if (pt->fRelativeSector>17) {
4149 UpdateClusters(t,nr);
4151 // prolonagate to the nearest cluster - if founded
4152 for (Int_t i=0; i<nseed; i++) {
4153 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4155 if (!pt->IsActive()) continue;
4156 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4157 if (pt->fRelativeSector>17) {
4160 FollowToNextCluster(*pt,nr);
4165 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac)
4169 // if we use TPC track itself we have to "update" covariance
4171 Int_t nseed= arr->GetEntriesFast();
4172 for (Int_t i=0;i<nseed;i++){
4173 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4177 //rotate to current local system at first accepted point
4178 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4179 Int_t sec = (index&0xff000000)>>24;
4181 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4182 if (angle1>TMath::Pi())
4183 angle1-=2.*TMath::Pi();
4184 Float_t angle2 = pt->GetAlpha();
4186 if (TMath::Abs(angle1-angle2)>0.001){
4187 pt->Rotate(angle1-angle2);
4188 //angle2 = pt->GetAlpha();
4189 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4190 //if (pt->GetAlpha()<0)
4191 // pt->fRelativeSector+=18;
4192 //sec = pt->fRelativeSector;
4201 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac)
4205 // if we use TPC track itself we have to "update" covariance
4207 Int_t nseed= arr->GetEntriesFast();
4208 for (Int_t i=0;i<nseed;i++){
4209 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4212 pt->fFirstPoint = pt->fLastPoint;
4220 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4223 // make back propagation
4225 Int_t nseed= arr->GetEntriesFast();
4226 for (Int_t i=0;i<nseed;i++){
4227 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4229 AliTPCseed *pt2 = new AliTPCseed(*pt);
4230 fSectors = fInnerSec;
4231 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4232 fSectors = fOuterSec;
4233 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4234 fSectors = fOuterSec;
4235 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4236 printf("\n%d",pt->GetLabel());
4237 fSectors = fInnerSec;
4238 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4239 fSectors = fOuterSec;
4240 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4241 fSectors = fOuterSec;
4249 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4252 // make forward propagation
4254 Int_t nseed= arr->GetEntriesFast();
4255 for (Int_t i=0;i<nseed;i++){
4256 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4258 AliTPCseed *pt2 = new AliTPCseed(*pt);
4259 fSectors = fOuterSec;
4260 FollowProlongation(*pt,0);
4261 fSectors = fOuterSec;
4262 FollowProlongation(*pt,0);
4263 fSectors = fInnerSec;
4264 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4265 printf("\n%d",pt->GetLabel());
4266 fSectors = fOuterSec;
4267 FollowProlongation(*pt2,0);
4268 fSectors = fOuterSec;
4269 FollowProlongation(*pt2,0);
4270 fSectors = fOuterSec;
4278 Int_t AliTPCtrackerMI::PropagateForward()
4280 fSectors = fOuterSec;
4281 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4282 fSectors = fInnerSec;
4283 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4293 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4296 // make back propagation, in between row0 and row1
4300 fSectors = fInnerSec;
4303 if (row1<fSectors->GetNRows())
4306 r1 = fSectors->GetNRows()-1;
4308 if (row0<fSectors->GetNRows()&& r1>0 )
4309 FollowBackProlongation(*pt,r1);
4310 if (row1<=fSectors->GetNRows())
4313 r1 = row1 - fSectors->GetNRows();
4314 if (r1<=0) return 0;
4315 if (r1>=fOuterSec->GetNRows()) return 0;
4316 fSectors = fOuterSec;
4317 return FollowBackProlongation(*pt,r1);
4325 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4329 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4330 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4331 Float_t padlength = GetPadPitchLength(row);