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]);
91 //__________________________________________________________________
92 AliTPCtrackerMI::AliTPCtrackerMI()
114 // default constructor
117 //_____________________________________________________________________
121 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
123 //update track information using current cluster - track->fCurrentCluster
126 AliTPCclusterMI* c =track->GetCurrentCluster();
127 if (accept>0) track->SetCurrentClusterIndex1(track->GetCurrentClusterIndex1() | 0x8000); //sign not accepted clusters
129 UInt_t i = track->GetCurrentClusterIndex1();
131 Int_t sec=(i&0xff000000)>>24;
132 //Int_t row = (i&0x00ff0000)>>16;
133 track->SetRow((i&0x00ff0000)>>16);
134 track->SetSector(sec);
135 // Int_t index = i&0xFFFF;
136 if (sec>=fParam->GetNInnerSector()) track->SetRow(track->GetRow()+fParam->GetNRowLow());
137 track->SetClusterIndex2(track->GetRow(), i);
138 //track->fFirstPoint = row;
139 //if ( track->fLastPoint<row) track->fLastPoint =row;
140 // if (track->fRow<0 || track->fRow>160) {
141 // printf("problem\n");
143 if (track->GetFirstPoint()>track->GetRow())
144 track->SetFirstPoint(track->GetRow());
145 if (track->GetLastPoint()<track->GetRow())
146 track->SetLastPoint(track->GetRow());
149 track->SetClusterPointer(track->GetRow(),c);
152 Double_t angle2 = track->GetSnp()*track->GetSnp();
154 //SET NEW Track Point
156 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
158 angle2 = TMath::Sqrt(angle2/(1-angle2));
159 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->GetRow()));
161 point.SetSigmaY(c->GetSigmaY2()/track->GetCurrentSigmaY2());
162 point.SetSigmaZ(c->GetSigmaZ2()/track->GetCurrentSigmaZ2());
163 point.SetErrY(sqrt(track->GetErrorY2()));
164 point.SetErrZ(sqrt(track->GetErrorZ2()));
166 point.SetX(track->GetX());
167 point.SetY(track->GetY());
168 point.SetZ(track->GetZ());
169 point.SetAngleY(angle2);
170 point.SetAngleZ(track->GetTgl());
171 if (point.IsShared()){
172 track->SetErrorY2(track->GetErrorY2()*4);
173 track->SetErrorZ2(track->GetErrorZ2()*4);
177 Double_t chi2 = track->GetPredictedChi2(track->GetCurrentCluster());
179 track->SetErrorY2(track->GetErrorY2()*1.3);
180 track->SetErrorY2(track->GetErrorY2()+0.01);
181 track->SetErrorZ2(track->GetErrorZ2()*1.3);
182 track->SetErrorZ2(track->GetErrorZ2()+0.005);
184 if (accept>0) return 0;
185 if (track->GetNumberOfClusters()%20==0){
186 // if (track->fHelixIn){
187 // TClonesArray & larr = *(track->fHelixIn);
188 // Int_t ihelix = larr.GetEntriesFast();
189 // new(larr[ihelix]) AliHelix(*track) ;
192 track->SetNoCluster(0);
193 return track->Update(c,chi2,i);
198 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
199 Float_t cory, Float_t corz)
202 // decide according desired precision to accept given
203 // cluster for tracking
204 Double_t sy2=ErrY2(seed,cluster)*cory;
205 Double_t sz2=ErrZ2(seed,cluster)*corz;
206 //sy2=ErrY2(seed,cluster)*cory;
207 //sz2=ErrZ2(seed,cluster)*cory;
209 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
210 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
212 Double_t rdistancey2 = (seed->GetCurrentCluster()->GetY()-seed->GetY())*
213 (seed->GetCurrentCluster()->GetY()-seed->GetY())/sdistancey2;
214 Double_t rdistancez2 = (seed->GetCurrentCluster()->GetZ()-seed->GetZ())*
215 (seed->GetCurrentCluster()->GetZ()-seed->GetZ())/sdistancez2;
217 Double_t rdistance2 = rdistancey2+rdistancez2;
220 if (rdistance2>16) return 3;
223 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
224 return 2; //suspisiouce - will be changed
226 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
227 // strict cut on overlaped cluster
228 return 2; //suspisiouce - will be changed
230 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
231 && cluster->GetType()<0){
232 seed->SetNFoundable(seed->GetNFoundable()-1);
241 //_____________________________________________________________________________
242 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
244 fkNIS(par->GetNInnerSector()/2),
246 fkNOS(par->GetNOuterSector()/2),
263 //---------------------------------------------------------------------
264 // The main TPC tracker constructor
265 //---------------------------------------------------------------------
266 fInnerSec=new AliTPCSector[fkNIS];
267 fOuterSec=new AliTPCSector[fkNOS];
270 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
271 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
274 Int_t nrowlow = par->GetNRowLow();
275 Int_t nrowup = par->GetNRowUp();
278 for (Int_t i=0;i<nrowlow;i++){
279 fXRow[i] = par->GetPadRowRadiiLow(i);
280 fPadLength[i]= par->GetPadPitchLength(0,i);
281 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
285 for (Int_t i=0;i<nrowup;i++){
286 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
287 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
288 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
291 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
293 //________________________________________________________________________
294 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
315 //------------------------------------
316 // dummy copy constructor
317 //------------------------------------------------------------------
320 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
321 //------------------------------
323 //--------------------------------------------------------------
326 //_____________________________________________________________________________
327 AliTPCtrackerMI::~AliTPCtrackerMI() {
328 //------------------------------------------------------------------
329 // TPC tracker destructor
330 //------------------------------------------------------------------
337 if (fDebugStreamer) delete fDebugStreamer;
340 void AliTPCtrackerMI::SetIO()
344 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
346 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
348 AliTPCtrack *iotrack= new AliTPCtrack;
349 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
355 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
371 AliTPCtrack *iotrack= new AliTPCtrack;
372 // iotrack->fHelixIn = new TClonesArray("AliHelix");
373 //iotrack->fHelixOut = new TClonesArray("AliHelix");
374 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
377 if (output && (fDebug&2)){
378 //write the full seed information if specified in debug mode
380 fSeedTree = new TTree("Seeds","Seeds");
381 AliTPCseed * vseed = new AliTPCseed;
383 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
384 arrtr->ExpandCreateFast(160);
385 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
387 vseed->SetPoints(arrtr);
388 vseed->SetEPoints(arre);
389 // vseed->fClusterPoints = arrcl;
390 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
393 fTreeDebug = new TTree("trackDebug","trackDebug");
394 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
395 fTreeDebug->Branch("debug",&arrd,32000,99);
403 void AliTPCtrackerMI::FillESD(TObjArray* arr)
407 //fill esds using updated tracks
409 // write tracks to the event
410 // store index of the track
411 Int_t nseed=arr->GetEntriesFast();
412 //FindKinks(arr,fEvent);
413 for (Int_t i=0; i<nseed; i++) {
414 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
417 // pt->PropagateTo(fParam->GetInnerRadiusLow());
418 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
419 pt->PropagateTo(fParam->GetInnerRadiusLow());
422 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
424 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
425 iotrack.SetTPCPoints(pt->GetPoints());
426 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
427 iotrack.SetV0Indexes(pt->GetV0Indexes());
428 // iotrack.SetTPCpid(pt->fTPCr);
429 //iotrack.SetTPCindex(i);
430 fEvent->AddTrack(&iotrack);
434 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.55) {
436 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
437 iotrack.SetTPCPoints(pt->GetPoints());
438 //iotrack.SetTPCindex(i);
439 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
440 iotrack.SetV0Indexes(pt->GetV0Indexes());
441 // iotrack.SetTPCpid(pt->fTPCr);
442 fEvent->AddTrack(&iotrack);
446 // short tracks - maybe decays
448 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.70) {
449 Int_t found,foundable,shared;
450 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
451 if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2)){
453 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
454 //iotrack.SetTPCindex(i);
455 iotrack.SetTPCPoints(pt->GetPoints());
456 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
457 iotrack.SetV0Indexes(pt->GetV0Indexes());
458 //iotrack.SetTPCpid(pt->fTPCr);
459 fEvent->AddTrack(&iotrack);
464 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.8) {
465 Int_t found,foundable,shared;
466 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
467 if (found<20) continue;
468 if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
471 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
472 iotrack.SetTPCPoints(pt->GetPoints());
473 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
474 iotrack.SetV0Indexes(pt->GetV0Indexes());
475 //iotrack.SetTPCpid(pt->fTPCr);
476 //iotrack.SetTPCindex(i);
477 fEvent->AddTrack(&iotrack);
480 // short tracks - secondaties
482 if ( (pt->GetNumberOfClusters()>30) ) {
483 Int_t found,foundable,shared;
484 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
485 if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
487 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
488 iotrack.SetTPCPoints(pt->GetPoints());
489 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
490 iotrack.SetV0Indexes(pt->GetV0Indexes());
491 //iotrack.SetTPCpid(pt->fTPCr);
492 //iotrack.SetTPCindex(i);
493 fEvent->AddTrack(&iotrack);
498 if ( (pt->GetNumberOfClusters()>15)) {
499 Int_t found,foundable,shared;
500 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
501 if (found<15) continue;
502 if (foundable<=0) continue;
503 if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
504 if (float(found)/float(foundable)<0.8) continue;
507 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
508 iotrack.SetTPCPoints(pt->GetPoints());
509 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
510 iotrack.SetV0Indexes(pt->GetV0Indexes());
511 // iotrack.SetTPCpid(pt->fTPCr);
512 //iotrack.SetTPCindex(i);
513 fEvent->AddTrack(&iotrack);
518 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
521 void AliTPCtrackerMI::WriteTracks(TTree * tree)
524 // write tracks from seed array to selected tree
528 AliTPCtrack *iotrack= new AliTPCtrack;
529 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
534 void AliTPCtrackerMI::WriteTracks()
537 // write tracks to the given output tree -
538 // output specified with SetIO routine
545 AliTPCtrack *iotrack= 0;
546 Int_t nseed=fSeeds->GetEntriesFast();
547 //for (Int_t i=0; i<nseed; i++) {
548 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
549 // if (iotrack) break;
551 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
552 TBranch * br = fOutput->GetBranch("tracks");
553 br->SetAddress(&iotrack);
555 for (Int_t i=0; i<nseed; i++) {
556 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
558 AliTPCtrack * track = new AliTPCtrack(*pt);
561 // br->SetAddress(&iotrack);
566 //fOutput->GetDirectory()->cd();
572 //write the full seed information if specified in debug mode
574 AliTPCseed * vseed = new AliTPCseed;
576 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
577 arrtr->ExpandCreateFast(160);
578 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
579 //arrcl->ExpandCreateFast(160);
580 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
582 vseed->SetPoints(arrtr);
583 vseed->SetEPoints(arre);
584 // vseed->fClusterPoints = arrcl;
585 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
586 TBranch * brseed = fSeedTree->GetBranch("seeds");
588 Int_t nseed=fSeeds->GetEntriesFast();
590 for (Int_t i=0; i<nseed; i++) {
591 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
593 pt->SetPoints(arrtr);
594 // pt->fClusterPoints = arrcl;
595 pt->SetEPoints(arre);
598 brseed->SetAddress(&vseed);
602 // pt->fClusterPoints = 0;
605 if (fTreeDebug) fTreeDebug->Write();
613 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
616 //seed->SetErrorY2(0.1);
618 //calculate look-up table at the beginning
619 static Bool_t ginit = kFALSE;
620 static Float_t gnoise1,gnoise2,gnoise3;
621 static Float_t ggg1[10000];
622 static Float_t ggg2[10000];
623 static Float_t ggg3[10000];
624 static Float_t glandau1[10000];
625 static Float_t glandau2[10000];
626 static Float_t glandau3[10000];
628 static Float_t gcor01[500];
629 static Float_t gcor02[500];
630 static Float_t gcorp[500];
635 for (Int_t i=1;i<500;i++){
636 Float_t rsigma = float(i)/100.;
637 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
638 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
639 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
643 for (Int_t i=3;i<10000;i++){
647 Float_t amp = float(i);
648 Float_t padlength =0.75;
649 gnoise1 = 0.0004/padlength;
650 Float_t nel = 0.268*amp;
651 Float_t nprim = 0.155*amp;
652 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
653 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
654 if (glandau1[i]>1) glandau1[i]=1;
655 glandau1[i]*=padlength*padlength/12.;
659 gnoise2 = 0.0004/padlength;
662 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
663 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
664 if (glandau2[i]>1) glandau2[i]=1;
665 glandau2[i]*=padlength*padlength/12.;
670 gnoise3 = 0.0004/padlength;
673 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
674 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
675 if (glandau3[i]>1) glandau3[i]=1;
676 glandau3[i]*=padlength*padlength/12.;
684 Int_t amp = int(TMath::Abs(cl->GetQ()));
686 seed->SetErrorY2(1.);
690 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
691 Int_t ctype = cl->GetType();
692 Float_t padlength= GetPadPitchLength(seed->GetRow());
693 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
694 angle2 = angle2/(1-angle2);
697 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->GetCurrentSigmaY2()));
700 if (fSectors==fInnerSec){
702 res = ggg1[amp]*z+glandau1[amp]*angle2;
703 if (ctype==0) res *= gcor01[rsigmay];
706 res*= gcorp[rsigmay];
712 res = ggg2[amp]*z+glandau2[amp]*angle2;
713 if (ctype==0) res *= gcor02[rsigmay];
716 res*= gcorp[rsigmay];
721 res = ggg3[amp]*z+glandau3[amp]*angle2;
722 if (ctype==0) res *= gcor02[rsigmay];
725 res*= gcorp[rsigmay];
732 res*=2.4; // overestimate error 2 times
739 seed->SetErrorY2(res);
747 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
750 //seed->SetErrorY2(0.1);
752 //calculate look-up table at the beginning
753 static Bool_t ginit = kFALSE;
754 static Float_t gnoise1,gnoise2,gnoise3;
755 static Float_t ggg1[10000];
756 static Float_t ggg2[10000];
757 static Float_t ggg3[10000];
758 static Float_t glandau1[10000];
759 static Float_t glandau2[10000];
760 static Float_t glandau3[10000];
762 static Float_t gcor01[1000];
763 static Float_t gcor02[1000];
764 static Float_t gcorp[1000];
769 for (Int_t i=1;i<1000;i++){
770 Float_t rsigma = float(i)/100.;
771 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
772 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
773 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
777 for (Int_t i=3;i<10000;i++){
781 Float_t amp = float(i);
782 Float_t padlength =0.75;
783 gnoise1 = 0.0004/padlength;
784 Float_t nel = 0.268*amp;
785 Float_t nprim = 0.155*amp;
786 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
787 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
788 if (glandau1[i]>1) glandau1[i]=1;
789 glandau1[i]*=padlength*padlength/12.;
793 gnoise2 = 0.0004/padlength;
796 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
797 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
798 if (glandau2[i]>1) glandau2[i]=1;
799 glandau2[i]*=padlength*padlength/12.;
804 gnoise3 = 0.0004/padlength;
807 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
808 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
809 if (glandau3[i]>1) glandau3[i]=1;
810 glandau3[i]*=padlength*padlength/12.;
818 Int_t amp = int(TMath::Abs(cl->GetQ()));
820 seed->SetErrorY2(1.);
824 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
825 Int_t ctype = cl->GetType();
826 Float_t padlength= GetPadPitchLength(seed->GetRow());
828 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
829 // if (angle2<0.6) angle2 = 0.6;
830 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
833 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->GetCurrentSigmaZ2()));
836 if (fSectors==fInnerSec){
838 res = ggg1[amp]*z+glandau1[amp]*angle2;
839 if (ctype==0) res *= gcor01[rsigmaz];
842 res*= gcorp[rsigmaz];
848 res = ggg2[amp]*z+glandau2[amp]*angle2;
849 if (ctype==0) res *= gcor02[rsigmaz];
852 res*= gcorp[rsigmaz];
857 res = ggg3[amp]*z+glandau3[amp]*angle2;
858 if (ctype==0) res *= gcor02[rsigmaz];
861 res*= gcorp[rsigmaz];
870 if ((ctype<0) &&<70){
878 seed->SetErrorZ2(res);
885 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
888 //seed->SetErrorZ2(0.1);
892 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
894 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
895 Int_t ctype = cl->GetType();
896 Float_t amp = TMath::Abs(cl->GetQ());
901 Float_t landau=2 ; //landau fluctuation part
902 Float_t gg=2; // gg fluctuation part
903 Float_t padlength= GetPadPitchLength(seed->GetX());
905 if (fSectors==fInnerSec){
906 snoise2 = 0.0004/padlength;
909 gg = (2+0.001*nel/(padlength*padlength))/nel;
910 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
911 if (landau>1) landau=1;
914 snoise2 = 0.0004/padlength;
917 gg = (2+0.0008*nel/(padlength*padlength))/nel;
918 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
919 if (landau>1) landau=1;
921 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
924 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
925 angle2 = TMath::Sqrt((1-angle2));
926 if (angle2<0.6) angle2 = 0.6;
929 Float_t angle = seed->GetTgl()/angle2;
930 Float_t angular = landau*angle*angle*padlength*padlength/12.;
931 Float_t res = sdiff + angular;
934 if ((ctype==0) && (fSectors ==fOuterSec))
935 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
937 if ((ctype==0) && (fSectors ==fInnerSec))
938 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
942 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
948 if ((ctype<0) &&<70){
956 seed->SetErrorZ2(res);
964 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
966 //rotate to track "local coordinata
967 Float_t x = seed->GetX();
968 Float_t y = seed->GetY();
969 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
972 seed->SetRelativeSector((seed->GetRelativeSector()+1) % fN);
973 if (!seed->Rotate(fSectors->GetAlpha()))
975 } else if (y <-ymax) {
976 seed->SetRelativeSector((seed->GetRelativeSector()-1+fN) % fN);
977 if (!seed->Rotate(-fSectors->GetAlpha()))
985 //_____________________________________________________________________________
986 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
987 Double_t x2,Double_t y2,
988 Double_t x3,Double_t y3)
990 //-----------------------------------------------------------------
991 // Initial approximation of the track curvature
992 //-----------------------------------------------------------------
993 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
994 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
995 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
996 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
997 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
999 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1000 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1001 return -xr*yr/sqrt(xr*xr+yr*yr);
1006 //_____________________________________________________________________________
1007 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1008 Double_t x2,Double_t y2,
1009 Double_t x3,Double_t y3)
1011 //-----------------------------------------------------------------
1012 // Initial approximation of the track curvature
1013 //-----------------------------------------------------------------
1019 Double_t det = x3*y2-x2*y3;
1024 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1025 Double_t x0 = x3*0.5-y3*u;
1026 Double_t y0 = y3*0.5+x3*u;
1027 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1033 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1034 Double_t x2,Double_t y2,
1035 Double_t x3,Double_t y3)
1037 //-----------------------------------------------------------------
1038 // Initial approximation of the track curvature
1039 //-----------------------------------------------------------------
1045 Double_t det = x3*y2-x2*y3;
1050 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1051 Double_t x0 = x3*0.5-y3*u;
1052 Double_t y0 = y3*0.5+x3*u;
1053 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1062 //_____________________________________________________________________________
1063 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1064 Double_t x2,Double_t y2,
1065 Double_t x3,Double_t y3)
1067 //-----------------------------------------------------------------
1068 // Initial approximation of the track curvature times center of curvature
1069 //-----------------------------------------------------------------
1070 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1071 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1072 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1073 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1074 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1076 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1078 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1081 //_____________________________________________________________________________
1082 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1083 Double_t x2,Double_t y2,
1084 Double_t z1,Double_t z2)
1086 //-----------------------------------------------------------------
1087 // Initial approximation of the tangent of the track dip angle
1088 //-----------------------------------------------------------------
1089 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1093 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1094 Double_t x2,Double_t y2,
1095 Double_t z1,Double_t z2, Double_t c)
1097 //-----------------------------------------------------------------
1098 // Initial approximation of the tangent of the track dip angle
1099 //-----------------------------------------------------------------
1103 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1105 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1106 if (TMath::Abs(d*c*0.5)>1) return 0;
1107 // Double_t angle2 = TMath::ASin(d*c*0.5);
1108 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1109 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1111 angle2 = (z1-z2)*c/(angle2*2.);
1115 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1116 {//-----------------------------------------------------------------
1117 // This function find proloncation of a track to a reference plane x=x2.
1118 //-----------------------------------------------------------------
1122 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1126 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1127 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1131 Double_t dy = dx*(c1+c2)/(r1+r2);
1134 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1136 if (TMath::Abs(delta)>0.01){
1137 dz = x[3]*TMath::ASin(delta)/x[4];
1139 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1142 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1150 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1155 return LoadClusters();
1158 Int_t AliTPCtrackerMI::LoadClusters()
1161 // load clusters to the memory
1162 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1163 clrow->SetClass("AliTPCclusterMI");
1165 clrow->GetArray()->ExpandCreateFast(10000);
1167 // TTree * tree = fClustersArray.GetTree();
1169 TTree * tree = fInput;
1170 TBranch * br = tree->GetBranch("Segment");
1171 br->SetAddress(&clrow);
1173 Int_t j=Int_t(tree->GetEntries());
1174 for (Int_t i=0; i<j; i++) {
1178 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1179 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1180 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1183 AliTPCRow * tpcrow=0;
1186 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1190 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1191 left = (sec-fkNIS*2)/fkNOS;
1194 tpcrow->SetN1(clrow->GetArray()->GetEntriesFast());
1195 tpcrow->SetClusters1(new AliTPCclusterMI[tpcrow->GetN1()]);
1196 for (Int_t i=0;i<tpcrow->GetN1();i++)
1197 tpcrow->SetCluster1(i, *(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
1200 tpcrow->SetN2(clrow->GetArray()->GetEntriesFast());
1201 tpcrow->SetClusters2(new AliTPCclusterMI[tpcrow->GetN2()]);
1202 for (Int_t i=0;i<tpcrow->GetN2();i++)
1203 tpcrow->SetCluster2(i,*(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
1214 void AliTPCtrackerMI::UnloadClusters()
1217 // unload clusters from the memory
1219 Int_t nrows = fOuterSec->GetNRows();
1220 for (Int_t sec = 0;sec<fkNOS;sec++)
1221 for (Int_t row = 0;row<nrows;row++){
1222 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1224 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1225 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1227 tpcrow->ResetClusters();
1230 nrows = fInnerSec->GetNRows();
1231 for (Int_t sec = 0;sec<fkNIS;sec++)
1232 for (Int_t row = 0;row<nrows;row++){
1233 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1235 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1236 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1238 tpcrow->ResetClusters();
1244 void AliTPCtrackerMI::Transform(AliCluster * cluster){
1248 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1249 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1251 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1252 Double_t posC[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1253 if (mat) mat->LocalToMaster(pos,posC);
1255 // chack Loading of Geo matrices from GeoManager - TEMPORARY FIX
1257 cluster->SetX(posC[0]);
1258 cluster->SetY(posC[1]);
1259 cluster->SetZ(posC[2]);
1262 //_____________________________________________________________________________
1263 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1264 //-----------------------------------------------------------------
1265 // This function fills outer TPC sectors with clusters.
1266 //-----------------------------------------------------------------
1267 Int_t nrows = fOuterSec->GetNRows();
1269 for (Int_t sec = 0;sec<fkNOS;sec++)
1270 for (Int_t row = 0;row<nrows;row++){
1271 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1272 Int_t sec2 = sec+2*fkNIS;
1274 Int_t ncl = tpcrow->GetN1();
1276 AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
1277 index=(((sec2<<8)+row)<<16)+ncl;
1278 tpcrow->InsertCluster(c,index);
1281 ncl = tpcrow->GetN2();
1283 AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
1284 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1285 tpcrow->InsertCluster(c,index);
1288 // write indexes for fast acces
1290 for (Int_t i=0;i<510;i++)
1291 tpcrow->SetFastCluster(i,-1);
1292 for (Int_t i=0;i<tpcrow->GetN();i++){
1293 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1294 tpcrow->SetFastCluster(zi,i); // write index
1297 for (Int_t i=0;i<510;i++){
1298 if (tpcrow->GetFastCluster(i)<0)
1299 tpcrow->SetFastCluster(i,last);
1301 last = tpcrow->GetFastCluster(i);
1310 //_____________________________________________________________________________
1311 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1312 //-----------------------------------------------------------------
1313 // This function fills inner TPC sectors with clusters.
1314 //-----------------------------------------------------------------
1315 Int_t nrows = fInnerSec->GetNRows();
1317 for (Int_t sec = 0;sec<fkNIS;sec++)
1318 for (Int_t row = 0;row<nrows;row++){
1319 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1322 Int_t ncl = tpcrow->GetN1();
1324 AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
1325 index=(((sec<<8)+row)<<16)+ncl;
1326 tpcrow->InsertCluster(c,index);
1329 ncl = tpcrow->GetN2();
1331 AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
1332 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1333 tpcrow->InsertCluster(c,index);
1336 // write indexes for fast acces
1338 for (Int_t i=0;i<510;i++)
1339 tpcrow->SetFastCluster(i,-1);
1340 for (Int_t i=0;i<tpcrow->GetN();i++){
1341 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1342 tpcrow->SetFastCluster(zi,i); // write index
1345 for (Int_t i=0;i<510;i++){
1346 if (tpcrow->GetFastCluster(i)<0)
1347 tpcrow->SetFastCluster(i,last);
1349 last = tpcrow->GetFastCluster(i);
1361 //_________________________________________________________________________
1362 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1363 //--------------------------------------------------------------------
1364 // Return pointer to a given cluster
1365 //--------------------------------------------------------------------
1366 if (index<0) return 0; // no cluster
1367 Int_t sec=(index&0xff000000)>>24;
1368 Int_t row=(index&0x00ff0000)>>16;
1369 Int_t ncl=(index&0x00007fff)>>00;
1371 const AliTPCRow * tpcrow=0;
1372 AliTPCclusterMI * clrow =0;
1374 if (sec<0 || sec>=fkNIS*4) {
1375 AliWarning(Form("Wrong sector %d",sec));
1380 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1381 if (tpcrow==0) return 0;
1384 if (tpcrow->GetN1()<=ncl) return 0;
1385 clrow = tpcrow->GetClusters1();
1388 if (tpcrow->GetN2()<=ncl) return 0;
1389 clrow = tpcrow->GetClusters2();
1393 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1394 if (tpcrow==0) return 0;
1396 if (sec-2*fkNIS<fkNOS) {
1397 if (tpcrow->GetN1()<=ncl) return 0;
1398 clrow = tpcrow->GetClusters1();
1401 if (tpcrow->GetN2()<=ncl) return 0;
1402 clrow = tpcrow->GetClusters2();
1406 return &(clrow[ncl]);
1412 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1413 //-----------------------------------------------------------------
1414 // This function tries to find a track prolongation to next pad row
1415 //-----------------------------------------------------------------
1417 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1418 AliTPCclusterMI *cl=0;
1419 Int_t tpcindex= t.GetClusterIndex2(nr);
1421 // update current shape info every 5 pad-row
1422 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1426 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1428 if (tpcindex==-1) return 0; //track in dead zone
1430 cl = t.GetClusterPointer(nr);
1431 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1432 t.SetCurrentClusterIndex1(tpcindex);
1435 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1436 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1438 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1439 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1441 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1442 Double_t rotation = angle-t.GetAlpha();
1443 t.SetRelativeSector(relativesector);
1444 if (!t.Rotate(rotation)) return 0;
1446 if (!t.PropagateTo(x)) return 0;
1448 t.SetCurrentCluster(cl);
1450 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1451 if ((tpcindex&0x8000)==0) accept =0;
1453 //if founded cluster is acceptible
1454 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1455 t.SetErrorY2(t.GetErrorY2()+0.03);
1456 t.SetErrorZ2(t.GetErrorZ2()+0.03);
1457 t.SetErrorY2(t.GetErrorY2()*3);
1458 t.SetErrorZ2(t.GetErrorZ2()*3);
1460 t.SetNFoundable(t.GetNFoundable()+1);
1461 UpdateTrack(&t,accept);
1466 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1468 // not look for new cluster during refitting
1469 t.SetNFoundable(t.GetNFoundable()+1);
1474 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1475 Double_t y=t.GetYat(x);
1476 if (TMath::Abs(y)>ymax){
1478 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1479 if (!t.Rotate(fSectors->GetAlpha()))
1481 } else if (y <-ymax) {
1482 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1483 if (!t.Rotate(-fSectors->GetAlpha()))
1489 if (!t.PropagateTo(x)) {
1490 if (fIteration==0) t.SetRemoval(10);
1494 Double_t z=t.GetZ();
1497 if (!IsActive(t.GetRelativeSector(),nr)) {
1499 t.SetClusterIndex2(nr,-1);
1502 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1503 Bool_t isActive = IsActive(t.GetRelativeSector(),nr);
1504 Bool_t isActive2 = (nr>=fInnerSec->GetNRows()) ? fOuterSec[t.GetRelativeSector()][nr-fInnerSec->GetNRows()].GetN()>0:fInnerSec[t.GetRelativeSector()][nr].GetN()>0;
1506 if (!isActive || !isActive2) return 0;
1508 const AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1509 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1511 Double_t roadz = 1.;
1513 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1515 t.SetClusterIndex2(nr,-1);
1520 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1521 t.SetNFoundable(t.GetNFoundable()+1);
1527 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1528 cl = krow.FindNearest2(y,z,roady,roadz,index);
1529 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));
1532 t.SetCurrentCluster(cl);
1534 if (fIteration==2&&cl->IsUsed(10)) return 0;
1535 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1536 if (fIteration==2&&cl->IsUsed(11)) {
1537 t.SetErrorY2(t.GetErrorY2()+0.03);
1538 t.SetErrorZ2(t.GetErrorZ2()+0.03);
1539 t.SetErrorY2(t.GetErrorY2()*3);
1540 t.SetErrorZ2(t.GetErrorZ2()*3);
1543 if (t.fCurrentCluster->IsUsed(10)){
1548 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1554 if (accept<3) UpdateTrack(&t,accept);
1557 if ( fIteration==0 && t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) t.SetRemoval(10);
1563 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1564 //-----------------------------------------------------------------
1565 // This function tries to find a track prolongation to next pad row
1566 //-----------------------------------------------------------------
1568 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1570 if (!t.GetProlongation(x,y,z)) {
1576 if (TMath::Abs(y)>ymax){
1579 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1580 if (!t.Rotate(fSectors->GetAlpha()))
1582 } else if (y <-ymax) {
1583 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1584 if (!t.Rotate(-fSectors->GetAlpha()))
1587 if (!t.PropagateTo(x)) {
1590 t.GetProlongation(x,y,z);
1593 // update current shape info every 3 pad-row
1594 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.GetCurrentSigmaY2()<0.0001) ){
1595 // t.fCurrentSigmaY = GetSigmaY(&t);
1596 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1600 AliTPCclusterMI *cl=0;
1605 const AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1606 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1608 Double_t roadz = 1.;
1611 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1613 t.SetClusterIndex2(row,-1);
1618 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1622 if ((cl==0)&&(krow)) {
1623 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1624 cl = krow.FindNearest2(y,z,roady,roadz,index);
1626 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));
1630 t.SetCurrentCluster(cl);
1631 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1633 t.SetClusterIndex2(row,index);
1634 t.SetClusterPointer(row, cl);
1642 //_________________________________________________________________________
1643 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1645 // Get track space point by index
1646 // return false in case the cluster doesn't exist
1647 AliTPCclusterMI *cl = GetClusterMI(index);
1648 if (!cl) return kFALSE;
1649 Int_t sector = (index&0xff000000)>>24;
1650 // Int_t row = (index&0x00ff0000)>>16;
1652 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1653 xyz[0] = cl->GetX();
1654 xyz[1] = cl->GetY();
1655 xyz[2] = cl->GetZ();
1657 fParam->AdjustCosSin(sector,cos,sin);
1658 Float_t x = cos*xyz[0]-sin*xyz[1];
1659 Float_t y = cos*xyz[1]+sin*xyz[0];
1661 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1662 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1663 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1664 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1665 cov[0] = sin*sin*sigmaY2;
1666 cov[1] = -sin*cos*sigmaY2;
1668 cov[3] = cos*cos*sigmaY2;
1671 p.SetXYZ(x,y,xyz[2],cov);
1672 AliAlignObj::ELayerID iLayer;
1674 if (sector < fParam->GetNInnerSector()) {
1675 iLayer = AliAlignObj::kTPC1;
1679 iLayer = AliAlignObj::kTPC2;
1680 idet = sector - fParam->GetNInnerSector();
1682 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1683 p.SetVolumeID(volid);
1689 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1690 //-----------------------------------------------------------------
1691 // This function tries to find a track prolongation to next pad row
1692 //-----------------------------------------------------------------
1693 t.SetCurrentCluster(0);
1694 t.SetCurrentClusterIndex1(0);
1696 Double_t xt=t.GetX();
1697 Int_t row = GetRowNumber(xt)-1;
1698 Double_t ymax= GetMaxY(nr);
1700 if (row < nr) return 1; // don't prolongate if not information until now -
1701 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1703 // return 0; // not prolongate strongly inclined tracks
1705 // if (TMath::Abs(t.GetSnp())>0.95) {
1707 // return 0; // not prolongate strongly inclined tracks
1708 // }// patch 28 fev 06
1710 Double_t x= GetXrow(nr);
1712 //t.PropagateTo(x+0.02);
1713 //t.PropagateTo(x+0.01);
1714 if (!t.PropagateTo(x)){
1721 if (TMath::Abs(y)>ymax){
1723 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1724 if (!t.Rotate(fSectors->GetAlpha()))
1726 } else if (y <-ymax) {
1727 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1728 if (!t.Rotate(-fSectors->GetAlpha()))
1731 // if (!t.PropagateTo(x)){
1738 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1740 if (!IsActive(t.GetRelativeSector(),nr)) {
1742 t.SetClusterIndex2(nr,-1);
1745 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1747 AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1749 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1751 t.SetClusterIndex2(nr,-1);
1756 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.SetNFoundable(t.GetNFoundable()+1);
1762 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1763 // t.fCurrentSigmaY = GetSigmaY(&t);
1764 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1768 AliTPCclusterMI *cl=0;
1771 Double_t roady = 1.;
1772 Double_t roadz = 1.;
1776 index = t.GetClusterIndex2(nr);
1777 if ( (index>0) && (index&0x8000)==0){
1778 cl = t.GetClusterPointer(nr);
1779 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1780 t.SetCurrentClusterIndex1(index);
1782 t.SetCurrentCluster(cl);
1788 // if (index<0) return 0;
1789 UInt_t uindex = TMath::Abs(index);
1792 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1793 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1796 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(uindex));
1797 t.SetCurrentCluster(cl);
1803 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1804 //-----------------------------------------------------------------
1805 // This function tries to find a track prolongation to next pad row
1806 //-----------------------------------------------------------------
1808 //update error according neighborhoud
1810 if (t.GetCurrentCluster()) {
1812 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1814 if (t.GetCurrentCluster()->IsUsed(10)){
1819 t.SetNShared(t.GetNShared()+1);
1820 if (t.GetNShared()>0.7*t.GetNumberOfClusters()) {
1825 if (fIteration>0) accept = 0;
1826 if (accept<3) UpdateTrack(&t,accept);
1830 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.SetRemoval(10);
1831 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.SetRemoval(10);
1833 if (( (t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) || t.GetNoCluster()>15)) t.SetRemoval(10);
1841 //_____________________________________________________________________________
1842 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1843 //-----------------------------------------------------------------
1844 // This function tries to find a track prolongation.
1845 //-----------------------------------------------------------------
1846 Double_t xt=t.GetX();
1848 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1849 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1850 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1852 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1854 Int_t first = GetRowNumber(xt)-1;
1855 for (Int_t nr= first; nr>=rf; nr-=step) {
1857 if (t.GetKinkIndexes()[0]>0){
1858 for (Int_t i=0;i<3;i++){
1859 Int_t index = t.GetKinkIndexes()[i];
1860 if (index==0) break;
1861 if (index<0) continue;
1863 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1865 printf("PROBLEM\n");
1868 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1870 AliExternalTrackParam paramd(t);
1871 kink->SetDaughter(paramd);
1872 kink->SetStatus(2,5);
1879 if (nr==80) t.UpdateReference();
1880 if (nr<fInnerSec->GetNRows())
1881 fSectors = fInnerSec;
1883 fSectors = fOuterSec;
1884 if (FollowToNext(t,nr)==0)
1893 //_____________________________________________________________________________
1894 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1895 //-----------------------------------------------------------------
1896 // This function tries to find a track prolongation.
1897 //-----------------------------------------------------------------
1898 Double_t xt=t.GetX();
1900 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1901 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1902 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1903 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1905 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1907 if (FollowToNextFast(t,nr)==0)
1908 if (!t.IsActive()) return 0;
1918 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1919 //-----------------------------------------------------------------
1920 // This function tries to find a track prolongation.
1921 //-----------------------------------------------------------------
1923 Double_t xt=t.GetX();
1924 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1925 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1926 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1927 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1929 Int_t first = t.GetFirstPoint();
1930 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1932 if (first<0) first=0;
1933 for (Int_t nr=first; nr<=rf; nr++) {
1934 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1935 if (t.GetKinkIndexes()[0]<0){
1936 for (Int_t i=0;i<3;i++){
1937 Int_t index = t.GetKinkIndexes()[i];
1938 if (index==0) break;
1939 if (index>0) continue;
1940 index = TMath::Abs(index);
1941 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1943 printf("PROBLEM\n");
1946 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1948 AliExternalTrackParam paramm(t);
1949 kink->SetMother(paramm);
1950 kink->SetStatus(2,1);
1957 if (nr<fInnerSec->GetNRows())
1958 fSectors = fInnerSec;
1960 fSectors = fOuterSec;
1971 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1979 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1982 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1984 Float_t distance = TMath::Sqrt(dz2+dy2);
1985 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1988 Int_t firstpoint = TMath::Min(s1->GetFirstPoint(),s2->GetFirstPoint());
1989 Int_t lastpoint = TMath::Max(s1->GetLastPoint(),s2->GetLastPoint());
1994 if (firstpoint>lastpoint) {
1995 firstpoint =lastpoint;
2000 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
2001 if (s1->GetClusterIndex2(i)>0) sum1++;
2002 if (s2->GetClusterIndex2(i)>0) sum2++;
2003 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
2007 if (sum<5) return 0;
2009 Float_t summin = TMath::Min(sum1+1,sum2+1);
2010 Float_t ratio = (sum+1)/Float_t(summin);
2014 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
2018 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
2019 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
2021 Float_t dz2 =(s1->GetZ() - s2->GetZ());
2023 Float_t dy2 =(s1->GetY() - s2->GetY());
2025 Float_t distance = dz2+dy2;
2026 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
2031 Int_t firstpoint = TMath::Max(s1->GetFirstPoint(),s2->GetFirstPoint());
2032 Int_t lastpoint = TMath::Min(s1->GetLastPoint(),s2->GetLastPoint());
2034 if (firstpoint>=lastpoint-5) return;;
2036 for (Int_t i=firstpoint;i<lastpoint;i++){
2037 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
2038 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
2045 for (Int_t i=firstpoint;i<lastpoint;i++){
2046 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
2047 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
2048 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
2049 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
2050 if (s1->IsActive()&&s2->IsActive()){
2051 p1->SetShared(kTRUE);
2052 p2->SetShared(kTRUE);
2059 for (Int_t i=0;i<4;i++){
2060 if (s1->GetOverlapLabel(3*i)==0){
2061 s1->SetOverlapLabel(3*i, s2->GetLabel());
2062 s1->SetOverlapLabel(3*i+1,sumshared);
2063 s1->SetOverlapLabel(3*i+2,s2->GetUniqueID());
2067 for (Int_t i=0;i<4;i++){
2068 if (s2->GetOverlapLabel(3*i)==0){
2069 s2->SetOverlapLabel(3*i, s1->GetLabel());
2070 s2->SetOverlapLabel(3*i+1,sumshared);
2071 s2->SetOverlapLabel(3*i+2,s1->GetUniqueID());
2079 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2082 //sort trackss according sectors
2084 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2085 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2087 //if (pt) RotateToLocal(pt);
2091 arr->Sort(); // sorting according z
2092 arr->Expand(arr->GetEntries());
2095 Int_t nseed=arr->GetEntriesFast();
2096 for (Int_t i=0; i<nseed; i++) {
2097 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2099 for (Int_t j=0;j<=12;j++){
2100 pt->SetOverlapLabel(j,0);
2103 for (Int_t i=0; i<nseed; i++) {
2104 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2106 if (pt->GetRemoval()>10) continue;
2107 for (Int_t j=i+1; j<nseed; j++){
2108 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2110 if (pt2->GetRemoval()<=10) {
2111 if ( TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>0) break;
2118 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2121 //sort trackss according sectors
2124 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2127 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2128 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2133 arr->Sort(); // sorting according z
2134 arr->Expand(arr->GetEntries());
2136 //reset overlap labels
2138 Int_t nseed=arr->GetEntriesFast();
2139 for (Int_t i=0; i<nseed; i++) {
2140 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2143 for (Int_t j=0;j<=12;j++){
2144 pt->SetOverlapLabel(j,0);
2148 //sign shared tracks
2149 for (Int_t i=0; i<nseed; i++) {
2150 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2152 if (pt->GetRemoval()>10) continue;
2153 Float_t deltac = pt->GetC()*0.1;
2154 for (Int_t j=i+1; j<nseed; j++){
2155 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2157 if (pt2->GetRemoval()<=10) {
2158 if ( TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>0) break;
2159 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2160 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2167 // remove highly shared tracks
2168 for (Int_t i=0; i<nseed; i++) {
2169 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2171 if (pt->GetRemoval()>10) continue;
2174 for (Int_t j=0;j<4;j++){
2175 sumshared = pt->GetOverlapLabel(j*3+1);
2177 Float_t factor = factor1;
2178 if (pt->GetRemoval()>0) factor = factor2;
2179 if (sumshared/pt->GetNumberOfClusters()>factor){
2180 for (Int_t j=0;j<4;j++){
2181 if (pt->GetOverlapLabel(3*j)==0) continue;
2182 if (pt->GetOverlapLabel(3*j+1)<5) continue;
2183 if (pt->GetRemoval()==removalindex) continue;
2184 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->GetOverlapLabel(3*j+2));
2186 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2187 // pt->fRemoval = removalindex;
2188 delete arr->RemoveAt(i);
2196 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2205 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2208 //sort tracks in array according mode criteria
2209 Int_t nseed = arr->GetEntriesFast();
2210 for (Int_t i=0; i<nseed; i++) {
2211 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2221 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2224 //Loop over all tracks and remove "overlaps"
2227 Int_t nseed = arr->GetEntriesFast();
2230 for (Int_t i=0; i<nseed; i++) {
2231 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2233 delete arr->RemoveAt(i);
2237 pt->SetBSigned(kFALSE);
2241 nseed = arr->GetEntriesFast();
2248 for (Int_t i=0; i<nseed; i++) {
2249 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2253 Int_t found,foundable,shared;
2255 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2257 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2259 Double_t factor = factor2;
2260 if (pt->GetBConstrain()) factor = factor1;
2262 if ((Float_t(shared)/Float_t(found))>factor){
2263 pt->Desactivate(removalindex);
2268 for (Int_t i=0; i<160; i++) {
2269 Int_t index=pt->GetClusterIndex2(i);
2270 if (index<0 || index&0x8000 ) continue;
2271 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2273 // if (!c->IsUsed(10)) c->Use(10);
2274 //if (pt->IsActive())
2283 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2288 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2291 //Loop over all tracks and remove "overlaps"
2296 Int_t nseed = arr->GetEntriesFast();
2297 Float_t * quality = new Float_t[nseed];
2298 Int_t * indexes = new Int_t[nseed];
2302 for (Int_t i=0; i<nseed; i++) {
2303 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2308 pt->UpdatePoints(); //select first last max dens points
2309 Float_t * points = pt->GetPoints();
2310 if (points[3]<0.8) quality[i] =-1;
2312 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2314 TMath::Sort(nseed,quality,indexes);
2317 for (Int_t itrack=0; itrack<nseed; itrack++) {
2318 Int_t trackindex = indexes[itrack];
2319 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2320 if (quality[trackindex]<0){
2322 delete arr->RemoveAt(trackindex);
2325 arr->RemoveAt(trackindex);
2330 Int_t first = Int_t(pt->GetPoints()[0]);
2331 Int_t last = Int_t(pt->GetPoints()[2]);
2332 Double_t factor = (pt->GetBConstrain()) ? factor1: factor2;
2334 Int_t found,foundable,shared;
2335 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2336 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2337 Bool_t itsgold =kFALSE;
2340 if (pt->GetESD()->GetITSclusters(dummy)>4) itsgold= kTRUE;
2344 if (Float_t(shared+1)/Float_t(found+1)>factor){
2345 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2346 delete arr->RemoveAt(trackindex);
2349 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2350 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2351 delete arr->RemoveAt(trackindex);
2357 if (sharedfactor>0.4) continue;
2358 if (pt->GetKinkIndexes()[0]>0) continue;
2359 for (Int_t i=first; i<last; i++) {
2360 Int_t index=pt->GetClusterIndex2(i);
2361 // if (index<0 || index&0x8000 ) continue;
2362 if (index<0 || index&0x8000 ) continue;
2363 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2370 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2376 void AliTPCtrackerMI::UnsignClusters()
2379 // loop over all clusters and unsign them
2382 for (Int_t sec=0;sec<fkNIS;sec++){
2383 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2384 AliTPCclusterMI *cl = fInnerSec[sec][row].GetClusters1();
2385 for (Int_t icl =0;icl< fInnerSec[sec][row].GetN1();icl++)
2386 // if (cl[icl].IsUsed(10))
2388 cl = fInnerSec[sec][row].GetClusters2();
2389 for (Int_t icl =0;icl< fInnerSec[sec][row].GetN2();icl++)
2390 //if (cl[icl].IsUsed(10))
2395 for (Int_t sec=0;sec<fkNOS;sec++){
2396 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2397 AliTPCclusterMI *cl = fOuterSec[sec][row].GetClusters1();
2398 for (Int_t icl =0;icl< fOuterSec[sec][row].GetN1();icl++)
2399 //if (cl[icl].IsUsed(10))
2401 cl = fOuterSec[sec][row].GetClusters2();
2402 for (Int_t icl =0;icl< fOuterSec[sec][row].GetN2();icl++)
2403 //if (cl[icl].IsUsed(10))
2412 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2415 //sign clusters to be "used"
2417 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2418 // loop over "primaries"
2432 Int_t nseed = arr->GetEntriesFast();
2433 for (Int_t i=0; i<nseed; i++) {
2434 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2438 if (!(pt->IsActive())) continue;
2439 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
2440 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2442 sumdens2+= dens*dens;
2443 sumn += pt->GetNumberOfClusters();
2444 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2445 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2448 sumchi2 +=chi2*chi2;
2453 Float_t mdensity = 0.9;
2454 Float_t meann = 130;
2455 Float_t meanchi = 1;
2456 Float_t sdensity = 0.1;
2457 Float_t smeann = 10;
2458 Float_t smeanchi =0.4;
2462 mdensity = sumdens/sum;
2464 meanchi = sumchi/sum;
2466 sdensity = sumdens2/sum-mdensity*mdensity;
2467 sdensity = TMath::Sqrt(sdensity);
2469 smeann = sumn2/sum-meann*meann;
2470 smeann = TMath::Sqrt(smeann);
2472 smeanchi = sumchi2/sum - meanchi*meanchi;
2473 smeanchi = TMath::Sqrt(smeanchi);
2477 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2479 for (Int_t i=0; i<nseed; i++) {
2480 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2484 if (pt->GetBSigned()) continue;
2485 if (pt->GetBConstrain()) continue;
2486 //if (!(pt->IsActive())) continue;
2488 Int_t found,foundable,shared;
2489 pt->GetClusterStatistic(0,160,found, foundable,shared);
2490 if (shared/float(found)>0.3) {
2491 if (shared/float(found)>0.9 ){
2492 //delete arr->RemoveAt(i);
2497 Bool_t isok =kFALSE;
2498 if ( (pt->GetNShared()/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2500 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->GetNShared()/pt->GetNumberOfClusters()<0.7))
2502 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2504 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2508 for (Int_t i=0; i<160; i++) {
2509 Int_t index=pt->GetClusterIndex2(i);
2510 if (index<0) continue;
2511 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2513 //if (!(c->IsUsed(10))) c->Use();
2520 Double_t maxchi = meanchi+2.*smeanchi;
2522 for (Int_t i=0; i<nseed; i++) {
2523 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2527 //if (!(pt->IsActive())) continue;
2528 if (pt->GetBSigned()) continue;
2529 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2530 if (chi>maxchi) continue;
2533 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
2535 //sign only tracks with enoug big density at the beginning
2537 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2540 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2541 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2543 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2544 if ( (pt->GetRemoval()==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2547 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2548 //Int_t noc=pt->GetNumberOfClusters();
2549 pt->SetBSigned(kTRUE);
2550 for (Int_t i=0; i<160; i++) {
2552 Int_t index=pt->GetClusterIndex2(i);
2553 if (index<0) continue;
2554 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2556 // if (!(c->IsUsed(10))) c->Use();
2561 // gLastCheck = nseed;
2569 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2571 // stop not active tracks
2572 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2573 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2574 Int_t nseed = arr->GetEntriesFast();
2576 for (Int_t i=0; i<nseed; i++) {
2577 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2581 if (!(pt->IsActive())) continue;
2582 StopNotActive(pt,row0,th0, th1,th2);
2588 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2591 // stop not active tracks
2592 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2593 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2596 Int_t foundable = 0;
2597 Int_t maxindex = seed->GetLastPoint(); //last foundable row
2598 if (seed->GetNFoundable()*th0 > seed->GetNumberOfClusters()) {
2599 seed->Desactivate(10) ;
2603 for (Int_t i=row0; i<maxindex; i++){
2604 Int_t index = seed->GetClusterIndex2(i);
2605 if (index!=-1) foundable++;
2607 if (foundable<=30) sumgood1++;
2608 if (foundable<=50) {
2615 if (foundable>=30.){
2616 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2619 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2623 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2626 // back propagation of ESD tracks
2632 //PrepareForProlongation(fSeeds,1);
2633 PropagateForward2(fSeeds);
2636 Int_t nseed = fSeeds->GetEntriesFast();
2637 for (Int_t i=0;i<nseed;i++){
2638 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2639 if (!seed) continue;
2640 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2642 seed->PropagateTo(fParam->GetInnerRadiusLow());
2643 seed->UpdatePoints();
2644 AliESDtrack *esd=event->GetTrack(i);
2645 seed->CookdEdx(0.02,0.6);
2646 CookLabel(seed,0.1); //For comparison only
2648 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2649 TTreeSRedirector &cstream = *fDebugStreamer;
2656 if (seed->GetNumberOfClusters()>15){
2657 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
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 // add seed to the esd track in Calib level
2667 if (AliTPCReconstructor::StreamLevel()>0){
2668 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2669 esd->AddCalibObject(seedCopy);
2674 //printf("problem\n");
2677 //FindKinks(fSeeds,event);
2678 Info("RefitInward","Number of refitted tracks %d",ntracks);
2685 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2688 // back propagation of ESD tracks
2694 PropagateBack(fSeeds);
2695 RemoveUsed2(fSeeds,0.4,0.4,20);
2697 Int_t nseed = fSeeds->GetEntriesFast();
2699 for (Int_t i=0;i<nseed;i++){
2700 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2701 if (!seed) continue;
2702 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2703 seed->UpdatePoints();
2704 AliESDtrack *esd=event->GetTrack(i);
2705 seed->CookdEdx(0.02,0.6);
2706 CookLabel(seed,0.1); //For comparison only
2707 if (seed->GetNumberOfClusters()>15){
2708 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2709 esd->SetTPCPoints(seed->GetPoints());
2710 esd->SetTPCPointsF(seed->GetNFoundable());
2711 Int_t ndedx = seed->GetNCDEDX(0)+seed->GetNCDEDX(1)+seed->GetNCDEDX(2)+seed->GetNCDEDX(3);
2712 Float_t sdedx = (seed->GetSDEDX(0)+seed->GetSDEDX(1)+seed->GetSDEDX(2)+seed->GetSDEDX(3))*0.25;
2713 Float_t dedx = seed->GetdEdx();
2714 esd->SetTPCsignal(dedx, sdedx, ndedx);
2716 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2717 (*fDebugStreamer)<<"Cback"<<
2719 "EventNr="<<eventnumber<<
2720 "\n"; // patch 28 fev 06
2723 //FindKinks(fSeeds,event);
2724 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2732 void AliTPCtrackerMI::DeleteSeeds()
2737 Int_t nseed = fSeeds->GetEntriesFast();
2738 for (Int_t i=0;i<nseed;i++){
2739 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2740 if (seed) delete fSeeds->RemoveAt(i);
2747 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2750 //read seeds from the event
2752 Int_t nentr=event->GetNumberOfTracks();
2754 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2759 fSeeds = new TObjArray(nentr);
2763 for (Int_t i=0; i<nentr; i++) {
2764 AliESDtrack *esd=event->GetTrack(i);
2765 ULong_t status=esd->GetStatus();
2766 if (!(status&AliESDtrack::kTPCin)) continue;
2767 AliTPCtrack t(*esd);
2768 t.SetNumberOfClusters(0);
2769 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2770 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2771 for (Int_t ikink=0;ikink<3;ikink++) {
2772 Int_t index = esd->GetKinkIndex(ikink);
2773 seed->GetKinkIndexes()[ikink] = index;
2774 if (index==0) continue;
2775 index = TMath::Abs(index);
2776 AliESDkink * kink = fEvent->GetKink(index-1);
2777 if (kink&&esd->GetKinkIndex(ikink)<0){
2778 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2779 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2781 if (kink&&esd->GetKinkIndex(ikink)>0){
2782 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2783 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2787 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance(10.);
2788 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance(10.);
2789 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2794 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2795 Double_t par0[5],par1[5],alpha,x;
2796 esd->GetInnerExternalParameters(alpha,x,par0);
2797 esd->GetExternalParameters(x,par1);
2798 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2799 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2801 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2802 //reset covariance if suspicious
2803 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2804 seed->ResetCovariance(10.);
2809 // rotate to the local coordinate system
2811 fSectors=fInnerSec; fN=fkNIS;
2812 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2813 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2814 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2815 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2816 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2817 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2818 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2819 alpha-=seed->GetAlpha();
2820 if (!seed->Rotate(alpha)) {
2826 if (esd->GetKinkIndex(0)<=0){
2827 for (Int_t irow=0;irow<160;irow++){
2828 Int_t index = seed->GetClusterIndex2(irow);
2831 AliTPCclusterMI * cl = GetClusterMI(index);
2832 seed->SetClusterPointer(irow,cl);
2834 if ((index & 0x8000)==0){
2835 cl->Use(10); // accepted cluster
2837 cl->Use(6); // close cluster not accepted
2840 Info("ReadSeeds","Not found cluster");
2845 fSeeds->AddAt(seed,i);
2851 //_____________________________________________________________________________
2852 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2853 Float_t deltay, Int_t ddsec) {
2854 //-----------------------------------------------------------------
2855 // This function creates track seeds.
2856 // SEEDING WITH VERTEX CONSTRAIN
2857 //-----------------------------------------------------------------
2858 // cuts[0] - fP4 cut
2859 // cuts[1] - tan(phi) cut
2860 // cuts[2] - zvertex cut
2861 // cuts[3] - fP3 cut
2869 Double_t x[5], c[15];
2870 // Int_t di = i1-i2;
2872 AliTPCseed * seed = new AliTPCseed;
2873 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2874 Double_t cs=cos(alpha), sn=sin(alpha);
2876 // Double_t x1 =fOuterSec->GetX(i1);
2877 //Double_t xx2=fOuterSec->GetX(i2);
2879 Double_t x1 =GetXrow(i1);
2880 Double_t xx2=GetXrow(i2);
2882 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2884 Int_t imiddle = (i2+i1)/2; //middle pad row index
2885 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2886 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2890 const AliTPCRow& kr1=GetRow(ns,i1);
2891 Double_t ymax = GetMaxY(i1)-kr1.GetDeadZone()-1.5;
2892 Double_t ymaxm = GetMaxY(imiddle)-kr1.GetDeadZone()-1.5;
2895 // change cut on curvature if it can't reach this layer
2896 // maximal curvature set to reach it
2897 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2898 if (dvertexmax*0.5*cuts[0]>0.85){
2899 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2901 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2904 if (deltay>0) ddsec = 0;
2905 // loop over clusters
2906 for (Int_t is=0; is < kr1; is++) {
2908 if (kr1[is]->IsUsed(10)) continue;
2909 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2910 //if (TMath::Abs(y1)>ymax) continue;
2912 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2914 // find possible directions
2915 Float_t anglez = (z1-z3)/(x1-x3);
2916 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2919 //find rotation angles relative to line given by vertex and point 1
2920 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2921 Double_t dvertex = TMath::Sqrt(dvertex2);
2922 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2923 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2926 // loop over 2 sectors
2932 Double_t dddz1=0; // direction of delta inclination in z axis
2939 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2940 Int_t sec2 = sec + dsec;
2942 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2943 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2944 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2945 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2946 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2947 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2949 // rotation angles to p1-p3
2950 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2951 Double_t x2, y2, z2;
2953 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2956 Double_t dxx0 = (xx2-x3)*cs13r;
2957 Double_t dyy0 = (xx2-x3)*sn13r;
2958 for (Int_t js=index1; js < index2; js++) {
2959 const AliTPCclusterMI *kcl = kr2[js];
2960 if (kcl->IsUsed(10)) continue;
2962 //calcutate parameters
2964 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2966 if (TMath::Abs(yy0)<0.000001) continue;
2967 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2968 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2969 Double_t r02 = (0.25+y0*y0)*dvertex2;
2970 //curvature (radius) cut
2971 if (r02<r2min) continue;
2975 Double_t c0 = 1/TMath::Sqrt(r02);
2979 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2980 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2981 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2982 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2985 Double_t z0 = kcl->GetZ();
2986 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2987 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2990 Double_t dip = (z1-z0)*c0/dfi1;
2991 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
3002 x2= xx2*cs-y2*sn*dsec;
3003 y2=+xx2*sn*dsec+y2*cs;
3013 // do we have cluster at the middle ?
3015 GetProlongation(x1,xm,x,ym,zm);
3017 AliTPCclusterMI * cm=0;
3018 if (TMath::Abs(ym)-ymaxm<0){
3019 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
3020 if ((!cm) || (cm->IsUsed(10))) {
3025 // rotate y1 to system 0
3026 // get state vector in rotated system
3027 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
3028 Double_t xr2 = x0*cs+yr1*sn*dsec;
3029 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
3031 GetProlongation(xx2,xm,xr,ym,zm);
3032 if (TMath::Abs(ym)-ymaxm<0){
3033 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
3034 if ((!cm) || (cm->IsUsed(10))) {
3044 dym = ym - cm->GetY();
3045 dzm = zm - cm->GetZ();
3052 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
3053 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
3054 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
3055 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3056 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
3058 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3059 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3060 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3061 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3062 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3063 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3065 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3066 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3067 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3068 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3072 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3073 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3074 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3075 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3076 c[13]=f30*sy1*f40+f32*sy2*f42;
3077 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3079 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3081 UInt_t index=kr1.GetIndex(is);
3082 AliTPCseed *track=new(seed) AliTPCseed(x1, ns*alpha+shift, x, c, index);
3084 track->SetIsSeeding(kTRUE);
3085 track->SetSeed1(i1);
3086 track->SetSeed2(i2);
3087 track->SetSeedType(3);
3091 FollowProlongation(*track, (i1+i2)/2,1);
3092 Int_t foundable,found,shared;
3093 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3094 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3096 seed->~AliTPCseed();
3102 FollowProlongation(*track, i2,1);
3106 track->SetBConstrain(1);
3107 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3108 track->SetLastPoint(i1); // first cluster in track position
3109 track->SetFirstPoint(track->GetLastPoint());
3111 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3112 track->GetNumberOfClusters() < track->GetNFoundable()*0.6 ||
3113 track->GetNShared()>0.4*track->GetNumberOfClusters() ) {
3115 seed->~AliTPCseed();
3119 // Z VERTEX CONDITION
3120 Double_t zv, bz=GetBz();
3121 if ( !track->GetZAt(0.,bz,zv) ) continue;
3122 if (TMath::Abs(zv-z3)>cuts[2]) {
3123 FollowProlongation(*track, TMath::Max(i2-20,0));
3124 if ( !track->GetZAt(0.,bz,zv) ) continue;
3125 if (TMath::Abs(zv-z3)>cuts[2]){
3126 FollowProlongation(*track, TMath::Max(i2-40,0));
3127 if ( !track->GetZAt(0.,bz,zv) ) continue;
3128 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->GetNFoundable()*0.7)){
3129 // make seed without constrain
3130 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3131 FollowProlongation(*track2, i2,1);
3132 track2->SetBConstrain(kFALSE);
3133 track2->SetSeedType(1);
3134 arr->AddLast(track2);
3136 seed->~AliTPCseed();
3141 seed->~AliTPCseed();
3148 track->SetSeedType(0);
3149 arr->AddLast(track);
3150 seed = new AliTPCseed;
3152 // don't consider other combinations
3153 if (track->GetNumberOfClusters() > track->GetNFoundable()*0.8)
3159 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3165 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3170 //-----------------------------------------------------------------
3171 // This function creates track seeds.
3172 //-----------------------------------------------------------------
3173 // cuts[0] - fP4 cut
3174 // cuts[1] - tan(phi) cut
3175 // cuts[2] - zvertex cut
3176 // cuts[3] - fP3 cut
3186 Double_t x[5], c[15];
3188 // make temporary seed
3189 AliTPCseed * seed = new AliTPCseed;
3190 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3191 // Double_t cs=cos(alpha), sn=sin(alpha);
3196 Double_t x1 = GetXrow(i1-1);
3197 const AliTPCRow& kr1=GetRow(sec,i1-1);
3198 Double_t y1max = GetMaxY(i1-1)-kr1.GetDeadZone()-1.5;
3200 Double_t x1p = GetXrow(i1);
3201 const AliTPCRow& kr1p=GetRow(sec,i1);
3203 Double_t x1m = GetXrow(i1-2);
3204 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3207 //last 3 padrow for seeding
3208 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3209 Double_t x3 = GetXrow(i1-7);
3210 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3212 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3213 Double_t x3p = GetXrow(i1-6);
3215 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3216 Double_t x3m = GetXrow(i1-8);
3221 Int_t im = i1-4; //middle pad row index
3222 Double_t xm = GetXrow(im); // radius of middle pad-row
3223 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3224 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3227 Double_t deltax = x1-x3;
3228 Double_t dymax = deltax*cuts[1];
3229 Double_t dzmax = deltax*cuts[3];
3231 // loop over clusters
3232 for (Int_t is=0; is < kr1; is++) {
3234 if (kr1[is]->IsUsed(10)) continue;
3235 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3237 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3239 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3240 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3246 for (Int_t js=index1; js < index2; js++) {
3247 const AliTPCclusterMI *kcl = kr3[js];
3248 if (kcl->IsUsed(10)) continue;
3250 // apply angular cuts
3251 if (TMath::Abs(y1-y3)>dymax) continue;
3254 if (TMath::Abs(z1-z3)>dzmax) continue;
3256 Double_t angley = (y1-y3)/(x1-x3);
3257 Double_t anglez = (z1-z3)/(x1-x3);
3259 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3260 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3262 Double_t yyym = angley*(xm-x1)+y1;
3263 Double_t zzzm = anglez*(xm-x1)+z1;
3265 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3267 if (kcm->IsUsed(10)) continue;
3269 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3270 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3277 // look around first
3278 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3284 if (kc1m->IsUsed(10)) used++;
3286 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3292 if (kc1p->IsUsed(10)) used++;
3294 if (used>1) continue;
3295 if (found<1) continue;
3299 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3305 if (kc3m->IsUsed(10)) used++;
3309 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3315 if (kc3p->IsUsed(10)) used++;
3319 if (used>1) continue;
3320 if (found<3) continue;
3330 x[4]=F1(x1,y1,x2,y2,x3,y3);
3331 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3334 x[2]=F2(x1,y1,x2,y2,x3,y3);
3337 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3338 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3342 Double_t sy1=0.1, sz1=0.1;
3343 Double_t sy2=0.1, sz2=0.1;
3344 Double_t sy3=0.1, sy=0.1, sz=0.1;
3346 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3347 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3348 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3349 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3350 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3351 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3353 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3354 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3355 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3356 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3360 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3361 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3362 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3363 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3364 c[13]=f30*sy1*f40+f32*sy2*f42;
3365 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3367 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3369 UInt_t index=kr1.GetIndex(is);
3370 AliTPCseed *track=new(seed) AliTPCseed(x1, sec*alpha+shift, x, c, index);
3372 track->SetIsSeeding(kTRUE);
3375 FollowProlongation(*track, i1-7,1);
3376 if (track->GetNumberOfClusters() < track->GetNFoundable()*0.75 ||
3377 track->GetNShared()>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3379 seed->~AliTPCseed();
3385 FollowProlongation(*track, i2,1);
3386 track->SetBConstrain(0);
3387 track->SetLastPoint(i1+fInnerSec->GetNRows()); // first cluster in track position
3388 track->SetFirstPoint(track->GetLastPoint());
3390 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3391 track->GetNumberOfClusters()<track->GetNFoundable()*0.7 ||
3392 track->GetNShared()>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3394 seed->~AliTPCseed();
3399 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3400 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3401 FollowProlongation(*track2, i2,1);
3402 track2->SetBConstrain(kFALSE);
3403 track2->SetSeedType(4);
3404 arr->AddLast(track2);
3406 seed->~AliTPCseed();
3410 //arr->AddLast(track);
3411 //seed = new AliTPCseed;
3417 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3423 //_____________________________________________________________________________
3424 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3425 Float_t deltay, Bool_t /*bconstrain*/) {
3426 //-----------------------------------------------------------------
3427 // This function creates track seeds - without vertex constraint
3428 //-----------------------------------------------------------------
3429 // cuts[0] - fP4 cut - not applied
3430 // cuts[1] - tan(phi) cut
3431 // cuts[2] - zvertex cut - not applied
3432 // cuts[3] - fP3 cut
3442 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3443 // Double_t cs=cos(alpha), sn=sin(alpha);
3444 Int_t row0 = (i1+i2)/2;
3445 Int_t drow = (i1-i2)/2;
3446 const AliTPCRow& kr0=fSectors[sec][row0];
3449 AliTPCpolyTrack polytrack;
3450 Int_t nclusters=fSectors[sec][row0];
3451 AliTPCseed * seed = new AliTPCseed;
3456 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3458 Int_t nfoundable =0;
3459 for (Int_t iter =1; iter<2; iter++){ //iterations
3460 const AliTPCRow& krm=fSectors[sec][row0-iter];
3461 const AliTPCRow& krp=fSectors[sec][row0+iter];
3462 const AliTPCclusterMI * cl= kr0[is];
3464 if (cl->IsUsed(10)) {
3470 Double_t x = kr0.GetX();
3471 // Initialization of the polytrack
3476 Double_t y0= cl->GetY();
3477 Double_t z0= cl->GetZ();
3481 Double_t ymax = fSectors->GetMaxY(row0)-kr0.GetDeadZone()-1.5;
3482 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3484 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3485 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3486 polytrack.AddPoint(x,y0,z0,erry, errz);
3489 if (cl->IsUsed(10)) sumused++;
3492 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3493 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3496 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3497 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3498 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3499 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3500 if (cl1->IsUsed(10)) sumused++;
3501 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3505 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3507 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3508 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3509 if (cl2->IsUsed(10)) sumused++;
3510 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3513 if (sumused>0) continue;
3515 polytrack.UpdateParameters();
3521 nfoundable = polytrack.GetN();
3522 nfound = nfoundable;
3524 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3525 Float_t maxdist = 0.8*(1.+3./(ddrow));
3526 for (Int_t delta = -1;delta<=1;delta+=2){
3527 Int_t row = row0+ddrow*delta;
3528 kr = &(fSectors[sec][row]);
3529 Double_t xn = kr->GetX();
3530 Double_t ymax = fSectors->GetMaxY(row)-kr->GetDeadZone()-1.5;
3531 polytrack.GetFitPoint(xn,yn,zn);
3532 if (TMath::Abs(yn)>ymax) continue;
3534 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3536 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3539 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3540 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3541 if (cln->IsUsed(10)) {
3542 // printf("used\n");
3550 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3555 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3556 polytrack.UpdateParameters();
3559 if ( (sumused>3) || (sumused>0.5*nfound)) {
3560 //printf("sumused %d\n",sumused);
3565 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3566 AliTPCpolyTrack track2;
3568 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3569 if (track2.GetN()<0.5*nfoundable) continue;
3572 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3574 // test seed with and without constrain
3575 for (Int_t constrain=0; constrain<=0;constrain++){
3576 // add polytrack candidate
3578 Double_t x[5], c[15];
3579 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3580 track2.GetBoundaries(x3,x1);
3582 track2.GetFitPoint(x1,y1,z1);
3583 track2.GetFitPoint(x2,y2,z2);
3584 track2.GetFitPoint(x3,y3,z3);
3586 //is track pointing to the vertex ?
3589 polytrack.GetFitPoint(x0,y0,z0);
3602 x[4]=F1(x1,y1,x2,y2,x3,y3);
3604 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3605 x[2]=F2(x1,y1,x2,y2,x3,y3);
3607 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3608 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3609 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3610 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3613 Double_t sy =0.1, sz =0.1;
3614 Double_t sy1=0.02, sz1=0.02;
3615 Double_t sy2=0.02, sz2=0.02;
3619 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3622 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3623 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3624 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3625 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3626 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3627 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3629 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3630 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3631 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3632 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3637 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3638 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3639 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3640 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3641 c[13]=f30*sy1*f40+f32*sy2*f42;
3642 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3644 //Int_t row1 = fSectors->GetRowNumber(x1);
3645 Int_t row1 = GetRowNumber(x1);
3649 AliTPCseed *track=new (seed) AliTPCseed(x1,sec*alpha+shift,x,c,index);
3650 track->SetIsSeeding(kTRUE);
3651 Int_t rc=FollowProlongation(*track, i2);
3652 if (constrain) track->SetBConstrain(1);
3654 track->SetBConstrain(0);
3655 track->SetLastPoint(row1+fInnerSec->GetNRows()); // first cluster in track position
3656 track->SetFirstPoint(track->GetLastPoint());
3658 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3659 track->GetNumberOfClusters() < track->GetNFoundable()*0.6 ||
3660 track->GetNShared()>0.4*track->GetNumberOfClusters()) {
3663 seed->~AliTPCseed();
3666 arr->AddLast(track);
3667 seed = new AliTPCseed;
3671 } // if accepted seed
3674 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3680 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3684 //reseed using track points
3685 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3686 Int_t p1 = int(r1*track->GetNumberOfClusters());
3687 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3689 Double_t x0[3],x1[3],x2[3];
3690 for (Int_t i=0;i<3;i++){
3696 // find track position at given ratio of the length
3697 Int_t sec0=0, sec1=0, sec2=0;
3700 for (Int_t i=0;i<160;i++){
3701 if (track->GetClusterPointer(i)){
3703 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3704 if ( (index<p0) || x0[0]<0 ){
3705 if (trpoint->GetX()>1){
3706 clindex = track->GetClusterIndex2(i);
3708 x0[0] = trpoint->GetX();
3709 x0[1] = trpoint->GetY();
3710 x0[2] = trpoint->GetZ();
3711 sec0 = ((clindex&0xff000000)>>24)%18;
3716 if ( (index<p1) &&(trpoint->GetX()>1)){
3717 clindex = track->GetClusterIndex2(i);
3719 x1[0] = trpoint->GetX();
3720 x1[1] = trpoint->GetY();
3721 x1[2] = trpoint->GetZ();
3722 sec1 = ((clindex&0xff000000)>>24)%18;
3725 if ( (index<p2) &&(trpoint->GetX()>1)){
3726 clindex = track->GetClusterIndex2(i);
3728 x2[0] = trpoint->GetX();
3729 x2[1] = trpoint->GetY();
3730 x2[2] = trpoint->GetZ();
3731 sec2 = ((clindex&0xff000000)>>24)%18;
3738 Double_t alpha, cs,sn, xx2,yy2;
3740 alpha = (sec1-sec2)*fSectors->GetAlpha();
3741 cs = TMath::Cos(alpha);
3742 sn = TMath::Sin(alpha);
3743 xx2= x1[0]*cs-x1[1]*sn;
3744 yy2= x1[0]*sn+x1[1]*cs;
3748 alpha = (sec0-sec2)*fSectors->GetAlpha();
3749 cs = TMath::Cos(alpha);
3750 sn = TMath::Sin(alpha);
3751 xx2= x0[0]*cs-x0[1]*sn;
3752 yy2= x0[0]*sn+x0[1]*cs;
3758 Double_t x[5],c[15];
3762 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3763 // if (x[4]>1) return 0;
3764 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3765 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3766 //if (TMath::Abs(x[3]) > 2.2) return 0;
3767 //if (TMath::Abs(x[2]) > 1.99) return 0;
3769 Double_t sy =0.1, sz =0.1;
3771 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3772 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3773 Double_t sy3=0.01+track->GetSigmaY2();
3775 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3776 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3777 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3778 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3779 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3780 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3782 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3783 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3784 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3785 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3790 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3791 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3792 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3793 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3794 c[13]=f30*sy1*f40+f32*sy2*f42;
3795 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3797 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3798 AliTPCseed *seed=new AliTPCseed(x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3799 // Double_t y0,z0,y1,z1, y2,z2;
3800 //seed->GetProlongation(x0[0],y0,z0);
3801 // seed->GetProlongation(x1[0],y1,z1);
3802 //seed->GetProlongation(x2[0],y2,z2);
3804 seed->SetLastPoint(pp2);
3805 seed->SetFirstPoint(pp2);
3812 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3816 //reseed using founded clusters
3818 // Find the number of clusters
3819 Int_t nclusters = 0;
3820 for (Int_t irow=0;irow<160;irow++){
3821 if (track->GetClusterIndex(irow)>0) nclusters++;
3825 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3826 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3827 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3831 Int_t row[3],sec[3]={0,0,0};
3833 // find track row position at given ratio of the length
3835 for (Int_t irow=0;irow<160;irow++){
3836 if (track->GetClusterIndex2(irow)<0) continue;
3838 for (Int_t ipoint=0;ipoint<3;ipoint++){
3839 if (index<=ipos[ipoint]) row[ipoint] = irow;
3843 //Get cluster and sector position
3844 for (Int_t ipoint=0;ipoint<3;ipoint++){
3845 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3846 AliTPCclusterMI * cl = GetClusterMI(clindex);
3849 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3852 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3853 xyz[ipoint][0] = GetXrow(row[ipoint]);
3854 xyz[ipoint][1] = cl->GetY();
3855 xyz[ipoint][2] = cl->GetZ();
3859 // Calculate seed state vector and covariance matrix
3861 Double_t alpha, cs,sn, xx2,yy2;
3863 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3864 cs = TMath::Cos(alpha);
3865 sn = TMath::Sin(alpha);
3866 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3867 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3871 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3872 cs = TMath::Cos(alpha);
3873 sn = TMath::Sin(alpha);
3874 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3875 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3881 Double_t x[5],c[15];
3885 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3886 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3887 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3889 Double_t sy =0.1, sz =0.1;
3891 Double_t sy1=0.2, sz1=0.2;
3892 Double_t sy2=0.2, sz2=0.2;
3895 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;
3896 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;
3897 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;
3898 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;
3899 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;
3900 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;
3902 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;
3903 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;
3904 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;
3905 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;
3910 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3911 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3912 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3913 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3914 c[13]=f30*sy1*f40+f32*sy2*f42;
3915 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3917 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3918 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3919 seed->SetLastPoint(row[2]);
3920 seed->SetFirstPoint(row[2]);
3925 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3929 //reseed using founded clusters
3932 Int_t row[3]={0,0,0};
3933 Int_t sec[3]={0,0,0};
3935 // forward direction
3937 for (Int_t irow=r0;irow<160;irow++){
3938 if (track->GetClusterIndex(irow)>0){
3943 for (Int_t irow=160;irow>r0;irow--){
3944 if (track->GetClusterIndex(irow)>0){
3949 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3950 if (track->GetClusterIndex(irow)>0){
3958 for (Int_t irow=0;irow<r0;irow++){
3959 if (track->GetClusterIndex(irow)>0){
3964 for (Int_t irow=r0;irow>0;irow--){
3965 if (track->GetClusterIndex(irow)>0){
3970 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3971 if (track->GetClusterIndex(irow)>0){
3978 if ((row[2]-row[0])<20) return 0;
3979 if (row[1]==0) return 0;
3982 //Get cluster and sector position
3983 for (Int_t ipoint=0;ipoint<3;ipoint++){
3984 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3985 AliTPCclusterMI * cl = GetClusterMI(clindex);
3988 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3991 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3992 xyz[ipoint][0] = GetXrow(row[ipoint]);
3993 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3994 if (point&&ipoint<2){
3996 xyz[ipoint][1] = point->GetY();
3997 xyz[ipoint][2] = point->GetZ();
4000 xyz[ipoint][1] = cl->GetY();
4001 xyz[ipoint][2] = cl->GetZ();
4008 // Calculate seed state vector and covariance matrix
4010 Double_t alpha, cs,sn, xx2,yy2;
4012 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
4013 cs = TMath::Cos(alpha);
4014 sn = TMath::Sin(alpha);
4015 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
4016 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
4020 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
4021 cs = TMath::Cos(alpha);
4022 sn = TMath::Sin(alpha);
4023 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
4024 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
4030 Double_t x[5],c[15];
4034 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
4035 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
4036 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
4038 Double_t sy =0.1, sz =0.1;
4040 Double_t sy1=0.2, sz1=0.2;
4041 Double_t sy2=0.2, sz2=0.2;
4044 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;
4045 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;
4046 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;
4047 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;
4048 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;
4049 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;
4051 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;
4052 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;
4053 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;
4054 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;
4059 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
4060 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
4061 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
4062 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
4063 c[13]=f30*sy1*f40+f32*sy2*f42;
4064 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
4066 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
4067 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
4068 seed->SetLastPoint(row[2]);
4069 seed->SetFirstPoint(row[2]);
4070 for (Int_t i=row[0];i<row[2];i++){
4071 seed->SetClusterIndex(i, track->GetClusterIndex(i));
4077 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4084 TObjArray *kinks= new TObjArray(10000);
4085 // TObjArray *v0s= new TObjArray(10000);
4086 Int_t nentries = array->GetEntriesFast();
4087 AliHelix *helixes = new AliHelix[nentries];
4088 Int_t *sign = new Int_t[nentries];
4089 Int_t *nclusters = new Int_t[nentries];
4090 Float_t *alpha = new Float_t[nentries];
4091 AliKink *kink = new AliKink();
4092 Int_t * usage = new Int_t[nentries];
4093 Float_t *zm = new Float_t[nentries];
4094 Float_t *z0 = new Float_t[nentries];
4095 Float_t *fim = new Float_t[nentries];
4096 Float_t *shared = new Float_t[nentries];
4097 Bool_t *circular = new Bool_t[nentries];
4098 Float_t *dca = new Float_t[nentries];
4099 //const AliESDVertex * primvertex = esd->GetVertex();
4101 // nentries = array->GetEntriesFast();
4106 for (Int_t i=0;i<nentries;i++){
4109 AliTPCseed* track = (AliTPCseed*)array->At(i);
4110 if (!track) continue;
4111 track->SetCircular(0);
4113 track->UpdatePoints();
4114 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4116 nclusters[i]=track->GetNumberOfClusters();
4117 alpha[i] = track->GetAlpha();
4118 new (&helixes[i]) AliHelix(*track);
4120 helixes[i].Evaluate(0,xyz);
4121 sign[i] = (track->GetC()>0) ? -1:1;
4124 if (track->GetProlongation(x,y,z)){
4126 fim[i] = alpha[i]+TMath::ATan2(y,x);
4129 zm[i] = track->GetZ();
4133 circular[i]= kFALSE;
4134 if (track->GetProlongation(0,y,z)) z0[i] = z;
4135 dca[i] = track->GetD(0,0);
4141 Int_t ncandidates =0;
4144 Double_t phase[2][2],radius[2];
4147 // Find circling track
4148 TTreeSRedirector &cstream = *fDebugStreamer;
4150 for (Int_t i0=0;i0<nentries;i0++){
4151 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4152 if (!track0) continue;
4153 if (track0->GetNumberOfClusters()<40) continue;
4154 if (TMath::Abs(1./track0->GetC())>200) continue;
4155 for (Int_t i1=i0+1;i1<nentries;i1++){
4156 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4157 if (!track1) continue;
4158 if (track1->GetNumberOfClusters()<40) continue;
4159 if ( TMath::Abs(track1->GetTgl()+track0->GetTgl())>0.1) continue;
4160 if (track0->GetBConstrain()&&track1->GetBConstrain()) continue;
4161 if (TMath::Abs(1./track1->GetC())>200) continue;
4162 if (track1->Get1Pt()*track0->Get1Pt()>0) continue;
4163 if (track1->GetTgl()*track0->GetTgl()>0) continue;
4164 if (max(TMath::Abs(1./track0->GetC()),TMath::Abs(1./track1->GetC()))>190) continue;
4165 if (track0->GetBConstrain()&&TMath::Abs(track1->Get1Pt())<TMath::Abs(track0->Get1Pt())) continue; //returning - lower momenta
4166 if (track1->GetBConstrain()&&TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())) continue; //returning - lower momenta
4168 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4169 if (mindcar<5) continue;
4170 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4171 if (mindcaz<5) continue;
4172 if (mindcar+mindcaz<20) continue;
4175 Float_t xc0 = helixes[i0].GetHelix(6);
4176 Float_t yc0 = helixes[i0].GetHelix(7);
4177 Float_t r0 = helixes[i0].GetHelix(8);
4178 Float_t xc1 = helixes[i1].GetHelix(6);
4179 Float_t yc1 = helixes[i1].GetHelix(7);
4180 Float_t r1 = helixes[i1].GetHelix(8);
4182 Float_t rmean = (r0+r1)*0.5;
4183 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4184 //if (delta>30) continue;
4185 if (delta>rmean*0.25) continue;
4186 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4188 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4189 if (npoints==0) continue;
4190 helixes[i0].GetClosestPhases(helixes[i1], phase);
4194 Double_t hangles[3];
4195 helixes[i0].Evaluate(phase[0][0],xyz0);
4196 helixes[i1].Evaluate(phase[0][1],xyz1);
4198 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4199 Double_t deltah[2],deltabest;
4200 if (hangles[2]<2.8) continue;
4202 cstream<<"C"<<track0->fLab<<track1->fLab<<
4203 track0->fP3<<track1->fP3<<
4204 track0->fP4<<track1->fP4<<
4205 delta<<rmean<<npoints<<
4206 hangles[0]<<hangles[2]<<
4207 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4211 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4213 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4214 if (deltah[1]<deltah[0]) ibest=1;
4216 deltabest = TMath::Sqrt(deltah[ibest]);
4217 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4218 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4219 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4220 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4222 if (deltabest>6) continue;
4223 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4224 Bool_t sign =kFALSE;
4225 if (hangles[2]>3.06) sign =kTRUE;
4228 circular[i0] = kTRUE;
4229 circular[i1] = kTRUE;
4230 if (TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())){
4231 track0->SetCircular(track0->GetCircular()+1);
4232 track1->SetCircular(track1->GetCircular()+2);
4235 track1->SetCircular(track1->GetCircular()+1);
4236 track0->SetCircular(track0->GetCircular()+2);
4239 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4241 Int_t lab0=track0->GetLabel();
4242 Int_t lab1=track1->GetLabel();
4243 cstream<<"Curling"<<
4250 "mindcar="<<mindcar<<
4251 "mindcaz="<<mindcaz<<
4254 "npoints="<<npoints<<
4255 "hangles0="<<hangles[0]<<
4256 "hangles2="<<hangles[2]<<
4261 "radius="<<radiusbest<<
4262 "deltabest="<<deltabest<<
4263 "phase0="<<phase[ibest][0]<<
4264 "phase1="<<phase[ibest][1]<<
4274 for (Int_t i =0;i<nentries;i++){
4275 if (sign[i]==0) continue;
4276 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4279 Double_t cradius0 = 40*40;
4280 Double_t cradius1 = 270*270;
4283 Double_t cdist3=0.55;
4284 for (Int_t j =i+1;j<nentries;j++){
4286 if (sign[j]*sign[i]<1) continue;
4287 if ( (nclusters[i]+nclusters[j])>200) continue;
4288 if ( (nclusters[i]+nclusters[j])<80) continue;
4289 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4290 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4291 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4292 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4293 if (npoints<1) continue;
4296 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4299 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4302 Double_t delta1=10000,delta2=10000;
4303 // cuts on the intersection radius
4304 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4305 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4306 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4308 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4309 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4310 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4313 Double_t distance1 = TMath::Min(delta1,delta2);
4314 if (distance1>cdist1) continue; // cut on DCA linear approximation
4316 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4317 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4318 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4319 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4322 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4323 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4324 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4326 distance1 = TMath::Min(delta1,delta2);
4329 rkink = TMath::Sqrt(radius[0]);
4332 rkink = TMath::Sqrt(radius[1]);
4334 if (distance1>cdist2) continue;
4337 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4340 Int_t row0 = GetRowNumber(rkink);
4341 if (row0<10) continue;
4342 if (row0>150) continue;
4345 Float_t dens00=-1,dens01=-1;
4346 Float_t dens10=-1,dens11=-1;
4348 Int_t found,foundable,shared;
4349 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4350 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4351 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4352 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4354 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4355 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4356 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4357 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4359 if (dens00<dens10 && dens01<dens11) continue;
4360 if (dens00>dens10 && dens01>dens11) continue;
4361 if (TMath::Max(dens00,dens10)<0.1) continue;
4362 if (TMath::Max(dens01,dens11)<0.3) continue;
4364 if (TMath::Min(dens00,dens10)>0.6) continue;
4365 if (TMath::Min(dens01,dens11)>0.6) continue;
4368 AliTPCseed * ktrack0, *ktrack1;
4377 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4378 AliExternalTrackParam paramm(*ktrack0);
4379 AliExternalTrackParam paramd(*ktrack1);
4380 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4383 kink->SetMother(paramm);
4384 kink->SetDaughter(paramd);
4387 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4389 fParam->Transform0to1(x,index);
4390 fParam->Transform1to2(x,index);
4391 row0 = GetRowNumber(x[0]);
4393 if (kink->GetR()<100) continue;
4394 if (kink->GetR()>240) continue;
4395 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4396 if (kink->GetDistance()>cdist3) continue;
4397 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4398 if (dird<0) continue;
4400 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4401 if (dirm<0) continue;
4402 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4403 if (mpt<0.2) continue;
4406 //for high momenta momentum not defined well in first iteration
4407 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->GetP();
4408 if (qt>0.35) continue;
4411 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4412 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4414 kink->SetTPCDensity(dens00,0,0);
4415 kink->SetTPCDensity(dens01,0,1);
4416 kink->SetTPCDensity(dens10,1,0);
4417 kink->SetTPCDensity(dens11,1,1);
4418 kink->SetIndex(i,0);
4419 kink->SetIndex(j,1);
4422 kink->SetTPCDensity(dens10,0,0);
4423 kink->SetTPCDensity(dens11,0,1);
4424 kink->SetTPCDensity(dens00,1,0);
4425 kink->SetTPCDensity(dens01,1,1);
4426 kink->SetIndex(j,0);
4427 kink->SetIndex(i,1);
4430 if (mpt<1||kink->GetAngle(2)>0.1){
4431 // angle and densities not defined yet
4432 if (kink->GetTPCDensityFactor()<0.8) continue;
4433 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4434 if (kink->GetAngle(2)*ktrack0->GetP()<0.003) continue; //too small angle
4435 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4436 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4438 Float_t criticalangle = track0->GetSigmaSnp2()+track0->GetSigmaTgl2();
4439 criticalangle+= track1->GetSigmaSnp2()+track1->GetSigmaTgl2();
4440 criticalangle= 3*TMath::Sqrt(criticalangle);
4441 if (criticalangle>0.02) criticalangle=0.02;
4442 if (kink->GetAngle(2)<criticalangle) continue;
4445 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4446 Float_t shapesum =0;
4448 for ( Int_t row = row0-drow; row<row0+drow;row++){
4449 if (row<0) continue;
4450 if (row>155) continue;
4451 if (ktrack0->GetClusterPointer(row)){
4452 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4453 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4456 if (ktrack1->GetClusterPointer(row)){
4457 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4458 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4463 kink->SetShapeFactor(-1.);
4466 kink->SetShapeFactor(shapesum/sum);
4468 // esd->AddKink(kink);
4469 kinks->AddLast(kink);
4475 // sort the kinks according quality - and refit them towards vertex
4477 Int_t nkinks = kinks->GetEntriesFast();
4478 Float_t *quality = new Float_t[nkinks];
4479 Int_t *indexes = new Int_t[nkinks];
4480 AliTPCseed *mothers = new AliTPCseed[nkinks];
4481 AliTPCseed *daughters = new AliTPCseed[nkinks];
4484 for (Int_t i=0;i<nkinks;i++){
4486 AliKink *kink = (AliKink*)kinks->At(i);
4488 // refit kinks towards vertex
4490 Int_t index0 = kink->GetIndex(0);
4491 Int_t index1 = kink->GetIndex(1);
4492 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4493 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4495 Int_t sumn=ktrack0->GetNumberOfClusters()+ktrack1->GetNumberOfClusters();
4497 // Refit Kink under if too small angle
4499 if (kink->GetAngle(2)<0.05){
4500 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4501 Int_t row0 = kink->GetTPCRow0();
4502 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4505 Int_t last = row0-drow;
4506 if (last<40) last=40;
4507 if (last<ktrack0->GetFirstPoint()+25) last = ktrack0->GetFirstPoint()+25;
4508 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4511 Int_t first = row0+drow;
4512 if (first>130) first=130;
4513 if (first>ktrack1->GetLastPoint()-25) first = TMath::Max(ktrack1->GetLastPoint()-25,30);
4514 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4516 if (seed0 && seed1){
4517 kink->SetStatus(1,8);
4518 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4519 row0 = GetRowNumber(kink->GetR());
4520 sumn = seed0->GetNumberOfClusters()+seed1->GetNumberOfClusters();
4521 new (&mothers[i]) AliTPCseed(*seed0);
4522 new (&daughters[i]) AliTPCseed(*seed1);
4525 delete kinks->RemoveAt(i);
4526 if (seed0) delete seed0;
4527 if (seed1) delete seed1;
4530 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4531 delete kinks->RemoveAt(i);
4532 if (seed0) delete seed0;
4533 if (seed1) delete seed1;
4541 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4543 TMath::Sort(nkinks,quality,indexes,kFALSE);
4545 //remove double find kinks
4547 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4548 AliKink * kink0 = (AliKink*) kinks->At(indexes[ikink0]);
4549 if (!kink0) continue;
4551 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4552 if (!kink0) continue;
4553 AliKink * kink1 = (AliKink*) kinks->At(indexes[ikink1]);
4554 if (!kink1) continue;
4555 // if not close kink continue
4556 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4557 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4558 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4560 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4561 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4562 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4563 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4564 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4573 for (Int_t i=0;i<row0;i++){
4574 if (mother0.GetClusterIndex(i)>0 && mother1.GetClusterIndex(i)>0){
4577 if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
4584 for (Int_t i=row0;i<158;i++){
4585 if (daughter0.GetClusterIndex(i)>0 && daughter0.GetClusterIndex(i)>0){
4588 if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
4594 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4595 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4596 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4597 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4598 Int_t sum0 = mother0.GetNumberOfClusters()+daughter0.GetNumberOfClusters();
4599 Int_t sum1 = mother1.GetNumberOfClusters()+daughter1.GetNumberOfClusters();
4601 shared[kink0->GetIndex(0)]= kTRUE;
4602 shared[kink0->GetIndex(1)]= kTRUE;
4603 delete kinks->RemoveAt(indexes[ikink0]);
4606 shared[kink1->GetIndex(0)]= kTRUE;
4607 shared[kink1->GetIndex(1)]= kTRUE;
4608 delete kinks->RemoveAt(indexes[ikink1]);
4615 for (Int_t i=0;i<nkinks;i++){
4616 AliKink * kink = (AliKink*) kinks->At(indexes[i]);
4617 if (!kink) continue;
4618 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4619 Int_t index0 = kink->GetIndex(0);
4620 Int_t index1 = kink->GetIndex(1);
4621 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4622 kink->SetMultiple(usage[index0],0);
4623 kink->SetMultiple(usage[index1],1);
4624 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4625 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4626 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4627 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4629 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4630 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4631 if (!ktrack0 || !ktrack1) continue;
4632 Int_t index = esd->AddKink(kink);
4635 if ( ktrack0->GetKinkIndex(0)==0 && ktrack1->GetKinkIndex(0)==0) { //best kink
4636 if (mothers[indexes[i]].GetNumberOfClusters()>20 && daughters[indexes[i]].GetNumberOfClusters()>20 && (mothers[indexes[i]].GetNumberOfClusters()+daughters[indexes[i]].GetNumberOfClusters())>100){
4637 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4638 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4642 ktrack0->SetKinkIndex(usage[index0],-(index+1));
4643 ktrack1->SetKinkIndex(usage[index1], (index+1));
4648 // Remove tracks corresponding to shared kink's
4650 for (Int_t i=0;i<nentries;i++){
4651 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4652 if (!track0) continue;
4653 if (track0->GetKinkIndex(0)!=0) continue;
4654 if (shared[i]) delete array->RemoveAt(i);
4659 RemoveUsed2(array,0.5,0.4,30);
4661 for (Int_t i=0;i<nentries;i++){
4662 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4663 if (!track0) continue;
4664 track0->CookdEdx(0.02,0.6);
4668 for (Int_t i=0;i<nentries;i++){
4669 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4670 if (!track0) continue;
4671 if (track0->GetPt()<1.4) continue;
4672 //remove double high momenta tracks - overlapped with kink candidates
4675 for (Int_t icl=track0->GetFirstPoint();icl<track0->GetLastPoint(); icl++){
4676 if (track0->GetClusterPointer(icl)!=0){
4678 if (track0->GetClusterPointer(icl)->IsUsed(10)) shared++;
4681 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4682 delete array->RemoveAt(i);
4686 if (track0->GetKinkIndex(0)!=0) continue;
4687 if (track0->GetNumberOfClusters()<80) continue;
4689 AliTPCseed *pmother = new AliTPCseed();
4690 AliTPCseed *pdaughter = new AliTPCseed();
4691 AliKink *pkink = new AliKink;
4693 AliTPCseed & mother = *pmother;
4694 AliTPCseed & daughter = *pdaughter;
4695 AliKink & kink = *pkink;
4696 if (CheckKinkPoint(track0,mother,daughter, kink)){
4697 if (mother.GetNumberOfClusters()<30||daughter.GetNumberOfClusters()<20) {
4701 continue; //too short tracks
4703 if (mother.GetPt()<1.4) {
4709 Int_t row0= kink.GetTPCRow0();
4710 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4717 Int_t index = esd->AddKink(&kink);
4718 mother.SetKinkIndex(0,-(index+1));
4719 daughter.SetKinkIndex(0,index+1);
4720 if (mother.GetNumberOfClusters()>50) {
4721 delete array->RemoveAt(i);
4722 array->AddAt(new AliTPCseed(mother),i);
4725 array->AddLast(new AliTPCseed(mother));
4727 array->AddLast(new AliTPCseed(daughter));
4728 for (Int_t icl=0;icl<row0;icl++) {
4729 if (mother.GetClusterPointer(icl)) mother.GetClusterPointer(icl)->Use(20);
4732 for (Int_t icl=row0;icl<158;icl++) {
4733 if (daughter.GetClusterPointer(icl)) daughter.GetClusterPointer(icl)->Use(20);
4742 delete [] daughters;
4764 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4768 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4774 TObjArray *tpcv0s = new TObjArray(100000);
4775 Int_t nentries = array->GetEntriesFast();
4776 AliHelix *helixes = new AliHelix[nentries];
4777 Int_t *sign = new Int_t[nentries];
4778 Float_t *alpha = new Float_t[nentries];
4779 Float_t *z0 = new Float_t[nentries];
4780 Float_t *dca = new Float_t[nentries];
4781 Float_t *sdcar = new Float_t[nentries];
4782 Float_t *cdcar = new Float_t[nentries];
4783 Float_t *pulldcar = new Float_t[nentries];
4784 Float_t *pulldcaz = new Float_t[nentries];
4785 Float_t *pulldca = new Float_t[nentries];
4786 Bool_t *isPrim = new Bool_t[nentries];
4787 const AliESDVertex * primvertex = esd->GetVertex();
4788 Double_t zvertex = primvertex->GetZv();
4790 // nentries = array->GetEntriesFast();
4792 for (Int_t i=0;i<nentries;i++){
4795 AliTPCseed* track = (AliTPCseed*)array->At(i);
4796 if (!track) continue;
4797 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4798 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4799 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4801 alpha[i] = track->GetAlpha();
4802 new (&helixes[i]) AliHelix(*track);
4804 helixes[i].Evaluate(0,xyz);
4805 sign[i] = (track->GetC()>0) ? -1:1;
4809 if (track->GetProlongation(0,y,z)) z0[i] = z;
4810 dca[i] = track->GetD(0,0);
4812 // dca error parrameterezation + pulls
4814 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->GetC())*(100*track->GetC()));
4815 if (TMath::Abs(track->GetTgl())>1) sdcar[i]*=2.5;
4816 cdcar[i] = TMath::Exp((TMath::Abs(track->GetC())-0.0106)*525.3);
4817 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4818 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4819 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4820 if (track->TPCrPID(1)+track->TPCrPID(2)+track->TPCrPID(3)>0.5) {
4821 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4823 if (track->TPCrPID(4)>0.5) {
4824 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4826 if (track->TPCrPID(0)>0.4) {
4827 isPrim[i]=kFALSE; //electron no sigma cut
4834 Int_t ncandidates =0;
4837 Double_t phase[2][2],radius[2];
4843 TTreeSRedirector &cstream = *fDebugStreamer;
4844 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4846 Double_t cradius0 = 10*10;
4847 Double_t cradius1 = 200*200;
4850 Double_t cpointAngle = 0.95;
4852 Double_t delta[2]={10000,10000};
4853 for (Int_t i =0;i<nentries;i++){
4854 if (sign[i]==0) continue;
4855 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4856 if (!track0) continue;
4857 if (AliTPCReconstructor::StreamLevel()>0){
4862 "zvertex="<<zvertex<<
4863 "sdcar0="<<sdcar[i]<<
4864 "cdcar0="<<cdcar[i]<<
4865 "pulldcar0="<<pulldcar[i]<<
4866 "pulldcaz0="<<pulldcaz[i]<<
4867 "pulldca0="<<pulldca[i]<<
4868 "isPrim="<<isPrim[i]<<
4872 if (track0->Get1Pt()<0) continue;
4873 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4875 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4880 for (Int_t j =0;j<nentries;j++){
4881 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4882 if (!track1) continue;
4883 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4884 if (sign[j]*sign[i]>0) continue;
4885 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4886 if (track0->GetCircular()+track1->GetCircular()>1) continue; //circling -returning track
4889 // DCA to prim vertex cut
4895 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4896 if (npoints<1) continue;
4900 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4901 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4902 if (delta[0]>cdist1) continue;
4905 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4906 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4907 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4908 if (delta[1]<delta[0]) iclosest=1;
4909 if (delta[iclosest]>cdist1) continue;
4911 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4912 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4914 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4915 if (pointAngle<cpointAngle) continue;
4917 Bool_t isGamma = kFALSE;
4918 vertex.SetP(*track0); //track0 - plus
4919 vertex.SetM(*track1); //track1 - minus
4920 vertex.Update(fprimvertex);
4921 if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4922 Double_t pointAngle2 = vertex.GetPointAngle();
4924 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4925 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4926 Float_t sigmae = 0.15*0.15;
4927 if (vertex.GetRr()<80)
4928 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4929 sigmae+= TMath::Sqrt(sigmae);
4930 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4931 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4932 Int_t row0 = GetRowNumber(vertex.GetRr());
4934 if (vertex.GetDist2()>0.2) continue;
4935 densb0 = track0->Density2(0,row0-5);
4936 densb1 = track1->Density2(0,row0-5);
4937 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4938 densa0 = track0->Density2(row0+5,row0+40);
4939 densa1 = track1->Density2(row0+5,row0+40);
4940 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4943 densa0 = track0->Density2(0,40); //cluster density
4944 densa1 = track1->Density2(0,40); //cluster density
4945 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4947 vertex.SetLab(0,track0->GetLabel());
4948 vertex.SetLab(1,track1->GetLabel());
4949 vertex.SetChi2After((densa0+densa1)*0.5);
4950 vertex.SetChi2Before((densb0+densb1)*0.5);
4951 vertex.SetIndex(0,i);
4952 vertex.SetIndex(1,j);
4953 vertex.SetStatus(1); // TPC v0 candidate
4954 vertex.SetRp(track0->TPCrPIDs());
4955 vertex.SetRm(track1->TPCrPIDs());
4956 tpcv0s->AddLast(new AliESDv0(vertex));
4959 Int_t eventNr = esd->GetEventNumber();
4960 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4961 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4962 if (AliTPCReconstructor::StreamLevel()>0) {
4963 Int_t lab0=track0->GetLabel();
4964 Int_t lab1=track1->GetLabel();
4965 Char_t c0=track0->GetCircular();
4966 Char_t c1=track1->GetCircular();
4969 "vertex.="<<&vertex<<
4972 "Helix0.="<<&helixes[i]<<
4975 "Helix1.="<<&helixes[j]<<
4976 "pointAngle="<<pointAngle<<
4977 "pointAngle2="<<pointAngle2<<
4982 "zvertex="<<zvertex<<
4985 "npoints="<<npoints<<
4986 "radius0="<<radius[0]<<
4987 "delta0="<<delta[0]<<
4988 "radius1="<<radius[1]<<
4989 "delta1="<<delta[1]<<
4990 "radiusm="<<radiusm<<
4992 "sdcar0="<<sdcar[i]<<
4993 "sdcar1="<<sdcar[j]<<
4994 "cdcar0="<<cdcar[i]<<
4995 "cdcar1="<<cdcar[j]<<
4996 "pulldcar0="<<pulldcar[i]<<
4997 "pulldcar1="<<pulldcar[j]<<
4998 "pulldcaz0="<<pulldcaz[i]<<
4999 "pulldcaz1="<<pulldcaz[j]<<
5000 "pulldca0="<<pulldca[i]<<
5001 "pulldca1="<<pulldca[j]<<
5011 Float_t *quality = new Float_t[ncandidates];
5012 Int_t *indexes = new Int_t[ncandidates];
5014 for (Int_t i=0;i<ncandidates;i++){
5016 AliESDv0 *v0 = (AliESDv0*)tpcv0s->At(i);
5017 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
5018 // quality[i] /= (0.5+v0->GetDist2());
5019 // quality[i] *= v0->GetChi2After(); //density factor
5020 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
5021 Int_t index0 = v0->GetIndex(0);
5022 Int_t index1 = v0->GetIndex(1);
5023 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
5024 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
5025 if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
5026 if (track0->TPCrPID(4)>0.9||track1->TPCrPID(4)>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
5029 TMath::Sort(ncandidates,quality,indexes,kTRUE);
5032 for (Int_t i=0;i<ncandidates;i++){
5033 AliESDv0 * v0 = (AliESDv0*)tpcv0s->At(indexes[i]);
5035 Int_t index0 = v0->GetIndex(0);
5036 Int_t index1 = v0->GetIndex(1);
5037 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
5038 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
5039 if (!track0||!track1) {
5043 Bool_t accept =kTRUE; //default accept
5044 Int_t *v0indexes0 = track0->GetV0Indexes();
5045 Int_t *v0indexes1 = track1->GetV0Indexes();
5047 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
5048 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
5049 if (v0indexes0[1]!=0) order0 =2;
5050 if (v0indexes1[1]!=0) order1 =2;
5052 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
5053 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
5055 AliESDv0 * v02 = v0;
5057 v0->SetOrder(0,order0);
5058 v0->SetOrder(1,order1);
5059 v0->SetOrder(1,order0+order1);
5060 v0->SetOnFlyStatus(kTRUE);
5061 Int_t index = esd->AddV0(v0);
5062 v02 = esd->GetV0(index);
5063 v0indexes0[order0]=index;
5064 v0indexes1[order1]=index;
5068 Int_t eventNr = esd->GetEventNumber();
5069 if (AliTPCReconstructor::StreamLevel()>0) {
5070 Int_t lab0=track0->GetLabel();
5071 Int_t lab1=track1->GetLabel();
5080 "dca0="<<dca[index0]<<
5081 "dca1="<<dca[index1]<<
5085 "quality="<<quality[i]<<
5086 "pulldca0="<<pulldca[index0]<<
5087 "pulldca1="<<pulldca[index1]<<
5111 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5115 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5118 // refit kink towards to the vertex
5121 AliKink &kink=(AliKink &)knk;
5123 Int_t row0 = GetRowNumber(kink.GetR());
5124 FollowProlongation(mother,0);
5125 mother.Reset(kFALSE);
5127 FollowProlongation(daughter,row0);
5128 daughter.Reset(kFALSE);
5129 FollowBackProlongation(daughter,158);
5130 daughter.Reset(kFALSE);
5131 Int_t first = TMath::Max(row0-20,30);
5132 Int_t last = TMath::Min(row0+20,140);
5134 const Int_t kNdiv =5;
5135 AliTPCseed param0[kNdiv]; // parameters along the track
5136 AliTPCseed param1[kNdiv]; // parameters along the track
5137 AliKink kinks[kNdiv]; // corresponding kink parameters
5140 for (Int_t irow=0; irow<kNdiv;irow++){
5141 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5143 // store parameters along the track
5145 for (Int_t irow=0;irow<kNdiv;irow++){
5146 FollowBackProlongation(mother, rows[irow]);
5147 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5148 new(¶m0[irow]) AliTPCseed(mother);
5149 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5153 for (Int_t irow=0; irow<kNdiv-1;irow++){
5154 if (param0[irow].GetNumberOfClusters()<kNdiv||param1[irow].GetNumberOfClusters()<kNdiv) continue;
5155 kinks[irow].SetMother(param0[irow]);
5156 kinks[irow].SetDaughter(param1[irow]);
5157 kinks[irow].Update();
5160 // choose kink with best "quality"
5162 Double_t mindist = 10000;
5163 for (Int_t irow=0;irow<kNdiv;irow++){
5164 if (param0[irow].GetNumberOfClusters()<20||param1[irow].GetNumberOfClusters()<20) continue;
5165 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5166 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5168 Float_t normdist = TMath::Abs(param0[irow].GetX()-kinks[irow].GetR())*(0.1+kink.GetDistance());
5169 normdist/= (param0[irow].GetNumberOfClusters()+param1[irow].GetNumberOfClusters()+40.);
5170 if (normdist < mindist){
5176 if (index==-1) return 0;
5179 param0[index].Reset(kTRUE);
5180 FollowProlongation(param0[index],0);
5182 new (&mother) AliTPCseed(param0[index]);
5183 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5185 kink.SetMother(mother);
5186 kink.SetDaughter(daughter);
5188 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5189 kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
5190 kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
5191 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5192 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5193 mother.SetLabel(kink.GetLabel(0));
5194 daughter.SetLabel(kink.GetLabel(1));
5200 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5202 // update Kink quality information for mother after back propagation
5204 if (seed->GetKinkIndex(0)>=0) return;
5205 for (Int_t ikink=0;ikink<3;ikink++){
5206 Int_t index = seed->GetKinkIndex(ikink);
5207 if (index>=0) break;
5208 index = TMath::Abs(index)-1;
5209 AliESDkink * kink = fEvent->GetKink(index);
5210 //kink->fTPCdensity2[0][0]=-1;
5211 //kink->fTPCdensity2[0][1]=-1;
5212 kink->SetTPCDensity2(-1,0,0);
5213 kink->SetTPCDensity2(1,0,1);
5215 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5216 if (row0<15) row0=15;
5218 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5219 if (row1>145) row1=145;
5221 Int_t found,foundable,shared;
5222 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5223 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5224 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5225 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5230 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5232 // update Kink quality information for daughter after refit
5234 if (seed->GetKinkIndex(0)<=0) return;
5235 for (Int_t ikink=0;ikink<3;ikink++){
5236 Int_t index = seed->GetKinkIndex(ikink);
5237 if (index<=0) break;
5238 index = TMath::Abs(index)-1;
5239 AliESDkink * kink = fEvent->GetKink(index);
5240 kink->SetTPCDensity2(-1,1,0);
5241 kink->SetTPCDensity2(-1,1,1);
5243 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5244 if (row0<15) row0=15;
5246 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5247 if (row1>145) row1=145;
5249 Int_t found,foundable,shared;
5250 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5251 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5252 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5253 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5259 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5262 // check kink point for given track
5263 // if return value=0 kink point not found
5264 // otherwise seed0 correspond to mother particle
5265 // seed1 correspond to daughter particle
5266 // kink parameter of kink point
5267 AliKink &kink=(AliKink &)knk;
5269 Int_t middlerow = (seed->GetFirstPoint()+seed->GetLastPoint())/2;
5270 Int_t first = seed->GetFirstPoint();
5271 Int_t last = seed->GetLastPoint();
5272 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5275 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5276 if (!seed1) return 0;
5277 FollowProlongation(*seed1,seed->GetLastPoint()-20);
5278 seed1->Reset(kTRUE);
5279 FollowProlongation(*seed1,158);
5280 seed1->Reset(kTRUE);
5281 last = seed1->GetLastPoint();
5283 AliTPCseed *seed0 = new AliTPCseed(*seed);
5284 seed0->Reset(kFALSE);
5287 AliTPCseed param0[20]; // parameters along the track
5288 AliTPCseed param1[20]; // parameters along the track
5289 AliKink kinks[20]; // corresponding kink parameters
5291 for (Int_t irow=0; irow<20;irow++){
5292 rows[irow] = first +((last-first)*irow)/19;
5294 // store parameters along the track
5296 for (Int_t irow=0;irow<20;irow++){
5297 FollowBackProlongation(*seed0, rows[irow]);
5298 FollowProlongation(*seed1,rows[19-irow]);
5299 new(¶m0[irow]) AliTPCseed(*seed0);
5300 new(¶m1[19-irow]) AliTPCseed(*seed1);
5304 for (Int_t irow=0; irow<19;irow++){
5305 kinks[irow].SetMother(param0[irow]);
5306 kinks[irow].SetDaughter(param1[irow]);
5307 kinks[irow].Update();
5310 // choose kink with biggest change of angle
5312 Double_t maxchange= 0;
5313 for (Int_t irow=1;irow<19;irow++){
5314 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5315 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5316 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5317 if ( quality > maxchange){
5318 maxchange = quality;
5325 if (index<0) return 0;
5327 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5328 seed0 = new AliTPCseed(param0[index]);
5329 seed1 = new AliTPCseed(param1[index]);
5330 seed0->Reset(kFALSE);
5331 seed1->Reset(kFALSE);
5332 seed0->ResetCovariance(10.);
5333 seed1->ResetCovariance(10.);
5334 FollowProlongation(*seed0,0);
5335 FollowBackProlongation(*seed1,158);
5336 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5337 seed0->Reset(kFALSE);
5338 seed1->Reset(kFALSE);
5339 seed0->ResetCovariance(10.);
5340 seed1->ResetCovariance(10.);
5342 first = TMath::Max(row0-20,0);
5343 last = TMath::Min(row0+20,158);
5345 for (Int_t irow=0; irow<20;irow++){
5346 rows[irow] = first +((last-first)*irow)/19;
5348 // store parameters along the track
5350 for (Int_t irow=0;irow<20;irow++){
5351 FollowBackProlongation(*seed0, rows[irow]);
5352 FollowProlongation(*seed1,rows[19-irow]);
5353 new(¶m0[irow]) AliTPCseed(*seed0);
5354 new(¶m1[19-irow]) AliTPCseed(*seed1);
5358 for (Int_t irow=0; irow<19;irow++){
5359 kinks[irow].SetMother(param0[irow]);
5360 kinks[irow].SetDaughter(param1[irow]);
5361 // param0[irow].Dump();
5362 //param1[irow].Dump();
5363 kinks[irow].Update();
5366 // choose kink with biggest change of angle
5369 for (Int_t irow=0;irow<20;irow++){
5370 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5371 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5372 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5373 if ( quality > maxchange){
5374 maxchange = quality;
5381 if (index==-1 || param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()<100){
5386 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5388 kink.SetMother(param0[index]);
5389 kink.SetDaughter(param1[index]);
5391 row0 = GetRowNumber(kink.GetR());
5392 kink.SetTPCRow0(row0);
5393 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5394 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5395 kink.SetIndex(-10,0);
5396 kink.SetIndex(int(param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()),1);
5397 kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
5398 kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
5401 // new (&mother) AliTPCseed(param0[index]);
5402 new (&daughter) AliTPCseed(param1[index]);
5403 daughter.SetLabel(kink.GetLabel(1));
5404 param0[index].Reset(kTRUE);
5405 FollowProlongation(param0[index],0);
5406 new (&mother) AliTPCseed(param0[index]);
5407 mother.SetLabel(kink.GetLabel(0));
5417 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5420 // reseed - refit - track
5423 // Int_t last = fSectors->GetNRows()-1;
5425 if (fSectors == fOuterSec){
5426 first = TMath::Max(first, t->GetFirstPoint()-fInnerSec->GetNRows());
5430 first = t->GetFirstPoint();
5432 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5433 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5435 FollowProlongation(*t,first);
5445 //_____________________________________________________________________________
5446 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5447 //-----------------------------------------------------------------
5448 // This function reades track seeds.
5449 //-----------------------------------------------------------------
5450 TDirectory *savedir=gDirectory;
5452 TFile *in=(TFile*)inp;
5453 if (!in->IsOpen()) {
5454 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5459 TTree *seedTree=(TTree*)in->Get("Seeds");
5461 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5462 cerr<<"can't get a tree with track seeds !\n";
5465 AliTPCtrack *seed=new AliTPCtrack;
5466 seedTree->SetBranchAddress("tracks",&seed);
5468 if (fSeeds==0) fSeeds=new TObjArray(15000);
5470 Int_t n=(Int_t)seedTree->GetEntries();
5471 for (Int_t i=0; i<n; i++) {
5472 seedTree->GetEvent(i);
5473 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5482 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5485 if (fSeeds) DeleteSeeds();
5488 if (!fSeeds) return 1;
5495 //_____________________________________________________________________________
5496 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5497 //-----------------------------------------------------------------
5498 // This is a track finder.
5499 //-----------------------------------------------------------------
5500 TDirectory *savedir=gDirectory;
5504 fSeeds = Tracking();
5507 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5509 //activate again some tracks
5510 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5511 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5513 Int_t nc=t.GetNumberOfClusters();
5515 delete fSeeds->RemoveAt(i);
5519 if (pt->GetRemoval()==10) {
5520 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5521 pt->Desactivate(10); // make track again active
5523 pt->Desactivate(20);
5524 delete fSeeds->RemoveAt(i);
5529 RemoveUsed2(fSeeds,0.85,0.85,0);
5530 if (AliTPCReconstructor::GetRecoParam()->GetDoKinks()) FindKinks(fSeeds,fEvent);
5531 RemoveUsed2(fSeeds,0.5,0.4,20);
5533 // // refit short tracks
5535 Int_t nseed=fSeeds->GetEntriesFast();
5536 // for (Int_t i=0; i<nseed; i++) {
5537 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5538 // if (!pt) continue;
5539 // Int_t nc=t.GetNumberOfClusters();
5541 // delete fSeeds->RemoveAt(i);
5544 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5545 // if (nc>100) continue; // hopefully, enough for ITS
5546 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5547 // //seed2->Reset(kFALSE);
5548 // //pt->ResetCovariance();
5549 // seed2->Modify(1);
5550 // FollowBackProlongation(*seed2,158);
5551 // //seed2->Reset(kFALSE);
5552 // seed2->Modify(10);
5553 // FollowProlongation(*seed2,0);
5554 // TTreeSRedirector &cstream = *fDebugStreamer;
5555 // cstream<<"Crefit"<<
5559 // if (seed2->fN>pt->fN){
5560 // delete fSeeds->RemoveAt(i);
5561 // fSeeds->AddAt(seed2,i);
5566 // RemoveUsed2(fSeeds,0.6,0.6,50);
5568 // FindV0s(fSeeds,fEvent);
5569 //RemoveDouble(fSeeds,0.2,0.6,11);
5573 for (Int_t i=0; i<nseed; i++) {
5574 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5576 Int_t nc=t.GetNumberOfClusters();
5578 delete fSeeds->RemoveAt(i);
5581 CookLabel(pt,0.1); //For comparison only
5582 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5583 if ((pt->IsActive() || (pt->GetRemoval()==10) )){
5585 if (fDebug>0) cerr<<found<<'\r';
5589 delete fSeeds->RemoveAt(i);
5593 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5595 //RemoveUsed(fSeeds,0.9,0.9,6);
5597 nseed=fSeeds->GetEntriesFast();
5599 for (Int_t i=0; i<nseed; i++) {
5600 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5602 Int_t nc=t.GetNumberOfClusters();
5604 delete fSeeds->RemoveAt(i);
5608 t.CookdEdx(0.02,0.6);
5609 // CheckKinkPoint(&t,0.05);
5610 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5611 if ((pt->IsActive() || (pt->GetRemoval()==10) )){
5619 delete fSeeds->RemoveAt(i);
5620 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5622 // FollowProlongation(*seed1,0);
5623 // Int_t n = seed1->GetNumberOfClusters();
5624 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5625 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5628 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5632 SortTracks(fSeeds, 1);
5636 PrepareForBackProlongation(fSeeds,5.);
5637 PropagateBack(fSeeds);
5638 printf("Time for back propagation: \t");timer.Print();timer.Start();
5642 PrepareForProlongation(fSeeds,5.);
5643 PropagateForward2(fSeeds);
5645 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5646 // RemoveUsed(fSeeds,0.7,0.7,6);
5647 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5649 nseed=fSeeds->GetEntriesFast();
5651 for (Int_t i=0; i<nseed; i++) {
5652 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5654 Int_t nc=t.GetNumberOfClusters();
5656 delete fSeeds->RemoveAt(i);
5659 t.CookdEdx(0.02,0.6);
5660 // CookLabel(pt,0.1); //For comparison only
5661 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5662 if ((pt->IsActive() || (pt->fRemoval==10) )){
5663 cerr<<found++<<'\r';
5666 delete fSeeds->RemoveAt(i);
5671 // fNTracks = found;
5673 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5676 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5677 Info("Clusters2Tracks","Number of found tracks %d",found);
5679 // UnloadClusters();
5684 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5687 // tracking of the seeds
5690 fSectors = fOuterSec;
5691 ParallelTracking(arr,150,63);
5692 fSectors = fOuterSec;
5693 ParallelTracking(arr,63,0);
5696 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5701 TObjArray * arr = new TObjArray;
5703 fSectors = fOuterSec;
5706 for (Int_t sec=0;sec<fkNOS;sec++){
5707 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5708 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5709 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5712 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5724 TObjArray * AliTPCtrackerMI::Tracking()
5728 if (AliTPCReconstructor::GetRecoParam()->GetSpecialSeeding()) return TrackingSpecial();
5731 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5733 TObjArray * seeds = new TObjArray;
5742 Float_t fnumber = 3.0;
5743 Float_t fdensity = 3.0;
5748 for (Int_t delta = 0; delta<18; delta+=6){
5752 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5753 SumTracks(seeds,arr);
5754 SignClusters(seeds,fnumber,fdensity);
5756 for (Int_t i=2;i<6;i+=2){
5757 // seed high pt tracks
5760 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5761 SumTracks(seeds,arr);
5762 SignClusters(seeds,fnumber,fdensity);
5767 // RemoveUsed(seeds,0.9,0.9,1);
5768 // UnsignClusters();
5769 // SignClusters(seeds,fnumber,fdensity);
5773 for (Int_t delta = 20; delta<120; delta+=10){
5775 // seed high pt tracks
5779 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5780 SumTracks(seeds,arr);
5781 SignClusters(seeds,fnumber,fdensity);
5786 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5787 SumTracks(seeds,arr);
5788 SignClusters(seeds,fnumber,fdensity);
5799 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5803 // RemoveUsed(seeds,0.75,0.75,1);
5805 //SignClusters(seeds,fnumber,fdensity);
5814 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5815 SumTracks(seeds,arr);
5816 SignClusters(seeds,fnumber,fdensity);
5818 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5819 SumTracks(seeds,arr);
5820 SignClusters(seeds,fnumber,fdensity);
5822 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5823 SumTracks(seeds,arr);
5824 SignClusters(seeds,fnumber,fdensity);
5828 for (Int_t delta = 3; delta<30; delta+=5){
5834 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5835 SumTracks(seeds,arr);
5836 SignClusters(seeds,fnumber,fdensity);
5838 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5839 SumTracks(seeds,arr);
5840 SignClusters(seeds,fnumber,fdensity);
5852 for (Int_t delta = 30; delta<90; delta+=10){
5858 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5859 SumTracks(seeds,arr);
5860 SignClusters(seeds,fnumber,fdensity);
5862 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5863 SumTracks(seeds,arr);
5864 SignClusters(seeds,fnumber,fdensity);
5868 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5879 TObjArray * AliTPCtrackerMI::TrackingSpecial()
5882 // seeding adjusted for laser and cosmic tests - short tracks with big inclination angle
5883 // no primary vertex seeding tried
5887 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5889 TObjArray * seeds = new TObjArray;
5894 Float_t fnumber = 3.0;
5895 Float_t fdensity = 3.0;
5898 cuts[0] = AliTPCReconstructor::GetRecoParam()->GetMaxC(); // max curvature
5899 cuts[1] = 3.5; // max tan(phi) angle for seeding
5900 cuts[2] = 3.; // not used (cut on z primary vertex)
5901 cuts[3] = 3.5; // max tan(theta) angle for seeding
5903 for (Int_t delta = 0; nup-delta-gap-1>0; delta+=3){
5905 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5906 SumTracks(seeds,arr);
5907 SignClusters(seeds,fnumber,fdensity);
5911 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5922 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5925 //sum tracks to common container
5926 //remove suspicious tracks
5927 Int_t nseed = arr2->GetEntriesFast();
5928 for (Int_t i=0;i<nseed;i++){
5929 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5932 // remove tracks with too big curvature
5934 if (TMath::Abs(pt->GetC())>AliTPCReconstructor::GetRecoParam()->GetMaxC()){
5935 delete arr2->RemoveAt(i);
5938 // REMOVE VERY SHORT TRACKS
5939 if (pt->GetNumberOfClusters()<20){
5940 delete arr2->RemoveAt(i);
5943 // NORMAL ACTIVE TRACK
5944 if (pt->IsActive()){
5945 arr1->AddLast(arr2->RemoveAt(i));
5948 //remove not usable tracks
5949 if (pt->GetRemoval()!=10){
5950 delete arr2->RemoveAt(i);
5954 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5955 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5956 arr1->AddLast(arr2->RemoveAt(i));
5958 delete arr2->RemoveAt(i);
5967 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5970 // try to track in parralel
5972 Int_t nseed=arr->GetEntriesFast();
5973 //prepare seeds for tracking
5974 for (Int_t i=0; i<nseed; i++) {
5975 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5977 if (!t.IsActive()) continue;
5978 // follow prolongation to the first layer
5979 if ( (fSectors ==fInnerSec) || (t.GetFirstPoint()-fParam->GetNRowLow()>rfirst+1) )
5980 FollowProlongation(t, rfirst+1);
5985 for (Int_t nr=rfirst; nr>=rlast; nr--){
5986 if (nr<fInnerSec->GetNRows())
5987 fSectors = fInnerSec;
5989 fSectors = fOuterSec;
5990 // make indexes with the cluster tracks for given
5992 // find nearest cluster
5993 for (Int_t i=0; i<nseed; i++) {
5994 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5996 if (nr==80) pt->UpdateReference();
5997 if (!pt->IsActive()) continue;
5998 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5999 if (pt->GetRelativeSector()>17) {
6002 UpdateClusters(t,nr);
6004 // prolonagate to the nearest cluster - if founded
6005 for (Int_t i=0; i<nseed; i++) {
6006 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
6008 if (!pt->IsActive()) continue;
6009 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
6010 if (pt->GetRelativeSector()>17) {
6013 FollowToNextCluster(*pt,nr);
6018 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
6022 // if we use TPC track itself we have to "update" covariance
6024 Int_t nseed= arr->GetEntriesFast();
6025 for (Int_t i=0;i<nseed;i++){
6026 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6030 //rotate to current local system at first accepted point
6031 Int_t index = pt->GetClusterIndex2(pt->GetFirstPoint());
6032 Int_t sec = (index&0xff000000)>>24;
6034 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
6035 if (angle1>TMath::Pi())
6036 angle1-=2.*TMath::Pi();
6037 Float_t angle2 = pt->GetAlpha();
6039 if (TMath::Abs(angle1-angle2)>0.001){
6040 pt->Rotate(angle1-angle2);
6041 //angle2 = pt->GetAlpha();
6042 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
6043 //if (pt->GetAlpha()<0)
6044 // pt->fRelativeSector+=18;
6045 //sec = pt->fRelativeSector;
6054 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
6058 // if we use TPC track itself we have to "update" covariance
6060 Int_t nseed= arr->GetEntriesFast();
6061 for (Int_t i=0;i<nseed;i++){
6062 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6065 pt->SetFirstPoint(pt->GetLastPoint());
6073 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
6076 // make back propagation
6078 Int_t nseed= arr->GetEntriesFast();
6079 for (Int_t i=0;i<nseed;i++){
6080 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6081 if (pt&& pt->GetKinkIndex(0)<=0) {
6082 //AliTPCseed *pt2 = new AliTPCseed(*pt);
6083 fSectors = fInnerSec;
6084 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
6085 //fSectors = fOuterSec;
6086 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6087 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
6088 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
6089 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6092 if (pt&& pt->GetKinkIndex(0)>0) {
6093 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
6094 pt->SetFirstPoint(kink->GetTPCRow0());
6095 fSectors = fInnerSec;
6096 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6104 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
6107 // make forward propagation
6109 Int_t nseed= arr->GetEntriesFast();
6111 for (Int_t i=0;i<nseed;i++){
6112 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6114 FollowProlongation(*pt,0);
6121 Int_t AliTPCtrackerMI::PropagateForward()
6124 // propagate track forward
6126 Int_t nseed = fSeeds->GetEntriesFast();
6127 for (Int_t i=0;i<nseed;i++){
6128 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
6130 AliTPCseed &t = *pt;
6131 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
6132 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
6133 if (alpha < 0. ) alpha += 2.*TMath::Pi();
6134 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
6138 fSectors = fOuterSec;
6139 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
6140 fSectors = fInnerSec;
6141 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
6151 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6154 // make back propagation, in between row0 and row1
6158 fSectors = fInnerSec;
6161 if (row1<fSectors->GetNRows())
6164 r1 = fSectors->GetNRows()-1;
6166 if (row0<fSectors->GetNRows()&& r1>0 )
6167 FollowBackProlongation(*pt,r1);
6168 if (row1<=fSectors->GetNRows())
6171 r1 = row1 - fSectors->GetNRows();
6172 if (r1<=0) return 0;
6173 if (r1>=fOuterSec->GetNRows()) return 0;
6174 fSectors = fOuterSec;
6175 return FollowBackProlongation(*pt,r1);
6183 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6187 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6188 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6189 Float_t padlength = GetPadPitchLength(row);
6191 Float_t sresy = (seed->GetSector() < fParam->GetNSector()/2) ? 0.2 :0.3;
6192 Double_t angulary = seed->GetSnp();
6193 angulary = angulary*angulary/(1-angulary*angulary);
6194 seed->SetCurrentSigmaY2(sd2+padlength*padlength*angulary/12.+sresy*sresy);
6196 Float_t sresz = fParam->GetZSigma();
6197 Float_t angularz = seed->GetTgl();
6198 seed->SetCurrentSigmaZ2(sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz);
6200 Float_t wy = GetSigmaY(seed);
6201 Float_t wz = GetSigmaZ(seed);
6204 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6205 printf("problem\n");
6211 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6215 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6216 Float_t padlength = fParam->GetPadPitchLength(seed->GetSector());
6217 Float_t sres = (seed->GetSector() < fParam->GetNSector()/2) ? 0.2 :0.3;
6218 Float_t angular = seed->GetSnp();
6219 angular = angular*angular/(1-angular*angular);
6220 // angular*=angular;
6221 //angular = TMath::Sqrt(angular/(1-angular));
6222 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6225 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6229 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6230 Float_t padlength = fParam->GetPadPitchLength(seed->GetSector());
6231 Float_t sres = fParam->GetZSigma();
6232 Float_t angular = seed->GetTgl();
6233 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6238 //__________________________________________________________________________
6239 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6240 //--------------------------------------------------------------------
6241 //This function "cooks" a track label. If label<0, this track is fake.
6242 //--------------------------------------------------------------------
6243 AliTPCseed * t = (AliTPCseed*)tk;
6244 Int_t noc=t->GetNumberOfClusters();
6246 //printf("\nnot founded prolongation\n\n\n");
6252 AliTPCclusterMI *clusters[160];
6254 for (Int_t i=0;i<160;i++) {
6261 for (i=0; i<160 && current<noc; i++) {
6263 Int_t index=t->GetClusterIndex2(i);
6264 if (index<=0) continue;
6265 if (index&0x8000) continue;
6267 //clusters[current]=GetClusterMI(index);
6268 if (t->GetClusterPointer(i)){
6269 clusters[current]=t->GetClusterPointer(i);
6275 Int_t lab=123456789;
6276 for (i=0; i<noc; i++) {
6277 AliTPCclusterMI *c=clusters[i];
6279 lab=TMath::Abs(c->GetLabel(0));
6281 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6287 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6289 for (i=0; i<noc; i++) {
6290 AliTPCclusterMI *c=clusters[i];
6292 if (TMath::Abs(c->GetLabel(1)) == lab ||
6293 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6296 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6299 Int_t tail=Int_t(0.10*noc);
6302 for (i=1; i<=160&&ind<tail; i++) {
6303 // AliTPCclusterMI *c=clusters[noc-i];
6304 AliTPCclusterMI *c=clusters[i];
6306 if (lab == TMath::Abs(c->GetLabel(0)) ||
6307 lab == TMath::Abs(c->GetLabel(1)) ||
6308 lab == TMath::Abs(c->GetLabel(2))) max++;
6311 if (max < Int_t(0.5*tail)) lab=-lab;
6318 //delete[] clusters;
6322 //__________________________________________________________________________
6323 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6324 //--------------------------------------------------------------------
6325 //This function "cooks" a track label. If label<0, this track is fake.
6326 //--------------------------------------------------------------------
6327 Int_t noc=t->GetNumberOfClusters();
6329 //printf("\nnot founded prolongation\n\n\n");
6335 AliTPCclusterMI *clusters[160];
6337 for (Int_t i=0;i<160;i++) {
6344 for (i=0; i<160 && current<noc; i++) {
6345 if (i<first) continue;
6346 if (i>last) continue;
6347 Int_t index=t->GetClusterIndex2(i);
6348 if (index<=0) continue;
6349 if (index&0x8000) continue;
6351 //clusters[current]=GetClusterMI(index);
6352 if (t->GetClusterPointer(i)){
6353 clusters[current]=t->GetClusterPointer(i);
6358 if (noc<5) return -1;
6359 Int_t lab=123456789;
6360 for (i=0; i<noc; i++) {
6361 AliTPCclusterMI *c=clusters[i];
6363 lab=TMath::Abs(c->GetLabel(0));
6365 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6371 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6373 for (i=0; i<noc; i++) {
6374 AliTPCclusterMI *c=clusters[i];
6376 if (TMath::Abs(c->GetLabel(1)) == lab ||
6377 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6380 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6383 Int_t tail=Int_t(0.10*noc);
6386 for (i=1; i<=160&&ind<tail; i++) {
6387 // AliTPCclusterMI *c=clusters[noc-i];
6388 AliTPCclusterMI *c=clusters[i];
6390 if (lab == TMath::Abs(c->GetLabel(0)) ||
6391 lab == TMath::Abs(c->GetLabel(1)) ||
6392 lab == TMath::Abs(c->GetLabel(2))) max++;
6395 if (max < Int_t(0.5*tail)) lab=-lab;
6398 // t->SetLabel(lab);
6402 //delete[] clusters;
6406 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6408 //return pad row number for this x
6411 r=fRow[fN-1].GetX();
6412 if (x > r) return fN;
6414 if (x < r) return -1;
6415 return Int_t((x-r)/fPadPitchLength + 0.5);}
6417 r=fRow[fN-1].GetX();
6418 if (x > r) return fN;
6420 if (x < r) return -1;
6421 Double_t r1=fRow[64].GetX();
6423 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6425 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6429 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6431 //return pad row number for given x vector
6432 Float_t phi = TMath::ATan2(x[1],x[0]);
6433 if(phi<0) phi=2.*TMath::Pi()+phi;
6434 // Get the local angle in the sector philoc
6435 const Float_t kRaddeg = 180/3.14159265358979312;
6436 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6437 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6438 return GetRowNumber(localx);
6441 //_________________________________________________________________________
6442 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6443 //-----------------------------------------------------------------------
6444 // Setup inner sector
6445 //-----------------------------------------------------------------------
6447 fAlpha=par->GetInnerAngle();
6448 fAlphaShift=par->GetInnerAngleShift();
6449 fPadPitchWidth=par->GetInnerPadPitchWidth();
6450 fPadPitchLength=par->GetInnerPadPitchLength();
6451 fN=par->GetNRowLow();
6452 fRow=new AliTPCRow[fN];
6453 for (Int_t i=0; i<fN; i++) {
6454 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6455 fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
6458 fAlpha=par->GetOuterAngle();
6459 fAlphaShift=par->GetOuterAngleShift();
6460 fPadPitchWidth = par->GetOuterPadPitchWidth();
6461 fPadPitchLength = par->GetOuter1PadPitchLength();
6462 f1PadPitchLength = par->GetOuter1PadPitchLength();
6463 f2PadPitchLength = par->GetOuter2PadPitchLength();
6465 fN=par->GetNRowUp();
6466 fRow=new AliTPCRow[fN];
6467 for (Int_t i=0; i<fN; i++) {
6468 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6469 fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
6474 AliTPCtrackerMI::AliTPCRow::AliTPCRow():
6484 // default constructor
6488 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6495 //_________________________________________________________________________
6497 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6498 //-----------------------------------------------------------------------
6499 // Insert a cluster into this pad row in accordence with its y-coordinate
6500 //-----------------------------------------------------------------------
6501 if (fN==kMaxClusterPerRow) {
6502 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6504 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6505 Int_t i=Find(c->GetZ());
6506 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6507 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6508 fIndex[i]=index; fClusters[i]=c; fN++;
6511 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6517 //delete[] fClusterArray;
6518 if (fClusters1) delete []fClusters1;
6519 if (fClusters2) delete []fClusters2;
6526 //___________________________________________________________________
6527 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6528 //-----------------------------------------------------------------------
6529 // Return the index of the nearest cluster
6530 //-----------------------------------------------------------------------
6531 if (fN==0) return 0;
6532 if (z <= fClusters[0]->GetZ()) return 0;
6533 if (z > fClusters[fN-1]->GetZ()) return fN;
6534 Int_t b=0, e=fN-1, m=(b+e)/2;
6535 for (; b<e; m=(b+e)/2) {
6536 if (z > fClusters[m]->GetZ()) b=m+1;
6544 //___________________________________________________________________
6545 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6546 //-----------------------------------------------------------------------
6547 // Return the index of the nearest cluster in z y
6548 //-----------------------------------------------------------------------
6549 Float_t maxdistance = roady*roady + roadz*roadz;
6551 AliTPCclusterMI *cl =0;
6552 for (Int_t i=Find(z-roadz); i<fN; i++) {
6553 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6554 if (c->GetZ() > z+roadz) break;
6555 if ( (c->GetY()-y) > roady ) continue;
6556 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6557 if (maxdistance>distance) {
6558 maxdistance = distance;
6565 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6567 //-----------------------------------------------------------------------
6568 // Return the index of the nearest cluster in z y
6569 //-----------------------------------------------------------------------
6570 Float_t maxdistance = roady*roady + roadz*roadz;
6571 AliTPCclusterMI *cl =0;
6573 //PH Check boundaries. 510 is the size of fFastCluster
6574 Int_t iz1 = Int_t(z-roadz+254.5);
6575 if (iz1<0 || iz1>=510) return cl;
6576 iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
6577 Int_t iz2 = Int_t(z+roadz+255.5);
6578 if (iz2<0 || iz2>=510) return cl;
6579 iz2 = TMath::Min(GetFastCluster(iz2)+1,fN);
6581 //FindNearest3(y,z,roady,roadz,index);
6582 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6583 for (Int_t i=iz1; i<iz2; i++) {
6584 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6585 if (c->GetZ() > z+roadz) break;
6586 if ( c->GetY()-y > roady ) continue;
6587 if ( y-c->GetY() > roady ) continue;
6588 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6589 if (maxdistance>distance) {
6590 maxdistance = distance;
6593 //roady = TMath::Sqrt(maxdistance);
6601 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6603 //-----------------------------------------------------------------------
6604 // Return the index of the nearest cluster in z y
6605 //-----------------------------------------------------------------------
6606 Float_t maxdistance = roady*roady + roadz*roadz;
6607 // Int_t iz = Int_t(z+255.);
6608 AliTPCclusterMI *cl =0;
6609 for (Int_t i=Find(z-roadz); i<fN; i++) {
6610 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6611 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6612 if (c->GetZ() > z+roadz) break;
6613 if ( c->GetY()-y > roady ) continue;
6614 if ( y-c->GetY() > roady ) continue;
6615 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6616 if (maxdistance>distance) {
6617 maxdistance = distance;
6620 //roady = TMath::Sqrt(maxdistance);
6630 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6634 // return &fTrackPoints[i];