1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker
23 //-------------------------------------------------------
28 #include "Riostream.h"
29 #include <TClonesArray.h>
31 #include <TObjArray.h>
35 #include "AliComplexCluster.h"
40 #include "AliRunLoader.h"
41 #include "AliTPCClustersRow.h"
42 #include "AliTPCParam.h"
43 #include "AliTPCReconstructor.h"
44 #include "AliTPCpolyTrack.h"
45 #include "AliTPCreco.h"
46 #include "AliTPCseed.h"
47 #include "AliTPCtrackerMI.h"
48 #include "TStopwatch.h"
49 #include "AliTPCReconstructor.h"
51 #include "TTreeStream.h"
52 #include "AliAlignObj.h"
53 #include "AliTrackPointArray.h"
57 ClassImp(AliTPCtrackerMI)
60 class AliTPCFastMath {
63 static Double_t FastAsin(Double_t x);
65 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
68 Double_t AliTPCFastMath::fgFastAsin[20000];
69 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
71 AliTPCFastMath::AliTPCFastMath(){
73 // initialized lookup table;
74 for (Int_t i=0;i<10000;i++){
75 fgFastAsin[2*i] = TMath::ASin(i/10000.);
76 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
80 Double_t AliTPCFastMath::FastAsin(Double_t x){
82 // return asin using lookup table
84 Int_t index = int(x*10000);
85 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
88 Int_t index = int(x*10000);
89 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
95 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
97 //update track information using current cluster - track->fCurrentCluster
100 AliTPCclusterMI* c =track->GetCurrentCluster();
101 if (accept>0) track->SetCurrentClusterIndex1(track->GetCurrentClusterIndex1() | 0x8000); //sign not accepted clusters
103 UInt_t i = track->GetCurrentClusterIndex1();
105 Int_t sec=(i&0xff000000)>>24;
106 //Int_t row = (i&0x00ff0000)>>16;
107 track->SetRow((i&0x00ff0000)>>16);
108 track->SetSector(sec);
109 // Int_t index = i&0xFFFF;
110 if (sec>=fParam->GetNInnerSector()) track->SetRow(track->GetRow()+fParam->GetNRowLow());
111 track->SetClusterIndex2(track->GetRow(), i);
112 //track->fFirstPoint = row;
113 //if ( track->fLastPoint<row) track->fLastPoint =row;
114 // if (track->fRow<0 || track->fRow>160) {
115 // printf("problem\n");
117 if (track->GetFirstPoint()>track->GetRow())
118 track->SetFirstPoint(track->GetRow());
119 if (track->GetLastPoint()<track->GetRow())
120 track->SetLastPoint(track->GetRow());
123 track->SetClusterPointer(track->GetRow(),c);
126 Double_t angle2 = track->GetSnp()*track->GetSnp();
128 //SET NEW Track Point
130 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
132 angle2 = TMath::Sqrt(angle2/(1-angle2));
133 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->GetRow()));
135 point.SetSigmaY(c->GetSigmaY2()/track->GetCurrentSigmaY2());
136 point.SetSigmaZ(c->GetSigmaZ2()/track->GetCurrentSigmaZ2());
137 point.SetErrY(sqrt(track->GetErrorY2()));
138 point.SetErrZ(sqrt(track->GetErrorZ2()));
140 point.SetX(track->GetX());
141 point.SetY(track->GetY());
142 point.SetZ(track->GetZ());
143 point.SetAngleY(angle2);
144 point.SetAngleZ(track->GetTgl());
145 if (point.IsShared()){
146 track->SetErrorY2(track->GetErrorY2()*4);
147 track->SetErrorZ2(track->GetErrorZ2()*4);
151 Double_t chi2 = track->GetPredictedChi2(track->GetCurrentCluster());
153 track->SetErrorY2(track->GetErrorY2()*1.3);
154 track->SetErrorY2(track->GetErrorY2()+0.01);
155 track->SetErrorZ2(track->GetErrorZ2()*1.3);
156 track->SetErrorZ2(track->GetErrorZ2()+0.005);
158 if (accept>0) return 0;
159 if (track->GetNumberOfClusters()%20==0){
160 // if (track->fHelixIn){
161 // TClonesArray & larr = *(track->fHelixIn);
162 // Int_t ihelix = larr.GetEntriesFast();
163 // new(larr[ihelix]) AliHelix(*track) ;
166 track->SetNoCluster(0);
167 return track->Update(c,chi2,i);
172 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
173 Float_t cory, Float_t corz)
176 // decide according desired precision to accept given
177 // cluster for tracking
178 Double_t sy2=ErrY2(seed,cluster)*cory;
179 Double_t sz2=ErrZ2(seed,cluster)*corz;
180 //sy2=ErrY2(seed,cluster)*cory;
181 //sz2=ErrZ2(seed,cluster)*cory;
183 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
184 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
186 Double_t rdistancey2 = (seed->GetCurrentCluster()->GetY()-seed->GetY())*
187 (seed->GetCurrentCluster()->GetY()-seed->GetY())/sdistancey2;
188 Double_t rdistancez2 = (seed->GetCurrentCluster()->GetZ()-seed->GetZ())*
189 (seed->GetCurrentCluster()->GetZ()-seed->GetZ())/sdistancez2;
191 Double_t rdistance2 = rdistancey2+rdistancez2;
194 if (rdistance2>16) return 3;
197 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
198 return 2; //suspisiouce - will be changed
200 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
201 // strict cut on overlaped cluster
202 return 2; //suspisiouce - will be changed
204 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
205 && cluster->GetType()<0){
206 seed->SetNFoundable(seed->GetNFoundable()-1);
215 //_____________________________________________________________________________
216 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
217 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
219 //---------------------------------------------------------------------
220 // The main TPC tracker constructor
221 //---------------------------------------------------------------------
222 fInnerSec=new AliTPCSector[fkNIS];
223 fOuterSec=new AliTPCSector[fkNOS];
226 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
227 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
234 Int_t nrowlow = par->GetNRowLow();
235 Int_t nrowup = par->GetNRowUp();
238 for (Int_t i=0;i<nrowlow;i++){
239 fXRow[i] = par->GetPadRowRadiiLow(i);
240 fPadLength[i]= par->GetPadPitchLength(0,i);
241 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
245 for (Int_t i=0;i<nrowup;i++){
246 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
247 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
248 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
259 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
261 //________________________________________________________________________
262 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
267 //------------------------------------
268 // dummy copy constructor
269 //------------------------------------------------------------------
271 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
272 //------------------------------
274 //--------------------------------------------------------------
277 //_____________________________________________________________________________
278 AliTPCtrackerMI::~AliTPCtrackerMI() {
279 //------------------------------------------------------------------
280 // TPC tracker destructor
281 //------------------------------------------------------------------
288 if (fDebugStreamer) delete fDebugStreamer;
291 void AliTPCtrackerMI::SetIO()
295 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
297 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
299 AliTPCtrack *iotrack= new AliTPCtrack;
300 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
306 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
322 AliTPCtrack *iotrack= new AliTPCtrack;
323 // iotrack->fHelixIn = new TClonesArray("AliHelix");
324 //iotrack->fHelixOut = new TClonesArray("AliHelix");
325 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
328 if (output && (fDebug&2)){
329 //write the full seed information if specified in debug mode
331 fSeedTree = new TTree("Seeds","Seeds");
332 AliTPCseed * vseed = new AliTPCseed;
334 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
335 arrtr->ExpandCreateFast(160);
336 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
338 vseed->SetPoints(arrtr);
339 vseed->SetEPoints(arre);
340 // vseed->fClusterPoints = arrcl;
341 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
344 fTreeDebug = new TTree("trackDebug","trackDebug");
345 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
346 fTreeDebug->Branch("debug",&arrd,32000,99);
354 void AliTPCtrackerMI::FillESD(TObjArray* arr)
358 //fill esds using updated tracks
360 // write tracks to the event
361 // store index of the track
362 Int_t nseed=arr->GetEntriesFast();
363 //FindKinks(arr,fEvent);
364 for (Int_t i=0; i<nseed; i++) {
365 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
368 // pt->PropagateTo(fParam->GetInnerRadiusLow());
369 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
370 pt->PropagateTo(fParam->GetInnerRadiusLow());
373 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
375 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
376 iotrack.SetTPCPoints(pt->GetPoints());
377 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
378 iotrack.SetV0Indexes(pt->GetV0Indexes());
379 // iotrack.SetTPCpid(pt->fTPCr);
380 //iotrack.SetTPCindex(i);
381 fEvent->AddTrack(&iotrack);
385 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.55) {
387 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
388 iotrack.SetTPCPoints(pt->GetPoints());
389 //iotrack.SetTPCindex(i);
390 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
391 iotrack.SetV0Indexes(pt->GetV0Indexes());
392 // iotrack.SetTPCpid(pt->fTPCr);
393 fEvent->AddTrack(&iotrack);
397 // short tracks - maybe decays
399 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.70) {
400 Int_t found,foundable,shared;
401 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
402 if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2)){
404 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
405 //iotrack.SetTPCindex(i);
406 iotrack.SetTPCPoints(pt->GetPoints());
407 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
408 iotrack.SetV0Indexes(pt->GetV0Indexes());
409 //iotrack.SetTPCpid(pt->fTPCr);
410 fEvent->AddTrack(&iotrack);
415 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.8) {
416 Int_t found,foundable,shared;
417 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
418 if (found<20) continue;
419 if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
422 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
423 iotrack.SetTPCPoints(pt->GetPoints());
424 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
425 iotrack.SetV0Indexes(pt->GetV0Indexes());
426 //iotrack.SetTPCpid(pt->fTPCr);
427 //iotrack.SetTPCindex(i);
428 fEvent->AddTrack(&iotrack);
431 // short tracks - secondaties
433 if ( (pt->GetNumberOfClusters()>30) ) {
434 Int_t found,foundable,shared;
435 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
436 if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
438 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
439 iotrack.SetTPCPoints(pt->GetPoints());
440 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
441 iotrack.SetV0Indexes(pt->GetV0Indexes());
442 //iotrack.SetTPCpid(pt->fTPCr);
443 //iotrack.SetTPCindex(i);
444 fEvent->AddTrack(&iotrack);
449 if ( (pt->GetNumberOfClusters()>15)) {
450 Int_t found,foundable,shared;
451 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
452 if (found<15) continue;
453 if (foundable<=0) continue;
454 if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
455 if (float(found)/float(foundable)<0.8) continue;
458 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
459 iotrack.SetTPCPoints(pt->GetPoints());
460 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
461 iotrack.SetV0Indexes(pt->GetV0Indexes());
462 // iotrack.SetTPCpid(pt->fTPCr);
463 //iotrack.SetTPCindex(i);
464 fEvent->AddTrack(&iotrack);
469 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
472 void AliTPCtrackerMI::WriteTracks(TTree * tree)
475 // write tracks from seed array to selected tree
479 AliTPCtrack *iotrack= new AliTPCtrack;
480 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
485 void AliTPCtrackerMI::WriteTracks()
488 // write tracks to the given output tree -
489 // output specified with SetIO routine
496 AliTPCtrack *iotrack= 0;
497 Int_t nseed=fSeeds->GetEntriesFast();
498 //for (Int_t i=0; i<nseed; i++) {
499 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
500 // if (iotrack) break;
502 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
503 TBranch * br = fOutput->GetBranch("tracks");
504 br->SetAddress(&iotrack);
506 for (Int_t i=0; i<nseed; i++) {
507 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
509 AliTPCtrack * track = new AliTPCtrack(*pt);
512 // br->SetAddress(&iotrack);
517 //fOutput->GetDirectory()->cd();
523 //write the full seed information if specified in debug mode
525 AliTPCseed * vseed = new AliTPCseed;
527 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
528 arrtr->ExpandCreateFast(160);
529 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
530 //arrcl->ExpandCreateFast(160);
531 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
533 vseed->SetPoints(arrtr);
534 vseed->SetEPoints(arre);
535 // vseed->fClusterPoints = arrcl;
536 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
537 TBranch * brseed = fSeedTree->GetBranch("seeds");
539 Int_t nseed=fSeeds->GetEntriesFast();
541 for (Int_t i=0; i<nseed; i++) {
542 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
544 pt->SetPoints(arrtr);
545 // pt->fClusterPoints = arrcl;
546 pt->SetEPoints(arre);
549 brseed->SetAddress(&vseed);
553 // pt->fClusterPoints = 0;
556 if (fTreeDebug) fTreeDebug->Write();
564 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
567 //seed->SetErrorY2(0.1);
569 //calculate look-up table at the beginning
570 static Bool_t ginit = kFALSE;
571 static Float_t gnoise1,gnoise2,gnoise3;
572 static Float_t ggg1[10000];
573 static Float_t ggg2[10000];
574 static Float_t ggg3[10000];
575 static Float_t glandau1[10000];
576 static Float_t glandau2[10000];
577 static Float_t glandau3[10000];
579 static Float_t gcor01[500];
580 static Float_t gcor02[500];
581 static Float_t gcorp[500];
586 for (Int_t i=1;i<500;i++){
587 Float_t rsigma = float(i)/100.;
588 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
589 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
590 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
594 for (Int_t i=3;i<10000;i++){
598 Float_t amp = float(i);
599 Float_t padlength =0.75;
600 gnoise1 = 0.0004/padlength;
601 Float_t nel = 0.268*amp;
602 Float_t nprim = 0.155*amp;
603 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
604 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
605 if (glandau1[i]>1) glandau1[i]=1;
606 glandau1[i]*=padlength*padlength/12.;
610 gnoise2 = 0.0004/padlength;
613 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
614 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
615 if (glandau2[i]>1) glandau2[i]=1;
616 glandau2[i]*=padlength*padlength/12.;
621 gnoise3 = 0.0004/padlength;
624 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
625 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
626 if (glandau3[i]>1) glandau3[i]=1;
627 glandau3[i]*=padlength*padlength/12.;
635 Int_t amp = int(TMath::Abs(cl->GetQ()));
637 seed->SetErrorY2(1.);
641 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
642 Int_t ctype = cl->GetType();
643 Float_t padlength= GetPadPitchLength(seed->GetRow());
644 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
645 angle2 = angle2/(1-angle2);
648 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->GetCurrentSigmaY2()));
651 if (fSectors==fInnerSec){
653 res = ggg1[amp]*z+glandau1[amp]*angle2;
654 if (ctype==0) res *= gcor01[rsigmay];
657 res*= gcorp[rsigmay];
663 res = ggg2[amp]*z+glandau2[amp]*angle2;
664 if (ctype==0) res *= gcor02[rsigmay];
667 res*= gcorp[rsigmay];
672 res = ggg3[amp]*z+glandau3[amp]*angle2;
673 if (ctype==0) res *= gcor02[rsigmay];
676 res*= gcorp[rsigmay];
683 res*=2.4; // overestimate error 2 times
690 seed->SetErrorY2(res);
698 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
701 //seed->SetErrorY2(0.1);
703 //calculate look-up table at the beginning
704 static Bool_t ginit = kFALSE;
705 static Float_t gnoise1,gnoise2,gnoise3;
706 static Float_t ggg1[10000];
707 static Float_t ggg2[10000];
708 static Float_t ggg3[10000];
709 static Float_t glandau1[10000];
710 static Float_t glandau2[10000];
711 static Float_t glandau3[10000];
713 static Float_t gcor01[1000];
714 static Float_t gcor02[1000];
715 static Float_t gcorp[1000];
720 for (Int_t i=1;i<1000;i++){
721 Float_t rsigma = float(i)/100.;
722 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
723 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
724 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
728 for (Int_t i=3;i<10000;i++){
732 Float_t amp = float(i);
733 Float_t padlength =0.75;
734 gnoise1 = 0.0004/padlength;
735 Float_t nel = 0.268*amp;
736 Float_t nprim = 0.155*amp;
737 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
738 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
739 if (glandau1[i]>1) glandau1[i]=1;
740 glandau1[i]*=padlength*padlength/12.;
744 gnoise2 = 0.0004/padlength;
747 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
748 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
749 if (glandau2[i]>1) glandau2[i]=1;
750 glandau2[i]*=padlength*padlength/12.;
755 gnoise3 = 0.0004/padlength;
758 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
759 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
760 if (glandau3[i]>1) glandau3[i]=1;
761 glandau3[i]*=padlength*padlength/12.;
769 Int_t amp = int(TMath::Abs(cl->GetQ()));
771 seed->SetErrorY2(1.);
775 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
776 Int_t ctype = cl->GetType();
777 Float_t padlength= GetPadPitchLength(seed->GetRow());
779 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
780 // if (angle2<0.6) angle2 = 0.6;
781 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
784 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->GetCurrentSigmaZ2()));
787 if (fSectors==fInnerSec){
789 res = ggg1[amp]*z+glandau1[amp]*angle2;
790 if (ctype==0) res *= gcor01[rsigmaz];
793 res*= gcorp[rsigmaz];
799 res = ggg2[amp]*z+glandau2[amp]*angle2;
800 if (ctype==0) res *= gcor02[rsigmaz];
803 res*= gcorp[rsigmaz];
808 res = ggg3[amp]*z+glandau3[amp]*angle2;
809 if (ctype==0) res *= gcor02[rsigmaz];
812 res*= gcorp[rsigmaz];
821 if ((ctype<0) &&<70){
829 seed->SetErrorZ2(res);
836 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
839 //seed->SetErrorZ2(0.1);
843 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
845 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
846 Int_t ctype = cl->GetType();
847 Float_t amp = TMath::Abs(cl->GetQ());
852 Float_t landau=2 ; //landau fluctuation part
853 Float_t gg=2; // gg fluctuation part
854 Float_t padlength= GetPadPitchLength(seed->GetX());
856 if (fSectors==fInnerSec){
857 snoise2 = 0.0004/padlength;
860 gg = (2+0.001*nel/(padlength*padlength))/nel;
861 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
862 if (landau>1) landau=1;
865 snoise2 = 0.0004/padlength;
868 gg = (2+0.0008*nel/(padlength*padlength))/nel;
869 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
870 if (landau>1) landau=1;
872 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
875 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
876 angle2 = TMath::Sqrt((1-angle2));
877 if (angle2<0.6) angle2 = 0.6;
880 Float_t angle = seed->GetTgl()/angle2;
881 Float_t angular = landau*angle*angle*padlength*padlength/12.;
882 Float_t res = sdiff + angular;
885 if ((ctype==0) && (fSectors ==fOuterSec))
886 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
888 if ((ctype==0) && (fSectors ==fInnerSec))
889 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
893 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
899 if ((ctype<0) &&<70){
907 seed->SetErrorZ2(res);
915 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
917 //rotate to track "local coordinata
918 Float_t x = seed->GetX();
919 Float_t y = seed->GetY();
920 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
923 seed->SetRelativeSector((seed->GetRelativeSector()+1) % fN);
924 if (!seed->Rotate(fSectors->GetAlpha()))
926 } else if (y <-ymax) {
927 seed->SetRelativeSector((seed->GetRelativeSector()-1+fN) % fN);
928 if (!seed->Rotate(-fSectors->GetAlpha()))
936 //_____________________________________________________________________________
937 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
938 Double_t x2,Double_t y2,
939 Double_t x3,Double_t y3)
941 //-----------------------------------------------------------------
942 // Initial approximation of the track curvature
943 //-----------------------------------------------------------------
944 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
945 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
946 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
947 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
948 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
950 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
951 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
952 return -xr*yr/sqrt(xr*xr+yr*yr);
957 //_____________________________________________________________________________
958 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
959 Double_t x2,Double_t y2,
960 Double_t x3,Double_t y3)
962 //-----------------------------------------------------------------
963 // Initial approximation of the track curvature
964 //-----------------------------------------------------------------
970 Double_t det = x3*y2-x2*y3;
975 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
976 Double_t x0 = x3*0.5-y3*u;
977 Double_t y0 = y3*0.5+x3*u;
978 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
984 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
985 Double_t x2,Double_t y2,
986 Double_t x3,Double_t y3)
988 //-----------------------------------------------------------------
989 // Initial approximation of the track curvature
990 //-----------------------------------------------------------------
996 Double_t det = x3*y2-x2*y3;
1001 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1002 Double_t x0 = x3*0.5-y3*u;
1003 Double_t y0 = y3*0.5+x3*u;
1004 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1013 //_____________________________________________________________________________
1014 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1015 Double_t x2,Double_t y2,
1016 Double_t x3,Double_t y3)
1018 //-----------------------------------------------------------------
1019 // Initial approximation of the track curvature times center of curvature
1020 //-----------------------------------------------------------------
1021 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1022 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1023 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1024 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1025 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1027 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1029 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1032 //_____________________________________________________________________________
1033 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1034 Double_t x2,Double_t y2,
1035 Double_t z1,Double_t z2)
1037 //-----------------------------------------------------------------
1038 // Initial approximation of the tangent of the track dip angle
1039 //-----------------------------------------------------------------
1040 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1044 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1045 Double_t x2,Double_t y2,
1046 Double_t z1,Double_t z2, Double_t c)
1048 //-----------------------------------------------------------------
1049 // Initial approximation of the tangent of the track dip angle
1050 //-----------------------------------------------------------------
1054 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1056 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1057 if (TMath::Abs(d*c*0.5)>1) return 0;
1058 // Double_t angle2 = TMath::ASin(d*c*0.5);
1059 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1060 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1062 angle2 = (z1-z2)*c/(angle2*2.);
1066 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1067 {//-----------------------------------------------------------------
1068 // This function find proloncation of a track to a reference plane x=x2.
1069 //-----------------------------------------------------------------
1073 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1077 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1078 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1082 Double_t dy = dx*(c1+c2)/(r1+r2);
1085 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1087 if (TMath::Abs(delta)>0.01){
1088 dz = x[3]*TMath::ASin(delta)/x[4];
1090 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1093 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1101 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1106 return LoadClusters();
1109 Int_t AliTPCtrackerMI::LoadClusters()
1112 // load clusters to the memory
1113 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1114 clrow->SetClass("AliTPCclusterMI");
1116 clrow->GetArray()->ExpandCreateFast(10000);
1118 // TTree * tree = fClustersArray.GetTree();
1120 TTree * tree = fInput;
1121 TBranch * br = tree->GetBranch("Segment");
1122 br->SetAddress(&clrow);
1124 Int_t j=Int_t(tree->GetEntries());
1125 for (Int_t i=0; i<j; i++) {
1129 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1130 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1131 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1134 AliTPCRow * tpcrow=0;
1137 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1141 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1142 left = (sec-fkNIS*2)/fkNOS;
1145 tpcrow->SetN1(clrow->GetArray()->GetEntriesFast());
1146 tpcrow->SetClusters1(new AliTPCclusterMI[tpcrow->GetN1()]);
1147 for (Int_t i=0;i<tpcrow->GetN1();i++)
1148 tpcrow->SetCluster1(i, *(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
1151 tpcrow->SetN2(clrow->GetArray()->GetEntriesFast());
1152 tpcrow->SetClusters2(new AliTPCclusterMI[tpcrow->GetN2()]);
1153 for (Int_t i=0;i<tpcrow->GetN2();i++)
1154 tpcrow->SetCluster2(i,*(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
1165 void AliTPCtrackerMI::UnloadClusters()
1168 // unload clusters from the memory
1170 Int_t nrows = fOuterSec->GetNRows();
1171 for (Int_t sec = 0;sec<fkNOS;sec++)
1172 for (Int_t row = 0;row<nrows;row++){
1173 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1175 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1176 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1178 tpcrow->ResetClusters();
1181 nrows = fInnerSec->GetNRows();
1182 for (Int_t sec = 0;sec<fkNIS;sec++)
1183 for (Int_t row = 0;row<nrows;row++){
1184 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1186 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1187 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1189 tpcrow->ResetClusters();
1195 void AliTPCtrackerMI::Transform(AliCluster * cluster){
1199 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1200 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1202 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1204 //mat.LocalToMaster(pos,posC);
1205 mat->LocalToMaster(pos,posC);
1206 cluster->SetX(posC[0]);
1207 cluster->SetY(posC[1]);
1208 cluster->SetZ(posC[2]);
1211 //_____________________________________________________________________________
1212 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1213 //-----------------------------------------------------------------
1214 // This function fills outer TPC sectors with clusters.
1215 //-----------------------------------------------------------------
1216 Int_t nrows = fOuterSec->GetNRows();
1218 for (Int_t sec = 0;sec<fkNOS;sec++)
1219 for (Int_t row = 0;row<nrows;row++){
1220 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1221 Int_t sec2 = sec+2*fkNIS;
1223 Int_t ncl = tpcrow->GetN1();
1225 AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
1226 index=(((sec2<<8)+row)<<16)+ncl;
1227 tpcrow->InsertCluster(c,index);
1230 ncl = tpcrow->GetN2();
1232 AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
1233 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1234 tpcrow->InsertCluster(c,index);
1237 // write indexes for fast acces
1239 for (Int_t i=0;i<510;i++)
1240 tpcrow->SetFastCluster(i,-1);
1241 for (Int_t i=0;i<tpcrow->GetN();i++){
1242 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1243 tpcrow->SetFastCluster(zi,i); // write index
1246 for (Int_t i=0;i<510;i++){
1247 if (tpcrow->GetFastCluster(i)<0)
1248 tpcrow->SetFastCluster(i,last);
1250 last = tpcrow->GetFastCluster(i);
1259 //_____________________________________________________________________________
1260 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1261 //-----------------------------------------------------------------
1262 // This function fills inner TPC sectors with clusters.
1263 //-----------------------------------------------------------------
1264 Int_t nrows = fInnerSec->GetNRows();
1266 for (Int_t sec = 0;sec<fkNIS;sec++)
1267 for (Int_t row = 0;row<nrows;row++){
1268 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1271 Int_t ncl = tpcrow->GetN1();
1273 AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
1274 index=(((sec<<8)+row)<<16)+ncl;
1275 tpcrow->InsertCluster(c,index);
1278 ncl = tpcrow->GetN2();
1280 AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
1281 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1282 tpcrow->InsertCluster(c,index);
1285 // write indexes for fast acces
1287 for (Int_t i=0;i<510;i++)
1288 tpcrow->SetFastCluster(i,-1);
1289 for (Int_t i=0;i<tpcrow->GetN();i++){
1290 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1291 tpcrow->SetFastCluster(zi,i); // write index
1294 for (Int_t i=0;i<510;i++){
1295 if (tpcrow->GetFastCluster(i)<0)
1296 tpcrow->SetFastCluster(i,last);
1298 last = tpcrow->GetFastCluster(i);
1310 //_________________________________________________________________________
1311 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1312 //--------------------------------------------------------------------
1313 // Return pointer to a given cluster
1314 //--------------------------------------------------------------------
1315 if (index<0) return 0; // no cluster
1316 Int_t sec=(index&0xff000000)>>24;
1317 Int_t row=(index&0x00ff0000)>>16;
1318 Int_t ncl=(index&0x00007fff)>>00;
1320 const AliTPCRow * tpcrow=0;
1321 AliTPCclusterMI * clrow =0;
1323 if (sec<0 || sec>=fkNIS*4) {
1324 AliWarning(Form("Wrong sector %d",sec));
1329 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1330 if (tpcrow==0) return 0;
1333 if (tpcrow->GetN1()<=ncl) return 0;
1334 clrow = tpcrow->GetClusters1();
1337 if (tpcrow->GetN2()<=ncl) return 0;
1338 clrow = tpcrow->GetClusters2();
1342 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1343 if (tpcrow==0) return 0;
1345 if (sec-2*fkNIS<fkNOS) {
1346 if (tpcrow->GetN1()<=ncl) return 0;
1347 clrow = tpcrow->GetClusters1();
1350 if (tpcrow->GetN2()<=ncl) return 0;
1351 clrow = tpcrow->GetClusters2();
1355 return &(clrow[ncl]);
1361 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1362 //-----------------------------------------------------------------
1363 // This function tries to find a track prolongation to next pad row
1364 //-----------------------------------------------------------------
1366 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1367 AliTPCclusterMI *cl=0;
1368 Int_t tpcindex= t.GetClusterIndex2(nr);
1370 // update current shape info every 5 pad-row
1371 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1375 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1377 if (tpcindex==-1) return 0; //track in dead zone
1379 cl = t.GetClusterPointer(nr);
1380 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1381 t.SetCurrentClusterIndex1(tpcindex);
1384 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1385 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1387 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1388 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1390 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1391 Double_t rotation = angle-t.GetAlpha();
1392 t.SetRelativeSector(relativesector);
1393 if (!t.Rotate(rotation)) return 0;
1395 if (!t.PropagateTo(x)) return 0;
1397 t.SetCurrentCluster(cl);
1399 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1400 if ((tpcindex&0x8000)==0) accept =0;
1402 //if founded cluster is acceptible
1403 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1404 t.SetErrorY2(t.GetErrorY2()+0.03);
1405 t.SetErrorZ2(t.GetErrorZ2()+0.03);
1406 t.SetErrorY2(t.GetErrorY2()*3);
1407 t.SetErrorZ2(t.GetErrorZ2()*3);
1409 t.SetNFoundable(t.GetNFoundable()+1);
1410 UpdateTrack(&t,accept);
1415 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1417 // not look for new cluster during refitting
1418 t.SetNFoundable(t.GetNFoundable()+1);
1423 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1424 Double_t y=t.GetYat(x);
1425 if (TMath::Abs(y)>ymax){
1427 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1428 if (!t.Rotate(fSectors->GetAlpha()))
1430 } else if (y <-ymax) {
1431 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1432 if (!t.Rotate(-fSectors->GetAlpha()))
1438 if (!t.PropagateTo(x)) {
1439 if (fIteration==0) t.SetRemoval(10);
1443 Double_t z=t.GetZ();
1446 if (!IsActive(t.GetRelativeSector(),nr)) {
1448 t.SetClusterIndex2(nr,-1);
1451 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1452 Bool_t isActive = IsActive(t.GetRelativeSector(),nr);
1453 Bool_t isActive2 = (nr>=fInnerSec->GetNRows()) ? fOuterSec[t.GetRelativeSector()][nr-fInnerSec->GetNRows()].GetN()>0:fInnerSec[t.GetRelativeSector()][nr].GetN()>0;
1455 if (!isActive || !isActive2) return 0;
1457 const AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1458 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1460 Double_t roadz = 1.;
1462 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1464 t.SetClusterIndex2(nr,-1);
1469 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1470 t.SetNFoundable(t.GetNFoundable()+1);
1476 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1477 cl = krow.FindNearest2(y,z,roady,roadz,index);
1478 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));
1481 t.SetCurrentCluster(cl);
1483 if (fIteration==2&&cl->IsUsed(10)) return 0;
1484 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1485 if (fIteration==2&&cl->IsUsed(11)) {
1486 t.SetErrorY2(t.GetErrorY2()+0.03);
1487 t.SetErrorZ2(t.GetErrorZ2()+0.03);
1488 t.SetErrorY2(t.GetErrorY2()*3);
1489 t.SetErrorZ2(t.GetErrorZ2()*3);
1492 if (t.fCurrentCluster->IsUsed(10)){
1497 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1503 if (accept<3) UpdateTrack(&t,accept);
1506 if ( fIteration==0 && t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) t.SetRemoval(10);
1512 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1513 //-----------------------------------------------------------------
1514 // This function tries to find a track prolongation to next pad row
1515 //-----------------------------------------------------------------
1517 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1519 if (!t.GetProlongation(x,y,z)) {
1525 if (TMath::Abs(y)>ymax){
1528 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1529 if (!t.Rotate(fSectors->GetAlpha()))
1531 } else if (y <-ymax) {
1532 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1533 if (!t.Rotate(-fSectors->GetAlpha()))
1536 if (!t.PropagateTo(x)) {
1539 t.GetProlongation(x,y,z);
1542 // update current shape info every 3 pad-row
1543 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.GetCurrentSigmaY2()<0.0001) ){
1544 // t.fCurrentSigmaY = GetSigmaY(&t);
1545 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1549 AliTPCclusterMI *cl=0;
1554 const AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1555 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1557 Double_t roadz = 1.;
1560 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1562 t.SetClusterIndex2(row,-1);
1567 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1571 if ((cl==0)&&(krow)) {
1572 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1573 cl = krow.FindNearest2(y,z,roady,roadz,index);
1575 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));
1579 t.SetCurrentCluster(cl);
1580 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1582 t.SetClusterIndex2(row,index);
1583 t.SetClusterPointer(row, cl);
1591 //_________________________________________________________________________
1592 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1594 // Get track space point by index
1595 // return false in case the cluster doesn't exist
1596 AliTPCclusterMI *cl = GetClusterMI(index);
1597 if (!cl) return kFALSE;
1598 Int_t sector = (index&0xff000000)>>24;
1599 // Int_t row = (index&0x00ff0000)>>16;
1601 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1602 xyz[0] = cl->GetX();
1603 xyz[1] = cl->GetY();
1604 xyz[2] = cl->GetZ();
1606 fParam->AdjustCosSin(sector,cos,sin);
1607 Float_t x = cos*xyz[0]-sin*xyz[1];
1608 Float_t y = cos*xyz[1]+sin*xyz[0];
1610 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1611 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1612 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1613 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1614 cov[0] = sin*sin*sigmaY2;
1615 cov[1] = -sin*cos*sigmaY2;
1617 cov[3] = cos*cos*sigmaY2;
1620 p.SetXYZ(x,y,xyz[2],cov);
1621 AliAlignObj::ELayerID iLayer;
1623 if (sector < fParam->GetNInnerSector()) {
1624 iLayer = AliAlignObj::kTPC1;
1628 iLayer = AliAlignObj::kTPC2;
1629 idet = sector - fParam->GetNInnerSector();
1631 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1632 p.SetVolumeID(volid);
1638 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1639 //-----------------------------------------------------------------
1640 // This function tries to find a track prolongation to next pad row
1641 //-----------------------------------------------------------------
1642 t.SetCurrentCluster(0);
1643 t.SetCurrentClusterIndex1(0);
1645 Double_t xt=t.GetX();
1646 Int_t row = GetRowNumber(xt)-1;
1647 Double_t ymax= GetMaxY(nr);
1649 if (row < nr) return 1; // don't prolongate if not information until now -
1650 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1652 // return 0; // not prolongate strongly inclined tracks
1654 // if (TMath::Abs(t.GetSnp())>0.95) {
1656 // return 0; // not prolongate strongly inclined tracks
1657 // }// patch 28 fev 06
1659 Double_t x= GetXrow(nr);
1661 //t.PropagateTo(x+0.02);
1662 //t.PropagateTo(x+0.01);
1663 if (!t.PropagateTo(x)){
1670 if (TMath::Abs(y)>ymax){
1672 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1673 if (!t.Rotate(fSectors->GetAlpha()))
1675 } else if (y <-ymax) {
1676 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1677 if (!t.Rotate(-fSectors->GetAlpha()))
1680 // if (!t.PropagateTo(x)){
1687 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1689 if (!IsActive(t.GetRelativeSector(),nr)) {
1691 t.SetClusterIndex2(nr,-1);
1694 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1696 AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1698 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1700 t.SetClusterIndex2(nr,-1);
1705 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.SetNFoundable(t.GetNFoundable()+1);
1711 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1712 // t.fCurrentSigmaY = GetSigmaY(&t);
1713 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1717 AliTPCclusterMI *cl=0;
1720 Double_t roady = 1.;
1721 Double_t roadz = 1.;
1725 index = t.GetClusterIndex2(nr);
1726 if ( (index>0) && (index&0x8000)==0){
1727 cl = t.GetClusterPointer(nr);
1728 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1729 t.SetCurrentClusterIndex1(index);
1731 t.SetCurrentCluster(cl);
1737 // if (index<0) return 0;
1738 UInt_t uindex = TMath::Abs(index);
1741 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1742 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1745 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(uindex));
1746 t.SetCurrentCluster(cl);
1752 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1753 //-----------------------------------------------------------------
1754 // This function tries to find a track prolongation to next pad row
1755 //-----------------------------------------------------------------
1757 //update error according neighborhoud
1759 if (t.GetCurrentCluster()) {
1761 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1763 if (t.GetCurrentCluster()->IsUsed(10)){
1768 t.SetNShared(t.GetNShared()+1);
1769 if (t.GetNShared()>0.7*t.GetNumberOfClusters()) {
1774 if (fIteration>0) accept = 0;
1775 if (accept<3) UpdateTrack(&t,accept);
1779 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.SetRemoval(10);
1780 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.SetRemoval(10);
1782 if (( (t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) || t.GetNoCluster()>15)) t.SetRemoval(10);
1790 //_____________________________________________________________________________
1791 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1792 //-----------------------------------------------------------------
1793 // This function tries to find a track prolongation.
1794 //-----------------------------------------------------------------
1795 Double_t xt=t.GetX();
1797 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1798 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1799 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1801 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1803 Int_t first = GetRowNumber(xt)-1;
1804 for (Int_t nr= first; nr>=rf; nr-=step) {
1806 if (t.GetKinkIndexes()[0]>0){
1807 for (Int_t i=0;i<3;i++){
1808 Int_t index = t.GetKinkIndexes()[i];
1809 if (index==0) break;
1810 if (index<0) continue;
1812 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1814 printf("PROBLEM\n");
1817 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1819 AliExternalTrackParam paramd(t);
1820 kink->SetDaughter(paramd);
1821 kink->SetStatus(2,5);
1828 if (nr==80) t.UpdateReference();
1829 if (nr<fInnerSec->GetNRows())
1830 fSectors = fInnerSec;
1832 fSectors = fOuterSec;
1833 if (FollowToNext(t,nr)==0)
1842 //_____________________________________________________________________________
1843 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1844 //-----------------------------------------------------------------
1845 // This function tries to find a track prolongation.
1846 //-----------------------------------------------------------------
1847 Double_t xt=t.GetX();
1849 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1850 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1851 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1852 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1854 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1856 if (FollowToNextFast(t,nr)==0)
1857 if (!t.IsActive()) return 0;
1867 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1868 //-----------------------------------------------------------------
1869 // This function tries to find a track prolongation.
1870 //-----------------------------------------------------------------
1872 Double_t xt=t.GetX();
1873 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1874 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1875 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1876 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1878 Int_t first = t.GetFirstPoint();
1879 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1881 if (first<0) first=0;
1882 for (Int_t nr=first; nr<=rf; nr++) {
1883 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1884 if (t.GetKinkIndexes()[0]<0){
1885 for (Int_t i=0;i<3;i++){
1886 Int_t index = t.GetKinkIndexes()[i];
1887 if (index==0) break;
1888 if (index>0) continue;
1889 index = TMath::Abs(index);
1890 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1892 printf("PROBLEM\n");
1895 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1897 AliExternalTrackParam paramm(t);
1898 kink->SetMother(paramm);
1899 kink->SetStatus(2,1);
1906 if (nr<fInnerSec->GetNRows())
1907 fSectors = fInnerSec;
1909 fSectors = fOuterSec;
1920 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1928 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1931 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1933 Float_t distance = TMath::Sqrt(dz2+dy2);
1934 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1937 Int_t firstpoint = TMath::Min(s1->GetFirstPoint(),s2->GetFirstPoint());
1938 Int_t lastpoint = TMath::Max(s1->GetLastPoint(),s2->GetLastPoint());
1943 if (firstpoint>lastpoint) {
1944 firstpoint =lastpoint;
1949 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1950 if (s1->GetClusterIndex2(i)>0) sum1++;
1951 if (s2->GetClusterIndex2(i)>0) sum2++;
1952 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1956 if (sum<5) return 0;
1958 Float_t summin = TMath::Min(sum1+1,sum2+1);
1959 Float_t ratio = (sum+1)/Float_t(summin);
1963 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1967 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1968 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1970 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1972 Float_t dy2 =(s1->GetY() - s2->GetY());
1974 Float_t distance = dz2+dy2;
1975 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1980 Int_t firstpoint = TMath::Max(s1->GetFirstPoint(),s2->GetFirstPoint());
1981 Int_t lastpoint = TMath::Min(s1->GetLastPoint(),s2->GetLastPoint());
1983 if (firstpoint>=lastpoint-5) return;;
1985 for (Int_t i=firstpoint;i<lastpoint;i++){
1986 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1987 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1994 for (Int_t i=firstpoint;i<lastpoint;i++){
1995 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1996 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1997 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1998 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1999 if (s1->IsActive()&&s2->IsActive()){
2000 p1->SetShared(kTRUE);
2001 p2->SetShared(kTRUE);
2008 for (Int_t i=0;i<4;i++){
2009 if (s1->GetOverlapLabel(3*i)==0){
2010 s1->SetOverlapLabel(3*i, s2->GetLabel());
2011 s1->SetOverlapLabel(3*i+1,sumshared);
2012 s1->SetOverlapLabel(3*i+2,s2->GetUniqueID());
2016 for (Int_t i=0;i<4;i++){
2017 if (s2->GetOverlapLabel(3*i)==0){
2018 s2->SetOverlapLabel(3*i, s1->GetLabel());
2019 s2->SetOverlapLabel(3*i+1,sumshared);
2020 s2->SetOverlapLabel(3*i+2,s1->GetUniqueID());
2028 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2031 //sort trackss according sectors
2033 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2034 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2036 //if (pt) RotateToLocal(pt);
2040 arr->Sort(); // sorting according z
2041 arr->Expand(arr->GetEntries());
2044 Int_t nseed=arr->GetEntriesFast();
2045 for (Int_t i=0; i<nseed; i++) {
2046 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2048 for (Int_t j=0;j<=12;j++){
2049 pt->SetOverlapLabel(j,0);
2052 for (Int_t i=0; i<nseed; i++) {
2053 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2055 if (pt->GetRemoval()>10) continue;
2056 for (Int_t j=i+1; j<nseed; j++){
2057 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2059 if (pt2->GetRemoval()<=10) {
2060 if ( TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>0) break;
2067 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2070 //sort trackss according sectors
2073 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2076 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2077 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2082 arr->Sort(); // sorting according z
2083 arr->Expand(arr->GetEntries());
2085 //reset overlap labels
2087 Int_t nseed=arr->GetEntriesFast();
2088 for (Int_t i=0; i<nseed; i++) {
2089 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2092 for (Int_t j=0;j<=12;j++){
2093 pt->SetOverlapLabel(j,0);
2097 //sign shared tracks
2098 for (Int_t i=0; i<nseed; i++) {
2099 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2101 if (pt->GetRemoval()>10) continue;
2102 Float_t deltac = pt->GetC()*0.1;
2103 for (Int_t j=i+1; j<nseed; j++){
2104 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2106 if (pt2->GetRemoval()<=10) {
2107 if ( TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>0) break;
2108 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2109 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2116 // remove highly shared tracks
2117 for (Int_t i=0; i<nseed; i++) {
2118 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2120 if (pt->GetRemoval()>10) continue;
2123 for (Int_t j=0;j<4;j++){
2124 sumshared = pt->GetOverlapLabel(j*3+1);
2126 Float_t factor = factor1;
2127 if (pt->GetRemoval()>0) factor = factor2;
2128 if (sumshared/pt->GetNumberOfClusters()>factor){
2129 for (Int_t j=0;j<4;j++){
2130 if (pt->GetOverlapLabel(3*j)==0) continue;
2131 if (pt->GetOverlapLabel(3*j+1)<5) continue;
2132 if (pt->GetRemoval()==removalindex) continue;
2133 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->GetOverlapLabel(3*j+2));
2135 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2136 // pt->fRemoval = removalindex;
2137 delete arr->RemoveAt(i);
2145 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2154 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2157 //sort tracks in array according mode criteria
2158 Int_t nseed = arr->GetEntriesFast();
2159 for (Int_t i=0; i<nseed; i++) {
2160 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2170 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2173 //Loop over all tracks and remove "overlaps"
2176 Int_t nseed = arr->GetEntriesFast();
2179 for (Int_t i=0; i<nseed; i++) {
2180 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2182 delete arr->RemoveAt(i);
2186 pt->SetBSigned(kFALSE);
2190 nseed = arr->GetEntriesFast();
2197 for (Int_t i=0; i<nseed; i++) {
2198 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2202 Int_t found,foundable,shared;
2204 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2206 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2208 Double_t factor = factor2;
2209 if (pt->GetBConstrain()) factor = factor1;
2211 if ((Float_t(shared)/Float_t(found))>factor){
2212 pt->Desactivate(removalindex);
2217 for (Int_t i=0; i<160; i++) {
2218 Int_t index=pt->GetClusterIndex2(i);
2219 if (index<0 || index&0x8000 ) continue;
2220 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2222 // if (!c->IsUsed(10)) c->Use(10);
2223 //if (pt->IsActive())
2232 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2237 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2240 //Loop over all tracks and remove "overlaps"
2245 Int_t nseed = arr->GetEntriesFast();
2246 Float_t * quality = new Float_t[nseed];
2247 Int_t * indexes = new Int_t[nseed];
2251 for (Int_t i=0; i<nseed; i++) {
2252 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2257 pt->UpdatePoints(); //select first last max dens points
2258 Float_t * points = pt->GetPoints();
2259 if (points[3]<0.8) quality[i] =-1;
2261 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2263 TMath::Sort(nseed,quality,indexes);
2266 for (Int_t itrack=0; itrack<nseed; itrack++) {
2267 Int_t trackindex = indexes[itrack];
2268 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2269 if (quality[trackindex]<0){
2271 delete arr->RemoveAt(trackindex);
2274 arr->RemoveAt(trackindex);
2279 Int_t first = Int_t(pt->GetPoints()[0]);
2280 Int_t last = Int_t(pt->GetPoints()[2]);
2281 Double_t factor = (pt->GetBConstrain()) ? factor1: factor2;
2283 Int_t found,foundable,shared;
2284 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2285 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2286 Bool_t itsgold =kFALSE;
2289 if (pt->GetESD()->GetITSclusters(dummy)>4) itsgold= kTRUE;
2293 if (Float_t(shared+1)/Float_t(found+1)>factor){
2294 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2295 delete arr->RemoveAt(trackindex);
2298 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2299 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2300 delete arr->RemoveAt(trackindex);
2306 if (sharedfactor>0.4) continue;
2307 if (pt->GetKinkIndexes()[0]>0) continue;
2308 for (Int_t i=first; i<last; i++) {
2309 Int_t index=pt->GetClusterIndex2(i);
2310 // if (index<0 || index&0x8000 ) continue;
2311 if (index<0 || index&0x8000 ) continue;
2312 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2319 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2325 void AliTPCtrackerMI::UnsignClusters()
2328 // loop over all clusters and unsign them
2331 for (Int_t sec=0;sec<fkNIS;sec++){
2332 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2333 AliTPCclusterMI *cl = fInnerSec[sec][row].GetClusters1();
2334 for (Int_t icl =0;icl< fInnerSec[sec][row].GetN1();icl++)
2335 // if (cl[icl].IsUsed(10))
2337 cl = fInnerSec[sec][row].GetClusters2();
2338 for (Int_t icl =0;icl< fInnerSec[sec][row].GetN2();icl++)
2339 //if (cl[icl].IsUsed(10))
2344 for (Int_t sec=0;sec<fkNOS;sec++){
2345 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2346 AliTPCclusterMI *cl = fOuterSec[sec][row].GetClusters1();
2347 for (Int_t icl =0;icl< fOuterSec[sec][row].GetN1();icl++)
2348 //if (cl[icl].IsUsed(10))
2350 cl = fOuterSec[sec][row].GetClusters2();
2351 for (Int_t icl =0;icl< fOuterSec[sec][row].GetN2();icl++)
2352 //if (cl[icl].IsUsed(10))
2361 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2364 //sign clusters to be "used"
2366 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2367 // loop over "primaries"
2381 Int_t nseed = arr->GetEntriesFast();
2382 for (Int_t i=0; i<nseed; i++) {
2383 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2387 if (!(pt->IsActive())) continue;
2388 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
2389 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2391 sumdens2+= dens*dens;
2392 sumn += pt->GetNumberOfClusters();
2393 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2394 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2397 sumchi2 +=chi2*chi2;
2402 Float_t mdensity = 0.9;
2403 Float_t meann = 130;
2404 Float_t meanchi = 1;
2405 Float_t sdensity = 0.1;
2406 Float_t smeann = 10;
2407 Float_t smeanchi =0.4;
2411 mdensity = sumdens/sum;
2413 meanchi = sumchi/sum;
2415 sdensity = sumdens2/sum-mdensity*mdensity;
2416 sdensity = TMath::Sqrt(sdensity);
2418 smeann = sumn2/sum-meann*meann;
2419 smeann = TMath::Sqrt(smeann);
2421 smeanchi = sumchi2/sum - meanchi*meanchi;
2422 smeanchi = TMath::Sqrt(smeanchi);
2426 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2428 for (Int_t i=0; i<nseed; i++) {
2429 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2433 if (pt->GetBSigned()) continue;
2434 if (pt->GetBConstrain()) continue;
2435 //if (!(pt->IsActive())) continue;
2437 Int_t found,foundable,shared;
2438 pt->GetClusterStatistic(0,160,found, foundable,shared);
2439 if (shared/float(found)>0.3) {
2440 if (shared/float(found)>0.9 ){
2441 //delete arr->RemoveAt(i);
2446 Bool_t isok =kFALSE;
2447 if ( (pt->GetNShared()/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2449 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->GetNShared()/pt->GetNumberOfClusters()<0.7))
2451 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2453 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2457 for (Int_t i=0; i<160; i++) {
2458 Int_t index=pt->GetClusterIndex2(i);
2459 if (index<0) continue;
2460 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2462 //if (!(c->IsUsed(10))) c->Use();
2469 Double_t maxchi = meanchi+2.*smeanchi;
2471 for (Int_t i=0; i<nseed; i++) {
2472 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2476 //if (!(pt->IsActive())) continue;
2477 if (pt->GetBSigned()) continue;
2478 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2479 if (chi>maxchi) continue;
2482 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
2484 //sign only tracks with enoug big density at the beginning
2486 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2489 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2490 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2492 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2493 if ( (pt->GetRemoval()==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2496 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2497 //Int_t noc=pt->GetNumberOfClusters();
2498 pt->SetBSigned(kTRUE);
2499 for (Int_t i=0; i<160; i++) {
2501 Int_t index=pt->GetClusterIndex2(i);
2502 if (index<0) continue;
2503 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2505 // if (!(c->IsUsed(10))) c->Use();
2510 // gLastCheck = nseed;
2518 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2520 // stop not active tracks
2521 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2522 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2523 Int_t nseed = arr->GetEntriesFast();
2525 for (Int_t i=0; i<nseed; i++) {
2526 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2530 if (!(pt->IsActive())) continue;
2531 StopNotActive(pt,row0,th0, th1,th2);
2537 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2540 // stop not active tracks
2541 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2542 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2545 Int_t foundable = 0;
2546 Int_t maxindex = seed->GetLastPoint(); //last foundable row
2547 if (seed->GetNFoundable()*th0 > seed->GetNumberOfClusters()) {
2548 seed->Desactivate(10) ;
2552 for (Int_t i=row0; i<maxindex; i++){
2553 Int_t index = seed->GetClusterIndex2(i);
2554 if (index!=-1) foundable++;
2556 if (foundable<=30) sumgood1++;
2557 if (foundable<=50) {
2564 if (foundable>=30.){
2565 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2568 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2572 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2575 // back propagation of ESD tracks
2581 //PrepareForProlongation(fSeeds,1);
2582 PropagateForward2(fSeeds);
2585 Int_t nseed = fSeeds->GetEntriesFast();
2586 for (Int_t i=0;i<nseed;i++){
2587 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2588 if (!seed) continue;
2589 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2591 seed->PropagateTo(fParam->GetInnerRadiusLow());
2592 seed->UpdatePoints();
2593 AliESDtrack *esd=event->GetTrack(i);
2594 seed->CookdEdx(0.02,0.6);
2595 CookLabel(seed,0.1); //For comparison only
2597 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2598 TTreeSRedirector &cstream = *fDebugStreamer;
2605 if (seed->GetNumberOfClusters()>15){
2606 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2607 esd->SetTPCPoints(seed->GetPoints());
2608 esd->SetTPCPointsF(seed->GetNFoundable());
2609 Int_t ndedx = seed->GetNCDEDX(0)+seed->GetNCDEDX(1)+seed->GetNCDEDX(2)+seed->GetNCDEDX(3);
2610 Float_t sdedx = (seed->GetSDEDX(0)+seed->GetSDEDX(1)+seed->GetSDEDX(2)+seed->GetSDEDX(3))*0.25;
2611 Float_t dedx = seed->GetdEdx();
2612 esd->SetTPCsignal(dedx, sdedx, ndedx);
2614 // add seed to the esd track in Calib level
2616 if (AliTPCReconstructor::StreamLevel()>0){
2617 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2618 esd->AddCalibObject(seedCopy);
2623 //printf("problem\n");
2626 //FindKinks(fSeeds,event);
2627 Info("RefitInward","Number of refitted tracks %d",ntracks);
2634 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2637 // back propagation of ESD tracks
2643 PropagateBack(fSeeds);
2644 RemoveUsed2(fSeeds,0.4,0.4,20);
2646 Int_t nseed = fSeeds->GetEntriesFast();
2648 for (Int_t i=0;i<nseed;i++){
2649 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2650 if (!seed) continue;
2651 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2652 seed->UpdatePoints();
2653 AliESDtrack *esd=event->GetTrack(i);
2654 seed->CookdEdx(0.02,0.6);
2655 CookLabel(seed,0.1); //For comparison only
2656 if (seed->GetNumberOfClusters()>15){
2657 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2658 esd->SetTPCPoints(seed->GetPoints());
2659 esd->SetTPCPointsF(seed->GetNFoundable());
2660 Int_t ndedx = seed->GetNCDEDX(0)+seed->GetNCDEDX(1)+seed->GetNCDEDX(2)+seed->GetNCDEDX(3);
2661 Float_t sdedx = (seed->GetSDEDX(0)+seed->GetSDEDX(1)+seed->GetSDEDX(2)+seed->GetSDEDX(3))*0.25;
2662 Float_t dedx = seed->GetdEdx();
2663 esd->SetTPCsignal(dedx, sdedx, ndedx);
2665 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2666 (*fDebugStreamer)<<"Cback"<<
2668 "EventNr="<<eventnumber<<
2669 "\n"; // patch 28 fev 06
2672 //FindKinks(fSeeds,event);
2673 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2681 void AliTPCtrackerMI::DeleteSeeds()
2686 Int_t nseed = fSeeds->GetEntriesFast();
2687 for (Int_t i=0;i<nseed;i++){
2688 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2689 if (seed) delete fSeeds->RemoveAt(i);
2696 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2699 //read seeds from the event
2701 Int_t nentr=event->GetNumberOfTracks();
2703 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2708 fSeeds = new TObjArray(nentr);
2712 for (Int_t i=0; i<nentr; i++) {
2713 AliESDtrack *esd=event->GetTrack(i);
2714 ULong_t status=esd->GetStatus();
2715 if (!(status&AliESDtrack::kTPCin)) continue;
2716 AliTPCtrack t(*esd);
2717 t.SetNumberOfClusters(0);
2718 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2719 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2720 for (Int_t ikink=0;ikink<3;ikink++) {
2721 Int_t index = esd->GetKinkIndex(ikink);
2722 seed->GetKinkIndexes()[ikink] = index;
2723 if (index==0) continue;
2724 index = TMath::Abs(index);
2725 AliESDkink * kink = fEvent->GetKink(index-1);
2726 if (kink&&esd->GetKinkIndex(ikink)<0){
2727 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2728 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2730 if (kink&&esd->GetKinkIndex(ikink)>0){
2731 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2732 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2736 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance(10.);
2737 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance(10.);
2738 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2743 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2744 Double_t par0[5],par1[5],alpha,x;
2745 esd->GetInnerExternalParameters(alpha,x,par0);
2746 esd->GetExternalParameters(x,par1);
2747 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2748 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2750 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2751 //reset covariance if suspicious
2752 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2753 seed->ResetCovariance(10.);
2758 // rotate to the local coordinate system
2760 fSectors=fInnerSec; fN=fkNIS;
2761 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2762 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2763 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2764 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2765 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2766 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2767 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2768 alpha-=seed->GetAlpha();
2769 if (!seed->Rotate(alpha)) {
2775 if (esd->GetKinkIndex(0)<=0){
2776 for (Int_t irow=0;irow<160;irow++){
2777 Int_t index = seed->GetClusterIndex2(irow);
2780 AliTPCclusterMI * cl = GetClusterMI(index);
2781 seed->SetClusterPointer(irow,cl);
2783 if ((index & 0x8000)==0){
2784 cl->Use(10); // accepted cluster
2786 cl->Use(6); // close cluster not accepted
2789 Info("ReadSeeds","Not found cluster");
2794 fSeeds->AddAt(seed,i);
2800 //_____________________________________________________________________________
2801 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2802 Float_t deltay, Int_t ddsec) {
2803 //-----------------------------------------------------------------
2804 // This function creates track seeds.
2805 // SEEDING WITH VERTEX CONSTRAIN
2806 //-----------------------------------------------------------------
2807 // cuts[0] - fP4 cut
2808 // cuts[1] - tan(phi) cut
2809 // cuts[2] - zvertex cut
2810 // cuts[3] - fP3 cut
2818 Double_t x[5], c[15];
2819 // Int_t di = i1-i2;
2821 AliTPCseed * seed = new AliTPCseed;
2822 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2823 Double_t cs=cos(alpha), sn=sin(alpha);
2825 // Double_t x1 =fOuterSec->GetX(i1);
2826 //Double_t xx2=fOuterSec->GetX(i2);
2828 Double_t x1 =GetXrow(i1);
2829 Double_t xx2=GetXrow(i2);
2831 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2833 Int_t imiddle = (i2+i1)/2; //middle pad row index
2834 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2835 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2839 const AliTPCRow& kr1=GetRow(ns,i1);
2840 Double_t ymax = GetMaxY(i1)-kr1.GetDeadZone()-1.5;
2841 Double_t ymaxm = GetMaxY(imiddle)-kr1.GetDeadZone()-1.5;
2844 // change cut on curvature if it can't reach this layer
2845 // maximal curvature set to reach it
2846 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2847 if (dvertexmax*0.5*cuts[0]>0.85){
2848 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2850 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2853 if (deltay>0) ddsec = 0;
2854 // loop over clusters
2855 for (Int_t is=0; is < kr1; is++) {
2857 if (kr1[is]->IsUsed(10)) continue;
2858 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2859 //if (TMath::Abs(y1)>ymax) continue;
2861 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2863 // find possible directions
2864 Float_t anglez = (z1-z3)/(x1-x3);
2865 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2868 //find rotation angles relative to line given by vertex and point 1
2869 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2870 Double_t dvertex = TMath::Sqrt(dvertex2);
2871 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2872 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2875 // loop over 2 sectors
2881 Double_t dddz1=0; // direction of delta inclination in z axis
2888 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2889 Int_t sec2 = sec + dsec;
2891 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2892 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2893 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2894 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2895 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2896 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2898 // rotation angles to p1-p3
2899 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2900 Double_t x2, y2, z2;
2902 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2905 Double_t dxx0 = (xx2-x3)*cs13r;
2906 Double_t dyy0 = (xx2-x3)*sn13r;
2907 for (Int_t js=index1; js < index2; js++) {
2908 const AliTPCclusterMI *kcl = kr2[js];
2909 if (kcl->IsUsed(10)) continue;
2911 //calcutate parameters
2913 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2915 if (TMath::Abs(yy0)<0.000001) continue;
2916 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2917 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2918 Double_t r02 = (0.25+y0*y0)*dvertex2;
2919 //curvature (radius) cut
2920 if (r02<r2min) continue;
2924 Double_t c0 = 1/TMath::Sqrt(r02);
2928 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2929 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2930 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2931 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2934 Double_t z0 = kcl->GetZ();
2935 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2936 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2939 Double_t dip = (z1-z0)*c0/dfi1;
2940 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2951 x2= xx2*cs-y2*sn*dsec;
2952 y2=+xx2*sn*dsec+y2*cs;
2962 // do we have cluster at the middle ?
2964 GetProlongation(x1,xm,x,ym,zm);
2966 AliTPCclusterMI * cm=0;
2967 if (TMath::Abs(ym)-ymaxm<0){
2968 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2969 if ((!cm) || (cm->IsUsed(10))) {
2974 // rotate y1 to system 0
2975 // get state vector in rotated system
2976 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2977 Double_t xr2 = x0*cs+yr1*sn*dsec;
2978 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2980 GetProlongation(xx2,xm,xr,ym,zm);
2981 if (TMath::Abs(ym)-ymaxm<0){
2982 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2983 if ((!cm) || (cm->IsUsed(10))) {
2993 dym = ym - cm->GetY();
2994 dzm = zm - cm->GetZ();
3001 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
3002 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
3003 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
3004 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3005 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
3007 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3008 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3009 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3010 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3011 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3012 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3014 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3015 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3016 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3017 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3021 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3022 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3023 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3024 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3025 c[13]=f30*sy1*f40+f32*sy2*f42;
3026 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3028 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3030 UInt_t index=kr1.GetIndex(is);
3031 AliTPCseed *track=new(seed) AliTPCseed(x1, ns*alpha+shift, x, c, index);
3033 track->SetIsSeeding(kTRUE);
3034 track->SetSeed1(i1);
3035 track->SetSeed2(i2);
3036 track->SetSeedType(3);
3040 FollowProlongation(*track, (i1+i2)/2,1);
3041 Int_t foundable,found,shared;
3042 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3043 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3045 seed->~AliTPCseed();
3051 FollowProlongation(*track, i2,1);
3055 track->SetBConstrain(1);
3056 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3057 track->SetLastPoint(i1); // first cluster in track position
3058 track->SetFirstPoint(track->GetLastPoint());
3060 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3061 track->GetNumberOfClusters() < track->GetNFoundable()*0.6 ||
3062 track->GetNShared()>0.4*track->GetNumberOfClusters() ) {
3064 seed->~AliTPCseed();
3068 // Z VERTEX CONDITION
3069 Double_t zv, bz=GetBz();
3070 if ( !track->GetZAt(0.,bz,zv) ) continue;
3071 if (TMath::Abs(zv-z3)>cuts[2]) {
3072 FollowProlongation(*track, TMath::Max(i2-20,0));
3073 if ( !track->GetZAt(0.,bz,zv) ) continue;
3074 if (TMath::Abs(zv-z3)>cuts[2]){
3075 FollowProlongation(*track, TMath::Max(i2-40,0));
3076 if ( !track->GetZAt(0.,bz,zv) ) continue;
3077 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->GetNFoundable()*0.7)){
3078 // make seed without constrain
3079 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3080 FollowProlongation(*track2, i2,1);
3081 track2->SetBConstrain(kFALSE);
3082 track2->SetSeedType(1);
3083 arr->AddLast(track2);
3085 seed->~AliTPCseed();
3090 seed->~AliTPCseed();
3097 track->SetSeedType(0);
3098 arr->AddLast(track);
3099 seed = new AliTPCseed;
3101 // don't consider other combinations
3102 if (track->GetNumberOfClusters() > track->GetNFoundable()*0.8)
3108 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3114 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3119 //-----------------------------------------------------------------
3120 // This function creates track seeds.
3121 //-----------------------------------------------------------------
3122 // cuts[0] - fP4 cut
3123 // cuts[1] - tan(phi) cut
3124 // cuts[2] - zvertex cut
3125 // cuts[3] - fP3 cut
3135 Double_t x[5], c[15];
3137 // make temporary seed
3138 AliTPCseed * seed = new AliTPCseed;
3139 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3140 // Double_t cs=cos(alpha), sn=sin(alpha);
3145 Double_t x1 = GetXrow(i1-1);
3146 const AliTPCRow& kr1=GetRow(sec,i1-1);
3147 Double_t y1max = GetMaxY(i1-1)-kr1.GetDeadZone()-1.5;
3149 Double_t x1p = GetXrow(i1);
3150 const AliTPCRow& kr1p=GetRow(sec,i1);
3152 Double_t x1m = GetXrow(i1-2);
3153 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3156 //last 3 padrow for seeding
3157 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3158 Double_t x3 = GetXrow(i1-7);
3159 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3161 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3162 Double_t x3p = GetXrow(i1-6);
3164 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3165 Double_t x3m = GetXrow(i1-8);
3170 Int_t im = i1-4; //middle pad row index
3171 Double_t xm = GetXrow(im); // radius of middle pad-row
3172 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3173 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3176 Double_t deltax = x1-x3;
3177 Double_t dymax = deltax*cuts[1];
3178 Double_t dzmax = deltax*cuts[3];
3180 // loop over clusters
3181 for (Int_t is=0; is < kr1; is++) {
3183 if (kr1[is]->IsUsed(10)) continue;
3184 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3186 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3188 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3189 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3195 for (Int_t js=index1; js < index2; js++) {
3196 const AliTPCclusterMI *kcl = kr3[js];
3197 if (kcl->IsUsed(10)) continue;
3199 // apply angular cuts
3200 if (TMath::Abs(y1-y3)>dymax) continue;
3203 if (TMath::Abs(z1-z3)>dzmax) continue;
3205 Double_t angley = (y1-y3)/(x1-x3);
3206 Double_t anglez = (z1-z3)/(x1-x3);
3208 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3209 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3211 Double_t yyym = angley*(xm-x1)+y1;
3212 Double_t zzzm = anglez*(xm-x1)+z1;
3214 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3216 if (kcm->IsUsed(10)) continue;
3218 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3219 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3226 // look around first
3227 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3233 if (kc1m->IsUsed(10)) used++;
3235 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3241 if (kc1p->IsUsed(10)) used++;
3243 if (used>1) continue;
3244 if (found<1) continue;
3248 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3254 if (kc3m->IsUsed(10)) used++;
3258 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3264 if (kc3p->IsUsed(10)) used++;
3268 if (used>1) continue;
3269 if (found<3) continue;
3279 x[4]=F1(x1,y1,x2,y2,x3,y3);
3280 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3283 x[2]=F2(x1,y1,x2,y2,x3,y3);
3286 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3287 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3291 Double_t sy1=0.1, sz1=0.1;
3292 Double_t sy2=0.1, sz2=0.1;
3293 Double_t sy3=0.1, sy=0.1, sz=0.1;
3295 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3296 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3297 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3298 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3299 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3300 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3302 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3303 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3304 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3305 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3309 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3310 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3311 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3312 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3313 c[13]=f30*sy1*f40+f32*sy2*f42;
3314 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3316 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3318 UInt_t index=kr1.GetIndex(is);
3319 AliTPCseed *track=new(seed) AliTPCseed(x1, sec*alpha+shift, x, c, index);
3321 track->SetIsSeeding(kTRUE);
3324 FollowProlongation(*track, i1-7,1);
3325 if (track->GetNumberOfClusters() < track->GetNFoundable()*0.75 ||
3326 track->GetNShared()>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3328 seed->~AliTPCseed();
3334 FollowProlongation(*track, i2,1);
3335 track->SetBConstrain(0);
3336 track->SetLastPoint(i1+fInnerSec->GetNRows()); // first cluster in track position
3337 track->SetFirstPoint(track->GetLastPoint());
3339 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3340 track->GetNumberOfClusters()<track->GetNFoundable()*0.7 ||
3341 track->GetNShared()>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3343 seed->~AliTPCseed();
3348 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3349 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3350 FollowProlongation(*track2, i2,1);
3351 track2->SetBConstrain(kFALSE);
3352 track2->SetSeedType(4);
3353 arr->AddLast(track2);
3355 seed->~AliTPCseed();
3359 //arr->AddLast(track);
3360 //seed = new AliTPCseed;
3366 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3372 //_____________________________________________________________________________
3373 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3374 Float_t deltay, Bool_t /*bconstrain*/) {
3375 //-----------------------------------------------------------------
3376 // This function creates track seeds - without vertex constraint
3377 //-----------------------------------------------------------------
3378 // cuts[0] - fP4 cut - not applied
3379 // cuts[1] - tan(phi) cut
3380 // cuts[2] - zvertex cut - not applied
3381 // cuts[3] - fP3 cut
3391 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3392 // Double_t cs=cos(alpha), sn=sin(alpha);
3393 Int_t row0 = (i1+i2)/2;
3394 Int_t drow = (i1-i2)/2;
3395 const AliTPCRow& kr0=fSectors[sec][row0];
3398 AliTPCpolyTrack polytrack;
3399 Int_t nclusters=fSectors[sec][row0];
3400 AliTPCseed * seed = new AliTPCseed;
3405 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3407 Int_t nfoundable =0;
3408 for (Int_t iter =1; iter<2; iter++){ //iterations
3409 const AliTPCRow& krm=fSectors[sec][row0-iter];
3410 const AliTPCRow& krp=fSectors[sec][row0+iter];
3411 const AliTPCclusterMI * cl= kr0[is];
3413 if (cl->IsUsed(10)) {
3419 Double_t x = kr0.GetX();
3420 // Initialization of the polytrack
3425 Double_t y0= cl->GetY();
3426 Double_t z0= cl->GetZ();
3430 Double_t ymax = fSectors->GetMaxY(row0)-kr0.GetDeadZone()-1.5;
3431 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3433 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3434 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3435 polytrack.AddPoint(x,y0,z0,erry, errz);
3438 if (cl->IsUsed(10)) sumused++;
3441 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3442 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3445 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3446 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3447 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3448 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3449 if (cl1->IsUsed(10)) sumused++;
3450 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3454 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3456 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3457 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3458 if (cl2->IsUsed(10)) sumused++;
3459 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3462 if (sumused>0) continue;
3464 polytrack.UpdateParameters();
3470 nfoundable = polytrack.GetN();
3471 nfound = nfoundable;
3473 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3474 Float_t maxdist = 0.8*(1.+3./(ddrow));
3475 for (Int_t delta = -1;delta<=1;delta+=2){
3476 Int_t row = row0+ddrow*delta;
3477 kr = &(fSectors[sec][row]);
3478 Double_t xn = kr->GetX();
3479 Double_t ymax = fSectors->GetMaxY(row)-kr->GetDeadZone()-1.5;
3480 polytrack.GetFitPoint(xn,yn,zn);
3481 if (TMath::Abs(yn)>ymax) continue;
3483 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3485 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3488 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3489 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3490 if (cln->IsUsed(10)) {
3491 // printf("used\n");
3499 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3504 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3505 polytrack.UpdateParameters();
3508 if ( (sumused>3) || (sumused>0.5*nfound)) {
3509 //printf("sumused %d\n",sumused);
3514 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3515 AliTPCpolyTrack track2;
3517 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3518 if (track2.GetN()<0.5*nfoundable) continue;
3521 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3523 // test seed with and without constrain
3524 for (Int_t constrain=0; constrain<=0;constrain++){
3525 // add polytrack candidate
3527 Double_t x[5], c[15];
3528 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3529 track2.GetBoundaries(x3,x1);
3531 track2.GetFitPoint(x1,y1,z1);
3532 track2.GetFitPoint(x2,y2,z2);
3533 track2.GetFitPoint(x3,y3,z3);
3535 //is track pointing to the vertex ?
3538 polytrack.GetFitPoint(x0,y0,z0);
3551 x[4]=F1(x1,y1,x2,y2,x3,y3);
3553 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3554 x[2]=F2(x1,y1,x2,y2,x3,y3);
3556 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3557 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3558 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3559 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3562 Double_t sy =0.1, sz =0.1;
3563 Double_t sy1=0.02, sz1=0.02;
3564 Double_t sy2=0.02, sz2=0.02;
3568 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3571 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3572 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3573 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3574 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3575 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3576 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3578 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3579 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3580 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3581 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3586 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3587 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3588 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3589 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3590 c[13]=f30*sy1*f40+f32*sy2*f42;
3591 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3593 //Int_t row1 = fSectors->GetRowNumber(x1);
3594 Int_t row1 = GetRowNumber(x1);
3598 AliTPCseed *track=new (seed) AliTPCseed(x1,sec*alpha+shift,x,c,index);
3599 track->SetIsSeeding(kTRUE);
3600 Int_t rc=FollowProlongation(*track, i2);
3601 if (constrain) track->SetBConstrain(1);
3603 track->SetBConstrain(0);
3604 track->SetLastPoint(row1+fInnerSec->GetNRows()); // first cluster in track position
3605 track->SetFirstPoint(track->GetLastPoint());
3607 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3608 track->GetNumberOfClusters() < track->GetNFoundable()*0.6 ||
3609 track->GetNShared()>0.4*track->GetNumberOfClusters()) {
3612 seed->~AliTPCseed();
3615 arr->AddLast(track);
3616 seed = new AliTPCseed;
3620 } // if accepted seed
3623 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3629 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3633 //reseed using track points
3634 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3635 Int_t p1 = int(r1*track->GetNumberOfClusters());
3636 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3638 Double_t x0[3],x1[3],x2[3];
3639 for (Int_t i=0;i<3;i++){
3645 // find track position at given ratio of the length
3646 Int_t sec0=0, sec1=0, sec2=0;
3649 for (Int_t i=0;i<160;i++){
3650 if (track->GetClusterPointer(i)){
3652 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3653 if ( (index<p0) || x0[0]<0 ){
3654 if (trpoint->GetX()>1){
3655 clindex = track->GetClusterIndex2(i);
3657 x0[0] = trpoint->GetX();
3658 x0[1] = trpoint->GetY();
3659 x0[2] = trpoint->GetZ();
3660 sec0 = ((clindex&0xff000000)>>24)%18;
3665 if ( (index<p1) &&(trpoint->GetX()>1)){
3666 clindex = track->GetClusterIndex2(i);
3668 x1[0] = trpoint->GetX();
3669 x1[1] = trpoint->GetY();
3670 x1[2] = trpoint->GetZ();
3671 sec1 = ((clindex&0xff000000)>>24)%18;
3674 if ( (index<p2) &&(trpoint->GetX()>1)){
3675 clindex = track->GetClusterIndex2(i);
3677 x2[0] = trpoint->GetX();
3678 x2[1] = trpoint->GetY();
3679 x2[2] = trpoint->GetZ();
3680 sec2 = ((clindex&0xff000000)>>24)%18;
3687 Double_t alpha, cs,sn, xx2,yy2;
3689 alpha = (sec1-sec2)*fSectors->GetAlpha();
3690 cs = TMath::Cos(alpha);
3691 sn = TMath::Sin(alpha);
3692 xx2= x1[0]*cs-x1[1]*sn;
3693 yy2= x1[0]*sn+x1[1]*cs;
3697 alpha = (sec0-sec2)*fSectors->GetAlpha();
3698 cs = TMath::Cos(alpha);
3699 sn = TMath::Sin(alpha);
3700 xx2= x0[0]*cs-x0[1]*sn;
3701 yy2= x0[0]*sn+x0[1]*cs;
3707 Double_t x[5],c[15];
3711 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3712 // if (x[4]>1) return 0;
3713 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3714 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3715 //if (TMath::Abs(x[3]) > 2.2) return 0;
3716 //if (TMath::Abs(x[2]) > 1.99) return 0;
3718 Double_t sy =0.1, sz =0.1;
3720 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3721 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3722 Double_t sy3=0.01+track->GetSigmaY2();
3724 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3725 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3726 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3727 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3728 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3729 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3731 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3732 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3733 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3734 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3739 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3740 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3741 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3742 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3743 c[13]=f30*sy1*f40+f32*sy2*f42;
3744 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3746 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3747 AliTPCseed *seed=new AliTPCseed(x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3748 // Double_t y0,z0,y1,z1, y2,z2;
3749 //seed->GetProlongation(x0[0],y0,z0);
3750 // seed->GetProlongation(x1[0],y1,z1);
3751 //seed->GetProlongation(x2[0],y2,z2);
3753 seed->SetLastPoint(pp2);
3754 seed->SetFirstPoint(pp2);
3761 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3765 //reseed using founded clusters
3767 // Find the number of clusters
3768 Int_t nclusters = 0;
3769 for (Int_t irow=0;irow<160;irow++){
3770 if (track->GetClusterIndex(irow)>0) nclusters++;
3774 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3775 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3776 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3780 Int_t row[3],sec[3]={0,0,0};
3782 // find track row position at given ratio of the length
3784 for (Int_t irow=0;irow<160;irow++){
3785 if (track->GetClusterIndex2(irow)<0) continue;
3787 for (Int_t ipoint=0;ipoint<3;ipoint++){
3788 if (index<=ipos[ipoint]) row[ipoint] = irow;
3792 //Get cluster and sector position
3793 for (Int_t ipoint=0;ipoint<3;ipoint++){
3794 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3795 AliTPCclusterMI * cl = GetClusterMI(clindex);
3798 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3801 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3802 xyz[ipoint][0] = GetXrow(row[ipoint]);
3803 xyz[ipoint][1] = cl->GetY();
3804 xyz[ipoint][2] = cl->GetZ();
3808 // Calculate seed state vector and covariance matrix
3810 Double_t alpha, cs,sn, xx2,yy2;
3812 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3813 cs = TMath::Cos(alpha);
3814 sn = TMath::Sin(alpha);
3815 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3816 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3820 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3821 cs = TMath::Cos(alpha);
3822 sn = TMath::Sin(alpha);
3823 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3824 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3830 Double_t x[5],c[15];
3834 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3835 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3836 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3838 Double_t sy =0.1, sz =0.1;
3840 Double_t sy1=0.2, sz1=0.2;
3841 Double_t sy2=0.2, sz2=0.2;
3844 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;
3845 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;
3846 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;
3847 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;
3848 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;
3849 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;
3851 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;
3852 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;
3853 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;
3854 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;
3859 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3860 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3861 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3862 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3863 c[13]=f30*sy1*f40+f32*sy2*f42;
3864 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3866 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3867 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3868 seed->SetLastPoint(row[2]);
3869 seed->SetFirstPoint(row[2]);
3874 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3878 //reseed using founded clusters
3881 Int_t row[3]={0,0,0};
3882 Int_t sec[3]={0,0,0};
3884 // forward direction
3886 for (Int_t irow=r0;irow<160;irow++){
3887 if (track->GetClusterIndex(irow)>0){
3892 for (Int_t irow=160;irow>r0;irow--){
3893 if (track->GetClusterIndex(irow)>0){
3898 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3899 if (track->GetClusterIndex(irow)>0){
3907 for (Int_t irow=0;irow<r0;irow++){
3908 if (track->GetClusterIndex(irow)>0){
3913 for (Int_t irow=r0;irow>0;irow--){
3914 if (track->GetClusterIndex(irow)>0){
3919 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3920 if (track->GetClusterIndex(irow)>0){
3927 if ((row[2]-row[0])<20) return 0;
3928 if (row[1]==0) return 0;
3931 //Get cluster and sector position
3932 for (Int_t ipoint=0;ipoint<3;ipoint++){
3933 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3934 AliTPCclusterMI * cl = GetClusterMI(clindex);
3937 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3940 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3941 xyz[ipoint][0] = GetXrow(row[ipoint]);
3942 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3943 if (point&&ipoint<2){
3945 xyz[ipoint][1] = point->GetY();
3946 xyz[ipoint][2] = point->GetZ();
3949 xyz[ipoint][1] = cl->GetY();
3950 xyz[ipoint][2] = cl->GetZ();
3957 // Calculate seed state vector and covariance matrix
3959 Double_t alpha, cs,sn, xx2,yy2;
3961 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3962 cs = TMath::Cos(alpha);
3963 sn = TMath::Sin(alpha);
3964 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3965 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3969 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3970 cs = TMath::Cos(alpha);
3971 sn = TMath::Sin(alpha);
3972 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3973 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3979 Double_t x[5],c[15];
3983 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3984 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3985 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3987 Double_t sy =0.1, sz =0.1;
3989 Double_t sy1=0.2, sz1=0.2;
3990 Double_t sy2=0.2, sz2=0.2;
3993 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;
3994 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;
3995 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;
3996 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;
3997 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;
3998 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;
4000 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;
4001 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;
4002 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;
4003 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;
4008 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
4009 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
4010 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
4011 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
4012 c[13]=f30*sy1*f40+f32*sy2*f42;
4013 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
4015 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
4016 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
4017 seed->SetLastPoint(row[2]);
4018 seed->SetFirstPoint(row[2]);
4019 for (Int_t i=row[0];i<row[2];i++){
4020 seed->SetClusterIndex(i, track->GetClusterIndex(i));
4026 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4033 TObjArray *kinks= new TObjArray(10000);
4034 // TObjArray *v0s= new TObjArray(10000);
4035 Int_t nentries = array->GetEntriesFast();
4036 AliHelix *helixes = new AliHelix[nentries];
4037 Int_t *sign = new Int_t[nentries];
4038 Int_t *nclusters = new Int_t[nentries];
4039 Float_t *alpha = new Float_t[nentries];
4040 AliKink *kink = new AliKink();
4041 Int_t * usage = new Int_t[nentries];
4042 Float_t *zm = new Float_t[nentries];
4043 Float_t *z0 = new Float_t[nentries];
4044 Float_t *fim = new Float_t[nentries];
4045 Float_t *shared = new Float_t[nentries];
4046 Bool_t *circular = new Bool_t[nentries];
4047 Float_t *dca = new Float_t[nentries];
4048 //const AliESDVertex * primvertex = esd->GetVertex();
4050 // nentries = array->GetEntriesFast();
4055 for (Int_t i=0;i<nentries;i++){
4058 AliTPCseed* track = (AliTPCseed*)array->At(i);
4059 if (!track) continue;
4060 track->SetCircular(0);
4062 track->UpdatePoints();
4063 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4065 nclusters[i]=track->GetNumberOfClusters();
4066 alpha[i] = track->GetAlpha();
4067 new (&helixes[i]) AliHelix(*track);
4069 helixes[i].Evaluate(0,xyz);
4070 sign[i] = (track->GetC()>0) ? -1:1;
4073 if (track->GetProlongation(x,y,z)){
4075 fim[i] = alpha[i]+TMath::ATan2(y,x);
4078 zm[i] = track->GetZ();
4082 circular[i]= kFALSE;
4083 if (track->GetProlongation(0,y,z)) z0[i] = z;
4084 dca[i] = track->GetD(0,0);
4090 Int_t ncandidates =0;
4093 Double_t phase[2][2],radius[2];
4096 // Find circling track
4097 TTreeSRedirector &cstream = *fDebugStreamer;
4099 for (Int_t i0=0;i0<nentries;i0++){
4100 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4101 if (!track0) continue;
4102 if (track0->GetNumberOfClusters()<40) continue;
4103 if (TMath::Abs(1./track0->GetC())>200) continue;
4104 for (Int_t i1=i0+1;i1<nentries;i1++){
4105 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4106 if (!track1) continue;
4107 if (track1->GetNumberOfClusters()<40) continue;
4108 if ( TMath::Abs(track1->GetTgl()+track0->GetTgl())>0.1) continue;
4109 if (track0->GetBConstrain()&&track1->GetBConstrain()) continue;
4110 if (TMath::Abs(1./track1->GetC())>200) continue;
4111 if (track1->Get1Pt()*track0->Get1Pt()>0) continue;
4112 if (track1->GetTgl()*track0->GetTgl()>0) continue;
4113 if (max(TMath::Abs(1./track0->GetC()),TMath::Abs(1./track1->GetC()))>190) continue;
4114 if (track0->GetBConstrain()&&TMath::Abs(track1->Get1Pt())<TMath::Abs(track0->Get1Pt())) continue; //returning - lower momenta
4115 if (track1->GetBConstrain()&&TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())) continue; //returning - lower momenta
4117 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4118 if (mindcar<5) continue;
4119 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4120 if (mindcaz<5) continue;
4121 if (mindcar+mindcaz<20) continue;
4124 Float_t xc0 = helixes[i0].GetHelix(6);
4125 Float_t yc0 = helixes[i0].GetHelix(7);
4126 Float_t r0 = helixes[i0].GetHelix(8);
4127 Float_t xc1 = helixes[i1].GetHelix(6);
4128 Float_t yc1 = helixes[i1].GetHelix(7);
4129 Float_t r1 = helixes[i1].GetHelix(8);
4131 Float_t rmean = (r0+r1)*0.5;
4132 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4133 //if (delta>30) continue;
4134 if (delta>rmean*0.25) continue;
4135 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4137 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4138 if (npoints==0) continue;
4139 helixes[i0].GetClosestPhases(helixes[i1], phase);
4143 Double_t hangles[3];
4144 helixes[i0].Evaluate(phase[0][0],xyz0);
4145 helixes[i1].Evaluate(phase[0][1],xyz1);
4147 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4148 Double_t deltah[2],deltabest;
4149 if (hangles[2]<2.8) continue;
4151 cstream<<"C"<<track0->fLab<<track1->fLab<<
4152 track0->fP3<<track1->fP3<<
4153 track0->fP4<<track1->fP4<<
4154 delta<<rmean<<npoints<<
4155 hangles[0]<<hangles[2]<<
4156 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4160 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4162 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4163 if (deltah[1]<deltah[0]) ibest=1;
4165 deltabest = TMath::Sqrt(deltah[ibest]);
4166 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4167 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4168 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4169 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4171 if (deltabest>6) continue;
4172 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4173 Bool_t sign =kFALSE;
4174 if (hangles[2]>3.06) sign =kTRUE;
4177 circular[i0] = kTRUE;
4178 circular[i1] = kTRUE;
4179 if (TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())){
4180 track0->SetCircular(track0->GetCircular()+1);
4181 track1->SetCircular(track1->GetCircular()+2);
4184 track1->SetCircular(track1->GetCircular()+1);
4185 track0->SetCircular(track0->GetCircular()+2);
4188 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4190 Int_t lab0=track0->GetLabel();
4191 Int_t lab1=track1->GetLabel();
4192 cstream<<"Curling"<<
4199 "mindcar="<<mindcar<<
4200 "mindcaz="<<mindcaz<<
4203 "npoints="<<npoints<<
4204 "hangles0="<<hangles[0]<<
4205 "hangles2="<<hangles[2]<<
4210 "radius="<<radiusbest<<
4211 "deltabest="<<deltabest<<
4212 "phase0="<<phase[ibest][0]<<
4213 "phase1="<<phase[ibest][1]<<
4223 for (Int_t i =0;i<nentries;i++){
4224 if (sign[i]==0) continue;
4225 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4228 Double_t cradius0 = 40*40;
4229 Double_t cradius1 = 270*270;
4232 Double_t cdist3=0.55;
4233 for (Int_t j =i+1;j<nentries;j++){
4235 if (sign[j]*sign[i]<1) continue;
4236 if ( (nclusters[i]+nclusters[j])>200) continue;
4237 if ( (nclusters[i]+nclusters[j])<80) continue;
4238 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4239 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4240 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4241 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4242 if (npoints<1) continue;
4245 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4248 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4251 Double_t delta1=10000,delta2=10000;
4252 // cuts on the intersection radius
4253 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4254 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4255 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4257 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4258 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4259 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4262 Double_t distance1 = TMath::Min(delta1,delta2);
4263 if (distance1>cdist1) continue; // cut on DCA linear approximation
4265 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4266 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4267 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4268 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4271 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4272 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4273 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4275 distance1 = TMath::Min(delta1,delta2);
4278 rkink = TMath::Sqrt(radius[0]);
4281 rkink = TMath::Sqrt(radius[1]);
4283 if (distance1>cdist2) continue;
4286 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4289 Int_t row0 = GetRowNumber(rkink);
4290 if (row0<10) continue;
4291 if (row0>150) continue;
4294 Float_t dens00=-1,dens01=-1;
4295 Float_t dens10=-1,dens11=-1;
4297 Int_t found,foundable,shared;
4298 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4299 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4300 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4301 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4303 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4304 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4305 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4306 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4308 if (dens00<dens10 && dens01<dens11) continue;
4309 if (dens00>dens10 && dens01>dens11) continue;
4310 if (TMath::Max(dens00,dens10)<0.1) continue;
4311 if (TMath::Max(dens01,dens11)<0.3) continue;
4313 if (TMath::Min(dens00,dens10)>0.6) continue;
4314 if (TMath::Min(dens01,dens11)>0.6) continue;
4317 AliTPCseed * ktrack0, *ktrack1;
4326 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4327 AliExternalTrackParam paramm(*ktrack0);
4328 AliExternalTrackParam paramd(*ktrack1);
4329 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4332 kink->SetMother(paramm);
4333 kink->SetDaughter(paramd);
4336 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4338 fParam->Transform0to1(x,index);
4339 fParam->Transform1to2(x,index);
4340 row0 = GetRowNumber(x[0]);
4342 if (kink->GetR()<100) continue;
4343 if (kink->GetR()>240) continue;
4344 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4345 if (kink->GetDistance()>cdist3) continue;
4346 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4347 if (dird<0) continue;
4349 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4350 if (dirm<0) continue;
4351 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4352 if (mpt<0.2) continue;
4355 //for high momenta momentum not defined well in first iteration
4356 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->GetP();
4357 if (qt>0.35) continue;
4360 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4361 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4363 kink->SetTPCDensity(dens00,0,0);
4364 kink->SetTPCDensity(dens01,0,1);
4365 kink->SetTPCDensity(dens10,1,0);
4366 kink->SetTPCDensity(dens11,1,1);
4367 kink->SetIndex(i,0);
4368 kink->SetIndex(j,1);
4371 kink->SetTPCDensity(dens10,0,0);
4372 kink->SetTPCDensity(dens11,0,1);
4373 kink->SetTPCDensity(dens00,1,0);
4374 kink->SetTPCDensity(dens01,1,1);
4375 kink->SetIndex(j,0);
4376 kink->SetIndex(i,1);
4379 if (mpt<1||kink->GetAngle(2)>0.1){
4380 // angle and densities not defined yet
4381 if (kink->GetTPCDensityFactor()<0.8) continue;
4382 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4383 if (kink->GetAngle(2)*ktrack0->GetP()<0.003) continue; //too small angle
4384 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4385 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4387 Float_t criticalangle = track0->GetSigmaSnp2()+track0->GetSigmaTgl2();
4388 criticalangle+= track1->GetSigmaSnp2()+track1->GetSigmaTgl2();
4389 criticalangle= 3*TMath::Sqrt(criticalangle);
4390 if (criticalangle>0.02) criticalangle=0.02;
4391 if (kink->GetAngle(2)<criticalangle) continue;
4394 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4395 Float_t shapesum =0;
4397 for ( Int_t row = row0-drow; row<row0+drow;row++){
4398 if (row<0) continue;
4399 if (row>155) continue;
4400 if (ktrack0->GetClusterPointer(row)){
4401 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4402 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4405 if (ktrack1->GetClusterPointer(row)){
4406 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4407 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4412 kink->SetShapeFactor(-1.);
4415 kink->SetShapeFactor(shapesum/sum);
4417 // esd->AddKink(kink);
4418 kinks->AddLast(kink);
4424 // sort the kinks according quality - and refit them towards vertex
4426 Int_t nkinks = kinks->GetEntriesFast();
4427 Float_t *quality = new Float_t[nkinks];
4428 Int_t *indexes = new Int_t[nkinks];
4429 AliTPCseed *mothers = new AliTPCseed[nkinks];
4430 AliTPCseed *daughters = new AliTPCseed[nkinks];
4433 for (Int_t i=0;i<nkinks;i++){
4435 AliKink *kink = (AliKink*)kinks->At(i);
4437 // refit kinks towards vertex
4439 Int_t index0 = kink->GetIndex(0);
4440 Int_t index1 = kink->GetIndex(1);
4441 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4442 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4444 Int_t sumn=ktrack0->GetNumberOfClusters()+ktrack1->GetNumberOfClusters();
4446 // Refit Kink under if too small angle
4448 if (kink->GetAngle(2)<0.05){
4449 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4450 Int_t row0 = kink->GetTPCRow0();
4451 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4454 Int_t last = row0-drow;
4455 if (last<40) last=40;
4456 if (last<ktrack0->GetFirstPoint()+25) last = ktrack0->GetFirstPoint()+25;
4457 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4460 Int_t first = row0+drow;
4461 if (first>130) first=130;
4462 if (first>ktrack1->GetLastPoint()-25) first = TMath::Max(ktrack1->GetLastPoint()-25,30);
4463 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4465 if (seed0 && seed1){
4466 kink->SetStatus(1,8);
4467 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4468 row0 = GetRowNumber(kink->GetR());
4469 sumn = seed0->GetNumberOfClusters()+seed1->GetNumberOfClusters();
4470 new (&mothers[i]) AliTPCseed(*seed0);
4471 new (&daughters[i]) AliTPCseed(*seed1);
4474 delete kinks->RemoveAt(i);
4475 if (seed0) delete seed0;
4476 if (seed1) delete seed1;
4479 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4480 delete kinks->RemoveAt(i);
4481 if (seed0) delete seed0;
4482 if (seed1) delete seed1;
4490 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4492 TMath::Sort(nkinks,quality,indexes,kFALSE);
4494 //remove double find kinks
4496 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4497 AliKink * kink0 = (AliKink*) kinks->At(indexes[ikink0]);
4498 if (!kink0) continue;
4500 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4501 if (!kink0) continue;
4502 AliKink * kink1 = (AliKink*) kinks->At(indexes[ikink1]);
4503 if (!kink1) continue;
4504 // if not close kink continue
4505 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4506 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4507 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4509 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4510 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4511 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4512 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4513 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4522 for (Int_t i=0;i<row0;i++){
4523 if (mother0.GetClusterIndex(i)>0 && mother1.GetClusterIndex(i)>0){
4526 if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
4533 for (Int_t i=row0;i<158;i++){
4534 if (daughter0.GetClusterIndex(i)>0 && daughter0.GetClusterIndex(i)>0){
4537 if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
4543 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4544 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4545 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4546 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4547 Int_t sum0 = mother0.GetNumberOfClusters()+daughter0.GetNumberOfClusters();
4548 Int_t sum1 = mother1.GetNumberOfClusters()+daughter1.GetNumberOfClusters();
4550 shared[kink0->GetIndex(0)]= kTRUE;
4551 shared[kink0->GetIndex(1)]= kTRUE;
4552 delete kinks->RemoveAt(indexes[ikink0]);
4555 shared[kink1->GetIndex(0)]= kTRUE;
4556 shared[kink1->GetIndex(1)]= kTRUE;
4557 delete kinks->RemoveAt(indexes[ikink1]);
4564 for (Int_t i=0;i<nkinks;i++){
4565 AliKink * kink = (AliKink*) kinks->At(indexes[i]);
4566 if (!kink) continue;
4567 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4568 Int_t index0 = kink->GetIndex(0);
4569 Int_t index1 = kink->GetIndex(1);
4570 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4571 kink->SetMultiple(usage[index0],0);
4572 kink->SetMultiple(usage[index1],1);
4573 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4574 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4575 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4576 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4578 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4579 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4580 if (!ktrack0 || !ktrack1) continue;
4581 Int_t index = esd->AddKink(kink);
4584 if ( ktrack0->GetKinkIndex(0)==0 && ktrack1->GetKinkIndex(0)==0) { //best kink
4585 if (mothers[indexes[i]].GetNumberOfClusters()>20 && daughters[indexes[i]].GetNumberOfClusters()>20 && (mothers[indexes[i]].GetNumberOfClusters()+daughters[indexes[i]].GetNumberOfClusters())>100){
4586 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4587 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4591 ktrack0->SetKinkIndex(usage[index0],-(index+1));
4592 ktrack1->SetKinkIndex(usage[index1], (index+1));
4597 // Remove tracks corresponding to shared kink's
4599 for (Int_t i=0;i<nentries;i++){
4600 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4601 if (!track0) continue;
4602 if (track0->GetKinkIndex(0)!=0) continue;
4603 if (shared[i]) delete array->RemoveAt(i);
4608 RemoveUsed2(array,0.5,0.4,30);
4610 for (Int_t i=0;i<nentries;i++){
4611 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4612 if (!track0) continue;
4613 track0->CookdEdx(0.02,0.6);
4617 for (Int_t i=0;i<nentries;i++){
4618 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4619 if (!track0) continue;
4620 if (track0->GetPt()<1.4) continue;
4621 //remove double high momenta tracks - overlapped with kink candidates
4624 for (Int_t icl=track0->GetFirstPoint();icl<track0->GetLastPoint(); icl++){
4625 if (track0->GetClusterPointer(icl)!=0){
4627 if (track0->GetClusterPointer(icl)->IsUsed(10)) shared++;
4630 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4631 delete array->RemoveAt(i);
4635 if (track0->GetKinkIndex(0)!=0) continue;
4636 if (track0->GetNumberOfClusters()<80) continue;
4638 AliTPCseed *pmother = new AliTPCseed();
4639 AliTPCseed *pdaughter = new AliTPCseed();
4640 AliKink *pkink = new AliKink;
4642 AliTPCseed & mother = *pmother;
4643 AliTPCseed & daughter = *pdaughter;
4644 AliKink & kink = *pkink;
4645 if (CheckKinkPoint(track0,mother,daughter, kink)){
4646 if (mother.GetNumberOfClusters()<30||daughter.GetNumberOfClusters()<20) {
4650 continue; //too short tracks
4652 if (mother.GetPt()<1.4) {
4658 Int_t row0= kink.GetTPCRow0();
4659 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4666 Int_t index = esd->AddKink(&kink);
4667 mother.SetKinkIndex(0,-(index+1));
4668 daughter.SetKinkIndex(0,index+1);
4669 if (mother.GetNumberOfClusters()>50) {
4670 delete array->RemoveAt(i);
4671 array->AddAt(new AliTPCseed(mother),i);
4674 array->AddLast(new AliTPCseed(mother));
4676 array->AddLast(new AliTPCseed(daughter));
4677 for (Int_t icl=0;icl<row0;icl++) {
4678 if (mother.GetClusterPointer(icl)) mother.GetClusterPointer(icl)->Use(20);
4681 for (Int_t icl=row0;icl<158;icl++) {
4682 if (daughter.GetClusterPointer(icl)) daughter.GetClusterPointer(icl)->Use(20);
4691 delete [] daughters;
4713 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4717 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4723 TObjArray *tpcv0s = new TObjArray(100000);
4724 Int_t nentries = array->GetEntriesFast();
4725 AliHelix *helixes = new AliHelix[nentries];
4726 Int_t *sign = new Int_t[nentries];
4727 Float_t *alpha = new Float_t[nentries];
4728 Float_t *z0 = new Float_t[nentries];
4729 Float_t *dca = new Float_t[nentries];
4730 Float_t *sdcar = new Float_t[nentries];
4731 Float_t *cdcar = new Float_t[nentries];
4732 Float_t *pulldcar = new Float_t[nentries];
4733 Float_t *pulldcaz = new Float_t[nentries];
4734 Float_t *pulldca = new Float_t[nentries];
4735 Bool_t *isPrim = new Bool_t[nentries];
4736 const AliESDVertex * primvertex = esd->GetVertex();
4737 Double_t zvertex = primvertex->GetZv();
4739 // nentries = array->GetEntriesFast();
4741 for (Int_t i=0;i<nentries;i++){
4744 AliTPCseed* track = (AliTPCseed*)array->At(i);
4745 if (!track) continue;
4746 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4747 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4748 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4750 alpha[i] = track->GetAlpha();
4751 new (&helixes[i]) AliHelix(*track);
4753 helixes[i].Evaluate(0,xyz);
4754 sign[i] = (track->GetC()>0) ? -1:1;
4758 if (track->GetProlongation(0,y,z)) z0[i] = z;
4759 dca[i] = track->GetD(0,0);
4761 // dca error parrameterezation + pulls
4763 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->GetC())*(100*track->GetC()));
4764 if (TMath::Abs(track->GetTgl())>1) sdcar[i]*=2.5;
4765 cdcar[i] = TMath::Exp((TMath::Abs(track->GetC())-0.0106)*525.3);
4766 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4767 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4768 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4769 if (track->TPCrPID(1)+track->TPCrPID(2)+track->TPCrPID(3)>0.5) {
4770 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4772 if (track->TPCrPID(4)>0.5) {
4773 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4775 if (track->TPCrPID(0)>0.4) {
4776 isPrim[i]=kFALSE; //electron no sigma cut
4783 Int_t ncandidates =0;
4786 Double_t phase[2][2],radius[2];
4792 TTreeSRedirector &cstream = *fDebugStreamer;
4793 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4795 Double_t cradius0 = 10*10;
4796 Double_t cradius1 = 200*200;
4799 Double_t cpointAngle = 0.95;
4801 Double_t delta[2]={10000,10000};
4802 for (Int_t i =0;i<nentries;i++){
4803 if (sign[i]==0) continue;
4804 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4805 if (!track0) continue;
4806 if (AliTPCReconstructor::StreamLevel()>0){
4811 "zvertex="<<zvertex<<
4812 "sdcar0="<<sdcar[i]<<
4813 "cdcar0="<<cdcar[i]<<
4814 "pulldcar0="<<pulldcar[i]<<
4815 "pulldcaz0="<<pulldcaz[i]<<
4816 "pulldca0="<<pulldca[i]<<
4817 "isPrim="<<isPrim[i]<<
4821 if (track0->Get1Pt()<0) continue;
4822 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4824 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4829 for (Int_t j =0;j<nentries;j++){
4830 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4831 if (!track1) continue;
4832 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4833 if (sign[j]*sign[i]>0) continue;
4834 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4835 if (track0->GetCircular()+track1->GetCircular()>1) continue; //circling -returning track
4838 // DCA to prim vertex cut
4844 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4845 if (npoints<1) continue;
4849 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4850 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4851 if (delta[0]>cdist1) continue;
4854 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4855 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4856 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4857 if (delta[1]<delta[0]) iclosest=1;
4858 if (delta[iclosest]>cdist1) continue;
4860 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4861 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4863 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4864 if (pointAngle<cpointAngle) continue;
4866 Bool_t isGamma = kFALSE;
4867 vertex.SetP(*track0); //track0 - plus
4868 vertex.SetM(*track1); //track1 - minus
4869 vertex.Update(fprimvertex);
4870 if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4871 Double_t pointAngle2 = vertex.GetPointAngle();
4873 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4874 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4875 Float_t sigmae = 0.15*0.15;
4876 if (vertex.GetRr()<80)
4877 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4878 sigmae+= TMath::Sqrt(sigmae);
4879 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4880 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4881 Int_t row0 = GetRowNumber(vertex.GetRr());
4883 if (vertex.GetDist2()>0.2) continue;
4884 densb0 = track0->Density2(0,row0-5);
4885 densb1 = track1->Density2(0,row0-5);
4886 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4887 densa0 = track0->Density2(row0+5,row0+40);
4888 densa1 = track1->Density2(row0+5,row0+40);
4889 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4892 densa0 = track0->Density2(0,40); //cluster density
4893 densa1 = track1->Density2(0,40); //cluster density
4894 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4896 vertex.SetLab(0,track0->GetLabel());
4897 vertex.SetLab(1,track1->GetLabel());
4898 vertex.SetChi2After((densa0+densa1)*0.5);
4899 vertex.SetChi2Before((densb0+densb1)*0.5);
4900 vertex.SetIndex(0,i);
4901 vertex.SetIndex(1,j);
4902 vertex.SetStatus(1); // TPC v0 candidate
4903 vertex.SetRp(track0->TPCrPIDs());
4904 vertex.SetRm(track1->TPCrPIDs());
4905 tpcv0s->AddLast(new AliESDv0(vertex));
4908 Int_t eventNr = esd->GetEventNumber();
4909 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4910 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4911 if (AliTPCReconstructor::StreamLevel()>0) {
4912 Int_t lab0=track0->GetLabel();
4913 Int_t lab1=track1->GetLabel();
4914 Char_t c0=track0->GetCircular();
4915 Char_t c1=track1->GetCircular();
4918 "vertex.="<<&vertex<<
4921 "Helix0.="<<&helixes[i]<<
4924 "Helix1.="<<&helixes[j]<<
4925 "pointAngle="<<pointAngle<<
4926 "pointAngle2="<<pointAngle2<<
4931 "zvertex="<<zvertex<<
4934 "npoints="<<npoints<<
4935 "radius0="<<radius[0]<<
4936 "delta0="<<delta[0]<<
4937 "radius1="<<radius[1]<<
4938 "delta1="<<delta[1]<<
4939 "radiusm="<<radiusm<<
4941 "sdcar0="<<sdcar[i]<<
4942 "sdcar1="<<sdcar[j]<<
4943 "cdcar0="<<cdcar[i]<<
4944 "cdcar1="<<cdcar[j]<<
4945 "pulldcar0="<<pulldcar[i]<<
4946 "pulldcar1="<<pulldcar[j]<<
4947 "pulldcaz0="<<pulldcaz[i]<<
4948 "pulldcaz1="<<pulldcaz[j]<<
4949 "pulldca0="<<pulldca[i]<<
4950 "pulldca1="<<pulldca[j]<<
4960 Float_t *quality = new Float_t[ncandidates];
4961 Int_t *indexes = new Int_t[ncandidates];
4963 for (Int_t i=0;i<ncandidates;i++){
4965 AliESDv0 *v0 = (AliESDv0*)tpcv0s->At(i);
4966 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4967 // quality[i] /= (0.5+v0->GetDist2());
4968 // quality[i] *= v0->GetChi2After(); //density factor
4969 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4970 Int_t index0 = v0->GetIndex(0);
4971 Int_t index1 = v0->GetIndex(1);
4972 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4973 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4974 if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4975 if (track0->TPCrPID(4)>0.9||track1->TPCrPID(4)>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4978 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4981 for (Int_t i=0;i<ncandidates;i++){
4982 AliESDv0 * v0 = (AliESDv0*)tpcv0s->At(indexes[i]);
4984 Int_t index0 = v0->GetIndex(0);
4985 Int_t index1 = v0->GetIndex(1);
4986 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4987 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4988 if (!track0||!track1) {
4992 Bool_t accept =kTRUE; //default accept
4993 Int_t *v0indexes0 = track0->GetV0Indexes();
4994 Int_t *v0indexes1 = track1->GetV0Indexes();
4996 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4997 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4998 if (v0indexes0[1]!=0) order0 =2;
4999 if (v0indexes1[1]!=0) order1 =2;
5001 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
5002 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
5004 AliESDv0 * v02 = v0;
5006 v0->SetOrder(0,order0);
5007 v0->SetOrder(1,order1);
5008 v0->SetOrder(1,order0+order1);
5009 v0->SetOnFlyStatus(kTRUE);
5010 Int_t index = esd->AddV0(v0);
5011 v02 = esd->GetV0(index);
5012 v0indexes0[order0]=index;
5013 v0indexes1[order1]=index;
5017 Int_t eventNr = esd->GetEventNumber();
5018 if (AliTPCReconstructor::StreamLevel()>0) {
5019 Int_t lab0=track0->GetLabel();
5020 Int_t lab1=track1->GetLabel();
5029 "dca0="<<dca[index0]<<
5030 "dca1="<<dca[index1]<<
5034 "quality="<<quality[i]<<
5035 "pulldca0="<<pulldca[index0]<<
5036 "pulldca1="<<pulldca[index1]<<
5060 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5064 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5067 // refit kink towards to the vertex
5070 AliKink &kink=(AliKink &)knk;
5072 Int_t row0 = GetRowNumber(kink.GetR());
5073 FollowProlongation(mother,0);
5074 mother.Reset(kFALSE);
5076 FollowProlongation(daughter,row0);
5077 daughter.Reset(kFALSE);
5078 FollowBackProlongation(daughter,158);
5079 daughter.Reset(kFALSE);
5080 Int_t first = TMath::Max(row0-20,30);
5081 Int_t last = TMath::Min(row0+20,140);
5083 const Int_t kNdiv =5;
5084 AliTPCseed param0[kNdiv]; // parameters along the track
5085 AliTPCseed param1[kNdiv]; // parameters along the track
5086 AliKink kinks[kNdiv]; // corresponding kink parameters
5089 for (Int_t irow=0; irow<kNdiv;irow++){
5090 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5092 // store parameters along the track
5094 for (Int_t irow=0;irow<kNdiv;irow++){
5095 FollowBackProlongation(mother, rows[irow]);
5096 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5097 new(¶m0[irow]) AliTPCseed(mother);
5098 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5102 for (Int_t irow=0; irow<kNdiv-1;irow++){
5103 if (param0[irow].GetNumberOfClusters()<kNdiv||param1[irow].GetNumberOfClusters()<kNdiv) continue;
5104 kinks[irow].SetMother(param0[irow]);
5105 kinks[irow].SetDaughter(param1[irow]);
5106 kinks[irow].Update();
5109 // choose kink with best "quality"
5111 Double_t mindist = 10000;
5112 for (Int_t irow=0;irow<kNdiv;irow++){
5113 if (param0[irow].GetNumberOfClusters()<20||param1[irow].GetNumberOfClusters()<20) continue;
5114 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5115 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5117 Float_t normdist = TMath::Abs(param0[irow].GetX()-kinks[irow].GetR())*(0.1+kink.GetDistance());
5118 normdist/= (param0[irow].GetNumberOfClusters()+param1[irow].GetNumberOfClusters()+40.);
5119 if (normdist < mindist){
5125 if (index==-1) return 0;
5128 param0[index].Reset(kTRUE);
5129 FollowProlongation(param0[index],0);
5131 new (&mother) AliTPCseed(param0[index]);
5132 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5134 kink.SetMother(mother);
5135 kink.SetDaughter(daughter);
5137 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5138 kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
5139 kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
5140 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5141 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5142 mother.SetLabel(kink.GetLabel(0));
5143 daughter.SetLabel(kink.GetLabel(1));
5149 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5151 // update Kink quality information for mother after back propagation
5153 if (seed->GetKinkIndex(0)>=0) return;
5154 for (Int_t ikink=0;ikink<3;ikink++){
5155 Int_t index = seed->GetKinkIndex(ikink);
5156 if (index>=0) break;
5157 index = TMath::Abs(index)-1;
5158 AliESDkink * kink = fEvent->GetKink(index);
5159 //kink->fTPCdensity2[0][0]=-1;
5160 //kink->fTPCdensity2[0][1]=-1;
5161 kink->SetTPCDensity2(-1,0,0);
5162 kink->SetTPCDensity2(1,0,1);
5164 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5165 if (row0<15) row0=15;
5167 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5168 if (row1>145) row1=145;
5170 Int_t found,foundable,shared;
5171 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5172 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5173 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5174 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5179 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5181 // update Kink quality information for daughter after refit
5183 if (seed->GetKinkIndex(0)<=0) return;
5184 for (Int_t ikink=0;ikink<3;ikink++){
5185 Int_t index = seed->GetKinkIndex(ikink);
5186 if (index<=0) break;
5187 index = TMath::Abs(index)-1;
5188 AliESDkink * kink = fEvent->GetKink(index);
5189 kink->SetTPCDensity2(-1,1,0);
5190 kink->SetTPCDensity2(-1,1,1);
5192 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5193 if (row0<15) row0=15;
5195 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5196 if (row1>145) row1=145;
5198 Int_t found,foundable,shared;
5199 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5200 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5201 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5202 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5208 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5211 // check kink point for given track
5212 // if return value=0 kink point not found
5213 // otherwise seed0 correspond to mother particle
5214 // seed1 correspond to daughter particle
5215 // kink parameter of kink point
5216 AliKink &kink=(AliKink &)knk;
5218 Int_t middlerow = (seed->GetFirstPoint()+seed->GetLastPoint())/2;
5219 Int_t first = seed->GetFirstPoint();
5220 Int_t last = seed->GetLastPoint();
5221 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5224 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5225 if (!seed1) return 0;
5226 FollowProlongation(*seed1,seed->GetLastPoint()-20);
5227 seed1->Reset(kTRUE);
5228 FollowProlongation(*seed1,158);
5229 seed1->Reset(kTRUE);
5230 last = seed1->GetLastPoint();
5232 AliTPCseed *seed0 = new AliTPCseed(*seed);
5233 seed0->Reset(kFALSE);
5236 AliTPCseed param0[20]; // parameters along the track
5237 AliTPCseed param1[20]; // parameters along the track
5238 AliKink kinks[20]; // corresponding kink parameters
5240 for (Int_t irow=0; irow<20;irow++){
5241 rows[irow] = first +((last-first)*irow)/19;
5243 // store parameters along the track
5245 for (Int_t irow=0;irow<20;irow++){
5246 FollowBackProlongation(*seed0, rows[irow]);
5247 FollowProlongation(*seed1,rows[19-irow]);
5248 new(¶m0[irow]) AliTPCseed(*seed0);
5249 new(¶m1[19-irow]) AliTPCseed(*seed1);
5253 for (Int_t irow=0; irow<19;irow++){
5254 kinks[irow].SetMother(param0[irow]);
5255 kinks[irow].SetDaughter(param1[irow]);
5256 kinks[irow].Update();
5259 // choose kink with biggest change of angle
5261 Double_t maxchange= 0;
5262 for (Int_t irow=1;irow<19;irow++){
5263 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5264 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5265 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5266 if ( quality > maxchange){
5267 maxchange = quality;
5274 if (index<0) return 0;
5276 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5277 seed0 = new AliTPCseed(param0[index]);
5278 seed1 = new AliTPCseed(param1[index]);
5279 seed0->Reset(kFALSE);
5280 seed1->Reset(kFALSE);
5281 seed0->ResetCovariance(10.);
5282 seed1->ResetCovariance(10.);
5283 FollowProlongation(*seed0,0);
5284 FollowBackProlongation(*seed1,158);
5285 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5286 seed0->Reset(kFALSE);
5287 seed1->Reset(kFALSE);
5288 seed0->ResetCovariance(10.);
5289 seed1->ResetCovariance(10.);
5291 first = TMath::Max(row0-20,0);
5292 last = TMath::Min(row0+20,158);
5294 for (Int_t irow=0; irow<20;irow++){
5295 rows[irow] = first +((last-first)*irow)/19;
5297 // store parameters along the track
5299 for (Int_t irow=0;irow<20;irow++){
5300 FollowBackProlongation(*seed0, rows[irow]);
5301 FollowProlongation(*seed1,rows[19-irow]);
5302 new(¶m0[irow]) AliTPCseed(*seed0);
5303 new(¶m1[19-irow]) AliTPCseed(*seed1);
5307 for (Int_t irow=0; irow<19;irow++){
5308 kinks[irow].SetMother(param0[irow]);
5309 kinks[irow].SetDaughter(param1[irow]);
5310 // param0[irow].Dump();
5311 //param1[irow].Dump();
5312 kinks[irow].Update();
5315 // choose kink with biggest change of angle
5318 for (Int_t irow=0;irow<20;irow++){
5319 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5320 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5321 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5322 if ( quality > maxchange){
5323 maxchange = quality;
5330 if (index==-1 || param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()<100){
5335 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5337 kink.SetMother(param0[index]);
5338 kink.SetDaughter(param1[index]);
5340 row0 = GetRowNumber(kink.GetR());
5341 kink.SetTPCRow0(row0);
5342 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5343 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5344 kink.SetIndex(-10,0);
5345 kink.SetIndex(int(param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()),1);
5346 kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
5347 kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
5350 // new (&mother) AliTPCseed(param0[index]);
5351 new (&daughter) AliTPCseed(param1[index]);
5352 daughter.SetLabel(kink.GetLabel(1));
5353 param0[index].Reset(kTRUE);
5354 FollowProlongation(param0[index],0);
5355 new (&mother) AliTPCseed(param0[index]);
5356 mother.SetLabel(kink.GetLabel(0));
5366 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5369 // reseed - refit - track
5372 // Int_t last = fSectors->GetNRows()-1;
5374 if (fSectors == fOuterSec){
5375 first = TMath::Max(first, t->GetFirstPoint()-fInnerSec->GetNRows());
5379 first = t->GetFirstPoint();
5381 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5382 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5384 FollowProlongation(*t,first);
5394 //_____________________________________________________________________________
5395 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5396 //-----------------------------------------------------------------
5397 // This function reades track seeds.
5398 //-----------------------------------------------------------------
5399 TDirectory *savedir=gDirectory;
5401 TFile *in=(TFile*)inp;
5402 if (!in->IsOpen()) {
5403 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5408 TTree *seedTree=(TTree*)in->Get("Seeds");
5410 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5411 cerr<<"can't get a tree with track seeds !\n";
5414 AliTPCtrack *seed=new AliTPCtrack;
5415 seedTree->SetBranchAddress("tracks",&seed);
5417 if (fSeeds==0) fSeeds=new TObjArray(15000);
5419 Int_t n=(Int_t)seedTree->GetEntries();
5420 for (Int_t i=0; i<n; i++) {
5421 seedTree->GetEvent(i);
5422 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5431 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5434 if (fSeeds) DeleteSeeds();
5437 if (!fSeeds) return 1;
5444 //_____________________________________________________________________________
5445 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5446 //-----------------------------------------------------------------
5447 // This is a track finder.
5448 //-----------------------------------------------------------------
5449 TDirectory *savedir=gDirectory;
5453 fSeeds = Tracking();
5456 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5458 //activate again some tracks
5459 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5460 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5462 Int_t nc=t.GetNumberOfClusters();
5464 delete fSeeds->RemoveAt(i);
5468 if (pt->GetRemoval()==10) {
5469 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5470 pt->Desactivate(10); // make track again active
5472 pt->Desactivate(20);
5473 delete fSeeds->RemoveAt(i);
5478 RemoveUsed2(fSeeds,0.85,0.85,0);
5479 if (AliTPCReconstructor::GetRecoParam()->GetDoKinks()) FindKinks(fSeeds,fEvent);
5480 RemoveUsed2(fSeeds,0.5,0.4,20);
5482 // // refit short tracks
5484 Int_t nseed=fSeeds->GetEntriesFast();
5485 // for (Int_t i=0; i<nseed; i++) {
5486 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5487 // if (!pt) continue;
5488 // Int_t nc=t.GetNumberOfClusters();
5490 // delete fSeeds->RemoveAt(i);
5493 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5494 // if (nc>100) continue; // hopefully, enough for ITS
5495 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5496 // //seed2->Reset(kFALSE);
5497 // //pt->ResetCovariance();
5498 // seed2->Modify(1);
5499 // FollowBackProlongation(*seed2,158);
5500 // //seed2->Reset(kFALSE);
5501 // seed2->Modify(10);
5502 // FollowProlongation(*seed2,0);
5503 // TTreeSRedirector &cstream = *fDebugStreamer;
5504 // cstream<<"Crefit"<<
5508 // if (seed2->fN>pt->fN){
5509 // delete fSeeds->RemoveAt(i);
5510 // fSeeds->AddAt(seed2,i);
5515 // RemoveUsed2(fSeeds,0.6,0.6,50);
5517 // FindV0s(fSeeds,fEvent);
5518 //RemoveDouble(fSeeds,0.2,0.6,11);
5522 for (Int_t i=0; i<nseed; i++) {
5523 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5525 Int_t nc=t.GetNumberOfClusters();
5527 delete fSeeds->RemoveAt(i);
5530 CookLabel(pt,0.1); //For comparison only
5531 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5532 if ((pt->IsActive() || (pt->GetRemoval()==10) )){
5534 if (fDebug>0) cerr<<found<<'\r';
5538 delete fSeeds->RemoveAt(i);
5542 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5544 //RemoveUsed(fSeeds,0.9,0.9,6);
5546 nseed=fSeeds->GetEntriesFast();
5548 for (Int_t i=0; i<nseed; i++) {
5549 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5551 Int_t nc=t.GetNumberOfClusters();
5553 delete fSeeds->RemoveAt(i);
5557 t.CookdEdx(0.02,0.6);
5558 // CheckKinkPoint(&t,0.05);
5559 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5560 if ((pt->IsActive() || (pt->GetRemoval()==10) )){
5568 delete fSeeds->RemoveAt(i);
5569 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5571 // FollowProlongation(*seed1,0);
5572 // Int_t n = seed1->GetNumberOfClusters();
5573 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5574 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5577 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5581 SortTracks(fSeeds, 1);
5585 PrepareForBackProlongation(fSeeds,5.);
5586 PropagateBack(fSeeds);
5587 printf("Time for back propagation: \t");timer.Print();timer.Start();
5591 PrepareForProlongation(fSeeds,5.);
5592 PropagateForward2(fSeeds);
5594 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5595 // RemoveUsed(fSeeds,0.7,0.7,6);
5596 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5598 nseed=fSeeds->GetEntriesFast();
5600 for (Int_t i=0; i<nseed; i++) {
5601 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5603 Int_t nc=t.GetNumberOfClusters();
5605 delete fSeeds->RemoveAt(i);
5608 t.CookdEdx(0.02,0.6);
5609 // CookLabel(pt,0.1); //For comparison only
5610 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5611 if ((pt->IsActive() || (pt->fRemoval==10) )){
5612 cerr<<found++<<'\r';
5615 delete fSeeds->RemoveAt(i);
5620 // fNTracks = found;
5622 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5625 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5626 Info("Clusters2Tracks","Number of found tracks %d",found);
5628 // UnloadClusters();
5633 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5636 // tracking of the seeds
5639 fSectors = fOuterSec;
5640 ParallelTracking(arr,150,63);
5641 fSectors = fOuterSec;
5642 ParallelTracking(arr,63,0);
5645 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5650 TObjArray * arr = new TObjArray;
5652 fSectors = fOuterSec;
5655 for (Int_t sec=0;sec<fkNOS;sec++){
5656 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5657 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5658 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5661 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5673 TObjArray * AliTPCtrackerMI::Tracking()
5677 if (AliTPCReconstructor::GetRecoParam()->GetSpecialSeeding()) return TrackingSpecial();
5680 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5682 TObjArray * seeds = new TObjArray;
5691 Float_t fnumber = 3.0;
5692 Float_t fdensity = 3.0;
5697 for (Int_t delta = 0; delta<18; delta+=6){
5701 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5702 SumTracks(seeds,arr);
5703 SignClusters(seeds,fnumber,fdensity);
5705 for (Int_t i=2;i<6;i+=2){
5706 // seed high pt tracks
5709 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5710 SumTracks(seeds,arr);
5711 SignClusters(seeds,fnumber,fdensity);
5716 // RemoveUsed(seeds,0.9,0.9,1);
5717 // UnsignClusters();
5718 // SignClusters(seeds,fnumber,fdensity);
5722 for (Int_t delta = 20; delta<120; delta+=10){
5724 // seed high pt tracks
5728 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5729 SumTracks(seeds,arr);
5730 SignClusters(seeds,fnumber,fdensity);
5735 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5736 SumTracks(seeds,arr);
5737 SignClusters(seeds,fnumber,fdensity);
5748 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5752 // RemoveUsed(seeds,0.75,0.75,1);
5754 //SignClusters(seeds,fnumber,fdensity);
5763 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5764 SumTracks(seeds,arr);
5765 SignClusters(seeds,fnumber,fdensity);
5767 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5768 SumTracks(seeds,arr);
5769 SignClusters(seeds,fnumber,fdensity);
5771 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5772 SumTracks(seeds,arr);
5773 SignClusters(seeds,fnumber,fdensity);
5777 for (Int_t delta = 3; delta<30; delta+=5){
5783 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5784 SumTracks(seeds,arr);
5785 SignClusters(seeds,fnumber,fdensity);
5787 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5788 SumTracks(seeds,arr);
5789 SignClusters(seeds,fnumber,fdensity);
5801 for (Int_t delta = 30; delta<90; delta+=10){
5807 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5808 SumTracks(seeds,arr);
5809 SignClusters(seeds,fnumber,fdensity);
5811 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5812 SumTracks(seeds,arr);
5813 SignClusters(seeds,fnumber,fdensity);
5817 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5828 TObjArray * AliTPCtrackerMI::TrackingSpecial()
5831 // seeding adjusted for laser and cosmic tests - short tracks with big inclination angle
5832 // no primary vertex seeding tried
5836 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5838 TObjArray * seeds = new TObjArray;
5843 Float_t fnumber = 3.0;
5844 Float_t fdensity = 3.0;
5847 cuts[0] = AliTPCReconstructor::GetRecoParam()->GetMaxC(); // max curvature
5848 cuts[1] = 3.5; // max tan(phi) angle for seeding
5849 cuts[2] = 3.; // not used (cut on z primary vertex)
5850 cuts[3] = 3.5; // max tan(theta) angle for seeding
5852 for (Int_t delta = 0; nup-delta-gap-1>0; delta+=3){
5854 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5855 SumTracks(seeds,arr);
5856 SignClusters(seeds,fnumber,fdensity);
5860 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5871 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5874 //sum tracks to common container
5875 //remove suspicious tracks
5876 Int_t nseed = arr2->GetEntriesFast();
5877 for (Int_t i=0;i<nseed;i++){
5878 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5881 // remove tracks with too big curvature
5883 if (TMath::Abs(pt->GetC())>AliTPCReconstructor::GetRecoParam()->GetMaxC()){
5884 delete arr2->RemoveAt(i);
5887 // REMOVE VERY SHORT TRACKS
5888 if (pt->GetNumberOfClusters()<20){
5889 delete arr2->RemoveAt(i);
5892 // NORMAL ACTIVE TRACK
5893 if (pt->IsActive()){
5894 arr1->AddLast(arr2->RemoveAt(i));
5897 //remove not usable tracks
5898 if (pt->GetRemoval()!=10){
5899 delete arr2->RemoveAt(i);
5903 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5904 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5905 arr1->AddLast(arr2->RemoveAt(i));
5907 delete arr2->RemoveAt(i);
5916 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5919 // try to track in parralel
5921 Int_t nseed=arr->GetEntriesFast();
5922 //prepare seeds for tracking
5923 for (Int_t i=0; i<nseed; i++) {
5924 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5926 if (!t.IsActive()) continue;
5927 // follow prolongation to the first layer
5928 if ( (fSectors ==fInnerSec) || (t.GetFirstPoint()-fParam->GetNRowLow()>rfirst+1) )
5929 FollowProlongation(t, rfirst+1);
5934 for (Int_t nr=rfirst; nr>=rlast; nr--){
5935 if (nr<fInnerSec->GetNRows())
5936 fSectors = fInnerSec;
5938 fSectors = fOuterSec;
5939 // make indexes with the cluster tracks for given
5941 // find nearest cluster
5942 for (Int_t i=0; i<nseed; i++) {
5943 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5945 if (nr==80) pt->UpdateReference();
5946 if (!pt->IsActive()) continue;
5947 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5948 if (pt->GetRelativeSector()>17) {
5951 UpdateClusters(t,nr);
5953 // prolonagate to the nearest cluster - if founded
5954 for (Int_t i=0; i<nseed; i++) {
5955 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5957 if (!pt->IsActive()) continue;
5958 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5959 if (pt->GetRelativeSector()>17) {
5962 FollowToNextCluster(*pt,nr);
5967 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5971 // if we use TPC track itself we have to "update" covariance
5973 Int_t nseed= arr->GetEntriesFast();
5974 for (Int_t i=0;i<nseed;i++){
5975 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5979 //rotate to current local system at first accepted point
5980 Int_t index = pt->GetClusterIndex2(pt->GetFirstPoint());
5981 Int_t sec = (index&0xff000000)>>24;
5983 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5984 if (angle1>TMath::Pi())
5985 angle1-=2.*TMath::Pi();
5986 Float_t angle2 = pt->GetAlpha();
5988 if (TMath::Abs(angle1-angle2)>0.001){
5989 pt->Rotate(angle1-angle2);
5990 //angle2 = pt->GetAlpha();
5991 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5992 //if (pt->GetAlpha()<0)
5993 // pt->fRelativeSector+=18;
5994 //sec = pt->fRelativeSector;
6003 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
6007 // if we use TPC track itself we have to "update" covariance
6009 Int_t nseed= arr->GetEntriesFast();
6010 for (Int_t i=0;i<nseed;i++){
6011 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6014 pt->SetFirstPoint(pt->GetLastPoint());
6022 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
6025 // make back propagation
6027 Int_t nseed= arr->GetEntriesFast();
6028 for (Int_t i=0;i<nseed;i++){
6029 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6030 if (pt&& pt->GetKinkIndex(0)<=0) {
6031 //AliTPCseed *pt2 = new AliTPCseed(*pt);
6032 fSectors = fInnerSec;
6033 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
6034 //fSectors = fOuterSec;
6035 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6036 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
6037 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
6038 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6041 if (pt&& pt->GetKinkIndex(0)>0) {
6042 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
6043 pt->SetFirstPoint(kink->GetTPCRow0());
6044 fSectors = fInnerSec;
6045 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6053 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
6056 // make forward propagation
6058 Int_t nseed= arr->GetEntriesFast();
6060 for (Int_t i=0;i<nseed;i++){
6061 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6063 FollowProlongation(*pt,0);
6070 Int_t AliTPCtrackerMI::PropagateForward()
6073 // propagate track forward
6075 Int_t nseed = fSeeds->GetEntriesFast();
6076 for (Int_t i=0;i<nseed;i++){
6077 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
6079 AliTPCseed &t = *pt;
6080 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
6081 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
6082 if (alpha < 0. ) alpha += 2.*TMath::Pi();
6083 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
6087 fSectors = fOuterSec;
6088 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
6089 fSectors = fInnerSec;
6090 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
6100 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6103 // make back propagation, in between row0 and row1
6107 fSectors = fInnerSec;
6110 if (row1<fSectors->GetNRows())
6113 r1 = fSectors->GetNRows()-1;
6115 if (row0<fSectors->GetNRows()&& r1>0 )
6116 FollowBackProlongation(*pt,r1);
6117 if (row1<=fSectors->GetNRows())
6120 r1 = row1 - fSectors->GetNRows();
6121 if (r1<=0) return 0;
6122 if (r1>=fOuterSec->GetNRows()) return 0;
6123 fSectors = fOuterSec;
6124 return FollowBackProlongation(*pt,r1);
6132 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6136 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6137 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6138 Float_t padlength = GetPadPitchLength(row);
6140 Float_t sresy = (seed->GetSector() < fParam->GetNSector()/2) ? 0.2 :0.3;
6141 Double_t angulary = seed->GetSnp();
6142 angulary = angulary*angulary/(1-angulary*angulary);
6143 seed->SetCurrentSigmaY2(sd2+padlength*padlength*angulary/12.+sresy*sresy);
6145 Float_t sresz = fParam->GetZSigma();
6146 Float_t angularz = seed->GetTgl();
6147 seed->SetCurrentSigmaZ2(sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz);
6149 Float_t wy = GetSigmaY(seed);
6150 Float_t wz = GetSigmaZ(seed);
6153 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6154 printf("problem\n");
6160 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6164 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6165 Float_t padlength = fParam->GetPadPitchLength(seed->GetSector());
6166 Float_t sres = (seed->GetSector() < fParam->GetNSector()/2) ? 0.2 :0.3;
6167 Float_t angular = seed->GetSnp();
6168 angular = angular*angular/(1-angular*angular);
6169 // angular*=angular;
6170 //angular = TMath::Sqrt(angular/(1-angular));
6171 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6174 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6178 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6179 Float_t padlength = fParam->GetPadPitchLength(seed->GetSector());
6180 Float_t sres = fParam->GetZSigma();
6181 Float_t angular = seed->GetTgl();
6182 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6187 //__________________________________________________________________________
6188 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6189 //--------------------------------------------------------------------
6190 //This function "cooks" a track label. If label<0, this track is fake.
6191 //--------------------------------------------------------------------
6192 AliTPCseed * t = (AliTPCseed*)tk;
6193 Int_t noc=t->GetNumberOfClusters();
6195 //printf("\nnot founded prolongation\n\n\n");
6201 AliTPCclusterMI *clusters[160];
6203 for (Int_t i=0;i<160;i++) {
6210 for (i=0; i<160 && current<noc; i++) {
6212 Int_t index=t->GetClusterIndex2(i);
6213 if (index<=0) continue;
6214 if (index&0x8000) continue;
6216 //clusters[current]=GetClusterMI(index);
6217 if (t->GetClusterPointer(i)){
6218 clusters[current]=t->GetClusterPointer(i);
6224 Int_t lab=123456789;
6225 for (i=0; i<noc; i++) {
6226 AliTPCclusterMI *c=clusters[i];
6228 lab=TMath::Abs(c->GetLabel(0));
6230 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6236 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6238 for (i=0; i<noc; i++) {
6239 AliTPCclusterMI *c=clusters[i];
6241 if (TMath::Abs(c->GetLabel(1)) == lab ||
6242 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6245 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6248 Int_t tail=Int_t(0.10*noc);
6251 for (i=1; i<=160&&ind<tail; i++) {
6252 // AliTPCclusterMI *c=clusters[noc-i];
6253 AliTPCclusterMI *c=clusters[i];
6255 if (lab == TMath::Abs(c->GetLabel(0)) ||
6256 lab == TMath::Abs(c->GetLabel(1)) ||
6257 lab == TMath::Abs(c->GetLabel(2))) max++;
6260 if (max < Int_t(0.5*tail)) lab=-lab;
6267 //delete[] clusters;
6271 //__________________________________________________________________________
6272 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6273 //--------------------------------------------------------------------
6274 //This function "cooks" a track label. If label<0, this track is fake.
6275 //--------------------------------------------------------------------
6276 Int_t noc=t->GetNumberOfClusters();
6278 //printf("\nnot founded prolongation\n\n\n");
6284 AliTPCclusterMI *clusters[160];
6286 for (Int_t i=0;i<160;i++) {
6293 for (i=0; i<160 && current<noc; i++) {
6294 if (i<first) continue;
6295 if (i>last) continue;
6296 Int_t index=t->GetClusterIndex2(i);
6297 if (index<=0) continue;
6298 if (index&0x8000) continue;
6300 //clusters[current]=GetClusterMI(index);
6301 if (t->GetClusterPointer(i)){
6302 clusters[current]=t->GetClusterPointer(i);
6307 if (noc<5) return -1;
6308 Int_t lab=123456789;
6309 for (i=0; i<noc; i++) {
6310 AliTPCclusterMI *c=clusters[i];
6312 lab=TMath::Abs(c->GetLabel(0));
6314 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6320 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6322 for (i=0; i<noc; i++) {
6323 AliTPCclusterMI *c=clusters[i];
6325 if (TMath::Abs(c->GetLabel(1)) == lab ||
6326 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6329 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6332 Int_t tail=Int_t(0.10*noc);
6335 for (i=1; i<=160&&ind<tail; i++) {
6336 // AliTPCclusterMI *c=clusters[noc-i];
6337 AliTPCclusterMI *c=clusters[i];
6339 if (lab == TMath::Abs(c->GetLabel(0)) ||
6340 lab == TMath::Abs(c->GetLabel(1)) ||
6341 lab == TMath::Abs(c->GetLabel(2))) max++;
6344 if (max < Int_t(0.5*tail)) lab=-lab;
6347 // t->SetLabel(lab);
6351 //delete[] clusters;
6355 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6357 //return pad row number for this x
6360 r=fRow[fN-1].GetX();
6361 if (x > r) return fN;
6363 if (x < r) return -1;
6364 return Int_t((x-r)/fPadPitchLength + 0.5);}
6366 r=fRow[fN-1].GetX();
6367 if (x > r) return fN;
6369 if (x < r) return -1;
6370 Double_t r1=fRow[64].GetX();
6372 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6374 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6378 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6380 //return pad row number for given x vector
6381 Float_t phi = TMath::ATan2(x[1],x[0]);
6382 if(phi<0) phi=2.*TMath::Pi()+phi;
6383 // Get the local angle in the sector philoc
6384 const Float_t kRaddeg = 180/3.14159265358979312;
6385 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6386 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6387 return GetRowNumber(localx);
6390 //_________________________________________________________________________
6391 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6392 //-----------------------------------------------------------------------
6393 // Setup inner sector
6394 //-----------------------------------------------------------------------
6396 fAlpha=par->GetInnerAngle();
6397 fAlphaShift=par->GetInnerAngleShift();
6398 fPadPitchWidth=par->GetInnerPadPitchWidth();
6399 fPadPitchLength=par->GetInnerPadPitchLength();
6400 fN=par->GetNRowLow();
6401 fRow=new AliTPCRow[fN];
6402 for (Int_t i=0; i<fN; i++) {
6403 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6404 fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
6407 fAlpha=par->GetOuterAngle();
6408 fAlphaShift=par->GetOuterAngleShift();
6409 fPadPitchWidth = par->GetOuterPadPitchWidth();
6410 fPadPitchLength = par->GetOuter1PadPitchLength();
6411 f1PadPitchLength = par->GetOuter1PadPitchLength();
6412 f2PadPitchLength = par->GetOuter2PadPitchLength();
6414 fN=par->GetNRowUp();
6415 fRow=new AliTPCRow[fN];
6416 for (Int_t i=0; i<fN; i++) {
6417 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6418 fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
6423 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6425 // default constructor
6433 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6440 //_________________________________________________________________________
6442 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6443 //-----------------------------------------------------------------------
6444 // Insert a cluster into this pad row in accordence with its y-coordinate
6445 //-----------------------------------------------------------------------
6446 if (fN==kMaxClusterPerRow) {
6447 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6449 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6450 Int_t i=Find(c->GetZ());
6451 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6452 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6453 fIndex[i]=index; fClusters[i]=c; fN++;
6456 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6462 //delete[] fClusterArray;
6463 if (fClusters1) delete []fClusters1;
6464 if (fClusters2) delete []fClusters2;
6471 //___________________________________________________________________
6472 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6473 //-----------------------------------------------------------------------
6474 // Return the index of the nearest cluster
6475 //-----------------------------------------------------------------------
6476 if (fN==0) return 0;
6477 if (z <= fClusters[0]->GetZ()) return 0;
6478 if (z > fClusters[fN-1]->GetZ()) return fN;
6479 Int_t b=0, e=fN-1, m=(b+e)/2;
6480 for (; b<e; m=(b+e)/2) {
6481 if (z > fClusters[m]->GetZ()) b=m+1;
6489 //___________________________________________________________________
6490 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6491 //-----------------------------------------------------------------------
6492 // Return the index of the nearest cluster in z y
6493 //-----------------------------------------------------------------------
6494 Float_t maxdistance = roady*roady + roadz*roadz;
6496 AliTPCclusterMI *cl =0;
6497 for (Int_t i=Find(z-roadz); i<fN; i++) {
6498 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6499 if (c->GetZ() > z+roadz) break;
6500 if ( (c->GetY()-y) > roady ) continue;
6501 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6502 if (maxdistance>distance) {
6503 maxdistance = distance;
6510 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6512 //-----------------------------------------------------------------------
6513 // Return the index of the nearest cluster in z y
6514 //-----------------------------------------------------------------------
6515 Float_t maxdistance = roady*roady + roadz*roadz;
6516 AliTPCclusterMI *cl =0;
6518 //PH Check boundaries. 510 is the size of fFastCluster
6519 Int_t iz1 = Int_t(z-roadz+254.5);
6520 if (iz1<0 || iz1>=510) return cl;
6521 iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
6522 Int_t iz2 = Int_t(z+roadz+255.5);
6523 if (iz2<0 || iz2>=510) return cl;
6524 iz2 = TMath::Min(GetFastCluster(iz2)+1,fN);
6526 //FindNearest3(y,z,roady,roadz,index);
6527 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6528 for (Int_t i=iz1; i<iz2; i++) {
6529 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6530 if (c->GetZ() > z+roadz) break;
6531 if ( c->GetY()-y > roady ) continue;
6532 if ( y-c->GetY() > roady ) continue;
6533 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6534 if (maxdistance>distance) {
6535 maxdistance = distance;
6538 //roady = TMath::Sqrt(maxdistance);
6546 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6548 //-----------------------------------------------------------------------
6549 // Return the index of the nearest cluster in z y
6550 //-----------------------------------------------------------------------
6551 Float_t maxdistance = roady*roady + roadz*roadz;
6552 // Int_t iz = Int_t(z+255.);
6553 AliTPCclusterMI *cl =0;
6554 for (Int_t i=Find(z-roadz); i<fN; i++) {
6555 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6556 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6557 if (c->GetZ() > z+roadz) break;
6558 if ( c->GetY()-y > roady ) continue;
6559 if ( y-c->GetY() > roady ) continue;
6560 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6561 if (maxdistance>distance) {
6562 maxdistance = distance;
6565 //roady = TMath::Sqrt(maxdistance);
6575 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6579 // return &fTrackPoints[i];