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 -
24 // run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 // run AliTPCFindTracksMI.C macro - to find tracks
26 // tracks are written to AliTPCtracks.root file
27 // for comparison also seeds are written to the same file - to special branch
28 //-------------------------------------------------------
33 #include "Riostream.h"
34 #include <TClonesArray.h>
36 #include <TObjArray.h>
39 #include "AliComplexCluster.h"
41 #include "AliESDkink.h"
43 #include "AliRunLoader.h"
44 #include "AliTPCClustersRow.h"
45 #include "AliTPCParam.h"
46 #include "AliTPCReconstructor.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCseed.h"
51 #include "AliTPCtrackerMI.h"
52 #include "TStopwatch.h"
53 #include "AliTPCReconstructor.h"
54 #include "AliESDkink.h"
56 #include "TTreeStream.h"
57 #include "AliAlignObj.h"
58 #include "AliTrackPointArray.h"
62 ClassImp(AliTPCtrackerMI)
65 class AliTPCFastMath {
68 static Double_t FastAsin(Double_t x);
70 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
73 Double_t AliTPCFastMath::fgFastAsin[20000];
74 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
76 AliTPCFastMath::AliTPCFastMath(){
78 // initialized lookup table;
79 for (Int_t i=0;i<10000;i++){
80 fgFastAsin[2*i] = TMath::ASin(i/10000.);
81 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
85 Double_t AliTPCFastMath::FastAsin(Double_t x){
87 // return asin using lookup table
89 Int_t index = int(x*10000);
90 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
93 Int_t index = int(x*10000);
94 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
100 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
102 //update track information using current cluster - track->fCurrentCluster
105 AliTPCclusterMI* c =track->fCurrentCluster;
106 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
108 UInt_t i = track->fCurrentClusterIndex1;
110 Int_t sec=(i&0xff000000)>>24;
111 //Int_t row = (i&0x00ff0000)>>16;
112 track->fRow=(i&0x00ff0000)>>16;
113 track->fSector = sec;
114 // Int_t index = i&0xFFFF;
115 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
116 track->SetClusterIndex2(track->fRow, i);
117 //track->fFirstPoint = row;
118 //if ( track->fLastPoint<row) track->fLastPoint =row;
119 // if (track->fRow<0 || track->fRow>160) {
120 // printf("problem\n");
122 if (track->fFirstPoint>track->fRow)
123 track->fFirstPoint = track->fRow;
124 if (track->fLastPoint<track->fRow)
125 track->fLastPoint = track->fRow;
128 track->fClusterPointer[track->fRow] = c;
131 Float_t angle2 = track->GetSnp()*track->GetSnp();
132 angle2 = TMath::Sqrt(angle2/(1-angle2));
134 //SET NEW Track Point
138 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
140 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
141 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
142 point.SetErrY(sqrt(track->fErrorY2));
143 point.SetErrZ(sqrt(track->fErrorZ2));
145 point.SetX(track->GetX());
146 point.SetY(track->GetY());
147 point.SetZ(track->GetZ());
148 point.SetAngleY(angle2);
149 point.SetAngleZ(track->GetTgl());
150 if (point.fIsShared){
151 track->fErrorY2 *= 4;
152 track->fErrorZ2 *= 4;
156 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
158 track->fErrorY2 *= 1.3;
159 track->fErrorY2 += 0.01;
160 track->fErrorZ2 *= 1.3;
161 track->fErrorZ2 += 0.005;
163 if (accept>0) return 0;
164 if (track->GetNumberOfClusters()%20==0){
165 // if (track->fHelixIn){
166 // TClonesArray & larr = *(track->fHelixIn);
167 // Int_t ihelix = larr.GetEntriesFast();
168 // new(larr[ihelix]) AliHelix(*track) ;
171 track->fNoCluster =0;
172 return track->Update(c,chi2,i);
177 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
178 Float_t cory, Float_t corz)
181 // decide according desired precision to accept given
182 // cluster for tracking
183 Double_t sy2=ErrY2(seed,cluster)*cory;
184 Double_t sz2=ErrZ2(seed,cluster)*corz;
185 //sy2=ErrY2(seed,cluster)*cory;
186 //sz2=ErrZ2(seed,cluster)*cory;
188 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
189 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
191 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
192 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
193 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
194 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
196 Double_t rdistance2 = rdistancey2+rdistancez2;
199 if (rdistance2>16) return 3;
202 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
203 return 2; //suspisiouce - will be changed
205 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
206 // strict cut on overlaped cluster
207 return 2; //suspisiouce - will be changed
209 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
210 && cluster->GetType()<0){
220 //_____________________________________________________________________________
221 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
222 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
224 //---------------------------------------------------------------------
225 // The main TPC tracker constructor
226 //---------------------------------------------------------------------
227 fInnerSec=new AliTPCSector[fkNIS];
228 fOuterSec=new AliTPCSector[fkNOS];
231 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
232 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
239 Int_t nrowlow = par->GetNRowLow();
240 Int_t nrowup = par->GetNRowUp();
243 for (Int_t i=0;i<nrowlow;i++){
244 fXRow[i] = par->GetPadRowRadiiLow(i);
245 fPadLength[i]= par->GetPadPitchLength(0,i);
246 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
250 for (Int_t i=0;i<nrowup;i++){
251 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
252 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
253 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
264 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
266 //________________________________________________________________________
267 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
272 //------------------------------------
273 // dummy copy constructor
274 //------------------------------------------------------------------
276 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
277 //------------------------------
279 //--------------------------------------------------------------
282 //_____________________________________________________________________________
283 AliTPCtrackerMI::~AliTPCtrackerMI() {
284 //------------------------------------------------------------------
285 // TPC tracker destructor
286 //------------------------------------------------------------------
293 if (fDebugStreamer) delete fDebugStreamer;
296 void AliTPCtrackerMI::SetIO()
300 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
302 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
304 AliTPCtrack *iotrack= new AliTPCtrack;
305 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
311 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
327 AliTPCtrack *iotrack= new AliTPCtrack;
328 // iotrack->fHelixIn = new TClonesArray("AliHelix");
329 //iotrack->fHelixOut = new TClonesArray("AliHelix");
330 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
333 if (output && (fDebug&2)){
334 //write the full seed information if specified in debug mode
336 fSeedTree = new TTree("Seeds","Seeds");
337 AliTPCseed * vseed = new AliTPCseed;
339 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
340 arrtr->ExpandCreateFast(160);
341 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
343 vseed->fPoints = arrtr;
344 vseed->fEPoints = arre;
345 // vseed->fClusterPoints = arrcl;
346 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
349 fTreeDebug = new TTree("trackDebug","trackDebug");
350 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
351 fTreeDebug->Branch("debug",&arrd,32000,99);
359 void AliTPCtrackerMI::FillESD(TObjArray* arr)
363 //fill esds using updated tracks
365 // write tracks to the event
366 // store index of the track
367 Int_t nseed=arr->GetEntriesFast();
368 //FindKinks(arr,fEvent);
369 for (Int_t i=0; i<nseed; i++) {
370 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
373 // pt->PropagateTo(fParam->GetInnerRadiusLow());
374 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
375 pt->PropagateTo(fParam->GetInnerRadiusLow());
378 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
380 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
381 iotrack.SetTPCPoints(pt->GetPoints());
382 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
383 iotrack.SetV0Indexes(pt->GetV0Indexes());
384 // iotrack.SetTPCpid(pt->fTPCr);
385 //iotrack.SetTPCindex(i);
386 fEvent->AddTrack(&iotrack);
390 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
392 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
393 iotrack.SetTPCPoints(pt->GetPoints());
394 //iotrack.SetTPCindex(i);
395 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
396 iotrack.SetV0Indexes(pt->GetV0Indexes());
397 // iotrack.SetTPCpid(pt->fTPCr);
398 fEvent->AddTrack(&iotrack);
402 // short tracks - maybe decays
404 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
405 Int_t found,foundable,shared;
406 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
407 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
409 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
410 //iotrack.SetTPCindex(i);
411 iotrack.SetTPCPoints(pt->GetPoints());
412 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
413 iotrack.SetV0Indexes(pt->GetV0Indexes());
414 //iotrack.SetTPCpid(pt->fTPCr);
415 fEvent->AddTrack(&iotrack);
420 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
421 Int_t found,foundable,shared;
422 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
423 if (found<20) continue;
424 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
427 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
428 iotrack.SetTPCPoints(pt->GetPoints());
429 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
430 iotrack.SetV0Indexes(pt->GetV0Indexes());
431 //iotrack.SetTPCpid(pt->fTPCr);
432 //iotrack.SetTPCindex(i);
433 fEvent->AddTrack(&iotrack);
436 // short tracks - secondaties
438 if ( (pt->GetNumberOfClusters()>30) ) {
439 Int_t found,foundable,shared;
440 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
441 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
443 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
444 iotrack.SetTPCPoints(pt->GetPoints());
445 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
446 iotrack.SetV0Indexes(pt->GetV0Indexes());
447 //iotrack.SetTPCpid(pt->fTPCr);
448 //iotrack.SetTPCindex(i);
449 fEvent->AddTrack(&iotrack);
454 if ( (pt->GetNumberOfClusters()>15)) {
455 Int_t found,foundable,shared;
456 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
457 if (found<15) continue;
458 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
459 if (float(found)/float(foundable)<0.8) continue;
462 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
463 iotrack.SetTPCPoints(pt->GetPoints());
464 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
465 iotrack.SetV0Indexes(pt->GetV0Indexes());
466 // iotrack.SetTPCpid(pt->fTPCr);
467 //iotrack.SetTPCindex(i);
468 fEvent->AddTrack(&iotrack);
473 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
476 void AliTPCtrackerMI::WriteTracks(TTree * tree)
479 // write tracks from seed array to selected tree
483 AliTPCtrack *iotrack= new AliTPCtrack;
484 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
489 void AliTPCtrackerMI::WriteTracks()
492 // write tracks to the given output tree -
493 // output specified with SetIO routine
500 AliTPCtrack *iotrack= 0;
501 Int_t nseed=fSeeds->GetEntriesFast();
502 //for (Int_t i=0; i<nseed; i++) {
503 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
504 // if (iotrack) break;
506 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
507 TBranch * br = fOutput->GetBranch("tracks");
508 br->SetAddress(&iotrack);
510 for (Int_t i=0; i<nseed; i++) {
511 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
513 AliTPCtrack * track = new AliTPCtrack(*pt);
516 // br->SetAddress(&iotrack);
521 //fOutput->GetDirectory()->cd();
527 //write the full seed information if specified in debug mode
529 AliTPCseed * vseed = new AliTPCseed;
531 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
532 arrtr->ExpandCreateFast(160);
533 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
534 //arrcl->ExpandCreateFast(160);
535 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
537 vseed->fPoints = arrtr;
538 vseed->fEPoints = arre;
539 // vseed->fClusterPoints = arrcl;
540 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
541 TBranch * brseed = fSeedTree->GetBranch("seeds");
543 Int_t nseed=fSeeds->GetEntriesFast();
545 for (Int_t i=0; i<nseed; i++) {
546 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
549 // pt->fClusterPoints = arrcl;
553 brseed->SetAddress(&vseed);
557 // pt->fClusterPoints = 0;
560 if (fTreeDebug) fTreeDebug->Write();
568 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
571 //seed->SetErrorY2(0.1);
573 //calculate look-up table at the beginning
574 static Bool_t ginit = kFALSE;
575 static Float_t gnoise1,gnoise2,gnoise3;
576 static Float_t ggg1[10000];
577 static Float_t ggg2[10000];
578 static Float_t ggg3[10000];
579 static Float_t glandau1[10000];
580 static Float_t glandau2[10000];
581 static Float_t glandau3[10000];
583 static Float_t gcor01[500];
584 static Float_t gcor02[500];
585 static Float_t gcorp[500];
590 for (Int_t i=1;i<500;i++){
591 Float_t rsigma = float(i)/100.;
592 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
593 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
594 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
598 for (Int_t i=3;i<10000;i++){
602 Float_t amp = float(i);
603 Float_t padlength =0.75;
604 gnoise1 = 0.0004/padlength;
605 Float_t nel = 0.268*amp;
606 Float_t nprim = 0.155*amp;
607 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
608 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
609 if (glandau1[i]>1) glandau1[i]=1;
610 glandau1[i]*=padlength*padlength/12.;
614 gnoise2 = 0.0004/padlength;
617 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
618 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
619 if (glandau2[i]>1) glandau2[i]=1;
620 glandau2[i]*=padlength*padlength/12.;
625 gnoise3 = 0.0004/padlength;
628 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
629 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
630 if (glandau3[i]>1) glandau3[i]=1;
631 glandau3[i]*=padlength*padlength/12.;
639 Int_t amp = int(TMath::Abs(cl->GetQ()));
641 seed->SetErrorY2(1.);
645 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
646 Int_t ctype = cl->GetType();
647 Float_t padlength= GetPadPitchLength(seed->fRow);
648 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
649 angle2 = angle2/(1-angle2);
652 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
655 if (fSectors==fInnerSec){
657 res = ggg1[amp]*z+glandau1[amp]*angle2;
658 if (ctype==0) res *= gcor01[rsigmay];
661 res*= gcorp[rsigmay];
667 res = ggg2[amp]*z+glandau2[amp]*angle2;
668 if (ctype==0) res *= gcor02[rsigmay];
671 res*= gcorp[rsigmay];
676 res = ggg3[amp]*z+glandau3[amp]*angle2;
677 if (ctype==0) res *= gcor02[rsigmay];
680 res*= gcorp[rsigmay];
687 res*=2.4; // overestimate error 2 times
694 seed->SetErrorY2(res);
702 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
705 //seed->SetErrorY2(0.1);
707 //calculate look-up table at the beginning
708 static Bool_t ginit = kFALSE;
709 static Float_t gnoise1,gnoise2,gnoise3;
710 static Float_t ggg1[10000];
711 static Float_t ggg2[10000];
712 static Float_t ggg3[10000];
713 static Float_t glandau1[10000];
714 static Float_t glandau2[10000];
715 static Float_t glandau3[10000];
717 static Float_t gcor01[1000];
718 static Float_t gcor02[1000];
719 static Float_t gcorp[1000];
724 for (Int_t i=1;i<1000;i++){
725 Float_t rsigma = float(i)/100.;
726 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
727 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
728 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
732 for (Int_t i=3;i<10000;i++){
736 Float_t amp = float(i);
737 Float_t padlength =0.75;
738 gnoise1 = 0.0004/padlength;
739 Float_t nel = 0.268*amp;
740 Float_t nprim = 0.155*amp;
741 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
742 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
743 if (glandau1[i]>1) glandau1[i]=1;
744 glandau1[i]*=padlength*padlength/12.;
748 gnoise2 = 0.0004/padlength;
751 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
752 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
753 if (glandau2[i]>1) glandau2[i]=1;
754 glandau2[i]*=padlength*padlength/12.;
759 gnoise3 = 0.0004/padlength;
762 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
763 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
764 if (glandau3[i]>1) glandau3[i]=1;
765 glandau3[i]*=padlength*padlength/12.;
773 Int_t amp = int(TMath::Abs(cl->GetQ()));
775 seed->SetErrorY2(1.);
779 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
780 Int_t ctype = cl->GetType();
781 Float_t padlength= GetPadPitchLength(seed->fRow);
783 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
784 // if (angle2<0.6) angle2 = 0.6;
785 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
788 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
791 if (fSectors==fInnerSec){
793 res = ggg1[amp]*z+glandau1[amp]*angle2;
794 if (ctype==0) res *= gcor01[rsigmaz];
797 res*= gcorp[rsigmaz];
803 res = ggg2[amp]*z+glandau2[amp]*angle2;
804 if (ctype==0) res *= gcor02[rsigmaz];
807 res*= gcorp[rsigmaz];
812 res = ggg3[amp]*z+glandau3[amp]*angle2;
813 if (ctype==0) res *= gcor02[rsigmaz];
816 res*= gcorp[rsigmaz];
825 if ((ctype<0) &&<70){
833 seed->SetErrorZ2(res);
840 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
843 //seed->SetErrorZ2(0.1);
847 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
849 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
850 Int_t ctype = cl->GetType();
851 Float_t amp = TMath::Abs(cl->GetQ());
856 Float_t landau=2 ; //landau fluctuation part
857 Float_t gg=2; // gg fluctuation part
858 Float_t padlength= GetPadPitchLength(seed->GetX());
860 if (fSectors==fInnerSec){
861 snoise2 = 0.0004/padlength;
864 gg = (2+0.001*nel/(padlength*padlength))/nel;
865 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
866 if (landau>1) landau=1;
869 snoise2 = 0.0004/padlength;
872 gg = (2+0.0008*nel/(padlength*padlength))/nel;
873 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
874 if (landau>1) landau=1;
876 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
879 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
880 angle2 = TMath::Sqrt((1-angle2));
881 if (angle2<0.6) angle2 = 0.6;
884 Float_t angle = seed->GetTgl()/angle2;
885 Float_t angular = landau*angle*angle*padlength*padlength/12.;
886 Float_t res = sdiff + angular;
889 if ((ctype==0) && (fSectors ==fOuterSec))
890 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
892 if ((ctype==0) && (fSectors ==fInnerSec))
893 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
897 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
903 if ((ctype<0) &&<70){
911 seed->SetErrorZ2(res);
919 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
921 //rotate to track "local coordinata
922 Float_t x = seed->GetX();
923 Float_t y = seed->GetY();
924 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
927 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
928 if (!seed->Rotate(fSectors->GetAlpha()))
930 } else if (y <-ymax) {
931 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
932 if (!seed->Rotate(-fSectors->GetAlpha()))
940 //_____________________________________________________________________________
941 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
942 Double_t x2,Double_t y2,
943 Double_t x3,Double_t y3)
945 //-----------------------------------------------------------------
946 // Initial approximation of the track curvature
947 //-----------------------------------------------------------------
948 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
949 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
950 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
951 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
952 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
954 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
955 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
956 return -xr*yr/sqrt(xr*xr+yr*yr);
961 //_____________________________________________________________________________
962 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
963 Double_t x2,Double_t y2,
964 Double_t x3,Double_t y3)
966 //-----------------------------------------------------------------
967 // Initial approximation of the track curvature
968 //-----------------------------------------------------------------
974 Double_t det = x3*y2-x2*y3;
979 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
980 Double_t x0 = x3*0.5-y3*u;
981 Double_t y0 = y3*0.5+x3*u;
982 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
988 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
989 Double_t x2,Double_t y2,
990 Double_t x3,Double_t y3)
992 //-----------------------------------------------------------------
993 // Initial approximation of the track curvature
994 //-----------------------------------------------------------------
1000 Double_t det = x3*y2-x2*y3;
1005 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1006 Double_t x0 = x3*0.5-y3*u;
1007 Double_t y0 = y3*0.5+x3*u;
1008 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1017 //_____________________________________________________________________________
1018 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1019 Double_t x2,Double_t y2,
1020 Double_t x3,Double_t y3)
1022 //-----------------------------------------------------------------
1023 // Initial approximation of the track curvature times center of curvature
1024 //-----------------------------------------------------------------
1025 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1026 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1027 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1028 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1029 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1031 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1033 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1036 //_____________________________________________________________________________
1037 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1038 Double_t x2,Double_t y2,
1039 Double_t z1,Double_t z2)
1041 //-----------------------------------------------------------------
1042 // Initial approximation of the tangent of the track dip angle
1043 //-----------------------------------------------------------------
1044 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1048 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1049 Double_t x2,Double_t y2,
1050 Double_t z1,Double_t z2, Double_t c)
1052 //-----------------------------------------------------------------
1053 // Initial approximation of the tangent of the track dip angle
1054 //-----------------------------------------------------------------
1058 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1060 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1061 if (TMath::Abs(d*c*0.5)>1) return 0;
1062 // Double_t angle2 = TMath::ASin(d*c*0.5);
1063 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1064 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1066 angle2 = (z1-z2)*c/(angle2*2.);
1070 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1071 {//-----------------------------------------------------------------
1072 // This function find proloncation of a track to a reference plane x=x2.
1073 //-----------------------------------------------------------------
1077 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1081 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1082 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1086 Double_t dy = dx*(c1+c2)/(r1+r2);
1089 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1091 if (TMath::Abs(delta)>0.01){
1092 dz = x[3]*TMath::ASin(delta)/x[4];
1094 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1097 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1105 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1110 return LoadClusters();
1113 Int_t AliTPCtrackerMI::LoadClusters()
1116 // load clusters to the memory
1117 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1118 clrow->SetClass("AliTPCclusterMI");
1120 clrow->GetArray()->ExpandCreateFast(10000);
1122 // TTree * tree = fClustersArray.GetTree();
1124 TTree * tree = fInput;
1125 TBranch * br = tree->GetBranch("Segment");
1126 br->SetAddress(&clrow);
1128 Int_t j=Int_t(tree->GetEntries());
1129 for (Int_t i=0; i<j; i++) {
1133 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
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();
1197 //_____________________________________________________________________________
1198 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1199 //-----------------------------------------------------------------
1200 // This function fills outer TPC sectors with clusters.
1201 //-----------------------------------------------------------------
1202 Int_t nrows = fOuterSec->GetNRows();
1204 for (Int_t sec = 0;sec<fkNOS;sec++)
1205 for (Int_t row = 0;row<nrows;row++){
1206 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1207 Int_t sec2 = sec+2*fkNIS;
1209 Int_t ncl = tpcrow->fN1;
1211 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1212 index=(((sec2<<8)+row)<<16)+ncl;
1213 tpcrow->InsertCluster(c,index);
1218 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1219 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1220 tpcrow->InsertCluster(c,index);
1223 // write indexes for fast acces
1225 for (Int_t i=0;i<510;i++)
1226 tpcrow->fFastCluster[i]=-1;
1227 for (Int_t i=0;i<tpcrow->GetN();i++){
1228 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1229 tpcrow->fFastCluster[zi]=i; // write index
1232 for (Int_t i=0;i<510;i++){
1233 if (tpcrow->fFastCluster[i]<0)
1234 tpcrow->fFastCluster[i] = last;
1236 last = tpcrow->fFastCluster[i];
1245 //_____________________________________________________________________________
1246 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1247 //-----------------------------------------------------------------
1248 // This function fills inner TPC sectors with clusters.
1249 //-----------------------------------------------------------------
1250 Int_t nrows = fInnerSec->GetNRows();
1252 for (Int_t sec = 0;sec<fkNIS;sec++)
1253 for (Int_t row = 0;row<nrows;row++){
1254 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1257 Int_t ncl = tpcrow->fN1;
1259 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1260 index=(((sec<<8)+row)<<16)+ncl;
1261 tpcrow->InsertCluster(c,index);
1266 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1267 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1268 tpcrow->InsertCluster(c,index);
1271 // write indexes for fast acces
1273 for (Int_t i=0;i<510;i++)
1274 tpcrow->fFastCluster[i]=-1;
1275 for (Int_t i=0;i<tpcrow->GetN();i++){
1276 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1277 tpcrow->fFastCluster[zi]=i; // write index
1280 for (Int_t i=0;i<510;i++){
1281 if (tpcrow->fFastCluster[i]<0)
1282 tpcrow->fFastCluster[i] = last;
1284 last = tpcrow->fFastCluster[i];
1296 //_________________________________________________________________________
1297 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1298 //--------------------------------------------------------------------
1299 // Return pointer to a given cluster
1300 //--------------------------------------------------------------------
1301 Int_t sec=(index&0xff000000)>>24;
1302 Int_t row=(index&0x00ff0000)>>16;
1303 Int_t ncl=(index&0x00007fff)>>00;
1305 const AliTPCRow * tpcrow=0;
1306 AliTPCclusterMI * clrow =0;
1309 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1310 if (tpcrow==0) return 0;
1313 if (tpcrow->fN1<=ncl) return 0;
1314 clrow = tpcrow->fClusters1;
1317 if (tpcrow->fN2<=ncl) return 0;
1318 clrow = tpcrow->fClusters2;
1322 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1323 if (tpcrow==0) return 0;
1325 if (sec-2*fkNIS<fkNOS) {
1326 if (tpcrow->fN1<=ncl) return 0;
1327 clrow = tpcrow->fClusters1;
1330 if (tpcrow->fN2<=ncl) return 0;
1331 clrow = tpcrow->fClusters2;
1335 return &(clrow[ncl]);
1341 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1342 //-----------------------------------------------------------------
1343 // This function tries to find a track prolongation to next pad row
1344 //-----------------------------------------------------------------
1346 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1347 AliTPCclusterMI *cl=0;
1348 Int_t tpcindex= t.GetClusterIndex2(nr);
1350 // update current shape info every 5 pad-row
1351 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1355 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1357 if (tpcindex==-1) return 0; //track in dead zone
1359 cl = t.fClusterPointer[nr];
1360 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1361 t.fCurrentClusterIndex1 = tpcindex;
1364 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1365 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1367 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1368 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1370 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1371 Double_t rotation = angle-t.GetAlpha();
1372 t.fRelativeSector= relativesector;
1377 t.fCurrentCluster = cl;
1379 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1380 if ((tpcindex&0x8000)==0) accept =0;
1382 //if founded cluster is acceptible
1383 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1390 UpdateTrack(&t,accept);
1395 if (fIteration>1) {t.fNFoundable++; return 0;} // not look for new cluster during refitting
1398 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1399 Double_t y=t.GetYat(x);
1400 if (TMath::Abs(y)>ymax){
1402 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1403 if (!t.Rotate(fSectors->GetAlpha()))
1405 } else if (y <-ymax) {
1406 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1407 if (!t.Rotate(-fSectors->GetAlpha()))
1413 if (!t.PropagateTo(x)) {
1414 if (fIteration==0) t.fRemoval = 10;
1418 Double_t z=t.GetZ();
1420 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1421 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1423 Double_t roadz = 1.;
1425 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1427 t.SetClusterIndex2(nr,-1);
1432 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() ) t.fNFoundable++;
1438 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1439 cl = krow.FindNearest2(y,z,roady,roadz,index);
1440 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1443 t.fCurrentCluster = cl;
1445 if (fIteration==2&&cl->IsUsed(10)) return 0;
1446 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1447 if (fIteration==2&&cl->IsUsed(11)) {
1454 if (t.fCurrentCluster->IsUsed(10)){
1459 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1465 if (accept<3) UpdateTrack(&t,accept);
1468 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1474 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1475 //-----------------------------------------------------------------
1476 // This function tries to find a track prolongation to next pad row
1477 //-----------------------------------------------------------------
1479 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1481 if (!t.GetProlongation(x,y,z)) {
1487 if (TMath::Abs(y)>ymax){
1490 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1491 if (!t.Rotate(fSectors->GetAlpha()))
1493 } else if (y <-ymax) {
1494 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1495 if (!t.Rotate(-fSectors->GetAlpha()))
1498 if (!t.PropagateTo(x)) {
1501 t.GetProlongation(x,y,z);
1504 // update current shape info every 3 pad-row
1505 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1506 // t.fCurrentSigmaY = GetSigmaY(&t);
1507 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1511 AliTPCclusterMI *cl=0;
1516 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1517 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1519 Double_t roadz = 1.;
1522 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1524 t.SetClusterIndex2(row,-1);
1529 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1533 if ((cl==0)&&(krow)) {
1534 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1535 cl = krow.FindNearest2(y,z,roady,roadz,index);
1537 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1541 t.fCurrentCluster = cl;
1542 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1544 t.SetClusterIndex2(row,index);
1545 t.fClusterPointer[row] = cl;
1553 //_________________________________________________________________________
1554 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1556 // Get track space point by index
1557 // return false in case the cluster doesn't exist
1558 AliTPCclusterMI *cl = GetClusterMI(index);
1559 if (!cl) return kFALSE;
1560 Int_t sector = (index&0xff000000)>>24;
1561 Int_t row = (index&0x00ff0000)>>16;
1563 xyz[0] = fParam->GetPadRowRadii(sector,row);
1564 xyz[1] = cl->GetY();
1565 xyz[2] = cl->GetZ();
1567 fParam->AdjustCosSin(sector,cos,sin);
1568 Float_t x = cos*xyz[0]-sin*xyz[1];
1569 Float_t y = cos*xyz[1]+sin*xyz[0];
1571 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1572 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1573 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1574 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1575 cov[0] = sin*sin*sigmaY2;
1576 cov[1] = -sin*cos*sigmaY2;
1578 cov[3] = cos*cos*sigmaY2;
1581 p.SetXYZ(x,y,xyz[2],cov);
1582 AliAlignObj::ELayerID iLayer;
1584 if (sector < fParam->GetNInnerSector()) {
1585 iLayer = AliAlignObj::kTPC1;
1589 iLayer = AliAlignObj::kTPC2;
1590 idet = sector - fParam->GetNInnerSector();
1592 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1593 p.SetVolumeID(volid);
1599 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1600 //-----------------------------------------------------------------
1601 // This function tries to find a track prolongation to next pad row
1602 //-----------------------------------------------------------------
1603 t.fCurrentCluster = 0;
1604 t.fCurrentClusterIndex1 = 0;
1606 Double_t xt=t.GetX();
1607 Int_t row = GetRowNumber(xt)-1;
1608 Double_t ymax= GetMaxY(nr);
1610 if (row < nr) return 1; // don't prolongate if not information until now -
1611 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1613 // return 0; // not prolongate strongly inclined tracks
1615 // if (TMath::Abs(t.GetSnp())>0.95) {
1617 // return 0; // not prolongate strongly inclined tracks
1618 // }// patch 28 fev 06
1620 Double_t x= GetXrow(nr);
1622 //t.PropagateTo(x+0.02);
1623 //t.PropagateTo(x+0.01);
1624 if (!t.PropagateTo(x)){
1631 if (TMath::Abs(y)>ymax){
1633 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1634 if (!t.Rotate(fSectors->GetAlpha()))
1636 } else if (y <-ymax) {
1637 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1638 if (!t.Rotate(-fSectors->GetAlpha()))
1641 // if (!t.PropagateTo(x)){
1649 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1651 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1653 t.SetClusterIndex2(nr,-1);
1658 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1664 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1665 // t.fCurrentSigmaY = GetSigmaY(&t);
1666 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1670 AliTPCclusterMI *cl=0;
1673 Double_t roady = 1.;
1674 Double_t roadz = 1.;
1678 index = t.GetClusterIndex2(nr);
1679 if ( (index>0) && (index&0x8000)==0){
1680 cl = t.fClusterPointer[nr];
1681 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1682 t.fCurrentClusterIndex1 = index;
1684 t.fCurrentCluster = cl;
1690 // if (index<0) return 0;
1691 UInt_t uindex = TMath::Abs(index);
1694 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1695 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1698 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1699 t.fCurrentCluster = cl;
1705 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1706 //-----------------------------------------------------------------
1707 // This function tries to find a track prolongation to next pad row
1708 //-----------------------------------------------------------------
1710 //update error according neighborhoud
1712 if (t.fCurrentCluster) {
1714 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1716 if (t.fCurrentCluster->IsUsed(10)){
1722 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1727 if (fIteration>0) accept = 0;
1728 if (accept<3) UpdateTrack(&t,accept);
1732 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1733 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1735 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1743 //_____________________________________________________________________________
1744 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1745 //-----------------------------------------------------------------
1746 // This function tries to find a track prolongation.
1747 //-----------------------------------------------------------------
1748 Double_t xt=t.GetX();
1750 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1751 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1752 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1754 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1756 Int_t first = GetRowNumber(xt)-1;
1757 for (Int_t nr= first; nr>=rf; nr-=step) {
1759 if (t.GetKinkIndexes()[0]>0){
1760 for (Int_t i=0;i<3;i++){
1761 Int_t index = t.GetKinkIndexes()[i];
1762 if (index==0) break;
1763 if (index<0) continue;
1765 AliESDkink * kink = fEvent->GetKink(index-1);
1767 printf("PROBLEM\n");
1770 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1772 AliExternalTrackParam paramd(t);
1773 kink->SetDaughter(paramd);
1774 kink->SetStatus(2,5);
1781 if (nr==80) t.UpdateReference();
1782 if (nr<fInnerSec->GetNRows())
1783 fSectors = fInnerSec;
1785 fSectors = fOuterSec;
1786 if (FollowToNext(t,nr)==0)
1795 //_____________________________________________________________________________
1796 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1797 //-----------------------------------------------------------------
1798 // This function tries to find a track prolongation.
1799 //-----------------------------------------------------------------
1800 Double_t xt=t.GetX();
1802 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1803 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1804 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1805 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1807 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1809 if (FollowToNextFast(t,nr)==0)
1810 if (!t.IsActive()) return 0;
1820 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1821 //-----------------------------------------------------------------
1822 // This function tries to find a track prolongation.
1823 //-----------------------------------------------------------------
1825 Double_t xt=t.GetX();
1826 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1827 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1828 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1829 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1831 Int_t first = t.fFirstPoint;
1832 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1834 if (first<0) first=0;
1835 for (Int_t nr=first; nr<=rf; nr++) {
1836 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1837 if (t.GetKinkIndexes()[0]<0){
1838 for (Int_t i=0;i<3;i++){
1839 Int_t index = t.GetKinkIndexes()[i];
1840 if (index==0) break;
1841 if (index>0) continue;
1842 index = TMath::Abs(index);
1843 AliESDkink * kink = fEvent->GetKink(index-1);
1845 printf("PROBLEM\n");
1848 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1850 AliExternalTrackParam paramm(t);
1851 kink->SetMother(paramm);
1852 kink->SetStatus(2,1);
1859 if (nr<fInnerSec->GetNRows())
1860 fSectors = fInnerSec;
1862 fSectors = fOuterSec;
1872 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1880 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1883 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1885 Float_t distance = TMath::Sqrt(dz2+dy2);
1886 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1889 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1890 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1895 if (firstpoint>lastpoint) {
1896 firstpoint =lastpoint;
1901 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1902 if (s1->GetClusterIndex2(i)>0) sum1++;
1903 if (s2->GetClusterIndex2(i)>0) sum2++;
1904 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1908 if (sum<5) return 0;
1910 Float_t summin = TMath::Min(sum1+1,sum2+1);
1911 Float_t ratio = (sum+1)/Float_t(summin);
1915 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1919 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1920 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1922 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1924 Float_t dy2 =(s1->GetY() - s2->GetY());
1926 Float_t distance = dz2+dy2;
1927 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1932 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1933 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1935 if (firstpoint>=lastpoint-5) return;;
1937 for (Int_t i=firstpoint;i<lastpoint;i++){
1938 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1939 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1946 for (Int_t i=firstpoint;i<lastpoint;i++){
1947 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1948 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1949 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1950 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1951 if (s1->IsActive()&&s2->IsActive()){
1952 p1->fIsShared = kTRUE;
1953 p2->fIsShared = kTRUE;
1960 for (Int_t i=0;i<4;i++){
1961 if (s1->fOverlapLabels[3*i]==0){
1962 s1->fOverlapLabels[3*i] = s2->GetLabel();
1963 s1->fOverlapLabels[3*i+1] = sumshared;
1964 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1968 for (Int_t i=0;i<4;i++){
1969 if (s2->fOverlapLabels[3*i]==0){
1970 s2->fOverlapLabels[3*i] = s1->GetLabel();
1971 s2->fOverlapLabels[3*i+1] = sumshared;
1972 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1980 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1983 //sort trackss according sectors
1985 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1986 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1988 //if (pt) RotateToLocal(pt);
1992 arr->Sort(); // sorting according z
1993 arr->Expand(arr->GetEntries());
1996 Int_t nseed=arr->GetEntriesFast();
1997 for (Int_t i=0; i<nseed; i++) {
1998 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2000 for (Int_t j=0;j<=12;j++){
2001 pt->fOverlapLabels[j] =0;
2004 for (Int_t i=0; i<nseed; i++) {
2005 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2007 if (pt->fRemoval>10) continue;
2008 for (Int_t j=i+1; j<nseed; j++){
2009 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2011 if (pt2->fRemoval<=10) {
2012 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2019 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2022 //sort trackss according sectors
2025 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2028 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2029 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2034 arr->Sort(); // sorting according z
2035 arr->Expand(arr->GetEntries());
2037 //reset overlap labels
2039 Int_t nseed=arr->GetEntriesFast();
2040 for (Int_t i=0; i<nseed; i++) {
2041 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2044 for (Int_t j=0;j<=12;j++){
2045 pt->fOverlapLabels[j] =0;
2049 //sign shared tracks
2050 for (Int_t i=0; i<nseed; i++) {
2051 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2053 if (pt->fRemoval>10) continue;
2054 Float_t deltac = pt->GetC()*0.1;
2055 for (Int_t j=i+1; j<nseed; j++){
2056 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2058 if (pt2->fRemoval<=10) {
2059 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2060 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2061 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2068 // remove highly shared tracks
2069 for (Int_t i=0; i<nseed; i++) {
2070 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2072 if (pt->fRemoval>10) continue;
2075 for (Int_t j=0;j<4;j++){
2076 sumshared = pt->fOverlapLabels[j*3+1];
2078 Float_t factor = factor1;
2079 if (pt->fRemoval>0) factor = factor2;
2080 if (sumshared/pt->GetNumberOfClusters()>factor){
2081 for (Int_t j=0;j<4;j++){
2082 if (pt->fOverlapLabels[3*j]==0) continue;
2083 if (pt->fOverlapLabels[3*j+1]<5) continue;
2084 if (pt->fRemoval==removalindex) continue;
2085 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2087 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2088 // pt->fRemoval = removalindex;
2089 delete arr->RemoveAt(i);
2097 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2106 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2109 //sort tracks in array according mode criteria
2110 Int_t nseed = arr->GetEntriesFast();
2111 for (Int_t i=0; i<nseed; i++) {
2112 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2122 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2125 //Loop over all tracks and remove "overlaps"
2128 Int_t nseed = arr->GetEntriesFast();
2131 for (Int_t i=0; i<nseed; i++) {
2132 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2134 delete arr->RemoveAt(i);
2138 pt->fBSigned = kFALSE;
2142 nseed = arr->GetEntriesFast();
2149 for (Int_t i=0; i<nseed; i++) {
2150 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2154 Int_t found,foundable,shared;
2156 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2158 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2160 Double_t factor = factor2;
2161 if (pt->fBConstrain) factor = factor1;
2163 if ((Float_t(shared)/Float_t(found))>factor){
2164 pt->Desactivate(removalindex);
2169 for (Int_t i=0; i<160; i++) {
2170 Int_t index=pt->GetClusterIndex2(i);
2171 if (index<0 || index&0x8000 ) continue;
2172 AliTPCclusterMI *c= pt->fClusterPointer[i];
2174 // if (!c->IsUsed(10)) c->Use(10);
2175 //if (pt->IsActive())
2184 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2189 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2192 //Loop over all tracks and remove "overlaps"
2197 Int_t nseed = arr->GetEntriesFast();
2198 Float_t * quality = new Float_t[nseed];
2199 Int_t * indexes = new Int_t[nseed];
2203 for (Int_t i=0; i<nseed; i++) {
2204 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2209 pt->UpdatePoints(); //select first last max dens points
2210 Float_t * points = pt->GetPoints();
2211 if (points[3]<0.8) quality[i] =-1;
2213 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2215 TMath::Sort(nseed,quality,indexes);
2218 for (Int_t itrack=0; itrack<nseed; itrack++) {
2219 Int_t trackindex = indexes[itrack];
2220 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2221 if (quality[trackindex]<0){
2223 delete arr->RemoveAt(trackindex);
2226 arr->RemoveAt(trackindex);
2231 Int_t first = Int_t(pt->GetPoints()[0]);
2232 Int_t last = Int_t(pt->GetPoints()[2]);
2233 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2235 Int_t found,foundable,shared;
2236 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2237 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2238 Bool_t itsgold =kFALSE;
2241 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
2245 if (Float_t(shared+1)/Float_t(found+1)>factor){
2246 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2247 delete arr->RemoveAt(trackindex);
2250 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2251 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2252 delete arr->RemoveAt(trackindex);
2258 if (sharedfactor>0.4) continue;
2259 if (pt->GetKinkIndexes()[0]>0) continue;
2260 for (Int_t i=first; i<last; i++) {
2261 Int_t index=pt->GetClusterIndex2(i);
2262 // if (index<0 || index&0x8000 ) continue;
2263 if (index<0 || index&0x8000 ) continue;
2264 AliTPCclusterMI *c= pt->fClusterPointer[i];
2271 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2277 void AliTPCtrackerMI::UnsignClusters()
2280 // loop over all clusters and unsign them
2283 for (Int_t sec=0;sec<fkNIS;sec++){
2284 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2285 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2286 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2287 // if (cl[icl].IsUsed(10))
2289 cl = fInnerSec[sec][row].fClusters2;
2290 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2291 //if (cl[icl].IsUsed(10))
2296 for (Int_t sec=0;sec<fkNOS;sec++){
2297 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2298 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2299 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2300 //if (cl[icl].IsUsed(10))
2302 cl = fOuterSec[sec][row].fClusters2;
2303 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2304 //if (cl[icl].IsUsed(10))
2313 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2316 //sign clusters to be "used"
2318 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2319 // loop over "primaries"
2333 Int_t nseed = arr->GetEntriesFast();
2334 for (Int_t i=0; i<nseed; i++) {
2335 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2339 if (!(pt->IsActive())) continue;
2340 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2341 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2343 sumdens2+= dens*dens;
2344 sumn += pt->GetNumberOfClusters();
2345 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2346 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2349 sumchi2 +=chi2*chi2;
2354 Float_t mdensity = 0.9;
2355 Float_t meann = 130;
2356 Float_t meanchi = 1;
2357 Float_t sdensity = 0.1;
2358 Float_t smeann = 10;
2359 Float_t smeanchi =0.4;
2363 mdensity = sumdens/sum;
2365 meanchi = sumchi/sum;
2367 sdensity = sumdens2/sum-mdensity*mdensity;
2368 sdensity = TMath::Sqrt(sdensity);
2370 smeann = sumn2/sum-meann*meann;
2371 smeann = TMath::Sqrt(smeann);
2373 smeanchi = sumchi2/sum - meanchi*meanchi;
2374 smeanchi = TMath::Sqrt(smeanchi);
2378 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2380 for (Int_t i=0; i<nseed; i++) {
2381 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2385 if (pt->fBSigned) continue;
2386 if (pt->fBConstrain) continue;
2387 //if (!(pt->IsActive())) continue;
2389 Int_t found,foundable,shared;
2390 pt->GetClusterStatistic(0,160,found, foundable,shared);
2391 if (shared/float(found)>0.3) {
2392 if (shared/float(found)>0.9 ){
2393 //delete arr->RemoveAt(i);
2398 Bool_t isok =kFALSE;
2399 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2401 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2403 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2405 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2409 for (Int_t i=0; i<160; i++) {
2410 Int_t index=pt->GetClusterIndex2(i);
2411 if (index<0) continue;
2412 AliTPCclusterMI *c= pt->fClusterPointer[i];
2414 //if (!(c->IsUsed(10))) c->Use();
2421 Double_t maxchi = meanchi+2.*smeanchi;
2423 for (Int_t i=0; i<nseed; i++) {
2424 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2428 //if (!(pt->IsActive())) continue;
2429 if (pt->fBSigned) continue;
2430 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2431 if (chi>maxchi) continue;
2434 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2436 //sign only tracks with enoug big density at the beginning
2438 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2441 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2442 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2444 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2445 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2448 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2449 //Int_t noc=pt->GetNumberOfClusters();
2450 pt->fBSigned = kTRUE;
2451 for (Int_t i=0; i<160; i++) {
2453 Int_t index=pt->GetClusterIndex2(i);
2454 if (index<0) continue;
2455 AliTPCclusterMI *c= pt->fClusterPointer[i];
2457 // if (!(c->IsUsed(10))) c->Use();
2462 // gLastCheck = nseed;
2470 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2472 // stop not active tracks
2473 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2474 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2475 Int_t nseed = arr->GetEntriesFast();
2477 for (Int_t i=0; i<nseed; i++) {
2478 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2482 if (!(pt->IsActive())) continue;
2483 StopNotActive(pt,row0,th0, th1,th2);
2489 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2492 // stop not active tracks
2493 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2494 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2497 Int_t foundable = 0;
2498 Int_t maxindex = seed->fLastPoint; //last foundable row
2499 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2500 seed->Desactivate(10) ;
2504 for (Int_t i=row0; i<maxindex; i++){
2505 Int_t index = seed->GetClusterIndex2(i);
2506 if (index!=-1) foundable++;
2508 if (foundable<=30) sumgood1++;
2509 if (foundable<=50) {
2516 if (foundable>=30.){
2517 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2520 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2524 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2527 // back propagation of ESD tracks
2533 //PrepareForProlongation(fSeeds,1);
2534 PropagateForward2(fSeeds);
2537 Int_t nseed = fSeeds->GetEntriesFast();
2538 for (Int_t i=0;i<nseed;i++){
2539 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2540 if (!seed) continue;
2541 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2543 seed->PropagateTo(fParam->GetInnerRadiusLow());
2544 seed->UpdatePoints();
2545 AliESDtrack *esd=event->GetTrack(i);
2546 seed->CookdEdx(0.02,0.6);
2547 CookLabel(seed,0.1); //For comparison only
2549 if (0 && seed!=0&&esd!=0) {
2550 TTreeSRedirector &cstream = *fDebugStreamer;
2556 if (seed->GetNumberOfClusters()>15){
2557 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2558 esd->SetTPCPoints(seed->GetPoints());
2559 esd->SetTPCPointsF(seed->fNFoundable);
2560 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2561 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2562 Float_t dedx = seed->GetdEdx();
2563 esd->SetTPCsignal(dedx, sdedx, ndedx);
2567 //printf("problem\n");
2570 //FindKinks(fSeeds,event);
2571 Info("RefitInward","Number of refitted tracks %d",ntracks);
2578 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2581 // back propagation of ESD tracks
2587 PropagateBack(fSeeds);
2588 RemoveUsed2(fSeeds,0.4,0.4,20);
2590 Int_t nseed = fSeeds->GetEntriesFast();
2592 for (Int_t i=0;i<nseed;i++){
2593 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2594 if (!seed) continue;
2595 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2596 seed->UpdatePoints();
2597 AliESDtrack *esd=event->GetTrack(i);
2598 seed->CookdEdx(0.02,0.6);
2599 CookLabel(seed,0.1); //For comparison only
2600 if (seed->GetNumberOfClusters()>15){
2601 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
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 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2610 (*fDebugStreamer)<<"Cback"<<
2612 "EventNr="<<eventnumber<<
2613 "\n"; // patch 28 fev 06
2616 //FindKinks(fSeeds,event);
2617 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2624 void AliTPCtrackerMI::DeleteSeeds()
2628 Int_t nseed = fSeeds->GetEntriesFast();
2629 for (Int_t i=0;i<nseed;i++){
2630 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2631 if (seed) delete fSeeds->RemoveAt(i);
2637 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2640 //read seeds from the event
2642 Int_t nentr=event->GetNumberOfTracks();
2644 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2649 fSeeds = new TObjArray(nentr);
2653 for (Int_t i=0; i<nentr; i++) {
2654 AliESDtrack *esd=event->GetTrack(i);
2655 ULong_t status=esd->GetStatus();
2656 if (!(status&AliESDtrack::kTPCin)) continue;
2657 AliTPCtrack t(*esd);
2658 t.SetNumberOfClusters(0);
2659 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2660 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2661 for (Int_t ikink=0;ikink<3;ikink++) {
2662 Int_t index = esd->GetKinkIndex(ikink);
2663 seed->GetKinkIndexes()[ikink] = index;
2664 if (index==0) continue;
2665 index = TMath::Abs(index);
2666 AliESDkink * kink = fEvent->GetKink(index-1);
2667 if (kink&&esd->GetKinkIndex(ikink)<0){
2668 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2669 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2671 if (kink&&esd->GetKinkIndex(ikink)>0){
2672 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2673 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2677 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance();
2678 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2679 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2684 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2685 Double_t par0[5],par1[5],alpha,x;
2686 esd->GetInnerExternalParameters(alpha,x,par0);
2687 esd->GetExternalParameters(x,par1);
2688 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2689 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2691 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2692 //reset covariance if suspicious
2693 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2694 seed->ResetCovariance();
2699 // rotate to the local coordinate system
2701 fSectors=fInnerSec; fN=fkNIS;
2702 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2703 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2704 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2705 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2706 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2707 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2708 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2709 alpha-=seed->GetAlpha();
2710 if (!seed->Rotate(alpha)) {
2716 if (esd->GetKinkIndex(0)<=0){
2717 for (Int_t irow=0;irow<160;irow++){
2718 Int_t index = seed->GetClusterIndex2(irow);
2721 AliTPCclusterMI * cl = GetClusterMI(index);
2722 seed->fClusterPointer[irow] = cl;
2724 if ((index & 0x8000)==0){
2725 cl->Use(10); // accepted cluster
2727 cl->Use(6); // close cluster not accepted
2730 Info("ReadSeeds","Not found cluster");
2735 fSeeds->AddAt(seed,i);
2741 //_____________________________________________________________________________
2742 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2743 Float_t deltay, Int_t ddsec) {
2744 //-----------------------------------------------------------------
2745 // This function creates track seeds.
2746 // SEEDING WITH VERTEX CONSTRAIN
2747 //-----------------------------------------------------------------
2748 // cuts[0] - fP4 cut
2749 // cuts[1] - tan(phi) cut
2750 // cuts[2] - zvertex cut
2751 // cuts[3] - fP3 cut
2759 Double_t x[5], c[15];
2760 // Int_t di = i1-i2;
2762 AliTPCseed * seed = new AliTPCseed;
2763 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2764 Double_t cs=cos(alpha), sn=sin(alpha);
2766 // Double_t x1 =fOuterSec->GetX(i1);
2767 //Double_t xx2=fOuterSec->GetX(i2);
2769 Double_t x1 =GetXrow(i1);
2770 Double_t xx2=GetXrow(i2);
2772 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2774 Int_t imiddle = (i2+i1)/2; //middle pad row index
2775 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2776 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2780 const AliTPCRow& kr1=GetRow(ns,i1);
2781 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2782 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2785 // change cut on curvature if it can't reach this layer
2786 // maximal curvature set to reach it
2787 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2788 if (dvertexmax*0.5*cuts[0]>0.85){
2789 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2791 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2794 if (deltay>0) ddsec = 0;
2795 // loop over clusters
2796 for (Int_t is=0; is < kr1; is++) {
2798 if (kr1[is]->IsUsed(10)) continue;
2799 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2800 //if (TMath::Abs(y1)>ymax) continue;
2802 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2804 // find possible directions
2805 Float_t anglez = (z1-z3)/(x1-x3);
2806 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2809 //find rotation angles relative to line given by vertex and point 1
2810 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2811 Double_t dvertex = TMath::Sqrt(dvertex2);
2812 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2813 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2816 // loop over 2 sectors
2822 Double_t dddz1=0; // direction of delta inclination in z axis
2829 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2830 Int_t sec2 = sec + dsec;
2832 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2833 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2834 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2835 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2836 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2837 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2839 // rotation angles to p1-p3
2840 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2841 Double_t x2, y2, z2;
2843 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2846 Double_t dxx0 = (xx2-x3)*cs13r;
2847 Double_t dyy0 = (xx2-x3)*sn13r;
2848 for (Int_t js=index1; js < index2; js++) {
2849 const AliTPCclusterMI *kcl = kr2[js];
2850 if (kcl->IsUsed(10)) continue;
2852 //calcutate parameters
2854 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2856 if (TMath::Abs(yy0)<0.000001) continue;
2857 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2858 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2859 Double_t r02 = (0.25+y0*y0)*dvertex2;
2860 //curvature (radius) cut
2861 if (r02<r2min) continue;
2865 Double_t c0 = 1/TMath::Sqrt(r02);
2869 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2870 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2871 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2872 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2875 Double_t z0 = kcl->GetZ();
2876 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2877 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2880 Double_t dip = (z1-z0)*c0/dfi1;
2881 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2892 x2= xx2*cs-y2*sn*dsec;
2893 y2=+xx2*sn*dsec+y2*cs;
2903 // do we have cluster at the middle ?
2905 GetProlongation(x1,xm,x,ym,zm);
2907 AliTPCclusterMI * cm=0;
2908 if (TMath::Abs(ym)-ymaxm<0){
2909 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2910 if ((!cm) || (cm->IsUsed(10))) {
2915 // rotate y1 to system 0
2916 // get state vector in rotated system
2917 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2918 Double_t xr2 = x0*cs+yr1*sn*dsec;
2919 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2921 GetProlongation(xx2,xm,xr,ym,zm);
2922 if (TMath::Abs(ym)-ymaxm<0){
2923 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2924 if ((!cm) || (cm->IsUsed(10))) {
2934 dym = ym - cm->GetY();
2935 dzm = zm - cm->GetZ();
2942 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2943 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2944 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2945 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2946 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2948 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2949 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2950 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2951 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2952 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2953 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2955 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2956 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2957 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2958 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2962 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2963 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2964 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2965 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2966 c[13]=f30*sy1*f40+f32*sy2*f42;
2967 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2969 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2971 UInt_t index=kr1.GetIndex(is);
2972 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2974 track->fIsSeeding = kTRUE;
2981 FollowProlongation(*track, (i1+i2)/2,1);
2982 Int_t foundable,found,shared;
2983 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2984 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2986 seed->~AliTPCseed();
2992 FollowProlongation(*track, i2,1);
2996 track->fBConstrain =1;
2997 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2998 track->fLastPoint = i1; // first cluster in track position
2999 track->fFirstPoint = track->fLastPoint;
3001 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3002 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3003 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3005 seed->~AliTPCseed();
3009 // Z VERTEX CONDITION
3011 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3012 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3013 if (TMath::Abs(zv-z3)>cuts[2]) {
3014 FollowProlongation(*track, TMath::Max(i2-20,0));
3015 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3016 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3017 if (TMath::Abs(zv-z3)>cuts[2]){
3018 FollowProlongation(*track, TMath::Max(i2-40,0));
3019 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3020 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3021 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3022 // make seed without constrain
3023 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3024 FollowProlongation(*track2, i2,1);
3025 track2->fBConstrain = kFALSE;
3026 track2->fSeedType = 1;
3027 arr->AddLast(track2);
3029 seed->~AliTPCseed();
3034 seed->~AliTPCseed();
3041 track->fSeedType =0;
3042 arr->AddLast(track);
3043 seed = new AliTPCseed;
3045 // don't consider other combinations
3046 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3052 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3058 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3063 //-----------------------------------------------------------------
3064 // This function creates track seeds.
3065 //-----------------------------------------------------------------
3066 // cuts[0] - fP4 cut
3067 // cuts[1] - tan(phi) cut
3068 // cuts[2] - zvertex cut
3069 // cuts[3] - fP3 cut
3079 Double_t x[5], c[15];
3081 // make temporary seed
3082 AliTPCseed * seed = new AliTPCseed;
3083 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3084 // Double_t cs=cos(alpha), sn=sin(alpha);
3089 Double_t x1 = GetXrow(i1-1);
3090 const AliTPCRow& kr1=GetRow(sec,i1-1);
3091 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3093 Double_t x1p = GetXrow(i1);
3094 const AliTPCRow& kr1p=GetRow(sec,i1);
3096 Double_t x1m = GetXrow(i1-2);
3097 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3100 //last 3 padrow for seeding
3101 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3102 Double_t x3 = GetXrow(i1-7);
3103 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3105 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3106 Double_t x3p = GetXrow(i1-6);
3108 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3109 Double_t x3m = GetXrow(i1-8);
3114 Int_t im = i1-4; //middle pad row index
3115 Double_t xm = GetXrow(im); // radius of middle pad-row
3116 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3117 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3120 Double_t deltax = x1-x3;
3121 Double_t dymax = deltax*cuts[1];
3122 Double_t dzmax = deltax*cuts[3];
3124 // loop over clusters
3125 for (Int_t is=0; is < kr1; is++) {
3127 if (kr1[is]->IsUsed(10)) continue;
3128 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3130 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3132 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3133 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3139 for (Int_t js=index1; js < index2; js++) {
3140 const AliTPCclusterMI *kcl = kr3[js];
3141 if (kcl->IsUsed(10)) continue;
3143 // apply angular cuts
3144 if (TMath::Abs(y1-y3)>dymax) continue;
3147 if (TMath::Abs(z1-z3)>dzmax) continue;
3149 Double_t angley = (y1-y3)/(x1-x3);
3150 Double_t anglez = (z1-z3)/(x1-x3);
3152 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3153 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3155 Double_t yyym = angley*(xm-x1)+y1;
3156 Double_t zzzm = anglez*(xm-x1)+z1;
3158 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3160 if (kcm->IsUsed(10)) continue;
3162 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3163 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3170 // look around first
3171 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3177 if (kc1m->IsUsed(10)) used++;
3179 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3185 if (kc1p->IsUsed(10)) used++;
3187 if (used>1) continue;
3188 if (found<1) continue;
3192 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3198 if (kc3m->IsUsed(10)) used++;
3202 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3208 if (kc3p->IsUsed(10)) used++;
3212 if (used>1) continue;
3213 if (found<3) continue;
3223 x[4]=F1(x1,y1,x2,y2,x3,y3);
3224 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3227 x[2]=F2(x1,y1,x2,y2,x3,y3);
3230 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3231 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3235 Double_t sy1=0.1, sz1=0.1;
3236 Double_t sy2=0.1, sz2=0.1;
3237 Double_t sy3=0.1, sy=0.1, sz=0.1;
3239 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3240 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3241 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3242 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3243 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3244 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3246 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3247 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3248 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3249 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3253 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3254 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3255 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3256 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3257 c[13]=f30*sy1*f40+f32*sy2*f42;
3258 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3260 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3262 UInt_t index=kr1.GetIndex(is);
3263 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3265 track->fIsSeeding = kTRUE;
3268 FollowProlongation(*track, i1-7,1);
3269 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3270 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3272 seed->~AliTPCseed();
3278 FollowProlongation(*track, i2,1);
3279 track->fBConstrain =0;
3280 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3281 track->fFirstPoint = track->fLastPoint;
3283 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3284 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3285 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3287 seed->~AliTPCseed();
3292 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3293 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3294 FollowProlongation(*track2, i2,1);
3295 track2->fBConstrain = kFALSE;
3296 track2->fSeedType = 4;
3297 arr->AddLast(track2);
3299 seed->~AliTPCseed();
3303 //arr->AddLast(track);
3304 //seed = new AliTPCseed;
3310 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3316 //_____________________________________________________________________________
3317 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3318 Float_t deltay, Bool_t /*bconstrain*/) {
3319 //-----------------------------------------------------------------
3320 // This function creates track seeds - without vertex constraint
3321 //-----------------------------------------------------------------
3322 // cuts[0] - fP4 cut - not applied
3323 // cuts[1] - tan(phi) cut
3324 // cuts[2] - zvertex cut - not applied
3325 // cuts[3] - fP3 cut
3335 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3336 // Double_t cs=cos(alpha), sn=sin(alpha);
3337 Int_t row0 = (i1+i2)/2;
3338 Int_t drow = (i1-i2)/2;
3339 const AliTPCRow& kr0=fSectors[sec][row0];
3342 AliTPCpolyTrack polytrack;
3343 Int_t nclusters=fSectors[sec][row0];
3344 AliTPCseed * seed = new AliTPCseed;
3349 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3351 Int_t nfoundable =0;
3352 for (Int_t iter =1; iter<2; iter++){ //iterations
3353 const AliTPCRow& krm=fSectors[sec][row0-iter];
3354 const AliTPCRow& krp=fSectors[sec][row0+iter];
3355 const AliTPCclusterMI * cl= kr0[is];
3357 if (cl->IsUsed(10)) {
3363 Double_t x = kr0.GetX();
3364 // Initialization of the polytrack
3369 Double_t y0= cl->GetY();
3370 Double_t z0= cl->GetZ();
3374 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3375 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3377 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3378 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3379 polytrack.AddPoint(x,y0,z0,erry, errz);
3382 if (cl->IsUsed(10)) sumused++;
3385 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3386 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3389 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3390 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3391 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3392 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3393 if (cl1->IsUsed(10)) sumused++;
3394 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3398 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3400 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3401 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3402 if (cl2->IsUsed(10)) sumused++;
3403 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3406 if (sumused>0) continue;
3408 polytrack.UpdateParameters();
3414 nfoundable = polytrack.GetN();
3415 nfound = nfoundable;
3417 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3418 Float_t maxdist = 0.8*(1.+3./(ddrow));
3419 for (Int_t delta = -1;delta<=1;delta+=2){
3420 Int_t row = row0+ddrow*delta;
3421 kr = &(fSectors[sec][row]);
3422 Double_t xn = kr->GetX();
3423 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3424 polytrack.GetFitPoint(xn,yn,zn);
3425 if (TMath::Abs(yn)>ymax) continue;
3427 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3429 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3432 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3433 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3434 if (cln->IsUsed(10)) {
3435 // printf("used\n");
3443 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3448 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3449 polytrack.UpdateParameters();
3452 if ( (sumused>3) || (sumused>0.5*nfound)) {
3453 //printf("sumused %d\n",sumused);
3458 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3459 AliTPCpolyTrack track2;
3461 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3462 if (track2.GetN()<0.5*nfoundable) continue;
3465 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3467 // test seed with and without constrain
3468 for (Int_t constrain=0; constrain<=0;constrain++){
3469 // add polytrack candidate
3471 Double_t x[5], c[15];
3472 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3473 track2.GetBoundaries(x3,x1);
3475 track2.GetFitPoint(x1,y1,z1);
3476 track2.GetFitPoint(x2,y2,z2);
3477 track2.GetFitPoint(x3,y3,z3);
3479 //is track pointing to the vertex ?
3482 polytrack.GetFitPoint(x0,y0,z0);
3495 x[4]=F1(x1,y1,x2,y2,x3,y3);
3497 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3498 x[2]=F2(x1,y1,x2,y2,x3,y3);
3500 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3501 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3502 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3503 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3506 Double_t sy =0.1, sz =0.1;
3507 Double_t sy1=0.02, sz1=0.02;
3508 Double_t sy2=0.02, sz2=0.02;
3512 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3515 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3516 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3517 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3518 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3519 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3520 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3522 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3523 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3524 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3525 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3530 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3531 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3532 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3533 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3534 c[13]=f30*sy1*f40+f32*sy2*f42;
3535 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3537 //Int_t row1 = fSectors->GetRowNumber(x1);
3538 Int_t row1 = GetRowNumber(x1);
3542 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3543 track->fIsSeeding = kTRUE;
3544 Int_t rc=FollowProlongation(*track, i2);
3545 if (constrain) track->fBConstrain =1;
3547 track->fBConstrain =0;
3548 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3549 track->fFirstPoint = track->fLastPoint;
3551 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3552 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3553 track->fNShared>0.4*track->GetNumberOfClusters()) {
3556 seed->~AliTPCseed();
3559 arr->AddLast(track);
3560 seed = new AliTPCseed;
3564 } // if accepted seed
3567 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3573 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3577 //reseed using track points
3578 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3579 Int_t p1 = int(r1*track->GetNumberOfClusters());
3580 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3582 Double_t x0[3],x1[3],x2[3];
3583 for (Int_t i=0;i<3;i++){
3589 // find track position at given ratio of the length
3590 Int_t sec0=0, sec1=0, sec2=0;
3593 for (Int_t i=0;i<160;i++){
3594 if (track->fClusterPointer[i]){
3596 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3597 if ( (index<p0) || x0[0]<0 ){
3598 if (trpoint->GetX()>1){
3599 clindex = track->GetClusterIndex2(i);
3601 x0[0] = trpoint->GetX();
3602 x0[1] = trpoint->GetY();
3603 x0[2] = trpoint->GetZ();
3604 sec0 = ((clindex&0xff000000)>>24)%18;
3609 if ( (index<p1) &&(trpoint->GetX()>1)){
3610 clindex = track->GetClusterIndex2(i);
3612 x1[0] = trpoint->GetX();
3613 x1[1] = trpoint->GetY();
3614 x1[2] = trpoint->GetZ();
3615 sec1 = ((clindex&0xff000000)>>24)%18;
3618 if ( (index<p2) &&(trpoint->GetX()>1)){
3619 clindex = track->GetClusterIndex2(i);
3621 x2[0] = trpoint->GetX();
3622 x2[1] = trpoint->GetY();
3623 x2[2] = trpoint->GetZ();
3624 sec2 = ((clindex&0xff000000)>>24)%18;
3631 Double_t alpha, cs,sn, xx2,yy2;
3633 alpha = (sec1-sec2)*fSectors->GetAlpha();
3634 cs = TMath::Cos(alpha);
3635 sn = TMath::Sin(alpha);
3636 xx2= x1[0]*cs-x1[1]*sn;
3637 yy2= x1[0]*sn+x1[1]*cs;
3641 alpha = (sec0-sec2)*fSectors->GetAlpha();
3642 cs = TMath::Cos(alpha);
3643 sn = TMath::Sin(alpha);
3644 xx2= x0[0]*cs-x0[1]*sn;
3645 yy2= x0[0]*sn+x0[1]*cs;
3651 Double_t x[5],c[15];
3655 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3656 // if (x[4]>1) return 0;
3657 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3658 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3659 //if (TMath::Abs(x[3]) > 2.2) return 0;
3660 //if (TMath::Abs(x[2]) > 1.99) return 0;
3662 Double_t sy =0.1, sz =0.1;
3664 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3665 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3666 Double_t sy3=0.01+track->GetSigmaY2();
3668 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3669 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3670 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3671 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3672 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3673 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3675 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3676 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3677 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3678 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3683 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3684 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3685 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3686 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3687 c[13]=f30*sy1*f40+f32*sy2*f42;
3688 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3690 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3691 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3692 // Double_t y0,z0,y1,z1, y2,z2;
3693 //seed->GetProlongation(x0[0],y0,z0);
3694 // seed->GetProlongation(x1[0],y1,z1);
3695 //seed->GetProlongation(x2[0],y2,z2);
3697 seed->fLastPoint = pp2;
3698 seed->fFirstPoint = pp2;
3705 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3709 //reseed using founded clusters
3711 // Find the number of clusters
3712 Int_t nclusters = 0;
3713 for (Int_t irow=0;irow<160;irow++){
3714 if (track->GetClusterIndex(irow)>0) nclusters++;
3718 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3719 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3720 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3724 Int_t row[3],sec[3]={0,0,0};
3726 // find track row position at given ratio of the length
3728 for (Int_t irow=0;irow<160;irow++){
3729 if (track->GetClusterIndex2(irow)<0) continue;
3731 for (Int_t ipoint=0;ipoint<3;ipoint++){
3732 if (index<=ipos[ipoint]) row[ipoint] = irow;
3736 //Get cluster and sector position
3737 for (Int_t ipoint=0;ipoint<3;ipoint++){
3738 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3739 AliTPCclusterMI * cl = GetClusterMI(clindex);
3742 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3745 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3746 xyz[ipoint][0] = GetXrow(row[ipoint]);
3747 xyz[ipoint][1] = cl->GetY();
3748 xyz[ipoint][2] = cl->GetZ();
3752 // Calculate seed state vector and covariance matrix
3754 Double_t alpha, cs,sn, xx2,yy2;
3756 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3757 cs = TMath::Cos(alpha);
3758 sn = TMath::Sin(alpha);
3759 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3760 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3764 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3765 cs = TMath::Cos(alpha);
3766 sn = TMath::Sin(alpha);
3767 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3768 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3774 Double_t x[5],c[15];
3778 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3779 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3780 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3782 Double_t sy =0.1, sz =0.1;
3784 Double_t sy1=0.2, sz1=0.2;
3785 Double_t sy2=0.2, sz2=0.2;
3788 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;
3789 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;
3790 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;
3791 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;
3792 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;
3793 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;
3795 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;
3796 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;
3797 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;
3798 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;
3803 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3804 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3805 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3806 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3807 c[13]=f30*sy1*f40+f32*sy2*f42;
3808 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3810 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3811 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3812 seed->fLastPoint = row[2];
3813 seed->fFirstPoint = row[2];
3818 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3822 //reseed using founded clusters
3825 Int_t row[3]={0,0,0};
3826 Int_t sec[3]={0,0,0};
3828 // forward direction
3830 for (Int_t irow=r0;irow<160;irow++){
3831 if (track->GetClusterIndex(irow)>0){
3836 for (Int_t irow=160;irow>r0;irow--){
3837 if (track->GetClusterIndex(irow)>0){
3842 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3843 if (track->GetClusterIndex(irow)>0){
3851 for (Int_t irow=0;irow<r0;irow++){
3852 if (track->GetClusterIndex(irow)>0){
3857 for (Int_t irow=r0;irow>0;irow--){
3858 if (track->GetClusterIndex(irow)>0){
3863 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3864 if (track->GetClusterIndex(irow)>0){
3871 if ((row[2]-row[0])<20) return 0;
3872 if (row[1]==0) return 0;
3875 //Get cluster and sector position
3876 for (Int_t ipoint=0;ipoint<3;ipoint++){
3877 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3878 AliTPCclusterMI * cl = GetClusterMI(clindex);
3881 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3884 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3885 xyz[ipoint][0] = GetXrow(row[ipoint]);
3886 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3887 if (point&&ipoint<2){
3889 xyz[ipoint][1] = point->GetY();
3890 xyz[ipoint][2] = point->GetZ();
3893 xyz[ipoint][1] = cl->GetY();
3894 xyz[ipoint][2] = cl->GetZ();
3901 // Calculate seed state vector and covariance matrix
3903 Double_t alpha, cs,sn, xx2,yy2;
3905 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3906 cs = TMath::Cos(alpha);
3907 sn = TMath::Sin(alpha);
3908 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3909 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3913 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3914 cs = TMath::Cos(alpha);
3915 sn = TMath::Sin(alpha);
3916 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3917 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3923 Double_t x[5],c[15];
3927 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3928 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3929 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3931 Double_t sy =0.1, sz =0.1;
3933 Double_t sy1=0.2, sz1=0.2;
3934 Double_t sy2=0.2, sz2=0.2;
3937 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;
3938 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;
3939 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;
3940 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;
3941 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;
3942 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;
3944 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;
3945 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;
3946 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;
3947 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;
3952 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3953 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3954 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3955 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3956 c[13]=f30*sy1*f40+f32*sy2*f42;
3957 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3959 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3960 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3961 seed->fLastPoint = row[2];
3962 seed->fFirstPoint = row[2];
3963 for (Int_t i=row[0];i<row[2];i++){
3964 seed->fIndex[i] = track->fIndex[i];
3970 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
3977 TObjArray *kinks= new TObjArray(10000);
3978 // TObjArray *v0s= new TObjArray(10000);
3979 Int_t nentries = array->GetEntriesFast();
3980 AliHelix *helixes = new AliHelix[nentries];
3981 Int_t *sign = new Int_t[nentries];
3982 Int_t *nclusters = new Int_t[nentries];
3983 Float_t *alpha = new Float_t[nentries];
3984 AliESDkink * kink = new AliESDkink();
3985 Int_t * usage = new Int_t[nentries];
3986 Float_t *zm = new Float_t[nentries];
3987 Float_t *z0 = new Float_t[nentries];
3988 Float_t *fim = new Float_t[nentries];
3989 Float_t *shared = new Float_t[nentries];
3990 Bool_t *circular = new Bool_t[nentries];
3991 Float_t *dca = new Float_t[nentries];
3992 //const AliESDVertex * primvertex = esd->GetVertex();
3994 // nentries = array->GetEntriesFast();
3999 for (Int_t i=0;i<nentries;i++){
4002 AliTPCseed* track = (AliTPCseed*)array->At(i);
4003 if (!track) continue;
4004 track->fCircular =0;
4006 track->UpdatePoints();
4007 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4009 nclusters[i]=track->GetNumberOfClusters();
4010 alpha[i] = track->GetAlpha();
4011 new (&helixes[i]) AliHelix(*track);
4013 helixes[i].Evaluate(0,xyz);
4014 sign[i] = (track->GetC()>0) ? -1:1;
4017 if (track->GetProlongation(x,y,z)){
4019 fim[i] = alpha[i]+TMath::ATan2(y,x);
4022 zm[i] = track->GetZ();
4026 circular[i]= kFALSE;
4027 if (track->GetProlongation(0,y,z)) z0[i] = z;
4028 dca[i] = track->GetD(0,0);
4034 Int_t ncandidates =0;
4037 Double_t phase[2][2],radius[2];
4040 // Find circling track
4041 TTreeSRedirector &cstream = *fDebugStreamer;
4043 for (Int_t i0=0;i0<nentries;i0++){
4044 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4045 if (!track0) continue;
4046 if (track0->fN<40) continue;
4047 if (TMath::Abs(1./track0->fP4)>200) continue;
4048 for (Int_t i1=i0+1;i1<nentries;i1++){
4049 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4050 if (!track1) continue;
4051 if (track1->fN<40) continue;
4052 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
4053 if (track0->fBConstrain&&track1->fBConstrain) continue;
4054 if (TMath::Abs(1./track1->fP4)>200) continue;
4055 if (track1->fP4*track0->fP4>0) continue;
4056 if (track1->fP3*track0->fP3>0) continue;
4057 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
4058 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
4059 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
4061 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4062 if (mindcar<5) continue;
4063 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4064 if (mindcaz<5) continue;
4065 if (mindcar+mindcaz<20) continue;
4068 Float_t xc0 = helixes[i0].GetHelix(6);
4069 Float_t yc0 = helixes[i0].GetHelix(7);
4070 Float_t r0 = helixes[i0].GetHelix(8);
4071 Float_t xc1 = helixes[i1].GetHelix(6);
4072 Float_t yc1 = helixes[i1].GetHelix(7);
4073 Float_t r1 = helixes[i1].GetHelix(8);
4075 Float_t rmean = (r0+r1)*0.5;
4076 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4077 //if (delta>30) continue;
4078 if (delta>rmean*0.25) continue;
4079 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4081 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4082 if (npoints==0) continue;
4083 helixes[i0].GetClosestPhases(helixes[i1], phase);
4087 Double_t hangles[3];
4088 helixes[i0].Evaluate(phase[0][0],xyz0);
4089 helixes[i1].Evaluate(phase[0][1],xyz1);
4091 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4092 Double_t deltah[2],deltabest;
4093 if (hangles[2]<2.8) continue;
4095 cstream<<"C"<<track0->fLab<<track1->fLab<<
4096 track0->fP3<<track1->fP3<<
4097 track0->fP4<<track1->fP4<<
4098 delta<<rmean<<npoints<<
4099 hangles[0]<<hangles[2]<<
4100 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4104 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4106 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4107 if (deltah[1]<deltah[0]) ibest=1;
4109 deltabest = TMath::Sqrt(deltah[ibest]);
4110 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4111 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4112 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4113 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4115 if (deltabest>6) continue;
4116 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4117 Bool_t sign =kFALSE;
4118 if (hangles[2]>3.06) sign =kTRUE;
4121 circular[i0] = kTRUE;
4122 circular[i1] = kTRUE;
4123 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4124 track0->fCircular += 1;
4125 track1->fCircular += 2;
4128 track1->fCircular += 1;
4129 track0->fCircular += 2;
4134 cstream<<"Curling"<<
4135 "lab0="<<track0->fLab<<
4136 "lab1="<<track1->fLab<<
4141 "mindcar="<<mindcar<<
4142 "mindcaz="<<mindcaz<<
4145 "npoints="<<npoints<<
4146 "hangles0="<<hangles[0]<<
4147 "hangles2="<<hangles[2]<<
4152 "radius="<<radiusbest<<
4153 "deltabest="<<deltabest<<
4154 "phase0="<<phase[ibest][0]<<
4155 "phase1="<<phase[ibest][1]<<
4165 for (Int_t i =0;i<nentries;i++){
4166 if (sign[i]==0) continue;
4167 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4170 Double_t cradius0 = 40*40;
4171 Double_t cradius1 = 270*270;
4174 Double_t cdist3=0.55;
4175 for (Int_t j =i+1;j<nentries;j++){
4177 if (sign[j]*sign[i]<1) continue;
4178 if ( (nclusters[i]+nclusters[j])>200) continue;
4179 if ( (nclusters[i]+nclusters[j])<80) continue;
4180 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4181 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4182 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4183 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4184 if (npoints<1) continue;
4187 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4190 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4193 Double_t delta1=10000,delta2=10000;
4194 // cuts on the intersection radius
4195 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4196 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4197 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4199 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4200 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4201 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4204 Double_t distance1 = TMath::Min(delta1,delta2);
4205 if (distance1>cdist1) continue; // cut on DCA linear approximation
4207 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4208 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4209 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4210 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4213 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4214 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4215 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4217 distance1 = TMath::Min(delta1,delta2);
4220 rkink = TMath::Sqrt(radius[0]);
4223 rkink = TMath::Sqrt(radius[1]);
4225 if (distance1>cdist2) continue;
4228 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4231 Int_t row0 = GetRowNumber(rkink);
4232 if (row0<10) continue;
4233 if (row0>150) continue;
4236 Float_t dens00=-1,dens01=-1;
4237 Float_t dens10=-1,dens11=-1;
4239 Int_t found,foundable,shared;
4240 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4241 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4242 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4243 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4245 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4246 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4247 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4248 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4250 if (dens00<dens10 && dens01<dens11) continue;
4251 if (dens00>dens10 && dens01>dens11) continue;
4252 if (TMath::Max(dens00,dens10)<0.1) continue;
4253 if (TMath::Max(dens01,dens11)<0.3) continue;
4255 if (TMath::Min(dens00,dens10)>0.6) continue;
4256 if (TMath::Min(dens01,dens11)>0.6) continue;
4259 AliTPCseed * ktrack0, *ktrack1;
4268 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4269 AliExternalTrackParam paramm(*ktrack0);
4270 AliExternalTrackParam paramd(*ktrack1);
4271 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4274 kink->SetMother(paramm);
4275 kink->SetDaughter(paramd);
4278 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4280 fParam->Transform0to1(x,index);
4281 fParam->Transform1to2(x,index);
4282 row0 = GetRowNumber(x[0]);
4284 if (kink->GetR()<100) continue;
4285 if (kink->GetR()>240) continue;
4286 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4287 if (kink->GetDistance()>cdist3) continue;
4288 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4289 if (dird<0) continue;
4291 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4292 if (dirm<0) continue;
4293 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4294 if (mpt<0.2) continue;
4297 //for high momenta momentum not defined well in first iteration
4298 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4299 if (qt>0.35) continue;
4302 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4303 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4305 kink->SetTPCDensity(dens00,0,0);
4306 kink->SetTPCDensity(dens01,0,1);
4307 kink->SetTPCDensity(dens10,1,0);
4308 kink->SetTPCDensity(dens11,1,1);
4309 kink->SetIndex(i,0);
4310 kink->SetIndex(j,1);
4313 kink->SetTPCDensity(dens10,0,0);
4314 kink->SetTPCDensity(dens11,0,1);
4315 kink->SetTPCDensity(dens00,1,0);
4316 kink->SetTPCDensity(dens01,1,1);
4317 kink->SetIndex(j,0);
4318 kink->SetIndex(i,1);
4321 if (mpt<1||kink->GetAngle(2)>0.1){
4322 // angle and densities not defined yet
4323 if (kink->GetTPCDensityFactor()<0.8) continue;
4324 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4325 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4326 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4327 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4329 Float_t criticalangle = track0->fC22+track0->fC33;
4330 criticalangle+= track1->fC22+track1->fC33;
4331 criticalangle= 3*TMath::Sqrt(criticalangle);
4332 if (criticalangle>0.02) criticalangle=0.02;
4333 if (kink->GetAngle(2)<criticalangle) continue;
4336 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4337 Float_t shapesum =0;
4339 for ( Int_t row = row0-drow; row<row0+drow;row++){
4340 if (row<0) continue;
4341 if (row>155) continue;
4342 if (ktrack0->fClusterPointer[row]){
4343 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4344 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4347 if (ktrack1->fClusterPointer[row]){
4348 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4349 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4354 kink->SetShapeFactor(-1.);
4357 kink->SetShapeFactor(shapesum/sum);
4359 // esd->AddKink(kink);
4360 kinks->AddLast(kink);
4361 kink = new AliESDkink;
4366 // sort the kinks according quality - and refit them towards vertex
4368 Int_t nkinks = kinks->GetEntriesFast();
4369 Float_t *quality = new Float_t[nkinks];
4370 Int_t *indexes = new Int_t[nkinks];
4371 AliTPCseed *mothers = new AliTPCseed[nkinks];
4372 AliTPCseed *daughters = new AliTPCseed[nkinks];
4375 for (Int_t i=0;i<nkinks;i++){
4377 AliESDkink *kink = (AliESDkink*)kinks->At(i);
4379 // refit kinks towards vertex
4381 Int_t index0 = kink->GetIndex(0);
4382 Int_t index1 = kink->GetIndex(1);
4383 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4384 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4386 Int_t sumn=ktrack0->fN+ktrack1->fN;
4388 // Refit Kink under if too small angle
4390 if (kink->GetAngle(2)<0.05){
4391 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4392 Int_t row0 = kink->GetTPCRow0();
4393 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4396 Int_t last = row0-drow;
4397 if (last<40) last=40;
4398 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4399 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4402 Int_t first = row0+drow;
4403 if (first>130) first=130;
4404 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4405 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4407 if (seed0 && seed1){
4408 kink->SetStatus(1,8);
4409 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4410 row0 = GetRowNumber(kink->GetR());
4411 sumn = seed0->fN+seed1->fN;
4412 new (&mothers[i]) AliTPCseed(*seed0);
4413 new (&daughters[i]) AliTPCseed(*seed1);
4416 delete kinks->RemoveAt(i);
4417 if (seed0) delete seed0;
4418 if (seed1) delete seed1;
4421 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4422 delete kinks->RemoveAt(i);
4423 if (seed0) delete seed0;
4424 if (seed1) delete seed1;
4432 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4434 TMath::Sort(nkinks,quality,indexes,kFALSE);
4436 //remove double find kinks
4438 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4439 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4440 if (!kink0) continue;
4442 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4443 if (!kink0) continue;
4444 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4445 if (!kink1) continue;
4446 // if not close kink continue
4447 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4448 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4449 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4451 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4452 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4453 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4454 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4455 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4464 for (Int_t i=0;i<row0;i++){
4465 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4468 if (mother0.fIndex[i]==mother1.fIndex[i]){
4475 for (Int_t i=row0;i<158;i++){
4476 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4479 if (mother0.fIndex[i]==mother1.fIndex[i]){
4485 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4486 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4487 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4488 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4489 Int_t sum0 = mother0.fN+daughter0.fN;
4490 Int_t sum1 = mother1.fN+daughter1.fN;
4492 shared[kink0->GetIndex(0)]= kTRUE;
4493 shared[kink0->GetIndex(1)]= kTRUE;
4494 delete kinks->RemoveAt(indexes[ikink0]);
4497 shared[kink1->GetIndex(0)]= kTRUE;
4498 shared[kink1->GetIndex(1)]= kTRUE;
4499 delete kinks->RemoveAt(indexes[ikink1]);
4506 for (Int_t i=0;i<nkinks;i++){
4507 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
4508 if (!kink) continue;
4509 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4510 Int_t index0 = kink->GetIndex(0);
4511 Int_t index1 = kink->GetIndex(1);
4512 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4513 kink->SetMultiple(usage[index0],0);
4514 kink->SetMultiple(usage[index1],1);
4515 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4516 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4517 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4518 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4520 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4521 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4522 if (!ktrack0 || !ktrack1) continue;
4523 Int_t index = esd->AddKink(kink);
4526 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4527 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4528 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4529 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4533 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4534 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4539 // Remove tracks corresponding to shared kink's
4541 for (Int_t i=0;i<nentries;i++){
4542 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4543 if (!track0) continue;
4544 if (track0->fKinkIndexes[0]!=0) continue;
4545 if (shared[i]) delete array->RemoveAt(i);
4550 RemoveUsed2(array,0.5,0.4,30);
4552 for (Int_t i=0;i<nentries;i++){
4553 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4554 if (!track0) continue;
4555 track0->CookdEdx(0.02,0.6);
4559 for (Int_t i=0;i<nentries;i++){
4560 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4561 if (!track0) continue;
4562 if (track0->Pt()<1.4) continue;
4563 //remove double high momenta tracks - overlapped with kink candidates
4566 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4567 if (track0->fClusterPointer[icl]!=0){
4569 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4572 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4573 delete array->RemoveAt(i);
4576 if (track0->fKinkIndexes[0]!=0) continue;
4577 if (track0->GetNumberOfClusters()<80) continue;
4579 AliTPCseed *pmother = new AliTPCseed();
4580 AliTPCseed *pdaughter = new AliTPCseed();
4581 AliESDkink *pkink = new AliESDkink;
4583 AliTPCseed & mother = *pmother;
4584 AliTPCseed & daughter = *pdaughter;
4585 AliESDkink & kink = *pkink;
4586 if (CheckKinkPoint(track0,mother,daughter, kink)){
4587 if (mother.fN<30||daughter.fN<20) {
4591 continue; //too short tracks
4593 if (mother.Pt()<1.4) {
4599 Int_t row0= kink.GetTPCRow0();
4600 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4607 Int_t index = esd->AddKink(&kink);
4608 mother.fKinkIndexes[0] = -(index+1);
4609 daughter.fKinkIndexes[0] = index+1;
4611 delete array->RemoveAt(i);
4612 array->AddAt(new AliTPCseed(mother),i);
4615 array->AddLast(new AliTPCseed(mother));
4617 array->AddLast(new AliTPCseed(daughter));
4618 for (Int_t icl=0;icl<row0;icl++) {
4619 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4622 for (Int_t icl=row0;icl<158;icl++) {
4623 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4632 delete [] daughters;
4654 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4658 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4664 TObjArray *tpcv0s = new TObjArray(100000);
4665 Int_t nentries = array->GetEntriesFast();
4666 AliHelix *helixes = new AliHelix[nentries];
4667 Int_t *sign = new Int_t[nentries];
4668 Float_t *alpha = new Float_t[nentries];
4669 Float_t *z0 = new Float_t[nentries];
4670 Float_t *dca = new Float_t[nentries];
4671 Float_t *sdcar = new Float_t[nentries];
4672 Float_t *cdcar = new Float_t[nentries];
4673 Float_t *pulldcar = new Float_t[nentries];
4674 Float_t *pulldcaz = new Float_t[nentries];
4675 Float_t *pulldca = new Float_t[nentries];
4676 Bool_t *isPrim = new Bool_t[nentries];
4677 const AliESDVertex * primvertex = esd->GetVertex();
4678 Double_t zvertex = primvertex->GetZv();
4680 // nentries = array->GetEntriesFast();
4682 for (Int_t i=0;i<nentries;i++){
4685 AliTPCseed* track = (AliTPCseed*)array->At(i);
4686 if (!track) continue;
4687 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4688 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4689 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4691 alpha[i] = track->GetAlpha();
4692 new (&helixes[i]) AliHelix(*track);
4694 helixes[i].Evaluate(0,xyz);
4695 sign[i] = (track->GetC()>0) ? -1:1;
4699 if (track->GetProlongation(0,y,z)) z0[i] = z;
4700 dca[i] = track->GetD(0,0);
4702 // dca error parrameterezation + pulls
4704 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4705 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4706 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4707 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4708 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4709 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4710 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4711 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4713 if (track->fTPCr[4]>0.5) {
4714 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4716 if (track->fTPCr[0]>0.4) {
4717 isPrim[i]=kFALSE; //electron no sigma cut
4724 Int_t ncandidates =0;
4727 Double_t phase[2][2],radius[2];
4733 TTreeSRedirector &cstream = *fDebugStreamer;
4734 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4736 Double_t cradius0 = 10*10;
4737 Double_t cradius1 = 200*200;
4740 Double_t cpointAngle = 0.95;
4742 Double_t delta[2]={10000,10000};
4743 for (Int_t i =0;i<nentries;i++){
4744 if (sign[i]==0) continue;
4745 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4746 if (!track0) continue;
4751 "zvertex="<<zvertex<<
4752 "sdcar0="<<sdcar[i]<<
4753 "cdcar0="<<cdcar[i]<<
4754 "pulldcar0="<<pulldcar[i]<<
4755 "pulldcaz0="<<pulldcaz[i]<<
4756 "pulldca0="<<pulldca[i]<<
4757 "isPrim="<<isPrim[i]<<
4760 if (track0->fP4<0) continue;
4761 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4763 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4768 for (Int_t j =0;j<nentries;j++){
4769 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4770 if (!track1) continue;
4771 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4772 if (sign[j]*sign[i]>0) continue;
4773 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4774 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4777 // DCA to prim vertex cut
4783 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4784 if (npoints<1) continue;
4788 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4789 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4790 if (delta[0]>cdist1) continue;
4793 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4794 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4795 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4796 if (delta[1]<delta[0]) iclosest=1;
4797 if (delta[iclosest]>cdist1) continue;
4799 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4800 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4802 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4803 if (pointAngle<cpointAngle) continue;
4805 Bool_t isGamma = kFALSE;
4806 vertex.SetP(*track0); //track0 - plus
4807 vertex.SetM(*track1); //track1 - minus
4808 vertex.Update(fprimvertex);
4809 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4810 Double_t pointAngle2 = vertex.GetPointAngle();
4812 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4813 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4814 Float_t sigmae = 0.15*0.15;
4815 if (vertex.GetRr()<80)
4816 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4817 sigmae+= TMath::Sqrt(sigmae);
4818 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4819 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4820 Int_t row0 = GetRowNumber(vertex.GetRr());
4822 if (vertex.GetDist2()>0.2) continue;
4823 densb0 = track0->Density2(0,row0-5);
4824 densb1 = track1->Density2(0,row0-5);
4825 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4826 densa0 = track0->Density2(row0+5,row0+40);
4827 densa1 = track1->Density2(row0+5,row0+40);
4828 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4831 densa0 = track0->Density2(0,40); //cluster density
4832 densa1 = track1->Density2(0,40); //cluster density
4833 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4835 vertex.SetLab(0,track0->GetLabel());
4836 vertex.SetLab(1,track1->GetLabel());
4837 vertex.SetChi2After((densa0+densa1)*0.5);
4838 vertex.SetChi2Before((densb0+densb1)*0.5);
4839 vertex.SetIndex(0,i);
4840 vertex.SetIndex(1,j);
4841 vertex.SetStatus(1); // TPC v0 candidate
4842 vertex.SetRp(track0->fTPCr);
4843 vertex.SetRm(track1->fTPCr);
4844 tpcv0s->AddLast(new AliESDV0MI(vertex));
4847 Int_t eventNr = esd->GetEventNumber();
4848 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4849 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4852 "vertex.="<<&vertex<<
4854 "lab0="<<track0->fLab<<
4855 "Helix0.="<<&helixes[i]<<
4857 "lab1="<<track1->fLab<<
4858 "Helix1.="<<&helixes[j]<<
4859 "pointAngle="<<pointAngle<<
4860 "pointAngle2="<<pointAngle2<<
4865 "zvertex="<<zvertex<<
4866 "circular0="<<track0->fCircular<<
4867 "circular1="<<track1->fCircular<<
4868 "npoints="<<npoints<<
4869 "radius0="<<radius[0]<<
4870 "delta0="<<delta[0]<<
4871 "radius1="<<radius[1]<<
4872 "delta1="<<delta[1]<<
4873 "radiusm="<<radiusm<<
4875 "sdcar0="<<sdcar[i]<<
4876 "sdcar1="<<sdcar[j]<<
4877 "cdcar0="<<cdcar[i]<<
4878 "cdcar1="<<cdcar[j]<<
4879 "pulldcar0="<<pulldcar[i]<<
4880 "pulldcar1="<<pulldcar[j]<<
4881 "pulldcaz0="<<pulldcaz[i]<<
4882 "pulldcaz1="<<pulldcaz[j]<<
4883 "pulldca0="<<pulldca[i]<<
4884 "pulldca1="<<pulldca[j]<<
4894 Float_t *quality = new Float_t[ncandidates];
4895 Int_t *indexes = new Int_t[ncandidates];
4897 for (Int_t i=0;i<ncandidates;i++){
4899 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4900 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4901 // quality[i] /= (0.5+v0->GetDist2());
4902 // quality[i] *= v0->GetChi2After(); //density factor
4903 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4904 Int_t index0 = v0->GetIndex(0);
4905 Int_t index1 = v0->GetIndex(1);
4906 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4907 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4908 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4909 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4912 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4915 for (Int_t i=0;i<ncandidates;i++){
4916 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4918 Int_t index0 = v0->GetIndex(0);
4919 Int_t index1 = v0->GetIndex(1);
4920 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4921 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4922 if (!track0||!track1) {
4926 Bool_t accept =kTRUE; //default accept
4927 Int_t *v0indexes0 = track0->GetV0Indexes();
4928 Int_t *v0indexes1 = track1->GetV0Indexes();
4930 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4931 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4932 if (v0indexes0[1]!=0) order0 =2;
4933 if (v0indexes1[1]!=0) order1 =2;
4935 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4936 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4938 AliESDV0MI * v02 = v0;
4940 v0->SetOrder(0,order0);
4941 v0->SetOrder(1,order1);
4942 v0->SetOrder(1,order0+order1);
4943 Int_t index = esd->AddV0MI(v0);
4944 v02 = esd->GetV0MI(index);
4945 v0indexes0[order0]=index;
4946 v0indexes1[order1]=index;
4950 Int_t eventNr = esd->GetEventNumber();
4956 "lab0="<<track0->fLab<<
4958 "lab1="<<track1->fLab<<
4959 "dca0="<<dca[index0]<<
4960 "dca1="<<dca[index1]<<
4964 "quality="<<quality[i]<<
4965 "pulldca0="<<pulldca[index0]<<
4966 "pulldca1="<<pulldca[index1]<<
4990 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
4994 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
4997 // refit kink towards to the vertex
5000 Int_t row0 = GetRowNumber(kink.GetR());
5001 FollowProlongation(mother,0);
5002 mother.Reset(kFALSE);
5004 FollowProlongation(daughter,row0);
5005 daughter.Reset(kFALSE);
5006 FollowBackProlongation(daughter,158);
5007 daughter.Reset(kFALSE);
5008 Int_t first = TMath::Max(row0-20,30);
5009 Int_t last = TMath::Min(row0+20,140);
5011 const Int_t kNdiv =5;
5012 AliTPCseed param0[kNdiv]; // parameters along the track
5013 AliTPCseed param1[kNdiv]; // parameters along the track
5014 AliESDkink kinks[kNdiv]; // corresponding kink parameters
5017 for (Int_t irow=0; irow<kNdiv;irow++){
5018 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5020 // store parameters along the track
5022 for (Int_t irow=0;irow<kNdiv;irow++){
5023 FollowBackProlongation(mother, rows[irow]);
5024 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5025 new(¶m0[irow]) AliTPCseed(mother);
5026 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5030 for (Int_t irow=0; irow<kNdiv-1;irow++){
5031 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5032 kinks[irow].SetMother(param0[irow]);
5033 kinks[irow].SetDaughter(param1[irow]);
5034 kinks[irow].Update();
5037 // choose kink with best "quality"
5039 Double_t mindist = 10000;
5040 for (Int_t irow=0;irow<kNdiv;irow++){
5041 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5042 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5043 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5045 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
5046 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5047 if (normdist < mindist){
5053 if (index==-1) return 0;
5056 param0[index].Reset(kTRUE);
5057 FollowProlongation(param0[index],0);
5059 new (&mother) AliTPCseed(param0[index]);
5060 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5062 kink.SetMother(mother);
5063 kink.SetDaughter(daughter);
5065 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5066 kink.SetTPCncls(param0[index].fN,0);
5067 kink.SetTPCncls(param1[index].fN,1);
5068 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5069 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5070 mother.SetLabel(kink.GetLabel(0));
5071 daughter.SetLabel(kink.GetLabel(1));
5077 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5079 // update Kink quality information for mother after back propagation
5081 if (seed->GetKinkIndex(0)>=0) return;
5082 for (Int_t ikink=0;ikink<3;ikink++){
5083 Int_t index = seed->GetKinkIndex(ikink);
5084 if (index>=0) break;
5085 index = TMath::Abs(index)-1;
5086 AliESDkink * kink = fEvent->GetKink(index);
5087 //kink->fTPCdensity2[0][0]=-1;
5088 //kink->fTPCdensity2[0][1]=-1;
5089 kink->SetTPCDensity2(-1,0,0);
5090 kink->SetTPCDensity2(1,0,1);
5092 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5093 if (row0<15) row0=15;
5095 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5096 if (row1>145) row1=145;
5098 Int_t found,foundable,shared;
5099 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5100 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5101 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5102 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5107 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5109 // update Kink quality information for daughter after refit
5111 if (seed->GetKinkIndex(0)<=0) return;
5112 for (Int_t ikink=0;ikink<3;ikink++){
5113 Int_t index = seed->GetKinkIndex(ikink);
5114 if (index<=0) break;
5115 index = TMath::Abs(index)-1;
5116 AliESDkink * kink = fEvent->GetKink(index);
5117 kink->SetTPCDensity2(-1,1,0);
5118 kink->SetTPCDensity2(-1,1,1);
5120 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5121 if (row0<15) row0=15;
5123 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5124 if (row1>145) row1=145;
5126 Int_t found,foundable,shared;
5127 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5128 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5129 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5130 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5136 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5139 // check kink point for given track
5140 // if return value=0 kink point not found
5141 // otherwise seed0 correspond to mother particle
5142 // seed1 correspond to daughter particle
5143 // kink parameter of kink point
5145 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5146 Int_t first = seed->fFirstPoint;
5147 Int_t last = seed->fLastPoint;
5148 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5151 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5152 if (!seed1) return 0;
5153 FollowProlongation(*seed1,seed->fLastPoint-20);
5154 seed1->Reset(kTRUE);
5155 FollowProlongation(*seed1,158);
5156 seed1->Reset(kTRUE);
5157 last = seed1->fLastPoint;
5159 AliTPCseed *seed0 = new AliTPCseed(*seed);
5160 seed0->Reset(kFALSE);
5163 AliTPCseed param0[20]; // parameters along the track
5164 AliTPCseed param1[20]; // parameters along the track
5165 AliESDkink kinks[20]; // corresponding kink parameters
5167 for (Int_t irow=0; irow<20;irow++){
5168 rows[irow] = first +((last-first)*irow)/19;
5170 // store parameters along the track
5172 for (Int_t irow=0;irow<20;irow++){
5173 FollowBackProlongation(*seed0, rows[irow]);
5174 FollowProlongation(*seed1,rows[19-irow]);
5175 new(¶m0[irow]) AliTPCseed(*seed0);
5176 new(¶m1[19-irow]) AliTPCseed(*seed1);
5180 for (Int_t irow=0; irow<19;irow++){
5181 kinks[irow].SetMother(param0[irow]);
5182 kinks[irow].SetDaughter(param1[irow]);
5183 kinks[irow].Update();
5186 // choose kink with biggest change of angle
5188 Double_t maxchange= 0;
5189 for (Int_t irow=1;irow<19;irow++){
5190 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5191 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5192 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5193 if ( quality > maxchange){
5194 maxchange = quality;
5201 if (index<0) return 0;
5203 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5204 seed0 = new AliTPCseed(param0[index]);
5205 seed1 = new AliTPCseed(param1[index]);
5206 seed0->Reset(kFALSE);
5207 seed1->Reset(kFALSE);
5208 seed0->ResetCovariance();
5209 seed1->ResetCovariance();
5210 FollowProlongation(*seed0,0);
5211 FollowBackProlongation(*seed1,158);
5212 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5213 seed0->Reset(kFALSE);
5214 seed1->Reset(kFALSE);
5215 seed0->ResetCovariance();
5216 seed1->ResetCovariance();
5218 first = TMath::Max(row0-20,0);
5219 last = TMath::Min(row0+20,158);
5221 for (Int_t irow=0; irow<20;irow++){
5222 rows[irow] = first +((last-first)*irow)/19;
5224 // store parameters along the track
5226 for (Int_t irow=0;irow<20;irow++){
5227 FollowBackProlongation(*seed0, rows[irow]);
5228 FollowProlongation(*seed1,rows[19-irow]);
5229 new(¶m0[irow]) AliTPCseed(*seed0);
5230 new(¶m1[19-irow]) AliTPCseed(*seed1);
5234 for (Int_t irow=0; irow<19;irow++){
5235 kinks[irow].SetMother(param0[irow]);
5236 kinks[irow].SetDaughter(param1[irow]);
5237 // param0[irow].Dump();
5238 //param1[irow].Dump();
5239 kinks[irow].Update();
5242 // choose kink with biggest change of angle
5245 for (Int_t irow=0;irow<20;irow++){
5246 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5247 if (TMath::Abs(kinks[irow].GetR())<90.) 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==-1 || param0[index].fN+param1[index].fN<100){
5262 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5264 kink.SetMother(param0[index]);
5265 kink.SetDaughter(param1[index]);
5267 row0 = GetRowNumber(kink.GetR());
5268 kink.SetTPCRow0(row0);
5269 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5270 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5271 kink.SetIndex(-10,0);
5272 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5273 kink.SetTPCncls(param0[index].fN,0);
5274 kink.SetTPCncls(param1[index].fN,1);
5277 // new (&mother) AliTPCseed(param0[index]);
5278 new (&daughter) AliTPCseed(param1[index]);
5279 daughter.SetLabel(kink.GetLabel(1));
5280 param0[index].Reset(kTRUE);
5281 FollowProlongation(param0[index],0);
5282 new (&mother) AliTPCseed(param0[index]);
5283 mother.SetLabel(kink.GetLabel(0));
5293 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5296 // reseed - refit - track
5299 // Int_t last = fSectors->GetNRows()-1;
5301 if (fSectors == fOuterSec){
5302 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5306 first = t->fFirstPoint;
5308 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5309 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5311 FollowProlongation(*t,first);
5321 //_____________________________________________________________________________
5322 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5323 //-----------------------------------------------------------------
5324 // This function reades track seeds.
5325 //-----------------------------------------------------------------
5326 TDirectory *savedir=gDirectory;
5328 TFile *in=(TFile*)inp;
5329 if (!in->IsOpen()) {
5330 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5335 TTree *seedTree=(TTree*)in->Get("Seeds");
5337 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5338 cerr<<"can't get a tree with track seeds !\n";
5341 AliTPCtrack *seed=new AliTPCtrack;
5342 seedTree->SetBranchAddress("tracks",&seed);
5344 if (fSeeds==0) fSeeds=new TObjArray(15000);
5346 Int_t n=(Int_t)seedTree->GetEntries();
5347 for (Int_t i=0; i<n; i++) {
5348 seedTree->GetEvent(i);
5349 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5358 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5361 if (fSeeds) DeleteSeeds();
5364 if (!fSeeds) return 1;
5371 //_____________________________________________________________________________
5372 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5373 //-----------------------------------------------------------------
5374 // This is a track finder.
5375 //-----------------------------------------------------------------
5376 TDirectory *savedir=gDirectory;
5380 fSeeds = Tracking();
5383 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5385 //activate again some tracks
5386 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5387 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5389 Int_t nc=t.GetNumberOfClusters();
5391 delete fSeeds->RemoveAt(i);
5395 if (pt->fRemoval==10) {
5396 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5397 pt->Desactivate(10); // make track again active
5399 pt->Desactivate(20);
5400 delete fSeeds->RemoveAt(i);
5405 RemoveUsed2(fSeeds,0.85,0.85,0);
5406 FindKinks(fSeeds,fEvent);
5407 RemoveUsed2(fSeeds,0.5,0.4,20);
5409 // // refit short tracks
5411 Int_t nseed=fSeeds->GetEntriesFast();
5412 // for (Int_t i=0; i<nseed; i++) {
5413 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5414 // if (!pt) continue;
5415 // Int_t nc=t.GetNumberOfClusters();
5417 // delete fSeeds->RemoveAt(i);
5420 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5421 // if (nc>100) continue; // hopefully, enough for ITS
5422 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5423 // //seed2->Reset(kFALSE);
5424 // //pt->ResetCovariance();
5425 // seed2->Modify(1);
5426 // FollowBackProlongation(*seed2,158);
5427 // //seed2->Reset(kFALSE);
5428 // seed2->Modify(10);
5429 // FollowProlongation(*seed2,0);
5430 // TTreeSRedirector &cstream = *fDebugStreamer;
5431 // cstream<<"Crefit"<<
5435 // if (seed2->fN>pt->fN){
5436 // delete fSeeds->RemoveAt(i);
5437 // fSeeds->AddAt(seed2,i);
5442 // RemoveUsed2(fSeeds,0.6,0.6,50);
5444 // FindV0s(fSeeds,fEvent);
5445 //RemoveDouble(fSeeds,0.2,0.6,11);
5449 for (Int_t i=0; i<nseed; i++) {
5450 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5452 Int_t nc=t.GetNumberOfClusters();
5454 delete fSeeds->RemoveAt(i);
5457 CookLabel(pt,0.1); //For comparison only
5458 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5459 if ((pt->IsActive() || (pt->fRemoval==10) )){
5461 if (fDebug>0) cerr<<found<<'\r';
5465 delete fSeeds->RemoveAt(i);
5469 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5471 //RemoveUsed(fSeeds,0.9,0.9,6);
5473 nseed=fSeeds->GetEntriesFast();
5475 for (Int_t i=0; i<nseed; i++) {
5476 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5478 Int_t nc=t.GetNumberOfClusters();
5480 delete fSeeds->RemoveAt(i);
5484 t.CookdEdx(0.02,0.6);
5485 // CheckKinkPoint(&t,0.05);
5486 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5487 if ((pt->IsActive() || (pt->fRemoval==10) )){
5495 delete fSeeds->RemoveAt(i);
5496 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5498 // FollowProlongation(*seed1,0);
5499 // Int_t n = seed1->GetNumberOfClusters();
5500 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5501 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5504 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5508 SortTracks(fSeeds, 1);
5512 PrepareForBackProlongation(fSeeds,5.);
5513 PropagateBack(fSeeds);
5514 printf("Time for back propagation: \t");timer.Print();timer.Start();
5518 PrepareForProlongation(fSeeds,5.);
5519 PropagateForward2(fSeeds);
5521 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5522 // RemoveUsed(fSeeds,0.7,0.7,6);
5523 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5525 nseed=fSeeds->GetEntriesFast();
5527 for (Int_t i=0; i<nseed; i++) {
5528 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5530 Int_t nc=t.GetNumberOfClusters();
5532 delete fSeeds->RemoveAt(i);
5535 t.CookdEdx(0.02,0.6);
5536 // CookLabel(pt,0.1); //For comparison only
5537 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5538 if ((pt->IsActive() || (pt->fRemoval==10) )){
5539 cerr<<found++<<'\r';
5542 delete fSeeds->RemoveAt(i);
5547 // fNTracks = found;
5549 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5552 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5553 Info("Clusters2Tracks","Number of found tracks %d",found);
5555 // UnloadClusters();
5560 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5563 // tracking of the seeds
5566 fSectors = fOuterSec;
5567 ParallelTracking(arr,150,63);
5568 fSectors = fOuterSec;
5569 ParallelTracking(arr,63,0);
5572 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5577 TObjArray * arr = new TObjArray;
5579 fSectors = fOuterSec;
5582 for (Int_t sec=0;sec<fkNOS;sec++){
5583 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5584 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5585 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5588 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5600 TObjArray * AliTPCtrackerMI::Tracking()
5606 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5608 TObjArray * seeds = new TObjArray;
5617 Float_t fnumber = 3.0;
5618 Float_t fdensity = 3.0;
5623 for (Int_t delta = 0; delta<18; delta+=6){
5627 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5628 SumTracks(seeds,arr);
5629 SignClusters(seeds,fnumber,fdensity);
5631 for (Int_t i=2;i<6;i+=2){
5632 // seed high pt tracks
5635 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5636 SumTracks(seeds,arr);
5637 SignClusters(seeds,fnumber,fdensity);
5642 // RemoveUsed(seeds,0.9,0.9,1);
5643 // UnsignClusters();
5644 // SignClusters(seeds,fnumber,fdensity);
5648 for (Int_t delta = 20; delta<120; delta+=10){
5650 // seed high pt tracks
5654 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5655 SumTracks(seeds,arr);
5656 SignClusters(seeds,fnumber,fdensity);
5661 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5662 SumTracks(seeds,arr);
5663 SignClusters(seeds,fnumber,fdensity);
5674 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5678 // RemoveUsed(seeds,0.75,0.75,1);
5680 //SignClusters(seeds,fnumber,fdensity);
5689 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5690 SumTracks(seeds,arr);
5691 SignClusters(seeds,fnumber,fdensity);
5693 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5694 SumTracks(seeds,arr);
5695 SignClusters(seeds,fnumber,fdensity);
5697 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5698 SumTracks(seeds,arr);
5699 SignClusters(seeds,fnumber,fdensity);
5703 for (Int_t delta = 3; delta<30; delta+=5){
5709 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5710 SumTracks(seeds,arr);
5711 SignClusters(seeds,fnumber,fdensity);
5713 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5714 SumTracks(seeds,arr);
5715 SignClusters(seeds,fnumber,fdensity);
5727 for (Int_t delta = 30; delta<90; delta+=10){
5733 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5734 SumTracks(seeds,arr);
5735 SignClusters(seeds,fnumber,fdensity);
5737 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5738 SumTracks(seeds,arr);
5739 SignClusters(seeds,fnumber,fdensity);
5743 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5754 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5757 //sum tracks to common container
5758 //remove suspicious tracks
5759 Int_t nseed = arr2->GetEntriesFast();
5760 for (Int_t i=0;i<nseed;i++){
5761 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5763 // REMOVE VERY SHORT TRACKS
5764 if (pt->GetNumberOfClusters()<20){
5765 delete arr2->RemoveAt(i);
5768 // NORMAL ACTIVE TRACK
5769 if (pt->IsActive()){
5770 arr1->AddLast(arr2->RemoveAt(i));
5773 //remove not usable tracks
5774 if (pt->fRemoval!=10){
5775 delete arr2->RemoveAt(i);
5779 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5780 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5781 arr1->AddLast(arr2->RemoveAt(i));
5783 delete arr2->RemoveAt(i);
5792 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5795 // try to track in parralel
5797 Int_t nseed=arr->GetEntriesFast();
5798 //prepare seeds for tracking
5799 for (Int_t i=0; i<nseed; i++) {
5800 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5802 if (!t.IsActive()) continue;
5803 // follow prolongation to the first layer
5804 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5805 FollowProlongation(t, rfirst+1);
5810 for (Int_t nr=rfirst; nr>=rlast; nr--){
5811 if (nr<fInnerSec->GetNRows())
5812 fSectors = fInnerSec;
5814 fSectors = fOuterSec;
5815 // make indexes with the cluster tracks for given
5817 // find nearest cluster
5818 for (Int_t i=0; i<nseed; i++) {
5819 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5821 if (nr==80) pt->UpdateReference();
5822 if (!pt->IsActive()) continue;
5823 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5824 if (pt->fRelativeSector>17) {
5827 UpdateClusters(t,nr);
5829 // prolonagate to the nearest cluster - if founded
5830 for (Int_t i=0; i<nseed; i++) {
5831 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5833 if (!pt->IsActive()) continue;
5834 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5835 if (pt->fRelativeSector>17) {
5838 FollowToNextCluster(*pt,nr);
5843 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5847 // if we use TPC track itself we have to "update" covariance
5849 Int_t nseed= arr->GetEntriesFast();
5850 for (Int_t i=0;i<nseed;i++){
5851 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5855 //rotate to current local system at first accepted point
5856 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5857 Int_t sec = (index&0xff000000)>>24;
5859 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5860 if (angle1>TMath::Pi())
5861 angle1-=2.*TMath::Pi();
5862 Float_t angle2 = pt->GetAlpha();
5864 if (TMath::Abs(angle1-angle2)>0.001){
5865 pt->Rotate(angle1-angle2);
5866 //angle2 = pt->GetAlpha();
5867 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5868 //if (pt->GetAlpha()<0)
5869 // pt->fRelativeSector+=18;
5870 //sec = pt->fRelativeSector;
5879 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5883 // if we use TPC track itself we have to "update" covariance
5885 Int_t nseed= arr->GetEntriesFast();
5886 for (Int_t i=0;i<nseed;i++){
5887 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5890 pt->fFirstPoint = pt->fLastPoint;
5898 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5901 // make back propagation
5903 Int_t nseed= arr->GetEntriesFast();
5904 for (Int_t i=0;i<nseed;i++){
5905 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5906 if (pt&& pt->GetKinkIndex(0)<=0) {
5907 //AliTPCseed *pt2 = new AliTPCseed(*pt);
5908 fSectors = fInnerSec;
5909 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5910 //fSectors = fOuterSec;
5911 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5912 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
5913 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
5914 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5917 if (pt&& pt->GetKinkIndex(0)>0) {
5918 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
5919 pt->fFirstPoint = kink->GetTPCRow0();
5920 fSectors = fInnerSec;
5921 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5929 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5932 // make forward propagation
5934 Int_t nseed= arr->GetEntriesFast();
5936 for (Int_t i=0;i<nseed;i++){
5937 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5939 FollowProlongation(*pt,0);
5946 Int_t AliTPCtrackerMI::PropagateForward()
5949 // propagate track forward
5951 Int_t nseed = fSeeds->GetEntriesFast();
5952 for (Int_t i=0;i<nseed;i++){
5953 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5955 AliTPCseed &t = *pt;
5956 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5957 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5958 if (alpha < 0. ) alpha += 2.*TMath::Pi();
5959 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
5963 fSectors = fOuterSec;
5964 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
5965 fSectors = fInnerSec;
5966 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
5976 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
5979 // make back propagation, in between row0 and row1
5983 fSectors = fInnerSec;
5986 if (row1<fSectors->GetNRows())
5989 r1 = fSectors->GetNRows()-1;
5991 if (row0<fSectors->GetNRows()&& r1>0 )
5992 FollowBackProlongation(*pt,r1);
5993 if (row1<=fSectors->GetNRows())
5996 r1 = row1 - fSectors->GetNRows();
5997 if (r1<=0) return 0;
5998 if (r1>=fOuterSec->GetNRows()) return 0;
5999 fSectors = fOuterSec;
6000 return FollowBackProlongation(*pt,r1);
6008 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6012 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6013 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6014 Float_t padlength = GetPadPitchLength(row);
6016 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6017 Float_t angulary = seed->GetSnp();
6018 angulary = angulary*angulary/(1-angulary*angulary);
6019 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6021 Float_t sresz = fParam->GetZSigma();
6022 Float_t angularz = seed->GetTgl();
6023 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6025 Float_t wy = GetSigmaY(seed);
6026 Float_t wz = GetSigmaZ(seed);
6029 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6030 printf("problem\n");
6036 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6040 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6041 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6042 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6043 Float_t angular = seed->GetSnp();
6044 angular = angular*angular/(1-angular*angular);
6045 // angular*=angular;
6046 //angular = TMath::Sqrt(angular/(1-angular));
6047 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6050 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6054 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6055 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6056 Float_t sres = fParam->GetZSigma();
6057 Float_t angular = seed->GetTgl();
6058 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6063 //__________________________________________________________________________
6064 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6065 //--------------------------------------------------------------------
6066 //This function "cooks" a track label. If label<0, this track is fake.
6067 //--------------------------------------------------------------------
6068 AliTPCseed * t = (AliTPCseed*)tk;
6069 Int_t noc=t->GetNumberOfClusters();
6071 //printf("\nnot founded prolongation\n\n\n");
6077 AliTPCclusterMI *clusters[160];
6079 for (Int_t i=0;i<160;i++) {
6086 for (i=0; i<160 && current<noc; i++) {
6088 Int_t index=t->GetClusterIndex2(i);
6089 if (index<=0) continue;
6090 if (index&0x8000) continue;
6092 //clusters[current]=GetClusterMI(index);
6093 if (t->fClusterPointer[i]){
6094 clusters[current]=t->fClusterPointer[i];
6100 Int_t lab=123456789;
6101 for (i=0; i<noc; i++) {
6102 AliTPCclusterMI *c=clusters[i];
6104 lab=TMath::Abs(c->GetLabel(0));
6106 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6112 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6114 for (i=0; i<noc; i++) {
6115 AliTPCclusterMI *c=clusters[i];
6117 if (TMath::Abs(c->GetLabel(1)) == lab ||
6118 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6121 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6124 Int_t tail=Int_t(0.10*noc);
6127 for (i=1; i<=160&&ind<tail; i++) {
6128 // AliTPCclusterMI *c=clusters[noc-i];
6129 AliTPCclusterMI *c=clusters[i];
6131 if (lab == TMath::Abs(c->GetLabel(0)) ||
6132 lab == TMath::Abs(c->GetLabel(1)) ||
6133 lab == TMath::Abs(c->GetLabel(2))) max++;
6136 if (max < Int_t(0.5*tail)) lab=-lab;
6143 //delete[] clusters;
6147 //__________________________________________________________________________
6148 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6149 //--------------------------------------------------------------------
6150 //This function "cooks" a track label. If label<0, this track is fake.
6151 //--------------------------------------------------------------------
6152 Int_t noc=t->GetNumberOfClusters();
6154 //printf("\nnot founded prolongation\n\n\n");
6160 AliTPCclusterMI *clusters[160];
6162 for (Int_t i=0;i<160;i++) {
6169 for (i=0; i<160 && current<noc; i++) {
6170 if (i<first) continue;
6171 if (i>last) continue;
6172 Int_t index=t->GetClusterIndex2(i);
6173 if (index<=0) continue;
6174 if (index&0x8000) continue;
6176 //clusters[current]=GetClusterMI(index);
6177 if (t->fClusterPointer[i]){
6178 clusters[current]=t->fClusterPointer[i];
6183 if (noc<5) return -1;
6184 Int_t lab=123456789;
6185 for (i=0; i<noc; i++) {
6186 AliTPCclusterMI *c=clusters[i];
6188 lab=TMath::Abs(c->GetLabel(0));
6190 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6196 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6198 for (i=0; i<noc; i++) {
6199 AliTPCclusterMI *c=clusters[i];
6201 if (TMath::Abs(c->GetLabel(1)) == lab ||
6202 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6205 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6208 Int_t tail=Int_t(0.10*noc);
6211 for (i=1; i<=160&&ind<tail; i++) {
6212 // AliTPCclusterMI *c=clusters[noc-i];
6213 AliTPCclusterMI *c=clusters[i];
6215 if (lab == TMath::Abs(c->GetLabel(0)) ||
6216 lab == TMath::Abs(c->GetLabel(1)) ||
6217 lab == TMath::Abs(c->GetLabel(2))) max++;
6220 if (max < Int_t(0.5*tail)) lab=-lab;
6223 // t->SetLabel(lab);
6227 //delete[] clusters;
6231 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6233 //return pad row number for this x
6236 r=fRow[fN-1].GetX();
6237 if (x > r) return fN;
6239 if (x < r) return -1;
6240 return Int_t((x-r)/fPadPitchLength + 0.5);}
6242 r=fRow[fN-1].GetX();
6243 if (x > r) return fN;
6245 if (x < r) return -1;
6246 Double_t r1=fRow[64].GetX();
6248 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6250 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6254 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6256 //return pad row number for given x vector
6257 Float_t phi = TMath::ATan2(x[1],x[0]);
6258 if(phi<0) phi=2.*TMath::Pi()+phi;
6259 // Get the local angle in the sector philoc
6260 const Float_t kRaddeg = 180/3.14159265358979312;
6261 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6262 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6263 return GetRowNumber(localx);
6266 //_________________________________________________________________________
6267 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6268 //-----------------------------------------------------------------------
6269 // Setup inner sector
6270 //-----------------------------------------------------------------------
6272 fAlpha=par->GetInnerAngle();
6273 fAlphaShift=par->GetInnerAngleShift();
6274 fPadPitchWidth=par->GetInnerPadPitchWidth();
6275 fPadPitchLength=par->GetInnerPadPitchLength();
6276 fN=par->GetNRowLow();
6277 fRow=new AliTPCRow[fN];
6278 for (Int_t i=0; i<fN; i++) {
6279 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6280 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6283 fAlpha=par->GetOuterAngle();
6284 fAlphaShift=par->GetOuterAngleShift();
6285 fPadPitchWidth = par->GetOuterPadPitchWidth();
6286 fPadPitchLength = par->GetOuter1PadPitchLength();
6287 f1PadPitchLength = par->GetOuter1PadPitchLength();
6288 f2PadPitchLength = par->GetOuter2PadPitchLength();
6290 fN=par->GetNRowUp();
6291 fRow=new AliTPCRow[fN];
6292 for (Int_t i=0; i<fN; i++) {
6293 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6294 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6299 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6301 // default constructor
6309 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6316 //_________________________________________________________________________
6318 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6319 //-----------------------------------------------------------------------
6320 // Insert a cluster into this pad row in accordence with its y-coordinate
6321 //-----------------------------------------------------------------------
6322 if (fN==kMaxClusterPerRow) {
6323 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6325 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6326 Int_t i=Find(c->GetZ());
6327 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6328 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6329 fIndex[i]=index; fClusters[i]=c; fN++;
6332 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6338 //delete[] fClusterArray;
6339 if (fClusters1) delete []fClusters1;
6340 if (fClusters2) delete []fClusters2;
6347 //___________________________________________________________________
6348 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6349 //-----------------------------------------------------------------------
6350 // Return the index of the nearest cluster
6351 //-----------------------------------------------------------------------
6352 if (fN==0) return 0;
6353 if (z <= fClusters[0]->GetZ()) return 0;
6354 if (z > fClusters[fN-1]->GetZ()) return fN;
6355 Int_t b=0, e=fN-1, m=(b+e)/2;
6356 for (; b<e; m=(b+e)/2) {
6357 if (z > fClusters[m]->GetZ()) b=m+1;
6365 //___________________________________________________________________
6366 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6367 //-----------------------------------------------------------------------
6368 // Return the index of the nearest cluster in z y
6369 //-----------------------------------------------------------------------
6370 Float_t maxdistance = roady*roady + roadz*roadz;
6372 AliTPCclusterMI *cl =0;
6373 for (Int_t i=Find(z-roadz); i<fN; i++) {
6374 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6375 if (c->GetZ() > z+roadz) break;
6376 if ( (c->GetY()-y) > roady ) continue;
6377 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6378 if (maxdistance>distance) {
6379 maxdistance = distance;
6386 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6388 //-----------------------------------------------------------------------
6389 // Return the index of the nearest cluster in z y
6390 //-----------------------------------------------------------------------
6391 Float_t maxdistance = roady*roady + roadz*roadz;
6392 AliTPCclusterMI *cl =0;
6394 //PH Check boundaries. 510 is the size of fFastCluster
6395 Int_t iz1 = Int_t(z-roadz+254.5);
6396 if (iz1<0 || iz1>=510) return cl;
6397 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6398 Int_t iz2 = Int_t(z+roadz+255.5);
6399 if (iz2<0 || iz2>=510) return cl;
6400 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6402 //FindNearest3(y,z,roady,roadz,index);
6403 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6404 for (Int_t i=iz1; i<iz2; i++) {
6405 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6406 if (c->GetZ() > z+roadz) break;
6407 if ( c->GetY()-y > roady ) continue;
6408 if ( y-c->GetY() > roady ) continue;
6409 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6410 if (maxdistance>distance) {
6411 maxdistance = distance;
6414 //roady = TMath::Sqrt(maxdistance);
6422 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6424 //-----------------------------------------------------------------------
6425 // Return the index of the nearest cluster in z y
6426 //-----------------------------------------------------------------------
6427 Float_t maxdistance = roady*roady + roadz*roadz;
6428 // Int_t iz = Int_t(z+255.);
6429 AliTPCclusterMI *cl =0;
6430 for (Int_t i=Find(z-roadz); i<fN; i++) {
6431 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6432 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6433 if (c->GetZ() > z+roadz) break;
6434 if ( c->GetY()-y > roady ) continue;
6435 if ( y-c->GetY() > roady ) continue;
6436 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6437 if (maxdistance>distance) {
6438 maxdistance = distance;
6441 //roady = TMath::Sqrt(maxdistance);
6451 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6455 // return &fTrackPoints[i];