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.16 2003/10/17 12:01:16 kowal2
19 Removed compiler warning.
21 Revision 1.15 2003/09/29 11:56:58 kowal2
24 Revision 1.14 2003/09/29 11:39:43 kowal2
27 Revision 1.13 2003/09/29 11:28:19 kowal2
30 Revision 1.9.4.3 2003/06/23 14:47:10 hristov
33 Revision 1.9.4.2 2003/06/23 10:06:13 hristov
34 Updated information about the overlapping clusters (M.Ivanov)
36 Revision 1.9.4.1 2003/06/19 06:59:58 hristov
37 Updated version of parallel tracking (M.Ivanov)
39 Revision 1.9 2003/03/19 17:14:11 hristov
40 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)
42 Revision 1.8 2003/03/05 11:16:15 kowal2
54 AliTPC parallel tracker -
56 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
57 run AliTPCFindTracksMI.C macro - to find tracks
58 tracks are written to AliTPCtracks.root file
59 for comparison also seeds are written to the same file - to special branch
62 //-------------------------------------------------------
63 // Implementation of the TPC tracker
65 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
67 //-------------------------------------------------------
68 #include <TObjArray.h>
71 #include "Riostream.h"
73 #include "AliTPCtrackerMI.h"
74 #include "AliTPCclusterMI.h"
75 #include "AliTPCParam.h"
76 #include "AliTPCClustersRow.h"
77 #include "AliComplexCluster.h"
78 #include "AliTPCpolyTrack.h"
79 #include "TStopwatch.h"
84 #include "AliRunLoader.h"
89 ClassImp(AliTPCtrackerMI)
95 static Double_t FastAsin(Double_t x);
97 static Double_t fgFastAsin[20000];
100 Double_t TPCFastMath::fgFastAsin[20000];
102 TPCFastMath::TPCFastMath(){
103 for (Int_t i=0;i<10000;i++){
104 fgFastAsin[2*i] = TMath::ASin(i/10000.);
105 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
109 Double_t TPCFastMath::FastAsin(Double_t x){
111 Int_t index = int(x*10000);
112 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
115 Int_t index = int(x*10000);
116 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
119 TPCFastMath gTPCMath;
123 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
125 AliTPCclusterMI* c =track->fCurrentCluster;
126 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
128 UInt_t i = track->fCurrentClusterIndex1;
130 Int_t sec=(i&0xff000000)>>24;
131 //Int_t row = (i&0x00ff0000)>>16;
132 track->fRow=(i&0x00ff0000)>>16;
133 track->fSector = sec;
134 // Int_t index = i&0xFFFF;
135 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
136 track->SetClusterIndex2(track->fRow, i);
138 //track->fFirstPoint = row;
139 //if ( track->fLastPoint<row) track->fLastPoint =row;
140 // if (track->fRow<0 || track->fRow>160) {
141 // printf("problem\n");
143 if (track->fFirstPoint>track->fRow)
144 track->fFirstPoint = track->fRow;
145 if (track->fLastPoint<track->fRow)
146 track->fLastPoint = track->fRow;
149 track->fClusterPointer[track->fRow] = c;
152 Float_t angle2 = track->GetSnp()*track->GetSnp();
153 angle2 = TMath::Sqrt(angle2/(1-angle2));
155 //SET NEW Track Point
159 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
161 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
162 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
163 point.SetErrY(sqrt(track->fErrorY2));
164 point.SetErrZ(sqrt(track->fErrorZ2));
166 point.SetX(track->GetX());
167 point.SetY(track->GetY());
168 point.SetZ(track->GetZ());
169 point.SetAngleY(angle2);
170 point.SetAngleZ(track->GetTgl());
171 if (point.fIsShared){
172 track->fErrorY2 *= 4;
173 track->fErrorZ2 *= 4;
177 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
179 track->fErrorY2 *= 1.3;
180 track->fErrorY2 += 0.01;
181 track->fErrorZ2 *= 1.3;
182 track->fErrorZ2 += 0.005;
184 if (accept>0) return 0;
185 if (track->GetNumberOfClusters()%20==0){
186 // if (track->fHelixIn){
187 // TClonesArray & larr = *(track->fHelixIn);
188 // Int_t ihelix = larr.GetEntriesFast();
189 // new(larr[ihelix]) AliHelix(*track) ;
192 track->fNoCluster =0;
193 return track->Update(c,chi2,i);
198 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
199 Float_t cory, Float_t corz)
202 // decide according desired precision to accept given
203 // cluster for tracking
204 Double_t sy2=ErrY2(seed,cluster)*cory;
205 Double_t sz2=ErrZ2(seed,cluster)*corz;
206 //sy2=ErrY2(seed,cluster)*cory;
207 //sz2=ErrZ2(seed,cluster)*cory;
209 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
210 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
212 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
213 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
214 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
215 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
217 Double_t rdistance2 = rdistancey2+rdistancez2;
220 if (rdistance2>16) return 3;
223 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
224 return 2; //suspisiouce - will be changed
226 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
227 // strict cut on overlaped cluster
228 return 2; //suspisiouce - will be changed
230 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
231 && cluster->GetType()<0){
241 //_____________________________________________________________________________
242 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
243 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
245 //---------------------------------------------------------------------
246 // The main TPC tracker constructor
247 //---------------------------------------------------------------------
248 fInnerSec=new AliTPCSector[fkNIS];
249 fOuterSec=new AliTPCSector[fkNOS];
252 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
253 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
260 Int_t nrowlow = par->GetNRowLow();
261 Int_t nrowup = par->GetNRowUp();
264 for (Int_t i=0;i<nrowlow;i++){
265 fXRow[i] = par->GetPadRowRadiiLow(i);
266 fPadLength[i]= par->GetPadPitchLength(0,i);
267 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
271 for (Int_t i=0;i<nrowup;i++){
272 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
273 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
274 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
287 //_____________________________________________________________________________
288 AliTPCtrackerMI::~AliTPCtrackerMI() {
289 //------------------------------------------------------------------
290 // TPC tracker destructor
291 //------------------------------------------------------------------
300 void AliTPCtrackerMI::SetIO()
304 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
305 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
306 AliTPCtrack *iotrack= new AliTPCtrack;
307 // iotrack->fHelixIn = new TClonesArray("AliHelix");
308 //iotrack->fHelixOut = new TClonesArray("AliHelix");
309 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
313 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
329 AliTPCtrack *iotrack= new AliTPCtrack;
330 // iotrack->fHelixIn = new TClonesArray("AliHelix");
331 //iotrack->fHelixOut = new TClonesArray("AliHelix");
332 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
335 if (output && (fDebug&2)){
336 //write the full seed information if specified in debug mode
338 fSeedTree = new TTree("Seeds","Seeds");
339 AliTPCseed * vseed = new AliTPCseed;
341 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
342 arrtr->ExpandCreateFast(160);
343 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
345 vseed->fPoints = arrtr;
346 vseed->fEPoints = arre;
347 // vseed->fClusterPoints = arrcl;
348 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
351 fTreeDebug = new TTree("trackDebug","trackDebug");
352 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
353 fTreeDebug->Branch("debug",&arrd,32000,99);
361 void AliTPCtrackerMI::WriteTracks()
364 // write tracks to the given output tree -
365 // output specified with SetIO routine
368 // write tracks to the event
369 // store index of the track
370 Int_t nseed=fSeeds->GetEntriesFast();
371 for (Int_t i=0; i<nseed; i++) {
372 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
375 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
376 //iotrack.SetTPCindex(i);
377 fEvent->AddTrack(&iotrack);
383 AliTPCtrack *iotrack= 0;
384 Int_t nseed=fSeeds->GetEntriesFast();
385 for (Int_t i=0; i<nseed; i++) {
386 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
390 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
391 TBranch * br = fOutput->GetBranch("tracks");
392 br->SetAddress(&iotrack);
394 for (Int_t i=0; i<nseed; i++) {
395 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
399 // br->SetAddress(&iotrack);
407 //write the full seed information if specified in debug mode
409 AliTPCseed * vseed = new AliTPCseed;
411 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
412 arrtr->ExpandCreateFast(160);
413 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
414 //arrcl->ExpandCreateFast(160);
415 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
417 vseed->fPoints = arrtr;
418 vseed->fEPoints = arre;
419 // vseed->fClusterPoints = arrcl;
420 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
421 TBranch * brseed = fSeedTree->GetBranch("seeds");
423 Int_t nseed=fSeeds->GetEntriesFast();
425 for (Int_t i=0; i<nseed; i++) {
426 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
429 // pt->fClusterPoints = arrcl;
433 brseed->SetAddress(&vseed);
437 // pt->fClusterPoints = 0;
440 if (fTreeDebug) fTreeDebug->Write();
448 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
451 //seed->SetErrorY2(0.1);
453 //calculate look-up table at the beginning
454 static Bool_t ginit = kFALSE;
455 static Float_t gnoise1,gnoise2,gnoise3;
456 static Float_t ggg1[10000];
457 static Float_t ggg2[10000];
458 static Float_t ggg3[10000];
459 static Float_t glandau1[10000];
460 static Float_t glandau2[10000];
461 static Float_t glandau3[10000];
463 static Float_t gcor01[500];
464 static Float_t gcor02[500];
465 static Float_t gcorp[500];
470 for (Int_t i=1;i<500;i++){
471 Float_t rsigma = float(i)/100.;
472 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
473 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
474 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
478 for (Int_t i=3;i<10000;i++){
482 Float_t amp = float(i);
483 Float_t padlength =0.75;
484 gnoise1 = 0.0004/padlength;
485 Float_t nel = 0.268*amp;
486 Float_t nprim = 0.155*amp;
487 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
488 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
489 if (glandau1[i]>1) glandau1[i]=1;
490 glandau1[i]*=padlength*padlength/12.;
494 gnoise2 = 0.0004/padlength;
497 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
498 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
499 if (glandau2[i]>1) glandau2[i]=1;
500 glandau2[i]*=padlength*padlength/12.;
505 gnoise3 = 0.0004/padlength;
508 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
509 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
510 if (glandau3[i]>1) glandau3[i]=1;
511 glandau3[i]*=padlength*padlength/12.;
519 Int_t amp = int(TMath::Abs(cl->GetQ()));
521 seed->SetErrorY2(1.);
525 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
526 Int_t ctype = cl->GetType();
527 Float_t padlength= GetPadPitchLength(seed->fRow);
528 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
529 angle2 = angle2/(1-angle2);
532 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
535 if (fSectors==fInnerSec){
537 res = ggg1[amp]*z+glandau1[amp]*angle2;
538 if (ctype==0) res *= gcor01[rsigmay];
541 res*= gcorp[rsigmay];
547 res = ggg2[amp]*z+glandau2[amp]*angle2;
548 if (ctype==0) res *= gcor02[rsigmay];
551 res*= gcorp[rsigmay];
556 res = ggg3[amp]*z+glandau3[amp]*angle2;
557 if (ctype==0) res *= gcor02[rsigmay];
560 res*= gcorp[rsigmay];
567 res*=2.4; // overestimate error 2 times
574 seed->SetErrorY2(res);
582 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
585 //seed->SetErrorY2(0.1);
587 //calculate look-up table at the beginning
588 static Bool_t ginit = kFALSE;
589 static Float_t gnoise1,gnoise2,gnoise3;
590 static Float_t ggg1[10000];
591 static Float_t ggg2[10000];
592 static Float_t ggg3[10000];
593 static Float_t glandau1[10000];
594 static Float_t glandau2[10000];
595 static Float_t glandau3[10000];
597 static Float_t gcor01[1000];
598 static Float_t gcor02[1000];
599 static Float_t gcorp[1000];
604 for (Int_t i=1;i<1000;i++){
605 Float_t rsigma = float(i)/100.;
606 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
607 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
608 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
612 for (Int_t i=3;i<10000;i++){
616 Float_t amp = float(i);
617 Float_t padlength =0.75;
618 gnoise1 = 0.0004/padlength;
619 Float_t nel = 0.268*amp;
620 Float_t nprim = 0.155*amp;
621 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
622 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
623 if (glandau1[i]>1) glandau1[i]=1;
624 glandau1[i]*=padlength*padlength/12.;
628 gnoise2 = 0.0004/padlength;
631 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
632 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
633 if (glandau2[i]>1) glandau2[i]=1;
634 glandau2[i]*=padlength*padlength/12.;
639 gnoise3 = 0.0004/padlength;
642 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
643 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
644 if (glandau3[i]>1) glandau3[i]=1;
645 glandau3[i]*=padlength*padlength/12.;
653 Int_t amp = int(TMath::Abs(cl->GetQ()));
655 seed->SetErrorY2(1.);
659 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
660 Int_t ctype = cl->GetType();
661 Float_t padlength= GetPadPitchLength(seed->fRow);
663 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
664 // if (angle2<0.6) angle2 = 0.6;
665 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
668 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
671 if (fSectors==fInnerSec){
673 res = ggg1[amp]*z+glandau1[amp]*angle2;
674 if (ctype==0) res *= gcor01[rsigmaz];
677 res*= gcorp[rsigmaz];
683 res = ggg2[amp]*z+glandau2[amp]*angle2;
684 if (ctype==0) res *= gcor02[rsigmaz];
687 res*= gcorp[rsigmaz];
692 res = ggg3[amp]*z+glandau3[amp]*angle2;
693 if (ctype==0) res *= gcor02[rsigmaz];
696 res*= gcorp[rsigmaz];
705 if ((ctype<0) &&<70){
713 seed->SetErrorZ2(res);
720 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
723 //seed->SetErrorZ2(0.1);
727 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
729 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
730 Int_t ctype = cl->GetType();
731 Float_t amp = TMath::Abs(cl->GetQ());
736 Float_t landau=2 ; //landau fluctuation part
737 Float_t gg=2; // gg fluctuation part
738 Float_t padlength= GetPadPitchLength(seed->GetX());
740 if (fSectors==fInnerSec){
741 snoise2 = 0.0004/padlength;
744 gg = (2+0.001*nel/(padlength*padlength))/nel;
745 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
746 if (landau>1) landau=1;
749 snoise2 = 0.0004/padlength;
752 gg = (2+0.0008*nel/(padlength*padlength))/nel;
753 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
754 if (landau>1) landau=1;
756 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
759 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
760 angle2 = TMath::Sqrt((1-angle2));
761 if (angle2<0.6) angle2 = 0.6;
764 Float_t angle = seed->GetTgl()/angle2;
765 Float_t angular = landau*angle*angle*padlength*padlength/12.;
766 Float_t res = sdiff + angular;
769 if ((ctype==0) && (fSectors ==fOuterSec))
770 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
772 if ((ctype==0) && (fSectors ==fInnerSec))
773 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
777 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
783 if ((ctype<0) &&<70){
791 seed->SetErrorZ2(res);
798 void AliTPCseed::Reset(Bool_t all)
802 SetNumberOfClusters(0);
808 for (Int_t i=0;i<8;i++){
809 delete [] fTrackPoints[i];
817 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
818 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
824 void AliTPCseed::Modify(Double_t factor)
827 //------------------------------------------------------------------
828 //This function makes a track forget its history :)
829 //------------------------------------------------------------------
835 fC10*=factor; fC11*=factor;
836 fC20*=factor; fC21*=factor; fC22*=factor;
837 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
838 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
839 SetNumberOfClusters(0);
843 fCurrentSigmaY2 = 0.000005;
844 fCurrentSigmaZ2 = 0.000005;
853 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
855 //-----------------------------------------------------------------
856 // This function find proloncation of a track to a reference plane x=xk.
857 // doesn't change internal state of the track
858 //-----------------------------------------------------------------
860 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
862 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
866 // Double_t y1=fP0, z1=fP1;
867 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
868 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
872 //y += dx*(c1+c2)/(r1+r2);
873 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
875 Double_t dy = dx*(c1+c2)/(r1+r2);
878 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
880 if (TMath::Abs(delta)>0.0001){
881 dz = fP3*TMath::ASin(delta)/fP4;
883 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
886 dz = fP3*TPCFastMath::FastAsin(delta)/fP4;
896 //_____________________________________________________________________________
897 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
899 //-----------------------------------------------------------------
900 // This function calculates a predicted chi2 increment.
901 //-----------------------------------------------------------------
902 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
903 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
904 r00+=fC00; r01+=fC10; r11+=fC11;
906 Double_t det=r00*r11 - r01*r01;
907 if (TMath::Abs(det) < 1.e-10) {
908 Int_t n=GetNumberOfClusters();
909 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
912 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
914 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
916 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
920 //_________________________________________________________________________________________
923 Int_t AliTPCseed::Compare(const TObject *o) const {
924 //-----------------------------------------------------------------
925 // This function compares tracks according to the sector - for given sector according z
926 //-----------------------------------------------------------------
927 AliTPCseed *t=(AliTPCseed*)o;
930 if (t->fRelativeSector>fRelativeSector) return -1;
931 if (t->fRelativeSector<fRelativeSector) return 1;
932 Double_t z2 = t->GetZ();
933 Double_t z1 = GetZ();
935 if (z2<z1) return -1;
940 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
941 if (t->fBConstrain) f2=1.2;
944 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
946 if (fBConstrain) f1=1.2;
948 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
953 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
955 //rotate to track "local coordinata
956 Float_t x = seed->GetX();
957 Float_t y = seed->GetY();
958 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
961 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
962 if (!seed->Rotate(fSectors->GetAlpha()))
964 } else if (y <-ymax) {
965 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
966 if (!seed->Rotate(-fSectors->GetAlpha()))
975 //_____________________________________________________________________________
976 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
977 //-----------------------------------------------------------------
978 // This function associates a cluster with this track.
979 //-----------------------------------------------------------------
980 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
982 r00+=fC00; r01+=fC10; r11+=fC11;
983 Double_t det=r00*r11 - r01*r01;
984 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
986 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
987 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
988 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
989 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
990 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
992 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
993 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
994 if (TMath::Abs(cur*fX-eta) >= 0.9) {
998 fP0 += k00*dy + k01*dz;
999 fP1 += k10*dy + k11*dz;
1001 fP3 += k30*dy + k31*dz;
1004 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1005 Double_t c12=fC21, c13=fC31, c14=fC41;
1007 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1008 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1009 fC40-=k00*c04+k01*c14;
1011 fC11-=k10*c01+k11*fC11;
1012 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1013 fC41-=k10*c04+k11*c14;
1015 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1016 fC42-=k20*c04+k21*c14;
1018 fC33-=k30*c03+k31*c13;
1019 fC43-=k40*c03+k41*c13;
1021 fC44-=k40*c04+k41*c14;
1023 Int_t n=GetNumberOfClusters();
1025 SetNumberOfClusters(n+1);
1026 SetChi2(GetChi2()+chisq);
1033 //_____________________________________________________________________________
1034 Double_t AliTPCtrackerMI::f1old(Double_t x1,Double_t y1,
1035 Double_t x2,Double_t y2,
1036 Double_t x3,Double_t y3)
1038 //-----------------------------------------------------------------
1039 // Initial approximation of the track curvature
1040 //-----------------------------------------------------------------
1041 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1042 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1043 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1044 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1045 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1047 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1048 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1049 return -xr*yr/sqrt(xr*xr+yr*yr);
1054 //_____________________________________________________________________________
1055 Double_t AliTPCtrackerMI::f1(Double_t x1,Double_t y1,
1056 Double_t x2,Double_t y2,
1057 Double_t x3,Double_t y3)
1059 //-----------------------------------------------------------------
1060 // Initial approximation of the track curvature
1061 //-----------------------------------------------------------------
1067 Double_t det = x3*y2-x2*y3;
1072 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1073 Double_t x0 = x3*0.5-y3*u;
1074 Double_t y0 = y3*0.5+x3*u;
1075 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1081 Double_t AliTPCtrackerMI::f2(Double_t x1,Double_t y1,
1082 Double_t x2,Double_t y2,
1083 Double_t x3,Double_t y3)
1085 //-----------------------------------------------------------------
1086 // Initial approximation of the track curvature
1087 //-----------------------------------------------------------------
1093 Double_t det = x3*y2-x2*y3;
1098 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1099 Double_t x0 = x3*0.5-y3*u;
1100 Double_t y0 = y3*0.5+x3*u;
1101 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1110 //_____________________________________________________________________________
1111 Double_t AliTPCtrackerMI::f2old(Double_t x1,Double_t y1,
1112 Double_t x2,Double_t y2,
1113 Double_t x3,Double_t y3)
1115 //-----------------------------------------------------------------
1116 // Initial approximation of the track curvature times center of curvature
1117 //-----------------------------------------------------------------
1118 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1119 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1120 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1121 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1122 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1124 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1126 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1129 //_____________________________________________________________________________
1130 Double_t AliTPCtrackerMI::f3(Double_t x1,Double_t y1,
1131 Double_t x2,Double_t y2,
1132 Double_t z1,Double_t z2)
1134 //-----------------------------------------------------------------
1135 // Initial approximation of the tangent of the track dip angle
1136 //-----------------------------------------------------------------
1137 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1141 Double_t AliTPCtrackerMI::f3n(Double_t x1,Double_t y1,
1142 Double_t x2,Double_t y2,
1143 Double_t z1,Double_t z2, Double_t c)
1145 //-----------------------------------------------------------------
1146 // Initial approximation of the tangent of the track dip angle
1147 //-----------------------------------------------------------------
1151 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1153 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1154 if (TMath::Abs(d*c*0.5)>1) return 0;
1155 // Double_t angle2 = TMath::ASin(d*c*0.5);
1156 // Double_t angle2 = TPCFastMath::FastAsin(d*c*0.5);
1157 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): TPCFastMath::FastAsin(d*c*0.5);
1159 angle2 = (z1-z2)*c/(angle2*2.);
1163 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1164 {//-----------------------------------------------------------------
1165 // This function find proloncation of a track to a reference plane x=x2.
1166 //-----------------------------------------------------------------
1170 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1174 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1175 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1179 Double_t dy = dx*(c1+c2)/(r1+r2);
1182 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1184 if (TMath::Abs(delta)>0.01){
1185 dz = x[3]*TMath::ASin(delta)/x[4];
1187 dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1190 //dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1200 Int_t AliTPCtrackerMI::LoadClusters()
1203 // load clusters to the memory
1204 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1205 clrow->SetClass("AliTPCclusterMI");
1207 clrow->GetArray()->ExpandCreateFast(10000);
1209 // TTree * tree = fClustersArray.GetTree();
1211 TTree * tree = fInput;
1212 TBranch * br = tree->GetBranch("Segment");
1213 br->SetAddress(&clrow);
1215 Int_t j=Int_t(tree->GetEntries());
1216 for (Int_t i=0; i<j; i++) {
1220 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1222 AliTPCRow * tpcrow=0;
1225 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1229 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1230 left = (sec-fkNIS*2)/fkNOS;
1233 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1234 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1235 for (Int_t i=0;i<tpcrow->fN1;i++)
1236 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1239 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1240 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1241 for (Int_t i=0;i<tpcrow->fN2;i++)
1242 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1253 void AliTPCtrackerMI::UnloadClusters()
1256 // unload clusters from the memory
1258 Int_t nrows = fOuterSec->GetNRows();
1259 for (Int_t sec = 0;sec<fkNOS;sec++)
1260 for (Int_t row = 0;row<nrows;row++){
1261 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1263 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1264 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1268 nrows = fInnerSec->GetNRows();
1269 for (Int_t sec = 0;sec<fkNIS;sec++)
1270 for (Int_t row = 0;row<nrows;row++){
1271 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1273 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1274 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1282 //_____________________________________________________________________________
1283 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1284 //-----------------------------------------------------------------
1285 // This function fills outer TPC sectors with clusters.
1286 //-----------------------------------------------------------------
1287 Int_t nrows = fOuterSec->GetNRows();
1289 for (Int_t sec = 0;sec<fkNOS;sec++)
1290 for (Int_t row = 0;row<nrows;row++){
1291 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1292 Int_t sec2 = sec+2*fkNIS;
1294 Int_t ncl = tpcrow->fN1;
1296 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1297 index=(((sec2<<8)+row)<<16)+ncl;
1298 tpcrow->InsertCluster(c,index);
1303 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1304 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1305 tpcrow->InsertCluster(c,index);
1308 // write indexes for fast acces
1310 for (Int_t i=0;i<510;i++)
1311 tpcrow->fFastCluster[i]=-1;
1312 for (Int_t i=0;i<tpcrow->GetN();i++){
1313 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1314 tpcrow->fFastCluster[zi]=i; // write index
1317 for (Int_t i=0;i<510;i++){
1318 if (tpcrow->fFastCluster[i]<0)
1319 tpcrow->fFastCluster[i] = last;
1321 last = tpcrow->fFastCluster[i];
1330 //_____________________________________________________________________________
1331 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1332 //-----------------------------------------------------------------
1333 // This function fills inner TPC sectors with clusters.
1334 //-----------------------------------------------------------------
1335 Int_t nrows = fInnerSec->GetNRows();
1337 for (Int_t sec = 0;sec<fkNIS;sec++)
1338 for (Int_t row = 0;row<nrows;row++){
1339 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1342 Int_t ncl = tpcrow->fN1;
1344 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1345 index=(((sec<<8)+row)<<16)+ncl;
1346 tpcrow->InsertCluster(c,index);
1351 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1352 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1353 tpcrow->InsertCluster(c,index);
1356 // write indexes for fast acces
1358 for (Int_t i=0;i<510;i++)
1359 tpcrow->fFastCluster[i]=-1;
1360 for (Int_t i=0;i<tpcrow->GetN();i++){
1361 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1362 tpcrow->fFastCluster[zi]=i; // write index
1365 for (Int_t i=0;i<510;i++){
1366 if (tpcrow->fFastCluster[i]<0)
1367 tpcrow->fFastCluster[i] = last;
1369 last = tpcrow->fFastCluster[i];
1381 //_________________________________________________________________________
1382 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1383 //--------------------------------------------------------------------
1384 // Return pointer to a given cluster
1385 //--------------------------------------------------------------------
1386 Int_t sec=(index&0xff000000)>>24;
1387 Int_t row=(index&0x00ff0000)>>16;
1388 Int_t ncl=(index&0x0000ffff)>>00;
1390 const AliTPCRow * tpcrow=0;
1391 AliTPCclusterMI * clrow =0;
1393 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1395 clrow = tpcrow->fClusters1;
1397 clrow = tpcrow->fClusters2;
1400 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1401 if (sec-2*fkNIS<fkNOS)
1402 clrow = tpcrow->fClusters1;
1404 clrow = tpcrow->fClusters2;
1406 if (tpcrow==0) return 0;
1407 if (tpcrow->GetN()<=ncl) return 0;
1408 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1409 return &(clrow[ncl]);
1415 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1416 //-----------------------------------------------------------------
1417 // This function tries to find a track prolongation to next pad row
1418 //-----------------------------------------------------------------
1420 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1422 // if (t.GetRadius()>x+10 ) return 0;
1423 // t.PropagateTo(x+0.02);
1424 //t.PropagateTo(x+0.01);
1425 if (!t.PropagateTo(x)) {
1430 Double_t y=t.GetY(), z=t.GetZ();
1431 if (TMath::Abs(y)>ymax){
1433 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1434 if (!t.Rotate(fSectors->GetAlpha()))
1436 } else if (y <-ymax) {
1437 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1438 if (!t.Rotate(-fSectors->GetAlpha()))
1441 if (!t.PropagateTo(x)) {
1447 // update current shape info every 3 pad-row
1448 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1449 //t.fCurrentSigmaY = GetSigmaY(&t);
1450 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1454 AliTPCclusterMI *cl=0;
1459 if (t.GetClusterIndex2(nr)>0){
1461 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1462 index = t.GetClusterIndex2(nr);
1463 cl = t.fClusterPointer[nr];
1464 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1465 t.fCurrentClusterIndex1 = index;
1468 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1469 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1471 Double_t roadz = 1.;
1473 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1475 t.SetClusterIndex2(nr,-1);
1480 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1486 t.fCurrentCluster = cl;
1488 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1490 //if founded cluster is acceptible
1491 UpdateTrack(&t,accept);
1497 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1498 cl = krow.FindNearest2(y,z,roady,roadz,index);
1499 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1504 t.fCurrentCluster = cl;
1506 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1508 if (t.fCurrentCluster->IsUsed(10)){
1513 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1519 if (accept<3) UpdateTrack(&t,accept);
1522 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1528 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1529 //-----------------------------------------------------------------
1530 // This function tries to find a track prolongation to next pad row
1531 //-----------------------------------------------------------------
1533 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1535 if (!t.GetProlongation(x,y,z)) {
1541 if (TMath::Abs(y)>ymax){
1545 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1546 if (!t.Rotate(fSectors->GetAlpha()))
1548 } else if (y <-ymax) {
1549 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1550 if (!t.Rotate(-fSectors->GetAlpha()))
1553 if (!t.PropagateTo(x)) {
1556 t.GetProlongation(x,y,z);
1559 // update current shape info every 3 pad-row
1560 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1561 // t.fCurrentSigmaY = GetSigmaY(&t);
1562 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1566 AliTPCclusterMI *cl=0;
1571 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1572 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1574 Double_t roadz = 1.;
1577 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1579 t.SetClusterIndex2(row,-1);
1584 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1588 if ((cl==0)&&(krow)) {
1589 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1590 cl = krow.FindNearest2(y,z,roady,roadz,index);
1592 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1596 t.fCurrentCluster = cl;
1597 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1599 t.SetClusterIndex2(row,index);
1600 t.fClusterPointer[row] = cl;
1608 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1609 //-----------------------------------------------------------------
1610 // This function tries to find a track prolongation to next pad row
1611 //-----------------------------------------------------------------
1612 t.fCurrentCluster = 0;
1613 t.fCurrentClusterIndex1 = 0;
1615 Double_t xt=t.GetX();
1616 Int_t row = GetRowNumber(xt)-1;
1617 Double_t ymax= GetMaxY(nr);
1619 if (row < nr) return 1; // don't prolongate if not information until now -
1620 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1622 return 0; // not prolongate strongly inclined tracks
1624 if (TMath::Abs(t.GetSnp())>0.95) {
1626 return 0; // not prolongate strongly inclined tracks
1629 Double_t x= GetXrow(nr);
1631 //t.PropagateTo(x+0.02);
1632 //t.PropagateTo(x+0.01);
1633 if (!t.PropagateTo(x)){
1640 if (TMath::Abs(y)>ymax){
1642 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1643 if (!t.Rotate(fSectors->GetAlpha()))
1645 } else if (y <-ymax) {
1646 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1647 if (!t.Rotate(-fSectors->GetAlpha()))
1650 if (!t.PropagateTo(x)){
1657 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1659 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1661 t.SetClusterIndex2(nr,-1);
1666 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1672 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1673 // t.fCurrentSigmaY = GetSigmaY(&t);
1674 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1678 AliTPCclusterMI *cl=0;
1681 Double_t roady = 1.;
1682 Double_t roadz = 1.;
1685 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1686 cl = krow.FindNearest2(y,z,roady,roadz,index);
1688 t.fCurrentCluster = cl;
1689 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1694 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1695 //-----------------------------------------------------------------
1696 // This function tries to find a track prolongation to next pad row
1697 //-----------------------------------------------------------------
1699 //update error according neighborhoud
1701 if (t.fCurrentCluster) {
1703 Bool_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1705 if (t.fCurrentCluster->IsUsed(10)){
1711 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1717 /*if (accept<3) */ UpdateTrack(&t,accept);
1721 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1722 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1724 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1732 //_____________________________________________________________________________
1733 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1734 //-----------------------------------------------------------------
1735 // This function tries to find a track prolongation.
1736 //-----------------------------------------------------------------
1737 Double_t xt=t.GetX();
1739 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1740 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1741 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1743 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1745 Int_t first = GetRowNumber(xt)-1;
1746 for (Int_t nr= first; nr>=rf; nr-=step) {
1747 if (FollowToNext(t,nr)==0)
1748 if (!t.IsActive()) return 0;
1755 //_____________________________________________________________________________
1756 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1757 //-----------------------------------------------------------------
1758 // This function tries to find a track prolongation.
1759 //-----------------------------------------------------------------
1760 Double_t xt=t.GetX();
1762 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1763 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1764 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1765 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1767 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1769 if (FollowToNextFast(t,nr)==0)
1770 if (!t.IsActive()) return 0;
1780 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1781 //-----------------------------------------------------------------
1782 // This function tries to find a track prolongation.
1783 //-----------------------------------------------------------------
1784 // Double_t xt=t.GetX();
1786 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1787 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1788 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1789 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1792 first = t.fFirstPoint+3;
1794 if (first<0) first=0;
1795 for (Int_t nr=first+1; nr<=rf; nr++) {
1796 //if ( (t.GetSnp()<0.9))
1806 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1814 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1817 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1819 Float_t distance = TMath::Sqrt(dz2+dy2);
1820 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1823 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1824 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1829 if (firstpoint>lastpoint) {
1830 firstpoint =lastpoint;
1835 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1836 if (s1->GetClusterIndex2(i)>0) sum1++;
1837 if (s2->GetClusterIndex2(i)>0) sum2++;
1838 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1842 if (sum<5) return 0;
1844 Float_t summin = TMath::Min(sum1+1,sum2+1);
1845 Float_t ratio = (sum+1)/Float_t(summin);
1849 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1853 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1854 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1856 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1858 Float_t dy2 =(s1->GetY() - s2->GetY());
1860 Float_t distance = dz2+dy2;
1861 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1866 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1867 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1869 if (firstpoint>=lastpoint-5) return;;
1871 for (Int_t i=firstpoint;i<lastpoint;i++){
1872 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1873 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1880 for (Int_t i=firstpoint;i<lastpoint;i++){
1881 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1882 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1883 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1884 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1885 if (s1->IsActive()&&s2->IsActive()){
1886 p1->fIsShared = kTRUE;
1887 p2->fIsShared = kTRUE;
1894 for (Int_t i=0;i<4;i++){
1895 if (s1->fOverlapLabels[3*i]==0){
1896 s1->fOverlapLabels[3*i] = s2->GetLabel();
1897 s1->fOverlapLabels[3*i+1] = sumshared;
1898 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1902 for (Int_t i=0;i<4;i++){
1903 if (s2->fOverlapLabels[3*i]==0){
1904 s2->fOverlapLabels[3*i] = s1->GetLabel();
1905 s2->fOverlapLabels[3*i+1] = sumshared;
1906 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1914 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1917 //sort trackss according sectors
1919 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1920 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1922 //if (pt) RotateToLocal(pt);
1926 arr->Sort(); // sorting according z
1927 arr->Expand(arr->GetEntries());
1930 Int_t nseed=arr->GetEntriesFast();
1931 for (Int_t i=0; i<nseed; i++) {
1932 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1934 for (Int_t j=0;j<=12;j++){
1935 pt->fOverlapLabels[j] =0;
1938 for (Int_t i=0; i<nseed; i++) {
1939 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1941 if (pt->fRemoval>10) continue;
1942 for (Int_t j=i+1; j<nseed; j++){
1943 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1945 if (pt2->fRemoval<=10) {
1946 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1953 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1956 //sort trackss according sectors
1959 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1962 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1963 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1968 arr->Sort(); // sorting according z
1969 arr->Expand(arr->GetEntries());
1971 //reset overlap labels
1973 Int_t nseed=arr->GetEntriesFast();
1974 for (Int_t i=0; i<nseed; i++) {
1975 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1978 for (Int_t j=0;j<=12;j++){
1979 pt->fOverlapLabels[j] =0;
1983 //sign shared tracks
1984 for (Int_t i=0; i<nseed; i++) {
1985 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1987 if (pt->fRemoval>10) continue;
1988 Float_t deltac = pt->GetC()*0.1;
1989 for (Int_t j=i+1; j<nseed; j++){
1990 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1992 if (pt2->fRemoval<=10) {
1993 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1994 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
1995 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2002 // remove highly shared tracks
2003 for (Int_t i=0; i<nseed; i++) {
2004 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2006 if (pt->fRemoval>10) continue;
2009 for (Int_t j=0;j<4;j++){
2010 sumshared = pt->fOverlapLabels[j*3+1];
2012 Float_t factor = factor1;
2013 if (pt->fRemoval>0) factor = factor2;
2014 if (sumshared/pt->GetNumberOfClusters()>factor){
2015 for (Int_t j=0;j<4;j++){
2016 if (pt->fOverlapLabels[3*j]==0) continue;
2017 if (pt->fOverlapLabels[3*j+1]<5) continue;
2018 if (pt->fRemoval==removalindex) continue;
2019 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2021 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2022 // pt->fRemoval = removalindex;
2023 delete arr->RemoveAt(i);
2031 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2040 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode)
2043 //sort tracks in array according mode criteria
2044 Int_t nseed = arr->GetEntriesFast();
2045 for (Int_t i=0; i<nseed; i++) {
2046 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2056 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2059 //Loop over all tracks and remove "overlaps"
2062 Int_t nseed = arr->GetEntriesFast();
2065 for (Int_t i=0; i<nseed; i++) {
2066 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2068 delete arr->RemoveAt(i);
2072 pt->fBSigned = kFALSE;
2076 nseed = arr->GetEntriesFast();
2083 for (Int_t i=0; i<nseed; i++) {
2084 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2088 Int_t found,foundable,shared;
2090 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2092 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2094 Double_t factor = factor2;
2095 if (pt->fBConstrain) factor = factor1;
2097 if ((Float_t(shared)/Float_t(found))>factor){
2098 pt->Desactivate(removalindex);
2103 for (Int_t i=0; i<160; i++) {
2104 Int_t index=pt->GetClusterIndex2(i);
2105 if (index<0 || index&0x8000 ) continue;
2106 AliTPCclusterMI *c= pt->fClusterPointer[i];
2108 // if (!c->IsUsed(10)) c->Use(10);
2109 //if (pt->IsActive())
2118 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2121 void AliTPCtrackerMI::UnsignClusters()
2124 // loop over all clusters and unsign them
2127 for (Int_t sec=0;sec<fkNIS;sec++){
2128 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2129 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2130 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2131 // if (cl[icl].IsUsed(10))
2133 cl = fInnerSec[sec][row].fClusters2;
2134 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2135 //if (cl[icl].IsUsed(10))
2140 for (Int_t sec=0;sec<fkNOS;sec++){
2141 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2142 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2143 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2144 //if (cl[icl].IsUsed(10))
2146 cl = fOuterSec[sec][row].fClusters2;
2147 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2148 //if (cl[icl].IsUsed(10))
2157 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2160 //sign clusters to be "used"
2162 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2163 // loop over "primaries"
2177 Int_t nseed = arr->GetEntriesFast();
2178 for (Int_t i=0; i<nseed; i++) {
2179 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2183 if (!(pt->IsActive())) continue;
2184 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2185 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2187 sumdens2+= dens*dens;
2188 sumn += pt->GetNumberOfClusters();
2189 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2190 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2193 sumchi2 +=chi2*chi2;
2198 Float_t mdensity = 0.9;
2199 Float_t meann = 130;
2200 Float_t meanchi = 1;
2201 Float_t sdensity = 0.1;
2202 Float_t smeann = 10;
2203 Float_t smeanchi =0.4;
2207 mdensity = sumdens/sum;
2209 meanchi = sumchi/sum;
2211 sdensity = sumdens2/sum-mdensity*mdensity;
2212 sdensity = TMath::Sqrt(sdensity);
2214 smeann = sumn2/sum-meann*meann;
2215 smeann = TMath::Sqrt(smeann);
2217 smeanchi = sumchi2/sum - meanchi*meanchi;
2218 smeanchi = TMath::Sqrt(smeanchi);
2222 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2224 for (Int_t i=0; i<nseed; i++) {
2225 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2229 if (pt->fBSigned) continue;
2230 if (pt->fBConstrain) continue;
2231 //if (!(pt->IsActive())) continue;
2233 Int_t found,foundable,shared;
2234 pt->GetClusterStatistic(0,160,found, foundable,shared);
2235 if (shared/float(found)>0.3) {
2236 if (shared/float(found)>0.9 ){
2237 //delete arr->RemoveAt(i);
2242 Bool_t isok =kFALSE;
2243 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2245 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2247 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2249 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2253 for (Int_t i=0; i<160; i++) {
2254 Int_t index=pt->GetClusterIndex2(i);
2255 if (index<0) continue;
2256 AliTPCclusterMI *c= pt->fClusterPointer[i];
2258 //if (!(c->IsUsed(10))) c->Use();
2265 Double_t maxchi = meanchi+2.*smeanchi;
2267 for (Int_t i=0; i<nseed; i++) {
2268 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2272 //if (!(pt->IsActive())) continue;
2273 if (pt->fBSigned) continue;
2274 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2275 if (chi>maxchi) continue;
2278 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2280 //sign only tracks with enoug big density at the beginning
2282 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2285 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2286 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2288 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2289 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2292 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2293 //Int_t noc=pt->GetNumberOfClusters();
2294 pt->fBSigned = kTRUE;
2295 for (Int_t i=0; i<160; i++) {
2297 Int_t index=pt->GetClusterIndex2(i);
2298 if (index<0) continue;
2299 AliTPCclusterMI *c= pt->fClusterPointer[i];
2301 // if (!(c->IsUsed(10))) c->Use();
2306 // gLastCheck = nseed;
2314 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2)
2316 // stop not active tracks
2317 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2318 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2319 Int_t nseed = arr->GetEntriesFast();
2321 for (Int_t i=0; i<nseed; i++) {
2322 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2326 if (!(pt->IsActive())) continue;
2327 StopNotActive(pt,row0,th0, th1,th2);
2333 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2336 // stop not active tracks
2337 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2338 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2341 Int_t foundable = 0;
2342 Int_t maxindex = seed->fLastPoint; //last foundable row
2343 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2344 seed->Desactivate(10) ;
2348 for (Int_t i=row0; i<maxindex; i++){
2349 Int_t index = seed->GetClusterIndex2(i);
2350 if (index!=-1) foundable++;
2352 if (foundable<=30) sumgood1++;
2353 if (foundable<=50) {
2360 if (foundable>=30.){
2361 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2364 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2369 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2372 // back propagation of ESD tracks
2377 PropagateBack(fSeeds);
2378 Int_t nseed = fSeeds->GetEntriesFast();
2379 for (Int_t i=0;i<nseed;i++){
2380 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2381 AliESDtrack *esd=event->GetTrack(i);
2382 seed->CookdEdx(0.02,0.06);
2383 CookLabel(seed,0.1); //For comparison only
2384 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2392 void AliTPCtrackerMI::DeleteSeeds()
2394 Int_t nseed = fSeeds->GetEntriesFast();
2395 for (Int_t i=0;i<nseed;i++){
2396 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2397 if (seed) delete fSeeds->RemoveAt(i);
2403 void AliTPCtrackerMI::ReadSeeds(AliESD *event)
2406 //read seeds from the event
2408 Int_t nentr=event->GetNumberOfTracks();
2409 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2413 fSeeds = new TObjArray;
2417 for (Int_t i=0; i<nentr; i++) {
2418 AliESDtrack *esd=event->GetTrack(i);
2419 ULong_t status=esd->GetStatus();
2420 const AliTPCtrack t(*esd);
2421 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2422 if (status==AliESDtrack::kTPCin) seed->Modify(0.8);
2425 // rotate to the local coordinate system
2427 fSectors=fInnerSec; fN=fkNIS;
2429 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2430 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2431 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2432 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2433 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2434 alpha-=seed->GetAlpha();
2435 if (!seed->Rotate(alpha)) continue;
2437 seed->PropagateTo(fSectors->GetX(0));
2439 // Int_t index = esd->GetTPCindex();
2440 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2442 fSeeds->AddLast(seed);
2448 //_____________________________________________________________________________
2449 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2450 Float_t deltay, Int_t ddsec) {
2451 //-----------------------------------------------------------------
2452 // This function creates track seeds.
2453 // SEEDING WITH VERTEX CONSTRAIN
2454 //-----------------------------------------------------------------
2455 // cuts[0] - fP4 cut
2456 // cuts[1] - tan(phi) cut
2457 // cuts[2] - zvertex cut
2458 // cuts[3] - fP3 cut
2466 Double_t x[5], c[15];
2467 // Int_t di = i1-i2;
2469 AliTPCseed * seed = new AliTPCseed;
2470 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2471 Double_t cs=cos(alpha), sn=sin(alpha);
2473 // Double_t x1 =fOuterSec->GetX(i1);
2474 //Double_t xx2=fOuterSec->GetX(i2);
2476 Double_t x1 =GetXrow(i1);
2477 Double_t xx2=GetXrow(i2);
2479 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2481 Int_t imiddle = (i2+i1)/2; //middle pad row index
2482 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2483 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2487 const AliTPCRow& kr1=GetRow(ns,i1);
2488 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2489 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2492 // change cut on curvature if it can't reach this layer
2493 // maximal curvature set to reach it
2494 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2495 if (dvertexmax*0.5*cuts[0]>0.85){
2496 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2498 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2501 if (deltay>0) ddsec = 0;
2502 // loop over clusters
2503 for (Int_t is=0; is < kr1; is++) {
2505 if (kr1[is]->IsUsed(10)) continue;
2506 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2507 //if (TMath::Abs(y1)>ymax) continue;
2509 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2511 // find possible directions
2512 Float_t anglez = (z1-z3)/(x1-x3);
2513 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2516 //find rotation angles relative to line given by vertex and point 1
2517 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2518 Double_t dvertex = TMath::Sqrt(dvertex2);
2519 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2520 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2523 // loop over 2 sectors
2529 Double_t dddz1=0; // direction of delta inclination in z axis
2536 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2537 Int_t sec2 = sec + dsec;
2539 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2540 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2541 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2542 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2543 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2544 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2546 // rotation angles to p1-p3
2547 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2548 Double_t x2, y2, z2;
2550 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2553 Double_t dxx0 = (xx2-x3)*cs13r;
2554 Double_t dyy0 = (xx2-x3)*sn13r;
2555 for (Int_t js=index1; js < index2; js++) {
2556 const AliTPCclusterMI *kcl = kr2[js];
2557 if (kcl->IsUsed(10)) continue;
2559 //calcutate parameters
2561 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2563 if (TMath::Abs(yy0)<0.000001) continue;
2564 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2565 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2566 Double_t r02 = (0.25+y0*y0)*dvertex2;
2567 //curvature (radius) cut
2568 if (r02<r2min) continue;
2572 Double_t c0 = 1/TMath::Sqrt(r02);
2576 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2577 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2578 Double_t dfi0 = 2.*TPCFastMath::FastAsin(dvertex*c0*0.5);
2579 Double_t dfi1 = 2.*TPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2582 Double_t z0 = kcl->GetZ();
2583 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2584 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2587 Double_t dip = (z1-z0)*c0/dfi1;
2588 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2599 x2= xx2*cs-y2*sn*dsec;
2600 y2=+xx2*sn*dsec+y2*cs;
2610 // do we have cluster at the middle ?
2612 GetProlongation(x1,xm,x,ym,zm);
2614 AliTPCclusterMI * cm=0;
2615 if (TMath::Abs(ym)-ymaxm<0){
2616 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2617 if ((!cm) || (cm->IsUsed(10))) {
2622 // rotate y1 to system 0
2623 // get state vector in rotated system
2624 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2625 Double_t xr2 = x0*cs+yr1*sn*dsec;
2626 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2628 GetProlongation(xx2,xm,xr,ym,zm);
2629 if (TMath::Abs(ym)-ymaxm<0){
2630 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2631 if ((!cm) || (cm->IsUsed(10))) {
2641 dym = ym - cm->GetY();
2642 dzm = zm - cm->GetZ();
2649 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2650 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2651 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2652 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2653 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2655 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2656 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2657 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2658 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2659 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2660 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2662 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2663 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2664 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2665 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2669 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2670 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2671 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2672 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2673 c[13]=f30*sy1*f40+f32*sy2*f42;
2674 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2676 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2678 UInt_t index=kr1.GetIndex(is);
2679 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2681 track->fIsSeeding = kTRUE;
2688 FollowProlongation(*track, (i1+i2)/2,1);
2689 Int_t foundable,found,shared;
2690 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2691 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2693 seed->~AliTPCseed();
2699 FollowProlongation(*track, i2,1);
2703 track->fBConstrain =1;
2704 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2705 track->fLastPoint = i1; // first cluster in track position
2706 track->fFirstPoint = track->fLastPoint;
2708 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2709 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2710 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2712 seed->~AliTPCseed();
2716 // Z VERTEX CONDITION
2718 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2719 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2720 if (TMath::Abs(zv-z3)>cuts[2]) {
2721 FollowProlongation(*track, TMath::Max(i2-20,0));
2722 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2723 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2724 if (TMath::Abs(zv-z3)>cuts[2]){
2725 FollowProlongation(*track, TMath::Max(i2-40,0));
2726 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2727 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2728 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2729 // make seed without constrain
2730 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2731 FollowProlongation(*track2, i2,1);
2732 track2->fBConstrain = kFALSE;
2733 track2->fSeedType = 1;
2734 arr->AddLast(track2);
2736 seed->~AliTPCseed();
2741 seed->~AliTPCseed();
2748 track->fSeedType =0;
2749 arr->AddLast(track);
2750 seed = new AliTPCseed;
2752 // don't consider other combinations
2753 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2759 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2765 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2770 //-----------------------------------------------------------------
2771 // This function creates track seeds.
2772 //-----------------------------------------------------------------
2773 // cuts[0] - fP4 cut
2774 // cuts[1] - tan(phi) cut
2775 // cuts[2] - zvertex cut
2776 // cuts[3] - fP3 cut
2786 Double_t x[5], c[15];
2788 // make temporary seed
2789 AliTPCseed * seed = new AliTPCseed;
2790 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2791 // Double_t cs=cos(alpha), sn=sin(alpha);
2796 Double_t x1 = GetXrow(i1-1);
2797 const AliTPCRow& kr1=GetRow(sec,i1-1);
2798 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2800 Double_t x1p = GetXrow(i1);
2801 const AliTPCRow& kr1p=GetRow(sec,i1);
2803 Double_t x1m = GetXrow(i1-2);
2804 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2807 //last 3 padrow for seeding
2808 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2809 Double_t x3 = GetXrow(i1-7);
2810 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2812 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2813 Double_t x3p = GetXrow(i1-6);
2815 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2816 Double_t x3m = GetXrow(i1-8);
2821 Int_t im = i1-4; //middle pad row index
2822 Double_t xm = GetXrow(im); // radius of middle pad-row
2823 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2824 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2827 Double_t deltax = x1-x3;
2828 Double_t dymax = deltax*cuts[1];
2829 Double_t dzmax = deltax*cuts[3];
2831 // loop over clusters
2832 for (Int_t is=0; is < kr1; is++) {
2834 if (kr1[is]->IsUsed(10)) continue;
2835 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2837 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2839 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2840 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2846 for (Int_t js=index1; js < index2; js++) {
2847 const AliTPCclusterMI *kcl = kr3[js];
2848 if (kcl->IsUsed(10)) continue;
2850 // apply angular cuts
2851 if (TMath::Abs(y1-y3)>dymax) continue;
2854 if (TMath::Abs(z1-z3)>dzmax) continue;
2856 Double_t angley = (y1-y3)/(x1-x3);
2857 Double_t anglez = (z1-z3)/(x1-x3);
2859 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2860 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2862 Double_t yyym = angley*(xm-x1)+y1;
2863 Double_t zzzm = anglez*(xm-x1)+z1;
2865 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2867 if (kcm->IsUsed(10)) continue;
2869 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2870 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2877 // look around first
2878 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2884 if (kc1m->IsUsed(10)) used++;
2886 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2892 if (kc1p->IsUsed(10)) used++;
2894 if (used>1) continue;
2895 if (found<1) continue;
2899 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2905 if (kc3m->IsUsed(10)) used++;
2909 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2915 if (kc3p->IsUsed(10)) used++;
2919 if (used>1) continue;
2920 if (found<3) continue;
2930 x[4]=f1(x1,y1,x2,y2,x3,y3);
2931 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
2934 x[2]=f2(x1,y1,x2,y2,x3,y3);
2937 x[3]=f3n(x1,y1,x2,y2,z1,z2,x[4]);
2938 //if (TMath::Abs(x[3]) > cuts[3]) continue;
2942 Double_t sy1=0.1, sz1=0.1;
2943 Double_t sy2=0.1, sz2=0.1;
2944 Double_t sy3=0.1, sy=0.1, sz=0.1;
2946 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2947 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2948 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2949 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2950 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2951 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2953 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2954 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2955 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2956 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2960 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2961 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2962 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2963 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2964 c[13]=f30*sy1*f40+f32*sy2*f42;
2965 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2967 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2969 UInt_t index=kr1.GetIndex(is);
2970 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
2972 track->fIsSeeding = kTRUE;
2975 FollowProlongation(*track, i1-7,1);
2976 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
2977 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
2979 seed->~AliTPCseed();
2985 FollowProlongation(*track, i2,1);
2986 track->fBConstrain =0;
2987 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2988 track->fFirstPoint = track->fLastPoint;
2990 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2991 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
2992 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
2994 seed->~AliTPCseed();
2999 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3000 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3001 FollowProlongation(*track2, i2,1);
3002 track2->fBConstrain = kFALSE;
3003 track2->fSeedType = 4;
3004 arr->AddLast(track2);
3006 seed->~AliTPCseed();
3010 //arr->AddLast(track);
3011 //seed = new AliTPCseed;
3017 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3023 //_____________________________________________________________________________
3024 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3025 Float_t deltay, Bool_t /*bconstrain*/) {
3026 //-----------------------------------------------------------------
3027 // This function creates track seeds - without vertex constraint
3028 //-----------------------------------------------------------------
3029 // cuts[0] - fP4 cut - not applied
3030 // cuts[1] - tan(phi) cut
3031 // cuts[2] - zvertex cut - not applied
3032 // cuts[3] - fP3 cut
3042 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3043 // Double_t cs=cos(alpha), sn=sin(alpha);
3044 Int_t row0 = (i1+i2)/2;
3045 Int_t drow = (i1-i2)/2;
3046 const AliTPCRow& kr0=fSectors[sec][row0];
3049 AliTPCpolyTrack polytrack;
3050 Int_t nclusters=fSectors[sec][row0];
3051 AliTPCseed * seed = new AliTPCseed;
3056 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3058 Int_t nfoundable =0;
3059 for (Int_t iter =1; iter<2; iter++){ //iterations
3060 const AliTPCRow& krm=fSectors[sec][row0-iter];
3061 const AliTPCRow& krp=fSectors[sec][row0+iter];
3062 const AliTPCclusterMI * cl= kr0[is];
3064 if (cl->IsUsed(10)) {
3070 Double_t x = kr0.GetX();
3071 // Initialization of the polytrack
3076 Double_t y0= cl->GetY();
3077 Double_t z0= cl->GetZ();
3081 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3082 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3084 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3085 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3086 polytrack.AddPoint(x,y0,z0,erry, errz);
3089 if (cl->IsUsed(10)) sumused++;
3092 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3093 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3096 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3097 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3098 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3099 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3100 if (cl1->IsUsed(10)) sumused++;
3101 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3105 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3107 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3108 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3109 if (cl2->IsUsed(10)) sumused++;
3110 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3113 if (sumused>0) continue;
3115 polytrack.UpdateParameters();
3121 nfoundable = polytrack.GetN();
3122 nfound = nfoundable;
3124 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3125 Float_t maxdist = 0.8*(1.+3./(ddrow));
3126 for (Int_t delta = -1;delta<=1;delta+=2){
3127 Int_t row = row0+ddrow*delta;
3128 kr = &(fSectors[sec][row]);
3129 Double_t xn = kr->GetX();
3130 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3131 polytrack.GetFitPoint(xn,yn,zn);
3132 if (TMath::Abs(yn)>ymax) continue;
3134 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3136 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3139 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3140 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3141 if (cln->IsUsed(10)) {
3142 // printf("used\n");
3150 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3155 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3156 polytrack.UpdateParameters();
3159 if ( (sumused>3) || (sumused>0.5*nfound)) {
3160 //printf("sumused %d\n",sumused);
3165 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3166 AliTPCpolyTrack track2;
3168 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3169 if (track2.GetN()<0.5*nfoundable) continue;
3172 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3174 // test seed with and without constrain
3175 for (Int_t constrain=0; constrain<=0;constrain++){
3176 // add polytrack candidate
3178 Double_t x[5], c[15];
3179 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3180 track2.GetBoundaries(x3,x1);
3182 track2.GetFitPoint(x1,y1,z1);
3183 track2.GetFitPoint(x2,y2,z2);
3184 track2.GetFitPoint(x3,y3,z3);
3186 //is track pointing to the vertex ?
3189 polytrack.GetFitPoint(x0,y0,z0);
3202 x[4]=f1(x1,y1,x2,y2,x3,y3);
3204 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3205 x[2]=f2(x1,y1,x2,y2,x3,y3);
3207 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3208 //x[3]=f3(x1,y1,x2,y2,z1,z2);
3209 x[3]=f3n(x1,y1,x3,y3,z1,z3,x[4]);
3210 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3213 Double_t sy =0.1, sz =0.1;
3214 Double_t sy1=0.02, sz1=0.02;
3215 Double_t sy2=0.02, sz2=0.02;
3219 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3222 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3223 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3224 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3225 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3226 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3227 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3229 Double_t f30=(f3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3230 Double_t f31=(f3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3231 Double_t f32=(f3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3232 Double_t f34=(f3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3237 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3238 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3239 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3240 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3241 c[13]=f30*sy1*f40+f32*sy2*f42;
3242 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3244 //Int_t row1 = fSectors->GetRowNumber(x1);
3245 Int_t row1 = GetRowNumber(x1);
3249 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3250 track->fIsSeeding = kTRUE;
3251 Int_t rc=FollowProlongation(*track, i2);
3252 if (constrain) track->fBConstrain =1;
3254 track->fBConstrain =0;
3255 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3256 track->fFirstPoint = track->fLastPoint;
3258 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3259 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3260 track->fNShared>0.4*track->GetNumberOfClusters()) {
3263 seed->~AliTPCseed();
3266 arr->AddLast(track);
3267 seed = new AliTPCseed;
3271 } // if accepted seed
3274 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3280 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3285 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3286 Int_t p1 = int(r1*track->GetNumberOfClusters());
3287 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3289 Double_t x0[3],x1[3],x2[3];
3294 // find track position at given ratio of the length
3295 Int_t sec0, sec1, sec2;
3301 for (Int_t i=0;i<160;i++){
3302 if (track->fClusterPointer[i]){
3304 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3305 if ( (index<p0) || x0[0]<0 ){
3306 if (trpoint->GetX()>1){
3307 clindex = track->GetClusterIndex2(i);
3309 x0[0] = trpoint->GetX();
3310 x0[1] = trpoint->GetY();
3311 x0[2] = trpoint->GetZ();
3312 sec0 = ((clindex&0xff000000)>>24)%18;
3317 if ( (index<p1) &&(trpoint->GetX()>1)){
3318 clindex = track->GetClusterIndex2(i);
3320 x1[0] = trpoint->GetX();
3321 x1[1] = trpoint->GetY();
3322 x1[2] = trpoint->GetZ();
3323 sec1 = ((clindex&0xff000000)>>24)%18;
3326 if ( (index<p2) &&(trpoint->GetX()>1)){
3327 clindex = track->GetClusterIndex2(i);
3329 x2[0] = trpoint->GetX();
3330 x2[1] = trpoint->GetY();
3331 x2[2] = trpoint->GetZ();
3332 sec2 = ((clindex&0xff000000)>>24)%18;
3339 Double_t alpha, cs,sn, xx2,yy2;
3341 alpha = (sec1-sec2)*fSectors->GetAlpha();
3342 cs = TMath::Cos(alpha);
3343 sn = TMath::Sin(alpha);
3344 xx2= x1[0]*cs-x1[1]*sn;
3345 yy2= x1[0]*sn+x1[1]*cs;
3349 alpha = (sec0-sec2)*fSectors->GetAlpha();
3350 cs = TMath::Cos(alpha);
3351 sn = TMath::Sin(alpha);
3352 xx2= x0[0]*cs-x0[1]*sn;
3353 yy2= x0[0]*sn+x0[1]*cs;
3359 Double_t x[5],c[15];
3363 x[4]=f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3364 // if (x[4]>1) return 0;
3365 x[2]=f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3366 x[3]=f3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3367 //if (TMath::Abs(x[3]) > 2.2) return 0;
3368 //if (TMath::Abs(x[2]) > 1.99) return 0;
3370 Double_t sy =0.1, sz =0.1;
3372 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3373 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3374 Double_t sy3=0.01+track->GetSigmaY2();
3376 Double_t f40=(f1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3377 Double_t f42=(f1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3378 Double_t f43=(f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3379 Double_t f20=(f2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3380 Double_t f22=(f2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3381 Double_t f23=(f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3383 Double_t f30=(f3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3384 Double_t f31=(f3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3385 Double_t f32=(f3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3386 Double_t f34=(f3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3391 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3392 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3393 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3394 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3395 c[13]=f30*sy1*f40+f32*sy2*f42;
3396 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3398 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3399 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3400 // Double_t y0,z0,y1,z1, y2,z2;
3401 //seed->GetProlongation(x0[0],y0,z0);
3402 // seed->GetProlongation(x1[0],y1,z1);
3403 //seed->GetProlongation(x2[0],y2,z2);
3405 seed->fLastPoint = pp2;
3406 seed->fFirstPoint = pp2;
3412 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3417 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3419 if (TMath::Abs(seed->GetC())>0.01) return 0;
3422 Float_t x[160], y[160], erry[160], z[160], errz[160];
3424 Float_t xt[160], yt[160], zt[160];
3429 Int_t middle = seed->GetNumberOfClusters()/2;
3432 // find central sector, get local cooordinates
3434 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3435 sec[i]= seed->GetClusterSector(i)%18;
3438 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3439 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3446 if (i>i2) i2 = i; //last point with cluster
3447 if (i2<i1) i1 = i; //first point with cluster
3450 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3452 yt[i] = point->GetY();
3453 zt[i] = point->GetZ();
3455 if (point->GetX()>0){
3456 erry[i] = point->GetErrY();
3457 errz[i] = point->GetErrZ();
3462 secm = sec[i]; //central sector
3463 padm = i; //middle point with cluster
3468 // rotate position to global coordinate system connected to sector at last the point
3470 for (Int_t i=i1;i<=i2;i++){
3472 if (sec[i]<0) continue;
3473 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3474 Double_t cs = TMath::Cos(alpha);
3475 Double_t sn = TMath::Sin(alpha);
3476 Float_t xx2= x[i]*cs+y[i]*sn;
3477 Float_t yy2= -x[i]*sn+y[i]*cs;
3481 xx2= xt[i]*cs+yt[i]*sn;
3482 yy2= -xt[i]*sn+yt[i]*cs;
3487 //get "state" vector
3488 Double_t xh[5],xm = x[padm];
3491 xh[4]=f1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3492 xh[2]=f2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3493 xh[3]=f3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3496 for (Int_t i=i1;i<=i2;i++){
3498 if (sec[i]<0) continue;
3499 GetProlongation(x[i2], x[i],xh,yy,zz);
3500 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3502 //xxh[4]=f1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3503 //xxh[2]=f2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3504 printf("problem\n");
3509 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3510 Float_t yup[160], ydown[160], zup[160], zdown[160];
3512 AliTPCpolyTrack ptrack1,ptrack2;
3515 for (Int_t i=i1;i<=i2;i++){
3516 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3518 if (cl->GetType()<0) continue;
3519 if (cl->GetType()>10) continue;
3522 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3524 if (ptrack1.GetN()>4.){
3525 ptrack1.UpdateParameters();
3527 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3529 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3538 dyup[i]=0.; //not enough points
3543 for (Int_t i=i2;i>=i1;i--){
3544 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3546 if (cl->GetType()<0) continue;
3547 if (cl->GetType()>10) continue;
3549 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3551 if (ptrack2.GetN()>4){
3552 ptrack2.UpdateParameters();
3554 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3556 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3564 dydown[i]=0.; //not enough points
3569 // find maximal difference of the derivation
3570 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3573 for (Int_t i=i1+10;i<i2-10;i++){
3574 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3575 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3577 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3578 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3579 if ( (ddy+ddz)> th){
3580 seed->fKinkPoint[0] = i;
3581 seed->fKinkPoint[1] = ddy;
3582 seed->fKinkPoint[2] = ddz;
3589 //write information to the debug tree
3590 TBranch * br = fTreeDebug->GetBranch("debug");
3591 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3592 arr->ExpandCreateFast(i2-i1);
3593 br->SetAddress(&arr);
3595 AliTPCclusterMI cldummy;
3597 AliTPCTrackPoint2 pdummy;
3598 pdummy.GetTPoint().fIsShared = 10;
3600 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3601 Double_t cs = TMath::Cos(alpha);
3602 Double_t sn = TMath::Sin(alpha);
3604 for (Int_t i=i1;i<i2;i++){
3605 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3607 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3609 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3612 Double_t x = GetXrow(i);
3613 trpoint->GetTPoint() = *point;
3614 trpoint->GetCPoint() = *cl0;
3615 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3616 trpoint->fID = seed->GetUniqueID();
3617 trpoint->fLab = seed->GetLabel();
3619 trpoint->fGX = cs *x + sn*point->GetY();
3620 trpoint->fGY = -sn *x + cs*point->GetY() ;
3621 trpoint->fGZ = point->GetZ();
3623 trpoint->fDY = y[i];
3624 trpoint->fDZ = z[i];
3626 trpoint->fDYU = dyup[i];
3627 trpoint->fDZU = dzup[i];
3629 trpoint->fDYD = dydown[i];
3630 trpoint->fDZD = dzdown[i];
3632 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3633 trpoint->fDDY = dydown[i]-dyup[i];
3634 trpoint->fDDZ = dzdown[i]-dzup[i];
3642 trpoint->GetCPoint()= cldummy;
3659 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3662 // reseed - refit - track
3665 // Int_t last = fSectors->GetNRows()-1;
3667 if (fSectors == fOuterSec){
3668 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3672 first = t->fFirstPoint;
3674 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3675 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3677 FollowProlongation(*t,first);
3687 //_____________________________________________________________________________
3688 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3689 //-----------------------------------------------------------------
3690 // This function reades track seeds.
3691 //-----------------------------------------------------------------
3692 TDirectory *savedir=gDirectory;
3694 TFile *in=(TFile*)inp;
3695 if (!in->IsOpen()) {
3696 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3701 TTree *seedTree=(TTree*)in->Get("Seeds");
3703 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3704 cerr<<"can't get a tree with track seeds !\n";
3707 AliTPCtrack *seed=new AliTPCtrack;
3708 seedTree->SetBranchAddress("tracks",&seed);
3710 if (fSeeds==0) fSeeds=new TObjArray(15000);
3712 Int_t n=(Int_t)seedTree->GetEntries();
3713 for (Int_t i=0; i<n; i++) {
3714 seedTree->GetEvent(i);
3715 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3724 //_____________________________________________________________________________
3725 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3726 //-----------------------------------------------------------------
3727 // This is a track finder.
3728 //-----------------------------------------------------------------
3729 TDirectory *savedir=gDirectory;
3732 if (!fInput) SetIO(); //set default IO using loaders
3734 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
3740 fSeeds = Tracking();
3743 printf("Time for tracking: \t");timer.Print();timer.Start();
3745 //activate again some tracks
3746 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3747 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3749 Int_t nc=t.GetNumberOfClusters();
3751 delete fSeeds->RemoveAt(i);
3754 if (pt->fRemoval==10) {
3755 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3756 pt->Desactivate(10); // make track again active
3758 pt->Desactivate(20);
3759 delete fSeeds->RemoveAt(i);
3763 RemoveDouble(fSeeds,0.2,0.6,11);
3764 //RemoveUsed(fSeeds,0.9,0.9,6);
3765 //RemoveUsed(fSeeds,0.8,0.8,6);
3766 //RemoveUsed(fSeeds,0.7,0.7,6);
3767 RemoveUsed(fSeeds,0.5,0.5,6);
3770 Int_t nseed=fSeeds->GetEntriesFast();
3772 for (Int_t i=0; i<nseed; i++) {
3773 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3775 Int_t nc=t.GetNumberOfClusters();
3777 delete fSeeds->RemoveAt(i);
3780 CookLabel(pt,0.1); //For comparison only
3781 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3782 if ((pt->IsActive() || (pt->fRemoval==10) )){
3783 cerr<<found++<<'\r';
3786 delete fSeeds->RemoveAt(i);
3791 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3793 //RemoveUsed(fSeeds,0.9,0.9,6);
3795 nseed=fSeeds->GetEntriesFast();
3797 for (Int_t i=0; i<nseed; i++) {
3798 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3800 Int_t nc=t.GetNumberOfClusters();
3802 delete fSeeds->RemoveAt(i);
3806 t.CookdEdx(0.02,0.6);
3807 // CheckKinkPoint(&t,0.05);
3808 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3809 if ((pt->IsActive() || (pt->fRemoval==10) )){
3810 cerr<<found++<<'\r';
3813 delete fSeeds->RemoveAt(i);
3817 SortTracks(fSeeds, 1);
3821 PrepareForBackProlongation(fSeeds,0.5);
3822 PropagateBack(fSeeds);
3823 printf("Time for back propagation: \t");timer.Print();timer.Start();
3827 PrepareForProlongation(fSeeds,1.);
3830 fSectors = fOuterSec;
3831 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3832 fSectors = fInnerSec;
3833 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3834 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
3835 // RemoveUsed(fSeeds,0.7,0.7,6);
3836 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
3838 nseed=fSeeds->GetEntriesFast();
3840 for (Int_t i=0; i<nseed; i++) {
3841 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3843 Int_t nc=t.GetNumberOfClusters();
3845 delete fSeeds->RemoveAt(i);
3848 t.CookdEdx(0.02,0.6);
3849 // CookLabel(pt,0.1); //For comparison only
3850 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3851 if ((pt->IsActive() || (pt->fRemoval==10) )){
3852 cerr<<found++<<'\r';
3855 delete fSeeds->RemoveAt(i);
3860 // fNTracks = found;
3861 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
3866 if (!fNewIO) fOutput->Write();
3868 AliRunLoader::GetDetectorLoader("TPC",AliConfig::fgkDefaultEventFolderName)->WriteTracks("OVERWRITE");
3871 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
3873 //if (seedtree) delete seedtree;
3874 // UnloadClusters();
3875 //printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
3880 void AliTPCtrackerMI::Tracking(TObjArray * arr)
3883 // tracking of the seeds
3886 fSectors = fOuterSec;
3887 ParallelTracking(arr,150,63);
3888 fSectors = fOuterSec;
3889 ParallelTracking(arr,63,0);
3892 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
3897 TObjArray * arr = new TObjArray;
3899 fSectors = fOuterSec;
3902 for (Int_t sec=0;sec<fkNOS;sec++){
3903 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
3904 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
3905 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
3908 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
3920 TObjArray * AliTPCtrackerMI::Tracking()
3926 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
3928 TObjArray * seeds = new TObjArray;
3937 Float_t fnumber = 3.0;
3938 Float_t fdensity = 3.0;
3943 for (Int_t delta = 0; delta<18; delta+=6){
3947 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
3948 SumTracks(seeds,arr);
3949 SignClusters(seeds,fnumber,fdensity);
3951 for (Int_t i=2;i<6;i+=2){
3952 // seed high pt tracks
3955 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
3956 SumTracks(seeds,arr);
3957 SignClusters(seeds,fnumber,fdensity);
3962 // RemoveUsed(seeds,0.9,0.9,1);
3963 // UnsignClusters();
3964 // SignClusters(seeds,fnumber,fdensity);
3968 for (Int_t delta = 20; delta<120; delta+=10){
3970 // seed high pt tracks
3974 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
3975 SumTracks(seeds,arr);
3976 SignClusters(seeds,fnumber,fdensity);
3981 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
3982 SumTracks(seeds,arr);
3983 SignClusters(seeds,fnumber,fdensity);
3994 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
3998 // RemoveUsed(seeds,0.75,0.75,1);
4000 //SignClusters(seeds,fnumber,fdensity);
4009 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4010 SumTracks(seeds,arr);
4011 SignClusters(seeds,fnumber,fdensity);
4013 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4014 SumTracks(seeds,arr);
4015 SignClusters(seeds,fnumber,fdensity);
4017 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4018 SumTracks(seeds,arr);
4019 SignClusters(seeds,fnumber,fdensity);
4023 for (Int_t delta = 3; delta<30; delta+=5){
4029 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4030 SumTracks(seeds,arr);
4031 SignClusters(seeds,fnumber,fdensity);
4033 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4034 SumTracks(seeds,arr);
4035 SignClusters(seeds,fnumber,fdensity);
4047 for (Int_t delta = 30; delta<70; delta+=10){
4053 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4054 SumTracks(seeds,arr);
4055 SignClusters(seeds,fnumber,fdensity);
4057 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4058 SumTracks(seeds,arr);
4059 SignClusters(seeds,fnumber,fdensity);
4063 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4074 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2)
4077 //sum tracks to common container
4078 //remove suspicious tracks
4079 Int_t nseed = arr2->GetEntriesFast();
4080 for (Int_t i=0;i<nseed;i++){
4081 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4084 // NORMAL ACTIVE TRACK
4085 if (pt->IsActive()){
4086 arr1->AddLast(arr2->RemoveAt(i));
4089 //remove not usable tracks
4090 if (pt->fRemoval!=10){
4091 delete arr2->RemoveAt(i);
4094 // REMOVE VERY SHORT TRACKS
4095 if (pt->GetNumberOfClusters()<20){
4096 delete arr2->RemoveAt(i);
4099 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4100 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4101 arr1->AddLast(arr2->RemoveAt(i));
4103 delete arr2->RemoveAt(i);
4112 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4115 // try to track in parralel
4117 Int_t nseed=arr->GetEntriesFast();
4118 //prepare seeds for tracking
4119 for (Int_t i=0; i<nseed; i++) {
4120 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4122 if (!t.IsActive()) continue;
4123 // follow prolongation to the first layer
4124 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4125 FollowProlongation(t, rfirst+1);
4130 for (Int_t nr=rfirst; nr>=rlast; nr--){
4131 // make indexes with the cluster tracks for given
4133 // find nearest cluster
4134 for (Int_t i=0; i<nseed; i++) {
4135 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4137 if (!pt->IsActive()) continue;
4138 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4139 if (pt->fRelativeSector>17) {
4142 UpdateClusters(t,nr);
4144 // prolonagate to the nearest cluster - if founded
4145 for (Int_t i=0; i<nseed; i++) {
4146 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4148 if (!pt->IsActive()) continue;
4149 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4150 if (pt->fRelativeSector>17) {
4153 FollowToNextCluster(*pt,nr);
4158 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac)
4162 // if we use TPC track itself we have to "update" covariance
4164 Int_t nseed= arr->GetEntriesFast();
4165 for (Int_t i=0;i<nseed;i++){
4166 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4170 //rotate to current local system at first accepted point
4171 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4172 Int_t sec = (index&0xff000000)>>24;
4174 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4175 if (angle1>TMath::Pi())
4176 angle1-=2.*TMath::Pi();
4177 Float_t angle2 = pt->GetAlpha();
4179 if (TMath::Abs(angle1-angle2)>0.001){
4180 pt->Rotate(angle1-angle2);
4181 //angle2 = pt->GetAlpha();
4182 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4183 //if (pt->GetAlpha()<0)
4184 // pt->fRelativeSector+=18;
4185 //sec = pt->fRelativeSector;
4194 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac)
4198 // if we use TPC track itself we have to "update" covariance
4200 Int_t nseed= arr->GetEntriesFast();
4201 for (Int_t i=0;i<nseed;i++){
4202 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4205 pt->fFirstPoint = pt->fLastPoint;
4213 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4216 // make back propagation
4218 Int_t nseed= arr->GetEntriesFast();
4219 for (Int_t i=0;i<nseed;i++){
4220 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4222 AliTPCseed *pt2 = new AliTPCseed(*pt);
4223 fSectors = fInnerSec;
4224 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4225 fSectors = fOuterSec;
4226 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4227 fSectors = fOuterSec;
4228 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4229 printf("\n%d",pt->GetLabel());
4230 fSectors = fInnerSec;
4231 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4232 fSectors = fOuterSec;
4233 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4234 fSectors = fOuterSec;
4242 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4245 // make forward propagation
4247 Int_t nseed= arr->GetEntriesFast();
4248 for (Int_t i=0;i<nseed;i++){
4249 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4251 AliTPCseed *pt2 = new AliTPCseed(*pt);
4252 fSectors = fOuterSec;
4253 FollowProlongation(*pt,0);
4254 fSectors = fOuterSec;
4255 FollowProlongation(*pt,0);
4256 fSectors = fInnerSec;
4257 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4258 printf("\n%d",pt->GetLabel());
4259 fSectors = fOuterSec;
4260 FollowProlongation(*pt2,0);
4261 fSectors = fOuterSec;
4262 FollowProlongation(*pt2,0);
4263 fSectors = fOuterSec;
4271 Int_t AliTPCtrackerMI::PropagateForward()
4273 fSectors = fOuterSec;
4274 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4275 fSectors = fInnerSec;
4276 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4286 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4289 // make back propagation, in between row0 and row1
4293 fSectors = fInnerSec;
4296 if (row1<fSectors->GetNRows())
4299 r1 = fSectors->GetNRows()-1;
4301 if (row0<fSectors->GetNRows()&& r1>0 )
4302 FollowBackProlongation(*pt,r1);
4303 if (row1<=fSectors->GetNRows())
4306 r1 = row1 - fSectors->GetNRows();
4307 if (r1<=0) return 0;
4308 if (r1>=fOuterSec->GetNRows()) return 0;
4309 fSectors = fOuterSec;
4310 return FollowBackProlongation(*pt,r1);
4318 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4322 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4323 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4324 Float_t padlength = GetPadPitchLength(row);
4326 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4327 Float_t angulary = seed->GetSnp();
4328 angulary = angulary*angulary/(1-angulary*angulary);
4329 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4331 Float_t sresz = fParam->GetZSigma();
4332 Float_t angularz = seed->GetTgl();
4333 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4335 Float_t wy = GetSigmaY(seed);
4336 Float_t wz = GetSigmaZ(seed);
4339 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4340 printf("problem\n");
4346 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4350 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4351 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4352 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4353 Float_t angular = seed->GetSnp();
4354 angular = angular*angular/(1-angular*angular);
4355 // angular*=angular;
4356 //angular = TMath::Sqrt(angular/(1-angular));
4357 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4360 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4364 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4365 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4366 Float_t sres = fParam->GetZSigma();
4367 Float_t angular = seed->GetTgl();
4368 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4375 //__________________________________________________________________________
4376 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4377 //--------------------------------------------------------------------
4378 //This function "cooks" a track label. If label<0, this track is fake.
4379 //--------------------------------------------------------------------
4380 Int_t noc=t->GetNumberOfClusters();
4382 printf("\nnot founded prolongation\n\n\n");
4388 AliTPCclusterMI *clusters[160];
4390 for (Int_t i=0;i<160;i++) {
4397 for (i=0; i<160 && current<noc; i++) {
4399 Int_t index=t->GetClusterIndex2(i);
4400 if (index<=0) continue;
4401 if (index&0x8000) continue;
4403 //clusters[current]=GetClusterMI(index);
4404 if (t->fClusterPointer[i]){
4405 clusters[current]=t->fClusterPointer[i];
4411 Int_t lab=123456789;
4412 for (i=0; i<noc; i++) {
4413 AliTPCclusterMI *c=clusters[i];
4415 lab=TMath::Abs(c->GetLabel(0));
4417 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4423 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4425 for (i=0; i<noc; i++) {
4426 AliTPCclusterMI *c=clusters[i];
4428 if (TMath::Abs(c->GetLabel(1)) == lab ||
4429 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4432 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4435 Int_t tail=Int_t(0.10*noc);
4438 for (i=1; i<=160&&ind<tail; i++) {
4439 // AliTPCclusterMI *c=clusters[noc-i];
4440 AliTPCclusterMI *c=clusters[i];
4442 if (lab == TMath::Abs(c->GetLabel(0)) ||
4443 lab == TMath::Abs(c->GetLabel(1)) ||
4444 lab == TMath::Abs(c->GetLabel(2))) max++;
4447 if (max < Int_t(0.5*tail)) lab=-lab;
4454 //delete[] clusters;
4457 //_________________________________________________________________________
4458 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4459 //-----------------------------------------------------------------------
4460 // Setup inner sector
4461 //-----------------------------------------------------------------------
4463 fAlpha=par->GetInnerAngle();
4464 fAlphaShift=par->GetInnerAngleShift();
4465 fPadPitchWidth=par->GetInnerPadPitchWidth();
4466 fPadPitchLength=par->GetInnerPadPitchLength();
4467 fN=par->GetNRowLow();
4468 fRow=new AliTPCRow[fN];
4469 for (Int_t i=0; i<fN; i++) {
4470 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4471 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4474 fAlpha=par->GetOuterAngle();
4475 fAlphaShift=par->GetOuterAngleShift();
4476 fPadPitchWidth = par->GetOuterPadPitchWidth();
4477 fPadPitchLength = par->GetOuter1PadPitchLength();
4478 f1PadPitchLength = par->GetOuter1PadPitchLength();
4479 f2PadPitchLength = par->GetOuter2PadPitchLength();
4481 fN=par->GetNRowUp();
4482 fRow=new AliTPCRow[fN];
4483 for (Int_t i=0; i<fN; i++) {
4484 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4485 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4491 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4497 //_________________________________________________________________________
4499 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4500 //-----------------------------------------------------------------------
4501 // Insert a cluster into this pad row in accordence with its y-coordinate
4502 //-----------------------------------------------------------------------
4503 if (fN==kMaxClusterPerRow) {
4504 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4506 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4507 Int_t i=Find(c->GetZ());
4508 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4509 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4510 fIndex[i]=index; fClusters[i]=c; fN++;
4514 //___________________________________________________________________
4515 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4516 //-----------------------------------------------------------------------
4517 // Return the index of the nearest cluster
4518 //-----------------------------------------------------------------------
4519 if (fN==0) return 0;
4520 if (z <= fClusters[0]->GetZ()) return 0;
4521 if (z > fClusters[fN-1]->GetZ()) return fN;
4522 Int_t b=0, e=fN-1, m=(b+e)/2;
4523 for (; b<e; m=(b+e)/2) {
4524 if (z > fClusters[m]->GetZ()) b=m+1;
4532 //___________________________________________________________________
4533 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4534 //-----------------------------------------------------------------------
4535 // Return the index of the nearest cluster in z y
4536 //-----------------------------------------------------------------------
4537 Float_t maxdistance = roady*roady + roadz*roadz;
4539 AliTPCclusterMI *cl =0;
4540 for (Int_t i=Find(z-roadz); i<fN; i++) {
4541 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4542 if (c->GetZ() > z+roadz) break;
4543 if ( (c->GetY()-y) > roady ) continue;
4544 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4545 if (maxdistance>distance) {
4546 maxdistance = distance;
4553 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4555 //-----------------------------------------------------------------------
4556 // Return the index of the nearest cluster in z y
4557 //-----------------------------------------------------------------------
4558 Float_t maxdistance = roady*roady + roadz*roadz;
4559 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4560 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4562 AliTPCclusterMI *cl =0;
4563 //FindNearest3(y,z,roady,roadz,index);
4564 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4565 for (Int_t i=iz1; i<iz2; i++) {
4566 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4567 if (c->GetZ() > z+roadz) break;
4568 if ( c->GetY()-y > roady ) continue;
4569 if ( y-c->GetY() > roady ) continue;
4570 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4571 if (maxdistance>distance) {
4572 maxdistance = distance;
4575 //roady = TMath::Sqrt(maxdistance);
4583 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4585 //-----------------------------------------------------------------------
4586 // Return the index of the nearest cluster in z y
4587 //-----------------------------------------------------------------------
4588 Float_t maxdistance = roady*roady + roadz*roadz;
4589 // Int_t iz = Int_t(z+255.);
4590 AliTPCclusterMI *cl =0;
4591 for (Int_t i=Find(z-roadz); i<fN; i++) {
4592 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4593 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4594 if (c->GetZ() > z+roadz) break;
4595 if ( c->GetY()-y > roady ) continue;
4596 if ( y-c->GetY() > roady ) continue;
4597 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4598 if (maxdistance>distance) {
4599 maxdistance = distance;
4602 //roady = TMath::Sqrt(maxdistance);
4611 AliTPCseed::AliTPCseed():AliTPCtrack(){
4615 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4616 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4632 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4639 for (Int_t i=0;i<160;i++) {
4640 fClusterPointer[i] = 0;
4641 Int_t index = t.GetClusterIndex(i);
4643 SetClusterIndex2(i,index);
4646 SetClusterIndex2(i,-3);
4656 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4658 for (Int_t i=0;i<160;i++) {
4659 fClusterPointer[i] = 0;
4660 Int_t index = t.GetClusterIndex(i);
4661 SetClusterIndex2(i,index);
4678 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4679 Double_t xr, Double_t alpha):
4680 AliTPCtrack(index, xx, cc, xr, alpha) {
4684 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4685 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4694 // fHelixIn = new TClonesArray("AliHelix",0);
4695 //fHelixOut = new TClonesArray("AliHelix",0);
4702 AliTPCseed::~AliTPCseed(){
4703 if (fPoints) delete fPoints;
4705 if (fEPoints) delete fEPoints;
4710 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4714 return &fTrackPoints[i];
4717 void AliTPCseed::RebuildSeed()
4720 // rebuild seed to be ready for storing
4721 AliTPCclusterMI cldummy;
4723 AliTPCTrackPoint pdummy;
4724 pdummy.GetTPoint().fIsShared = 10;
4725 for (Int_t i=0;i<160;i++){
4726 AliTPCclusterMI * cl0 = fClusterPointer[i];
4727 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
4729 trpoint->GetTPoint() = *(GetTrackPoint(i));
4730 trpoint->GetCPoint() = *cl0;
4731 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4735 trpoint->GetCPoint()= cldummy;
4743 Double_t AliTPCseed::GetDensityFirst(Int_t n)
4747 // return cluster for n rows bellow first point
4748 Int_t nfoundable = 1;
4750 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
4751 Int_t index = GetClusterIndex2(i);
4752 if (index!=-1) nfoundable++;
4753 if (index>0) nfound++;
4755 if (nfoundable<n) return 0;
4756 return Double_t(nfound)/Double_t(nfoundable);
4761 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
4763 // get cluster stat. on given region
4768 for (Int_t i=first;i<last; i++){
4769 Int_t index = GetClusterIndex2(i);
4770 if (index!=-1) foundable++;
4771 if (fClusterPointer[i]) {
4777 if (fClusterPointer[i]->IsUsed(10)) {
4781 if (!plus2) continue; //take also neighborhoud
4783 if ( (i>0) && fClusterPointer[i-1]){
4784 if (fClusterPointer[i-1]->IsUsed(10)) {
4789 if ( fClusterPointer[i+1]){
4790 if (fClusterPointer[i+1]->IsUsed(10)) {
4798 printf("problem\n");
4802 //_____________________________________________________________________________
4803 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
4804 //-----------------------------------------------------------------
4805 // This funtion calculates dE/dX within the "low" and "up" cuts.
4806 //-----------------------------------------------------------------
4809 Float_t angular[200];
4810 Float_t weight[200];
4813 // TClonesArray & arr = *fPoints;
4814 Float_t meanlog = 100.;
4816 Float_t mean[4] = {0,0,0,0};
4817 Float_t sigma[4] = {1000,1000,1000,1000};
4818 Int_t nc[4] = {0,0,0,0};
4819 Float_t norm[4] = {1000,1000,1000,1000};
4824 for (Int_t of =0; of<4; of++){
4825 for (Int_t i=of+i1;i<i2;i+=4)
4827 Int_t index = fIndex[i];
4828 if (index<0||index&0x8000) continue;
4830 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
4831 AliTPCTrackerPoint * point = GetTrackPoint(i);
4832 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
4833 //AliTPCTrackerPoint * pointp = 0;
4834 //if (i<159) pointp = GetTrackPoint(i+1);
4836 if (point==0) continue;
4837 AliTPCclusterMI * cl = fClusterPointer[i];
4838 if (cl==0) continue;
4839 if (onlyused && (!cl->IsUsed(10))) continue;
4840 if (cl->IsUsed(11)) {
4844 Int_t type = cl->GetType();
4845 //if (point->fIsShared){
4850 // if (pointm->fIsShared) continue;
4852 // if (pointp->fIsShared) continue;
4854 if (type<0) continue;
4855 //if (type>10) continue;
4856 //if (point->GetErrY()==0) continue;
4857 //if (point->GetErrZ()==0) continue;
4859 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
4860 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
4861 //if ((ddy*ddy+ddz*ddz)>10) continue;
4864 // if (point->GetCPoint().GetMax()<5) continue;
4865 if (cl->GetMax()<5) continue;
4866 Float_t angley = point->GetAngleY();
4867 Float_t anglez = point->GetAngleZ();
4869 Float_t rsigmay2 = point->GetSigmaY();
4870 Float_t rsigmaz2 = point->GetSigmaZ();
4874 rsigmay += pointm->GetTPoint().GetSigmaY();
4875 rsigmaz += pointm->GetTPoint().GetSigmaZ();
4879 rsigmay += pointp->GetTPoint().GetSigmaY();
4880 rsigmaz += pointp->GetTPoint().GetSigmaZ();
4887 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
4889 Float_t ampc = 0; // normalization to the number of electrons
4891 // ampc = 1.*point->GetCPoint().GetMax();
4892 ampc = 1.*cl->GetMax();
4893 //ampc = 1.*point->GetCPoint().GetQ();
4894 // AliTPCClusterPoint & p = point->GetCPoint();
4895 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
4896 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4898 // TMath::Abs( Int_t(iz) - iz + 0.5);
4899 //ampc *= 1.15*(1-0.3*dy);
4900 //ampc *= 1.15*(1-0.3*dz);
4901 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
4905 //ampc = 1.0*point->GetCPoint().GetMax();
4906 ampc = 1.0*cl->GetMax();
4907 //ampc = 1.0*point->GetCPoint().GetQ();
4908 //AliTPCClusterPoint & p = point->GetCPoint();
4909 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
4910 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4912 // TMath::Abs( Int_t(iz) - iz + 0.5);
4914 //ampc *= 1.15*(1-0.3*dy);
4915 //ampc *= 1.15*(1-0.3*dz);
4916 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
4920 ampc *= 2.0; // put mean value to channel 50
4921 //ampc *= 0.58; // put mean value to channel 50
4923 // if (type>0) w = 1./(type/2.-0.5);
4924 // Float_t z = TMath::Abs(cl->GetZ());
4927 //ampc /= (1+0.0008*z);
4931 //ampc /= (1+0.0008*z);
4933 //ampc /= (1+0.0008*z);
4936 if (type<0) { //amp at the border - lower weight
4941 if (rsigma>1.5) ampc/=1.3; // if big backround
4943 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
4948 TMath::Sort(nc[of],amp,index,kFALSE);
4952 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
4954 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
4955 Float_t ampl = amp[index[i]]/angular[index[i]];
4956 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
4958 sumw += weight[index[i]];
4959 sumamp += weight[index[i]]*ampl;
4960 sumamp2 += weight[index[i]]*ampl*ampl;
4961 norm[of] += angular[index[i]]*weight[index[i]];
4968 mean[of] = sumamp/sumw;
4969 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
4971 sigma[of] = TMath::Sqrt(sigma[of]);
4975 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
4976 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
4977 //mean *=(1-0.1*(norm-1.));
4984 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
4985 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
4988 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
4989 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
4993 for (Int_t i =0;i<4;i++){
4994 if (nc[i]>2&&nc[i]<1000){
4995 dedx += mean[i] *nc[i];
4996 fSdEdx += sigma[i]*(nc[i]-2);
4997 fMAngular += norm[i] *nc[i];
5002 fSDEDX[i] = sigma[i];
5015 // Float_t dedx1 =dedx;
5018 for (Int_t i =0;i<4;i++){
5019 if (nc[i]>2&&nc[i]<1000){
5020 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5021 dedx += mean[i] *nc[i];
5036 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5039 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5040 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5041 SetMass(0.93827); return;
5045 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5046 SetMass(0.93827); return;
5049 SetMass(0.13957); return;
5059 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5060 //-----------------------------------------------------------------
5061 // This funtion calculates dE/dX within the "low" and "up" cuts.
5062 //-----------------------------------------------------------------
5065 Float_t angular[200];
5066 Float_t weight[200];
5068 Bool_t inlimit[200];
5069 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5070 for (Int_t i=0;i<200;i++) amp[i]=10000;
5071 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5075 Float_t meanlog = 100.;
5076 Int_t indexde[4]={0,64,128,160};
5083 Float_t mean[4] = {0,0,0,0};
5084 Float_t sigma[4] = {1000,1000,1000,1000};
5085 Int_t nc[4] = {0,0,0,0};
5086 Float_t norm[4] = {1000,1000,1000,1000};
5091 // for (Int_t of =0; of<3; of++){
5092 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5093 for (Int_t i =0; i<160;i++)
5095 AliTPCTrackPoint * point = GetTrackPoint(i);
5096 if (point==0) continue;
5097 if (point->fIsShared){
5101 Int_t type = point->GetCPoint().GetType();
5102 if (type<0) continue;
5103 if (point->GetCPoint().GetMax()<5) continue;
5104 Float_t angley = point->GetTPoint().GetAngleY();
5105 Float_t anglez = point->GetTPoint().GetAngleZ();
5106 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5107 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5108 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5110 Float_t ampc = 0; // normalization to the number of electrons
5112 ampc = point->GetCPoint().GetMax();
5115 ampc = point->GetCPoint().GetMax();
5117 ampc *= 2.0; // put mean value to channel 50
5118 // ampc *= 0.565; // put mean value to channel 50
5121 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5128 if (type<0) { //amp at the border - lower weight
5131 if (rsigma>1.5) ampc/=1.3; // if big backround
5132 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5133 amp[i] = ampc/angular[i];
5138 TMath::Sort(159,amp,index,kFALSE);
5139 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5140 inlimit[index[i]] = kTRUE; // take all clusters
5143 // meanlog = amp[index[Int_t(anc*0.3)]];
5145 for (Int_t of =0; of<3; of++){
5149 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5151 if (inlimit[i]==kFALSE) continue;
5152 Float_t ampl = amp[i];
5154 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5157 sumamp += weight[i]*ampl;
5158 sumamp2 += weight[i]*ampl*ampl;
5159 norm[of] += angular[i]*weight[i];
5167 mean[of] = sumamp/sumw;
5168 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5170 sigma[of] = TMath::Sqrt(sigma[of]);
5173 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5183 Float_t www[3] = {12.,14.,17.};
5184 //Float_t www[3] = {1.,1.,1.};
5186 for (Int_t i =0;i<3;i++){
5187 if (nc[i]>2&&nc[i]<1000){
5188 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5189 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5190 fMAngular += norm[i] *nc[i];
5191 norm2 += nc[i]*www[i]/sigma[i];
5192 norm3 += (nc[i]-2)*www[i]/sigma[i];
5195 fSDEDX[i] = sigma[i];
5208 // Float_t dedx1 =dedx;
5212 for (Int_t i =0;i<3;i++){
5213 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5214 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5215 dedx += mean[i] *(nc[i])/(sigma[i]);
5216 norm4 += (nc[i])/(sigma[i]);
5220 if (norm4>0) dedx /= norm4;