1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker
23 //-------------------------------------------------------
28 #include "Riostream.h"
29 #include <TClonesArray.h>
31 #include <TObjArray.h>
34 #include "AliComplexCluster.h"
36 #include "AliESDkink.h"
38 #include "AliRunLoader.h"
39 #include "AliTPCClustersRow.h"
40 #include "AliTPCParam.h"
41 #include "AliTPCReconstructor.h"
42 #include "AliTPCclusterMI.h"
43 #include "AliTPCpolyTrack.h"
44 #include "AliTPCreco.h"
45 #include "AliTPCseed.h"
46 #include "AliTPCtrackerMI.h"
47 #include "TStopwatch.h"
48 #include "AliTPCReconstructor.h"
49 #include "AliESDkink.h"
51 #include "TTreeStream.h"
52 #include "AliAlignObj.h"
53 #include "AliTrackPointArray.h"
57 ClassImp(AliTPCtrackerMI)
60 class AliTPCFastMath {
63 static Double_t FastAsin(Double_t x);
65 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
68 Double_t AliTPCFastMath::fgFastAsin[20000];
69 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
71 AliTPCFastMath::AliTPCFastMath(){
73 // initialized lookup table;
74 for (Int_t i=0;i<10000;i++){
75 fgFastAsin[2*i] = TMath::ASin(i/10000.);
76 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
80 Double_t AliTPCFastMath::FastAsin(Double_t x){
82 // return asin using lookup table
84 Int_t index = int(x*10000);
85 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
88 Int_t index = int(x*10000);
89 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
95 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
97 //update track information using current cluster - track->fCurrentCluster
100 AliTPCclusterMI* c =track->fCurrentCluster;
101 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
103 UInt_t i = track->fCurrentClusterIndex1;
105 Int_t sec=(i&0xff000000)>>24;
106 //Int_t row = (i&0x00ff0000)>>16;
107 track->fRow=(i&0x00ff0000)>>16;
108 track->fSector = sec;
109 // Int_t index = i&0xFFFF;
110 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
111 track->SetClusterIndex2(track->fRow, i);
112 //track->fFirstPoint = row;
113 //if ( track->fLastPoint<row) track->fLastPoint =row;
114 // if (track->fRow<0 || track->fRow>160) {
115 // printf("problem\n");
117 if (track->fFirstPoint>track->fRow)
118 track->fFirstPoint = track->fRow;
119 if (track->fLastPoint<track->fRow)
120 track->fLastPoint = track->fRow;
123 track->fClusterPointer[track->fRow] = c;
126 Double_t angle2 = track->GetSnp()*track->GetSnp();
127 angle2 = TMath::Sqrt(angle2/(1-angle2));
129 //SET NEW Track Point
133 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
135 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
136 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
137 point.SetErrY(sqrt(track->fErrorY2));
138 point.SetErrZ(sqrt(track->fErrorZ2));
140 point.SetX(track->GetX());
141 point.SetY(track->GetY());
142 point.SetZ(track->GetZ());
143 point.SetAngleY(angle2);
144 point.SetAngleZ(track->GetTgl());
145 if (point.fIsShared){
146 track->fErrorY2 *= 4;
147 track->fErrorZ2 *= 4;
151 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
153 track->fErrorY2 *= 1.3;
154 track->fErrorY2 += 0.01;
155 track->fErrorZ2 *= 1.3;
156 track->fErrorZ2 += 0.005;
158 if (accept>0) return 0;
159 if (track->GetNumberOfClusters()%20==0){
160 // if (track->fHelixIn){
161 // TClonesArray & larr = *(track->fHelixIn);
162 // Int_t ihelix = larr.GetEntriesFast();
163 // new(larr[ihelix]) AliHelix(*track) ;
166 track->fNoCluster =0;
167 return track->Update(c,chi2,i);
172 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
173 Float_t cory, Float_t corz)
176 // decide according desired precision to accept given
177 // cluster for tracking
178 Double_t sy2=ErrY2(seed,cluster)*cory;
179 Double_t sz2=ErrZ2(seed,cluster)*corz;
180 //sy2=ErrY2(seed,cluster)*cory;
181 //sz2=ErrZ2(seed,cluster)*cory;
183 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
184 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
186 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
187 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
188 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
189 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
191 Double_t rdistance2 = rdistancey2+rdistancez2;
194 if (rdistance2>16) return 3;
197 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
198 return 2; //suspisiouce - will be changed
200 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
201 // strict cut on overlaped cluster
202 return 2; //suspisiouce - will be changed
204 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
205 && cluster->GetType()<0){
215 //_____________________________________________________________________________
216 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
217 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
219 //---------------------------------------------------------------------
220 // The main TPC tracker constructor
221 //---------------------------------------------------------------------
222 fInnerSec=new AliTPCSector[fkNIS];
223 fOuterSec=new AliTPCSector[fkNOS];
226 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
227 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
234 Int_t nrowlow = par->GetNRowLow();
235 Int_t nrowup = par->GetNRowUp();
238 for (Int_t i=0;i<nrowlow;i++){
239 fXRow[i] = par->GetPadRowRadiiLow(i);
240 fPadLength[i]= par->GetPadPitchLength(0,i);
241 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
245 for (Int_t i=0;i<nrowup;i++){
246 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
247 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
248 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
259 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
261 //________________________________________________________________________
262 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
267 //------------------------------------
268 // dummy copy constructor
269 //------------------------------------------------------------------
271 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
272 //------------------------------
274 //--------------------------------------------------------------
277 //_____________________________________________________________________________
278 AliTPCtrackerMI::~AliTPCtrackerMI() {
279 //------------------------------------------------------------------
280 // TPC tracker destructor
281 //------------------------------------------------------------------
288 if (fDebugStreamer) delete fDebugStreamer;
291 void AliTPCtrackerMI::SetIO()
295 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
297 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
299 AliTPCtrack *iotrack= new AliTPCtrack;
300 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
306 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
322 AliTPCtrack *iotrack= new AliTPCtrack;
323 // iotrack->fHelixIn = new TClonesArray("AliHelix");
324 //iotrack->fHelixOut = new TClonesArray("AliHelix");
325 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
328 if (output && (fDebug&2)){
329 //write the full seed information if specified in debug mode
331 fSeedTree = new TTree("Seeds","Seeds");
332 AliTPCseed * vseed = new AliTPCseed;
334 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
335 arrtr->ExpandCreateFast(160);
336 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
338 vseed->fPoints = arrtr;
339 vseed->fEPoints = arre;
340 // vseed->fClusterPoints = arrcl;
341 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
344 fTreeDebug = new TTree("trackDebug","trackDebug");
345 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
346 fTreeDebug->Branch("debug",&arrd,32000,99);
354 void AliTPCtrackerMI::FillESD(TObjArray* arr)
358 //fill esds using updated tracks
360 // write tracks to the event
361 // store index of the track
362 Int_t nseed=arr->GetEntriesFast();
363 //FindKinks(arr,fEvent);
364 for (Int_t i=0; i<nseed; i++) {
365 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
368 // pt->PropagateTo(fParam->GetInnerRadiusLow());
369 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
370 pt->PropagateTo(fParam->GetInnerRadiusLow());
373 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
375 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
376 iotrack.SetTPCPoints(pt->GetPoints());
377 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
378 iotrack.SetV0Indexes(pt->GetV0Indexes());
379 // iotrack.SetTPCpid(pt->fTPCr);
380 //iotrack.SetTPCindex(i);
381 fEvent->AddTrack(&iotrack);
385 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
387 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
388 iotrack.SetTPCPoints(pt->GetPoints());
389 //iotrack.SetTPCindex(i);
390 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
391 iotrack.SetV0Indexes(pt->GetV0Indexes());
392 // iotrack.SetTPCpid(pt->fTPCr);
393 fEvent->AddTrack(&iotrack);
397 // short tracks - maybe decays
399 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
400 Int_t found,foundable,shared;
401 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
402 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
404 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
405 //iotrack.SetTPCindex(i);
406 iotrack.SetTPCPoints(pt->GetPoints());
407 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
408 iotrack.SetV0Indexes(pt->GetV0Indexes());
409 //iotrack.SetTPCpid(pt->fTPCr);
410 fEvent->AddTrack(&iotrack);
415 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
416 Int_t found,foundable,shared;
417 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
418 if (found<20) continue;
419 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
422 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
423 iotrack.SetTPCPoints(pt->GetPoints());
424 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
425 iotrack.SetV0Indexes(pt->GetV0Indexes());
426 //iotrack.SetTPCpid(pt->fTPCr);
427 //iotrack.SetTPCindex(i);
428 fEvent->AddTrack(&iotrack);
431 // short tracks - secondaties
433 if ( (pt->GetNumberOfClusters()>30) ) {
434 Int_t found,foundable,shared;
435 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
436 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
438 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
439 iotrack.SetTPCPoints(pt->GetPoints());
440 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
441 iotrack.SetV0Indexes(pt->GetV0Indexes());
442 //iotrack.SetTPCpid(pt->fTPCr);
443 //iotrack.SetTPCindex(i);
444 fEvent->AddTrack(&iotrack);
449 if ( (pt->GetNumberOfClusters()>15)) {
450 Int_t found,foundable,shared;
451 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
452 if (found<15) continue;
453 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
454 if (float(found)/float(foundable)<0.8) continue;
457 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
458 iotrack.SetTPCPoints(pt->GetPoints());
459 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
460 iotrack.SetV0Indexes(pt->GetV0Indexes());
461 // iotrack.SetTPCpid(pt->fTPCr);
462 //iotrack.SetTPCindex(i);
463 fEvent->AddTrack(&iotrack);
468 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
471 void AliTPCtrackerMI::WriteTracks(TTree * tree)
474 // write tracks from seed array to selected tree
478 AliTPCtrack *iotrack= new AliTPCtrack;
479 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
484 void AliTPCtrackerMI::WriteTracks()
487 // write tracks to the given output tree -
488 // output specified with SetIO routine
495 AliTPCtrack *iotrack= 0;
496 Int_t nseed=fSeeds->GetEntriesFast();
497 //for (Int_t i=0; i<nseed; i++) {
498 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
499 // if (iotrack) break;
501 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
502 TBranch * br = fOutput->GetBranch("tracks");
503 br->SetAddress(&iotrack);
505 for (Int_t i=0; i<nseed; i++) {
506 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
508 AliTPCtrack * track = new AliTPCtrack(*pt);
511 // br->SetAddress(&iotrack);
516 //fOutput->GetDirectory()->cd();
522 //write the full seed information if specified in debug mode
524 AliTPCseed * vseed = new AliTPCseed;
526 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
527 arrtr->ExpandCreateFast(160);
528 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
529 //arrcl->ExpandCreateFast(160);
530 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
532 vseed->fPoints = arrtr;
533 vseed->fEPoints = arre;
534 // vseed->fClusterPoints = arrcl;
535 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
536 TBranch * brseed = fSeedTree->GetBranch("seeds");
538 Int_t nseed=fSeeds->GetEntriesFast();
540 for (Int_t i=0; i<nseed; i++) {
541 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
544 // pt->fClusterPoints = arrcl;
548 brseed->SetAddress(&vseed);
552 // pt->fClusterPoints = 0;
555 if (fTreeDebug) fTreeDebug->Write();
563 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
566 //seed->SetErrorY2(0.1);
568 //calculate look-up table at the beginning
569 static Bool_t ginit = kFALSE;
570 static Float_t gnoise1,gnoise2,gnoise3;
571 static Float_t ggg1[10000];
572 static Float_t ggg2[10000];
573 static Float_t ggg3[10000];
574 static Float_t glandau1[10000];
575 static Float_t glandau2[10000];
576 static Float_t glandau3[10000];
578 static Float_t gcor01[500];
579 static Float_t gcor02[500];
580 static Float_t gcorp[500];
585 for (Int_t i=1;i<500;i++){
586 Float_t rsigma = float(i)/100.;
587 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
588 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
589 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
593 for (Int_t i=3;i<10000;i++){
597 Float_t amp = float(i);
598 Float_t padlength =0.75;
599 gnoise1 = 0.0004/padlength;
600 Float_t nel = 0.268*amp;
601 Float_t nprim = 0.155*amp;
602 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
603 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
604 if (glandau1[i]>1) glandau1[i]=1;
605 glandau1[i]*=padlength*padlength/12.;
609 gnoise2 = 0.0004/padlength;
612 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
613 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
614 if (glandau2[i]>1) glandau2[i]=1;
615 glandau2[i]*=padlength*padlength/12.;
620 gnoise3 = 0.0004/padlength;
623 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
624 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
625 if (glandau3[i]>1) glandau3[i]=1;
626 glandau3[i]*=padlength*padlength/12.;
634 Int_t amp = int(TMath::Abs(cl->GetQ()));
636 seed->SetErrorY2(1.);
640 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
641 Int_t ctype = cl->GetType();
642 Float_t padlength= GetPadPitchLength(seed->fRow);
643 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
644 angle2 = angle2/(1-angle2);
647 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
650 if (fSectors==fInnerSec){
652 res = ggg1[amp]*z+glandau1[amp]*angle2;
653 if (ctype==0) res *= gcor01[rsigmay];
656 res*= gcorp[rsigmay];
662 res = ggg2[amp]*z+glandau2[amp]*angle2;
663 if (ctype==0) res *= gcor02[rsigmay];
666 res*= gcorp[rsigmay];
671 res = ggg3[amp]*z+glandau3[amp]*angle2;
672 if (ctype==0) res *= gcor02[rsigmay];
675 res*= gcorp[rsigmay];
682 res*=2.4; // overestimate error 2 times
689 seed->SetErrorY2(res);
697 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
700 //seed->SetErrorY2(0.1);
702 //calculate look-up table at the beginning
703 static Bool_t ginit = kFALSE;
704 static Float_t gnoise1,gnoise2,gnoise3;
705 static Float_t ggg1[10000];
706 static Float_t ggg2[10000];
707 static Float_t ggg3[10000];
708 static Float_t glandau1[10000];
709 static Float_t glandau2[10000];
710 static Float_t glandau3[10000];
712 static Float_t gcor01[1000];
713 static Float_t gcor02[1000];
714 static Float_t gcorp[1000];
719 for (Int_t i=1;i<1000;i++){
720 Float_t rsigma = float(i)/100.;
721 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
722 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
723 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
727 for (Int_t i=3;i<10000;i++){
731 Float_t amp = float(i);
732 Float_t padlength =0.75;
733 gnoise1 = 0.0004/padlength;
734 Float_t nel = 0.268*amp;
735 Float_t nprim = 0.155*amp;
736 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
737 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
738 if (glandau1[i]>1) glandau1[i]=1;
739 glandau1[i]*=padlength*padlength/12.;
743 gnoise2 = 0.0004/padlength;
746 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
747 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
748 if (glandau2[i]>1) glandau2[i]=1;
749 glandau2[i]*=padlength*padlength/12.;
754 gnoise3 = 0.0004/padlength;
757 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
758 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
759 if (glandau3[i]>1) glandau3[i]=1;
760 glandau3[i]*=padlength*padlength/12.;
768 Int_t amp = int(TMath::Abs(cl->GetQ()));
770 seed->SetErrorY2(1.);
774 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
775 Int_t ctype = cl->GetType();
776 Float_t padlength= GetPadPitchLength(seed->fRow);
778 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
779 // if (angle2<0.6) angle2 = 0.6;
780 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
783 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
786 if (fSectors==fInnerSec){
788 res = ggg1[amp]*z+glandau1[amp]*angle2;
789 if (ctype==0) res *= gcor01[rsigmaz];
792 res*= gcorp[rsigmaz];
798 res = ggg2[amp]*z+glandau2[amp]*angle2;
799 if (ctype==0) res *= gcor02[rsigmaz];
802 res*= gcorp[rsigmaz];
807 res = ggg3[amp]*z+glandau3[amp]*angle2;
808 if (ctype==0) res *= gcor02[rsigmaz];
811 res*= gcorp[rsigmaz];
820 if ((ctype<0) &&<70){
828 seed->SetErrorZ2(res);
835 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
838 //seed->SetErrorZ2(0.1);
842 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
844 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
845 Int_t ctype = cl->GetType();
846 Float_t amp = TMath::Abs(cl->GetQ());
851 Float_t landau=2 ; //landau fluctuation part
852 Float_t gg=2; // gg fluctuation part
853 Float_t padlength= GetPadPitchLength(seed->GetX());
855 if (fSectors==fInnerSec){
856 snoise2 = 0.0004/padlength;
859 gg = (2+0.001*nel/(padlength*padlength))/nel;
860 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
861 if (landau>1) landau=1;
864 snoise2 = 0.0004/padlength;
867 gg = (2+0.0008*nel/(padlength*padlength))/nel;
868 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
869 if (landau>1) landau=1;
871 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
874 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
875 angle2 = TMath::Sqrt((1-angle2));
876 if (angle2<0.6) angle2 = 0.6;
879 Float_t angle = seed->GetTgl()/angle2;
880 Float_t angular = landau*angle*angle*padlength*padlength/12.;
881 Float_t res = sdiff + angular;
884 if ((ctype==0) && (fSectors ==fOuterSec))
885 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
887 if ((ctype==0) && (fSectors ==fInnerSec))
888 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
892 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
898 if ((ctype<0) &&<70){
906 seed->SetErrorZ2(res);
914 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
916 //rotate to track "local coordinata
917 Float_t x = seed->GetX();
918 Float_t y = seed->GetY();
919 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
922 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
923 if (!seed->Rotate(fSectors->GetAlpha()))
925 } else if (y <-ymax) {
926 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
927 if (!seed->Rotate(-fSectors->GetAlpha()))
935 //_____________________________________________________________________________
936 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
937 Double_t x2,Double_t y2,
938 Double_t x3,Double_t y3)
940 //-----------------------------------------------------------------
941 // Initial approximation of the track curvature
942 //-----------------------------------------------------------------
943 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
944 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
945 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
946 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
947 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
949 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
950 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
951 return -xr*yr/sqrt(xr*xr+yr*yr);
956 //_____________________________________________________________________________
957 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
958 Double_t x2,Double_t y2,
959 Double_t x3,Double_t y3)
961 //-----------------------------------------------------------------
962 // Initial approximation of the track curvature
963 //-----------------------------------------------------------------
969 Double_t det = x3*y2-x2*y3;
974 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
975 Double_t x0 = x3*0.5-y3*u;
976 Double_t y0 = y3*0.5+x3*u;
977 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
983 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
984 Double_t x2,Double_t y2,
985 Double_t x3,Double_t y3)
987 //-----------------------------------------------------------------
988 // Initial approximation of the track curvature
989 //-----------------------------------------------------------------
995 Double_t det = x3*y2-x2*y3;
1000 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1001 Double_t x0 = x3*0.5-y3*u;
1002 Double_t y0 = y3*0.5+x3*u;
1003 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1012 //_____________________________________________________________________________
1013 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1014 Double_t x2,Double_t y2,
1015 Double_t x3,Double_t y3)
1017 //-----------------------------------------------------------------
1018 // Initial approximation of the track curvature times center of curvature
1019 //-----------------------------------------------------------------
1020 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1021 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1022 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1023 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1024 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1026 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1028 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1031 //_____________________________________________________________________________
1032 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1033 Double_t x2,Double_t y2,
1034 Double_t z1,Double_t z2)
1036 //-----------------------------------------------------------------
1037 // Initial approximation of the tangent of the track dip angle
1038 //-----------------------------------------------------------------
1039 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1043 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1044 Double_t x2,Double_t y2,
1045 Double_t z1,Double_t z2, Double_t c)
1047 //-----------------------------------------------------------------
1048 // Initial approximation of the tangent of the track dip angle
1049 //-----------------------------------------------------------------
1053 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1055 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1056 if (TMath::Abs(d*c*0.5)>1) return 0;
1057 // Double_t angle2 = TMath::ASin(d*c*0.5);
1058 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1059 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1061 angle2 = (z1-z2)*c/(angle2*2.);
1065 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1066 {//-----------------------------------------------------------------
1067 // This function find proloncation of a track to a reference plane x=x2.
1068 //-----------------------------------------------------------------
1072 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1076 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1077 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1081 Double_t dy = dx*(c1+c2)/(r1+r2);
1084 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1086 if (TMath::Abs(delta)>0.01){
1087 dz = x[3]*TMath::ASin(delta)/x[4];
1089 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1092 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1100 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1105 return LoadClusters();
1108 Int_t AliTPCtrackerMI::LoadClusters()
1111 // load clusters to the memory
1112 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1113 clrow->SetClass("AliTPCclusterMI");
1115 clrow->GetArray()->ExpandCreateFast(10000);
1117 // TTree * tree = fClustersArray.GetTree();
1119 TTree * tree = fInput;
1120 TBranch * br = tree->GetBranch("Segment");
1121 br->SetAddress(&clrow);
1123 Int_t j=Int_t(tree->GetEntries());
1124 for (Int_t i=0; i<j; i++) {
1128 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1129 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1130 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1133 AliTPCRow * tpcrow=0;
1136 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1140 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1141 left = (sec-fkNIS*2)/fkNOS;
1144 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1145 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1146 for (Int_t i=0;i<tpcrow->fN1;i++)
1147 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1150 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1151 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1152 for (Int_t i=0;i<tpcrow->fN2;i++)
1153 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1164 void AliTPCtrackerMI::UnloadClusters()
1167 // unload clusters from the memory
1169 Int_t nrows = fOuterSec->GetNRows();
1170 for (Int_t sec = 0;sec<fkNOS;sec++)
1171 for (Int_t row = 0;row<nrows;row++){
1172 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1174 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1175 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1177 tpcrow->ResetClusters();
1180 nrows = fInnerSec->GetNRows();
1181 for (Int_t sec = 0;sec<fkNIS;sec++)
1182 for (Int_t row = 0;row<nrows;row++){
1183 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1185 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1186 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1188 tpcrow->ResetClusters();
1194 void AliTPCtrackerMI::Transform(AliCluster * cluster){
1198 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1199 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1200 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1202 mat->LocalToMaster(pos,posC);
1203 cluster->SetX(posC[0]);
1204 cluster->SetY(posC[1]);
1205 cluster->SetZ(posC[2]);
1208 //_____________________________________________________________________________
1209 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1210 //-----------------------------------------------------------------
1211 // This function fills outer TPC sectors with clusters.
1212 //-----------------------------------------------------------------
1213 Int_t nrows = fOuterSec->GetNRows();
1215 for (Int_t sec = 0;sec<fkNOS;sec++)
1216 for (Int_t row = 0;row<nrows;row++){
1217 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1218 Int_t sec2 = sec+2*fkNIS;
1220 Int_t ncl = tpcrow->fN1;
1222 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1223 index=(((sec2<<8)+row)<<16)+ncl;
1224 tpcrow->InsertCluster(c,index);
1229 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1230 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1231 tpcrow->InsertCluster(c,index);
1234 // write indexes for fast acces
1236 for (Int_t i=0;i<510;i++)
1237 tpcrow->fFastCluster[i]=-1;
1238 for (Int_t i=0;i<tpcrow->GetN();i++){
1239 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1240 tpcrow->fFastCluster[zi]=i; // write index
1243 for (Int_t i=0;i<510;i++){
1244 if (tpcrow->fFastCluster[i]<0)
1245 tpcrow->fFastCluster[i] = last;
1247 last = tpcrow->fFastCluster[i];
1256 //_____________________________________________________________________________
1257 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1258 //-----------------------------------------------------------------
1259 // This function fills inner TPC sectors with clusters.
1260 //-----------------------------------------------------------------
1261 Int_t nrows = fInnerSec->GetNRows();
1263 for (Int_t sec = 0;sec<fkNIS;sec++)
1264 for (Int_t row = 0;row<nrows;row++){
1265 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1268 Int_t ncl = tpcrow->fN1;
1270 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1271 index=(((sec<<8)+row)<<16)+ncl;
1272 tpcrow->InsertCluster(c,index);
1277 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1278 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1279 tpcrow->InsertCluster(c,index);
1282 // write indexes for fast acces
1284 for (Int_t i=0;i<510;i++)
1285 tpcrow->fFastCluster[i]=-1;
1286 for (Int_t i=0;i<tpcrow->GetN();i++){
1287 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1288 tpcrow->fFastCluster[zi]=i; // write index
1291 for (Int_t i=0;i<510;i++){
1292 if (tpcrow->fFastCluster[i]<0)
1293 tpcrow->fFastCluster[i] = last;
1295 last = tpcrow->fFastCluster[i];
1307 //_________________________________________________________________________
1308 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1309 //--------------------------------------------------------------------
1310 // Return pointer to a given cluster
1311 //--------------------------------------------------------------------
1312 Int_t sec=(index&0xff000000)>>24;
1313 Int_t row=(index&0x00ff0000)>>16;
1314 Int_t ncl=(index&0x00007fff)>>00;
1316 const AliTPCRow * tpcrow=0;
1317 AliTPCclusterMI * clrow =0;
1320 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1321 if (tpcrow==0) return 0;
1324 if (tpcrow->fN1<=ncl) return 0;
1325 clrow = tpcrow->fClusters1;
1328 if (tpcrow->fN2<=ncl) return 0;
1329 clrow = tpcrow->fClusters2;
1333 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1334 if (tpcrow==0) return 0;
1336 if (sec-2*fkNIS<fkNOS) {
1337 if (tpcrow->fN1<=ncl) return 0;
1338 clrow = tpcrow->fClusters1;
1341 if (tpcrow->fN2<=ncl) return 0;
1342 clrow = tpcrow->fClusters2;
1346 return &(clrow[ncl]);
1352 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1353 //-----------------------------------------------------------------
1354 // This function tries to find a track prolongation to next pad row
1355 //-----------------------------------------------------------------
1357 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1358 AliTPCclusterMI *cl=0;
1359 Int_t tpcindex= t.GetClusterIndex2(nr);
1361 // update current shape info every 5 pad-row
1362 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1366 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1368 if (tpcindex==-1) return 0; //track in dead zone
1370 cl = t.fClusterPointer[nr];
1371 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1372 t.fCurrentClusterIndex1 = tpcindex;
1375 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1376 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1378 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1379 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1381 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1382 Double_t rotation = angle-t.GetAlpha();
1383 t.fRelativeSector= relativesector;
1384 if (!t.Rotate(rotation)) return 0;
1386 if (!t.PropagateTo(x)) return 0;
1388 t.fCurrentCluster = cl;
1390 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1391 if ((tpcindex&0x8000)==0) accept =0;
1393 //if founded cluster is acceptible
1394 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1401 UpdateTrack(&t,accept);
1406 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1408 // not look for new cluster during refitting
1414 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1415 Double_t y=t.GetYat(x);
1416 if (TMath::Abs(y)>ymax){
1418 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1419 if (!t.Rotate(fSectors->GetAlpha()))
1421 } else if (y <-ymax) {
1422 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1423 if (!t.Rotate(-fSectors->GetAlpha()))
1429 if (!t.PropagateTo(x)) {
1430 if (fIteration==0) t.fRemoval = 10;
1434 Double_t z=t.GetZ();
1436 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1437 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1439 Double_t roadz = 1.;
1441 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1443 t.SetClusterIndex2(nr,-1);
1448 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1455 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1456 cl = krow.FindNearest2(y,z,roady,roadz,index);
1457 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1460 t.fCurrentCluster = cl;
1462 if (fIteration==2&&cl->IsUsed(10)) return 0;
1463 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1464 if (fIteration==2&&cl->IsUsed(11)) {
1471 if (t.fCurrentCluster->IsUsed(10)){
1476 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1482 if (accept<3) UpdateTrack(&t,accept);
1485 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1491 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1492 //-----------------------------------------------------------------
1493 // This function tries to find a track prolongation to next pad row
1494 //-----------------------------------------------------------------
1496 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1498 if (!t.GetProlongation(x,y,z)) {
1504 if (TMath::Abs(y)>ymax){
1507 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1508 if (!t.Rotate(fSectors->GetAlpha()))
1510 } else if (y <-ymax) {
1511 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1512 if (!t.Rotate(-fSectors->GetAlpha()))
1515 if (!t.PropagateTo(x)) {
1518 t.GetProlongation(x,y,z);
1521 // update current shape info every 3 pad-row
1522 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1523 // t.fCurrentSigmaY = GetSigmaY(&t);
1524 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1528 AliTPCclusterMI *cl=0;
1533 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1534 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1536 Double_t roadz = 1.;
1539 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1541 t.SetClusterIndex2(row,-1);
1546 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1550 if ((cl==0)&&(krow)) {
1551 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1552 cl = krow.FindNearest2(y,z,roady,roadz,index);
1554 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1558 t.fCurrentCluster = cl;
1559 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1561 t.SetClusterIndex2(row,index);
1562 t.fClusterPointer[row] = cl;
1570 //_________________________________________________________________________
1571 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1573 // Get track space point by index
1574 // return false in case the cluster doesn't exist
1575 AliTPCclusterMI *cl = GetClusterMI(index);
1576 if (!cl) return kFALSE;
1577 Int_t sector = (index&0xff000000)>>24;
1578 // Int_t row = (index&0x00ff0000)>>16;
1580 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1581 xyz[0] = cl->GetX();
1582 xyz[1] = cl->GetY();
1583 xyz[2] = cl->GetZ();
1585 fParam->AdjustCosSin(sector,cos,sin);
1586 Float_t x = cos*xyz[0]-sin*xyz[1];
1587 Float_t y = cos*xyz[1]+sin*xyz[0];
1589 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1590 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1591 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1592 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1593 cov[0] = sin*sin*sigmaY2;
1594 cov[1] = -sin*cos*sigmaY2;
1596 cov[3] = cos*cos*sigmaY2;
1599 p.SetXYZ(x,y,xyz[2],cov);
1600 AliAlignObj::ELayerID iLayer;
1602 if (sector < fParam->GetNInnerSector()) {
1603 iLayer = AliAlignObj::kTPC1;
1607 iLayer = AliAlignObj::kTPC2;
1608 idet = sector - fParam->GetNInnerSector();
1610 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1611 p.SetVolumeID(volid);
1617 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1618 //-----------------------------------------------------------------
1619 // This function tries to find a track prolongation to next pad row
1620 //-----------------------------------------------------------------
1621 t.fCurrentCluster = 0;
1622 t.fCurrentClusterIndex1 = 0;
1624 Double_t xt=t.GetX();
1625 Int_t row = GetRowNumber(xt)-1;
1626 Double_t ymax= GetMaxY(nr);
1628 if (row < nr) return 1; // don't prolongate if not information until now -
1629 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1631 // return 0; // not prolongate strongly inclined tracks
1633 // if (TMath::Abs(t.GetSnp())>0.95) {
1635 // return 0; // not prolongate strongly inclined tracks
1636 // }// patch 28 fev 06
1638 Double_t x= GetXrow(nr);
1640 //t.PropagateTo(x+0.02);
1641 //t.PropagateTo(x+0.01);
1642 if (!t.PropagateTo(x)){
1649 if (TMath::Abs(y)>ymax){
1651 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1652 if (!t.Rotate(fSectors->GetAlpha()))
1654 } else if (y <-ymax) {
1655 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1656 if (!t.Rotate(-fSectors->GetAlpha()))
1659 // if (!t.PropagateTo(x)){
1666 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1667 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1669 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1671 t.SetClusterIndex2(nr,-1);
1676 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.fNFoundable++;
1682 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1683 // t.fCurrentSigmaY = GetSigmaY(&t);
1684 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1688 AliTPCclusterMI *cl=0;
1691 Double_t roady = 1.;
1692 Double_t roadz = 1.;
1696 index = t.GetClusterIndex2(nr);
1697 if ( (index>0) && (index&0x8000)==0){
1698 cl = t.fClusterPointer[nr];
1699 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1700 t.fCurrentClusterIndex1 = index;
1702 t.fCurrentCluster = cl;
1708 // if (index<0) return 0;
1709 UInt_t uindex = TMath::Abs(index);
1712 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1713 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1716 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
1717 t.fCurrentCluster = cl;
1723 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1724 //-----------------------------------------------------------------
1725 // This function tries to find a track prolongation to next pad row
1726 //-----------------------------------------------------------------
1728 //update error according neighborhoud
1730 if (t.fCurrentCluster) {
1732 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1734 if (t.fCurrentCluster->IsUsed(10)){
1740 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1745 if (fIteration>0) accept = 0;
1746 if (accept<3) UpdateTrack(&t,accept);
1750 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1751 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1753 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1761 //_____________________________________________________________________________
1762 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1763 //-----------------------------------------------------------------
1764 // This function tries to find a track prolongation.
1765 //-----------------------------------------------------------------
1766 Double_t xt=t.GetX();
1768 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1769 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1770 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1772 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1774 Int_t first = GetRowNumber(xt)-1;
1775 for (Int_t nr= first; nr>=rf; nr-=step) {
1777 if (t.GetKinkIndexes()[0]>0){
1778 for (Int_t i=0;i<3;i++){
1779 Int_t index = t.GetKinkIndexes()[i];
1780 if (index==0) break;
1781 if (index<0) continue;
1783 AliESDkink * kink = fEvent->GetKink(index-1);
1785 printf("PROBLEM\n");
1788 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1790 AliExternalTrackParam paramd(t);
1791 kink->SetDaughter(paramd);
1792 kink->SetStatus(2,5);
1799 if (nr==80) t.UpdateReference();
1800 if (nr<fInnerSec->GetNRows())
1801 fSectors = fInnerSec;
1803 fSectors = fOuterSec;
1804 if (FollowToNext(t,nr)==0)
1813 //_____________________________________________________________________________
1814 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1815 //-----------------------------------------------------------------
1816 // This function tries to find a track prolongation.
1817 //-----------------------------------------------------------------
1818 Double_t xt=t.GetX();
1820 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1821 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1822 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1823 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1825 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1827 if (FollowToNextFast(t,nr)==0)
1828 if (!t.IsActive()) return 0;
1838 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1839 //-----------------------------------------------------------------
1840 // This function tries to find a track prolongation.
1841 //-----------------------------------------------------------------
1843 Double_t xt=t.GetX();
1844 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1845 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1846 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1847 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1849 Int_t first = t.fFirstPoint;
1850 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1852 if (first<0) first=0;
1853 for (Int_t nr=first; nr<=rf; nr++) {
1854 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1855 if (t.GetKinkIndexes()[0]<0){
1856 for (Int_t i=0;i<3;i++){
1857 Int_t index = t.GetKinkIndexes()[i];
1858 if (index==0) break;
1859 if (index>0) continue;
1860 index = TMath::Abs(index);
1861 AliESDkink * kink = fEvent->GetKink(index-1);
1863 printf("PROBLEM\n");
1866 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1868 AliExternalTrackParam paramm(t);
1869 kink->SetMother(paramm);
1870 kink->SetStatus(2,1);
1877 if (nr<fInnerSec->GetNRows())
1878 fSectors = fInnerSec;
1880 fSectors = fOuterSec;
1890 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1898 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1901 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1903 Float_t distance = TMath::Sqrt(dz2+dy2);
1904 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1907 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1908 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1913 if (firstpoint>lastpoint) {
1914 firstpoint =lastpoint;
1919 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1920 if (s1->GetClusterIndex2(i)>0) sum1++;
1921 if (s2->GetClusterIndex2(i)>0) sum2++;
1922 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1926 if (sum<5) return 0;
1928 Float_t summin = TMath::Min(sum1+1,sum2+1);
1929 Float_t ratio = (sum+1)/Float_t(summin);
1933 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1937 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1938 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1940 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1942 Float_t dy2 =(s1->GetY() - s2->GetY());
1944 Float_t distance = dz2+dy2;
1945 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1950 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1951 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1953 if (firstpoint>=lastpoint-5) return;;
1955 for (Int_t i=firstpoint;i<lastpoint;i++){
1956 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1957 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1964 for (Int_t i=firstpoint;i<lastpoint;i++){
1965 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1966 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1967 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1968 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1969 if (s1->IsActive()&&s2->IsActive()){
1970 p1->fIsShared = kTRUE;
1971 p2->fIsShared = kTRUE;
1978 for (Int_t i=0;i<4;i++){
1979 if (s1->fOverlapLabels[3*i]==0){
1980 s1->fOverlapLabels[3*i] = s2->GetLabel();
1981 s1->fOverlapLabels[3*i+1] = sumshared;
1982 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1986 for (Int_t i=0;i<4;i++){
1987 if (s2->fOverlapLabels[3*i]==0){
1988 s2->fOverlapLabels[3*i] = s1->GetLabel();
1989 s2->fOverlapLabels[3*i+1] = sumshared;
1990 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1998 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2001 //sort trackss according sectors
2003 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2004 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2006 //if (pt) RotateToLocal(pt);
2010 arr->Sort(); // sorting according z
2011 arr->Expand(arr->GetEntries());
2014 Int_t nseed=arr->GetEntriesFast();
2015 for (Int_t i=0; i<nseed; i++) {
2016 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2018 for (Int_t j=0;j<=12;j++){
2019 pt->fOverlapLabels[j] =0;
2022 for (Int_t i=0; i<nseed; i++) {
2023 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2025 if (pt->fRemoval>10) continue;
2026 for (Int_t j=i+1; j<nseed; j++){
2027 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2029 if (pt2->fRemoval<=10) {
2030 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2037 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2040 //sort trackss according sectors
2043 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2046 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2047 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2052 arr->Sort(); // sorting according z
2053 arr->Expand(arr->GetEntries());
2055 //reset overlap labels
2057 Int_t nseed=arr->GetEntriesFast();
2058 for (Int_t i=0; i<nseed; i++) {
2059 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2062 for (Int_t j=0;j<=12;j++){
2063 pt->fOverlapLabels[j] =0;
2067 //sign shared tracks
2068 for (Int_t i=0; i<nseed; i++) {
2069 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2071 if (pt->fRemoval>10) continue;
2072 Float_t deltac = pt->GetC()*0.1;
2073 for (Int_t j=i+1; j<nseed; j++){
2074 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2076 if (pt2->fRemoval<=10) {
2077 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2078 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2079 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2086 // remove highly shared tracks
2087 for (Int_t i=0; i<nseed; i++) {
2088 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2090 if (pt->fRemoval>10) continue;
2093 for (Int_t j=0;j<4;j++){
2094 sumshared = pt->fOverlapLabels[j*3+1];
2096 Float_t factor = factor1;
2097 if (pt->fRemoval>0) factor = factor2;
2098 if (sumshared/pt->GetNumberOfClusters()>factor){
2099 for (Int_t j=0;j<4;j++){
2100 if (pt->fOverlapLabels[3*j]==0) continue;
2101 if (pt->fOverlapLabels[3*j+1]<5) continue;
2102 if (pt->fRemoval==removalindex) continue;
2103 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2105 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2106 // pt->fRemoval = removalindex;
2107 delete arr->RemoveAt(i);
2115 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2124 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2127 //sort tracks in array according mode criteria
2128 Int_t nseed = arr->GetEntriesFast();
2129 for (Int_t i=0; i<nseed; i++) {
2130 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2140 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2143 //Loop over all tracks and remove "overlaps"
2146 Int_t nseed = arr->GetEntriesFast();
2149 for (Int_t i=0; i<nseed; i++) {
2150 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2152 delete arr->RemoveAt(i);
2156 pt->fBSigned = kFALSE;
2160 nseed = arr->GetEntriesFast();
2167 for (Int_t i=0; i<nseed; i++) {
2168 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2172 Int_t found,foundable,shared;
2174 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2176 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2178 Double_t factor = factor2;
2179 if (pt->fBConstrain) factor = factor1;
2181 if ((Float_t(shared)/Float_t(found))>factor){
2182 pt->Desactivate(removalindex);
2187 for (Int_t i=0; i<160; i++) {
2188 Int_t index=pt->GetClusterIndex2(i);
2189 if (index<0 || index&0x8000 ) continue;
2190 AliTPCclusterMI *c= pt->fClusterPointer[i];
2192 // if (!c->IsUsed(10)) c->Use(10);
2193 //if (pt->IsActive())
2202 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2207 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2210 //Loop over all tracks and remove "overlaps"
2215 Int_t nseed = arr->GetEntriesFast();
2216 Float_t * quality = new Float_t[nseed];
2217 Int_t * indexes = new Int_t[nseed];
2221 for (Int_t i=0; i<nseed; i++) {
2222 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2227 pt->UpdatePoints(); //select first last max dens points
2228 Float_t * points = pt->GetPoints();
2229 if (points[3]<0.8) quality[i] =-1;
2231 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2233 TMath::Sort(nseed,quality,indexes);
2236 for (Int_t itrack=0; itrack<nseed; itrack++) {
2237 Int_t trackindex = indexes[itrack];
2238 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2239 if (quality[trackindex]<0){
2241 delete arr->RemoveAt(trackindex);
2244 arr->RemoveAt(trackindex);
2249 Int_t first = Int_t(pt->GetPoints()[0]);
2250 Int_t last = Int_t(pt->GetPoints()[2]);
2251 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2253 Int_t found,foundable,shared;
2254 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2255 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2256 Bool_t itsgold =kFALSE;
2259 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
2263 if (Float_t(shared+1)/Float_t(found+1)>factor){
2264 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2265 delete arr->RemoveAt(trackindex);
2268 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2269 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2270 delete arr->RemoveAt(trackindex);
2276 if (sharedfactor>0.4) continue;
2277 if (pt->GetKinkIndexes()[0]>0) continue;
2278 for (Int_t i=first; i<last; i++) {
2279 Int_t index=pt->GetClusterIndex2(i);
2280 // if (index<0 || index&0x8000 ) continue;
2281 if (index<0 || index&0x8000 ) continue;
2282 AliTPCclusterMI *c= pt->fClusterPointer[i];
2289 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2295 void AliTPCtrackerMI::UnsignClusters()
2298 // loop over all clusters and unsign them
2301 for (Int_t sec=0;sec<fkNIS;sec++){
2302 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2303 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2304 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2305 // if (cl[icl].IsUsed(10))
2307 cl = fInnerSec[sec][row].fClusters2;
2308 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2309 //if (cl[icl].IsUsed(10))
2314 for (Int_t sec=0;sec<fkNOS;sec++){
2315 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2316 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2317 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2318 //if (cl[icl].IsUsed(10))
2320 cl = fOuterSec[sec][row].fClusters2;
2321 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2322 //if (cl[icl].IsUsed(10))
2331 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2334 //sign clusters to be "used"
2336 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2337 // loop over "primaries"
2351 Int_t nseed = arr->GetEntriesFast();
2352 for (Int_t i=0; i<nseed; i++) {
2353 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2357 if (!(pt->IsActive())) continue;
2358 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2359 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2361 sumdens2+= dens*dens;
2362 sumn += pt->GetNumberOfClusters();
2363 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2364 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2367 sumchi2 +=chi2*chi2;
2372 Float_t mdensity = 0.9;
2373 Float_t meann = 130;
2374 Float_t meanchi = 1;
2375 Float_t sdensity = 0.1;
2376 Float_t smeann = 10;
2377 Float_t smeanchi =0.4;
2381 mdensity = sumdens/sum;
2383 meanchi = sumchi/sum;
2385 sdensity = sumdens2/sum-mdensity*mdensity;
2386 sdensity = TMath::Sqrt(sdensity);
2388 smeann = sumn2/sum-meann*meann;
2389 smeann = TMath::Sqrt(smeann);
2391 smeanchi = sumchi2/sum - meanchi*meanchi;
2392 smeanchi = TMath::Sqrt(smeanchi);
2396 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2398 for (Int_t i=0; i<nseed; i++) {
2399 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2403 if (pt->fBSigned) continue;
2404 if (pt->fBConstrain) continue;
2405 //if (!(pt->IsActive())) continue;
2407 Int_t found,foundable,shared;
2408 pt->GetClusterStatistic(0,160,found, foundable,shared);
2409 if (shared/float(found)>0.3) {
2410 if (shared/float(found)>0.9 ){
2411 //delete arr->RemoveAt(i);
2416 Bool_t isok =kFALSE;
2417 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2419 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2421 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2423 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2427 for (Int_t i=0; i<160; i++) {
2428 Int_t index=pt->GetClusterIndex2(i);
2429 if (index<0) continue;
2430 AliTPCclusterMI *c= pt->fClusterPointer[i];
2432 //if (!(c->IsUsed(10))) c->Use();
2439 Double_t maxchi = meanchi+2.*smeanchi;
2441 for (Int_t i=0; i<nseed; i++) {
2442 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2446 //if (!(pt->IsActive())) continue;
2447 if (pt->fBSigned) continue;
2448 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2449 if (chi>maxchi) continue;
2452 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2454 //sign only tracks with enoug big density at the beginning
2456 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2459 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2460 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2462 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2463 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2466 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2467 //Int_t noc=pt->GetNumberOfClusters();
2468 pt->fBSigned = kTRUE;
2469 for (Int_t i=0; i<160; i++) {
2471 Int_t index=pt->GetClusterIndex2(i);
2472 if (index<0) continue;
2473 AliTPCclusterMI *c= pt->fClusterPointer[i];
2475 // if (!(c->IsUsed(10))) c->Use();
2480 // gLastCheck = nseed;
2488 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2490 // stop not active tracks
2491 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2492 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2493 Int_t nseed = arr->GetEntriesFast();
2495 for (Int_t i=0; i<nseed; i++) {
2496 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2500 if (!(pt->IsActive())) continue;
2501 StopNotActive(pt,row0,th0, th1,th2);
2507 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2510 // stop not active tracks
2511 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2512 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2515 Int_t foundable = 0;
2516 Int_t maxindex = seed->fLastPoint; //last foundable row
2517 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2518 seed->Desactivate(10) ;
2522 for (Int_t i=row0; i<maxindex; i++){
2523 Int_t index = seed->GetClusterIndex2(i);
2524 if (index!=-1) foundable++;
2526 if (foundable<=30) sumgood1++;
2527 if (foundable<=50) {
2534 if (foundable>=30.){
2535 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2538 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2542 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2545 // back propagation of ESD tracks
2551 //PrepareForProlongation(fSeeds,1);
2552 PropagateForward2(fSeeds);
2555 Int_t nseed = fSeeds->GetEntriesFast();
2556 for (Int_t i=0;i<nseed;i++){
2557 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2558 if (!seed) continue;
2559 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2561 seed->PropagateTo(fParam->GetInnerRadiusLow());
2562 seed->UpdatePoints();
2563 AliESDtrack *esd=event->GetTrack(i);
2564 seed->CookdEdx(0.02,0.6);
2565 CookLabel(seed,0.1); //For comparison only
2567 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2568 TTreeSRedirector &cstream = *fDebugStreamer;
2574 if (seed->GetNumberOfClusters()>15){
2575 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2576 esd->SetTPCPoints(seed->GetPoints());
2577 esd->SetTPCPointsF(seed->fNFoundable);
2578 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2579 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2580 Float_t dedx = seed->GetdEdx();
2581 esd->SetTPCsignal(dedx, sdedx, ndedx);
2585 //printf("problem\n");
2588 //FindKinks(fSeeds,event);
2589 Info("RefitInward","Number of refitted tracks %d",ntracks);
2596 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2599 // back propagation of ESD tracks
2605 PropagateBack(fSeeds);
2606 RemoveUsed2(fSeeds,0.4,0.4,20);
2608 Int_t nseed = fSeeds->GetEntriesFast();
2610 for (Int_t i=0;i<nseed;i++){
2611 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2612 if (!seed) continue;
2613 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2614 seed->UpdatePoints();
2615 AliESDtrack *esd=event->GetTrack(i);
2616 seed->CookdEdx(0.02,0.6);
2617 CookLabel(seed,0.1); //For comparison only
2618 if (seed->GetNumberOfClusters()>15){
2619 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2620 esd->SetTPCPoints(seed->GetPoints());
2621 esd->SetTPCPointsF(seed->fNFoundable);
2622 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2623 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2624 Float_t dedx = seed->GetdEdx();
2625 esd->SetTPCsignal(dedx, sdedx, ndedx);
2627 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2628 (*fDebugStreamer)<<"Cback"<<
2630 "EventNr="<<eventnumber<<
2631 "\n"; // patch 28 fev 06
2634 //FindKinks(fSeeds,event);
2635 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2642 void AliTPCtrackerMI::DeleteSeeds()
2646 Int_t nseed = fSeeds->GetEntriesFast();
2647 for (Int_t i=0;i<nseed;i++){
2648 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2649 if (seed) delete fSeeds->RemoveAt(i);
2655 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2658 //read seeds from the event
2660 Int_t nentr=event->GetNumberOfTracks();
2662 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2667 fSeeds = new TObjArray(nentr);
2671 for (Int_t i=0; i<nentr; i++) {
2672 AliESDtrack *esd=event->GetTrack(i);
2673 ULong_t status=esd->GetStatus();
2674 if (!(status&AliESDtrack::kTPCin)) continue;
2675 AliTPCtrack t(*esd);
2676 t.SetNumberOfClusters(0);
2677 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2678 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2679 for (Int_t ikink=0;ikink<3;ikink++) {
2680 Int_t index = esd->GetKinkIndex(ikink);
2681 seed->GetKinkIndexes()[ikink] = index;
2682 if (index==0) continue;
2683 index = TMath::Abs(index);
2684 AliESDkink * kink = fEvent->GetKink(index-1);
2685 if (kink&&esd->GetKinkIndex(ikink)<0){
2686 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2687 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2689 if (kink&&esd->GetKinkIndex(ikink)>0){
2690 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2691 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2695 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance();
2696 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2697 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2702 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2703 Double_t par0[5],par1[5],alpha,x;
2704 esd->GetInnerExternalParameters(alpha,x,par0);
2705 esd->GetExternalParameters(x,par1);
2706 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2707 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2709 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2710 //reset covariance if suspicious
2711 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2712 seed->ResetCovariance();
2717 // rotate to the local coordinate system
2719 fSectors=fInnerSec; fN=fkNIS;
2720 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2721 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2722 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2723 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2724 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2725 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2726 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2727 alpha-=seed->GetAlpha();
2728 if (!seed->Rotate(alpha)) {
2734 if (esd->GetKinkIndex(0)<=0){
2735 for (Int_t irow=0;irow<160;irow++){
2736 Int_t index = seed->GetClusterIndex2(irow);
2739 AliTPCclusterMI * cl = GetClusterMI(index);
2740 seed->fClusterPointer[irow] = cl;
2742 if ((index & 0x8000)==0){
2743 cl->Use(10); // accepted cluster
2745 cl->Use(6); // close cluster not accepted
2748 Info("ReadSeeds","Not found cluster");
2753 fSeeds->AddAt(seed,i);
2759 //_____________________________________________________________________________
2760 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2761 Float_t deltay, Int_t ddsec) {
2762 //-----------------------------------------------------------------
2763 // This function creates track seeds.
2764 // SEEDING WITH VERTEX CONSTRAIN
2765 //-----------------------------------------------------------------
2766 // cuts[0] - fP4 cut
2767 // cuts[1] - tan(phi) cut
2768 // cuts[2] - zvertex cut
2769 // cuts[3] - fP3 cut
2777 Double_t x[5], c[15];
2778 // Int_t di = i1-i2;
2780 AliTPCseed * seed = new AliTPCseed;
2781 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2782 Double_t cs=cos(alpha), sn=sin(alpha);
2784 // Double_t x1 =fOuterSec->GetX(i1);
2785 //Double_t xx2=fOuterSec->GetX(i2);
2787 Double_t x1 =GetXrow(i1);
2788 Double_t xx2=GetXrow(i2);
2790 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2792 Int_t imiddle = (i2+i1)/2; //middle pad row index
2793 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2794 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2798 const AliTPCRow& kr1=GetRow(ns,i1);
2799 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2800 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2803 // change cut on curvature if it can't reach this layer
2804 // maximal curvature set to reach it
2805 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2806 if (dvertexmax*0.5*cuts[0]>0.85){
2807 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2809 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2812 if (deltay>0) ddsec = 0;
2813 // loop over clusters
2814 for (Int_t is=0; is < kr1; is++) {
2816 if (kr1[is]->IsUsed(10)) continue;
2817 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2818 //if (TMath::Abs(y1)>ymax) continue;
2820 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2822 // find possible directions
2823 Float_t anglez = (z1-z3)/(x1-x3);
2824 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2827 //find rotation angles relative to line given by vertex and point 1
2828 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2829 Double_t dvertex = TMath::Sqrt(dvertex2);
2830 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2831 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2834 // loop over 2 sectors
2840 Double_t dddz1=0; // direction of delta inclination in z axis
2847 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2848 Int_t sec2 = sec + dsec;
2850 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2851 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2852 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2853 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2854 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2855 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2857 // rotation angles to p1-p3
2858 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2859 Double_t x2, y2, z2;
2861 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2864 Double_t dxx0 = (xx2-x3)*cs13r;
2865 Double_t dyy0 = (xx2-x3)*sn13r;
2866 for (Int_t js=index1; js < index2; js++) {
2867 const AliTPCclusterMI *kcl = kr2[js];
2868 if (kcl->IsUsed(10)) continue;
2870 //calcutate parameters
2872 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2874 if (TMath::Abs(yy0)<0.000001) continue;
2875 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2876 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2877 Double_t r02 = (0.25+y0*y0)*dvertex2;
2878 //curvature (radius) cut
2879 if (r02<r2min) continue;
2883 Double_t c0 = 1/TMath::Sqrt(r02);
2887 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2888 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2889 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2890 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2893 Double_t z0 = kcl->GetZ();
2894 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2895 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2898 Double_t dip = (z1-z0)*c0/dfi1;
2899 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2910 x2= xx2*cs-y2*sn*dsec;
2911 y2=+xx2*sn*dsec+y2*cs;
2921 // do we have cluster at the middle ?
2923 GetProlongation(x1,xm,x,ym,zm);
2925 AliTPCclusterMI * cm=0;
2926 if (TMath::Abs(ym)-ymaxm<0){
2927 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2928 if ((!cm) || (cm->IsUsed(10))) {
2933 // rotate y1 to system 0
2934 // get state vector in rotated system
2935 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2936 Double_t xr2 = x0*cs+yr1*sn*dsec;
2937 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2939 GetProlongation(xx2,xm,xr,ym,zm);
2940 if (TMath::Abs(ym)-ymaxm<0){
2941 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2942 if ((!cm) || (cm->IsUsed(10))) {
2952 dym = ym - cm->GetY();
2953 dzm = zm - cm->GetZ();
2960 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2961 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2962 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2963 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2964 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2966 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2967 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2968 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2969 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2970 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2971 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2973 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2974 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2975 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2976 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2980 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2981 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2982 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2983 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2984 c[13]=f30*sy1*f40+f32*sy2*f42;
2985 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2987 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2989 UInt_t index=kr1.GetIndex(is);
2990 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2992 track->fIsSeeding = kTRUE;
2999 FollowProlongation(*track, (i1+i2)/2,1);
3000 Int_t foundable,found,shared;
3001 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3002 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3004 seed->~AliTPCseed();
3010 FollowProlongation(*track, i2,1);
3014 track->fBConstrain =1;
3015 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3016 track->fLastPoint = i1; // first cluster in track position
3017 track->fFirstPoint = track->fLastPoint;
3019 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3020 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3021 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3023 seed->~AliTPCseed();
3027 // Z VERTEX CONDITION
3029 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3030 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3031 if (TMath::Abs(zv-z3)>cuts[2]) {
3032 FollowProlongation(*track, TMath::Max(i2-20,0));
3033 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3034 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3035 if (TMath::Abs(zv-z3)>cuts[2]){
3036 FollowProlongation(*track, TMath::Max(i2-40,0));
3037 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3038 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3039 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3040 // make seed without constrain
3041 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3042 FollowProlongation(*track2, i2,1);
3043 track2->fBConstrain = kFALSE;
3044 track2->fSeedType = 1;
3045 arr->AddLast(track2);
3047 seed->~AliTPCseed();
3052 seed->~AliTPCseed();
3059 track->fSeedType =0;
3060 arr->AddLast(track);
3061 seed = new AliTPCseed;
3063 // don't consider other combinations
3064 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3070 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3076 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3081 //-----------------------------------------------------------------
3082 // This function creates track seeds.
3083 //-----------------------------------------------------------------
3084 // cuts[0] - fP4 cut
3085 // cuts[1] - tan(phi) cut
3086 // cuts[2] - zvertex cut
3087 // cuts[3] - fP3 cut
3097 Double_t x[5], c[15];
3099 // make temporary seed
3100 AliTPCseed * seed = new AliTPCseed;
3101 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3102 // Double_t cs=cos(alpha), sn=sin(alpha);
3107 Double_t x1 = GetXrow(i1-1);
3108 const AliTPCRow& kr1=GetRow(sec,i1-1);
3109 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3111 Double_t x1p = GetXrow(i1);
3112 const AliTPCRow& kr1p=GetRow(sec,i1);
3114 Double_t x1m = GetXrow(i1-2);
3115 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3118 //last 3 padrow for seeding
3119 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3120 Double_t x3 = GetXrow(i1-7);
3121 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3123 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3124 Double_t x3p = GetXrow(i1-6);
3126 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3127 Double_t x3m = GetXrow(i1-8);
3132 Int_t im = i1-4; //middle pad row index
3133 Double_t xm = GetXrow(im); // radius of middle pad-row
3134 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3135 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3138 Double_t deltax = x1-x3;
3139 Double_t dymax = deltax*cuts[1];
3140 Double_t dzmax = deltax*cuts[3];
3142 // loop over clusters
3143 for (Int_t is=0; is < kr1; is++) {
3145 if (kr1[is]->IsUsed(10)) continue;
3146 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3148 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3150 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3151 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3157 for (Int_t js=index1; js < index2; js++) {
3158 const AliTPCclusterMI *kcl = kr3[js];
3159 if (kcl->IsUsed(10)) continue;
3161 // apply angular cuts
3162 if (TMath::Abs(y1-y3)>dymax) continue;
3165 if (TMath::Abs(z1-z3)>dzmax) continue;
3167 Double_t angley = (y1-y3)/(x1-x3);
3168 Double_t anglez = (z1-z3)/(x1-x3);
3170 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3171 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3173 Double_t yyym = angley*(xm-x1)+y1;
3174 Double_t zzzm = anglez*(xm-x1)+z1;
3176 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3178 if (kcm->IsUsed(10)) continue;
3180 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3181 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3188 // look around first
3189 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3195 if (kc1m->IsUsed(10)) used++;
3197 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3203 if (kc1p->IsUsed(10)) used++;
3205 if (used>1) continue;
3206 if (found<1) continue;
3210 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3216 if (kc3m->IsUsed(10)) used++;
3220 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3226 if (kc3p->IsUsed(10)) used++;
3230 if (used>1) continue;
3231 if (found<3) continue;
3241 x[4]=F1(x1,y1,x2,y2,x3,y3);
3242 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3245 x[2]=F2(x1,y1,x2,y2,x3,y3);
3248 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3249 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3253 Double_t sy1=0.1, sz1=0.1;
3254 Double_t sy2=0.1, sz2=0.1;
3255 Double_t sy3=0.1, sy=0.1, sz=0.1;
3257 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3258 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3259 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3260 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3261 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3262 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3264 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3265 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3266 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3267 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3271 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3272 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3273 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3274 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3275 c[13]=f30*sy1*f40+f32*sy2*f42;
3276 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3278 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3280 UInt_t index=kr1.GetIndex(is);
3281 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3283 track->fIsSeeding = kTRUE;
3286 FollowProlongation(*track, i1-7,1);
3287 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3288 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3290 seed->~AliTPCseed();
3296 FollowProlongation(*track, i2,1);
3297 track->fBConstrain =0;
3298 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3299 track->fFirstPoint = track->fLastPoint;
3301 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3302 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3303 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3305 seed->~AliTPCseed();
3310 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3311 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3312 FollowProlongation(*track2, i2,1);
3313 track2->fBConstrain = kFALSE;
3314 track2->fSeedType = 4;
3315 arr->AddLast(track2);
3317 seed->~AliTPCseed();
3321 //arr->AddLast(track);
3322 //seed = new AliTPCseed;
3328 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3334 //_____________________________________________________________________________
3335 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3336 Float_t deltay, Bool_t /*bconstrain*/) {
3337 //-----------------------------------------------------------------
3338 // This function creates track seeds - without vertex constraint
3339 //-----------------------------------------------------------------
3340 // cuts[0] - fP4 cut - not applied
3341 // cuts[1] - tan(phi) cut
3342 // cuts[2] - zvertex cut - not applied
3343 // cuts[3] - fP3 cut
3353 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3354 // Double_t cs=cos(alpha), sn=sin(alpha);
3355 Int_t row0 = (i1+i2)/2;
3356 Int_t drow = (i1-i2)/2;
3357 const AliTPCRow& kr0=fSectors[sec][row0];
3360 AliTPCpolyTrack polytrack;
3361 Int_t nclusters=fSectors[sec][row0];
3362 AliTPCseed * seed = new AliTPCseed;
3367 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3369 Int_t nfoundable =0;
3370 for (Int_t iter =1; iter<2; iter++){ //iterations
3371 const AliTPCRow& krm=fSectors[sec][row0-iter];
3372 const AliTPCRow& krp=fSectors[sec][row0+iter];
3373 const AliTPCclusterMI * cl= kr0[is];
3375 if (cl->IsUsed(10)) {
3381 Double_t x = kr0.GetX();
3382 // Initialization of the polytrack
3387 Double_t y0= cl->GetY();
3388 Double_t z0= cl->GetZ();
3392 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3393 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3395 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3396 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3397 polytrack.AddPoint(x,y0,z0,erry, errz);
3400 if (cl->IsUsed(10)) sumused++;
3403 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3404 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3407 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3408 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3409 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3410 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3411 if (cl1->IsUsed(10)) sumused++;
3412 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3416 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3418 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3419 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3420 if (cl2->IsUsed(10)) sumused++;
3421 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3424 if (sumused>0) continue;
3426 polytrack.UpdateParameters();
3432 nfoundable = polytrack.GetN();
3433 nfound = nfoundable;
3435 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3436 Float_t maxdist = 0.8*(1.+3./(ddrow));
3437 for (Int_t delta = -1;delta<=1;delta+=2){
3438 Int_t row = row0+ddrow*delta;
3439 kr = &(fSectors[sec][row]);
3440 Double_t xn = kr->GetX();
3441 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3442 polytrack.GetFitPoint(xn,yn,zn);
3443 if (TMath::Abs(yn)>ymax) continue;
3445 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3447 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3450 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3451 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3452 if (cln->IsUsed(10)) {
3453 // printf("used\n");
3461 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3466 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3467 polytrack.UpdateParameters();
3470 if ( (sumused>3) || (sumused>0.5*nfound)) {
3471 //printf("sumused %d\n",sumused);
3476 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3477 AliTPCpolyTrack track2;
3479 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3480 if (track2.GetN()<0.5*nfoundable) continue;
3483 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3485 // test seed with and without constrain
3486 for (Int_t constrain=0; constrain<=0;constrain++){
3487 // add polytrack candidate
3489 Double_t x[5], c[15];
3490 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3491 track2.GetBoundaries(x3,x1);
3493 track2.GetFitPoint(x1,y1,z1);
3494 track2.GetFitPoint(x2,y2,z2);
3495 track2.GetFitPoint(x3,y3,z3);
3497 //is track pointing to the vertex ?
3500 polytrack.GetFitPoint(x0,y0,z0);
3513 x[4]=F1(x1,y1,x2,y2,x3,y3);
3515 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3516 x[2]=F2(x1,y1,x2,y2,x3,y3);
3518 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3519 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3520 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3521 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3524 Double_t sy =0.1, sz =0.1;
3525 Double_t sy1=0.02, sz1=0.02;
3526 Double_t sy2=0.02, sz2=0.02;
3530 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3533 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3534 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3535 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3536 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3537 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3538 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3540 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3541 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3542 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3543 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3548 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3549 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3550 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3551 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3552 c[13]=f30*sy1*f40+f32*sy2*f42;
3553 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3555 //Int_t row1 = fSectors->GetRowNumber(x1);
3556 Int_t row1 = GetRowNumber(x1);
3560 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3561 track->fIsSeeding = kTRUE;
3562 Int_t rc=FollowProlongation(*track, i2);
3563 if (constrain) track->fBConstrain =1;
3565 track->fBConstrain =0;
3566 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3567 track->fFirstPoint = track->fLastPoint;
3569 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3570 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3571 track->fNShared>0.4*track->GetNumberOfClusters()) {
3574 seed->~AliTPCseed();
3577 arr->AddLast(track);
3578 seed = new AliTPCseed;
3582 } // if accepted seed
3585 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3591 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3595 //reseed using track points
3596 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3597 Int_t p1 = int(r1*track->GetNumberOfClusters());
3598 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3600 Double_t x0[3],x1[3],x2[3];
3601 for (Int_t i=0;i<3;i++){
3607 // find track position at given ratio of the length
3608 Int_t sec0=0, sec1=0, sec2=0;
3611 for (Int_t i=0;i<160;i++){
3612 if (track->fClusterPointer[i]){
3614 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3615 if ( (index<p0) || x0[0]<0 ){
3616 if (trpoint->GetX()>1){
3617 clindex = track->GetClusterIndex2(i);
3619 x0[0] = trpoint->GetX();
3620 x0[1] = trpoint->GetY();
3621 x0[2] = trpoint->GetZ();
3622 sec0 = ((clindex&0xff000000)>>24)%18;
3627 if ( (index<p1) &&(trpoint->GetX()>1)){
3628 clindex = track->GetClusterIndex2(i);
3630 x1[0] = trpoint->GetX();
3631 x1[1] = trpoint->GetY();
3632 x1[2] = trpoint->GetZ();
3633 sec1 = ((clindex&0xff000000)>>24)%18;
3636 if ( (index<p2) &&(trpoint->GetX()>1)){
3637 clindex = track->GetClusterIndex2(i);
3639 x2[0] = trpoint->GetX();
3640 x2[1] = trpoint->GetY();
3641 x2[2] = trpoint->GetZ();
3642 sec2 = ((clindex&0xff000000)>>24)%18;
3649 Double_t alpha, cs,sn, xx2,yy2;
3651 alpha = (sec1-sec2)*fSectors->GetAlpha();
3652 cs = TMath::Cos(alpha);
3653 sn = TMath::Sin(alpha);
3654 xx2= x1[0]*cs-x1[1]*sn;
3655 yy2= x1[0]*sn+x1[1]*cs;
3659 alpha = (sec0-sec2)*fSectors->GetAlpha();
3660 cs = TMath::Cos(alpha);
3661 sn = TMath::Sin(alpha);
3662 xx2= x0[0]*cs-x0[1]*sn;
3663 yy2= x0[0]*sn+x0[1]*cs;
3669 Double_t x[5],c[15];
3673 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3674 // if (x[4]>1) return 0;
3675 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3676 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3677 //if (TMath::Abs(x[3]) > 2.2) return 0;
3678 //if (TMath::Abs(x[2]) > 1.99) return 0;
3680 Double_t sy =0.1, sz =0.1;
3682 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3683 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3684 Double_t sy3=0.01+track->GetSigmaY2();
3686 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3687 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3688 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3689 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3690 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3691 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3693 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3694 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3695 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3696 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3701 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3702 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3703 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3704 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3705 c[13]=f30*sy1*f40+f32*sy2*f42;
3706 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3708 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3709 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3710 // Double_t y0,z0,y1,z1, y2,z2;
3711 //seed->GetProlongation(x0[0],y0,z0);
3712 // seed->GetProlongation(x1[0],y1,z1);
3713 //seed->GetProlongation(x2[0],y2,z2);
3715 seed->fLastPoint = pp2;
3716 seed->fFirstPoint = pp2;
3723 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3727 //reseed using founded clusters
3729 // Find the number of clusters
3730 Int_t nclusters = 0;
3731 for (Int_t irow=0;irow<160;irow++){
3732 if (track->GetClusterIndex(irow)>0) nclusters++;
3736 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3737 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3738 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3742 Int_t row[3],sec[3]={0,0,0};
3744 // find track row position at given ratio of the length
3746 for (Int_t irow=0;irow<160;irow++){
3747 if (track->GetClusterIndex2(irow)<0) continue;
3749 for (Int_t ipoint=0;ipoint<3;ipoint++){
3750 if (index<=ipos[ipoint]) row[ipoint] = irow;
3754 //Get cluster and sector position
3755 for (Int_t ipoint=0;ipoint<3;ipoint++){
3756 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3757 AliTPCclusterMI * cl = GetClusterMI(clindex);
3760 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3763 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3764 xyz[ipoint][0] = GetXrow(row[ipoint]);
3765 xyz[ipoint][1] = cl->GetY();
3766 xyz[ipoint][2] = cl->GetZ();
3770 // Calculate seed state vector and covariance matrix
3772 Double_t alpha, cs,sn, xx2,yy2;
3774 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3775 cs = TMath::Cos(alpha);
3776 sn = TMath::Sin(alpha);
3777 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3778 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3782 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3783 cs = TMath::Cos(alpha);
3784 sn = TMath::Sin(alpha);
3785 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3786 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3792 Double_t x[5],c[15];
3796 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3797 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3798 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3800 Double_t sy =0.1, sz =0.1;
3802 Double_t sy1=0.2, sz1=0.2;
3803 Double_t sy2=0.2, sz2=0.2;
3806 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;
3807 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;
3808 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;
3809 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;
3810 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;
3811 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;
3813 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;
3814 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;
3815 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;
3816 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;
3821 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3822 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3823 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3824 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3825 c[13]=f30*sy1*f40+f32*sy2*f42;
3826 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3828 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3829 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3830 seed->fLastPoint = row[2];
3831 seed->fFirstPoint = row[2];
3836 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3840 //reseed using founded clusters
3843 Int_t row[3]={0,0,0};
3844 Int_t sec[3]={0,0,0};
3846 // forward direction
3848 for (Int_t irow=r0;irow<160;irow++){
3849 if (track->GetClusterIndex(irow)>0){
3854 for (Int_t irow=160;irow>r0;irow--){
3855 if (track->GetClusterIndex(irow)>0){
3860 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3861 if (track->GetClusterIndex(irow)>0){
3869 for (Int_t irow=0;irow<r0;irow++){
3870 if (track->GetClusterIndex(irow)>0){
3875 for (Int_t irow=r0;irow>0;irow--){
3876 if (track->GetClusterIndex(irow)>0){
3881 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3882 if (track->GetClusterIndex(irow)>0){
3889 if ((row[2]-row[0])<20) return 0;
3890 if (row[1]==0) return 0;
3893 //Get cluster and sector position
3894 for (Int_t ipoint=0;ipoint<3;ipoint++){
3895 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3896 AliTPCclusterMI * cl = GetClusterMI(clindex);
3899 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3902 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3903 xyz[ipoint][0] = GetXrow(row[ipoint]);
3904 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3905 if (point&&ipoint<2){
3907 xyz[ipoint][1] = point->GetY();
3908 xyz[ipoint][2] = point->GetZ();
3911 xyz[ipoint][1] = cl->GetY();
3912 xyz[ipoint][2] = cl->GetZ();
3919 // Calculate seed state vector and covariance matrix
3921 Double_t alpha, cs,sn, xx2,yy2;
3923 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3924 cs = TMath::Cos(alpha);
3925 sn = TMath::Sin(alpha);
3926 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3927 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3931 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3932 cs = TMath::Cos(alpha);
3933 sn = TMath::Sin(alpha);
3934 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3935 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3941 Double_t x[5],c[15];
3945 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3946 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3947 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3949 Double_t sy =0.1, sz =0.1;
3951 Double_t sy1=0.2, sz1=0.2;
3952 Double_t sy2=0.2, sz2=0.2;
3955 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;
3956 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;
3957 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;
3958 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;
3959 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;
3960 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;
3962 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;
3963 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;
3964 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;
3965 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;
3970 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3971 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3972 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3973 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3974 c[13]=f30*sy1*f40+f32*sy2*f42;
3975 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3977 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3978 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3979 seed->fLastPoint = row[2];
3980 seed->fFirstPoint = row[2];
3981 for (Int_t i=row[0];i<row[2];i++){
3982 seed->fIndex[i] = track->fIndex[i];
3988 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
3995 TObjArray *kinks= new TObjArray(10000);
3996 // TObjArray *v0s= new TObjArray(10000);
3997 Int_t nentries = array->GetEntriesFast();
3998 AliHelix *helixes = new AliHelix[nentries];
3999 Int_t *sign = new Int_t[nentries];
4000 Int_t *nclusters = new Int_t[nentries];
4001 Float_t *alpha = new Float_t[nentries];
4002 AliESDkink * kink = new AliESDkink();
4003 Int_t * usage = new Int_t[nentries];
4004 Float_t *zm = new Float_t[nentries];
4005 Float_t *z0 = new Float_t[nentries];
4006 Float_t *fim = new Float_t[nentries];
4007 Float_t *shared = new Float_t[nentries];
4008 Bool_t *circular = new Bool_t[nentries];
4009 Float_t *dca = new Float_t[nentries];
4010 //const AliESDVertex * primvertex = esd->GetVertex();
4012 // nentries = array->GetEntriesFast();
4017 for (Int_t i=0;i<nentries;i++){
4020 AliTPCseed* track = (AliTPCseed*)array->At(i);
4021 if (!track) continue;
4022 track->fCircular =0;
4024 track->UpdatePoints();
4025 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4027 nclusters[i]=track->GetNumberOfClusters();
4028 alpha[i] = track->GetAlpha();
4029 new (&helixes[i]) AliHelix(*track);
4031 helixes[i].Evaluate(0,xyz);
4032 sign[i] = (track->GetC()>0) ? -1:1;
4035 if (track->GetProlongation(x,y,z)){
4037 fim[i] = alpha[i]+TMath::ATan2(y,x);
4040 zm[i] = track->GetZ();
4044 circular[i]= kFALSE;
4045 if (track->GetProlongation(0,y,z)) z0[i] = z;
4046 dca[i] = track->GetD(0,0);
4052 Int_t ncandidates =0;
4055 Double_t phase[2][2],radius[2];
4058 // Find circling track
4059 TTreeSRedirector &cstream = *fDebugStreamer;
4061 for (Int_t i0=0;i0<nentries;i0++){
4062 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4063 if (!track0) continue;
4064 if (track0->fN<40) continue;
4065 if (TMath::Abs(1./track0->fP4)>200) continue;
4066 for (Int_t i1=i0+1;i1<nentries;i1++){
4067 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4068 if (!track1) continue;
4069 if (track1->fN<40) continue;
4070 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
4071 if (track0->fBConstrain&&track1->fBConstrain) continue;
4072 if (TMath::Abs(1./track1->fP4)>200) continue;
4073 if (track1->fP4*track0->fP4>0) continue;
4074 if (track1->fP3*track0->fP3>0) continue;
4075 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
4076 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
4077 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
4079 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4080 if (mindcar<5) continue;
4081 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4082 if (mindcaz<5) continue;
4083 if (mindcar+mindcaz<20) continue;
4086 Float_t xc0 = helixes[i0].GetHelix(6);
4087 Float_t yc0 = helixes[i0].GetHelix(7);
4088 Float_t r0 = helixes[i0].GetHelix(8);
4089 Float_t xc1 = helixes[i1].GetHelix(6);
4090 Float_t yc1 = helixes[i1].GetHelix(7);
4091 Float_t r1 = helixes[i1].GetHelix(8);
4093 Float_t rmean = (r0+r1)*0.5;
4094 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4095 //if (delta>30) continue;
4096 if (delta>rmean*0.25) continue;
4097 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4099 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4100 if (npoints==0) continue;
4101 helixes[i0].GetClosestPhases(helixes[i1], phase);
4105 Double_t hangles[3];
4106 helixes[i0].Evaluate(phase[0][0],xyz0);
4107 helixes[i1].Evaluate(phase[0][1],xyz1);
4109 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4110 Double_t deltah[2],deltabest;
4111 if (hangles[2]<2.8) continue;
4113 cstream<<"C"<<track0->fLab<<track1->fLab<<
4114 track0->fP3<<track1->fP3<<
4115 track0->fP4<<track1->fP4<<
4116 delta<<rmean<<npoints<<
4117 hangles[0]<<hangles[2]<<
4118 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4122 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4124 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4125 if (deltah[1]<deltah[0]) ibest=1;
4127 deltabest = TMath::Sqrt(deltah[ibest]);
4128 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4129 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4130 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4131 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4133 if (deltabest>6) continue;
4134 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4135 Bool_t sign =kFALSE;
4136 if (hangles[2]>3.06) sign =kTRUE;
4139 circular[i0] = kTRUE;
4140 circular[i1] = kTRUE;
4141 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4142 track0->fCircular += 1;
4143 track1->fCircular += 2;
4146 track1->fCircular += 1;
4147 track0->fCircular += 2;
4150 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4152 cstream<<"Curling"<<
4153 "lab0="<<track0->fLab<<
4154 "lab1="<<track1->fLab<<
4159 "mindcar="<<mindcar<<
4160 "mindcaz="<<mindcaz<<
4163 "npoints="<<npoints<<
4164 "hangles0="<<hangles[0]<<
4165 "hangles2="<<hangles[2]<<
4170 "radius="<<radiusbest<<
4171 "deltabest="<<deltabest<<
4172 "phase0="<<phase[ibest][0]<<
4173 "phase1="<<phase[ibest][1]<<
4183 for (Int_t i =0;i<nentries;i++){
4184 if (sign[i]==0) continue;
4185 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4188 Double_t cradius0 = 40*40;
4189 Double_t cradius1 = 270*270;
4192 Double_t cdist3=0.55;
4193 for (Int_t j =i+1;j<nentries;j++){
4195 if (sign[j]*sign[i]<1) continue;
4196 if ( (nclusters[i]+nclusters[j])>200) continue;
4197 if ( (nclusters[i]+nclusters[j])<80) continue;
4198 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4199 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4200 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4201 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4202 if (npoints<1) continue;
4205 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4208 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4211 Double_t delta1=10000,delta2=10000;
4212 // cuts on the intersection radius
4213 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4214 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4215 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4217 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4218 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4219 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4222 Double_t distance1 = TMath::Min(delta1,delta2);
4223 if (distance1>cdist1) continue; // cut on DCA linear approximation
4225 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4226 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4227 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4228 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4231 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4232 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4233 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4235 distance1 = TMath::Min(delta1,delta2);
4238 rkink = TMath::Sqrt(radius[0]);
4241 rkink = TMath::Sqrt(radius[1]);
4243 if (distance1>cdist2) continue;
4246 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4249 Int_t row0 = GetRowNumber(rkink);
4250 if (row0<10) continue;
4251 if (row0>150) continue;
4254 Float_t dens00=-1,dens01=-1;
4255 Float_t dens10=-1,dens11=-1;
4257 Int_t found,foundable,shared;
4258 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4259 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4260 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4261 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4263 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4264 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4265 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4266 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4268 if (dens00<dens10 && dens01<dens11) continue;
4269 if (dens00>dens10 && dens01>dens11) continue;
4270 if (TMath::Max(dens00,dens10)<0.1) continue;
4271 if (TMath::Max(dens01,dens11)<0.3) continue;
4273 if (TMath::Min(dens00,dens10)>0.6) continue;
4274 if (TMath::Min(dens01,dens11)>0.6) continue;
4277 AliTPCseed * ktrack0, *ktrack1;
4286 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4287 AliExternalTrackParam paramm(*ktrack0);
4288 AliExternalTrackParam paramd(*ktrack1);
4289 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4292 kink->SetMother(paramm);
4293 kink->SetDaughter(paramd);
4296 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4298 fParam->Transform0to1(x,index);
4299 fParam->Transform1to2(x,index);
4300 row0 = GetRowNumber(x[0]);
4302 if (kink->GetR()<100) continue;
4303 if (kink->GetR()>240) continue;
4304 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4305 if (kink->GetDistance()>cdist3) continue;
4306 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4307 if (dird<0) continue;
4309 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4310 if (dirm<0) continue;
4311 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4312 if (mpt<0.2) continue;
4315 //for high momenta momentum not defined well in first iteration
4316 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4317 if (qt>0.35) continue;
4320 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4321 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4323 kink->SetTPCDensity(dens00,0,0);
4324 kink->SetTPCDensity(dens01,0,1);
4325 kink->SetTPCDensity(dens10,1,0);
4326 kink->SetTPCDensity(dens11,1,1);
4327 kink->SetIndex(i,0);
4328 kink->SetIndex(j,1);
4331 kink->SetTPCDensity(dens10,0,0);
4332 kink->SetTPCDensity(dens11,0,1);
4333 kink->SetTPCDensity(dens00,1,0);
4334 kink->SetTPCDensity(dens01,1,1);
4335 kink->SetIndex(j,0);
4336 kink->SetIndex(i,1);
4339 if (mpt<1||kink->GetAngle(2)>0.1){
4340 // angle and densities not defined yet
4341 if (kink->GetTPCDensityFactor()<0.8) continue;
4342 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4343 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4344 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4345 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4347 Float_t criticalangle = track0->fC22+track0->fC33;
4348 criticalangle+= track1->fC22+track1->fC33;
4349 criticalangle= 3*TMath::Sqrt(criticalangle);
4350 if (criticalangle>0.02) criticalangle=0.02;
4351 if (kink->GetAngle(2)<criticalangle) continue;
4354 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4355 Float_t shapesum =0;
4357 for ( Int_t row = row0-drow; row<row0+drow;row++){
4358 if (row<0) continue;
4359 if (row>155) continue;
4360 if (ktrack0->fClusterPointer[row]){
4361 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4362 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4365 if (ktrack1->fClusterPointer[row]){
4366 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4367 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4372 kink->SetShapeFactor(-1.);
4375 kink->SetShapeFactor(shapesum/sum);
4377 // esd->AddKink(kink);
4378 kinks->AddLast(kink);
4379 kink = new AliESDkink;
4384 // sort the kinks according quality - and refit them towards vertex
4386 Int_t nkinks = kinks->GetEntriesFast();
4387 Float_t *quality = new Float_t[nkinks];
4388 Int_t *indexes = new Int_t[nkinks];
4389 AliTPCseed *mothers = new AliTPCseed[nkinks];
4390 AliTPCseed *daughters = new AliTPCseed[nkinks];
4393 for (Int_t i=0;i<nkinks;i++){
4395 AliESDkink *kink = (AliESDkink*)kinks->At(i);
4397 // refit kinks towards vertex
4399 Int_t index0 = kink->GetIndex(0);
4400 Int_t index1 = kink->GetIndex(1);
4401 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4402 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4404 Int_t sumn=ktrack0->fN+ktrack1->fN;
4406 // Refit Kink under if too small angle
4408 if (kink->GetAngle(2)<0.05){
4409 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4410 Int_t row0 = kink->GetTPCRow0();
4411 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4414 Int_t last = row0-drow;
4415 if (last<40) last=40;
4416 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4417 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4420 Int_t first = row0+drow;
4421 if (first>130) first=130;
4422 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4423 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4425 if (seed0 && seed1){
4426 kink->SetStatus(1,8);
4427 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4428 row0 = GetRowNumber(kink->GetR());
4429 sumn = seed0->fN+seed1->fN;
4430 new (&mothers[i]) AliTPCseed(*seed0);
4431 new (&daughters[i]) AliTPCseed(*seed1);
4434 delete kinks->RemoveAt(i);
4435 if (seed0) delete seed0;
4436 if (seed1) delete seed1;
4439 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4440 delete kinks->RemoveAt(i);
4441 if (seed0) delete seed0;
4442 if (seed1) delete seed1;
4450 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4452 TMath::Sort(nkinks,quality,indexes,kFALSE);
4454 //remove double find kinks
4456 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4457 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4458 if (!kink0) continue;
4460 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4461 if (!kink0) continue;
4462 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4463 if (!kink1) continue;
4464 // if not close kink continue
4465 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4466 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4467 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4469 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4470 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4471 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4472 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4473 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4482 for (Int_t i=0;i<row0;i++){
4483 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4486 if (mother0.fIndex[i]==mother1.fIndex[i]){
4493 for (Int_t i=row0;i<158;i++){
4494 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4497 if (mother0.fIndex[i]==mother1.fIndex[i]){
4503 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4504 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4505 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4506 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4507 Int_t sum0 = mother0.fN+daughter0.fN;
4508 Int_t sum1 = mother1.fN+daughter1.fN;
4510 shared[kink0->GetIndex(0)]= kTRUE;
4511 shared[kink0->GetIndex(1)]= kTRUE;
4512 delete kinks->RemoveAt(indexes[ikink0]);
4515 shared[kink1->GetIndex(0)]= kTRUE;
4516 shared[kink1->GetIndex(1)]= kTRUE;
4517 delete kinks->RemoveAt(indexes[ikink1]);
4524 for (Int_t i=0;i<nkinks;i++){
4525 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
4526 if (!kink) continue;
4527 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4528 Int_t index0 = kink->GetIndex(0);
4529 Int_t index1 = kink->GetIndex(1);
4530 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4531 kink->SetMultiple(usage[index0],0);
4532 kink->SetMultiple(usage[index1],1);
4533 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4534 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4535 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4536 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4538 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4539 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4540 if (!ktrack0 || !ktrack1) continue;
4541 Int_t index = esd->AddKink(kink);
4544 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4545 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4546 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4547 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4551 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4552 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4557 // Remove tracks corresponding to shared kink's
4559 for (Int_t i=0;i<nentries;i++){
4560 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4561 if (!track0) continue;
4562 if (track0->fKinkIndexes[0]!=0) continue;
4563 if (shared[i]) delete array->RemoveAt(i);
4568 RemoveUsed2(array,0.5,0.4,30);
4570 for (Int_t i=0;i<nentries;i++){
4571 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4572 if (!track0) continue;
4573 track0->CookdEdx(0.02,0.6);
4577 for (Int_t i=0;i<nentries;i++){
4578 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4579 if (!track0) continue;
4580 if (track0->Pt()<1.4) continue;
4581 //remove double high momenta tracks - overlapped with kink candidates
4584 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4585 if (track0->fClusterPointer[icl]!=0){
4587 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4590 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4591 delete array->RemoveAt(i);
4594 if (track0->fKinkIndexes[0]!=0) continue;
4595 if (track0->GetNumberOfClusters()<80) continue;
4597 AliTPCseed *pmother = new AliTPCseed();
4598 AliTPCseed *pdaughter = new AliTPCseed();
4599 AliESDkink *pkink = new AliESDkink;
4601 AliTPCseed & mother = *pmother;
4602 AliTPCseed & daughter = *pdaughter;
4603 AliESDkink & kink = *pkink;
4604 if (CheckKinkPoint(track0,mother,daughter, kink)){
4605 if (mother.fN<30||daughter.fN<20) {
4609 continue; //too short tracks
4611 if (mother.Pt()<1.4) {
4617 Int_t row0= kink.GetTPCRow0();
4618 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4625 Int_t index = esd->AddKink(&kink);
4626 mother.fKinkIndexes[0] = -(index+1);
4627 daughter.fKinkIndexes[0] = index+1;
4629 delete array->RemoveAt(i);
4630 array->AddAt(new AliTPCseed(mother),i);
4633 array->AddLast(new AliTPCseed(mother));
4635 array->AddLast(new AliTPCseed(daughter));
4636 for (Int_t icl=0;icl<row0;icl++) {
4637 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4640 for (Int_t icl=row0;icl<158;icl++) {
4641 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4650 delete [] daughters;
4672 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4676 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4682 TObjArray *tpcv0s = new TObjArray(100000);
4683 Int_t nentries = array->GetEntriesFast();
4684 AliHelix *helixes = new AliHelix[nentries];
4685 Int_t *sign = new Int_t[nentries];
4686 Float_t *alpha = new Float_t[nentries];
4687 Float_t *z0 = new Float_t[nentries];
4688 Float_t *dca = new Float_t[nentries];
4689 Float_t *sdcar = new Float_t[nentries];
4690 Float_t *cdcar = new Float_t[nentries];
4691 Float_t *pulldcar = new Float_t[nentries];
4692 Float_t *pulldcaz = new Float_t[nentries];
4693 Float_t *pulldca = new Float_t[nentries];
4694 Bool_t *isPrim = new Bool_t[nentries];
4695 const AliESDVertex * primvertex = esd->GetVertex();
4696 Double_t zvertex = primvertex->GetZv();
4698 // nentries = array->GetEntriesFast();
4700 for (Int_t i=0;i<nentries;i++){
4703 AliTPCseed* track = (AliTPCseed*)array->At(i);
4704 if (!track) continue;
4705 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4706 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4707 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4709 alpha[i] = track->GetAlpha();
4710 new (&helixes[i]) AliHelix(*track);
4712 helixes[i].Evaluate(0,xyz);
4713 sign[i] = (track->GetC()>0) ? -1:1;
4717 if (track->GetProlongation(0,y,z)) z0[i] = z;
4718 dca[i] = track->GetD(0,0);
4720 // dca error parrameterezation + pulls
4722 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4723 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4724 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4725 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4726 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4727 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4728 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4729 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4731 if (track->fTPCr[4]>0.5) {
4732 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4734 if (track->fTPCr[0]>0.4) {
4735 isPrim[i]=kFALSE; //electron no sigma cut
4742 Int_t ncandidates =0;
4745 Double_t phase[2][2],radius[2];
4751 TTreeSRedirector &cstream = *fDebugStreamer;
4752 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4754 Double_t cradius0 = 10*10;
4755 Double_t cradius1 = 200*200;
4758 Double_t cpointAngle = 0.95;
4760 Double_t delta[2]={10000,10000};
4761 for (Int_t i =0;i<nentries;i++){
4762 if (sign[i]==0) continue;
4763 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4764 if (!track0) continue;
4765 if (AliTPCReconstructor::StreamLevel()>0){
4770 "zvertex="<<zvertex<<
4771 "sdcar0="<<sdcar[i]<<
4772 "cdcar0="<<cdcar[i]<<
4773 "pulldcar0="<<pulldcar[i]<<
4774 "pulldcaz0="<<pulldcaz[i]<<
4775 "pulldca0="<<pulldca[i]<<
4776 "isPrim="<<isPrim[i]<<
4780 if (track0->fP4<0) continue;
4781 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4783 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4788 for (Int_t j =0;j<nentries;j++){
4789 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4790 if (!track1) continue;
4791 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4792 if (sign[j]*sign[i]>0) continue;
4793 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4794 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4797 // DCA to prim vertex cut
4803 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4804 if (npoints<1) continue;
4808 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4809 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4810 if (delta[0]>cdist1) continue;
4813 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4814 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4815 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4816 if (delta[1]<delta[0]) iclosest=1;
4817 if (delta[iclosest]>cdist1) continue;
4819 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4820 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4822 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4823 if (pointAngle<cpointAngle) continue;
4825 Bool_t isGamma = kFALSE;
4826 vertex.SetP(*track0); //track0 - plus
4827 vertex.SetM(*track1); //track1 - minus
4828 vertex.Update(fprimvertex);
4829 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4830 Double_t pointAngle2 = vertex.GetPointAngle();
4832 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4833 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4834 Float_t sigmae = 0.15*0.15;
4835 if (vertex.GetRr()<80)
4836 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4837 sigmae+= TMath::Sqrt(sigmae);
4838 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4839 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4840 Int_t row0 = GetRowNumber(vertex.GetRr());
4842 if (vertex.GetDist2()>0.2) continue;
4843 densb0 = track0->Density2(0,row0-5);
4844 densb1 = track1->Density2(0,row0-5);
4845 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4846 densa0 = track0->Density2(row0+5,row0+40);
4847 densa1 = track1->Density2(row0+5,row0+40);
4848 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4851 densa0 = track0->Density2(0,40); //cluster density
4852 densa1 = track1->Density2(0,40); //cluster density
4853 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4855 vertex.SetLab(0,track0->GetLabel());
4856 vertex.SetLab(1,track1->GetLabel());
4857 vertex.SetChi2After((densa0+densa1)*0.5);
4858 vertex.SetChi2Before((densb0+densb1)*0.5);
4859 vertex.SetIndex(0,i);
4860 vertex.SetIndex(1,j);
4861 vertex.SetStatus(1); // TPC v0 candidate
4862 vertex.SetRp(track0->fTPCr);
4863 vertex.SetRm(track1->fTPCr);
4864 tpcv0s->AddLast(new AliESDV0MI(vertex));
4867 Int_t eventNr = esd->GetEventNumber();
4868 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4869 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4870 if (AliTPCReconstructor::StreamLevel()>0)
4873 "vertex.="<<&vertex<<
4875 "lab0="<<track0->fLab<<
4876 "Helix0.="<<&helixes[i]<<
4878 "lab1="<<track1->fLab<<
4879 "Helix1.="<<&helixes[j]<<
4880 "pointAngle="<<pointAngle<<
4881 "pointAngle2="<<pointAngle2<<
4886 "zvertex="<<zvertex<<
4887 "circular0="<<track0->fCircular<<
4888 "circular1="<<track1->fCircular<<
4889 "npoints="<<npoints<<
4890 "radius0="<<radius[0]<<
4891 "delta0="<<delta[0]<<
4892 "radius1="<<radius[1]<<
4893 "delta1="<<delta[1]<<
4894 "radiusm="<<radiusm<<
4896 "sdcar0="<<sdcar[i]<<
4897 "sdcar1="<<sdcar[j]<<
4898 "cdcar0="<<cdcar[i]<<
4899 "cdcar1="<<cdcar[j]<<
4900 "pulldcar0="<<pulldcar[i]<<
4901 "pulldcar1="<<pulldcar[j]<<
4902 "pulldcaz0="<<pulldcaz[i]<<
4903 "pulldcaz1="<<pulldcaz[j]<<
4904 "pulldca0="<<pulldca[i]<<
4905 "pulldca1="<<pulldca[j]<<
4915 Float_t *quality = new Float_t[ncandidates];
4916 Int_t *indexes = new Int_t[ncandidates];
4918 for (Int_t i=0;i<ncandidates;i++){
4920 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4921 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4922 // quality[i] /= (0.5+v0->GetDist2());
4923 // quality[i] *= v0->GetChi2After(); //density factor
4924 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4925 Int_t index0 = v0->GetIndex(0);
4926 Int_t index1 = v0->GetIndex(1);
4927 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4928 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4929 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4930 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4933 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4936 for (Int_t i=0;i<ncandidates;i++){
4937 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4939 Int_t index0 = v0->GetIndex(0);
4940 Int_t index1 = v0->GetIndex(1);
4941 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4942 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4943 if (!track0||!track1) {
4947 Bool_t accept =kTRUE; //default accept
4948 Int_t *v0indexes0 = track0->GetV0Indexes();
4949 Int_t *v0indexes1 = track1->GetV0Indexes();
4951 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4952 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4953 if (v0indexes0[1]!=0) order0 =2;
4954 if (v0indexes1[1]!=0) order1 =2;
4956 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4957 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4959 AliESDV0MI * v02 = v0;
4961 v0->SetOrder(0,order0);
4962 v0->SetOrder(1,order1);
4963 v0->SetOrder(1,order0+order1);
4964 Int_t index = esd->AddV0MI(v0);
4965 v02 = esd->GetV0MI(index);
4966 v0indexes0[order0]=index;
4967 v0indexes1[order1]=index;
4971 Int_t eventNr = esd->GetEventNumber();
4972 if (AliTPCReconstructor::StreamLevel()>0)
4978 "lab0="<<track0->fLab<<
4980 "lab1="<<track1->fLab<<
4981 "dca0="<<dca[index0]<<
4982 "dca1="<<dca[index1]<<
4986 "quality="<<quality[i]<<
4987 "pulldca0="<<pulldca[index0]<<
4988 "pulldca1="<<pulldca[index1]<<
5012 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5016 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5019 // refit kink towards to the vertex
5022 Int_t row0 = GetRowNumber(kink.GetR());
5023 FollowProlongation(mother,0);
5024 mother.Reset(kFALSE);
5026 FollowProlongation(daughter,row0);
5027 daughter.Reset(kFALSE);
5028 FollowBackProlongation(daughter,158);
5029 daughter.Reset(kFALSE);
5030 Int_t first = TMath::Max(row0-20,30);
5031 Int_t last = TMath::Min(row0+20,140);
5033 const Int_t kNdiv =5;
5034 AliTPCseed param0[kNdiv]; // parameters along the track
5035 AliTPCseed param1[kNdiv]; // parameters along the track
5036 AliESDkink kinks[kNdiv]; // corresponding kink parameters
5039 for (Int_t irow=0; irow<kNdiv;irow++){
5040 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5042 // store parameters along the track
5044 for (Int_t irow=0;irow<kNdiv;irow++){
5045 FollowBackProlongation(mother, rows[irow]);
5046 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5047 new(¶m0[irow]) AliTPCseed(mother);
5048 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5052 for (Int_t irow=0; irow<kNdiv-1;irow++){
5053 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5054 kinks[irow].SetMother(param0[irow]);
5055 kinks[irow].SetDaughter(param1[irow]);
5056 kinks[irow].Update();
5059 // choose kink with best "quality"
5061 Double_t mindist = 10000;
5062 for (Int_t irow=0;irow<kNdiv;irow++){
5063 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5064 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5065 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5067 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
5068 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5069 if (normdist < mindist){
5075 if (index==-1) return 0;
5078 param0[index].Reset(kTRUE);
5079 FollowProlongation(param0[index],0);
5081 new (&mother) AliTPCseed(param0[index]);
5082 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5084 kink.SetMother(mother);
5085 kink.SetDaughter(daughter);
5087 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5088 kink.SetTPCncls(param0[index].fN,0);
5089 kink.SetTPCncls(param1[index].fN,1);
5090 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5091 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5092 mother.SetLabel(kink.GetLabel(0));
5093 daughter.SetLabel(kink.GetLabel(1));
5099 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5101 // update Kink quality information for mother after back propagation
5103 if (seed->GetKinkIndex(0)>=0) return;
5104 for (Int_t ikink=0;ikink<3;ikink++){
5105 Int_t index = seed->GetKinkIndex(ikink);
5106 if (index>=0) break;
5107 index = TMath::Abs(index)-1;
5108 AliESDkink * kink = fEvent->GetKink(index);
5109 //kink->fTPCdensity2[0][0]=-1;
5110 //kink->fTPCdensity2[0][1]=-1;
5111 kink->SetTPCDensity2(-1,0,0);
5112 kink->SetTPCDensity2(1,0,1);
5114 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5115 if (row0<15) row0=15;
5117 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5118 if (row1>145) row1=145;
5120 Int_t found,foundable,shared;
5121 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5122 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5123 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5124 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5129 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5131 // update Kink quality information for daughter after refit
5133 if (seed->GetKinkIndex(0)<=0) return;
5134 for (Int_t ikink=0;ikink<3;ikink++){
5135 Int_t index = seed->GetKinkIndex(ikink);
5136 if (index<=0) break;
5137 index = TMath::Abs(index)-1;
5138 AliESDkink * kink = fEvent->GetKink(index);
5139 kink->SetTPCDensity2(-1,1,0);
5140 kink->SetTPCDensity2(-1,1,1);
5142 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5143 if (row0<15) row0=15;
5145 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5146 if (row1>145) row1=145;
5148 Int_t found,foundable,shared;
5149 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5150 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5151 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5152 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5158 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5161 // check kink point for given track
5162 // if return value=0 kink point not found
5163 // otherwise seed0 correspond to mother particle
5164 // seed1 correspond to daughter particle
5165 // kink parameter of kink point
5167 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5168 Int_t first = seed->fFirstPoint;
5169 Int_t last = seed->fLastPoint;
5170 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5173 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5174 if (!seed1) return 0;
5175 FollowProlongation(*seed1,seed->fLastPoint-20);
5176 seed1->Reset(kTRUE);
5177 FollowProlongation(*seed1,158);
5178 seed1->Reset(kTRUE);
5179 last = seed1->fLastPoint;
5181 AliTPCseed *seed0 = new AliTPCseed(*seed);
5182 seed0->Reset(kFALSE);
5185 AliTPCseed param0[20]; // parameters along the track
5186 AliTPCseed param1[20]; // parameters along the track
5187 AliESDkink kinks[20]; // corresponding kink parameters
5189 for (Int_t irow=0; irow<20;irow++){
5190 rows[irow] = first +((last-first)*irow)/19;
5192 // store parameters along the track
5194 for (Int_t irow=0;irow<20;irow++){
5195 FollowBackProlongation(*seed0, rows[irow]);
5196 FollowProlongation(*seed1,rows[19-irow]);
5197 new(¶m0[irow]) AliTPCseed(*seed0);
5198 new(¶m1[19-irow]) AliTPCseed(*seed1);
5202 for (Int_t irow=0; irow<19;irow++){
5203 kinks[irow].SetMother(param0[irow]);
5204 kinks[irow].SetDaughter(param1[irow]);
5205 kinks[irow].Update();
5208 // choose kink with biggest change of angle
5210 Double_t maxchange= 0;
5211 for (Int_t irow=1;irow<19;irow++){
5212 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5213 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5214 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5215 if ( quality > maxchange){
5216 maxchange = quality;
5223 if (index<0) return 0;
5225 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5226 seed0 = new AliTPCseed(param0[index]);
5227 seed1 = new AliTPCseed(param1[index]);
5228 seed0->Reset(kFALSE);
5229 seed1->Reset(kFALSE);
5230 seed0->ResetCovariance();
5231 seed1->ResetCovariance();
5232 FollowProlongation(*seed0,0);
5233 FollowBackProlongation(*seed1,158);
5234 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5235 seed0->Reset(kFALSE);
5236 seed1->Reset(kFALSE);
5237 seed0->ResetCovariance();
5238 seed1->ResetCovariance();
5240 first = TMath::Max(row0-20,0);
5241 last = TMath::Min(row0+20,158);
5243 for (Int_t irow=0; irow<20;irow++){
5244 rows[irow] = first +((last-first)*irow)/19;
5246 // store parameters along the track
5248 for (Int_t irow=0;irow<20;irow++){
5249 FollowBackProlongation(*seed0, rows[irow]);
5250 FollowProlongation(*seed1,rows[19-irow]);
5251 new(¶m0[irow]) AliTPCseed(*seed0);
5252 new(¶m1[19-irow]) AliTPCseed(*seed1);
5256 for (Int_t irow=0; irow<19;irow++){
5257 kinks[irow].SetMother(param0[irow]);
5258 kinks[irow].SetDaughter(param1[irow]);
5259 // param0[irow].Dump();
5260 //param1[irow].Dump();
5261 kinks[irow].Update();
5264 // choose kink with biggest change of angle
5267 for (Int_t irow=0;irow<20;irow++){
5268 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5269 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5270 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5271 if ( quality > maxchange){
5272 maxchange = quality;
5279 if (index==-1 || param0[index].fN+param1[index].fN<100){
5284 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5286 kink.SetMother(param0[index]);
5287 kink.SetDaughter(param1[index]);
5289 row0 = GetRowNumber(kink.GetR());
5290 kink.SetTPCRow0(row0);
5291 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5292 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5293 kink.SetIndex(-10,0);
5294 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5295 kink.SetTPCncls(param0[index].fN,0);
5296 kink.SetTPCncls(param1[index].fN,1);
5299 // new (&mother) AliTPCseed(param0[index]);
5300 new (&daughter) AliTPCseed(param1[index]);
5301 daughter.SetLabel(kink.GetLabel(1));
5302 param0[index].Reset(kTRUE);
5303 FollowProlongation(param0[index],0);
5304 new (&mother) AliTPCseed(param0[index]);
5305 mother.SetLabel(kink.GetLabel(0));
5315 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5318 // reseed - refit - track
5321 // Int_t last = fSectors->GetNRows()-1;
5323 if (fSectors == fOuterSec){
5324 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5328 first = t->fFirstPoint;
5330 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5331 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5333 FollowProlongation(*t,first);
5343 //_____________________________________________________________________________
5344 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5345 //-----------------------------------------------------------------
5346 // This function reades track seeds.
5347 //-----------------------------------------------------------------
5348 TDirectory *savedir=gDirectory;
5350 TFile *in=(TFile*)inp;
5351 if (!in->IsOpen()) {
5352 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5357 TTree *seedTree=(TTree*)in->Get("Seeds");
5359 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5360 cerr<<"can't get a tree with track seeds !\n";
5363 AliTPCtrack *seed=new AliTPCtrack;
5364 seedTree->SetBranchAddress("tracks",&seed);
5366 if (fSeeds==0) fSeeds=new TObjArray(15000);
5368 Int_t n=(Int_t)seedTree->GetEntries();
5369 for (Int_t i=0; i<n; i++) {
5370 seedTree->GetEvent(i);
5371 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5380 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5383 if (fSeeds) DeleteSeeds();
5386 if (!fSeeds) return 1;
5393 //_____________________________________________________________________________
5394 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5395 //-----------------------------------------------------------------
5396 // This is a track finder.
5397 //-----------------------------------------------------------------
5398 TDirectory *savedir=gDirectory;
5402 fSeeds = Tracking();
5405 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5407 //activate again some tracks
5408 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5409 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5411 Int_t nc=t.GetNumberOfClusters();
5413 delete fSeeds->RemoveAt(i);
5417 if (pt->fRemoval==10) {
5418 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5419 pt->Desactivate(10); // make track again active
5421 pt->Desactivate(20);
5422 delete fSeeds->RemoveAt(i);
5427 RemoveUsed2(fSeeds,0.85,0.85,0);
5428 FindKinks(fSeeds,fEvent);
5429 RemoveUsed2(fSeeds,0.5,0.4,20);
5431 // // refit short tracks
5433 Int_t nseed=fSeeds->GetEntriesFast();
5434 // for (Int_t i=0; i<nseed; i++) {
5435 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5436 // if (!pt) continue;
5437 // Int_t nc=t.GetNumberOfClusters();
5439 // delete fSeeds->RemoveAt(i);
5442 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5443 // if (nc>100) continue; // hopefully, enough for ITS
5444 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5445 // //seed2->Reset(kFALSE);
5446 // //pt->ResetCovariance();
5447 // seed2->Modify(1);
5448 // FollowBackProlongation(*seed2,158);
5449 // //seed2->Reset(kFALSE);
5450 // seed2->Modify(10);
5451 // FollowProlongation(*seed2,0);
5452 // TTreeSRedirector &cstream = *fDebugStreamer;
5453 // cstream<<"Crefit"<<
5457 // if (seed2->fN>pt->fN){
5458 // delete fSeeds->RemoveAt(i);
5459 // fSeeds->AddAt(seed2,i);
5464 // RemoveUsed2(fSeeds,0.6,0.6,50);
5466 // FindV0s(fSeeds,fEvent);
5467 //RemoveDouble(fSeeds,0.2,0.6,11);
5471 for (Int_t i=0; i<nseed; i++) {
5472 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5474 Int_t nc=t.GetNumberOfClusters();
5476 delete fSeeds->RemoveAt(i);
5479 CookLabel(pt,0.1); //For comparison only
5480 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5481 if ((pt->IsActive() || (pt->fRemoval==10) )){
5483 if (fDebug>0) cerr<<found<<'\r';
5487 delete fSeeds->RemoveAt(i);
5491 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5493 //RemoveUsed(fSeeds,0.9,0.9,6);
5495 nseed=fSeeds->GetEntriesFast();
5497 for (Int_t i=0; i<nseed; i++) {
5498 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5500 Int_t nc=t.GetNumberOfClusters();
5502 delete fSeeds->RemoveAt(i);
5506 t.CookdEdx(0.02,0.6);
5507 // CheckKinkPoint(&t,0.05);
5508 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5509 if ((pt->IsActive() || (pt->fRemoval==10) )){
5517 delete fSeeds->RemoveAt(i);
5518 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5520 // FollowProlongation(*seed1,0);
5521 // Int_t n = seed1->GetNumberOfClusters();
5522 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5523 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5526 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5530 SortTracks(fSeeds, 1);
5534 PrepareForBackProlongation(fSeeds,5.);
5535 PropagateBack(fSeeds);
5536 printf("Time for back propagation: \t");timer.Print();timer.Start();
5540 PrepareForProlongation(fSeeds,5.);
5541 PropagateForward2(fSeeds);
5543 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5544 // RemoveUsed(fSeeds,0.7,0.7,6);
5545 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5547 nseed=fSeeds->GetEntriesFast();
5549 for (Int_t i=0; i<nseed; i++) {
5550 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5552 Int_t nc=t.GetNumberOfClusters();
5554 delete fSeeds->RemoveAt(i);
5557 t.CookdEdx(0.02,0.6);
5558 // CookLabel(pt,0.1); //For comparison only
5559 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5560 if ((pt->IsActive() || (pt->fRemoval==10) )){
5561 cerr<<found++<<'\r';
5564 delete fSeeds->RemoveAt(i);
5569 // fNTracks = found;
5571 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5574 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5575 Info("Clusters2Tracks","Number of found tracks %d",found);
5577 // UnloadClusters();
5582 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5585 // tracking of the seeds
5588 fSectors = fOuterSec;
5589 ParallelTracking(arr,150,63);
5590 fSectors = fOuterSec;
5591 ParallelTracking(arr,63,0);
5594 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5599 TObjArray * arr = new TObjArray;
5601 fSectors = fOuterSec;
5604 for (Int_t sec=0;sec<fkNOS;sec++){
5605 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5606 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5607 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5610 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5622 TObjArray * AliTPCtrackerMI::Tracking()
5628 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5630 TObjArray * seeds = new TObjArray;
5639 Float_t fnumber = 3.0;
5640 Float_t fdensity = 3.0;
5645 for (Int_t delta = 0; delta<18; delta+=6){
5649 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5650 SumTracks(seeds,arr);
5651 SignClusters(seeds,fnumber,fdensity);
5653 for (Int_t i=2;i<6;i+=2){
5654 // seed high pt tracks
5657 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5658 SumTracks(seeds,arr);
5659 SignClusters(seeds,fnumber,fdensity);
5664 // RemoveUsed(seeds,0.9,0.9,1);
5665 // UnsignClusters();
5666 // SignClusters(seeds,fnumber,fdensity);
5670 for (Int_t delta = 20; delta<120; delta+=10){
5672 // seed high pt tracks
5676 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5677 SumTracks(seeds,arr);
5678 SignClusters(seeds,fnumber,fdensity);
5683 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5684 SumTracks(seeds,arr);
5685 SignClusters(seeds,fnumber,fdensity);
5696 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5700 // RemoveUsed(seeds,0.75,0.75,1);
5702 //SignClusters(seeds,fnumber,fdensity);
5711 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5712 SumTracks(seeds,arr);
5713 SignClusters(seeds,fnumber,fdensity);
5715 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5716 SumTracks(seeds,arr);
5717 SignClusters(seeds,fnumber,fdensity);
5719 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5720 SumTracks(seeds,arr);
5721 SignClusters(seeds,fnumber,fdensity);
5725 for (Int_t delta = 3; delta<30; delta+=5){
5731 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5732 SumTracks(seeds,arr);
5733 SignClusters(seeds,fnumber,fdensity);
5735 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5736 SumTracks(seeds,arr);
5737 SignClusters(seeds,fnumber,fdensity);
5749 for (Int_t delta = 30; delta<90; delta+=10){
5755 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5756 SumTracks(seeds,arr);
5757 SignClusters(seeds,fnumber,fdensity);
5759 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5760 SumTracks(seeds,arr);
5761 SignClusters(seeds,fnumber,fdensity);
5765 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5776 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5779 //sum tracks to common container
5780 //remove suspicious tracks
5781 Int_t nseed = arr2->GetEntriesFast();
5782 for (Int_t i=0;i<nseed;i++){
5783 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5785 // REMOVE VERY SHORT TRACKS
5786 if (pt->GetNumberOfClusters()<20){
5787 delete arr2->RemoveAt(i);
5790 // NORMAL ACTIVE TRACK
5791 if (pt->IsActive()){
5792 arr1->AddLast(arr2->RemoveAt(i));
5795 //remove not usable tracks
5796 if (pt->fRemoval!=10){
5797 delete arr2->RemoveAt(i);
5801 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5802 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5803 arr1->AddLast(arr2->RemoveAt(i));
5805 delete arr2->RemoveAt(i);
5814 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
5817 // try to track in parralel
5819 Int_t nseed=arr->GetEntriesFast();
5820 //prepare seeds for tracking
5821 for (Int_t i=0; i<nseed; i++) {
5822 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5824 if (!t.IsActive()) continue;
5825 // follow prolongation to the first layer
5826 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
5827 FollowProlongation(t, rfirst+1);
5832 for (Int_t nr=rfirst; nr>=rlast; nr--){
5833 if (nr<fInnerSec->GetNRows())
5834 fSectors = fInnerSec;
5836 fSectors = fOuterSec;
5837 // make indexes with the cluster tracks for given
5839 // find nearest cluster
5840 for (Int_t i=0; i<nseed; i++) {
5841 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
5843 if (nr==80) pt->UpdateReference();
5844 if (!pt->IsActive()) continue;
5845 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5846 if (pt->fRelativeSector>17) {
5849 UpdateClusters(t,nr);
5851 // prolonagate to the nearest cluster - if founded
5852 for (Int_t i=0; i<nseed; i++) {
5853 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5855 if (!pt->IsActive()) continue;
5856 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5857 if (pt->fRelativeSector>17) {
5860 FollowToNextCluster(*pt,nr);
5865 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5869 // if we use TPC track itself we have to "update" covariance
5871 Int_t nseed= arr->GetEntriesFast();
5872 for (Int_t i=0;i<nseed;i++){
5873 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5877 //rotate to current local system at first accepted point
5878 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5879 Int_t sec = (index&0xff000000)>>24;
5881 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5882 if (angle1>TMath::Pi())
5883 angle1-=2.*TMath::Pi();
5884 Float_t angle2 = pt->GetAlpha();
5886 if (TMath::Abs(angle1-angle2)>0.001){
5887 pt->Rotate(angle1-angle2);
5888 //angle2 = pt->GetAlpha();
5889 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5890 //if (pt->GetAlpha()<0)
5891 // pt->fRelativeSector+=18;
5892 //sec = pt->fRelativeSector;
5901 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5905 // if we use TPC track itself we have to "update" covariance
5907 Int_t nseed= arr->GetEntriesFast();
5908 for (Int_t i=0;i<nseed;i++){
5909 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5912 pt->fFirstPoint = pt->fLastPoint;
5920 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5923 // make back propagation
5925 Int_t nseed= arr->GetEntriesFast();
5926 for (Int_t i=0;i<nseed;i++){
5927 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5928 if (pt&& pt->GetKinkIndex(0)<=0) {
5929 //AliTPCseed *pt2 = new AliTPCseed(*pt);
5930 fSectors = fInnerSec;
5931 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5932 //fSectors = fOuterSec;
5933 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5934 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
5935 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
5936 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5939 if (pt&& pt->GetKinkIndex(0)>0) {
5940 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
5941 pt->fFirstPoint = kink->GetTPCRow0();
5942 fSectors = fInnerSec;
5943 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5951 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5954 // make forward propagation
5956 Int_t nseed= arr->GetEntriesFast();
5958 for (Int_t i=0;i<nseed;i++){
5959 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5961 FollowProlongation(*pt,0);
5968 Int_t AliTPCtrackerMI::PropagateForward()
5971 // propagate track forward
5973 Int_t nseed = fSeeds->GetEntriesFast();
5974 for (Int_t i=0;i<nseed;i++){
5975 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5977 AliTPCseed &t = *pt;
5978 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5979 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5980 if (alpha < 0. ) alpha += 2.*TMath::Pi();
5981 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
5985 fSectors = fOuterSec;
5986 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
5987 fSectors = fInnerSec;
5988 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
5998 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6001 // make back propagation, in between row0 and row1
6005 fSectors = fInnerSec;
6008 if (row1<fSectors->GetNRows())
6011 r1 = fSectors->GetNRows()-1;
6013 if (row0<fSectors->GetNRows()&& r1>0 )
6014 FollowBackProlongation(*pt,r1);
6015 if (row1<=fSectors->GetNRows())
6018 r1 = row1 - fSectors->GetNRows();
6019 if (r1<=0) return 0;
6020 if (r1>=fOuterSec->GetNRows()) return 0;
6021 fSectors = fOuterSec;
6022 return FollowBackProlongation(*pt,r1);
6030 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6034 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6035 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6036 Float_t padlength = GetPadPitchLength(row);
6038 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6039 Double_t angulary = seed->GetSnp();
6040 angulary = angulary*angulary/(1-angulary*angulary);
6041 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6043 Float_t sresz = fParam->GetZSigma();
6044 Float_t angularz = seed->GetTgl();
6045 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6047 Float_t wy = GetSigmaY(seed);
6048 Float_t wz = GetSigmaZ(seed);
6051 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6052 printf("problem\n");
6058 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6062 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6063 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6064 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6065 Float_t angular = seed->GetSnp();
6066 angular = angular*angular/(1-angular*angular);
6067 // angular*=angular;
6068 //angular = TMath::Sqrt(angular/(1-angular));
6069 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6072 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6076 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6077 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6078 Float_t sres = fParam->GetZSigma();
6079 Float_t angular = seed->GetTgl();
6080 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6085 //__________________________________________________________________________
6086 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6087 //--------------------------------------------------------------------
6088 //This function "cooks" a track label. If label<0, this track is fake.
6089 //--------------------------------------------------------------------
6090 AliTPCseed * t = (AliTPCseed*)tk;
6091 Int_t noc=t->GetNumberOfClusters();
6093 //printf("\nnot founded prolongation\n\n\n");
6099 AliTPCclusterMI *clusters[160];
6101 for (Int_t i=0;i<160;i++) {
6108 for (i=0; i<160 && current<noc; i++) {
6110 Int_t index=t->GetClusterIndex2(i);
6111 if (index<=0) continue;
6112 if (index&0x8000) continue;
6114 //clusters[current]=GetClusterMI(index);
6115 if (t->fClusterPointer[i]){
6116 clusters[current]=t->fClusterPointer[i];
6122 Int_t lab=123456789;
6123 for (i=0; i<noc; i++) {
6124 AliTPCclusterMI *c=clusters[i];
6126 lab=TMath::Abs(c->GetLabel(0));
6128 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6134 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6136 for (i=0; i<noc; i++) {
6137 AliTPCclusterMI *c=clusters[i];
6139 if (TMath::Abs(c->GetLabel(1)) == lab ||
6140 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6143 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6146 Int_t tail=Int_t(0.10*noc);
6149 for (i=1; i<=160&&ind<tail; i++) {
6150 // AliTPCclusterMI *c=clusters[noc-i];
6151 AliTPCclusterMI *c=clusters[i];
6153 if (lab == TMath::Abs(c->GetLabel(0)) ||
6154 lab == TMath::Abs(c->GetLabel(1)) ||
6155 lab == TMath::Abs(c->GetLabel(2))) max++;
6158 if (max < Int_t(0.5*tail)) lab=-lab;
6165 //delete[] clusters;
6169 //__________________________________________________________________________
6170 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6171 //--------------------------------------------------------------------
6172 //This function "cooks" a track label. If label<0, this track is fake.
6173 //--------------------------------------------------------------------
6174 Int_t noc=t->GetNumberOfClusters();
6176 //printf("\nnot founded prolongation\n\n\n");
6182 AliTPCclusterMI *clusters[160];
6184 for (Int_t i=0;i<160;i++) {
6191 for (i=0; i<160 && current<noc; i++) {
6192 if (i<first) continue;
6193 if (i>last) continue;
6194 Int_t index=t->GetClusterIndex2(i);
6195 if (index<=0) continue;
6196 if (index&0x8000) continue;
6198 //clusters[current]=GetClusterMI(index);
6199 if (t->fClusterPointer[i]){
6200 clusters[current]=t->fClusterPointer[i];
6205 if (noc<5) return -1;
6206 Int_t lab=123456789;
6207 for (i=0; i<noc; i++) {
6208 AliTPCclusterMI *c=clusters[i];
6210 lab=TMath::Abs(c->GetLabel(0));
6212 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6218 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6220 for (i=0; i<noc; i++) {
6221 AliTPCclusterMI *c=clusters[i];
6223 if (TMath::Abs(c->GetLabel(1)) == lab ||
6224 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6227 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6230 Int_t tail=Int_t(0.10*noc);
6233 for (i=1; i<=160&&ind<tail; i++) {
6234 // AliTPCclusterMI *c=clusters[noc-i];
6235 AliTPCclusterMI *c=clusters[i];
6237 if (lab == TMath::Abs(c->GetLabel(0)) ||
6238 lab == TMath::Abs(c->GetLabel(1)) ||
6239 lab == TMath::Abs(c->GetLabel(2))) max++;
6242 if (max < Int_t(0.5*tail)) lab=-lab;
6245 // t->SetLabel(lab);
6249 //delete[] clusters;
6253 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6255 //return pad row number for this x
6258 r=fRow[fN-1].GetX();
6259 if (x > r) return fN;
6261 if (x < r) return -1;
6262 return Int_t((x-r)/fPadPitchLength + 0.5);}
6264 r=fRow[fN-1].GetX();
6265 if (x > r) return fN;
6267 if (x < r) return -1;
6268 Double_t r1=fRow[64].GetX();
6270 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6272 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6276 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6278 //return pad row number for given x vector
6279 Float_t phi = TMath::ATan2(x[1],x[0]);
6280 if(phi<0) phi=2.*TMath::Pi()+phi;
6281 // Get the local angle in the sector philoc
6282 const Float_t kRaddeg = 180/3.14159265358979312;
6283 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6284 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6285 return GetRowNumber(localx);
6288 //_________________________________________________________________________
6289 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6290 //-----------------------------------------------------------------------
6291 // Setup inner sector
6292 //-----------------------------------------------------------------------
6294 fAlpha=par->GetInnerAngle();
6295 fAlphaShift=par->GetInnerAngleShift();
6296 fPadPitchWidth=par->GetInnerPadPitchWidth();
6297 fPadPitchLength=par->GetInnerPadPitchLength();
6298 fN=par->GetNRowLow();
6299 fRow=new AliTPCRow[fN];
6300 for (Int_t i=0; i<fN; i++) {
6301 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6302 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6305 fAlpha=par->GetOuterAngle();
6306 fAlphaShift=par->GetOuterAngleShift();
6307 fPadPitchWidth = par->GetOuterPadPitchWidth();
6308 fPadPitchLength = par->GetOuter1PadPitchLength();
6309 f1PadPitchLength = par->GetOuter1PadPitchLength();
6310 f2PadPitchLength = par->GetOuter2PadPitchLength();
6312 fN=par->GetNRowUp();
6313 fRow=new AliTPCRow[fN];
6314 for (Int_t i=0; i<fN; i++) {
6315 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6316 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6321 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6323 // default constructor
6331 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6338 //_________________________________________________________________________
6340 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6341 //-----------------------------------------------------------------------
6342 // Insert a cluster into this pad row in accordence with its y-coordinate
6343 //-----------------------------------------------------------------------
6344 if (fN==kMaxClusterPerRow) {
6345 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6347 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6348 Int_t i=Find(c->GetZ());
6349 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6350 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6351 fIndex[i]=index; fClusters[i]=c; fN++;
6354 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6360 //delete[] fClusterArray;
6361 if (fClusters1) delete []fClusters1;
6362 if (fClusters2) delete []fClusters2;
6369 //___________________________________________________________________
6370 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6371 //-----------------------------------------------------------------------
6372 // Return the index of the nearest cluster
6373 //-----------------------------------------------------------------------
6374 if (fN==0) return 0;
6375 if (z <= fClusters[0]->GetZ()) return 0;
6376 if (z > fClusters[fN-1]->GetZ()) return fN;
6377 Int_t b=0, e=fN-1, m=(b+e)/2;
6378 for (; b<e; m=(b+e)/2) {
6379 if (z > fClusters[m]->GetZ()) b=m+1;
6387 //___________________________________________________________________
6388 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6389 //-----------------------------------------------------------------------
6390 // Return the index of the nearest cluster in z y
6391 //-----------------------------------------------------------------------
6392 Float_t maxdistance = roady*roady + roadz*roadz;
6394 AliTPCclusterMI *cl =0;
6395 for (Int_t i=Find(z-roadz); i<fN; i++) {
6396 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6397 if (c->GetZ() > z+roadz) break;
6398 if ( (c->GetY()-y) > roady ) continue;
6399 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6400 if (maxdistance>distance) {
6401 maxdistance = distance;
6408 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6410 //-----------------------------------------------------------------------
6411 // Return the index of the nearest cluster in z y
6412 //-----------------------------------------------------------------------
6413 Float_t maxdistance = roady*roady + roadz*roadz;
6414 AliTPCclusterMI *cl =0;
6416 //PH Check boundaries. 510 is the size of fFastCluster
6417 Int_t iz1 = Int_t(z-roadz+254.5);
6418 if (iz1<0 || iz1>=510) return cl;
6419 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6420 Int_t iz2 = Int_t(z+roadz+255.5);
6421 if (iz2<0 || iz2>=510) return cl;
6422 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6424 //FindNearest3(y,z,roady,roadz,index);
6425 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6426 for (Int_t i=iz1; i<iz2; i++) {
6427 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6428 if (c->GetZ() > z+roadz) break;
6429 if ( c->GetY()-y > roady ) continue;
6430 if ( y-c->GetY() > roady ) continue;
6431 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6432 if (maxdistance>distance) {
6433 maxdistance = distance;
6436 //roady = TMath::Sqrt(maxdistance);
6444 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6446 //-----------------------------------------------------------------------
6447 // Return the index of the nearest cluster in z y
6448 //-----------------------------------------------------------------------
6449 Float_t maxdistance = roady*roady + roadz*roadz;
6450 // Int_t iz = Int_t(z+255.);
6451 AliTPCclusterMI *cl =0;
6452 for (Int_t i=Find(z-roadz); i<fN; i++) {
6453 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6454 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6455 if (c->GetZ() > z+roadz) break;
6456 if ( c->GetY()-y > roady ) continue;
6457 if ( y-c->GetY() > roady ) continue;
6458 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6459 if (maxdistance>distance) {
6460 maxdistance = distance;
6463 //roady = TMath::Sqrt(maxdistance);
6473 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6477 // return &fTrackPoints[i];