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];
67 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
69 AliTPCFastMath::AliTPCFastMath(){
71 // initialized lookup table;
72 for (Int_t i=0;i<10000;i++){
73 fgFastAsin[2*i] = TMath::ASin(i/10000.);
74 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
78 Double_t AliTPCFastMath::FastAsin(Double_t x){
80 // return asin using lookup table
82 Int_t index = int(x*10000);
83 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
86 Int_t index = int(x*10000);
87 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
93 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
95 //update track information using current cluster - track->fCurrentCluster
98 AliTPCclusterMI* c =track->fCurrentCluster;
99 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
101 UInt_t i = track->fCurrentClusterIndex1;
103 Int_t sec=(i&0xff000000)>>24;
104 //Int_t row = (i&0x00ff0000)>>16;
105 track->fRow=(i&0x00ff0000)>>16;
106 track->fSector = sec;
107 // Int_t index = i&0xFFFF;
108 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
109 track->SetClusterIndex2(track->fRow, i);
110 //track->fFirstPoint = row;
111 //if ( track->fLastPoint<row) track->fLastPoint =row;
112 // if (track->fRow<0 || track->fRow>160) {
113 // printf("problem\n");
115 if (track->fFirstPoint>track->fRow)
116 track->fFirstPoint = track->fRow;
117 if (track->fLastPoint<track->fRow)
118 track->fLastPoint = track->fRow;
121 track->fClusterPointer[track->fRow] = c;
124 Float_t angle2 = track->GetSnp()*track->GetSnp();
125 angle2 = TMath::Sqrt(angle2/(1-angle2));
127 //SET NEW Track Point
131 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
133 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
134 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
135 point.SetErrY(sqrt(track->fErrorY2));
136 point.SetErrZ(sqrt(track->fErrorZ2));
138 point.SetX(track->GetX());
139 point.SetY(track->GetY());
140 point.SetZ(track->GetZ());
141 point.SetAngleY(angle2);
142 point.SetAngleZ(track->GetTgl());
143 if (point.fIsShared){
144 track->fErrorY2 *= 4;
145 track->fErrorZ2 *= 4;
149 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
151 track->fErrorY2 *= 1.3;
152 track->fErrorY2 += 0.01;
153 track->fErrorZ2 *= 1.3;
154 track->fErrorZ2 += 0.005;
156 if (accept>0) return 0;
157 if (track->GetNumberOfClusters()%20==0){
158 // if (track->fHelixIn){
159 // TClonesArray & larr = *(track->fHelixIn);
160 // Int_t ihelix = larr.GetEntriesFast();
161 // new(larr[ihelix]) AliHelix(*track) ;
164 track->fNoCluster =0;
165 return track->Update(c,chi2,i);
170 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
171 Float_t cory, Float_t corz)
174 // decide according desired precision to accept given
175 // cluster for tracking
176 Double_t sy2=ErrY2(seed,cluster)*cory;
177 Double_t sz2=ErrZ2(seed,cluster)*corz;
178 //sy2=ErrY2(seed,cluster)*cory;
179 //sz2=ErrZ2(seed,cluster)*cory;
181 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
182 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
184 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
185 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
186 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
187 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
189 Double_t rdistance2 = rdistancey2+rdistancez2;
192 if (rdistance2>16) return 3;
195 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
196 return 2; //suspisiouce - will be changed
198 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
199 // strict cut on overlaped cluster
200 return 2; //suspisiouce - will be changed
202 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
203 && cluster->GetType()<0){
213 //_____________________________________________________________________________
214 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
215 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
217 //---------------------------------------------------------------------
218 // The main TPC tracker constructor
219 //---------------------------------------------------------------------
220 fInnerSec=new AliTPCSector[fkNIS];
221 fOuterSec=new AliTPCSector[fkNOS];
224 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
225 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
232 Int_t nrowlow = par->GetNRowLow();
233 Int_t nrowup = par->GetNRowUp();
236 for (Int_t i=0;i<nrowlow;i++){
237 fXRow[i] = par->GetPadRowRadiiLow(i);
238 fPadLength[i]= par->GetPadPitchLength(0,i);
239 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
243 for (Int_t i=0;i<nrowup;i++){
244 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
245 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
246 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
259 //_____________________________________________________________________________
260 AliTPCtrackerMI::~AliTPCtrackerMI() {
261 //------------------------------------------------------------------
262 // TPC tracker destructor
263 //------------------------------------------------------------------
272 void AliTPCtrackerMI::SetIO()
276 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
278 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
280 AliTPCtrack *iotrack= new AliTPCtrack;
281 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
287 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
303 AliTPCtrack *iotrack= new AliTPCtrack;
304 // iotrack->fHelixIn = new TClonesArray("AliHelix");
305 //iotrack->fHelixOut = new TClonesArray("AliHelix");
306 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
309 if (output && (fDebug&2)){
310 //write the full seed information if specified in debug mode
312 fSeedTree = new TTree("Seeds","Seeds");
313 AliTPCseed * vseed = new AliTPCseed;
315 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
316 arrtr->ExpandCreateFast(160);
317 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
319 vseed->fPoints = arrtr;
320 vseed->fEPoints = arre;
321 // vseed->fClusterPoints = arrcl;
322 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
325 fTreeDebug = new TTree("trackDebug","trackDebug");
326 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
327 fTreeDebug->Branch("debug",&arrd,32000,99);
335 void AliTPCtrackerMI::FillESD(TObjArray* arr)
339 //fill esds using updated tracks
341 // write tracks to the event
342 // store index of the track
343 Int_t nseed=arr->GetEntriesFast();
344 for (Int_t i=0; i<nseed; i++) {
345 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
347 pt->PropagateTo(fParam->GetInnerRadiusLow());
348 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
350 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
351 //iotrack.SetTPCindex(i);
352 fEvent->AddTrack(&iotrack);
358 void AliTPCtrackerMI::WriteTracks(TTree * tree)
361 // write tracks from seed array to selected tree
365 AliTPCtrack *iotrack= new AliTPCtrack;
366 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
371 void AliTPCtrackerMI::WriteTracks()
374 // write tracks to the given output tree -
375 // output specified with SetIO routine
382 AliTPCtrack *iotrack= 0;
383 Int_t nseed=fSeeds->GetEntriesFast();
384 //for (Int_t i=0; i<nseed; i++) {
385 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
386 // if (iotrack) break;
388 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
389 TBranch * br = fOutput->GetBranch("tracks");
390 br->SetAddress(&iotrack);
392 for (Int_t i=0; i<nseed; i++) {
393 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
395 AliTPCtrack * track = new AliTPCtrack(*pt);
398 // br->SetAddress(&iotrack);
403 //fOutput->GetDirectory()->cd();
409 //write the full seed information if specified in debug mode
411 AliTPCseed * vseed = new AliTPCseed;
413 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
414 arrtr->ExpandCreateFast(160);
415 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
416 //arrcl->ExpandCreateFast(160);
417 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
419 vseed->fPoints = arrtr;
420 vseed->fEPoints = arre;
421 // vseed->fClusterPoints = arrcl;
422 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
423 TBranch * brseed = fSeedTree->GetBranch("seeds");
425 Int_t nseed=fSeeds->GetEntriesFast();
427 for (Int_t i=0; i<nseed; i++) {
428 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
431 // pt->fClusterPoints = arrcl;
435 brseed->SetAddress(&vseed);
439 // pt->fClusterPoints = 0;
442 if (fTreeDebug) fTreeDebug->Write();
450 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
453 //seed->SetErrorY2(0.1);
455 //calculate look-up table at the beginning
456 static Bool_t ginit = kFALSE;
457 static Float_t gnoise1,gnoise2,gnoise3;
458 static Float_t ggg1[10000];
459 static Float_t ggg2[10000];
460 static Float_t ggg3[10000];
461 static Float_t glandau1[10000];
462 static Float_t glandau2[10000];
463 static Float_t glandau3[10000];
465 static Float_t gcor01[500];
466 static Float_t gcor02[500];
467 static Float_t gcorp[500];
472 for (Int_t i=1;i<500;i++){
473 Float_t rsigma = float(i)/100.;
474 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
475 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
476 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
480 for (Int_t i=3;i<10000;i++){
484 Float_t amp = float(i);
485 Float_t padlength =0.75;
486 gnoise1 = 0.0004/padlength;
487 Float_t nel = 0.268*amp;
488 Float_t nprim = 0.155*amp;
489 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
490 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
491 if (glandau1[i]>1) glandau1[i]=1;
492 glandau1[i]*=padlength*padlength/12.;
496 gnoise2 = 0.0004/padlength;
499 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
500 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
501 if (glandau2[i]>1) glandau2[i]=1;
502 glandau2[i]*=padlength*padlength/12.;
507 gnoise3 = 0.0004/padlength;
510 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
511 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
512 if (glandau3[i]>1) glandau3[i]=1;
513 glandau3[i]*=padlength*padlength/12.;
521 Int_t amp = int(TMath::Abs(cl->GetQ()));
523 seed->SetErrorY2(1.);
527 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
528 Int_t ctype = cl->GetType();
529 Float_t padlength= GetPadPitchLength(seed->fRow);
530 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
531 angle2 = angle2/(1-angle2);
534 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
537 if (fSectors==fInnerSec){
539 res = ggg1[amp]*z+glandau1[amp]*angle2;
540 if (ctype==0) res *= gcor01[rsigmay];
543 res*= gcorp[rsigmay];
549 res = ggg2[amp]*z+glandau2[amp]*angle2;
550 if (ctype==0) res *= gcor02[rsigmay];
553 res*= gcorp[rsigmay];
558 res = ggg3[amp]*z+glandau3[amp]*angle2;
559 if (ctype==0) res *= gcor02[rsigmay];
562 res*= gcorp[rsigmay];
569 res*=2.4; // overestimate error 2 times
576 seed->SetErrorY2(res);
584 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
587 //seed->SetErrorY2(0.1);
589 //calculate look-up table at the beginning
590 static Bool_t ginit = kFALSE;
591 static Float_t gnoise1,gnoise2,gnoise3;
592 static Float_t ggg1[10000];
593 static Float_t ggg2[10000];
594 static Float_t ggg3[10000];
595 static Float_t glandau1[10000];
596 static Float_t glandau2[10000];
597 static Float_t glandau3[10000];
599 static Float_t gcor01[1000];
600 static Float_t gcor02[1000];
601 static Float_t gcorp[1000];
606 for (Int_t i=1;i<1000;i++){
607 Float_t rsigma = float(i)/100.;
608 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
609 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
610 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
614 for (Int_t i=3;i<10000;i++){
618 Float_t amp = float(i);
619 Float_t padlength =0.75;
620 gnoise1 = 0.0004/padlength;
621 Float_t nel = 0.268*amp;
622 Float_t nprim = 0.155*amp;
623 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
624 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
625 if (glandau1[i]>1) glandau1[i]=1;
626 glandau1[i]*=padlength*padlength/12.;
630 gnoise2 = 0.0004/padlength;
633 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
634 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
635 if (glandau2[i]>1) glandau2[i]=1;
636 glandau2[i]*=padlength*padlength/12.;
641 gnoise3 = 0.0004/padlength;
644 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
645 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
646 if (glandau3[i]>1) glandau3[i]=1;
647 glandau3[i]*=padlength*padlength/12.;
655 Int_t amp = int(TMath::Abs(cl->GetQ()));
657 seed->SetErrorY2(1.);
661 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
662 Int_t ctype = cl->GetType();
663 Float_t padlength= GetPadPitchLength(seed->fRow);
665 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
666 // if (angle2<0.6) angle2 = 0.6;
667 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
670 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
673 if (fSectors==fInnerSec){
675 res = ggg1[amp]*z+glandau1[amp]*angle2;
676 if (ctype==0) res *= gcor01[rsigmaz];
679 res*= gcorp[rsigmaz];
685 res = ggg2[amp]*z+glandau2[amp]*angle2;
686 if (ctype==0) res *= gcor02[rsigmaz];
689 res*= gcorp[rsigmaz];
694 res = ggg3[amp]*z+glandau3[amp]*angle2;
695 if (ctype==0) res *= gcor02[rsigmaz];
698 res*= gcorp[rsigmaz];
707 if ((ctype<0) &&<70){
715 seed->SetErrorZ2(res);
722 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
725 //seed->SetErrorZ2(0.1);
729 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
731 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
732 Int_t ctype = cl->GetType();
733 Float_t amp = TMath::Abs(cl->GetQ());
738 Float_t landau=2 ; //landau fluctuation part
739 Float_t gg=2; // gg fluctuation part
740 Float_t padlength= GetPadPitchLength(seed->GetX());
742 if (fSectors==fInnerSec){
743 snoise2 = 0.0004/padlength;
746 gg = (2+0.001*nel/(padlength*padlength))/nel;
747 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
748 if (landau>1) landau=1;
751 snoise2 = 0.0004/padlength;
754 gg = (2+0.0008*nel/(padlength*padlength))/nel;
755 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
756 if (landau>1) landau=1;
758 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
761 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
762 angle2 = TMath::Sqrt((1-angle2));
763 if (angle2<0.6) angle2 = 0.6;
766 Float_t angle = seed->GetTgl()/angle2;
767 Float_t angular = landau*angle*angle*padlength*padlength/12.;
768 Float_t res = sdiff + angular;
771 if ((ctype==0) && (fSectors ==fOuterSec))
772 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
774 if ((ctype==0) && (fSectors ==fInnerSec))
775 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
779 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
785 if ((ctype<0) &&<70){
793 seed->SetErrorZ2(res);
800 void AliTPCseed::Reset(Bool_t all)
804 SetNumberOfClusters(0);
810 for (Int_t i=0;i<8;i++){
811 delete [] fTrackPoints[i];
819 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
820 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
826 void AliTPCseed::Modify(Double_t factor)
829 //------------------------------------------------------------------
830 //This function makes a track forget its history :)
831 //------------------------------------------------------------------
837 fC10*=0; fC11*=factor;
838 fC20*=0; fC21*=0; fC22*=factor;
839 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
840 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
841 SetNumberOfClusters(0);
845 fCurrentSigmaY2 = 0.000005;
846 fCurrentSigmaZ2 = 0.000005;
855 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
857 //-----------------------------------------------------------------
858 // This function find proloncation of a track to a reference plane x=xk.
859 // doesn't change internal state of the track
860 //-----------------------------------------------------------------
862 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
864 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
868 // Double_t y1=fP0, z1=fP1;
869 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
870 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
874 //y += dx*(c1+c2)/(r1+r2);
875 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
877 Double_t dy = dx*(c1+c2)/(r1+r2);
880 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
882 if (TMath::Abs(delta)>0.0001){
883 dz = fP3*TMath::ASin(delta)/fP4;
885 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
888 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
898 //_____________________________________________________________________________
899 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
901 //-----------------------------------------------------------------
902 // This function calculates a predicted chi2 increment.
903 //-----------------------------------------------------------------
904 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
905 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
906 r00+=fC00; r01+=fC10; r11+=fC11;
908 Double_t det=r00*r11 - r01*r01;
909 if (TMath::Abs(det) < 1.e-10) {
910 Int_t n=GetNumberOfClusters();
911 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
914 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
916 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
918 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
922 //_________________________________________________________________________________________
925 Int_t AliTPCseed::Compare(const TObject *o) const {
926 //-----------------------------------------------------------------
927 // This function compares tracks according to the sector - for given sector according z
928 //-----------------------------------------------------------------
929 AliTPCseed *t=(AliTPCseed*)o;
932 if (t->fRelativeSector>fRelativeSector) return -1;
933 if (t->fRelativeSector<fRelativeSector) return 1;
934 Double_t z2 = t->GetZ();
935 Double_t z1 = GetZ();
937 if (z2<z1) return -1;
942 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
943 if (t->fBConstrain) f2=1.2;
946 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
948 if (fBConstrain) f1=1.2;
950 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
955 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
957 //rotate to track "local coordinata
958 Float_t x = seed->GetX();
959 Float_t y = seed->GetY();
960 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
963 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
964 if (!seed->Rotate(fSectors->GetAlpha()))
966 } else if (y <-ymax) {
967 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
968 if (!seed->Rotate(-fSectors->GetAlpha()))
977 //_____________________________________________________________________________
978 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
979 //-----------------------------------------------------------------
980 // This function associates a cluster with this track.
981 //-----------------------------------------------------------------
982 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
984 r00+=fC00; r01+=fC10; r11+=fC11;
985 Double_t det=r00*r11 - r01*r01;
986 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
988 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
989 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
990 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
991 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
992 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
994 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
995 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
996 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1000 fP0 += k00*dy + k01*dz;
1001 fP1 += k10*dy + k11*dz;
1003 fP3 += k30*dy + k31*dz;
1006 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1007 Double_t c12=fC21, c13=fC31, c14=fC41;
1009 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1010 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1011 fC40-=k00*c04+k01*c14;
1013 fC11-=k10*c01+k11*fC11;
1014 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1015 fC41-=k10*c04+k11*c14;
1017 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1018 fC42-=k20*c04+k21*c14;
1020 fC33-=k30*c03+k31*c13;
1021 fC43-=k40*c03+k41*c13;
1023 fC44-=k40*c04+k41*c14;
1025 Int_t n=GetNumberOfClusters();
1027 SetNumberOfClusters(n+1);
1028 SetChi2(GetChi2()+chisq);
1035 //_____________________________________________________________________________
1036 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1037 Double_t x2,Double_t y2,
1038 Double_t x3,Double_t y3)
1040 //-----------------------------------------------------------------
1041 // Initial approximation of the track curvature
1042 //-----------------------------------------------------------------
1043 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1044 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1045 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1046 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1047 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1049 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1050 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1051 return -xr*yr/sqrt(xr*xr+yr*yr);
1056 //_____________________________________________________________________________
1057 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1058 Double_t x2,Double_t y2,
1059 Double_t x3,Double_t y3)
1061 //-----------------------------------------------------------------
1062 // Initial approximation of the track curvature
1063 //-----------------------------------------------------------------
1069 Double_t det = x3*y2-x2*y3;
1074 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1075 Double_t x0 = x3*0.5-y3*u;
1076 Double_t y0 = y3*0.5+x3*u;
1077 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1083 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1084 Double_t x2,Double_t y2,
1085 Double_t x3,Double_t y3)
1087 //-----------------------------------------------------------------
1088 // Initial approximation of the track curvature
1089 //-----------------------------------------------------------------
1095 Double_t det = x3*y2-x2*y3;
1100 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1101 Double_t x0 = x3*0.5-y3*u;
1102 Double_t y0 = y3*0.5+x3*u;
1103 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1112 //_____________________________________________________________________________
1113 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1114 Double_t x2,Double_t y2,
1115 Double_t x3,Double_t y3)
1117 //-----------------------------------------------------------------
1118 // Initial approximation of the track curvature times center of curvature
1119 //-----------------------------------------------------------------
1120 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1121 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1122 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1123 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1124 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1126 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1128 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1131 //_____________________________________________________________________________
1132 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1133 Double_t x2,Double_t y2,
1134 Double_t z1,Double_t z2)
1136 //-----------------------------------------------------------------
1137 // Initial approximation of the tangent of the track dip angle
1138 //-----------------------------------------------------------------
1139 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1143 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1144 Double_t x2,Double_t y2,
1145 Double_t z1,Double_t z2, Double_t c)
1147 //-----------------------------------------------------------------
1148 // Initial approximation of the tangent of the track dip angle
1149 //-----------------------------------------------------------------
1153 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1155 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1156 if (TMath::Abs(d*c*0.5)>1) return 0;
1157 // Double_t angle2 = TMath::ASin(d*c*0.5);
1158 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1159 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1161 angle2 = (z1-z2)*c/(angle2*2.);
1165 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1166 {//-----------------------------------------------------------------
1167 // This function find proloncation of a track to a reference plane x=x2.
1168 //-----------------------------------------------------------------
1172 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1176 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1177 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1181 Double_t dy = dx*(c1+c2)/(r1+r2);
1184 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1186 if (TMath::Abs(delta)>0.01){
1187 dz = x[3]*TMath::ASin(delta)/x[4];
1189 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1192 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1200 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1205 return LoadClusters();
1208 Int_t AliTPCtrackerMI::LoadClusters()
1211 // load clusters to the memory
1212 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1213 clrow->SetClass("AliTPCclusterMI");
1215 clrow->GetArray()->ExpandCreateFast(10000);
1217 // TTree * tree = fClustersArray.GetTree();
1219 TTree * tree = fInput;
1220 TBranch * br = tree->GetBranch("Segment");
1221 br->SetAddress(&clrow);
1223 Int_t j=Int_t(tree->GetEntries());
1224 for (Int_t i=0; i<j; i++) {
1228 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1230 AliTPCRow * tpcrow=0;
1233 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1237 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1238 left = (sec-fkNIS*2)/fkNOS;
1241 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1242 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1243 for (Int_t i=0;i<tpcrow->fN1;i++)
1244 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1247 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1248 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1249 for (Int_t i=0;i<tpcrow->fN2;i++)
1250 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1261 void AliTPCtrackerMI::UnloadClusters()
1264 // unload clusters from the memory
1266 Int_t nrows = fOuterSec->GetNRows();
1267 for (Int_t sec = 0;sec<fkNOS;sec++)
1268 for (Int_t row = 0;row<nrows;row++){
1269 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1271 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1272 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1274 tpcrow->ResetClusters();
1277 nrows = fInnerSec->GetNRows();
1278 for (Int_t sec = 0;sec<fkNIS;sec++)
1279 for (Int_t row = 0;row<nrows;row++){
1280 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1282 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1283 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1285 tpcrow->ResetClusters();
1292 //_____________________________________________________________________________
1293 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1294 //-----------------------------------------------------------------
1295 // This function fills outer TPC sectors with clusters.
1296 //-----------------------------------------------------------------
1297 Int_t nrows = fOuterSec->GetNRows();
1299 for (Int_t sec = 0;sec<fkNOS;sec++)
1300 for (Int_t row = 0;row<nrows;row++){
1301 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1302 Int_t sec2 = sec+2*fkNIS;
1304 Int_t ncl = tpcrow->fN1;
1306 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1307 index=(((sec2<<8)+row)<<16)+ncl;
1308 tpcrow->InsertCluster(c,index);
1313 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1314 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1315 tpcrow->InsertCluster(c,index);
1318 // write indexes for fast acces
1320 for (Int_t i=0;i<510;i++)
1321 tpcrow->fFastCluster[i]=-1;
1322 for (Int_t i=0;i<tpcrow->GetN();i++){
1323 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1324 tpcrow->fFastCluster[zi]=i; // write index
1327 for (Int_t i=0;i<510;i++){
1328 if (tpcrow->fFastCluster[i]<0)
1329 tpcrow->fFastCluster[i] = last;
1331 last = tpcrow->fFastCluster[i];
1340 //_____________________________________________________________________________
1341 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1342 //-----------------------------------------------------------------
1343 // This function fills inner TPC sectors with clusters.
1344 //-----------------------------------------------------------------
1345 Int_t nrows = fInnerSec->GetNRows();
1347 for (Int_t sec = 0;sec<fkNIS;sec++)
1348 for (Int_t row = 0;row<nrows;row++){
1349 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1352 Int_t ncl = tpcrow->fN1;
1354 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1355 index=(((sec<<8)+row)<<16)+ncl;
1356 tpcrow->InsertCluster(c,index);
1361 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1362 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1363 tpcrow->InsertCluster(c,index);
1366 // write indexes for fast acces
1368 for (Int_t i=0;i<510;i++)
1369 tpcrow->fFastCluster[i]=-1;
1370 for (Int_t i=0;i<tpcrow->GetN();i++){
1371 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1372 tpcrow->fFastCluster[zi]=i; // write index
1375 for (Int_t i=0;i<510;i++){
1376 if (tpcrow->fFastCluster[i]<0)
1377 tpcrow->fFastCluster[i] = last;
1379 last = tpcrow->fFastCluster[i];
1391 //_________________________________________________________________________
1392 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1393 //--------------------------------------------------------------------
1394 // Return pointer to a given cluster
1395 //--------------------------------------------------------------------
1396 Int_t sec=(index&0xff000000)>>24;
1397 Int_t row=(index&0x00ff0000)>>16;
1398 Int_t ncl=(index&0x00007fff)>>00;
1400 const AliTPCRow * tpcrow=0;
1401 AliTPCclusterMI * clrow =0;
1403 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1405 clrow = tpcrow->fClusters1;
1407 clrow = tpcrow->fClusters2;
1410 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1411 if (sec-2*fkNIS<fkNOS)
1412 clrow = tpcrow->fClusters1;
1414 clrow = tpcrow->fClusters2;
1416 if (tpcrow==0) return 0;
1417 if (tpcrow->GetN()<=ncl) return 0;
1418 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1419 return &(clrow[ncl]);
1425 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1426 //-----------------------------------------------------------------
1427 // This function tries to find a track prolongation to next pad row
1428 //-----------------------------------------------------------------
1430 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1431 AliTPCclusterMI *cl=0;
1432 Int_t tpcindex= t.GetClusterIndex2(nr);
1434 // update current shape info every 5 pad-row
1435 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1439 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1441 if (tpcindex==-1) return 0; //track in dead zone
1443 cl = t.fClusterPointer[nr];
1444 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1445 t.fCurrentClusterIndex1 = tpcindex;
1448 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1449 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1451 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1452 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1454 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1455 Double_t rotation = angle-t.GetAlpha();
1456 t.fRelativeSector= relativesector;
1461 t.fCurrentCluster = cl;
1463 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1464 if ((tpcindex&0x8000)==0) accept =0;
1466 //if founded cluster is acceptible
1467 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1474 UpdateTrack(&t,accept);
1479 if (fIteration>1) return 0; // not look for new cluster during refitting
1482 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1483 Double_t y=t.GetYat(x);
1484 if (TMath::Abs(y)>ymax){
1486 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1487 if (!t.Rotate(fSectors->GetAlpha()))
1489 } else if (y <-ymax) {
1490 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1491 if (!t.Rotate(-fSectors->GetAlpha()))
1497 if (!t.PropagateTo(x)) {
1498 if (fIteration==0) t.fRemoval = 10;
1502 Double_t z=t.GetZ();
1504 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1505 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1507 Double_t roadz = 1.;
1509 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1511 t.SetClusterIndex2(nr,-1);
1516 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1522 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1523 cl = krow.FindNearest2(y,z,roady,roadz,index);
1524 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1527 t.fCurrentCluster = cl;
1529 if (fIteration==2&&cl->IsUsed(10)) return 0;
1530 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1531 if (fIteration==2&&cl->IsUsed(11)) {
1538 if (t.fCurrentCluster->IsUsed(10)){
1543 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1549 if (accept<3) UpdateTrack(&t,accept);
1552 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1558 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1559 //-----------------------------------------------------------------
1560 // This function tries to find a track prolongation to next pad row
1561 //-----------------------------------------------------------------
1563 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1565 if (!t.GetProlongation(x,y,z)) {
1571 if (TMath::Abs(y)>ymax){
1574 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1575 if (!t.Rotate(fSectors->GetAlpha()))
1577 } else if (y <-ymax) {
1578 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1579 if (!t.Rotate(-fSectors->GetAlpha()))
1582 if (!t.PropagateTo(x)) {
1585 t.GetProlongation(x,y,z);
1588 // update current shape info every 3 pad-row
1589 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1590 // t.fCurrentSigmaY = GetSigmaY(&t);
1591 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1595 AliTPCclusterMI *cl=0;
1600 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1601 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1603 Double_t roadz = 1.;
1606 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1608 t.SetClusterIndex2(row,-1);
1613 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1617 if ((cl==0)&&(krow)) {
1618 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1619 cl = krow.FindNearest2(y,z,roady,roadz,index);
1621 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1625 t.fCurrentCluster = cl;
1626 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1628 t.SetClusterIndex2(row,index);
1629 t.fClusterPointer[row] = cl;
1637 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1638 //-----------------------------------------------------------------
1639 // This function tries to find a track prolongation to next pad row
1640 //-----------------------------------------------------------------
1641 t.fCurrentCluster = 0;
1642 t.fCurrentClusterIndex1 = 0;
1644 Double_t xt=t.GetX();
1645 Int_t row = GetRowNumber(xt)-1;
1646 Double_t ymax= GetMaxY(nr);
1648 if (row < nr) return 1; // don't prolongate if not information until now -
1649 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1651 return 0; // not prolongate strongly inclined tracks
1653 if (TMath::Abs(t.GetSnp())>0.95) {
1655 return 0; // not prolongate strongly inclined tracks
1658 Double_t x= GetXrow(nr);
1660 //t.PropagateTo(x+0.02);
1661 //t.PropagateTo(x+0.01);
1662 if (!t.PropagateTo(x)){
1669 if (TMath::Abs(y)>ymax){
1671 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1672 if (!t.Rotate(fSectors->GetAlpha()))
1674 } else if (y <-ymax) {
1675 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1676 if (!t.Rotate(-fSectors->GetAlpha()))
1679 // if (!t.PropagateTo(x)){
1687 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1689 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1691 t.SetClusterIndex2(nr,-1);
1696 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1702 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1703 // t.fCurrentSigmaY = GetSigmaY(&t);
1704 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1708 AliTPCclusterMI *cl=0;
1711 Double_t roady = 1.;
1712 Double_t roadz = 1.;
1716 index = t.GetClusterIndex2(nr);
1717 if ( (index>0) && (index&0x8000)==0){
1718 cl = t.fClusterPointer[nr];
1719 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1720 t.fCurrentClusterIndex1 = index;
1722 t.fCurrentCluster = cl;
1729 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1730 cl = krow.FindNearest2(y,z,roady,roadz,index);
1733 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1734 t.fCurrentCluster = cl;
1740 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1741 //-----------------------------------------------------------------
1742 // This function tries to find a track prolongation to next pad row
1743 //-----------------------------------------------------------------
1745 //update error according neighborhoud
1747 if (t.fCurrentCluster) {
1749 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1751 if (t.fCurrentCluster->IsUsed(10)){
1757 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1762 if (fIteration>0) accept = 0;
1763 if (accept<3) UpdateTrack(&t,accept);
1767 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1768 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1770 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1778 //_____________________________________________________________________________
1779 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1780 //-----------------------------------------------------------------
1781 // This function tries to find a track prolongation.
1782 //-----------------------------------------------------------------
1783 Double_t xt=t.GetX();
1785 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1786 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1787 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1789 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1791 Int_t first = GetRowNumber(xt)-1;
1792 for (Int_t nr= first; nr>=rf; nr-=step) {
1793 if (nr<fInnerSec->GetNRows())
1794 fSectors = fInnerSec;
1796 fSectors = fOuterSec;
1797 if (FollowToNext(t,nr)==0)
1806 //_____________________________________________________________________________
1807 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1808 //-----------------------------------------------------------------
1809 // This function tries to find a track prolongation.
1810 //-----------------------------------------------------------------
1811 Double_t xt=t.GetX();
1813 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1814 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1815 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1816 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1818 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1820 if (FollowToNextFast(t,nr)==0)
1821 if (!t.IsActive()) return 0;
1831 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1832 //-----------------------------------------------------------------
1833 // This function tries to find a track prolongation.
1834 //-----------------------------------------------------------------
1835 // Double_t xt=t.GetX();
1837 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1838 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1839 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1840 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1842 Int_t first = t.fFirstPoint;
1844 if (first<0) first=0;
1845 for (Int_t nr=first; nr<=rf; nr++) {
1846 //if ( (t.GetSnp()<0.9))
1847 if (nr<fInnerSec->GetNRows())
1848 fSectors = fInnerSec;
1850 fSectors = fOuterSec;
1860 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1868 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1871 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1873 Float_t distance = TMath::Sqrt(dz2+dy2);
1874 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1877 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1878 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1883 if (firstpoint>lastpoint) {
1884 firstpoint =lastpoint;
1889 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1890 if (s1->GetClusterIndex2(i)>0) sum1++;
1891 if (s2->GetClusterIndex2(i)>0) sum2++;
1892 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1896 if (sum<5) return 0;
1898 Float_t summin = TMath::Min(sum1+1,sum2+1);
1899 Float_t ratio = (sum+1)/Float_t(summin);
1903 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1907 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1908 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1910 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1912 Float_t dy2 =(s1->GetY() - s2->GetY());
1914 Float_t distance = dz2+dy2;
1915 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1920 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1921 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1923 if (firstpoint>=lastpoint-5) return;;
1925 for (Int_t i=firstpoint;i<lastpoint;i++){
1926 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1927 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1934 for (Int_t i=firstpoint;i<lastpoint;i++){
1935 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1936 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1937 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1938 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1939 if (s1->IsActive()&&s2->IsActive()){
1940 p1->fIsShared = kTRUE;
1941 p2->fIsShared = kTRUE;
1948 for (Int_t i=0;i<4;i++){
1949 if (s1->fOverlapLabels[3*i]==0){
1950 s1->fOverlapLabels[3*i] = s2->GetLabel();
1951 s1->fOverlapLabels[3*i+1] = sumshared;
1952 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1956 for (Int_t i=0;i<4;i++){
1957 if (s2->fOverlapLabels[3*i]==0){
1958 s2->fOverlapLabels[3*i] = s1->GetLabel();
1959 s2->fOverlapLabels[3*i+1] = sumshared;
1960 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1968 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1971 //sort trackss according sectors
1973 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1974 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1976 //if (pt) RotateToLocal(pt);
1980 arr->Sort(); // sorting according z
1981 arr->Expand(arr->GetEntries());
1984 Int_t nseed=arr->GetEntriesFast();
1985 for (Int_t i=0; i<nseed; i++) {
1986 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1988 for (Int_t j=0;j<=12;j++){
1989 pt->fOverlapLabels[j] =0;
1992 for (Int_t i=0; i<nseed; i++) {
1993 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1995 if (pt->fRemoval>10) continue;
1996 for (Int_t j=i+1; j<nseed; j++){
1997 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1999 if (pt2->fRemoval<=10) {
2000 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2007 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2010 //sort trackss according sectors
2013 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2016 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2017 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2022 arr->Sort(); // sorting according z
2023 arr->Expand(arr->GetEntries());
2025 //reset overlap labels
2027 Int_t nseed=arr->GetEntriesFast();
2028 for (Int_t i=0; i<nseed; i++) {
2029 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2032 for (Int_t j=0;j<=12;j++){
2033 pt->fOverlapLabels[j] =0;
2037 //sign shared tracks
2038 for (Int_t i=0; i<nseed; i++) {
2039 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2041 if (pt->fRemoval>10) continue;
2042 Float_t deltac = pt->GetC()*0.1;
2043 for (Int_t j=i+1; j<nseed; j++){
2044 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2046 if (pt2->fRemoval<=10) {
2047 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2048 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2049 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2056 // remove highly shared tracks
2057 for (Int_t i=0; i<nseed; i++) {
2058 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2060 if (pt->fRemoval>10) continue;
2063 for (Int_t j=0;j<4;j++){
2064 sumshared = pt->fOverlapLabels[j*3+1];
2066 Float_t factor = factor1;
2067 if (pt->fRemoval>0) factor = factor2;
2068 if (sumshared/pt->GetNumberOfClusters()>factor){
2069 for (Int_t j=0;j<4;j++){
2070 if (pt->fOverlapLabels[3*j]==0) continue;
2071 if (pt->fOverlapLabels[3*j+1]<5) continue;
2072 if (pt->fRemoval==removalindex) continue;
2073 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2075 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2076 // pt->fRemoval = removalindex;
2077 delete arr->RemoveAt(i);
2085 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2094 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2097 //sort tracks in array according mode criteria
2098 Int_t nseed = arr->GetEntriesFast();
2099 for (Int_t i=0; i<nseed; i++) {
2100 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2110 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2113 //Loop over all tracks and remove "overlaps"
2116 Int_t nseed = arr->GetEntriesFast();
2119 for (Int_t i=0; i<nseed; i++) {
2120 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2122 delete arr->RemoveAt(i);
2126 pt->fBSigned = kFALSE;
2130 nseed = arr->GetEntriesFast();
2137 for (Int_t i=0; i<nseed; i++) {
2138 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2142 Int_t found,foundable,shared;
2144 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2146 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2148 Double_t factor = factor2;
2149 if (pt->fBConstrain) factor = factor1;
2151 if ((Float_t(shared)/Float_t(found))>factor){
2152 pt->Desactivate(removalindex);
2157 for (Int_t i=0; i<160; i++) {
2158 Int_t index=pt->GetClusterIndex2(i);
2159 if (index<0 || index&0x8000 ) continue;
2160 AliTPCclusterMI *c= pt->fClusterPointer[i];
2162 // if (!c->IsUsed(10)) c->Use(10);
2163 //if (pt->IsActive())
2172 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2176 void AliTPCtrackerMI::UnsignClusters()
2179 // loop over all clusters and unsign them
2182 for (Int_t sec=0;sec<fkNIS;sec++){
2183 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2184 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2185 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2186 // if (cl[icl].IsUsed(10))
2188 cl = fInnerSec[sec][row].fClusters2;
2189 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2190 //if (cl[icl].IsUsed(10))
2195 for (Int_t sec=0;sec<fkNOS;sec++){
2196 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2197 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2198 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2199 //if (cl[icl].IsUsed(10))
2201 cl = fOuterSec[sec][row].fClusters2;
2202 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2203 //if (cl[icl].IsUsed(10))
2212 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2215 //sign clusters to be "used"
2217 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2218 // loop over "primaries"
2232 Int_t nseed = arr->GetEntriesFast();
2233 for (Int_t i=0; i<nseed; i++) {
2234 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2238 if (!(pt->IsActive())) continue;
2239 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2240 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2242 sumdens2+= dens*dens;
2243 sumn += pt->GetNumberOfClusters();
2244 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2245 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2248 sumchi2 +=chi2*chi2;
2253 Float_t mdensity = 0.9;
2254 Float_t meann = 130;
2255 Float_t meanchi = 1;
2256 Float_t sdensity = 0.1;
2257 Float_t smeann = 10;
2258 Float_t smeanchi =0.4;
2262 mdensity = sumdens/sum;
2264 meanchi = sumchi/sum;
2266 sdensity = sumdens2/sum-mdensity*mdensity;
2267 sdensity = TMath::Sqrt(sdensity);
2269 smeann = sumn2/sum-meann*meann;
2270 smeann = TMath::Sqrt(smeann);
2272 smeanchi = sumchi2/sum - meanchi*meanchi;
2273 smeanchi = TMath::Sqrt(smeanchi);
2277 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2279 for (Int_t i=0; i<nseed; i++) {
2280 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2284 if (pt->fBSigned) continue;
2285 if (pt->fBConstrain) continue;
2286 //if (!(pt->IsActive())) continue;
2288 Int_t found,foundable,shared;
2289 pt->GetClusterStatistic(0,160,found, foundable,shared);
2290 if (shared/float(found)>0.3) {
2291 if (shared/float(found)>0.9 ){
2292 //delete arr->RemoveAt(i);
2297 Bool_t isok =kFALSE;
2298 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2300 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2302 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2304 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2308 for (Int_t i=0; i<160; i++) {
2309 Int_t index=pt->GetClusterIndex2(i);
2310 if (index<0) continue;
2311 AliTPCclusterMI *c= pt->fClusterPointer[i];
2313 //if (!(c->IsUsed(10))) c->Use();
2320 Double_t maxchi = meanchi+2.*smeanchi;
2322 for (Int_t i=0; i<nseed; i++) {
2323 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2327 //if (!(pt->IsActive())) continue;
2328 if (pt->fBSigned) continue;
2329 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2330 if (chi>maxchi) continue;
2333 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2335 //sign only tracks with enoug big density at the beginning
2337 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2340 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2341 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2343 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2344 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2347 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2348 //Int_t noc=pt->GetNumberOfClusters();
2349 pt->fBSigned = kTRUE;
2350 for (Int_t i=0; i<160; i++) {
2352 Int_t index=pt->GetClusterIndex2(i);
2353 if (index<0) continue;
2354 AliTPCclusterMI *c= pt->fClusterPointer[i];
2356 // if (!(c->IsUsed(10))) c->Use();
2361 // gLastCheck = nseed;
2369 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2371 // stop not active tracks
2372 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2373 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2374 Int_t nseed = arr->GetEntriesFast();
2376 for (Int_t i=0; i<nseed; i++) {
2377 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2381 if (!(pt->IsActive())) continue;
2382 StopNotActive(pt,row0,th0, th1,th2);
2388 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2391 // stop not active tracks
2392 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2393 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2396 Int_t foundable = 0;
2397 Int_t maxindex = seed->fLastPoint; //last foundable row
2398 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2399 seed->Desactivate(10) ;
2403 for (Int_t i=row0; i<maxindex; i++){
2404 Int_t index = seed->GetClusterIndex2(i);
2405 if (index!=-1) foundable++;
2407 if (foundable<=30) sumgood1++;
2408 if (foundable<=50) {
2415 if (foundable>=30.){
2416 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2419 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2423 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2426 // back propagation of ESD tracks
2432 //PrepareForProlongation(fSeeds,1);
2433 PropagateForward2(fSeeds);
2435 Int_t nseed = fSeeds->GetEntriesFast();
2436 for (Int_t i=0;i<nseed;i++){
2437 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2438 if (!seed) continue;
2439 seed->PropagateTo(fParam->GetInnerRadiusLow());
2440 AliESDtrack *esd=event->GetTrack(i);
2441 seed->CookdEdx(0.02,0.6);
2442 CookLabel(seed,0.1); //For comparison only
2443 if (seed->GetNumberOfClusters()>60){
2444 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2448 //printf("problem\n");
2451 Info("RefitInward","Number of refitted tracks %d",ntracks);
2458 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2461 // back propagation of ESD tracks
2467 PropagateBack(fSeeds);
2468 Int_t nseed = fSeeds->GetEntriesFast();
2470 for (Int_t i=0;i<nseed;i++){
2471 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2472 if (!seed) continue;
2473 AliESDtrack *esd=event->GetTrack(i);
2474 seed->CookdEdx(0.02,0.6);
2475 CookLabel(seed,0.1); //For comparison only
2476 if (seed->GetNumberOfClusters()>60){
2477 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2481 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2488 void AliTPCtrackerMI::DeleteSeeds()
2492 Int_t nseed = fSeeds->GetEntriesFast();
2493 for (Int_t i=0;i<nseed;i++){
2494 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2495 if (seed) delete fSeeds->RemoveAt(i);
2501 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2504 //read seeds from the event
2506 Int_t nentr=event->GetNumberOfTracks();
2508 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2513 fSeeds = new TObjArray(nentr);
2517 for (Int_t i=0; i<nentr; i++) {
2518 AliESDtrack *esd=event->GetTrack(i);
2519 ULong_t status=esd->GetStatus();
2520 AliTPCtrack t(*esd);
2521 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2522 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2523 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2524 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2529 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2530 Double_t par0[5],par1[5],x;
2531 esd->GetInnerExternalParameters(x,par0);
2532 esd->GetExternalParameters(x,par1);
2533 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2534 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2535 //reset covariance if suspicious
2536 if ( (delta1>0.1) || (delta2>0.006))
2537 seed->ResetCovariance();
2542 // rotate to the local coordinate system
2544 fSectors=fInnerSec; fN=fkNIS;
2546 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2547 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2548 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2549 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2550 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2551 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2552 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2553 alpha-=seed->GetAlpha();
2554 if (!seed->Rotate(alpha)) {
2560 //seed->PropagateTo(fSectors->GetX(0));
2562 // Int_t index = esd->GetTPCindex();
2563 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2564 //if (direction==2){
2565 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2573 for (Int_t irow=0;irow<160;irow++){
2574 Int_t index = seed->GetClusterIndex2(irow);
2577 AliTPCclusterMI * cl = GetClusterMI(index);
2578 seed->fClusterPointer[irow] = cl;
2580 if ((index & 0x8000)==0){
2581 cl->Use(10); // accepted cluster
2583 cl->Use(6); // close cluster not accepted
2586 Info("ReadSeeds","Not found cluster");
2590 fSeeds->AddAt(seed,i);
2596 //_____________________________________________________________________________
2597 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2598 Float_t deltay, Int_t ddsec) {
2599 //-----------------------------------------------------------------
2600 // This function creates track seeds.
2601 // SEEDING WITH VERTEX CONSTRAIN
2602 //-----------------------------------------------------------------
2603 // cuts[0] - fP4 cut
2604 // cuts[1] - tan(phi) cut
2605 // cuts[2] - zvertex cut
2606 // cuts[3] - fP3 cut
2614 Double_t x[5], c[15];
2615 // Int_t di = i1-i2;
2617 AliTPCseed * seed = new AliTPCseed;
2618 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2619 Double_t cs=cos(alpha), sn=sin(alpha);
2621 // Double_t x1 =fOuterSec->GetX(i1);
2622 //Double_t xx2=fOuterSec->GetX(i2);
2624 Double_t x1 =GetXrow(i1);
2625 Double_t xx2=GetXrow(i2);
2627 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2629 Int_t imiddle = (i2+i1)/2; //middle pad row index
2630 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2631 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2635 const AliTPCRow& kr1=GetRow(ns,i1);
2636 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2637 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2640 // change cut on curvature if it can't reach this layer
2641 // maximal curvature set to reach it
2642 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2643 if (dvertexmax*0.5*cuts[0]>0.85){
2644 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2646 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2649 if (deltay>0) ddsec = 0;
2650 // loop over clusters
2651 for (Int_t is=0; is < kr1; is++) {
2653 if (kr1[is]->IsUsed(10)) continue;
2654 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2655 //if (TMath::Abs(y1)>ymax) continue;
2657 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2659 // find possible directions
2660 Float_t anglez = (z1-z3)/(x1-x3);
2661 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2664 //find rotation angles relative to line given by vertex and point 1
2665 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2666 Double_t dvertex = TMath::Sqrt(dvertex2);
2667 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2668 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2671 // loop over 2 sectors
2677 Double_t dddz1=0; // direction of delta inclination in z axis
2684 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2685 Int_t sec2 = sec + dsec;
2687 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2688 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2689 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2690 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2691 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2692 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2694 // rotation angles to p1-p3
2695 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2696 Double_t x2, y2, z2;
2698 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2701 Double_t dxx0 = (xx2-x3)*cs13r;
2702 Double_t dyy0 = (xx2-x3)*sn13r;
2703 for (Int_t js=index1; js < index2; js++) {
2704 const AliTPCclusterMI *kcl = kr2[js];
2705 if (kcl->IsUsed(10)) continue;
2707 //calcutate parameters
2709 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2711 if (TMath::Abs(yy0)<0.000001) continue;
2712 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2713 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2714 Double_t r02 = (0.25+y0*y0)*dvertex2;
2715 //curvature (radius) cut
2716 if (r02<r2min) continue;
2720 Double_t c0 = 1/TMath::Sqrt(r02);
2724 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2725 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2726 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2727 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2730 Double_t z0 = kcl->GetZ();
2731 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2732 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2735 Double_t dip = (z1-z0)*c0/dfi1;
2736 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2747 x2= xx2*cs-y2*sn*dsec;
2748 y2=+xx2*sn*dsec+y2*cs;
2758 // do we have cluster at the middle ?
2760 GetProlongation(x1,xm,x,ym,zm);
2762 AliTPCclusterMI * cm=0;
2763 if (TMath::Abs(ym)-ymaxm<0){
2764 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2765 if ((!cm) || (cm->IsUsed(10))) {
2770 // rotate y1 to system 0
2771 // get state vector in rotated system
2772 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2773 Double_t xr2 = x0*cs+yr1*sn*dsec;
2774 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2776 GetProlongation(xx2,xm,xr,ym,zm);
2777 if (TMath::Abs(ym)-ymaxm<0){
2778 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2779 if ((!cm) || (cm->IsUsed(10))) {
2789 dym = ym - cm->GetY();
2790 dzm = zm - cm->GetZ();
2797 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2798 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2799 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2800 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2801 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2803 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2804 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2805 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2806 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2807 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2808 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2810 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2811 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2812 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2813 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2817 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2818 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2819 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2820 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2821 c[13]=f30*sy1*f40+f32*sy2*f42;
2822 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2824 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2826 UInt_t index=kr1.GetIndex(is);
2827 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2829 track->fIsSeeding = kTRUE;
2836 FollowProlongation(*track, (i1+i2)/2,1);
2837 Int_t foundable,found,shared;
2838 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2839 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2841 seed->~AliTPCseed();
2847 FollowProlongation(*track, i2,1);
2851 track->fBConstrain =1;
2852 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2853 track->fLastPoint = i1; // first cluster in track position
2854 track->fFirstPoint = track->fLastPoint;
2856 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2857 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2858 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2860 seed->~AliTPCseed();
2864 // Z VERTEX CONDITION
2866 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2867 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2868 if (TMath::Abs(zv-z3)>cuts[2]) {
2869 FollowProlongation(*track, TMath::Max(i2-20,0));
2870 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2871 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2872 if (TMath::Abs(zv-z3)>cuts[2]){
2873 FollowProlongation(*track, TMath::Max(i2-40,0));
2874 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2875 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2876 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2877 // make seed without constrain
2878 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2879 FollowProlongation(*track2, i2,1);
2880 track2->fBConstrain = kFALSE;
2881 track2->fSeedType = 1;
2882 arr->AddLast(track2);
2884 seed->~AliTPCseed();
2889 seed->~AliTPCseed();
2896 track->fSeedType =0;
2897 arr->AddLast(track);
2898 seed = new AliTPCseed;
2900 // don't consider other combinations
2901 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2907 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2913 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2918 //-----------------------------------------------------------------
2919 // This function creates track seeds.
2920 //-----------------------------------------------------------------
2921 // cuts[0] - fP4 cut
2922 // cuts[1] - tan(phi) cut
2923 // cuts[2] - zvertex cut
2924 // cuts[3] - fP3 cut
2934 Double_t x[5], c[15];
2936 // make temporary seed
2937 AliTPCseed * seed = new AliTPCseed;
2938 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2939 // Double_t cs=cos(alpha), sn=sin(alpha);
2944 Double_t x1 = GetXrow(i1-1);
2945 const AliTPCRow& kr1=GetRow(sec,i1-1);
2946 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2948 Double_t x1p = GetXrow(i1);
2949 const AliTPCRow& kr1p=GetRow(sec,i1);
2951 Double_t x1m = GetXrow(i1-2);
2952 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2955 //last 3 padrow for seeding
2956 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2957 Double_t x3 = GetXrow(i1-7);
2958 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2960 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2961 Double_t x3p = GetXrow(i1-6);
2963 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2964 Double_t x3m = GetXrow(i1-8);
2969 Int_t im = i1-4; //middle pad row index
2970 Double_t xm = GetXrow(im); // radius of middle pad-row
2971 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2972 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2975 Double_t deltax = x1-x3;
2976 Double_t dymax = deltax*cuts[1];
2977 Double_t dzmax = deltax*cuts[3];
2979 // loop over clusters
2980 for (Int_t is=0; is < kr1; is++) {
2982 if (kr1[is]->IsUsed(10)) continue;
2983 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2985 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2987 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2988 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2994 for (Int_t js=index1; js < index2; js++) {
2995 const AliTPCclusterMI *kcl = kr3[js];
2996 if (kcl->IsUsed(10)) continue;
2998 // apply angular cuts
2999 if (TMath::Abs(y1-y3)>dymax) continue;
3002 if (TMath::Abs(z1-z3)>dzmax) continue;
3004 Double_t angley = (y1-y3)/(x1-x3);
3005 Double_t anglez = (z1-z3)/(x1-x3);
3007 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3008 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3010 Double_t yyym = angley*(xm-x1)+y1;
3011 Double_t zzzm = anglez*(xm-x1)+z1;
3013 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3015 if (kcm->IsUsed(10)) continue;
3017 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3018 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3025 // look around first
3026 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3032 if (kc1m->IsUsed(10)) used++;
3034 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3040 if (kc1p->IsUsed(10)) used++;
3042 if (used>1) continue;
3043 if (found<1) continue;
3047 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3053 if (kc3m->IsUsed(10)) used++;
3057 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3063 if (kc3p->IsUsed(10)) used++;
3067 if (used>1) continue;
3068 if (found<3) continue;
3078 x[4]=F1(x1,y1,x2,y2,x3,y3);
3079 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3082 x[2]=F2(x1,y1,x2,y2,x3,y3);
3085 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3086 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3090 Double_t sy1=0.1, sz1=0.1;
3091 Double_t sy2=0.1, sz2=0.1;
3092 Double_t sy3=0.1, sy=0.1, sz=0.1;
3094 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3095 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3096 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3097 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3098 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3099 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3101 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3102 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3103 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3104 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3108 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3109 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3110 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3111 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3112 c[13]=f30*sy1*f40+f32*sy2*f42;
3113 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3115 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3117 UInt_t index=kr1.GetIndex(is);
3118 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3120 track->fIsSeeding = kTRUE;
3123 FollowProlongation(*track, i1-7,1);
3124 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3125 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3127 seed->~AliTPCseed();
3133 FollowProlongation(*track, i2,1);
3134 track->fBConstrain =0;
3135 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3136 track->fFirstPoint = track->fLastPoint;
3138 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3139 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3140 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3142 seed->~AliTPCseed();
3147 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3148 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3149 FollowProlongation(*track2, i2,1);
3150 track2->fBConstrain = kFALSE;
3151 track2->fSeedType = 4;
3152 arr->AddLast(track2);
3154 seed->~AliTPCseed();
3158 //arr->AddLast(track);
3159 //seed = new AliTPCseed;
3165 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3171 //_____________________________________________________________________________
3172 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3173 Float_t deltay, Bool_t /*bconstrain*/) {
3174 //-----------------------------------------------------------------
3175 // This function creates track seeds - without vertex constraint
3176 //-----------------------------------------------------------------
3177 // cuts[0] - fP4 cut - not applied
3178 // cuts[1] - tan(phi) cut
3179 // cuts[2] - zvertex cut - not applied
3180 // cuts[3] - fP3 cut
3190 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3191 // Double_t cs=cos(alpha), sn=sin(alpha);
3192 Int_t row0 = (i1+i2)/2;
3193 Int_t drow = (i1-i2)/2;
3194 const AliTPCRow& kr0=fSectors[sec][row0];
3197 AliTPCpolyTrack polytrack;
3198 Int_t nclusters=fSectors[sec][row0];
3199 AliTPCseed * seed = new AliTPCseed;
3204 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3206 Int_t nfoundable =0;
3207 for (Int_t iter =1; iter<2; iter++){ //iterations
3208 const AliTPCRow& krm=fSectors[sec][row0-iter];
3209 const AliTPCRow& krp=fSectors[sec][row0+iter];
3210 const AliTPCclusterMI * cl= kr0[is];
3212 if (cl->IsUsed(10)) {
3218 Double_t x = kr0.GetX();
3219 // Initialization of the polytrack
3224 Double_t y0= cl->GetY();
3225 Double_t z0= cl->GetZ();
3229 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3230 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3232 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3233 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3234 polytrack.AddPoint(x,y0,z0,erry, errz);
3237 if (cl->IsUsed(10)) sumused++;
3240 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3241 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3244 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3245 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3246 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3247 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3248 if (cl1->IsUsed(10)) sumused++;
3249 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3253 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3255 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3256 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3257 if (cl2->IsUsed(10)) sumused++;
3258 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3261 if (sumused>0) continue;
3263 polytrack.UpdateParameters();
3269 nfoundable = polytrack.GetN();
3270 nfound = nfoundable;
3272 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3273 Float_t maxdist = 0.8*(1.+3./(ddrow));
3274 for (Int_t delta = -1;delta<=1;delta+=2){
3275 Int_t row = row0+ddrow*delta;
3276 kr = &(fSectors[sec][row]);
3277 Double_t xn = kr->GetX();
3278 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3279 polytrack.GetFitPoint(xn,yn,zn);
3280 if (TMath::Abs(yn)>ymax) continue;
3282 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3284 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3287 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3288 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3289 if (cln->IsUsed(10)) {
3290 // printf("used\n");
3298 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3303 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3304 polytrack.UpdateParameters();
3307 if ( (sumused>3) || (sumused>0.5*nfound)) {
3308 //printf("sumused %d\n",sumused);
3313 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3314 AliTPCpolyTrack track2;
3316 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3317 if (track2.GetN()<0.5*nfoundable) continue;
3320 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3322 // test seed with and without constrain
3323 for (Int_t constrain=0; constrain<=0;constrain++){
3324 // add polytrack candidate
3326 Double_t x[5], c[15];
3327 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3328 track2.GetBoundaries(x3,x1);
3330 track2.GetFitPoint(x1,y1,z1);
3331 track2.GetFitPoint(x2,y2,z2);
3332 track2.GetFitPoint(x3,y3,z3);
3334 //is track pointing to the vertex ?
3337 polytrack.GetFitPoint(x0,y0,z0);
3350 x[4]=F1(x1,y1,x2,y2,x3,y3);
3352 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3353 x[2]=F2(x1,y1,x2,y2,x3,y3);
3355 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3356 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3357 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3358 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3361 Double_t sy =0.1, sz =0.1;
3362 Double_t sy1=0.02, sz1=0.02;
3363 Double_t sy2=0.02, sz2=0.02;
3367 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3370 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3371 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3372 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3373 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3374 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3375 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3377 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3378 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3379 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3380 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3385 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3386 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3387 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3388 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3389 c[13]=f30*sy1*f40+f32*sy2*f42;
3390 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3392 //Int_t row1 = fSectors->GetRowNumber(x1);
3393 Int_t row1 = GetRowNumber(x1);
3397 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3398 track->fIsSeeding = kTRUE;
3399 Int_t rc=FollowProlongation(*track, i2);
3400 if (constrain) track->fBConstrain =1;
3402 track->fBConstrain =0;
3403 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3404 track->fFirstPoint = track->fLastPoint;
3406 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3407 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3408 track->fNShared>0.4*track->GetNumberOfClusters()) {
3411 seed->~AliTPCseed();
3414 arr->AddLast(track);
3415 seed = new AliTPCseed;
3419 } // if accepted seed
3422 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3428 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3432 //reseed using track points
3433 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3434 Int_t p1 = int(r1*track->GetNumberOfClusters());
3435 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3437 Double_t x0[3],x1[3],x2[3];
3442 // find track position at given ratio of the length
3443 Int_t sec0, sec1, sec2;
3449 for (Int_t i=0;i<160;i++){
3450 if (track->fClusterPointer[i]){
3452 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3453 if ( (index<p0) || x0[0]<0 ){
3454 if (trpoint->GetX()>1){
3455 clindex = track->GetClusterIndex2(i);
3457 x0[0] = trpoint->GetX();
3458 x0[1] = trpoint->GetY();
3459 x0[2] = trpoint->GetZ();
3460 sec0 = ((clindex&0xff000000)>>24)%18;
3465 if ( (index<p1) &&(trpoint->GetX()>1)){
3466 clindex = track->GetClusterIndex2(i);
3468 x1[0] = trpoint->GetX();
3469 x1[1] = trpoint->GetY();
3470 x1[2] = trpoint->GetZ();
3471 sec1 = ((clindex&0xff000000)>>24)%18;
3474 if ( (index<p2) &&(trpoint->GetX()>1)){
3475 clindex = track->GetClusterIndex2(i);
3477 x2[0] = trpoint->GetX();
3478 x2[1] = trpoint->GetY();
3479 x2[2] = trpoint->GetZ();
3480 sec2 = ((clindex&0xff000000)>>24)%18;
3487 Double_t alpha, cs,sn, xx2,yy2;
3489 alpha = (sec1-sec2)*fSectors->GetAlpha();
3490 cs = TMath::Cos(alpha);
3491 sn = TMath::Sin(alpha);
3492 xx2= x1[0]*cs-x1[1]*sn;
3493 yy2= x1[0]*sn+x1[1]*cs;
3497 alpha = (sec0-sec2)*fSectors->GetAlpha();
3498 cs = TMath::Cos(alpha);
3499 sn = TMath::Sin(alpha);
3500 xx2= x0[0]*cs-x0[1]*sn;
3501 yy2= x0[0]*sn+x0[1]*cs;
3507 Double_t x[5],c[15];
3511 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3512 // if (x[4]>1) return 0;
3513 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3514 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3515 //if (TMath::Abs(x[3]) > 2.2) return 0;
3516 //if (TMath::Abs(x[2]) > 1.99) return 0;
3518 Double_t sy =0.1, sz =0.1;
3520 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3521 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3522 Double_t sy3=0.01+track->GetSigmaY2();
3524 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3525 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3526 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3527 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3528 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3529 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3531 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3532 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3533 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3534 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3539 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3540 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3541 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3542 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3543 c[13]=f30*sy1*f40+f32*sy2*f42;
3544 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3546 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3547 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3548 // Double_t y0,z0,y1,z1, y2,z2;
3549 //seed->GetProlongation(x0[0],y0,z0);
3550 // seed->GetProlongation(x1[0],y1,z1);
3551 //seed->GetProlongation(x2[0],y2,z2);
3553 seed->fLastPoint = pp2;
3554 seed->fFirstPoint = pp2;
3561 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3565 //reseed using founded clusters
3567 // Find the number of clusters
3568 Int_t nclusters = 0;
3569 for (Int_t irow=0;irow<160;irow++){
3570 if (track->GetClusterIndex(irow)>0) nclusters++;
3574 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3575 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3576 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3580 Int_t row[3],sec[3]={0,0,0};
3582 // find track row position at given ratio of the length
3584 for (Int_t irow=0;irow<160;irow++){
3585 if (track->GetClusterIndex2(irow)<0) continue;
3587 for (Int_t ipoint=0;ipoint<3;ipoint++){
3588 if (index<=ipos[ipoint]) row[ipoint] = irow;
3592 //Get cluster and sector position
3593 for (Int_t ipoint=0;ipoint<3;ipoint++){
3594 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3595 AliTPCclusterMI * cl = GetClusterMI(clindex);
3598 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3601 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3602 xyz[ipoint][0] = GetXrow(row[ipoint]);
3603 xyz[ipoint][1] = cl->GetY();
3604 xyz[ipoint][2] = cl->GetZ();
3608 // Calculate seed state vector and covariance matrix
3610 Double_t alpha, cs,sn, xx2,yy2;
3612 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3613 cs = TMath::Cos(alpha);
3614 sn = TMath::Sin(alpha);
3615 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3616 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3620 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3621 cs = TMath::Cos(alpha);
3622 sn = TMath::Sin(alpha);
3623 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3624 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3630 Double_t x[5],c[15];
3634 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3635 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3636 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3638 Double_t sy =0.1, sz =0.1;
3640 Double_t sy1=0.2, sz1=0.2;
3641 Double_t sy2=0.2, sz2=0.2;
3644 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;
3645 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;
3646 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;
3647 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;
3648 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;
3649 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;
3651 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;
3652 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;
3653 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;
3654 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;
3659 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3660 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3661 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3662 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3663 c[13]=f30*sy1*f40+f32*sy2*f42;
3664 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3666 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3667 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3668 seed->fLastPoint = row[2];
3669 seed->fFirstPoint = row[2];
3673 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3678 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3680 if (TMath::Abs(seed->GetC())>0.01) return 0;
3683 Float_t x[160], y[160], erry[160], z[160], errz[160];
3685 Float_t xt[160], yt[160], zt[160];
3690 Int_t middle = seed->GetNumberOfClusters()/2;
3693 // find central sector, get local cooordinates
3695 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3696 sec[i]= seed->GetClusterSector(i)%18;
3699 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3700 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3707 if (i>i2) i2 = i; //last point with cluster
3708 if (i2<i1) i1 = i; //first point with cluster
3711 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3713 yt[i] = point->GetY();
3714 zt[i] = point->GetZ();
3716 if (point->GetX()>0){
3717 erry[i] = point->GetErrY();
3718 errz[i] = point->GetErrZ();
3723 secm = sec[i]; //central sector
3724 padm = i; //middle point with cluster
3729 // rotate position to global coordinate system connected to sector at last the point
3731 for (Int_t i=i1;i<=i2;i++){
3733 if (sec[i]<0) continue;
3734 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3735 Double_t cs = TMath::Cos(alpha);
3736 Double_t sn = TMath::Sin(alpha);
3737 Float_t xx2= x[i]*cs+y[i]*sn;
3738 Float_t yy2= -x[i]*sn+y[i]*cs;
3742 xx2= xt[i]*cs+yt[i]*sn;
3743 yy2= -xt[i]*sn+yt[i]*cs;
3748 //get "state" vector
3749 Double_t xh[5],xm = x[padm];
3752 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3753 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3754 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3757 for (Int_t i=i1;i<=i2;i++){
3759 if (sec[i]<0) continue;
3760 GetProlongation(x[i2], x[i],xh,yy,zz);
3761 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3763 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3764 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3765 Error("AliTPCtrackerMI::CheckKinkPoint","problem\n");
3770 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3771 Float_t yup[160], ydown[160], zup[160], zdown[160];
3773 AliTPCpolyTrack ptrack1,ptrack2;
3776 for (Int_t i=i1;i<=i2;i++){
3777 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3779 if (cl->GetType()<0) continue;
3780 if (cl->GetType()>10) continue;
3783 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3785 if (ptrack1.GetN()>4.){
3786 ptrack1.UpdateParameters();
3788 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3790 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3799 dyup[i]=0.; //not enough points
3804 for (Int_t i=i2;i>=i1;i--){
3805 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3807 if (cl->GetType()<0) continue;
3808 if (cl->GetType()>10) continue;
3810 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3812 if (ptrack2.GetN()>4){
3813 ptrack2.UpdateParameters();
3815 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3817 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3825 dydown[i]=0.; //not enough points
3830 // find maximal difference of the derivation
3831 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3834 for (Int_t i=i1+10;i<i2-10;i++){
3835 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3836 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3838 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3839 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3840 if ( (ddy+ddz)> th){
3841 seed->fKinkPoint[0] = i;
3842 seed->fKinkPoint[1] = ddy;
3843 seed->fKinkPoint[2] = ddz;
3850 //write information to the debug tree
3851 TBranch * br = fTreeDebug->GetBranch("debug");
3852 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3853 arr->ExpandCreateFast(i2-i1);
3854 br->SetAddress(&arr);
3856 AliTPCclusterMI cldummy;
3858 AliTPCTrackPoint2 pdummy;
3859 pdummy.GetTPoint().fIsShared = 10;
3861 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3862 Double_t cs = TMath::Cos(alpha);
3863 Double_t sn = TMath::Sin(alpha);
3865 for (Int_t i=i1;i<i2;i++){
3866 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3868 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3870 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3873 Double_t x = GetXrow(i);
3874 trpoint->GetTPoint() = *point;
3875 trpoint->GetCPoint() = *cl0;
3876 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3877 trpoint->fID = seed->GetUniqueID();
3878 trpoint->fLab = seed->GetLabel();
3880 trpoint->fGX = cs *x + sn*point->GetY();
3881 trpoint->fGY = -sn *x + cs*point->GetY() ;
3882 trpoint->fGZ = point->GetZ();
3884 trpoint->fDY = y[i];
3885 trpoint->fDZ = z[i];
3887 trpoint->fDYU = dyup[i];
3888 trpoint->fDZU = dzup[i];
3890 trpoint->fDYD = dydown[i];
3891 trpoint->fDZD = dzdown[i];
3893 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3894 trpoint->fDDY = dydown[i]-dyup[i];
3895 trpoint->fDDZ = dzdown[i]-dzup[i];
3903 trpoint->GetCPoint()= cldummy;
3920 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3923 // reseed - refit - track
3926 // Int_t last = fSectors->GetNRows()-1;
3928 if (fSectors == fOuterSec){
3929 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3933 first = t->fFirstPoint;
3935 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3936 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3938 FollowProlongation(*t,first);
3948 //_____________________________________________________________________________
3949 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3950 //-----------------------------------------------------------------
3951 // This function reades track seeds.
3952 //-----------------------------------------------------------------
3953 TDirectory *savedir=gDirectory;
3955 TFile *in=(TFile*)inp;
3956 if (!in->IsOpen()) {
3957 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3962 TTree *seedTree=(TTree*)in->Get("Seeds");
3964 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3965 cerr<<"can't get a tree with track seeds !\n";
3968 AliTPCtrack *seed=new AliTPCtrack;
3969 seedTree->SetBranchAddress("tracks",&seed);
3971 if (fSeeds==0) fSeeds=new TObjArray(15000);
3973 Int_t n=(Int_t)seedTree->GetEntries();
3974 for (Int_t i=0; i<n; i++) {
3975 seedTree->GetEvent(i);
3976 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3985 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
3988 if (fSeeds) DeleteSeeds();
3991 if (!fSeeds) return 1;
3998 //_____________________________________________________________________________
3999 Int_t AliTPCtrackerMI::Clusters2Tracks() {
4000 //-----------------------------------------------------------------
4001 // This is a track finder.
4002 //-----------------------------------------------------------------
4003 TDirectory *savedir=gDirectory;
4007 fSeeds = Tracking();
4010 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
4012 //activate again some tracks
4013 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
4014 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4016 Int_t nc=t.GetNumberOfClusters();
4018 delete fSeeds->RemoveAt(i);
4021 if (pt->fRemoval==10) {
4022 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4023 pt->Desactivate(10); // make track again active
4025 pt->Desactivate(20);
4026 delete fSeeds->RemoveAt(i);
4030 RemoveDouble(fSeeds,0.2,0.6,11);
4031 RemoveUsed(fSeeds,0.5,0.5,6);
4034 Int_t nseed=fSeeds->GetEntriesFast();
4036 for (Int_t i=0; i<nseed; i++) {
4037 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4039 Int_t nc=t.GetNumberOfClusters();
4041 delete fSeeds->RemoveAt(i);
4044 CookLabel(pt,0.1); //For comparison only
4045 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4046 if ((pt->IsActive() || (pt->fRemoval==10) )){
4048 if (fDebug>0) cerr<<found<<'\r';
4052 delete fSeeds->RemoveAt(i);
4056 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
4058 //RemoveUsed(fSeeds,0.9,0.9,6);
4060 nseed=fSeeds->GetEntriesFast();
4062 for (Int_t i=0; i<nseed; i++) {
4063 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4065 Int_t nc=t.GetNumberOfClusters();
4067 delete fSeeds->RemoveAt(i);
4071 t.CookdEdx(0.02,0.6);
4072 // CheckKinkPoint(&t,0.05);
4073 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4074 if ((pt->IsActive() || (pt->fRemoval==10) )){
4082 delete fSeeds->RemoveAt(i);
4083 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
4085 // FollowProlongation(*seed1,0);
4086 // Int_t n = seed1->GetNumberOfClusters();
4087 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
4088 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
4091 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
4095 SortTracks(fSeeds, 1);
4099 PrepareForBackProlongation(fSeeds,5.);
4100 PropagateBack(fSeeds);
4101 printf("Time for back propagation: \t");timer.Print();timer.Start();
4105 PrepareForProlongation(fSeeds,5.);
4106 PropagateForward2(fSeeds);
4108 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
4109 // RemoveUsed(fSeeds,0.7,0.7,6);
4110 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
4112 nseed=fSeeds->GetEntriesFast();
4114 for (Int_t i=0; i<nseed; i++) {
4115 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4117 Int_t nc=t.GetNumberOfClusters();
4119 delete fSeeds->RemoveAt(i);
4122 t.CookdEdx(0.02,0.6);
4123 // CookLabel(pt,0.1); //For comparison only
4124 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4125 if ((pt->IsActive() || (pt->fRemoval==10) )){
4126 cerr<<found++<<'\r';
4129 delete fSeeds->RemoveAt(i);
4134 // fNTracks = found;
4136 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
4139 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
4140 Info("Clusters2Tracks","Number of found tracks %d",found);
4142 // UnloadClusters();
4147 void AliTPCtrackerMI::Tracking(TObjArray * arr)
4150 // tracking of the seeds
4153 fSectors = fOuterSec;
4154 ParallelTracking(arr,150,63);
4155 fSectors = fOuterSec;
4156 ParallelTracking(arr,63,0);
4159 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
4164 TObjArray * arr = new TObjArray;
4166 fSectors = fOuterSec;
4169 for (Int_t sec=0;sec<fkNOS;sec++){
4170 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
4171 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
4172 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
4175 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
4187 TObjArray * AliTPCtrackerMI::Tracking()
4193 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
4195 TObjArray * seeds = new TObjArray;
4204 Float_t fnumber = 3.0;
4205 Float_t fdensity = 3.0;
4210 for (Int_t delta = 0; delta<18; delta+=6){
4214 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
4215 SumTracks(seeds,arr);
4216 SignClusters(seeds,fnumber,fdensity);
4218 for (Int_t i=2;i<6;i+=2){
4219 // seed high pt tracks
4222 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
4223 SumTracks(seeds,arr);
4224 SignClusters(seeds,fnumber,fdensity);
4229 // RemoveUsed(seeds,0.9,0.9,1);
4230 // UnsignClusters();
4231 // SignClusters(seeds,fnumber,fdensity);
4235 for (Int_t delta = 20; delta<120; delta+=10){
4237 // seed high pt tracks
4241 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
4242 SumTracks(seeds,arr);
4243 SignClusters(seeds,fnumber,fdensity);
4248 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4249 SumTracks(seeds,arr);
4250 SignClusters(seeds,fnumber,fdensity);
4261 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4265 // RemoveUsed(seeds,0.75,0.75,1);
4267 //SignClusters(seeds,fnumber,fdensity);
4276 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4277 SumTracks(seeds,arr);
4278 SignClusters(seeds,fnumber,fdensity);
4280 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4281 SumTracks(seeds,arr);
4282 SignClusters(seeds,fnumber,fdensity);
4284 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4285 SumTracks(seeds,arr);
4286 SignClusters(seeds,fnumber,fdensity);
4290 for (Int_t delta = 3; delta<30; delta+=5){
4296 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4297 SumTracks(seeds,arr);
4298 SignClusters(seeds,fnumber,fdensity);
4300 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4301 SumTracks(seeds,arr);
4302 SignClusters(seeds,fnumber,fdensity);
4314 for (Int_t delta = 30; delta<70; delta+=10){
4320 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4321 SumTracks(seeds,arr);
4322 SignClusters(seeds,fnumber,fdensity);
4324 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4325 SumTracks(seeds,arr);
4326 SignClusters(seeds,fnumber,fdensity);
4330 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4341 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
4344 //sum tracks to common container
4345 //remove suspicious tracks
4346 Int_t nseed = arr2->GetEntriesFast();
4347 for (Int_t i=0;i<nseed;i++){
4348 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4351 // NORMAL ACTIVE TRACK
4352 if (pt->IsActive()){
4353 arr1->AddLast(arr2->RemoveAt(i));
4356 //remove not usable tracks
4357 if (pt->fRemoval!=10){
4358 delete arr2->RemoveAt(i);
4361 // REMOVE VERY SHORT TRACKS
4362 if (pt->GetNumberOfClusters()<20){
4363 delete arr2->RemoveAt(i);
4366 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4367 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4368 arr1->AddLast(arr2->RemoveAt(i));
4370 delete arr2->RemoveAt(i);
4379 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4382 // try to track in parralel
4384 Int_t nseed=arr->GetEntriesFast();
4385 //prepare seeds for tracking
4386 for (Int_t i=0; i<nseed; i++) {
4387 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4389 if (!t.IsActive()) continue;
4390 // follow prolongation to the first layer
4391 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4392 FollowProlongation(t, rfirst+1);
4397 for (Int_t nr=rfirst; nr>=rlast; nr--){
4398 if (nr<fInnerSec->GetNRows())
4399 fSectors = fInnerSec;
4401 fSectors = fOuterSec;
4402 // make indexes with the cluster tracks for given
4404 // find nearest cluster
4405 for (Int_t i=0; i<nseed; i++) {
4406 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4408 if (!pt->IsActive()) continue;
4409 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4410 if (pt->fRelativeSector>17) {
4413 UpdateClusters(t,nr);
4415 // prolonagate to the nearest cluster - if founded
4416 for (Int_t i=0; i<nseed; i++) {
4417 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4419 if (!pt->IsActive()) continue;
4420 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4421 if (pt->fRelativeSector>17) {
4424 FollowToNextCluster(*pt,nr);
4429 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
4433 // if we use TPC track itself we have to "update" covariance
4435 Int_t nseed= arr->GetEntriesFast();
4436 for (Int_t i=0;i<nseed;i++){
4437 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4441 //rotate to current local system at first accepted point
4442 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4443 Int_t sec = (index&0xff000000)>>24;
4445 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4446 if (angle1>TMath::Pi())
4447 angle1-=2.*TMath::Pi();
4448 Float_t angle2 = pt->GetAlpha();
4450 if (TMath::Abs(angle1-angle2)>0.001){
4451 pt->Rotate(angle1-angle2);
4452 //angle2 = pt->GetAlpha();
4453 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4454 //if (pt->GetAlpha()<0)
4455 // pt->fRelativeSector+=18;
4456 //sec = pt->fRelativeSector;
4465 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
4469 // if we use TPC track itself we have to "update" covariance
4471 Int_t nseed= arr->GetEntriesFast();
4472 for (Int_t i=0;i<nseed;i++){
4473 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4476 pt->fFirstPoint = pt->fLastPoint;
4484 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4487 // make back propagation
4489 Int_t nseed= arr->GetEntriesFast();
4490 for (Int_t i=0;i<nseed;i++){
4491 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4493 //AliTPCseed *pt2 = new AliTPCseed(*pt);
4494 fSectors = fInnerSec;
4495 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
4496 //fSectors = fOuterSec;
4497 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4498 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
4499 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
4500 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4508 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4511 // make forward propagation
4513 Int_t nseed= arr->GetEntriesFast();
4515 for (Int_t i=0;i<nseed;i++){
4516 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4518 FollowProlongation(*pt,0);
4525 Int_t AliTPCtrackerMI::PropagateForward()
4528 // propagate track forward
4530 Int_t nseed = fSeeds->GetEntriesFast();
4531 for (Int_t i=0;i<nseed;i++){
4532 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
4534 AliTPCseed &t = *pt;
4535 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
4536 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
4537 if (alpha < 0. ) alpha += 2.*TMath::Pi();
4538 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
4542 fSectors = fOuterSec;
4543 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
4544 fSectors = fInnerSec;
4545 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
4555 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4558 // make back propagation, in between row0 and row1
4562 fSectors = fInnerSec;
4565 if (row1<fSectors->GetNRows())
4568 r1 = fSectors->GetNRows()-1;
4570 if (row0<fSectors->GetNRows()&& r1>0 )
4571 FollowBackProlongation(*pt,r1);
4572 if (row1<=fSectors->GetNRows())
4575 r1 = row1 - fSectors->GetNRows();
4576 if (r1<=0) return 0;
4577 if (r1>=fOuterSec->GetNRows()) return 0;
4578 fSectors = fOuterSec;
4579 return FollowBackProlongation(*pt,r1);
4587 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4591 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4592 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4593 Float_t padlength = GetPadPitchLength(row);
4595 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4596 Float_t angulary = seed->GetSnp();
4597 angulary = angulary*angulary/(1-angulary*angulary);
4598 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4600 Float_t sresz = fParam->GetZSigma();
4601 Float_t angularz = seed->GetTgl();
4602 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4604 Float_t wy = GetSigmaY(seed);
4605 Float_t wz = GetSigmaZ(seed);
4608 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4609 printf("problem\n");
4615 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4619 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4620 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4621 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4622 Float_t angular = seed->GetSnp();
4623 angular = angular*angular/(1-angular*angular);
4624 // angular*=angular;
4625 //angular = TMath::Sqrt(angular/(1-angular));
4626 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4629 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4633 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4634 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4635 Float_t sres = fParam->GetZSigma();
4636 Float_t angular = seed->GetTgl();
4637 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4644 //__________________________________________________________________________
4645 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4646 //--------------------------------------------------------------------
4647 //This function "cooks" a track label. If label<0, this track is fake.
4648 //--------------------------------------------------------------------
4649 Int_t noc=t->GetNumberOfClusters();
4651 //printf("\nnot founded prolongation\n\n\n");
4657 AliTPCclusterMI *clusters[160];
4659 for (Int_t i=0;i<160;i++) {
4666 for (i=0; i<160 && current<noc; i++) {
4668 Int_t index=t->GetClusterIndex2(i);
4669 if (index<=0) continue;
4670 if (index&0x8000) continue;
4672 //clusters[current]=GetClusterMI(index);
4673 if (t->fClusterPointer[i]){
4674 clusters[current]=t->fClusterPointer[i];
4680 Int_t lab=123456789;
4681 for (i=0; i<noc; i++) {
4682 AliTPCclusterMI *c=clusters[i];
4684 lab=TMath::Abs(c->GetLabel(0));
4686 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4692 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4694 for (i=0; i<noc; i++) {
4695 AliTPCclusterMI *c=clusters[i];
4697 if (TMath::Abs(c->GetLabel(1)) == lab ||
4698 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4701 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4704 Int_t tail=Int_t(0.10*noc);
4707 for (i=1; i<=160&&ind<tail; i++) {
4708 // AliTPCclusterMI *c=clusters[noc-i];
4709 AliTPCclusterMI *c=clusters[i];
4711 if (lab == TMath::Abs(c->GetLabel(0)) ||
4712 lab == TMath::Abs(c->GetLabel(1)) ||
4713 lab == TMath::Abs(c->GetLabel(2))) max++;
4716 if (max < Int_t(0.5*tail)) lab=-lab;
4723 //delete[] clusters;
4727 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
4729 //return pad row number for this x
4732 r=fRow[fN-1].GetX();
4733 if (x > r) return fN;
4735 if (x < r) return -1;
4736 return Int_t((x-r)/fPadPitchLength + 0.5);}
4738 r=fRow[fN-1].GetX();
4739 if (x > r) return fN;
4741 if (x < r) return -1;
4742 Double_t r1=fRow[64].GetX();
4744 return Int_t((x-r)/f1PadPitchLength + 0.5);}
4746 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
4750 //_________________________________________________________________________
4751 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4752 //-----------------------------------------------------------------------
4753 // Setup inner sector
4754 //-----------------------------------------------------------------------
4756 fAlpha=par->GetInnerAngle();
4757 fAlphaShift=par->GetInnerAngleShift();
4758 fPadPitchWidth=par->GetInnerPadPitchWidth();
4759 fPadPitchLength=par->GetInnerPadPitchLength();
4760 fN=par->GetNRowLow();
4761 fRow=new AliTPCRow[fN];
4762 for (Int_t i=0; i<fN; i++) {
4763 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4764 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4767 fAlpha=par->GetOuterAngle();
4768 fAlphaShift=par->GetOuterAngleShift();
4769 fPadPitchWidth = par->GetOuterPadPitchWidth();
4770 fPadPitchLength = par->GetOuter1PadPitchLength();
4771 f1PadPitchLength = par->GetOuter1PadPitchLength();
4772 f2PadPitchLength = par->GetOuter2PadPitchLength();
4774 fN=par->GetNRowUp();
4775 fRow=new AliTPCRow[fN];
4776 for (Int_t i=0; i<fN; i++) {
4777 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4778 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4783 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
4785 // default constructor
4793 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4800 //_________________________________________________________________________
4802 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4803 //-----------------------------------------------------------------------
4804 // Insert a cluster into this pad row in accordence with its y-coordinate
4805 //-----------------------------------------------------------------------
4806 if (fN==kMaxClusterPerRow) {
4807 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4809 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4810 Int_t i=Find(c->GetZ());
4811 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4812 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4813 fIndex[i]=index; fClusters[i]=c; fN++;
4816 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
4822 //delete[] fClusterArray;
4823 if (fClusters1) delete []fClusters1;
4824 if (fClusters2) delete []fClusters2;
4831 //___________________________________________________________________
4832 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4833 //-----------------------------------------------------------------------
4834 // Return the index of the nearest cluster
4835 //-----------------------------------------------------------------------
4836 if (fN==0) return 0;
4837 if (z <= fClusters[0]->GetZ()) return 0;
4838 if (z > fClusters[fN-1]->GetZ()) return fN;
4839 Int_t b=0, e=fN-1, m=(b+e)/2;
4840 for (; b<e; m=(b+e)/2) {
4841 if (z > fClusters[m]->GetZ()) b=m+1;
4849 //___________________________________________________________________
4850 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4851 //-----------------------------------------------------------------------
4852 // Return the index of the nearest cluster in z y
4853 //-----------------------------------------------------------------------
4854 Float_t maxdistance = roady*roady + roadz*roadz;
4856 AliTPCclusterMI *cl =0;
4857 for (Int_t i=Find(z-roadz); i<fN; i++) {
4858 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4859 if (c->GetZ() > z+roadz) break;
4860 if ( (c->GetY()-y) > roady ) continue;
4861 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4862 if (maxdistance>distance) {
4863 maxdistance = distance;
4870 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4872 //-----------------------------------------------------------------------
4873 // Return the index of the nearest cluster in z y
4874 //-----------------------------------------------------------------------
4875 Float_t maxdistance = roady*roady + roadz*roadz;
4876 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4877 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4879 AliTPCclusterMI *cl =0;
4880 //FindNearest3(y,z,roady,roadz,index);
4881 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4882 for (Int_t i=iz1; i<iz2; i++) {
4883 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4884 if (c->GetZ() > z+roadz) break;
4885 if ( c->GetY()-y > roady ) continue;
4886 if ( y-c->GetY() > roady ) continue;
4887 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4888 if (maxdistance>distance) {
4889 maxdistance = distance;
4892 //roady = TMath::Sqrt(maxdistance);
4900 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4902 //-----------------------------------------------------------------------
4903 // Return the index of the nearest cluster in z y
4904 //-----------------------------------------------------------------------
4905 Float_t maxdistance = roady*roady + roadz*roadz;
4906 // Int_t iz = Int_t(z+255.);
4907 AliTPCclusterMI *cl =0;
4908 for (Int_t i=Find(z-roadz); i<fN; i++) {
4909 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4910 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4911 if (c->GetZ() > z+roadz) break;
4912 if ( c->GetY()-y > roady ) continue;
4913 if ( y-c->GetY() > roady ) continue;
4914 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4915 if (maxdistance>distance) {
4916 maxdistance = distance;
4919 //roady = TMath::Sqrt(maxdistance);
4928 AliTPCseed::AliTPCseed():AliTPCtrack(){
4932 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4933 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4951 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4960 for (Int_t i=0;i<160;i++) {
4961 fClusterPointer[i] = 0;
4962 Int_t index = t.GetClusterIndex(i);
4964 SetClusterIndex2(i,index);
4967 SetClusterIndex2(i,-3);
4980 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4984 for (Int_t i=0;i<160;i++) {
4985 fClusterPointer[i] = 0;
4986 Int_t index = t.GetClusterIndex(i);
4987 SetClusterIndex2(i,index);
5008 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
5009 Double_t xr, Double_t alpha):
5010 AliTPCtrack(index, xx, cc, xr, alpha) {
5015 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
5016 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
5025 // fHelixIn = new TClonesArray("AliHelix",0);
5026 //fHelixOut = new TClonesArray("AliHelix",0);
5036 AliTPCseed::~AliTPCseed(){
5039 if (fPoints) delete fPoints;
5041 if (fEPoints) delete fEPoints;
5046 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
5050 return &fTrackPoints[i];
5053 void AliTPCseed::RebuildSeed()
5056 // rebuild seed to be ready for storing
5057 AliTPCclusterMI cldummy;
5059 AliTPCTrackPoint pdummy;
5060 pdummy.GetTPoint().fIsShared = 10;
5061 for (Int_t i=0;i<160;i++){
5062 AliTPCclusterMI * cl0 = fClusterPointer[i];
5063 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
5065 trpoint->GetTPoint() = *(GetTrackPoint(i));
5066 trpoint->GetCPoint() = *cl0;
5067 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
5071 trpoint->GetCPoint()= cldummy;
5079 Double_t AliTPCseed::GetDensityFirst(Int_t n)
5083 // return cluster for n rows bellow first point
5084 Int_t nfoundable = 1;
5086 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
5087 Int_t index = GetClusterIndex2(i);
5088 if (index!=-1) nfoundable++;
5089 if (index>0) nfound++;
5091 if (nfoundable<n) return 0;
5092 return Double_t(nfound)/Double_t(nfoundable);
5097 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
5099 // get cluster stat. on given region
5104 for (Int_t i=first;i<last; i++){
5105 Int_t index = GetClusterIndex2(i);
5106 if (index!=-1) foundable++;
5107 if (fClusterPointer[i]) {
5113 if (fClusterPointer[i]->IsUsed(10)) {
5117 if (!plus2) continue; //take also neighborhoud
5119 if ( (i>0) && fClusterPointer[i-1]){
5120 if (fClusterPointer[i-1]->IsUsed(10)) {
5125 if ( fClusterPointer[i+1]){
5126 if (fClusterPointer[i+1]->IsUsed(10)) {
5133 //if (shared>found){
5134 //Error("AliTPCseed::GetClusterStatistic","problem\n");
5138 //_____________________________________________________________________________
5139 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
5140 //-----------------------------------------------------------------
5141 // This funtion calculates dE/dX within the "low" and "up" cuts.
5142 //-----------------------------------------------------------------
5145 Float_t angular[200];
5146 Float_t weight[200];
5149 // TClonesArray & arr = *fPoints;
5150 Float_t meanlog = 100.;
5152 Float_t mean[4] = {0,0,0,0};
5153 Float_t sigma[4] = {1000,1000,1000,1000};
5154 Int_t nc[4] = {0,0,0,0};
5155 Float_t norm[4] = {1000,1000,1000,1000};
5160 for (Int_t of =0; of<4; of++){
5161 for (Int_t i=of+i1;i<i2;i+=4)
5163 Int_t index = fIndex[i];
5164 if (index<0||index&0x8000) continue;
5166 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
5167 AliTPCTrackerPoint * point = GetTrackPoint(i);
5168 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
5169 //AliTPCTrackerPoint * pointp = 0;
5170 //if (i<159) pointp = GetTrackPoint(i+1);
5172 if (point==0) continue;
5173 AliTPCclusterMI * cl = fClusterPointer[i];
5174 if (cl==0) continue;
5175 if (onlyused && (!cl->IsUsed(10))) continue;
5176 if (cl->IsUsed(11)) {
5180 Int_t type = cl->GetType();
5181 //if (point->fIsShared){
5186 // if (pointm->fIsShared) continue;
5188 // if (pointp->fIsShared) continue;
5190 if (type<0) continue;
5191 //if (type>10) continue;
5192 //if (point->GetErrY()==0) continue;
5193 //if (point->GetErrZ()==0) continue;
5195 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
5196 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
5197 //if ((ddy*ddy+ddz*ddz)>10) continue;
5200 // if (point->GetCPoint().GetMax()<5) continue;
5201 if (cl->GetMax()<5) continue;
5202 Float_t angley = point->GetAngleY();
5203 Float_t anglez = point->GetAngleZ();
5205 Float_t rsigmay2 = point->GetSigmaY();
5206 Float_t rsigmaz2 = point->GetSigmaZ();
5210 rsigmay += pointm->GetTPoint().GetSigmaY();
5211 rsigmaz += pointm->GetTPoint().GetSigmaZ();
5215 rsigmay += pointp->GetTPoint().GetSigmaY();
5216 rsigmaz += pointp->GetTPoint().GetSigmaZ();
5223 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
5225 Float_t ampc = 0; // normalization to the number of electrons
5227 // ampc = 1.*point->GetCPoint().GetMax();
5228 ampc = 1.*cl->GetMax();
5229 //ampc = 1.*point->GetCPoint().GetQ();
5230 // AliTPCClusterPoint & p = point->GetCPoint();
5231 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
5232 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5234 // TMath::Abs( Int_t(iz) - iz + 0.5);
5235 //ampc *= 1.15*(1-0.3*dy);
5236 //ampc *= 1.15*(1-0.3*dz);
5237 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
5241 //ampc = 1.0*point->GetCPoint().GetMax();
5242 ampc = 1.0*cl->GetMax();
5243 //ampc = 1.0*point->GetCPoint().GetQ();
5244 //AliTPCClusterPoint & p = point->GetCPoint();
5245 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
5246 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5248 // TMath::Abs( Int_t(iz) - iz + 0.5);
5250 //ampc *= 1.15*(1-0.3*dy);
5251 //ampc *= 1.15*(1-0.3*dz);
5252 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
5256 ampc *= 2.0; // put mean value to channel 50
5257 //ampc *= 0.58; // put mean value to channel 50
5259 // if (type>0) w = 1./(type/2.-0.5);
5260 // Float_t z = TMath::Abs(cl->GetZ());
5263 //ampc /= (1+0.0008*z);
5267 //ampc /= (1+0.0008*z);
5269 //ampc /= (1+0.0008*z);
5272 if (type<0) { //amp at the border - lower weight
5277 if (rsigma>1.5) ampc/=1.3; // if big backround
5279 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5284 TMath::Sort(nc[of],amp,index,kFALSE);
5288 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
5290 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5291 Float_t ampl = amp[index[i]]/angular[index[i]];
5292 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5294 sumw += weight[index[i]];
5295 sumamp += weight[index[i]]*ampl;
5296 sumamp2 += weight[index[i]]*ampl*ampl;
5297 norm[of] += angular[index[i]]*weight[index[i]];
5304 mean[of] = sumamp/sumw;
5305 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5307 sigma[of] = TMath::Sqrt(sigma[of]);
5311 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5312 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5313 //mean *=(1-0.1*(norm-1.));
5320 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
5321 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
5324 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
5325 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
5329 for (Int_t i =0;i<4;i++){
5330 if (nc[i]>2&&nc[i]<1000){
5331 dedx += mean[i] *nc[i];
5332 fSdEdx += sigma[i]*(nc[i]-2);
5333 fMAngular += norm[i] *nc[i];
5338 fSDEDX[i] = sigma[i];
5351 // Float_t dedx1 =dedx;
5354 for (Int_t i =0;i<4;i++){
5355 if (nc[i]>2&&nc[i]<1000){
5356 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5357 dedx += mean[i] *nc[i];
5372 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5375 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5376 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5377 SetMass(0.93827); return;
5381 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5382 SetMass(0.93827); return;
5385 SetMass(0.13957); return;
5395 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5396 //-----------------------------------------------------------------
5397 // This funtion calculates dE/dX within the "low" and "up" cuts.
5398 //-----------------------------------------------------------------
5401 Float_t angular[200];
5402 Float_t weight[200];
5404 Bool_t inlimit[200];
5405 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5406 for (Int_t i=0;i<200;i++) amp[i]=10000;
5407 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5411 Float_t meanlog = 100.;
5412 Int_t indexde[4]={0,64,128,160};
5419 Float_t mean[4] = {0,0,0,0};
5420 Float_t sigma[4] = {1000,1000,1000,1000};
5421 Int_t nc[4] = {0,0,0,0};
5422 Float_t norm[4] = {1000,1000,1000,1000};
5427 // for (Int_t of =0; of<3; of++){
5428 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5429 for (Int_t i =0; i<160;i++)
5431 AliTPCTrackPoint * point = GetTrackPoint(i);
5432 if (point==0) continue;
5433 if (point->fIsShared){
5437 Int_t type = point->GetCPoint().GetType();
5438 if (type<0) continue;
5439 if (point->GetCPoint().GetMax()<5) continue;
5440 Float_t angley = point->GetTPoint().GetAngleY();
5441 Float_t anglez = point->GetTPoint().GetAngleZ();
5442 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5443 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5444 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5446 Float_t ampc = 0; // normalization to the number of electrons
5448 ampc = point->GetCPoint().GetMax();
5451 ampc = point->GetCPoint().GetMax();
5453 ampc *= 2.0; // put mean value to channel 50
5454 // ampc *= 0.565; // put mean value to channel 50
5457 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5464 if (type<0) { //amp at the border - lower weight
5467 if (rsigma>1.5) ampc/=1.3; // if big backround
5468 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5469 amp[i] = ampc/angular[i];
5474 TMath::Sort(159,amp,index,kFALSE);
5475 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5476 inlimit[index[i]] = kTRUE; // take all clusters
5479 // meanlog = amp[index[Int_t(anc*0.3)]];
5481 for (Int_t of =0; of<3; of++){
5485 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5487 if (inlimit[i]==kFALSE) continue;
5488 Float_t ampl = amp[i];
5490 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5493 sumamp += weight[i]*ampl;
5494 sumamp2 += weight[i]*ampl*ampl;
5495 norm[of] += angular[i]*weight[i];
5503 mean[of] = sumamp/sumw;
5504 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5506 sigma[of] = TMath::Sqrt(sigma[of]);
5509 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5519 Float_t www[3] = {12.,14.,17.};
5520 //Float_t www[3] = {1.,1.,1.};
5522 for (Int_t i =0;i<3;i++){
5523 if (nc[i]>2&&nc[i]<1000){
5524 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5525 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5526 fMAngular += norm[i] *nc[i];
5527 norm2 += nc[i]*www[i]/sigma[i];
5528 norm3 += (nc[i]-2)*www[i]/sigma[i];
5531 fSDEDX[i] = sigma[i];
5544 // Float_t dedx1 =dedx;
5548 for (Int_t i =0;i<3;i++){
5549 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5550 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5551 dedx += mean[i] *(nc[i])/(sigma[i]);
5552 norm4 += (nc[i])/(sigma[i]);
5556 if (norm4>0) dedx /= norm4;