1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker -
24 // run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 // run AliTPCFindTracksMI.C macro - to find tracks
26 // tracks are written to AliTPCtracks.root file
27 // for comparison also seeds are written to the same file - to special branch
28 //-------------------------------------------------------
33 #include "Riostream.h"
34 #include <TClonesArray.h>
36 #include <TObjArray.h>
39 #include "AliComplexCluster.h"
41 #include "AliESDkink.h"
43 #include "AliRunLoader.h"
44 #include "AliTPCClustersRow.h"
45 #include "AliTPCParam.h"
46 #include "AliTPCReconstructor.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCseed.h"
51 #include "AliTPCtrackerMI.h"
52 #include "TStopwatch.h"
53 #include "AliTPCReconstructor.h"
54 #include "AliESDkink.h"
56 #include "TTreeStream.h"
59 ClassImp(AliTPCtrackerMI)
62 class AliTPCFastMath {
65 static Double_t FastAsin(Double_t x);
67 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
70 Double_t AliTPCFastMath::fgFastAsin[20000];
71 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
73 AliTPCFastMath::AliTPCFastMath(){
75 // initialized lookup table;
76 for (Int_t i=0;i<10000;i++){
77 fgFastAsin[2*i] = TMath::ASin(i/10000.);
78 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
82 Double_t AliTPCFastMath::FastAsin(Double_t x){
84 // return asin using lookup table
86 Int_t index = int(x*10000);
87 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
90 Int_t index = int(x*10000);
91 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
97 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
99 //update track information using current cluster - track->fCurrentCluster
102 AliTPCclusterMI* c =track->fCurrentCluster;
103 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
105 UInt_t i = track->fCurrentClusterIndex1;
107 Int_t sec=(i&0xff000000)>>24;
108 //Int_t row = (i&0x00ff0000)>>16;
109 track->fRow=(i&0x00ff0000)>>16;
110 track->fSector = sec;
111 // Int_t index = i&0xFFFF;
112 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
113 track->SetClusterIndex2(track->fRow, i);
114 //track->fFirstPoint = row;
115 //if ( track->fLastPoint<row) track->fLastPoint =row;
116 // if (track->fRow<0 || track->fRow>160) {
117 // printf("problem\n");
119 if (track->fFirstPoint>track->fRow)
120 track->fFirstPoint = track->fRow;
121 if (track->fLastPoint<track->fRow)
122 track->fLastPoint = track->fRow;
125 track->fClusterPointer[track->fRow] = c;
128 Float_t angle2 = track->GetSnp()*track->GetSnp();
129 angle2 = TMath::Sqrt(angle2/(1-angle2));
131 //SET NEW Track Point
135 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
137 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
138 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
139 point.SetErrY(sqrt(track->fErrorY2));
140 point.SetErrZ(sqrt(track->fErrorZ2));
142 point.SetX(track->GetX());
143 point.SetY(track->GetY());
144 point.SetZ(track->GetZ());
145 point.SetAngleY(angle2);
146 point.SetAngleZ(track->GetTgl());
147 if (point.fIsShared){
148 track->fErrorY2 *= 4;
149 track->fErrorZ2 *= 4;
153 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
155 track->fErrorY2 *= 1.3;
156 track->fErrorY2 += 0.01;
157 track->fErrorZ2 *= 1.3;
158 track->fErrorZ2 += 0.005;
160 if (accept>0) return 0;
161 if (track->GetNumberOfClusters()%20==0){
162 // if (track->fHelixIn){
163 // TClonesArray & larr = *(track->fHelixIn);
164 // Int_t ihelix = larr.GetEntriesFast();
165 // new(larr[ihelix]) AliHelix(*track) ;
168 track->fNoCluster =0;
169 return track->Update(c,chi2,i);
174 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
175 Float_t cory, Float_t corz)
178 // decide according desired precision to accept given
179 // cluster for tracking
180 Double_t sy2=ErrY2(seed,cluster)*cory;
181 Double_t sz2=ErrZ2(seed,cluster)*corz;
182 //sy2=ErrY2(seed,cluster)*cory;
183 //sz2=ErrZ2(seed,cluster)*cory;
185 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
186 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
188 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
189 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
190 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
191 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
193 Double_t rdistance2 = rdistancey2+rdistancez2;
196 if (rdistance2>16) return 3;
199 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
200 return 2; //suspisiouce - will be changed
202 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
203 // strict cut on overlaped cluster
204 return 2; //suspisiouce - will be changed
206 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
207 && cluster->GetType()<0){
217 //_____________________________________________________________________________
218 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
219 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
221 //---------------------------------------------------------------------
222 // The main TPC tracker constructor
223 //---------------------------------------------------------------------
224 fInnerSec=new AliTPCSector[fkNIS];
225 fOuterSec=new AliTPCSector[fkNOS];
228 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
229 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
236 Int_t nrowlow = par->GetNRowLow();
237 Int_t nrowup = par->GetNRowUp();
240 for (Int_t i=0;i<nrowlow;i++){
241 fXRow[i] = par->GetPadRowRadiiLow(i);
242 fPadLength[i]= par->GetPadPitchLength(0,i);
243 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
247 for (Int_t i=0;i<nrowup;i++){
248 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
249 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
250 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
261 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
263 //________________________________________________________________________
264 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
269 //------------------------------------
270 // dummy copy constructor
271 //------------------------------------------------------------------
273 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
274 //------------------------------
276 //--------------------------------------------------------------
279 //_____________________________________________________________________________
280 AliTPCtrackerMI::~AliTPCtrackerMI() {
281 //------------------------------------------------------------------
282 // TPC tracker destructor
283 //------------------------------------------------------------------
290 if (fDebugStreamer) delete fDebugStreamer;
293 void AliTPCtrackerMI::SetIO()
297 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
299 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
301 AliTPCtrack *iotrack= new AliTPCtrack;
302 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
308 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
324 AliTPCtrack *iotrack= new AliTPCtrack;
325 // iotrack->fHelixIn = new TClonesArray("AliHelix");
326 //iotrack->fHelixOut = new TClonesArray("AliHelix");
327 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
330 if (output && (fDebug&2)){
331 //write the full seed information if specified in debug mode
333 fSeedTree = new TTree("Seeds","Seeds");
334 AliTPCseed * vseed = new AliTPCseed;
336 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
337 arrtr->ExpandCreateFast(160);
338 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
340 vseed->fPoints = arrtr;
341 vseed->fEPoints = arre;
342 // vseed->fClusterPoints = arrcl;
343 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
346 fTreeDebug = new TTree("trackDebug","trackDebug");
347 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
348 fTreeDebug->Branch("debug",&arrd,32000,99);
356 void AliTPCtrackerMI::FillESD(TObjArray* arr)
360 //fill esds using updated tracks
362 // write tracks to the event
363 // store index of the track
364 Int_t nseed=arr->GetEntriesFast();
365 //FindKinks(arr,fEvent);
366 for (Int_t i=0; i<nseed; i++) {
367 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
370 // pt->PropagateTo(fParam->GetInnerRadiusLow());
371 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
372 pt->PropagateTo(fParam->GetInnerRadiusLow());
375 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
377 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
378 iotrack.SetTPCPoints(pt->GetPoints());
379 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
380 iotrack.SetV0Indexes(pt->GetV0Indexes());
381 // iotrack.SetTPCpid(pt->fTPCr);
382 //iotrack.SetTPCindex(i);
383 fEvent->AddTrack(&iotrack);
387 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
389 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
390 iotrack.SetTPCPoints(pt->GetPoints());
391 //iotrack.SetTPCindex(i);
392 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
393 iotrack.SetV0Indexes(pt->GetV0Indexes());
394 // iotrack.SetTPCpid(pt->fTPCr);
395 fEvent->AddTrack(&iotrack);
399 // short tracks - maybe decays
401 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
402 Int_t found,foundable,shared;
403 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
404 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
406 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
407 //iotrack.SetTPCindex(i);
408 iotrack.SetTPCPoints(pt->GetPoints());
409 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
410 iotrack.SetV0Indexes(pt->GetV0Indexes());
411 //iotrack.SetTPCpid(pt->fTPCr);
412 fEvent->AddTrack(&iotrack);
417 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
418 Int_t found,foundable,shared;
419 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
420 if (found<20) continue;
421 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
424 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
425 iotrack.SetTPCPoints(pt->GetPoints());
426 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
427 iotrack.SetV0Indexes(pt->GetV0Indexes());
428 //iotrack.SetTPCpid(pt->fTPCr);
429 //iotrack.SetTPCindex(i);
430 fEvent->AddTrack(&iotrack);
433 // short tracks - secondaties
435 if ( (pt->GetNumberOfClusters()>30) ) {
436 Int_t found,foundable,shared;
437 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
438 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
440 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
441 iotrack.SetTPCPoints(pt->GetPoints());
442 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
443 iotrack.SetV0Indexes(pt->GetV0Indexes());
444 //iotrack.SetTPCpid(pt->fTPCr);
445 //iotrack.SetTPCindex(i);
446 fEvent->AddTrack(&iotrack);
451 if ( (pt->GetNumberOfClusters()>15)) {
452 Int_t found,foundable,shared;
453 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
454 if (found<15) continue;
455 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
456 if (float(found)/float(foundable)<0.8) continue;
459 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
460 iotrack.SetTPCPoints(pt->GetPoints());
461 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
462 iotrack.SetV0Indexes(pt->GetV0Indexes());
463 // iotrack.SetTPCpid(pt->fTPCr);
464 //iotrack.SetTPCindex(i);
465 fEvent->AddTrack(&iotrack);
470 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
473 void AliTPCtrackerMI::WriteTracks(TTree * tree)
476 // write tracks from seed array to selected tree
480 AliTPCtrack *iotrack= new AliTPCtrack;
481 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
486 void AliTPCtrackerMI::WriteTracks()
489 // write tracks to the given output tree -
490 // output specified with SetIO routine
497 AliTPCtrack *iotrack= 0;
498 Int_t nseed=fSeeds->GetEntriesFast();
499 //for (Int_t i=0; i<nseed; i++) {
500 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
501 // if (iotrack) break;
503 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
504 TBranch * br = fOutput->GetBranch("tracks");
505 br->SetAddress(&iotrack);
507 for (Int_t i=0; i<nseed; i++) {
508 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
510 AliTPCtrack * track = new AliTPCtrack(*pt);
513 // br->SetAddress(&iotrack);
518 //fOutput->GetDirectory()->cd();
524 //write the full seed information if specified in debug mode
526 AliTPCseed * vseed = new AliTPCseed;
528 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
529 arrtr->ExpandCreateFast(160);
530 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
531 //arrcl->ExpandCreateFast(160);
532 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
534 vseed->fPoints = arrtr;
535 vseed->fEPoints = arre;
536 // vseed->fClusterPoints = arrcl;
537 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
538 TBranch * brseed = fSeedTree->GetBranch("seeds");
540 Int_t nseed=fSeeds->GetEntriesFast();
542 for (Int_t i=0; i<nseed; i++) {
543 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
546 // pt->fClusterPoints = arrcl;
550 brseed->SetAddress(&vseed);
554 // pt->fClusterPoints = 0;
557 if (fTreeDebug) fTreeDebug->Write();
565 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
568 //seed->SetErrorY2(0.1);
570 //calculate look-up table at the beginning
571 static Bool_t ginit = kFALSE;
572 static Float_t gnoise1,gnoise2,gnoise3;
573 static Float_t ggg1[10000];
574 static Float_t ggg2[10000];
575 static Float_t ggg3[10000];
576 static Float_t glandau1[10000];
577 static Float_t glandau2[10000];
578 static Float_t glandau3[10000];
580 static Float_t gcor01[500];
581 static Float_t gcor02[500];
582 static Float_t gcorp[500];
587 for (Int_t i=1;i<500;i++){
588 Float_t rsigma = float(i)/100.;
589 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
590 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
591 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
595 for (Int_t i=3;i<10000;i++){
599 Float_t amp = float(i);
600 Float_t padlength =0.75;
601 gnoise1 = 0.0004/padlength;
602 Float_t nel = 0.268*amp;
603 Float_t nprim = 0.155*amp;
604 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
605 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
606 if (glandau1[i]>1) glandau1[i]=1;
607 glandau1[i]*=padlength*padlength/12.;
611 gnoise2 = 0.0004/padlength;
614 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
615 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
616 if (glandau2[i]>1) glandau2[i]=1;
617 glandau2[i]*=padlength*padlength/12.;
622 gnoise3 = 0.0004/padlength;
625 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
626 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
627 if (glandau3[i]>1) glandau3[i]=1;
628 glandau3[i]*=padlength*padlength/12.;
636 Int_t amp = int(TMath::Abs(cl->GetQ()));
638 seed->SetErrorY2(1.);
642 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
643 Int_t ctype = cl->GetType();
644 Float_t padlength= GetPadPitchLength(seed->fRow);
645 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
646 angle2 = angle2/(1-angle2);
649 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
652 if (fSectors==fInnerSec){
654 res = ggg1[amp]*z+glandau1[amp]*angle2;
655 if (ctype==0) res *= gcor01[rsigmay];
658 res*= gcorp[rsigmay];
664 res = ggg2[amp]*z+glandau2[amp]*angle2;
665 if (ctype==0) res *= gcor02[rsigmay];
668 res*= gcorp[rsigmay];
673 res = ggg3[amp]*z+glandau3[amp]*angle2;
674 if (ctype==0) res *= gcor02[rsigmay];
677 res*= gcorp[rsigmay];
684 res*=2.4; // overestimate error 2 times
691 seed->SetErrorY2(res);
699 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
702 //seed->SetErrorY2(0.1);
704 //calculate look-up table at the beginning
705 static Bool_t ginit = kFALSE;
706 static Float_t gnoise1,gnoise2,gnoise3;
707 static Float_t ggg1[10000];
708 static Float_t ggg2[10000];
709 static Float_t ggg3[10000];
710 static Float_t glandau1[10000];
711 static Float_t glandau2[10000];
712 static Float_t glandau3[10000];
714 static Float_t gcor01[1000];
715 static Float_t gcor02[1000];
716 static Float_t gcorp[1000];
721 for (Int_t i=1;i<1000;i++){
722 Float_t rsigma = float(i)/100.;
723 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
724 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
725 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
729 for (Int_t i=3;i<10000;i++){
733 Float_t amp = float(i);
734 Float_t padlength =0.75;
735 gnoise1 = 0.0004/padlength;
736 Float_t nel = 0.268*amp;
737 Float_t nprim = 0.155*amp;
738 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
739 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
740 if (glandau1[i]>1) glandau1[i]=1;
741 glandau1[i]*=padlength*padlength/12.;
745 gnoise2 = 0.0004/padlength;
748 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
749 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
750 if (glandau2[i]>1) glandau2[i]=1;
751 glandau2[i]*=padlength*padlength/12.;
756 gnoise3 = 0.0004/padlength;
759 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
760 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
761 if (glandau3[i]>1) glandau3[i]=1;
762 glandau3[i]*=padlength*padlength/12.;
770 Int_t amp = int(TMath::Abs(cl->GetQ()));
772 seed->SetErrorY2(1.);
776 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
777 Int_t ctype = cl->GetType();
778 Float_t padlength= GetPadPitchLength(seed->fRow);
780 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
781 // if (angle2<0.6) angle2 = 0.6;
782 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
785 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
788 if (fSectors==fInnerSec){
790 res = ggg1[amp]*z+glandau1[amp]*angle2;
791 if (ctype==0) res *= gcor01[rsigmaz];
794 res*= gcorp[rsigmaz];
800 res = ggg2[amp]*z+glandau2[amp]*angle2;
801 if (ctype==0) res *= gcor02[rsigmaz];
804 res*= gcorp[rsigmaz];
809 res = ggg3[amp]*z+glandau3[amp]*angle2;
810 if (ctype==0) res *= gcor02[rsigmaz];
813 res*= gcorp[rsigmaz];
822 if ((ctype<0) &&<70){
830 seed->SetErrorZ2(res);
837 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
840 //seed->SetErrorZ2(0.1);
844 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
846 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
847 Int_t ctype = cl->GetType();
848 Float_t amp = TMath::Abs(cl->GetQ());
853 Float_t landau=2 ; //landau fluctuation part
854 Float_t gg=2; // gg fluctuation part
855 Float_t padlength= GetPadPitchLength(seed->GetX());
857 if (fSectors==fInnerSec){
858 snoise2 = 0.0004/padlength;
861 gg = (2+0.001*nel/(padlength*padlength))/nel;
862 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
863 if (landau>1) landau=1;
866 snoise2 = 0.0004/padlength;
869 gg = (2+0.0008*nel/(padlength*padlength))/nel;
870 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
871 if (landau>1) landau=1;
873 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
876 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
877 angle2 = TMath::Sqrt((1-angle2));
878 if (angle2<0.6) angle2 = 0.6;
881 Float_t angle = seed->GetTgl()/angle2;
882 Float_t angular = landau*angle*angle*padlength*padlength/12.;
883 Float_t res = sdiff + angular;
886 if ((ctype==0) && (fSectors ==fOuterSec))
887 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
889 if ((ctype==0) && (fSectors ==fInnerSec))
890 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
894 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
900 if ((ctype<0) &&<70){
908 seed->SetErrorZ2(res);
916 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
918 //rotate to track "local coordinata
919 Float_t x = seed->GetX();
920 Float_t y = seed->GetY();
921 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
924 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
925 if (!seed->Rotate(fSectors->GetAlpha()))
927 } else if (y <-ymax) {
928 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
929 if (!seed->Rotate(-fSectors->GetAlpha()))
937 //_____________________________________________________________________________
938 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
939 Double_t x2,Double_t y2,
940 Double_t x3,Double_t y3)
942 //-----------------------------------------------------------------
943 // Initial approximation of the track curvature
944 //-----------------------------------------------------------------
945 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
946 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
947 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
948 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
949 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
951 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
952 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
953 return -xr*yr/sqrt(xr*xr+yr*yr);
958 //_____________________________________________________________________________
959 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
960 Double_t x2,Double_t y2,
961 Double_t x3,Double_t y3)
963 //-----------------------------------------------------------------
964 // Initial approximation of the track curvature
965 //-----------------------------------------------------------------
971 Double_t det = x3*y2-x2*y3;
976 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
977 Double_t x0 = x3*0.5-y3*u;
978 Double_t y0 = y3*0.5+x3*u;
979 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
985 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
986 Double_t x2,Double_t y2,
987 Double_t x3,Double_t y3)
989 //-----------------------------------------------------------------
990 // Initial approximation of the track curvature
991 //-----------------------------------------------------------------
997 Double_t det = x3*y2-x2*y3;
1002 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1003 Double_t x0 = x3*0.5-y3*u;
1004 Double_t y0 = y3*0.5+x3*u;
1005 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1014 //_____________________________________________________________________________
1015 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1016 Double_t x2,Double_t y2,
1017 Double_t x3,Double_t y3)
1019 //-----------------------------------------------------------------
1020 // Initial approximation of the track curvature times center of curvature
1021 //-----------------------------------------------------------------
1022 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1023 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1024 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1025 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1026 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1028 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1030 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1033 //_____________________________________________________________________________
1034 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1035 Double_t x2,Double_t y2,
1036 Double_t z1,Double_t z2)
1038 //-----------------------------------------------------------------
1039 // Initial approximation of the tangent of the track dip angle
1040 //-----------------------------------------------------------------
1041 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1045 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1046 Double_t x2,Double_t y2,
1047 Double_t z1,Double_t z2, Double_t c)
1049 //-----------------------------------------------------------------
1050 // Initial approximation of the tangent of the track dip angle
1051 //-----------------------------------------------------------------
1055 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1057 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1058 if (TMath::Abs(d*c*0.5)>1) return 0;
1059 // Double_t angle2 = TMath::ASin(d*c*0.5);
1060 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1061 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1063 angle2 = (z1-z2)*c/(angle2*2.);
1067 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1068 {//-----------------------------------------------------------------
1069 // This function find proloncation of a track to a reference plane x=x2.
1070 //-----------------------------------------------------------------
1074 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1078 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1079 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1083 Double_t dy = dx*(c1+c2)/(r1+r2);
1086 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1088 if (TMath::Abs(delta)>0.01){
1089 dz = x[3]*TMath::ASin(delta)/x[4];
1091 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1094 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1102 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1107 return LoadClusters();
1110 Int_t AliTPCtrackerMI::LoadClusters()
1113 // load clusters to the memory
1114 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1115 clrow->SetClass("AliTPCclusterMI");
1117 clrow->GetArray()->ExpandCreateFast(10000);
1119 // TTree * tree = fClustersArray.GetTree();
1121 TTree * tree = fInput;
1122 TBranch * br = tree->GetBranch("Segment");
1123 br->SetAddress(&clrow);
1125 Int_t j=Int_t(tree->GetEntries());
1126 for (Int_t i=0; i<j; i++) {
1130 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1132 AliTPCRow * tpcrow=0;
1135 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1139 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1140 left = (sec-fkNIS*2)/fkNOS;
1143 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1144 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1145 for (Int_t i=0;i<tpcrow->fN1;i++)
1146 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1149 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1150 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1151 for (Int_t i=0;i<tpcrow->fN2;i++)
1152 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1163 void AliTPCtrackerMI::UnloadClusters()
1166 // unload clusters from the memory
1168 Int_t nrows = fOuterSec->GetNRows();
1169 for (Int_t sec = 0;sec<fkNOS;sec++)
1170 for (Int_t row = 0;row<nrows;row++){
1171 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1173 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1174 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1176 tpcrow->ResetClusters();
1179 nrows = fInnerSec->GetNRows();
1180 for (Int_t sec = 0;sec<fkNIS;sec++)
1181 for (Int_t row = 0;row<nrows;row++){
1182 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1184 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1185 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1187 tpcrow->ResetClusters();
1194 //_____________________________________________________________________________
1195 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1196 //-----------------------------------------------------------------
1197 // This function fills outer TPC sectors with clusters.
1198 //-----------------------------------------------------------------
1199 Int_t nrows = fOuterSec->GetNRows();
1201 for (Int_t sec = 0;sec<fkNOS;sec++)
1202 for (Int_t row = 0;row<nrows;row++){
1203 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1204 Int_t sec2 = sec+2*fkNIS;
1206 Int_t ncl = tpcrow->fN1;
1208 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1209 index=(((sec2<<8)+row)<<16)+ncl;
1210 tpcrow->InsertCluster(c,index);
1215 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1216 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1217 tpcrow->InsertCluster(c,index);
1220 // write indexes for fast acces
1222 for (Int_t i=0;i<510;i++)
1223 tpcrow->fFastCluster[i]=-1;
1224 for (Int_t i=0;i<tpcrow->GetN();i++){
1225 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1226 tpcrow->fFastCluster[zi]=i; // write index
1229 for (Int_t i=0;i<510;i++){
1230 if (tpcrow->fFastCluster[i]<0)
1231 tpcrow->fFastCluster[i] = last;
1233 last = tpcrow->fFastCluster[i];
1242 //_____________________________________________________________________________
1243 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1244 //-----------------------------------------------------------------
1245 // This function fills inner TPC sectors with clusters.
1246 //-----------------------------------------------------------------
1247 Int_t nrows = fInnerSec->GetNRows();
1249 for (Int_t sec = 0;sec<fkNIS;sec++)
1250 for (Int_t row = 0;row<nrows;row++){
1251 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1254 Int_t ncl = tpcrow->fN1;
1256 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1257 index=(((sec<<8)+row)<<16)+ncl;
1258 tpcrow->InsertCluster(c,index);
1263 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1264 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1265 tpcrow->InsertCluster(c,index);
1268 // write indexes for fast acces
1270 for (Int_t i=0;i<510;i++)
1271 tpcrow->fFastCluster[i]=-1;
1272 for (Int_t i=0;i<tpcrow->GetN();i++){
1273 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1274 tpcrow->fFastCluster[zi]=i; // write index
1277 for (Int_t i=0;i<510;i++){
1278 if (tpcrow->fFastCluster[i]<0)
1279 tpcrow->fFastCluster[i] = last;
1281 last = tpcrow->fFastCluster[i];
1293 //_________________________________________________________________________
1294 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1295 //--------------------------------------------------------------------
1296 // Return pointer to a given cluster
1297 //--------------------------------------------------------------------
1298 Int_t sec=(index&0xff000000)>>24;
1299 Int_t row=(index&0x00ff0000)>>16;
1300 Int_t ncl=(index&0x00007fff)>>00;
1302 const AliTPCRow * tpcrow=0;
1303 AliTPCclusterMI * clrow =0;
1306 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1307 if (tpcrow==0) return 0;
1310 if (tpcrow->fN1<=ncl) return 0;
1311 clrow = tpcrow->fClusters1;
1314 if (tpcrow->fN2<=ncl) return 0;
1315 clrow = tpcrow->fClusters2;
1319 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1320 if (tpcrow==0) return 0;
1322 if (sec-2*fkNIS<fkNOS) {
1323 if (tpcrow->fN1<=ncl) return 0;
1324 clrow = tpcrow->fClusters1;
1327 if (tpcrow->fN2<=ncl) return 0;
1328 clrow = tpcrow->fClusters2;
1332 return &(clrow[ncl]);
1338 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1339 //-----------------------------------------------------------------
1340 // This function tries to find a track prolongation to next pad row
1341 //-----------------------------------------------------------------
1343 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1344 AliTPCclusterMI *cl=0;
1345 Int_t tpcindex= t.GetClusterIndex2(nr);
1347 // update current shape info every 5 pad-row
1348 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1352 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1354 if (tpcindex==-1) return 0; //track in dead zone
1356 cl = t.fClusterPointer[nr];
1357 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1358 t.fCurrentClusterIndex1 = tpcindex;
1361 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1362 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1364 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1365 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1367 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1368 Double_t rotation = angle-t.GetAlpha();
1369 t.fRelativeSector= relativesector;
1374 t.fCurrentCluster = cl;
1376 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1377 if ((tpcindex&0x8000)==0) accept =0;
1379 //if founded cluster is acceptible
1380 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1387 UpdateTrack(&t,accept);
1392 if (fIteration>1) return 0; // not look for new cluster during refitting
1395 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1396 Double_t y=t.GetYat(x);
1397 if (TMath::Abs(y)>ymax){
1399 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1400 if (!t.Rotate(fSectors->GetAlpha()))
1402 } else if (y <-ymax) {
1403 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1404 if (!t.Rotate(-fSectors->GetAlpha()))
1410 if (!t.PropagateTo(x)) {
1411 if (fIteration==0) t.fRemoval = 10;
1415 Double_t z=t.GetZ();
1417 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1418 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1420 Double_t roadz = 1.;
1422 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1424 t.SetClusterIndex2(nr,-1);
1429 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() ) t.fNFoundable++;
1435 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1436 cl = krow.FindNearest2(y,z,roady,roadz,index);
1437 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1440 t.fCurrentCluster = cl;
1442 if (fIteration==2&&cl->IsUsed(10)) return 0;
1443 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1444 if (fIteration==2&&cl->IsUsed(11)) {
1451 if (t.fCurrentCluster->IsUsed(10)){
1456 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1462 if (accept<3) UpdateTrack(&t,accept);
1465 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1471 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1472 //-----------------------------------------------------------------
1473 // This function tries to find a track prolongation to next pad row
1474 //-----------------------------------------------------------------
1476 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1478 if (!t.GetProlongation(x,y,z)) {
1484 if (TMath::Abs(y)>ymax){
1487 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1488 if (!t.Rotate(fSectors->GetAlpha()))
1490 } else if (y <-ymax) {
1491 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1492 if (!t.Rotate(-fSectors->GetAlpha()))
1495 if (!t.PropagateTo(x)) {
1498 t.GetProlongation(x,y,z);
1501 // update current shape info every 3 pad-row
1502 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1503 // t.fCurrentSigmaY = GetSigmaY(&t);
1504 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1508 AliTPCclusterMI *cl=0;
1513 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1514 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1516 Double_t roadz = 1.;
1519 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1521 t.SetClusterIndex2(row,-1);
1526 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1530 if ((cl==0)&&(krow)) {
1531 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1532 cl = krow.FindNearest2(y,z,roady,roadz,index);
1534 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1538 t.fCurrentCluster = cl;
1539 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1541 t.SetClusterIndex2(row,index);
1542 t.fClusterPointer[row] = cl;
1550 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1551 //-----------------------------------------------------------------
1552 // This function tries to find a track prolongation to next pad row
1553 //-----------------------------------------------------------------
1554 t.fCurrentCluster = 0;
1555 t.fCurrentClusterIndex1 = 0;
1557 Double_t xt=t.GetX();
1558 Int_t row = GetRowNumber(xt)-1;
1559 Double_t ymax= GetMaxY(nr);
1561 if (row < nr) return 1; // don't prolongate if not information until now -
1562 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1564 return 0; // not prolongate strongly inclined tracks
1566 if (TMath::Abs(t.GetSnp())>0.95) {
1568 return 0; // not prolongate strongly inclined tracks
1571 Double_t x= GetXrow(nr);
1573 //t.PropagateTo(x+0.02);
1574 //t.PropagateTo(x+0.01);
1575 if (!t.PropagateTo(x)){
1582 if (TMath::Abs(y)>ymax){
1584 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1585 if (!t.Rotate(fSectors->GetAlpha()))
1587 } else if (y <-ymax) {
1588 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1589 if (!t.Rotate(-fSectors->GetAlpha()))
1592 // if (!t.PropagateTo(x)){
1600 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1602 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1604 t.SetClusterIndex2(nr,-1);
1609 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1615 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1616 // t.fCurrentSigmaY = GetSigmaY(&t);
1617 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1621 AliTPCclusterMI *cl=0;
1624 Double_t roady = 1.;
1625 Double_t roadz = 1.;
1629 index = t.GetClusterIndex2(nr);
1630 if ( (index>0) && (index&0x8000)==0){
1631 cl = t.fClusterPointer[nr];
1632 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1633 t.fCurrentClusterIndex1 = index;
1635 t.fCurrentCluster = cl;
1641 // if (index<0) return 0;
1642 UInt_t uindex = TMath::Abs(index);
1645 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1646 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1649 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1650 t.fCurrentCluster = cl;
1656 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1657 //-----------------------------------------------------------------
1658 // This function tries to find a track prolongation to next pad row
1659 //-----------------------------------------------------------------
1661 //update error according neighborhoud
1663 if (t.fCurrentCluster) {
1665 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1667 if (t.fCurrentCluster->IsUsed(10)){
1673 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1678 if (fIteration>0) accept = 0;
1679 if (accept<3) UpdateTrack(&t,accept);
1683 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1684 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1686 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1694 //_____________________________________________________________________________
1695 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1696 //-----------------------------------------------------------------
1697 // This function tries to find a track prolongation.
1698 //-----------------------------------------------------------------
1699 Double_t xt=t.GetX();
1701 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1702 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1703 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1705 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1707 Int_t first = GetRowNumber(xt)-1;
1708 for (Int_t nr= first; nr>=rf; nr-=step) {
1710 if (t.GetKinkIndexes()[0]>0){
1711 for (Int_t i=0;i<3;i++){
1712 Int_t index = t.GetKinkIndexes()[i];
1713 if (index==0) break;
1714 if (index<0) continue;
1716 AliESDkink * kink = fEvent->GetKink(index-1);
1718 printf("PROBLEM\n");
1721 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1723 AliExternalTrackParam paramd(t);
1724 kink->SetDaughter(paramd);
1725 kink->SetStatus(2,5);
1732 if (nr==80) t.UpdateReference();
1733 if (nr<fInnerSec->GetNRows())
1734 fSectors = fInnerSec;
1736 fSectors = fOuterSec;
1737 if (FollowToNext(t,nr)==0)
1746 //_____________________________________________________________________________
1747 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1748 //-----------------------------------------------------------------
1749 // This function tries to find a track prolongation.
1750 //-----------------------------------------------------------------
1751 Double_t xt=t.GetX();
1753 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1754 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1755 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1756 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1758 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1760 if (FollowToNextFast(t,nr)==0)
1761 if (!t.IsActive()) return 0;
1771 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1772 //-----------------------------------------------------------------
1773 // This function tries to find a track prolongation.
1774 //-----------------------------------------------------------------
1776 Double_t xt=t.GetX();
1777 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1778 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1779 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1780 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1782 Int_t first = t.fFirstPoint;
1783 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1785 if (first<0) first=0;
1786 for (Int_t nr=first; nr<=rf; nr++) {
1787 if ( (TMath::Abs(t.GetSnp())>0.95)) break;
1788 if (t.GetKinkIndexes()[0]<0){
1789 for (Int_t i=0;i<3;i++){
1790 Int_t index = t.GetKinkIndexes()[i];
1791 if (index==0) break;
1792 if (index>0) continue;
1793 index = TMath::Abs(index);
1794 AliESDkink * kink = fEvent->GetKink(index-1);
1796 printf("PROBLEM\n");
1799 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1801 AliExternalTrackParam paramm(t);
1802 kink->SetMother(paramm);
1803 kink->SetStatus(2,1);
1810 if (nr<fInnerSec->GetNRows())
1811 fSectors = fInnerSec;
1813 fSectors = fOuterSec;
1823 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1831 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1834 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1836 Float_t distance = TMath::Sqrt(dz2+dy2);
1837 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1840 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1841 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1846 if (firstpoint>lastpoint) {
1847 firstpoint =lastpoint;
1852 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1853 if (s1->GetClusterIndex2(i)>0) sum1++;
1854 if (s2->GetClusterIndex2(i)>0) sum2++;
1855 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1859 if (sum<5) return 0;
1861 Float_t summin = TMath::Min(sum1+1,sum2+1);
1862 Float_t ratio = (sum+1)/Float_t(summin);
1866 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1870 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1871 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1873 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1875 Float_t dy2 =(s1->GetY() - s2->GetY());
1877 Float_t distance = dz2+dy2;
1878 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1883 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1884 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1886 if (firstpoint>=lastpoint-5) return;;
1888 for (Int_t i=firstpoint;i<lastpoint;i++){
1889 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1890 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1897 for (Int_t i=firstpoint;i<lastpoint;i++){
1898 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1899 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1900 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1901 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1902 if (s1->IsActive()&&s2->IsActive()){
1903 p1->fIsShared = kTRUE;
1904 p2->fIsShared = kTRUE;
1911 for (Int_t i=0;i<4;i++){
1912 if (s1->fOverlapLabels[3*i]==0){
1913 s1->fOverlapLabels[3*i] = s2->GetLabel();
1914 s1->fOverlapLabels[3*i+1] = sumshared;
1915 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1919 for (Int_t i=0;i<4;i++){
1920 if (s2->fOverlapLabels[3*i]==0){
1921 s2->fOverlapLabels[3*i] = s1->GetLabel();
1922 s2->fOverlapLabels[3*i+1] = sumshared;
1923 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1931 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1934 //sort trackss according sectors
1936 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1937 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1939 //if (pt) RotateToLocal(pt);
1943 arr->Sort(); // sorting according z
1944 arr->Expand(arr->GetEntries());
1947 Int_t nseed=arr->GetEntriesFast();
1948 for (Int_t i=0; i<nseed; i++) {
1949 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1951 for (Int_t j=0;j<=12;j++){
1952 pt->fOverlapLabels[j] =0;
1955 for (Int_t i=0; i<nseed; i++) {
1956 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1958 if (pt->fRemoval>10) continue;
1959 for (Int_t j=i+1; j<nseed; j++){
1960 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1962 if (pt2->fRemoval<=10) {
1963 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1970 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1973 //sort trackss according sectors
1976 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
1979 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1980 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1985 arr->Sort(); // sorting according z
1986 arr->Expand(arr->GetEntries());
1988 //reset overlap labels
1990 Int_t nseed=arr->GetEntriesFast();
1991 for (Int_t i=0; i<nseed; i++) {
1992 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1995 for (Int_t j=0;j<=12;j++){
1996 pt->fOverlapLabels[j] =0;
2000 //sign shared tracks
2001 for (Int_t i=0; i<nseed; i++) {
2002 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2004 if (pt->fRemoval>10) continue;
2005 Float_t deltac = pt->GetC()*0.1;
2006 for (Int_t j=i+1; j<nseed; j++){
2007 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2009 if (pt2->fRemoval<=10) {
2010 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2011 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2012 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2019 // remove highly shared tracks
2020 for (Int_t i=0; i<nseed; i++) {
2021 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2023 if (pt->fRemoval>10) continue;
2026 for (Int_t j=0;j<4;j++){
2027 sumshared = pt->fOverlapLabels[j*3+1];
2029 Float_t factor = factor1;
2030 if (pt->fRemoval>0) factor = factor2;
2031 if (sumshared/pt->GetNumberOfClusters()>factor){
2032 for (Int_t j=0;j<4;j++){
2033 if (pt->fOverlapLabels[3*j]==0) continue;
2034 if (pt->fOverlapLabels[3*j+1]<5) continue;
2035 if (pt->fRemoval==removalindex) continue;
2036 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2038 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2039 // pt->fRemoval = removalindex;
2040 delete arr->RemoveAt(i);
2048 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2057 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2060 //sort tracks in array according mode criteria
2061 Int_t nseed = arr->GetEntriesFast();
2062 for (Int_t i=0; i<nseed; i++) {
2063 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2073 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2076 //Loop over all tracks and remove "overlaps"
2079 Int_t nseed = arr->GetEntriesFast();
2082 for (Int_t i=0; i<nseed; i++) {
2083 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2085 delete arr->RemoveAt(i);
2089 pt->fBSigned = kFALSE;
2093 nseed = arr->GetEntriesFast();
2100 for (Int_t i=0; i<nseed; i++) {
2101 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2105 Int_t found,foundable,shared;
2107 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2109 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2111 Double_t factor = factor2;
2112 if (pt->fBConstrain) factor = factor1;
2114 if ((Float_t(shared)/Float_t(found))>factor){
2115 pt->Desactivate(removalindex);
2120 for (Int_t i=0; i<160; i++) {
2121 Int_t index=pt->GetClusterIndex2(i);
2122 if (index<0 || index&0x8000 ) continue;
2123 AliTPCclusterMI *c= pt->fClusterPointer[i];
2125 // if (!c->IsUsed(10)) c->Use(10);
2126 //if (pt->IsActive())
2135 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2140 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2143 //Loop over all tracks and remove "overlaps"
2148 Int_t nseed = arr->GetEntriesFast();
2149 Float_t * quality = new Float_t[nseed];
2150 Int_t * indexes = new Int_t[nseed];
2154 for (Int_t i=0; i<nseed; i++) {
2155 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2160 pt->UpdatePoints(); //select first last max dens points
2161 Float_t * points = pt->GetPoints();
2162 if (points[3]<0.8) quality[i] =-1;
2164 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2166 TMath::Sort(nseed,quality,indexes);
2169 for (Int_t itrack=0; itrack<nseed; itrack++) {
2170 Int_t trackindex = indexes[itrack];
2171 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2172 if (quality[trackindex]<0){
2174 delete arr->RemoveAt(trackindex);
2177 arr->RemoveAt(trackindex);
2182 Int_t first = Int_t(pt->GetPoints()[0]);
2183 Int_t last = Int_t(pt->GetPoints()[2]);
2184 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2186 Int_t found,foundable,shared;
2187 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2188 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2190 if (Float_t(shared+1)/Float_t(found+1)>factor){
2191 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2192 delete arr->RemoveAt(trackindex);
2196 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2197 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2198 delete arr->RemoveAt(trackindex);
2203 if (sharedfactor>0.4) continue;
2204 for (Int_t i=first; i<last; i++) {
2205 Int_t index=pt->GetClusterIndex2(i);
2206 // if (index<0 || index&0x8000 ) continue;
2207 if (index<0 || index&0x8000 ) continue;
2208 AliTPCclusterMI *c= pt->fClusterPointer[i];
2215 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2221 void AliTPCtrackerMI::UnsignClusters()
2224 // loop over all clusters and unsign them
2227 for (Int_t sec=0;sec<fkNIS;sec++){
2228 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2229 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2230 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2231 // if (cl[icl].IsUsed(10))
2233 cl = fInnerSec[sec][row].fClusters2;
2234 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2235 //if (cl[icl].IsUsed(10))
2240 for (Int_t sec=0;sec<fkNOS;sec++){
2241 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2242 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2243 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2244 //if (cl[icl].IsUsed(10))
2246 cl = fOuterSec[sec][row].fClusters2;
2247 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2248 //if (cl[icl].IsUsed(10))
2257 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2260 //sign clusters to be "used"
2262 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2263 // loop over "primaries"
2277 Int_t nseed = arr->GetEntriesFast();
2278 for (Int_t i=0; i<nseed; i++) {
2279 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2283 if (!(pt->IsActive())) continue;
2284 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2285 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2287 sumdens2+= dens*dens;
2288 sumn += pt->GetNumberOfClusters();
2289 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2290 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2293 sumchi2 +=chi2*chi2;
2298 Float_t mdensity = 0.9;
2299 Float_t meann = 130;
2300 Float_t meanchi = 1;
2301 Float_t sdensity = 0.1;
2302 Float_t smeann = 10;
2303 Float_t smeanchi =0.4;
2307 mdensity = sumdens/sum;
2309 meanchi = sumchi/sum;
2311 sdensity = sumdens2/sum-mdensity*mdensity;
2312 sdensity = TMath::Sqrt(sdensity);
2314 smeann = sumn2/sum-meann*meann;
2315 smeann = TMath::Sqrt(smeann);
2317 smeanchi = sumchi2/sum - meanchi*meanchi;
2318 smeanchi = TMath::Sqrt(smeanchi);
2322 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2324 for (Int_t i=0; i<nseed; i++) {
2325 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2329 if (pt->fBSigned) continue;
2330 if (pt->fBConstrain) continue;
2331 //if (!(pt->IsActive())) continue;
2333 Int_t found,foundable,shared;
2334 pt->GetClusterStatistic(0,160,found, foundable,shared);
2335 if (shared/float(found)>0.3) {
2336 if (shared/float(found)>0.9 ){
2337 //delete arr->RemoveAt(i);
2342 Bool_t isok =kFALSE;
2343 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2345 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2347 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2349 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2353 for (Int_t i=0; i<160; i++) {
2354 Int_t index=pt->GetClusterIndex2(i);
2355 if (index<0) continue;
2356 AliTPCclusterMI *c= pt->fClusterPointer[i];
2358 //if (!(c->IsUsed(10))) c->Use();
2365 Double_t maxchi = meanchi+2.*smeanchi;
2367 for (Int_t i=0; i<nseed; i++) {
2368 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2372 //if (!(pt->IsActive())) continue;
2373 if (pt->fBSigned) continue;
2374 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2375 if (chi>maxchi) continue;
2378 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2380 //sign only tracks with enoug big density at the beginning
2382 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2385 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2386 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2388 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2389 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2392 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2393 //Int_t noc=pt->GetNumberOfClusters();
2394 pt->fBSigned = kTRUE;
2395 for (Int_t i=0; i<160; i++) {
2397 Int_t index=pt->GetClusterIndex2(i);
2398 if (index<0) continue;
2399 AliTPCclusterMI *c= pt->fClusterPointer[i];
2401 // if (!(c->IsUsed(10))) c->Use();
2406 // gLastCheck = nseed;
2414 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2416 // stop not active tracks
2417 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2418 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2419 Int_t nseed = arr->GetEntriesFast();
2421 for (Int_t i=0; i<nseed; i++) {
2422 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2426 if (!(pt->IsActive())) continue;
2427 StopNotActive(pt,row0,th0, th1,th2);
2433 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2436 // stop not active tracks
2437 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2438 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2441 Int_t foundable = 0;
2442 Int_t maxindex = seed->fLastPoint; //last foundable row
2443 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2444 seed->Desactivate(10) ;
2448 for (Int_t i=row0; i<maxindex; i++){
2449 Int_t index = seed->GetClusterIndex2(i);
2450 if (index!=-1) foundable++;
2452 if (foundable<=30) sumgood1++;
2453 if (foundable<=50) {
2460 if (foundable>=30.){
2461 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2464 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2468 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2471 // back propagation of ESD tracks
2477 //PrepareForProlongation(fSeeds,1);
2478 PropagateForward2(fSeeds);
2480 Int_t nseed = fSeeds->GetEntriesFast();
2481 for (Int_t i=0;i<nseed;i++){
2482 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2483 if (!seed) continue;
2484 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2486 seed->PropagateTo(fParam->GetInnerRadiusLow());
2487 seed->UpdatePoints();
2488 AliESDtrack *esd=event->GetTrack(i);
2489 seed->CookdEdx(0.02,0.6);
2490 CookLabel(seed,0.1); //For comparison only
2491 if (seed->GetNumberOfClusters()>15){
2492 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2493 esd->SetTPCPoints(seed->GetPoints());
2497 //printf("problem\n");
2500 //FindKinks(fSeeds,event);
2501 Info("RefitInward","Number of refitted tracks %d",ntracks);
2508 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2511 // back propagation of ESD tracks
2517 PropagateBack(fSeeds);
2518 Int_t nseed = fSeeds->GetEntriesFast();
2520 for (Int_t i=0;i<nseed;i++){
2521 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2522 if (!seed) continue;
2523 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2524 seed->UpdatePoints();
2525 AliESDtrack *esd=event->GetTrack(i);
2526 seed->CookdEdx(0.02,0.6);
2527 CookLabel(seed,0.1); //For comparison only
2528 if (seed->GetNumberOfClusters()>15){
2529 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2530 esd->SetTPCPoints(seed->GetPoints());
2534 //FindKinks(fSeeds,event);
2535 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2542 void AliTPCtrackerMI::DeleteSeeds()
2546 Int_t nseed = fSeeds->GetEntriesFast();
2547 for (Int_t i=0;i<nseed;i++){
2548 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2549 if (seed) delete fSeeds->RemoveAt(i);
2555 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2558 //read seeds from the event
2560 Int_t nentr=event->GetNumberOfTracks();
2562 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2567 fSeeds = new TObjArray(nentr);
2571 for (Int_t i=0; i<nentr; i++) {
2572 AliESDtrack *esd=event->GetTrack(i);
2573 ULong_t status=esd->GetStatus();
2574 if (!(status&AliESDtrack::kTPCin)) continue;
2575 AliTPCtrack t(*esd);
2576 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2577 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2578 for (Int_t ikink=0;ikink<3;ikink++) {
2579 Int_t index = esd->GetKinkIndex(ikink);
2580 seed->GetKinkIndexes()[ikink] = index;
2581 if (index==0) continue;
2582 index = TMath::Abs(index);
2583 AliESDkink * kink = fEvent->GetKink(index-1);
2584 if (kink&&esd->GetKinkIndex(ikink)<0){
2585 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2586 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2588 if (kink&&esd->GetKinkIndex(ikink)>0){
2589 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2590 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2594 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2595 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2596 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2601 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2602 Double_t par0[5],par1[5],x;
2603 esd->GetInnerExternalParameters(x,par0);
2604 esd->GetExternalParameters(x,par1);
2605 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2606 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2608 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2609 //reset covariance if suspicious
2610 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2611 seed->ResetCovariance();
2616 // rotate to the local coordinate system
2618 fSectors=fInnerSec; fN=fkNIS;
2619 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2620 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2621 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2622 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2623 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2624 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2625 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2626 alpha-=seed->GetAlpha();
2627 if (!seed->Rotate(alpha)) {
2633 for (Int_t irow=0;irow<160;irow++){
2634 Int_t index = seed->GetClusterIndex2(irow);
2637 AliTPCclusterMI * cl = GetClusterMI(index);
2638 seed->fClusterPointer[irow] = cl;
2640 if ((index & 0x8000)==0){
2641 cl->Use(10); // accepted cluster
2643 cl->Use(6); // close cluster not accepted
2646 Info("ReadSeeds","Not found cluster");
2650 fSeeds->AddAt(seed,i);
2656 //_____________________________________________________________________________
2657 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2658 Float_t deltay, Int_t ddsec) {
2659 //-----------------------------------------------------------------
2660 // This function creates track seeds.
2661 // SEEDING WITH VERTEX CONSTRAIN
2662 //-----------------------------------------------------------------
2663 // cuts[0] - fP4 cut
2664 // cuts[1] - tan(phi) cut
2665 // cuts[2] - zvertex cut
2666 // cuts[3] - fP3 cut
2674 Double_t x[5], c[15];
2675 // Int_t di = i1-i2;
2677 AliTPCseed * seed = new AliTPCseed;
2678 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2679 Double_t cs=cos(alpha), sn=sin(alpha);
2681 // Double_t x1 =fOuterSec->GetX(i1);
2682 //Double_t xx2=fOuterSec->GetX(i2);
2684 Double_t x1 =GetXrow(i1);
2685 Double_t xx2=GetXrow(i2);
2687 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2689 Int_t imiddle = (i2+i1)/2; //middle pad row index
2690 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2691 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2695 const AliTPCRow& kr1=GetRow(ns,i1);
2696 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2697 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2700 // change cut on curvature if it can't reach this layer
2701 // maximal curvature set to reach it
2702 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2703 if (dvertexmax*0.5*cuts[0]>0.85){
2704 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2706 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2709 if (deltay>0) ddsec = 0;
2710 // loop over clusters
2711 for (Int_t is=0; is < kr1; is++) {
2713 if (kr1[is]->IsUsed(10)) continue;
2714 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2715 //if (TMath::Abs(y1)>ymax) continue;
2717 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2719 // find possible directions
2720 Float_t anglez = (z1-z3)/(x1-x3);
2721 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2724 //find rotation angles relative to line given by vertex and point 1
2725 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2726 Double_t dvertex = TMath::Sqrt(dvertex2);
2727 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2728 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2731 // loop over 2 sectors
2737 Double_t dddz1=0; // direction of delta inclination in z axis
2744 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2745 Int_t sec2 = sec + dsec;
2747 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2748 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2749 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2750 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2751 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2752 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2754 // rotation angles to p1-p3
2755 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2756 Double_t x2, y2, z2;
2758 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2761 Double_t dxx0 = (xx2-x3)*cs13r;
2762 Double_t dyy0 = (xx2-x3)*sn13r;
2763 for (Int_t js=index1; js < index2; js++) {
2764 const AliTPCclusterMI *kcl = kr2[js];
2765 if (kcl->IsUsed(10)) continue;
2767 //calcutate parameters
2769 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2771 if (TMath::Abs(yy0)<0.000001) continue;
2772 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2773 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2774 Double_t r02 = (0.25+y0*y0)*dvertex2;
2775 //curvature (radius) cut
2776 if (r02<r2min) continue;
2780 Double_t c0 = 1/TMath::Sqrt(r02);
2784 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2785 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2786 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2787 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2790 Double_t z0 = kcl->GetZ();
2791 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2792 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2795 Double_t dip = (z1-z0)*c0/dfi1;
2796 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2807 x2= xx2*cs-y2*sn*dsec;
2808 y2=+xx2*sn*dsec+y2*cs;
2818 // do we have cluster at the middle ?
2820 GetProlongation(x1,xm,x,ym,zm);
2822 AliTPCclusterMI * cm=0;
2823 if (TMath::Abs(ym)-ymaxm<0){
2824 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2825 if ((!cm) || (cm->IsUsed(10))) {
2830 // rotate y1 to system 0
2831 // get state vector in rotated system
2832 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2833 Double_t xr2 = x0*cs+yr1*sn*dsec;
2834 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2836 GetProlongation(xx2,xm,xr,ym,zm);
2837 if (TMath::Abs(ym)-ymaxm<0){
2838 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2839 if ((!cm) || (cm->IsUsed(10))) {
2849 dym = ym - cm->GetY();
2850 dzm = zm - cm->GetZ();
2857 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2858 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2859 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2860 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2861 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2863 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2864 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2865 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2866 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2867 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2868 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2870 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2871 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2872 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2873 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2877 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2878 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2879 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2880 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2881 c[13]=f30*sy1*f40+f32*sy2*f42;
2882 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2884 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2886 UInt_t index=kr1.GetIndex(is);
2887 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2889 track->fIsSeeding = kTRUE;
2896 FollowProlongation(*track, (i1+i2)/2,1);
2897 Int_t foundable,found,shared;
2898 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2899 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2901 seed->~AliTPCseed();
2907 FollowProlongation(*track, i2,1);
2911 track->fBConstrain =1;
2912 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2913 track->fLastPoint = i1; // first cluster in track position
2914 track->fFirstPoint = track->fLastPoint;
2916 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2917 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2918 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2920 seed->~AliTPCseed();
2924 // Z VERTEX CONDITION
2926 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2927 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2928 if (TMath::Abs(zv-z3)>cuts[2]) {
2929 FollowProlongation(*track, TMath::Max(i2-20,0));
2930 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2931 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2932 if (TMath::Abs(zv-z3)>cuts[2]){
2933 FollowProlongation(*track, TMath::Max(i2-40,0));
2934 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2935 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2936 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2937 // make seed without constrain
2938 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2939 FollowProlongation(*track2, i2,1);
2940 track2->fBConstrain = kFALSE;
2941 track2->fSeedType = 1;
2942 arr->AddLast(track2);
2944 seed->~AliTPCseed();
2949 seed->~AliTPCseed();
2956 track->fSeedType =0;
2957 arr->AddLast(track);
2958 seed = new AliTPCseed;
2960 // don't consider other combinations
2961 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2967 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2973 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2978 //-----------------------------------------------------------------
2979 // This function creates track seeds.
2980 //-----------------------------------------------------------------
2981 // cuts[0] - fP4 cut
2982 // cuts[1] - tan(phi) cut
2983 // cuts[2] - zvertex cut
2984 // cuts[3] - fP3 cut
2994 Double_t x[5], c[15];
2996 // make temporary seed
2997 AliTPCseed * seed = new AliTPCseed;
2998 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2999 // Double_t cs=cos(alpha), sn=sin(alpha);
3004 Double_t x1 = GetXrow(i1-1);
3005 const AliTPCRow& kr1=GetRow(sec,i1-1);
3006 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3008 Double_t x1p = GetXrow(i1);
3009 const AliTPCRow& kr1p=GetRow(sec,i1);
3011 Double_t x1m = GetXrow(i1-2);
3012 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3015 //last 3 padrow for seeding
3016 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3017 Double_t x3 = GetXrow(i1-7);
3018 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3020 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3021 Double_t x3p = GetXrow(i1-6);
3023 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3024 Double_t x3m = GetXrow(i1-8);
3029 Int_t im = i1-4; //middle pad row index
3030 Double_t xm = GetXrow(im); // radius of middle pad-row
3031 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3032 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3035 Double_t deltax = x1-x3;
3036 Double_t dymax = deltax*cuts[1];
3037 Double_t dzmax = deltax*cuts[3];
3039 // loop over clusters
3040 for (Int_t is=0; is < kr1; is++) {
3042 if (kr1[is]->IsUsed(10)) continue;
3043 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3045 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3047 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3048 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3054 for (Int_t js=index1; js < index2; js++) {
3055 const AliTPCclusterMI *kcl = kr3[js];
3056 if (kcl->IsUsed(10)) continue;
3058 // apply angular cuts
3059 if (TMath::Abs(y1-y3)>dymax) continue;
3062 if (TMath::Abs(z1-z3)>dzmax) continue;
3064 Double_t angley = (y1-y3)/(x1-x3);
3065 Double_t anglez = (z1-z3)/(x1-x3);
3067 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3068 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3070 Double_t yyym = angley*(xm-x1)+y1;
3071 Double_t zzzm = anglez*(xm-x1)+z1;
3073 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3075 if (kcm->IsUsed(10)) continue;
3077 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3078 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3085 // look around first
3086 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3092 if (kc1m->IsUsed(10)) used++;
3094 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3100 if (kc1p->IsUsed(10)) used++;
3102 if (used>1) continue;
3103 if (found<1) continue;
3107 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3113 if (kc3m->IsUsed(10)) used++;
3117 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3123 if (kc3p->IsUsed(10)) used++;
3127 if (used>1) continue;
3128 if (found<3) continue;
3138 x[4]=F1(x1,y1,x2,y2,x3,y3);
3139 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3142 x[2]=F2(x1,y1,x2,y2,x3,y3);
3145 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3146 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3150 Double_t sy1=0.1, sz1=0.1;
3151 Double_t sy2=0.1, sz2=0.1;
3152 Double_t sy3=0.1, sy=0.1, sz=0.1;
3154 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3155 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3156 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3157 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3158 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3159 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3161 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3162 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3163 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3164 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3168 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3169 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3170 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3171 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3172 c[13]=f30*sy1*f40+f32*sy2*f42;
3173 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3175 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3177 UInt_t index=kr1.GetIndex(is);
3178 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3180 track->fIsSeeding = kTRUE;
3183 FollowProlongation(*track, i1-7,1);
3184 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3185 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3187 seed->~AliTPCseed();
3193 FollowProlongation(*track, i2,1);
3194 track->fBConstrain =0;
3195 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3196 track->fFirstPoint = track->fLastPoint;
3198 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3199 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3200 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3202 seed->~AliTPCseed();
3207 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3208 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3209 FollowProlongation(*track2, i2,1);
3210 track2->fBConstrain = kFALSE;
3211 track2->fSeedType = 4;
3212 arr->AddLast(track2);
3214 seed->~AliTPCseed();
3218 //arr->AddLast(track);
3219 //seed = new AliTPCseed;
3225 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3231 //_____________________________________________________________________________
3232 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3233 Float_t deltay, Bool_t /*bconstrain*/) {
3234 //-----------------------------------------------------------------
3235 // This function creates track seeds - without vertex constraint
3236 //-----------------------------------------------------------------
3237 // cuts[0] - fP4 cut - not applied
3238 // cuts[1] - tan(phi) cut
3239 // cuts[2] - zvertex cut - not applied
3240 // cuts[3] - fP3 cut
3250 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3251 // Double_t cs=cos(alpha), sn=sin(alpha);
3252 Int_t row0 = (i1+i2)/2;
3253 Int_t drow = (i1-i2)/2;
3254 const AliTPCRow& kr0=fSectors[sec][row0];
3257 AliTPCpolyTrack polytrack;
3258 Int_t nclusters=fSectors[sec][row0];
3259 AliTPCseed * seed = new AliTPCseed;
3264 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3266 Int_t nfoundable =0;
3267 for (Int_t iter =1; iter<2; iter++){ //iterations
3268 const AliTPCRow& krm=fSectors[sec][row0-iter];
3269 const AliTPCRow& krp=fSectors[sec][row0+iter];
3270 const AliTPCclusterMI * cl= kr0[is];
3272 if (cl->IsUsed(10)) {
3278 Double_t x = kr0.GetX();
3279 // Initialization of the polytrack
3284 Double_t y0= cl->GetY();
3285 Double_t z0= cl->GetZ();
3289 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3290 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3292 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3293 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3294 polytrack.AddPoint(x,y0,z0,erry, errz);
3297 if (cl->IsUsed(10)) sumused++;
3300 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3301 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3304 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3305 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3306 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3307 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3308 if (cl1->IsUsed(10)) sumused++;
3309 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3313 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3315 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3316 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3317 if (cl2->IsUsed(10)) sumused++;
3318 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3321 if (sumused>0) continue;
3323 polytrack.UpdateParameters();
3329 nfoundable = polytrack.GetN();
3330 nfound = nfoundable;
3332 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3333 Float_t maxdist = 0.8*(1.+3./(ddrow));
3334 for (Int_t delta = -1;delta<=1;delta+=2){
3335 Int_t row = row0+ddrow*delta;
3336 kr = &(fSectors[sec][row]);
3337 Double_t xn = kr->GetX();
3338 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3339 polytrack.GetFitPoint(xn,yn,zn);
3340 if (TMath::Abs(yn)>ymax) continue;
3342 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3344 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3347 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3348 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3349 if (cln->IsUsed(10)) {
3350 // printf("used\n");
3358 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3363 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3364 polytrack.UpdateParameters();
3367 if ( (sumused>3) || (sumused>0.5*nfound)) {
3368 //printf("sumused %d\n",sumused);
3373 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3374 AliTPCpolyTrack track2;
3376 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3377 if (track2.GetN()<0.5*nfoundable) continue;
3380 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3382 // test seed with and without constrain
3383 for (Int_t constrain=0; constrain<=0;constrain++){
3384 // add polytrack candidate
3386 Double_t x[5], c[15];
3387 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3388 track2.GetBoundaries(x3,x1);
3390 track2.GetFitPoint(x1,y1,z1);
3391 track2.GetFitPoint(x2,y2,z2);
3392 track2.GetFitPoint(x3,y3,z3);
3394 //is track pointing to the vertex ?
3397 polytrack.GetFitPoint(x0,y0,z0);
3410 x[4]=F1(x1,y1,x2,y2,x3,y3);
3412 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3413 x[2]=F2(x1,y1,x2,y2,x3,y3);
3415 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3416 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3417 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3418 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3421 Double_t sy =0.1, sz =0.1;
3422 Double_t sy1=0.02, sz1=0.02;
3423 Double_t sy2=0.02, sz2=0.02;
3427 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3430 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3431 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3432 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3433 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3434 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3435 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3437 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3438 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3439 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3440 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3445 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3446 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3447 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3448 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3449 c[13]=f30*sy1*f40+f32*sy2*f42;
3450 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3452 //Int_t row1 = fSectors->GetRowNumber(x1);
3453 Int_t row1 = GetRowNumber(x1);
3457 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3458 track->fIsSeeding = kTRUE;
3459 Int_t rc=FollowProlongation(*track, i2);
3460 if (constrain) track->fBConstrain =1;
3462 track->fBConstrain =0;
3463 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3464 track->fFirstPoint = track->fLastPoint;
3466 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3467 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3468 track->fNShared>0.4*track->GetNumberOfClusters()) {
3471 seed->~AliTPCseed();
3474 arr->AddLast(track);
3475 seed = new AliTPCseed;
3479 } // if accepted seed
3482 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3488 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3492 //reseed using track points
3493 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3494 Int_t p1 = int(r1*track->GetNumberOfClusters());
3495 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3497 Double_t x0[3],x1[3],x2[3];
3498 for (Int_t i=0;i<3;i++){
3504 // find track position at given ratio of the length
3505 Int_t sec0=0, sec1=0, sec2=0;
3508 for (Int_t i=0;i<160;i++){
3509 if (track->fClusterPointer[i]){
3511 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3512 if ( (index<p0) || x0[0]<0 ){
3513 if (trpoint->GetX()>1){
3514 clindex = track->GetClusterIndex2(i);
3516 x0[0] = trpoint->GetX();
3517 x0[1] = trpoint->GetY();
3518 x0[2] = trpoint->GetZ();
3519 sec0 = ((clindex&0xff000000)>>24)%18;
3524 if ( (index<p1) &&(trpoint->GetX()>1)){
3525 clindex = track->GetClusterIndex2(i);
3527 x1[0] = trpoint->GetX();
3528 x1[1] = trpoint->GetY();
3529 x1[2] = trpoint->GetZ();
3530 sec1 = ((clindex&0xff000000)>>24)%18;
3533 if ( (index<p2) &&(trpoint->GetX()>1)){
3534 clindex = track->GetClusterIndex2(i);
3536 x2[0] = trpoint->GetX();
3537 x2[1] = trpoint->GetY();
3538 x2[2] = trpoint->GetZ();
3539 sec2 = ((clindex&0xff000000)>>24)%18;
3546 Double_t alpha, cs,sn, xx2,yy2;
3548 alpha = (sec1-sec2)*fSectors->GetAlpha();
3549 cs = TMath::Cos(alpha);
3550 sn = TMath::Sin(alpha);
3551 xx2= x1[0]*cs-x1[1]*sn;
3552 yy2= x1[0]*sn+x1[1]*cs;
3556 alpha = (sec0-sec2)*fSectors->GetAlpha();
3557 cs = TMath::Cos(alpha);
3558 sn = TMath::Sin(alpha);
3559 xx2= x0[0]*cs-x0[1]*sn;
3560 yy2= x0[0]*sn+x0[1]*cs;
3566 Double_t x[5],c[15];
3570 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3571 // if (x[4]>1) return 0;
3572 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3573 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3574 //if (TMath::Abs(x[3]) > 2.2) return 0;
3575 //if (TMath::Abs(x[2]) > 1.99) return 0;
3577 Double_t sy =0.1, sz =0.1;
3579 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3580 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3581 Double_t sy3=0.01+track->GetSigmaY2();
3583 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3584 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3585 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3586 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3587 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3588 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3590 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3591 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3592 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3593 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3598 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3599 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3600 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3601 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3602 c[13]=f30*sy1*f40+f32*sy2*f42;
3603 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3605 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3606 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3607 // Double_t y0,z0,y1,z1, y2,z2;
3608 //seed->GetProlongation(x0[0],y0,z0);
3609 // seed->GetProlongation(x1[0],y1,z1);
3610 //seed->GetProlongation(x2[0],y2,z2);
3612 seed->fLastPoint = pp2;
3613 seed->fFirstPoint = pp2;
3620 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3624 //reseed using founded clusters
3626 // Find the number of clusters
3627 Int_t nclusters = 0;
3628 for (Int_t irow=0;irow<160;irow++){
3629 if (track->GetClusterIndex(irow)>0) nclusters++;
3633 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3634 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3635 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3639 Int_t row[3],sec[3]={0,0,0};
3641 // find track row position at given ratio of the length
3643 for (Int_t irow=0;irow<160;irow++){
3644 if (track->GetClusterIndex2(irow)<0) continue;
3646 for (Int_t ipoint=0;ipoint<3;ipoint++){
3647 if (index<=ipos[ipoint]) row[ipoint] = irow;
3651 //Get cluster and sector position
3652 for (Int_t ipoint=0;ipoint<3;ipoint++){
3653 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3654 AliTPCclusterMI * cl = GetClusterMI(clindex);
3657 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3660 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3661 xyz[ipoint][0] = GetXrow(row[ipoint]);
3662 xyz[ipoint][1] = cl->GetY();
3663 xyz[ipoint][2] = cl->GetZ();
3667 // Calculate seed state vector and covariance matrix
3669 Double_t alpha, cs,sn, xx2,yy2;
3671 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3672 cs = TMath::Cos(alpha);
3673 sn = TMath::Sin(alpha);
3674 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3675 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3679 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3680 cs = TMath::Cos(alpha);
3681 sn = TMath::Sin(alpha);
3682 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3683 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3689 Double_t x[5],c[15];
3693 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3694 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3695 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3697 Double_t sy =0.1, sz =0.1;
3699 Double_t sy1=0.2, sz1=0.2;
3700 Double_t sy2=0.2, sz2=0.2;
3703 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;
3704 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;
3705 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;
3706 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;
3707 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;
3708 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;
3710 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;
3711 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;
3712 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;
3713 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;
3718 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3719 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3720 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3721 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3722 c[13]=f30*sy1*f40+f32*sy2*f42;
3723 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3725 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3726 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3727 seed->fLastPoint = row[2];
3728 seed->fFirstPoint = row[2];
3733 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3737 //reseed using founded clusters
3740 Int_t row[3]={0,0,0};
3741 Int_t sec[3]={0,0,0};
3743 // forward direction
3745 for (Int_t irow=r0;irow<160;irow++){
3746 if (track->GetClusterIndex(irow)>0){
3751 for (Int_t irow=160;irow>r0;irow--){
3752 if (track->GetClusterIndex(irow)>0){
3757 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3758 if (track->GetClusterIndex(irow)>0){
3766 for (Int_t irow=0;irow<r0;irow++){
3767 if (track->GetClusterIndex(irow)>0){
3772 for (Int_t irow=r0;irow>0;irow--){
3773 if (track->GetClusterIndex(irow)>0){
3778 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3779 if (track->GetClusterIndex(irow)>0){
3786 if ((row[2]-row[0])<20) return 0;
3787 if (row[1]==0) return 0;
3790 //Get cluster and sector position
3791 for (Int_t ipoint=0;ipoint<3;ipoint++){
3792 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3793 AliTPCclusterMI * cl = GetClusterMI(clindex);
3796 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3799 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3800 xyz[ipoint][0] = GetXrow(row[ipoint]);
3801 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3802 if (point&&ipoint<2){
3804 xyz[ipoint][1] = point->GetY();
3805 xyz[ipoint][2] = point->GetZ();
3808 xyz[ipoint][1] = cl->GetY();
3809 xyz[ipoint][2] = cl->GetZ();
3816 // Calculate seed state vector and covariance matrix
3818 Double_t alpha, cs,sn, xx2,yy2;
3820 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3821 cs = TMath::Cos(alpha);
3822 sn = TMath::Sin(alpha);
3823 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3824 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3828 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3829 cs = TMath::Cos(alpha);
3830 sn = TMath::Sin(alpha);
3831 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3832 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3838 Double_t x[5],c[15];
3842 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3843 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3844 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3846 Double_t sy =0.1, sz =0.1;
3848 Double_t sy1=0.2, sz1=0.2;
3849 Double_t sy2=0.2, sz2=0.2;
3852 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;
3853 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;
3854 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;
3855 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;
3856 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;
3857 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;
3859 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;
3860 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;
3861 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;
3862 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;
3867 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3868 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3869 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3870 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3871 c[13]=f30*sy1*f40+f32*sy2*f42;
3872 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3874 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3875 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3876 seed->fLastPoint = row[2];
3877 seed->fFirstPoint = row[2];
3878 for (Int_t i=row[0];i<row[2];i++){
3879 seed->fIndex[i] = track->fIndex[i];
3885 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
3892 TObjArray *kinks= new TObjArray(10000);
3893 // TObjArray *v0s= new TObjArray(10000);
3894 Int_t nentries = array->GetEntriesFast();
3895 AliHelix *helixes = new AliHelix[nentries];
3896 Int_t *sign = new Int_t[nentries];
3897 Int_t *nclusters = new Int_t[nentries];
3898 Float_t *alpha = new Float_t[nentries];
3899 AliESDkink * kink = new AliESDkink();
3900 Int_t * usage = new Int_t[nentries];
3901 Float_t *zm = new Float_t[nentries];
3902 Float_t *z0 = new Float_t[nentries];
3903 Float_t *fim = new Float_t[nentries];
3904 Float_t *shared = new Float_t[nentries];
3905 Bool_t *circular = new Bool_t[nentries];
3906 Float_t *dca = new Float_t[nentries];
3907 //const AliESDVertex * primvertex = esd->GetVertex();
3909 // nentries = array->GetEntriesFast();
3914 for (Int_t i=0;i<nentries;i++){
3917 AliTPCseed* track = (AliTPCseed*)array->At(i);
3918 if (!track) continue;
3919 track->fCircular =0;
3921 track->UpdatePoints();
3922 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
3924 nclusters[i]=track->GetNumberOfClusters();
3925 alpha[i] = track->GetAlpha();
3926 new (&helixes[i]) AliHelix(*track);
3928 helixes[i].Evaluate(0,xyz);
3929 sign[i] = (track->GetC()>0) ? -1:1;
3932 if (track->GetProlongation(x,y,z)){
3934 fim[i] = alpha[i]+TMath::ATan2(y,x);
3937 zm[i] = track->GetZ();
3941 circular[i]= kFALSE;
3942 if (track->GetProlongation(0,y,z)) z0[i] = z;
3943 dca[i] = track->GetD(0,0);
3949 Int_t ncandidates =0;
3952 Double_t phase[2][2],radius[2];
3955 // Find circling track
3956 TTreeSRedirector &cstream = *fDebugStreamer;
3958 for (Int_t i0=0;i0<nentries;i0++){
3959 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
3960 if (!track0) continue;
3961 if (track0->fN<40) continue;
3962 if (TMath::Abs(1./track0->fP4)>200) continue;
3963 for (Int_t i1=i0+1;i1<nentries;i1++){
3964 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
3965 if (!track1) continue;
3966 if (track1->fN<40) continue;
3967 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
3968 if (track0->fBConstrain&&track1->fBConstrain) continue;
3969 if (TMath::Abs(1./track1->fP4)>200) continue;
3970 if (track1->fP4*track0->fP4>0) continue;
3971 if (track1->fP3*track0->fP3>0) continue;
3972 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
3973 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
3974 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
3976 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
3977 if (mindcar<5) continue;
3978 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
3979 if (mindcaz<5) continue;
3980 if (mindcar+mindcaz<20) continue;
3983 Float_t xc0 = helixes[i0].GetHelix(6);
3984 Float_t yc0 = helixes[i0].GetHelix(7);
3985 Float_t r0 = helixes[i0].GetHelix(8);
3986 Float_t xc1 = helixes[i1].GetHelix(6);
3987 Float_t yc1 = helixes[i1].GetHelix(7);
3988 Float_t r1 = helixes[i1].GetHelix(8);
3990 Float_t rmean = (r0+r1)*0.5;
3991 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
3992 //if (delta>30) continue;
3993 if (delta>rmean*0.25) continue;
3994 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
3996 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
3997 if (npoints==0) continue;
3998 helixes[i0].GetClosestPhases(helixes[i1], phase);
4002 Double_t hangles[3];
4003 helixes[i0].Evaluate(phase[0][0],xyz0);
4004 helixes[i1].Evaluate(phase[0][1],xyz1);
4006 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4007 Double_t deltah[2],deltabest;
4008 if (hangles[2]<2.8) continue;
4010 cstream<<"C"<<track0->fLab<<track1->fLab<<
4011 track0->fP3<<track1->fP3<<
4012 track0->fP4<<track1->fP4<<
4013 delta<<rmean<<npoints<<
4014 hangles[0]<<hangles[2]<<
4015 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4019 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4021 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4022 if (deltah[1]<deltah[0]) ibest=1;
4024 deltabest = TMath::Sqrt(deltah[ibest]);
4025 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4026 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4027 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4028 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4030 if (deltabest>6) continue;
4031 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4032 Bool_t sign =kFALSE;
4033 if (hangles[2]>3.06) sign =kTRUE;
4036 circular[i0] = kTRUE;
4037 circular[i1] = kTRUE;
4038 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4039 track0->fCircular += 1;
4040 track1->fCircular += 2;
4043 track1->fCircular += 1;
4044 track0->fCircular += 2;
4049 cstream<<"Curling"<<
4050 "lab0="<<track0->fLab<<
4051 "lab1="<<track1->fLab<<
4056 "mindcar="<<mindcar<<
4057 "mindcaz="<<mindcaz<<
4060 "npoints="<<npoints<<
4061 "hangles0="<<hangles[0]<<
4062 "hangles2="<<hangles[2]<<
4067 "radius="<<radiusbest<<
4068 "deltabest="<<deltabest<<
4069 "phase0="<<phase[ibest][0]<<
4070 "phase1="<<phase[ibest][1]<<
4080 for (Int_t i =0;i<nentries;i++){
4081 if (sign[i]==0) continue;
4082 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4085 Double_t cradius0 = 40*40;
4086 Double_t cradius1 = 270*270;
4089 Double_t cdist3=0.55;
4090 for (Int_t j =i+1;j<nentries;j++){
4092 if (sign[j]*sign[i]<1) continue;
4093 if ( (nclusters[i]+nclusters[j])>200) continue;
4094 if ( (nclusters[i]+nclusters[j])<80) continue;
4095 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4096 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4097 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4098 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4099 if (npoints<1) continue;
4102 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4105 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4108 Double_t delta1=10000,delta2=10000;
4109 // cuts on the intersection radius
4110 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4111 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4112 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4114 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4115 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4116 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4119 Double_t distance1 = TMath::Min(delta1,delta2);
4120 if (distance1>cdist1) continue; // cut on DCA linear approximation
4122 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4123 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4124 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4125 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4128 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4129 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4130 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4132 distance1 = TMath::Min(delta1,delta2);
4135 rkink = TMath::Sqrt(radius[0]);
4138 rkink = TMath::Sqrt(radius[1]);
4140 if (distance1>cdist2) continue;
4143 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4146 Int_t row0 = GetRowNumber(rkink);
4147 if (row0<10) continue;
4148 if (row0>150) continue;
4151 Float_t dens00=-1,dens01=-1;
4152 Float_t dens10=-1,dens11=-1;
4154 Int_t found,foundable,shared;
4155 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4156 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4157 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4158 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4160 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4161 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4162 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4163 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4165 if (dens00<dens10 && dens01<dens11) continue;
4166 if (dens00>dens10 && dens01>dens11) continue;
4167 if (TMath::Max(dens00,dens10)<0.1) continue;
4168 if (TMath::Max(dens01,dens11)<0.3) continue;
4170 if (TMath::Min(dens00,dens10)>0.6) continue;
4171 if (TMath::Min(dens01,dens11)>0.6) continue;
4174 AliTPCseed * ktrack0, *ktrack1;
4183 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4184 AliExternalTrackParam paramm(*ktrack0);
4185 AliExternalTrackParam paramd(*ktrack1);
4186 if (row0>60&&ktrack1->GetReference().X()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4189 kink->SetMother(paramm);
4190 kink->SetDaughter(paramd);
4193 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4195 fParam->Transform0to1(x,index);
4196 fParam->Transform1to2(x,index);
4197 row0 = GetRowNumber(x[0]);
4199 if (kink->GetR()<100) continue;
4200 if (kink->GetR()>240) continue;
4201 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4202 if (kink->GetDistance()>cdist3) continue;
4203 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4204 if (dird<0) continue;
4206 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4207 if (dirm<0) continue;
4208 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4209 if (mpt<0.2) continue;
4212 //for high momenta momentum not defined well in first iteration
4213 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4214 if (qt>0.35) continue;
4217 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4218 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4220 kink->SetTPCDensity(dens00,0,0);
4221 kink->SetTPCDensity(dens01,0,1);
4222 kink->SetTPCDensity(dens10,1,0);
4223 kink->SetTPCDensity(dens11,1,1);
4224 kink->SetIndex(i,0);
4225 kink->SetIndex(j,1);
4228 kink->SetTPCDensity(dens10,0,0);
4229 kink->SetTPCDensity(dens11,0,1);
4230 kink->SetTPCDensity(dens00,1,0);
4231 kink->SetTPCDensity(dens01,1,1);
4232 kink->SetIndex(j,0);
4233 kink->SetIndex(i,1);
4236 if (mpt<1||kink->GetAngle(2)>0.1){
4237 // angle and densities not defined yet
4238 if (kink->GetTPCDensityFactor()<0.8) continue;
4239 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4240 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4241 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4242 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4244 Float_t criticalangle = track0->fC22+track0->fC33;
4245 criticalangle+= track1->fC22+track1->fC33;
4246 criticalangle= 3*TMath::Sqrt(criticalangle);
4247 if (criticalangle>0.02) criticalangle=0.02;
4248 if (kink->GetAngle(2)<criticalangle) continue;
4251 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4252 Float_t shapesum =0;
4254 for ( Int_t row = row0-drow; row<row0+drow;row++){
4255 if (row<0) continue;
4256 if (row>155) continue;