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"
35 #include "AliESDEvent.h"
36 #include "AliESDtrack.h"
37 #include "AliESDVertex.h"
41 #include "AliRunLoader.h"
42 #include "AliTPCClustersRow.h"
43 #include "AliTPCParam.h"
44 #include "AliTPCReconstructor.h"
45 #include "AliTPCpolyTrack.h"
46 #include "AliTPCreco.h"
47 #include "AliTPCseed.h"
48 #include "AliTPCtrackerMI.h"
49 #include "TStopwatch.h"
50 #include "AliTPCReconstructor.h"
52 #include "TTreeStream.h"
53 #include "AliAlignObj.h"
54 #include "AliTrackPointArray.h"
56 //#include "AliTPCTransform.h"
60 ClassImp(AliTPCtrackerMI)
63 class AliTPCFastMath {
66 static Double_t FastAsin(Double_t x);
68 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
71 Double_t AliTPCFastMath::fgFastAsin[20000];
72 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
74 AliTPCFastMath::AliTPCFastMath(){
76 // initialized lookup table;
77 for (Int_t i=0;i<10000;i++){
78 fgFastAsin[2*i] = TMath::ASin(i/10000.);
79 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
83 Double_t AliTPCFastMath::FastAsin(Double_t x){
85 // return asin using lookup table
87 Int_t index = int(x*10000);
88 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
91 Int_t index = int(x*10000);
92 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
94 //__________________________________________________________________
95 AliTPCtrackerMI::AliTPCtrackerMI()
117 // default constructor
120 //_____________________________________________________________________
124 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
126 //update track information using current cluster - track->fCurrentCluster
129 AliTPCclusterMI* c =track->GetCurrentCluster();
130 if (accept>0) track->SetCurrentClusterIndex1(track->GetCurrentClusterIndex1() | 0x8000); //sign not accepted clusters
132 UInt_t i = track->GetCurrentClusterIndex1();
134 Int_t sec=(i&0xff000000)>>24;
135 //Int_t row = (i&0x00ff0000)>>16;
136 track->SetRow((i&0x00ff0000)>>16);
137 track->SetSector(sec);
138 // Int_t index = i&0xFFFF;
139 if (sec>=fParam->GetNInnerSector()) track->SetRow(track->GetRow()+fParam->GetNRowLow());
140 track->SetClusterIndex2(track->GetRow(), i);
141 //track->fFirstPoint = row;
142 //if ( track->fLastPoint<row) track->fLastPoint =row;
143 // if (track->fRow<0 || track->fRow>160) {
144 // printf("problem\n");
146 if (track->GetFirstPoint()>track->GetRow())
147 track->SetFirstPoint(track->GetRow());
148 if (track->GetLastPoint()<track->GetRow())
149 track->SetLastPoint(track->GetRow());
152 track->SetClusterPointer(track->GetRow(),c);
155 Double_t angle2 = track->GetSnp()*track->GetSnp();
157 //SET NEW Track Point
159 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
161 angle2 = TMath::Sqrt(angle2/(1-angle2));
162 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->GetRow()));
164 point.SetSigmaY(c->GetSigmaY2()/track->GetCurrentSigmaY2());
165 point.SetSigmaZ(c->GetSigmaZ2()/track->GetCurrentSigmaZ2());
166 point.SetErrY(sqrt(track->GetErrorY2()));
167 point.SetErrZ(sqrt(track->GetErrorZ2()));
169 point.SetX(track->GetX());
170 point.SetY(track->GetY());
171 point.SetZ(track->GetZ());
172 point.SetAngleY(angle2);
173 point.SetAngleZ(track->GetTgl());
174 if (point.IsShared()){
175 track->SetErrorY2(track->GetErrorY2()*4);
176 track->SetErrorZ2(track->GetErrorZ2()*4);
180 Double_t chi2 = track->GetPredictedChi2(track->GetCurrentCluster());
182 track->SetErrorY2(track->GetErrorY2()*1.3);
183 track->SetErrorY2(track->GetErrorY2()+0.01);
184 track->SetErrorZ2(track->GetErrorZ2()*1.3);
185 track->SetErrorZ2(track->GetErrorZ2()+0.005);
187 if (accept>0) return 0;
188 if (track->GetNumberOfClusters()%20==0){
189 // if (track->fHelixIn){
190 // TClonesArray & larr = *(track->fHelixIn);
191 // Int_t ihelix = larr.GetEntriesFast();
192 // new(larr[ihelix]) AliHelix(*track) ;
195 track->SetNoCluster(0);
196 return track->Update(c,chi2,i);
201 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
202 Float_t cory, Float_t corz)
205 // decide according desired precision to accept given
206 // cluster for tracking
207 Double_t sy2=ErrY2(seed,cluster)*cory;
208 Double_t sz2=ErrZ2(seed,cluster)*corz;
209 //sy2=ErrY2(seed,cluster)*cory;
210 //sz2=ErrZ2(seed,cluster)*cory;
212 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
213 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
215 Double_t rdistancey2 = (seed->GetCurrentCluster()->GetY()-seed->GetY())*
216 (seed->GetCurrentCluster()->GetY()-seed->GetY())/sdistancey2;
217 Double_t rdistancez2 = (seed->GetCurrentCluster()->GetZ()-seed->GetZ())*
218 (seed->GetCurrentCluster()->GetZ()-seed->GetZ())/sdistancez2;
220 Double_t rdistance2 = rdistancey2+rdistancez2;
223 if (rdistance2>16) return 3;
226 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
227 return 2; //suspisiouce - will be changed
229 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
230 // strict cut on overlaped cluster
231 return 2; //suspisiouce - will be changed
233 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
234 && cluster->GetType()<0){
235 seed->SetNFoundable(seed->GetNFoundable()-1);
244 //_____________________________________________________________________________
245 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
247 fkNIS(par->GetNInnerSector()/2),
249 fkNOS(par->GetNOuterSector()/2),
266 //---------------------------------------------------------------------
267 // The main TPC tracker constructor
268 //---------------------------------------------------------------------
269 fInnerSec=new AliTPCSector[fkNIS];
270 fOuterSec=new AliTPCSector[fkNOS];
273 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
274 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
277 Int_t nrowlow = par->GetNRowLow();
278 Int_t nrowup = par->GetNRowUp();
281 for (Int_t i=0;i<nrowlow;i++){
282 fXRow[i] = par->GetPadRowRadiiLow(i);
283 fPadLength[i]= par->GetPadPitchLength(0,i);
284 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
288 for (Int_t i=0;i<nrowup;i++){
289 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
290 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
291 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
294 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
296 //________________________________________________________________________
297 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
318 //------------------------------------
319 // dummy copy constructor
320 //------------------------------------------------------------------
323 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
324 //------------------------------
326 //--------------------------------------------------------------
329 //_____________________________________________________________________________
330 AliTPCtrackerMI::~AliTPCtrackerMI() {
331 //------------------------------------------------------------------
332 // TPC tracker destructor
333 //------------------------------------------------------------------
340 if (fDebugStreamer) delete fDebugStreamer;
343 void AliTPCtrackerMI::SetIO()
347 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
349 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
351 AliTPCtrack *iotrack= new AliTPCtrack;
352 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
358 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESDEvent * event)
374 AliTPCtrack *iotrack= new AliTPCtrack;
375 // iotrack->fHelixIn = new TClonesArray("AliHelix");
376 //iotrack->fHelixOut = new TClonesArray("AliHelix");
377 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
380 if (output && (fDebug&2)){
381 //write the full seed information if specified in debug mode
383 fSeedTree = new TTree("Seeds","Seeds");
384 AliTPCseed * vseed = new AliTPCseed;
386 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
387 arrtr->ExpandCreateFast(160);
388 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
390 vseed->SetPoints(arrtr);
391 vseed->SetEPoints(arre);
392 // vseed->fClusterPoints = arrcl;
393 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
396 fTreeDebug = new TTree("trackDebug","trackDebug");
397 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
398 fTreeDebug->Branch("debug",&arrd,32000,99);
406 void AliTPCtrackerMI::FillESD(TObjArray* arr)
410 //fill esds using updated tracks
412 // write tracks to the event
413 // store index of the track
414 Int_t nseed=arr->GetEntriesFast();
415 //FindKinks(arr,fEvent);
416 for (Int_t i=0; i<nseed; i++) {
417 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
420 // pt->PropagateTo(fParam->GetInnerRadiusLow());
421 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
422 pt->PropagateTo(fParam->GetInnerRadiusLow());
425 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
427 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
428 iotrack.SetTPCPoints(pt->GetPoints());
429 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
430 iotrack.SetV0Indexes(pt->GetV0Indexes());
431 // iotrack.SetTPCpid(pt->fTPCr);
432 //iotrack.SetTPCindex(i);
433 fEvent->AddTrack(&iotrack);
437 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.55) {
439 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
440 iotrack.SetTPCPoints(pt->GetPoints());
441 //iotrack.SetTPCindex(i);
442 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
443 iotrack.SetV0Indexes(pt->GetV0Indexes());
444 // iotrack.SetTPCpid(pt->fTPCr);
445 fEvent->AddTrack(&iotrack);
449 // short tracks - maybe decays
451 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.70) {
452 Int_t found,foundable,shared;
453 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
454 if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2)){
456 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
457 //iotrack.SetTPCindex(i);
458 iotrack.SetTPCPoints(pt->GetPoints());
459 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
460 iotrack.SetV0Indexes(pt->GetV0Indexes());
461 //iotrack.SetTPCpid(pt->fTPCr);
462 fEvent->AddTrack(&iotrack);
467 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.8) {
468 Int_t found,foundable,shared;
469 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
470 if (found<20) continue;
471 if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
474 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
475 iotrack.SetTPCPoints(pt->GetPoints());
476 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
477 iotrack.SetV0Indexes(pt->GetV0Indexes());
478 //iotrack.SetTPCpid(pt->fTPCr);
479 //iotrack.SetTPCindex(i);
480 fEvent->AddTrack(&iotrack);
483 // short tracks - secondaties
485 if ( (pt->GetNumberOfClusters()>30) ) {
486 Int_t found,foundable,shared;
487 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
488 if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
490 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
491 iotrack.SetTPCPoints(pt->GetPoints());
492 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
493 iotrack.SetV0Indexes(pt->GetV0Indexes());
494 //iotrack.SetTPCpid(pt->fTPCr);
495 //iotrack.SetTPCindex(i);
496 fEvent->AddTrack(&iotrack);
501 if ( (pt->GetNumberOfClusters()>15)) {
502 Int_t found,foundable,shared;
503 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
504 if (found<15) continue;
505 if (foundable<=0) continue;
506 if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
507 if (float(found)/float(foundable)<0.8) continue;
510 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
511 iotrack.SetTPCPoints(pt->GetPoints());
512 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
513 iotrack.SetV0Indexes(pt->GetV0Indexes());
514 // iotrack.SetTPCpid(pt->fTPCr);
515 //iotrack.SetTPCindex(i);
516 fEvent->AddTrack(&iotrack);
521 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
524 void AliTPCtrackerMI::WriteTracks(TTree * tree)
527 // write tracks from seed array to selected tree
531 AliTPCtrack *iotrack= new AliTPCtrack;
532 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
537 void AliTPCtrackerMI::WriteTracks()
540 // write tracks to the given output tree -
541 // output specified with SetIO routine
548 AliTPCtrack *iotrack= 0;
549 Int_t nseed=fSeeds->GetEntriesFast();
550 //for (Int_t i=0; i<nseed; i++) {
551 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
552 // if (iotrack) break;
554 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
555 TBranch * br = fOutput->GetBranch("tracks");
556 br->SetAddress(&iotrack);
558 for (Int_t i=0; i<nseed; i++) {
559 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
561 AliTPCtrack * track = new AliTPCtrack(*pt);
564 // br->SetAddress(&iotrack);
569 //fOutput->GetDirectory()->cd();
575 //write the full seed information if specified in debug mode
577 AliTPCseed * vseed = new AliTPCseed;
579 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
580 arrtr->ExpandCreateFast(160);
581 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
582 //arrcl->ExpandCreateFast(160);
583 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
585 vseed->SetPoints(arrtr);
586 vseed->SetEPoints(arre);
587 // vseed->fClusterPoints = arrcl;
588 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
589 TBranch * brseed = fSeedTree->GetBranch("seeds");
591 Int_t nseed=fSeeds->GetEntriesFast();
593 for (Int_t i=0; i<nseed; i++) {
594 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
596 pt->SetPoints(arrtr);
597 // pt->fClusterPoints = arrcl;
598 pt->SetEPoints(arre);
601 brseed->SetAddress(&vseed);
605 // pt->fClusterPoints = 0;
608 if (fTreeDebug) fTreeDebug->Write();
616 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
619 //seed->SetErrorY2(0.1);
621 //calculate look-up table at the beginning
622 static Bool_t ginit = kFALSE;
623 static Float_t gnoise1,gnoise2,gnoise3;
624 static Float_t ggg1[10000];
625 static Float_t ggg2[10000];
626 static Float_t ggg3[10000];
627 static Float_t glandau1[10000];
628 static Float_t glandau2[10000];
629 static Float_t glandau3[10000];
631 static Float_t gcor01[500];
632 static Float_t gcor02[500];
633 static Float_t gcorp[500];
638 for (Int_t i=1;i<500;i++){
639 Float_t rsigma = float(i)/100.;
640 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
641 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
642 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
646 for (Int_t i=3;i<10000;i++){
650 Float_t amp = float(i);
651 Float_t padlength =0.75;
652 gnoise1 = 0.0004/padlength;
653 Float_t nel = 0.268*amp;
654 Float_t nprim = 0.155*amp;
655 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
656 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
657 if (glandau1[i]>1) glandau1[i]=1;
658 glandau1[i]*=padlength*padlength/12.;
662 gnoise2 = 0.0004/padlength;
665 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
666 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
667 if (glandau2[i]>1) glandau2[i]=1;
668 glandau2[i]*=padlength*padlength/12.;
673 gnoise3 = 0.0004/padlength;
676 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
677 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
678 if (glandau3[i]>1) glandau3[i]=1;
679 glandau3[i]*=padlength*padlength/12.;
687 Int_t amp = int(TMath::Abs(cl->GetQ()));
689 seed->SetErrorY2(1.);
693 Float_t z = TMath::Abs(fParam->GetZLength(0)-TMath::Abs(seed->GetZ()));
694 Int_t ctype = cl->GetType();
695 Float_t padlength= GetPadPitchLength(seed->GetRow());
696 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
697 angle2 = angle2/(1-angle2);
700 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->GetCurrentSigmaY2()));
703 if (fSectors==fInnerSec){
705 res = ggg1[amp]*z+glandau1[amp]*angle2;
706 if (ctype==0) res *= gcor01[rsigmay];
709 res*= gcorp[rsigmay];
715 res = ggg2[amp]*z+glandau2[amp]*angle2;
716 if (ctype==0) res *= gcor02[rsigmay];
719 res*= gcorp[rsigmay];
724 res = ggg3[amp]*z+glandau3[amp]*angle2;
725 if (ctype==0) res *= gcor02[rsigmay];
728 res*= gcorp[rsigmay];
735 res*=2.4; // overestimate error 2 times
742 seed->SetErrorY2(res);
750 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
753 //seed->SetErrorY2(0.1);
755 //calculate look-up table at the beginning
756 static Bool_t ginit = kFALSE;
757 static Float_t gnoise1,gnoise2,gnoise3;
758 static Float_t ggg1[10000];
759 static Float_t ggg2[10000];
760 static Float_t ggg3[10000];
761 static Float_t glandau1[10000];
762 static Float_t glandau2[10000];
763 static Float_t glandau3[10000];
765 static Float_t gcor01[1000];
766 static Float_t gcor02[1000];
767 static Float_t gcorp[1000];
772 for (Int_t i=1;i<1000;i++){
773 Float_t rsigma = float(i)/100.;
774 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
775 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
776 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
780 for (Int_t i=3;i<10000;i++){
784 Float_t amp = float(i);
785 Float_t padlength =0.75;
786 gnoise1 = 0.0004/padlength;
787 Float_t nel = 0.268*amp;
788 Float_t nprim = 0.155*amp;
789 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
790 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
791 if (glandau1[i]>1) glandau1[i]=1;
792 glandau1[i]*=padlength*padlength/12.;
796 gnoise2 = 0.0004/padlength;
799 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
800 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
801 if (glandau2[i]>1) glandau2[i]=1;
802 glandau2[i]*=padlength*padlength/12.;
807 gnoise3 = 0.0004/padlength;
810 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
811 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
812 if (glandau3[i]>1) glandau3[i]=1;
813 glandau3[i]*=padlength*padlength/12.;
821 Int_t amp = int(TMath::Abs(cl->GetQ()));
823 seed->SetErrorY2(1.);
827 Float_t z = TMath::Abs(fParam->GetZLength(0)-TMath::Abs(seed->GetZ()));
828 Int_t ctype = cl->GetType();
829 Float_t padlength= GetPadPitchLength(seed->GetRow());
831 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
832 // if (angle2<0.6) angle2 = 0.6;
833 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
836 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->GetCurrentSigmaZ2()));
839 if (fSectors==fInnerSec){
841 res = ggg1[amp]*z+glandau1[amp]*angle2;
842 if (ctype==0) res *= gcor01[rsigmaz];
845 res*= gcorp[rsigmaz];
851 res = ggg2[amp]*z+glandau2[amp]*angle2;
852 if (ctype==0) res *= gcor02[rsigmaz];
855 res*= gcorp[rsigmaz];
860 res = ggg3[amp]*z+glandau3[amp]*angle2;
861 if (ctype==0) res *= gcor02[rsigmaz];
864 res*= gcorp[rsigmaz];
873 if ((ctype<0) &&<70){
881 seed->SetErrorZ2(res);
888 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
891 //seed->SetErrorZ2(0.1);
895 Float_t z = TMath::Abs(fParam->GetZLength(0)-TMath::Abs(seed->GetZ()));
897 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
898 Int_t ctype = cl->GetType();
899 Float_t amp = TMath::Abs(cl->GetQ());
904 Float_t landau=2 ; //landau fluctuation part
905 Float_t gg=2; // gg fluctuation part
906 Float_t padlength= GetPadPitchLength(seed->GetX());
908 if (fSectors==fInnerSec){
909 snoise2 = 0.0004/padlength;
912 gg = (2+0.001*nel/(padlength*padlength))/nel;
913 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
914 if (landau>1) landau=1;
917 snoise2 = 0.0004/padlength;
920 gg = (2+0.0008*nel/(padlength*padlength))/nel;
921 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
922 if (landau>1) landau=1;
924 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
927 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
928 angle2 = TMath::Sqrt((1-angle2));
929 if (angle2<0.6) angle2 = 0.6;
932 Float_t angle = seed->GetTgl()/angle2;
933 Float_t angular = landau*angle*angle*padlength*padlength/12.;
934 Float_t res = sdiff + angular;
937 if ((ctype==0) && (fSectors ==fOuterSec))
938 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
940 if ((ctype==0) && (fSectors ==fInnerSec))
941 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
945 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
951 if ((ctype<0) &&<70){
959 seed->SetErrorZ2(res);
967 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
969 //rotate to track "local coordinata
970 Float_t x = seed->GetX();
971 Float_t y = seed->GetY();
972 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
975 seed->SetRelativeSector((seed->GetRelativeSector()+1) % fN);
976 if (!seed->Rotate(fSectors->GetAlpha()))
978 } else if (y <-ymax) {
979 seed->SetRelativeSector((seed->GetRelativeSector()-1+fN) % fN);
980 if (!seed->Rotate(-fSectors->GetAlpha()))
988 //_____________________________________________________________________________
989 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
990 Double_t x2,Double_t y2,
991 Double_t x3,Double_t y3)
993 //-----------------------------------------------------------------
994 // Initial approximation of the track curvature
995 //-----------------------------------------------------------------
996 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
997 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
998 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
999 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1000 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1002 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1003 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1004 return -xr*yr/sqrt(xr*xr+yr*yr);
1009 //_____________________________________________________________________________
1010 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1011 Double_t x2,Double_t y2,
1012 Double_t x3,Double_t y3)
1014 //-----------------------------------------------------------------
1015 // Initial approximation of the track curvature
1016 //-----------------------------------------------------------------
1022 Double_t det = x3*y2-x2*y3;
1027 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1028 Double_t x0 = x3*0.5-y3*u;
1029 Double_t y0 = y3*0.5+x3*u;
1030 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1036 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1037 Double_t x2,Double_t y2,
1038 Double_t x3,Double_t y3)
1040 //-----------------------------------------------------------------
1041 // Initial approximation of the track curvature
1042 //-----------------------------------------------------------------
1048 Double_t det = x3*y2-x2*y3;
1053 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1054 Double_t x0 = x3*0.5-y3*u;
1055 Double_t y0 = y3*0.5+x3*u;
1056 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1065 //_____________________________________________________________________________
1066 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1067 Double_t x2,Double_t y2,
1068 Double_t x3,Double_t y3)
1070 //-----------------------------------------------------------------
1071 // Initial approximation of the track curvature times center of curvature
1072 //-----------------------------------------------------------------
1073 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1074 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1075 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1076 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1077 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1079 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1081 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1084 //_____________________________________________________________________________
1085 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1086 Double_t x2,Double_t y2,
1087 Double_t z1,Double_t z2)
1089 //-----------------------------------------------------------------
1090 // Initial approximation of the tangent of the track dip angle
1091 //-----------------------------------------------------------------
1092 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1096 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1097 Double_t x2,Double_t y2,
1098 Double_t z1,Double_t z2, Double_t c)
1100 //-----------------------------------------------------------------
1101 // Initial approximation of the tangent of the track dip angle
1102 //-----------------------------------------------------------------
1106 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1108 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1109 if (TMath::Abs(d*c*0.5)>1) return 0;
1110 // Double_t angle2 = TMath::ASin(d*c*0.5);
1111 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1112 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1114 angle2 = (z1-z2)*c/(angle2*2.);
1118 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1119 {//-----------------------------------------------------------------
1120 // This function find proloncation of a track to a reference plane x=x2.
1121 //-----------------------------------------------------------------
1125 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1129 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1130 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1134 Double_t dy = dx*(c1+c2)/(r1+r2);
1137 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1139 if (TMath::Abs(delta)>0.01){
1140 dz = x[3]*TMath::ASin(delta)/x[4];
1142 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1145 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1153 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1158 return LoadClusters();
1161 Int_t AliTPCtrackerMI::LoadClusters()
1164 // load clusters to the memory
1165 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1166 clrow->SetClass("AliTPCclusterMI");
1168 clrow->GetArray()->ExpandCreateFast(10000);
1170 // TTree * tree = fClustersArray.GetTree();
1172 TTree * tree = fInput;
1173 TBranch * br = tree->GetBranch("Segment");
1174 br->SetAddress(&clrow);
1176 Int_t j=Int_t(tree->GetEntries());
1177 for (Int_t i=0; i<j; i++) {
1181 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1182 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1183 Transform((AliTPCclusterMI*)(clrow->GetArray()->At(icl)));
1186 AliTPCRow * tpcrow=0;
1189 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1193 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1194 left = (sec-fkNIS*2)/fkNOS;
1197 tpcrow->SetN1(clrow->GetArray()->GetEntriesFast());
1198 tpcrow->SetClusters1(new AliTPCclusterMI[tpcrow->GetN1()]);
1199 for (Int_t i=0;i<tpcrow->GetN1();i++)
1200 tpcrow->SetCluster1(i, *(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
1203 tpcrow->SetN2(clrow->GetArray()->GetEntriesFast());
1204 tpcrow->SetClusters2(new AliTPCclusterMI[tpcrow->GetN2()]);
1205 for (Int_t i=0;i<tpcrow->GetN2();i++)
1206 tpcrow->SetCluster2(i,*(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
1217 void AliTPCtrackerMI::UnloadClusters()
1220 // unload clusters from the memory
1222 Int_t nrows = fOuterSec->GetNRows();
1223 for (Int_t sec = 0;sec<fkNOS;sec++)
1224 for (Int_t row = 0;row<nrows;row++){
1225 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1227 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1228 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1230 tpcrow->ResetClusters();
1233 nrows = fInnerSec->GetNRows();
1234 for (Int_t sec = 0;sec<fkNIS;sec++)
1235 for (Int_t row = 0;row<nrows;row++){
1236 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1238 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1239 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1241 tpcrow->ResetClusters();
1247 void AliTPCtrackerMI::Transform(AliTPCclusterMI * cluster){
1251 // AliTPCTransform trafo;
1253 // Double_t x[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1254 // Int_t i[1]={cluster->GetDetector()};
1256 // trafo.Transform(x,i,0,1);
1258 // cluster->SetX(x[0]);
1259 // cluster->SetY(x[1]);
1260 // cluster->SetZ(x[2]);
1269 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1270 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
1272 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1273 Double_t posC[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1274 if (mat) mat->LocalToMaster(pos,posC);
1276 // chack Loading of Geo matrices from GeoManager - TEMPORARY FIX
1278 //cluster->SetX(posC[0]);
1279 //cluster->SetY(posC[1]);
1280 //cluster->SetZ(posC[2]);
1283 //_____________________________________________________________________________
1284 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1285 //-----------------------------------------------------------------
1286 // This function fills outer TPC sectors with clusters.
1287 //-----------------------------------------------------------------
1288 Int_t nrows = fOuterSec->GetNRows();
1290 for (Int_t sec = 0;sec<fkNOS;sec++)
1291 for (Int_t row = 0;row<nrows;row++){
1292 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1293 Int_t sec2 = sec+2*fkNIS;
1295 Int_t ncl = tpcrow->GetN1();
1297 AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
1298 index=(((sec2<<8)+row)<<16)+ncl;
1299 tpcrow->InsertCluster(c,index);
1302 ncl = tpcrow->GetN2();
1304 AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
1305 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1306 tpcrow->InsertCluster(c,index);
1309 // write indexes for fast acces
1311 for (Int_t i=0;i<510;i++)
1312 tpcrow->SetFastCluster(i,-1);
1313 for (Int_t i=0;i<tpcrow->GetN();i++){
1314 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1315 tpcrow->SetFastCluster(zi,i); // write index
1318 for (Int_t i=0;i<510;i++){
1319 if (tpcrow->GetFastCluster(i)<0)
1320 tpcrow->SetFastCluster(i,last);
1322 last = tpcrow->GetFastCluster(i);
1331 //_____________________________________________________________________________
1332 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1333 //-----------------------------------------------------------------
1334 // This function fills inner TPC sectors with clusters.
1335 //-----------------------------------------------------------------
1336 Int_t nrows = fInnerSec->GetNRows();
1338 for (Int_t sec = 0;sec<fkNIS;sec++)
1339 for (Int_t row = 0;row<nrows;row++){
1340 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1343 Int_t ncl = tpcrow->GetN1();
1345 AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
1346 index=(((sec<<8)+row)<<16)+ncl;
1347 tpcrow->InsertCluster(c,index);
1350 ncl = tpcrow->GetN2();
1352 AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
1353 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1354 tpcrow->InsertCluster(c,index);
1357 // write indexes for fast acces
1359 for (Int_t i=0;i<510;i++)
1360 tpcrow->SetFastCluster(i,-1);
1361 for (Int_t i=0;i<tpcrow->GetN();i++){
1362 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1363 tpcrow->SetFastCluster(zi,i); // write index
1366 for (Int_t i=0;i<510;i++){
1367 if (tpcrow->GetFastCluster(i)<0)
1368 tpcrow->SetFastCluster(i,last);
1370 last = tpcrow->GetFastCluster(i);
1382 //_________________________________________________________________________
1383 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1384 //--------------------------------------------------------------------
1385 // Return pointer to a given cluster
1386 //--------------------------------------------------------------------
1387 if (index<0) return 0; // no cluster
1388 Int_t sec=(index&0xff000000)>>24;
1389 Int_t row=(index&0x00ff0000)>>16;
1390 Int_t ncl=(index&0x00007fff)>>00;
1392 const AliTPCRow * tpcrow=0;
1393 AliTPCclusterMI * clrow =0;
1395 if (sec<0 || sec>=fkNIS*4) {
1396 AliWarning(Form("Wrong sector %d",sec));
1401 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1402 if (tpcrow==0) return 0;
1405 if (tpcrow->GetN1()<=ncl) return 0;
1406 clrow = tpcrow->GetClusters1();
1409 if (tpcrow->GetN2()<=ncl) return 0;
1410 clrow = tpcrow->GetClusters2();
1414 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1415 if (tpcrow==0) return 0;
1417 if (sec-2*fkNIS<fkNOS) {
1418 if (tpcrow->GetN1()<=ncl) return 0;
1419 clrow = tpcrow->GetClusters1();
1422 if (tpcrow->GetN2()<=ncl) return 0;
1423 clrow = tpcrow->GetClusters2();
1427 return &(clrow[ncl]);
1433 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1434 //-----------------------------------------------------------------
1435 // This function tries to find a track prolongation to next pad row
1436 //-----------------------------------------------------------------
1438 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1439 AliTPCclusterMI *cl=0;
1440 Int_t tpcindex= t.GetClusterIndex2(nr);
1442 // update current shape info every 5 pad-row
1443 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1447 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1449 if (tpcindex==-1) return 0; //track in dead zone
1451 cl = t.GetClusterPointer(nr);
1452 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1453 t.SetCurrentClusterIndex1(tpcindex);
1456 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1457 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1459 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1460 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1462 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1463 Double_t rotation = angle-t.GetAlpha();
1464 t.SetRelativeSector(relativesector);
1465 if (!t.Rotate(rotation)) return 0;
1467 if (!t.PropagateTo(x)) return 0;
1469 t.SetCurrentCluster(cl);
1471 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1472 if ((tpcindex&0x8000)==0) accept =0;
1474 //if founded cluster is acceptible
1475 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1476 t.SetErrorY2(t.GetErrorY2()+0.03);
1477 t.SetErrorZ2(t.GetErrorZ2()+0.03);
1478 t.SetErrorY2(t.GetErrorY2()*3);
1479 t.SetErrorZ2(t.GetErrorZ2()*3);
1481 t.SetNFoundable(t.GetNFoundable()+1);
1482 UpdateTrack(&t,accept);
1487 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1489 // not look for new cluster during refitting
1490 t.SetNFoundable(t.GetNFoundable()+1);
1495 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
1496 Double_t y=t.GetYat(x);
1497 if (TMath::Abs(y)>ymax){
1499 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1500 if (!t.Rotate(fSectors->GetAlpha()))
1502 } else if (y <-ymax) {
1503 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1504 if (!t.Rotate(-fSectors->GetAlpha()))
1510 if (!t.PropagateTo(x)) {
1511 if (fIteration==0) t.SetRemoval(10);
1515 Double_t z=t.GetZ();
1518 if (!IsActive(t.GetRelativeSector(),nr)) {
1520 t.SetClusterIndex2(nr,-1);
1523 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1524 Bool_t isActive = IsActive(t.GetRelativeSector(),nr);
1525 Bool_t isActive2 = (nr>=fInnerSec->GetNRows()) ? fOuterSec[t.GetRelativeSector()][nr-fInnerSec->GetNRows()].GetN()>0:fInnerSec[t.GetRelativeSector()][nr].GetN()>0;
1527 if (!isActive || !isActive2) return 0;
1529 const AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1530 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1532 Double_t roadz = 1.;
1534 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1536 t.SetClusterIndex2(nr,-1);
1541 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength(0) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1542 t.SetNFoundable(t.GetNFoundable()+1);
1548 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1549 cl = krow.FindNearest2(y,z,roady,roadz,index);
1550 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));
1553 t.SetCurrentCluster(cl);
1555 if (fIteration==2&&cl->IsUsed(10)) return 0;
1556 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1557 if (fIteration==2&&cl->IsUsed(11)) {
1558 t.SetErrorY2(t.GetErrorY2()+0.03);
1559 t.SetErrorZ2(t.GetErrorZ2()+0.03);
1560 t.SetErrorY2(t.GetErrorY2()*3);
1561 t.SetErrorZ2(t.GetErrorZ2()*3);
1564 if (t.fCurrentCluster->IsUsed(10)){
1569 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1575 if (accept<3) UpdateTrack(&t,accept);
1578 if ( fIteration==0 && t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) t.SetRemoval(10);
1584 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1585 //-----------------------------------------------------------------
1586 // This function tries to find a track prolongation to next pad row
1587 //-----------------------------------------------------------------
1589 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1591 if (!t.GetProlongation(x,y,z)) {
1597 if (TMath::Abs(y)>ymax){
1600 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1601 if (!t.Rotate(fSectors->GetAlpha()))
1603 } else if (y <-ymax) {
1604 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1605 if (!t.Rotate(-fSectors->GetAlpha()))
1608 if (!t.PropagateTo(x)) {
1611 t.GetProlongation(x,y,z);
1614 // update current shape info every 3 pad-row
1615 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.GetCurrentSigmaY2()<0.0001) ){
1616 // t.fCurrentSigmaY = GetSigmaY(&t);
1617 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1621 AliTPCclusterMI *cl=0;
1626 const AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1627 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1629 Double_t roadz = 1.;
1632 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1634 t.SetClusterIndex2(row,-1);
1639 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1643 if ((cl==0)&&(krow)) {
1644 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1645 cl = krow.FindNearest2(y,z,roady,roadz,index);
1647 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));
1651 t.SetCurrentCluster(cl);
1652 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1654 t.SetClusterIndex2(row,index);
1655 t.SetClusterPointer(row, cl);
1663 //_________________________________________________________________________
1664 Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1666 // Get track space point by index
1667 // return false in case the cluster doesn't exist
1668 AliTPCclusterMI *cl = GetClusterMI(index);
1669 if (!cl) return kFALSE;
1670 Int_t sector = (index&0xff000000)>>24;
1671 // Int_t row = (index&0x00ff0000)>>16;
1673 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1674 xyz[0] = cl->GetX();
1675 xyz[1] = cl->GetY();
1676 xyz[2] = cl->GetZ();
1678 fParam->AdjustCosSin(sector,cos,sin);
1679 Float_t x = cos*xyz[0]-sin*xyz[1];
1680 Float_t y = cos*xyz[1]+sin*xyz[0];
1682 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1683 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1684 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1685 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1686 cov[0] = sin*sin*sigmaY2;
1687 cov[1] = -sin*cos*sigmaY2;
1689 cov[3] = cos*cos*sigmaY2;
1692 p.SetXYZ(x,y,xyz[2],cov);
1693 AliGeomManager::ELayerID iLayer;
1695 if (sector < fParam->GetNInnerSector()) {
1696 iLayer = AliGeomManager::kTPC1;
1700 iLayer = AliGeomManager::kTPC2;
1701 idet = sector - fParam->GetNInnerSector();
1703 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet);
1704 p.SetVolumeID(volid);
1710 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1711 //-----------------------------------------------------------------
1712 // This function tries to find a track prolongation to next pad row
1713 //-----------------------------------------------------------------
1714 t.SetCurrentCluster(0);
1715 t.SetCurrentClusterIndex1(0);
1717 Double_t xt=t.GetX();
1718 Int_t row = GetRowNumber(xt)-1;
1719 Double_t ymax= GetMaxY(nr);
1721 if (row < nr) return 1; // don't prolongate if not information until now -
1722 // if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1724 // return 0; // not prolongate strongly inclined tracks
1726 // if (TMath::Abs(t.GetSnp())>0.95) {
1728 // return 0; // not prolongate strongly inclined tracks
1729 // }// patch 28 fev 06
1731 Double_t x= GetXrow(nr);
1733 //t.PropagateTo(x+0.02);
1734 //t.PropagateTo(x+0.01);
1735 if (!t.PropagateTo(x)){
1742 if (TMath::Abs(y)>ymax){
1744 t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
1745 if (!t.Rotate(fSectors->GetAlpha()))
1747 } else if (y <-ymax) {
1748 t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
1749 if (!t.Rotate(-fSectors->GetAlpha()))
1752 // if (!t.PropagateTo(x)){
1759 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
1761 if (!IsActive(t.GetRelativeSector(),nr)) {
1763 t.SetClusterIndex2(nr,-1);
1766 //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
1768 AliTPCRow &krow=GetRow(t.GetRelativeSector(),nr);
1770 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
1772 t.SetClusterIndex2(nr,-1);
1777 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.SetNFoundable(t.GetNFoundable()+1);
1783 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1784 // t.fCurrentSigmaY = GetSigmaY(&t);
1785 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1789 AliTPCclusterMI *cl=0;
1792 Double_t roady = 1.;
1793 Double_t roadz = 1.;
1797 index = t.GetClusterIndex2(nr);
1798 if ( (index>0) && (index&0x8000)==0){
1799 cl = t.GetClusterPointer(nr);
1800 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1801 t.SetCurrentClusterIndex1(index);
1803 t.SetCurrentCluster(cl);
1809 // if (index<0) return 0;
1810 UInt_t uindex = TMath::Abs(index);
1813 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1814 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
1817 if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(uindex));
1818 t.SetCurrentCluster(cl);
1824 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1825 //-----------------------------------------------------------------
1826 // This function tries to find a track prolongation to next pad row
1827 //-----------------------------------------------------------------
1829 //update error according neighborhoud
1831 if (t.GetCurrentCluster()) {
1833 Int_t accept = AcceptCluster(&t,t.GetCurrentCluster(),1.);
1835 if (t.GetCurrentCluster()->IsUsed(10)){
1840 t.SetNShared(t.GetNShared()+1);
1841 if (t.GetNShared()>0.7*t.GetNumberOfClusters()) {
1846 if (fIteration>0) accept = 0;
1847 if (accept<3) UpdateTrack(&t,accept);
1851 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.SetRemoval(10);
1852 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.SetRemoval(10);
1854 if (( (t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) || t.GetNoCluster()>15)) t.SetRemoval(10);
1862 //_____________________________________________________________________________
1863 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1864 //-----------------------------------------------------------------
1865 // This function tries to find a track prolongation.
1866 //-----------------------------------------------------------------
1867 Double_t xt=t.GetX();
1869 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1870 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1871 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1873 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1875 Int_t first = GetRowNumber(xt)-1;
1876 for (Int_t nr= first; nr>=rf; nr-=step) {
1878 if (t.GetKinkIndexes()[0]>0){
1879 for (Int_t i=0;i<3;i++){
1880 Int_t index = t.GetKinkIndexes()[i];
1881 if (index==0) break;
1882 if (index<0) continue;
1884 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1886 printf("PROBLEM\n");
1889 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
1891 AliExternalTrackParam paramd(t);
1892 kink->SetDaughter(paramd);
1893 kink->SetStatus(2,5);
1900 if (nr==80) t.UpdateReference();
1901 if (nr<fInnerSec->GetNRows())
1902 fSectors = fInnerSec;
1904 fSectors = fOuterSec;
1905 if (FollowToNext(t,nr)==0)
1914 //_____________________________________________________________________________
1915 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1916 //-----------------------------------------------------------------
1917 // This function tries to find a track prolongation.
1918 //-----------------------------------------------------------------
1919 Double_t xt=t.GetX();
1921 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1922 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1923 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1924 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1926 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1928 if (FollowToNextFast(t,nr)==0)
1929 if (!t.IsActive()) return 0;
1939 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1940 //-----------------------------------------------------------------
1941 // This function tries to find a track prolongation.
1942 //-----------------------------------------------------------------
1944 Double_t xt=t.GetX();
1945 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1946 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1947 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1948 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
1950 Int_t first = t.GetFirstPoint();
1951 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
1953 if (first<0) first=0;
1954 for (Int_t nr=first; nr<=rf; nr++) {
1955 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
1956 if (t.GetKinkIndexes()[0]<0){
1957 for (Int_t i=0;i<3;i++){
1958 Int_t index = t.GetKinkIndexes()[i];
1959 if (index==0) break;
1960 if (index>0) continue;
1961 index = TMath::Abs(index);
1962 AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
1964 printf("PROBLEM\n");
1967 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
1969 AliExternalTrackParam paramm(t);
1970 kink->SetMother(paramm);
1971 kink->SetStatus(2,1);
1978 if (nr<fInnerSec->GetNRows())
1979 fSectors = fInnerSec;
1981 fSectors = fOuterSec;
1992 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
2000 Float_t dz2 =(s1->GetZ() - s2->GetZ());
2003 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
2005 Float_t distance = TMath::Sqrt(dz2+dy2);
2006 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
2009 Int_t firstpoint = TMath::Min(s1->GetFirstPoint(),s2->GetFirstPoint());
2010 Int_t lastpoint = TMath::Max(s1->GetLastPoint(),s2->GetLastPoint());
2015 if (firstpoint>lastpoint) {
2016 firstpoint =lastpoint;
2021 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
2022 if (s1->GetClusterIndex2(i)>0) sum1++;
2023 if (s2->GetClusterIndex2(i)>0) sum2++;
2024 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
2028 if (sum<5) return 0;
2030 Float_t summin = TMath::Min(sum1+1,sum2+1);
2031 Float_t ratio = (sum+1)/Float_t(summin);
2035 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
2039 Float_t thetaCut = 0.2;//+10.*TMath::Sqrt(s1->GetSigmaTglZ()+ s2->GetSigmaTglZ());
2040 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>thetaCut) return;
2041 Float_t minCl = TMath::Min(s1->GetNumberOfClusters(),s2->GetNumberOfClusters());
2042 Int_t cutN0 = TMath::Max(5,TMath::Nint(0.1*minCl));
2047 //Int_t firstpoint = TMath::Max(s1->GetFirstPoint(),s2->GetFirstPoint());
2048 //Int_t lastpoint = TMath::Min(s1->GetLastPoint(),s2->GetLastPoint());
2049 Int_t firstpoint = 0;
2050 Int_t lastpoint = 160;
2052 // if (firstpoint>=lastpoint-5) return;;
2054 for (Int_t i=firstpoint;i<lastpoint;i++){
2055 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
2056 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
2058 s1->SetSharedMapBit(i, kTRUE);
2059 s2->SetSharedMapBit(i, kTRUE);
2061 if (s1->GetClusterIndex2(i)>0)
2062 s1->SetClusterMapBit(i, kTRUE);
2064 if (sumshared>cutN0){
2067 for (Int_t i=firstpoint;i<lastpoint;i++){
2068 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
2069 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
2070 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
2071 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
2072 if (s1->IsActive()&&s2->IsActive()){
2073 p1->SetShared(kTRUE);
2074 p2->SetShared(kTRUE);
2080 if (sumshared>cutN0){
2081 for (Int_t i=0;i<4;i++){
2082 if (s1->GetOverlapLabel(3*i)==0){
2083 s1->SetOverlapLabel(3*i, s2->GetLabel());
2084 s1->SetOverlapLabel(3*i+1,sumshared);
2085 s1->SetOverlapLabel(3*i+2,s2->GetUniqueID());
2089 for (Int_t i=0;i<4;i++){
2090 if (s2->GetOverlapLabel(3*i)==0){
2091 s2->SetOverlapLabel(3*i, s1->GetLabel());
2092 s2->SetOverlapLabel(3*i+1,sumshared);
2093 s2->SetOverlapLabel(3*i+2,s1->GetUniqueID());
2100 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2103 //sort trackss according sectors
2105 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2106 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2108 //if (pt) RotateToLocal(pt);
2112 arr->Sort(); // sorting according z
2113 arr->Expand(arr->GetEntries());
2116 Int_t nseed=arr->GetEntriesFast();
2117 for (Int_t i=0; i<nseed; i++) {
2118 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2120 for (Int_t j=0;j<=12;j++){
2121 pt->SetOverlapLabel(j,0);
2124 for (Int_t i=0; i<nseed; i++) {
2125 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2127 if (pt->GetRemoval()>10) continue;
2128 for (Int_t j=i+1; j<nseed; j++){
2129 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2131 if (pt2->GetRemoval()<=10) {
2132 if ( TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>0) break;
2139 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2142 //sort trackss according sectors
2145 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2148 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2149 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2154 arr->Sort(); // sorting according z
2155 arr->Expand(arr->GetEntries());
2157 //reset overlap labels
2159 Int_t nseed=arr->GetEntriesFast();
2160 for (Int_t i=0; i<nseed; i++) {
2161 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2164 for (Int_t j=0;j<=12;j++){
2165 pt->SetOverlapLabel(j,0);
2169 //sign shared tracks
2170 for (Int_t i=0; i<nseed; i++) {
2171 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2173 if (pt->GetRemoval()>10) continue;
2174 Float_t deltac = pt->GetC()*0.1;
2175 for (Int_t j=i+1; j<nseed; j++){
2176 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2178 if (pt2->GetRemoval()<=10) {
2179 if ( TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>0) break;
2180 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2181 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2188 // remove highly shared tracks
2189 for (Int_t i=0; i<nseed; i++) {
2190 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2192 if (pt->GetRemoval()>10) continue;
2195 for (Int_t j=0;j<4;j++){
2196 sumshared = pt->GetOverlapLabel(j*3+1);
2198 Float_t factor = factor1;
2199 if (pt->GetRemoval()>0) factor = factor2;
2200 if (sumshared/pt->GetNumberOfClusters()>factor){
2201 for (Int_t j=0;j<4;j++){
2202 if (pt->GetOverlapLabel(3*j)==0) continue;
2203 if (pt->GetOverlapLabel(3*j+1)<5) continue;
2204 if (pt->GetRemoval()==removalindex) continue;
2205 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->GetOverlapLabel(3*j+2));
2207 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2208 // pt->fRemoval = removalindex;
2209 delete arr->RemoveAt(i);
2217 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2226 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2229 //sort tracks in array according mode criteria
2230 Int_t nseed = arr->GetEntriesFast();
2231 for (Int_t i=0; i<nseed; i++) {
2232 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2242 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2245 //Loop over all tracks and remove "overlaps"
2248 Int_t nseed = arr->GetEntriesFast();
2251 for (Int_t i=0; i<nseed; i++) {
2252 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2254 delete arr->RemoveAt(i);
2258 pt->SetBSigned(kFALSE);
2262 nseed = arr->GetEntriesFast();
2269 for (Int_t i=0; i<nseed; i++) {
2270 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2274 Int_t found,foundable,shared;
2276 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2278 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2280 Double_t factor = factor2;
2281 if (pt->GetBConstrain()) factor = factor1;
2283 if ((Float_t(shared)/Float_t(found))>factor){
2284 pt->Desactivate(removalindex);
2289 for (Int_t i=0; i<160; i++) {
2290 Int_t index=pt->GetClusterIndex2(i);
2291 if (index<0 || index&0x8000 ) continue;
2292 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2294 // if (!c->IsUsed(10)) c->Use(10);
2295 //if (pt->IsActive())
2304 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2309 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2312 //Loop over all tracks and remove "overlaps"
2317 Int_t nseed = arr->GetEntriesFast();
2318 Float_t * quality = new Float_t[nseed];
2319 Int_t * indexes = new Int_t[nseed];
2323 for (Int_t i=0; i<nseed; i++) {
2324 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2329 pt->UpdatePoints(); //select first last max dens points
2330 Float_t * points = pt->GetPoints();
2331 if (points[3]<0.8) quality[i] =-1;
2333 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2335 TMath::Sort(nseed,quality,indexes);
2338 for (Int_t itrack=0; itrack<nseed; itrack++) {
2339 Int_t trackindex = indexes[itrack];
2340 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2341 if (quality[trackindex]<0){
2343 delete arr->RemoveAt(trackindex);
2346 arr->RemoveAt(trackindex);
2351 Int_t first = Int_t(pt->GetPoints()[0]);
2352 Int_t last = Int_t(pt->GetPoints()[2]);
2353 Double_t factor = (pt->GetBConstrain()) ? factor1: factor2;
2355 Int_t found,foundable,shared;
2356 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2357 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
2358 Bool_t itsgold =kFALSE;
2361 if (pt->GetESD()->GetITSclusters(dummy)>4) itsgold= kTRUE;
2365 if (Float_t(shared+1)/Float_t(found+1)>factor){
2366 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2367 delete arr->RemoveAt(trackindex);
2370 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2371 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2372 delete arr->RemoveAt(trackindex);
2378 if (sharedfactor>0.4) continue;
2379 if (pt->GetKinkIndexes()[0]>0) continue;
2380 for (Int_t i=first; i<last; i++) {
2381 Int_t index=pt->GetClusterIndex2(i);
2382 // if (index<0 || index&0x8000 ) continue;
2383 if (index<0 || index&0x8000 ) continue;
2384 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2391 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2397 void AliTPCtrackerMI::UnsignClusters()
2400 // loop over all clusters and unsign them
2403 for (Int_t sec=0;sec<fkNIS;sec++){
2404 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2405 AliTPCclusterMI *cl = fInnerSec[sec][row].GetClusters1();
2406 for (Int_t icl =0;icl< fInnerSec[sec][row].GetN1();icl++)
2407 // if (cl[icl].IsUsed(10))
2409 cl = fInnerSec[sec][row].GetClusters2();
2410 for (Int_t icl =0;icl< fInnerSec[sec][row].GetN2();icl++)
2411 //if (cl[icl].IsUsed(10))
2416 for (Int_t sec=0;sec<fkNOS;sec++){
2417 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2418 AliTPCclusterMI *cl = fOuterSec[sec][row].GetClusters1();
2419 for (Int_t icl =0;icl< fOuterSec[sec][row].GetN1();icl++)
2420 //if (cl[icl].IsUsed(10))
2422 cl = fOuterSec[sec][row].GetClusters2();
2423 for (Int_t icl =0;icl< fOuterSec[sec][row].GetN2();icl++)
2424 //if (cl[icl].IsUsed(10))
2433 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2436 //sign clusters to be "used"
2438 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2439 // loop over "primaries"
2453 Int_t nseed = arr->GetEntriesFast();
2454 for (Int_t i=0; i<nseed; i++) {
2455 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2459 if (!(pt->IsActive())) continue;
2460 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
2461 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2463 sumdens2+= dens*dens;
2464 sumn += pt->GetNumberOfClusters();
2465 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2466 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2469 sumchi2 +=chi2*chi2;
2474 Float_t mdensity = 0.9;
2475 Float_t meann = 130;
2476 Float_t meanchi = 1;
2477 Float_t sdensity = 0.1;
2478 Float_t smeann = 10;
2479 Float_t smeanchi =0.4;
2483 mdensity = sumdens/sum;
2485 meanchi = sumchi/sum;
2487 sdensity = sumdens2/sum-mdensity*mdensity;
2488 sdensity = TMath::Sqrt(sdensity);
2490 smeann = sumn2/sum-meann*meann;
2491 smeann = TMath::Sqrt(smeann);
2493 smeanchi = sumchi2/sum - meanchi*meanchi;
2494 smeanchi = TMath::Sqrt(smeanchi);
2498 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2500 for (Int_t i=0; i<nseed; i++) {
2501 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2505 if (pt->GetBSigned()) continue;
2506 if (pt->GetBConstrain()) continue;
2507 //if (!(pt->IsActive())) continue;
2509 Int_t found,foundable,shared;
2510 pt->GetClusterStatistic(0,160,found, foundable,shared);
2511 if (shared/float(found)>0.3) {
2512 if (shared/float(found)>0.9 ){
2513 //delete arr->RemoveAt(i);
2518 Bool_t isok =kFALSE;
2519 if ( (pt->GetNShared()/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2521 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->GetNShared()/pt->GetNumberOfClusters()<0.7))
2523 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2525 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2529 for (Int_t i=0; i<160; i++) {
2530 Int_t index=pt->GetClusterIndex2(i);
2531 if (index<0) continue;
2532 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2534 //if (!(c->IsUsed(10))) c->Use();
2541 Double_t maxchi = meanchi+2.*smeanchi;
2543 for (Int_t i=0; i<nseed; i++) {
2544 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2548 //if (!(pt->IsActive())) continue;
2549 if (pt->GetBSigned()) continue;
2550 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2551 if (chi>maxchi) continue;
2554 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
2556 //sign only tracks with enoug big density at the beginning
2558 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2561 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2562 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2564 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2565 if ( (pt->GetRemoval()==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2568 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2569 //Int_t noc=pt->GetNumberOfClusters();
2570 pt->SetBSigned(kTRUE);
2571 for (Int_t i=0; i<160; i++) {
2573 Int_t index=pt->GetClusterIndex2(i);
2574 if (index<0) continue;
2575 AliTPCclusterMI *c= pt->GetClusterPointer(i);
2577 // if (!(c->IsUsed(10))) c->Use();
2582 // gLastCheck = nseed;
2590 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2592 // stop not active tracks
2593 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2594 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2595 Int_t nseed = arr->GetEntriesFast();
2597 for (Int_t i=0; i<nseed; i++) {
2598 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2602 if (!(pt->IsActive())) continue;
2603 StopNotActive(pt,row0,th0, th1,th2);
2609 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2612 // stop not active tracks
2613 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2614 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2617 Int_t foundable = 0;
2618 Int_t maxindex = seed->GetLastPoint(); //last foundable row
2619 if (seed->GetNFoundable()*th0 > seed->GetNumberOfClusters()) {
2620 seed->Desactivate(10) ;
2624 for (Int_t i=row0; i<maxindex; i++){
2625 Int_t index = seed->GetClusterIndex2(i);
2626 if (index!=-1) foundable++;
2628 if (foundable<=30) sumgood1++;
2629 if (foundable<=50) {
2636 if (foundable>=30.){
2637 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2640 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2644 Int_t AliTPCtrackerMI::RefitInward(AliESDEvent *event)
2647 // back propagation of ESD tracks
2653 //PrepareForProlongation(fSeeds,1);
2654 PropagateForward2(fSeeds);
2655 TObjArray arraySeed(fSeeds->GetEntries());
2656 for (Int_t i=0;i<fSeeds->GetEntries();i++) {
2657 arraySeed.AddAt(fSeeds->At(i),i);
2659 SignShared(&arraySeed);
2662 Int_t nseed = fSeeds->GetEntriesFast();
2663 for (Int_t i=0;i<nseed;i++){
2664 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2665 if (!seed) continue;
2666 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2668 seed->PropagateTo(fParam->GetInnerRadiusLow());
2669 seed->UpdatePoints();
2671 AliESDtrack *esd=event->GetTrack(i);
2672 seed->CookdEdx(0.02,0.6);
2673 CookLabel(seed,0.1); //For comparison only
2674 esd->SetTPCClusterMap(seed->GetClusterMap());
2675 esd->SetTPCSharedMap(seed->GetSharedMap());
2677 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
2678 TTreeSRedirector &cstream = *fDebugStreamer;
2685 if (seed->GetNumberOfClusters()>15){
2686 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2687 esd->SetTPCPoints(seed->GetPoints());
2688 esd->SetTPCPointsF(seed->GetNFoundable());
2689 Int_t ndedx = seed->GetNCDEDX(0)+seed->GetNCDEDX(1)+seed->GetNCDEDX(2)+seed->GetNCDEDX(3);
2690 Float_t sdedx = (seed->GetSDEDX(0)+seed->GetSDEDX(1)+seed->GetSDEDX(2)+seed->GetSDEDX(3))*0.25;
2691 Float_t dedx = seed->GetdEdx();
2692 esd->SetTPCsignal(dedx, sdedx, ndedx);
2694 // add seed to the esd track in Calib level
2696 if (AliTPCReconstructor::StreamLevel()>0){
2697 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2698 esd->AddCalibObject(seedCopy);
2703 //printf("problem\n");
2706 //FindKinks(fSeeds,event);
2707 Info("RefitInward","Number of refitted tracks %d",ntracks);
2714 Int_t AliTPCtrackerMI::PropagateBack(AliESDEvent *event)
2717 // back propagation of ESD tracks
2723 PropagateBack(fSeeds);
2724 RemoveUsed2(fSeeds,0.4,0.4,20);
2726 Int_t nseed = fSeeds->GetEntriesFast();
2728 for (Int_t i=0;i<nseed;i++){
2729 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2730 if (!seed) continue;
2731 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2732 seed->UpdatePoints();
2733 AliESDtrack *esd=event->GetTrack(i);
2734 seed->CookdEdx(0.02,0.6);
2735 CookLabel(seed,0.1); //For comparison only
2736 if (seed->GetNumberOfClusters()>15){
2737 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2738 esd->SetTPCPoints(seed->GetPoints());
2739 esd->SetTPCPointsF(seed->GetNFoundable());
2740 Int_t ndedx = seed->GetNCDEDX(0)+seed->GetNCDEDX(1)+seed->GetNCDEDX(2)+seed->GetNCDEDX(3);
2741 Float_t sdedx = (seed->GetSDEDX(0)+seed->GetSDEDX(1)+seed->GetSDEDX(2)+seed->GetSDEDX(3))*0.25;
2742 Float_t dedx = seed->GetdEdx();
2743 esd->SetTPCsignal(dedx, sdedx, ndedx);
2745 Int_t eventnumber = event->GetEventNumberInFile();// patch 28 fev 06
2746 // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number
2747 (*fDebugStreamer)<<"Cback"<<
2749 "EventNrInFile="<<eventnumber<<
2750 "\n"; // patch 28 fev 06
2753 //FindKinks(fSeeds,event);
2754 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2762 void AliTPCtrackerMI::DeleteSeeds()
2767 Int_t nseed = fSeeds->GetEntriesFast();
2768 for (Int_t i=0;i<nseed;i++){
2769 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2770 if (seed) delete fSeeds->RemoveAt(i);
2777 void AliTPCtrackerMI::ReadSeeds(AliESDEvent *event, Int_t direction)
2780 //read seeds from the event
2782 Int_t nentr=event->GetNumberOfTracks();
2784 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2789 fSeeds = new TObjArray(nentr);
2793 for (Int_t i=0; i<nentr; i++) {
2794 AliESDtrack *esd=event->GetTrack(i);
2795 ULong_t status=esd->GetStatus();
2796 if (!(status&AliESDtrack::kTPCin)) continue;
2797 AliTPCtrack t(*esd);
2798 t.SetNumberOfClusters(0);
2799 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2800 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2801 seed->SetUniqueID(esd->GetID());
2802 for (Int_t ikink=0;ikink<3;ikink++) {
2803 Int_t index = esd->GetKinkIndex(ikink);
2804 seed->GetKinkIndexes()[ikink] = index;
2805 if (index==0) continue;
2806 index = TMath::Abs(index);
2807 AliESDkink * kink = fEvent->GetKink(index-1);
2808 if (kink&&esd->GetKinkIndex(ikink)<0){
2809 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2810 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2812 if (kink&&esd->GetKinkIndex(ikink)>0){
2813 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2814 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2818 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance(10.);
2819 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance(10.);
2820 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2825 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2826 Double_t par0[5],par1[5],alpha,x;
2827 esd->GetInnerExternalParameters(alpha,x,par0);
2828 esd->GetExternalParameters(x,par1);
2829 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2830 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2832 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2833 //reset covariance if suspicious
2834 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2835 seed->ResetCovariance(10.);
2840 // rotate to the local coordinate system
2842 fSectors=fInnerSec; fN=fkNIS;
2843 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2844 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2845 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2846 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2847 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2848 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2849 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2850 alpha-=seed->GetAlpha();
2851 if (!seed->Rotate(alpha)) {
2857 if (esd->GetKinkIndex(0)<=0){
2858 for (Int_t irow=0;irow<160;irow++){
2859 Int_t index = seed->GetClusterIndex2(irow);
2862 AliTPCclusterMI * cl = GetClusterMI(index);
2863 seed->SetClusterPointer(irow,cl);
2865 if ((index & 0x8000)==0){
2866 cl->Use(10); // accepted cluster
2868 cl->Use(6); // close cluster not accepted
2871 Info("ReadSeeds","Not found cluster");
2876 fSeeds->AddAt(seed,i);
2882 //_____________________________________________________________________________
2883 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2884 Float_t deltay, Int_t ddsec) {
2885 //-----------------------------------------------------------------
2886 // This function creates track seeds.
2887 // SEEDING WITH VERTEX CONSTRAIN
2888 //-----------------------------------------------------------------
2889 // cuts[0] - fP4 cut
2890 // cuts[1] - tan(phi) cut
2891 // cuts[2] - zvertex cut
2892 // cuts[3] - fP3 cut
2900 Double_t x[5], c[15];
2901 // Int_t di = i1-i2;
2903 AliTPCseed * seed = new AliTPCseed;
2904 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2905 Double_t cs=cos(alpha), sn=sin(alpha);
2907 // Double_t x1 =fOuterSec->GetX(i1);
2908 //Double_t xx2=fOuterSec->GetX(i2);
2910 Double_t x1 =GetXrow(i1);
2911 Double_t xx2=GetXrow(i2);
2913 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2915 Int_t imiddle = (i2+i1)/2; //middle pad row index
2916 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2917 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2921 const AliTPCRow& kr1=GetRow(ns,i1);
2922 Double_t ymax = GetMaxY(i1)-kr1.GetDeadZone()-1.5;
2923 Double_t ymaxm = GetMaxY(imiddle)-kr1.GetDeadZone()-1.5;
2926 // change cut on curvature if it can't reach this layer
2927 // maximal curvature set to reach it
2928 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2929 if (dvertexmax*0.5*cuts[0]>0.85){
2930 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2932 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2935 if (deltay>0) ddsec = 0;
2936 // loop over clusters
2937 for (Int_t is=0; is < kr1; is++) {
2939 if (kr1[is]->IsUsed(10)) continue;
2940 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2941 //if (TMath::Abs(y1)>ymax) continue;
2943 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2945 // find possible directions
2946 Float_t anglez = (z1-z3)/(x1-x3);
2947 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2950 //find rotation angles relative to line given by vertex and point 1
2951 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2952 Double_t dvertex = TMath::Sqrt(dvertex2);
2953 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2954 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2957 // loop over 2 sectors
2963 Double_t dddz1=0; // direction of delta inclination in z axis
2970 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2971 Int_t sec2 = sec + dsec;
2973 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2974 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2975 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2976 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2977 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2978 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2980 // rotation angles to p1-p3
2981 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2982 Double_t x2, y2, z2;
2984 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2987 Double_t dxx0 = (xx2-x3)*cs13r;
2988 Double_t dyy0 = (xx2-x3)*sn13r;
2989 for (Int_t js=index1; js < index2; js++) {
2990 const AliTPCclusterMI *kcl = kr2[js];
2991 if (kcl->IsUsed(10)) continue;
2993 //calcutate parameters
2995 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2997 if (TMath::Abs(yy0)<0.000001) continue;
2998 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2999 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
3000 Double_t r02 = (0.25+y0*y0)*dvertex2;
3001 //curvature (radius) cut
3002 if (r02<r2min) continue;
3006 Double_t c0 = 1/TMath::Sqrt(r02);
3010 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
3011 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
3012 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
3013 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
3016 Double_t z0 = kcl->GetZ();
3017 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
3018 if (TMath::Abs(zzzz2-z0)>0.5) continue;
3021 Double_t dip = (z1-z0)*c0/dfi1;
3022 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
3033 x2= xx2*cs-y2*sn*dsec;
3034 y2=+xx2*sn*dsec+y2*cs;
3044 // do we have cluster at the middle ?
3046 GetProlongation(x1,xm,x,ym,zm);
3048 AliTPCclusterMI * cm=0;
3049 if (TMath::Abs(ym)-ymaxm<0){
3050 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
3051 if ((!cm) || (cm->IsUsed(10))) {
3056 // rotate y1 to system 0
3057 // get state vector in rotated system
3058 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
3059 Double_t xr2 = x0*cs+yr1*sn*dsec;
3060 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
3062 GetProlongation(xx2,xm,xr,ym,zm);
3063 if (TMath::Abs(ym)-ymaxm<0){
3064 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
3065 if ((!cm) || (cm->IsUsed(10))) {
3075 dym = ym - cm->GetY();
3076 dzm = zm - cm->GetZ();
3083 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
3084 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
3085 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
3086 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3087 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
3089 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3090 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3091 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3092 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3093 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3094 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3096 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3097 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3098 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3099 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3103 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3104 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3105 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3106 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3107 c[13]=f30*sy1*f40+f32*sy2*f42;
3108 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3110 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3112 UInt_t index=kr1.GetIndex(is);
3113 AliTPCseed *track=new(seed) AliTPCseed(x1, ns*alpha+shift, x, c, index);
3115 track->SetIsSeeding(kTRUE);
3116 track->SetSeed1(i1);
3117 track->SetSeed2(i2);
3118 track->SetSeedType(3);
3122 FollowProlongation(*track, (i1+i2)/2,1);
3123 Int_t foundable,found,shared;
3124 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3125 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3127 seed->~AliTPCseed();
3133 FollowProlongation(*track, i2,1);
3137 track->SetBConstrain(1);
3138 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3139 track->SetLastPoint(i1); // first cluster in track position
3140 track->SetFirstPoint(track->GetLastPoint());
3142 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3143 track->GetNumberOfClusters() < track->GetNFoundable()*0.6 ||
3144 track->GetNShared()>0.4*track->GetNumberOfClusters() ) {
3146 seed->~AliTPCseed();
3150 // Z VERTEX CONDITION
3151 Double_t zv, bz=GetBz();
3152 if ( !track->GetZAt(0.,bz,zv) ) continue;
3153 if (TMath::Abs(zv-z3)>cuts[2]) {
3154 FollowProlongation(*track, TMath::Max(i2-20,0));
3155 if ( !track->GetZAt(0.,bz,zv) ) continue;
3156 if (TMath::Abs(zv-z3)>cuts[2]){
3157 FollowProlongation(*track, TMath::Max(i2-40,0));
3158 if ( !track->GetZAt(0.,bz,zv) ) continue;
3159 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->GetNFoundable()*0.7)){
3160 // make seed without constrain
3161 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3162 FollowProlongation(*track2, i2,1);
3163 track2->SetBConstrain(kFALSE);
3164 track2->SetSeedType(1);
3165 arr->AddLast(track2);
3167 seed->~AliTPCseed();
3172 seed->~AliTPCseed();
3179 track->SetSeedType(0);
3180 arr->AddLast(track);
3181 seed = new AliTPCseed;
3183 // don't consider other combinations
3184 if (track->GetNumberOfClusters() > track->GetNFoundable()*0.8)
3190 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3196 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3201 //-----------------------------------------------------------------
3202 // This function creates track seeds.
3203 //-----------------------------------------------------------------
3204 // cuts[0] - fP4 cut
3205 // cuts[1] - tan(phi) cut
3206 // cuts[2] - zvertex cut
3207 // cuts[3] - fP3 cut
3217 Double_t x[5], c[15];
3219 // make temporary seed
3220 AliTPCseed * seed = new AliTPCseed;
3221 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3222 // Double_t cs=cos(alpha), sn=sin(alpha);
3227 Double_t x1 = GetXrow(i1-1);
3228 const AliTPCRow& kr1=GetRow(sec,i1-1);
3229 Double_t y1max = GetMaxY(i1-1)-kr1.GetDeadZone()-1.5;
3231 Double_t x1p = GetXrow(i1);
3232 const AliTPCRow& kr1p=GetRow(sec,i1);
3234 Double_t x1m = GetXrow(i1-2);
3235 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3238 //last 3 padrow for seeding
3239 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3240 Double_t x3 = GetXrow(i1-7);
3241 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3243 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3244 Double_t x3p = GetXrow(i1-6);
3246 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3247 Double_t x3m = GetXrow(i1-8);
3252 Int_t im = i1-4; //middle pad row index
3253 Double_t xm = GetXrow(im); // radius of middle pad-row
3254 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3255 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3258 Double_t deltax = x1-x3;
3259 Double_t dymax = deltax*cuts[1];
3260 Double_t dzmax = deltax*cuts[3];
3262 // loop over clusters
3263 for (Int_t is=0; is < kr1; is++) {
3265 if (kr1[is]->IsUsed(10)) continue;
3266 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3268 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3270 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3271 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3277 for (Int_t js=index1; js < index2; js++) {
3278 const AliTPCclusterMI *kcl = kr3[js];
3279 if (kcl->IsUsed(10)) continue;
3281 // apply angular cuts
3282 if (TMath::Abs(y1-y3)>dymax) continue;
3285 if (TMath::Abs(z1-z3)>dzmax) continue;
3287 Double_t angley = (y1-y3)/(x1-x3);
3288 Double_t anglez = (z1-z3)/(x1-x3);
3290 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3291 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3293 Double_t yyym = angley*(xm-x1)+y1;
3294 Double_t zzzm = anglez*(xm-x1)+z1;
3296 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3298 if (kcm->IsUsed(10)) continue;
3300 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3301 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3308 // look around first
3309 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3315 if (kc1m->IsUsed(10)) used++;
3317 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3323 if (kc1p->IsUsed(10)) used++;
3325 if (used>1) continue;
3326 if (found<1) continue;
3330 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3336 if (kc3m->IsUsed(10)) used++;
3340 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3346 if (kc3p->IsUsed(10)) used++;
3350 if (used>1) continue;
3351 if (found<3) continue;
3361 x[4]=F1(x1,y1,x2,y2,x3,y3);
3362 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3365 x[2]=F2(x1,y1,x2,y2,x3,y3);
3368 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3369 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3373 Double_t sy1=0.1, sz1=0.1;
3374 Double_t sy2=0.1, sz2=0.1;
3375 Double_t sy3=0.1, sy=0.1, sz=0.1;
3377 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3378 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3379 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3380 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3381 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3382 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3384 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3385 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3386 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3387 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3391 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3392 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3393 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3394 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3395 c[13]=f30*sy1*f40+f32*sy2*f42;
3396 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3398 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3400 UInt_t index=kr1.GetIndex(is);
3401 AliTPCseed *track=new(seed) AliTPCseed(x1, sec*alpha+shift, x, c, index);
3403 track->SetIsSeeding(kTRUE);
3406 FollowProlongation(*track, i1-7,1);
3407 if (track->GetNumberOfClusters() < track->GetNFoundable()*0.75 ||
3408 track->GetNShared()>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3410 seed->~AliTPCseed();
3416 FollowProlongation(*track, i2,1);
3417 track->SetBConstrain(0);
3418 track->SetLastPoint(i1+fInnerSec->GetNRows()); // first cluster in track position
3419 track->SetFirstPoint(track->GetLastPoint());
3421 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3422 track->GetNumberOfClusters()<track->GetNFoundable()*0.7 ||
3423 track->GetNShared()>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3425 seed->~AliTPCseed();
3430 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3431 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3432 FollowProlongation(*track2, i2,1);
3433 track2->SetBConstrain(kFALSE);
3434 track2->SetSeedType(4);
3435 arr->AddLast(track2);
3437 seed->~AliTPCseed();
3441 //arr->AddLast(track);
3442 //seed = new AliTPCseed;
3448 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3454 //_____________________________________________________________________________
3455 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3456 Float_t deltay, Bool_t /*bconstrain*/) {
3457 //-----------------------------------------------------------------
3458 // This function creates track seeds - without vertex constraint
3459 //-----------------------------------------------------------------
3460 // cuts[0] - fP4 cut - not applied
3461 // cuts[1] - tan(phi) cut
3462 // cuts[2] - zvertex cut - not applied
3463 // cuts[3] - fP3 cut
3473 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3474 // Double_t cs=cos(alpha), sn=sin(alpha);
3475 Int_t row0 = (i1+i2)/2;
3476 Int_t drow = (i1-i2)/2;
3477 const AliTPCRow& kr0=fSectors[sec][row0];
3480 AliTPCpolyTrack polytrack;
3481 Int_t nclusters=fSectors[sec][row0];
3482 AliTPCseed * seed = new AliTPCseed;
3487 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3489 Int_t nfoundable =0;
3490 for (Int_t iter =1; iter<2; iter++){ //iterations
3491 const AliTPCRow& krm=fSectors[sec][row0-iter];
3492 const AliTPCRow& krp=fSectors[sec][row0+iter];
3493 const AliTPCclusterMI * cl= kr0[is];
3495 if (cl->IsUsed(10)) {
3501 Double_t x = kr0.GetX();
3502 // Initialization of the polytrack
3507 Double_t y0= cl->GetY();
3508 Double_t z0= cl->GetZ();
3512 Double_t ymax = fSectors->GetMaxY(row0)-kr0.GetDeadZone()-1.5;
3513 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3515 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3516 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3517 polytrack.AddPoint(x,y0,z0,erry, errz);
3520 if (cl->IsUsed(10)) sumused++;
3523 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3524 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3527 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3528 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3529 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3530 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3531 if (cl1->IsUsed(10)) sumused++;
3532 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3536 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3538 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3539 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3540 if (cl2->IsUsed(10)) sumused++;
3541 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3544 if (sumused>0) continue;
3546 polytrack.UpdateParameters();
3552 nfoundable = polytrack.GetN();
3553 nfound = nfoundable;
3555 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3556 Float_t maxdist = 0.8*(1.+3./(ddrow));
3557 for (Int_t delta = -1;delta<=1;delta+=2){
3558 Int_t row = row0+ddrow*delta;
3559 kr = &(fSectors[sec][row]);
3560 Double_t xn = kr->GetX();
3561 Double_t ymax = fSectors->GetMaxY(row)-kr->GetDeadZone()-1.5;
3562 polytrack.GetFitPoint(xn,yn,zn);
3563 if (TMath::Abs(yn)>ymax) continue;
3565 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3567 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3570 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3571 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3572 if (cln->IsUsed(10)) {
3573 // printf("used\n");
3581 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3586 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3587 polytrack.UpdateParameters();
3590 if ( (sumused>3) || (sumused>0.5*nfound)) {
3591 //printf("sumused %d\n",sumused);
3596 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3597 AliTPCpolyTrack track2;
3599 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3600 if (track2.GetN()<0.5*nfoundable) continue;
3603 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3605 // test seed with and without constrain
3606 for (Int_t constrain=0; constrain<=0;constrain++){
3607 // add polytrack candidate
3609 Double_t x[5], c[15];
3610 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3611 track2.GetBoundaries(x3,x1);
3613 track2.GetFitPoint(x1,y1,z1);
3614 track2.GetFitPoint(x2,y2,z2);
3615 track2.GetFitPoint(x3,y3,z3);
3617 //is track pointing to the vertex ?
3620 polytrack.GetFitPoint(x0,y0,z0);
3633 x[4]=F1(x1,y1,x2,y2,x3,y3);
3635 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3636 x[2]=F2(x1,y1,x2,y2,x3,y3);
3638 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3639 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3640 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3641 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3644 Double_t sy =0.1, sz =0.1;
3645 Double_t sy1=0.02, sz1=0.02;
3646 Double_t sy2=0.02, sz2=0.02;
3650 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3653 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3654 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3655 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3656 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3657 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3658 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3660 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3661 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3662 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3663 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3668 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3669 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3670 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3671 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3672 c[13]=f30*sy1*f40+f32*sy2*f42;
3673 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3675 //Int_t row1 = fSectors->GetRowNumber(x1);
3676 Int_t row1 = GetRowNumber(x1);
3680 AliTPCseed *track=new (seed) AliTPCseed(x1,sec*alpha+shift,x,c,index);
3681 track->SetIsSeeding(kTRUE);
3682 Int_t rc=FollowProlongation(*track, i2);
3683 if (constrain) track->SetBConstrain(1);
3685 track->SetBConstrain(0);
3686 track->SetLastPoint(row1+fInnerSec->GetNRows()); // first cluster in track position
3687 track->SetFirstPoint(track->GetLastPoint());
3689 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3690 track->GetNumberOfClusters() < track->GetNFoundable()*0.6 ||
3691 track->GetNShared()>0.4*track->GetNumberOfClusters()) {
3694 seed->~AliTPCseed();
3697 arr->AddLast(track);
3698 seed = new AliTPCseed;
3702 } // if accepted seed
3705 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3711 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3715 //reseed using track points
3716 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3717 Int_t p1 = int(r1*track->GetNumberOfClusters());
3718 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3720 Double_t x0[3],x1[3],x2[3];
3721 for (Int_t i=0;i<3;i++){
3727 // find track position at given ratio of the length
3728 Int_t sec0=0, sec1=0, sec2=0;
3731 for (Int_t i=0;i<160;i++){
3732 if (track->GetClusterPointer(i)){
3734 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3735 if ( (index<p0) || x0[0]<0 ){
3736 if (trpoint->GetX()>1){
3737 clindex = track->GetClusterIndex2(i);
3739 x0[0] = trpoint->GetX();
3740 x0[1] = trpoint->GetY();
3741 x0[2] = trpoint->GetZ();
3742 sec0 = ((clindex&0xff000000)>>24)%18;
3747 if ( (index<p1) &&(trpoint->GetX()>1)){
3748 clindex = track->GetClusterIndex2(i);
3750 x1[0] = trpoint->GetX();
3751 x1[1] = trpoint->GetY();
3752 x1[2] = trpoint->GetZ();
3753 sec1 = ((clindex&0xff000000)>>24)%18;
3756 if ( (index<p2) &&(trpoint->GetX()>1)){
3757 clindex = track->GetClusterIndex2(i);
3759 x2[0] = trpoint->GetX();
3760 x2[1] = trpoint->GetY();
3761 x2[2] = trpoint->GetZ();
3762 sec2 = ((clindex&0xff000000)>>24)%18;
3769 Double_t alpha, cs,sn, xx2,yy2;
3771 alpha = (sec1-sec2)*fSectors->GetAlpha();
3772 cs = TMath::Cos(alpha);
3773 sn = TMath::Sin(alpha);
3774 xx2= x1[0]*cs-x1[1]*sn;
3775 yy2= x1[0]*sn+x1[1]*cs;
3779 alpha = (sec0-sec2)*fSectors->GetAlpha();
3780 cs = TMath::Cos(alpha);
3781 sn = TMath::Sin(alpha);
3782 xx2= x0[0]*cs-x0[1]*sn;
3783 yy2= x0[0]*sn+x0[1]*cs;
3789 Double_t x[5],c[15];
3793 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3794 // if (x[4]>1) return 0;
3795 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3796 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3797 //if (TMath::Abs(x[3]) > 2.2) return 0;
3798 //if (TMath::Abs(x[2]) > 1.99) return 0;
3800 Double_t sy =0.1, sz =0.1;
3802 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3803 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3804 Double_t sy3=0.01+track->GetSigmaY2();
3806 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3807 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3808 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3809 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3810 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3811 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3813 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3814 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3815 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3816 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[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(x2[0]);
3829 AliTPCseed *seed=new AliTPCseed(x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3830 // Double_t y0,z0,y1,z1, y2,z2;
3831 //seed->GetProlongation(x0[0],y0,z0);
3832 // seed->GetProlongation(x1[0],y1,z1);
3833 //seed->GetProlongation(x2[0],y2,z2);
3835 seed->SetLastPoint(pp2);
3836 seed->SetFirstPoint(pp2);
3843 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3847 //reseed using founded clusters
3849 // Find the number of clusters
3850 Int_t nclusters = 0;
3851 for (Int_t irow=0;irow<160;irow++){
3852 if (track->GetClusterIndex(irow)>0) nclusters++;
3856 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3857 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3858 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3862 Int_t row[3],sec[3]={0,0,0};
3864 // find track row position at given ratio of the length
3866 for (Int_t irow=0;irow<160;irow++){
3867 if (track->GetClusterIndex2(irow)<0) continue;
3869 for (Int_t ipoint=0;ipoint<3;ipoint++){
3870 if (index<=ipos[ipoint]) row[ipoint] = irow;
3874 //Get cluster and sector position
3875 for (Int_t ipoint=0;ipoint<3;ipoint++){
3876 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3877 AliTPCclusterMI * cl = GetClusterMI(clindex);
3880 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3883 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3884 xyz[ipoint][0] = GetXrow(row[ipoint]);
3885 xyz[ipoint][1] = cl->GetY();
3886 xyz[ipoint][2] = cl->GetZ();
3890 // Calculate seed state vector and covariance matrix
3892 Double_t alpha, cs,sn, xx2,yy2;
3894 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3895 cs = TMath::Cos(alpha);
3896 sn = TMath::Sin(alpha);
3897 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3898 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3902 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3903 cs = TMath::Cos(alpha);
3904 sn = TMath::Sin(alpha);
3905 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3906 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3912 Double_t x[5],c[15];
3916 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3917 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3918 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3920 Double_t sy =0.1, sz =0.1;
3922 Double_t sy1=0.2, sz1=0.2;
3923 Double_t sy2=0.2, sz2=0.2;
3926 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;
3927 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;
3928 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;
3929 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;
3930 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;
3931 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;
3933 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;
3934 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;
3935 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;
3936 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;
3941 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3942 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3943 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3944 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3945 c[13]=f30*sy1*f40+f32*sy2*f42;
3946 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3948 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3949 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
3950 seed->SetLastPoint(row[2]);
3951 seed->SetFirstPoint(row[2]);
3956 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3960 //reseed using founded clusters
3963 Int_t row[3]={0,0,0};
3964 Int_t sec[3]={0,0,0};
3966 // forward direction
3968 for (Int_t irow=r0;irow<160;irow++){
3969 if (track->GetClusterIndex(irow)>0){
3974 for (Int_t irow=160;irow>r0;irow--){
3975 if (track->GetClusterIndex(irow)>0){
3980 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3981 if (track->GetClusterIndex(irow)>0){
3989 for (Int_t irow=0;irow<r0;irow++){
3990 if (track->GetClusterIndex(irow)>0){
3995 for (Int_t irow=r0;irow>0;irow--){
3996 if (track->GetClusterIndex(irow)>0){
4001 for (Int_t irow=row[2]-15;irow>row[0];irow--){
4002 if (track->GetClusterIndex(irow)>0){
4009 if ((row[2]-row[0])<20) return 0;
4010 if (row[1]==0) return 0;
4013 //Get cluster and sector position
4014 for (Int_t ipoint=0;ipoint<3;ipoint++){
4015 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
4016 AliTPCclusterMI * cl = GetClusterMI(clindex);
4019 // AliTPCclusterMI * cl = GetClusterMI(clindex);
4022 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
4023 xyz[ipoint][0] = GetXrow(row[ipoint]);
4024 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
4025 if (point&&ipoint<2){
4027 xyz[ipoint][1] = point->GetY();
4028 xyz[ipoint][2] = point->GetZ();
4031 xyz[ipoint][1] = cl->GetY();
4032 xyz[ipoint][2] = cl->GetZ();
4039 // Calculate seed state vector and covariance matrix
4041 Double_t alpha, cs,sn, xx2,yy2;
4043 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
4044 cs = TMath::Cos(alpha);
4045 sn = TMath::Sin(alpha);
4046 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
4047 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
4051 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
4052 cs = TMath::Cos(alpha);
4053 sn = TMath::Sin(alpha);
4054 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
4055 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
4061 Double_t x[5],c[15];
4065 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
4066 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
4067 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
4069 Double_t sy =0.1, sz =0.1;
4071 Double_t sy1=0.2, sz1=0.2;
4072 Double_t sy2=0.2, sz2=0.2;
4075 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;
4076 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;
4077 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;
4078 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;
4079 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;
4080 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;
4082 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;
4083 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;
4084 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;
4085 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;
4090 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
4091 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
4092 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
4093 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
4094 c[13]=f30*sy1*f40+f32*sy2*f42;
4095 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
4097 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
4098 AliTPCseed *seed=new AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
4099 seed->SetLastPoint(row[2]);
4100 seed->SetFirstPoint(row[2]);
4101 for (Int_t i=row[0];i<row[2];i++){
4102 seed->SetClusterIndex(i, track->GetClusterIndex(i));
4108 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESDEvent *esd)
4115 TObjArray *kinks= new TObjArray(10000);
4116 // TObjArray *v0s= new TObjArray(10000);
4117 Int_t nentries = array->GetEntriesFast();
4118 AliHelix *helixes = new AliHelix[nentries];
4119 Int_t *sign = new Int_t[nentries];
4120 Int_t *nclusters = new Int_t[nentries];
4121 Float_t *alpha = new Float_t[nentries];
4122 AliKink *kink = new AliKink();
4123 Int_t * usage = new Int_t[nentries];
4124 Float_t *zm = new Float_t[nentries];
4125 Float_t *z0 = new Float_t[nentries];
4126 Float_t *fim = new Float_t[nentries];
4127 Float_t *shared = new Float_t[nentries];
4128 Bool_t *circular = new Bool_t[nentries];
4129 Float_t *dca = new Float_t[nentries];
4130 //const AliESDVertex * primvertex = esd->GetVertex();
4132 // nentries = array->GetEntriesFast();
4137 for (Int_t i=0;i<nentries;i++){
4140 AliTPCseed* track = (AliTPCseed*)array->At(i);
4141 if (!track) continue;
4142 track->SetCircular(0);
4144 track->UpdatePoints();
4145 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
4147 nclusters[i]=track->GetNumberOfClusters();
4148 alpha[i] = track->GetAlpha();
4149 new (&helixes[i]) AliHelix(*track);
4151 helixes[i].Evaluate(0,xyz);
4152 sign[i] = (track->GetC()>0) ? -1:1;
4155 if (track->GetProlongation(x,y,z)){
4157 fim[i] = alpha[i]+TMath::ATan2(y,x);
4160 zm[i] = track->GetZ();
4164 circular[i]= kFALSE;
4165 if (track->GetProlongation(0,y,z)) z0[i] = z;
4166 dca[i] = track->GetD(0,0);
4172 Int_t ncandidates =0;
4175 Double_t phase[2][2],radius[2];
4178 // Find circling track
4179 TTreeSRedirector &cstream = *fDebugStreamer;
4181 for (Int_t i0=0;i0<nentries;i0++){
4182 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4183 if (!track0) continue;
4184 if (track0->GetNumberOfClusters()<40) continue;
4185 if (TMath::Abs(1./track0->GetC())>200) continue;
4186 for (Int_t i1=i0+1;i1<nentries;i1++){
4187 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4188 if (!track1) continue;
4189 if (track1->GetNumberOfClusters()<40) continue;
4190 if ( TMath::Abs(track1->GetTgl()+track0->GetTgl())>0.1) continue;
4191 if (track0->GetBConstrain()&&track1->GetBConstrain()) continue;
4192 if (TMath::Abs(1./track1->GetC())>200) continue;
4193 if (track1->Get1Pt()*track0->Get1Pt()>0) continue;
4194 if (track1->GetTgl()*track0->GetTgl()>0) continue;
4195 if (TMath::Max(TMath::Abs(1./track0->GetC()),TMath::Abs(1./track1->GetC()))>190) continue;
4196 if (track0->GetBConstrain()&&TMath::Abs(track1->Get1Pt())<TMath::Abs(track0->Get1Pt())) continue; //returning - lower momenta
4197 if (track1->GetBConstrain()&&TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())) continue; //returning - lower momenta
4199 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4200 if (mindcar<5) continue;
4201 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4202 if (mindcaz<5) continue;
4203 if (mindcar+mindcaz<20) continue;
4206 Float_t xc0 = helixes[i0].GetHelix(6);
4207 Float_t yc0 = helixes[i0].GetHelix(7);
4208 Float_t r0 = helixes[i0].GetHelix(8);
4209 Float_t xc1 = helixes[i1].GetHelix(6);
4210 Float_t yc1 = helixes[i1].GetHelix(7);
4211 Float_t r1 = helixes[i1].GetHelix(8);
4213 Float_t rmean = (r0+r1)*0.5;
4214 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
4215 //if (delta>30) continue;
4216 if (delta>rmean*0.25) continue;
4217 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4219 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4220 if (npoints==0) continue;
4221 helixes[i0].GetClosestPhases(helixes[i1], phase);
4225 Double_t hangles[3];
4226 helixes[i0].Evaluate(phase[0][0],xyz0);
4227 helixes[i1].Evaluate(phase[0][1],xyz1);
4229 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4230 Double_t deltah[2],deltabest;
4231 if (hangles[2]<2.8) continue;
4233 cstream<<"C"<<track0->fLab<<track1->fLab<<
4234 track0->fP3<<track1->fP3<<
4235 track0->fP4<<track1->fP4<<
4236 delta<<rmean<<npoints<<
4237 hangles[0]<<hangles[2]<<
4238 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4242 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
4244 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
4245 if (deltah[1]<deltah[0]) ibest=1;
4247 deltabest = TMath::Sqrt(deltah[ibest]);
4248 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4249 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4250 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
4251 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
4253 if (deltabest>6) continue;
4254 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
4255 Bool_t sign =kFALSE;
4256 if (hangles[2]>3.06) sign =kTRUE;
4259 circular[i0] = kTRUE;
4260 circular[i1] = kTRUE;
4261 if (TMath::Abs(track0->Get1Pt())<TMath::Abs(track1->Get1Pt())){
4262 track0->SetCircular(track0->GetCircular()+1);
4263 track1->SetCircular(track1->GetCircular()+2);
4266 track1->SetCircular(track1->GetCircular()+1);
4267 track0->SetCircular(track0->GetCircular()+2);
4270 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4272 Int_t lab0=track0->GetLabel();
4273 Int_t lab1=track1->GetLabel();
4274 cstream<<"Curling"<<
4281 "mindcar="<<mindcar<<
4282 "mindcaz="<<mindcaz<<
4285 "npoints="<<npoints<<
4286 "hangles0="<<hangles[0]<<
4287 "hangles2="<<hangles[2]<<
4292 "radius="<<radiusbest<<
4293 "deltabest="<<deltabest<<
4294 "phase0="<<phase[ibest][0]<<
4295 "phase1="<<phase[ibest][1]<<
4305 for (Int_t i =0;i<nentries;i++){
4306 if (sign[i]==0) continue;
4307 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4310 Double_t cradius0 = 40*40;
4311 Double_t cradius1 = 270*270;
4314 Double_t cdist3=0.55;
4315 for (Int_t j =i+1;j<nentries;j++){
4317 if (sign[j]*sign[i]<1) continue;
4318 if ( (nclusters[i]+nclusters[j])>200) continue;
4319 if ( (nclusters[i]+nclusters[j])<80) continue;
4320 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4321 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4322 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4323 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4324 if (npoints<1) continue;
4327 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4330 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4333 Double_t delta1=10000,delta2=10000;
4334 // cuts on the intersection radius
4335 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4336 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4337 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4339 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4340 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4341 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4344 Double_t distance1 = TMath::Min(delta1,delta2);
4345 if (distance1>cdist1) continue; // cut on DCA linear approximation
4347 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4348 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4349 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4350 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4353 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4354 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4355 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4357 distance1 = TMath::Min(delta1,delta2);
4360 rkink = TMath::Sqrt(radius[0]);
4363 rkink = TMath::Sqrt(radius[1]);
4365 if (distance1>cdist2) continue;
4368 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4371 Int_t row0 = GetRowNumber(rkink);
4372 if (row0<10) continue;
4373 if (row0>150) continue;
4376 Float_t dens00=-1,dens01=-1;
4377 Float_t dens10=-1,dens11=-1;
4379 Int_t found,foundable,shared;
4380 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4381 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4382 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4383 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4385 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4386 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4387 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4388 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4390 if (dens00<dens10 && dens01<dens11) continue;
4391 if (dens00>dens10 && dens01>dens11) continue;
4392 if (TMath::Max(dens00,dens10)<0.1) continue;
4393 if (TMath::Max(dens01,dens11)<0.3) continue;
4395 if (TMath::Min(dens00,dens10)>0.6) continue;
4396 if (TMath::Min(dens01,dens11)>0.6) continue;
4399 AliTPCseed * ktrack0, *ktrack1;
4408 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4409 AliExternalTrackParam paramm(*ktrack0);
4410 AliExternalTrackParam paramd(*ktrack1);
4411 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4414 kink->SetMother(paramm);
4415 kink->SetDaughter(paramd);
4418 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
4420 fParam->Transform0to1(x,index);
4421 fParam->Transform1to2(x,index);
4422 row0 = GetRowNumber(x[0]);
4424 if (kink->GetR()<100) continue;
4425 if (kink->GetR()>240) continue;
4426 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4427 if (kink->GetDistance()>cdist3) continue;
4428 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
4429 if (dird<0) continue;
4431 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
4432 if (dirm<0) continue;
4433 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
4434 if (mpt<0.2) continue;
4437 //for high momenta momentum not defined well in first iteration
4438 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->GetP();
4439 if (qt>0.35) continue;
4442 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4443 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
4445 kink->SetTPCDensity(dens00,0,0);
4446 kink->SetTPCDensity(dens01,0,1);
4447 kink->SetTPCDensity(dens10,1,0);
4448 kink->SetTPCDensity(dens11,1,1);
4449 kink->SetIndex(i,0);
4450 kink->SetIndex(j,1);
4453 kink->SetTPCDensity(dens10,0,0);
4454 kink->SetTPCDensity(dens11,0,1);
4455 kink->SetTPCDensity(dens00,1,0);
4456 kink->SetTPCDensity(dens01,1,1);
4457 kink->SetIndex(j,0);
4458 kink->SetIndex(i,1);
4461 if (mpt<1||kink->GetAngle(2)>0.1){
4462 // angle and densities not defined yet
4463 if (kink->GetTPCDensityFactor()<0.8) continue;
4464 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4465 if (kink->GetAngle(2)*ktrack0->GetP()<0.003) continue; //too small angle
4466 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4467 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4469 Float_t criticalangle = track0->GetSigmaSnp2()+track0->GetSigmaTgl2();
4470 criticalangle+= track1->GetSigmaSnp2()+track1->GetSigmaTgl2();
4471 criticalangle= 3*TMath::Sqrt(criticalangle);
4472 if (criticalangle>0.02) criticalangle=0.02;
4473 if (kink->GetAngle(2)<criticalangle) continue;
4476 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
4477 Float_t shapesum =0;
4479 for ( Int_t row = row0-drow; row<row0+drow;row++){
4480 if (row<0) continue;
4481 if (row>155) continue;
4482 if (ktrack0->GetClusterPointer(row)){
4483 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4484 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4487 if (ktrack1->GetClusterPointer(row)){
4488 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4489 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4494 kink->SetShapeFactor(-1.);
4497 kink->SetShapeFactor(shapesum/sum);
4499 // esd->AddKink(kink);
4500 kinks->AddLast(kink);
4506 // sort the kinks according quality - and refit them towards vertex
4508 Int_t nkinks = kinks->GetEntriesFast();
4509 Float_t *quality = new Float_t[nkinks];
4510 Int_t *indexes = new Int_t[nkinks];
4511 AliTPCseed *mothers = new AliTPCseed[nkinks];
4512 AliTPCseed *daughters = new AliTPCseed[nkinks];
4515 for (Int_t i=0;i<nkinks;i++){
4517 AliKink *kink = (AliKink*)kinks->At(i);
4519 // refit kinks towards vertex
4521 Int_t index0 = kink->GetIndex(0);
4522 Int_t index1 = kink->GetIndex(1);
4523 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4524 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4526 Int_t sumn=ktrack0->GetNumberOfClusters()+ktrack1->GetNumberOfClusters();
4528 // Refit Kink under if too small angle
4530 if (kink->GetAngle(2)<0.05){
4531 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4532 Int_t row0 = kink->GetTPCRow0();
4533 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4536 Int_t last = row0-drow;
4537 if (last<40) last=40;
4538 if (last<ktrack0->GetFirstPoint()+25) last = ktrack0->GetFirstPoint()+25;
4539 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4542 Int_t first = row0+drow;
4543 if (first>130) first=130;
4544 if (first>ktrack1->GetLastPoint()-25) first = TMath::Max(ktrack1->GetLastPoint()-25,30);
4545 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4547 if (seed0 && seed1){
4548 kink->SetStatus(1,8);
4549 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4550 row0 = GetRowNumber(kink->GetR());
4551 sumn = seed0->GetNumberOfClusters()+seed1->GetNumberOfClusters();
4552 new (&mothers[i]) AliTPCseed(*seed0);
4553 new (&daughters[i]) AliTPCseed(*seed1);
4556 delete kinks->RemoveAt(i);
4557 if (seed0) delete seed0;
4558 if (seed1) delete seed1;
4561 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4562 delete kinks->RemoveAt(i);
4563 if (seed0) delete seed0;
4564 if (seed1) delete seed1;
4572 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
4574 TMath::Sort(nkinks,quality,indexes,kFALSE);
4576 //remove double find kinks
4578 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4579 AliKink * kink0 = (AliKink*) kinks->At(indexes[ikink0]);
4580 if (!kink0) continue;
4582 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4583 if (!kink0) continue;
4584 AliKink * kink1 = (AliKink*) kinks->At(indexes[ikink1]);
4585 if (!kink1) continue;
4586 // if not close kink continue
4587 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4588 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4589 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4591 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4592 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4593 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4594 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4595 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4604 for (Int_t i=0;i<row0;i++){
4605 if (mother0.GetClusterIndex(i)>0 && mother1.GetClusterIndex(i)>0){
4608 if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
4615 for (Int_t i=row0;i<158;i++){
4616 if (daughter0.GetClusterIndex(i)>0 && daughter0.GetClusterIndex(i)>0){
4619 if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
4625 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4626 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4627 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4628 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4629 Int_t sum0 = mother0.GetNumberOfClusters()+daughter0.GetNumberOfClusters();
4630 Int_t sum1 = mother1.GetNumberOfClusters()+daughter1.GetNumberOfClusters();
4632 shared[kink0->GetIndex(0)]= kTRUE;
4633 shared[kink0->GetIndex(1)]= kTRUE;
4634 delete kinks->RemoveAt(indexes[ikink0]);
4637 shared[kink1->GetIndex(0)]= kTRUE;
4638 shared[kink1->GetIndex(1)]= kTRUE;
4639 delete kinks->RemoveAt(indexes[ikink1]);
4646 for (Int_t i=0;i<nkinks;i++){
4647 AliKink * kink = (AliKink*) kinks->At(indexes[i]);
4648 if (!kink) continue;
4649 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4650 Int_t index0 = kink->GetIndex(0);
4651 Int_t index1 = kink->GetIndex(1);
4652 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4653 kink->SetMultiple(usage[index0],0);
4654 kink->SetMultiple(usage[index1],1);
4655 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4656 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4657 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4658 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
4660 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4661 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4662 if (!ktrack0 || !ktrack1) continue;
4663 Int_t index = esd->AddKink(kink);
4666 if ( ktrack0->GetKinkIndex(0)==0 && ktrack1->GetKinkIndex(0)==0) { //best kink
4667 if (mothers[indexes[i]].GetNumberOfClusters()>20 && daughters[indexes[i]].GetNumberOfClusters()>20 && (mothers[indexes[i]].GetNumberOfClusters()+daughters[indexes[i]].GetNumberOfClusters())>100){
4668 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4669 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4673 ktrack0->SetKinkIndex(usage[index0],-(index+1));
4674 ktrack1->SetKinkIndex(usage[index1], (index+1));
4679 // Remove tracks corresponding to shared kink's
4681 for (Int_t i=0;i<nentries;i++){
4682 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4683 if (!track0) continue;
4684 if (track0->GetKinkIndex(0)!=0) continue;
4685 if (shared[i]) delete array->RemoveAt(i);
4690 RemoveUsed2(array,0.5,0.4,30);
4692 for (Int_t i=0;i<nentries;i++){
4693 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4694 if (!track0) continue;
4695 track0->CookdEdx(0.02,0.6);
4699 for (Int_t i=0;i<nentries;i++){
4700 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4701 if (!track0) continue;
4702 if (track0->GetPt()<1.4) continue;
4703 //remove double high momenta tracks - overlapped with kink candidates
4706 for (Int_t icl=track0->GetFirstPoint();icl<track0->GetLastPoint(); icl++){
4707 if (track0->GetClusterPointer(icl)!=0){
4709 if (track0->GetClusterPointer(icl)->IsUsed(10)) shared++;
4712 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4713 delete array->RemoveAt(i);
4717 if (track0->GetKinkIndex(0)!=0) continue;
4718 if (track0->GetNumberOfClusters()<80) continue;
4720 AliTPCseed *pmother = new AliTPCseed();
4721 AliTPCseed *pdaughter = new AliTPCseed();
4722 AliKink *pkink = new AliKink;
4724 AliTPCseed & mother = *pmother;
4725 AliTPCseed & daughter = *pdaughter;
4726 AliKink & kink = *pkink;
4727 if (CheckKinkPoint(track0,mother,daughter, kink)){
4728 if (mother.GetNumberOfClusters()<30||daughter.GetNumberOfClusters()<20) {
4732 continue; //too short tracks
4734 if (mother.GetPt()<1.4) {
4740 Int_t row0= kink.GetTPCRow0();
4741 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4748 Int_t index = esd->AddKink(&kink);
4749 mother.SetKinkIndex(0,-(index+1));
4750 daughter.SetKinkIndex(0,index+1);
4751 if (mother.GetNumberOfClusters()>50) {
4752 delete array->RemoveAt(i);
4753 array->AddAt(new AliTPCseed(mother),i);
4756 array->AddLast(new AliTPCseed(mother));
4758 array->AddLast(new AliTPCseed(daughter));
4759 for (Int_t icl=0;icl<row0;icl++) {
4760 if (mother.GetClusterPointer(icl)) mother.GetClusterPointer(icl)->Use(20);
4763 for (Int_t icl=row0;icl<158;icl++) {
4764 if (daughter.GetClusterPointer(icl)) daughter.GetClusterPointer(icl)->Use(20);
4773 delete [] daughters;
4795 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
4799 void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESDEvent *esd)
4805 TObjArray *tpcv0s = new TObjArray(100000);
4806 Int_t nentries = array->GetEntriesFast();
4807 AliHelix *helixes = new AliHelix[nentries];
4808 Int_t *sign = new Int_t[nentries];
4809 Float_t *alpha = new Float_t[nentries];
4810 Float_t *z0 = new Float_t[nentries];
4811 Float_t *dca = new Float_t[nentries];
4812 Float_t *sdcar = new Float_t[nentries];
4813 Float_t *cdcar = new Float_t[nentries];
4814 Float_t *pulldcar = new Float_t[nentries];
4815 Float_t *pulldcaz = new Float_t[nentries];
4816 Float_t *pulldca = new Float_t[nentries];
4817 Bool_t *isPrim = new Bool_t[nentries];
4818 const AliESDVertex * primvertex = esd->GetVertex();
4819 Double_t zvertex = primvertex->GetZv();
4821 // nentries = array->GetEntriesFast();
4823 for (Int_t i=0;i<nentries;i++){
4826 AliTPCseed* track = (AliTPCseed*)array->At(i);
4827 if (!track) continue;
4828 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4829 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4830 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4832 alpha[i] = track->GetAlpha();
4833 new (&helixes[i]) AliHelix(*track);
4835 helixes[i].Evaluate(0,xyz);
4836 sign[i] = (track->GetC()>0) ? -1:1;
4840 if (track->GetProlongation(0,y,z)) z0[i] = z;
4841 dca[i] = track->GetD(0,0);
4843 // dca error parrameterezation + pulls
4845 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->GetC())*(100*track->GetC()));
4846 if (TMath::Abs(track->GetTgl())>1) sdcar[i]*=2.5;
4847 cdcar[i] = TMath::Exp((TMath::Abs(track->GetC())-0.0106)*525.3);
4848 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4849 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4850 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4851 if (track->TPCrPID(1)+track->TPCrPID(2)+track->TPCrPID(3)>0.5) {
4852 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4854 if (track->TPCrPID(4)>0.5) {
4855 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4857 if (track->TPCrPID(0)>0.4) {
4858 isPrim[i]=kFALSE; //electron no sigma cut
4865 Int_t ncandidates =0;
4868 Double_t phase[2][2],radius[2];
4874 TTreeSRedirector &cstream = *fDebugStreamer;
4875 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4877 Double_t cradius0 = 10*10;
4878 Double_t cradius1 = 200*200;
4881 Double_t cpointAngle = 0.95;
4883 Double_t delta[2]={10000,10000};
4884 for (Int_t i =0;i<nentries;i++){
4885 if (sign[i]==0) continue;
4886 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4887 if (!track0) continue;
4888 if (AliTPCReconstructor::StreamLevel()>0){
4893 "zvertex="<<zvertex<<
4894 "sdcar0="<<sdcar[i]<<
4895 "cdcar0="<<cdcar[i]<<
4896 "pulldcar0="<<pulldcar[i]<<
4897 "pulldcaz0="<<pulldcaz[i]<<
4898 "pulldca0="<<pulldca[i]<<
4899 "isPrim="<<isPrim[i]<<
4903 if (track0->Get1Pt()<0) continue;
4904 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4906 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4911 for (Int_t j =0;j<nentries;j++){
4912 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4913 if (!track1) continue;
4914 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4915 if (sign[j]*sign[i]>0) continue;
4916 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4917 if (track0->GetCircular()+track1->GetCircular()>1) continue; //circling -returning track
4920 // DCA to prim vertex cut
4926 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4927 if (npoints<1) continue;
4931 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4932 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4933 if (delta[0]>cdist1) continue;
4936 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4937 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4938 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4939 if (delta[1]<delta[0]) iclosest=1;
4940 if (delta[iclosest]>cdist1) continue;
4942 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4943 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4945 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4946 if (pointAngle<cpointAngle) continue;
4948 Bool_t isGamma = kFALSE;
4949 vertex.SetParamP(*track0); //track0 - plus
4950 vertex.SetParamN(*track1); //track1 - minus
4951 vertex.Update(fprimvertex);
4952 if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4953 Double_t pointAngle2 = vertex.GetV0CosineOfPointingAngle();
4955 if (vertex.GetV0CosineOfPointingAngle()<cpointAngle && (!isGamma)) continue;// point angle cut
4956 //Bo: if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4957 if (vertex.GetDcaV0Daughters()>2&&(!isGamma)) continue;//Bo: // point angle cut
4958 Float_t sigmae = 0.15*0.15;
4959 if (vertex.GetRr()<80)
4960 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4961 sigmae+= TMath::Sqrt(sigmae);
4962 //Bo: if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4963 if (vertex.GetDcaV0Daughters()/sigmae>3.&&(!isGamma)) continue;
4964 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4965 Int_t row0 = GetRowNumber(vertex.GetRr());
4967 //Bo: if (vertex.GetDist2()>0.2) continue;
4968 if (vertex.GetDcaV0Daughters()>0.2) continue;
4969 densb0 = track0->Density2(0,row0-5);
4970 densb1 = track1->Density2(0,row0-5);
4971 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4972 densa0 = track0->Density2(row0+5,row0+40);
4973 densa1 = track1->Density2(row0+5,row0+40);
4974 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4977 densa0 = track0->Density2(0,40); //cluster density
4978 densa1 = track1->Density2(0,40); //cluster density
4979 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4981 //Bo: vertex.SetLab(0,track0->GetLabel());
4982 //Bo: vertex.SetLab(1,track1->GetLabel());
4983 vertex.SetChi2After((densa0+densa1)*0.5);
4984 vertex.SetChi2Before((densb0+densb1)*0.5);
4985 vertex.SetIndex(0,i);
4986 vertex.SetIndex(1,j);
4987 //Bo: vertex.SetStatus(1); // TPC v0 candidate
4988 vertex.SetOnFlyStatus(2);//Bo: // TPC v0 candidate
4989 //Bo: vertex.SetRp(track0->TPCrPIDs());
4990 //Bo: vertex.SetRm(track1->TPCrPIDs());
4991 tpcv0s->AddLast(new AliESDv0(vertex));
4994 Int_t eventNr = esd->GetEventNumberInFile(); // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number
4995 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4996 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
4997 if (AliTPCReconstructor::StreamLevel()>0) {
4998 Int_t lab0=track0->GetLabel();
4999 Int_t lab1=track1->GetLabel();
5000 Char_t c0=track0->GetCircular();
5001 Char_t c1=track1->GetCircular();
5004 "vertex.="<<&vertex<<
5007 "Helix0.="<<&helixes[i]<<
5010 "Helix1.="<<&helixes[j]<<
5011 "pointAngle="<<pointAngle<<
5012 "pointAngle2="<<pointAngle2<<
5017 "zvertex="<<zvertex<<
5020 "npoints="<<npoints<<
5021 "radius0="<<radius[0]<<
5022 "delta0="<<delta[0]<<
5023 "radius1="<<radius[1]<<
5024 "delta1="<<delta[1]<<
5025 "radiusm="<<radiusm<<
5027 "sdcar0="<<sdcar[i]<<
5028 "sdcar1="<<sdcar[j]<<
5029 "cdcar0="<<cdcar[i]<<
5030 "cdcar1="<<cdcar[j]<<
5031 "pulldcar0="<<pulldcar[i]<<
5032 "pulldcar1="<<pulldcar[j]<<
5033 "pulldcaz0="<<pulldcaz[i]<<
5034 "pulldcaz1="<<pulldcaz[j]<<
5035 "pulldca0="<<pulldca[i]<<
5036 "pulldca1="<<pulldca[j]<<
5046 Float_t *quality = new Float_t[ncandidates];
5047 Int_t *indexes = new Int_t[ncandidates];
5049 for (Int_t i=0;i<ncandidates;i++){
5051 AliESDv0 *v0 = (AliESDv0*)tpcv0s->At(i);
5052 quality[i] = 1./(1.00001-v0->GetV0CosineOfPointingAngle()); //base point angle
5053 // quality[i] /= (0.5+v0->GetDist2());
5054 // quality[i] *= v0->GetChi2After(); //density factor
5056 Int_t index0 = v0->GetIndex(0);
5057 Int_t index1 = v0->GetIndex(1);
5058 //Bo: Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
5059 Double_t minpulldca = TMath::Min(2.+pulldca[index0],(2.+pulldca[index1]) );//Bo:
5063 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
5064 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
5065 if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
5066 if (track0->TPCrPID(4)>0.9||track1->TPCrPID(4)>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
5069 TMath::Sort(ncandidates,quality,indexes,kTRUE);
5072 for (Int_t i=0;i<ncandidates;i++){
5073 AliESDv0 * v0 = (AliESDv0*)tpcv0s->At(indexes[i]);
5075 Int_t index0 = v0->GetIndex(0);
5076 Int_t index1 = v0->GetIndex(1);
5077 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
5078 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
5079 if (!track0||!track1) {
5083 Bool_t accept =kTRUE; //default accept
5084 Int_t *v0indexes0 = track0->GetV0Indexes();
5085 Int_t *v0indexes1 = track1->GetV0Indexes();
5087 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
5088 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
5089 if (v0indexes0[1]!=0) order0 =2;
5090 if (v0indexes1[1]!=0) order1 =2;
5092 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
5093 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
5095 AliESDv0 * v02 = v0;
5097 //Bo: v0->SetOrder(0,order0);
5098 //Bo: v0->SetOrder(1,order1);
5099 //Bo: v0->SetOrder(1,order0+order1);
5100 v0->SetOnFlyStatus(kTRUE);
5101 Int_t index = esd->AddV0(v0);
5102 v02 = esd->GetV0(index);
5103 v0indexes0[order0]=index;
5104 v0indexes1[order1]=index;
5108 Int_t eventNr = esd->GetEventNumberInFile(); // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number
5109 if (AliTPCReconstructor::StreamLevel()>0) {
5110 Int_t lab0=track0->GetLabel();
5111 Int_t lab1=track1->GetLabel();
5120 "dca0="<<dca[index0]<<
5121 "dca1="<<dca[index1]<<
5125 "quality="<<quality[i]<<
5126 "pulldca0="<<pulldca[index0]<<
5127 "pulldca1="<<pulldca[index1]<<
5151 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5155 Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5158 // refit kink towards to the vertex
5161 AliKink &kink=(AliKink &)knk;
5163 Int_t row0 = GetRowNumber(kink.GetR());
5164 FollowProlongation(mother,0);
5165 mother.Reset(kFALSE);
5167 FollowProlongation(daughter,row0);
5168 daughter.Reset(kFALSE);
5169 FollowBackProlongation(daughter,158);
5170 daughter.Reset(kFALSE);
5171 Int_t first = TMath::Max(row0-20,30);
5172 Int_t last = TMath::Min(row0+20,140);
5174 const Int_t kNdiv =5;
5175 AliTPCseed param0[kNdiv]; // parameters along the track
5176 AliTPCseed param1[kNdiv]; // parameters along the track
5177 AliKink kinks[kNdiv]; // corresponding kink parameters
5180 for (Int_t irow=0; irow<kNdiv;irow++){
5181 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5183 // store parameters along the track
5185 for (Int_t irow=0;irow<kNdiv;irow++){
5186 FollowBackProlongation(mother, rows[irow]);
5187 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5188 new(¶m0[irow]) AliTPCseed(mother);
5189 new(¶m1[kNdiv-1-irow]) AliTPCseed(daughter);
5193 for (Int_t irow=0; irow<kNdiv-1;irow++){
5194 if (param0[irow].GetNumberOfClusters()<kNdiv||param1[irow].GetNumberOfClusters()<kNdiv) continue;
5195 kinks[irow].SetMother(param0[irow]);
5196 kinks[irow].SetDaughter(param1[irow]);
5197 kinks[irow].Update();
5200 // choose kink with best "quality"
5202 Double_t mindist = 10000;
5203 for (Int_t irow=0;irow<kNdiv;irow++){
5204 if (param0[irow].GetNumberOfClusters()<20||param1[irow].GetNumberOfClusters()<20) continue;
5205 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5206 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5208 Float_t normdist = TMath::Abs(param0[irow].GetX()-kinks[irow].GetR())*(0.1+kink.GetDistance());
5209 normdist/= (param0[irow].GetNumberOfClusters()+param1[irow].GetNumberOfClusters()+40.);
5210 if (normdist < mindist){
5216 if (index==-1) return 0;
5219 param0[index].Reset(kTRUE);
5220 FollowProlongation(param0[index],0);
5222 new (&mother) AliTPCseed(param0[index]);
5223 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5225 kink.SetMother(mother);
5226 kink.SetDaughter(daughter);
5228 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5229 kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
5230 kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
5231 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5232 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5233 mother.SetLabel(kink.GetLabel(0));
5234 daughter.SetLabel(kink.GetLabel(1));
5240 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5242 // update Kink quality information for mother after back propagation
5244 if (seed->GetKinkIndex(0)>=0) return;
5245 for (Int_t ikink=0;ikink<3;ikink++){
5246 Int_t index = seed->GetKinkIndex(ikink);
5247 if (index>=0) break;
5248 index = TMath::Abs(index)-1;
5249 AliESDkink * kink = fEvent->GetKink(index);
5250 //kink->fTPCdensity2[0][0]=-1;
5251 //kink->fTPCdensity2[0][1]=-1;
5252 kink->SetTPCDensity2(-1,0,0);
5253 kink->SetTPCDensity2(1,0,1);
5255 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5256 if (row0<15) row0=15;
5258 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5259 if (row1>145) row1=145;
5261 Int_t found,foundable,shared;
5262 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5263 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
5264 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5265 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
5270 void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
5272 // update Kink quality information for daughter after refit
5274 if (seed->GetKinkIndex(0)<=0) return;
5275 for (Int_t ikink=0;ikink<3;ikink++){
5276 Int_t index = seed->GetKinkIndex(ikink);
5277 if (index<=0) break;
5278 index = TMath::Abs(index)-1;
5279 AliESDkink * kink = fEvent->GetKink(index);
5280 kink->SetTPCDensity2(-1,1,0);
5281 kink->SetTPCDensity2(-1,1,1);
5283 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5284 if (row0<15) row0=15;
5286 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5287 if (row1>145) row1=145;
5289 Int_t found,foundable,shared;
5290 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5291 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5292 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5293 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
5299 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
5302 // check kink point for given track
5303 // if return value=0 kink point not found
5304 // otherwise seed0 correspond to mother particle
5305 // seed1 correspond to daughter particle
5306 // kink parameter of kink point
5307 AliKink &kink=(AliKink &)knk;
5309 Int_t middlerow = (seed->GetFirstPoint()+seed->GetLastPoint())/2;
5310 Int_t first = seed->GetFirstPoint();
5311 Int_t last = seed->GetLastPoint();
5312 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
5315 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5316 if (!seed1) return 0;
5317 FollowProlongation(*seed1,seed->GetLastPoint()-20);
5318 seed1->Reset(kTRUE);
5319 FollowProlongation(*seed1,158);
5320 seed1->Reset(kTRUE);
5321 last = seed1->GetLastPoint();
5323 AliTPCseed *seed0 = new AliTPCseed(*seed);
5324 seed0->Reset(kFALSE);
5327 AliTPCseed param0[20]; // parameters along the track
5328 AliTPCseed param1[20]; // parameters along the track
5329 AliKink kinks[20]; // corresponding kink parameters
5331 for (Int_t irow=0; irow<20;irow++){
5332 rows[irow] = first +((last-first)*irow)/19;
5334 // store parameters along the track
5336 for (Int_t irow=0;irow<20;irow++){
5337 FollowBackProlongation(*seed0, rows[irow]);
5338 FollowProlongation(*seed1,rows[19-irow]);
5339 new(¶m0[irow]) AliTPCseed(*seed0);
5340 new(¶m1[19-irow]) AliTPCseed(*seed1);
5344 for (Int_t irow=0; irow<19;irow++){
5345 kinks[irow].SetMother(param0[irow]);
5346 kinks[irow].SetDaughter(param1[irow]);
5347 kinks[irow].Update();
5350 // choose kink with biggest change of angle
5352 Double_t maxchange= 0;
5353 for (Int_t irow=1;irow<19;irow++){
5354 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5355 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5356 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5357 if ( quality > maxchange){
5358 maxchange = quality;
5365 if (index<0) return 0;
5367 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5368 seed0 = new AliTPCseed(param0[index]);
5369 seed1 = new AliTPCseed(param1[index]);
5370 seed0->Reset(kFALSE);
5371 seed1->Reset(kFALSE);
5372 seed0->ResetCovariance(10.);
5373 seed1->ResetCovariance(10.);
5374 FollowProlongation(*seed0,0);
5375 FollowBackProlongation(*seed1,158);
5376 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5377 seed0->Reset(kFALSE);
5378 seed1->Reset(kFALSE);
5379 seed0->ResetCovariance(10.);
5380 seed1->ResetCovariance(10.);
5382 first = TMath::Max(row0-20,0);
5383 last = TMath::Min(row0+20,158);
5385 for (Int_t irow=0; irow<20;irow++){
5386 rows[irow] = first +((last-first)*irow)/19;
5388 // store parameters along the track
5390 for (Int_t irow=0;irow<20;irow++){
5391 FollowBackProlongation(*seed0, rows[irow]);
5392 FollowProlongation(*seed1,rows[19-irow]);
5393 new(¶m0[irow]) AliTPCseed(*seed0);
5394 new(¶m1[19-irow]) AliTPCseed(*seed1);
5398 for (Int_t irow=0; irow<19;irow++){
5399 kinks[irow].SetMother(param0[irow]);
5400 kinks[irow].SetDaughter(param1[irow]);
5401 // param0[irow].Dump();
5402 //param1[irow].Dump();
5403 kinks[irow].Update();
5406 // choose kink with biggest change of angle
5409 for (Int_t irow=0;irow<20;irow++){
5410 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5411 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5412 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
5413 if ( quality > maxchange){
5414 maxchange = quality;
5421 if (index==-1 || param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()<100){
5426 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
5428 kink.SetMother(param0[index]);
5429 kink.SetDaughter(param1[index]);
5431 row0 = GetRowNumber(kink.GetR());
5432 kink.SetTPCRow0(row0);
5433 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5434 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5435 kink.SetIndex(-10,0);
5436 kink.SetIndex(int(param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()),1);
5437 kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
5438 kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
5441 // new (&mother) AliTPCseed(param0[index]);
5442 new (&daughter) AliTPCseed(param1[index]);
5443 daughter.SetLabel(kink.GetLabel(1));
5444 param0[index].Reset(kTRUE);
5445 FollowProlongation(param0[index],0);
5446 new (&mother) AliTPCseed(param0[index]);
5447 mother.SetLabel(kink.GetLabel(0));
5457 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5460 // reseed - refit - track
5463 // Int_t last = fSectors->GetNRows()-1;
5465 if (fSectors == fOuterSec){
5466 first = TMath::Max(first, t->GetFirstPoint()-fInnerSec->GetNRows());
5470 first = t->GetFirstPoint();
5472 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5473 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5475 FollowProlongation(*t,first);
5485 //_____________________________________________________________________________
5486 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5487 //-----------------------------------------------------------------
5488 // This function reades track seeds.
5489 //-----------------------------------------------------------------
5490 TDirectory *savedir=gDirectory;
5492 TFile *in=(TFile*)inp;
5493 if (!in->IsOpen()) {
5494 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5499 TTree *seedTree=(TTree*)in->Get("Seeds");
5501 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5502 cerr<<"can't get a tree with track seeds !\n";
5505 AliTPCtrack *seed=new AliTPCtrack;
5506 seedTree->SetBranchAddress("tracks",&seed);
5508 if (fSeeds==0) fSeeds=new TObjArray(15000);
5510 Int_t n=(Int_t)seedTree->GetEntries();
5511 for (Int_t i=0; i<n; i++) {
5512 seedTree->GetEvent(i);
5513 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
5522 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESDEvent *esd)
5525 if (fSeeds) DeleteSeeds();
5528 if (!fSeeds) return 1;
5535 //_____________________________________________________________________________
5536 Int_t AliTPCtrackerMI::Clusters2Tracks() {
5537 //-----------------------------------------------------------------
5538 // This is a track finder.
5539 //-----------------------------------------------------------------
5540 TDirectory *savedir=gDirectory;
5544 fSeeds = Tracking();
5547 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5549 //activate again some tracks
5550 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5551 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5553 Int_t nc=t.GetNumberOfClusters();
5555 delete fSeeds->RemoveAt(i);
5559 if (pt->GetRemoval()==10) {
5560 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5561 pt->Desactivate(10); // make track again active
5563 pt->Desactivate(20);
5564 delete fSeeds->RemoveAt(i);
5569 RemoveUsed2(fSeeds,0.85,0.85,0);
5570 if (AliTPCReconstructor::GetRecoParam()->GetDoKinks()) FindKinks(fSeeds,fEvent);
5571 RemoveUsed2(fSeeds,0.5,0.4,20);
5573 // // refit short tracks
5575 Int_t nseed=fSeeds->GetEntriesFast();
5576 // for (Int_t i=0; i<nseed; i++) {
5577 // AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5578 // if (!pt) continue;
5579 // Int_t nc=t.GetNumberOfClusters();
5581 // delete fSeeds->RemoveAt(i);
5584 // if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5585 // if (nc>100) continue; // hopefully, enough for ITS
5586 // AliTPCseed *seed2 = new AliTPCseed(*pt);
5587 // //seed2->Reset(kFALSE);
5588 // //pt->ResetCovariance();
5589 // seed2->Modify(1);
5590 // FollowBackProlongation(*seed2,158);
5591 // //seed2->Reset(kFALSE);
5592 // seed2->Modify(10);
5593 // FollowProlongation(*seed2,0);
5594 // TTreeSRedirector &cstream = *fDebugStreamer;
5595 // cstream<<"Crefit"<<
5599 // if (seed2->fN>pt->fN){
5600 // delete fSeeds->RemoveAt(i);
5601 // fSeeds->AddAt(seed2,i);
5606 // RemoveUsed2(fSeeds,0.6,0.6,50);
5608 // FindV0s(fSeeds,fEvent);
5609 //RemoveDouble(fSeeds,0.2,0.6,11);
5613 for (Int_t i=0; i<nseed; i++) {
5614 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5616 Int_t nc=t.GetNumberOfClusters();
5618 delete fSeeds->RemoveAt(i);
5621 CookLabel(pt,0.1); //For comparison only
5622 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5623 if ((pt->IsActive() || (pt->GetRemoval()==10) )){
5625 if (fDebug>0) cerr<<found<<'\r';
5629 delete fSeeds->RemoveAt(i);
5633 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5635 //RemoveUsed(fSeeds,0.9,0.9,6);
5637 nseed=fSeeds->GetEntriesFast();
5639 for (Int_t i=0; i<nseed; i++) {
5640 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5642 Int_t nc=t.GetNumberOfClusters();
5644 delete fSeeds->RemoveAt(i);
5648 t.CookdEdx(0.02,0.6);
5649 // CheckKinkPoint(&t,0.05);
5650 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5651 if ((pt->IsActive() || (pt->GetRemoval()==10) )){
5659 delete fSeeds->RemoveAt(i);
5660 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5662 // FollowProlongation(*seed1,0);
5663 // Int_t n = seed1->GetNumberOfClusters();
5664 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5665 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5668 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5672 SortTracks(fSeeds, 1);
5676 PrepareForBackProlongation(fSeeds,5.);
5677 PropagateBack(fSeeds);
5678 printf("Time for back propagation: \t");timer.Print();timer.Start();
5682 PrepareForProlongation(fSeeds,5.);
5683 PropagateForward2(fSeeds);
5685 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5686 // RemoveUsed(fSeeds,0.7,0.7,6);
5687 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
5689 nseed=fSeeds->GetEntriesFast();
5691 for (Int_t i=0; i<nseed; i++) {
5692 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5694 Int_t nc=t.GetNumberOfClusters();
5696 delete fSeeds->RemoveAt(i);
5699 t.CookdEdx(0.02,0.6);
5700 // CookLabel(pt,0.1); //For comparison only
5701 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5702 if ((pt->IsActive() || (pt->fRemoval==10) )){
5703 cerr<<found++<<'\r';
5706 delete fSeeds->RemoveAt(i);
5711 // fNTracks = found;
5713 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5716 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5717 Info("Clusters2Tracks","Number of found tracks %d",found);
5719 // UnloadClusters();
5724 void AliTPCtrackerMI::Tracking(TObjArray * arr)
5727 // tracking of the seeds
5730 fSectors = fOuterSec;
5731 ParallelTracking(arr,150,63);
5732 fSectors = fOuterSec;
5733 ParallelTracking(arr,63,0);
5736 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5741 TObjArray * arr = new TObjArray;
5743 fSectors = fOuterSec;
5746 for (Int_t sec=0;sec<fkNOS;sec++){
5747 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5748 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5749 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5752 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
5764 TObjArray * AliTPCtrackerMI::Tracking()
5768 if (AliTPCReconstructor::GetRecoParam()->GetSpecialSeeding()) return TrackingSpecial();
5771 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5773 TObjArray * seeds = new TObjArray;
5782 Float_t fnumber = 3.0;
5783 Float_t fdensity = 3.0;
5788 for (Int_t delta = 0; delta<18; delta+=6){
5792 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5793 SumTracks(seeds,arr);
5794 SignClusters(seeds,fnumber,fdensity);
5796 for (Int_t i=2;i<6;i+=2){
5797 // seed high pt tracks
5800 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5801 SumTracks(seeds,arr);
5802 SignClusters(seeds,fnumber,fdensity);
5807 // RemoveUsed(seeds,0.9,0.9,1);
5808 // UnsignClusters();
5809 // SignClusters(seeds,fnumber,fdensity);
5813 for (Int_t delta = 20; delta<120; delta+=10){
5815 // seed high pt tracks
5819 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5820 SumTracks(seeds,arr);
5821 SignClusters(seeds,fnumber,fdensity);
5826 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5827 SumTracks(seeds,arr);
5828 SignClusters(seeds,fnumber,fdensity);
5839 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
5843 // RemoveUsed(seeds,0.75,0.75,1);
5845 //SignClusters(seeds,fnumber,fdensity);
5854 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5855 SumTracks(seeds,arr);
5856 SignClusters(seeds,fnumber,fdensity);
5858 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5859 SumTracks(seeds,arr);
5860 SignClusters(seeds,fnumber,fdensity);
5862 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5863 SumTracks(seeds,arr);
5864 SignClusters(seeds,fnumber,fdensity);
5868 for (Int_t delta = 3; delta<30; delta+=5){
5874 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5875 SumTracks(seeds,arr);
5876 SignClusters(seeds,fnumber,fdensity);
5878 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5879 SumTracks(seeds,arr);
5880 SignClusters(seeds,fnumber,fdensity);
5892 for (Int_t delta = 30; delta<90; delta+=10){
5898 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5899 SumTracks(seeds,arr);
5900 SignClusters(seeds,fnumber,fdensity);
5902 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5903 SumTracks(seeds,arr);
5904 SignClusters(seeds,fnumber,fdensity);
5908 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5919 TObjArray * AliTPCtrackerMI::TrackingSpecial()
5922 // seeding adjusted for laser and cosmic tests - short tracks with big inclination angle
5923 // no primary vertex seeding tried
5927 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5929 TObjArray * seeds = new TObjArray;
5934 Float_t fnumber = 3.0;
5935 Float_t fdensity = 3.0;
5938 cuts[0] = AliTPCReconstructor::GetRecoParam()->GetMaxC(); // max curvature
5939 cuts[1] = 3.5; // max tan(phi) angle for seeding
5940 cuts[2] = 3.; // not used (cut on z primary vertex)
5941 cuts[3] = 3.5; // max tan(theta) angle for seeding
5943 for (Int_t delta = 0; nup-delta-gap-1>0; delta+=3){
5945 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5946 SumTracks(seeds,arr);
5947 SignClusters(seeds,fnumber,fdensity);
5951 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
5962 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
5965 //sum tracks to common container
5966 //remove suspicious tracks
5967 Int_t nseed = arr2->GetEntriesFast();
5968 for (Int_t i=0;i<nseed;i++){
5969 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5972 // remove tracks with too big curvature
5974 if (TMath::Abs(pt->GetC())>AliTPCReconstructor::GetRecoParam()->GetMaxC()){
5975 delete arr2->RemoveAt(i);
5978 // REMOVE VERY SHORT TRACKS
5979 if (pt->GetNumberOfClusters()<20){
5980 delete arr2->RemoveAt(i);
5983 // NORMAL ACTIVE TRACK
5984 if (pt->IsActive()){
5985 arr1->AddLast(arr2->RemoveAt(i));
5988 //remove not usable tracks
5989 if (pt->GetRemoval()!=10){
5990 delete arr2->RemoveAt(i);
5994 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5995 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5996 arr1->AddLast(arr2->RemoveAt(i));
5998 delete arr2->RemoveAt(i);
6007 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
6010 // try to track in parralel
6012 Int_t nseed=arr->GetEntriesFast();
6013 //prepare seeds for tracking
6014 for (Int_t i=0; i<nseed; i++) {
6015 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
6017 if (!t.IsActive()) continue;
6018 // follow prolongation to the first layer
6019 if ( (fSectors ==fInnerSec) || (t.GetFirstPoint()-fParam->GetNRowLow()>rfirst+1) )
6020 FollowProlongation(t, rfirst+1);
6025 for (Int_t nr=rfirst; nr>=rlast; nr--){
6026 if (nr<fInnerSec->GetNRows())
6027 fSectors = fInnerSec;
6029 fSectors = fOuterSec;
6030 // make indexes with the cluster tracks for given
6032 // find nearest cluster
6033 for (Int_t i=0; i<nseed; i++) {
6034 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
6036 if (nr==80) pt->UpdateReference();
6037 if (!pt->IsActive()) continue;
6038 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
6039 if (pt->GetRelativeSector()>17) {
6042 UpdateClusters(t,nr);
6044 // prolonagate to the nearest cluster - if founded
6045 for (Int_t i=0; i<nseed; i++) {
6046 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
6048 if (!pt->IsActive()) continue;
6049 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
6050 if (pt->GetRelativeSector()>17) {
6053 FollowToNextCluster(*pt,nr);
6058 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
6062 // if we use TPC track itself we have to "update" covariance
6064 Int_t nseed= arr->GetEntriesFast();
6065 for (Int_t i=0;i<nseed;i++){
6066 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6070 //rotate to current local system at first accepted point
6071 Int_t index = pt->GetClusterIndex2(pt->GetFirstPoint());
6072 Int_t sec = (index&0xff000000)>>24;
6074 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
6075 if (angle1>TMath::Pi())
6076 angle1-=2.*TMath::Pi();
6077 Float_t angle2 = pt->GetAlpha();
6079 if (TMath::Abs(angle1-angle2)>0.001){
6080 pt->Rotate(angle1-angle2);
6081 //angle2 = pt->GetAlpha();
6082 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
6083 //if (pt->GetAlpha()<0)
6084 // pt->fRelativeSector+=18;
6085 //sec = pt->fRelativeSector;
6094 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
6098 // if we use TPC track itself we have to "update" covariance
6100 Int_t nseed= arr->GetEntriesFast();
6101 for (Int_t i=0;i<nseed;i++){
6102 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6105 pt->SetFirstPoint(pt->GetLastPoint());
6113 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
6116 // make back propagation
6118 Int_t nseed= arr->GetEntriesFast();
6119 for (Int_t i=0;i<nseed;i++){
6120 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6121 if (pt&& pt->GetKinkIndex(0)<=0) {
6122 //AliTPCseed *pt2 = new AliTPCseed(*pt);
6123 fSectors = fInnerSec;
6124 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
6125 //fSectors = fOuterSec;
6126 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6127 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
6128 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
6129 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6132 if (pt&& pt->GetKinkIndex(0)>0) {
6133 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
6134 pt->SetFirstPoint(kink->GetTPCRow0());
6135 fSectors = fInnerSec;
6136 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
6144 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
6147 // make forward propagation
6149 Int_t nseed= arr->GetEntriesFast();
6151 for (Int_t i=0;i<nseed;i++){
6152 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
6154 FollowProlongation(*pt,0);
6161 Int_t AliTPCtrackerMI::PropagateForward()
6164 // propagate track forward
6166 Int_t nseed = fSeeds->GetEntriesFast();
6167 for (Int_t i=0;i<nseed;i++){
6168 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
6170 AliTPCseed &t = *pt;
6171 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
6172 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
6173 if (alpha < 0. ) alpha += 2.*TMath::Pi();
6174 t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
6178 fSectors = fOuterSec;
6179 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
6180 fSectors = fInnerSec;
6181 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
6191 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6194 // make back propagation, in between row0 and row1
6198 fSectors = fInnerSec;
6201 if (row1<fSectors->GetNRows())
6204 r1 = fSectors->GetNRows()-1;
6206 if (row0<fSectors->GetNRows()&& r1>0 )
6207 FollowBackProlongation(*pt,r1);
6208 if (row1<=fSectors->GetNRows())
6211 r1 = row1 - fSectors->GetNRows();
6212 if (r1<=0) return 0;
6213 if (r1>=fOuterSec->GetNRows()) return 0;
6214 fSectors = fOuterSec;
6215 return FollowBackProlongation(*pt,r1);
6223 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6227 Float_t sd2 = TMath::Abs((fParam->GetZLength(0)-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6228 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6229 Float_t padlength = GetPadPitchLength(row);
6231 Float_t sresy = (seed->GetSector() < fParam->GetNSector()/2) ? 0.2 :0.3;
6232 Double_t angulary = seed->GetSnp();
6233 angulary = angulary*angulary/(1-angulary*angulary);
6234 seed->SetCurrentSigmaY2(sd2+padlength*padlength*angulary/12.+sresy*sresy);
6236 Float_t sresz = fParam->GetZSigma();
6237 Float_t angularz = seed->GetTgl();
6238 seed->SetCurrentSigmaZ2(sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz);
6240 Float_t wy = GetSigmaY(seed);
6241 Float_t wz = GetSigmaZ(seed);
6244 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6245 printf("problem\n");
6251 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6255 Float_t sd2 = TMath::Abs((fParam->GetZLength(0)-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6256 Float_t padlength = fParam->GetPadPitchLength(seed->GetSector());
6257 Float_t sres = (seed->GetSector() < fParam->GetNSector()/2) ? 0.2 :0.3;
6258 Float_t angular = seed->GetSnp();
6259 angular = angular*angular/(1-angular*angular);
6260 // angular*=angular;
6261 //angular = TMath::Sqrt(angular/(1-angular));
6262 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6265 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6269 Float_t sd2 = TMath::Abs((fParam->GetZLength(0)-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6270 Float_t padlength = fParam->GetPadPitchLength(seed->GetSector());
6271 Float_t sres = fParam->GetZSigma();
6272 Float_t angular = seed->GetTgl();
6273 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6278 //__________________________________________________________________________
6279 void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
6280 //--------------------------------------------------------------------
6281 //This function "cooks" a track label. If label<0, this track is fake.
6282 //--------------------------------------------------------------------
6283 AliTPCseed * t = (AliTPCseed*)tk;
6284 Int_t noc=t->GetNumberOfClusters();
6286 //printf("\nnot founded prolongation\n\n\n");
6292 AliTPCclusterMI *clusters[160];
6294 for (Int_t i=0;i<160;i++) {
6301 for (i=0; i<160 && current<noc; i++) {
6303 Int_t index=t->GetClusterIndex2(i);
6304 if (index<=0) continue;
6305 if (index&0x8000) continue;
6307 //clusters[current]=GetClusterMI(index);
6308 if (t->GetClusterPointer(i)){
6309 clusters[current]=t->GetClusterPointer(i);
6315 Int_t lab=123456789;
6316 for (i=0; i<noc; i++) {
6317 AliTPCclusterMI *c=clusters[i];
6319 lab=TMath::Abs(c->GetLabel(0));
6321 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6327 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6329 for (i=0; i<noc; i++) {
6330 AliTPCclusterMI *c=clusters[i];
6332 if (TMath::Abs(c->GetLabel(1)) == lab ||
6333 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6336 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6339 Int_t tail=Int_t(0.10*noc);
6342 for (i=1; i<=160&&ind<tail; i++) {
6343 // AliTPCclusterMI *c=clusters[noc-i];
6344 AliTPCclusterMI *c=clusters[i];
6346 if (lab == TMath::Abs(c->GetLabel(0)) ||
6347 lab == TMath::Abs(c->GetLabel(1)) ||
6348 lab == TMath::Abs(c->GetLabel(2))) max++;
6351 if (max < Int_t(0.5*tail)) lab=-lab;
6358 //delete[] clusters;
6362 //__________________________________________________________________________
6363 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6364 //--------------------------------------------------------------------
6365 //This function "cooks" a track label. If label<0, this track is fake.
6366 //--------------------------------------------------------------------
6367 Int_t noc=t->GetNumberOfClusters();
6369 //printf("\nnot founded prolongation\n\n\n");
6375 AliTPCclusterMI *clusters[160];
6377 for (Int_t i=0;i<160;i++) {
6384 for (i=0; i<160 && current<noc; i++) {
6385 if (i<first) continue;
6386 if (i>last) continue;
6387 Int_t index=t->GetClusterIndex2(i);
6388 if (index<=0) continue;
6389 if (index&0x8000) continue;
6391 //clusters[current]=GetClusterMI(index);
6392 if (t->GetClusterPointer(i)){
6393 clusters[current]=t->GetClusterPointer(i);
6398 if (noc<5) return -1;
6399 Int_t lab=123456789;
6400 for (i=0; i<noc; i++) {
6401 AliTPCclusterMI *c=clusters[i];
6403 lab=TMath::Abs(c->GetLabel(0));
6405 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6411 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6413 for (i=0; i<noc; i++) {
6414 AliTPCclusterMI *c=clusters[i];
6416 if (TMath::Abs(c->GetLabel(1)) == lab ||
6417 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6420 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6423 Int_t tail=Int_t(0.10*noc);
6426 for (i=1; i<=160&&ind<tail; i++) {
6427 // AliTPCclusterMI *c=clusters[noc-i];
6428 AliTPCclusterMI *c=clusters[i];
6430 if (lab == TMath::Abs(c->GetLabel(0)) ||
6431 lab == TMath::Abs(c->GetLabel(1)) ||
6432 lab == TMath::Abs(c->GetLabel(2))) max++;
6435 if (max < Int_t(0.5*tail)) lab=-lab;
6438 // t->SetLabel(lab);
6442 //delete[] clusters;
6446 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6448 //return pad row number for this x
6451 r=fRow[fN-1].GetX();
6452 if (x > r) return fN;
6454 if (x < r) return -1;
6455 return Int_t((x-r)/fPadPitchLength + 0.5);}
6457 r=fRow[fN-1].GetX();
6458 if (x > r) return fN;
6460 if (x < r) return -1;
6461 Double_t r1=fRow[64].GetX();
6463 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6465 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6469 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6471 //return pad row number for given x vector
6472 Float_t phi = TMath::ATan2(x[1],x[0]);
6473 if(phi<0) phi=2.*TMath::Pi()+phi;
6474 // Get the local angle in the sector philoc
6475 const Float_t kRaddeg = 180/3.14159265358979312;
6476 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6477 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6478 return GetRowNumber(localx);
6481 //_________________________________________________________________________
6482 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6483 //-----------------------------------------------------------------------
6484 // Setup inner sector
6485 //-----------------------------------------------------------------------
6487 fAlpha=par->GetInnerAngle();
6488 fAlphaShift=par->GetInnerAngleShift();
6489 fPadPitchWidth=par->GetInnerPadPitchWidth();
6490 fPadPitchLength=par->GetInnerPadPitchLength();
6491 fN=par->GetNRowLow();
6492 fRow=new AliTPCRow[fN];
6493 for (Int_t i=0; i<fN; i++) {
6494 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6495 fRow[i].SetDeadZone(1.5); //1.5 cm of dead zone
6498 fAlpha=par->GetOuterAngle();
6499 fAlphaShift=par->GetOuterAngleShift();
6500 fPadPitchWidth = par->GetOuterPadPitchWidth();
6501 fPadPitchLength = par->GetOuter1PadPitchLength();
6502 f1PadPitchLength = par->GetOuter1PadPitchLength();
6503 f2PadPitchLength = par->GetOuter2PadPitchLength();
6505 fN=par->GetNRowUp();
6506 fRow=new AliTPCRow[fN];
6507 for (Int_t i=0; i<fN; i++) {
6508 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6509 fRow[i].SetDeadZone(1.5); // 1.5 cm of dead zone
6514 AliTPCtrackerMI::AliTPCRow::AliTPCRow():
6524 // default constructor
6528 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6535 //_________________________________________________________________________
6537 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6538 //-----------------------------------------------------------------------
6539 // Insert a cluster into this pad row in accordence with its y-coordinate
6540 //-----------------------------------------------------------------------
6541 if (fN==kMaxClusterPerRow) {
6542 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6544 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6545 Int_t i=Find(c->GetZ());
6546 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6547 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6548 fIndex[i]=index; fClusters[i]=c; fN++;
6551 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6557 //delete[] fClusterArray;
6558 if (fClusters1) delete []fClusters1;
6559 if (fClusters2) delete []fClusters2;
6566 //___________________________________________________________________
6567 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6568 //-----------------------------------------------------------------------
6569 // Return the index of the nearest cluster
6570 //-----------------------------------------------------------------------
6571 if (fN==0) return 0;
6572 if (z <= fClusters[0]->GetZ()) return 0;
6573 if (z > fClusters[fN-1]->GetZ()) return fN;
6574 Int_t b=0, e=fN-1, m=(b+e)/2;
6575 for (; b<e; m=(b+e)/2) {
6576 if (z > fClusters[m]->GetZ()) b=m+1;
6584 //___________________________________________________________________
6585 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6586 //-----------------------------------------------------------------------
6587 // Return the index of the nearest cluster in z y
6588 //-----------------------------------------------------------------------
6589 Float_t maxdistance = roady*roady + roadz*roadz;
6591 AliTPCclusterMI *cl =0;
6592 for (Int_t i=Find(z-roadz); i<fN; i++) {
6593 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6594 if (c->GetZ() > z+roadz) break;
6595 if ( (c->GetY()-y) > roady ) continue;
6596 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6597 if (maxdistance>distance) {
6598 maxdistance = distance;
6605 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6607 //-----------------------------------------------------------------------
6608 // Return the index of the nearest cluster in z y
6609 //-----------------------------------------------------------------------
6610 Float_t maxdistance = roady*roady + roadz*roadz;
6611 AliTPCclusterMI *cl =0;
6613 //PH Check boundaries. 510 is the size of fFastCluster
6614 Int_t iz1 = Int_t(z-roadz+254.5);
6615 if (iz1<0 || iz1>=510) return cl;
6616 iz1 = TMath::Max(GetFastCluster(iz1)-1,0);
6617 Int_t iz2 = Int_t(z+roadz+255.5);
6618 if (iz2<0 || iz2>=510) return cl;
6619 iz2 = TMath::Min(GetFastCluster(iz2)+1,fN);
6621 //FindNearest3(y,z,roady,roadz,index);
6622 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6623 for (Int_t i=iz1; i<iz2; i++) {
6624 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6625 if (c->GetZ() > z+roadz) break;
6626 if ( c->GetY()-y > roady ) continue;
6627 if ( y-c->GetY() > roady ) continue;
6628 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6629 if (maxdistance>distance) {
6630 maxdistance = distance;
6633 //roady = TMath::Sqrt(maxdistance);
6641 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6643 //-----------------------------------------------------------------------
6644 // Return the index of the nearest cluster in z y
6645 //-----------------------------------------------------------------------
6646 Float_t maxdistance = roady*roady + roadz*roadz;
6647 // Int_t iz = Int_t(z+255.);
6648 AliTPCclusterMI *cl =0;
6649 for (Int_t i=Find(z-roadz); i<fN; i++) {
6650 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6651 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6652 if (c->GetZ() > z+roadz) break;
6653 if ( c->GetY()-y > roady ) continue;
6654 if ( y-c->GetY() > roady ) continue;
6655 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6656 if (maxdistance>distance) {
6657 maxdistance = distance;
6660 //roady = TMath::Sqrt(maxdistance);
6670 // AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6674 // return &fTrackPoints[i];
6678 void AliTPCtrackerMI::MakeBitmaps(AliTPCseed *t)
6680 //-----------------------------------------------------------------------
6681 // Fill the cluster and sharing bitmaps of the track
6682 //-----------------------------------------------------------------------
6684 Int_t firstpoint = 0;
6685 Int_t lastpoint = 159;
6686 AliTPCTrackerPoint *point;
6688 for (int iter=firstpoint; iter<lastpoint; iter++) {
6689 point = t->GetTrackPoint(iter);
6691 t->SetClusterMapBit(iter, kTRUE);
6692 if (point->IsShared())
6693 t->SetSharedMapBit(iter,kTRUE);
6695 t->SetSharedMapBit(iter, kFALSE);
6698 t->SetClusterMapBit(iter, kFALSE);
6699 t->SetSharedMapBit(iter, kFALSE);