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.15 2003/09/29 11:56:58 kowal2
21 Revision 1.14 2003/09/29 11:39:43 kowal2
24 Revision 1.13 2003/09/29 11:28:19 kowal2
27 Revision 1.9.4.3 2003/06/23 14:47:10 hristov
30 Revision 1.9.4.2 2003/06/23 10:06:13 hristov
31 Updated information about the overlapping clusters (M.Ivanov)
33 Revision 1.9.4.1 2003/06/19 06:59:58 hristov
34 Updated version of parallel tracking (M.Ivanov)
36 Revision 1.9 2003/03/19 17:14:11 hristov
37 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)
39 Revision 1.8 2003/03/05 11:16:15 kowal2
51 AliTPC parallel tracker -
53 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
54 run AliTPCFindTracksMI.C macro - to find tracks
55 tracks are written to AliTPCtracks.root file
56 for comparison also seeds are written to the same file - to special branch
59 //-------------------------------------------------------
60 // Implementation of the TPC tracker
62 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
64 //-------------------------------------------------------
65 #include <TObjArray.h>
68 #include "Riostream.h"
70 #include "AliTPCtrackerMI.h"
71 #include "AliTPCclusterMI.h"
72 #include "AliTPCParam.h"
73 #include "AliTPCClustersRow.h"
74 #include "AliComplexCluster.h"
75 #include "AliTPCpolyTrack.h"
76 #include "TStopwatch.h"
81 #include "AliRunLoader.h"
86 ClassImp(AliTPCtrackerMI)
92 static Double_t FastAsin(Double_t x);
94 static Double_t fgFastAsin[20000];
97 Double_t TPCFastMath::fgFastAsin[20000];
99 TPCFastMath::TPCFastMath(){
100 for (Int_t i=0;i<10000;i++){
101 fgFastAsin[2*i] = TMath::ASin(i/10000.);
102 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
106 Double_t TPCFastMath::FastAsin(Double_t x){
108 Int_t index = int(x*10000);
109 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
112 Int_t index = int(x*10000);
113 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
116 TPCFastMath gTPCMath;
120 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
122 AliTPCclusterMI* c =track->fCurrentCluster;
123 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
125 UInt_t i = track->fCurrentClusterIndex1;
127 Int_t sec=(i&0xff000000)>>24;
128 //Int_t row = (i&0x00ff0000)>>16;
129 track->fRow=(i&0x00ff0000)>>16;
130 track->fSector = sec;
131 // Int_t index = i&0xFFFF;
132 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
133 track->SetClusterIndex2(track->fRow, i);
135 //track->fFirstPoint = row;
136 //if ( track->fLastPoint<row) track->fLastPoint =row;
137 // if (track->fRow<0 || track->fRow>160) {
138 // printf("problem\n");
140 if (track->fFirstPoint>track->fRow)
141 track->fFirstPoint = track->fRow;
142 if (track->fLastPoint<track->fRow)
143 track->fLastPoint = track->fRow;
146 track->fClusterPointer[track->fRow] = c;
149 Float_t angle2 = track->GetSnp()*track->GetSnp();
150 angle2 = TMath::Sqrt(angle2/(1-angle2));
152 //SET NEW Track Point
156 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
158 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
159 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
160 point.SetErrY(sqrt(track->fErrorY2));
161 point.SetErrZ(sqrt(track->fErrorZ2));
163 point.SetX(track->GetX());
164 point.SetY(track->GetY());
165 point.SetZ(track->GetZ());
166 point.SetAngleY(angle2);
167 point.SetAngleZ(track->GetTgl());
168 if (point.fIsShared){
169 track->fErrorY2 *= 4;
170 track->fErrorZ2 *= 4;
174 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
176 track->fErrorY2 *= 1.3;
177 track->fErrorY2 += 0.01;
178 track->fErrorZ2 *= 1.3;
179 track->fErrorZ2 += 0.005;
181 if (accept>0) return 0;
182 if (track->GetNumberOfClusters()%20==0){
183 // if (track->fHelixIn){
184 // TClonesArray & larr = *(track->fHelixIn);
185 // Int_t ihelix = larr.GetEntriesFast();
186 // new(larr[ihelix]) AliHelix(*track) ;
189 track->fNoCluster =0;
190 return track->Update(c,chi2,i);
195 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
196 Float_t cory, Float_t corz)
199 // decide according desired precision to accept given
200 // cluster for tracking
201 Double_t sy2=ErrY2(seed,cluster)*cory;
202 Double_t sz2=ErrZ2(seed,cluster)*corz;
203 //sy2=ErrY2(seed,cluster)*cory;
204 //sz2=ErrZ2(seed,cluster)*cory;
206 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
207 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
209 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
210 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
211 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
212 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
214 Double_t rdistance2 = rdistancey2+rdistancez2;
217 if (rdistance2>16) return 3;
220 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
221 return 2; //suspisiouce - will be changed
223 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
224 // strict cut on overlaped cluster
225 return 2; //suspisiouce - will be changed
227 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
228 && cluster->GetType()<0){
238 //_____________________________________________________________________________
239 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
240 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
242 //---------------------------------------------------------------------
243 // The main TPC tracker constructor
244 //---------------------------------------------------------------------
245 fInnerSec=new AliTPCSector[fkNIS];
246 fOuterSec=new AliTPCSector[fkNOS];
249 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
250 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
257 Int_t nrowlow = par->GetNRowLow();
258 Int_t nrowup = par->GetNRowUp();
261 for (Int_t i=0;i<nrowlow;i++){
262 fXRow[i] = par->GetPadRowRadiiLow(i);
263 fPadLength[i]= par->GetPadPitchLength(0,i);
264 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
268 for (Int_t i=0;i<nrowup;i++){
269 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
270 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
271 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
284 //_____________________________________________________________________________
285 AliTPCtrackerMI::~AliTPCtrackerMI() {
286 //------------------------------------------------------------------
287 // TPC tracker destructor
288 //------------------------------------------------------------------
297 void AliTPCtrackerMI::SetIO()
301 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
302 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
303 AliTPCtrack *iotrack= new AliTPCtrack;
304 // iotrack->fHelixIn = new TClonesArray("AliHelix");
305 //iotrack->fHelixOut = new TClonesArray("AliHelix");
306 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
310 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
326 AliTPCtrack *iotrack= new AliTPCtrack;
327 // iotrack->fHelixIn = new TClonesArray("AliHelix");
328 //iotrack->fHelixOut = new TClonesArray("AliHelix");
329 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
332 if (output && (fDebug&2)){
333 //write the full seed information if specified in debug mode
335 fSeedTree = new TTree("Seeds","Seeds");
336 AliTPCseed * vseed = new AliTPCseed;
338 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
339 arrtr->ExpandCreateFast(160);
340 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
342 vseed->fPoints = arrtr;
343 vseed->fEPoints = arre;
344 // vseed->fClusterPoints = arrcl;
345 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
348 fTreeDebug = new TTree("trackDebug","trackDebug");
349 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
350 fTreeDebug->Branch("debug",&arrd,32000,99);
358 void AliTPCtrackerMI::WriteTracks()
361 // write tracks to the given output tree -
362 // output specified with SetIO routine
365 // write tracks to the event
366 // store index of the track
367 Int_t nseed=fSeeds->GetEntriesFast();
368 for (Int_t i=0; i<nseed; i++) {
369 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
372 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
373 //iotrack.SetTPCindex(i);
374 fEvent->AddTrack(&iotrack);
380 AliTPCtrack *iotrack= 0;
381 Int_t nseed=fSeeds->GetEntriesFast();
382 for (Int_t i=0; i<nseed; i++) {
383 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
387 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
388 TBranch * br = fOutput->GetBranch("tracks");
389 br->SetAddress(&iotrack);
391 for (Int_t i=0; i<nseed; i++) {
392 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
396 // br->SetAddress(&iotrack);
404 //write the full seed information if specified in debug mode
406 AliTPCseed * vseed = new AliTPCseed;
408 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
409 arrtr->ExpandCreateFast(160);
410 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
411 //arrcl->ExpandCreateFast(160);
412 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
414 vseed->fPoints = arrtr;
415 vseed->fEPoints = arre;
416 // vseed->fClusterPoints = arrcl;
417 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
418 TBranch * brseed = fSeedTree->GetBranch("seeds");
420 Int_t nseed=fSeeds->GetEntriesFast();
422 for (Int_t i=0; i<nseed; i++) {
423 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
426 // pt->fClusterPoints = arrcl;
430 brseed->SetAddress(&vseed);
434 // pt->fClusterPoints = 0;
437 if (fTreeDebug) fTreeDebug->Write();
445 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
448 //seed->SetErrorY2(0.1);
450 //calculate look-up table at the beginning
451 static Bool_t ginit = kFALSE;
452 static Float_t gnoise1,gnoise2,gnoise3;
453 static Float_t ggg1[10000];
454 static Float_t ggg2[10000];
455 static Float_t ggg3[10000];
456 static Float_t glandau1[10000];
457 static Float_t glandau2[10000];
458 static Float_t glandau3[10000];
460 static Float_t gcor01[500];
461 static Float_t gcor02[500];
462 static Float_t gcorp[500];
467 for (Int_t i=1;i<500;i++){
468 Float_t rsigma = float(i)/100.;
469 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
470 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
471 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
475 for (Int_t i=3;i<10000;i++){
479 Float_t amp = float(i);
480 Float_t padlength =0.75;
481 gnoise1 = 0.0004/padlength;
482 Float_t nel = 0.268*amp;
483 Float_t nprim = 0.155*amp;
484 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
485 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
486 if (glandau1[i]>1) glandau1[i]=1;
487 glandau1[i]*=padlength*padlength/12.;
491 gnoise2 = 0.0004/padlength;
494 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
495 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
496 if (glandau2[i]>1) glandau2[i]=1;
497 glandau2[i]*=padlength*padlength/12.;
502 gnoise3 = 0.0004/padlength;
505 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
506 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
507 if (glandau3[i]>1) glandau3[i]=1;
508 glandau3[i]*=padlength*padlength/12.;
516 Int_t amp = int(TMath::Abs(cl->GetQ()));
518 seed->SetErrorY2(1.);
522 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
523 Int_t ctype = cl->GetType();
524 Float_t padlength= GetPadPitchLength(seed->fRow);
525 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
526 angle2 = angle2/(1-angle2);
529 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
532 if (fSectors==fInnerSec){
534 res = ggg1[amp]*z+glandau1[amp]*angle2;
535 if (ctype==0) res *= gcor01[rsigmay];
538 res*= gcorp[rsigmay];
544 res = ggg2[amp]*z+glandau2[amp]*angle2;
545 if (ctype==0) res *= gcor02[rsigmay];
548 res*= gcorp[rsigmay];
553 res = ggg3[amp]*z+glandau3[amp]*angle2;
554 if (ctype==0) res *= gcor02[rsigmay];
557 res*= gcorp[rsigmay];
564 res*=2.4; // overestimate error 2 times
571 seed->SetErrorY2(res);
579 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
582 //seed->SetErrorY2(0.1);
584 //calculate look-up table at the beginning
585 static Bool_t ginit = kFALSE;
586 static Float_t gnoise1,gnoise2,gnoise3;
587 static Float_t ggg1[10000];
588 static Float_t ggg2[10000];
589 static Float_t ggg3[10000];
590 static Float_t glandau1[10000];
591 static Float_t glandau2[10000];
592 static Float_t glandau3[10000];
594 static Float_t gcor01[1000];
595 static Float_t gcor02[1000];
596 static Float_t gcorp[1000];
601 for (Int_t i=1;i<1000;i++){
602 Float_t rsigma = float(i)/100.;
603 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
604 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
605 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
609 for (Int_t i=3;i<10000;i++){
613 Float_t amp = float(i);
614 Float_t padlength =0.75;
615 gnoise1 = 0.0004/padlength;
616 Float_t nel = 0.268*amp;
617 Float_t nprim = 0.155*amp;
618 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
619 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
620 if (glandau1[i]>1) glandau1[i]=1;
621 glandau1[i]*=padlength*padlength/12.;
625 gnoise2 = 0.0004/padlength;
628 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
629 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
630 if (glandau2[i]>1) glandau2[i]=1;
631 glandau2[i]*=padlength*padlength/12.;
636 gnoise3 = 0.0004/padlength;
639 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
640 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
641 if (glandau3[i]>1) glandau3[i]=1;
642 glandau3[i]*=padlength*padlength/12.;
650 Int_t amp = int(TMath::Abs(cl->GetQ()));
652 seed->SetErrorY2(1.);
656 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
657 Int_t ctype = cl->GetType();
658 Float_t padlength= GetPadPitchLength(seed->fRow);
660 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
661 // if (angle2<0.6) angle2 = 0.6;
662 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
665 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
668 if (fSectors==fInnerSec){
670 res = ggg1[amp]*z+glandau1[amp]*angle2;
671 if (ctype==0) res *= gcor01[rsigmaz];
674 res*= gcorp[rsigmaz];
680 res = ggg2[amp]*z+glandau2[amp]*angle2;
681 if (ctype==0) res *= gcor02[rsigmaz];
684 res*= gcorp[rsigmaz];
689 res = ggg3[amp]*z+glandau3[amp]*angle2;
690 if (ctype==0) res *= gcor02[rsigmaz];
693 res*= gcorp[rsigmaz];
702 if ((ctype<0) &&<70){
710 seed->SetErrorZ2(res);
717 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
720 //seed->SetErrorZ2(0.1);
724 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
726 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
727 Int_t ctype = cl->GetType();
728 Float_t amp = TMath::Abs(cl->GetQ());
733 Float_t landau=2 ; //landau fluctuation part
734 Float_t gg=2; // gg fluctuation part
735 Float_t padlength= GetPadPitchLength(seed->GetX());
737 if (fSectors==fInnerSec){
738 snoise2 = 0.0004/padlength;
741 gg = (2+0.001*nel/(padlength*padlength))/nel;
742 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
743 if (landau>1) landau=1;
746 snoise2 = 0.0004/padlength;
749 gg = (2+0.0008*nel/(padlength*padlength))/nel;
750 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
751 if (landau>1) landau=1;
753 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
756 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
757 angle2 = TMath::Sqrt((1-angle2));
758 if (angle2<0.6) angle2 = 0.6;
761 Float_t angle = seed->GetTgl()/angle2;
762 Float_t angular = landau*angle*angle*padlength*padlength/12.;
763 Float_t res = sdiff + angular;
766 if ((ctype==0) && (fSectors ==fOuterSec))
767 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
769 if ((ctype==0) && (fSectors ==fInnerSec))
770 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
774 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
780 if ((ctype<0) &&<70){
788 seed->SetErrorZ2(res);
795 void AliTPCseed::Reset(Bool_t all)
799 SetNumberOfClusters(0);
805 for (Int_t i=0;i<8;i++){
806 delete [] fTrackPoints[i];
814 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
815 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
821 void AliTPCseed::Modify(Double_t factor)
824 //------------------------------------------------------------------
825 //This function makes a track forget its history :)
826 //------------------------------------------------------------------
832 fC10*=factor; fC11*=factor;
833 fC20*=factor; fC21*=factor; fC22*=factor;
834 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
835 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
836 SetNumberOfClusters(0);
840 fCurrentSigmaY2 = 0.000005;
841 fCurrentSigmaZ2 = 0.000005;
850 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
852 //-----------------------------------------------------------------
853 // This function find proloncation of a track to a reference plane x=xk.
854 // doesn't change internal state of the track
855 //-----------------------------------------------------------------
857 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
859 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
863 // Double_t y1=fP0, z1=fP1;
864 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
865 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
869 //y += dx*(c1+c2)/(r1+r2);
870 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
872 Double_t dy = dx*(c1+c2)/(r1+r2);
875 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
877 if (TMath::Abs(delta)>0.0001){
878 dz = fP3*TMath::ASin(delta)/fP4;
880 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
883 dz = fP3*TPCFastMath::FastAsin(delta)/fP4;
893 //_____________________________________________________________________________
894 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
896 //-----------------------------------------------------------------
897 // This function calculates a predicted chi2 increment.
898 //-----------------------------------------------------------------
899 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
900 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
901 r00+=fC00; r01+=fC10; r11+=fC11;
903 Double_t det=r00*r11 - r01*r01;
904 if (TMath::Abs(det) < 1.e-10) {
905 Int_t n=GetNumberOfClusters();
906 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
909 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
911 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
913 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
917 //_________________________________________________________________________________________
920 Int_t AliTPCseed::Compare(const TObject *o) const {
921 //-----------------------------------------------------------------
922 // This function compares tracks according to the sector - for given sector according z
923 //-----------------------------------------------------------------
924 AliTPCseed *t=(AliTPCseed*)o;
927 if (t->fRelativeSector>fRelativeSector) return -1;
928 if (t->fRelativeSector<fRelativeSector) return 1;
929 Double_t z2 = t->GetZ();
930 Double_t z1 = GetZ();
932 if (z2<z1) return -1;
937 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
938 if (t->fBConstrain) f2=1.2;
941 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
943 if (fBConstrain) f1=1.2;
945 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
950 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
952 //rotate to track "local coordinata
953 Float_t x = seed->GetX();
954 Float_t y = seed->GetY();
955 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
958 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
959 if (!seed->Rotate(fSectors->GetAlpha()))
961 } else if (y <-ymax) {
962 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
963 if (!seed->Rotate(-fSectors->GetAlpha()))
972 //_____________________________________________________________________________
973 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
974 //-----------------------------------------------------------------
975 // This function associates a cluster with this track.
976 //-----------------------------------------------------------------
977 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
979 r00+=fC00; r01+=fC10; r11+=fC11;
980 Double_t det=r00*r11 - r01*r01;
981 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
983 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
984 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
985 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
986 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
987 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
989 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
990 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
991 if (TMath::Abs(cur*fX-eta) >= 0.9) {
995 fP0 += k00*dy + k01*dz;
996 fP1 += k10*dy + k11*dz;
998 fP3 += k30*dy + k31*dz;
1001 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1002 Double_t c12=fC21, c13=fC31, c14=fC41;
1004 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1005 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1006 fC40-=k00*c04+k01*c14;
1008 fC11-=k10*c01+k11*fC11;
1009 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1010 fC41-=k10*c04+k11*c14;
1012 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1013 fC42-=k20*c04+k21*c14;
1015 fC33-=k30*c03+k31*c13;
1016 fC43-=k40*c03+k41*c13;
1018 fC44-=k40*c04+k41*c14;
1020 Int_t n=GetNumberOfClusters();
1022 SetNumberOfClusters(n+1);
1023 SetChi2(GetChi2()+chisq);
1030 //_____________________________________________________________________________
1031 Double_t AliTPCtrackerMI::f1old(Double_t x1,Double_t y1,
1032 Double_t x2,Double_t y2,
1033 Double_t x3,Double_t y3)
1035 //-----------------------------------------------------------------
1036 // Initial approximation of the track curvature
1037 //-----------------------------------------------------------------
1038 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1039 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1040 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1041 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1042 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1044 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1045 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1046 return -xr*yr/sqrt(xr*xr+yr*yr);
1051 //_____________________________________________________________________________
1052 Double_t AliTPCtrackerMI::f1(Double_t x1,Double_t y1,
1053 Double_t x2,Double_t y2,
1054 Double_t x3,Double_t y3)
1056 //-----------------------------------------------------------------
1057 // Initial approximation of the track curvature
1058 //-----------------------------------------------------------------
1064 Double_t det = x3*y2-x2*y3;
1069 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1070 Double_t x0 = x3*0.5-y3*u;
1071 Double_t y0 = y3*0.5+x3*u;
1072 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1078 Double_t AliTPCtrackerMI::f2(Double_t x1,Double_t y1,
1079 Double_t x2,Double_t y2,
1080 Double_t x3,Double_t y3)
1082 //-----------------------------------------------------------------
1083 // Initial approximation of the track curvature
1084 //-----------------------------------------------------------------
1090 Double_t det = x3*y2-x2*y3;
1095 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1096 Double_t x0 = x3*0.5-y3*u;
1097 Double_t y0 = y3*0.5+x3*u;
1098 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1107 //_____________________________________________________________________________
1108 Double_t AliTPCtrackerMI::f2old(Double_t x1,Double_t y1,
1109 Double_t x2,Double_t y2,
1110 Double_t x3,Double_t y3)
1112 //-----------------------------------------------------------------
1113 // Initial approximation of the track curvature times center of curvature
1114 //-----------------------------------------------------------------
1115 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1116 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1117 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1118 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1119 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1121 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1123 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1126 //_____________________________________________________________________________
1127 Double_t AliTPCtrackerMI::f3(Double_t x1,Double_t y1,
1128 Double_t x2,Double_t y2,
1129 Double_t z1,Double_t z2)
1131 //-----------------------------------------------------------------
1132 // Initial approximation of the tangent of the track dip angle
1133 //-----------------------------------------------------------------
1134 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1138 Double_t AliTPCtrackerMI::f3n(Double_t x1,Double_t y1,
1139 Double_t x2,Double_t y2,
1140 Double_t z1,Double_t z2, Double_t c)
1142 //-----------------------------------------------------------------
1143 // Initial approximation of the tangent of the track dip angle
1144 //-----------------------------------------------------------------
1148 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1150 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1151 if (TMath::Abs(d*c*0.5)>1) return 0;
1152 // Double_t angle2 = TMath::ASin(d*c*0.5);
1153 // Double_t angle2 = TPCFastMath::FastAsin(d*c*0.5);
1154 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): TPCFastMath::FastAsin(d*c*0.5);
1156 angle2 = (z1-z2)*c/(angle2*2.);
1160 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1161 {//-----------------------------------------------------------------
1162 // This function find proloncation of a track to a reference plane x=x2.
1163 //-----------------------------------------------------------------
1167 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1171 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1172 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1176 Double_t dy = dx*(c1+c2)/(r1+r2);
1179 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1181 if (TMath::Abs(delta)>0.01){
1182 dz = x[3]*TMath::ASin(delta)/x[4];
1184 dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1187 //dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1197 Int_t AliTPCtrackerMI::LoadClusters()
1200 // load clusters to the memory
1201 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1202 clrow->SetClass("AliTPCclusterMI");
1204 clrow->GetArray()->ExpandCreateFast(10000);
1206 // TTree * tree = fClustersArray.GetTree();
1208 TTree * tree = fInput;
1209 TBranch * br = tree->GetBranch("Segment");
1210 br->SetAddress(&clrow);
1212 Int_t j=Int_t(tree->GetEntries());
1213 for (Int_t i=0; i<j; i++) {
1217 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1219 AliTPCRow * tpcrow=0;
1222 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1226 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1227 left = (sec-fkNIS*2)/fkNOS;
1230 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1231 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1232 for (Int_t i=0;i<tpcrow->fN1;i++)
1233 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1236 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1237 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1238 for (Int_t i=0;i<tpcrow->fN2;i++)
1239 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1250 void AliTPCtrackerMI::UnloadClusters()
1253 // unload clusters from the memory
1255 Int_t nrows = fOuterSec->GetNRows();
1256 for (Int_t sec = 0;sec<fkNOS;sec++)
1257 for (Int_t row = 0;row<nrows;row++){
1258 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1260 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1261 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1265 nrows = fInnerSec->GetNRows();
1266 for (Int_t sec = 0;sec<fkNIS;sec++)
1267 for (Int_t row = 0;row<nrows;row++){
1268 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1270 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1271 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1279 //_____________________________________________________________________________
1280 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1281 //-----------------------------------------------------------------
1282 // This function fills outer TPC sectors with clusters.
1283 //-----------------------------------------------------------------
1284 Int_t nrows = fOuterSec->GetNRows();
1286 for (Int_t sec = 0;sec<fkNOS;sec++)
1287 for (Int_t row = 0;row<nrows;row++){
1288 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1289 Int_t sec2 = sec+2*fkNIS;
1291 Int_t ncl = tpcrow->fN1;
1293 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1294 index=(((sec2<<8)+row)<<16)+ncl;
1295 tpcrow->InsertCluster(c,index);
1300 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1301 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1302 tpcrow->InsertCluster(c,index);
1305 // write indexes for fast acces
1307 for (Int_t i=0;i<510;i++)
1308 tpcrow->fFastCluster[i]=-1;
1309 for (Int_t i=0;i<tpcrow->GetN();i++){
1310 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1311 tpcrow->fFastCluster[zi]=i; // write index
1314 for (Int_t i=0;i<510;i++){
1315 if (tpcrow->fFastCluster[i]<0)
1316 tpcrow->fFastCluster[i] = last;
1318 last = tpcrow->fFastCluster[i];
1327 //_____________________________________________________________________________
1328 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1329 //-----------------------------------------------------------------
1330 // This function fills inner TPC sectors with clusters.
1331 //-----------------------------------------------------------------
1332 Int_t nrows = fInnerSec->GetNRows();
1334 for (Int_t sec = 0;sec<fkNIS;sec++)
1335 for (Int_t row = 0;row<nrows;row++){
1336 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1339 Int_t ncl = tpcrow->fN1;
1341 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1342 index=(((sec<<8)+row)<<16)+ncl;
1343 tpcrow->InsertCluster(c,index);
1348 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1349 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1350 tpcrow->InsertCluster(c,index);
1353 // write indexes for fast acces
1355 for (Int_t i=0;i<510;i++)
1356 tpcrow->fFastCluster[i]=-1;
1357 for (Int_t i=0;i<tpcrow->GetN();i++){
1358 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1359 tpcrow->fFastCluster[zi]=i; // write index
1362 for (Int_t i=0;i<510;i++){
1363 if (tpcrow->fFastCluster[i]<0)
1364 tpcrow->fFastCluster[i] = last;
1366 last = tpcrow->fFastCluster[i];
1378 //_________________________________________________________________________
1379 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1380 //--------------------------------------------------------------------
1381 // Return pointer to a given cluster
1382 //--------------------------------------------------------------------
1383 Int_t sec=(index&0xff000000)>>24;
1384 Int_t row=(index&0x00ff0000)>>16;
1385 Int_t ncl=(index&0x0000ffff)>>00;
1387 const AliTPCRow * tpcrow=0;
1388 AliTPCclusterMI * clrow =0;
1390 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1392 clrow = tpcrow->fClusters1;
1394 clrow = tpcrow->fClusters2;
1397 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1398 if (sec-2*fkNIS<fkNOS)
1399 clrow = tpcrow->fClusters1;
1401 clrow = tpcrow->fClusters2;
1403 if (tpcrow==0) return 0;
1404 if (tpcrow->GetN()<=ncl) return 0;
1405 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1406 return &(clrow[ncl]);
1412 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1413 //-----------------------------------------------------------------
1414 // This function tries to find a track prolongation to next pad row
1415 //-----------------------------------------------------------------
1417 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1419 // if (t.GetRadius()>x+10 ) return 0;
1420 // t.PropagateTo(x+0.02);
1421 //t.PropagateTo(x+0.01);
1422 if (!t.PropagateTo(x)) {
1427 Double_t y=t.GetY(), z=t.GetZ();
1428 if (TMath::Abs(y)>ymax){
1430 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1431 if (!t.Rotate(fSectors->GetAlpha()))
1433 } else if (y <-ymax) {
1434 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1435 if (!t.Rotate(-fSectors->GetAlpha()))
1438 if (!t.PropagateTo(x)) {
1444 // update current shape info every 3 pad-row
1445 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1446 //t.fCurrentSigmaY = GetSigmaY(&t);
1447 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1451 AliTPCclusterMI *cl=0;
1456 if (t.GetClusterIndex2(nr)>0){
1458 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1459 index = t.GetClusterIndex2(nr);
1460 cl = t.fClusterPointer[nr];
1461 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1462 t.fCurrentClusterIndex1 = index;
1465 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1466 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1468 Double_t roadz = 1.;
1470 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1472 t.SetClusterIndex2(nr,-1);
1477 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1483 t.fCurrentCluster = cl;
1485 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1487 //if founded cluster is acceptible
1488 UpdateTrack(&t,accept);
1494 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1495 cl = krow.FindNearest2(y,z,roady,roadz,index);
1496 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1501 t.fCurrentCluster = cl;
1503 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1505 if (t.fCurrentCluster->IsUsed(10)){
1510 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1516 if (accept<3) UpdateTrack(&t,accept);
1519 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1525 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1526 //-----------------------------------------------------------------
1527 // This function tries to find a track prolongation to next pad row
1528 //-----------------------------------------------------------------
1530 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1532 if (!t.GetProlongation(x,y,z)) {
1538 if (TMath::Abs(y)>ymax){
1542 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1543 if (!t.Rotate(fSectors->GetAlpha()))
1545 } else if (y <-ymax) {
1546 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1547 if (!t.Rotate(-fSectors->GetAlpha()))
1550 if (!t.PropagateTo(x)) {
1553 t.GetProlongation(x,y,z);
1556 // update current shape info every 3 pad-row
1557 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1558 // t.fCurrentSigmaY = GetSigmaY(&t);
1559 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1563 AliTPCclusterMI *cl=0;
1568 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1569 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1571 Double_t roadz = 1.;
1574 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1576 t.SetClusterIndex2(row,-1);
1581 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1585 if ((cl==0)&&(krow)) {
1586 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1587 cl = krow.FindNearest2(y,z,roady,roadz,index);
1589 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1593 t.fCurrentCluster = cl;
1594 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1596 t.SetClusterIndex2(row,index);
1597 t.fClusterPointer[row] = cl;
1605 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1606 //-----------------------------------------------------------------
1607 // This function tries to find a track prolongation to next pad row
1608 //-----------------------------------------------------------------
1609 t.fCurrentCluster = 0;
1610 t.fCurrentClusterIndex1 = 0;
1612 Double_t xt=t.GetX();
1613 Int_t row = GetRowNumber(xt)-1;
1614 Double_t ymax= GetMaxY(nr);
1616 if (row < nr) return 1; // don't prolongate if not information until now -
1617 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1619 return 0; // not prolongate strongly inclined tracks
1621 if (TMath::Abs(t.GetSnp())>0.95) {
1623 return 0; // not prolongate strongly inclined tracks
1626 Double_t x= GetXrow(nr);
1628 //t.PropagateTo(x+0.02);
1629 //t.PropagateTo(x+0.01);
1630 if (!t.PropagateTo(x)){
1637 if (TMath::Abs(y)>ymax){
1639 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1640 if (!t.Rotate(fSectors->GetAlpha()))
1642 } else if (y <-ymax) {
1643 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1644 if (!t.Rotate(-fSectors->GetAlpha()))
1647 if (!t.PropagateTo(x)){
1654 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1656 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1658 t.SetClusterIndex2(nr,-1);
1663 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1669 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1670 // t.fCurrentSigmaY = GetSigmaY(&t);
1671 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1675 AliTPCclusterMI *cl=0;
1678 Double_t roady = 1.;
1679 Double_t roadz = 1.;
1682 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1683 cl = krow.FindNearest2(y,z,roady,roadz,index);
1685 t.fCurrentCluster = cl;
1686 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1691 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1692 //-----------------------------------------------------------------
1693 // This function tries to find a track prolongation to next pad row
1694 //-----------------------------------------------------------------
1696 //update error according neighborhoud
1698 if (t.fCurrentCluster) {
1700 Bool_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1702 if (t.fCurrentCluster->IsUsed(10)){
1708 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1714 if (accept<3) UpdateTrack(&t,accept);
1718 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1719 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1721 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1729 //_____________________________________________________________________________
1730 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1731 //-----------------------------------------------------------------
1732 // This function tries to find a track prolongation.
1733 //-----------------------------------------------------------------
1734 Double_t xt=t.GetX();
1736 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1737 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1738 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1740 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1742 Int_t first = GetRowNumber(xt)-1;
1743 for (Int_t nr= first; nr>=rf; nr-=step) {
1744 if (FollowToNext(t,nr)==0)
1745 if (!t.IsActive()) return 0;
1752 //_____________________________________________________________________________
1753 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1754 //-----------------------------------------------------------------
1755 // This function tries to find a track prolongation.
1756 //-----------------------------------------------------------------
1757 Double_t xt=t.GetX();
1759 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1760 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1761 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1762 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1764 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1766 if (FollowToNextFast(t,nr)==0)
1767 if (!t.IsActive()) return 0;
1777 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1778 //-----------------------------------------------------------------
1779 // This function tries to find a track prolongation.
1780 //-----------------------------------------------------------------
1781 // Double_t xt=t.GetX();
1783 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1784 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1785 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1786 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1789 first = t.fFirstPoint+3;
1791 if (first<0) first=0;
1792 for (Int_t nr=first+1; nr<=rf; nr++) {
1793 //if ( (t.GetSnp()<0.9))
1803 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1811 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1814 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1816 Float_t distance = TMath::Sqrt(dz2+dy2);
1817 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1820 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1821 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1826 if (firstpoint>lastpoint) {
1827 firstpoint =lastpoint;
1832 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1833 if (s1->GetClusterIndex2(i)>0) sum1++;
1834 if (s2->GetClusterIndex2(i)>0) sum2++;
1835 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1839 if (sum<5) return 0;
1841 Float_t summin = TMath::Min(sum1+1,sum2+1);
1842 Float_t ratio = (sum+1)/Float_t(summin);
1846 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1850 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1851 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1853 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1855 Float_t dy2 =(s1->GetY() - s2->GetY());
1857 Float_t distance = dz2+dy2;
1858 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1863 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1864 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1866 if (firstpoint>=lastpoint-5) return;;
1868 for (Int_t i=firstpoint;i<lastpoint;i++){
1869 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1870 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1877 for (Int_t i=firstpoint;i<lastpoint;i++){
1878 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1879 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1880 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1881 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1882 if (s1->IsActive()&&s2->IsActive()){
1883 p1->fIsShared = kTRUE;
1884 p2->fIsShared = kTRUE;
1891 for (Int_t i=0;i<4;i++){
1892 if (s1->fOverlapLabels[3*i]==0){
1893 s1->fOverlapLabels[3*i] = s2->GetLabel();
1894 s1->fOverlapLabels[3*i+1] = sumshared;
1895 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1899 for (Int_t i=0;i<4;i++){
1900 if (s2->fOverlapLabels[3*i]==0){
1901 s2->fOverlapLabels[3*i] = s1->GetLabel();
1902 s2->fOverlapLabels[3*i+1] = sumshared;
1903 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1911 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1914 //sort trackss according sectors
1916 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1917 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1919 //if (pt) RotateToLocal(pt);
1923 arr->Sort(); // sorting according z
1924 arr->Expand(arr->GetEntries());
1927 Int_t nseed=arr->GetEntriesFast();
1928 for (Int_t i=0; i<nseed; i++) {
1929 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1931 for (Int_t j=0;j<=12;j++){
1932 pt->fOverlapLabels[j] =0;
1935 for (Int_t i=0; i<nseed; i++) {
1936 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1938 if (pt->fRemoval>10) continue;
1939 for (Int_t j=i+1; j<nseed; j++){
1940 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1942 if (pt2->fRemoval<=10) {
1943 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1950 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1953 //sort trackss according sectors
1956 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1959 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1960 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1965 arr->Sort(); // sorting according z
1966 arr->Expand(arr->GetEntries());
1968 //reset overlap labels
1970 Int_t nseed=arr->GetEntriesFast();
1971 for (Int_t i=0; i<nseed; i++) {
1972 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1975 for (Int_t j=0;j<=12;j++){
1976 pt->fOverlapLabels[j] =0;
1980 //sign shared tracks
1981 for (Int_t i=0; i<nseed; i++) {
1982 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1984 if (pt->fRemoval>10) continue;
1985 Float_t deltac = pt->GetC()*0.1;
1986 for (Int_t j=i+1; j<nseed; j++){
1987 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1989 if (pt2->fRemoval<=10) {
1990 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1991 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
1992 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
1999 // remove highly shared tracks
2000 for (Int_t i=0; i<nseed; i++) {
2001 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2003 if (pt->fRemoval>10) continue;
2006 for (Int_t j=0;j<4;j++){
2007 sumshared = pt->fOverlapLabels[j*3+1];
2009 Float_t factor = factor1;
2010 if (pt->fRemoval>0) factor = factor2;
2011 if (sumshared/pt->GetNumberOfClusters()>factor){
2012 for (Int_t j=0;j<4;j++){
2013 if (pt->fOverlapLabels[3*j]==0) continue;
2014 if (pt->fOverlapLabels[3*j+1]<5) continue;
2015 if (pt->fRemoval==removalindex) continue;
2016 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2018 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2019 // pt->fRemoval = removalindex;
2020 delete arr->RemoveAt(i);
2028 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2037 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode)
2040 //sort tracks in array according mode criteria
2041 Int_t nseed = arr->GetEntriesFast();
2042 for (Int_t i=0; i<nseed; i++) {
2043 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2053 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2056 //Loop over all tracks and remove "overlaps"
2059 Int_t nseed = arr->GetEntriesFast();
2062 for (Int_t i=0; i<nseed; i++) {
2063 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2065 delete arr->RemoveAt(i);
2069 pt->fBSigned = kFALSE;
2073 nseed = arr->GetEntriesFast();
2080 for (Int_t i=0; i<nseed; i++) {
2081 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2085 Int_t found,foundable,shared;
2087 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2089 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2091 Double_t factor = factor2;
2092 if (pt->fBConstrain) factor = factor1;
2094 if ((Float_t(shared)/Float_t(found))>factor){
2095 pt->Desactivate(removalindex);
2100 for (Int_t i=0; i<160; i++) {
2101 Int_t index=pt->GetClusterIndex2(i);
2102 if (index<0 || index&0x8000 ) continue;
2103 AliTPCclusterMI *c= pt->fClusterPointer[i];
2105 // if (!c->IsUsed(10)) c->Use(10);
2106 //if (pt->IsActive())
2115 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2118 void AliTPCtrackerMI::UnsignClusters()
2121 // loop over all clusters and unsign them
2124 for (Int_t sec=0;sec<fkNIS;sec++){
2125 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2126 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2127 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2128 // if (cl[icl].IsUsed(10))
2130 cl = fInnerSec[sec][row].fClusters2;
2131 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2132 //if (cl[icl].IsUsed(10))
2137 for (Int_t sec=0;sec<fkNOS;sec++){
2138 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2139 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2140 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2141 //if (cl[icl].IsUsed(10))
2143 cl = fOuterSec[sec][row].fClusters2;
2144 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2145 //if (cl[icl].IsUsed(10))
2154 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2157 //sign clusters to be "used"
2159 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2160 // loop over "primaries"
2174 Int_t nseed = arr->GetEntriesFast();
2175 for (Int_t i=0; i<nseed; i++) {
2176 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2180 if (!(pt->IsActive())) continue;
2181 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2182 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2184 sumdens2+= dens*dens;
2185 sumn += pt->GetNumberOfClusters();
2186 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2187 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2190 sumchi2 +=chi2*chi2;
2195 Float_t mdensity = 0.9;
2196 Float_t meann = 130;
2197 Float_t meanchi = 1;
2198 Float_t sdensity = 0.1;
2199 Float_t smeann = 10;
2200 Float_t smeanchi =0.4;
2204 mdensity = sumdens/sum;
2206 meanchi = sumchi/sum;
2208 sdensity = sumdens2/sum-mdensity*mdensity;
2209 sdensity = TMath::Sqrt(sdensity);
2211 smeann = sumn2/sum-meann*meann;
2212 smeann = TMath::Sqrt(smeann);
2214 smeanchi = sumchi2/sum - meanchi*meanchi;
2215 smeanchi = TMath::Sqrt(smeanchi);
2219 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2221 for (Int_t i=0; i<nseed; i++) {
2222 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2226 if (pt->fBSigned) continue;
2227 if (pt->fBConstrain) continue;
2228 //if (!(pt->IsActive())) continue;
2230 Int_t found,foundable,shared;
2231 pt->GetClusterStatistic(0,160,found, foundable,shared);
2232 if (shared/float(found)>0.3) {
2233 if (shared/float(found)>0.9 ){
2234 //delete arr->RemoveAt(i);
2239 Bool_t isok =kFALSE;
2240 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2242 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2244 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2246 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2250 for (Int_t i=0; i<160; i++) {
2251 Int_t index=pt->GetClusterIndex2(i);
2252 if (index<0) continue;
2253 AliTPCclusterMI *c= pt->fClusterPointer[i];
2255 //if (!(c->IsUsed(10))) c->Use();
2262 Double_t maxchi = meanchi+2.*smeanchi;
2264 for (Int_t i=0; i<nseed; i++) {
2265 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2269 //if (!(pt->IsActive())) continue;
2270 if (pt->fBSigned) continue;
2271 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2272 if (chi>maxchi) continue;
2275 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2277 //sign only tracks with enoug big density at the beginning
2279 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2282 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2283 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2285 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2286 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2289 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2290 //Int_t noc=pt->GetNumberOfClusters();
2291 pt->fBSigned = kTRUE;
2292 for (Int_t i=0; i<160; i++) {
2294 Int_t index=pt->GetClusterIndex2(i);
2295 if (index<0) continue;
2296 AliTPCclusterMI *c= pt->fClusterPointer[i];
2298 // if (!(c->IsUsed(10))) c->Use();
2303 // gLastCheck = nseed;
2311 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2)
2313 // stop not active tracks
2314 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2315 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2316 Int_t nseed = arr->GetEntriesFast();
2318 for (Int_t i=0; i<nseed; i++) {
2319 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2323 if (!(pt->IsActive())) continue;
2324 StopNotActive(pt,row0,th0, th1,th2);
2330 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2333 // stop not active tracks
2334 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2335 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2338 Int_t foundable = 0;
2339 Int_t maxindex = seed->fLastPoint; //last foundable row
2340 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2341 seed->Desactivate(10) ;
2345 for (Int_t i=row0; i<maxindex; i++){
2346 Int_t index = seed->GetClusterIndex2(i);
2347 if (index!=-1) foundable++;
2349 if (foundable<=30) sumgood1++;
2350 if (foundable<=50) {
2357 if (foundable>=30.){
2358 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2361 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2366 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2369 // back propagation of ESD tracks
2374 PropagateBack(fSeeds);
2375 Int_t nseed = fSeeds->GetEntriesFast();
2376 for (Int_t i=0;i<nseed;i++){
2377 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2378 AliESDtrack *esd=event->GetTrack(i);
2379 seed->CookdEdx(0.02,0.06);
2380 CookLabel(seed,0.1); //For comparison only
2381 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2389 void AliTPCtrackerMI::DeleteSeeds()
2391 Int_t nseed = fSeeds->GetEntriesFast();
2392 for (Int_t i=0;i<nseed;i++){
2393 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2394 if (seed) delete fSeeds->RemoveAt(i);
2400 void AliTPCtrackerMI::ReadSeeds(AliESD *event)
2403 //read seeds from the event
2405 Int_t nentr=event->GetNumberOfTracks();
2406 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2410 fSeeds = new TObjArray;
2414 for (Int_t i=0; i<nentr; i++) {
2415 AliESDtrack *esd=event->GetTrack(i);
2416 ULong_t status=esd->GetStatus();
2417 const AliTPCtrack t(*esd);
2418 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2419 if (status==AliESDtrack::kTPCin) seed->Modify(0.8);
2422 // rotate to the local coordinate system
2424 fSectors=fInnerSec; fN=fkNIS;
2426 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2427 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2428 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2429 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2430 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2431 alpha-=seed->GetAlpha();
2432 if (!seed->Rotate(alpha)) continue;
2434 seed->PropagateTo(fSectors->GetX(0));
2436 // Int_t index = esd->GetTPCindex();
2437 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2439 fSeeds->AddLast(seed);
2445 //_____________________________________________________________________________
2446 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2447 Float_t deltay, Int_t ddsec) {
2448 //-----------------------------------------------------------------
2449 // This function creates track seeds.
2450 // SEEDING WITH VERTEX CONSTRAIN
2451 //-----------------------------------------------------------------
2452 // cuts[0] - fP4 cut
2453 // cuts[1] - tan(phi) cut
2454 // cuts[2] - zvertex cut
2455 // cuts[3] - fP3 cut
2463 Double_t x[5], c[15];
2464 // Int_t di = i1-i2;
2466 AliTPCseed * seed = new AliTPCseed;
2467 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2468 Double_t cs=cos(alpha), sn=sin(alpha);
2470 // Double_t x1 =fOuterSec->GetX(i1);
2471 //Double_t xx2=fOuterSec->GetX(i2);
2473 Double_t x1 =GetXrow(i1);
2474 Double_t xx2=GetXrow(i2);
2476 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2478 Int_t imiddle = (i2+i1)/2; //middle pad row index
2479 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2480 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2484 const AliTPCRow& kr1=GetRow(ns,i1);
2485 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2486 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2489 // change cut on curvature if it can't reach this layer
2490 // maximal curvature set to reach it
2491 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2492 if (dvertexmax*0.5*cuts[0]>0.85){
2493 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2495 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2498 if (deltay>0) ddsec = 0;
2499 // loop over clusters
2500 for (Int_t is=0; is < kr1; is++) {
2502 if (kr1[is]->IsUsed(10)) continue;
2503 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2504 //if (TMath::Abs(y1)>ymax) continue;
2506 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2508 // find possible directions
2509 Float_t anglez = (z1-z3)/(x1-x3);
2510 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2513 //find rotation angles relative to line given by vertex and point 1
2514 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2515 Double_t dvertex = TMath::Sqrt(dvertex2);
2516 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2517 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2520 // loop over 2 sectors
2526 Double_t dddz1=0; // direction of delta inclination in z axis
2533 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2534 Int_t sec2 = sec + dsec;
2536 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2537 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2538 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2539 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2540 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2541 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2543 // rotation angles to p1-p3
2544 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2545 Double_t x2, y2, z2;
2547 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2550 Double_t dxx0 = (xx2-x3)*cs13r;
2551 Double_t dyy0 = (xx2-x3)*sn13r;
2552 for (Int_t js=index1; js < index2; js++) {
2553 const AliTPCclusterMI *kcl = kr2[js];
2554 if (kcl->IsUsed(10)) continue;
2556 //calcutate parameters
2558 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2560 if (TMath::Abs(yy0)<0.000001) continue;
2561 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2562 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2563 Double_t r02 = (0.25+y0*y0)*dvertex2;
2564 //curvature (radius) cut
2565 if (r02<r2min) continue;
2569 Double_t c0 = 1/TMath::Sqrt(r02);
2573 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2574 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2575 Double_t dfi0 = 2.*TPCFastMath::FastAsin(dvertex*c0*0.5);
2576 Double_t dfi1 = 2.*TPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2579 Double_t z0 = kcl->GetZ();
2580 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2581 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2584 Double_t dip = (z1-z0)*c0/dfi1;
2585 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2596 x2= xx2*cs-y2*sn*dsec;
2597 y2=+xx2*sn*dsec+y2*cs;
2607 // do we have cluster at the middle ?
2609 GetProlongation(x1,xm,x,ym,zm);
2611 AliTPCclusterMI * cm=0;
2612 if (TMath::Abs(ym)-ymaxm<0){
2613 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2614 if ((!cm) || (cm->IsUsed(10))) {
2619 // rotate y1 to system 0
2620 // get state vector in rotated system
2621 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2622 Double_t xr2 = x0*cs+yr1*sn*dsec;
2623 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2625 GetProlongation(xx2,xm,xr,ym,zm);
2626 if (TMath::Abs(ym)-ymaxm<0){
2627 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2628 if ((!cm) || (cm->IsUsed(10))) {
2638 dym = ym - cm->GetY();
2639 dzm = zm - cm->GetZ();
2646 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2647 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2648 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2649 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2650 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2652 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2653 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2654 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2655 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2656 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2657 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2659 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2660 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2661 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2662 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2666 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2667 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2668 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2669 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2670 c[13]=f30*sy1*f40+f32*sy2*f42;
2671 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2673 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2675 UInt_t index=kr1.GetIndex(is);
2676 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2678 track->fIsSeeding = kTRUE;
2685 FollowProlongation(*track, (i1+i2)/2,1);
2686 Int_t foundable,found,shared;
2687 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2688 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2690 seed->~AliTPCseed();
2696 FollowProlongation(*track, i2,1);
2700 track->fBConstrain =1;
2701 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2702 track->fLastPoint = i1; // first cluster in track position
2703 track->fFirstPoint = track->fLastPoint;
2705 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2706 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2707 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2709 seed->~AliTPCseed();
2713 // Z VERTEX CONDITION
2715 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2716 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2717 if (TMath::Abs(zv-z3)>cuts[2]) {
2718 FollowProlongation(*track, TMath::Max(i2-20,0));
2719 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2720 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2721 if (TMath::Abs(zv-z3)>cuts[2]){
2722 FollowProlongation(*track, TMath::Max(i2-40,0));
2723 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2724 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2725 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2726 // make seed without constrain
2727 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2728 FollowProlongation(*track2, i2,1);
2729 track2->fBConstrain = kFALSE;
2730 track2->fSeedType = 1;
2731 arr->AddLast(track2);
2733 seed->~AliTPCseed();
2738 seed->~AliTPCseed();
2745 track->fSeedType =0;
2746 arr->AddLast(track);
2747 seed = new AliTPCseed;
2749 // don't consider other combinations
2750 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2756 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2762 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2767 //-----------------------------------------------------------------
2768 // This function creates track seeds.
2769 //-----------------------------------------------------------------
2770 // cuts[0] - fP4 cut
2771 // cuts[1] - tan(phi) cut
2772 // cuts[2] - zvertex cut
2773 // cuts[3] - fP3 cut
2783 Double_t x[5], c[15];
2785 // make temporary seed
2786 AliTPCseed * seed = new AliTPCseed;
2787 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2788 // Double_t cs=cos(alpha), sn=sin(alpha);
2793 Double_t x1 = GetXrow(i1-1);
2794 const AliTPCRow& kr1=GetRow(sec,i1-1);
2795 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2797 Double_t x1p = GetXrow(i1);
2798 const AliTPCRow& kr1p=GetRow(sec,i1);
2800 Double_t x1m = GetXrow(i1-2);
2801 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2804 //last 3 padrow for seeding
2805 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2806 Double_t x3 = GetXrow(i1-7);
2807 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2809 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2810 Double_t x3p = GetXrow(i1-6);
2812 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2813 Double_t x3m = GetXrow(i1-8);
2818 Int_t im = i1-4; //middle pad row index
2819 Double_t xm = GetXrow(im); // radius of middle pad-row
2820 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2821 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2824 Double_t deltax = x1-x3;
2825 Double_t dymax = deltax*cuts[1];
2826 Double_t dzmax = deltax*cuts[3];
2828 // loop over clusters
2829 for (Int_t is=0; is < kr1; is++) {
2831 if (kr1[is]->IsUsed(10)) continue;
2832 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2834 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2836 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2837 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2843 for (Int_t js=index1; js < index2; js++) {
2844 const AliTPCclusterMI *kcl = kr3[js];
2845 if (kcl->IsUsed(10)) continue;
2847 // apply angular cuts
2848 if (TMath::Abs(y1-y3)>dymax) continue;
2851 if (TMath::Abs(z1-z3)>dzmax) continue;
2853 Double_t angley = (y1-y3)/(x1-x3);
2854 Double_t anglez = (z1-z3)/(x1-x3);
2856 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2857 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2859 Double_t yyym = angley*(xm-x1)+y1;
2860 Double_t zzzm = anglez*(xm-x1)+z1;
2862 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2864 if (kcm->IsUsed(10)) continue;
2866 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2867 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2874 // look around first
2875 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2881 if (kc1m->IsUsed(10)) used++;
2883 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2889 if (kc1p->IsUsed(10)) used++;
2891 if (used>1) continue;
2892 if (found<1) continue;
2896 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2902 if (kc3m->IsUsed(10)) used++;
2906 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2912 if (kc3p->IsUsed(10)) used++;
2916 if (used>1) continue;
2917 if (found<3) continue;
2927 x[4]=f1(x1,y1,x2,y2,x3,y3);
2928 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
2931 x[2]=f2(x1,y1,x2,y2,x3,y3);
2934 x[3]=f3n(x1,y1,x2,y2,z1,z2,x[4]);
2935 //if (TMath::Abs(x[3]) > cuts[3]) continue;
2939 Double_t sy1=0.1, sz1=0.1;
2940 Double_t sy2=0.1, sz2=0.1;
2941 Double_t sy3=0.1, sy=0.1, sz=0.1;
2943 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2944 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2945 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2946 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2947 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2948 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2950 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2951 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2952 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2953 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2957 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2958 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2959 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2960 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2961 c[13]=f30*sy1*f40+f32*sy2*f42;
2962 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2964 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2966 UInt_t index=kr1.GetIndex(is);
2967 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
2969 track->fIsSeeding = kTRUE;
2972 FollowProlongation(*track, i1-7,1);
2973 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
2974 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
2976 seed->~AliTPCseed();
2982 FollowProlongation(*track, i2,1);
2983 track->fBConstrain =0;
2984 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2985 track->fFirstPoint = track->fLastPoint;
2987 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2988 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
2989 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
2991 seed->~AliTPCseed();
2996 FollowProlongation(*track, TMath::Max(i2-10,0),1);
2997 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
2998 FollowProlongation(*track2, i2,1);
2999 track2->fBConstrain = kFALSE;
3000 track2->fSeedType = 4;
3001 arr->AddLast(track2);
3003 seed->~AliTPCseed();
3007 //arr->AddLast(track);
3008 //seed = new AliTPCseed;
3014 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3020 //_____________________________________________________________________________
3021 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3022 Float_t deltay, Bool_t /*bconstrain*/) {
3023 //-----------------------------------------------------------------
3024 // This function creates track seeds - without vertex constraint
3025 //-----------------------------------------------------------------
3026 // cuts[0] - fP4 cut - not applied
3027 // cuts[1] - tan(phi) cut
3028 // cuts[2] - zvertex cut - not applied
3029 // cuts[3] - fP3 cut
3039 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3040 // Double_t cs=cos(alpha), sn=sin(alpha);
3041 Int_t row0 = (i1+i2)/2;
3042 Int_t drow = (i1-i2)/2;
3043 const AliTPCRow& kr0=fSectors[sec][row0];
3046 AliTPCpolyTrack polytrack;
3047 Int_t nclusters=fSectors[sec][row0];
3048 AliTPCseed * seed = new AliTPCseed;
3053 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3055 Int_t nfoundable =0;
3056 for (Int_t iter =1; iter<2; iter++){ //iterations
3057 const AliTPCRow& krm=fSectors[sec][row0-iter];
3058 const AliTPCRow& krp=fSectors[sec][row0+iter];
3059 const AliTPCclusterMI * cl= kr0[is];
3061 if (cl->IsUsed(10)) {
3067 Double_t x = kr0.GetX();
3068 // Initialization of the polytrack
3073 Double_t y0= cl->GetY();
3074 Double_t z0= cl->GetZ();
3078 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3079 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3081 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3082 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3083 polytrack.AddPoint(x,y0,z0,erry, errz);
3086 if (cl->IsUsed(10)) sumused++;
3089 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3090 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3093 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3094 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3095 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3096 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3097 if (cl1->IsUsed(10)) sumused++;
3098 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3102 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3104 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3105 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3106 if (cl2->IsUsed(10)) sumused++;
3107 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3110 if (sumused>0) continue;
3112 polytrack.UpdateParameters();
3118 nfoundable = polytrack.GetN();
3119 nfound = nfoundable;
3121 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3122 Float_t maxdist = 0.8*(1.+3./(ddrow));
3123 for (Int_t delta = -1;delta<=1;delta+=2){
3124 Int_t row = row0+ddrow*delta;
3125 kr = &(fSectors[sec][row]);
3126 Double_t xn = kr->GetX();
3127 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3128 polytrack.GetFitPoint(xn,yn,zn);
3129 if (TMath::Abs(yn)>ymax) continue;
3131 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3133 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3136 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3137 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3138 if (cln->IsUsed(10)) {
3139 // printf("used\n");
3147 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3152 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3153 polytrack.UpdateParameters();
3156 if ( (sumused>3) || (sumused>0.5*nfound)) {
3157 //printf("sumused %d\n",sumused);
3162 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3163 AliTPCpolyTrack track2;
3165 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3166 if (track2.GetN()<0.5*nfoundable) continue;
3169 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3171 // test seed with and without constrain
3172 for (Int_t constrain=0; constrain<=0;constrain++){
3173 // add polytrack candidate
3175 Double_t x[5], c[15];
3176 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3177 track2.GetBoundaries(x3,x1);
3179 track2.GetFitPoint(x1,y1,z1);
3180 track2.GetFitPoint(x2,y2,z2);
3181 track2.GetFitPoint(x3,y3,z3);
3183 //is track pointing to the vertex ?
3186 polytrack.GetFitPoint(x0,y0,z0);
3199 x[4]=f1(x1,y1,x2,y2,x3,y3);
3201 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3202 x[2]=f2(x1,y1,x2,y2,x3,y3);
3204 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3205 //x[3]=f3(x1,y1,x2,y2,z1,z2);
3206 x[3]=f3n(x1,y1,x3,y3,z1,z3,x[4]);
3207 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3210 Double_t sy =0.1, sz =0.1;
3211 Double_t sy1=0.02, sz1=0.02;
3212 Double_t sy2=0.02, sz2=0.02;
3216 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3219 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3220 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3221 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3222 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3223 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3224 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3226 Double_t f30=(f3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3227 Double_t f31=(f3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3228 Double_t f32=(f3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3229 Double_t f34=(f3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3234 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3235 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3236 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3237 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3238 c[13]=f30*sy1*f40+f32*sy2*f42;
3239 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3241 //Int_t row1 = fSectors->GetRowNumber(x1);
3242 Int_t row1 = GetRowNumber(x1);
3246 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3247 track->fIsSeeding = kTRUE;
3248 Int_t rc=FollowProlongation(*track, i2);
3249 if (constrain) track->fBConstrain =1;
3251 track->fBConstrain =0;
3252 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3253 track->fFirstPoint = track->fLastPoint;
3255 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3256 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3257 track->fNShared>0.4*track->GetNumberOfClusters()) {
3260 seed->~AliTPCseed();
3263 arr->AddLast(track);
3264 seed = new AliTPCseed;
3268 } // if accepted seed
3271 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3277 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3282 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3283 Int_t p1 = int(r1*track->GetNumberOfClusters());
3284 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3286 Double_t x0[3],x1[3],x2[3];
3291 // find track position at given ratio of the length
3292 Int_t sec0, sec1, sec2;
3298 for (Int_t i=0;i<160;i++){
3299 if (track->fClusterPointer[i]){
3301 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3302 if ( (index<p0) || x0[0]<0 ){
3303 if (trpoint->GetX()>1){
3304 clindex = track->GetClusterIndex2(i);
3306 x0[0] = trpoint->GetX();
3307 x0[1] = trpoint->GetY();
3308 x0[2] = trpoint->GetZ();
3309 sec0 = ((clindex&0xff000000)>>24)%18;
3314 if ( (index<p1) &&(trpoint->GetX()>1)){
3315 clindex = track->GetClusterIndex2(i);
3317 x1[0] = trpoint->GetX();
3318 x1[1] = trpoint->GetY();
3319 x1[2] = trpoint->GetZ();
3320 sec1 = ((clindex&0xff000000)>>24)%18;
3323 if ( (index<p2) &&(trpoint->GetX()>1)){
3324 clindex = track->GetClusterIndex2(i);
3326 x2[0] = trpoint->GetX();
3327 x2[1] = trpoint->GetY();
3328 x2[2] = trpoint->GetZ();
3329 sec2 = ((clindex&0xff000000)>>24)%18;
3336 Double_t alpha, cs,sn, xx2,yy2;
3338 alpha = (sec1-sec2)*fSectors->GetAlpha();
3339 cs = TMath::Cos(alpha);
3340 sn = TMath::Sin(alpha);
3341 xx2= x1[0]*cs-x1[1]*sn;
3342 yy2= x1[0]*sn+x1[1]*cs;
3346 alpha = (sec0-sec2)*fSectors->GetAlpha();
3347 cs = TMath::Cos(alpha);
3348 sn = TMath::Sin(alpha);
3349 xx2= x0[0]*cs-x0[1]*sn;
3350 yy2= x0[0]*sn+x0[1]*cs;
3356 Double_t x[5],c[15];
3360 x[4]=f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3361 // if (x[4]>1) return 0;
3362 x[2]=f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3363 x[3]=f3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3364 //if (TMath::Abs(x[3]) > 2.2) return 0;
3365 //if (TMath::Abs(x[2]) > 1.99) return 0;
3367 Double_t sy =0.1, sz =0.1;
3369 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3370 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3371 Double_t sy3=0.01+track->GetSigmaY2();
3373 Double_t f40=(f1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3374 Double_t f42=(f1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3375 Double_t f43=(f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3376 Double_t f20=(f2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3377 Double_t f22=(f2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3378 Double_t f23=(f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3380 Double_t f30=(f3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3381 Double_t f31=(f3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3382 Double_t f32=(f3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3383 Double_t f34=(f3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3388 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3389 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3390 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3391 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3392 c[13]=f30*sy1*f40+f32*sy2*f42;
3393 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3395 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3396 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3397 // Double_t y0,z0,y1,z1, y2,z2;
3398 //seed->GetProlongation(x0[0],y0,z0);
3399 // seed->GetProlongation(x1[0],y1,z1);
3400 //seed->GetProlongation(x2[0],y2,z2);
3402 seed->fLastPoint = pp2;
3403 seed->fFirstPoint = pp2;
3409 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3414 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3416 if (TMath::Abs(seed->GetC())>0.01) return 0;
3419 Float_t x[160], y[160], erry[160], z[160], errz[160];
3421 Float_t xt[160], yt[160], zt[160];
3426 Int_t middle = seed->GetNumberOfClusters()/2;
3429 // find central sector, get local cooordinates
3431 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3432 sec[i]= seed->GetClusterSector(i)%18;
3435 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3436 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3443 if (i>i2) i2 = i; //last point with cluster
3444 if (i2<i1) i1 = i; //first point with cluster
3447 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3449 yt[i] = point->GetY();
3450 zt[i] = point->GetZ();
3452 if (point->GetX()>0){
3453 erry[i] = point->GetErrY();
3454 errz[i] = point->GetErrZ();
3459 secm = sec[i]; //central sector
3460 padm = i; //middle point with cluster
3465 // rotate position to global coordinate system connected to sector at last the point
3467 for (Int_t i=i1;i<=i2;i++){
3469 if (sec[i]<0) continue;
3470 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3471 Double_t cs = TMath::Cos(alpha);
3472 Double_t sn = TMath::Sin(alpha);
3473 Float_t xx2= x[i]*cs+y[i]*sn;
3474 Float_t yy2= -x[i]*sn+y[i]*cs;
3478 xx2= xt[i]*cs+yt[i]*sn;
3479 yy2= -xt[i]*sn+yt[i]*cs;
3484 //get "state" vector
3485 Double_t xh[5],xm = x[padm];
3488 xh[4]=f1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3489 xh[2]=f2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3490 xh[3]=f3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3493 for (Int_t i=i1;i<=i2;i++){
3495 if (sec[i]<0) continue;
3496 GetProlongation(x[i2], x[i],xh,yy,zz);
3497 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3499 //xxh[4]=f1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3500 //xxh[2]=f2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3501 printf("problem\n");
3506 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3507 Float_t yup[160], ydown[160], zup[160], zdown[160];
3509 AliTPCpolyTrack ptrack1,ptrack2;
3512 for (Int_t i=i1;i<=i2;i++){
3513 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3515 if (cl->GetType()<0) continue;
3516 if (cl->GetType()>10) continue;
3519 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3521 if (ptrack1.GetN()>4.){
3522 ptrack1.UpdateParameters();
3524 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3526 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3535 dyup[i]=0.; //not enough points
3540 for (Int_t i=i2;i>=i1;i--){
3541 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3543 if (cl->GetType()<0) continue;
3544 if (cl->GetType()>10) continue;
3546 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3548 if (ptrack2.GetN()>4){
3549 ptrack2.UpdateParameters();
3551 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3553 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3561 dydown[i]=0.; //not enough points
3566 // find maximal difference of the derivation
3567 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3570 for (Int_t i=i1+10;i<i2-10;i++){
3571 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3572 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3574 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3575 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3576 if ( (ddy+ddz)> th){
3577 seed->fKinkPoint[0] = i;
3578 seed->fKinkPoint[1] = ddy;
3579 seed->fKinkPoint[2] = ddz;
3586 //write information to the debug tree
3587 TBranch * br = fTreeDebug->GetBranch("debug");
3588 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3589 arr->ExpandCreateFast(i2-i1);
3590 br->SetAddress(&arr);
3592 AliTPCclusterMI cldummy;
3594 AliTPCTrackPoint2 pdummy;
3595 pdummy.GetTPoint().fIsShared = 10;
3597 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3598 Double_t cs = TMath::Cos(alpha);
3599 Double_t sn = TMath::Sin(alpha);
3601 for (Int_t i=i1;i<i2;i++){
3602 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3604 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3606 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3609 Double_t x = GetXrow(i);
3610 trpoint->GetTPoint() = *point;
3611 trpoint->GetCPoint() = *cl0;
3612 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3613 trpoint->fID = seed->GetUniqueID();
3614 trpoint->fLab = seed->GetLabel();
3616 trpoint->fGX = cs *x + sn*point->GetY();
3617 trpoint->fGY = -sn *x + cs*point->GetY() ;
3618 trpoint->fGZ = point->GetZ();
3620 trpoint->fDY = y[i];
3621 trpoint->fDZ = z[i];
3623 trpoint->fDYU = dyup[i];
3624 trpoint->fDZU = dzup[i];
3626 trpoint->fDYD = dydown[i];
3627 trpoint->fDZD = dzdown[i];
3629 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3630 trpoint->fDDY = dydown[i]-dyup[i];
3631 trpoint->fDDZ = dzdown[i]-dzup[i];
3639 trpoint->GetCPoint()= cldummy;
3656 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3659 // reseed - refit - track
3662 // Int_t last = fSectors->GetNRows()-1;
3664 if (fSectors == fOuterSec){
3665 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3669 first = t->fFirstPoint;
3671 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3672 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3674 FollowProlongation(*t,first);
3684 //_____________________________________________________________________________
3685 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3686 //-----------------------------------------------------------------
3687 // This function reades track seeds.
3688 //-----------------------------------------------------------------
3689 TDirectory *savedir=gDirectory;
3691 TFile *in=(TFile*)inp;
3692 if (!in->IsOpen()) {
3693 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3698 TTree *seedTree=(TTree*)in->Get("Seeds");
3700 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3701 cerr<<"can't get a tree with track seeds !\n";
3704 AliTPCtrack *seed=new AliTPCtrack;
3705 seedTree->SetBranchAddress("tracks",&seed);
3707 if (fSeeds==0) fSeeds=new TObjArray(15000);
3709 Int_t n=(Int_t)seedTree->GetEntries();
3710 for (Int_t i=0; i<n; i++) {
3711 seedTree->GetEvent(i);
3712 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3721 //_____________________________________________________________________________
3722 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3723 //-----------------------------------------------------------------
3724 // This is a track finder.
3725 //-----------------------------------------------------------------
3726 TDirectory *savedir=gDirectory;
3729 if (!fInput) SetIO(); //set default IO using loaders
3731 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
3737 fSeeds = Tracking();
3740 printf("Time for tracking: \t");timer.Print();timer.Start();
3742 //activate again some tracks
3743 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3744 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3746 Int_t nc=t.GetNumberOfClusters();
3748 delete fSeeds->RemoveAt(i);
3751 if (pt->fRemoval==10) {
3752 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3753 pt->Desactivate(10); // make track again active
3755 pt->Desactivate(20);
3756 delete fSeeds->RemoveAt(i);
3760 RemoveDouble(fSeeds,0.2,0.6,11);
3761 //RemoveUsed(fSeeds,0.9,0.9,6);
3762 //RemoveUsed(fSeeds,0.8,0.8,6);
3763 //RemoveUsed(fSeeds,0.7,0.7,6);
3764 RemoveUsed(fSeeds,0.5,0.5,6);
3767 Int_t nseed=fSeeds->GetEntriesFast();
3769 for (Int_t i=0; i<nseed; i++) {
3770 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3772 Int_t nc=t.GetNumberOfClusters();
3774 delete fSeeds->RemoveAt(i);
3777 CookLabel(pt,0.1); //For comparison only
3778 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3779 if ((pt->IsActive() || (pt->fRemoval==10) )){
3780 cerr<<found++<<'\r';
3783 delete fSeeds->RemoveAt(i);
3788 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3790 //RemoveUsed(fSeeds,0.9,0.9,6);
3792 nseed=fSeeds->GetEntriesFast();
3794 for (Int_t i=0; i<nseed; i++) {
3795 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3797 Int_t nc=t.GetNumberOfClusters();
3799 delete fSeeds->RemoveAt(i);
3803 t.CookdEdx(0.02,0.6);
3804 // CheckKinkPoint(&t,0.05);
3805 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3806 if ((pt->IsActive() || (pt->fRemoval==10) )){
3807 cerr<<found++<<'\r';
3810 delete fSeeds->RemoveAt(i);
3814 SortTracks(fSeeds, 1);
3818 PrepareForBackProlongation(fSeeds,0.5);
3819 PropagateBack(fSeeds);
3820 printf("Time for back propagation: \t");timer.Print();timer.Start();
3824 PrepareForProlongation(fSeeds,1.);
3827 fSectors = fOuterSec;
3828 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3829 fSectors = fInnerSec;
3830 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3831 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
3832 // RemoveUsed(fSeeds,0.7,0.7,6);
3833 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
3835 nseed=fSeeds->GetEntriesFast();
3837 for (Int_t i=0; i<nseed; i++) {
3838 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3840 Int_t nc=t.GetNumberOfClusters();
3842 delete fSeeds->RemoveAt(i);
3845 t.CookdEdx(0.02,0.6);
3846 // CookLabel(pt,0.1); //For comparison only
3847 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3848 if ((pt->IsActive() || (pt->fRemoval==10) )){
3849 cerr<<found++<<'\r';
3852 delete fSeeds->RemoveAt(i);
3857 // fNTracks = found;
3858 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
3863 if (!fNewIO) fOutput->Write();
3865 AliRunLoader::GetDetectorLoader("TPC",AliConfig::fgkDefaultEventFolderName)->WriteTracks("OVERWRITE");
3868 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
3870 //if (seedtree) delete seedtree;
3871 // UnloadClusters();
3872 //printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
3877 void AliTPCtrackerMI::Tracking(TObjArray * arr)
3880 // tracking of the seeds
3883 fSectors = fOuterSec;
3884 ParallelTracking(arr,150,63);
3885 fSectors = fOuterSec;
3886 ParallelTracking(arr,63,0);
3889 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
3894 TObjArray * arr = new TObjArray;
3896 fSectors = fOuterSec;
3899 for (Int_t sec=0;sec<fkNOS;sec++){
3900 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
3901 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
3902 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
3905 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
3917 TObjArray * AliTPCtrackerMI::Tracking()
3923 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
3925 TObjArray * seeds = new TObjArray;
3934 Float_t fnumber = 3.0;
3935 Float_t fdensity = 3.0;
3940 for (Int_t delta = 0; delta<18; delta+=6){
3944 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
3945 SumTracks(seeds,arr);
3946 SignClusters(seeds,fnumber,fdensity);
3948 for (Int_t i=2;i<6;i+=2){
3949 // seed high pt tracks
3952 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
3953 SumTracks(seeds,arr);
3954 SignClusters(seeds,fnumber,fdensity);
3959 // RemoveUsed(seeds,0.9,0.9,1);
3960 // UnsignClusters();
3961 // SignClusters(seeds,fnumber,fdensity);
3965 for (Int_t delta = 20; delta<120; delta+=10){
3967 // seed high pt tracks
3971 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
3972 SumTracks(seeds,arr);
3973 SignClusters(seeds,fnumber,fdensity);
3978 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
3979 SumTracks(seeds,arr);
3980 SignClusters(seeds,fnumber,fdensity);
3991 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
3995 // RemoveUsed(seeds,0.75,0.75,1);
3997 //SignClusters(seeds,fnumber,fdensity);
4006 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4007 SumTracks(seeds,arr);
4008 SignClusters(seeds,fnumber,fdensity);
4010 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4011 SumTracks(seeds,arr);
4012 SignClusters(seeds,fnumber,fdensity);
4014 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4015 SumTracks(seeds,arr);
4016 SignClusters(seeds,fnumber,fdensity);
4020 for (Int_t delta = 3; delta<30; delta+=5){
4026 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4027 SumTracks(seeds,arr);
4028 SignClusters(seeds,fnumber,fdensity);
4030 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4031 SumTracks(seeds,arr);
4032 SignClusters(seeds,fnumber,fdensity);
4044 for (Int_t delta = 30; delta<70; delta+=10){
4050 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4051 SumTracks(seeds,arr);
4052 SignClusters(seeds,fnumber,fdensity);
4054 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4055 SumTracks(seeds,arr);
4056 SignClusters(seeds,fnumber,fdensity);
4060 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4071 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2)
4074 //sum tracks to common container
4075 //remove suspicious tracks
4076 Int_t nseed = arr2->GetEntriesFast();
4077 for (Int_t i=0;i<nseed;i++){
4078 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4081 // NORMAL ACTIVE TRACK
4082 if (pt->IsActive()){
4083 arr1->AddLast(arr2->RemoveAt(i));
4086 //remove not usable tracks
4087 if (pt->fRemoval!=10){
4088 delete arr2->RemoveAt(i);
4091 // REMOVE VERY SHORT TRACKS
4092 if (pt->GetNumberOfClusters()<20){
4093 delete arr2->RemoveAt(i);
4096 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4097 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4098 arr1->AddLast(arr2->RemoveAt(i));
4100 delete arr2->RemoveAt(i);
4109 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4112 // try to track in parralel
4114 Int_t nseed=arr->GetEntriesFast();
4115 //prepare seeds for tracking
4116 for (Int_t i=0; i<nseed; i++) {
4117 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4119 if (!t.IsActive()) continue;
4120 // follow prolongation to the first layer
4121 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4122 FollowProlongation(t, rfirst+1);
4127 for (Int_t nr=rfirst; nr>=rlast; nr--){
4128 // make indexes with the cluster tracks for given
4130 // find nearest cluster
4131 for (Int_t i=0; i<nseed; i++) {
4132 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4134 if (!pt->IsActive()) continue;
4135 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4136 if (pt->fRelativeSector>17) {
4139 UpdateClusters(t,nr);
4141 // prolonagate to the nearest cluster - if founded
4142 for (Int_t i=0; i<nseed; i++) {
4143 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4145 if (!pt->IsActive()) continue;
4146 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4147 if (pt->fRelativeSector>17) {
4150 FollowToNextCluster(*pt,nr);
4155 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac)
4159 // if we use TPC track itself we have to "update" covariance
4161 Int_t nseed= arr->GetEntriesFast();
4162 for (Int_t i=0;i<nseed;i++){
4163 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4167 //rotate to current local system at first accepted point
4168 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4169 Int_t sec = (index&0xff000000)>>24;
4171 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4172 if (angle1>TMath::Pi())
4173 angle1-=2.*TMath::Pi();
4174 Float_t angle2 = pt->GetAlpha();
4176 if (TMath::Abs(angle1-angle2)>0.001){
4177 pt->Rotate(angle1-angle2);
4178 //angle2 = pt->GetAlpha();
4179 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4180 //if (pt->GetAlpha()<0)
4181 // pt->fRelativeSector+=18;
4182 //sec = pt->fRelativeSector;
4191 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac)
4195 // if we use TPC track itself we have to "update" covariance
4197 Int_t nseed= arr->GetEntriesFast();
4198 for (Int_t i=0;i<nseed;i++){
4199 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4202 pt->fFirstPoint = pt->fLastPoint;
4210 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4213 // make back propagation
4215 Int_t nseed= arr->GetEntriesFast();
4216 for (Int_t i=0;i<nseed;i++){
4217 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4219 AliTPCseed *pt2 = new AliTPCseed(*pt);
4220 fSectors = fInnerSec;
4221 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4222 fSectors = fOuterSec;
4223 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4224 fSectors = fOuterSec;
4225 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4226 printf("\n%d",pt->GetLabel());
4227 fSectors = fInnerSec;
4228 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4229 fSectors = fOuterSec;
4230 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4231 fSectors = fOuterSec;
4239 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4242 // make forward propagation
4244 Int_t nseed= arr->GetEntriesFast();
4245 for (Int_t i=0;i<nseed;i++){
4246 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4248 AliTPCseed *pt2 = new AliTPCseed(*pt);
4249 fSectors = fOuterSec;
4250 FollowProlongation(*pt,0);
4251 fSectors = fOuterSec;
4252 FollowProlongation(*pt,0);
4253 fSectors = fInnerSec;
4254 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4255 printf("\n%d",pt->GetLabel());
4256 fSectors = fOuterSec;
4257 FollowProlongation(*pt2,0);
4258 fSectors = fOuterSec;
4259 FollowProlongation(*pt2,0);
4260 fSectors = fOuterSec;
4268 Int_t AliTPCtrackerMI::PropagateForward()
4270 fSectors = fOuterSec;
4271 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4272 fSectors = fInnerSec;
4273 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4283 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4286 // make back propagation, in between row0 and row1
4290 fSectors = fInnerSec;
4293 if (row1<fSectors->GetNRows())
4296 r1 = fSectors->GetNRows()-1;
4298 if (row0<fSectors->GetNRows()&& r1>0 )
4299 FollowBackProlongation(*pt,r1);
4300 if (row1<=fSectors->GetNRows())
4303 r1 = row1 - fSectors->GetNRows();
4304 if (r1<=0) return 0;
4305 if (r1>=fOuterSec->GetNRows()) return 0;
4306 fSectors = fOuterSec;
4307 return FollowBackProlongation(*pt,r1);
4315 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4319 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4320 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4321 Float_t padlength = GetPadPitchLength(row);
4323 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4324 Float_t angulary = seed->GetSnp();
4325 angulary = angulary*angulary/(1-angulary*angulary);
4326 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4328 Float_t sresz = fParam->GetZSigma();
4329 Float_t angularz = seed->GetTgl();
4330 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4332 Float_t wy = GetSigmaY(seed);
4333 Float_t wz = GetSigmaZ(seed);
4336 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4337 printf("problem\n");
4343 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4347 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4348 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4349 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4350 Float_t angular = seed->GetSnp();
4351 angular = angular*angular/(1-angular*angular);
4352 // angular*=angular;
4353 //angular = TMath::Sqrt(angular/(1-angular));
4354 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4357 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4361 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4362 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4363 Float_t sres = fParam->GetZSigma();
4364 Float_t angular = seed->GetTgl();
4365 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4372 //__________________________________________________________________________
4373 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4374 //--------------------------------------------------------------------
4375 //This function "cooks" a track label. If label<0, this track is fake.
4376 //--------------------------------------------------------------------
4377 Int_t noc=t->GetNumberOfClusters();
4379 printf("\nnot founded prolongation\n\n\n");
4385 AliTPCclusterMI *clusters[160];
4387 for (Int_t i=0;i<160;i++) {
4394 for (i=0; i<160 && current<noc; i++) {
4396 Int_t index=t->GetClusterIndex2(i);
4397 if (index<=0) continue;
4398 if (index&0x8000) continue;
4400 //clusters[current]=GetClusterMI(index);
4401 if (t->fClusterPointer[i]){
4402 clusters[current]=t->fClusterPointer[i];
4408 Int_t lab=123456789;
4409 for (i=0; i<noc; i++) {
4410 AliTPCclusterMI *c=clusters[i];
4412 lab=TMath::Abs(c->GetLabel(0));
4414 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4420 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4422 for (i=0; i<noc; i++) {
4423 AliTPCclusterMI *c=clusters[i];
4425 if (TMath::Abs(c->GetLabel(1)) == lab ||
4426 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4429 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4432 Int_t tail=Int_t(0.10*noc);
4435 for (i=1; i<=160&&ind<tail; i++) {
4436 // AliTPCclusterMI *c=clusters[noc-i];
4437 AliTPCclusterMI *c=clusters[i];
4439 if (lab == TMath::Abs(c->GetLabel(0)) ||
4440 lab == TMath::Abs(c->GetLabel(1)) ||
4441 lab == TMath::Abs(c->GetLabel(2))) max++;
4444 if (max < Int_t(0.5*tail)) lab=-lab;
4451 //delete[] clusters;
4454 //_________________________________________________________________________
4455 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4456 //-----------------------------------------------------------------------
4457 // Setup inner sector
4458 //-----------------------------------------------------------------------
4460 fAlpha=par->GetInnerAngle();
4461 fAlphaShift=par->GetInnerAngleShift();
4462 fPadPitchWidth=par->GetInnerPadPitchWidth();
4463 fPadPitchLength=par->GetInnerPadPitchLength();
4464 fN=par->GetNRowLow();
4465 fRow=new AliTPCRow[fN];
4466 for (Int_t i=0; i<fN; i++) {
4467 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4468 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4471 fAlpha=par->GetOuterAngle();
4472 fAlphaShift=par->GetOuterAngleShift();
4473 fPadPitchWidth = par->GetOuterPadPitchWidth();
4474 fPadPitchLength = par->GetOuter1PadPitchLength();
4475 f1PadPitchLength = par->GetOuter1PadPitchLength();
4476 f2PadPitchLength = par->GetOuter2PadPitchLength();
4478 fN=par->GetNRowUp();
4479 fRow=new AliTPCRow[fN];
4480 for (Int_t i=0; i<fN; i++) {
4481 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4482 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4488 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4494 //_________________________________________________________________________
4496 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4497 //-----------------------------------------------------------------------
4498 // Insert a cluster into this pad row in accordence with its y-coordinate
4499 //-----------------------------------------------------------------------
4500 if (fN==kMaxClusterPerRow) {
4501 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4503 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4504 Int_t i=Find(c->GetZ());
4505 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4506 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4507 fIndex[i]=index; fClusters[i]=c; fN++;
4511 //___________________________________________________________________
4512 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4513 //-----------------------------------------------------------------------
4514 // Return the index of the nearest cluster
4515 //-----------------------------------------------------------------------
4516 if (fN==0) return 0;
4517 if (z <= fClusters[0]->GetZ()) return 0;
4518 if (z > fClusters[fN-1]->GetZ()) return fN;
4519 Int_t b=0, e=fN-1, m=(b+e)/2;
4520 for (; b<e; m=(b+e)/2) {
4521 if (z > fClusters[m]->GetZ()) b=m+1;
4529 //___________________________________________________________________
4530 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4531 //-----------------------------------------------------------------------
4532 // Return the index of the nearest cluster in z y
4533 //-----------------------------------------------------------------------
4534 Float_t maxdistance = roady*roady + roadz*roadz;
4536 AliTPCclusterMI *cl =0;
4537 for (Int_t i=Find(z-roadz); i<fN; i++) {
4538 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4539 if (c->GetZ() > z+roadz) break;
4540 if ( (c->GetY()-y) > roady ) continue;
4541 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4542 if (maxdistance>distance) {
4543 maxdistance = distance;
4550 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4552 //-----------------------------------------------------------------------
4553 // Return the index of the nearest cluster in z y
4554 //-----------------------------------------------------------------------
4555 Float_t maxdistance = roady*roady + roadz*roadz;
4556 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4557 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4559 AliTPCclusterMI *cl =0;
4560 //FindNearest3(y,z,roady,roadz,index);
4561 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4562 for (Int_t i=iz1; i<iz2; i++) {
4563 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4564 if (c->GetZ() > z+roadz) break;
4565 if ( c->GetY()-y > roady ) continue;
4566 if ( y-c->GetY() > roady ) continue;
4567 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4568 if (maxdistance>distance) {
4569 maxdistance = distance;
4572 //roady = TMath::Sqrt(maxdistance);
4580 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4582 //-----------------------------------------------------------------------
4583 // Return the index of the nearest cluster in z y
4584 //-----------------------------------------------------------------------
4585 Float_t maxdistance = roady*roady + roadz*roadz;
4586 // Int_t iz = Int_t(z+255.);
4587 AliTPCclusterMI *cl =0;
4588 for (Int_t i=Find(z-roadz); i<fN; i++) {
4589 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4590 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4591 if (c->GetZ() > z+roadz) break;
4592 if ( c->GetY()-y > roady ) continue;
4593 if ( y-c->GetY() > roady ) continue;
4594 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4595 if (maxdistance>distance) {
4596 maxdistance = distance;
4599 //roady = TMath::Sqrt(maxdistance);
4608 AliTPCseed::AliTPCseed():AliTPCtrack(){
4612 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4613 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4629 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4636 for (Int_t i=0;i<160;i++) {
4637 fClusterPointer[i] = 0;
4638 Int_t index = t.GetClusterIndex(i);
4640 SetClusterIndex2(i,index);
4643 SetClusterIndex2(i,-3);
4653 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4655 for (Int_t i=0;i<160;i++) {
4656 fClusterPointer[i] = 0;
4657 Int_t index = t.GetClusterIndex(i);
4658 SetClusterIndex2(i,index);
4675 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4676 Double_t xr, Double_t alpha):
4677 AliTPCtrack(index, xx, cc, xr, alpha) {
4681 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4682 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4691 // fHelixIn = new TClonesArray("AliHelix",0);
4692 //fHelixOut = new TClonesArray("AliHelix",0);
4699 AliTPCseed::~AliTPCseed(){
4700 if (fPoints) delete fPoints;
4702 if (fEPoints) delete fEPoints;
4707 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4711 return &fTrackPoints[i];
4714 void AliTPCseed::RebuildSeed()
4717 // rebuild seed to be ready for storing
4718 AliTPCclusterMI cldummy;
4720 AliTPCTrackPoint pdummy;
4721 pdummy.GetTPoint().fIsShared = 10;
4722 for (Int_t i=0;i<160;i++){
4723 AliTPCclusterMI * cl0 = fClusterPointer[i];
4724 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
4726 trpoint->GetTPoint() = *(GetTrackPoint(i));
4727 trpoint->GetCPoint() = *cl0;
4728 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4732 trpoint->GetCPoint()= cldummy;
4740 Double_t AliTPCseed::GetDensityFirst(Int_t n)
4744 // return cluster for n rows bellow first point
4745 Int_t nfoundable = 1;
4747 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
4748 Int_t index = GetClusterIndex2(i);
4749 if (index!=-1) nfoundable++;
4750 if (index>0) nfound++;
4752 if (nfoundable<n) return 0;
4753 return Double_t(nfound)/Double_t(nfoundable);
4758 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
4760 // get cluster stat. on given region
4765 for (Int_t i=first;i<last; i++){
4766 Int_t index = GetClusterIndex2(i);
4767 if (index!=-1) foundable++;
4768 if (fClusterPointer[i]) {
4774 if (fClusterPointer[i]->IsUsed(10)) {
4778 if (!plus2) continue; //take also neighborhoud
4780 if ( (i>0) && fClusterPointer[i-1]){
4781 if (fClusterPointer[i-1]->IsUsed(10)) {
4786 if ( fClusterPointer[i+1]){
4787 if (fClusterPointer[i+1]->IsUsed(10)) {
4795 printf("problem\n");
4799 //_____________________________________________________________________________
4800 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
4801 //-----------------------------------------------------------------
4802 // This funtion calculates dE/dX within the "low" and "up" cuts.
4803 //-----------------------------------------------------------------
4806 Float_t angular[200];
4807 Float_t weight[200];
4810 // TClonesArray & arr = *fPoints;
4811 Float_t meanlog = 100.;
4813 Float_t mean[4] = {0,0,0,0};
4814 Float_t sigma[4] = {1000,1000,1000,1000};
4815 Int_t nc[4] = {0,0,0,0};
4816 Float_t norm[4] = {1000,1000,1000,1000};
4821 for (Int_t of =0; of<4; of++){
4822 for (Int_t i=of+i1;i<i2;i+=4)
4824 Int_t index = fIndex[i];
4825 if (index<0||index&0x8000) continue;
4827 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
4828 AliTPCTrackerPoint * point = GetTrackPoint(i);
4829 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
4830 //AliTPCTrackerPoint * pointp = 0;
4831 //if (i<159) pointp = GetTrackPoint(i+1);
4833 if (point==0) continue;
4834 AliTPCclusterMI * cl = fClusterPointer[i];
4835 if (cl==0) continue;
4836 if (onlyused && (!cl->IsUsed(10))) continue;
4837 if (cl->IsUsed(11)) {
4841 Int_t type = cl->GetType();
4842 //if (point->fIsShared){
4847 // if (pointm->fIsShared) continue;
4849 // if (pointp->fIsShared) continue;
4851 if (type<0) continue;
4852 //if (type>10) continue;
4853 //if (point->GetErrY()==0) continue;
4854 //if (point->GetErrZ()==0) continue;
4856 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
4857 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
4858 //if ((ddy*ddy+ddz*ddz)>10) continue;
4861 // if (point->GetCPoint().GetMax()<5) continue;
4862 if (cl->GetMax()<5) continue;
4863 Float_t angley = point->GetAngleY();
4864 Float_t anglez = point->GetAngleZ();
4866 Float_t rsigmay2 = point->GetSigmaY();
4867 Float_t rsigmaz2 = point->GetSigmaZ();
4871 rsigmay += pointm->GetTPoint().GetSigmaY();
4872 rsigmaz += pointm->GetTPoint().GetSigmaZ();
4876 rsigmay += pointp->GetTPoint().GetSigmaY();
4877 rsigmaz += pointp->GetTPoint().GetSigmaZ();
4884 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
4886 Float_t ampc = 0; // normalization to the number of electrons
4888 // ampc = 1.*point->GetCPoint().GetMax();
4889 ampc = 1.*cl->GetMax();
4890 //ampc = 1.*point->GetCPoint().GetQ();
4891 // AliTPCClusterPoint & p = point->GetCPoint();
4892 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
4893 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4895 // TMath::Abs( Int_t(iz) - iz + 0.5);
4896 //ampc *= 1.15*(1-0.3*dy);
4897 //ampc *= 1.15*(1-0.3*dz);
4898 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
4902 //ampc = 1.0*point->GetCPoint().GetMax();
4903 ampc = 1.0*cl->GetMax();
4904 //ampc = 1.0*point->GetCPoint().GetQ();
4905 //AliTPCClusterPoint & p = point->GetCPoint();
4906 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
4907 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4909 // TMath::Abs( Int_t(iz) - iz + 0.5);
4911 //ampc *= 1.15*(1-0.3*dy);
4912 //ampc *= 1.15*(1-0.3*dz);
4913 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
4917 ampc *= 2.0; // put mean value to channel 50
4918 //ampc *= 0.58; // put mean value to channel 50
4920 // if (type>0) w = 1./(type/2.-0.5);
4921 // Float_t z = TMath::Abs(cl->GetZ());
4924 //ampc /= (1+0.0008*z);
4928 //ampc /= (1+0.0008*z);
4930 //ampc /= (1+0.0008*z);
4933 if (type<0) { //amp at the border - lower weight
4938 if (rsigma>1.5) ampc/=1.3; // if big backround
4940 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
4945 TMath::Sort(nc[of],amp,index,kFALSE);
4949 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
4951 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
4952 Float_t ampl = amp[index[i]]/angular[index[i]];
4953 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
4955 sumw += weight[index[i]];
4956 sumamp += weight[index[i]]*ampl;
4957 sumamp2 += weight[index[i]]*ampl*ampl;
4958 norm[of] += angular[index[i]]*weight[index[i]];
4965 mean[of] = sumamp/sumw;
4966 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
4968 sigma[of] = TMath::Sqrt(sigma[of]);
4972 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
4973 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
4974 //mean *=(1-0.1*(norm-1.));
4981 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
4982 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
4985 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
4986 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
4990 for (Int_t i =0;i<4;i++){
4991 if (nc[i]>2&&nc[i]<1000){
4992 dedx += mean[i] *nc[i];
4993 fSdEdx += sigma[i]*(nc[i]-2);
4994 fMAngular += norm[i] *nc[i];
4999 fSDEDX[i] = sigma[i];
5012 // Float_t dedx1 =dedx;
5015 for (Int_t i =0;i<4;i++){
5016 if (nc[i]>2&&nc[i]<1000){
5017 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5018 dedx += mean[i] *nc[i];
5033 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5036 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5037 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5038 SetMass(0.93827); return;
5042 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5043 SetMass(0.93827); return;
5046 SetMass(0.13957); return;
5056 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5057 //-----------------------------------------------------------------
5058 // This funtion calculates dE/dX within the "low" and "up" cuts.
5059 //-----------------------------------------------------------------
5062 Float_t angular[200];
5063 Float_t weight[200];
5065 Bool_t inlimit[200];
5066 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5067 for (Int_t i=0;i<200;i++) amp[i]=10000;
5068 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5072 Float_t meanlog = 100.;
5073 Int_t indexde[4]={0,64,128,160};
5080 Float_t mean[4] = {0,0,0,0};
5081 Float_t sigma[4] = {1000,1000,1000,1000};
5082 Int_t nc[4] = {0,0,0,0};
5083 Float_t norm[4] = {1000,1000,1000,1000};
5088 // for (Int_t of =0; of<3; of++){
5089 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5090 for (Int_t i =0; i<160;i++)
5092 AliTPCTrackPoint * point = GetTrackPoint(i);
5093 if (point==0) continue;
5094 if (point->fIsShared){
5098 Int_t type = point->GetCPoint().GetType();
5099 if (type<0) continue;
5100 if (point->GetCPoint().GetMax()<5) continue;
5101 Float_t angley = point->GetTPoint().GetAngleY();
5102 Float_t anglez = point->GetTPoint().GetAngleZ();
5103 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5104 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5105 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5107 Float_t ampc = 0; // normalization to the number of electrons
5109 ampc = point->GetCPoint().GetMax();
5112 ampc = point->GetCPoint().GetMax();
5114 ampc *= 2.0; // put mean value to channel 50
5115 // ampc *= 0.565; // put mean value to channel 50
5118 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5125 if (type<0) { //amp at the border - lower weight
5128 if (rsigma>1.5) ampc/=1.3; // if big backround
5129 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5130 amp[i] = ampc/angular[i];
5135 TMath::Sort(159,amp,index,kFALSE);
5136 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5137 inlimit[index[i]] = kTRUE; // take all clusters
5140 // meanlog = amp[index[Int_t(anc*0.3)]];
5142 for (Int_t of =0; of<3; of++){
5146 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5148 if (inlimit[i]==kFALSE) continue;
5149 Float_t ampl = amp[i];
5151 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5154 sumamp += weight[i]*ampl;
5155 sumamp2 += weight[i]*ampl*ampl;
5156 norm[of] += angular[i]*weight[i];
5164 mean[of] = sumamp/sumw;
5165 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5167 sigma[of] = TMath::Sqrt(sigma[of]);
5170 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5180 Float_t www[3] = {12.,14.,17.};
5181 //Float_t www[3] = {1.,1.,1.};
5183 for (Int_t i =0;i<3;i++){
5184 if (nc[i]>2&&nc[i]<1000){
5185 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5186 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5187 fMAngular += norm[i] *nc[i];
5188 norm2 += nc[i]*www[i]/sigma[i];
5189 norm3 += (nc[i]-2)*www[i]/sigma[i];
5192 fSDEDX[i] = sigma[i];
5205 // Float_t dedx1 =dedx;
5209 for (Int_t i =0;i<3;i++){
5210 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5211 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5212 dedx += mean[i] *(nc[i])/(sigma[i]);
5213 norm4 += (nc[i])/(sigma[i]);
5217 if (norm4>0) dedx /= norm4;