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>
34 #include "AliComplexCluster.h"
36 #include "AliESDkink.h"
38 #include "AliRunLoader.h"
39 #include "AliTPCClustersRow.h"
40 #include "AliTPCParam.h"
41 #include "AliTPCReconstructor.h"
42 #include "AliTPCclusterMI.h"
43 #include "AliTPCpolyTrack.h"
44 #include "AliTPCreco.h"
45 #include "AliTPCseed.h"
46 #include "AliTPCtrackerMI.h"
47 #include "TStopwatch.h"
48 #include "AliTPCReconstructor.h"
49 #include "AliESDkink.h"
51 #include "TTreeStream.h"
52 #include "AliAlignObj.h"
53 #include "AliTrackPointArray.h"
57 ClassImp(AliTPCtrackerMI)
60 class AliTPCFastMath {
63 static Double_t FastAsin(Double_t x);
65 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
68 Double_t AliTPCFastMath::fgFastAsin[20000];
69 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
71 AliTPCFastMath::AliTPCFastMath(){
73 // initialized lookup table;
74 for (Int_t i=0;i<10000;i++){
75 fgFastAsin[2*i] = TMath::ASin(i/10000.);
76 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
80 Double_t AliTPCFastMath::FastAsin(Double_t x){
82 // return asin using lookup table
84 Int_t index = int(x*10000);
85 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
88 Int_t index = int(x*10000);
89 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
95 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
97 //update track information using current cluster - track->fCurrentCluster
100 AliTPCclusterMI* c =track->fCurrentCluster;
101 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
103 UInt_t i = track->fCurrentClusterIndex1;
105 Int_t sec=(i&0xff000000)>>24;
106 //Int_t row = (i&0x00ff0000)>>16;
107 track->fRow=(i&0x00ff0000)>>16;
108 track->fSector = sec;
109 // Int_t index = i&0xFFFF;
110 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
111 track->SetClusterIndex2(track->fRow, i);
112 //track->fFirstPoint = row;
113 //if ( track->fLastPoint<row) track->fLastPoint =row;
114 // if (track->fRow<0 || track->fRow>160) {
115 // printf("problem\n");
117 if (track->fFirstPoint>track->fRow)
118 track->fFirstPoint = track->fRow;
119 if (track->fLastPoint<track->fRow)
120 track->fLastPoint = track->fRow;
123 track->fClusterPointer[track->fRow] = c;
126 Double_t angle2 = track->GetSnp()*track->GetSnp();
128 //SET NEW Track Point
130 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
132 angle2 = TMath::Sqrt(angle2/(1-angle2));
133 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
135 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
136 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
137 point.SetErrY(sqrt(track->fErrorY2));
138 point.SetErrZ(sqrt(track->fErrorZ2));
140 point.SetX(track->GetX());
141 point.SetY(track->GetY());
142 point.SetZ(track->GetZ());
143 point.SetAngleY(angle2);
144 point.SetAngleZ(track->GetTgl());
145 if (point.fIsShared){
146 track->fErrorY2 *= 4;
147 track->fErrorZ2 *= 4;
151 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
153 track->fErrorY2 *= 1.3;
154 track->fErrorY2 += 0.01;
155 track->fErrorZ2 *= 1.3;
156 track->fErrorZ2 += 0.005;
158 if (accept>0) return 0;
159 if (track->GetNumberOfClusters()%20==0){
160 // if (track->fHelixIn){
161 // TClonesArray & larr = *(track->fHelixIn);
162 // Int_t ihelix = larr.GetEntriesFast();
163 // new(larr[ihelix]) AliHelix(*track) ;
166 track->fNoCluster =0;
167 return track->Update(c,chi2,i);
172 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
173 Float_t cory, Float_t corz)
176 // decide according desired precision to accept given
177 // cluster for tracking
178 Double_t sy2=ErrY2(seed,cluster)*cory;
179 Double_t sz2=ErrZ2(seed,cluster)*corz;
180 //sy2=ErrY2(seed,cluster)*cory;
181 //sz2=ErrZ2(seed,cluster)*cory;
183 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
184 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
186 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
187 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
188 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
189 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
191 Double_t rdistance2 = rdistancey2+rdistancez2;
194 if (rdistance2>16) return 3;
197 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
198 return 2; //suspisiouce - will be changed
200 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
201 // strict cut on overlaped cluster
202 return 2; //suspisiouce - will be changed
204 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
205 && cluster->GetType()<0){
215 //_____________________________________________________________________________
216 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
217 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
219 //---------------------------------------------------------------------
220 // The main TPC tracker constructor
221 //---------------------------------------------------------------------
222 fInnerSec=new AliTPCSector[fkNIS];
223 fOuterSec=new AliTPCSector[fkNOS];
226 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
227 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
234 Int_t nrowlow = par->GetNRowLow();
235 Int_t nrowup = par->GetNRowUp();
238 for (Int_t i=0;i<nrowlow;i++){
239 fXRow[i] = par->GetPadRowRadiiLow(i);
240 fPadLength[i]= par->GetPadPitchLength(0,i);
241 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
245 for (Int_t i=0;i<nrowup;i++){
246 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
247 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
248 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
259 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
261 //________________________________________________________________________
262 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
267 //------------------------------------
268 // dummy copy constructor
269 //------------------------------------------------------------------
271 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
272 //------------------------------
274 //--------------------------------------------------------------
277 //_____________________________________________________________________________
278 AliTPCtrackerMI::~AliTPCtrackerMI() {
279 //------------------------------------------------------------------
280 // TPC tracker destructor
281 //------------------------------------------------------------------
288 if (fDebugStreamer) delete fDebugStreamer;
291 void AliTPCtrackerMI::SetIO()
295 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
297 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
299 AliTPCtrack *iotrack= new AliTPCtrack;
300 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
306 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
322 AliTPCtrack *iotrack= new AliTPCtrack;
323 // iotrack->fHelixIn = new TClonesArray("AliHelix");
324 //iotrack->fHelixOut = new TClonesArray("AliHelix");
325 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
328 if (output && (fDebug&2)){
329 //write the full seed information if specified in debug mode
331 fSeedTree = new TTree("Seeds","Seeds");
332 AliTPCseed * vseed = new AliTPCseed;
334 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
335 arrtr->ExpandCreateFast(160);
336 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
338 vseed->fPoints = arrtr;
339 vseed->fEPoints = arre;
340 // vseed->fClusterPoints = arrcl;
341 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
344 fTreeDebug = new TTree("trackDebug","trackDebug");
345 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
346 fTreeDebug->Branch("debug",&arrd,32000,99);
354 void AliTPCtrackerMI::FillESD(TObjArray* arr)
358 //fill esds using updated tracks
360 // write tracks to the event
361 // store index of the track
362 Int_t nseed=arr->GetEntriesFast();
363 //FindKinks(arr,fEvent);
364 for (Int_t i=0; i<nseed; i++) {
365 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
368 // pt->PropagateTo(fParam->GetInnerRadiusLow());
369 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
370 pt->PropagateTo(fParam->GetInnerRadiusLow());
373 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
375 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
376 iotrack.SetTPCPoints(pt->GetPoints());
377 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
378 iotrack.SetV0Indexes(pt->GetV0Indexes());
379 // iotrack.SetTPCpid(pt->fTPCr);
380 //iotrack.SetTPCindex(i);
381 fEvent->AddTrack(&iotrack);
385 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
387 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
388 iotrack.SetTPCPoints(pt->GetPoints());
389 //iotrack.SetTPCindex(i);
390 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
391 iotrack.SetV0Indexes(pt->GetV0Indexes());
392 // iotrack.SetTPCpid(pt->fTPCr);
393 fEvent->AddTrack(&iotrack);
397 // short tracks - maybe decays
399 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
400 Int_t found,foundable,shared;
401 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
402 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
404 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
405 //iotrack.SetTPCindex(i);
406 iotrack.SetTPCPoints(pt->GetPoints());
407 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
408 iotrack.SetV0Indexes(pt->GetV0Indexes());
409 //iotrack.SetTPCpid(pt->fTPCr);
410 fEvent->AddTrack(&iotrack);
415 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
416 Int_t found,foundable,shared;
417 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
418 if (found<20) continue;
419 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
422 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
423 iotrack.SetTPCPoints(pt->GetPoints());
424 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
425 iotrack.SetV0Indexes(pt->GetV0Indexes());
426 //iotrack.SetTPCpid(pt->fTPCr);
427 //iotrack.SetTPCindex(i);
428 fEvent->AddTrack(&iotrack);
431 // short tracks - secondaties
433 if ( (pt->GetNumberOfClusters()>30) ) {
434 Int_t found,foundable,shared;
435 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
436 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
438 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
439 iotrack.SetTPCPoints(pt->GetPoints());
440 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
441 iotrack.SetV0Indexes(pt->GetV0Indexes());
442 //iotrack.SetTPCpid(pt->fTPCr);
443 //iotrack.SetTPCindex(i);
444 fEvent->AddTrack(&iotrack);
449 if ( (pt->GetNumberOfClusters()>15)) {
450 Int_t found,foundable,shared;
451 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
452 if (found<15) continue;
453 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
454 if (float(found)/float(foundable)<0.8) continue;
457 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
458 iotrack.SetTPCPoints(pt->GetPoints());
459 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
460 iotrack.SetV0Indexes(pt->GetV0Indexes());
461 // iotrack.SetTPCpid(pt->fTPCr);
462 //iotrack.SetTPCindex(i);
463 fEvent->AddTrack(&iotrack);
468 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
471 void AliTPCtrackerMI::WriteTracks(TTree * tree)
474 // write tracks from seed array to selected tree
478 AliTPCtrack *iotrack= new AliTPCtrack;
479 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
484 void AliTPCtrackerMI::WriteTracks()
487 // write tracks to the given output tree -
488 // output specified with SetIO routine
495 AliTPCtrack *iotrack= 0;
496 Int_t nseed=fSeeds->GetEntriesFast();
497 //for (Int_t i=0; i<nseed; i++) {
498 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
499 // if (iotrack) break;
501 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
502 TBranch * br = fOutput->GetBranch("tracks");
503 br->SetAddress(&iotrack);
505 for (Int_t i=0; i<nseed; i++) {
506 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
508 AliTPCtrack * track = new AliTPCtrack(*pt);
511 // br->SetAddress(&iotrack);
516 //fOutput->GetDirectory()->cd();
522 //write the full seed information if specified in debug mode
524 AliTPCseed * vseed = new AliTPCseed;
526 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
527 arrtr->ExpandCreateFast(160);
528 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
529 //arrcl->ExpandCreateFast(160);
530 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
532 vseed->fPoints = arrtr;
533 vseed->fEPoints = arre;
534 // vseed->fClusterPoints = arrcl;
535 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
536 TBranch * brseed = fSeedTree->GetBranch("seeds");
538 Int_t nseed=fSeeds->GetEntriesFast();
540 for (Int_t i=0; i<nseed; i++) {
541 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
544 // pt->fClusterPoints = arrcl;
548 brseed->SetAddress(&vseed);
552 // pt->fClusterPoints = 0;
555 if (fTreeDebug) fTreeDebug->Write();
563 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
566 //seed->SetErrorY2(0.1);
568 //calculate look-up table at the beginning
569 static Bool_t ginit = kFALSE;
570 static Float_t gnoise1,gnoise2,gnoise3;
571 static Float_t ggg1[10000];
572 static Float_t ggg2[10000];
573 static Float_t ggg3[10000];
574 static Float_t glandau1[10000];
575 static Float_t glandau2[10000];
576 static Float_t glandau3[10000];
578 static Float_t gcor01[500];
579 static Float_t gcor02[500];
580 static Float_t gcorp[500];
585 for (Int_t i=1;i<500;i++){
586 Float_t rsigma = float(i)/100.;
587 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
588 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
589 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
593 for (Int_t i=3;i<10000;i++){
597 Float_t amp = float(i);
598 Float_t padlength =0.75;
599 gnoise1 = 0.0004/padlength;
600 Float_t nel = 0.268*amp;
601 Float_t nprim = 0.155*amp;
602 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
603 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
604 if (glandau1[i]>1) glandau1[i]=1;
605 glandau1[i]*=padlength*padlength/12.;
609 gnoise2 = 0.0004/padlength;
612 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
613 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
614 if (glandau2[i]>1) glandau2[i]=1;
615 glandau2[i]*=padlength*padlength/12.;
620 gnoise3 = 0.0004/padlength;
623 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
624 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
625 if (glandau3[i]>1) glandau3[i]=1;
626 glandau3[i]*=padlength*padlength/12.;
634 Int_t amp = int(TMath::Abs(cl->GetQ()));
636 seed->SetErrorY2(1.);
640 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
641 Int_t ctype = cl->GetType();
642 Float_t padlength= GetPadPitchLength(seed->fRow);
643 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
644 angle2 = angle2/(1-angle2);
647 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
650 if (fSectors==fInnerSec){
652 res = ggg1[amp]*z+glandau1[amp]*angle2;
653 if (ctype==0) res *= gcor01[rsigmay];
656 res*= gcorp[rsigmay];
662 res = ggg2[amp]*z+glandau2[amp]*angle2;
663 if (ctype==0) res *= gcor02[rsigmay];
666 res*= gcorp[rsigmay];
671 res = ggg3[amp]*z+glandau3[amp]*angle2;
672 if (ctype==0) res *= gcor02[rsigmay];
675 res*= gcorp[rsigmay];
682 res*=2.4; // overestimate error 2 times
689 seed->SetErrorY2(res);
697 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
700 //seed->SetErrorY2(0.1);
702 //calculate look-up table at the beginning
703 static Bool_t ginit = kFALSE;
704 static Float_t gnoise1,gnoise2,gnoise3;
705 static Float_t ggg1[10000];
706 static Float_t ggg2[10000];
707 static Float_t ggg3[10000];
708 static Float_t glandau1[10000];
709 static Float_t glandau2[10000];
710 static Float_t glandau3[10000];
712 static Float_t gcor01[1000];
713 static Float_t gcor02[1000];
714 static Float_t gcorp[1000];
719 for (Int_t i=1;i<1000;i++){
720 Float_t rsigma = float(i)/100.;
721 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
722 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
723 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
727 for (Int_t i=3;i<10000;i++){
731 Float_t amp = float(i);
732 Float_t padlength =0.75;
733 gnoise1 = 0.0004/padlength;
734 Float_t nel = 0.268*amp;
735 Float_t nprim = 0.155*amp;
736 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
737 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
738 if (glandau1[i]>1) glandau1[i]=1;
739 glandau1[i]*=padlength*padlength/12.;
743 gnoise2 = 0.0004/padlength;
746 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
747 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
748 if (glandau2[i]>1) glandau2[i]=1;
749 glandau2[i]*=padlength*padlength/12.;
754 gnoise3 = 0.0004/padlength;
757 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
758 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
759 if (glandau3[i]>1) glandau3[i]=1;
760 glandau3[i]*=padlength*padlength/12.;
768 Int_t amp = int(TMath::Abs(cl->GetQ()));
770 seed->SetErrorY2(1.);
774 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
775 Int_t ctype = cl->GetType();
776 Float_t padlength= GetPadPitchLength(seed->fRow);
778 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
779 // if (angle2<0.6) angle2 = 0.6;
780 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
783 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
786 if (fSectors==fInnerSec){
788 res = ggg1[amp]*z+glandau1[amp]*angle2;
789 if (ctype==0) res *= gcor01[rsigmaz];
792 res*= gcorp[rsigmaz];
798 res = ggg2[amp]*z+glandau2[amp]*angle2;
799 if (ctype==0) res *= gcor02[rsigmaz];
802 res*= gcorp[rsigmaz];
807 res = ggg3[amp]*z+glandau3[amp]*angle2;
808 if (ctype==0) res *= gcor02[rsigmaz];
811 res*= gcorp[rsigmaz];
820 if ((ctype<0) &&<70){
828 seed->SetErrorZ2(res);
835 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
838 //seed->SetErrorZ2(0.1);
842 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
844 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
845 Int_t ctype = cl->GetType();
846 Float_t amp = TMath::Abs(cl->GetQ());
851 Float_t landau=2 ; //landau fluctuation part
852 Float_t gg=2; // gg fluctuation part
853 Float_t padlength= GetPadPitchLength(seed->GetX());
855 if (fSectors==fInnerSec){
856 snoise2 = 0.0004/padlength;
859 gg = (2+0.001*nel/(padlength*padlength))/nel;
860 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
861 if (landau>1) landau=1;
864 snoise2 = 0.0004/padlength;
867 gg = (2+0.0008*nel/(padlength*padlength))/nel;
868 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
869 if (landau>1) landau=1;
871 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
874 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
875 angle2 = TMath::Sqrt((1-angle2));
876 if (angle2<0.6) angle2 = 0.6;
879 Float_t angle = seed->GetTgl()/angle2;
880 Float_t angular = landau*angle*angle*padlength*padlength/12.;
881 Float_t res = sdiff + angular;
884 if ((ctype==0) && (fSectors ==fOuterSec))
885 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
887 if ((ctype==0) && (fSectors ==fInnerSec))
888 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
892 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
898 if ((ctype<0) &&<70){
906 seed->SetErrorZ2(res);
914 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
916 //rotate to track "local coordinata
917 Float_t x = seed->GetX();
918 Float_t y = seed->GetY();
919 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
922 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
923 if (!seed->Rotate(fSectors->GetAlpha()))
925 } else if (y <-ymax) {
926 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
927 if (!seed->Rotate(-fSectors->GetAlpha()))
935 //_____________________________________________________________________________
936 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
937 Double_t x2,Double_t y2,
938 Double_t x3,Double_t y3)
940 //-----------------------------------------------------------------
941 // Initial approximation of the track curvature
942 //-----------------------------------------------------------------
943 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
944 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
945 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
946 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
947 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
949 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
950 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
951 return -xr*yr/sqrt(xr*xr+yr*yr);
956 //_____________________________________________________________________________
957 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
958 Double_t x2,Double_t y2,
959 Double_t x3,Double_t y3)
961 //-----------------------------------------------------------------
962 // Initial approximation of the track curvature
963 //-----------------------------------------------------------------
969 Double_t det = x3*y2-x2*y3;
974 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
975 Double_t x0 = x3*0.5-y3*u;
976 Double_t y0 = y3*0.5+x3*u;
977 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
983 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
984 Double_t x2,Double_t y2,
985 Double_t x3,Double_t y3)
987 //-----------------------------------------------------------------
988 // Initial approximation of the track curvature
989 //-----------------------------------------------------------------
995 Double_t det = x3*y2-x2*y3;
1000 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1001 Double_t x0 = x3*0.5-y3*u;
1002 Double_t y0 = y3*0.5+x3*u;
1003 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1012 //_____________________________________________________________________________
1013 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1014 Double_t x2,Double_t y2,
1015 Double_t x3,Double_t y3)
1017 //-----------------------------------------------------------------
1018 // Initial approximation of the track curvature times center of curvature
1019 //-----------------------------------------------------------------
1020 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1021 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1022 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1023 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1024 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1026 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1028 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1031 //_____________________________________________________________________________
1032 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1033 Double_t x2,Double_t y2,
1034 Double_t z1,Double_t z2)
1036 //-----------------------------------------------------------------
1037 // Initial approximation of the tangent of the track dip angle
1038 //-----------------------------------------------------------------
1039 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1043 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1044 Double_t x2,Double_t y2,
1045 Double_t z1,Double_t z2, Double_t c)
1047 //-----------------------------------------------------------------
1048 // Initial approximation of the tangent of the track dip angle
1049 //-----------------------------------------------------------------
1053 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1055 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1056 if (TMath::Abs(d*c*0.5)>1) return 0;
1057 // Double_t angle2 = TMath::ASin(d*c*0.5);
1058 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1059 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1061 angle2 = (z1-z2)*c/(angle2*2.);
1065 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1066 {//-----------------------------------------------------------------
1067 // This function find proloncation of a track to a reference plane x=x2.
1068 //-----------------------------------------------------------------
1072 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1076 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1077 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1081 Double_t dy = dx*(c1+c2)/(r1+r2);
1084 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1086 if (TMath::Abs(delta)>0.01){
1087 dz = x[3]*TMath::ASin(delta)/x[4];
1089 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1092 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1100 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1105 return LoadClusters();
1108 Int_t AliTPCtrackerMI::LoadClusters()
1111 // load clusters to the memory
1112 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1113 clrow->SetClass("AliTPCclusterMI");
1115 clrow->GetArray()->ExpandCreateFast(10000);
1117 // TTree * tree = fClustersArray.GetTree();
1119 TTree * tree = fInput;
1120 TBranch * br = tree->GetBranch("Segment");
1121 br->SetAddress(&clrow);
1123 Int_t j=Int_t(tree->GetEntries());
1124 for (Int_t i=0; i<j; i++) {
1128 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1129 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1130 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1133 AliTPCRow * tpcrow=0;
1136 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1140 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1141 left = (sec-fkNIS*2)/fkNOS;
1144 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1145 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1146 for (Int_t i=0;i<tpcrow->fN1;i++)
1147 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1150 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1151 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1152 for (Int_t i=0;i<tpcrow->fN2;i++)
1153 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1164 void AliTPCtrackerMI::UnloadClusters()
1167 // unload clusters from the memory
1169 Int_t nrows = fOuterSec->GetNRows();
1170 for (Int_t sec = 0;sec<fkNOS;sec++)
1171 for (Int_t row = 0;row<nrows;row++){
1172 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1174 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1175 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1177 tpcrow->ResetClusters();
1180 nrows = fInnerSec->GetNRows();
1181 for (Int_t sec = 0;sec<fkNIS;sec++)
1182 for (Int_t row = 0;row<nrows;row++){
1183 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1185 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1186 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1188 tpcrow->ResetClusters();
1194 void AliTPCtrackerMI::Transform(AliCluster * cluster){
1198 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1199 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1200 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1202 mat->LocalToMaster(pos,posC);
1203 cluster->SetX(posC[0]);
1204 cluster->SetY(posC[1]);
1205 cluster->SetZ(posC[2]);
1208 //_____________________________________________________________________________
1209 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1210 //-----------------------------------------------------------------
1211 // This function fills outer TPC sectors with clusters.
1212 //-----------------------------------------------------------------
1213 Int_t nrows = fOuterSec->GetNRows();
1215 for (Int_t sec = 0;sec<fkNOS;sec++)
1216 for (Int_t row = 0;row<nrows;row++){
1217 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1218 Int_t sec2 = sec+2*fkNIS;
1220 Int_t ncl = tpcrow->fN1;
1222 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1223 index=(((sec2<<8)+row)<<16)+ncl;
1224 tpcrow->InsertCluster(c,index);
1229 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1230 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1231 tpcrow->InsertCluster(c,index);
1234 // write indexes for fast acces
1236 for (Int_t i=0;i<510;i++)
1237 tpcrow->fFastCluster[i]=-1;
1238 for (Int_t i=0;i<tpcrow->GetN();i++){
1239 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1240 tpcrow->fFastCluster[zi]=i; // write index
1243 for (Int_t i=0;i<510;i++){
1244 if (tpcrow->fFastCluster[i]<0)
1245 tpcrow->fFastCluster[i] = last;
1247 last = tpcrow->fFastCluster[i];
1256 //_____________________________________________________________________________
1257 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1258 //-----------------------------------------------------------------
1259 // This function fills inner TPC sectors with clusters.
1260 //-----------------------------------------------------------------
1261 Int_t nrows = fInnerSec->GetNRows();
1263 for (Int_t sec = 0;sec<fkNIS;sec++)
1264 for (Int_t row = 0;row<nrows;row++){
1265 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1268 Int_t ncl = tpcrow->fN1;
1270 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1271 index=(((sec<<8)+row)<<16)+ncl;
1272 tpcrow->InsertCluster(c,index);
1277 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1278 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1279 tpcrow->InsertCluster(c,index);
1282 // write indexes for fast acces
1284 for (Int_t i=0;i<510;i++)
1285 tpcrow->fFastCluster[i]=-1;
1286 for (Int_t i=0;i<tpcrow->GetN();i++){
1287 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1288 tpcrow->fFastCluster[zi]=i; // write index
1291 for (Int_t i=0;i<510;i++){
1292 if (tpcrow->fFastCluster[i]<0)
1293 tpcrow->fFastCluster[i] = last;
1295 last = tpcrow->fFastCluster[i];
1307 //_________________________________________________________________________
1308 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1309 //--------------------------------------------------------------------
1310 // Return pointer to a given cluster
1311 //--------------------------------------------------------------------
1312 Int_t sec=(index&0xff000000)>>24;
1313 Int_t row=(index&0x00ff0000)>>16;
1314 Int_t ncl=(index&0x00007fff)>>00;
1316 const AliTPCRow * tpcrow=0;
1317 AliTPCclusterMI * clrow =0;
1319 if (sec<0 || sec>=fkNIS*4) {
1320 AliWarning(Form("Wrong sector %d",sec));
1325 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1326 if (tpcrow==0) return 0;
1329 if (tpcrow->fN1<=ncl) return 0;
1330 clrow = tpcrow->fClusters1;
1333 if (tpcrow->fN2<=ncl) return 0;
1334 clrow = tpcrow->fClusters2;
1338 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1339 if (tpcrow==0) return 0;
1341 if (sec-2*fkNIS<fkNOS) {
1342 if (tpcrow->fN1<=ncl) return 0;
1343 clrow = tpcrow->fClusters1;
1346 if (tpcrow->fN2<=ncl) return 0;
1347 clrow = tpcrow->fClusters2;
1351 return &(clrow[ncl]);
1357 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1358 //-----------------------------------------------------------------
1359 // This function tries to find a track prolongation to next pad row
1360 //-----------------------------------------------------------------
1362 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1363 AliTPCclusterMI *cl=0;
1364 Int_t tpcindex= t.GetClusterIndex2(nr);
1366 // update current shape info every 5 pad-row
1367 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1371 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1373 if (tpcindex==-1) return 0; //track in dead zone
1375 cl = t.fClusterPointer[nr];
1376 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1377 t.fCurrentClusterIndex1 = tpcindex;
1380 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1381 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1383 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1384 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1386 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1387 Double_t rotation = angle-t.GetAlpha();
1388 t.fRelativeSector= relativesector;
1389 if (!t.Rotate(rotation)) return 0;
1391 if (!t.PropagateTo(x)) return 0;
1393 t.fCurrentCluster = cl;
1395 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1396 if ((tpcindex&0x8000)==0) accept =0;
1398 //if founded cluster is acceptible
1399 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1406 UpdateTrack(&t,accept);
1411 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1413 // not look for new cluster during refitting
1419 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1420 Double_t y=t.GetYat(x);
1421 if (TMath::Abs(y)>ymax){
1423 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1424 if (!t.Rotate(fSectors->GetAlpha()))
1426 } else if (y <-ymax) {
1427 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1428 if (!t.Rotate(-fSectors->GetAlpha()))
1434 if (!t.PropagateTo(x)) {
1435 if (fIteration==0) t.fRemoval = 10;
1439 Double_t z=t.GetZ();
1441 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1442 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1444 Double_t roadz = 1.;
1446 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1448 t.SetClusterIndex2(nr,-1);
1453 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1460 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1461 cl = krow.FindNearest2(y,z,roady,roadz,index);
1462 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1465 t.fCurrentCluster = cl;
1467 if (fIteration==2&&cl->IsUsed(10)) return 0;
1468 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1469 if (fIteration==2&&cl->IsUsed(11)) {
1476 if (t.fCurrentCluster->IsUsed(10)){
1481 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1487 if (accept<3) UpdateTrack(&t,accept);
1490 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1496 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1497 //-----------------------------------------------------------------
1498 // This function tries to find a track prolongation to next pad row
1499 //-----------------------------------------------------------------
1501 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1503 if (!t.GetProlongation(x,y,z)) {
1509 if (TMath::Abs(y)>ymax){
1512 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1513 if (!t.Rotate(fSectors->GetAlpha()))
1515 } else if (y <-ymax) {
1516 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1517 if (!t.Rotate(-fSectors->GetAlpha()))
1520 if (!t.PropagateTo(x)) {
1523 t.GetProlongation(x,y,z);
1526 // update current shape info every 3 pad-row
1527 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1528 // t.fCurrentSigmaY = GetSigmaY(&t);
1529 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1533 AliTPCclusterMI *cl=0;
1538 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1539 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1541 Double_t roadz = 1.;
1544 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1546 t.SetClusterIndex2(row,-1);
1551 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1555 if ((cl==0)&&(krow)) {
1556 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1557 cl = krow.FindNearest2(y,z,roady,roadz,index);
1559 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1563 t.fCurrentCluster = cl;
1564 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1566 t.SetClusterIndex2(row,index);
1567 t.fClusterPointer[row] = cl;
1575 //_________________________________________________________________________
1576 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1578 // Get track space point by index
1579 // return false in case the cluster doesn't exist
1580 AliTPCclusterMI *cl = GetClusterMI(index);
1581 if (!cl) return kFALSE;
1582 Int_t sector = (index&0xff000000)>>24;
1583 // Int_t row = (index&0x00ff0000)>>16;
1585 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1586 xyz[0] = cl->GetX();
1587 xyz[1] = cl->GetY();
1588 xyz[2] = cl->GetZ();
1590 fParam->AdjustCosSin(sector,cos,sin);
1591 Float_t x = cos*xyz[0]-sin*xyz[1];
1592 Float_t y = cos*xyz[1]+sin*xyz[0];
1594 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1595 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1596 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1597 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1598 cov[0] = sin*sin*sigmaY2;
1599 cov[1] = -sin*cos*sigmaY2;
1601 cov[3] = cos*cos*sigmaY2;
1604 p.SetXYZ(x,y,xyz[2],cov);
1605 AliAlignObj::ELayerID iLayer;
1607 if (sector < fParam->GetNInnerSector()) {
1608 iLayer = AliAlignObj::kTPC1;
1612 iLayer = AliAlignObj::kTPC2;
1613 idet = sector - fParam->GetNInnerSector();
1615 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1616 p.SetVolumeID(volid);
1622 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1623 //-----------------------------------------------------------------
1624 // This function tries to find a track prolongation to next pad row
1625 //-----------------------------------------------------------------
1626 t.fCurrentCluster = 0;
1627 t.fCurrentClusterIndex1 = 0;
1629 Double_t xt=t.GetX();
1630 Int_t row = GetRowNumber(xt)-1;
1631 Double_t ymax= GetMaxY(nr);
1633 if (row < nr) return 1; // don't prolongate if not information until now -
1634 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1636 // return 0; // not prolongate strongly inclined tracks
1638 // if (TMath::Abs(t.GetSnp())>0.95) {
1640 // return 0; // not prolongate strongly inclined tracks
1641 // }// patch 28 fev 06
1643 Double_t x= GetXrow(nr);
1645 //t.PropagateTo(x+0.02);
1646 //t.PropagateTo(x+0.01);
1647 if (!t.PropagateTo(x)){
1654 if (TMath::Abs(y)>ymax){
1656 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1657 if (!t.Rotate(fSectors->GetAlpha()))
1659 } else if (y <-ymax) {
1660 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1661 if (!t.Rotate(-fSectors->GetAlpha()))
1664 // if (!t.PropagateTo(x)){
1671 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1672 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1674 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1676 t.SetClusterIndex2(nr,-1);
1681 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.fNFoundable++;
1687 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1688 // t.fCurrentSigmaY = GetSigmaY(&t);
1689 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1693 AliTPCclusterMI *cl=0;
1696 Double_t roady = 1.;
1697 Double_t roadz = 1.;
1701 index = t.GetClusterIndex2(nr);
1702 if ( (index>0) && (index&0x8000)==0){
1703 cl = t.fClusterPointer[nr];
1704 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1705 t.fCurrentClusterIndex1 = index;
1707 t.fCurrentCluster = cl;
1713 // if (index<0) return 0;
1714 UInt_t uindex = TMath::Abs(index);
1717 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1718 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1721 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1722 t.fCurrentCluster = cl;
1728 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1729 //-----------------------------------------------------------------
1730 // This function tries to find a track prolongation to next pad row
1731 //-----------------------------------------------------------------
1733 //update error according neighborhoud
1735 if (t.fCurrentCluster) {
1737 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1739 if (t.fCurrentCluster->IsUsed(10)){
1745 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1750 if (fIteration>0) accept = 0;
1751 if (accept<3) UpdateTrack(&t,accept);
1755 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1756 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1758 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1766 //_____________________________________________________________________________
1767 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1768 //-----------------------------------------------------------------
1769 // This function tries to find a track prolongation.
1770 //-----------------------------------------------------------------
1771 Double_t xt=t.GetX();
1773 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1774 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1775 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1777 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1779 Int_t first = GetRowNumber(xt)-1;
1780 for (Int_t nr= first; nr>=rf; nr-=step) {
1782 if (t.GetKinkIndexes()[0]>0){
1783 for (Int_t i=0;i<3;i++){
1784 Int_t index = t.GetKinkIndexes()[i];
1785 if (index==0) break;
1786 if (index<0) continue;
1788 AliESDkink * kink = fEvent->GetKink(index-1);
1790 printf("PROBLEM\n");
1793 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1795 AliExternalTrackParam paramd(t);
1796 kink->SetDaughter(paramd);
1797 kink->SetStatus(2,5);
1804 if (nr==80) t.UpdateReference();
1805 if (nr<fInnerSec->GetNRows())
1806 fSectors = fInnerSec;
1808 fSectors = fOuterSec;
1809 if (FollowToNext(t,nr)==0)
1818 //_____________________________________________________________________________
1819 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1820 //-----------------------------------------------------------------
1821 // This function tries to find a track prolongation.
1822 //-----------------------------------------------------------------
1823 Double_t xt=t.GetX();
1825 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1826 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1827 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1828 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1830 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1832 if (FollowToNextFast(t,nr)==0)
1833 if (!t.IsActive()) return 0;
1843 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1844 //-----------------------------------------------------------------
1845 // This function tries to find a track prolongation.
1846 //-----------------------------------------------------------------
1848 Double_t xt=t.GetX();
1849 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1850 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1851 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1852 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1854 Int_t first = t.fFirstPoint;
1855 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1857 if (first<0) first=0;
1858 for (Int_t nr=first; nr<=rf; nr++) {
1859 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1860 if (t.GetKinkIndexes()[0]<0){
1861 for (Int_t i=0;i<3;i++){
1862 Int_t index = t.GetKinkIndexes()[i];
1863 if (index==0) break;
1864 if (index>0) continue;
1865 index = TMath::Abs(index);
1866 AliESDkink * kink = fEvent->GetKink(index-1);
1868 printf("PROBLEM\n");
1871 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1873 AliExternalTrackParam paramm(t);
1874 kink->SetMother(paramm);
1875 kink->SetStatus(2,1);
1882 if (nr<fInnerSec->GetNRows())
1883 fSectors = fInnerSec;
1885 fSectors = fOuterSec;
1895 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1903 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1906 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1908 Float_t distance = TMath::Sqrt(dz2+dy2);
1909 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1912 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1913 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1918 if (firstpoint>lastpoint) {
1919 firstpoint =lastpoint;
1924 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1925 if (s1->GetClusterIndex2(i)>0) sum1++;
1926 if (s2->GetClusterIndex2(i)>0) sum2++;
1927 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1931 if (sum<5) return 0;
1933 Float_t summin = TMath::Min(sum1+1,sum2+1);
1934 Float_t ratio = (sum+1)/Float_t(summin);
1938 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1942 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1943 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1945 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1947 Float_t dy2 =(s1->GetY() - s2->GetY());
1949 Float_t distance = dz2+dy2;
1950 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1955 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1956 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1958 if (firstpoint>=lastpoint-5) return;;
1960 for (Int_t i=firstpoint;i<lastpoint;i++){
1961 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1962 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1969 for (Int_t i=firstpoint;i<lastpoint;i++){
1970 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1971 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1972 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1973 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1974 if (s1->IsActive()&&s2->IsActive()){
1975 p1->fIsShared = kTRUE;
1976 p2->fIsShared = kTRUE;
1983 for (Int_t i=0;i<4;i++){
1984 if (s1->fOverlapLabels[3*i]==0){
1985 s1->fOverlapLabels[3*i] = s2->GetLabel();
1986 s1->fOverlapLabels[3*i+1] = sumshared;
1987 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1991 for (Int_t i=0;i<4;i++){
1992 if (s2->fOverlapLabels[3*i]==0){
1993 s2->fOverlapLabels[3*i] = s1->GetLabel();
1994 s2->fOverlapLabels[3*i+1] = sumshared;
1995 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2003 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2006 //sort trackss according sectors
2008 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2009 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2011 //if (pt) RotateToLocal(pt);
2015 arr->Sort(); // sorting according z
2016 arr->Expand(arr->GetEntries());
2019 Int_t nseed=arr->GetEntriesFast();
2020 for (Int_t i=0; i<nseed; i++) {
2021 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2023 for (Int_t j=0;j<=12;j++){
2024 pt->fOverlapLabels[j] =0;
2027 for (Int_t i=0; i<nseed; i++) {
2028 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2030 if (pt->fRemoval>10) continue;
2031 for (Int_t j=i+1; j<nseed; j++){
2032 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2034 if (pt2->fRemoval<=10) {
2035 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2042 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2045 //sort trackss according sectors
2048 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2051 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2052 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2057 arr->Sort(); // sorting according z
2058 arr->Expand(arr->GetEntries());
2060 //reset overlap labels
2062 Int_t nseed=arr->GetEntriesFast();
2063 for (Int_t i=0; i<nseed; i++) {
2064 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2067 for (Int_t j=0;j<=12;j++){
2068 pt->fOverlapLabels[j] =0;
2072 //sign shared tracks
2073 for (Int_t i=0; i<nseed; i++) {
2074 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2076 if (pt->fRemoval>10) continue;
2077 Float_t deltac = pt->GetC()*0.1;
2078 for (Int_t j=i+1; j<nseed; j++){
2079 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2081 if (pt2->fRemoval<=10) {
2082 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2083 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2084 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2091 // remove highly shared tracks
2092 for (Int_t i=0; i<nseed; i++) {
2093 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2095 if (pt->fRemoval>10) continue;
2098 for (Int_t j=0;j<4;j++){
2099 sumshared = pt->fOverlapLabels[j*3+1];
2101 Float_t factor = factor1;
2102 if (pt->fRemoval>0) factor = factor2;
2103 if (sumshared/pt->GetNumberOfClusters()>factor){
2104 for (Int_t j=0;j<4;j++){
2105 if (pt->fOverlapLabels[3*j]==0) continue;
2106 if (pt->fOverlapLabels[3*j+1]<5) continue;
2107 if (pt->fRemoval==removalindex) continue;
2108 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2110 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2111 // pt->fRemoval = removalindex;
2112 delete arr->RemoveAt(i);
2120 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2129 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2132 //sort tracks in array according mode criteria
2133 Int_t nseed = arr->GetEntriesFast();
2134 for (Int_t i=0; i<nseed; i++) {
2135 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2145 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2148 //Loop over all tracks and remove "overlaps"
2151 Int_t nseed = arr->GetEntriesFast();
2154 for (Int_t i=0; i<nseed; i++) {
2155 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2157 delete arr->RemoveAt(i);
2161 pt->fBSigned = kFALSE;
2165 nseed = arr->GetEntriesFast();
2172 for (Int_t i=0; i<nseed; i++) {
2173 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2177 Int_t found,foundable,shared;
2179 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2181 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2183 Double_t factor = factor2;
2184 if (pt->fBConstrain) factor = factor1;
2186 if ((Float_t(shared)/Float_t(found))>factor){
2187 pt->Desactivate(removalindex);
2192 for (Int_t i=0; i<160; i++) {
2193 Int_t index=pt->GetClusterIndex2(i);
2194 if (index<0 || index&0x8000 ) continue;
2195 AliTPCclusterMI *c= pt->fClusterPointer[i];
2197 // if (!c->IsUsed(10)) c->Use(10);
2198 //if (pt->IsActive())
2207 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2212 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2215 //Loop over all tracks and remove "overlaps"
2220 Int_t nseed = arr->GetEntriesFast();
2221 Float_t * quality = new Float_t[nseed];
2222 Int_t * indexes = new Int_t[nseed];
2226 for (Int_t i=0; i<nseed; i++) {
2227 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2232 pt->UpdatePoints(); //select first last max dens points
2233 Float_t * points = pt->GetPoints();
2234 if (points[3]<0.8) quality[i] =-1;
2236 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2238 TMath::Sort(nseed,quality,indexes);
2241 for (Int_t itrack=0; itrack<nseed; itrack++) {
2242 Int_t trackindex = indexes[itrack];
2243 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2244 if (quality[trackindex]<0){
2246 delete arr->RemoveAt(trackindex);
2249 arr->RemoveAt(trackindex);
2254 Int_t first = Int_t(pt->GetPoints()[0]);
2255 Int_t last = Int_t(pt->GetPoints()[2]);
2256 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2258 Int_t found,foundable,shared;
2259 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2260 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2261 Bool_t itsgold =kFALSE;
2264 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
2268 if (Float_t(shared+1)/Float_t(found+1)>factor){
2269 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2270 delete arr->RemoveAt(trackindex);
2273 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2274 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2275 delete arr->RemoveAt(trackindex);
2281 if (sharedfactor>0.4) continue;
2282 if (pt->GetKinkIndexes()[0]>0) continue;
2283 for (Int_t i=first; i<last; i++) {
2284 Int_t index=pt->GetClusterIndex2(i);
2285 // if (index<0 || index&0x8000 ) continue;
2286 if (index<0 || index&0x8000 ) continue;
2287 AliTPCclusterMI *c= pt->fClusterPointer[i];
2294 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2300 void AliTPCtrackerMI::UnsignClusters()
2303 // loop over all clusters and unsign them
2306 for (Int_t sec=0;sec<fkNIS;sec++){
2307 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2308 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2309 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2310 // if (cl[icl].IsUsed(10))
2312 cl = fInnerSec[sec][row].fClusters2;
2313 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2314 //if (cl[icl].IsUsed(10))
2319 for (Int_t sec=0;sec<fkNOS;sec++){
2320 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2321 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2322 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2323 //if (cl[icl].IsUsed(10))
2325 cl = fOuterSec[sec][row].fClusters2;
2326 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2327 //if (cl[icl].IsUsed(10))
2336 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2339 //sign clusters to be "used"
2341 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2342 // loop over "primaries"
2356 Int_t nseed = arr->GetEntriesFast();
2357 for (Int_t i=0; i<nseed; i++) {
2358 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2362 if (!(pt->IsActive())) continue;
2363 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2364 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2366 sumdens2+= dens*dens;
2367 sumn += pt->GetNumberOfClusters();
2368 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2369 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2372 sumchi2 +=chi2*chi2;
2377 Float_t mdensity = 0.9;
2378 Float_t meann = 130;
2379 Float_t meanchi = 1;
2380 Float_t sdensity = 0.1;
2381 Float_t smeann = 10;
2382 Float_t smeanchi =0.4;
2386 mdensity = sumdens/sum;
2388 meanchi = sumchi/sum;
2390 sdensity = sumdens2/sum-mdensity*mdensity;
2391 sdensity = TMath::Sqrt(sdensity);
2393 smeann = sumn2/sum-meann*meann;
2394 smeann = TMath::Sqrt(smeann);
2396 smeanchi = sumchi2/sum - meanchi*meanchi;
2397 smeanchi = TMath::Sqrt(smeanchi);
2401 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2403 for (Int_t i=0; i<nseed; i++) {
2404 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2408 if (pt->fBSigned) continue;
2409 if (pt->fBConstrain) continue;
2410 //if (!(pt->IsActive())) continue;
2412 Int_t found,foundable,shared;
2413 pt->GetClusterStatistic(0,160,found, foundable,shared);
2414 if (shared/float(found)>0.3) {
2415 if (shared/float(found)>0.9 ){
2416 //delete arr->RemoveAt(i);
2421 Bool_t isok =kFALSE;
2422 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2424 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2426 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2428 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2432 for (Int_t i=0; i<160; i++) {
2433 Int_t index=pt->GetClusterIndex2(i);
2434 if (index<0) continue;
2435 AliTPCclusterMI *c= pt->fClusterPointer[i];
2437 //if (!(c->IsUsed(10))) c->Use();
2444 Double_t maxchi = meanchi+2.*smeanchi;
2446 for (Int_t i=0; i<nseed; i++) {
2447 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2451 //if (!(pt->IsActive())) continue;
2452 if (pt->fBSigned) continue;
2453 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2454 if (chi>maxchi) continue;
2457 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2459 //sign only tracks with enoug big density at the beginning
2461 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2464 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2465 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2467 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2468 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2471 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2472 //Int_t noc=pt->GetNumberOfClusters();
2473 pt->fBSigned = kTRUE;
2474 for (Int_t i=0; i<160; i++) {
2476 Int_t index=pt->GetClusterIndex2(i);
2477 if (index<0) continue;
2478 AliTPCclusterMI *c= pt->fClusterPointer[i];
2480 // if (!(c->IsUsed(10))) c->Use();
2485 // gLastCheck = nseed;
2493 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2495 // stop not active tracks
2496 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2497 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2498 Int_t nseed = arr->GetEntriesFast();
2500 for (Int_t i=0; i<nseed; i++) {
2501 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2505 if (!(pt->IsActive())) continue;
2506 StopNotActive(pt,row0,th0, th1,th2);
2512 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2515 // stop not active tracks
2516 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2517 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2520 Int_t foundable = 0;
2521 Int_t maxindex = seed->fLastPoint; //last foundable row
2522 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2523 seed->Desactivate(10) ;
2527 for (Int_t i=row0; i<maxindex; i++){
2528 Int_t index = seed->GetClusterIndex2(i);
2529 if (index!=-1) foundable++;
2531 if (foundable<=30) sumgood1++;
2532 if (foundable<=50) {
2539 if (foundable>=30.){
2540 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2543 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2547 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2550 // back propagation of ESD tracks
2556 //PrepareForProlongation(fSeeds,1);
2557 PropagateForward2(fSeeds);
2560 Int_t nseed = fSeeds->GetEntriesFast();
2561 for (Int_t i=0;i<nseed;i++){
2562 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2563 if (!seed) continue;
2564 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2566 seed->PropagateTo(fParam->GetInnerRadiusLow());
2567 seed->UpdatePoints();
2568 AliESDtrack *esd=event->GetTrack(i);
2569 seed->CookdEdx(0.02,0.6);
2570 CookLabel(seed,0.1); //For comparison only
2572 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2573 TTreeSRedirector &cstream = *fDebugStreamer;
2579 if (seed->GetNumberOfClusters()>15){
2580 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2581 esd->SetTPCPoints(seed->GetPoints());
2582 esd->SetTPCPointsF(seed->fNFoundable);
2583 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2584 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2585 Float_t dedx = seed->GetdEdx();
2586 esd->SetTPCsignal(dedx, sdedx, ndedx);
2590 //printf("problem\n");
2593 //FindKinks(fSeeds,event);
2594 Info("RefitInward","Number of refitted tracks %d",ntracks);
2601 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2604 // back propagation of ESD tracks
2610 PropagateBack(fSeeds);
2611 RemoveUsed2(fSeeds,0.4,0.4,20);
2613 Int_t nseed = fSeeds->GetEntriesFast();
2615 for (Int_t i=0;i<nseed;i++){
2616 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2617 if (!seed) continue;
2618 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2619 seed->UpdatePoints();
2620 AliESDtrack *esd=event->GetTrack(i);
2621 seed->CookdEdx(0.02,0.6);
2622 CookLabel(seed,0.1); //For comparison only
2623 if (seed->GetNumberOfClusters()>15){
2624 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2625 esd->SetTPCPoints(seed->GetPoints());
2626 esd->SetTPCPointsF(seed->fNFoundable);
2627 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2628 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2629 Float_t dedx = seed->GetdEdx();
2630 esd->SetTPCsignal(dedx, sdedx, ndedx);
2632 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2633 (*fDebugStreamer)<<"Cback"<<
2635 "EventNr="<<eventnumber<<
2636 "\n"; // patch 28 fev 06
2639 //FindKinks(fSeeds,event);
2640 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2647 void AliTPCtrackerMI::DeleteSeeds()
2651 Int_t nseed = fSeeds->GetEntriesFast();
2652 for (Int_t i=0;i<nseed;i++){
2653 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2654 if (seed) delete fSeeds->RemoveAt(i);
2660 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2663 //read seeds from the event
2665 Int_t nentr=event->GetNumberOfTracks();
2667 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2672 fSeeds = new TObjArray(nentr);
2676 for (Int_t i=0; i<nentr; i++) {
2677 AliESDtrack *esd=event->GetTrack(i);
2678 ULong_t status=esd->GetStatus();
2679 if (!(status&AliESDtrack::kTPCin)) continue;
2680 AliTPCtrack t(*esd);
2681 t.SetNumberOfClusters(0);
2682 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2683 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2684 for (Int_t ikink=0;ikink<3;ikink++) {
2685 Int_t index = esd->GetKinkIndex(ikink);
2686 seed->GetKinkIndexes()[ikink] = index;
2687 if (index==0) continue;
2688 index = TMath::Abs(index);
2689 AliESDkink * kink = fEvent->GetKink(index-1);
2690 if (kink&&esd->GetKinkIndex(ikink)<0){
2691 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2692 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2694 if (kink&&esd->GetKinkIndex(ikink)>0){
2695 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2696 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2700 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance();
2701 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2702 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2707 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2708 Double_t par0[5],par1[5],alpha,x;
2709 esd->GetInnerExternalParameters(alpha,x,par0);
2710 esd->GetExternalParameters(x,par1);
2711 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2712 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2714 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2715 //reset covariance if suspicious
2716 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2717 seed->ResetCovariance();
2722 // rotate to the local coordinate system
2724 fSectors=fInnerSec; fN=fkNIS;
2725 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2726 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2727 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2728 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2729 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2730 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2731 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2732 alpha-=seed->GetAlpha();
2733 if (!seed->Rotate(alpha)) {
2739 if (esd->GetKinkIndex(0)<=0){
2740 for (Int_t irow=0;irow<160;irow++){
2741 Int_t index = seed->GetClusterIndex2(irow);
2744 AliTPCclusterMI * cl = GetClusterMI(index);
2745 seed->fClusterPointer[irow] = cl;
2747 if ((index & 0x8000)==0){
2748 cl->Use(10); // accepted cluster
2750 cl->Use(6); // close cluster not accepted
2753 Info("ReadSeeds","Not found cluster");
2758 fSeeds->AddAt(seed,i);
2764 //_____________________________________________________________________________
2765 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2766 Float_t deltay, Int_t ddsec) {
2767 //-----------------------------------------------------------------
2768 // This function creates track seeds.
2769 // SEEDING WITH VERTEX CONSTRAIN
2770 //-----------------------------------------------------------------
2771 // cuts[0] - fP4 cut
2772 // cuts[1] - tan(phi) cut
2773 // cuts[2] - zvertex cut
2774 // cuts[3] - fP3 cut
2782 Double_t x[5], c[15];
2783 // Int_t di = i1-i2;
2785 AliTPCseed * seed = new AliTPCseed;
2786 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2787 Double_t cs=cos(alpha), sn=sin(alpha);
2789 // Double_t x1 =fOuterSec->GetX(i1);
2790 //Double_t xx2=fOuterSec->GetX(i2);
2792 Double_t x1 =GetXrow(i1);
2793 Double_t xx2=GetXrow(i2);
2795 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2797 Int_t imiddle = (i2+i1)/2; //middle pad row index
2798 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2799 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2803 const AliTPCRow& kr1=GetRow(ns,i1);
2804 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2805 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2808 // change cut on curvature if it can't reach this layer
2809 // maximal curvature set to reach it
2810 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2811 if (dvertexmax*0.5*cuts[0]>0.85){
2812 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2814 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2817 if (deltay>0) ddsec = 0;
2818 // loop over clusters
2819 for (Int_t is=0; is < kr1; is++) {
2821 if (kr1[is]->IsUsed(10)) continue;
2822 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2823 //if (TMath::Abs(y1)>ymax) continue;
2825 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2827 // find possible directions
2828 Float_t anglez = (z1-z3)/(x1-x3);
2829 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2832 //find rotation angles relative to line given by vertex and point 1
2833 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2834 Double_t dvertex = TMath::Sqrt(dvertex2);
2835 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2836 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2839 // loop over 2 sectors
2845 Double_t dddz1=0; // direction of delta inclination in z axis
2852 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2853 Int_t sec2 = sec + dsec;
2855 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2856 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2857 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2858 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2859 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2860 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2862 // rotation angles to p1-p3
2863 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2864 Double_t x2, y2, z2;
2866 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2869 Double_t dxx0 = (xx2-x3)*cs13r;
2870 Double_t dyy0 = (xx2-x3)*sn13r;
2871 for (Int_t js=index1; js < index2; js++) {
2872 const AliTPCclusterMI *kcl = kr2[js];
2873 if (kcl->IsUsed(10)) continue;
2875 //calcutate parameters
2877 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2879 if (TMath::Abs(yy0)<0.000001) continue;
2880 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2881 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2882 Double_t r02 = (0.25+y0*y0)*dvertex2;
2883 //curvature (radius) cut
2884 if (r02<r2min) continue;
2888 Double_t c0 = 1/TMath::Sqrt(r02);
2892 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2893 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2894 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2895 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2898 Double_t z0 = kcl->GetZ();
2899 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2900 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2903 Double_t dip = (z1-z0)*c0/dfi1;
2904 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2915 x2= xx2*cs-y2*sn*dsec;
2916 y2=+xx2*sn*dsec+y2*cs;
2926 // do we have cluster at the middle ?
2928 GetProlongation(x1,xm,x,ym,zm);
2930 AliTPCclusterMI * cm=0;
2931 if (TMath::Abs(ym)-ymaxm<0){
2932 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2933 if ((!cm) || (cm->IsUsed(10))) {
2938 // rotate y1 to system 0
2939 // get state vector in rotated system
2940 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2941 Double_t xr2 = x0*cs+yr1*sn*dsec;
2942 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2944 GetProlongation(xx2,xm,xr,ym,zm);
2945 if (TMath::Abs(ym)-ymaxm<0){
2946 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2947 if ((!cm) || (cm->IsUsed(10))) {
2957 dym = ym - cm->GetY();
2958 dzm = zm - cm->GetZ();
2965 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2966 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2967 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2968 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2969 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2971 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2972 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2973 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2974 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2975 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2976 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2978 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2979 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2980 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2981 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2985 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2986 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2987 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2988 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2989 c[13]=f30*sy1*f40+f32*sy2*f42;
2990 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2992 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2994 UInt_t index=kr1.GetIndex(is);
2995 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2997 track->fIsSeeding = kTRUE;
3004 FollowProlongation(*track, (i1+i2)/2,1);
3005 Int_t foundable,found,shared;
3006 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3007 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3009 seed->~AliTPCseed();
3015 FollowProlongation(*track, i2,1);
3019 track->fBConstrain =1;
3020 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3021 track->fLastPoint = i1; // first cluster in track position
3022 track->fFirstPoint = track->fLastPoint;
3024 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3025 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3026 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3028 seed->~AliTPCseed();
3032 // Z VERTEX CONDITION
3034 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3035 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3036 if (TMath::Abs(zv-z3)>cuts[2]) {
3037 FollowProlongation(*track, TMath::Max(i2-20,0));
3038 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3039 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3040 if (TMath::Abs(zv-z3)>cuts[2]){
3041 FollowProlongation(*track, TMath::Max(i2-40,0));
3042 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3043 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3044 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3045 // make seed without constrain
3046 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3047 FollowProlongation(*track2, i2,1);
3048 track2->fBConstrain = kFALSE;
3049 track2->fSeedType = 1;
3050 arr->AddLast(track2);
3052 seed->~AliTPCseed();
3057 seed->~AliTPCseed();
3064 track->fSeedType =0;
3065 arr->AddLast(track);
3066 seed = new AliTPCseed;
3068 // don't consider other combinations
3069 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3075 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3081 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3086 //-----------------------------------------------------------------
3087 // This function creates track seeds.
3088 //-----------------------------------------------------------------
3089 // cuts[0] - fP4 cut
3090 // cuts[1] - tan(phi) cut
3091 // cuts[2] - zvertex cut
3092 // cuts[3] - fP3 cut
3102 Double_t x[5], c[15];
3104 // make temporary seed
3105 AliTPCseed * seed = new AliTPCseed;
3106 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3107 // Double_t cs=cos(alpha), sn=sin(alpha);
3112 Double_t x1 = GetXrow(i1-1);
3113 const AliTPCRow& kr1=GetRow(sec,i1-1);
3114 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3116 Double_t x1p = GetXrow(i1);
3117 const AliTPCRow& kr1p=GetRow(sec,i1);
3119 Double_t x1m = GetXrow(i1-2);
3120 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3123 //last 3 padrow for seeding
3124 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3125 Double_t x3 = GetXrow(i1-7);
3126 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3128 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3129 Double_t x3p = GetXrow(i1-6);
3131 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3132 Double_t x3m = GetXrow(i1-8);
3137 Int_t im = i1-4; //middle pad row index
3138 Double_t xm = GetXrow(im); // radius of middle pad-row
3139 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3140 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3143 Double_t deltax = x1-x3;
3144 Double_t dymax = deltax*cuts[1];
3145 Double_t dzmax = deltax*cuts[3];
3147 // loop over clusters
3148 for (Int_t is=0; is < kr1; is++) {
3150 if (kr1[is]->IsUsed(10)) continue;
3151 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3153 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3155 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3156 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3162 for (Int_t js=index1; js < index2; js++) {
3163 const AliTPCclusterMI *kcl = kr3[js];
3164 if (kcl->IsUsed(10)) continue;
3166 // apply angular cuts
3167 if (TMath::Abs(y1-y3)>dymax) continue;
3170 if (TMath::Abs(z1-z3)>dzmax) continue;
3172 Double_t angley = (y1-y3)/(x1-x3);
3173 Double_t anglez = (z1-z3)/(x1-x3);
3175 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3176 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3178 Double_t yyym = angley*(xm-x1)+y1;
3179 Double_t zzzm = anglez*(xm-x1)+z1;
3181 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3183 if (kcm->IsUsed(10)) continue;
3185 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3186 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3193 // look around first
3194 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3200 if (kc1m->IsUsed(10)) used++;
3202 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3208 if (kc1p->IsUsed(10)) used++;
3210 if (used>1) continue;
3211 if (found<1) continue;
3215 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3221 if (kc3m->IsUsed(10)) used++;
3225 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3231 if (kc3p->IsUsed(10)) used++;
3235 if (used>1) continue;
3236 if (found<3) continue;
3246 x[4]=F1(x1,y1,x2,y2,x3,y3);
3247 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3250 x[2]=F2(x1,y1,x2,y2,x3,y3);
3253 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3254 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3258 Double_t sy1=0.1, sz1=0.1;
3259 Double_t sy2=0.1, sz2=0.1;
3260 Double_t sy3=0.1, sy=0.1, sz=0.1;
3262 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3263 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3264 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3265 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3266 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3267 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3269 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3270 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3271 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3272 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3276 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3277 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3278 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3279 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3280 c[13]=f30*sy1*f40+f32*sy2*f42;
3281 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3283 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3285 UInt_t index=kr1.GetIndex(is);
3286 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3288 track->fIsSeeding = kTRUE;
3291 FollowProlongation(*track, i1-7,1);
3292 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3293 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3295 seed->~AliTPCseed();
3301 FollowProlongation(*track, i2,1);
3302 track->fBConstrain =0;
3303 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3304 track->fFirstPoint = track->fLastPoint;
3306 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3307 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3308 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3310 seed->~AliTPCseed();
3315 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3316 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3317 FollowProlongation(*track2, i2,1);
3318 track2->fBConstrain = kFALSE;
3319 track2->fSeedType = 4;
3320 arr->AddLast(track2);
3322 seed->~AliTPCseed();
3326 //arr->AddLast(track);
3327 //seed = new AliTPCseed;
3333 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3339 //_____________________________________________________________________________
3340 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3341 Float_t deltay, Bool_t /*bconstrain*/) {
3342 //-----------------------------------------------------------------
3343 // This function creates track seeds - without vertex constraint
3344 //-----------------------------------------------------------------
3345 // cuts[0] - fP4 cut - not applied
3346 // cuts[1] - tan(phi) cut
3347 // cuts[2] - zvertex cut - not applied
3348 // cuts[3] - fP3 cut
3358 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3359 // Double_t cs=cos(alpha), sn=sin(alpha);
3360 Int_t row0 = (i1+i2)/2;
3361 Int_t drow = (i1-i2)/2;
3362 const AliTPCRow& kr0=fSectors[sec][row0];
3365 AliTPCpolyTrack polytrack;
3366 Int_t nclusters=fSectors[sec][row0];
3367 AliTPCseed * seed = new AliTPCseed;
3372 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3374 Int_t nfoundable =0;
3375 for (Int_t iter =1; iter<2; iter++){ //iterations
3376 const AliTPCRow& krm=fSectors[sec][row0-iter];
3377 const AliTPCRow& krp=fSectors[sec][row0+iter];
3378 const AliTPCclusterMI * cl= kr0[is];
3380 if (cl->IsUsed(10)) {
3386 Double_t x = kr0.GetX();
3387 // Initialization of the polytrack
3392 Double_t y0= cl->GetY();
3393 Double_t z0= cl->GetZ();
3397 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3398 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3400 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3401 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3402 polytrack.AddPoint(x,y0,z0,erry, errz);
3405 if (cl->IsUsed(10)) sumused++;
3408 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3409 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3412 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3413 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3414 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3415 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3416 if (cl1->IsUsed(10)) sumused++;
3417 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3421 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3423 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3424 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3425 if (cl2->IsUsed(10)) sumused++;
3426 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3429 if (sumused>0) continue;
3431 polytrack.UpdateParameters();
3437 nfoundable = polytrack.GetN();
3438 nfound = nfoundable;
3440 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3441 Float_t maxdist = 0.8*(1.+3./(ddrow));
3442 for (Int_t delta = -1;delta<=1;delta+=2){
3443 Int_t row = row0+ddrow*delta;
3444 kr = &(fSectors[sec][row]);
3445 Double_t xn = kr->GetX();
3446 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3447 polytrack.GetFitPoint(xn,yn,zn);
3448 if (TMath::Abs(yn)>ymax) continue;
3450 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3452 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3455 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3456 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3457 if (cln->IsUsed(10)) {
3458 // printf("used\n");
3466 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3471 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3472 polytrack.UpdateParameters();
3475 if ( (sumused>3) || (sumused>0.5*nfound)) {
3476 //printf("sumused %d\n",sumused);
3481 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3482 AliTPCpolyTrack track2;
3484 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3485 if (track2.GetN()<0.5*nfoundable) continue;
3488 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3490 // test seed with and without constrain
3491 for (Int_t constrain=0; constrain<=0;constrain++){
3492 // add polytrack candidate
3494 Double_t x[5], c[15];
3495 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3496 track2.GetBoundaries(x3,x1);
3498 track2.GetFitPoint(x1,y1,z1);
3499 track2.GetFitPoint(x2,y2,z2);
3500 track2.GetFitPoint(x3,y3,z3);
3502 //is track pointing to the vertex ?
3505 polytrack.GetFitPoint(x0,y0,z0);
3518 x[4]=F1(x1,y1,x2,y2,x3,y3);
3520 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3521 x[2]=F2(x1,y1,x2,y2,x3,y3);
3523 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3524 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3525 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3526 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3529 Double_t sy =0.1, sz =0.1;
3530 Double_t sy1=0.02, sz1=0.02;
3531 Double_t sy2=0.02, sz2=0.02;
3535 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3538 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3539 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3540 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3541 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3542 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3543 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3545 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3546 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3547 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3548 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3553 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3554 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3555 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3556 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3557 c[13]=f30*sy1*f40+f32*sy2*f42;
3558 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3560 //Int_t row1 = fSectors->GetRowNumber(x1);
3561 Int_t row1 = GetRowNumber(x1);
3565 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3566 track->fIsSeeding = kTRUE;
3567 Int_t rc=FollowProlongation(*track, i2);
3568 if (constrain) track->fBConstrain =1;
3570 track->fBConstrain =0;
3571 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3572 track->fFirstPoint = track->fLastPoint;
3574 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3575 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3576 track->fNShared>0.4*track->GetNumberOfClusters()) {
3579 seed->~AliTPCseed();
3582 arr->AddLast(track);
3583 seed = new AliTPCseed;
3587 } // if accepted seed
3590 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3596 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3600 //reseed using track points
3601 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3602 Int_t p1 = int(r1*track->GetNumberOfClusters());
3603 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3605 Double_t x0[3],x1[3],x2[3];
3606 for (Int_t i=0;i<3;i++){
3612 // find track position at given ratio of the length
3613 Int_t sec0=0, sec1=0, sec2=0;
3616 for (Int_t i=0;i<160;i++){
3617 if (track->fClusterPointer[i]){
3619 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3620 if ( (index<p0) || x0[0]<0 ){
3621 if (trpoint->GetX()>1){
3622 clindex = track->GetClusterIndex2(i);
3624 x0[0] = trpoint->GetX();
3625 x0[1] = trpoint->GetY();
3626 x0[2] = trpoint->GetZ();
3627 sec0 = ((clindex&0xff000000)>>24)%18;
3632 if ( (index<p1) &&(trpoint->GetX()>1)){
3633 clindex = track->GetClusterIndex2(i);
3635 x1[0] = trpoint->GetX();
3636 x1[1] = trpoint->GetY();
3637 x1[2] = trpoint->GetZ();
3638 sec1 = ((clindex&0xff000000)>>24)%18;
3641 if ( (index<p2) &&(trpoint->GetX()>1)){
3642 clindex = track->GetClusterIndex2(i);
3644 x2[0] = trpoint->GetX();
3645 x2[1] = trpoint->GetY();
3646 x2[2] = trpoint->GetZ();
3647 sec2 = ((clindex&0xff000000)>>24)%18;
3654 Double_t alpha, cs,sn, xx2,yy2;
3656 alpha = (sec1-sec2)*fSectors->GetAlpha();
3657 cs = TMath::Cos(alpha);
3658 sn = TMath::Sin(alpha);
3659 xx2= x1[0]*cs-x1[1]*sn;
3660 yy2= x1[0]*sn+x1[1]*cs;
3664 alpha = (sec0-sec2)*fSectors->GetAlpha();
3665 cs = TMath::Cos(alpha);
3666 sn = TMath::Sin(alpha);
3667 xx2= x0[0]*cs-x0[1]*sn;
3668 yy2= x0[0]*sn+x0[1]*cs;
3674 Double_t x[5],c[15];
3678 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3679 // if (x[4]>1) return 0;
3680 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3681 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3682 //if (TMath::Abs(x[3]) > 2.2) return 0;
3683 //if (TMath::Abs(x[2]) > 1.99) return 0;
3685 Double_t sy =0.1, sz =0.1;
3687 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3688 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3689 Double_t sy3=0.01+track->GetSigmaY2();
3691 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3692 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3693 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3694 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3695 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3696 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3698 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3699 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3700 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3701 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3706 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3707 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3708 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3709 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3710 c[13]=f30*sy1*f40+f32*sy2*f42;
3711 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3713 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3714 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3715 // Double_t y0,z0,y1,z1, y2,z2;
3716 //seed->GetProlongation(x0[0],y0,z0);
3717 // seed->GetProlongation(x1[0],y1,z1);
3718 //seed->GetProlongation(x2[0],y2,z2);
3720 seed->fLastPoint = pp2;
3721 seed->fFirstPoint = pp2;
3728 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3732 //reseed using founded clusters
3734 // Find the number of clusters
3735 Int_t nclusters = 0;
3736 for (Int_t irow=0;irow<160;irow++){
3737 if (track->GetClusterIndex(irow)>0) nclusters++;
3741 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3742 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3743 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3747 Int_t row[3],sec[3]={0,0,0};
3749 // find track row position at given ratio of the length
3751 for (Int_t irow=0;irow<160;irow++){
3752 if (track->GetClusterIndex2(irow)<0) continue;
3754 for (Int_t ipoint=0;ipoint<3;ipoint++){
3755 if (index<=ipos[ipoint]) row[ipoint] = irow;
3759 //Get cluster and sector position
3760 for (Int_t ipoint=0;ipoint<3;ipoint++){
3761 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3762 AliTPCclusterMI * cl = GetClusterMI(clindex);
3765 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3768 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3769 xyz[ipoint][0] = GetXrow(row[ipoint]);
3770 xyz[ipoint][1] = cl->GetY();
3771 xyz[ipoint][2] = cl->GetZ();
3775 // Calculate seed state vector and covariance matrix
3777 Double_t alpha, cs,sn, xx2,yy2;
3779 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3780 cs = TMath::Cos(alpha);
3781 sn = TMath::Sin(alpha);
3782 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3783 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3787 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3788 cs = TMath::Cos(alpha);
3789 sn = TMath::Sin(alpha);
3790 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3791 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3797 Double_t x[5],c[15];
3801 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3802 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3803 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3805 Double_t sy =0.1, sz =0.1;
3807 Double_t sy1=0.2, sz1=0.2;
3808 Double_t sy2=0.2, sz2=0.2;
3811 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;
3812 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;
3813 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;
3814 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;
3815 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;
3816 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;
3818 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;
3819 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;
3820 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;
3821 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;
3826 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3827 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3828 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3829 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3830 c[13]=f30*sy1*f40+f32*sy2*f42;
3831 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3833 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3834 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3835 seed->fLastPoint = row[2];
3836 seed->fFirstPoint = row[2];
3841 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3845 //reseed using founded clusters
3848 Int_t row[3]={0,0,0};
3849 Int_t sec[3]={0,0,0};
3851 // forward direction
3853 for (Int_t irow=r0;irow<160;irow++){
3854 if (track->GetClusterIndex(irow)>0){
3859 for (Int_t irow=160;irow>r0;irow--){
3860 if (track->GetClusterIndex(irow)>0){
3865 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3866 if (track->GetClusterIndex(irow)>0){
3874 for (Int_t irow=0;irow<r0;irow++){
3875 if (track->GetClusterIndex(irow)>0){
3880 for (Int_t irow=r0;irow>0;irow--){
3881 if (track->GetClusterIndex(irow)>0){
3886 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3887 if (track->GetClusterIndex(irow)>0){
3894 if ((row[2]-row[0])<20) return 0;
3895 if (row[1]==0) return 0;
3898 //Get cluster and sector position
3899 for (Int_t ipoint=0;ipoint<3;ipoint++){
3900 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3901 AliTPCclusterMI * cl = GetClusterMI(clindex);
3904 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3907 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3908 xyz[ipoint][0] = GetXrow(row[ipoint]);
3909 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3910 if (point&&ipoint<2){
3912 xyz[ipoint][1] = point->GetY();
3913 xyz[ipoint][2] = point->GetZ();
3916 xyz[ipoint][1] = cl->GetY();
3917 xyz[ipoint][2] = cl->GetZ();
3924 // Calculate seed state vector and covariance matrix
3926 Double_t alpha, cs,sn, xx2,yy2;
3928 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3929 cs = TMath::Cos(alpha);
3930 sn = TMath::Sin(alpha);
3931 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3932 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3936 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3937 cs = TMath::Cos(alpha);
3938 sn = TMath::Sin(alpha);
3939 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3940 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3946 Double_t x[5],c[15];
3950 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3951 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3952 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3954 Double_t sy =0.1, sz =0.1;
3956 Double_t sy1=0.2, sz1=0.2;
3957 Double_t sy2=0.2, sz2=0.2;
3960 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;
3961 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;
3962 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;
3963 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;
3964 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;
3965 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;
3967 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;
3968 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;
3969 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;
3970 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;
3975 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3976 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3977 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3978 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3979 c[13]=f30*sy1*f40+f32*sy2*f42;
3980 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3982 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3983 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3984 seed->fLastPoint = row[2];
3985 seed->fFirstPoint = row[2];
3986 for (Int_t i=row[0];i<row[2];i++){
3987 seed->fIndex[i] = track->fIndex[i];
3993 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4000 TObjArray *kinks= new TObjArray(10000);
4001 // TObjArray *v0s= new TObjArray(10000);
4002 Int_t nentries = array->GetEntriesFast();
4003 AliHelix *helixes = new AliHelix[nentries];
4004 Int_t *sign = new Int_t[nentries];
4005 Int_t *nclusters = new Int_t[nentries];
4006 Float_t *alpha = new Float_t[nentries];
4007 AliESDkink * kink = new AliESDkink();
4008 Int_t * usage = new Int_t[nentries];
4009 Float_t *zm = new Float_t[nentries];
4010 Float_t *z0 = new Float_t[nentries];
4011 Float_t *fim = new Float_t[nentries];
4012 Float_t *shared = new Float_t[nentries];
4013 Bool_t *circular = new Bool_t[nentries];
4014 Float_t *dca = new Float_t[nentries];
4015 //const AliESDVertex * primvertex = esd->GetVertex();
4017 // nentries = array->GetEntriesFast();
4022 for (Int_t i=0;i<nentries;i++){
4025 AliTPCseed* track = (AliTPCseed*)array->At(i);
4026 if (!track) continue;
4027 track->fCircular =0;
4029 track->UpdatePoints();
4030 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4032 nclusters[i]=track->GetNumberOfClusters();
4033 alpha[i] = track->GetAlpha();
4034 new (&helixes[i]) AliHelix(*track);
4036 helixes[i].Evaluate(0,xyz);
4037 sign[i] = (track->GetC()>0) ? -1:1;
4040 if (track->GetProlongation(x,y,z)){
4042 fim[i] = alpha[i]+TMath::ATan2(y,x);
4045 zm[i] = track->GetZ();
4049 circular[i]= kFALSE;
4050 if (track->GetProlongation(0,y,z)) z0[i] = z;
4051 dca[i] = track->GetD(0,0);
4057 Int_t ncandidates =0;
4060 Double_t phase[2][2],radius[2];
4063 // Find circling track
4064 TTreeSRedirector &cstream = *fDebugStreamer;
4066 for (Int_t i0=0;i0<nentries;i0++){
4067 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4068 if (!track0) continue;
4069 if (track0->fN<40) continue;
4070 if (TMath::Abs(1./track0->fP4)>200) continue;
4071 for (Int_t i1=i0+1;i1<nentries;i1++){
4072 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4073 if (!track1) continue;
4074 if (track1->fN<40) continue;
4075 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
4076 if (track0->fBConstrain&&track1->fBConstrain) continue;
4077 if (TMath::Abs(1./track1->fP4)>200) continue;
4078 if (track1->fP4*track0->fP4>0) continue;
4079 if (track1->fP3*track0->fP3>0) continue;
4080 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
4081 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
4082 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
4084 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4085 if (mindcar<5) continue;
4086 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4087 if (mindcaz<5) continue;
4088 if (mindcar+mindcaz<20) continue;
4091 Float_t xc0 = helixes[i0].GetHelix(6);
4092 Float_t yc0 = helixes[i0].GetHelix(7);
4093 Float_t r0 = helixes[i0].GetHelix(8);
4094 Float_t xc1 = helixes[i1].GetHelix(6);
4095 Float_t yc1 = helixes[i1].GetHelix(7);
4096 Float_t r1 = helixes[i1].GetHelix(8);
4098 Float_t rmean = (r0+r1)*0.5;
4099 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4100 //if (delta>30) continue;
4101 if (delta>rmean*0.25) continue;
4102 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4104 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4105 if (npoints==0) continue;
4106 helixes[i0].GetClosestPhases(helixes[i1], phase);
4110 Double_t hangles[3];
4111 helixes[i0].Evaluate(phase[0][0],xyz0);
4112 helixes[i1].Evaluate(phase[0][1],xyz1);
4114 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4115 Double_t deltah[2],deltabest;
4116 if (hangles[2]<2.8) continue;
4118 cstream<<"C"<<track0->fLab<<track1->fLab<<
4119 track0->fP3<<track1->fP3<<
4120 track0->fP4<<track1->fP4<<
4121 delta<<rmean<<npoints<<
4122 hangles[0]<<hangles[2]<<
4123 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4127 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4129 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4130 if (deltah[1]<deltah[0]) ibest=1;
4132 deltabest = TMath::Sqrt(deltah[ibest]);
4133 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4134 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4135 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4136 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4138 if (deltabest>6) continue;
4139 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4140 Bool_t sign =kFALSE;
4141 if (hangles[2]>3.06) sign =kTRUE;
4144 circular[i0] = kTRUE;
4145 circular[i1] = kTRUE;
4146 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4147 track0->fCircular += 1;
4148 track1->fCircular += 2;
4151 track1->fCircular += 1;
4152 track0->fCircular += 2;
4155 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4157 cstream<<"Curling"<<
4158 "lab0="<<track0->fLab<<
4159 "lab1="<<track1->fLab<<
4164 "mindcar="<<mindcar<<
4165 "mindcaz="<<mindcaz<<
4168 "npoints="<<npoints<<
4169 "hangles0="<<hangles[0]<<
4170 "hangles2="<<hangles[2]<<
4175 "radius="<<radiusbest<<
4176 "deltabest="<<deltabest<<
4177 "phase0="<<phase[ibest][0]<<
4178 "phase1="<<phase[ibest][1]<<
4188 for (Int_t i =0;i<nentries;i++){
4189 if (sign[i]==0) continue;
4190 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4193 Double_t cradius0 = 40*40;
4194 Double_t cradius1 = 270*270;
4197 Double_t cdist3=0.55;
4198 for (Int_t j =i+1;j<nentries;j++){
4200 if (sign[j]*sign[i]<1) continue;
4201 if ( (nclusters[i]+nclusters[j])>200) continue;
4202 if ( (nclusters[i]+nclusters[j])<80) continue;
4203 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4204 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4205 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4206 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4207 if (npoints<1) continue;
4210 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4213 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4216 Double_t delta1=10000,delta2=10000;
4217 // cuts on the intersection radius
4218 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4219 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4220 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4222 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4223 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4224 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4227 Double_t distance1 = TMath::Min(delta1,delta2);
4228 if (distance1>cdist1) continue; // cut on DCA linear approximation
4230 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4231 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4232 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4233 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4236 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4237 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4238 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4240 distance1 = TMath::Min(delta1,delta2);
4243 rkink = TMath::Sqrt(radius[0]);
4246 rkink = TMath::Sqrt(radius[1]);
4248 if (distance1>cdist2) continue;
4251 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4254 Int_t row0 = GetRowNumber(rkink);
4255 if (row0<10) continue;
4256 if (row0>150) continue;
4259 Float_t dens00=-1,dens01=-1;
4260 Float_t dens10=-1,dens11=-1;
4262 Int_t found,foundable,shared;
4263 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4264 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4265 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4266 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4268 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4269 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4270 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4271 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4273 if (dens00<dens10 && dens01<dens11) continue;
4274 if (dens00>dens10 && dens01>dens11) continue;
4275 if (TMath::Max(dens00,dens10)<0.1) continue;
4276 if (TMath::Max(dens01,dens11)<0.3) continue;
4278 if (TMath::Min(dens00,dens10)>0.6) continue;
4279 if (TMath::Min(dens01,dens11)>0.6) continue;
4282 AliTPCseed * ktrack0, *ktrack1;
4291 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4292 AliExternalTrackParam paramm(*ktrack0);
4293 AliExternalTrackParam paramd(*ktrack1);
4294 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4297 kink->SetMother(paramm);
4298 kink->SetDaughter(paramd);
4301 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4303 fParam->Transform0to1(x,index);
4304 fParam->Transform1to2(x,index);
4305 row0 = GetRowNumber(x[0]);
4307 if (kink->GetR()<100) continue;
4308 if (kink->GetR()>240) continue;
4309 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4310 if (kink->GetDistance()>cdist3) continue;
4311 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4312 if (dird<0) continue;
4314 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4315 if (dirm<0) continue;
4316 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4317 if (mpt<0.2) continue;
4320 //for high momenta momentum not defined well in first iteration
4321 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4322 if (qt>0.35) continue;
4325 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4326 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4328 kink->SetTPCDensity(dens00,0,0);
4329 kink->SetTPCDensity(dens01,0,1);
4330 kink->SetTPCDensity(dens10,1,0);
4331 kink->SetTPCDensity(dens11,1,1);
4332 kink->SetIndex(i,0);
4333 kink->SetIndex(j,1);
4336 kink->SetTPCDensity(dens10,0,0);
4337 kink->SetTPCDensity(dens11,0,1);
4338 kink->SetTPCDensity(dens00,1,0);
4339 kink->SetTPCDensity(dens01,1,1);
4340 kink->SetIndex(j,0);
4341 kink->SetIndex(i,1);
4344 if (mpt<1||kink->GetAngle(2)>0.1){
4345 // angle and densities not defined yet
4346 if (kink->GetTPCDensityFactor()<0.8) continue;
4347 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4348 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4349 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4350 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4352 Float_t criticalangle = track0->fC22+track0->fC33;
4353 criticalangle+= track1->fC22+track1->fC33;
4354 criticalangle= 3*TMath::Sqrt(criticalangle);
4355 if (criticalangle>0.02) criticalangle=0.02;
4356 if (kink->GetAngle(2)<criticalangle) continue;
4359 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4360 Float_t shapesum =0;
4362 for ( Int_t row = row0-drow; row<row0+drow;row++){
4363 if (row<0) continue;
4364 if (row>155) continue;
4365 if (ktrack0->fClusterPointer[row]){
4366 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4367 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4370 if (ktrack1->fClusterPointer[row]){
4371 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4372 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4377 kink->SetShapeFactor(-1.);
4380 kink->SetShapeFactor(shapesum/sum);
4382 // esd->AddKink(kink);
4383 kinks->AddLast(kink);
4384 kink = new AliESDkink;
4389 // sort the kinks according quality - and refit them towards vertex
4391 Int_t nkinks = kinks->GetEntriesFast();
4392 Float_t *quality = new Float_t[nkinks];
4393 Int_t *indexes = new Int_t[nkinks];
4394 AliTPCseed *mothers = new AliTPCseed[nkinks];
4395 AliTPCseed *daughters = new AliTPCseed[nkinks];
4398 for (Int_t i=0;i<nkinks;i++){
4400 AliESDkink *kink = (AliESDkink*)kinks->At(i);
4402 // refit kinks towards vertex
4404 Int_t index0 = kink->GetIndex(0);
4405 Int_t index1 = kink->GetIndex(1);
4406 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4407 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4409 Int_t sumn=ktrack0->fN+ktrack1->fN;
4411 // Refit Kink under if too small angle
4413 if (kink->GetAngle(2)<0.05){
4414 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4415 Int_t row0 = kink->GetTPCRow0();
4416 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4419 Int_t last = row0-drow;
4420 if (last<40) last=40;
4421 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4422 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4425 Int_t first = row0+drow;
4426 if (first>130) first=130;
4427 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4428 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4430 if (seed0 && seed1){
4431 kink->SetStatus(1,8);
4432 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4433 row0 = GetRowNumber(kink->GetR());
4434 sumn = seed0->fN+seed1->fN;
4435 new (&mothers[i]) AliTPCseed(*seed0);
4436 new (&daughters[i]) AliTPCseed(*seed1);
4439 delete kinks->RemoveAt(i);
4440 if (seed0) delete seed0;
4441 if (seed1) delete seed1;
4444 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4445 delete kinks->RemoveAt(i);
4446 if (seed0) delete seed0;
4447 if (seed1) delete seed1;
4455 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4457 TMath::Sort(nkinks,quality,indexes,kFALSE);
4459 //remove double find kinks
4461 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4462 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4463 if (!kink0) continue;
4465 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4466 if (!kink0) continue;
4467 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4468 if (!kink1) continue;
4469 // if not close kink continue
4470 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4471 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4472 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4474 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4475 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4476 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4477 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4478 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4487 for (Int_t i=0;i<row0;i++){
4488 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4491 if (mother0.fIndex[i]==mother1.fIndex[i]){
4498 for (Int_t i=row0;i<158;i++){
4499 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4502 if (mother0.fIndex[i]==mother1.fIndex[i]){
4508 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4509 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4510 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4511 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4512 Int_t sum0 = mother0.fN+daughter0.fN;
4513 Int_t sum1 = mother1.fN+daughter1.fN;
4515 shared[kink0->GetIndex(0)]= kTRUE;
4516 shared[kink0->GetIndex(1)]= kTRUE;
4517 delete kinks->RemoveAt(indexes[ikink0]);
4520 shared[kink1->GetIndex(0)]= kTRUE;
4521 shared[kink1->GetIndex(1)]= kTRUE;
4522 delete kinks->RemoveAt(indexes[ikink1]);
4529 for (Int_t i=0;i<nkinks;i++){
4530 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
4531 if (!kink) continue;
4532 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4533 Int_t index0 = kink->GetIndex(0);
4534 Int_t index1 = kink->GetIndex(1);
4535 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4536 kink->SetMultiple(usage[index0],0);
4537 kink->SetMultiple(usage[index1],1);
4538 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4539 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4540 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4541 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4543 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4544 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4545 if (!ktrack0 || !ktrack1) continue;
4546 Int_t index = esd->AddKink(kink);
4549 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4550 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4551 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4552 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4556 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4557 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4562 // Remove tracks corresponding to shared kink's
4564 for (Int_t i=0;i<nentries;i++){
4565 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4566 if (!track0) continue;
4567 if (track0->fKinkIndexes[0]!=0) continue;
4568 if (shared[i]) delete array->RemoveAt(i);
4573 RemoveUsed2(array,0.5,0.4,30);
4575 for (Int_t i=0;i<nentries;i++){
4576 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4577 if (!track0) continue;
4578 track0->CookdEdx(0.02,0.6);
4582 for (Int_t i=0;i<nentries;i++){
4583 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4584 if (!track0) continue;
4585 if (track0->Pt()<1.4) continue;
4586 //remove double high momenta tracks - overlapped with kink candidates
4589 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4590 if (track0->fClusterPointer[icl]!=0){
4592 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4595 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4596 delete array->RemoveAt(i);
4599 if (track0->fKinkIndexes[0]!=0) continue;
4600 if (track0->GetNumberOfClusters()<80) continue;
4602 AliTPCseed *pmother = new AliTPCseed();
4603 AliTPCseed *pdaughter = new AliTPCseed();
4604 AliESDkink *pkink = new AliESDkink;
4606 AliTPCseed & mother = *pmother;
4607 AliTPCseed & daughter = *pdaughter;
4608 AliESDkink & kink = *pkink;
4609 if (CheckKinkPoint(track0,mother,daughter, kink)){
4610 if (mother.fN<30||daughter.fN<20) {
4614 continue; //too short tracks
4616 if (mother.Pt()<1.4) {
4622 Int_t row0= kink.GetTPCRow0();
4623 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4630 Int_t index = esd->AddKink(&kink);
4631 mother.fKinkIndexes[0] = -(index+1);
4632 daughter.fKinkIndexes[0] = index+1;
4634 delete array->RemoveAt(i);
4635 array->AddAt(new AliTPCseed(mother),i);
4638 array->AddLast(new AliTPCseed(mother));
4640 array->AddLast(new AliTPCseed(daughter));
4641 for (Int_t icl=0;icl<row0;icl++) {
4642 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4645 for (Int_t icl=row0;icl<158;icl++) {
4646 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4655 delete [] daughters;
4677 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4681 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4687 TObjArray *tpcv0s = new TObjArray(100000);
4688 Int_t nentries = array->GetEntriesFast();
4689 AliHelix *helixes = new AliHelix[nentries];
4690 Int_t *sign = new Int_t[nentries];
4691 Float_t *alpha = new Float_t[nentries];
4692 Float_t *z0 = new Float_t[nentries];
4693 Float_t *dca = new Float_t[nentries];
4694 Float_t *sdcar = new Float_t[nentries];
4695 Float_t *cdcar = new Float_t[nentries];
4696 Float_t *pulldcar = new Float_t[nentries];
4697 Float_t *pulldcaz = new Float_t[nentries];
4698 Float_t *pulldca = new Float_t[nentries];
4699 Bool_t *isPrim = new Bool_t[nentries];
4700 const AliESDVertex * primvertex = esd->GetVertex();
4701 Double_t zvertex = primvertex->GetZv();
4703 // nentries = array->GetEntriesFast();
4705 for (Int_t i=0;i<nentries;i++){
4708 AliTPCseed* track = (AliTPCseed*)array->At(i);
4709 if (!track) continue;
4710 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4711 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4712 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4714 alpha[i] = track->GetAlpha();
4715 new (&helixes[i]) AliHelix(*track);
4717 helixes[i].Evaluate(0,xyz);
4718 sign[i] = (track->GetC()>0) ? -1:1;
4722 if (track->GetProlongation(0,y,z)) z0[i] = z;
4723 dca[i] = track->GetD(0,0);
4725 // dca error parrameterezation + pulls
4727 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4728 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4729 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4730 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4731 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4732 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4733 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4734 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4736 if (track->fTPCr[4]>0.5) {
4737 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4739 if (track->fTPCr[0]>0.4) {
4740 isPrim[i]=kFALSE; //electron no sigma cut
4747 Int_t ncandidates =0;
4750 Double_t phase[2][2],radius[2];
4756 TTreeSRedirector &cstream = *fDebugStreamer;
4757 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4759 Double_t cradius0 = 10*10;
4760 Double_t cradius1 = 200*200;
4763 Double_t cpointAngle = 0.95;
4765 Double_t delta[2]={10000,10000};
4766 for (Int_t i =0;i<nentries;i++){
4767 if (sign[i]==0) continue;
4768 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4769 if (!track0) continue;
4770 if (AliTPCReconstructor::StreamLevel()>0){
4775 "zvertex="<<zvertex<<
4776 "sdcar0="<<sdcar[i]<<
4777 "cdcar0="<<cdcar[i]<<
4778 "pulldcar0="<<pulldcar[i]<<
4779 "pulldcaz0="<<pulldcaz[i]<<
4780 "pulldca0="<<pulldca[i]<<
4781 "isPrim="<<isPrim[i]<<
4785 if (track0->fP4<0) continue;
4786 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4788 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4793 for (Int_t j =0;j<nentries;j++){
4794 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4795 if (!track1) continue;
4796 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4797 if (sign[j]*sign[i]>0) continue;
4798 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4799 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4802 // DCA to prim vertex cut
4808 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4809 if (npoints<1) continue;
4813 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4814 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4815 if (delta[0]>cdist1) continue;
4818 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4819 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4820 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4821 if (delta[1]<delta[0]) iclosest=1;
4822 if (delta[iclosest]>cdist1) continue;
4824 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4825 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4827 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4828 if (pointAngle<cpointAngle) continue;
4830 Bool_t isGamma = kFALSE;
4831 vertex.SetP(*track0); //track0 - plus
4832 vertex.SetM(*track1); //track1 - minus
4833 vertex.Update(fprimvertex);
4834 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4835 Double_t pointAngle2 = vertex.GetPointAngle();
4837 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4838 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4839 Float_t sigmae = 0.15*0.15;
4840 if (vertex.GetRr()<80)
4841 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4842 sigmae+= TMath::Sqrt(sigmae);
4843 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4844 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4845 Int_t row0 = GetRowNumber(vertex.GetRr());
4847 if (vertex.GetDist2()>0.2) continue;
4848 densb0 = track0->Density2(0,row0-5);
4849 densb1 = track1->Density2(0,row0-5);
4850 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4851 densa0 = track0->Density2(row0+5,row0+40);
4852 densa1 = track1->Density2(row0+5,row0+40);
4853 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4856 densa0 = track0->Density2(0,40); //cluster density
4857 densa1 = track1->Density2(0,40); //cluster density
4858 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4860 vertex.SetLab(0,track0->GetLabel());
4861 vertex.SetLab(1,track1->GetLabel());
4862 vertex.SetChi2After((densa0+densa1)*0.5);
4863 vertex.SetChi2Before((densb0+densb1)*0.5);
4864 vertex.SetIndex(0,i);
4865 vertex.SetIndex(1,j);
4866 vertex.SetStatus(1); // TPC v0 candidate
4867 vertex.SetRp(track0->fTPCr);
4868 vertex.SetRm(track1->fTPCr);
4869 tpcv0s->AddLast(new AliESDV0MI(vertex));
4872 Int_t eventNr = esd->GetEventNumber();
4873 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4874 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4875 if (AliTPCReconstructor::StreamLevel()>0)
4878 "vertex.="<<&vertex<<
4880 "lab0="<<track0->fLab<<
4881 "Helix0.="<<&helixes[i]<<
4883 "lab1="<<track1->fLab<<
4884 "Helix1.="<<&helixes[j]<<
4885 "pointAngle="<<pointAngle<<
4886 "pointAngle2="<<pointAngle2<<
4891 "zvertex="<<zvertex<<
4892 "circular0="<<track0->fCircular<<
4893 "circular1="<<track1->fCircular<<
4894 "npoints="<<npoints<<
4895 "radius0="<<radius[0]<<
4896 "delta0="<<delta[0]<<
4897 "radius1="<<radius[1]<<
4898 "delta1="<<delta[1]<<
4899 "radiusm="<<radiusm<<
4901 "sdcar0="<<sdcar[i]<<
4902 "sdcar1="<<sdcar[j]<<
4903 "cdcar0="<<cdcar[i]<<
4904 "cdcar1="<<cdcar[j]<<
4905 "pulldcar0="<<pulldcar[i]<<
4906 "pulldcar1="<<pulldcar[j]<<
4907 "pulldcaz0="<<pulldcaz[i]<<
4908 "pulldcaz1="<<pulldcaz[j]<<
4909 "pulldca0="<<pulldca[i]<<
4910 "pulldca1="<<pulldca[j]<<
4920 Float_t *quality = new Float_t[ncandidates];
4921 Int_t *indexes = new Int_t[ncandidates];
4923 for (Int_t i=0;i<ncandidates;i++){
4925 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4926 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4927 // quality[i] /= (0.5+v0->GetDist2());
4928 // quality[i] *= v0->GetChi2After(); //density factor
4929 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4930 Int_t index0 = v0->GetIndex(0);
4931 Int_t index1 = v0->GetIndex(1);
4932 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4933 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4934 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4935 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4938 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4941 for (Int_t i=0;i<ncandidates;i++){
4942 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4944 Int_t index0 = v0->GetIndex(0);
4945 Int_t index1 = v0->GetIndex(1);
4946 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4947 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4948 if (!track0||!track1) {
4952 Bool_t accept =kTRUE; //default accept
4953 Int_t *v0indexes0 = track0->GetV0Indexes();
4954 Int_t *v0indexes1 = track1->GetV0Indexes();
4956 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4957 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4958 if (v0indexes0[1]!=0) order0 =2;
4959 if (v0indexes1[1]!=0) order1 =2;
4961 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4962 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4964 AliESDV0MI * v02 = v0;
4966 v0->SetOrder(0,order0);
4967 v0->SetOrder(1,order1);
4968 v0->SetOrder(1,order0+order1);
4969 Int_t index = esd->AddV0MI(v0);
4970 v02 = esd->GetV0MI(index);
4971 v0indexes0[order0]=index;
4972 v0indexes1[order1]=index;
4976 Int_t eventNr = esd->GetEventNumber();
4977 if (AliTPCReconstructor::StreamLevel()>0)
4983 "lab0="<<track0->fLab<<
4985 "lab1="<<track1->fLab<<
4986 "dca0="<<dca[index0]<<
4987 "dca1="<<dca[index1]<<
4991 "quality="<<quality[i]<<
4992 "pulldca0="<<pulldca[index0]<<
4993 "pulldca1="<<pulldca[index1]<<
5017 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5021 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5024 // refit kink towards to the vertex
5027 Int_t row0 = GetRowNumber(kink.GetR());
5028 FollowProlongation(mother,0);
5029 mother.Reset(kFALSE);
5031 FollowProlongation(daughter,row0);
5032 daughter.Reset(kFALSE);
5033 FollowBackProlongation(daughter,158);
5034 daughter.Reset(kFALSE);
5035 Int_t first = TMath::Max(row0-20,30);
5036 Int_t last = TMath::Min(row0+20,140);
5038 const Int_t kNdiv =5;
5039 AliTPCseed param0[kNdiv]; // parameters along the track
5040 AliTPCseed param1[kNdiv]; // parameters along the track
5041 AliESDkink kinks[kNdiv]; // corresponding kink parameters
5044 for (Int_t irow=0; irow<kNdiv;irow++){
5045 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5047 // store parameters along the track
5049 for (Int_t irow=0;irow<kNdiv;irow++){
5050 FollowBackProlongation(mother, rows[irow]);
5051 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5052 new(¶m0[irow]) AliTPCseed(mother);
5053 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5057 for (Int_t irow=0; irow<kNdiv-1;irow++){
5058 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5059 kinks[irow].SetMother(param0[irow]);
5060 kinks[irow].SetDaughter(param1[irow]);
5061 kinks[irow].Update();
5064 // choose kink with best "quality"
5066 Double_t mindist = 10000;
5067 for (Int_t irow=0;irow<kNdiv;irow++){
5068 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5069 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5070 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5072 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
5073 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5074 if (normdist < mindist){
5080 if (index==-1) return 0;
5083 param0[index].Reset(kTRUE);
5084 FollowProlongation(param0[index],0);
5086 new (&mother) AliTPCseed(param0[index]);
5087 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5089 kink.SetMother(mother);
5090 kink.SetDaughter(daughter);
5092 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5093 kink.SetTPCncls(param0[index].fN,0);
5094 kink.SetTPCncls(param1[index].fN,1);
5095 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5096 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5097 mother.SetLabel(kink.GetLabel(0));
5098 daughter.SetLabel(kink.GetLabel(1));
5104 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5106 // update Kink quality information for mother after back propagation
5108 if (seed->GetKinkIndex(0)>=0) return;
5109 for (Int_t ikink=0;ikink<3;ikink++){
5110 Int_t index = seed->GetKinkIndex(ikink);
5111 if (index>=0) break;
5112 index = TMath::Abs(index)-1;
5113 AliESDkink * kink = fEvent->GetKink(index);
5114 //kink->fTPCdensity2[0][0]=-1;
5115 //kink->fTPCdensity2[0][1]=-1;
5116 kink->SetTPCDensity2(-1,0,0);
5117 kink->SetTPCDensity2(1,0,1);
5119 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5120 if (row0<15) row0=15;
5122 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5123 if (row1>145) row1=145;
5125 Int_t found,foundable,shared;
5126 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5127 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5128 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5129 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5134 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5136 // update Kink quality information for daughter after refit
5138 if (seed->GetKinkIndex(0)<=0) return;
5139 for (Int_t ikink=0;ikink<3;ikink++){
5140 Int_t index = seed->GetKinkIndex(ikink);
5141 if (index<=0) break;
5142 index = TMath::Abs(index)-1;
5143 AliESDkink * kink = fEvent->GetKink(index);
5144 kink->SetTPCDensity2(-1,1,0);
5145 kink->SetTPCDensity2(-1,1,1);
5147 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5148 if (row0<15) row0=15;
5150 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5151 if (row1>145) row1=145;
5153 Int_t found,foundable,shared;
5154 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5155 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5156 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5157 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5163 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5166 // check kink point for given track
5167 // if return value=0 kink point not found
5168 // otherwise seed0 correspond to mother particle
5169 // seed1 correspond to daughter particle
5170 // kink parameter of kink point
5172 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5173 Int_t first = seed->fFirstPoint;
5174 Int_t last = seed->fLastPoint;
5175 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5178 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5179 if (!seed1) return 0;
5180 FollowProlongation(*seed1,seed->fLastPoint-20);
5181 seed1->Reset(kTRUE);
5182 FollowProlongation(*seed1,158);
5183 seed1->Reset(kTRUE);
5184 last = seed1->fLastPoint;
5186 AliTPCseed *seed0 = new AliTPCseed(*seed);
5187 seed0->Reset(kFALSE);
5190 AliTPCseed param0[20]; // parameters along the track
5191 AliTPCseed param1[20]; // parameters along the track
5192 AliESDkink kinks[20]; // corresponding kink parameters
5194 for (Int_t irow=0; irow<20;irow++){
5195 rows[irow] = first +((last-first)*irow)/19;
5197 // store parameters along the track
5199 for (Int_t irow=0;irow<20;irow++){
5200 FollowBackProlongation(*seed0, rows[irow]);
5201 FollowProlongation(*seed1,rows[19-irow]);
5202 new(¶m0[irow]) AliTPCseed(*seed0);
5203 new(¶m1[19-irow]) AliTPCseed(*seed1);
5207 for (Int_t irow=0; irow<19;irow++){
5208 kinks[irow].SetMother(param0[irow]);
5209 kinks[irow].SetDaughter(param1[irow]);
5210 kinks[irow].Update();
5213 // choose kink with biggest change of angle
5215 Double_t maxchange= 0;
5216 for (Int_t irow=1;irow<19;irow++){
5217 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5218 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5219 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5220 if ( quality > maxchange){
5221 maxchange = quality;
5228 if (index<0) return 0;
5230 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5231 seed0 = new AliTPCseed(param0[index]);
5232 seed1 = new AliTPCseed(param1[index]);
5233 seed0->Reset(kFALSE);
5234 seed1->Reset(kFALSE);
5235 seed0->ResetCovariance();
5236 seed1->ResetCovariance();
5237 FollowProlongation(*seed0,0);
5238 FollowBackProlongation(*seed1,158);
5239 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5240 seed0->Reset(kFALSE);
5241 seed1->Reset(kFALSE);
5242 seed0->ResetCovariance();
5243 seed1->ResetCovariance();
5245 first = TMath::Max(row0-20,0);
5246 last = TMath::Min(row0+20,158);
5248 for (Int_t irow=0; irow<20;irow++){
5249 rows[irow] = first +((last-first)*irow)/19;
5251 // store parameters along the track
5253 for (Int_t irow=0;irow<20;irow++){
5254 FollowBackProlongation(*seed0, rows[irow]);
5255 FollowProlongation(*seed1,rows[19-irow]);
5256 new(¶m0[irow]) AliTPCseed(*seed0);
5257 new(¶m1[19-irow]) AliTPCseed(*seed1);
5261 for (Int_t irow=0; irow<19;irow++){
5262 kinks[irow].SetMother(param0[irow]);
5263 kinks[irow].SetDaughter(param1[irow]);
5264 // param0[irow].Dump();
5265 //param1[irow].Dump();
5266 kinks[irow].Update();
5269 // choose kink with biggest change of angle
5272 for (Int_t irow=0;irow<20;irow++){
5273 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5274 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5275 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5276 if ( quality > maxchange){
5277 maxchange = quality;
5284 if (index==-1 || param0[index].fN+param1[index].fN<100){
5289 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5291 kink.SetMother(param0[index]);
5292 kink.SetDaughter(param1[index]);
5294 row0 = GetRowNumber(kink.GetR());
5295 kink.SetTPCRow0(row0);
5296 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5297 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5298 kink.SetIndex(-10,0);
5299 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5300 kink.SetTPCncls(param0[index].fN,0);
5301 kink.SetTPCncls(param1[index].fN,1);
5304 // new (&mother) AliTPCseed(param0[index]);
5305 new (&daughter) AliTPCseed(param1[index]);
5306 daughter.SetLabel(kink.GetLabel(1));
5307 param0[index].Reset(kTRUE);
5308 FollowProlongation(param0[index],0);
5309 new (&mother) AliTPCseed(param0[index]);
5310 mother.SetLabel(kink.GetLabel(0));
5320 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5323 // reseed - refit - track
5326 // Int_t last = fSectors->GetNRows()-1;
5328 if (fSectors == fOuterSec){
5329 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5333 first = t->fFirstPoint;
5335 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5336 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5338 FollowProlongation(*t,first);
5348 //_____________________________________________________________________________
5349 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5350 //-----------------------------------------------------------------
5351 // This function reades track seeds.
5352 //-----------------------------------------------------------------
5353 TDirectory *savedir=gDirectory;
5355 TFile *in=(TFile*)inp;
5356 if (!in->IsOpen()) {
5357 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5362 TTree *seedTree=(TTree*)in->Get("Seeds");
5364 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5365 cerr<<"can't get a tree with track seeds !\n";
5368 AliTPCtrack *seed=new AliTPCtrack;
5369 seedTree->SetBranchAddress("tracks",&seed);
5371 if (fSeeds==0) fSeeds=new TObjArray(15000);
5373 Int_t n=(Int_t)seedTree->GetEntries();
5374 for (Int_t i=0; i<n; i++) {
5375 seedTree->GetEvent(i);
5376 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5385 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5388 if (fSeeds) DeleteSeeds();
5391 if (!fSeeds) return 1;
5398 //_____________________________________________________________________________
5399 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5400 //-----------------------------------------------------------------
5401 // This is a track finder.
5402 //-----------------------------------------------------------------
5403 TDirectory *savedir=gDirectory;
5407 fSeeds = Tracking();
5410 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5412 //activate again some tracks
5413 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5414 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5416 Int_t nc=t.GetNumberOfClusters();
5418 delete fSeeds->RemoveAt(i);
5422 if (pt->fRemoval==10) {
5423 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5424 pt->Desactivate(10); // make track again active
5426 pt->Desactivate(20);
5427 delete fSeeds->RemoveAt(i);
5432 RemoveUsed2(fSeeds,0.85,0.85,0);
5433 FindKinks(fSeeds,fEvent);
5434 RemoveUsed2(fSeeds,0.5,0.4,20);
5436 // // refit short tracks
5438 Int_t nseed=fSeeds->GetEntriesFast();
5439 // for (Int_t i=0; i<nseed; i++) {
5440 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5441 // if (!pt) continue;
5442 // Int_t nc=t.GetNumberOfClusters();
5444 // delete fSeeds->RemoveAt(i);
5447 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5448 // if (nc>100) continue; // hopefully, enough for ITS
5449 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5450 // //seed2->Reset(kFALSE);
5451 // //pt->ResetCovariance();
5452 // seed2->Modify(1);
5453 // FollowBackProlongation(*seed2,158);
5454 // //seed2->Reset(kFALSE);
5455 // seed2->Modify(10);
5456 // FollowProlongation(*seed2,0);
5457 // TTreeSRedirector &cstream = *fDebugStreamer;
5458 // cstream<<"Crefit"<<
5462 // if (seed2->fN>pt->fN){
5463 // delete fSeeds->RemoveAt(i);
5464 // fSeeds->AddAt(seed2,i);
5469 // RemoveUsed2(fSeeds,0.6,0.6,50);
5471 // FindV0s(fSeeds,fEvent);
5472 //RemoveDouble(fSeeds,0.2,0.6,11);
5476 for (Int_t i=0; i<nseed; i++) {
5477 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5479 Int_t nc=t.GetNumberOfClusters();
5481 delete fSeeds->RemoveAt(i);
5484 CookLabel(pt,0.1); //For comparison only
5485 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5486 if ((pt->IsActive() || (pt->fRemoval==10) )){
5488 if (fDebug>0) cerr<<found<<'\r';
5492 delete fSeeds->RemoveAt(i);
5496 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5498 //RemoveUsed(fSeeds,0.9,0.9,6);
5500 nseed=fSeeds->GetEntriesFast();
5502 for (Int_t i=0; i<nseed; i++) {
5503 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5505 Int_t nc=t.GetNumberOfClusters();
5507 delete fSeeds->RemoveAt(i);
5511 t.CookdEdx(0.02,0.6);
5512 // CheckKinkPoint(&t,0.05);
5513 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5514 if ((pt->IsActive() || (pt->fRemoval==10) )){
5522 delete fSeeds->RemoveAt(i);
5523 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5525 // FollowProlongation(*seed1,0);
5526 // Int_t n = seed1->GetNumberOfClusters();
5527 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5528 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5531 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5535 SortTracks(fSeeds, 1);
5539 PrepareForBackProlongation(fSeeds,5.);
5540 PropagateBack(fSeeds);
5541 printf("Time for back propagation: \t");timer.Print();timer.Start();
5545 PrepareForProlongation(fSeeds,5.);
5546 PropagateForward2(fSeeds);
5548 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5549 // RemoveUsed(fSeeds,0.7,0.7,6);
5550 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5552 nseed=fSeeds->GetEntriesFast();
5554 for (Int_t i=0; i<nseed; i++) {
5555 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5557 Int_t nc=t.GetNumberOfClusters();
5559 delete fSeeds->RemoveAt(i);
5562 t.CookdEdx(0.02,0.6);
5563 // CookLabel(pt,0.1); //For comparison only
5564 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5565 if ((pt->IsActive() || (pt->fRemoval==10) )){
5566 cerr<<found++<<'\r';
5569 delete fSeeds->RemoveAt(i);
5574 // fNTracks = found;
5576 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5579 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5580 Info("Clusters2Tracks","Number of found tracks %d",found);
5582 // UnloadClusters();
5587 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5590 // tracking of the seeds
5593 fSectors = fOuterSec;
5594 ParallelTracking(arr,150,63);
5595 fSectors = fOuterSec;
5596 ParallelTracking(arr,63,0);
5599 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5604 TObjArray * arr = new TObjArray;
5606 fSectors = fOuterSec;
5609 for (Int_t sec=0;sec<fkNOS;sec++){
5610 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5611 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5612 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5615 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5627 TObjArray * AliTPCtrackerMI::Tracking()
5633 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5635 TObjArray * seeds = new TObjArray;
5644 Float_t fnumber = 3.0;
5645 Float_t fdensity = 3.0;
5650 for (Int_t delta = 0; delta<18; delta+=6){
5654 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5655 SumTracks(seeds,arr);
5656 SignClusters(seeds,fnumber,fdensity);
5658 for (Int_t i=2;i<6;i+=2){
5659 // seed high pt tracks
5662 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5663 SumTracks(seeds,arr);
5664 SignClusters(seeds,fnumber,fdensity);
5669 // RemoveUsed(seeds,0.9,0.9,1);
5670 // UnsignClusters();
5671 // SignClusters(seeds,fnumber,fdensity);
5675 for (Int_t delta = 20; delta<120; delta+=10){
5677 // seed high pt tracks
5681 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5682 SumTracks(seeds,arr);
5683 SignClusters(seeds,fnumber,fdensity);
5688 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5689 SumTracks(seeds,arr);
5690 SignClusters(seeds,fnumber,fdensity);
5701 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5705 // RemoveUsed(seeds,0.75,0.75,1);
5707 //SignClusters(seeds,fnumber,fdensity);
5716 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5717 SumTracks(seeds,arr);
5718 SignClusters(seeds,fnumber,fdensity);
5720 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5721 SumTracks(seeds,arr);
5722 SignClusters(seeds,fnumber,fdensity);
5724 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5725 SumTracks(seeds,arr);
5726 SignClusters(seeds,fnumber,fdensity);
5730 for (Int_t delta = 3; delta<30; delta+=5){
5736 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5737 SumTracks(seeds,arr);
5738 SignClusters(seeds,fnumber,fdensity);
5740 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5741 SumTracks(seeds,arr);
5742 SignClusters(seeds,fnumber,fdensity);
5754 for (Int_t delta = 30; delta<90; delta+=10){
5760 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5761 SumTracks(seeds,arr);
5762 SignClusters(seeds,fnumber,fdensity);
5764 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5765 SumTracks(seeds,arr);
5766 SignClusters(seeds,fnumber,fdensity);
5770 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5781 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5784 //sum tracks to common container
5785 //remove suspicious tracks
5786 Int_t nseed = arr2->GetEntriesFast();
5787 for (Int_t i=0;i<nseed;i++){
5788 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5790 // REMOVE VERY SHORT TRACKS
5791 if (pt->GetNumberOfClusters()<20){
5792 delete arr2->RemoveAt(i);
5795 // NORMAL ACTIVE TRACK
5796 if (pt->IsActive()){
5797 arr1->AddLast(arr2->RemoveAt(i));
5800 //remove not usable tracks
5801 if (pt->fRemoval!=10){
5802 delete arr2->RemoveAt(i);
5806 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5807 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5808 arr1->AddLast(arr2->RemoveAt(i));
5810 delete arr2->RemoveAt(i);
5819 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5822 // try to track in parralel
5824 Int_t nseed=arr->GetEntriesFast();
5825 //prepare seeds for tracking
5826 for (Int_t i=0; i<nseed; i++) {
5827 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5829 if (!t.IsActive()) continue;
5830 // follow prolongation to the first layer
5831 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5832 FollowProlongation(t, rfirst+1);
5837 for (Int_t nr=rfirst; nr>=rlast; nr--){
5838 if (nr<fInnerSec->GetNRows())
5839 fSectors = fInnerSec;
5841 fSectors = fOuterSec;
5842 // make indexes with the cluster tracks for given
5844 // find nearest cluster
5845 for (Int_t i=0; i<nseed; i++) {
5846 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5848 if (nr==80) pt->UpdateReference();
5849 if (!pt->IsActive()) continue;
5850 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5851 if (pt->fRelativeSector>17) {
5854 UpdateClusters(t,nr);
5856 // prolonagate to the nearest cluster - if founded
5857 for (Int_t i=0; i<nseed; i++) {
5858 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5860 if (!pt->IsActive()) continue;
5861 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5862 if (pt->fRelativeSector>17) {
5865 FollowToNextCluster(*pt,nr);
5870 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5874 // if we use TPC track itself we have to "update" covariance
5876 Int_t nseed= arr->GetEntriesFast();
5877 for (Int_t i=0;i<nseed;i++){
5878 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5882 //rotate to current local system at first accepted point
5883 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5884 Int_t sec = (index&0xff000000)>>24;
5886 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5887 if (angle1>TMath::Pi())
5888 angle1-=2.*TMath::Pi();
5889 Float_t angle2 = pt->GetAlpha();
5891 if (TMath::Abs(angle1-angle2)>0.001){
5892 pt->Rotate(angle1-angle2);
5893 //angle2 = pt->GetAlpha();
5894 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5895 //if (pt->GetAlpha()<0)
5896 // pt->fRelativeSector+=18;
5897 //sec = pt->fRelativeSector;
5906 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5910 // if we use TPC track itself we have to "update" covariance
5912 Int_t nseed= arr->GetEntriesFast();
5913 for (Int_t i=0;i<nseed;i++){
5914 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5917 pt->fFirstPoint = pt->fLastPoint;
5925 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5928 // make back propagation
5930 Int_t nseed= arr->GetEntriesFast();
5931 for (Int_t i=0;i<nseed;i++){
5932 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5933 if (pt&& pt->GetKinkIndex(0)<=0) {
5934 //AliTPCseed *pt2 = new AliTPCseed(*pt);
5935 fSectors = fInnerSec;
5936 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5937 //fSectors = fOuterSec;
5938 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5939 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
5940 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
5941 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5944 if (pt&& pt->GetKinkIndex(0)>0) {
5945 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
5946 pt->fFirstPoint = kink->GetTPCRow0();
5947 fSectors = fInnerSec;
5948 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5956 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5959 // make forward propagation
5961 Int_t nseed= arr->GetEntriesFast();
5963 for (Int_t i=0;i<nseed;i++){
5964 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5966 FollowProlongation(*pt,0);
5973 Int_t AliTPCtrackerMI::PropagateForward()
5976 // propagate track forward
5978 Int_t nseed = fSeeds->GetEntriesFast();
5979 for (Int_t i=0;i<nseed;i++){
5980 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5982 AliTPCseed &t = *pt;
5983 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5984 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5985 if (alpha < 0. ) alpha += 2.*TMath::Pi();
5986 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
5990 fSectors = fOuterSec;
5991 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
5992 fSectors = fInnerSec;
5993 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
6003 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6006 // make back propagation, in between row0 and row1
6010 fSectors = fInnerSec;
6013 if (row1<fSectors->GetNRows())
6016 r1 = fSectors->GetNRows()-1;
6018 if (row0<fSectors->GetNRows()&& r1>0 )
6019 FollowBackProlongation(*pt,r1);
6020 if (row1<=fSectors->GetNRows())
6023 r1 = row1 - fSectors->GetNRows();
6024 if (r1<=0) return 0;
6025 if (r1>=fOuterSec->GetNRows()) return 0;
6026 fSectors = fOuterSec;
6027 return FollowBackProlongation(*pt,r1);
6035 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6039 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6040 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6041 Float_t padlength = GetPadPitchLength(row);
6043 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6044 Double_t angulary = seed->GetSnp();
6045 angulary = angulary*angulary/(1-angulary*angulary);
6046 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6048 Float_t sresz = fParam->GetZSigma();
6049 Float_t angularz = seed->GetTgl();
6050 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6052 Float_t wy = GetSigmaY(seed);
6053 Float_t wz = GetSigmaZ(seed);
6056 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6057 printf("problem\n");
6063 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6067 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6068 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6069 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6070 Float_t angular = seed->GetSnp();
6071 angular = angular*angular/(1-angular*angular);
6072 // angular*=angular;
6073 //angular = TMath::Sqrt(angular/(1-angular));
6074 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6077 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6081 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6082 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6083 Float_t sres = fParam->GetZSigma();
6084 Float_t angular = seed->GetTgl();
6085 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6090 //__________________________________________________________________________
6091 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6092 //--------------------------------------------------------------------
6093 //This function "cooks" a track label. If label<0, this track is fake.
6094 //--------------------------------------------------------------------
6095 AliTPCseed * t = (AliTPCseed*)tk;
6096 Int_t noc=t->GetNumberOfClusters();
6098 //printf("\nnot founded prolongation\n\n\n");
6104 AliTPCclusterMI *clusters[160];
6106 for (Int_t i=0;i<160;i++) {
6113 for (i=0; i<160 && current<noc; i++) {
6115 Int_t index=t->GetClusterIndex2(i);
6116 if (index<=0) continue;
6117 if (index&0x8000) continue;
6119 //clusters[current]=GetClusterMI(index);
6120 if (t->fClusterPointer[i]){
6121 clusters[current]=t->fClusterPointer[i];
6127 Int_t lab=123456789;
6128 for (i=0; i<noc; i++) {
6129 AliTPCclusterMI *c=clusters[i];
6131 lab=TMath::Abs(c->GetLabel(0));
6133 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6139 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6141 for (i=0; i<noc; i++) {
6142 AliTPCclusterMI *c=clusters[i];
6144 if (TMath::Abs(c->GetLabel(1)) == lab ||
6145 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6148 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6151 Int_t tail=Int_t(0.10*noc);
6154 for (i=1; i<=160&&ind<tail; i++) {
6155 // AliTPCclusterMI *c=clusters[noc-i];
6156 AliTPCclusterMI *c=clusters[i];
6158 if (lab == TMath::Abs(c->GetLabel(0)) ||
6159 lab == TMath::Abs(c->GetLabel(1)) ||
6160 lab == TMath::Abs(c->GetLabel(2))) max++;
6163 if (max < Int_t(0.5*tail)) lab=-lab;
6170 //delete[] clusters;
6174 //__________________________________________________________________________
6175 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6176 //--------------------------------------------------------------------
6177 //This function "cooks" a track label. If label<0, this track is fake.
6178 //--------------------------------------------------------------------
6179 Int_t noc=t->GetNumberOfClusters();
6181 //printf("\nnot founded prolongation\n\n\n");
6187 AliTPCclusterMI *clusters[160];
6189 for (Int_t i=0;i<160;i++) {
6196 for (i=0; i<160 && current<noc; i++) {
6197 if (i<first) continue;
6198 if (i>last) continue;
6199 Int_t index=t->GetClusterIndex2(i);
6200 if (index<=0) continue;
6201 if (index&0x8000) continue;
6203 //clusters[current]=GetClusterMI(index);
6204 if (t->fClusterPointer[i]){
6205 clusters[current]=t->fClusterPointer[i];
6210 if (noc<5) return -1;
6211 Int_t lab=123456789;
6212 for (i=0; i<noc; i++) {
6213 AliTPCclusterMI *c=clusters[i];
6215 lab=TMath::Abs(c->GetLabel(0));
6217 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6223 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6225 for (i=0; i<noc; i++) {
6226 AliTPCclusterMI *c=clusters[i];
6228 if (TMath::Abs(c->GetLabel(1)) == lab ||
6229 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6232 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6235 Int_t tail=Int_t(0.10*noc);
6238 for (i=1; i<=160&&ind<tail; i++) {
6239 // AliTPCclusterMI *c=clusters[noc-i];
6240 AliTPCclusterMI *c=clusters[i];
6242 if (lab == TMath::Abs(c->GetLabel(0)) ||
6243 lab == TMath::Abs(c->GetLabel(1)) ||
6244 lab == TMath::Abs(c->GetLabel(2))) max++;
6247 if (max < Int_t(0.5*tail)) lab=-lab;
6250 // t->SetLabel(lab);
6254 //delete[] clusters;
6258 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6260 //return pad row number for this x
6263 r=fRow[fN-1].GetX();
6264 if (x > r) return fN;
6266 if (x < r) return -1;
6267 return Int_t((x-r)/fPadPitchLength + 0.5);}
6269 r=fRow[fN-1].GetX();
6270 if (x > r) return fN;
6272 if (x < r) return -1;
6273 Double_t r1=fRow[64].GetX();
6275 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6277 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6281 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6283 //return pad row number for given x vector
6284 Float_t phi = TMath::ATan2(x[1],x[0]);
6285 if(phi<0) phi=2.*TMath::Pi()+phi;
6286 // Get the local angle in the sector philoc
6287 const Float_t kRaddeg = 180/3.14159265358979312;
6288 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6289 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6290 return GetRowNumber(localx);
6293 //_________________________________________________________________________
6294 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6295 //-----------------------------------------------------------------------
6296 // Setup inner sector
6297 //-----------------------------------------------------------------------
6299 fAlpha=par->GetInnerAngle();
6300 fAlphaShift=par->GetInnerAngleShift();
6301 fPadPitchWidth=par->GetInnerPadPitchWidth();
6302 fPadPitchLength=par->GetInnerPadPitchLength();
6303 fN=par->GetNRowLow();
6304 fRow=new AliTPCRow[fN];
6305 for (Int_t i=0; i<fN; i++) {
6306 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6307 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6310 fAlpha=par->GetOuterAngle();
6311 fAlphaShift=par->GetOuterAngleShift();
6312 fPadPitchWidth = par->GetOuterPadPitchWidth();
6313 fPadPitchLength = par->GetOuter1PadPitchLength();
6314 f1PadPitchLength = par->GetOuter1PadPitchLength();
6315 f2PadPitchLength = par->GetOuter2PadPitchLength();
6317 fN=par->GetNRowUp();
6318 fRow=new AliTPCRow[fN];
6319 for (Int_t i=0; i<fN; i++) {
6320 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6321 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6326 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6328 // default constructor
6336 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6343 //_________________________________________________________________________
6345 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6346 //-----------------------------------------------------------------------
6347 // Insert a cluster into this pad row in accordence with its y-coordinate
6348 //-----------------------------------------------------------------------
6349 if (fN==kMaxClusterPerRow) {
6350 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6352 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6353 Int_t i=Find(c->GetZ());
6354 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6355 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6356 fIndex[i]=index; fClusters[i]=c; fN++;
6359 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6365 //delete[] fClusterArray;
6366 if (fClusters1) delete []fClusters1;
6367 if (fClusters2) delete []fClusters2;
6374 //___________________________________________________________________
6375 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6376 //-----------------------------------------------------------------------
6377 // Return the index of the nearest cluster
6378 //-----------------------------------------------------------------------
6379 if (fN==0) return 0;
6380 if (z <= fClusters[0]->GetZ()) return 0;
6381 if (z > fClusters[fN-1]->GetZ()) return fN;
6382 Int_t b=0, e=fN-1, m=(b+e)/2;
6383 for (; b<e; m=(b+e)/2) {
6384 if (z > fClusters[m]->GetZ()) b=m+1;
6392 //___________________________________________________________________
6393 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6394 //-----------------------------------------------------------------------
6395 // Return the index of the nearest cluster in z y
6396 //-----------------------------------------------------------------------
6397 Float_t maxdistance = roady*roady + roadz*roadz;
6399 AliTPCclusterMI *cl =0;
6400 for (Int_t i=Find(z-roadz); i<fN; i++) {
6401 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6402 if (c->GetZ() > z+roadz) break;
6403 if ( (c->GetY()-y) > roady ) continue;
6404 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6405 if (maxdistance>distance) {
6406 maxdistance = distance;
6413 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6415 //-----------------------------------------------------------------------
6416 // Return the index of the nearest cluster in z y
6417 //-----------------------------------------------------------------------
6418 Float_t maxdistance = roady*roady + roadz*roadz;
6419 AliTPCclusterMI *cl =0;
6421 //PH Check boundaries. 510 is the size of fFastCluster
6422 Int_t iz1 = Int_t(z-roadz+254.5);
6423 if (iz1<0 || iz1>=510) return cl;
6424 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6425 Int_t iz2 = Int_t(z+roadz+255.5);
6426 if (iz2<0 || iz2>=510) return cl;
6427 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6429 //FindNearest3(y,z,roady,roadz,index);
6430 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6431 for (Int_t i=iz1; i<iz2; i++) {
6432 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6433 if (c->GetZ() > z+roadz) break;
6434 if ( c->GetY()-y > roady ) continue;
6435 if ( y-c->GetY() > roady ) continue;
6436 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6437 if (maxdistance>distance) {
6438 maxdistance = distance;
6441 //roady = TMath::Sqrt(maxdistance);
6449 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6451 //-----------------------------------------------------------------------
6452 // Return the index of the nearest cluster in z y
6453 //-----------------------------------------------------------------------
6454 Float_t maxdistance = roady*roady + roadz*roadz;
6455 // Int_t iz = Int_t(z+255.);
6456 AliTPCclusterMI *cl =0;
6457 for (Int_t i=Find(z-roadz); i<fN; i++) {
6458 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6459 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6460 if (c->GetZ() > z+roadz) break;
6461 if ( c->GetY()-y > roady ) continue;
6462 if ( y-c->GetY() > roady ) continue;
6463 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6464 if (maxdistance>distance) {
6465 maxdistance = distance;
6468 //roady = TMath::Sqrt(maxdistance);
6478 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6482 // return &fTrackPoints[i];