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.17 2003/10/17 12:28:02 kowal2
19 Removed "always true" comparison
21 Revision 1.16 2003/10/17 12:01:16 kowal2
22 Removed compiler warning.
24 Revision 1.15 2003/09/29 11:56:58 kowal2
27 Revision 1.14 2003/09/29 11:39:43 kowal2
30 Revision 1.13 2003/09/29 11:28:19 kowal2
33 Revision 1.9.4.3 2003/06/23 14:47:10 hristov
36 Revision 1.9.4.2 2003/06/23 10:06:13 hristov
37 Updated information about the overlapping clusters (M.Ivanov)
39 Revision 1.9.4.1 2003/06/19 06:59:58 hristov
40 Updated version of parallel tracking (M.Ivanov)
42 Revision 1.9 2003/03/19 17:14:11 hristov
43 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)
45 Revision 1.8 2003/03/05 11:16:15 kowal2
57 AliTPC parallel tracker -
59 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
60 run AliTPCFindTracksMI.C macro - to find tracks
61 tracks are written to AliTPCtracks.root file
62 for comparison also seeds are written to the same file - to special branch
65 //-------------------------------------------------------
66 // Implementation of the TPC tracker
68 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
70 //-------------------------------------------------------
71 #include <TObjArray.h>
74 #include "Riostream.h"
76 #include "AliTPCtrackerMI.h"
77 #include "AliTPCclusterMI.h"
78 #include "AliTPCParam.h"
79 #include "AliTPCClustersRow.h"
80 #include "AliComplexCluster.h"
81 #include "AliTPCpolyTrack.h"
82 #include "TStopwatch.h"
87 #include "AliRunLoader.h"
92 ClassImp(AliTPCtrackerMI)
98 static Double_t FastAsin(Double_t x);
100 static Double_t fgFastAsin[20000];
103 Double_t TPCFastMath::fgFastAsin[20000];
105 TPCFastMath::TPCFastMath(){
106 for (Int_t i=0;i<10000;i++){
107 fgFastAsin[2*i] = TMath::ASin(i/10000.);
108 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
112 Double_t TPCFastMath::FastAsin(Double_t x){
114 Int_t index = int(x*10000);
115 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
118 Int_t index = int(x*10000);
119 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
122 TPCFastMath gTPCMath;
126 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
128 AliTPCclusterMI* c =track->fCurrentCluster;
129 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
131 UInt_t i = track->fCurrentClusterIndex1;
133 Int_t sec=(i&0xff000000)>>24;
134 //Int_t row = (i&0x00ff0000)>>16;
135 track->fRow=(i&0x00ff0000)>>16;
136 track->fSector = sec;
137 // Int_t index = i&0xFFFF;
138 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
139 track->SetClusterIndex2(track->fRow, i);
141 //track->fFirstPoint = row;
142 //if ( track->fLastPoint<row) track->fLastPoint =row;
143 // if (track->fRow<0 || track->fRow>160) {
144 // printf("problem\n");
146 if (track->fFirstPoint>track->fRow)
147 track->fFirstPoint = track->fRow;
148 if (track->fLastPoint<track->fRow)
149 track->fLastPoint = track->fRow;
152 track->fClusterPointer[track->fRow] = c;
155 Float_t angle2 = track->GetSnp()*track->GetSnp();
156 angle2 = TMath::Sqrt(angle2/(1-angle2));
158 //SET NEW Track Point
162 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
164 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
165 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
166 point.SetErrY(sqrt(track->fErrorY2));
167 point.SetErrZ(sqrt(track->fErrorZ2));
169 point.SetX(track->GetX());
170 point.SetY(track->GetY());
171 point.SetZ(track->GetZ());
172 point.SetAngleY(angle2);
173 point.SetAngleZ(track->GetTgl());
174 if (point.fIsShared){
175 track->fErrorY2 *= 4;
176 track->fErrorZ2 *= 4;
180 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
182 track->fErrorY2 *= 1.3;
183 track->fErrorY2 += 0.01;
184 track->fErrorZ2 *= 1.3;
185 track->fErrorZ2 += 0.005;
187 if (accept>0) return 0;
188 if (track->GetNumberOfClusters()%20==0){
189 // if (track->fHelixIn){
190 // TClonesArray & larr = *(track->fHelixIn);
191 // Int_t ihelix = larr.GetEntriesFast();
192 // new(larr[ihelix]) AliHelix(*track) ;
195 track->fNoCluster =0;
196 return track->Update(c,chi2,i);
201 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
202 Float_t cory, Float_t corz)
205 // decide according desired precision to accept given
206 // cluster for tracking
207 Double_t sy2=ErrY2(seed,cluster)*cory;
208 Double_t sz2=ErrZ2(seed,cluster)*corz;
209 //sy2=ErrY2(seed,cluster)*cory;
210 //sz2=ErrZ2(seed,cluster)*cory;
212 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
213 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
215 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
216 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
217 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
218 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
220 Double_t rdistance2 = rdistancey2+rdistancez2;
223 if (rdistance2>16) return 3;
226 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
227 return 2; //suspisiouce - will be changed
229 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
230 // strict cut on overlaped cluster
231 return 2; //suspisiouce - will be changed
233 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
234 && cluster->GetType()<0){
244 //_____________________________________________________________________________
245 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
246 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
248 //---------------------------------------------------------------------
249 // The main TPC tracker constructor
250 //---------------------------------------------------------------------
251 fInnerSec=new AliTPCSector[fkNIS];
252 fOuterSec=new AliTPCSector[fkNOS];
255 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
256 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
263 Int_t nrowlow = par->GetNRowLow();
264 Int_t nrowup = par->GetNRowUp();
267 for (Int_t i=0;i<nrowlow;i++){
268 fXRow[i] = par->GetPadRowRadiiLow(i);
269 fPadLength[i]= par->GetPadPitchLength(0,i);
270 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
274 for (Int_t i=0;i<nrowup;i++){
275 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
276 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
277 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
290 //_____________________________________________________________________________
291 AliTPCtrackerMI::~AliTPCtrackerMI() {
292 //------------------------------------------------------------------
293 // TPC tracker destructor
294 //------------------------------------------------------------------
303 void AliTPCtrackerMI::SetIO()
307 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
308 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
309 AliTPCtrack *iotrack= new AliTPCtrack;
310 // iotrack->fHelixIn = new TClonesArray("AliHelix");
311 //iotrack->fHelixOut = new TClonesArray("AliHelix");
312 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
316 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
332 AliTPCtrack *iotrack= new AliTPCtrack;
333 // iotrack->fHelixIn = new TClonesArray("AliHelix");
334 //iotrack->fHelixOut = new TClonesArray("AliHelix");
335 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
338 if (output && (fDebug&2)){
339 //write the full seed information if specified in debug mode
341 fSeedTree = new TTree("Seeds","Seeds");
342 AliTPCseed * vseed = new AliTPCseed;
344 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
345 arrtr->ExpandCreateFast(160);
346 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
348 vseed->fPoints = arrtr;
349 vseed->fEPoints = arre;
350 // vseed->fClusterPoints = arrcl;
351 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
354 fTreeDebug = new TTree("trackDebug","trackDebug");
355 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
356 fTreeDebug->Branch("debug",&arrd,32000,99);
364 void AliTPCtrackerMI::WriteTracks()
367 // write tracks to the given output tree -
368 // output specified with SetIO routine
371 // write tracks to the event
372 // store index of the track
373 Int_t nseed=fSeeds->GetEntriesFast();
374 for (Int_t i=0; i<nseed; i++) {
375 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
378 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
379 //iotrack.SetTPCindex(i);
380 fEvent->AddTrack(&iotrack);
386 AliTPCtrack *iotrack= 0;
387 Int_t nseed=fSeeds->GetEntriesFast();
388 for (Int_t i=0; i<nseed; i++) {
389 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
393 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
394 TBranch * br = fOutput->GetBranch("tracks");
395 br->SetAddress(&iotrack);
397 for (Int_t i=0; i<nseed; i++) {
398 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
402 // br->SetAddress(&iotrack);
410 //write the full seed information if specified in debug mode
412 AliTPCseed * vseed = new AliTPCseed;
414 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
415 arrtr->ExpandCreateFast(160);
416 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
417 //arrcl->ExpandCreateFast(160);
418 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
420 vseed->fPoints = arrtr;
421 vseed->fEPoints = arre;
422 // vseed->fClusterPoints = arrcl;
423 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
424 TBranch * brseed = fSeedTree->GetBranch("seeds");
426 Int_t nseed=fSeeds->GetEntriesFast();
428 for (Int_t i=0; i<nseed; i++) {
429 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
432 // pt->fClusterPoints = arrcl;
436 brseed->SetAddress(&vseed);
440 // pt->fClusterPoints = 0;
443 if (fTreeDebug) fTreeDebug->Write();
451 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
454 //seed->SetErrorY2(0.1);
456 //calculate look-up table at the beginning
457 static Bool_t ginit = kFALSE;
458 static Float_t gnoise1,gnoise2,gnoise3;
459 static Float_t ggg1[10000];
460 static Float_t ggg2[10000];
461 static Float_t ggg3[10000];
462 static Float_t glandau1[10000];
463 static Float_t glandau2[10000];
464 static Float_t glandau3[10000];
466 static Float_t gcor01[500];
467 static Float_t gcor02[500];
468 static Float_t gcorp[500];
473 for (Int_t i=1;i<500;i++){
474 Float_t rsigma = float(i)/100.;
475 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
476 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
477 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
481 for (Int_t i=3;i<10000;i++){
485 Float_t amp = float(i);
486 Float_t padlength =0.75;
487 gnoise1 = 0.0004/padlength;
488 Float_t nel = 0.268*amp;
489 Float_t nprim = 0.155*amp;
490 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
491 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
492 if (glandau1[i]>1) glandau1[i]=1;
493 glandau1[i]*=padlength*padlength/12.;
497 gnoise2 = 0.0004/padlength;
500 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
501 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
502 if (glandau2[i]>1) glandau2[i]=1;
503 glandau2[i]*=padlength*padlength/12.;
508 gnoise3 = 0.0004/padlength;
511 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
512 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
513 if (glandau3[i]>1) glandau3[i]=1;
514 glandau3[i]*=padlength*padlength/12.;
522 Int_t amp = int(TMath::Abs(cl->GetQ()));
524 seed->SetErrorY2(1.);
528 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
529 Int_t ctype = cl->GetType();
530 Float_t padlength= GetPadPitchLength(seed->fRow);
531 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
532 angle2 = angle2/(1-angle2);
535 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
538 if (fSectors==fInnerSec){
540 res = ggg1[amp]*z+glandau1[amp]*angle2;
541 if (ctype==0) res *= gcor01[rsigmay];
544 res*= gcorp[rsigmay];
550 res = ggg2[amp]*z+glandau2[amp]*angle2;
551 if (ctype==0) res *= gcor02[rsigmay];
554 res*= gcorp[rsigmay];
559 res = ggg3[amp]*z+glandau3[amp]*angle2;
560 if (ctype==0) res *= gcor02[rsigmay];
563 res*= gcorp[rsigmay];
570 res*=2.4; // overestimate error 2 times
577 seed->SetErrorY2(res);
585 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
588 //seed->SetErrorY2(0.1);
590 //calculate look-up table at the beginning
591 static Bool_t ginit = kFALSE;
592 static Float_t gnoise1,gnoise2,gnoise3;
593 static Float_t ggg1[10000];
594 static Float_t ggg2[10000];
595 static Float_t ggg3[10000];
596 static Float_t glandau1[10000];
597 static Float_t glandau2[10000];
598 static Float_t glandau3[10000];
600 static Float_t gcor01[1000];
601 static Float_t gcor02[1000];
602 static Float_t gcorp[1000];
607 for (Int_t i=1;i<1000;i++){
608 Float_t rsigma = float(i)/100.;
609 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
610 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
611 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
615 for (Int_t i=3;i<10000;i++){
619 Float_t amp = float(i);
620 Float_t padlength =0.75;
621 gnoise1 = 0.0004/padlength;
622 Float_t nel = 0.268*amp;
623 Float_t nprim = 0.155*amp;
624 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
625 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
626 if (glandau1[i]>1) glandau1[i]=1;
627 glandau1[i]*=padlength*padlength/12.;
631 gnoise2 = 0.0004/padlength;
634 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
635 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
636 if (glandau2[i]>1) glandau2[i]=1;
637 glandau2[i]*=padlength*padlength/12.;
642 gnoise3 = 0.0004/padlength;
645 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
646 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
647 if (glandau3[i]>1) glandau3[i]=1;
648 glandau3[i]*=padlength*padlength/12.;
656 Int_t amp = int(TMath::Abs(cl->GetQ()));
658 seed->SetErrorY2(1.);
662 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
663 Int_t ctype = cl->GetType();
664 Float_t padlength= GetPadPitchLength(seed->fRow);
666 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
667 // if (angle2<0.6) angle2 = 0.6;
668 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
671 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
674 if (fSectors==fInnerSec){
676 res = ggg1[amp]*z+glandau1[amp]*angle2;
677 if (ctype==0) res *= gcor01[rsigmaz];
680 res*= gcorp[rsigmaz];
686 res = ggg2[amp]*z+glandau2[amp]*angle2;
687 if (ctype==0) res *= gcor02[rsigmaz];
690 res*= gcorp[rsigmaz];
695 res = ggg3[amp]*z+glandau3[amp]*angle2;
696 if (ctype==0) res *= gcor02[rsigmaz];
699 res*= gcorp[rsigmaz];
708 if ((ctype<0) &&<70){
716 seed->SetErrorZ2(res);
723 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
726 //seed->SetErrorZ2(0.1);
730 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
732 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
733 Int_t ctype = cl->GetType();
734 Float_t amp = TMath::Abs(cl->GetQ());
739 Float_t landau=2 ; //landau fluctuation part
740 Float_t gg=2; // gg fluctuation part
741 Float_t padlength= GetPadPitchLength(seed->GetX());
743 if (fSectors==fInnerSec){
744 snoise2 = 0.0004/padlength;
747 gg = (2+0.001*nel/(padlength*padlength))/nel;
748 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
749 if (landau>1) landau=1;
752 snoise2 = 0.0004/padlength;
755 gg = (2+0.0008*nel/(padlength*padlength))/nel;
756 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
757 if (landau>1) landau=1;
759 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
762 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
763 angle2 = TMath::Sqrt((1-angle2));
764 if (angle2<0.6) angle2 = 0.6;
767 Float_t angle = seed->GetTgl()/angle2;
768 Float_t angular = landau*angle*angle*padlength*padlength/12.;
769 Float_t res = sdiff + angular;
772 if ((ctype==0) && (fSectors ==fOuterSec))
773 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
775 if ((ctype==0) && (fSectors ==fInnerSec))
776 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
780 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
786 if ((ctype<0) &&<70){
794 seed->SetErrorZ2(res);
801 void AliTPCseed::Reset(Bool_t all)
805 SetNumberOfClusters(0);
811 for (Int_t i=0;i<8;i++){
812 delete [] fTrackPoints[i];
820 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
821 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
827 void AliTPCseed::Modify(Double_t factor)
830 //------------------------------------------------------------------
831 //This function makes a track forget its history :)
832 //------------------------------------------------------------------
838 fC10*=factor; fC11*=factor;
839 fC20*=factor; fC21*=factor; fC22*=factor;
840 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
841 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
842 SetNumberOfClusters(0);
846 fCurrentSigmaY2 = 0.000005;
847 fCurrentSigmaZ2 = 0.000005;
856 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
858 //-----------------------------------------------------------------
859 // This function find proloncation of a track to a reference plane x=xk.
860 // doesn't change internal state of the track
861 //-----------------------------------------------------------------
863 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
865 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
869 // Double_t y1=fP0, z1=fP1;
870 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
871 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
875 //y += dx*(c1+c2)/(r1+r2);
876 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
878 Double_t dy = dx*(c1+c2)/(r1+r2);
881 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
883 if (TMath::Abs(delta)>0.0001){
884 dz = fP3*TMath::ASin(delta)/fP4;
886 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
889 dz = fP3*TPCFastMath::FastAsin(delta)/fP4;
899 //_____________________________________________________________________________
900 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
902 //-----------------------------------------------------------------
903 // This function calculates a predicted chi2 increment.
904 //-----------------------------------------------------------------
905 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
906 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
907 r00+=fC00; r01+=fC10; r11+=fC11;
909 Double_t det=r00*r11 - r01*r01;
910 if (TMath::Abs(det) < 1.e-10) {
911 Int_t n=GetNumberOfClusters();
912 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
915 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
917 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
919 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
923 //_________________________________________________________________________________________
926 Int_t AliTPCseed::Compare(const TObject *o) const {
927 //-----------------------------------------------------------------
928 // This function compares tracks according to the sector - for given sector according z
929 //-----------------------------------------------------------------
930 AliTPCseed *t=(AliTPCseed*)o;
933 if (t->fRelativeSector>fRelativeSector) return -1;
934 if (t->fRelativeSector<fRelativeSector) return 1;
935 Double_t z2 = t->GetZ();
936 Double_t z1 = GetZ();
938 if (z2<z1) return -1;
943 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
944 if (t->fBConstrain) f2=1.2;
947 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
949 if (fBConstrain) f1=1.2;
951 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
956 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
958 //rotate to track "local coordinata
959 Float_t x = seed->GetX();
960 Float_t y = seed->GetY();
961 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
964 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
965 if (!seed->Rotate(fSectors->GetAlpha()))
967 } else if (y <-ymax) {
968 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
969 if (!seed->Rotate(-fSectors->GetAlpha()))
978 //_____________________________________________________________________________
979 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
980 //-----------------------------------------------------------------
981 // This function associates a cluster with this track.
982 //-----------------------------------------------------------------
983 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
985 r00+=fC00; r01+=fC10; r11+=fC11;
986 Double_t det=r00*r11 - r01*r01;
987 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
989 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
990 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
991 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
992 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
993 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
995 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
996 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
997 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1001 fP0 += k00*dy + k01*dz;
1002 fP1 += k10*dy + k11*dz;
1004 fP3 += k30*dy + k31*dz;
1007 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1008 Double_t c12=fC21, c13=fC31, c14=fC41;
1010 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1011 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1012 fC40-=k00*c04+k01*c14;
1014 fC11-=k10*c01+k11*fC11;
1015 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1016 fC41-=k10*c04+k11*c14;
1018 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1019 fC42-=k20*c04+k21*c14;
1021 fC33-=k30*c03+k31*c13;
1022 fC43-=k40*c03+k41*c13;
1024 fC44-=k40*c04+k41*c14;
1026 Int_t n=GetNumberOfClusters();
1028 SetNumberOfClusters(n+1);
1029 SetChi2(GetChi2()+chisq);
1036 //_____________________________________________________________________________
1037 Double_t AliTPCtrackerMI::f1old(Double_t x1,Double_t y1,
1038 Double_t x2,Double_t y2,
1039 Double_t x3,Double_t y3)
1041 //-----------------------------------------------------------------
1042 // Initial approximation of the track curvature
1043 //-----------------------------------------------------------------
1044 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1045 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1046 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1047 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1048 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1050 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1051 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1052 return -xr*yr/sqrt(xr*xr+yr*yr);
1057 //_____________________________________________________________________________
1058 Double_t AliTPCtrackerMI::f1(Double_t x1,Double_t y1,
1059 Double_t x2,Double_t y2,
1060 Double_t x3,Double_t y3)
1062 //-----------------------------------------------------------------
1063 // Initial approximation of the track curvature
1064 //-----------------------------------------------------------------
1070 Double_t det = x3*y2-x2*y3;
1075 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1076 Double_t x0 = x3*0.5-y3*u;
1077 Double_t y0 = y3*0.5+x3*u;
1078 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1084 Double_t AliTPCtrackerMI::f2(Double_t x1,Double_t y1,
1085 Double_t x2,Double_t y2,
1086 Double_t x3,Double_t y3)
1088 //-----------------------------------------------------------------
1089 // Initial approximation of the track curvature
1090 //-----------------------------------------------------------------
1096 Double_t det = x3*y2-x2*y3;
1101 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1102 Double_t x0 = x3*0.5-y3*u;
1103 Double_t y0 = y3*0.5+x3*u;
1104 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1113 //_____________________________________________________________________________
1114 Double_t AliTPCtrackerMI::f2old(Double_t x1,Double_t y1,
1115 Double_t x2,Double_t y2,
1116 Double_t x3,Double_t y3)
1118 //-----------------------------------------------------------------
1119 // Initial approximation of the track curvature times center of curvature
1120 //-----------------------------------------------------------------
1121 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1122 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1123 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1124 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1125 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1127 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1129 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1132 //_____________________________________________________________________________
1133 Double_t AliTPCtrackerMI::f3(Double_t x1,Double_t y1,
1134 Double_t x2,Double_t y2,
1135 Double_t z1,Double_t z2)
1137 //-----------------------------------------------------------------
1138 // Initial approximation of the tangent of the track dip angle
1139 //-----------------------------------------------------------------
1140 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1144 Double_t AliTPCtrackerMI::f3n(Double_t x1,Double_t y1,
1145 Double_t x2,Double_t y2,
1146 Double_t z1,Double_t z2, Double_t c)
1148 //-----------------------------------------------------------------
1149 // Initial approximation of the tangent of the track dip angle
1150 //-----------------------------------------------------------------
1154 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1156 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1157 if (TMath::Abs(d*c*0.5)>1) return 0;
1158 // Double_t angle2 = TMath::ASin(d*c*0.5);
1159 // Double_t angle2 = TPCFastMath::FastAsin(d*c*0.5);
1160 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): TPCFastMath::FastAsin(d*c*0.5);
1162 angle2 = (z1-z2)*c/(angle2*2.);
1166 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1167 {//-----------------------------------------------------------------
1168 // This function find proloncation of a track to a reference plane x=x2.
1169 //-----------------------------------------------------------------
1173 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1177 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1178 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1182 Double_t dy = dx*(c1+c2)/(r1+r2);
1185 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1187 if (TMath::Abs(delta)>0.01){
1188 dz = x[3]*TMath::ASin(delta)/x[4];
1190 dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1193 //dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1203 Int_t AliTPCtrackerMI::LoadClusters()
1206 // load clusters to the memory
1207 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1208 clrow->SetClass("AliTPCclusterMI");
1210 clrow->GetArray()->ExpandCreateFast(10000);
1212 // TTree * tree = fClustersArray.GetTree();
1214 TTree * tree = fInput;
1215 TBranch * br = tree->GetBranch("Segment");
1216 br->SetAddress(&clrow);
1218 Int_t j=Int_t(tree->GetEntries());
1219 for (Int_t i=0; i<j; i++) {
1223 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1225 AliTPCRow * tpcrow=0;
1228 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1232 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1233 left = (sec-fkNIS*2)/fkNOS;
1236 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1237 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1238 for (Int_t i=0;i<tpcrow->fN1;i++)
1239 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1242 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1243 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1244 for (Int_t i=0;i<tpcrow->fN2;i++)
1245 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1256 void AliTPCtrackerMI::UnloadClusters()
1259 // unload clusters from the memory
1261 Int_t nrows = fOuterSec->GetNRows();
1262 for (Int_t sec = 0;sec<fkNOS;sec++)
1263 for (Int_t row = 0;row<nrows;row++){
1264 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1266 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1267 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1271 nrows = fInnerSec->GetNRows();
1272 for (Int_t sec = 0;sec<fkNIS;sec++)
1273 for (Int_t row = 0;row<nrows;row++){
1274 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1276 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1277 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1285 //_____________________________________________________________________________
1286 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1287 //-----------------------------------------------------------------
1288 // This function fills outer TPC sectors with clusters.
1289 //-----------------------------------------------------------------
1290 Int_t nrows = fOuterSec->GetNRows();
1292 for (Int_t sec = 0;sec<fkNOS;sec++)
1293 for (Int_t row = 0;row<nrows;row++){
1294 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1295 Int_t sec2 = sec+2*fkNIS;
1297 Int_t ncl = tpcrow->fN1;
1299 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1300 index=(((sec2<<8)+row)<<16)+ncl;
1301 tpcrow->InsertCluster(c,index);
1306 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1307 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1308 tpcrow->InsertCluster(c,index);
1311 // write indexes for fast acces
1313 for (Int_t i=0;i<510;i++)
1314 tpcrow->fFastCluster[i]=-1;
1315 for (Int_t i=0;i<tpcrow->GetN();i++){
1316 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1317 tpcrow->fFastCluster[zi]=i; // write index
1320 for (Int_t i=0;i<510;i++){
1321 if (tpcrow->fFastCluster[i]<0)
1322 tpcrow->fFastCluster[i] = last;
1324 last = tpcrow->fFastCluster[i];
1333 //_____________________________________________________________________________
1334 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1335 //-----------------------------------------------------------------
1336 // This function fills inner TPC sectors with clusters.
1337 //-----------------------------------------------------------------
1338 Int_t nrows = fInnerSec->GetNRows();
1340 for (Int_t sec = 0;sec<fkNIS;sec++)
1341 for (Int_t row = 0;row<nrows;row++){
1342 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1345 Int_t ncl = tpcrow->fN1;
1347 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1348 index=(((sec<<8)+row)<<16)+ncl;
1349 tpcrow->InsertCluster(c,index);
1354 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1355 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1356 tpcrow->InsertCluster(c,index);
1359 // write indexes for fast acces
1361 for (Int_t i=0;i<510;i++)
1362 tpcrow->fFastCluster[i]=-1;
1363 for (Int_t i=0;i<tpcrow->GetN();i++){
1364 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1365 tpcrow->fFastCluster[zi]=i; // write index
1368 for (Int_t i=0;i<510;i++){
1369 if (tpcrow->fFastCluster[i]<0)
1370 tpcrow->fFastCluster[i] = last;
1372 last = tpcrow->fFastCluster[i];
1384 //_________________________________________________________________________
1385 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1386 //--------------------------------------------------------------------
1387 // Return pointer to a given cluster
1388 //--------------------------------------------------------------------
1389 Int_t sec=(index&0xff000000)>>24;
1390 Int_t row=(index&0x00ff0000)>>16;
1391 Int_t ncl=(index&0x0000ffff)>>00;
1393 const AliTPCRow * tpcrow=0;
1394 AliTPCclusterMI * clrow =0;
1396 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1398 clrow = tpcrow->fClusters1;
1400 clrow = tpcrow->fClusters2;
1403 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1404 if (sec-2*fkNIS<fkNOS)
1405 clrow = tpcrow->fClusters1;
1407 clrow = tpcrow->fClusters2;
1409 if (tpcrow==0) return 0;
1410 if (tpcrow->GetN()<=ncl) return 0;
1411 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1412 return &(clrow[ncl]);
1418 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1419 //-----------------------------------------------------------------
1420 // This function tries to find a track prolongation to next pad row
1421 //-----------------------------------------------------------------
1423 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1425 // if (t.GetRadius()>x+10 ) return 0;
1426 // t.PropagateTo(x+0.02);
1427 //t.PropagateTo(x+0.01);
1428 if (!t.PropagateTo(x)) {
1433 Double_t y=t.GetY(), z=t.GetZ();
1434 if (TMath::Abs(y)>ymax){
1436 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1437 if (!t.Rotate(fSectors->GetAlpha()))
1439 } else if (y <-ymax) {
1440 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1441 if (!t.Rotate(-fSectors->GetAlpha()))
1444 if (!t.PropagateTo(x)) {
1450 // update current shape info every 3 pad-row
1451 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1452 //t.fCurrentSigmaY = GetSigmaY(&t);
1453 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1457 AliTPCclusterMI *cl=0;
1462 if (t.GetClusterIndex2(nr)>0){
1464 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1465 index = t.GetClusterIndex2(nr);
1466 cl = t.fClusterPointer[nr];
1467 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1468 t.fCurrentClusterIndex1 = index;
1471 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1472 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1474 Double_t roadz = 1.;
1476 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1478 t.SetClusterIndex2(nr,-1);
1483 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1489 t.fCurrentCluster = cl;
1491 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1493 //if founded cluster is acceptible
1494 UpdateTrack(&t,accept);
1500 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1501 cl = krow.FindNearest2(y,z,roady,roadz,index);
1502 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1507 t.fCurrentCluster = cl;
1509 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1511 if (t.fCurrentCluster->IsUsed(10)){
1516 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1522 if (accept<3) UpdateTrack(&t,accept);
1525 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1531 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1532 //-----------------------------------------------------------------
1533 // This function tries to find a track prolongation to next pad row
1534 //-----------------------------------------------------------------
1536 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1538 if (!t.GetProlongation(x,y,z)) {
1544 if (TMath::Abs(y)>ymax){
1548 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1549 if (!t.Rotate(fSectors->GetAlpha()))
1551 } else if (y <-ymax) {
1552 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1553 if (!t.Rotate(-fSectors->GetAlpha()))
1556 if (!t.PropagateTo(x)) {
1559 t.GetProlongation(x,y,z);
1562 // update current shape info every 3 pad-row
1563 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1564 // t.fCurrentSigmaY = GetSigmaY(&t);
1565 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1569 AliTPCclusterMI *cl=0;
1574 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1575 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1577 Double_t roadz = 1.;
1580 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1582 t.SetClusterIndex2(row,-1);
1587 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1591 if ((cl==0)&&(krow)) {
1592 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1593 cl = krow.FindNearest2(y,z,roady,roadz,index);
1595 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1599 t.fCurrentCluster = cl;
1600 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1602 t.SetClusterIndex2(row,index);
1603 t.fClusterPointer[row] = cl;
1611 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1612 //-----------------------------------------------------------------
1613 // This function tries to find a track prolongation to next pad row
1614 //-----------------------------------------------------------------
1615 t.fCurrentCluster = 0;
1616 t.fCurrentClusterIndex1 = 0;
1618 Double_t xt=t.GetX();
1619 Int_t row = GetRowNumber(xt)-1;
1620 Double_t ymax= GetMaxY(nr);
1622 if (row < nr) return 1; // don't prolongate if not information until now -
1623 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1625 return 0; // not prolongate strongly inclined tracks
1627 if (TMath::Abs(t.GetSnp())>0.95) {
1629 return 0; // not prolongate strongly inclined tracks
1632 Double_t x= GetXrow(nr);
1634 //t.PropagateTo(x+0.02);
1635 //t.PropagateTo(x+0.01);
1636 if (!t.PropagateTo(x)){
1643 if (TMath::Abs(y)>ymax){
1645 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1646 if (!t.Rotate(fSectors->GetAlpha()))
1648 } else if (y <-ymax) {
1649 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1650 if (!t.Rotate(-fSectors->GetAlpha()))
1653 if (!t.PropagateTo(x)){
1660 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1662 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1664 t.SetClusterIndex2(nr,-1);
1669 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1675 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1676 // t.fCurrentSigmaY = GetSigmaY(&t);
1677 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1681 AliTPCclusterMI *cl=0;
1684 Double_t roady = 1.;
1685 Double_t roadz = 1.;
1688 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1689 cl = krow.FindNearest2(y,z,roady,roadz,index);
1691 t.fCurrentCluster = cl;
1692 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1697 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1698 //-----------------------------------------------------------------
1699 // This function tries to find a track prolongation to next pad row
1700 //-----------------------------------------------------------------
1702 //update error according neighborhoud
1704 if (t.fCurrentCluster) {
1706 Bool_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1708 if (t.fCurrentCluster->IsUsed(10)){
1714 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1720 if (accept<3) UpdateTrack(&t,accept);
1724 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1725 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1727 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1735 //_____________________________________________________________________________
1736 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1737 //-----------------------------------------------------------------
1738 // This function tries to find a track prolongation.
1739 //-----------------------------------------------------------------
1740 Double_t xt=t.GetX();
1742 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1743 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1744 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1746 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1748 Int_t first = GetRowNumber(xt)-1;
1749 for (Int_t nr= first; nr>=rf; nr-=step) {
1750 if (FollowToNext(t,nr)==0)
1751 if (!t.IsActive()) return 0;
1758 //_____________________________________________________________________________
1759 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1760 //-----------------------------------------------------------------
1761 // This function tries to find a track prolongation.
1762 //-----------------------------------------------------------------
1763 Double_t xt=t.GetX();
1765 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1766 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1767 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1768 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1770 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1772 if (FollowToNextFast(t,nr)==0)
1773 if (!t.IsActive()) return 0;
1783 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1784 //-----------------------------------------------------------------
1785 // This function tries to find a track prolongation.
1786 //-----------------------------------------------------------------
1787 // Double_t xt=t.GetX();
1789 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1790 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1791 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1792 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1795 first = t.fFirstPoint+3;
1797 if (first<0) first=0;
1798 for (Int_t nr=first+1; nr<=rf; nr++) {
1799 //if ( (t.GetSnp()<0.9))
1809 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1817 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1820 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1822 Float_t distance = TMath::Sqrt(dz2+dy2);
1823 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1826 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1827 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1832 if (firstpoint>lastpoint) {
1833 firstpoint =lastpoint;
1838 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1839 if (s1->GetClusterIndex2(i)>0) sum1++;
1840 if (s2->GetClusterIndex2(i)>0) sum2++;
1841 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1845 if (sum<5) return 0;
1847 Float_t summin = TMath::Min(sum1+1,sum2+1);
1848 Float_t ratio = (sum+1)/Float_t(summin);
1852 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1856 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1857 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1859 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1861 Float_t dy2 =(s1->GetY() - s2->GetY());
1863 Float_t distance = dz2+dy2;
1864 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1869 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1870 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1872 if (firstpoint>=lastpoint-5) return;;
1874 for (Int_t i=firstpoint;i<lastpoint;i++){
1875 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1876 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1883 for (Int_t i=firstpoint;i<lastpoint;i++){
1884 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1885 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1886 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1887 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1888 if (s1->IsActive()&&s2->IsActive()){
1889 p1->fIsShared = kTRUE;
1890 p2->fIsShared = kTRUE;
1897 for (Int_t i=0;i<4;i++){
1898 if (s1->fOverlapLabels[3*i]==0){
1899 s1->fOverlapLabels[3*i] = s2->GetLabel();
1900 s1->fOverlapLabels[3*i+1] = sumshared;
1901 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1905 for (Int_t i=0;i<4;i++){
1906 if (s2->fOverlapLabels[3*i]==0){
1907 s2->fOverlapLabels[3*i] = s1->GetLabel();
1908 s2->fOverlapLabels[3*i+1] = sumshared;
1909 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1917 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1920 //sort trackss according sectors
1922 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1923 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1925 //if (pt) RotateToLocal(pt);
1929 arr->Sort(); // sorting according z
1930 arr->Expand(arr->GetEntries());
1933 Int_t nseed=arr->GetEntriesFast();
1934 for (Int_t i=0; i<nseed; i++) {
1935 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1937 for (Int_t j=0;j<=12;j++){
1938 pt->fOverlapLabels[j] =0;
1941 for (Int_t i=0; i<nseed; i++) {
1942 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1944 if (pt->fRemoval>10) continue;
1945 for (Int_t j=i+1; j<nseed; j++){
1946 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1948 if (pt2->fRemoval<=10) {
1949 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1956 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1959 //sort trackss according sectors
1962 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1965 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1966 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1971 arr->Sort(); // sorting according z
1972 arr->Expand(arr->GetEntries());
1974 //reset overlap labels
1976 Int_t nseed=arr->GetEntriesFast();
1977 for (Int_t i=0; i<nseed; i++) {
1978 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1981 for (Int_t j=0;j<=12;j++){
1982 pt->fOverlapLabels[j] =0;
1986 //sign shared tracks
1987 for (Int_t i=0; i<nseed; i++) {
1988 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1990 if (pt->fRemoval>10) continue;
1991 Float_t deltac = pt->GetC()*0.1;
1992 for (Int_t j=i+1; j<nseed; j++){
1993 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1995 if (pt2->fRemoval<=10) {
1996 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1997 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
1998 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2005 // remove highly shared tracks
2006 for (Int_t i=0; i<nseed; i++) {
2007 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2009 if (pt->fRemoval>10) continue;
2012 for (Int_t j=0;j<4;j++){
2013 sumshared = pt->fOverlapLabels[j*3+1];
2015 Float_t factor = factor1;
2016 if (pt->fRemoval>0) factor = factor2;
2017 if (sumshared/pt->GetNumberOfClusters()>factor){
2018 for (Int_t j=0;j<4;j++){
2019 if (pt->fOverlapLabels[3*j]==0) continue;
2020 if (pt->fOverlapLabels[3*j+1]<5) continue;
2021 if (pt->fRemoval==removalindex) continue;
2022 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2024 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2025 // pt->fRemoval = removalindex;
2026 delete arr->RemoveAt(i);
2034 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2043 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode)
2046 //sort tracks in array according mode criteria
2047 Int_t nseed = arr->GetEntriesFast();
2048 for (Int_t i=0; i<nseed; i++) {
2049 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2059 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2062 //Loop over all tracks and remove "overlaps"
2065 Int_t nseed = arr->GetEntriesFast();
2068 for (Int_t i=0; i<nseed; i++) {
2069 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2071 delete arr->RemoveAt(i);
2075 pt->fBSigned = kFALSE;
2079 nseed = arr->GetEntriesFast();
2086 for (Int_t i=0; i<nseed; i++) {
2087 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2091 Int_t found,foundable,shared;
2093 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2095 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2097 Double_t factor = factor2;
2098 if (pt->fBConstrain) factor = factor1;
2100 if ((Float_t(shared)/Float_t(found))>factor){
2101 pt->Desactivate(removalindex);
2106 for (Int_t i=0; i<160; i++) {
2107 Int_t index=pt->GetClusterIndex2(i);
2108 if (index<0 || index&0x8000 ) continue;
2109 AliTPCclusterMI *c= pt->fClusterPointer[i];
2111 // if (!c->IsUsed(10)) c->Use(10);
2112 //if (pt->IsActive())
2121 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2124 void AliTPCtrackerMI::UnsignClusters()
2127 // loop over all clusters and unsign them
2130 for (Int_t sec=0;sec<fkNIS;sec++){
2131 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2132 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2133 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2134 // if (cl[icl].IsUsed(10))
2136 cl = fInnerSec[sec][row].fClusters2;
2137 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2138 //if (cl[icl].IsUsed(10))
2143 for (Int_t sec=0;sec<fkNOS;sec++){
2144 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2145 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2146 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2147 //if (cl[icl].IsUsed(10))
2149 cl = fOuterSec[sec][row].fClusters2;
2150 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2151 //if (cl[icl].IsUsed(10))
2160 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2163 //sign clusters to be "used"
2165 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2166 // loop over "primaries"
2180 Int_t nseed = arr->GetEntriesFast();
2181 for (Int_t i=0; i<nseed; i++) {
2182 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2186 if (!(pt->IsActive())) continue;
2187 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2188 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2190 sumdens2+= dens*dens;
2191 sumn += pt->GetNumberOfClusters();
2192 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2193 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2196 sumchi2 +=chi2*chi2;
2201 Float_t mdensity = 0.9;
2202 Float_t meann = 130;
2203 Float_t meanchi = 1;
2204 Float_t sdensity = 0.1;
2205 Float_t smeann = 10;
2206 Float_t smeanchi =0.4;
2210 mdensity = sumdens/sum;
2212 meanchi = sumchi/sum;
2214 sdensity = sumdens2/sum-mdensity*mdensity;
2215 sdensity = TMath::Sqrt(sdensity);
2217 smeann = sumn2/sum-meann*meann;
2218 smeann = TMath::Sqrt(smeann);
2220 smeanchi = sumchi2/sum - meanchi*meanchi;
2221 smeanchi = TMath::Sqrt(smeanchi);
2225 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2227 for (Int_t i=0; i<nseed; i++) {
2228 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2232 if (pt->fBSigned) continue;
2233 if (pt->fBConstrain) continue;
2234 //if (!(pt->IsActive())) continue;
2236 Int_t found,foundable,shared;
2237 pt->GetClusterStatistic(0,160,found, foundable,shared);
2238 if (shared/float(found)>0.3) {
2239 if (shared/float(found)>0.9 ){
2240 //delete arr->RemoveAt(i);
2245 Bool_t isok =kFALSE;
2246 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2248 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2250 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2252 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2256 for (Int_t i=0; i<160; i++) {
2257 Int_t index=pt->GetClusterIndex2(i);
2258 if (index<0) continue;
2259 AliTPCclusterMI *c= pt->fClusterPointer[i];
2261 //if (!(c->IsUsed(10))) c->Use();
2268 Double_t maxchi = meanchi+2.*smeanchi;
2270 for (Int_t i=0; i<nseed; i++) {
2271 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2275 //if (!(pt->IsActive())) continue;
2276 if (pt->fBSigned) continue;
2277 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2278 if (chi>maxchi) continue;
2281 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2283 //sign only tracks with enoug big density at the beginning
2285 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2288 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2289 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2291 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2292 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2295 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2296 //Int_t noc=pt->GetNumberOfClusters();
2297 pt->fBSigned = kTRUE;
2298 for (Int_t i=0; i<160; i++) {
2300 Int_t index=pt->GetClusterIndex2(i);
2301 if (index<0) continue;
2302 AliTPCclusterMI *c= pt->fClusterPointer[i];
2304 // if (!(c->IsUsed(10))) c->Use();
2309 // gLastCheck = nseed;
2317 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2)
2319 // stop not active tracks
2320 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2321 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2322 Int_t nseed = arr->GetEntriesFast();
2324 for (Int_t i=0; i<nseed; i++) {
2325 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2329 if (!(pt->IsActive())) continue;
2330 StopNotActive(pt,row0,th0, th1,th2);
2336 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2339 // stop not active tracks
2340 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2341 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2344 Int_t foundable = 0;
2345 Int_t maxindex = seed->fLastPoint; //last foundable row
2346 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2347 seed->Desactivate(10) ;
2351 for (Int_t i=row0; i<maxindex; i++){
2352 Int_t index = seed->GetClusterIndex2(i);
2353 if (index!=-1) foundable++;
2355 if (foundable<=30) sumgood1++;
2356 if (foundable<=50) {
2363 if (foundable>=30.){
2364 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2367 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2372 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2375 // back propagation of ESD tracks
2380 PropagateBack(fSeeds);
2381 Int_t nseed = fSeeds->GetEntriesFast();
2382 for (Int_t i=0;i<nseed;i++){
2383 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2384 AliESDtrack *esd=event->GetTrack(i);
2385 seed->CookdEdx(0.02,0.06);
2386 CookLabel(seed,0.1); //For comparison only
2387 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2395 void AliTPCtrackerMI::DeleteSeeds()
2397 Int_t nseed = fSeeds->GetEntriesFast();
2398 for (Int_t i=0;i<nseed;i++){
2399 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2400 if (seed) delete fSeeds->RemoveAt(i);
2406 void AliTPCtrackerMI::ReadSeeds(AliESD *event)
2409 //read seeds from the event
2411 Int_t nentr=event->GetNumberOfTracks();
2412 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2416 fSeeds = new TObjArray;
2420 for (Int_t i=0; i<nentr; i++) {
2421 AliESDtrack *esd=event->GetTrack(i);
2422 ULong_t status=esd->GetStatus();
2423 const AliTPCtrack t(*esd);
2424 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2425 if (status==AliESDtrack::kTPCin) seed->Modify(0.8);
2428 // rotate to the local coordinate system
2430 fSectors=fInnerSec; fN=fkNIS;
2432 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2433 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2434 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2435 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2436 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2437 alpha-=seed->GetAlpha();
2438 if (!seed->Rotate(alpha)) continue;
2440 seed->PropagateTo(fSectors->GetX(0));
2442 // Int_t index = esd->GetTPCindex();
2443 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2445 fSeeds->AddLast(seed);
2451 //_____________________________________________________________________________
2452 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2453 Float_t deltay, Int_t ddsec) {
2454 //-----------------------------------------------------------------
2455 // This function creates track seeds.
2456 // SEEDING WITH VERTEX CONSTRAIN
2457 //-----------------------------------------------------------------
2458 // cuts[0] - fP4 cut
2459 // cuts[1] - tan(phi) cut
2460 // cuts[2] - zvertex cut
2461 // cuts[3] - fP3 cut
2469 Double_t x[5], c[15];
2470 // Int_t di = i1-i2;
2472 AliTPCseed * seed = new AliTPCseed;
2473 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2474 Double_t cs=cos(alpha), sn=sin(alpha);
2476 // Double_t x1 =fOuterSec->GetX(i1);
2477 //Double_t xx2=fOuterSec->GetX(i2);
2479 Double_t x1 =GetXrow(i1);
2480 Double_t xx2=GetXrow(i2);
2482 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2484 Int_t imiddle = (i2+i1)/2; //middle pad row index
2485 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2486 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2490 const AliTPCRow& kr1=GetRow(ns,i1);
2491 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2492 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2495 // change cut on curvature if it can't reach this layer
2496 // maximal curvature set to reach it
2497 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2498 if (dvertexmax*0.5*cuts[0]>0.85){
2499 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2501 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2504 if (deltay>0) ddsec = 0;
2505 // loop over clusters
2506 for (Int_t is=0; is < kr1; is++) {
2508 if (kr1[is]->IsUsed(10)) continue;
2509 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2510 //if (TMath::Abs(y1)>ymax) continue;
2512 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2514 // find possible directions
2515 Float_t anglez = (z1-z3)/(x1-x3);
2516 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2519 //find rotation angles relative to line given by vertex and point 1
2520 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2521 Double_t dvertex = TMath::Sqrt(dvertex2);
2522 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2523 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2526 // loop over 2 sectors
2532 Double_t dddz1=0; // direction of delta inclination in z axis
2539 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2540 Int_t sec2 = sec + dsec;
2542 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2543 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2544 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2545 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2546 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2547 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2549 // rotation angles to p1-p3
2550 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2551 Double_t x2, y2, z2;
2553 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2556 Double_t dxx0 = (xx2-x3)*cs13r;
2557 Double_t dyy0 = (xx2-x3)*sn13r;
2558 for (Int_t js=index1; js < index2; js++) {
2559 const AliTPCclusterMI *kcl = kr2[js];
2560 if (kcl->IsUsed(10)) continue;
2562 //calcutate parameters
2564 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2566 if (TMath::Abs(yy0)<0.000001) continue;
2567 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2568 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2569 Double_t r02 = (0.25+y0*y0)*dvertex2;
2570 //curvature (radius) cut
2571 if (r02<r2min) continue;
2575 Double_t c0 = 1/TMath::Sqrt(r02);
2579 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2580 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2581 Double_t dfi0 = 2.*TPCFastMath::FastAsin(dvertex*c0*0.5);
2582 Double_t dfi1 = 2.*TPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2585 Double_t z0 = kcl->GetZ();
2586 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2587 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2590 Double_t dip = (z1-z0)*c0/dfi1;
2591 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2602 x2= xx2*cs-y2*sn*dsec;
2603 y2=+xx2*sn*dsec+y2*cs;
2613 // do we have cluster at the middle ?
2615 GetProlongation(x1,xm,x,ym,zm);
2617 AliTPCclusterMI * cm=0;
2618 if (TMath::Abs(ym)-ymaxm<0){
2619 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2620 if ((!cm) || (cm->IsUsed(10))) {
2625 // rotate y1 to system 0
2626 // get state vector in rotated system
2627 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2628 Double_t xr2 = x0*cs+yr1*sn*dsec;
2629 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2631 GetProlongation(xx2,xm,xr,ym,zm);
2632 if (TMath::Abs(ym)-ymaxm<0){
2633 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2634 if ((!cm) || (cm->IsUsed(10))) {
2644 dym = ym - cm->GetY();
2645 dzm = zm - cm->GetZ();
2652 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2653 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2654 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2655 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2656 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2658 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2659 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2660 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2661 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2662 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2663 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2665 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2666 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2667 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2668 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2672 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2673 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2674 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2675 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2676 c[13]=f30*sy1*f40+f32*sy2*f42;
2677 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2679 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2681 UInt_t index=kr1.GetIndex(is);
2682 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2684 track->fIsSeeding = kTRUE;
2691 FollowProlongation(*track, (i1+i2)/2,1);
2692 Int_t foundable,found,shared;
2693 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2694 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2696 seed->~AliTPCseed();
2702 FollowProlongation(*track, i2,1);
2706 track->fBConstrain =1;
2707 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2708 track->fLastPoint = i1; // first cluster in track position
2709 track->fFirstPoint = track->fLastPoint;
2711 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2712 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2713 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2715 seed->~AliTPCseed();
2719 // Z VERTEX CONDITION
2721 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2722 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2723 if (TMath::Abs(zv-z3)>cuts[2]) {
2724 FollowProlongation(*track, TMath::Max(i2-20,0));
2725 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2726 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2727 if (TMath::Abs(zv-z3)>cuts[2]){
2728 FollowProlongation(*track, TMath::Max(i2-40,0));
2729 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2730 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2731 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2732 // make seed without constrain
2733 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2734 FollowProlongation(*track2, i2,1);
2735 track2->fBConstrain = kFALSE;
2736 track2->fSeedType = 1;
2737 arr->AddLast(track2);
2739 seed->~AliTPCseed();
2744 seed->~AliTPCseed();
2751 track->fSeedType =0;
2752 arr->AddLast(track);
2753 seed = new AliTPCseed;
2755 // don't consider other combinations
2756 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2762 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2768 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2773 //-----------------------------------------------------------------
2774 // This function creates track seeds.
2775 //-----------------------------------------------------------------
2776 // cuts[0] - fP4 cut
2777 // cuts[1] - tan(phi) cut
2778 // cuts[2] - zvertex cut
2779 // cuts[3] - fP3 cut
2789 Double_t x[5], c[15];
2791 // make temporary seed
2792 AliTPCseed * seed = new AliTPCseed;
2793 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2794 // Double_t cs=cos(alpha), sn=sin(alpha);
2799 Double_t x1 = GetXrow(i1-1);
2800 const AliTPCRow& kr1=GetRow(sec,i1-1);
2801 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2803 Double_t x1p = GetXrow(i1);
2804 const AliTPCRow& kr1p=GetRow(sec,i1);
2806 Double_t x1m = GetXrow(i1-2);
2807 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2810 //last 3 padrow for seeding
2811 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2812 Double_t x3 = GetXrow(i1-7);
2813 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2815 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2816 Double_t x3p = GetXrow(i1-6);
2818 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2819 Double_t x3m = GetXrow(i1-8);
2824 Int_t im = i1-4; //middle pad row index
2825 Double_t xm = GetXrow(im); // radius of middle pad-row
2826 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2827 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2830 Double_t deltax = x1-x3;
2831 Double_t dymax = deltax*cuts[1];
2832 Double_t dzmax = deltax*cuts[3];
2834 // loop over clusters
2835 for (Int_t is=0; is < kr1; is++) {
2837 if (kr1[is]->IsUsed(10)) continue;
2838 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2840 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2842 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2843 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2849 for (Int_t js=index1; js < index2; js++) {
2850 const AliTPCclusterMI *kcl = kr3[js];
2851 if (kcl->IsUsed(10)) continue;
2853 // apply angular cuts
2854 if (TMath::Abs(y1-y3)>dymax) continue;
2857 if (TMath::Abs(z1-z3)>dzmax) continue;
2859 Double_t angley = (y1-y3)/(x1-x3);
2860 Double_t anglez = (z1-z3)/(x1-x3);
2862 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2863 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2865 Double_t yyym = angley*(xm-x1)+y1;
2866 Double_t zzzm = anglez*(xm-x1)+z1;
2868 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2870 if (kcm->IsUsed(10)) continue;
2872 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2873 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2880 // look around first
2881 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2887 if (kc1m->IsUsed(10)) used++;
2889 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2895 if (kc1p->IsUsed(10)) used++;
2897 if (used>1) continue;
2898 if (found<1) continue;
2902 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2908 if (kc3m->IsUsed(10)) used++;
2912 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2918 if (kc3p->IsUsed(10)) used++;
2922 if (used>1) continue;
2923 if (found<3) continue;
2933 x[4]=f1(x1,y1,x2,y2,x3,y3);
2934 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
2937 x[2]=f2(x1,y1,x2,y2,x3,y3);
2940 x[3]=f3n(x1,y1,x2,y2,z1,z2,x[4]);
2941 //if (TMath::Abs(x[3]) > cuts[3]) continue;
2945 Double_t sy1=0.1, sz1=0.1;
2946 Double_t sy2=0.1, sz2=0.1;
2947 Double_t sy3=0.1, sy=0.1, sz=0.1;
2949 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2950 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2951 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2952 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2953 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2954 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2956 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2957 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2958 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2959 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2963 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2964 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2965 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2966 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2967 c[13]=f30*sy1*f40+f32*sy2*f42;
2968 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2970 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2972 UInt_t index=kr1.GetIndex(is);
2973 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
2975 track->fIsSeeding = kTRUE;
2978 FollowProlongation(*track, i1-7,1);
2979 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
2980 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
2982 seed->~AliTPCseed();
2988 FollowProlongation(*track, i2,1);
2989 track->fBConstrain =0;
2990 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2991 track->fFirstPoint = track->fLastPoint;
2993 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2994 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
2995 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
2997 seed->~AliTPCseed();
3002 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3003 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3004 FollowProlongation(*track2, i2,1);
3005 track2->fBConstrain = kFALSE;
3006 track2->fSeedType = 4;
3007 arr->AddLast(track2);
3009 seed->~AliTPCseed();
3013 //arr->AddLast(track);
3014 //seed = new AliTPCseed;
3020 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3026 //_____________________________________________________________________________
3027 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3028 Float_t deltay, Bool_t /*bconstrain*/) {
3029 //-----------------------------------------------------------------
3030 // This function creates track seeds - without vertex constraint
3031 //-----------------------------------------------------------------
3032 // cuts[0] - fP4 cut - not applied
3033 // cuts[1] - tan(phi) cut
3034 // cuts[2] - zvertex cut - not applied
3035 // cuts[3] - fP3 cut
3045 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3046 // Double_t cs=cos(alpha), sn=sin(alpha);
3047 Int_t row0 = (i1+i2)/2;
3048 Int_t drow = (i1-i2)/2;
3049 const AliTPCRow& kr0=fSectors[sec][row0];
3052 AliTPCpolyTrack polytrack;
3053 Int_t nclusters=fSectors[sec][row0];
3054 AliTPCseed * seed = new AliTPCseed;
3059 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3061 Int_t nfoundable =0;
3062 for (Int_t iter =1; iter<2; iter++){ //iterations
3063 const AliTPCRow& krm=fSectors[sec][row0-iter];
3064 const AliTPCRow& krp=fSectors[sec][row0+iter];
3065 const AliTPCclusterMI * cl= kr0[is];
3067 if (cl->IsUsed(10)) {
3073 Double_t x = kr0.GetX();
3074 // Initialization of the polytrack
3079 Double_t y0= cl->GetY();
3080 Double_t z0= cl->GetZ();
3084 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3085 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3087 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3088 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3089 polytrack.AddPoint(x,y0,z0,erry, errz);
3092 if (cl->IsUsed(10)) sumused++;
3095 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3096 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3099 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3100 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3101 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3102 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3103 if (cl1->IsUsed(10)) sumused++;
3104 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3108 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3110 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3111 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3112 if (cl2->IsUsed(10)) sumused++;
3113 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3116 if (sumused>0) continue;
3118 polytrack.UpdateParameters();
3124 nfoundable = polytrack.GetN();
3125 nfound = nfoundable;
3127 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3128 Float_t maxdist = 0.8*(1.+3./(ddrow));
3129 for (Int_t delta = -1;delta<=1;delta+=2){
3130 Int_t row = row0+ddrow*delta;
3131 kr = &(fSectors[sec][row]);
3132 Double_t xn = kr->GetX();
3133 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3134 polytrack.GetFitPoint(xn,yn,zn);
3135 if (TMath::Abs(yn)>ymax) continue;
3137 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3139 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3142 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3143 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3144 if (cln->IsUsed(10)) {
3145 // printf("used\n");
3153 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3158 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3159 polytrack.UpdateParameters();
3162 if ( (sumused>3) || (sumused>0.5*nfound)) {
3163 //printf("sumused %d\n",sumused);
3168 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3169 AliTPCpolyTrack track2;
3171 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3172 if (track2.GetN()<0.5*nfoundable) continue;
3175 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3177 // test seed with and without constrain
3178 for (Int_t constrain=0; constrain<=0;constrain++){
3179 // add polytrack candidate
3181 Double_t x[5], c[15];
3182 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3183 track2.GetBoundaries(x3,x1);
3185 track2.GetFitPoint(x1,y1,z1);
3186 track2.GetFitPoint(x2,y2,z2);
3187 track2.GetFitPoint(x3,y3,z3);
3189 //is track pointing to the vertex ?
3192 polytrack.GetFitPoint(x0,y0,z0);
3205 x[4]=f1(x1,y1,x2,y2,x3,y3);
3207 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3208 x[2]=f2(x1,y1,x2,y2,x3,y3);
3210 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3211 //x[3]=f3(x1,y1,x2,y2,z1,z2);
3212 x[3]=f3n(x1,y1,x3,y3,z1,z3,x[4]);
3213 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3216 Double_t sy =0.1, sz =0.1;
3217 Double_t sy1=0.02, sz1=0.02;
3218 Double_t sy2=0.02, sz2=0.02;
3222 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3225 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3226 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3227 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3228 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3229 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3230 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3232 Double_t f30=(f3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3233 Double_t f31=(f3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3234 Double_t f32=(f3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3235 Double_t f34=(f3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3240 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3241 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3242 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3243 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3244 c[13]=f30*sy1*f40+f32*sy2*f42;
3245 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3247 //Int_t row1 = fSectors->GetRowNumber(x1);
3248 Int_t row1 = GetRowNumber(x1);
3252 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3253 track->fIsSeeding = kTRUE;
3254 Int_t rc=FollowProlongation(*track, i2);
3255 if (constrain) track->fBConstrain =1;
3257 track->fBConstrain =0;
3258 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3259 track->fFirstPoint = track->fLastPoint;
3261 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3262 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3263 track->fNShared>0.4*track->GetNumberOfClusters()) {
3266 seed->~AliTPCseed();
3269 arr->AddLast(track);
3270 seed = new AliTPCseed;
3274 } // if accepted seed
3277 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3283 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3288 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3289 Int_t p1 = int(r1*track->GetNumberOfClusters());
3290 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3292 Double_t x0[3],x1[3],x2[3];
3297 // find track position at given ratio of the length
3298 Int_t sec0, sec1, sec2;
3304 for (Int_t i=0;i<160;i++){
3305 if (track->fClusterPointer[i]){
3307 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3308 if ( (index<p0) || x0[0]<0 ){
3309 if (trpoint->GetX()>1){
3310 clindex = track->GetClusterIndex2(i);
3312 x0[0] = trpoint->GetX();
3313 x0[1] = trpoint->GetY();
3314 x0[2] = trpoint->GetZ();
3315 sec0 = ((clindex&0xff000000)>>24)%18;
3320 if ( (index<p1) &&(trpoint->GetX()>1)){
3321 clindex = track->GetClusterIndex2(i);
3323 x1[0] = trpoint->GetX();
3324 x1[1] = trpoint->GetY();
3325 x1[2] = trpoint->GetZ();
3326 sec1 = ((clindex&0xff000000)>>24)%18;
3329 if ( (index<p2) &&(trpoint->GetX()>1)){
3330 clindex = track->GetClusterIndex2(i);
3332 x2[0] = trpoint->GetX();
3333 x2[1] = trpoint->GetY();
3334 x2[2] = trpoint->GetZ();
3335 sec2 = ((clindex&0xff000000)>>24)%18;
3342 Double_t alpha, cs,sn, xx2,yy2;
3344 alpha = (sec1-sec2)*fSectors->GetAlpha();
3345 cs = TMath::Cos(alpha);
3346 sn = TMath::Sin(alpha);
3347 xx2= x1[0]*cs-x1[1]*sn;
3348 yy2= x1[0]*sn+x1[1]*cs;
3352 alpha = (sec0-sec2)*fSectors->GetAlpha();
3353 cs = TMath::Cos(alpha);
3354 sn = TMath::Sin(alpha);
3355 xx2= x0[0]*cs-x0[1]*sn;
3356 yy2= x0[0]*sn+x0[1]*cs;
3362 Double_t x[5],c[15];
3366 x[4]=f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3367 // if (x[4]>1) return 0;
3368 x[2]=f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3369 x[3]=f3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3370 //if (TMath::Abs(x[3]) > 2.2) return 0;
3371 //if (TMath::Abs(x[2]) > 1.99) return 0;
3373 Double_t sy =0.1, sz =0.1;
3375 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3376 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3377 Double_t sy3=0.01+track->GetSigmaY2();
3379 Double_t f40=(f1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3380 Double_t f42=(f1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3381 Double_t f43=(f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3382 Double_t f20=(f2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3383 Double_t f22=(f2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3384 Double_t f23=(f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3386 Double_t f30=(f3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3387 Double_t f31=(f3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3388 Double_t f32=(f3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3389 Double_t f34=(f3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3394 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3395 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3396 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3397 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3398 c[13]=f30*sy1*f40+f32*sy2*f42;
3399 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3401 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3402 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3403 // Double_t y0,z0,y1,z1, y2,z2;
3404 //seed->GetProlongation(x0[0],y0,z0);
3405 // seed->GetProlongation(x1[0],y1,z1);
3406 //seed->GetProlongation(x2[0],y2,z2);
3408 seed->fLastPoint = pp2;
3409 seed->fFirstPoint = pp2;
3415 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3420 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3422 if (TMath::Abs(seed->GetC())>0.01) return 0;
3425 Float_t x[160], y[160], erry[160], z[160], errz[160];
3427 Float_t xt[160], yt[160], zt[160];
3432 Int_t middle = seed->GetNumberOfClusters()/2;
3435 // find central sector, get local cooordinates
3437 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3438 sec[i]= seed->GetClusterSector(i)%18;
3441 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3442 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3449 if (i>i2) i2 = i; //last point with cluster
3450 if (i2<i1) i1 = i; //first point with cluster
3453 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3455 yt[i] = point->GetY();
3456 zt[i] = point->GetZ();
3458 if (point->GetX()>0){
3459 erry[i] = point->GetErrY();
3460 errz[i] = point->GetErrZ();
3465 secm = sec[i]; //central sector
3466 padm = i; //middle point with cluster
3471 // rotate position to global coordinate system connected to sector at last the point
3473 for (Int_t i=i1;i<=i2;i++){
3475 if (sec[i]<0) continue;
3476 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3477 Double_t cs = TMath::Cos(alpha);
3478 Double_t sn = TMath::Sin(alpha);
3479 Float_t xx2= x[i]*cs+y[i]*sn;
3480 Float_t yy2= -x[i]*sn+y[i]*cs;
3484 xx2= xt[i]*cs+yt[i]*sn;
3485 yy2= -xt[i]*sn+yt[i]*cs;
3490 //get "state" vector
3491 Double_t xh[5],xm = x[padm];
3494 xh[4]=f1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3495 xh[2]=f2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3496 xh[3]=f3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3499 for (Int_t i=i1;i<=i2;i++){
3501 if (sec[i]<0) continue;
3502 GetProlongation(x[i2], x[i],xh,yy,zz);
3503 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3505 //xxh[4]=f1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3506 //xxh[2]=f2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3507 printf("problem\n");
3512 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3513 Float_t yup[160], ydown[160], zup[160], zdown[160];
3515 AliTPCpolyTrack ptrack1,ptrack2;
3518 for (Int_t i=i1;i<=i2;i++){
3519 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3521 if (cl->GetType()<0) continue;
3522 if (cl->GetType()>10) continue;
3525 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3527 if (ptrack1.GetN()>4.){
3528 ptrack1.UpdateParameters();
3530 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3532 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3541 dyup[i]=0.; //not enough points
3546 for (Int_t i=i2;i>=i1;i--){
3547 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3549 if (cl->GetType()<0) continue;
3550 if (cl->GetType()>10) continue;
3552 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3554 if (ptrack2.GetN()>4){
3555 ptrack2.UpdateParameters();
3557 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3559 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3567 dydown[i]=0.; //not enough points
3572 // find maximal difference of the derivation
3573 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3576 for (Int_t i=i1+10;i<i2-10;i++){
3577 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3578 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3580 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3581 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3582 if ( (ddy+ddz)> th){
3583 seed->fKinkPoint[0] = i;
3584 seed->fKinkPoint[1] = ddy;
3585 seed->fKinkPoint[2] = ddz;
3592 //write information to the debug tree
3593 TBranch * br = fTreeDebug->GetBranch("debug");
3594 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3595 arr->ExpandCreateFast(i2-i1);
3596 br->SetAddress(&arr);
3598 AliTPCclusterMI cldummy;
3600 AliTPCTrackPoint2 pdummy;
3601 pdummy.GetTPoint().fIsShared = 10;
3603 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3604 Double_t cs = TMath::Cos(alpha);
3605 Double_t sn = TMath::Sin(alpha);
3607 for (Int_t i=i1;i<i2;i++){
3608 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3610 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3612 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3615 Double_t x = GetXrow(i);
3616 trpoint->GetTPoint() = *point;
3617 trpoint->GetCPoint() = *cl0;
3618 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3619 trpoint->fID = seed->GetUniqueID();
3620 trpoint->fLab = seed->GetLabel();
3622 trpoint->fGX = cs *x + sn*point->GetY();
3623 trpoint->fGY = -sn *x + cs*point->GetY() ;
3624 trpoint->fGZ = point->GetZ();
3626 trpoint->fDY = y[i];
3627 trpoint->fDZ = z[i];
3629 trpoint->fDYU = dyup[i];
3630 trpoint->fDZU = dzup[i];
3632 trpoint->fDYD = dydown[i];
3633 trpoint->fDZD = dzdown[i];
3635 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3636 trpoint->fDDY = dydown[i]-dyup[i];
3637 trpoint->fDDZ = dzdown[i]-dzup[i];
3645 trpoint->GetCPoint()= cldummy;
3662 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3665 // reseed - refit - track
3668 // Int_t last = fSectors->GetNRows()-1;
3670 if (fSectors == fOuterSec){
3671 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3675 first = t->fFirstPoint;
3677 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3678 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3680 FollowProlongation(*t,first);
3690 //_____________________________________________________________________________
3691 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3692 //-----------------------------------------------------------------
3693 // This function reades track seeds.
3694 //-----------------------------------------------------------------
3695 TDirectory *savedir=gDirectory;
3697 TFile *in=(TFile*)inp;
3698 if (!in->IsOpen()) {
3699 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3704 TTree *seedTree=(TTree*)in->Get("Seeds");
3706 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3707 cerr<<"can't get a tree with track seeds !\n";
3710 AliTPCtrack *seed=new AliTPCtrack;
3711 seedTree->SetBranchAddress("tracks",&seed);
3713 if (fSeeds==0) fSeeds=new TObjArray(15000);
3715 Int_t n=(Int_t)seedTree->GetEntries();
3716 for (Int_t i=0; i<n; i++) {
3717 seedTree->GetEvent(i);
3718 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3727 //_____________________________________________________________________________
3728 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3729 //-----------------------------------------------------------------
3730 // This is a track finder.
3731 //-----------------------------------------------------------------
3732 TDirectory *savedir=gDirectory;
3735 if (!fInput) SetIO(); //set default IO using loaders
3737 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
3743 fSeeds = Tracking();
3746 printf("Time for tracking: \t");timer.Print();timer.Start();
3748 //activate again some tracks
3749 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3750 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3752 Int_t nc=t.GetNumberOfClusters();
3754 delete fSeeds->RemoveAt(i);
3757 if (pt->fRemoval==10) {
3758 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3759 pt->Desactivate(10); // make track again active
3761 pt->Desactivate(20);
3762 delete fSeeds->RemoveAt(i);
3766 RemoveDouble(fSeeds,0.2,0.6,11);
3767 //RemoveUsed(fSeeds,0.9,0.9,6);
3768 //RemoveUsed(fSeeds,0.8,0.8,6);
3769 //RemoveUsed(fSeeds,0.7,0.7,6);
3770 RemoveUsed(fSeeds,0.5,0.5,6);
3773 Int_t nseed=fSeeds->GetEntriesFast();
3775 for (Int_t i=0; i<nseed; i++) {
3776 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3778 Int_t nc=t.GetNumberOfClusters();
3780 delete fSeeds->RemoveAt(i);
3783 CookLabel(pt,0.1); //For comparison only
3784 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3785 if ((pt->IsActive() || (pt->fRemoval==10) )){
3786 cerr<<found++<<'\r';
3789 delete fSeeds->RemoveAt(i);
3794 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3796 //RemoveUsed(fSeeds,0.9,0.9,6);
3798 nseed=fSeeds->GetEntriesFast();
3800 for (Int_t i=0; i<nseed; i++) {
3801 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3803 Int_t nc=t.GetNumberOfClusters();
3805 delete fSeeds->RemoveAt(i);
3809 t.CookdEdx(0.02,0.6);
3810 // CheckKinkPoint(&t,0.05);
3811 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3812 if ((pt->IsActive() || (pt->fRemoval==10) )){
3813 cerr<<found++<<'\r';
3816 delete fSeeds->RemoveAt(i);
3820 SortTracks(fSeeds, 1);
3824 PrepareForBackProlongation(fSeeds,0.5);
3825 PropagateBack(fSeeds);
3826 printf("Time for back propagation: \t");timer.Print();timer.Start();
3830 PrepareForProlongation(fSeeds,1.);
3833 fSectors = fOuterSec;
3834 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3835 fSectors = fInnerSec;
3836 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3837 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
3838 // RemoveUsed(fSeeds,0.7,0.7,6);
3839 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
3841 nseed=fSeeds->GetEntriesFast();
3843 for (Int_t i=0; i<nseed; i++) {
3844 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3846 Int_t nc=t.GetNumberOfClusters();
3848 delete fSeeds->RemoveAt(i);
3851 t.CookdEdx(0.02,0.6);
3852 // CookLabel(pt,0.1); //For comparison only
3853 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3854 if ((pt->IsActive() || (pt->fRemoval==10) )){
3855 cerr<<found++<<'\r';
3858 delete fSeeds->RemoveAt(i);
3863 // fNTracks = found;
3864 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
3869 if (!fNewIO) fOutput->Write();
3871 AliRunLoader::GetDetectorLoader("TPC",AliConfig::fgkDefaultEventFolderName)->WriteTracks("OVERWRITE");
3874 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
3876 //if (seedtree) delete seedtree;
3877 // UnloadClusters();
3878 //printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
3883 void AliTPCtrackerMI::Tracking(TObjArray * arr)
3886 // tracking of the seeds
3889 fSectors = fOuterSec;
3890 ParallelTracking(arr,150,63);
3891 fSectors = fOuterSec;
3892 ParallelTracking(arr,63,0);
3895 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
3900 TObjArray * arr = new TObjArray;
3902 fSectors = fOuterSec;
3905 for (Int_t sec=0;sec<fkNOS;sec++){
3906 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
3907 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
3908 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
3911 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
3923 TObjArray * AliTPCtrackerMI::Tracking()
3929 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
3931 TObjArray * seeds = new TObjArray;
3940 Float_t fnumber = 3.0;
3941 Float_t fdensity = 3.0;
3946 for (Int_t delta = 0; delta<18; delta+=6){
3950 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
3951 SumTracks(seeds,arr);
3952 SignClusters(seeds,fnumber,fdensity);
3954 for (Int_t i=2;i<6;i+=2){
3955 // seed high pt tracks
3958 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
3959 SumTracks(seeds,arr);
3960 SignClusters(seeds,fnumber,fdensity);
3965 // RemoveUsed(seeds,0.9,0.9,1);
3966 // UnsignClusters();
3967 // SignClusters(seeds,fnumber,fdensity);
3971 for (Int_t delta = 20; delta<120; delta+=10){
3973 // seed high pt tracks
3977 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
3978 SumTracks(seeds,arr);
3979 SignClusters(seeds,fnumber,fdensity);
3984 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
3985 SumTracks(seeds,arr);
3986 SignClusters(seeds,fnumber,fdensity);
3997 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4001 // RemoveUsed(seeds,0.75,0.75,1);
4003 //SignClusters(seeds,fnumber,fdensity);
4012 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4013 SumTracks(seeds,arr);
4014 SignClusters(seeds,fnumber,fdensity);
4016 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4017 SumTracks(seeds,arr);
4018 SignClusters(seeds,fnumber,fdensity);
4020 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4021 SumTracks(seeds,arr);
4022 SignClusters(seeds,fnumber,fdensity);
4026 for (Int_t delta = 3; delta<30; delta+=5){
4032 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4033 SumTracks(seeds,arr);
4034 SignClusters(seeds,fnumber,fdensity);
4036 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4037 SumTracks(seeds,arr);
4038 SignClusters(seeds,fnumber,fdensity);
4050 for (Int_t delta = 30; delta<70; delta+=10){
4056 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4057 SumTracks(seeds,arr);
4058 SignClusters(seeds,fnumber,fdensity);
4060 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4061 SumTracks(seeds,arr);
4062 SignClusters(seeds,fnumber,fdensity);
4066 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4077 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2)
4080 //sum tracks to common container
4081 //remove suspicious tracks
4082 Int_t nseed = arr2->GetEntriesFast();
4083 for (Int_t i=0;i<nseed;i++){
4084 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4087 // NORMAL ACTIVE TRACK
4088 if (pt->IsActive()){
4089 arr1->AddLast(arr2->RemoveAt(i));
4092 //remove not usable tracks
4093 if (pt->fRemoval!=10){
4094 delete arr2->RemoveAt(i);
4097 // REMOVE VERY SHORT TRACKS
4098 if (pt->GetNumberOfClusters()<20){
4099 delete arr2->RemoveAt(i);
4102 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4103 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4104 arr1->AddLast(arr2->RemoveAt(i));
4106 delete arr2->RemoveAt(i);
4115 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4118 // try to track in parralel
4120 Int_t nseed=arr->GetEntriesFast();
4121 //prepare seeds for tracking
4122 for (Int_t i=0; i<nseed; i++) {
4123 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4125 if (!t.IsActive()) continue;
4126 // follow prolongation to the first layer
4127 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4128 FollowProlongation(t, rfirst+1);
4133 for (Int_t nr=rfirst; nr>=rlast; nr--){
4134 // make indexes with the cluster tracks for given
4136 // find nearest cluster
4137 for (Int_t i=0; i<nseed; i++) {
4138 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4140 if (!pt->IsActive()) continue;
4141 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4142 if (pt->fRelativeSector>17) {
4145 UpdateClusters(t,nr);
4147 // prolonagate to the nearest cluster - if founded
4148 for (Int_t i=0; i<nseed; i++) {
4149 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4151 if (!pt->IsActive()) continue;
4152 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4153 if (pt->fRelativeSector>17) {
4156 FollowToNextCluster(*pt,nr);
4161 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac)
4165 // if we use TPC track itself we have to "update" covariance
4167 Int_t nseed= arr->GetEntriesFast();
4168 for (Int_t i=0;i<nseed;i++){
4169 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4173 //rotate to current local system at first accepted point
4174 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4175 Int_t sec = (index&0xff000000)>>24;
4177 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4178 if (angle1>TMath::Pi())
4179 angle1-=2.*TMath::Pi();
4180 Float_t angle2 = pt->GetAlpha();
4182 if (TMath::Abs(angle1-angle2)>0.001){
4183 pt->Rotate(angle1-angle2);
4184 //angle2 = pt->GetAlpha();
4185 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4186 //if (pt->GetAlpha()<0)
4187 // pt->fRelativeSector+=18;
4188 //sec = pt->fRelativeSector;
4197 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac)
4201 // if we use TPC track itself we have to "update" covariance
4203 Int_t nseed= arr->GetEntriesFast();
4204 for (Int_t i=0;i<nseed;i++){
4205 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4208 pt->fFirstPoint = pt->fLastPoint;
4216 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4219 // make back propagation
4221 Int_t nseed= arr->GetEntriesFast();
4222 for (Int_t i=0;i<nseed;i++){
4223 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4225 AliTPCseed *pt2 = new AliTPCseed(*pt);
4226 fSectors = fInnerSec;
4227 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4228 fSectors = fOuterSec;
4229 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4230 fSectors = fOuterSec;
4231 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4232 printf("\n%d",pt->GetLabel());
4233 fSectors = fInnerSec;
4234 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4235 fSectors = fOuterSec;
4236 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4237 fSectors = fOuterSec;
4245 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4248 // make forward propagation
4250 Int_t nseed= arr->GetEntriesFast();
4251 for (Int_t i=0;i<nseed;i++){
4252 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4254 AliTPCseed *pt2 = new AliTPCseed(*pt);
4255 fSectors = fOuterSec;
4256 FollowProlongation(*pt,0);
4257 fSectors = fOuterSec;
4258 FollowProlongation(*pt,0);
4259 fSectors = fInnerSec;
4260 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4261 printf("\n%d",pt->GetLabel());
4262 fSectors = fOuterSec;
4263 FollowProlongation(*pt2,0);
4264 fSectors = fOuterSec;
4265 FollowProlongation(*pt2,0);
4266 fSectors = fOuterSec;
4274 Int_t AliTPCtrackerMI::PropagateForward()
4276 fSectors = fOuterSec;
4277 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4278 fSectors = fInnerSec;
4279 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4289 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4292 // make back propagation, in between row0 and row1
4296 fSectors = fInnerSec;
4299 if (row1<fSectors->GetNRows())
4302 r1 = fSectors->GetNRows()-1;
4304 if (row0<fSectors->GetNRows()&& r1>0 )
4305 FollowBackProlongation(*pt,r1);
4306 if (row1<=fSectors->GetNRows())
4309 r1 = row1 - fSectors->GetNRows();
4310 if (r1<=0) return 0;
4311 if (r1>=fOuterSec->GetNRows()) return 0;
4312 fSectors = fOuterSec;
4313 return FollowBackProlongation(*pt,r1);
4321 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4325 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4326 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4327 Float_t padlength = GetPadPitchLength(row);
4329 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4330 Float_t angulary = seed->GetSnp();
4331 angulary = angulary*angulary/(1-angulary*angulary);
4332 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4334 Float_t sresz = fParam->GetZSigma();
4335 Float_t angularz = seed->GetTgl();
4336 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4338 Float_t wy = GetSigmaY(seed);
4339 Float_t wz = GetSigmaZ(seed);
4342 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4343 printf("problem\n");
4349 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4353 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4354 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4355 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4356 Float_t angular = seed->GetSnp();
4357 angular = angular*angular/(1-angular*angular);
4358 // angular*=angular;
4359 //angular = TMath::Sqrt(angular/(1-angular));
4360 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4363 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4367 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4368 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4369 Float_t sres = fParam->GetZSigma();
4370 Float_t angular = seed->GetTgl();
4371 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4378 //__________________________________________________________________________
4379 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4380 //--------------------------------------------------------------------
4381 //This function "cooks" a track label. If label<0, this track is fake.
4382 //--------------------------------------------------------------------
4383 Int_t noc=t->GetNumberOfClusters();
4385 printf("\nnot founded prolongation\n\n\n");
4391 AliTPCclusterMI *clusters[160];
4393 for (Int_t i=0;i<160;i++) {
4400 for (i=0; i<160 && current<noc; i++) {
4402 Int_t index=t->GetClusterIndex2(i);
4403 if (index<=0) continue;
4404 if (index&0x8000) continue;
4406 //clusters[current]=GetClusterMI(index);
4407 if (t->fClusterPointer[i]){
4408 clusters[current]=t->fClusterPointer[i];
4414 Int_t lab=123456789;
4415 for (i=0; i<noc; i++) {
4416 AliTPCclusterMI *c=clusters[i];
4418 lab=TMath::Abs(c->GetLabel(0));
4420 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4426 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4428 for (i=0; i<noc; i++) {
4429 AliTPCclusterMI *c=clusters[i];
4431 if (TMath::Abs(c->GetLabel(1)) == lab ||
4432 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4435 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4438 Int_t tail=Int_t(0.10*noc);
4441 for (i=1; i<=160&&ind<tail; i++) {
4442 // AliTPCclusterMI *c=clusters[noc-i];
4443 AliTPCclusterMI *c=clusters[i];
4445 if (lab == TMath::Abs(c->GetLabel(0)) ||
4446 lab == TMath::Abs(c->GetLabel(1)) ||
4447 lab == TMath::Abs(c->GetLabel(2))) max++;
4450 if (max < Int_t(0.5*tail)) lab=-lab;
4457 //delete[] clusters;
4460 //_________________________________________________________________________
4461 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4462 //-----------------------------------------------------------------------
4463 // Setup inner sector
4464 //-----------------------------------------------------------------------
4466 fAlpha=par->GetInnerAngle();
4467 fAlphaShift=par->GetInnerAngleShift();
4468 fPadPitchWidth=par->GetInnerPadPitchWidth();
4469 fPadPitchLength=par->GetInnerPadPitchLength();
4470 fN=par->GetNRowLow();
4471 fRow=new AliTPCRow[fN];
4472 for (Int_t i=0; i<fN; i++) {
4473 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4474 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4477 fAlpha=par->GetOuterAngle();
4478 fAlphaShift=par->GetOuterAngleShift();
4479 fPadPitchWidth = par->GetOuterPadPitchWidth();
4480 fPadPitchLength = par->GetOuter1PadPitchLength();
4481 f1PadPitchLength = par->GetOuter1PadPitchLength();
4482 f2PadPitchLength = par->GetOuter2PadPitchLength();
4484 fN=par->GetNRowUp();
4485 fRow=new AliTPCRow[fN];
4486 for (Int_t i=0; i<fN; i++) {
4487 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4488 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4494 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4500 //_________________________________________________________________________
4502 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4503 //-----------------------------------------------------------------------
4504 // Insert a cluster into this pad row in accordence with its y-coordinate
4505 //-----------------------------------------------------------------------
4506 if (fN==kMaxClusterPerRow) {
4507 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4509 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4510 Int_t i=Find(c->GetZ());
4511 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4512 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4513 fIndex[i]=index; fClusters[i]=c; fN++;
4517 //___________________________________________________________________
4518 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4519 //-----------------------------------------------------------------------
4520 // Return the index of the nearest cluster
4521 //-----------------------------------------------------------------------
4522 if (fN==0) return 0;
4523 if (z <= fClusters[0]->GetZ()) return 0;
4524 if (z > fClusters[fN-1]->GetZ()) return fN;
4525 Int_t b=0, e=fN-1, m=(b+e)/2;
4526 for (; b<e; m=(b+e)/2) {
4527 if (z > fClusters[m]->GetZ()) b=m+1;
4535 //___________________________________________________________________
4536 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4537 //-----------------------------------------------------------------------
4538 // Return the index of the nearest cluster in z y
4539 //-----------------------------------------------------------------------
4540 Float_t maxdistance = roady*roady + roadz*roadz;
4542 AliTPCclusterMI *cl =0;
4543 for (Int_t i=Find(z-roadz); i<fN; i++) {
4544 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4545 if (c->GetZ() > z+roadz) break;
4546 if ( (c->GetY()-y) > roady ) continue;
4547 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4548 if (maxdistance>distance) {
4549 maxdistance = distance;
4556 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4558 //-----------------------------------------------------------------------
4559 // Return the index of the nearest cluster in z y
4560 //-----------------------------------------------------------------------
4561 Float_t maxdistance = roady*roady + roadz*roadz;
4562 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4563 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4565 AliTPCclusterMI *cl =0;
4566 //FindNearest3(y,z,roady,roadz,index);
4567 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4568 for (Int_t i=iz1; i<iz2; i++) {
4569 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4570 if (c->GetZ() > z+roadz) break;
4571 if ( c->GetY()-y > roady ) continue;
4572 if ( y-c->GetY() > roady ) continue;
4573 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4574 if (maxdistance>distance) {
4575 maxdistance = distance;
4578 //roady = TMath::Sqrt(maxdistance);
4586 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4588 //-----------------------------------------------------------------------
4589 // Return the index of the nearest cluster in z y
4590 //-----------------------------------------------------------------------
4591 Float_t maxdistance = roady*roady + roadz*roadz;
4592 // Int_t iz = Int_t(z+255.);
4593 AliTPCclusterMI *cl =0;
4594 for (Int_t i=Find(z-roadz); i<fN; i++) {
4595 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4596 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4597 if (c->GetZ() > z+roadz) break;
4598 if ( c->GetY()-y > roady ) continue;
4599 if ( y-c->GetY() > roady ) continue;
4600 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4601 if (maxdistance>distance) {
4602 maxdistance = distance;
4605 //roady = TMath::Sqrt(maxdistance);
4614 AliTPCseed::AliTPCseed():AliTPCtrack(){
4618 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4619 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4635 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4642 for (Int_t i=0;i<160;i++) {
4643 fClusterPointer[i] = 0;
4644 Int_t index = t.GetClusterIndex(i);
4646 SetClusterIndex2(i,index);
4649 SetClusterIndex2(i,-3);
4659 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4661 for (Int_t i=0;i<160;i++) {
4662 fClusterPointer[i] = 0;
4663 Int_t index = t.GetClusterIndex(i);
4664 SetClusterIndex2(i,index);
4681 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4682 Double_t xr, Double_t alpha):
4683 AliTPCtrack(index, xx, cc, xr, alpha) {
4687 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4688 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4697 // fHelixIn = new TClonesArray("AliHelix",0);
4698 //fHelixOut = new TClonesArray("AliHelix",0);
4705 AliTPCseed::~AliTPCseed(){
4706 if (fPoints) delete fPoints;
4708 if (fEPoints) delete fEPoints;
4713 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4717 return &fTrackPoints[i];
4720 void AliTPCseed::RebuildSeed()
4723 // rebuild seed to be ready for storing
4724 AliTPCclusterMI cldummy;
4726 AliTPCTrackPoint pdummy;
4727 pdummy.GetTPoint().fIsShared = 10;
4728 for (Int_t i=0;i<160;i++){
4729 AliTPCclusterMI * cl0 = fClusterPointer[i];
4730 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
4732 trpoint->GetTPoint() = *(GetTrackPoint(i));
4733 trpoint->GetCPoint() = *cl0;
4734 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4738 trpoint->GetCPoint()= cldummy;
4746 Double_t AliTPCseed::GetDensityFirst(Int_t n)
4750 // return cluster for n rows bellow first point
4751 Int_t nfoundable = 1;
4753 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
4754 Int_t index = GetClusterIndex2(i);
4755 if (index!=-1) nfoundable++;
4756 if (index>0) nfound++;
4758 if (nfoundable<n) return 0;
4759 return Double_t(nfound)/Double_t(nfoundable);
4764 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
4766 // get cluster stat. on given region
4771 for (Int_t i=first;i<last; i++){
4772 Int_t index = GetClusterIndex2(i);
4773 if (index!=-1) foundable++;
4774 if (fClusterPointer[i]) {
4780 if (fClusterPointer[i]->IsUsed(10)) {
4784 if (!plus2) continue; //take also neighborhoud
4786 if ( (i>0) && fClusterPointer[i-1]){
4787 if (fClusterPointer[i-1]->IsUsed(10)) {
4792 if ( fClusterPointer[i+1]){
4793 if (fClusterPointer[i+1]->IsUsed(10)) {
4801 printf("problem\n");
4805 //_____________________________________________________________________________
4806 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
4807 //-----------------------------------------------------------------
4808 // This funtion calculates dE/dX within the "low" and "up" cuts.
4809 //-----------------------------------------------------------------
4812 Float_t angular[200];
4813 Float_t weight[200];
4816 // TClonesArray & arr = *fPoints;
4817 Float_t meanlog = 100.;
4819 Float_t mean[4] = {0,0,0,0};
4820 Float_t sigma[4] = {1000,1000,1000,1000};
4821 Int_t nc[4] = {0,0,0,0};
4822 Float_t norm[4] = {1000,1000,1000,1000};
4827 for (Int_t of =0; of<4; of++){
4828 for (Int_t i=of+i1;i<i2;i+=4)
4830 Int_t index = fIndex[i];
4831 if (index<0||index&0x8000) continue;
4833 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
4834 AliTPCTrackerPoint * point = GetTrackPoint(i);
4835 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
4836 //AliTPCTrackerPoint * pointp = 0;
4837 //if (i<159) pointp = GetTrackPoint(i+1);
4839 if (point==0) continue;
4840 AliTPCclusterMI * cl = fClusterPointer[i];
4841 if (cl==0) continue;
4842 if (onlyused && (!cl->IsUsed(10))) continue;
4843 if (cl->IsUsed(11)) {
4847 Int_t type = cl->GetType();
4848 //if (point->fIsShared){
4853 // if (pointm->fIsShared) continue;
4855 // if (pointp->fIsShared) continue;
4857 if (type<0) continue;
4858 //if (type>10) continue;
4859 //if (point->GetErrY()==0) continue;
4860 //if (point->GetErrZ()==0) continue;
4862 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
4863 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
4864 //if ((ddy*ddy+ddz*ddz)>10) continue;
4867 // if (point->GetCPoint().GetMax()<5) continue;
4868 if (cl->GetMax()<5) continue;
4869 Float_t angley = point->GetAngleY();
4870 Float_t anglez = point->GetAngleZ();
4872 Float_t rsigmay2 = point->GetSigmaY();
4873 Float_t rsigmaz2 = point->GetSigmaZ();
4877 rsigmay += pointm->GetTPoint().GetSigmaY();
4878 rsigmaz += pointm->GetTPoint().GetSigmaZ();
4882 rsigmay += pointp->GetTPoint().GetSigmaY();
4883 rsigmaz += pointp->GetTPoint().GetSigmaZ();
4890 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
4892 Float_t ampc = 0; // normalization to the number of electrons
4894 // ampc = 1.*point->GetCPoint().GetMax();
4895 ampc = 1.*cl->GetMax();
4896 //ampc = 1.*point->GetCPoint().GetQ();
4897 // AliTPCClusterPoint & p = point->GetCPoint();
4898 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
4899 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4901 // TMath::Abs( Int_t(iz) - iz + 0.5);
4902 //ampc *= 1.15*(1-0.3*dy);
4903 //ampc *= 1.15*(1-0.3*dz);
4904 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
4908 //ampc = 1.0*point->GetCPoint().GetMax();
4909 ampc = 1.0*cl->GetMax();
4910 //ampc = 1.0*point->GetCPoint().GetQ();
4911 //AliTPCClusterPoint & p = point->GetCPoint();
4912 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
4913 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4915 // TMath::Abs( Int_t(iz) - iz + 0.5);
4917 //ampc *= 1.15*(1-0.3*dy);
4918 //ampc *= 1.15*(1-0.3*dz);
4919 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
4923 ampc *= 2.0; // put mean value to channel 50
4924 //ampc *= 0.58; // put mean value to channel 50
4926 // if (type>0) w = 1./(type/2.-0.5);
4927 // Float_t z = TMath::Abs(cl->GetZ());
4930 //ampc /= (1+0.0008*z);
4934 //ampc /= (1+0.0008*z);
4936 //ampc /= (1+0.0008*z);
4939 if (type<0) { //amp at the border - lower weight
4944 if (rsigma>1.5) ampc/=1.3; // if big backround
4946 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
4951 TMath::Sort(nc[of],amp,index,kFALSE);
4955 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
4957 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
4958 Float_t ampl = amp[index[i]]/angular[index[i]];
4959 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
4961 sumw += weight[index[i]];
4962 sumamp += weight[index[i]]*ampl;
4963 sumamp2 += weight[index[i]]*ampl*ampl;
4964 norm[of] += angular[index[i]]*weight[index[i]];
4971 mean[of] = sumamp/sumw;
4972 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
4974 sigma[of] = TMath::Sqrt(sigma[of]);
4978 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
4979 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
4980 //mean *=(1-0.1*(norm-1.));
4987 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
4988 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
4991 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
4992 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
4996 for (Int_t i =0;i<4;i++){
4997 if (nc[i]>2&&nc[i]<1000){
4998 dedx += mean[i] *nc[i];
4999 fSdEdx += sigma[i]*(nc[i]-2);
5000 fMAngular += norm[i] *nc[i];
5005 fSDEDX[i] = sigma[i];
5018 // Float_t dedx1 =dedx;
5021 for (Int_t i =0;i<4;i++){
5022 if (nc[i]>2&&nc[i]<1000){
5023 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5024 dedx += mean[i] *nc[i];
5039 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5042 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5043 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5044 SetMass(0.93827); return;
5048 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5049 SetMass(0.93827); return;
5052 SetMass(0.13957); return;
5062 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5063 //-----------------------------------------------------------------
5064 // This funtion calculates dE/dX within the "low" and "up" cuts.
5065 //-----------------------------------------------------------------
5068 Float_t angular[200];
5069 Float_t weight[200];
5071 Bool_t inlimit[200];
5072 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5073 for (Int_t i=0;i<200;i++) amp[i]=10000;
5074 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5078 Float_t meanlog = 100.;
5079 Int_t indexde[4]={0,64,128,160};
5086 Float_t mean[4] = {0,0,0,0};
5087 Float_t sigma[4] = {1000,1000,1000,1000};
5088 Int_t nc[4] = {0,0,0,0};
5089 Float_t norm[4] = {1000,1000,1000,1000};
5094 // for (Int_t of =0; of<3; of++){
5095 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5096 for (Int_t i =0; i<160;i++)
5098 AliTPCTrackPoint * point = GetTrackPoint(i);
5099 if (point==0) continue;
5100 if (point->fIsShared){
5104 Int_t type = point->GetCPoint().GetType();
5105 if (type<0) continue;
5106 if (point->GetCPoint().GetMax()<5) continue;
5107 Float_t angley = point->GetTPoint().GetAngleY();
5108 Float_t anglez = point->GetTPoint().GetAngleZ();
5109 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5110 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5111 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5113 Float_t ampc = 0; // normalization to the number of electrons
5115 ampc = point->GetCPoint().GetMax();
5118 ampc = point->GetCPoint().GetMax();
5120 ampc *= 2.0; // put mean value to channel 50
5121 // ampc *= 0.565; // put mean value to channel 50
5124 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5131 if (type<0) { //amp at the border - lower weight
5134 if (rsigma>1.5) ampc/=1.3; // if big backround
5135 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5136 amp[i] = ampc/angular[i];
5141 TMath::Sort(159,amp,index,kFALSE);
5142 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5143 inlimit[index[i]] = kTRUE; // take all clusters
5146 // meanlog = amp[index[Int_t(anc*0.3)]];
5148 for (Int_t of =0; of<3; of++){
5152 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5154 if (inlimit[i]==kFALSE) continue;
5155 Float_t ampl = amp[i];
5157 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5160 sumamp += weight[i]*ampl;
5161 sumamp2 += weight[i]*ampl*ampl;
5162 norm[of] += angular[i]*weight[i];
5170 mean[of] = sumamp/sumw;
5171 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5173 sigma[of] = TMath::Sqrt(sigma[of]);
5176 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5186 Float_t www[3] = {12.,14.,17.};
5187 //Float_t www[3] = {1.,1.,1.};
5189 for (Int_t i =0;i<3;i++){
5190 if (nc[i]>2&&nc[i]<1000){
5191 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5192 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5193 fMAngular += norm[i] *nc[i];
5194 norm2 += nc[i]*www[i]/sigma[i];
5195 norm3 += (nc[i]-2)*www[i]/sigma[i];
5198 fSDEDX[i] = sigma[i];
5211 // Float_t dedx1 =dedx;
5215 for (Int_t i =0;i<3;i++){
5216 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5217 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5218 dedx += mean[i] *(nc[i])/(sigma[i]);
5219 norm4 += (nc[i])/(sigma[i]);
5223 if (norm4>0) dedx /= norm4;