1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker -
24 // run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 // run AliTPCFindTracksMI.C macro - to find tracks
26 // tracks are written to AliTPCtracks.root file
27 // for comparison also seeds are written to the same file - to special branch
28 //-------------------------------------------------------
35 #include "Riostream.h"
36 #include <TClonesArray.h>
38 #include <TObjArray.h>
41 #include "AliComplexCluster.h"
44 #include "AliRunLoader.h"
45 #include "AliTPCClustersRow.h"
46 #include "AliTPCParam.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCtrackerMI.h"
51 #include "TStopwatch.h"
55 ClassImp(AliTPCtrackerMI)
58 class AliTPCFastMath {
61 static Double_t FastAsin(Double_t x);
63 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
66 Double_t AliTPCFastMath::fgFastAsin[20000];
68 AliTPCFastMath::AliTPCFastMath(){
70 // initialized lookup table;
71 for (Int_t i=0;i<10000;i++){
72 fgFastAsin[2*i] = TMath::ASin(i/10000.);
73 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
77 Double_t AliTPCFastMath::FastAsin(Double_t x){
79 // return asin using lookup table
81 Int_t index = int(x*10000);
82 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
85 Int_t index = int(x*10000);
86 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
92 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
94 //update track information using current cluster - track->fCurrentCluster
97 AliTPCclusterMI* c =track->fCurrentCluster;
98 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
100 UInt_t i = track->fCurrentClusterIndex1;
102 Int_t sec=(i&0xff000000)>>24;
103 //Int_t row = (i&0x00ff0000)>>16;
104 track->fRow=(i&0x00ff0000)>>16;
105 track->fSector = sec;
106 // Int_t index = i&0xFFFF;
107 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
108 track->SetClusterIndex2(track->fRow, i);
109 //track->fFirstPoint = row;
110 //if ( track->fLastPoint<row) track->fLastPoint =row;
111 // if (track->fRow<0 || track->fRow>160) {
112 // printf("problem\n");
114 if (track->fFirstPoint>track->fRow)
115 track->fFirstPoint = track->fRow;
116 if (track->fLastPoint<track->fRow)
117 track->fLastPoint = track->fRow;
120 track->fClusterPointer[track->fRow] = c;
123 Float_t angle2 = track->GetSnp()*track->GetSnp();
124 angle2 = TMath::Sqrt(angle2/(1-angle2));
126 //SET NEW Track Point
130 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
132 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
133 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
134 point.SetErrY(sqrt(track->fErrorY2));
135 point.SetErrZ(sqrt(track->fErrorZ2));
137 point.SetX(track->GetX());
138 point.SetY(track->GetY());
139 point.SetZ(track->GetZ());
140 point.SetAngleY(angle2);
141 point.SetAngleZ(track->GetTgl());
142 if (point.fIsShared){
143 track->fErrorY2 *= 4;
144 track->fErrorZ2 *= 4;
148 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
150 track->fErrorY2 *= 1.3;
151 track->fErrorY2 += 0.01;
152 track->fErrorZ2 *= 1.3;
153 track->fErrorZ2 += 0.005;
155 if (accept>0) return 0;
156 if (track->GetNumberOfClusters()%20==0){
157 // if (track->fHelixIn){
158 // TClonesArray & larr = *(track->fHelixIn);
159 // Int_t ihelix = larr.GetEntriesFast();
160 // new(larr[ihelix]) AliHelix(*track) ;
163 track->fNoCluster =0;
164 return track->Update(c,chi2,i);
169 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
170 Float_t cory, Float_t corz)
173 // decide according desired precision to accept given
174 // cluster for tracking
175 Double_t sy2=ErrY2(seed,cluster)*cory;
176 Double_t sz2=ErrZ2(seed,cluster)*corz;
177 //sy2=ErrY2(seed,cluster)*cory;
178 //sz2=ErrZ2(seed,cluster)*cory;
180 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
181 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
183 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
184 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
185 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
186 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
188 Double_t rdistance2 = rdistancey2+rdistancez2;
191 if (rdistance2>16) return 3;
194 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
195 return 2; //suspisiouce - will be changed
197 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
198 // strict cut on overlaped cluster
199 return 2; //suspisiouce - will be changed
201 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
202 && cluster->GetType()<0){
212 //_____________________________________________________________________________
213 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
214 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
216 //---------------------------------------------------------------------
217 // The main TPC tracker constructor
218 //---------------------------------------------------------------------
219 fInnerSec=new AliTPCSector[fkNIS];
220 fOuterSec=new AliTPCSector[fkNOS];
223 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
224 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
231 Int_t nrowlow = par->GetNRowLow();
232 Int_t nrowup = par->GetNRowUp();
235 for (Int_t i=0;i<nrowlow;i++){
236 fXRow[i] = par->GetPadRowRadiiLow(i);
237 fPadLength[i]= par->GetPadPitchLength(0,i);
238 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
242 for (Int_t i=0;i<nrowup;i++){
243 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
244 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
245 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
258 //_____________________________________________________________________________
259 AliTPCtrackerMI::~AliTPCtrackerMI() {
260 //------------------------------------------------------------------
261 // TPC tracker destructor
262 //------------------------------------------------------------------
271 void AliTPCtrackerMI::SetIO()
275 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
277 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
279 AliTPCtrack *iotrack= new AliTPCtrack;
280 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
286 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
302 AliTPCtrack *iotrack= new AliTPCtrack;
303 // iotrack->fHelixIn = new TClonesArray("AliHelix");
304 //iotrack->fHelixOut = new TClonesArray("AliHelix");
305 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
308 if (output && (fDebug&2)){
309 //write the full seed information if specified in debug mode
311 fSeedTree = new TTree("Seeds","Seeds");
312 AliTPCseed * vseed = new AliTPCseed;
314 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
315 arrtr->ExpandCreateFast(160);
316 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
318 vseed->fPoints = arrtr;
319 vseed->fEPoints = arre;
320 // vseed->fClusterPoints = arrcl;
321 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
324 fTreeDebug = new TTree("trackDebug","trackDebug");
325 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
326 fTreeDebug->Branch("debug",&arrd,32000,99);
334 void AliTPCtrackerMI::FillESD(TObjArray* arr)
338 //fill esds using updated tracks
340 // write tracks to the event
341 // store index of the track
342 Int_t nseed=arr->GetEntriesFast();
343 for (Int_t i=0; i<nseed; i++) {
344 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
346 pt->PropagateTo(fParam->GetInnerRadiusLow());
347 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
349 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
350 //iotrack.SetTPCindex(i);
351 fEvent->AddTrack(&iotrack);
357 void AliTPCtrackerMI::WriteTracks(TTree * tree)
360 // write tracks from seed array to selected tree
364 AliTPCtrack *iotrack= new AliTPCtrack;
365 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
370 void AliTPCtrackerMI::WriteTracks()
373 // write tracks to the given output tree -
374 // output specified with SetIO routine
381 AliTPCtrack *iotrack= 0;
382 Int_t nseed=fSeeds->GetEntriesFast();
383 //for (Int_t i=0; i<nseed; i++) {
384 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
385 // if (iotrack) break;
387 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
388 TBranch * br = fOutput->GetBranch("tracks");
389 br->SetAddress(&iotrack);
391 for (Int_t i=0; i<nseed; i++) {
392 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
394 AliTPCtrack * track = new AliTPCtrack(*pt);
397 // br->SetAddress(&iotrack);
402 //fOutput->GetDirectory()->cd();
408 //write the full seed information if specified in debug mode
410 AliTPCseed * vseed = new AliTPCseed;
412 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
413 arrtr->ExpandCreateFast(160);
414 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
415 //arrcl->ExpandCreateFast(160);
416 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
418 vseed->fPoints = arrtr;
419 vseed->fEPoints = arre;
420 // vseed->fClusterPoints = arrcl;
421 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
422 TBranch * brseed = fSeedTree->GetBranch("seeds");
424 Int_t nseed=fSeeds->GetEntriesFast();
426 for (Int_t i=0; i<nseed; i++) {
427 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
430 // pt->fClusterPoints = arrcl;
434 brseed->SetAddress(&vseed);
438 // pt->fClusterPoints = 0;
441 if (fTreeDebug) fTreeDebug->Write();
449 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
452 //seed->SetErrorY2(0.1);
454 //calculate look-up table at the beginning
455 static Bool_t ginit = kFALSE;
456 static Float_t gnoise1,gnoise2,gnoise3;
457 static Float_t ggg1[10000];
458 static Float_t ggg2[10000];
459 static Float_t ggg3[10000];
460 static Float_t glandau1[10000];
461 static Float_t glandau2[10000];
462 static Float_t glandau3[10000];
464 static Float_t gcor01[500];
465 static Float_t gcor02[500];
466 static Float_t gcorp[500];
471 for (Int_t i=1;i<500;i++){
472 Float_t rsigma = float(i)/100.;
473 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
474 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
475 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
479 for (Int_t i=3;i<10000;i++){
483 Float_t amp = float(i);
484 Float_t padlength =0.75;
485 gnoise1 = 0.0004/padlength;
486 Float_t nel = 0.268*amp;
487 Float_t nprim = 0.155*amp;
488 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
489 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
490 if (glandau1[i]>1) glandau1[i]=1;
491 glandau1[i]*=padlength*padlength/12.;
495 gnoise2 = 0.0004/padlength;
498 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
499 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
500 if (glandau2[i]>1) glandau2[i]=1;
501 glandau2[i]*=padlength*padlength/12.;
506 gnoise3 = 0.0004/padlength;
509 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
510 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
511 if (glandau3[i]>1) glandau3[i]=1;
512 glandau3[i]*=padlength*padlength/12.;
520 Int_t amp = int(TMath::Abs(cl->GetQ()));
522 seed->SetErrorY2(1.);
526 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
527 Int_t ctype = cl->GetType();
528 Float_t padlength= GetPadPitchLength(seed->fRow);
529 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
530 angle2 = angle2/(1-angle2);
533 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
536 if (fSectors==fInnerSec){
538 res = ggg1[amp]*z+glandau1[amp]*angle2;
539 if (ctype==0) res *= gcor01[rsigmay];
542 res*= gcorp[rsigmay];
548 res = ggg2[amp]*z+glandau2[amp]*angle2;
549 if (ctype==0) res *= gcor02[rsigmay];
552 res*= gcorp[rsigmay];
557 res = ggg3[amp]*z+glandau3[amp]*angle2;
558 if (ctype==0) res *= gcor02[rsigmay];
561 res*= gcorp[rsigmay];
568 res*=2.4; // overestimate error 2 times
575 seed->SetErrorY2(res);
583 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
586 //seed->SetErrorY2(0.1);
588 //calculate look-up table at the beginning
589 static Bool_t ginit = kFALSE;
590 static Float_t gnoise1,gnoise2,gnoise3;
591 static Float_t ggg1[10000];
592 static Float_t ggg2[10000];
593 static Float_t ggg3[10000];
594 static Float_t glandau1[10000];
595 static Float_t glandau2[10000];
596 static Float_t glandau3[10000];
598 static Float_t gcor01[1000];
599 static Float_t gcor02[1000];
600 static Float_t gcorp[1000];
605 for (Int_t i=1;i<1000;i++){
606 Float_t rsigma = float(i)/100.;
607 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
608 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
609 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
613 for (Int_t i=3;i<10000;i++){
617 Float_t amp = float(i);
618 Float_t padlength =0.75;
619 gnoise1 = 0.0004/padlength;
620 Float_t nel = 0.268*amp;
621 Float_t nprim = 0.155*amp;
622 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
623 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
624 if (glandau1[i]>1) glandau1[i]=1;
625 glandau1[i]*=padlength*padlength/12.;
629 gnoise2 = 0.0004/padlength;
632 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
633 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
634 if (glandau2[i]>1) glandau2[i]=1;
635 glandau2[i]*=padlength*padlength/12.;
640 gnoise3 = 0.0004/padlength;
643 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
644 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
645 if (glandau3[i]>1) glandau3[i]=1;
646 glandau3[i]*=padlength*padlength/12.;
654 Int_t amp = int(TMath::Abs(cl->GetQ()));
656 seed->SetErrorY2(1.);
660 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
661 Int_t ctype = cl->GetType();
662 Float_t padlength= GetPadPitchLength(seed->fRow);
664 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
665 // if (angle2<0.6) angle2 = 0.6;
666 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
669 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
672 if (fSectors==fInnerSec){
674 res = ggg1[amp]*z+glandau1[amp]*angle2;
675 if (ctype==0) res *= gcor01[rsigmaz];
678 res*= gcorp[rsigmaz];
684 res = ggg2[amp]*z+glandau2[amp]*angle2;
685 if (ctype==0) res *= gcor02[rsigmaz];
688 res*= gcorp[rsigmaz];
693 res = ggg3[amp]*z+glandau3[amp]*angle2;
694 if (ctype==0) res *= gcor02[rsigmaz];
697 res*= gcorp[rsigmaz];
706 if ((ctype<0) &&<70){
714 seed->SetErrorZ2(res);
721 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
724 //seed->SetErrorZ2(0.1);
728 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
730 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
731 Int_t ctype = cl->GetType();
732 Float_t amp = TMath::Abs(cl->GetQ());
737 Float_t landau=2 ; //landau fluctuation part
738 Float_t gg=2; // gg fluctuation part
739 Float_t padlength= GetPadPitchLength(seed->GetX());
741 if (fSectors==fInnerSec){
742 snoise2 = 0.0004/padlength;
745 gg = (2+0.001*nel/(padlength*padlength))/nel;
746 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
747 if (landau>1) landau=1;
750 snoise2 = 0.0004/padlength;
753 gg = (2+0.0008*nel/(padlength*padlength))/nel;
754 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
755 if (landau>1) landau=1;
757 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
760 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
761 angle2 = TMath::Sqrt((1-angle2));
762 if (angle2<0.6) angle2 = 0.6;
765 Float_t angle = seed->GetTgl()/angle2;
766 Float_t angular = landau*angle*angle*padlength*padlength/12.;
767 Float_t res = sdiff + angular;
770 if ((ctype==0) && (fSectors ==fOuterSec))
771 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
773 if ((ctype==0) && (fSectors ==fInnerSec))
774 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
778 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
784 if ((ctype<0) &&<70){
792 seed->SetErrorZ2(res);
799 void AliTPCseed::Reset(Bool_t all)
803 SetNumberOfClusters(0);
809 for (Int_t i=0;i<8;i++){
810 delete [] fTrackPoints[i];
818 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
819 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
825 void AliTPCseed::Modify(Double_t factor)
828 //------------------------------------------------------------------
829 //This function makes a track forget its history :)
830 //------------------------------------------------------------------
836 fC10*=0; fC11*=factor;
837 fC20*=0; fC21*=0; fC22*=factor;
838 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
839 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
840 SetNumberOfClusters(0);
844 fCurrentSigmaY2 = 0.000005;
845 fCurrentSigmaZ2 = 0.000005;
854 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
856 //-----------------------------------------------------------------
857 // This function find proloncation of a track to a reference plane x=xk.
858 // doesn't change internal state of the track
859 //-----------------------------------------------------------------
861 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
863 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
867 // Double_t y1=fP0, z1=fP1;
868 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
869 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
873 //y += dx*(c1+c2)/(r1+r2);
874 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
876 Double_t dy = dx*(c1+c2)/(r1+r2);
879 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
881 if (TMath::Abs(delta)>0.0001){
882 dz = fP3*TMath::ASin(delta)/fP4;
884 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
887 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
897 //_____________________________________________________________________________
898 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
900 //-----------------------------------------------------------------
901 // This function calculates a predicted chi2 increment.
902 //-----------------------------------------------------------------
903 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
904 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
905 r00+=fC00; r01+=fC10; r11+=fC11;
907 Double_t det=r00*r11 - r01*r01;
908 if (TMath::Abs(det) < 1.e-10) {
909 Int_t n=GetNumberOfClusters();
910 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
913 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
915 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
917 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
921 //_________________________________________________________________________________________
924 Int_t AliTPCseed::Compare(const TObject *o) const {
925 //-----------------------------------------------------------------
926 // This function compares tracks according to the sector - for given sector according z
927 //-----------------------------------------------------------------
928 AliTPCseed *t=(AliTPCseed*)o;
931 if (t->fRelativeSector>fRelativeSector) return -1;
932 if (t->fRelativeSector<fRelativeSector) return 1;
933 Double_t z2 = t->GetZ();
934 Double_t z1 = GetZ();
936 if (z2<z1) return -1;
941 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
942 if (t->fBConstrain) f2=1.2;
945 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
947 if (fBConstrain) f1=1.2;
949 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
954 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
956 //rotate to track "local coordinata
957 Float_t x = seed->GetX();
958 Float_t y = seed->GetY();
959 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
962 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
963 if (!seed->Rotate(fSectors->GetAlpha()))
965 } else if (y <-ymax) {
966 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
967 if (!seed->Rotate(-fSectors->GetAlpha()))
976 //_____________________________________________________________________________
977 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
978 //-----------------------------------------------------------------
979 // This function associates a cluster with this track.
980 //-----------------------------------------------------------------
981 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
983 r00+=fC00; r01+=fC10; r11+=fC11;
984 Double_t det=r00*r11 - r01*r01;
985 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
987 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
988 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
989 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
990 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
991 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
993 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
994 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
995 if (TMath::Abs(cur*fX-eta) >= 0.9) {
999 fP0 += k00*dy + k01*dz;
1000 fP1 += k10*dy + k11*dz;
1002 fP3 += k30*dy + k31*dz;
1005 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1006 Double_t c12=fC21, c13=fC31, c14=fC41;
1008 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1009 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1010 fC40-=k00*c04+k01*c14;
1012 fC11-=k10*c01+k11*fC11;
1013 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1014 fC41-=k10*c04+k11*c14;
1016 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1017 fC42-=k20*c04+k21*c14;
1019 fC33-=k30*c03+k31*c13;
1020 fC43-=k40*c03+k41*c13;
1022 fC44-=k40*c04+k41*c14;
1024 Int_t n=GetNumberOfClusters();
1026 SetNumberOfClusters(n+1);
1027 SetChi2(GetChi2()+chisq);
1034 //_____________________________________________________________________________
1035 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1036 Double_t x2,Double_t y2,
1037 Double_t x3,Double_t y3)
1039 //-----------------------------------------------------------------
1040 // Initial approximation of the track curvature
1041 //-----------------------------------------------------------------
1042 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1043 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1044 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1045 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1046 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1048 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1049 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1050 return -xr*yr/sqrt(xr*xr+yr*yr);
1055 //_____________________________________________________________________________
1056 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1057 Double_t x2,Double_t y2,
1058 Double_t x3,Double_t y3)
1060 //-----------------------------------------------------------------
1061 // Initial approximation of the track curvature
1062 //-----------------------------------------------------------------
1068 Double_t det = x3*y2-x2*y3;
1073 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1074 Double_t x0 = x3*0.5-y3*u;
1075 Double_t y0 = y3*0.5+x3*u;
1076 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1082 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1083 Double_t x2,Double_t y2,
1084 Double_t x3,Double_t y3)
1086 //-----------------------------------------------------------------
1087 // Initial approximation of the track curvature
1088 //-----------------------------------------------------------------
1094 Double_t det = x3*y2-x2*y3;
1099 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1100 Double_t x0 = x3*0.5-y3*u;
1101 Double_t y0 = y3*0.5+x3*u;
1102 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1111 //_____________________________________________________________________________
1112 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1113 Double_t x2,Double_t y2,
1114 Double_t x3,Double_t y3)
1116 //-----------------------------------------------------------------
1117 // Initial approximation of the track curvature times center of curvature
1118 //-----------------------------------------------------------------
1119 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1120 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1121 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1122 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1123 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1125 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1127 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1130 //_____________________________________________________________________________
1131 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1132 Double_t x2,Double_t y2,
1133 Double_t z1,Double_t z2)
1135 //-----------------------------------------------------------------
1136 // Initial approximation of the tangent of the track dip angle
1137 //-----------------------------------------------------------------
1138 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1142 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1143 Double_t x2,Double_t y2,
1144 Double_t z1,Double_t z2, Double_t c)
1146 //-----------------------------------------------------------------
1147 // Initial approximation of the tangent of the track dip angle
1148 //-----------------------------------------------------------------
1152 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1154 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1155 if (TMath::Abs(d*c*0.5)>1) return 0;
1156 // Double_t angle2 = TMath::ASin(d*c*0.5);
1157 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1158 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1160 angle2 = (z1-z2)*c/(angle2*2.);
1164 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1165 {//-----------------------------------------------------------------
1166 // This function find proloncation of a track to a reference plane x=x2.
1167 //-----------------------------------------------------------------
1171 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1175 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1176 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1180 Double_t dy = dx*(c1+c2)/(r1+r2);
1183 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1185 if (TMath::Abs(delta)>0.01){
1186 dz = x[3]*TMath::ASin(delta)/x[4];
1188 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1191 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1199 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1204 return LoadClusters();
1207 Int_t AliTPCtrackerMI::LoadClusters()
1210 // load clusters to the memory
1211 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1212 clrow->SetClass("AliTPCclusterMI");
1214 clrow->GetArray()->ExpandCreateFast(10000);
1216 // TTree * tree = fClustersArray.GetTree();
1218 TTree * tree = fInput;
1219 TBranch * br = tree->GetBranch("Segment");
1220 br->SetAddress(&clrow);
1222 Int_t j=Int_t(tree->GetEntries());
1223 for (Int_t i=0; i<j; i++) {
1227 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1229 AliTPCRow * tpcrow=0;
1232 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1236 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1237 left = (sec-fkNIS*2)/fkNOS;
1240 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1241 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1242 for (Int_t i=0;i<tpcrow->fN1;i++)
1243 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1246 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1247 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1248 for (Int_t i=0;i<tpcrow->fN2;i++)
1249 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1260 void AliTPCtrackerMI::UnloadClusters()
1263 // unload clusters from the memory
1265 Int_t nrows = fOuterSec->GetNRows();
1266 for (Int_t sec = 0;sec<fkNOS;sec++)
1267 for (Int_t row = 0;row<nrows;row++){
1268 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1270 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1271 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1273 tpcrow->ResetClusters();
1276 nrows = fInnerSec->GetNRows();
1277 for (Int_t sec = 0;sec<fkNIS;sec++)
1278 for (Int_t row = 0;row<nrows;row++){
1279 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1281 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1282 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1284 tpcrow->ResetClusters();
1291 //_____________________________________________________________________________
1292 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1293 //-----------------------------------------------------------------
1294 // This function fills outer TPC sectors with clusters.
1295 //-----------------------------------------------------------------
1296 Int_t nrows = fOuterSec->GetNRows();
1298 for (Int_t sec = 0;sec<fkNOS;sec++)
1299 for (Int_t row = 0;row<nrows;row++){
1300 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1301 Int_t sec2 = sec+2*fkNIS;
1303 Int_t ncl = tpcrow->fN1;
1305 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1306 index=(((sec2<<8)+row)<<16)+ncl;
1307 tpcrow->InsertCluster(c,index);
1312 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1313 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1314 tpcrow->InsertCluster(c,index);
1317 // write indexes for fast acces
1319 for (Int_t i=0;i<510;i++)
1320 tpcrow->fFastCluster[i]=-1;
1321 for (Int_t i=0;i<tpcrow->GetN();i++){
1322 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1323 tpcrow->fFastCluster[zi]=i; // write index
1326 for (Int_t i=0;i<510;i++){
1327 if (tpcrow->fFastCluster[i]<0)
1328 tpcrow->fFastCluster[i] = last;
1330 last = tpcrow->fFastCluster[i];
1339 //_____________________________________________________________________________
1340 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1341 //-----------------------------------------------------------------
1342 // This function fills inner TPC sectors with clusters.
1343 //-----------------------------------------------------------------
1344 Int_t nrows = fInnerSec->GetNRows();
1346 for (Int_t sec = 0;sec<fkNIS;sec++)
1347 for (Int_t row = 0;row<nrows;row++){
1348 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1351 Int_t ncl = tpcrow->fN1;
1353 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1354 index=(((sec<<8)+row)<<16)+ncl;
1355 tpcrow->InsertCluster(c,index);
1360 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1361 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1362 tpcrow->InsertCluster(c,index);
1365 // write indexes for fast acces
1367 for (Int_t i=0;i<510;i++)
1368 tpcrow->fFastCluster[i]=-1;
1369 for (Int_t i=0;i<tpcrow->GetN();i++){
1370 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1371 tpcrow->fFastCluster[zi]=i; // write index
1374 for (Int_t i=0;i<510;i++){
1375 if (tpcrow->fFastCluster[i]<0)
1376 tpcrow->fFastCluster[i] = last;
1378 last = tpcrow->fFastCluster[i];
1390 //_________________________________________________________________________
1391 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1392 //--------------------------------------------------------------------
1393 // Return pointer to a given cluster
1394 //--------------------------------------------------------------------
1395 Int_t sec=(index&0xff000000)>>24;
1396 Int_t row=(index&0x00ff0000)>>16;
1397 Int_t ncl=(index&0x00007fff)>>00;
1399 const AliTPCRow * tpcrow=0;
1400 AliTPCclusterMI * clrow =0;
1402 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1404 clrow = tpcrow->fClusters1;
1406 clrow = tpcrow->fClusters2;
1409 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1410 if (sec-2*fkNIS<fkNOS)
1411 clrow = tpcrow->fClusters1;
1413 clrow = tpcrow->fClusters2;
1415 if (tpcrow==0) return 0;
1416 if (tpcrow->GetN()<=ncl) return 0;
1417 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1418 return &(clrow[ncl]);
1424 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1425 //-----------------------------------------------------------------
1426 // This function tries to find a track prolongation to next pad row
1427 //-----------------------------------------------------------------
1429 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1430 AliTPCclusterMI *cl=0;
1431 Int_t tpcindex= t.GetClusterIndex2(nr);
1433 // update current shape info every 5 pad-row
1434 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1438 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1440 if (tpcindex==-1) return 0; //track in dead zone
1442 cl = t.fClusterPointer[nr];
1443 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1444 t.fCurrentClusterIndex1 = tpcindex;
1447 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1448 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1450 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1451 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1453 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1454 Double_t rotation = angle-t.GetAlpha();
1455 t.fRelativeSector= relativesector;
1460 t.fCurrentCluster = cl;
1462 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1463 if ((tpcindex&0x8000)==0) accept =0;
1465 //if founded cluster is acceptible
1466 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1473 UpdateTrack(&t,accept);
1478 if (fIteration>1) return 0; // not look for new cluster during refitting
1481 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1482 Double_t y=t.GetYat(x);
1483 if (TMath::Abs(y)>ymax){
1485 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1486 if (!t.Rotate(fSectors->GetAlpha()))
1488 } else if (y <-ymax) {
1489 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1490 if (!t.Rotate(-fSectors->GetAlpha()))
1496 if (!t.PropagateTo(x)) {
1497 if (fIteration==0) t.fRemoval = 10;
1501 Double_t z=t.GetZ();
1503 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1504 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1506 Double_t roadz = 1.;
1508 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1510 t.SetClusterIndex2(nr,-1);
1515 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1521 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1522 cl = krow.FindNearest2(y,z,roady,roadz,index);
1523 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1526 t.fCurrentCluster = cl;
1528 if (fIteration==2&&cl->IsUsed(10)) return 0;
1529 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1530 if (fIteration==2&&cl->IsUsed(11)) {
1537 if (t.fCurrentCluster->IsUsed(10)){
1542 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1548 if (accept<3) UpdateTrack(&t,accept);
1551 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1557 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1558 //-----------------------------------------------------------------
1559 // This function tries to find a track prolongation to next pad row
1560 //-----------------------------------------------------------------
1562 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1564 if (!t.GetProlongation(x,y,z)) {
1570 if (TMath::Abs(y)>ymax){
1573 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1574 if (!t.Rotate(fSectors->GetAlpha()))
1576 } else if (y <-ymax) {
1577 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1578 if (!t.Rotate(-fSectors->GetAlpha()))
1581 if (!t.PropagateTo(x)) {
1584 t.GetProlongation(x,y,z);
1587 // update current shape info every 3 pad-row
1588 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1589 // t.fCurrentSigmaY = GetSigmaY(&t);
1590 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1594 AliTPCclusterMI *cl=0;
1599 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1600 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1602 Double_t roadz = 1.;
1605 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1607 t.SetClusterIndex2(row,-1);
1612 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1616 if ((cl==0)&&(krow)) {
1617 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1618 cl = krow.FindNearest2(y,z,roady,roadz,index);
1620 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1624 t.fCurrentCluster = cl;
1625 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1627 t.SetClusterIndex2(row,index);
1628 t.fClusterPointer[row] = cl;
1636 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1637 //-----------------------------------------------------------------
1638 // This function tries to find a track prolongation to next pad row
1639 //-----------------------------------------------------------------
1640 t.fCurrentCluster = 0;
1641 t.fCurrentClusterIndex1 = 0;
1643 Double_t xt=t.GetX();
1644 Int_t row = GetRowNumber(xt)-1;
1645 Double_t ymax= GetMaxY(nr);
1647 if (row < nr) return 1; // don't prolongate if not information until now -
1648 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1650 return 0; // not prolongate strongly inclined tracks
1652 if (TMath::Abs(t.GetSnp())>0.95) {
1654 return 0; // not prolongate strongly inclined tracks
1657 Double_t x= GetXrow(nr);
1659 //t.PropagateTo(x+0.02);
1660 //t.PropagateTo(x+0.01);
1661 if (!t.PropagateTo(x)){
1668 if (TMath::Abs(y)>ymax){
1670 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1671 if (!t.Rotate(fSectors->GetAlpha()))
1673 } else if (y <-ymax) {
1674 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1675 if (!t.Rotate(-fSectors->GetAlpha()))
1678 // if (!t.PropagateTo(x)){
1686 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1688 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1690 t.SetClusterIndex2(nr,-1);
1695 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1701 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1702 // t.fCurrentSigmaY = GetSigmaY(&t);
1703 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1707 AliTPCclusterMI *cl=0;
1710 Double_t roady = 1.;
1711 Double_t roadz = 1.;
1715 index = t.GetClusterIndex2(nr);
1716 if ( (index>0) && (index&0x8000)==0){
1717 cl = t.fClusterPointer[nr];
1718 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1719 t.fCurrentClusterIndex1 = index;
1721 t.fCurrentCluster = cl;
1728 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1729 cl = krow.FindNearest2(y,z,roady,roadz,index);
1732 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1733 t.fCurrentCluster = cl;
1739 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1740 //-----------------------------------------------------------------
1741 // This function tries to find a track prolongation to next pad row
1742 //-----------------------------------------------------------------
1744 //update error according neighborhoud
1746 if (t.fCurrentCluster) {
1748 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1750 if (t.fCurrentCluster->IsUsed(10)){
1756 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1761 if (fIteration>0) accept = 0;
1762 if (accept<3) UpdateTrack(&t,accept);
1766 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1767 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1769 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1777 //_____________________________________________________________________________
1778 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1779 //-----------------------------------------------------------------
1780 // This function tries to find a track prolongation.
1781 //-----------------------------------------------------------------
1782 Double_t xt=t.GetX();
1784 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1785 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1786 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1788 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1790 Int_t first = GetRowNumber(xt)-1;
1791 for (Int_t nr= first; nr>=rf; nr-=step) {
1792 if (nr<fInnerSec->GetNRows())
1793 fSectors = fInnerSec;
1795 fSectors = fOuterSec;
1796 if (FollowToNext(t,nr)==0)
1805 //_____________________________________________________________________________
1806 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1807 //-----------------------------------------------------------------
1808 // This function tries to find a track prolongation.
1809 //-----------------------------------------------------------------
1810 Double_t xt=t.GetX();
1812 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1813 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1814 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1815 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1817 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1819 if (FollowToNextFast(t,nr)==0)
1820 if (!t.IsActive()) return 0;
1830 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1831 //-----------------------------------------------------------------
1832 // This function tries to find a track prolongation.
1833 //-----------------------------------------------------------------
1834 // Double_t xt=t.GetX();
1836 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1837 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1838 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1839 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1841 Int_t first = t.fFirstPoint;
1843 if (first<0) first=0;
1844 for (Int_t nr=first; nr<=rf; nr++) {
1845 //if ( (t.GetSnp()<0.9))
1846 if (nr<fInnerSec->GetNRows())
1847 fSectors = fInnerSec;
1849 fSectors = fOuterSec;
1859 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1867 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1870 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1872 Float_t distance = TMath::Sqrt(dz2+dy2);
1873 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1876 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1877 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1882 if (firstpoint>lastpoint) {
1883 firstpoint =lastpoint;
1888 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1889 if (s1->GetClusterIndex2(i)>0) sum1++;
1890 if (s2->GetClusterIndex2(i)>0) sum2++;
1891 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1895 if (sum<5) return 0;
1897 Float_t summin = TMath::Min(sum1+1,sum2+1);
1898 Float_t ratio = (sum+1)/Float_t(summin);
1902 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1906 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1907 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1909 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1911 Float_t dy2 =(s1->GetY() - s2->GetY());
1913 Float_t distance = dz2+dy2;
1914 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1919 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1920 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1922 if (firstpoint>=lastpoint-5) return;;
1924 for (Int_t i=firstpoint;i<lastpoint;i++){
1925 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1926 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1933 for (Int_t i=firstpoint;i<lastpoint;i++){
1934 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1935 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1936 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1937 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1938 if (s1->IsActive()&&s2->IsActive()){
1939 p1->fIsShared = kTRUE;
1940 p2->fIsShared = kTRUE;
1947 for (Int_t i=0;i<4;i++){
1948 if (s1->fOverlapLabels[3*i]==0){
1949 s1->fOverlapLabels[3*i] = s2->GetLabel();
1950 s1->fOverlapLabels[3*i+1] = sumshared;
1951 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1955 for (Int_t i=0;i<4;i++){
1956 if (s2->fOverlapLabels[3*i]==0){
1957 s2->fOverlapLabels[3*i] = s1->GetLabel();
1958 s2->fOverlapLabels[3*i+1] = sumshared;
1959 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1967 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1970 //sort trackss according sectors
1972 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1973 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1975 //if (pt) RotateToLocal(pt);
1979 arr->Sort(); // sorting according z
1980 arr->Expand(arr->GetEntries());
1983 Int_t nseed=arr->GetEntriesFast();
1984 for (Int_t i=0; i<nseed; i++) {
1985 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1987 for (Int_t j=0;j<=12;j++){
1988 pt->fOverlapLabels[j] =0;
1991 for (Int_t i=0; i<nseed; i++) {
1992 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1994 if (pt->fRemoval>10) continue;
1995 for (Int_t j=i+1; j<nseed; j++){
1996 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1998 if (pt2->fRemoval<=10) {
1999 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2006 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2009 //sort trackss according sectors
2012 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2015 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2016 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2021 arr->Sort(); // sorting according z
2022 arr->Expand(arr->GetEntries());
2024 //reset overlap labels
2026 Int_t nseed=arr->GetEntriesFast();
2027 for (Int_t i=0; i<nseed; i++) {
2028 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2031 for (Int_t j=0;j<=12;j++){
2032 pt->fOverlapLabels[j] =0;
2036 //sign shared tracks
2037 for (Int_t i=0; i<nseed; i++) {
2038 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2040 if (pt->fRemoval>10) continue;
2041 Float_t deltac = pt->GetC()*0.1;
2042 for (Int_t j=i+1; j<nseed; j++){
2043 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2045 if (pt2->fRemoval<=10) {
2046 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2047 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2048 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2055 // remove highly shared tracks
2056 for (Int_t i=0; i<nseed; i++) {
2057 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2059 if (pt->fRemoval>10) continue;
2062 for (Int_t j=0;j<4;j++){
2063 sumshared = pt->fOverlapLabels[j*3+1];
2065 Float_t factor = factor1;
2066 if (pt->fRemoval>0) factor = factor2;
2067 if (sumshared/pt->GetNumberOfClusters()>factor){
2068 for (Int_t j=0;j<4;j++){
2069 if (pt->fOverlapLabels[3*j]==0) continue;
2070 if (pt->fOverlapLabels[3*j+1]<5) continue;
2071 if (pt->fRemoval==removalindex) continue;
2072 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2074 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2075 // pt->fRemoval = removalindex;
2076 delete arr->RemoveAt(i);
2084 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2093 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2096 //sort tracks in array according mode criteria
2097 Int_t nseed = arr->GetEntriesFast();
2098 for (Int_t i=0; i<nseed; i++) {
2099 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2109 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2112 //Loop over all tracks and remove "overlaps"
2115 Int_t nseed = arr->GetEntriesFast();
2118 for (Int_t i=0; i<nseed; i++) {
2119 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2121 delete arr->RemoveAt(i);
2125 pt->fBSigned = kFALSE;
2129 nseed = arr->GetEntriesFast();
2136 for (Int_t i=0; i<nseed; i++) {
2137 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2141 Int_t found,foundable,shared;
2143 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2145 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2147 Double_t factor = factor2;
2148 if (pt->fBConstrain) factor = factor1;
2150 if ((Float_t(shared)/Float_t(found))>factor){
2151 pt->Desactivate(removalindex);
2156 for (Int_t i=0; i<160; i++) {
2157 Int_t index=pt->GetClusterIndex2(i);
2158 if (index<0 || index&0x8000 ) continue;
2159 AliTPCclusterMI *c= pt->fClusterPointer[i];
2161 // if (!c->IsUsed(10)) c->Use(10);
2162 //if (pt->IsActive())
2171 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2175 void AliTPCtrackerMI::UnsignClusters()
2178 // loop over all clusters and unsign them
2181 for (Int_t sec=0;sec<fkNIS;sec++){
2182 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2183 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2184 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2185 // if (cl[icl].IsUsed(10))
2187 cl = fInnerSec[sec][row].fClusters2;
2188 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2189 //if (cl[icl].IsUsed(10))
2194 for (Int_t sec=0;sec<fkNOS;sec++){
2195 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2196 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2197 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2198 //if (cl[icl].IsUsed(10))
2200 cl = fOuterSec[sec][row].fClusters2;
2201 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2202 //if (cl[icl].IsUsed(10))
2211 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2214 //sign clusters to be "used"
2216 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2217 // loop over "primaries"
2231 Int_t nseed = arr->GetEntriesFast();
2232 for (Int_t i=0; i<nseed; i++) {
2233 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2237 if (!(pt->IsActive())) continue;
2238 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2239 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2241 sumdens2+= dens*dens;
2242 sumn += pt->GetNumberOfClusters();
2243 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2244 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2247 sumchi2 +=chi2*chi2;
2252 Float_t mdensity = 0.9;
2253 Float_t meann = 130;
2254 Float_t meanchi = 1;
2255 Float_t sdensity = 0.1;
2256 Float_t smeann = 10;
2257 Float_t smeanchi =0.4;
2261 mdensity = sumdens/sum;
2263 meanchi = sumchi/sum;
2265 sdensity = sumdens2/sum-mdensity*mdensity;
2266 sdensity = TMath::Sqrt(sdensity);
2268 smeann = sumn2/sum-meann*meann;
2269 smeann = TMath::Sqrt(smeann);
2271 smeanchi = sumchi2/sum - meanchi*meanchi;
2272 smeanchi = TMath::Sqrt(smeanchi);
2276 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2278 for (Int_t i=0; i<nseed; i++) {
2279 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2283 if (pt->fBSigned) continue;
2284 if (pt->fBConstrain) continue;
2285 //if (!(pt->IsActive())) continue;
2287 Int_t found,foundable,shared;
2288 pt->GetClusterStatistic(0,160,found, foundable,shared);
2289 if (shared/float(found)>0.3) {
2290 if (shared/float(found)>0.9 ){
2291 //delete arr->RemoveAt(i);
2296 Bool_t isok =kFALSE;
2297 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2299 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2301 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2303 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2307 for (Int_t i=0; i<160; i++) {
2308 Int_t index=pt->GetClusterIndex2(i);
2309 if (index<0) continue;
2310 AliTPCclusterMI *c= pt->fClusterPointer[i];
2312 //if (!(c->IsUsed(10))) c->Use();
2319 Double_t maxchi = meanchi+2.*smeanchi;
2321 for (Int_t i=0; i<nseed; i++) {
2322 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2326 //if (!(pt->IsActive())) continue;
2327 if (pt->fBSigned) continue;
2328 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2329 if (chi>maxchi) continue;
2332 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2334 //sign only tracks with enoug big density at the beginning
2336 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2339 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2340 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2342 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2343 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2346 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2347 //Int_t noc=pt->GetNumberOfClusters();
2348 pt->fBSigned = kTRUE;
2349 for (Int_t i=0; i<160; i++) {
2351 Int_t index=pt->GetClusterIndex2(i);
2352 if (index<0) continue;
2353 AliTPCclusterMI *c= pt->fClusterPointer[i];
2355 // if (!(c->IsUsed(10))) c->Use();
2360 // gLastCheck = nseed;
2368 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2370 // stop not active tracks
2371 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2372 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2373 Int_t nseed = arr->GetEntriesFast();
2375 for (Int_t i=0; i<nseed; i++) {
2376 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2380 if (!(pt->IsActive())) continue;
2381 StopNotActive(pt,row0,th0, th1,th2);
2387 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2390 // stop not active tracks
2391 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2392 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2395 Int_t foundable = 0;
2396 Int_t maxindex = seed->fLastPoint; //last foundable row
2397 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2398 seed->Desactivate(10) ;
2402 for (Int_t i=row0; i<maxindex; i++){
2403 Int_t index = seed->GetClusterIndex2(i);
2404 if (index!=-1) foundable++;
2406 if (foundable<=30) sumgood1++;
2407 if (foundable<=50) {
2414 if (foundable>=30.){
2415 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2418 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2422 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2425 // back propagation of ESD tracks
2431 //PrepareForProlongation(fSeeds,1);
2432 PropagateForward2(fSeeds);
2434 Int_t nseed = fSeeds->GetEntriesFast();
2435 for (Int_t i=0;i<nseed;i++){
2436 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2437 if (!seed) continue;
2438 seed->PropagateTo(fParam->GetInnerRadiusLow());
2439 AliESDtrack *esd=event->GetTrack(i);
2440 seed->CookdEdx(0.02,0.6);
2441 CookLabel(seed,0.1); //For comparison only
2442 if (seed->GetNumberOfClusters()>60){
2443 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2447 //printf("problem\n");
2450 Info("RefitInward","Number of refitted tracks %d",ntracks);
2457 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2460 // back propagation of ESD tracks
2466 PropagateBack(fSeeds);
2467 Int_t nseed = fSeeds->GetEntriesFast();
2469 for (Int_t i=0;i<nseed;i++){
2470 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2471 if (!seed) continue;
2472 AliESDtrack *esd=event->GetTrack(i);
2473 seed->CookdEdx(0.02,0.6);
2474 CookLabel(seed,0.1); //For comparison only
2475 if (seed->GetNumberOfClusters()>60){
2476 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2480 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2487 void AliTPCtrackerMI::DeleteSeeds()
2491 Int_t nseed = fSeeds->GetEntriesFast();
2492 for (Int_t i=0;i<nseed;i++){
2493 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2494 if (seed) delete fSeeds->RemoveAt(i);
2500 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2503 //read seeds from the event
2505 Int_t nentr=event->GetNumberOfTracks();
2507 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2512 fSeeds = new TObjArray(nentr);
2516 for (Int_t i=0; i<nentr; i++) {
2517 AliESDtrack *esd=event->GetTrack(i);
2518 ULong_t status=esd->GetStatus();
2519 AliTPCtrack t(*esd);
2520 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2521 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2522 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2523 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2528 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2529 Double_t par0[5],par1[5],x;
2530 esd->GetInnerExternalParameters(x,par0);
2531 esd->GetExternalParameters(x,par1);
2532 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2533 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2534 //reset covariance if suspicious
2535 if ( (delta1>0.1) || (delta2>0.006))
2536 seed->ResetCovariance();
2541 // rotate to the local coordinate system
2543 fSectors=fInnerSec; fN=fkNIS;
2545 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2546 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2547 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2548 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2549 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2550 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2551 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2552 alpha-=seed->GetAlpha();
2553 if (!seed->Rotate(alpha)) {
2559 //seed->PropagateTo(fSectors->GetX(0));
2561 // Int_t index = esd->GetTPCindex();
2562 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2563 //if (direction==2){
2564 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2572 for (Int_t irow=0;irow<160;irow++){
2573 Int_t index = seed->GetClusterIndex2(irow);
2576 AliTPCclusterMI * cl = GetClusterMI(index);
2577 seed->fClusterPointer[irow] = cl;
2579 if ((index & 0x8000)==0){
2580 cl->Use(10); // accepted cluster
2582 cl->Use(6); // close cluster not accepted
2585 Info("ReadSeeds","Not found cluster");
2589 fSeeds->AddAt(seed,i);
2595 //_____________________________________________________________________________
2596 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2597 Float_t deltay, Int_t ddsec) {
2598 //-----------------------------------------------------------------
2599 // This function creates track seeds.
2600 // SEEDING WITH VERTEX CONSTRAIN
2601 //-----------------------------------------------------------------
2602 // cuts[0] - fP4 cut
2603 // cuts[1] - tan(phi) cut
2604 // cuts[2] - zvertex cut
2605 // cuts[3] - fP3 cut
2613 Double_t x[5], c[15];
2614 // Int_t di = i1-i2;
2616 AliTPCseed * seed = new AliTPCseed;
2617 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2618 Double_t cs=cos(alpha), sn=sin(alpha);
2620 // Double_t x1 =fOuterSec->GetX(i1);
2621 //Double_t xx2=fOuterSec->GetX(i2);
2623 Double_t x1 =GetXrow(i1);
2624 Double_t xx2=GetXrow(i2);
2626 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2628 Int_t imiddle = (i2+i1)/2; //middle pad row index
2629 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2630 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2634 const AliTPCRow& kr1=GetRow(ns,i1);
2635 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2636 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2639 // change cut on curvature if it can't reach this layer
2640 // maximal curvature set to reach it
2641 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2642 if (dvertexmax*0.5*cuts[0]>0.85){
2643 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2645 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2648 if (deltay>0) ddsec = 0;
2649 // loop over clusters
2650 for (Int_t is=0; is < kr1; is++) {
2652 if (kr1[is]->IsUsed(10)) continue;
2653 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2654 //if (TMath::Abs(y1)>ymax) continue;
2656 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2658 // find possible directions
2659 Float_t anglez = (z1-z3)/(x1-x3);
2660 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2663 //find rotation angles relative to line given by vertex and point 1
2664 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2665 Double_t dvertex = TMath::Sqrt(dvertex2);
2666 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2667 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2670 // loop over 2 sectors
2676 Double_t dddz1=0; // direction of delta inclination in z axis
2683 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2684 Int_t sec2 = sec + dsec;
2686 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2687 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2688 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2689 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2690 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2691 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2693 // rotation angles to p1-p3
2694 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2695 Double_t x2, y2, z2;
2697 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2700 Double_t dxx0 = (xx2-x3)*cs13r;
2701 Double_t dyy0 = (xx2-x3)*sn13r;
2702 for (Int_t js=index1; js < index2; js++) {
2703 const AliTPCclusterMI *kcl = kr2[js];
2704 if (kcl->IsUsed(10)) continue;
2706 //calcutate parameters
2708 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2710 if (TMath::Abs(yy0)<0.000001) continue;
2711 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2712 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2713 Double_t r02 = (0.25+y0*y0)*dvertex2;
2714 //curvature (radius) cut
2715 if (r02<r2min) continue;
2719 Double_t c0 = 1/TMath::Sqrt(r02);
2723 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2724 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2725 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2726 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2729 Double_t z0 = kcl->GetZ();
2730 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2731 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2734 Double_t dip = (z1-z0)*c0/dfi1;
2735 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2746 x2= xx2*cs-y2*sn*dsec;
2747 y2=+xx2*sn*dsec+y2*cs;
2757 // do we have cluster at the middle ?
2759 GetProlongation(x1,xm,x,ym,zm);
2761 AliTPCclusterMI * cm=0;
2762 if (TMath::Abs(ym)-ymaxm<0){
2763 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2764 if ((!cm) || (cm->IsUsed(10))) {
2769 // rotate y1 to system 0
2770 // get state vector in rotated system
2771 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2772 Double_t xr2 = x0*cs+yr1*sn*dsec;
2773 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2775 GetProlongation(xx2,xm,xr,ym,zm);
2776 if (TMath::Abs(ym)-ymaxm<0){
2777 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2778 if ((!cm) || (cm->IsUsed(10))) {
2788 dym = ym - cm->GetY();
2789 dzm = zm - cm->GetZ();
2796 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2797 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2798 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2799 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2800 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2802 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2803 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2804 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2805 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2806 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2807 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2809 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2810 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2811 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2812 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2816 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2817 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2818 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2819 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2820 c[13]=f30*sy1*f40+f32*sy2*f42;
2821 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2823 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2825 UInt_t index=kr1.GetIndex(is);
2826 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2828 track->fIsSeeding = kTRUE;
2835 FollowProlongation(*track, (i1+i2)/2,1);
2836 Int_t foundable,found,shared;
2837 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2838 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2840 seed->~AliTPCseed();
2846 FollowProlongation(*track, i2,1);
2850 track->fBConstrain =1;
2851 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2852 track->fLastPoint = i1; // first cluster in track position
2853 track->fFirstPoint = track->fLastPoint;
2855 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2856 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2857 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2859 seed->~AliTPCseed();
2863 // Z VERTEX CONDITION
2865 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2866 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2867 if (TMath::Abs(zv-z3)>cuts[2]) {
2868 FollowProlongation(*track, TMath::Max(i2-20,0));
2869 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2870 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2871 if (TMath::Abs(zv-z3)>cuts[2]){
2872 FollowProlongation(*track, TMath::Max(i2-40,0));
2873 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2874 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2875 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2876 // make seed without constrain
2877 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2878 FollowProlongation(*track2, i2,1);
2879 track2->fBConstrain = kFALSE;
2880 track2->fSeedType = 1;
2881 arr->AddLast(track2);
2883 seed->~AliTPCseed();
2888 seed->~AliTPCseed();
2895 track->fSeedType =0;
2896 arr->AddLast(track);
2897 seed = new AliTPCseed;
2899 // don't consider other combinations
2900 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2906 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2912 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2917 //-----------------------------------------------------------------
2918 // This function creates track seeds.
2919 //-----------------------------------------------------------------
2920 // cuts[0] - fP4 cut
2921 // cuts[1] - tan(phi) cut
2922 // cuts[2] - zvertex cut
2923 // cuts[3] - fP3 cut
2933 Double_t x[5], c[15];
2935 // make temporary seed
2936 AliTPCseed * seed = new AliTPCseed;
2937 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2938 // Double_t cs=cos(alpha), sn=sin(alpha);
2943 Double_t x1 = GetXrow(i1-1);
2944 const AliTPCRow& kr1=GetRow(sec,i1-1);
2945 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2947 Double_t x1p = GetXrow(i1);
2948 const AliTPCRow& kr1p=GetRow(sec,i1);
2950 Double_t x1m = GetXrow(i1-2);
2951 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2954 //last 3 padrow for seeding
2955 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2956 Double_t x3 = GetXrow(i1-7);
2957 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2959 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2960 Double_t x3p = GetXrow(i1-6);
2962 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2963 Double_t x3m = GetXrow(i1-8);
2968 Int_t im = i1-4; //middle pad row index
2969 Double_t xm = GetXrow(im); // radius of middle pad-row
2970 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2971 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2974 Double_t deltax = x1-x3;
2975 Double_t dymax = deltax*cuts[1];
2976 Double_t dzmax = deltax*cuts[3];
2978 // loop over clusters
2979 for (Int_t is=0; is < kr1; is++) {
2981 if (kr1[is]->IsUsed(10)) continue;
2982 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2984 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2986 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2987 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2993 for (Int_t js=index1; js < index2; js++) {
2994 const AliTPCclusterMI *kcl = kr3[js];
2995 if (kcl->IsUsed(10)) continue;
2997 // apply angular cuts
2998 if (TMath::Abs(y1-y3)>dymax) continue;
3001 if (TMath::Abs(z1-z3)>dzmax) continue;
3003 Double_t angley = (y1-y3)/(x1-x3);
3004 Double_t anglez = (z1-z3)/(x1-x3);
3006 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3007 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3009 Double_t yyym = angley*(xm-x1)+y1;
3010 Double_t zzzm = anglez*(xm-x1)+z1;
3012 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3014 if (kcm->IsUsed(10)) continue;
3016 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3017 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3024 // look around first
3025 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3031 if (kc1m->IsUsed(10)) used++;
3033 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3039 if (kc1p->IsUsed(10)) used++;
3041 if (used>1) continue;
3042 if (found<1) continue;
3046 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3052 if (kc3m->IsUsed(10)) used++;
3056 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3062 if (kc3p->IsUsed(10)) used++;
3066 if (used>1) continue;
3067 if (found<3) continue;
3077 x[4]=F1(x1,y1,x2,y2,x3,y3);
3078 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3081 x[2]=F2(x1,y1,x2,y2,x3,y3);
3084 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3085 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3089 Double_t sy1=0.1, sz1=0.1;
3090 Double_t sy2=0.1, sz2=0.1;
3091 Double_t sy3=0.1, sy=0.1, sz=0.1;
3093 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3094 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3095 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3096 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3097 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3098 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3100 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3101 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3102 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3103 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3107 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3108 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3109 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3110 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3111 c[13]=f30*sy1*f40+f32*sy2*f42;
3112 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3114 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3116 UInt_t index=kr1.GetIndex(is);
3117 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3119 track->fIsSeeding = kTRUE;
3122 FollowProlongation(*track, i1-7,1);
3123 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3124 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3126 seed->~AliTPCseed();
3132 FollowProlongation(*track, i2,1);
3133 track->fBConstrain =0;
3134 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3135 track->fFirstPoint = track->fLastPoint;
3137 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3138 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3139 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3141 seed->~AliTPCseed();
3146 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3147 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3148 FollowProlongation(*track2, i2,1);
3149 track2->fBConstrain = kFALSE;
3150 track2->fSeedType = 4;
3151 arr->AddLast(track2);
3153 seed->~AliTPCseed();
3157 //arr->AddLast(track);
3158 //seed = new AliTPCseed;
3164 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3170 //_____________________________________________________________________________
3171 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3172 Float_t deltay, Bool_t /*bconstrain*/) {
3173 //-----------------------------------------------------------------
3174 // This function creates track seeds - without vertex constraint
3175 //-----------------------------------------------------------------
3176 // cuts[0] - fP4 cut - not applied
3177 // cuts[1] - tan(phi) cut
3178 // cuts[2] - zvertex cut - not applied
3179 // cuts[3] - fP3 cut
3189 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3190 // Double_t cs=cos(alpha), sn=sin(alpha);
3191 Int_t row0 = (i1+i2)/2;
3192 Int_t drow = (i1-i2)/2;
3193 const AliTPCRow& kr0=fSectors[sec][row0];
3196 AliTPCpolyTrack polytrack;
3197 Int_t nclusters=fSectors[sec][row0];
3198 AliTPCseed * seed = new AliTPCseed;
3203 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3205 Int_t nfoundable =0;
3206 for (Int_t iter =1; iter<2; iter++){ //iterations
3207 const AliTPCRow& krm=fSectors[sec][row0-iter];
3208 const AliTPCRow& krp=fSectors[sec][row0+iter];
3209 const AliTPCclusterMI * cl= kr0[is];
3211 if (cl->IsUsed(10)) {
3217 Double_t x = kr0.GetX();
3218 // Initialization of the polytrack
3223 Double_t y0= cl->GetY();
3224 Double_t z0= cl->GetZ();
3228 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3229 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3231 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3232 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3233 polytrack.AddPoint(x,y0,z0,erry, errz);
3236 if (cl->IsUsed(10)) sumused++;
3239 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3240 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3243 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3244 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3245 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3246 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3247 if (cl1->IsUsed(10)) sumused++;
3248 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3252 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3254 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3255 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3256 if (cl2->IsUsed(10)) sumused++;
3257 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3260 if (sumused>0) continue;
3262 polytrack.UpdateParameters();
3268 nfoundable = polytrack.GetN();
3269 nfound = nfoundable;
3271 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3272 Float_t maxdist = 0.8*(1.+3./(ddrow));
3273 for (Int_t delta = -1;delta<=1;delta+=2){
3274 Int_t row = row0+ddrow*delta;
3275 kr = &(fSectors[sec][row]);
3276 Double_t xn = kr->GetX();
3277 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3278 polytrack.GetFitPoint(xn,yn,zn);
3279 if (TMath::Abs(yn)>ymax) continue;
3281 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3283 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3286 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3287 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3288 if (cln->IsUsed(10)) {
3289 // printf("used\n");
3297 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3302 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3303 polytrack.UpdateParameters();
3306 if ( (sumused>3) || (sumused>0.5*nfound)) {
3307 //printf("sumused %d\n",sumused);
3312 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3313 AliTPCpolyTrack track2;
3315 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3316 if (track2.GetN()<0.5*nfoundable) continue;
3319 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3321 // test seed with and without constrain
3322 for (Int_t constrain=0; constrain<=0;constrain++){
3323 // add polytrack candidate
3325 Double_t x[5], c[15];
3326 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3327 track2.GetBoundaries(x3,x1);
3329 track2.GetFitPoint(x1,y1,z1);
3330 track2.GetFitPoint(x2,y2,z2);
3331 track2.GetFitPoint(x3,y3,z3);
3333 //is track pointing to the vertex ?
3336 polytrack.GetFitPoint(x0,y0,z0);
3349 x[4]=F1(x1,y1,x2,y2,x3,y3);
3351 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3352 x[2]=F2(x1,y1,x2,y2,x3,y3);
3354 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3355 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3356 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3357 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3360 Double_t sy =0.1, sz =0.1;
3361 Double_t sy1=0.02, sz1=0.02;
3362 Double_t sy2=0.02, sz2=0.02;
3366 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3369 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3370 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3371 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3372 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3373 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3374 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3376 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3377 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3378 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3379 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3384 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3385 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3386 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3387 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3388 c[13]=f30*sy1*f40+f32*sy2*f42;
3389 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3391 //Int_t row1 = fSectors->GetRowNumber(x1);
3392 Int_t row1 = GetRowNumber(x1);
3396 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3397 track->fIsSeeding = kTRUE;
3398 Int_t rc=FollowProlongation(*track, i2);
3399 if (constrain) track->fBConstrain =1;
3401 track->fBConstrain =0;
3402 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3403 track->fFirstPoint = track->fLastPoint;
3405 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3406 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3407 track->fNShared>0.4*track->GetNumberOfClusters()) {
3410 seed->~AliTPCseed();
3413 arr->AddLast(track);
3414 seed = new AliTPCseed;
3418 } // if accepted seed
3421 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3427 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3431 //reseed using track points
3432 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3433 Int_t p1 = int(r1*track->GetNumberOfClusters());
3434 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3436 Double_t x0[3],x1[3],x2[3];
3441 // find track position at given ratio of the length
3442 Int_t sec0, sec1, sec2;
3448 for (Int_t i=0;i<160;i++){
3449 if (track->fClusterPointer[i]){
3451 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3452 if ( (index<p0) || x0[0]<0 ){
3453 if (trpoint->GetX()>1){
3454 clindex = track->GetClusterIndex2(i);
3456 x0[0] = trpoint->GetX();
3457 x0[1] = trpoint->GetY();
3458 x0[2] = trpoint->GetZ();
3459 sec0 = ((clindex&0xff000000)>>24)%18;
3464 if ( (index<p1) &&(trpoint->GetX()>1)){
3465 clindex = track->GetClusterIndex2(i);
3467 x1[0] = trpoint->GetX();
3468 x1[1] = trpoint->GetY();
3469 x1[2] = trpoint->GetZ();
3470 sec1 = ((clindex&0xff000000)>>24)%18;
3473 if ( (index<p2) &&(trpoint->GetX()>1)){
3474 clindex = track->GetClusterIndex2(i);
3476 x2[0] = trpoint->GetX();
3477 x2[1] = trpoint->GetY();
3478 x2[2] = trpoint->GetZ();
3479 sec2 = ((clindex&0xff000000)>>24)%18;
3486 Double_t alpha, cs,sn, xx2,yy2;
3488 alpha = (sec1-sec2)*fSectors->GetAlpha();
3489 cs = TMath::Cos(alpha);
3490 sn = TMath::Sin(alpha);
3491 xx2= x1[0]*cs-x1[1]*sn;
3492 yy2= x1[0]*sn+x1[1]*cs;
3496 alpha = (sec0-sec2)*fSectors->GetAlpha();
3497 cs = TMath::Cos(alpha);
3498 sn = TMath::Sin(alpha);
3499 xx2= x0[0]*cs-x0[1]*sn;
3500 yy2= x0[0]*sn+x0[1]*cs;
3506 Double_t x[5],c[15];
3510 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3511 // if (x[4]>1) return 0;
3512 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3513 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3514 //if (TMath::Abs(x[3]) > 2.2) return 0;
3515 //if (TMath::Abs(x[2]) > 1.99) return 0;
3517 Double_t sy =0.1, sz =0.1;
3519 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3520 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3521 Double_t sy3=0.01+track->GetSigmaY2();
3523 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3524 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3525 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3526 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3527 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3528 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3530 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3531 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3532 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3533 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3538 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3539 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3540 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3541 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3542 c[13]=f30*sy1*f40+f32*sy2*f42;
3543 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3545 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3546 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3547 // Double_t y0,z0,y1,z1, y2,z2;
3548 //seed->GetProlongation(x0[0],y0,z0);
3549 // seed->GetProlongation(x1[0],y1,z1);
3550 //seed->GetProlongation(x2[0],y2,z2);
3552 seed->fLastPoint = pp2;
3553 seed->fFirstPoint = pp2;
3560 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3564 //reseed using founded clusters
3566 // Find the number of clusters
3567 Int_t nclusters = 0;
3568 for (Int_t irow=0;irow<160;irow++){
3569 if (track->GetClusterIndex(irow)>0) nclusters++;
3573 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3574 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3575 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3579 Int_t row[3],sec[3]={0,0,0};
3581 // find track row position at given ratio of the length
3583 for (Int_t irow=0;irow<160;irow++){
3584 if (track->GetClusterIndex2(irow)<0) continue;
3586 for (Int_t ipoint=0;ipoint<3;ipoint++){
3587 if (index<=ipos[ipoint]) row[ipoint] = irow;
3591 //Get cluster and sector position
3592 for (Int_t ipoint=0;ipoint<3;ipoint++){
3593 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3594 AliTPCclusterMI * cl = GetClusterMI(clindex);
3597 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3600 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3601 xyz[ipoint][0] = GetXrow(row[ipoint]);
3602 xyz[ipoint][1] = cl->GetY();
3603 xyz[ipoint][2] = cl->GetZ();
3607 // Calculate seed state vector and covariance matrix
3609 Double_t alpha, cs,sn, xx2,yy2;
3611 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3612 cs = TMath::Cos(alpha);
3613 sn = TMath::Sin(alpha);
3614 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3615 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3619 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3620 cs = TMath::Cos(alpha);
3621 sn = TMath::Sin(alpha);
3622 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3623 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3629 Double_t x[5],c[15];
3633 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3634 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3635 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3637 Double_t sy =0.1, sz =0.1;
3639 Double_t sy1=0.2, sz1=0.2;
3640 Double_t sy2=0.2, sz2=0.2;
3643 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;
3644 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;
3645 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;
3646 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;
3647 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;
3648 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;
3650 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;
3651 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;
3652 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;
3653 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;
3658 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3659 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3660 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3661 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3662 c[13]=f30*sy1*f40+f32*sy2*f42;
3663 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3665 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3666 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3667 seed->fLastPoint = row[2];
3668 seed->fFirstPoint = row[2];
3672 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3677 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3679 if (TMath::Abs(seed->GetC())>0.01) return 0;
3682 Float_t x[160], y[160], erry[160], z[160], errz[160];
3684 Float_t xt[160], yt[160], zt[160];
3689 Int_t middle = seed->GetNumberOfClusters()/2;
3692 // find central sector, get local cooordinates
3694 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3695 sec[i]= seed->GetClusterSector(i)%18;
3698 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3699 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3706 if (i>i2) i2 = i; //last point with cluster
3707 if (i2<i1) i1 = i; //first point with cluster
3710 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3712 yt[i] = point->GetY();
3713 zt[i] = point->GetZ();
3715 if (point->GetX()>0){
3716 erry[i] = point->GetErrY();
3717 errz[i] = point->GetErrZ();
3722 secm = sec[i]; //central sector
3723 padm = i; //middle point with cluster
3728 // rotate position to global coordinate system connected to sector at last the point
3730 for (Int_t i=i1;i<=i2;i++){
3732 if (sec[i]<0) continue;
3733 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3734 Double_t cs = TMath::Cos(alpha);
3735 Double_t sn = TMath::Sin(alpha);
3736 Float_t xx2= x[i]*cs+y[i]*sn;
3737 Float_t yy2= -x[i]*sn+y[i]*cs;
3741 xx2= xt[i]*cs+yt[i]*sn;
3742 yy2= -xt[i]*sn+yt[i]*cs;
3747 //get "state" vector
3748 Double_t xh[5],xm = x[padm];
3751 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3752 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3753 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3756 for (Int_t i=i1;i<=i2;i++){
3758 if (sec[i]<0) continue;
3759 GetProlongation(x[i2], x[i],xh,yy,zz);
3760 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3762 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3763 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3764 Error("AliTPCtrackerMI::CheckKinkPoint","problem\n");
3769 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3770 Float_t yup[160], ydown[160], zup[160], zdown[160];
3772 AliTPCpolyTrack ptrack1,ptrack2;
3775 for (Int_t i=i1;i<=i2;i++){
3776 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3778 if (cl->GetType()<0) continue;
3779 if (cl->GetType()>10) continue;
3782 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3784 if (ptrack1.GetN()>4.){
3785 ptrack1.UpdateParameters();
3787 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3789 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3798 dyup[i]=0.; //not enough points
3803 for (Int_t i=i2;i>=i1;i--){
3804 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3806 if (cl->GetType()<0) continue;
3807 if (cl->GetType()>10) continue;
3809 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3811 if (ptrack2.GetN()>4){
3812 ptrack2.UpdateParameters();
3814 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3816 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3824 dydown[i]=0.; //not enough points
3829 // find maximal difference of the derivation
3830 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3833 for (Int_t i=i1+10;i<i2-10;i++){
3834 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3835 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3837 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3838 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3839 if ( (ddy+ddz)> th){
3840 seed->fKinkPoint[0] = i;
3841 seed->fKinkPoint[1] = ddy;
3842 seed->fKinkPoint[2] = ddz;
3849 //write information to the debug tree
3850 TBranch * br = fTreeDebug->GetBranch("debug");
3851 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3852 arr->ExpandCreateFast(i2-i1);
3853 br->SetAddress(&arr);
3855 AliTPCclusterMI cldummy;
3857 AliTPCTrackPoint2 pdummy;
3858 pdummy.GetTPoint().fIsShared = 10;
3860 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3861 Double_t cs = TMath::Cos(alpha);
3862 Double_t sn = TMath::Sin(alpha);
3864 for (Int_t i=i1;i<i2;i++){
3865 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3867 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3869 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3872 Double_t x = GetXrow(i);
3873 trpoint->GetTPoint() = *point;
3874 trpoint->GetCPoint() = *cl0;
3875 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3876 trpoint->fID = seed->GetUniqueID();
3877 trpoint->fLab = seed->GetLabel();
3879 trpoint->fGX = cs *x + sn*point->GetY();
3880 trpoint->fGY = -sn *x + cs*point->GetY() ;
3881 trpoint->fGZ = point->GetZ();
3883 trpoint->fDY = y[i];
3884 trpoint->fDZ = z[i];
3886 trpoint->fDYU = dyup[i];
3887 trpoint->fDZU = dzup[i];
3889 trpoint->fDYD = dydown[i];
3890 trpoint->fDZD = dzdown[i];
3892 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3893 trpoint->fDDY = dydown[i]-dyup[i];
3894 trpoint->fDDZ = dzdown[i]-dzup[i];
3902 trpoint->GetCPoint()= cldummy;
3919 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3922 // reseed - refit - track
3925 // Int_t last = fSectors->GetNRows()-1;
3927 if (fSectors == fOuterSec){
3928 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3932 first = t->fFirstPoint;
3934 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3935 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3937 FollowProlongation(*t,first);
3947 //_____________________________________________________________________________
3948 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3949 //-----------------------------------------------------------------
3950 // This function reades track seeds.
3951 //-----------------------------------------------------------------
3952 TDirectory *savedir=gDirectory;
3954 TFile *in=(TFile*)inp;
3955 if (!in->IsOpen()) {
3956 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3961 TTree *seedTree=(TTree*)in->Get("Seeds");
3963 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3964 cerr<<"can't get a tree with track seeds !\n";
3967 AliTPCtrack *seed=new AliTPCtrack;
3968 seedTree->SetBranchAddress("tracks",&seed);
3970 if (fSeeds==0) fSeeds=new TObjArray(15000);
3972 Int_t n=(Int_t)seedTree->GetEntries();
3973 for (Int_t i=0; i<n; i++) {
3974 seedTree->GetEvent(i);
3975 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3984 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
3987 if (fSeeds) DeleteSeeds();
3990 if (!fSeeds) return 1;
3997 //_____________________________________________________________________________
3998 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3999 //-----------------------------------------------------------------
4000 // This is a track finder.
4001 //-----------------------------------------------------------------
4002 TDirectory *savedir=gDirectory;
4006 fSeeds = Tracking();
4009 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
4011 //activate again some tracks
4012 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
4013 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4015 Int_t nc=t.GetNumberOfClusters();
4017 delete fSeeds->RemoveAt(i);
4020 if (pt->fRemoval==10) {
4021 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4022 pt->Desactivate(10); // make track again active
4024 pt->Desactivate(20);
4025 delete fSeeds->RemoveAt(i);
4029 RemoveDouble(fSeeds,0.2,0.6,11);
4030 RemoveUsed(fSeeds,0.5,0.5,6);
4033 Int_t nseed=fSeeds->GetEntriesFast();
4035 for (Int_t i=0; i<nseed; i++) {
4036 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4038 Int_t nc=t.GetNumberOfClusters();
4040 delete fSeeds->RemoveAt(i);
4043 CookLabel(pt,0.1); //For comparison only
4044 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4045 if ((pt->IsActive() || (pt->fRemoval==10) )){
4047 if (fDebug>0) cerr<<found<<'\r';
4051 delete fSeeds->RemoveAt(i);
4055 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
4057 //RemoveUsed(fSeeds,0.9,0.9,6);
4059 nseed=fSeeds->GetEntriesFast();
4061 for (Int_t i=0; i<nseed; i++) {
4062 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4064 Int_t nc=t.GetNumberOfClusters();
4066 delete fSeeds->RemoveAt(i);
4070 t.CookdEdx(0.02,0.6);
4071 // CheckKinkPoint(&t,0.05);
4072 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4073 if ((pt->IsActive() || (pt->fRemoval==10) )){
4081 delete fSeeds->RemoveAt(i);
4082 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
4084 // FollowProlongation(*seed1,0);
4085 // Int_t n = seed1->GetNumberOfClusters();
4086 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
4087 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
4090 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
4094 SortTracks(fSeeds, 1);
4098 PrepareForBackProlongation(fSeeds,5.);
4099 PropagateBack(fSeeds);
4100 printf("Time for back propagation: \t");timer.Print();timer.Start();
4104 PrepareForProlongation(fSeeds,5.);
4105 PropagateForward2(fSeeds);
4107 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
4108 // RemoveUsed(fSeeds,0.7,0.7,6);
4109 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
4111 nseed=fSeeds->GetEntriesFast();
4113 for (Int_t i=0; i<nseed; i++) {
4114 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4116 Int_t nc=t.GetNumberOfClusters();
4118 delete fSeeds->RemoveAt(i);
4121 t.CookdEdx(0.02,0.6);
4122 // CookLabel(pt,0.1); //For comparison only
4123 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4124 if ((pt->IsActive() || (pt->fRemoval==10) )){
4125 cerr<<found++<<'\r';
4128 delete fSeeds->RemoveAt(i);
4133 // fNTracks = found;
4135 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
4138 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
4139 Info("Clusters2Tracks","Number of found tracks %d",found);
4141 // UnloadClusters();
4146 void AliTPCtrackerMI::Tracking(TObjArray * arr)
4149 // tracking of the seeds
4152 fSectors = fOuterSec;
4153 ParallelTracking(arr,150,63);
4154 fSectors = fOuterSec;
4155 ParallelTracking(arr,63,0);
4158 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
4163 TObjArray * arr = new TObjArray;
4165 fSectors = fOuterSec;
4168 for (Int_t sec=0;sec<fkNOS;sec++){
4169 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
4170 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
4171 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
4174 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
4186 TObjArray * AliTPCtrackerMI::Tracking()
4192 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
4194 TObjArray * seeds = new TObjArray;
4203 Float_t fnumber = 3.0;
4204 Float_t fdensity = 3.0;
4209 for (Int_t delta = 0; delta<18; delta+=6){
4213 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
4214 SumTracks(seeds,arr);
4215 SignClusters(seeds,fnumber,fdensity);
4217 for (Int_t i=2;i<6;i+=2){
4218 // seed high pt tracks
4221 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
4222 SumTracks(seeds,arr);
4223 SignClusters(seeds,fnumber,fdensity);
4228 // RemoveUsed(seeds,0.9,0.9,1);
4229 // UnsignClusters();
4230 // SignClusters(seeds,fnumber,fdensity);
4234 for (Int_t delta = 20; delta<120; delta+=10){
4236 // seed high pt tracks
4240 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
4241 SumTracks(seeds,arr);
4242 SignClusters(seeds,fnumber,fdensity);
4247 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4248 SumTracks(seeds,arr);
4249 SignClusters(seeds,fnumber,fdensity);
4260 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4264 // RemoveUsed(seeds,0.75,0.75,1);
4266 //SignClusters(seeds,fnumber,fdensity);
4275 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4276 SumTracks(seeds,arr);
4277 SignClusters(seeds,fnumber,fdensity);
4279 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4280 SumTracks(seeds,arr);
4281 SignClusters(seeds,fnumber,fdensity);
4283 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4284 SumTracks(seeds,arr);
4285 SignClusters(seeds,fnumber,fdensity);
4289 for (Int_t delta = 3; delta<30; delta+=5){
4295 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4296 SumTracks(seeds,arr);
4297 SignClusters(seeds,fnumber,fdensity);
4299 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4300 SumTracks(seeds,arr);
4301 SignClusters(seeds,fnumber,fdensity);
4313 for (Int_t delta = 30; delta<70; delta+=10){
4319 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4320 SumTracks(seeds,arr);
4321 SignClusters(seeds,fnumber,fdensity);
4323 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4324 SumTracks(seeds,arr);
4325 SignClusters(seeds,fnumber,fdensity);
4329 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4340 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
4343 //sum tracks to common container
4344 //remove suspicious tracks
4345 Int_t nseed = arr2->GetEntriesFast();
4346 for (Int_t i=0;i<nseed;i++){
4347 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4350 // NORMAL ACTIVE TRACK
4351 if (pt->IsActive()){
4352 arr1->AddLast(arr2->RemoveAt(i));
4355 //remove not usable tracks
4356 if (pt->fRemoval!=10){
4357 delete arr2->RemoveAt(i);
4360 // REMOVE VERY SHORT TRACKS
4361 if (pt->GetNumberOfClusters()<20){
4362 delete arr2->RemoveAt(i);
4365 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4366 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4367 arr1->AddLast(arr2->RemoveAt(i));
4369 delete arr2->RemoveAt(i);
4378 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4381 // try to track in parralel
4383 Int_t nseed=arr->GetEntriesFast();
4384 //prepare seeds for tracking
4385 for (Int_t i=0; i<nseed; i++) {
4386 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4388 if (!t.IsActive()) continue;
4389 // follow prolongation to the first layer
4390 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4391 FollowProlongation(t, rfirst+1);
4396 for (Int_t nr=rfirst; nr>=rlast; nr--){
4397 if (nr<fInnerSec->GetNRows())
4398 fSectors = fInnerSec;
4400 fSectors = fOuterSec;
4401 // make indexes with the cluster tracks for given
4403 // find nearest cluster
4404 for (Int_t i=0; i<nseed; i++) {
4405 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4407 if (!pt->IsActive()) continue;
4408 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4409 if (pt->fRelativeSector>17) {
4412 UpdateClusters(t,nr);
4414 // prolonagate to the nearest cluster - if founded
4415 for (Int_t i=0; i<nseed; i++) {
4416 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4418 if (!pt->IsActive()) continue;
4419 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4420 if (pt->fRelativeSector>17) {
4423 FollowToNextCluster(*pt,nr);
4428 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
4432 // if we use TPC track itself we have to "update" covariance
4434 Int_t nseed= arr->GetEntriesFast();
4435 for (Int_t i=0;i<nseed;i++){
4436 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4440 //rotate to current local system at first accepted point
4441 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4442 Int_t sec = (index&0xff000000)>>24;
4444 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4445 if (angle1>TMath::Pi())
4446 angle1-=2.*TMath::Pi();
4447 Float_t angle2 = pt->GetAlpha();
4449 if (TMath::Abs(angle1-angle2)>0.001){
4450 pt->Rotate(angle1-angle2);
4451 //angle2 = pt->GetAlpha();
4452 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4453 //if (pt->GetAlpha()<0)
4454 // pt->fRelativeSector+=18;
4455 //sec = pt->fRelativeSector;
4464 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
4468 // if we use TPC track itself we have to "update" covariance
4470 Int_t nseed= arr->GetEntriesFast();
4471 for (Int_t i=0;i<nseed;i++){
4472 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4475 pt->fFirstPoint = pt->fLastPoint;
4483 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4486 // make back propagation
4488 Int_t nseed= arr->GetEntriesFast();
4489 for (Int_t i=0;i<nseed;i++){
4490 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4492 //AliTPCseed *pt2 = new AliTPCseed(*pt);
4493 fSectors = fInnerSec;
4494 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
4495 //fSectors = fOuterSec;
4496 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4497 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
4498 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
4499 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4507 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4510 // make forward propagation
4512 Int_t nseed= arr->GetEntriesFast();
4514 for (Int_t i=0;i<nseed;i++){
4515 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4517 FollowProlongation(*pt,0);
4524 Int_t AliTPCtrackerMI::PropagateForward()
4527 // propagate track forward
4529 Int_t nseed = fSeeds->GetEntriesFast();
4530 for (Int_t i=0;i<nseed;i++){
4531 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
4533 AliTPCseed &t = *pt;
4534 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
4535 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
4536 if (alpha < 0. ) alpha += 2.*TMath::Pi();
4537 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
4541 fSectors = fOuterSec;
4542 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
4543 fSectors = fInnerSec;
4544 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
4554 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4557 // make back propagation, in between row0 and row1
4561 fSectors = fInnerSec;
4564 if (row1<fSectors->GetNRows())
4567 r1 = fSectors->GetNRows()-1;
4569 if (row0<fSectors->GetNRows()&& r1>0 )
4570 FollowBackProlongation(*pt,r1);
4571 if (row1<=fSectors->GetNRows())
4574 r1 = row1 - fSectors->GetNRows();
4575 if (r1<=0) return 0;
4576 if (r1>=fOuterSec->GetNRows()) return 0;
4577 fSectors = fOuterSec;
4578 return FollowBackProlongation(*pt,r1);
4586 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4590 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4591 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4592 Float_t padlength = GetPadPitchLength(row);
4594 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4595 Float_t angulary = seed->GetSnp();
4596 angulary = angulary*angulary/(1-angulary*angulary);
4597 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4599 Float_t sresz = fParam->GetZSigma();
4600 Float_t angularz = seed->GetTgl();
4601 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4603 Float_t wy = GetSigmaY(seed);
4604 Float_t wz = GetSigmaZ(seed);
4607 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4608 printf("problem\n");
4614 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4618 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4619 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4620 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4621 Float_t angular = seed->GetSnp();
4622 angular = angular*angular/(1-angular*angular);
4623 // angular*=angular;
4624 //angular = TMath::Sqrt(angular/(1-angular));
4625 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4628 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4632 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4633 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4634 Float_t sres = fParam->GetZSigma();
4635 Float_t angular = seed->GetTgl();
4636 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4643 //__________________________________________________________________________
4644 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4645 //--------------------------------------------------------------------
4646 //This function "cooks" a track label. If label<0, this track is fake.
4647 //--------------------------------------------------------------------
4648 Int_t noc=t->GetNumberOfClusters();
4650 //printf("\nnot founded prolongation\n\n\n");
4656 AliTPCclusterMI *clusters[160];
4658 for (Int_t i=0;i<160;i++) {
4665 for (i=0; i<160 && current<noc; i++) {
4667 Int_t index=t->GetClusterIndex2(i);
4668 if (index<=0) continue;
4669 if (index&0x8000) continue;
4671 //clusters[current]=GetClusterMI(index);
4672 if (t->fClusterPointer[i]){
4673 clusters[current]=t->fClusterPointer[i];
4679 Int_t lab=123456789;
4680 for (i=0; i<noc; i++) {
4681 AliTPCclusterMI *c=clusters[i];
4683 lab=TMath::Abs(c->GetLabel(0));
4685 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4691 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4693 for (i=0; i<noc; i++) {
4694 AliTPCclusterMI *c=clusters[i];
4696 if (TMath::Abs(c->GetLabel(1)) == lab ||
4697 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4700 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4703 Int_t tail=Int_t(0.10*noc);
4706 for (i=1; i<=160&&ind<tail; i++) {
4707 // AliTPCclusterMI *c=clusters[noc-i];
4708 AliTPCclusterMI *c=clusters[i];
4710 if (lab == TMath::Abs(c->GetLabel(0)) ||
4711 lab == TMath::Abs(c->GetLabel(1)) ||
4712 lab == TMath::Abs(c->GetLabel(2))) max++;
4715 if (max < Int_t(0.5*tail)) lab=-lab;
4722 //delete[] clusters;
4726 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
4728 //return pad row number for this x
4731 r=fRow[fN-1].GetX();
4732 if (x > r) return fN;
4734 if (x < r) return -1;
4735 return Int_t((x-r)/fPadPitchLength + 0.5);}
4737 r=fRow[fN-1].GetX();
4738 if (x > r) return fN;
4740 if (x < r) return -1;
4741 Double_t r1=fRow[64].GetX();
4743 return Int_t((x-r)/f1PadPitchLength + 0.5);}
4745 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
4749 //_________________________________________________________________________
4750 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4751 //-----------------------------------------------------------------------
4752 // Setup inner sector
4753 //-----------------------------------------------------------------------
4755 fAlpha=par->GetInnerAngle();
4756 fAlphaShift=par->GetInnerAngleShift();
4757 fPadPitchWidth=par->GetInnerPadPitchWidth();
4758 fPadPitchLength=par->GetInnerPadPitchLength();
4759 fN=par->GetNRowLow();
4760 fRow=new AliTPCRow[fN];
4761 for (Int_t i=0; i<fN; i++) {
4762 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4763 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4766 fAlpha=par->GetOuterAngle();
4767 fAlphaShift=par->GetOuterAngleShift();
4768 fPadPitchWidth = par->GetOuterPadPitchWidth();
4769 fPadPitchLength = par->GetOuter1PadPitchLength();
4770 f1PadPitchLength = par->GetOuter1PadPitchLength();
4771 f2PadPitchLength = par->GetOuter2PadPitchLength();
4773 fN=par->GetNRowUp();
4774 fRow=new AliTPCRow[fN];
4775 for (Int_t i=0; i<fN; i++) {
4776 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4777 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4782 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
4784 // default constructor
4792 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4799 //_________________________________________________________________________
4801 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4802 //-----------------------------------------------------------------------
4803 // Insert a cluster into this pad row in accordence with its y-coordinate
4804 //-----------------------------------------------------------------------
4805 if (fN==kMaxClusterPerRow) {
4806 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4808 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4809 Int_t i=Find(c->GetZ());
4810 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4811 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4812 fIndex[i]=index; fClusters[i]=c; fN++;
4815 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
4821 //delete[] fClusterArray;
4822 if (fClusters1) delete []fClusters1;
4823 if (fClusters2) delete []fClusters2;
4830 //___________________________________________________________________
4831 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4832 //-----------------------------------------------------------------------
4833 // Return the index of the nearest cluster
4834 //-----------------------------------------------------------------------
4835 if (fN==0) return 0;
4836 if (z <= fClusters[0]->GetZ()) return 0;
4837 if (z > fClusters[fN-1]->GetZ()) return fN;
4838 Int_t b=0, e=fN-1, m=(b+e)/2;
4839 for (; b<e; m=(b+e)/2) {
4840 if (z > fClusters[m]->GetZ()) b=m+1;
4848 //___________________________________________________________________
4849 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4850 //-----------------------------------------------------------------------
4851 // Return the index of the nearest cluster in z y
4852 //-----------------------------------------------------------------------
4853 Float_t maxdistance = roady*roady + roadz*roadz;
4855 AliTPCclusterMI *cl =0;
4856 for (Int_t i=Find(z-roadz); i<fN; i++) {
4857 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4858 if (c->GetZ() > z+roadz) break;
4859 if ( (c->GetY()-y) > roady ) continue;
4860 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4861 if (maxdistance>distance) {
4862 maxdistance = distance;
4869 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4871 //-----------------------------------------------------------------------
4872 // Return the index of the nearest cluster in z y
4873 //-----------------------------------------------------------------------
4874 Float_t maxdistance = roady*roady + roadz*roadz;
4875 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4876 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4878 AliTPCclusterMI *cl =0;
4879 //FindNearest3(y,z,roady,roadz,index);
4880 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4881 for (Int_t i=iz1; i<iz2; i++) {
4882 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4883 if (c->GetZ() > z+roadz) break;
4884 if ( c->GetY()-y > roady ) continue;
4885 if ( y-c->GetY() > roady ) continue;
4886 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4887 if (maxdistance>distance) {
4888 maxdistance = distance;
4891 //roady = TMath::Sqrt(maxdistance);
4899 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4901 //-----------------------------------------------------------------------
4902 // Return the index of the nearest cluster in z y
4903 //-----------------------------------------------------------------------
4904 Float_t maxdistance = roady*roady + roadz*roadz;
4905 // Int_t iz = Int_t(z+255.);
4906 AliTPCclusterMI *cl =0;
4907 for (Int_t i=Find(z-roadz); i<fN; i++) {
4908 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4909 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4910 if (c->GetZ() > z+roadz) break;
4911 if ( c->GetY()-y > roady ) continue;
4912 if ( y-c->GetY() > roady ) continue;
4913 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4914 if (maxdistance>distance) {
4915 maxdistance = distance;
4918 //roady = TMath::Sqrt(maxdistance);
4927 AliTPCseed::AliTPCseed():AliTPCtrack(){
4931 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4932 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4950 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4959 for (Int_t i=0;i<160;i++) {
4960 fClusterPointer[i] = 0;
4961 Int_t index = t.GetClusterIndex(i);
4963 SetClusterIndex2(i,index);
4966 SetClusterIndex2(i,-3);
4979 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4983 for (Int_t i=0;i<160;i++) {
4984 fClusterPointer[i] = 0;
4985 Int_t index = t.GetClusterIndex(i);
4986 SetClusterIndex2(i,index);
5007 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
5008 Double_t xr, Double_t alpha):
5009 AliTPCtrack(index, xx, cc, xr, alpha) {
5014 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
5015 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
5024 // fHelixIn = new TClonesArray("AliHelix",0);
5025 //fHelixOut = new TClonesArray("AliHelix",0);
5035 AliTPCseed::~AliTPCseed(){
5038 if (fPoints) delete fPoints;
5040 if (fEPoints) delete fEPoints;
5045 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
5049 return &fTrackPoints[i];
5052 void AliTPCseed::RebuildSeed()
5055 // rebuild seed to be ready for storing
5056 AliTPCclusterMI cldummy;
5058 AliTPCTrackPoint pdummy;
5059 pdummy.GetTPoint().fIsShared = 10;
5060 for (Int_t i=0;i<160;i++){
5061 AliTPCclusterMI * cl0 = fClusterPointer[i];
5062 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
5064 trpoint->GetTPoint() = *(GetTrackPoint(i));
5065 trpoint->GetCPoint() = *cl0;
5066 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
5070 trpoint->GetCPoint()= cldummy;
5078 Double_t AliTPCseed::GetDensityFirst(Int_t n)
5082 // return cluster for n rows bellow first point
5083 Int_t nfoundable = 1;
5085 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
5086 Int_t index = GetClusterIndex2(i);
5087 if (index!=-1) nfoundable++;
5088 if (index>0) nfound++;
5090 if (nfoundable<n) return 0;
5091 return Double_t(nfound)/Double_t(nfoundable);
5096 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
5098 // get cluster stat. on given region
5103 for (Int_t i=first;i<last; i++){
5104 Int_t index = GetClusterIndex2(i);
5105 if (index!=-1) foundable++;
5106 if (fClusterPointer[i]) {
5112 if (fClusterPointer[i]->IsUsed(10)) {
5116 if (!plus2) continue; //take also neighborhoud
5118 if ( (i>0) && fClusterPointer[i-1]){
5119 if (fClusterPointer[i-1]->IsUsed(10)) {
5124 if ( fClusterPointer[i+1]){
5125 if (fClusterPointer[i+1]->IsUsed(10)) {
5132 //if (shared>found){
5133 //Error("AliTPCseed::GetClusterStatistic","problem\n");
5137 //_____________________________________________________________________________
5138 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
5139 //-----------------------------------------------------------------
5140 // This funtion calculates dE/dX within the "low" and "up" cuts.
5141 //-----------------------------------------------------------------
5144 Float_t angular[200];
5145 Float_t weight[200];
5148 // TClonesArray & arr = *fPoints;
5149 Float_t meanlog = 100.;
5151 Float_t mean[4] = {0,0,0,0};
5152 Float_t sigma[4] = {1000,1000,1000,1000};
5153 Int_t nc[4] = {0,0,0,0};
5154 Float_t norm[4] = {1000,1000,1000,1000};
5159 for (Int_t of =0; of<4; of++){
5160 for (Int_t i=of+i1;i<i2;i+=4)
5162 Int_t index = fIndex[i];
5163 if (index<0||index&0x8000) continue;
5165 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
5166 AliTPCTrackerPoint * point = GetTrackPoint(i);
5167 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
5168 //AliTPCTrackerPoint * pointp = 0;
5169 //if (i<159) pointp = GetTrackPoint(i+1);
5171 if (point==0) continue;
5172 AliTPCclusterMI * cl = fClusterPointer[i];
5173 if (cl==0) continue;
5174 if (onlyused && (!cl->IsUsed(10))) continue;
5175 if (cl->IsUsed(11)) {
5179 Int_t type = cl->GetType();
5180 //if (point->fIsShared){
5185 // if (pointm->fIsShared) continue;
5187 // if (pointp->fIsShared) continue;
5189 if (type<0) continue;
5190 //if (type>10) continue;
5191 //if (point->GetErrY()==0) continue;
5192 //if (point->GetErrZ()==0) continue;
5194 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
5195 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
5196 //if ((ddy*ddy+ddz*ddz)>10) continue;
5199 // if (point->GetCPoint().GetMax()<5) continue;
5200 if (cl->GetMax()<5) continue;
5201 Float_t angley = point->GetAngleY();
5202 Float_t anglez = point->GetAngleZ();
5204 Float_t rsigmay2 = point->GetSigmaY();
5205 Float_t rsigmaz2 = point->GetSigmaZ();
5209 rsigmay += pointm->GetTPoint().GetSigmaY();
5210 rsigmaz += pointm->GetTPoint().GetSigmaZ();
5214 rsigmay += pointp->GetTPoint().GetSigmaY();
5215 rsigmaz += pointp->GetTPoint().GetSigmaZ();
5222 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
5224 Float_t ampc = 0; // normalization to the number of electrons
5226 // ampc = 1.*point->GetCPoint().GetMax();
5227 ampc = 1.*cl->GetMax();
5228 //ampc = 1.*point->GetCPoint().GetQ();
5229 // AliTPCClusterPoint & p = point->GetCPoint();
5230 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
5231 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5233 // TMath::Abs( Int_t(iz) - iz + 0.5);
5234 //ampc *= 1.15*(1-0.3*dy);
5235 //ampc *= 1.15*(1-0.3*dz);
5236 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
5240 //ampc = 1.0*point->GetCPoint().GetMax();
5241 ampc = 1.0*cl->GetMax();
5242 //ampc = 1.0*point->GetCPoint().GetQ();
5243 //AliTPCClusterPoint & p = point->GetCPoint();
5244 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
5245 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5247 // TMath::Abs( Int_t(iz) - iz + 0.5);
5249 //ampc *= 1.15*(1-0.3*dy);
5250 //ampc *= 1.15*(1-0.3*dz);
5251 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
5255 ampc *= 2.0; // put mean value to channel 50
5256 //ampc *= 0.58; // put mean value to channel 50
5258 // if (type>0) w = 1./(type/2.-0.5);
5259 // Float_t z = TMath::Abs(cl->GetZ());
5262 //ampc /= (1+0.0008*z);
5266 //ampc /= (1+0.0008*z);
5268 //ampc /= (1+0.0008*z);
5271 if (type<0) { //amp at the border - lower weight
5276 if (rsigma>1.5) ampc/=1.3; // if big backround
5278 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5283 TMath::Sort(nc[of],amp,index,kFALSE);
5287 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
5289 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5290 Float_t ampl = amp[index[i]]/angular[index[i]];
5291 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5293 sumw += weight[index[i]];
5294 sumamp += weight[index[i]]*ampl;
5295 sumamp2 += weight[index[i]]*ampl*ampl;
5296 norm[of] += angular[index[i]]*weight[index[i]];
5303 mean[of] = sumamp/sumw;
5304 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5306 sigma[of] = TMath::Sqrt(sigma[of]);
5310 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5311 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5312 //mean *=(1-0.1*(norm-1.));
5319 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
5320 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
5323 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
5324 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
5328 for (Int_t i =0;i<4;i++){
5329 if (nc[i]>2&&nc[i]<1000){
5330 dedx += mean[i] *nc[i];
5331 fSdEdx += sigma[i]*(nc[i]-2);
5332 fMAngular += norm[i] *nc[i];
5337 fSDEDX[i] = sigma[i];
5350 // Float_t dedx1 =dedx;
5353 for (Int_t i =0;i<4;i++){
5354 if (nc[i]>2&&nc[i]<1000){
5355 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5356 dedx += mean[i] *nc[i];
5371 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5374 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5375 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5376 SetMass(0.93827); return;
5380 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5381 SetMass(0.93827); return;
5384 SetMass(0.13957); return;
5394 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5395 //-----------------------------------------------------------------
5396 // This funtion calculates dE/dX within the "low" and "up" cuts.
5397 //-----------------------------------------------------------------
5400 Float_t angular[200];
5401 Float_t weight[200];
5403 Bool_t inlimit[200];
5404 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5405 for (Int_t i=0;i<200;i++) amp[i]=10000;
5406 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5410 Float_t meanlog = 100.;
5411 Int_t indexde[4]={0,64,128,160};
5418 Float_t mean[4] = {0,0,0,0};
5419 Float_t sigma[4] = {1000,1000,1000,1000};
5420 Int_t nc[4] = {0,0,0,0};
5421 Float_t norm[4] = {1000,1000,1000,1000};
5426 // for (Int_t of =0; of<3; of++){
5427 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5428 for (Int_t i =0; i<160;i++)
5430 AliTPCTrackPoint * point = GetTrackPoint(i);
5431 if (point==0) continue;
5432 if (point->fIsShared){
5436 Int_t type = point->GetCPoint().GetType();
5437 if (type<0) continue;
5438 if (point->GetCPoint().GetMax()<5) continue;
5439 Float_t angley = point->GetTPoint().GetAngleY();
5440 Float_t anglez = point->GetTPoint().GetAngleZ();
5441 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5442 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5443 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5445 Float_t ampc = 0; // normalization to the number of electrons
5447 ampc = point->GetCPoint().GetMax();
5450 ampc = point->GetCPoint().GetMax();
5452 ampc *= 2.0; // put mean value to channel 50
5453 // ampc *= 0.565; // put mean value to channel 50
5456 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5463 if (type<0) { //amp at the border - lower weight
5466 if (rsigma>1.5) ampc/=1.3; // if big backround
5467 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5468 amp[i] = ampc/angular[i];
5473 TMath::Sort(159,amp,index,kFALSE);
5474 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5475 inlimit[index[i]] = kTRUE; // take all clusters
5478 // meanlog = amp[index[Int_t(anc*0.3)]];
5480 for (Int_t of =0; of<3; of++){
5484 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5486 if (inlimit[i]==kFALSE) continue;
5487 Float_t ampl = amp[i];
5489 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5492 sumamp += weight[i]*ampl;
5493 sumamp2 += weight[i]*ampl*ampl;
5494 norm[of] += angular[i]*weight[i];
5502 mean[of] = sumamp/sumw;
5503 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5505 sigma[of] = TMath::Sqrt(sigma[of]);
5508 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5518 Float_t www[3] = {12.,14.,17.};
5519 //Float_t www[3] = {1.,1.,1.};
5521 for (Int_t i =0;i<3;i++){
5522 if (nc[i]>2&&nc[i]<1000){
5523 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5524 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5525 fMAngular += norm[i] *nc[i];
5526 norm2 += nc[i]*www[i]/sigma[i];
5527 norm3 += (nc[i]-2)*www[i]/sigma[i];
5530 fSDEDX[i] = sigma[i];
5543 // Float_t dedx1 =dedx;
5547 for (Int_t i =0;i<3;i++){
5548 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5549 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5550 dedx += mean[i] *(nc[i])/(sigma[i]);
5551 norm4 += (nc[i])/(sigma[i]);
5555 if (norm4>0) dedx /= norm4;