1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker
23 //-------------------------------------------------------
28 #include "Riostream.h"
29 #include <TClonesArray.h>
31 #include <TObjArray.h>
35 #include "AliComplexCluster.h"
37 #include "AliESDkink.h"
39 #include "AliRunLoader.h"
40 #include "AliTPCClustersRow.h"
41 #include "AliTPCParam.h"
42 #include "AliTPCReconstructor.h"
43 #include "AliTPCclusterMI.h"
44 #include "AliTPCpolyTrack.h"
45 #include "AliTPCreco.h"
46 #include "AliTPCseed.h"
47 #include "AliTPCtrackerMI.h"
48 #include "TStopwatch.h"
49 #include "AliTPCReconstructor.h"
50 #include "AliESDkink.h"
52 #include "TTreeStream.h"
53 #include "AliAlignObj.h"
54 #include "AliTrackPointArray.h"
58 ClassImp(AliTPCtrackerMI)
61 class AliTPCFastMath {
64 static Double_t FastAsin(Double_t x);
66 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
69 Double_t AliTPCFastMath::fgFastAsin[20000];
70 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
72 AliTPCFastMath::AliTPCFastMath(){
74 // initialized lookup table;
75 for (Int_t i=0;i<10000;i++){
76 fgFastAsin[2*i] = TMath::ASin(i/10000.);
77 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
81 Double_t AliTPCFastMath::FastAsin(Double_t x){
83 // return asin using lookup table
85 Int_t index = int(x*10000);
86 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
89 Int_t index = int(x*10000);
90 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
96 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
98 //update track information using current cluster - track->fCurrentCluster
101 AliTPCclusterMI* c =track->fCurrentCluster;
102 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
104 UInt_t i = track->fCurrentClusterIndex1;
106 Int_t sec=(i&0xff000000)>>24;
107 //Int_t row = (i&0x00ff0000)>>16;
108 track->fRow=(i&0x00ff0000)>>16;
109 track->fSector = sec;
110 // Int_t index = i&0xFFFF;
111 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
112 track->SetClusterIndex2(track->fRow, i);
113 //track->fFirstPoint = row;
114 //if ( track->fLastPoint<row) track->fLastPoint =row;
115 // if (track->fRow<0 || track->fRow>160) {
116 // printf("problem\n");
118 if (track->fFirstPoint>track->fRow)
119 track->fFirstPoint = track->fRow;
120 if (track->fLastPoint<track->fRow)
121 track->fLastPoint = track->fRow;
124 track->fClusterPointer[track->fRow] = c;
127 Double_t angle2 = track->GetSnp()*track->GetSnp();
129 //SET NEW Track Point
131 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
133 angle2 = TMath::Sqrt(angle2/(1-angle2));
134 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
136 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
137 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
138 point.SetErrY(sqrt(track->fErrorY2));
139 point.SetErrZ(sqrt(track->fErrorZ2));
141 point.SetX(track->GetX());
142 point.SetY(track->GetY());
143 point.SetZ(track->GetZ());
144 point.SetAngleY(angle2);
145 point.SetAngleZ(track->GetTgl());
146 if (point.fIsShared){
147 track->fErrorY2 *= 4;
148 track->fErrorZ2 *= 4;
152 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
154 track->fErrorY2 *= 1.3;
155 track->fErrorY2 += 0.01;
156 track->fErrorZ2 *= 1.3;
157 track->fErrorZ2 += 0.005;
159 if (accept>0) return 0;
160 if (track->GetNumberOfClusters()%20==0){
161 // if (track->fHelixIn){
162 // TClonesArray & larr = *(track->fHelixIn);
163 // Int_t ihelix = larr.GetEntriesFast();
164 // new(larr[ihelix]) AliHelix(*track) ;
167 track->fNoCluster =0;
168 return track->Update(c,chi2,i);
173 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
174 Float_t cory, Float_t corz)
177 // decide according desired precision to accept given
178 // cluster for tracking
179 Double_t sy2=ErrY2(seed,cluster)*cory;
180 Double_t sz2=ErrZ2(seed,cluster)*corz;
181 //sy2=ErrY2(seed,cluster)*cory;
182 //sz2=ErrZ2(seed,cluster)*cory;
184 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
185 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
187 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
188 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
189 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
190 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
192 Double_t rdistance2 = rdistancey2+rdistancez2;
195 if (rdistance2>16) return 3;
198 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
199 return 2; //suspisiouce - will be changed
201 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
202 // strict cut on overlaped cluster
203 return 2; //suspisiouce - will be changed
205 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
206 && cluster->GetType()<0){
216 //_____________________________________________________________________________
217 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
218 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
220 //---------------------------------------------------------------------
221 // The main TPC tracker constructor
222 //---------------------------------------------------------------------
223 fInnerSec=new AliTPCSector[fkNIS];
224 fOuterSec=new AliTPCSector[fkNOS];
227 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
228 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
235 Int_t nrowlow = par->GetNRowLow();
236 Int_t nrowup = par->GetNRowUp();
239 for (Int_t i=0;i<nrowlow;i++){
240 fXRow[i] = par->GetPadRowRadiiLow(i);
241 fPadLength[i]= par->GetPadPitchLength(0,i);
242 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
246 for (Int_t i=0;i<nrowup;i++){
247 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
248 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
249 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
260 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
262 //________________________________________________________________________
263 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
268 //------------------------------------
269 // dummy copy constructor
270 //------------------------------------------------------------------
272 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
273 //------------------------------
275 //--------------------------------------------------------------
278 //_____________________________________________________________________________
279 AliTPCtrackerMI::~AliTPCtrackerMI() {
280 //------------------------------------------------------------------
281 // TPC tracker destructor
282 //------------------------------------------------------------------
289 if (fDebugStreamer) delete fDebugStreamer;
292 void AliTPCtrackerMI::SetIO()
296 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
298 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
300 AliTPCtrack *iotrack= new AliTPCtrack;
301 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
307 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
323 AliTPCtrack *iotrack= new AliTPCtrack;
324 // iotrack->fHelixIn = new TClonesArray("AliHelix");
325 //iotrack->fHelixOut = new TClonesArray("AliHelix");
326 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
329 if (output && (fDebug&2)){
330 //write the full seed information if specified in debug mode
332 fSeedTree = new TTree("Seeds","Seeds");
333 AliTPCseed * vseed = new AliTPCseed;
335 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
336 arrtr->ExpandCreateFast(160);
337 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
339 vseed->fPoints = arrtr;
340 vseed->fEPoints = arre;
341 // vseed->fClusterPoints = arrcl;
342 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
345 fTreeDebug = new TTree("trackDebug","trackDebug");
346 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
347 fTreeDebug->Branch("debug",&arrd,32000,99);
355 void AliTPCtrackerMI::FillESD(TObjArray* arr)
359 //fill esds using updated tracks
361 // write tracks to the event
362 // store index of the track
363 Int_t nseed=arr->GetEntriesFast();
364 //FindKinks(arr,fEvent);
365 for (Int_t i=0; i<nseed; i++) {
366 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
369 // pt->PropagateTo(fParam->GetInnerRadiusLow());
370 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
371 pt->PropagateTo(fParam->GetInnerRadiusLow());
374 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
376 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
377 iotrack.SetTPCPoints(pt->GetPoints());
378 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
379 iotrack.SetV0Indexes(pt->GetV0Indexes());
380 // iotrack.SetTPCpid(pt->fTPCr);
381 //iotrack.SetTPCindex(i);
382 fEvent->AddTrack(&iotrack);
386 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
388 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
389 iotrack.SetTPCPoints(pt->GetPoints());
390 //iotrack.SetTPCindex(i);
391 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
392 iotrack.SetV0Indexes(pt->GetV0Indexes());
393 // iotrack.SetTPCpid(pt->fTPCr);
394 fEvent->AddTrack(&iotrack);
398 // short tracks - maybe decays
400 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
401 Int_t found,foundable,shared;
402 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
403 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
405 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
406 //iotrack.SetTPCindex(i);
407 iotrack.SetTPCPoints(pt->GetPoints());
408 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
409 iotrack.SetV0Indexes(pt->GetV0Indexes());
410 //iotrack.SetTPCpid(pt->fTPCr);
411 fEvent->AddTrack(&iotrack);
416 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
417 Int_t found,foundable,shared;
418 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
419 if (found<20) continue;
420 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
423 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
424 iotrack.SetTPCPoints(pt->GetPoints());
425 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
426 iotrack.SetV0Indexes(pt->GetV0Indexes());
427 //iotrack.SetTPCpid(pt->fTPCr);
428 //iotrack.SetTPCindex(i);
429 fEvent->AddTrack(&iotrack);
432 // short tracks - secondaties
434 if ( (pt->GetNumberOfClusters()>30) ) {
435 Int_t found,foundable,shared;
436 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
437 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
439 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
440 iotrack.SetTPCPoints(pt->GetPoints());
441 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
442 iotrack.SetV0Indexes(pt->GetV0Indexes());
443 //iotrack.SetTPCpid(pt->fTPCr);
444 //iotrack.SetTPCindex(i);
445 fEvent->AddTrack(&iotrack);
450 if ( (pt->GetNumberOfClusters()>15)) {
451 Int_t found,foundable,shared;
452 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
453 if (found<15) continue;
454 if (foundable<=0) continue;
455 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
456 if (float(found)/float(foundable)<0.8) continue;
459 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
460 iotrack.SetTPCPoints(pt->GetPoints());
461 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
462 iotrack.SetV0Indexes(pt->GetV0Indexes());
463 // iotrack.SetTPCpid(pt->fTPCr);
464 //iotrack.SetTPCindex(i);
465 fEvent->AddTrack(&iotrack);
470 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
473 void AliTPCtrackerMI::WriteTracks(TTree * tree)
476 // write tracks from seed array to selected tree
480 AliTPCtrack *iotrack= new AliTPCtrack;
481 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
486 void AliTPCtrackerMI::WriteTracks()
489 // write tracks to the given output tree -
490 // output specified with SetIO routine
497 AliTPCtrack *iotrack= 0;
498 Int_t nseed=fSeeds->GetEntriesFast();
499 //for (Int_t i=0; i<nseed; i++) {
500 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
501 // if (iotrack) break;
503 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
504 TBranch * br = fOutput->GetBranch("tracks");
505 br->SetAddress(&iotrack);
507 for (Int_t i=0; i<nseed; i++) {
508 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
510 AliTPCtrack * track = new AliTPCtrack(*pt);
513 // br->SetAddress(&iotrack);
518 //fOutput->GetDirectory()->cd();
524 //write the full seed information if specified in debug mode
526 AliTPCseed * vseed = new AliTPCseed;
528 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
529 arrtr->ExpandCreateFast(160);
530 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
531 //arrcl->ExpandCreateFast(160);
532 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
534 vseed->fPoints = arrtr;
535 vseed->fEPoints = arre;
536 // vseed->fClusterPoints = arrcl;
537 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
538 TBranch * brseed = fSeedTree->GetBranch("seeds");
540 Int_t nseed=fSeeds->GetEntriesFast();
542 for (Int_t i=0; i<nseed; i++) {
543 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
546 // pt->fClusterPoints = arrcl;
550 brseed->SetAddress(&vseed);
554 // pt->fClusterPoints = 0;
557 if (fTreeDebug) fTreeDebug->Write();
565 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
568 //seed->SetErrorY2(0.1);
570 //calculate look-up table at the beginning
571 static Bool_t ginit = kFALSE;
572 static Float_t gnoise1,gnoise2,gnoise3;
573 static Float_t ggg1[10000];
574 static Float_t ggg2[10000];
575 static Float_t ggg3[10000];
576 static Float_t glandau1[10000];
577 static Float_t glandau2[10000];
578 static Float_t glandau3[10000];
580 static Float_t gcor01[500];
581 static Float_t gcor02[500];
582 static Float_t gcorp[500];
587 for (Int_t i=1;i<500;i++){
588 Float_t rsigma = float(i)/100.;
589 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
590 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
591 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
595 for (Int_t i=3;i<10000;i++){
599 Float_t amp = float(i);
600 Float_t padlength =0.75;
601 gnoise1 = 0.0004/padlength;
602 Float_t nel = 0.268*amp;
603 Float_t nprim = 0.155*amp;
604 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
605 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
606 if (glandau1[i]>1) glandau1[i]=1;
607 glandau1[i]*=padlength*padlength/12.;
611 gnoise2 = 0.0004/padlength;
614 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
615 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
616 if (glandau2[i]>1) glandau2[i]=1;
617 glandau2[i]*=padlength*padlength/12.;
622 gnoise3 = 0.0004/padlength;
625 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
626 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
627 if (glandau3[i]>1) glandau3[i]=1;
628 glandau3[i]*=padlength*padlength/12.;
636 Int_t amp = int(TMath::Abs(cl->GetQ()));
638 seed->SetErrorY2(1.);
642 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
643 Int_t ctype = cl->GetType();
644 Float_t padlength= GetPadPitchLength(seed->fRow);
645 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
646 angle2 = angle2/(1-angle2);
649 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
652 if (fSectors==fInnerSec){
654 res = ggg1[amp]*z+glandau1[amp]*angle2;
655 if (ctype==0) res *= gcor01[rsigmay];
658 res*= gcorp[rsigmay];
664 res = ggg2[amp]*z+glandau2[amp]*angle2;
665 if (ctype==0) res *= gcor02[rsigmay];
668 res*= gcorp[rsigmay];
673 res = ggg3[amp]*z+glandau3[amp]*angle2;
674 if (ctype==0) res *= gcor02[rsigmay];
677 res*= gcorp[rsigmay];
684 res*=2.4; // overestimate error 2 times
691 seed->SetErrorY2(res);
699 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
702 //seed->SetErrorY2(0.1);
704 //calculate look-up table at the beginning
705 static Bool_t ginit = kFALSE;
706 static Float_t gnoise1,gnoise2,gnoise3;
707 static Float_t ggg1[10000];
708 static Float_t ggg2[10000];
709 static Float_t ggg3[10000];
710 static Float_t glandau1[10000];
711 static Float_t glandau2[10000];
712 static Float_t glandau3[10000];
714 static Float_t gcor01[1000];
715 static Float_t gcor02[1000];
716 static Float_t gcorp[1000];
721 for (Int_t i=1;i<1000;i++){
722 Float_t rsigma = float(i)/100.;
723 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
724 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
725 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
729 for (Int_t i=3;i<10000;i++){
733 Float_t amp = float(i);
734 Float_t padlength =0.75;
735 gnoise1 = 0.0004/padlength;
736 Float_t nel = 0.268*amp;
737 Float_t nprim = 0.155*amp;
738 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
739 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
740 if (glandau1[i]>1) glandau1[i]=1;
741 glandau1[i]*=padlength*padlength/12.;
745 gnoise2 = 0.0004/padlength;
748 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
749 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
750 if (glandau2[i]>1) glandau2[i]=1;
751 glandau2[i]*=padlength*padlength/12.;
756 gnoise3 = 0.0004/padlength;
759 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
760 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
761 if (glandau3[i]>1) glandau3[i]=1;
762 glandau3[i]*=padlength*padlength/12.;
770 Int_t amp = int(TMath::Abs(cl->GetQ()));
772 seed->SetErrorY2(1.);
776 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
777 Int_t ctype = cl->GetType();
778 Float_t padlength= GetPadPitchLength(seed->fRow);
780 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
781 // if (angle2<0.6) angle2 = 0.6;
782 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
785 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
788 if (fSectors==fInnerSec){
790 res = ggg1[amp]*z+glandau1[amp]*angle2;
791 if (ctype==0) res *= gcor01[rsigmaz];
794 res*= gcorp[rsigmaz];
800 res = ggg2[amp]*z+glandau2[amp]*angle2;
801 if (ctype==0) res *= gcor02[rsigmaz];
804 res*= gcorp[rsigmaz];
809 res = ggg3[amp]*z+glandau3[amp]*angle2;
810 if (ctype==0) res *= gcor02[rsigmaz];
813 res*= gcorp[rsigmaz];
822 if ((ctype<0) &&<70){
830 seed->SetErrorZ2(res);
837 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
840 //seed->SetErrorZ2(0.1);
844 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
846 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
847 Int_t ctype = cl->GetType();
848 Float_t amp = TMath::Abs(cl->GetQ());
853 Float_t landau=2 ; //landau fluctuation part
854 Float_t gg=2; // gg fluctuation part
855 Float_t padlength= GetPadPitchLength(seed->GetX());
857 if (fSectors==fInnerSec){
858 snoise2 = 0.0004/padlength;
861 gg = (2+0.001*nel/(padlength*padlength))/nel;
862 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
863 if (landau>1) landau=1;
866 snoise2 = 0.0004/padlength;
869 gg = (2+0.0008*nel/(padlength*padlength))/nel;
870 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
871 if (landau>1) landau=1;
873 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
876 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
877 angle2 = TMath::Sqrt((1-angle2));
878 if (angle2<0.6) angle2 = 0.6;
881 Float_t angle = seed->GetTgl()/angle2;
882 Float_t angular = landau*angle*angle*padlength*padlength/12.;
883 Float_t res = sdiff + angular;
886 if ((ctype==0) && (fSectors ==fOuterSec))
887 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
889 if ((ctype==0) && (fSectors ==fInnerSec))
890 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
894 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
900 if ((ctype<0) &&<70){
908 seed->SetErrorZ2(res);
916 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
918 //rotate to track "local coordinata
919 Float_t x = seed->GetX();
920 Float_t y = seed->GetY();
921 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
924 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
925 if (!seed->Rotate(fSectors->GetAlpha()))
927 } else if (y <-ymax) {
928 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
929 if (!seed->Rotate(-fSectors->GetAlpha()))
937 //_____________________________________________________________________________
938 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
939 Double_t x2,Double_t y2,
940 Double_t x3,Double_t y3)
942 //-----------------------------------------------------------------
943 // Initial approximation of the track curvature
944 //-----------------------------------------------------------------
945 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
946 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
947 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
948 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
949 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
951 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
952 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
953 return -xr*yr/sqrt(xr*xr+yr*yr);
958 //_____________________________________________________________________________
959 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
960 Double_t x2,Double_t y2,
961 Double_t x3,Double_t y3)
963 //-----------------------------------------------------------------
964 // Initial approximation of the track curvature
965 //-----------------------------------------------------------------
971 Double_t det = x3*y2-x2*y3;
976 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
977 Double_t x0 = x3*0.5-y3*u;
978 Double_t y0 = y3*0.5+x3*u;
979 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
985 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
986 Double_t x2,Double_t y2,
987 Double_t x3,Double_t y3)
989 //-----------------------------------------------------------------
990 // Initial approximation of the track curvature
991 //-----------------------------------------------------------------
997 Double_t det = x3*y2-x2*y3;
1002 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1003 Double_t x0 = x3*0.5-y3*u;
1004 Double_t y0 = y3*0.5+x3*u;
1005 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1014 //_____________________________________________________________________________
1015 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1016 Double_t x2,Double_t y2,
1017 Double_t x3,Double_t y3)
1019 //-----------------------------------------------------------------
1020 // Initial approximation of the track curvature times center of curvature
1021 //-----------------------------------------------------------------
1022 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1023 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1024 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1025 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1026 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1028 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1030 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1033 //_____________________________________________________________________________
1034 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1035 Double_t x2,Double_t y2,
1036 Double_t z1,Double_t z2)
1038 //-----------------------------------------------------------------
1039 // Initial approximation of the tangent of the track dip angle
1040 //-----------------------------------------------------------------
1041 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1045 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1046 Double_t x2,Double_t y2,
1047 Double_t z1,Double_t z2, Double_t c)
1049 //-----------------------------------------------------------------
1050 // Initial approximation of the tangent of the track dip angle
1051 //-----------------------------------------------------------------
1055 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1057 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1058 if (TMath::Abs(d*c*0.5)>1) return 0;
1059 // Double_t angle2 = TMath::ASin(d*c*0.5);
1060 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1061 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1063 angle2 = (z1-z2)*c/(angle2*2.);
1067 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1068 {//-----------------------------------------------------------------
1069 // This function find proloncation of a track to a reference plane x=x2.
1070 //-----------------------------------------------------------------
1074 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1078 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1079 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1083 Double_t dy = dx*(c1+c2)/(r1+r2);
1086 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1088 if (TMath::Abs(delta)>0.01){
1089 dz = x[3]*TMath::ASin(delta)/x[4];
1091 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1094 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1102 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1107 return LoadClusters();
1110 Int_t AliTPCtrackerMI::LoadClusters()
1113 // load clusters to the memory
1114 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1115 clrow->SetClass("AliTPCclusterMI");
1117 clrow->GetArray()->ExpandCreateFast(10000);
1119 // TTree * tree = fClustersArray.GetTree();
1121 TTree * tree = fInput;
1122 TBranch * br = tree->GetBranch("Segment");
1123 br->SetAddress(&clrow);
1125 Int_t j=Int_t(tree->GetEntries());
1126 for (Int_t i=0; i<j; i++) {
1130 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1131 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1132 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1135 AliTPCRow * tpcrow=0;
1138 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1142 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1143 left = (sec-fkNIS*2)/fkNOS;
1146 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1147 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1148 for (Int_t i=0;i<tpcrow->fN1;i++)
1149 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1152 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1153 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1154 for (Int_t i=0;i<tpcrow->fN2;i++)
1155 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1166 void AliTPCtrackerMI::UnloadClusters()
1169 // unload clusters from the memory
1171 Int_t nrows = fOuterSec->GetNRows();
1172 for (Int_t sec = 0;sec<fkNOS;sec++)
1173 for (Int_t row = 0;row<nrows;row++){
1174 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1176 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1177 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1179 tpcrow->ResetClusters();
1182 nrows = fInnerSec->GetNRows();
1183 for (Int_t sec = 0;sec<fkNIS;sec++)
1184 for (Int_t row = 0;row<nrows;row++){
1185 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1187 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1188 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1190 tpcrow->ResetClusters();
1196 void AliTPCtrackerMI::Transform(AliCluster * cluster){
1200 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1201 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1203 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1205 //mat.LocalToMaster(pos,posC);
1206 mat->LocalToMaster(pos,posC);
1207 cluster->SetX(posC[0]);
1208 cluster->SetY(posC[1]);
1209 cluster->SetZ(posC[2]);
1212 //_____________________________________________________________________________
1213 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1214 //-----------------------------------------------------------------
1215 // This function fills outer TPC sectors with clusters.
1216 //-----------------------------------------------------------------
1217 Int_t nrows = fOuterSec->GetNRows();
1219 for (Int_t sec = 0;sec<fkNOS;sec++)
1220 for (Int_t row = 0;row<nrows;row++){
1221 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1222 Int_t sec2 = sec+2*fkNIS;
1224 Int_t ncl = tpcrow->fN1;
1226 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1227 index=(((sec2<<8)+row)<<16)+ncl;
1228 tpcrow->InsertCluster(c,index);
1233 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1234 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1235 tpcrow->InsertCluster(c,index);
1238 // write indexes for fast acces
1240 for (Int_t i=0;i<510;i++)
1241 tpcrow->fFastCluster[i]=-1;
1242 for (Int_t i=0;i<tpcrow->GetN();i++){
1243 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1244 tpcrow->fFastCluster[zi]=i; // write index
1247 for (Int_t i=0;i<510;i++){
1248 if (tpcrow->fFastCluster[i]<0)
1249 tpcrow->fFastCluster[i] = last;
1251 last = tpcrow->fFastCluster[i];
1260 //_____________________________________________________________________________
1261 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1262 //-----------------------------------------------------------------
1263 // This function fills inner TPC sectors with clusters.
1264 //-----------------------------------------------------------------
1265 Int_t nrows = fInnerSec->GetNRows();
1267 for (Int_t sec = 0;sec<fkNIS;sec++)
1268 for (Int_t row = 0;row<nrows;row++){
1269 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1272 Int_t ncl = tpcrow->fN1;
1274 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1275 index=(((sec<<8)+row)<<16)+ncl;
1276 tpcrow->InsertCluster(c,index);
1281 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1282 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1283 tpcrow->InsertCluster(c,index);
1286 // write indexes for fast acces
1288 for (Int_t i=0;i<510;i++)
1289 tpcrow->fFastCluster[i]=-1;
1290 for (Int_t i=0;i<tpcrow->GetN();i++){
1291 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1292 tpcrow->fFastCluster[zi]=i; // write index
1295 for (Int_t i=0;i<510;i++){
1296 if (tpcrow->fFastCluster[i]<0)
1297 tpcrow->fFastCluster[i] = last;
1299 last = tpcrow->fFastCluster[i];
1311 //_________________________________________________________________________
1312 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1313 //--------------------------------------------------------------------
1314 // Return pointer to a given cluster
1315 //--------------------------------------------------------------------
1316 if (index<0) return 0; // no cluster
1317 Int_t sec=(index&0xff000000)>>24;
1318 Int_t row=(index&0x00ff0000)>>16;
1319 Int_t ncl=(index&0x00007fff)>>00;
1321 const AliTPCRow * tpcrow=0;
1322 AliTPCclusterMI * clrow =0;
1324 if (sec<0 || sec>=fkNIS*4) {
1325 AliWarning(Form("Wrong sector %d",sec));
1330 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1331 if (tpcrow==0) return 0;
1334 if (tpcrow->fN1<=ncl) return 0;
1335 clrow = tpcrow->fClusters1;
1338 if (tpcrow->fN2<=ncl) return 0;
1339 clrow = tpcrow->fClusters2;
1343 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1344 if (tpcrow==0) return 0;
1346 if (sec-2*fkNIS<fkNOS) {
1347 if (tpcrow->fN1<=ncl) return 0;
1348 clrow = tpcrow->fClusters1;
1351 if (tpcrow->fN2<=ncl) return 0;
1352 clrow = tpcrow->fClusters2;
1356 return &(clrow[ncl]);
1362 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1363 //-----------------------------------------------------------------
1364 // This function tries to find a track prolongation to next pad row
1365 //-----------------------------------------------------------------
1367 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1368 AliTPCclusterMI *cl=0;
1369 Int_t tpcindex= t.GetClusterIndex2(nr);
1371 // update current shape info every 5 pad-row
1372 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1376 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1378 if (tpcindex==-1) return 0; //track in dead zone
1380 cl = t.fClusterPointer[nr];
1381 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1382 t.fCurrentClusterIndex1 = tpcindex;
1385 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1386 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1388 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1389 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1391 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1392 Double_t rotation = angle-t.GetAlpha();
1393 t.fRelativeSector= relativesector;
1394 if (!t.Rotate(rotation)) return 0;
1396 if (!t.PropagateTo(x)) return 0;
1398 t.fCurrentCluster = cl;
1400 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1401 if ((tpcindex&0x8000)==0) accept =0;
1403 //if founded cluster is acceptible
1404 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1411 UpdateTrack(&t,accept);
1416 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1418 // not look for new cluster during refitting
1424 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1425 Double_t y=t.GetYat(x);
1426 if (TMath::Abs(y)>ymax){
1428 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1429 if (!t.Rotate(fSectors->GetAlpha()))
1431 } else if (y <-ymax) {
1432 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1433 if (!t.Rotate(-fSectors->GetAlpha()))
1439 if (!t.PropagateTo(x)) {
1440 if (fIteration==0) t.fRemoval = 10;
1444 Double_t z=t.GetZ();
1446 if (!IsActive(t.fRelativeSector,nr)) {
1448 t.SetClusterIndex2(nr,-1);
1451 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1452 Bool_t isActive = IsActive(t.fRelativeSector,nr);
1453 Bool_t isActive2 = (nr>=fInnerSec->GetNRows()) ? fOuterSec[t.fRelativeSector][nr-fInnerSec->GetNRows()].GetN()>0:fInnerSec[t.fRelativeSector][nr].GetN()>0;
1455 if (!isActive || !isActive2) return 0;
1456 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1457 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1459 Double_t roadz = 1.;
1461 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1463 t.SetClusterIndex2(nr,-1);
1468 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1475 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1476 cl = krow.FindNearest2(y,z,roady,roadz,index);
1477 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1480 t.fCurrentCluster = cl;
1482 if (fIteration==2&&cl->IsUsed(10)) return 0;
1483 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1484 if (fIteration==2&&cl->IsUsed(11)) {
1491 if (t.fCurrentCluster->IsUsed(10)){
1496 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1502 if (accept<3) UpdateTrack(&t,accept);
1505 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1511 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1512 //-----------------------------------------------------------------
1513 // This function tries to find a track prolongation to next pad row
1514 //-----------------------------------------------------------------
1516 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1518 if (!t.GetProlongation(x,y,z)) {
1524 if (TMath::Abs(y)>ymax){
1527 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1528 if (!t.Rotate(fSectors->GetAlpha()))
1530 } else if (y <-ymax) {
1531 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1532 if (!t.Rotate(-fSectors->GetAlpha()))
1535 if (!t.PropagateTo(x)) {
1538 t.GetProlongation(x,y,z);
1541 // update current shape info every 3 pad-row
1542 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1543 // t.fCurrentSigmaY = GetSigmaY(&t);
1544 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1548 AliTPCclusterMI *cl=0;
1553 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1554 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1556 Double_t roadz = 1.;
1559 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1561 t.SetClusterIndex2(row,-1);
1566 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1570 if ((cl==0)&&(krow)) {
1571 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1572 cl = krow.FindNearest2(y,z,roady,roadz,index);
1574 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1578 t.fCurrentCluster = cl;
1579 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1581 t.SetClusterIndex2(row,index);
1582 t.fClusterPointer[row] = cl;
1590 //_________________________________________________________________________
1591 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1593 // Get track space point by index
1594 // return false in case the cluster doesn't exist
1595 AliTPCclusterMI *cl = GetClusterMI(index);
1596 if (!cl) return kFALSE;
1597 Int_t sector = (index&0xff000000)>>24;
1598 // Int_t row = (index&0x00ff0000)>>16;
1600 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1601 xyz[0] = cl->GetX();
1602 xyz[1] = cl->GetY();
1603 xyz[2] = cl->GetZ();
1605 fParam->AdjustCosSin(sector,cos,sin);
1606 Float_t x = cos*xyz[0]-sin*xyz[1];
1607 Float_t y = cos*xyz[1]+sin*xyz[0];
1609 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1610 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1611 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1612 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1613 cov[0] = sin*sin*sigmaY2;
1614 cov[1] = -sin*cos*sigmaY2;
1616 cov[3] = cos*cos*sigmaY2;
1619 p.SetXYZ(x,y,xyz[2],cov);
1620 AliAlignObj::ELayerID iLayer;
1622 if (sector < fParam->GetNInnerSector()) {
1623 iLayer = AliAlignObj::kTPC1;
1627 iLayer = AliAlignObj::kTPC2;
1628 idet = sector - fParam->GetNInnerSector();
1630 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1631 p.SetVolumeID(volid);
1637 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1638 //-----------------------------------------------------------------
1639 // This function tries to find a track prolongation to next pad row
1640 //-----------------------------------------------------------------
1641 t.fCurrentCluster = 0;
1642 t.fCurrentClusterIndex1 = 0;
1644 Double_t xt=t.GetX();
1645 Int_t row = GetRowNumber(xt)-1;
1646 Double_t ymax= GetMaxY(nr);
1648 if (row < nr) return 1; // don't prolongate if not information until now -
1649 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1651 // return 0; // not prolongate strongly inclined tracks
1653 // if (TMath::Abs(t.GetSnp())>0.95) {
1655 // return 0; // not prolongate strongly inclined tracks
1656 // }// patch 28 fev 06
1658 Double_t x= GetXrow(nr);
1660 //t.PropagateTo(x+0.02);
1661 //t.PropagateTo(x+0.01);
1662 if (!t.PropagateTo(x)){
1669 if (TMath::Abs(y)>ymax){
1671 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1672 if (!t.Rotate(fSectors->GetAlpha()))
1674 } else if (y <-ymax) {
1675 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1676 if (!t.Rotate(-fSectors->GetAlpha()))
1679 // if (!t.PropagateTo(x)){
1686 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1687 if (!IsActive(t.fRelativeSector,nr)) {
1689 t.SetClusterIndex2(nr,-1);
1692 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1693 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1695 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1697 t.SetClusterIndex2(nr,-1);
1702 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.fNFoundable++;
1708 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1709 // t.fCurrentSigmaY = GetSigmaY(&t);
1710 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1714 AliTPCclusterMI *cl=0;
1717 Double_t roady = 1.;
1718 Double_t roadz = 1.;
1722 index = t.GetClusterIndex2(nr);
1723 if ( (index>0) && (index&0x8000)==0){
1724 cl = t.fClusterPointer[nr];
1725 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1726 t.fCurrentClusterIndex1 = index;
1728 t.fCurrentCluster = cl;
1734 // if (index<0) return 0;
1735 UInt_t uindex = TMath::Abs(index);
1738 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1739 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1742 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1743 t.fCurrentCluster = cl;
1749 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1750 //-----------------------------------------------------------------
1751 // This function tries to find a track prolongation to next pad row
1752 //-----------------------------------------------------------------
1754 //update error according neighborhoud
1756 if (t.fCurrentCluster) {
1758 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1760 if (t.fCurrentCluster->IsUsed(10)){
1766 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1771 if (fIteration>0) accept = 0;
1772 if (accept<3) UpdateTrack(&t,accept);
1776 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1777 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1779 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1787 //_____________________________________________________________________________
1788 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1789 //-----------------------------------------------------------------
1790 // This function tries to find a track prolongation.
1791 //-----------------------------------------------------------------
1792 Double_t xt=t.GetX();
1794 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1795 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1796 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1798 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1800 Int_t first = GetRowNumber(xt)-1;
1801 for (Int_t nr= first; nr>=rf; nr-=step) {
1803 if (t.GetKinkIndexes()[0]>0){
1804 for (Int_t i=0;i<3;i++){
1805 Int_t index = t.GetKinkIndexes()[i];
1806 if (index==0) break;
1807 if (index<0) continue;
1809 AliESDkink * kink = fEvent->GetKink(index-1);
1811 printf("PROBLEM\n");
1814 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1816 AliExternalTrackParam paramd(t);
1817 kink->SetDaughter(paramd);
1818 kink->SetStatus(2,5);
1825 if (nr==80) t.UpdateReference();
1826 if (nr<fInnerSec->GetNRows())
1827 fSectors = fInnerSec;
1829 fSectors = fOuterSec;
1830 if (FollowToNext(t,nr)==0)
1839 //_____________________________________________________________________________
1840 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1841 //-----------------------------------------------------------------
1842 // This function tries to find a track prolongation.
1843 //-----------------------------------------------------------------
1844 Double_t xt=t.GetX();
1846 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1847 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1848 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1849 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1851 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1853 if (FollowToNextFast(t,nr)==0)
1854 if (!t.IsActive()) return 0;
1864 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1865 //-----------------------------------------------------------------
1866 // This function tries to find a track prolongation.
1867 //-----------------------------------------------------------------
1869 Double_t xt=t.GetX();
1870 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1871 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1872 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1873 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1875 Int_t first = t.fFirstPoint;
1876 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1878 if (first<0) first=0;
1879 for (Int_t nr=first; nr<=rf; nr++) {
1880 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1881 if (t.GetKinkIndexes()[0]<0){
1882 for (Int_t i=0;i<3;i++){
1883 Int_t index = t.GetKinkIndexes()[i];
1884 if (index==0) break;
1885 if (index>0) continue;
1886 index = TMath::Abs(index);
1887 AliESDkink * kink = fEvent->GetKink(index-1);
1889 printf("PROBLEM\n");
1892 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1894 AliExternalTrackParam paramm(t);
1895 kink->SetMother(paramm);
1896 kink->SetStatus(2,1);
1903 if (nr<fInnerSec->GetNRows())
1904 fSectors = fInnerSec;
1906 fSectors = fOuterSec;
1916 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1924 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1927 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1929 Float_t distance = TMath::Sqrt(dz2+dy2);
1930 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1933 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1934 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1939 if (firstpoint>lastpoint) {
1940 firstpoint =lastpoint;
1945 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1946 if (s1->GetClusterIndex2(i)>0) sum1++;
1947 if (s2->GetClusterIndex2(i)>0) sum2++;
1948 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1952 if (sum<5) return 0;
1954 Float_t summin = TMath::Min(sum1+1,sum2+1);
1955 Float_t ratio = (sum+1)/Float_t(summin);
1959 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1963 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1964 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1966 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1968 Float_t dy2 =(s1->GetY() - s2->GetY());
1970 Float_t distance = dz2+dy2;
1971 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1976 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1977 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1979 if (firstpoint>=lastpoint-5) return;;
1981 for (Int_t i=firstpoint;i<lastpoint;i++){
1982 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1983 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1990 for (Int_t i=firstpoint;i<lastpoint;i++){
1991 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1992 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1993 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1994 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1995 if (s1->IsActive()&&s2->IsActive()){
1996 p1->fIsShared = kTRUE;
1997 p2->fIsShared = kTRUE;
2004 for (Int_t i=0;i<4;i++){
2005 if (s1->fOverlapLabels[3*i]==0){
2006 s1->fOverlapLabels[3*i] = s2->GetLabel();
2007 s1->fOverlapLabels[3*i+1] = sumshared;
2008 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
2012 for (Int_t i=0;i<4;i++){
2013 if (s2->fOverlapLabels[3*i]==0){
2014 s2->fOverlapLabels[3*i] = s1->GetLabel();
2015 s2->fOverlapLabels[3*i+1] = sumshared;
2016 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2024 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2027 //sort trackss according sectors
2029 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2030 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2032 //if (pt) RotateToLocal(pt);
2036 arr->Sort(); // sorting according z
2037 arr->Expand(arr->GetEntries());
2040 Int_t nseed=arr->GetEntriesFast();
2041 for (Int_t i=0; i<nseed; i++) {
2042 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2044 for (Int_t j=0;j<=12;j++){
2045 pt->fOverlapLabels[j] =0;
2048 for (Int_t i=0; i<nseed; i++) {
2049 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2051 if (pt->fRemoval>10) continue;
2052 for (Int_t j=i+1; j<nseed; j++){
2053 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2055 if (pt2->fRemoval<=10) {
2056 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2063 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2066 //sort trackss according sectors
2069 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2072 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2073 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2078 arr->Sort(); // sorting according z
2079 arr->Expand(arr->GetEntries());
2081 //reset overlap labels
2083 Int_t nseed=arr->GetEntriesFast();
2084 for (Int_t i=0; i<nseed; i++) {
2085 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2088 for (Int_t j=0;j<=12;j++){
2089 pt->fOverlapLabels[j] =0;
2093 //sign shared tracks
2094 for (Int_t i=0; i<nseed; i++) {
2095 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2097 if (pt->fRemoval>10) continue;
2098 Float_t deltac = pt->GetC()*0.1;
2099 for (Int_t j=i+1; j<nseed; j++){
2100 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2102 if (pt2->fRemoval<=10) {
2103 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2104 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2105 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2112 // remove highly shared tracks
2113 for (Int_t i=0; i<nseed; i++) {
2114 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2116 if (pt->fRemoval>10) continue;
2119 for (Int_t j=0;j<4;j++){
2120 sumshared = pt->fOverlapLabels[j*3+1];
2122 Float_t factor = factor1;
2123 if (pt->fRemoval>0) factor = factor2;
2124 if (sumshared/pt->GetNumberOfClusters()>factor){
2125 for (Int_t j=0;j<4;j++){
2126 if (pt->fOverlapLabels[3*j]==0) continue;
2127 if (pt->fOverlapLabels[3*j+1]<5) continue;
2128 if (pt->fRemoval==removalindex) continue;
2129 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2131 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2132 // pt->fRemoval = removalindex;
2133 delete arr->RemoveAt(i);
2141 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2150 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2153 //sort tracks in array according mode criteria
2154 Int_t nseed = arr->GetEntriesFast();
2155 for (Int_t i=0; i<nseed; i++) {
2156 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2166 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2169 //Loop over all tracks and remove "overlaps"
2172 Int_t nseed = arr->GetEntriesFast();
2175 for (Int_t i=0; i<nseed; i++) {
2176 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2178 delete arr->RemoveAt(i);
2182 pt->fBSigned = kFALSE;
2186 nseed = arr->GetEntriesFast();
2193 for (Int_t i=0; i<nseed; i++) {
2194 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2198 Int_t found,foundable,shared;
2200 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2202 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2204 Double_t factor = factor2;
2205 if (pt->fBConstrain) factor = factor1;
2207 if ((Float_t(shared)/Float_t(found))>factor){
2208 pt->Desactivate(removalindex);
2213 for (Int_t i=0; i<160; i++) {
2214 Int_t index=pt->GetClusterIndex2(i);
2215 if (index<0 || index&0x8000 ) continue;
2216 AliTPCclusterMI *c= pt->fClusterPointer[i];
2218 // if (!c->IsUsed(10)) c->Use(10);
2219 //if (pt->IsActive())
2228 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2233 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2236 //Loop over all tracks and remove "overlaps"
2241 Int_t nseed = arr->GetEntriesFast();
2242 Float_t * quality = new Float_t[nseed];
2243 Int_t * indexes = new Int_t[nseed];
2247 for (Int_t i=0; i<nseed; i++) {
2248 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2253 pt->UpdatePoints(); //select first last max dens points
2254 Float_t * points = pt->GetPoints();
2255 if (points[3]<0.8) quality[i] =-1;
2257 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2259 TMath::Sort(nseed,quality,indexes);
2262 for (Int_t itrack=0; itrack<nseed; itrack++) {
2263 Int_t trackindex = indexes[itrack];
2264 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2265 if (quality[trackindex]<0){
2267 delete arr->RemoveAt(trackindex);
2270 arr->RemoveAt(trackindex);
2275 Int_t first = Int_t(pt->GetPoints()[0]);
2276 Int_t last = Int_t(pt->GetPoints()[2]);
2277 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2279 Int_t found,foundable,shared;
2280 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2281 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2282 Bool_t itsgold =kFALSE;
2285 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
2289 if (Float_t(shared+1)/Float_t(found+1)>factor){
2290 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2291 delete arr->RemoveAt(trackindex);
2294 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2295 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2296 delete arr->RemoveAt(trackindex);
2302 if (sharedfactor>0.4) continue;
2303 if (pt->GetKinkIndexes()[0]>0) continue;
2304 for (Int_t i=first; i<last; i++) {
2305 Int_t index=pt->GetClusterIndex2(i);
2306 // if (index<0 || index&0x8000 ) continue;
2307 if (index<0 || index&0x8000 ) continue;
2308 AliTPCclusterMI *c= pt->fClusterPointer[i];
2315 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2321 void AliTPCtrackerMI::UnsignClusters()
2324 // loop over all clusters and unsign them
2327 for (Int_t sec=0;sec<fkNIS;sec++){
2328 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2329 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2330 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2331 // if (cl[icl].IsUsed(10))
2333 cl = fInnerSec[sec][row].fClusters2;
2334 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2335 //if (cl[icl].IsUsed(10))
2340 for (Int_t sec=0;sec<fkNOS;sec++){
2341 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2342 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2343 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2344 //if (cl[icl].IsUsed(10))
2346 cl = fOuterSec[sec][row].fClusters2;
2347 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2348 //if (cl[icl].IsUsed(10))
2357 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2360 //sign clusters to be "used"
2362 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2363 // loop over "primaries"
2377 Int_t nseed = arr->GetEntriesFast();
2378 for (Int_t i=0; i<nseed; i++) {
2379 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2383 if (!(pt->IsActive())) continue;
2384 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2385 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2387 sumdens2+= dens*dens;
2388 sumn += pt->GetNumberOfClusters();
2389 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2390 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2393 sumchi2 +=chi2*chi2;
2398 Float_t mdensity = 0.9;
2399 Float_t meann = 130;
2400 Float_t meanchi = 1;
2401 Float_t sdensity = 0.1;
2402 Float_t smeann = 10;
2403 Float_t smeanchi =0.4;
2407 mdensity = sumdens/sum;
2409 meanchi = sumchi/sum;
2411 sdensity = sumdens2/sum-mdensity*mdensity;
2412 sdensity = TMath::Sqrt(sdensity);
2414 smeann = sumn2/sum-meann*meann;
2415 smeann = TMath::Sqrt(smeann);
2417 smeanchi = sumchi2/sum - meanchi*meanchi;
2418 smeanchi = TMath::Sqrt(smeanchi);
2422 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2424 for (Int_t i=0; i<nseed; i++) {
2425 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2429 if (pt->fBSigned) continue;
2430 if (pt->fBConstrain) continue;
2431 //if (!(pt->IsActive())) continue;
2433 Int_t found,foundable,shared;
2434 pt->GetClusterStatistic(0,160,found, foundable,shared);
2435 if (shared/float(found)>0.3) {
2436 if (shared/float(found)>0.9 ){
2437 //delete arr->RemoveAt(i);
2442 Bool_t isok =kFALSE;
2443 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2445 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2447 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2449 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2453 for (Int_t i=0; i<160; i++) {
2454 Int_t index=pt->GetClusterIndex2(i);
2455 if (index<0) continue;
2456 AliTPCclusterMI *c= pt->fClusterPointer[i];
2458 //if (!(c->IsUsed(10))) c->Use();
2465 Double_t maxchi = meanchi+2.*smeanchi;
2467 for (Int_t i=0; i<nseed; i++) {
2468 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2472 //if (!(pt->IsActive())) continue;
2473 if (pt->fBSigned) continue;
2474 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2475 if (chi>maxchi) continue;
2478 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2480 //sign only tracks with enoug big density at the beginning
2482 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2485 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2486 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2488 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2489 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2492 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2493 //Int_t noc=pt->GetNumberOfClusters();
2494 pt->fBSigned = kTRUE;
2495 for (Int_t i=0; i<160; i++) {
2497 Int_t index=pt->GetClusterIndex2(i);
2498 if (index<0) continue;
2499 AliTPCclusterMI *c= pt->fClusterPointer[i];
2501 // if (!(c->IsUsed(10))) c->Use();
2506 // gLastCheck = nseed;
2514 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2516 // stop not active tracks
2517 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2518 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2519 Int_t nseed = arr->GetEntriesFast();
2521 for (Int_t i=0; i<nseed; i++) {
2522 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2526 if (!(pt->IsActive())) continue;
2527 StopNotActive(pt,row0,th0, th1,th2);
2533 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2536 // stop not active tracks
2537 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2538 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2541 Int_t foundable = 0;
2542 Int_t maxindex = seed->fLastPoint; //last foundable row
2543 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2544 seed->Desactivate(10) ;
2548 for (Int_t i=row0; i<maxindex; i++){
2549 Int_t index = seed->GetClusterIndex2(i);
2550 if (index!=-1) foundable++;
2552 if (foundable<=30) sumgood1++;
2553 if (foundable<=50) {
2560 if (foundable>=30.){
2561 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2564 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2568 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2571 // back propagation of ESD tracks
2577 //PrepareForProlongation(fSeeds,1);
2578 PropagateForward2(fSeeds);
2581 Int_t nseed = fSeeds->GetEntriesFast();
2582 for (Int_t i=0;i<nseed;i++){
2583 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2584 if (!seed) continue;
2585 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2587 seed->PropagateTo(fParam->GetInnerRadiusLow());
2588 seed->UpdatePoints();
2589 AliESDtrack *esd=event->GetTrack(i);
2590 seed->CookdEdx(0.02,0.6);
2591 CookLabel(seed,0.1); //For comparison only
2593 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2594 TTreeSRedirector &cstream = *fDebugStreamer;
2600 if (seed->GetNumberOfClusters()>15){
2601 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2602 esd->SetTPCPoints(seed->GetPoints());
2603 esd->SetTPCPointsF(seed->fNFoundable);
2604 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2605 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2606 Float_t dedx = seed->GetdEdx();
2607 esd->SetTPCsignal(dedx, sdedx, ndedx);
2609 // add seed to the esd track in Calib level
2611 if (AliTPCReconstructor::StreamLevel()>0){
2612 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2613 esd->AddCalibObject(seedCopy);
2618 //printf("problem\n");
2621 //FindKinks(fSeeds,event);
2622 Info("RefitInward","Number of refitted tracks %d",ntracks);
2629 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2632 // back propagation of ESD tracks
2638 PropagateBack(fSeeds);
2639 RemoveUsed2(fSeeds,0.4,0.4,20);
2641 Int_t nseed = fSeeds->GetEntriesFast();
2643 for (Int_t i=0;i<nseed;i++){
2644 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2645 if (!seed) continue;
2646 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2647 seed->UpdatePoints();
2648 AliESDtrack *esd=event->GetTrack(i);
2649 seed->CookdEdx(0.02,0.6);
2650 CookLabel(seed,0.1); //For comparison only
2651 if (seed->GetNumberOfClusters()>15){
2652 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2653 esd->SetTPCPoints(seed->GetPoints());
2654 esd->SetTPCPointsF(seed->fNFoundable);
2655 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2656 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2657 Float_t dedx = seed->GetdEdx();
2658 esd->SetTPCsignal(dedx, sdedx, ndedx);
2660 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2661 (*fDebugStreamer)<<"Cback"<<
2663 "EventNr="<<eventnumber<<
2664 "\n"; // patch 28 fev 06
2667 //FindKinks(fSeeds,event);
2668 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2675 void AliTPCtrackerMI::DeleteSeeds()
2679 Int_t nseed = fSeeds->GetEntriesFast();
2680 for (Int_t i=0;i<nseed;i++){
2681 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2682 if (seed) delete fSeeds->RemoveAt(i);
2688 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2691 //read seeds from the event
2693 Int_t nentr=event->GetNumberOfTracks();
2695 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2700 fSeeds = new TObjArray(nentr);
2704 for (Int_t i=0; i<nentr; i++) {
2705 AliESDtrack *esd=event->GetTrack(i);
2706 ULong_t status=esd->GetStatus();
2707 if (!(status&AliESDtrack::kTPCin)) continue;
2708 AliTPCtrack t(*esd);
2709 t.SetNumberOfClusters(0);
2710 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2711 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2712 for (Int_t ikink=0;ikink<3;ikink++) {
2713 Int_t index = esd->GetKinkIndex(ikink);
2714 seed->GetKinkIndexes()[ikink] = index;
2715 if (index==0) continue;
2716 index = TMath::Abs(index);
2717 AliESDkink * kink = fEvent->GetKink(index-1);
2718 if (kink&&esd->GetKinkIndex(ikink)<0){
2719 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2720 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2722 if (kink&&esd->GetKinkIndex(ikink)>0){
2723 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2724 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2728 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance();
2729 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2730 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2735 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2736 Double_t par0[5],par1[5],alpha,x;
2737 esd->GetInnerExternalParameters(alpha,x,par0);
2738 esd->GetExternalParameters(x,par1);
2739 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2740 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2742 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2743 //reset covariance if suspicious
2744 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2745 seed->ResetCovariance();
2750 // rotate to the local coordinate system
2752 fSectors=fInnerSec; fN=fkNIS;
2753 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2754 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2755 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2756 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2757 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2758 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2759 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2760 alpha-=seed->GetAlpha();
2761 if (!seed->Rotate(alpha)) {
2767 if (esd->GetKinkIndex(0)<=0){
2768 for (Int_t irow=0;irow<160;irow++){
2769 Int_t index = seed->GetClusterIndex2(irow);
2772 AliTPCclusterMI * cl = GetClusterMI(index);
2773 seed->fClusterPointer[irow] = cl;
2775 if ((index & 0x8000)==0){
2776 cl->Use(10); // accepted cluster
2778 cl->Use(6); // close cluster not accepted
2781 Info("ReadSeeds","Not found cluster");
2786 fSeeds->AddAt(seed,i);
2792 //_____________________________________________________________________________
2793 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2794 Float_t deltay, Int_t ddsec) {
2795 //-----------------------------------------------------------------
2796 // This function creates track seeds.
2797 // SEEDING WITH VERTEX CONSTRAIN
2798 //-----------------------------------------------------------------
2799 // cuts[0] - fP4 cut
2800 // cuts[1] - tan(phi) cut
2801 // cuts[2] - zvertex cut
2802 // cuts[3] - fP3 cut
2810 Double_t x[5], c[15];
2811 // Int_t di = i1-i2;
2813 AliTPCseed * seed = new AliTPCseed;
2814 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2815 Double_t cs=cos(alpha), sn=sin(alpha);
2817 // Double_t x1 =fOuterSec->GetX(i1);
2818 //Double_t xx2=fOuterSec->GetX(i2);
2820 Double_t x1 =GetXrow(i1);
2821 Double_t xx2=GetXrow(i2);
2823 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2825 Int_t imiddle = (i2+i1)/2; //middle pad row index
2826 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2827 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2831 const AliTPCRow& kr1=GetRow(ns,i1);
2832 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2833 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2836 // change cut on curvature if it can't reach this layer
2837 // maximal curvature set to reach it
2838 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2839 if (dvertexmax*0.5*cuts[0]>0.85){
2840 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2842 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2845 if (deltay>0) ddsec = 0;
2846 // loop over clusters
2847 for (Int_t is=0; is < kr1; is++) {
2849 if (kr1[is]->IsUsed(10)) continue;
2850 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2851 //if (TMath::Abs(y1)>ymax) continue;
2853 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2855 // find possible directions
2856 Float_t anglez = (z1-z3)/(x1-x3);
2857 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2860 //find rotation angles relative to line given by vertex and point 1
2861 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2862 Double_t dvertex = TMath::Sqrt(dvertex2);
2863 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2864 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2867 // loop over 2 sectors
2873 Double_t dddz1=0; // direction of delta inclination in z axis
2880 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2881 Int_t sec2 = sec + dsec;
2883 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2884 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2885 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2886 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2887 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2888 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2890 // rotation angles to p1-p3
2891 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2892 Double_t x2, y2, z2;
2894 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2897 Double_t dxx0 = (xx2-x3)*cs13r;
2898 Double_t dyy0 = (xx2-x3)*sn13r;
2899 for (Int_t js=index1; js < index2; js++) {
2900 const AliTPCclusterMI *kcl = kr2[js];
2901 if (kcl->IsUsed(10)) continue;
2903 //calcutate parameters
2905 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2907 if (TMath::Abs(yy0)<0.000001) continue;
2908 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2909 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2910 Double_t r02 = (0.25+y0*y0)*dvertex2;
2911 //curvature (radius) cut
2912 if (r02<r2min) continue;
2916 Double_t c0 = 1/TMath::Sqrt(r02);
2920 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2921 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2922 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2923 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2926 Double_t z0 = kcl->GetZ();
2927 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2928 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2931 Double_t dip = (z1-z0)*c0/dfi1;
2932 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2943 x2= xx2*cs-y2*sn*dsec;
2944 y2=+xx2*sn*dsec+y2*cs;
2954 // do we have cluster at the middle ?
2956 GetProlongation(x1,xm,x,ym,zm);
2958 AliTPCclusterMI * cm=0;
2959 if (TMath::Abs(ym)-ymaxm<0){
2960 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2961 if ((!cm) || (cm->IsUsed(10))) {
2966 // rotate y1 to system 0
2967 // get state vector in rotated system
2968 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2969 Double_t xr2 = x0*cs+yr1*sn*dsec;
2970 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2972 GetProlongation(xx2,xm,xr,ym,zm);
2973 if (TMath::Abs(ym)-ymaxm<0){
2974 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2975 if ((!cm) || (cm->IsUsed(10))) {
2985 dym = ym - cm->GetY();
2986 dzm = zm - cm->GetZ();
2993 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2994 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2995 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2996 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2997 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2999 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3000 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3001 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3002 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3003 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3004 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3006 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3007 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3008 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3009 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3013 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3014 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3015 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3016 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3017 c[13]=f30*sy1*f40+f32*sy2*f42;
3018 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3020 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3022 UInt_t index=kr1.GetIndex(is);
3023 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
3025 track->fIsSeeding = kTRUE;
3032 FollowProlongation(*track, (i1+i2)/2,1);
3033 Int_t foundable,found,shared;
3034 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3035 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3037 seed->~AliTPCseed();
3043 FollowProlongation(*track, i2,1);
3047 track->fBConstrain =1;
3048 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3049 track->fLastPoint = i1; // first cluster in track position
3050 track->fFirstPoint = track->fLastPoint;
3052 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3053 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3054 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3056 seed->~AliTPCseed();
3060 // Z VERTEX CONDITION
3062 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3063 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3064 if (TMath::Abs(zv-z3)>cuts[2]) {
3065 FollowProlongation(*track, TMath::Max(i2-20,0));
3066 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3067 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3068 if (TMath::Abs(zv-z3)>cuts[2]){
3069 FollowProlongation(*track, TMath::Max(i2-40,0));
3070 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3071 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3072 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3073 // make seed without constrain
3074 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3075 FollowProlongation(*track2, i2,1);
3076 track2->fBConstrain = kFALSE;
3077 track2->fSeedType = 1;
3078 arr->AddLast(track2);
3080 seed->~AliTPCseed();
3085 seed->~AliTPCseed();
3092 track->fSeedType =0;
3093 arr->AddLast(track);
3094 seed = new AliTPCseed;
3096 // don't consider other combinations
3097 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3103 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3109 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3114 //-----------------------------------------------------------------
3115 // This function creates track seeds.
3116 //-----------------------------------------------------------------
3117 // cuts[0] - fP4 cut
3118 // cuts[1] - tan(phi) cut
3119 // cuts[2] - zvertex cut
3120 // cuts[3] - fP3 cut
3130 Double_t x[5], c[15];
3132 // make temporary seed
3133 AliTPCseed * seed = new AliTPCseed;
3134 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3135 // Double_t cs=cos(alpha), sn=sin(alpha);
3140 Double_t x1 = GetXrow(i1-1);
3141 const AliTPCRow& kr1=GetRow(sec,i1-1);
3142 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3144 Double_t x1p = GetXrow(i1);
3145 const AliTPCRow& kr1p=GetRow(sec,i1);
3147 Double_t x1m = GetXrow(i1-2);
3148 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3151 //last 3 padrow for seeding
3152 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3153 Double_t x3 = GetXrow(i1-7);
3154 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3156 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3157 Double_t x3p = GetXrow(i1-6);
3159 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3160 Double_t x3m = GetXrow(i1-8);
3165 Int_t im = i1-4; //middle pad row index
3166 Double_t xm = GetXrow(im); // radius of middle pad-row
3167 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3168 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3171 Double_t deltax = x1-x3;
3172 Double_t dymax = deltax*cuts[1];
3173 Double_t dzmax = deltax*cuts[3];
3175 // loop over clusters
3176 for (Int_t is=0; is < kr1; is++) {
3178 if (kr1[is]->IsUsed(10)) continue;
3179 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3181 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3183 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3184 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3190 for (Int_t js=index1; js < index2; js++) {
3191 const AliTPCclusterMI *kcl = kr3[js];
3192 if (kcl->IsUsed(10)) continue;
3194 // apply angular cuts
3195 if (TMath::Abs(y1-y3)>dymax) continue;
3198 if (TMath::Abs(z1-z3)>dzmax) continue;
3200 Double_t angley = (y1-y3)/(x1-x3);
3201 Double_t anglez = (z1-z3)/(x1-x3);
3203 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3204 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3206 Double_t yyym = angley*(xm-x1)+y1;
3207 Double_t zzzm = anglez*(xm-x1)+z1;
3209 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3211 if (kcm->IsUsed(10)) continue;
3213 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3214 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3221 // look around first
3222 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3228 if (kc1m->IsUsed(10)) used++;
3230 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3236 if (kc1p->IsUsed(10)) used++;
3238 if (used>1) continue;
3239 if (found<1) continue;
3243 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3249 if (kc3m->IsUsed(10)) used++;
3253 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3259 if (kc3p->IsUsed(10)) used++;
3263 if (used>1) continue;
3264 if (found<3) continue;
3274 x[4]=F1(x1,y1,x2,y2,x3,y3);
3275 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3278 x[2]=F2(x1,y1,x2,y2,x3,y3);
3281 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3282 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3286 Double_t sy1=0.1, sz1=0.1;
3287 Double_t sy2=0.1, sz2=0.1;
3288 Double_t sy3=0.1, sy=0.1, sz=0.1;
3290 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3291 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3292 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3293 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3294 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3295 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3297 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3298 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3299 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3300 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3304 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3305 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3306 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3307 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3308 c[13]=f30*sy1*f40+f32*sy2*f42;
3309 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3311 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3313 UInt_t index=kr1.GetIndex(is);
3314 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3316 track->fIsSeeding = kTRUE;
3319 FollowProlongation(*track, i1-7,1);
3320 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3321 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3323 seed->~AliTPCseed();
3329 FollowProlongation(*track, i2,1);
3330 track->fBConstrain =0;
3331 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3332 track->fFirstPoint = track->fLastPoint;
3334 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3335 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3336 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3338 seed->~AliTPCseed();
3343 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3344 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3345 FollowProlongation(*track2, i2,1);
3346 track2->fBConstrain = kFALSE;
3347 track2->fSeedType = 4;
3348 arr->AddLast(track2);
3350 seed->~AliTPCseed();
3354 //arr->AddLast(track);
3355 //seed = new AliTPCseed;
3361 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3367 //_____________________________________________________________________________
3368 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3369 Float_t deltay, Bool_t /*bconstrain*/) {
3370 //-----------------------------------------------------------------
3371 // This function creates track seeds - without vertex constraint
3372 //-----------------------------------------------------------------
3373 // cuts[0] - fP4 cut - not applied
3374 // cuts[1] - tan(phi) cut
3375 // cuts[2] - zvertex cut - not applied
3376 // cuts[3] - fP3 cut
3386 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3387 // Double_t cs=cos(alpha), sn=sin(alpha);
3388 Int_t row0 = (i1+i2)/2;
3389 Int_t drow = (i1-i2)/2;
3390 const AliTPCRow& kr0=fSectors[sec][row0];
3393 AliTPCpolyTrack polytrack;
3394 Int_t nclusters=fSectors[sec][row0];
3395 AliTPCseed * seed = new AliTPCseed;
3400 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3402 Int_t nfoundable =0;
3403 for (Int_t iter =1; iter<2; iter++){ //iterations
3404 const AliTPCRow& krm=fSectors[sec][row0-iter];
3405 const AliTPCRow& krp=fSectors[sec][row0+iter];
3406 const AliTPCclusterMI * cl= kr0[is];
3408 if (cl->IsUsed(10)) {
3414 Double_t x = kr0.GetX();
3415 // Initialization of the polytrack
3420 Double_t y0= cl->GetY();
3421 Double_t z0= cl->GetZ();
3425 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3426 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3428 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3429 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3430 polytrack.AddPoint(x,y0,z0,erry, errz);
3433 if (cl->IsUsed(10)) sumused++;
3436 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3437 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3440 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3441 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3442 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3443 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3444 if (cl1->IsUsed(10)) sumused++;
3445 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3449 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3451 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3452 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3453 if (cl2->IsUsed(10)) sumused++;
3454 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3457 if (sumused>0) continue;
3459 polytrack.UpdateParameters();
3465 nfoundable = polytrack.GetN();
3466 nfound = nfoundable;
3468 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3469 Float_t maxdist = 0.8*(1.+3./(ddrow));
3470 for (Int_t delta = -1;delta<=1;delta+=2){
3471 Int_t row = row0+ddrow*delta;
3472 kr = &(fSectors[sec][row]);
3473 Double_t xn = kr->GetX();
3474 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3475 polytrack.GetFitPoint(xn,yn,zn);
3476 if (TMath::Abs(yn)>ymax) continue;
3478 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3480 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3483 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3484 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3485 if (cln->IsUsed(10)) {
3486 // printf("used\n");
3494 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3499 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3500 polytrack.UpdateParameters();
3503 if ( (sumused>3) || (sumused>0.5*nfound)) {
3504 //printf("sumused %d\n",sumused);
3509 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3510 AliTPCpolyTrack track2;
3512 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3513 if (track2.GetN()<0.5*nfoundable) continue;
3516 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3518 // test seed with and without constrain
3519 for (Int_t constrain=0; constrain<=0;constrain++){
3520 // add polytrack candidate
3522 Double_t x[5], c[15];
3523 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3524 track2.GetBoundaries(x3,x1);
3526 track2.GetFitPoint(x1,y1,z1);
3527 track2.GetFitPoint(x2,y2,z2);
3528 track2.GetFitPoint(x3,y3,z3);
3530 //is track pointing to the vertex ?
3533 polytrack.GetFitPoint(x0,y0,z0);
3546 x[4]=F1(x1,y1,x2,y2,x3,y3);
3548 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3549 x[2]=F2(x1,y1,x2,y2,x3,y3);
3551 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3552 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3553 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3554 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3557 Double_t sy =0.1, sz =0.1;
3558 Double_t sy1=0.02, sz1=0.02;
3559 Double_t sy2=0.02, sz2=0.02;
3563 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3566 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3567 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3568 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3569 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3570 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3571 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3573 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3574 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3575 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3576 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3581 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3582 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3583 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3584 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3585 c[13]=f30*sy1*f40+f32*sy2*f42;
3586 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3588 //Int_t row1 = fSectors->GetRowNumber(x1);
3589 Int_t row1 = GetRowNumber(x1);
3593 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3594 track->fIsSeeding = kTRUE;
3595 Int_t rc=FollowProlongation(*track, i2);
3596 if (constrain) track->fBConstrain =1;
3598 track->fBConstrain =0;
3599 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3600 track->fFirstPoint = track->fLastPoint;
3602 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3603 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3604 track->fNShared>0.4*track->GetNumberOfClusters()) {
3607 seed->~AliTPCseed();
3610 arr->AddLast(track);
3611 seed = new AliTPCseed;
3615 } // if accepted seed
3618 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3624 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3628 //reseed using track points
3629 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3630 Int_t p1 = int(r1*track->GetNumberOfClusters());
3631 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3633 Double_t x0[3],x1[3],x2[3];
3634 for (Int_t i=0;i<3;i++){
3640 // find track position at given ratio of the length
3641 Int_t sec0=0, sec1=0, sec2=0;
3644 for (Int_t i=0;i<160;i++){
3645 if (track->fClusterPointer[i]){
3647 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3648 if ( (index<p0) || x0[0]<0 ){
3649 if (trpoint->GetX()>1){
3650 clindex = track->GetClusterIndex2(i);
3652 x0[0] = trpoint->GetX();
3653 x0[1] = trpoint->GetY();
3654 x0[2] = trpoint->GetZ();
3655 sec0 = ((clindex&0xff000000)>>24)%18;
3660 if ( (index<p1) &&(trpoint->GetX()>1)){
3661 clindex = track->GetClusterIndex2(i);
3663 x1[0] = trpoint->GetX();
3664 x1[1] = trpoint->GetY();
3665 x1[2] = trpoint->GetZ();
3666 sec1 = ((clindex&0xff000000)>>24)%18;
3669 if ( (index<p2) &&(trpoint->GetX()>1)){
3670 clindex = track->GetClusterIndex2(i);
3672 x2[0] = trpoint->GetX();
3673 x2[1] = trpoint->GetY();
3674 x2[2] = trpoint->GetZ();
3675 sec2 = ((clindex&0xff000000)>>24)%18;
3682 Double_t alpha, cs,sn, xx2,yy2;
3684 alpha = (sec1-sec2)*fSectors->GetAlpha();
3685 cs = TMath::Cos(alpha);
3686 sn = TMath::Sin(alpha);
3687 xx2= x1[0]*cs-x1[1]*sn;
3688 yy2= x1[0]*sn+x1[1]*cs;
3692 alpha = (sec0-sec2)*fSectors->GetAlpha();
3693 cs = TMath::Cos(alpha);
3694 sn = TMath::Sin(alpha);
3695 xx2= x0[0]*cs-x0[1]*sn;
3696 yy2= x0[0]*sn+x0[1]*cs;
3702 Double_t x[5],c[15];
3706 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3707 // if (x[4]>1) return 0;
3708 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3709 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3710 //if (TMath::Abs(x[3]) > 2.2) return 0;
3711 //if (TMath::Abs(x[2]) > 1.99) return 0;
3713 Double_t sy =0.1, sz =0.1;
3715 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3716 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3717 Double_t sy3=0.01+track->GetSigmaY2();
3719 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3720 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3721 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3722 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3723 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3724 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3726 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3727 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3728 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3729 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3734 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3735 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3736 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3737 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3738 c[13]=f30*sy1*f40+f32*sy2*f42;
3739 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3741 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3742 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3743 // Double_t y0,z0,y1,z1, y2,z2;
3744 //seed->GetProlongation(x0[0],y0,z0);
3745 // seed->GetProlongation(x1[0],y1,z1);
3746 //seed->GetProlongation(x2[0],y2,z2);
3748 seed->fLastPoint = pp2;
3749 seed->fFirstPoint = pp2;
3756 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3760 //reseed using founded clusters
3762 // Find the number of clusters
3763 Int_t nclusters = 0;
3764 for (Int_t irow=0;irow<160;irow++){
3765 if (track->GetClusterIndex(irow)>0) nclusters++;
3769 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3770 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3771 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3775 Int_t row[3],sec[3]={0,0,0};
3777 // find track row position at given ratio of the length
3779 for (Int_t irow=0;irow<160;irow++){
3780 if (track->GetClusterIndex2(irow)<0) continue;
3782 for (Int_t ipoint=0;ipoint<3;ipoint++){
3783 if (index<=ipos[ipoint]) row[ipoint] = irow;
3787 //Get cluster and sector position
3788 for (Int_t ipoint=0;ipoint<3;ipoint++){
3789 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3790 AliTPCclusterMI * cl = GetClusterMI(clindex);
3793 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3796 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3797 xyz[ipoint][0] = GetXrow(row[ipoint]);
3798 xyz[ipoint][1] = cl->GetY();
3799 xyz[ipoint][2] = cl->GetZ();
3803 // Calculate seed state vector and covariance matrix
3805 Double_t alpha, cs,sn, xx2,yy2;
3807 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3808 cs = TMath::Cos(alpha);
3809 sn = TMath::Sin(alpha);
3810 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3811 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3815 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3816 cs = TMath::Cos(alpha);
3817 sn = TMath::Sin(alpha);
3818 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3819 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3825 Double_t x[5],c[15];
3829 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3830 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3831 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3833 Double_t sy =0.1, sz =0.1;
3835 Double_t sy1=0.2, sz1=0.2;
3836 Double_t sy2=0.2, sz2=0.2;
3839 Double_t f40=(F1(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[4])/sy;
3840 Double_t f42=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[4])/sy;
3841 Double_t f43=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[4])/sy;
3842 Double_t f20=(F2(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[2])/sy;
3843 Double_t f22=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[2])/sy;
3844 Double_t f23=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[2])/sy;
3846 Double_t f30=(F3(xyz[2][0],xyz[2][1]+sy,xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2])-x[3])/sy;
3847 Double_t f31=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2]+sz,xyz[0][2])-x[3])/sz;
3848 Double_t f32=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1]+sy,xyz[2][2],xyz[0][2])-x[3])/sy;
3849 Double_t f34=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2]+sz)-x[3])/sz;
3854 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3855 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3856 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3857 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3858 c[13]=f30*sy1*f40+f32*sy2*f42;
3859 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3861 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3862 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3863 seed->fLastPoint = row[2];
3864 seed->fFirstPoint = row[2];
3869 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3873 //reseed using founded clusters
3876 Int_t row[3]={0,0,0};
3877 Int_t sec[3]={0,0,0};
3879 // forward direction
3881 for (Int_t irow=r0;irow<160;irow++){
3882 if (track->GetClusterIndex(irow)>0){
3887 for (Int_t irow=160;irow>r0;irow--){
3888 if (track->GetClusterIndex(irow)>0){
3893 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3894 if (track->GetClusterIndex(irow)>0){
3902 for (Int_t irow=0;irow<r0;irow++){
3903 if (track->GetClusterIndex(irow)>0){
3908 for (Int_t irow=r0;irow>0;irow--){
3909 if (track->GetClusterIndex(irow)>0){
3914 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3915 if (track->GetClusterIndex(irow)>0){
3922 if ((row[2]-row[0])<20) return 0;
3923 if (row[1]==0) return 0;
3926 //Get cluster and sector position
3927 for (Int_t ipoint=0;ipoint<3;ipoint++){
3928 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3929 AliTPCclusterMI * cl = GetClusterMI(clindex);
3932 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3935 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3936 xyz[ipoint][0] = GetXrow(row[ipoint]);
3937 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3938 if (point&&ipoint<2){
3940 xyz[ipoint][1] = point->GetY();
3941 xyz[ipoint][2] = point->GetZ();
3944 xyz[ipoint][1] = cl->GetY();
3945 xyz[ipoint][2] = cl->GetZ();
3952 // Calculate seed state vector and covariance matrix
3954 Double_t alpha, cs,sn, xx2,yy2;
3956 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3957 cs = TMath::Cos(alpha);
3958 sn = TMath::Sin(alpha);
3959 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3960 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3964 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3965 cs = TMath::Cos(alpha);
3966 sn = TMath::Sin(alpha);
3967 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3968 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3974 Double_t x[5],c[15];
3978 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3979 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3980 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3982 Double_t sy =0.1, sz =0.1;
3984 Double_t sy1=0.2, sz1=0.2;
3985 Double_t sy2=0.2, sz2=0.2;
3988 Double_t f40=(F1(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[4])/sy;
3989 Double_t f42=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[4])/sy;
3990 Double_t f43=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[4])/sy;
3991 Double_t f20=(F2(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[2])/sy;
3992 Double_t f22=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[2])/sy;
3993 Double_t f23=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[2])/sy;
3995 Double_t f30=(F3(xyz[2][0],xyz[2][1]+sy,xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2])-x[3])/sy;
3996 Double_t f31=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2]+sz,xyz[0][2])-x[3])/sz;
3997 Double_t f32=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1]+sy,xyz[2][2],xyz[0][2])-x[3])/sy;
3998 Double_t f34=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2]+sz)-x[3])/sz;
4003 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
4004 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
4005 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
4006 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
4007 c[13]=f30*sy1*f40+f32*sy2*f42;
4008 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
4010 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
4011 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
4012 seed->fLastPoint = row[2];
4013 seed->fFirstPoint = row[2];
4014 for (Int_t i=row[0];i<row[2];i++){
4015 seed->fIndex[i] = track->fIndex[i];
4021 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4028 TObjArray *kinks= new TObjArray(10000);
4029 // TObjArray *v0s= new TObjArray(10000);
4030 Int_t nentries = array->GetEntriesFast();
4031 AliHelix *helixes = new AliHelix[nentries];
4032 Int_t *sign = new Int_t[nentries];
4033 Int_t *nclusters = new Int_t[nentries];
4034 Float_t *alpha = new Float_t[nentries];
4035 AliESDkink * kink = new AliESDkink();
4036 Int_t * usage = new Int_t[nentries];
4037 Float_t *zm = new Float_t[nentries];
4038 Float_t *z0 = new Float_t[nentries];
4039 Float_t *fim = new Float_t[nentries];
4040 Float_t *shared = new Float_t[nentries];
4041 Bool_t *circular = new Bool_t[nentries];
4042 Float_t *dca = new Float_t[nentries];
4043 //const AliESDVertex * primvertex = esd->GetVertex();
4045 // nentries = array->GetEntriesFast();
4050 for (Int_t i=0;i<nentries;i++){
4053 AliTPCseed* track = (AliTPCseed*)array->At(i);
4054 if (!track) continue;
4055 track->fCircular =0;
4057 track->UpdatePoints();
4058 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4060 nclusters[i]=track->GetNumberOfClusters();
4061 alpha[i] = track->GetAlpha();
4062 new (&helixes[i]) AliHelix(*track);
4064 helixes[i].Evaluate(0,xyz);
4065 sign[i] = (track->GetC()>0) ? -1:1;
4068 if (track->GetProlongation(x,y,z)){
4070 fim[i] = alpha[i]+TMath::ATan2(y,x);
4073 zm[i] = track->GetZ();
4077 circular[i]= kFALSE;
4078 if (track->GetProlongation(0,y,z)) z0[i] = z;
4079 dca[i] = track->GetD(0,0);
4085 Int_t ncandidates =0;
4088 Double_t phase[2][2],radius[2];
4091 // Find circling track
4092 TTreeSRedirector &cstream = *fDebugStreamer;
4094 for (Int_t i0=0;i0<nentries;i0++){
4095 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4096 if (!track0) continue;
4097 if (track0->fN<40) continue;
4098 if (TMath::Abs(1./track0->fP4)>200) continue;
4099 for (Int_t i1=i0+1;i1<nentries;i1++){
4100 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4101 if (!track1) continue;
4102 if (track1->fN<40) continue;
4103 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
4104 if (track0->fBConstrain&&track1->fBConstrain) continue;
4105 if (TMath::Abs(1./track1->fP4)>200) continue;
4106 if (track1->fP4*track0->fP4>0) continue;
4107 if (track1->fP3*track0->fP3>0) continue;
4108 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
4109 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
4110 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
4112 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4113 if (mindcar<5) continue;
4114 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4115 if (mindcaz<5) continue;
4116 if (mindcar+mindcaz<20) continue;
4119 Float_t xc0 = helixes[i0].GetHelix(6);
4120 Float_t yc0 = helixes[i0].GetHelix(7);
4121 Float_t r0 = helixes[i0].GetHelix(8);
4122 Float_t xc1 = helixes[i1].GetHelix(6);
4123 Float_t yc1 = helixes[i1].GetHelix(7);
4124 Float_t r1 = helixes[i1].GetHelix(8);
4126 Float_t rmean = (r0+r1)*0.5;
4127 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4128 //if (delta>30) continue;
4129 if (delta>rmean*0.25) continue;
4130 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4132 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4133 if (npoints==0) continue;
4134 helixes[i0].GetClosestPhases(helixes[i1], phase);
4138 Double_t hangles[3];
4139 helixes[i0].Evaluate(phase[0][0],xyz0);
4140 helixes[i1].Evaluate(phase[0][1],xyz1);
4142 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4143 Double_t deltah[2],deltabest;
4144 if (hangles[2]<2.8) continue;
4146 cstream<<"C"<<track0->fLab<<track1->fLab<<
4147 track0->fP3<<track1->fP3<<
4148 track0->fP4<<track1->fP4<<
4149 delta<<rmean<<npoints<<
4150 hangles[0]<<hangles[2]<<
4151 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4155 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4157 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4158 if (deltah[1]<deltah[0]) ibest=1;
4160 deltabest = TMath::Sqrt(deltah[ibest]);
4161 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4162 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4163 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4164 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4166 if (deltabest>6) continue;
4167 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4168 Bool_t sign =kFALSE;
4169 if (hangles[2]>3.06) sign =kTRUE;
4172 circular[i0] = kTRUE;
4173 circular[i1] = kTRUE;
4174 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4175 track0->fCircular += 1;
4176 track1->fCircular += 2;
4179 track1->fCircular += 1;
4180 track0->fCircular += 2;
4183 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4185 cstream<<"Curling"<<
4186 "lab0="<<track0->fLab<<
4187 "lab1="<<track1->fLab<<
4192 "mindcar="<<mindcar<<
4193 "mindcaz="<<mindcaz<<
4196 "npoints="<<npoints<<
4197 "hangles0="<<hangles[0]<<
4198 "hangles2="<<hangles[2]<<
4203 "radius="<<radiusbest<<
4204 "deltabest="<<deltabest<<
4205 "phase0="<<phase[ibest][0]<<
4206 "phase1="<<phase[ibest][1]<<
4216 for (Int_t i =0;i<nentries;i++){
4217 if (sign[i]==0) continue;
4218 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4221 Double_t cradius0 = 40*40;
4222 Double_t cradius1 = 270*270;
4225 Double_t cdist3=0.55;
4226 for (Int_t j =i+1;j<nentries;j++){
4228 if (sign[j]*sign[i]<1) continue;
4229 if ( (nclusters[i]+nclusters[j])>200) continue;
4230 if ( (nclusters[i]+nclusters[j])<80) continue;
4231 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4232 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4233 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4234 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4235 if (npoints<1) continue;
4238 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4241 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4244 Double_t delta1=10000,delta2=10000;
4245 // cuts on the intersection radius
4246 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4247 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4248 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4250 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4251 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4252 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4255 Double_t distance1 = TMath::Min(delta1,delta2);
4256 if (distance1>cdist1) continue; // cut on DCA linear approximation
4258 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4259 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4260 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4261 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4264 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4265 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4266 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4268 distance1 = TMath::Min(delta1,delta2);
4271 rkink = TMath::Sqrt(radius[0]);
4274 rkink = TMath::Sqrt(radius[1]);
4276 if (distance1>cdist2) continue;
4279 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4282 Int_t row0 = GetRowNumber(rkink);
4283 if (row0<10) continue;
4284 if (row0>150) continue;
4287 Float_t dens00=-1,dens01=-1;
4288 Float_t dens10=-1,dens11=-1;
4290 Int_t found,foundable,shared;
4291 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4292 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4293 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4294 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4296 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4297 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4298 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4299 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4301 if (dens00<dens10 && dens01<dens11) continue;
4302 if (dens00>dens10 && dens01>dens11) continue;
4303 if (TMath::Max(dens00,dens10)<0.1) continue;
4304 if (TMath::Max(dens01,dens11)<0.3) continue;
4306 if (TMath::Min(dens00,dens10)>0.6) continue;
4307 if (TMath::Min(dens01,dens11)>0.6) continue;
4310 AliTPCseed * ktrack0, *ktrack1;
4319 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4320 AliExternalTrackParam paramm(*ktrack0);
4321 AliExternalTrackParam paramd(*ktrack1);
4322 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4325 kink->SetMother(paramm);
4326 kink->SetDaughter(paramd);
4329 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4331 fParam->Transform0to1(x,index);
4332 fParam->Transform1to2(x,index);
4333 row0 = GetRowNumber(x[0]);
4335 if (kink->GetR()<100) continue;
4336 if (kink->GetR()>240) continue;
4337 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4338 if (kink->GetDistance()>cdist3) continue;
4339 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4340 if (dird<0) continue;
4342 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4343 if (dirm<0) continue;
4344 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4345 if (mpt<0.2) continue;
4348 //for high momenta momentum not defined well in first iteration
4349 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4350 if (qt>0.35) continue;
4353 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4354 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4356 kink->SetTPCDensity(dens00,0,0);
4357 kink->SetTPCDensity(dens01,0,1);
4358 kink->SetTPCDensity(dens10,1,0);
4359 kink->SetTPCDensity(dens11,1,1);
4360 kink->SetIndex(i,0);
4361 kink->SetIndex(j,1);
4364 kink->SetTPCDensity(dens10,0,0);
4365 kink->SetTPCDensity(dens11,0,1);
4366 kink->SetTPCDensity(dens00,1,0);
4367 kink->SetTPCDensity(dens01,1,1);
4368 kink->SetIndex(j,0);
4369 kink->SetIndex(i,1);
4372 if (mpt<1||kink->GetAngle(2)>0.1){
4373 // angle and densities not defined yet
4374 if (kink->GetTPCDensityFactor()<0.8) continue;
4375 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4376 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4377 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4378 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4380 Float_t criticalangle = track0->fC22+track0->fC33;
4381 criticalangle+= track1->fC22+track1->fC33;
4382 criticalangle= 3*TMath::Sqrt(criticalangle);
4383 if (criticalangle>0.02) criticalangle=0.02;
4384 if (kink->GetAngle(2)<criticalangle) continue;
4387 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4388 Float_t shapesum =0;
4390 for ( Int_t row = row0-drow; row<row0+drow;row++){
4391 if (row<0) continue;
4392 if (row>155) continue;
4393 if (ktrack0->fClusterPointer[row]){
4394 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4395 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4398 if (ktrack1->fClusterPointer[row]){
4399 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4400 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4405 kink->SetShapeFactor(-1.);
4408 kink->SetShapeFactor(shapesum/sum);
4410 // esd->AddKink(kink);
4411 kinks->AddLast(kink);
4412 kink = new AliESDkink;
4417 // sort the kinks according quality - and refit them towards vertex
4419 Int_t nkinks = kinks->GetEntriesFast();
4420 Float_t *quality = new Float_t[nkinks];
4421 Int_t *indexes = new Int_t[nkinks];
4422 AliTPCseed *mothers = new AliTPCseed[nkinks];
4423 AliTPCseed *daughters = new AliTPCseed[nkinks];
4426 for (Int_t i=0;i<nkinks;i++){
4428 AliESDkink *kink = (AliESDkink*)kinks->At(i);
4430 // refit kinks towards vertex
4432 Int_t index0 = kink->GetIndex(0);
4433 Int_t index1 = kink->GetIndex(1);
4434 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4435 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4437 Int_t sumn=ktrack0->fN+ktrack1->fN;
4439 // Refit Kink under if too small angle
4441 if (kink->GetAngle(2)<0.05){
4442 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4443 Int_t row0 = kink->GetTPCRow0();
4444 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4447 Int_t last = row0-drow;
4448 if (last<40) last=40;
4449 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4450 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4453 Int_t first = row0+drow;
4454 if (first>130) first=130;
4455 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4456 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4458 if (seed0 && seed1){
4459 kink->SetStatus(1,8);
4460 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4461 row0 = GetRowNumber(kink->GetR());
4462 sumn = seed0->fN+seed1->fN;
4463 new (&mothers[i]) AliTPCseed(*seed0);
4464 new (&daughters[i]) AliTPCseed(*seed1);
4467 delete kinks->RemoveAt(i);
4468 if (seed0) delete seed0;
4469 if (seed1) delete seed1;
4472 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4473 delete kinks->RemoveAt(i);
4474 if (seed0) delete seed0;
4475 if (seed1) delete seed1;
4483 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4485 TMath::Sort(nkinks,quality,indexes,kFALSE);
4487 //remove double find kinks
4489 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4490 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4491 if (!kink0) continue;
4493 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4494 if (!kink0) continue;
4495 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4496 if (!kink1) continue;
4497 // if not close kink continue
4498 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4499 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4500 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4502 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4503 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4504 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4505 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4506 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4515 for (Int_t i=0;i<row0;i++){
4516 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4519 if (mother0.fIndex[i]==mother1.fIndex[i]){
4526 for (Int_t i=row0;i<158;i++){
4527 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4530 if (mother0.fIndex[i]==mother1.fIndex[i]){
4536 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4537 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4538 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4539 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4540 Int_t sum0 = mother0.fN+daughter0.fN;
4541 Int_t sum1 = mother1.fN+daughter1.fN;
4543 shared[kink0->GetIndex(0)]= kTRUE;
4544 shared[kink0->GetIndex(1)]= kTRUE;
4545 delete kinks->RemoveAt(indexes[ikink0]);
4548 shared[kink1->GetIndex(0)]= kTRUE;
4549 shared[kink1->GetIndex(1)]= kTRUE;
4550 delete kinks->RemoveAt(indexes[ikink1]);
4557 for (Int_t i=0;i<nkinks;i++){
4558 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
4559 if (!kink) continue;
4560 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4561 Int_t index0 = kink->GetIndex(0);
4562 Int_t index1 = kink->GetIndex(1);
4563 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4564 kink->SetMultiple(usage[index0],0);
4565 kink->SetMultiple(usage[index1],1);
4566 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4567 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4568 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4569 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4571 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4572 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4573 if (!ktrack0 || !ktrack1) continue;
4574 Int_t index = esd->AddKink(kink);
4577 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4578 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4579 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4580 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4584 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4585 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4590 // Remove tracks corresponding to shared kink's
4592 for (Int_t i=0;i<nentries;i++){
4593 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4594 if (!track0) continue;
4595 if (track0->fKinkIndexes[0]!=0) continue;
4596 if (shared[i]) delete array->RemoveAt(i);
4601 RemoveUsed2(array,0.5,0.4,30);
4603 for (Int_t i=0;i<nentries;i++){
4604 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4605 if (!track0) continue;
4606 track0->CookdEdx(0.02,0.6);
4610 for (Int_t i=0;i<nentries;i++){
4611 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4612 if (!track0) continue;
4613 if (track0->Pt()<1.4) continue;
4614 //remove double high momenta tracks - overlapped with kink candidates
4617 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4618 if (track0->fClusterPointer[icl]!=0){
4620 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4623 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4624 delete array->RemoveAt(i);
4628 if (track0->fKinkIndexes[0]!=0) continue;
4629 if (track0->GetNumberOfClusters()<80) continue;
4631 AliTPCseed *pmother = new AliTPCseed();
4632 AliTPCseed *pdaughter = new AliTPCseed();
4633 AliESDkink *pkink = new AliESDkink;
4635 AliTPCseed & mother = *pmother;
4636 AliTPCseed & daughter = *pdaughter;
4637 AliESDkink & kink = *pkink;
4638 if (CheckKinkPoint(track0,mother,daughter, kink)){
4639 if (mother.fN<30||daughter.fN<20) {
4643 continue; //too short tracks
4645 if (mother.Pt()<1.4) {
4651 Int_t row0= kink.GetTPCRow0();
4652 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4659 Int_t index = esd->AddKink(&kink);
4660 mother.fKinkIndexes[0] = -(index+1);
4661 daughter.fKinkIndexes[0] = index+1;
4663 delete array->RemoveAt(i);
4664 array->AddAt(new AliTPCseed(mother),i);
4667 array->AddLast(new AliTPCseed(mother));
4669 array->AddLast(new AliTPCseed(daughter));
4670 for (Int_t icl=0;icl<row0;icl++) {
4671 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4674 for (Int_t icl=row0;icl<158;icl++) {
4675 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4684 delete [] daughters;
4706 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4710 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4716 TObjArray *tpcv0s = new TObjArray(100000);
4717 Int_t nentries = array->GetEntriesFast();
4718 AliHelix *helixes = new AliHelix[nentries];
4719 Int_t *sign = new Int_t[nentries];
4720 Float_t *alpha = new Float_t[nentries];
4721 Float_t *z0 = new Float_t[nentries];
4722 Float_t *dca = new Float_t[nentries];
4723 Float_t *sdcar = new Float_t[nentries];
4724 Float_t *cdcar = new Float_t[nentries];
4725 Float_t *pulldcar = new Float_t[nentries];
4726 Float_t *pulldcaz = new Float_t[nentries];
4727 Float_t *pulldca = new Float_t[nentries];
4728 Bool_t *isPrim = new Bool_t[nentries];
4729 const AliESDVertex * primvertex = esd->GetVertex();
4730 Double_t zvertex = primvertex->GetZv();
4732 // nentries = array->GetEntriesFast();
4734 for (Int_t i=0;i<nentries;i++){
4737 AliTPCseed* track = (AliTPCseed*)array->At(i);
4738 if (!track) continue;
4739 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4740 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4741 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4743 alpha[i] = track->GetAlpha();
4744 new (&helixes[i]) AliHelix(*track);
4746 helixes[i].Evaluate(0,xyz);
4747 sign[i] = (track->GetC()>0) ? -1:1;
4751 if (track->GetProlongation(0,y,z)) z0[i] = z;
4752 dca[i] = track->GetD(0,0);
4754 // dca error parrameterezation + pulls
4756 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4757 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4758 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4759 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4760 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4761 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4762 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4763 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4765 if (track->fTPCr[4]>0.5) {
4766 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4768 if (track->fTPCr[0]>0.4) {
4769 isPrim[i]=kFALSE; //electron no sigma cut
4776 Int_t ncandidates =0;
4779 Double_t phase[2][2],radius[2];
4785 TTreeSRedirector &cstream = *fDebugStreamer;
4786 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4788 Double_t cradius0 = 10*10;
4789 Double_t cradius1 = 200*200;
4792 Double_t cpointAngle = 0.95;
4794 Double_t delta[2]={10000,10000};
4795 for (Int_t i =0;i<nentries;i++){
4796 if (sign[i]==0) continue;
4797 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4798 if (!track0) continue;
4799 if (AliTPCReconstructor::StreamLevel()>0){
4804 "zvertex="<<zvertex<<
4805 "sdcar0="<<sdcar[i]<<
4806 "cdcar0="<<cdcar[i]<<
4807 "pulldcar0="<<pulldcar[i]<<
4808 "pulldcaz0="<<pulldcaz[i]<<
4809 "pulldca0="<<pulldca[i]<<
4810 "isPrim="<<isPrim[i]<<
4814 if (track0->fP4<0) continue;
4815 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4817 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4822 for (Int_t j =0;j<nentries;j++){
4823 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4824 if (!track1) continue;
4825 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4826 if (sign[j]*sign[i]>0) continue;
4827 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4828 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4831 // DCA to prim vertex cut
4837 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4838 if (npoints<1) continue;
4842 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4843 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4844 if (delta[0]>cdist1) continue;
4847 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4848 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4849 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4850 if (delta[1]<delta[0]) iclosest=1;
4851 if (delta[iclosest]>cdist1) continue;
4853 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4854 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4856 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4857 if (pointAngle<cpointAngle) continue;
4859 Bool_t isGamma = kFALSE;
4860 vertex.SetP(*track0); //track0 - plus
4861 vertex.SetM(*track1); //track1 - minus
4862 vertex.Update(fprimvertex);
4863 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4864 Double_t pointAngle2 = vertex.GetPointAngle();
4866 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4867 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4868 Float_t sigmae = 0.15*0.15;
4869 if (vertex.GetRr()<80)
4870 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4871 sigmae+= TMath::Sqrt(sigmae);
4872 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4873 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4874 Int_t row0 = GetRowNumber(vertex.GetRr());
4876 if (vertex.GetDist2()>0.2) continue;
4877 densb0 = track0->Density2(0,row0-5);
4878 densb1 = track1->Density2(0,row0-5);
4879 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4880 densa0 = track0->Density2(row0+5,row0+40);
4881 densa1 = track1->Density2(row0+5,row0+40);
4882 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4885 densa0 = track0->Density2(0,40); //cluster density
4886 densa1 = track1->Density2(0,40); //cluster density
4887 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4889 vertex.SetLab(0,track0->GetLabel());
4890 vertex.SetLab(1,track1->GetLabel());
4891 vertex.SetChi2After((densa0+densa1)*0.5);
4892 vertex.SetChi2Before((densb0+densb1)*0.5);
4893 vertex.SetIndex(0,i);
4894 vertex.SetIndex(1,j);
4895 vertex.SetStatus(1); // TPC v0 candidate
4896 vertex.SetRp(track0->fTPCr);
4897 vertex.SetRm(track1->fTPCr);
4898 tpcv0s->AddLast(new AliESDV0MI(vertex));
4901 Int_t eventNr = esd->GetEventNumber();
4902 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4903 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4904 if (AliTPCReconstructor::StreamLevel()>0)
4907 "vertex.="<<&vertex<<
4909 "lab0="<<track0->fLab<<
4910 "Helix0.="<<&helixes[i]<<
4912 "lab1="<<track1->fLab<<
4913 "Helix1.="<<&helixes[j]<<
4914 "pointAngle="<<pointAngle<<
4915 "pointAngle2="<<pointAngle2<<
4920 "zvertex="<<zvertex<<
4921 "circular0="<<track0->fCircular<<
4922 "circular1="<<track1->fCircular<<
4923 "npoints="<<npoints<<
4924 "radius0="<<radius[0]<<
4925 "delta0="<<delta[0]<<
4926 "radius1="<<radius[1]<<
4927 "delta1="<<delta[1]<<
4928 "radiusm="<<radiusm<<
4930 "sdcar0="<<sdcar[i]<<
4931 "sdcar1="<<sdcar[j]<<
4932 "cdcar0="<<cdcar[i]<<
4933 "cdcar1="<<cdcar[j]<<
4934 "pulldcar0="<<pulldcar[i]<<
4935 "pulldcar1="<<pulldcar[j]<<
4936 "pulldcaz0="<<pulldcaz[i]<<
4937 "pulldcaz1="<<pulldcaz[j]<<
4938 "pulldca0="<<pulldca[i]<<
4939 "pulldca1="<<pulldca[j]<<
4949 Float_t *quality = new Float_t[ncandidates];
4950 Int_t *indexes = new Int_t[ncandidates];
4952 for (Int_t i=0;i<ncandidates;i++){
4954 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4955 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4956 // quality[i] /= (0.5+v0->GetDist2());
4957 // quality[i] *= v0->GetChi2After(); //density factor
4958 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4959 Int_t index0 = v0->GetIndex(0);
4960 Int_t index1 = v0->GetIndex(1);
4961 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4962 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4963 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4964 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4967 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4970 for (Int_t i=0;i<ncandidates;i++){
4971 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4973 Int_t index0 = v0->GetIndex(0);
4974 Int_t index1 = v0->GetIndex(1);
4975 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4976 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4977 if (!track0||!track1) {
4981 Bool_t accept =kTRUE; //default accept
4982 Int_t *v0indexes0 = track0->GetV0Indexes();
4983 Int_t *v0indexes1 = track1->GetV0Indexes();
4985 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4986 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4987 if (v0indexes0[1]!=0) order0 =2;
4988 if (v0indexes1[1]!=0) order1 =2;
4990 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4991 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4993 AliESDV0MI * v02 = v0;
4995 v0->SetOrder(0,order0);
4996 v0->SetOrder(1,order1);
4997 v0->SetOrder(1,order0+order1);
4998 Int_t index = esd->AddV0MI(v0);
4999 v02 = esd->GetV0MI(index);
5000 v0indexes0[order0]=index;
5001 v0indexes1[order1]=index;
5005 Int_t eventNr = esd->GetEventNumber();
5006 if (AliTPCReconstructor::StreamLevel()>0)
5012 "lab0="<<track0->fLab<<
5014 "lab1="<<track1->fLab<<
5015 "dca0="<<dca[index0]<<
5016 "dca1="<<dca[index1]<<
5020 "quality="<<quality[i]<<
5021 "pulldca0="<<pulldca[index0]<<
5022 "pulldca1="<<pulldca[index1]<<
5046 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5050 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5053 // refit kink towards to the vertex
5056 Int_t row0 = GetRowNumber(kink.GetR());
5057 FollowProlongation(mother,0);
5058 mother.Reset(kFALSE);
5060 FollowProlongation(daughter,row0);
5061 daughter.Reset(kFALSE);
5062 FollowBackProlongation(daughter,158);
5063 daughter.Reset(kFALSE);
5064 Int_t first = TMath::Max(row0-20,30);
5065 Int_t last = TMath::Min(row0+20,140);
5067 const Int_t kNdiv =5;
5068 AliTPCseed param0[kNdiv]; // parameters along the track
5069 AliTPCseed param1[kNdiv]; // parameters along the track
5070 AliESDkink kinks[kNdiv]; // corresponding kink parameters
5073 for (Int_t irow=0; irow<kNdiv;irow++){
5074 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5076 // store parameters along the track
5078 for (Int_t irow=0;irow<kNdiv;irow++){
5079 FollowBackProlongation(mother, rows[irow]);
5080 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5081 new(¶m0[irow]) AliTPCseed(mother);
5082 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5086 for (Int_t irow=0; irow<kNdiv-1;irow++){
5087 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5088 kinks[irow].SetMother(param0[irow]);
5089 kinks[irow].SetDaughter(param1[irow]);
5090 kinks[irow].Update();
5093 // choose kink with best "quality"
5095 Double_t mindist = 10000;
5096 for (Int_t irow=0;irow<kNdiv;irow++){
5097 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5098 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5099 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5101 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
5102 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5103 if (normdist < mindist){
5109 if (index==-1) return 0;
5112 param0[index].Reset(kTRUE);
5113 FollowProlongation(param0[index],0);
5115 new (&mother) AliTPCseed(param0[index]);
5116 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5118 kink.SetMother(mother);
5119 kink.SetDaughter(daughter);
5121 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5122 kink.SetTPCncls(param0[index].fN,0);
5123 kink.SetTPCncls(param1[index].fN,1);
5124 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5125 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5126 mother.SetLabel(kink.GetLabel(0));
5127 daughter.SetLabel(kink.GetLabel(1));
5133 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5135 // update Kink quality information for mother after back propagation
5137 if (seed->GetKinkIndex(0)>=0) return;
5138 for (Int_t ikink=0;ikink<3;ikink++){
5139 Int_t index = seed->GetKinkIndex(ikink);
5140 if (index>=0) break;
5141 index = TMath::Abs(index)-1;
5142 AliESDkink * kink = fEvent->GetKink(index);
5143 //kink->fTPCdensity2[0][0]=-1;
5144 //kink->fTPCdensity2[0][1]=-1;
5145 kink->SetTPCDensity2(-1,0,0);
5146 kink->SetTPCDensity2(1,0,1);
5148 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5149 if (row0<15) row0=15;
5151 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5152 if (row1>145) row1=145;
5154 Int_t found,foundable,shared;
5155 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5156 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5157 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5158 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5163 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5165 // update Kink quality information for daughter after refit
5167 if (seed->GetKinkIndex(0)<=0) return;
5168 for (Int_t ikink=0;ikink<3;ikink++){
5169 Int_t index = seed->GetKinkIndex(ikink);
5170 if (index<=0) break;
5171 index = TMath::Abs(index)-1;
5172 AliESDkink * kink = fEvent->GetKink(index);
5173 kink->SetTPCDensity2(-1,1,0);
5174 kink->SetTPCDensity2(-1,1,1);
5176 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5177 if (row0<15) row0=15;
5179 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5180 if (row1>145) row1=145;
5182 Int_t found,foundable,shared;
5183 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5184 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5185 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5186 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5192 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5195 // check kink point for given track
5196 // if return value=0 kink point not found
5197 // otherwise seed0 correspond to mother particle
5198 // seed1 correspond to daughter particle
5199 // kink parameter of kink point
5201 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5202 Int_t first = seed->fFirstPoint;
5203 Int_t last = seed->fLastPoint;
5204 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5207 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5208 if (!seed1) return 0;
5209 FollowProlongation(*seed1,seed->fLastPoint-20);
5210 seed1->Reset(kTRUE);
5211 FollowProlongation(*seed1,158);
5212 seed1->Reset(kTRUE);
5213 last = seed1->fLastPoint;
5215 AliTPCseed *seed0 = new AliTPCseed(*seed);
5216 seed0->Reset(kFALSE);
5219 AliTPCseed param0[20]; // parameters along the track
5220 AliTPCseed param1[20]; // parameters along the track
5221 AliESDkink kinks[20]; // corresponding kink parameters
5223 for (Int_t irow=0; irow<20;irow++){
5224 rows[irow] = first +((last-first)*irow)/19;
5226 // store parameters along the track
5228 for (Int_t irow=0;irow<20;irow++){
5229 FollowBackProlongation(*seed0, rows[irow]);
5230 FollowProlongation(*seed1,rows[19-irow]);
5231 new(¶m0[irow]) AliTPCseed(*seed0);
5232 new(¶m1[19-irow]) AliTPCseed(*seed1);
5236 for (Int_t irow=0; irow<19;irow++){
5237 kinks[irow].SetMother(param0[irow]);
5238 kinks[irow].SetDaughter(param1[irow]);
5239 kinks[irow].Update();
5242 // choose kink with biggest change of angle
5244 Double_t maxchange= 0;
5245 for (Int_t irow=1;irow<19;irow++){
5246 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5247 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5248 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5249 if ( quality > maxchange){
5250 maxchange = quality;
5257 if (index<0) return 0;
5259 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5260 seed0 = new AliTPCseed(param0[index]);
5261 seed1 = new AliTPCseed(param1[index]);
5262 seed0->Reset(kFALSE);
5263 seed1->Reset(kFALSE);
5264 seed0->ResetCovariance();
5265 seed1->ResetCovariance();
5266 FollowProlongation(*seed0,0);
5267 FollowBackProlongation(*seed1,158);
5268 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5269 seed0->Reset(kFALSE);
5270 seed1->Reset(kFALSE);
5271 seed0->ResetCovariance();
5272 seed1->ResetCovariance();
5274 first = TMath::Max(row0-20,0);
5275 last = TMath::Min(row0+20,158);
5277 for (Int_t irow=0; irow<20;irow++){
5278 rows[irow] = first +((last-first)*irow)/19;
5280 // store parameters along the track
5282 for (Int_t irow=0;irow<20;irow++){
5283 FollowBackProlongation(*seed0, rows[irow]);
5284 FollowProlongation(*seed1,rows[19-irow]);
5285 new(¶m0[irow]) AliTPCseed(*seed0);
5286 new(¶m1[19-irow]) AliTPCseed(*seed1);
5290 for (Int_t irow=0; irow<19;irow++){
5291 kinks[irow].SetMother(param0[irow]);
5292 kinks[irow].SetDaughter(param1[irow]);
5293 // param0[irow].Dump();
5294 //param1[irow].Dump();
5295 kinks[irow].Update();
5298 // choose kink with biggest change of angle
5301 for (Int_t irow=0;irow<20;irow++){
5302 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5303 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5304 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5305 if ( quality > maxchange){
5306 maxchange = quality;
5313 if (index==-1 || param0[index].fN+param1[index].fN<100){
5318 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5320 kink.SetMother(param0[index]);
5321 kink.SetDaughter(param1[index]);
5323 row0 = GetRowNumber(kink.GetR());
5324 kink.SetTPCRow0(row0);
5325 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5326 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5327 kink.SetIndex(-10,0);
5328 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5329 kink.SetTPCncls(param0[index].fN,0);
5330 kink.SetTPCncls(param1[index].fN,1);
5333 // new (&mother) AliTPCseed(param0[index]);
5334 new (&daughter) AliTPCseed(param1[index]);
5335 daughter.SetLabel(kink.GetLabel(1));
5336 param0[index].Reset(kTRUE);
5337 FollowProlongation(param0[index],0);
5338 new (&mother) AliTPCseed(param0[index]);
5339 mother.SetLabel(kink.GetLabel(0));
5349 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5352 // reseed - refit - track
5355 // Int_t last = fSectors->GetNRows()-1;
5357 if (fSectors == fOuterSec){
5358 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5362 first = t->fFirstPoint;
5364 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5365 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5367 FollowProlongation(*t,first);
5377 //_____________________________________________________________________________
5378 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5379 //-----------------------------------------------------------------
5380 // This function reades track seeds.
5381 //-----------------------------------------------------------------
5382 TDirectory *savedir=gDirectory;
5384 TFile *in=(TFile*)inp;
5385 if (!in->IsOpen()) {
5386 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5391 TTree *seedTree=(TTree*)in->Get("Seeds");
5393 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5394 cerr<<"can't get a tree with track seeds !\n";
5397 AliTPCtrack *seed=new AliTPCtrack;
5398 seedTree->SetBranchAddress("tracks",&seed);
5400 if (fSeeds==0) fSeeds=new TObjArray(15000);
5402 Int_t n=(Int_t)seedTree->GetEntries();
5403 for (Int_t i=0; i<n; i++) {
5404 seedTree->GetEvent(i);
5405 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5414 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5417 if (fSeeds) DeleteSeeds();
5420 if (!fSeeds) return 1;
5427 //_____________________________________________________________________________
5428 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5429 //-----------------------------------------------------------------
5430 // This is a track finder.
5431 //-----------------------------------------------------------------
5432 TDirectory *savedir=gDirectory;
5436 fSeeds = Tracking();
5439 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5441 //activate again some tracks
5442 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5443 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5445 Int_t nc=t.GetNumberOfClusters();
5447 delete fSeeds->RemoveAt(i);
5451 if (pt->fRemoval==10) {
5452 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5453 pt->Desactivate(10); // make track again active
5455 pt->Desactivate(20);
5456 delete fSeeds->RemoveAt(i);
5461 RemoveUsed2(fSeeds,0.85,0.85,0);
5462 if (AliTPCReconstructor::GetRecoParam()->GetDoKinks()) FindKinks(fSeeds,fEvent);
5463 RemoveUsed2(fSeeds,0.5,0.4,20);
5465 // // refit short tracks
5467 Int_t nseed=fSeeds->GetEntriesFast();
5468 // for (Int_t i=0; i<nseed; i++) {
5469 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5470 // if (!pt) continue;
5471 // Int_t nc=t.GetNumberOfClusters();
5473 // delete fSeeds->RemoveAt(i);
5476 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5477 // if (nc>100) continue; // hopefully, enough for ITS
5478 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5479 // //seed2->Reset(kFALSE);
5480 // //pt->ResetCovariance();
5481 // seed2->Modify(1);
5482 // FollowBackProlongation(*seed2,158);
5483 // //seed2->Reset(kFALSE);
5484 // seed2->Modify(10);
5485 // FollowProlongation(*seed2,0);
5486 // TTreeSRedirector &cstream = *fDebugStreamer;
5487 // cstream<<"Crefit"<<
5491 // if (seed2->fN>pt->fN){
5492 // delete fSeeds->RemoveAt(i);
5493 // fSeeds->AddAt(seed2,i);
5498 // RemoveUsed2(fSeeds,0.6,0.6,50);
5500 // FindV0s(fSeeds,fEvent);
5501 //RemoveDouble(fSeeds,0.2,0.6,11);
5505 for (Int_t i=0; i<nseed; i++) {
5506 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5508 Int_t nc=t.GetNumberOfClusters();
5510 delete fSeeds->RemoveAt(i);
5513 CookLabel(pt,0.1); //For comparison only
5514 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5515 if ((pt->IsActive() || (pt->fRemoval==10) )){
5517 if (fDebug>0) cerr<<found<<'\r';
5521 delete fSeeds->RemoveAt(i);
5525 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5527 //RemoveUsed(fSeeds,0.9,0.9,6);
5529 nseed=fSeeds->GetEntriesFast();
5531 for (Int_t i=0; i<nseed; i++) {
5532 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5534 Int_t nc=t.GetNumberOfClusters();
5536 delete fSeeds->RemoveAt(i);
5540 t.CookdEdx(0.02,0.6);
5541 // CheckKinkPoint(&t,0.05);
5542 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5543 if ((pt->IsActive() || (pt->fRemoval==10) )){
5551 delete fSeeds->RemoveAt(i);
5552 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5554 // FollowProlongation(*seed1,0);
5555 // Int_t n = seed1->GetNumberOfClusters();
5556 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5557 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5560 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5564 SortTracks(fSeeds, 1);
5568 PrepareForBackProlongation(fSeeds,5.);
5569 PropagateBack(fSeeds);
5570 printf("Time for back propagation: \t");timer.Print();timer.Start();
5574 PrepareForProlongation(fSeeds,5.);
5575 PropagateForward2(fSeeds);
5577 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5578 // RemoveUsed(fSeeds,0.7,0.7,6);
5579 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5581 nseed=fSeeds->GetEntriesFast();
5583 for (Int_t i=0; i<nseed; i++) {
5584 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5586 Int_t nc=t.GetNumberOfClusters();
5588 delete fSeeds->RemoveAt(i);
5591 t.CookdEdx(0.02,0.6);
5592 // CookLabel(pt,0.1); //For comparison only
5593 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5594 if ((pt->IsActive() || (pt->fRemoval==10) )){
5595 cerr<<found++<<'\r';
5598 delete fSeeds->RemoveAt(i);
5603 // fNTracks = found;
5605 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5608 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5609 Info("Clusters2Tracks","Number of found tracks %d",found);
5611 // UnloadClusters();
5616 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5619 // tracking of the seeds
5622 fSectors = fOuterSec;
5623 ParallelTracking(arr,150,63);
5624 fSectors = fOuterSec;
5625 ParallelTracking(arr,63,0);
5628 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5633 TObjArray * arr = new TObjArray;
5635 fSectors = fOuterSec;
5638 for (Int_t sec=0;sec<fkNOS;sec++){
5639 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5640 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5641 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5644 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5656 TObjArray * AliTPCtrackerMI::Tracking()
5660 if (AliTPCReconstructor::GetRecoParam()->GetSpecialSeeding()) return TrackingSpecial();
5663 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5665 TObjArray * seeds = new TObjArray;
5674 Float_t fnumber = 3.0;
5675 Float_t fdensity = 3.0;
5680 for (Int_t delta = 0; delta<18; delta+=6){
5684 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5685 SumTracks(seeds,arr);
5686 SignClusters(seeds,fnumber,fdensity);
5688 for (Int_t i=2;i<6;i+=2){
5689 // seed high pt tracks
5692 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5693 SumTracks(seeds,arr);
5694 SignClusters(seeds,fnumber,fdensity);
5699 // RemoveUsed(seeds,0.9,0.9,1);
5700 // UnsignClusters();
5701 // SignClusters(seeds,fnumber,fdensity);
5705 for (Int_t delta = 20; delta<120; delta+=10){
5707 // seed high pt tracks
5711 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5712 SumTracks(seeds,arr);
5713 SignClusters(seeds,fnumber,fdensity);
5718 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5719 SumTracks(seeds,arr);
5720 SignClusters(seeds,fnumber,fdensity);
5731 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5735 // RemoveUsed(seeds,0.75,0.75,1);
5737 //SignClusters(seeds,fnumber,fdensity);
5746 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5747 SumTracks(seeds,arr);
5748 SignClusters(seeds,fnumber,fdensity);
5750 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5751 SumTracks(seeds,arr);
5752 SignClusters(seeds,fnumber,fdensity);
5754 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5755 SumTracks(seeds,arr);
5756 SignClusters(seeds,fnumber,fdensity);
5760 for (Int_t delta = 3; delta<30; delta+=5){
5766 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5767 SumTracks(seeds,arr);
5768 SignClusters(seeds,fnumber,fdensity);
5770 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5771 SumTracks(seeds,arr);
5772 SignClusters(seeds,fnumber,fdensity);
5784 for (Int_t delta = 30; delta<90; delta+=10){
5790 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5791 SumTracks(seeds,arr);
5792 SignClusters(seeds,fnumber,fdensity);
5794 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5795 SumTracks(seeds,arr);
5796 SignClusters(seeds,fnumber,fdensity);
5800 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5811 TObjArray * AliTPCtrackerMI::TrackingSpecial()
5814 // seeding adjusted for laser and cosmic tests - short tracks with big inclination angle
5815 // no primary vertex seeding tried
5819 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5821 TObjArray * seeds = new TObjArray;
5826 Float_t fnumber = 3.0;
5827 Float_t fdensity = 3.0;
5830 cuts[0] = AliTPCReconstructor::GetRecoParam()->GetMaxC(); // max curvature
5831 cuts[1] = 3.5; // max tan(phi) angle for seeding
5832 cuts[2] = 3.; // not used (cut on z primary vertex)
5833 cuts[3] = 3.5; // max tan(theta) angle for seeding
5835 for (Int_t delta = 0; nup-delta-gap-1>0; delta+=3){
5837 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5838 SumTracks(seeds,arr);
5839 SignClusters(seeds,fnumber,fdensity);
5843 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5854 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5857 //sum tracks to common container
5858 //remove suspicious tracks
5859 Int_t nseed = arr2->GetEntriesFast();
5860 for (Int_t i=0;i<nseed;i++){
5861 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5864 // remove tracks with too big curvature
5866 if (TMath::Abs(pt->GetC())>AliTPCReconstructor::GetRecoParam()->GetMaxC()){
5867 delete arr2->RemoveAt(i);
5870 // REMOVE VERY SHORT TRACKS
5871 if (pt->GetNumberOfClusters()<20){
5872 delete arr2->RemoveAt(i);
5875 // NORMAL ACTIVE TRACK
5876 if (pt->IsActive()){
5877 arr1->AddLast(arr2->RemoveAt(i));
5880 //remove not usable tracks
5881 if (pt->fRemoval!=10){
5882 delete arr2->RemoveAt(i);
5886 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5887 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5888 arr1->AddLast(arr2->RemoveAt(i));
5890 delete arr2->RemoveAt(i);
5899 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5902 // try to track in parralel
5904 Int_t nseed=arr->GetEntriesFast();
5905 //prepare seeds for tracking
5906 for (Int_t i=0; i<nseed; i++) {
5907 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5909 if (!t.IsActive()) continue;
5910 // follow prolongation to the first layer
5911 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5912 FollowProlongation(t, rfirst+1);
5917 for (Int_t nr=rfirst; nr>=rlast; nr--){
5918 if (nr<fInnerSec->GetNRows())
5919 fSectors = fInnerSec;
5921 fSectors = fOuterSec;
5922 // make indexes with the cluster tracks for given
5924 // find nearest cluster
5925 for (Int_t i=0; i<nseed; i++) {
5926 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5928 if (nr==80) pt->UpdateReference();
5929 if (!pt->IsActive()) continue;
5930 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5931 if (pt->fRelativeSector>17) {
5934 UpdateClusters(t,nr);
5936 // prolonagate to the nearest cluster - if founded
5937 for (Int_t i=0; i<nseed; i++) {
5938 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5940 if (!pt->IsActive()) continue;
5941 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5942 if (pt->fRelativeSector>17) {
5945 FollowToNextCluster(*pt,nr);
5950 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5954 // if we use TPC track itself we have to "update" covariance
5956 Int_t nseed= arr->GetEntriesFast();
5957 for (Int_t i=0;i<nseed;i++){
5958 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5962 //rotate to current local system at first accepted point
5963 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5964 Int_t sec = (index&0xff000000)>>24;
5966 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5967 if (angle1>TMath::Pi())
5968 angle1-=2.*TMath::Pi();
5969 Float_t angle2 = pt->GetAlpha();
5971 if (TMath::Abs(angle1-angle2)>0.001){
5972 pt->Rotate(angle1-angle2);
5973 //angle2 = pt->GetAlpha();
5974 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5975 //if (pt->GetAlpha()<0)
5976 // pt->fRelativeSector+=18;
5977 //sec = pt->fRelativeSector;
5986 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5990 // if we use TPC track itself we have to "update" covariance
5992 Int_t nseed= arr->GetEntriesFast();
5993 for (Int_t i=0;i<nseed;i++){
5994 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5997 pt->fFirstPoint = pt->fLastPoint;
6005 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
6008 // make back propagation
6010 Int_t nseed= arr->GetEntriesFast();
6011 for (Int_t i=0;i<nseed;i++){
6012 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6013 if (pt&& pt->GetKinkIndex(0)<=0) {
6014 //AliTPCseed *pt2 = new AliTPCseed(*pt);
6015 fSectors = fInnerSec;
6016 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
6017 //fSectors = fOuterSec;
6018 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6019 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
6020 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
6021 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6024 if (pt&& pt->GetKinkIndex(0)>0) {
6025 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
6026 pt->fFirstPoint = kink->GetTPCRow0();
6027 fSectors = fInnerSec;
6028 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6036 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
6039 // make forward propagation
6041 Int_t nseed= arr->GetEntriesFast();
6043 for (Int_t i=0;i<nseed;i++){
6044 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6046 FollowProlongation(*pt,0);
6053 Int_t AliTPCtrackerMI::PropagateForward()
6056 // propagate track forward
6058 Int_t nseed = fSeeds->GetEntriesFast();
6059 for (Int_t i=0;i<nseed;i++){
6060 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
6062 AliTPCseed &t = *pt;
6063 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
6064 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
6065 if (alpha < 0. ) alpha += 2.*TMath::Pi();
6066 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
6070 fSectors = fOuterSec;
6071 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
6072 fSectors = fInnerSec;
6073 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
6083 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6086 // make back propagation, in between row0 and row1
6090 fSectors = fInnerSec;
6093 if (row1<fSectors->GetNRows())
6096 r1 = fSectors->GetNRows()-1;
6098 if (row0<fSectors->GetNRows()&& r1>0 )
6099 FollowBackProlongation(*pt,r1);
6100 if (row1<=fSectors->GetNRows())
6103 r1 = row1 - fSectors->GetNRows();
6104 if (r1<=0) return 0;
6105 if (r1>=fOuterSec->GetNRows()) return 0;
6106 fSectors = fOuterSec;
6107 return FollowBackProlongation(*pt,r1);
6115 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6119 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6120 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6121 Float_t padlength = GetPadPitchLength(row);
6123 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6124 Double_t angulary = seed->GetSnp();
6125 angulary = angulary*angulary/(1-angulary*angulary);
6126 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6128 Float_t sresz = fParam->GetZSigma();
6129 Float_t angularz = seed->GetTgl();
6130 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6132 Float_t wy = GetSigmaY(seed);
6133 Float_t wz = GetSigmaZ(seed);
6136 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6137 printf("problem\n");
6143 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6147 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6148 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6149 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6150 Float_t angular = seed->GetSnp();
6151 angular = angular*angular/(1-angular*angular);
6152 // angular*=angular;
6153 //angular = TMath::Sqrt(angular/(1-angular));
6154 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6157 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6161 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6162 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6163 Float_t sres = fParam->GetZSigma();
6164 Float_t angular = seed->GetTgl();
6165 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6170 //__________________________________________________________________________
6171 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6172 //--------------------------------------------------------------------
6173 //This function "cooks" a track label. If label<0, this track is fake.
6174 //--------------------------------------------------------------------
6175 AliTPCseed * t = (AliTPCseed*)tk;
6176 Int_t noc=t->GetNumberOfClusters();
6178 //printf("\nnot founded prolongation\n\n\n");
6184 AliTPCclusterMI *clusters[160];
6186 for (Int_t i=0;i<160;i++) {
6193 for (i=0; i<160 && current<noc; i++) {
6195 Int_t index=t->GetClusterIndex2(i);
6196 if (index<=0) continue;
6197 if (index&0x8000) continue;
6199 //clusters[current]=GetClusterMI(index);
6200 if (t->fClusterPointer[i]){
6201 clusters[current]=t->fClusterPointer[i];
6207 Int_t lab=123456789;
6208 for (i=0; i<noc; i++) {
6209 AliTPCclusterMI *c=clusters[i];
6211 lab=TMath::Abs(c->GetLabel(0));
6213 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6219 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6221 for (i=0; i<noc; i++) {
6222 AliTPCclusterMI *c=clusters[i];
6224 if (TMath::Abs(c->GetLabel(1)) == lab ||
6225 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6228 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6231 Int_t tail=Int_t(0.10*noc);
6234 for (i=1; i<=160&&ind<tail; i++) {
6235 // AliTPCclusterMI *c=clusters[noc-i];
6236 AliTPCclusterMI *c=clusters[i];
6238 if (lab == TMath::Abs(c->GetLabel(0)) ||
6239 lab == TMath::Abs(c->GetLabel(1)) ||
6240 lab == TMath::Abs(c->GetLabel(2))) max++;
6243 if (max < Int_t(0.5*tail)) lab=-lab;
6250 //delete[] clusters;
6254 //__________________________________________________________________________
6255 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6256 //--------------------------------------------------------------------
6257 //This function "cooks" a track label. If label<0, this track is fake.
6258 //--------------------------------------------------------------------
6259 Int_t noc=t->GetNumberOfClusters();
6261 //printf("\nnot founded prolongation\n\n\n");
6267 AliTPCclusterMI *clusters[160];
6269 for (Int_t i=0;i<160;i++) {
6276 for (i=0; i<160 && current<noc; i++) {
6277 if (i<first) continue;
6278 if (i>last) continue;
6279 Int_t index=t->GetClusterIndex2(i);
6280 if (index<=0) continue;
6281 if (index&0x8000) continue;
6283 //clusters[current]=GetClusterMI(index);
6284 if (t->fClusterPointer[i]){
6285 clusters[current]=t->fClusterPointer[i];
6290 if (noc<5) return -1;
6291 Int_t lab=123456789;
6292 for (i=0; i<noc; i++) {
6293 AliTPCclusterMI *c=clusters[i];
6295 lab=TMath::Abs(c->GetLabel(0));
6297 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6303 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6305 for (i=0; i<noc; i++) {
6306 AliTPCclusterMI *c=clusters[i];
6308 if (TMath::Abs(c->GetLabel(1)) == lab ||
6309 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6312 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6315 Int_t tail=Int_t(0.10*noc);
6318 for (i=1; i<=160&&ind<tail; i++) {
6319 // AliTPCclusterMI *c=clusters[noc-i];
6320 AliTPCclusterMI *c=clusters[i];
6322 if (lab == TMath::Abs(c->GetLabel(0)) ||
6323 lab == TMath::Abs(c->GetLabel(1)) ||
6324 lab == TMath::Abs(c->GetLabel(2))) max++;
6327 if (max < Int_t(0.5*tail)) lab=-lab;
6330 // t->SetLabel(lab);
6334 //delete[] clusters;
6338 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6340 //return pad row number for this x
6343 r=fRow[fN-1].GetX();
6344 if (x > r) return fN;
6346 if (x < r) return -1;
6347 return Int_t((x-r)/fPadPitchLength + 0.5);}
6349 r=fRow[fN-1].GetX();
6350 if (x > r) return fN;
6352 if (x < r) return -1;
6353 Double_t r1=fRow[64].GetX();
6355 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6357 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6361 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6363 //return pad row number for given x vector
6364 Float_t phi = TMath::ATan2(x[1],x[0]);
6365 if(phi<0) phi=2.*TMath::Pi()+phi;
6366 // Get the local angle in the sector philoc
6367 const Float_t kRaddeg = 180/3.14159265358979312;
6368 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6369 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6370 return GetRowNumber(localx);
6373 //_________________________________________________________________________
6374 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6375 //-----------------------------------------------------------------------
6376 // Setup inner sector
6377 //-----------------------------------------------------------------------
6379 fAlpha=par->GetInnerAngle();
6380 fAlphaShift=par->GetInnerAngleShift();
6381 fPadPitchWidth=par->GetInnerPadPitchWidth();
6382 fPadPitchLength=par->GetInnerPadPitchLength();
6383 fN=par->GetNRowLow();
6384 fRow=new AliTPCRow[fN];
6385 for (Int_t i=0; i<fN; i++) {
6386 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6387 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6390 fAlpha=par->GetOuterAngle();
6391 fAlphaShift=par->GetOuterAngleShift();
6392 fPadPitchWidth = par->GetOuterPadPitchWidth();
6393 fPadPitchLength = par->GetOuter1PadPitchLength();
6394 f1PadPitchLength = par->GetOuter1PadPitchLength();
6395 f2PadPitchLength = par->GetOuter2PadPitchLength();
6397 fN=par->GetNRowUp();
6398 fRow=new AliTPCRow[fN];
6399 for (Int_t i=0; i<fN; i++) {
6400 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6401 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6406 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6408 // default constructor
6416 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6423 //_________________________________________________________________________
6425 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6426 //-----------------------------------------------------------------------
6427 // Insert a cluster into this pad row in accordence with its y-coordinate
6428 //-----------------------------------------------------------------------
6429 if (fN==kMaxClusterPerRow) {
6430 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6432 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6433 Int_t i=Find(c->GetZ());
6434 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6435 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6436 fIndex[i]=index; fClusters[i]=c; fN++;
6439 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6445 //delete[] fClusterArray;
6446 if (fClusters1) delete []fClusters1;
6447 if (fClusters2) delete []fClusters2;
6454 //___________________________________________________________________
6455 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6456 //-----------------------------------------------------------------------
6457 // Return the index of the nearest cluster
6458 //-----------------------------------------------------------------------
6459 if (fN==0) return 0;
6460 if (z <= fClusters[0]->GetZ()) return 0;
6461 if (z > fClusters[fN-1]->GetZ()) return fN;
6462 Int_t b=0, e=fN-1, m=(b+e)/2;
6463 for (; b<e; m=(b+e)/2) {
6464 if (z > fClusters[m]->GetZ()) b=m+1;
6472 //___________________________________________________________________
6473 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6474 //-----------------------------------------------------------------------
6475 // Return the index of the nearest cluster in z y
6476 //-----------------------------------------------------------------------
6477 Float_t maxdistance = roady*roady + roadz*roadz;
6479 AliTPCclusterMI *cl =0;
6480 for (Int_t i=Find(z-roadz); i<fN; i++) {
6481 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6482 if (c->GetZ() > z+roadz) break;
6483 if ( (c->GetY()-y) > roady ) continue;
6484 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6485 if (maxdistance>distance) {
6486 maxdistance = distance;
6493 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6495 //-----------------------------------------------------------------------
6496 // Return the index of the nearest cluster in z y
6497 //-----------------------------------------------------------------------
6498 Float_t maxdistance = roady*roady + roadz*roadz;
6499 AliTPCclusterMI *cl =0;
6501 //PH Check boundaries. 510 is the size of fFastCluster
6502 Int_t iz1 = Int_t(z-roadz+254.5);
6503 if (iz1<0 || iz1>=510) return cl;
6504 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6505 Int_t iz2 = Int_t(z+roadz+255.5);
6506 if (iz2<0 || iz2>=510) return cl;
6507 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6509 //FindNearest3(y,z,roady,roadz,index);
6510 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6511 for (Int_t i=iz1; i<iz2; i++) {
6512 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6513 if (c->GetZ() > z+roadz) break;
6514 if ( c->GetY()-y > roady ) continue;
6515 if ( y-c->GetY() > roady ) continue;
6516 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6517 if (maxdistance>distance) {
6518 maxdistance = distance;
6521 //roady = TMath::Sqrt(maxdistance);
6529 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6531 //-----------------------------------------------------------------------
6532 // Return the index of the nearest cluster in z y
6533 //-----------------------------------------------------------------------
6534 Float_t maxdistance = roady*roady + roadz*roadz;
6535 // Int_t iz = Int_t(z+255.);
6536 AliTPCclusterMI *cl =0;
6537 for (Int_t i=Find(z-roadz); i<fN; i++) {
6538 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6539 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6540 if (c->GetZ() > z+roadz) break;
6541 if ( c->GetY()-y > roady ) continue;
6542 if ( y-c->GetY() > roady ) continue;
6543 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6544 if (maxdistance>distance) {
6545 maxdistance = distance;
6548 //roady = TMath::Sqrt(maxdistance);
6558 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6562 // return &fTrackPoints[i];