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 //-------------------------------------------------------
34 #include <TObjArray.h>
37 #include <TClonesArray.h>
39 #include "Riostream.h"
41 #include "AliTPCclusterMI.h"
42 #include "AliComplexCluster.h"
43 #include "AliTPCParam.h"
44 #include "AliTPCClustersRow.h"
45 #include "AliTPCpolyTrack.h"
46 #include "TStopwatch.h"
50 #include "AliRunLoader.h"
52 #include "AliTPCreco.h"
53 #include "AliTPCtrackerMI.h"
58 ClassImp(AliTPCtrackerMI)
61 class AliTPCFastMath {
64 static Double_t FastAsin(Double_t x);
66 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
69 Double_t AliTPCFastMath::fgFastAsin[20000];
70 AliTPCFastMath gAliTPCFastMath;
72 AliTPCFastMath::AliTPCFastMath(){
74 // initialized lookup table;
75 for (Int_t i=0;i<10000;i++){
76 fgFastAsin[2*i] = TMath::ASin(i/10000.);
77 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
81 Double_t AliTPCFastMath::FastAsin(Double_t x){
83 // return asin using lookup table
85 Int_t index = int(x*10000);
86 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
89 Int_t index = int(x*10000);
90 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
96 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
98 //update track information using current cluster - track->fCurrentCluster
101 AliTPCclusterMI* c =track->fCurrentCluster;
102 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
104 UInt_t i = track->fCurrentClusterIndex1;
106 Int_t sec=(i&0xff000000)>>24;
107 //Int_t row = (i&0x00ff0000)>>16;
108 track->fRow=(i&0x00ff0000)>>16;
109 track->fSector = sec;
110 // Int_t index = i&0xFFFF;
111 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
112 track->SetClusterIndex2(track->fRow, i);
113 //track->fFirstPoint = row;
114 //if ( track->fLastPoint<row) track->fLastPoint =row;
115 // if (track->fRow<0 || track->fRow>160) {
116 // printf("problem\n");
118 if (track->fFirstPoint>track->fRow)
119 track->fFirstPoint = track->fRow;
120 if (track->fLastPoint<track->fRow)
121 track->fLastPoint = track->fRow;
124 track->fClusterPointer[track->fRow] = c;
127 Float_t angle2 = track->GetSnp()*track->GetSnp();
128 angle2 = TMath::Sqrt(angle2/(1-angle2));
130 //SET NEW Track Point
134 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
136 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
137 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
138 point.SetErrY(sqrt(track->fErrorY2));
139 point.SetErrZ(sqrt(track->fErrorZ2));
141 point.SetX(track->GetX());
142 point.SetY(track->GetY());
143 point.SetZ(track->GetZ());
144 point.SetAngleY(angle2);
145 point.SetAngleZ(track->GetTgl());
146 if (point.fIsShared){
147 track->fErrorY2 *= 4;
148 track->fErrorZ2 *= 4;
152 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
154 track->fErrorY2 *= 1.3;
155 track->fErrorY2 += 0.01;
156 track->fErrorZ2 *= 1.3;
157 track->fErrorZ2 += 0.005;
159 if (accept>0) return 0;
160 if (track->GetNumberOfClusters()%20==0){
161 // if (track->fHelixIn){
162 // TClonesArray & larr = *(track->fHelixIn);
163 // Int_t ihelix = larr.GetEntriesFast();
164 // new(larr[ihelix]) AliHelix(*track) ;
167 track->fNoCluster =0;
168 return track->Update(c,chi2,i);
173 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
174 Float_t cory, Float_t corz)
177 // decide according desired precision to accept given
178 // cluster for tracking
179 Double_t sy2=ErrY2(seed,cluster)*cory;
180 Double_t sz2=ErrZ2(seed,cluster)*corz;
181 //sy2=ErrY2(seed,cluster)*cory;
182 //sz2=ErrZ2(seed,cluster)*cory;
184 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
185 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
187 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
188 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
189 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
190 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
192 Double_t rdistance2 = rdistancey2+rdistancez2;
195 if (rdistance2>16) return 3;
198 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
199 return 2; //suspisiouce - will be changed
201 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
202 // strict cut on overlaped cluster
203 return 2; //suspisiouce - will be changed
205 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
206 && cluster->GetType()<0){
216 //_____________________________________________________________________________
217 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
218 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
220 //---------------------------------------------------------------------
221 // The main TPC tracker constructor
222 //---------------------------------------------------------------------
223 fInnerSec=new AliTPCSector[fkNIS];
224 fOuterSec=new AliTPCSector[fkNOS];
227 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
228 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
235 Int_t nrowlow = par->GetNRowLow();
236 Int_t nrowup = par->GetNRowUp();
239 for (Int_t i=0;i<nrowlow;i++){
240 fXRow[i] = par->GetPadRowRadiiLow(i);
241 fPadLength[i]= par->GetPadPitchLength(0,i);
242 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
246 for (Int_t i=0;i<nrowup;i++){
247 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
248 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
249 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
262 //_____________________________________________________________________________
263 AliTPCtrackerMI::~AliTPCtrackerMI() {
264 //------------------------------------------------------------------
265 // TPC tracker destructor
266 //------------------------------------------------------------------
275 void AliTPCtrackerMI::SetIO()
279 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
281 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
283 AliTPCtrack *iotrack= new AliTPCtrack;
284 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
290 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
306 AliTPCtrack *iotrack= new AliTPCtrack;
307 // iotrack->fHelixIn = new TClonesArray("AliHelix");
308 //iotrack->fHelixOut = new TClonesArray("AliHelix");
309 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
312 if (output && (fDebug&2)){
313 //write the full seed information if specified in debug mode
315 fSeedTree = new TTree("Seeds","Seeds");
316 AliTPCseed * vseed = new AliTPCseed;
318 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
319 arrtr->ExpandCreateFast(160);
320 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
322 vseed->fPoints = arrtr;
323 vseed->fEPoints = arre;
324 // vseed->fClusterPoints = arrcl;
325 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
328 fTreeDebug = new TTree("trackDebug","trackDebug");
329 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
330 fTreeDebug->Branch("debug",&arrd,32000,99);
338 void AliTPCtrackerMI::FillESD(TObjArray* arr)
342 //fill esds using updated tracks
344 // write tracks to the event
345 // store index of the track
346 Int_t nseed=arr->GetEntriesFast();
347 for (Int_t i=0; i<nseed; i++) {
348 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
350 pt->PropagateTo(fParam->GetInnerRadiusLow());
351 if (pt->GetNumberOfClusters()>70) {
353 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
354 //iotrack.SetTPCindex(i);
355 fEvent->AddTrack(&iotrack);
361 void AliTPCtrackerMI::WriteTracks(TTree * tree)
364 // write tracks from seed array to selected tree
368 AliTPCtrack *iotrack= new AliTPCtrack;
369 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
374 void AliTPCtrackerMI::WriteTracks()
377 // write tracks to the given output tree -
378 // output specified with SetIO routine
385 AliTPCtrack *iotrack= 0;
386 Int_t nseed=fSeeds->GetEntriesFast();
387 //for (Int_t i=0; i<nseed; i++) {
388 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
389 // if (iotrack) break;
391 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
392 TBranch * br = fOutput->GetBranch("tracks");
393 br->SetAddress(&iotrack);
395 for (Int_t i=0; i<nseed; i++) {
396 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
398 AliTPCtrack * track = new AliTPCtrack(*pt);
401 // br->SetAddress(&iotrack);
406 //fOutput->GetDirectory()->cd();
412 //write the full seed information if specified in debug mode
414 AliTPCseed * vseed = new AliTPCseed;
416 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
417 arrtr->ExpandCreateFast(160);
418 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
419 //arrcl->ExpandCreateFast(160);
420 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
422 vseed->fPoints = arrtr;
423 vseed->fEPoints = arre;
424 // vseed->fClusterPoints = arrcl;
425 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
426 TBranch * brseed = fSeedTree->GetBranch("seeds");
428 Int_t nseed=fSeeds->GetEntriesFast();
430 for (Int_t i=0; i<nseed; i++) {
431 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
434 // pt->fClusterPoints = arrcl;
438 brseed->SetAddress(&vseed);
442 // pt->fClusterPoints = 0;
445 if (fTreeDebug) fTreeDebug->Write();
453 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
456 //seed->SetErrorY2(0.1);
458 //calculate look-up table at the beginning
459 static Bool_t ginit = kFALSE;
460 static Float_t gnoise1,gnoise2,gnoise3;
461 static Float_t ggg1[10000];
462 static Float_t ggg2[10000];
463 static Float_t ggg3[10000];
464 static Float_t glandau1[10000];
465 static Float_t glandau2[10000];
466 static Float_t glandau3[10000];
468 static Float_t gcor01[500];
469 static Float_t gcor02[500];
470 static Float_t gcorp[500];
475 for (Int_t i=1;i<500;i++){
476 Float_t rsigma = float(i)/100.;
477 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
478 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
479 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
483 for (Int_t i=3;i<10000;i++){
487 Float_t amp = float(i);
488 Float_t padlength =0.75;
489 gnoise1 = 0.0004/padlength;
490 Float_t nel = 0.268*amp;
491 Float_t nprim = 0.155*amp;
492 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
493 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
494 if (glandau1[i]>1) glandau1[i]=1;
495 glandau1[i]*=padlength*padlength/12.;
499 gnoise2 = 0.0004/padlength;
502 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
503 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
504 if (glandau2[i]>1) glandau2[i]=1;
505 glandau2[i]*=padlength*padlength/12.;
510 gnoise3 = 0.0004/padlength;
513 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
514 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
515 if (glandau3[i]>1) glandau3[i]=1;
516 glandau3[i]*=padlength*padlength/12.;
524 Int_t amp = int(TMath::Abs(cl->GetQ()));
526 seed->SetErrorY2(1.);
530 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
531 Int_t ctype = cl->GetType();
532 Float_t padlength= GetPadPitchLength(seed->fRow);
533 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
534 angle2 = angle2/(1-angle2);
537 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
540 if (fSectors==fInnerSec){
542 res = ggg1[amp]*z+glandau1[amp]*angle2;
543 if (ctype==0) res *= gcor01[rsigmay];
546 res*= gcorp[rsigmay];
552 res = ggg2[amp]*z+glandau2[amp]*angle2;
553 if (ctype==0) res *= gcor02[rsigmay];
556 res*= gcorp[rsigmay];
561 res = ggg3[amp]*z+glandau3[amp]*angle2;
562 if (ctype==0) res *= gcor02[rsigmay];
565 res*= gcorp[rsigmay];
572 res*=2.4; // overestimate error 2 times
579 seed->SetErrorY2(res);
587 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
590 //seed->SetErrorY2(0.1);
592 //calculate look-up table at the beginning
593 static Bool_t ginit = kFALSE;
594 static Float_t gnoise1,gnoise2,gnoise3;
595 static Float_t ggg1[10000];
596 static Float_t ggg2[10000];
597 static Float_t ggg3[10000];
598 static Float_t glandau1[10000];
599 static Float_t glandau2[10000];
600 static Float_t glandau3[10000];
602 static Float_t gcor01[1000];
603 static Float_t gcor02[1000];
604 static Float_t gcorp[1000];
609 for (Int_t i=1;i<1000;i++){
610 Float_t rsigma = float(i)/100.;
611 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
612 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
613 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
617 for (Int_t i=3;i<10000;i++){
621 Float_t amp = float(i);
622 Float_t padlength =0.75;
623 gnoise1 = 0.0004/padlength;
624 Float_t nel = 0.268*amp;
625 Float_t nprim = 0.155*amp;
626 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
627 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
628 if (glandau1[i]>1) glandau1[i]=1;
629 glandau1[i]*=padlength*padlength/12.;
633 gnoise2 = 0.0004/padlength;
636 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
637 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
638 if (glandau2[i]>1) glandau2[i]=1;
639 glandau2[i]*=padlength*padlength/12.;
644 gnoise3 = 0.0004/padlength;
647 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
648 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
649 if (glandau3[i]>1) glandau3[i]=1;
650 glandau3[i]*=padlength*padlength/12.;
658 Int_t amp = int(TMath::Abs(cl->GetQ()));
660 seed->SetErrorY2(1.);
664 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
665 Int_t ctype = cl->GetType();
666 Float_t padlength= GetPadPitchLength(seed->fRow);
668 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
669 // if (angle2<0.6) angle2 = 0.6;
670 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
673 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
676 if (fSectors==fInnerSec){
678 res = ggg1[amp]*z+glandau1[amp]*angle2;
679 if (ctype==0) res *= gcor01[rsigmaz];
682 res*= gcorp[rsigmaz];
688 res = ggg2[amp]*z+glandau2[amp]*angle2;
689 if (ctype==0) res *= gcor02[rsigmaz];
692 res*= gcorp[rsigmaz];
697 res = ggg3[amp]*z+glandau3[amp]*angle2;
698 if (ctype==0) res *= gcor02[rsigmaz];
701 res*= gcorp[rsigmaz];
710 if ((ctype<0) &&<70){
718 seed->SetErrorZ2(res);
725 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
728 //seed->SetErrorZ2(0.1);
732 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
734 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
735 Int_t ctype = cl->GetType();
736 Float_t amp = TMath::Abs(cl->GetQ());
741 Float_t landau=2 ; //landau fluctuation part
742 Float_t gg=2; // gg fluctuation part
743 Float_t padlength= GetPadPitchLength(seed->GetX());
745 if (fSectors==fInnerSec){
746 snoise2 = 0.0004/padlength;
749 gg = (2+0.001*nel/(padlength*padlength))/nel;
750 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
751 if (landau>1) landau=1;
754 snoise2 = 0.0004/padlength;
757 gg = (2+0.0008*nel/(padlength*padlength))/nel;
758 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
759 if (landau>1) landau=1;
761 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
764 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
765 angle2 = TMath::Sqrt((1-angle2));
766 if (angle2<0.6) angle2 = 0.6;
769 Float_t angle = seed->GetTgl()/angle2;
770 Float_t angular = landau*angle*angle*padlength*padlength/12.;
771 Float_t res = sdiff + angular;
774 if ((ctype==0) && (fSectors ==fOuterSec))
775 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
777 if ((ctype==0) && (fSectors ==fInnerSec))
778 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
782 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
788 if ((ctype<0) &&<70){
796 seed->SetErrorZ2(res);
803 void AliTPCseed::Reset(Bool_t all)
807 SetNumberOfClusters(0);
813 for (Int_t i=0;i<8;i++){
814 delete [] fTrackPoints[i];
822 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
823 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
829 void AliTPCseed::Modify(Double_t factor)
832 //------------------------------------------------------------------
833 //This function makes a track forget its history :)
834 //------------------------------------------------------------------
840 fC10*=0; fC11*=factor;
841 fC20*=0; fC21*=0; fC22*=factor;
842 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
843 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
844 SetNumberOfClusters(0);
848 fCurrentSigmaY2 = 0.000005;
849 fCurrentSigmaZ2 = 0.000005;
858 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
860 //-----------------------------------------------------------------
861 // This function find proloncation of a track to a reference plane x=xk.
862 // doesn't change internal state of the track
863 //-----------------------------------------------------------------
865 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
867 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
871 // Double_t y1=fP0, z1=fP1;
872 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
873 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
877 //y += dx*(c1+c2)/(r1+r2);
878 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
880 Double_t dy = dx*(c1+c2)/(r1+r2);
883 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
885 if (TMath::Abs(delta)>0.0001){
886 dz = fP3*TMath::ASin(delta)/fP4;
888 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
891 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
901 //_____________________________________________________________________________
902 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
904 //-----------------------------------------------------------------
905 // This function calculates a predicted chi2 increment.
906 //-----------------------------------------------------------------
907 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
908 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
909 r00+=fC00; r01+=fC10; r11+=fC11;
911 Double_t det=r00*r11 - r01*r01;
912 if (TMath::Abs(det) < 1.e-10) {
913 Int_t n=GetNumberOfClusters();
914 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
917 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
919 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
921 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
925 //_________________________________________________________________________________________
928 Int_t AliTPCseed::Compare(const TObject *o) const {
929 //-----------------------------------------------------------------
930 // This function compares tracks according to the sector - for given sector according z
931 //-----------------------------------------------------------------
932 AliTPCseed *t=(AliTPCseed*)o;
935 if (t->fRelativeSector>fRelativeSector) return -1;
936 if (t->fRelativeSector<fRelativeSector) return 1;
937 Double_t z2 = t->GetZ();
938 Double_t z1 = GetZ();
940 if (z2<z1) return -1;
945 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
946 if (t->fBConstrain) f2=1.2;
949 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
951 if (fBConstrain) f1=1.2;
953 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
958 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
960 //rotate to track "local coordinata
961 Float_t x = seed->GetX();
962 Float_t y = seed->GetY();
963 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
966 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
967 if (!seed->Rotate(fSectors->GetAlpha()))
969 } else if (y <-ymax) {
970 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
971 if (!seed->Rotate(-fSectors->GetAlpha()))
980 //_____________________________________________________________________________
981 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
982 //-----------------------------------------------------------------
983 // This function associates a cluster with this track.
984 //-----------------------------------------------------------------
985 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
987 r00+=fC00; r01+=fC10; r11+=fC11;
988 Double_t det=r00*r11 - r01*r01;
989 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
991 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
992 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
993 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
994 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
995 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
997 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
998 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
999 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1003 fP0 += k00*dy + k01*dz;
1004 fP1 += k10*dy + k11*dz;
1006 fP3 += k30*dy + k31*dz;
1009 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1010 Double_t c12=fC21, c13=fC31, c14=fC41;
1012 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1013 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1014 fC40-=k00*c04+k01*c14;
1016 fC11-=k10*c01+k11*fC11;
1017 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1018 fC41-=k10*c04+k11*c14;
1020 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1021 fC42-=k20*c04+k21*c14;
1023 fC33-=k30*c03+k31*c13;
1024 fC43-=k40*c03+k41*c13;
1026 fC44-=k40*c04+k41*c14;
1028 Int_t n=GetNumberOfClusters();
1030 SetNumberOfClusters(n+1);
1031 SetChi2(GetChi2()+chisq);
1038 //_____________________________________________________________________________
1039 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1040 Double_t x2,Double_t y2,
1041 Double_t x3,Double_t y3)
1043 //-----------------------------------------------------------------
1044 // Initial approximation of the track curvature
1045 //-----------------------------------------------------------------
1046 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1047 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1048 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1049 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1050 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1052 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1053 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1054 return -xr*yr/sqrt(xr*xr+yr*yr);
1059 //_____________________________________________________________________________
1060 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1061 Double_t x2,Double_t y2,
1062 Double_t x3,Double_t y3)
1064 //-----------------------------------------------------------------
1065 // Initial approximation of the track curvature
1066 //-----------------------------------------------------------------
1072 Double_t det = x3*y2-x2*y3;
1077 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1078 Double_t x0 = x3*0.5-y3*u;
1079 Double_t y0 = y3*0.5+x3*u;
1080 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1086 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1087 Double_t x2,Double_t y2,
1088 Double_t x3,Double_t y3)
1090 //-----------------------------------------------------------------
1091 // Initial approximation of the track curvature
1092 //-----------------------------------------------------------------
1098 Double_t det = x3*y2-x2*y3;
1103 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1104 Double_t x0 = x3*0.5-y3*u;
1105 Double_t y0 = y3*0.5+x3*u;
1106 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1115 //_____________________________________________________________________________
1116 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1117 Double_t x2,Double_t y2,
1118 Double_t x3,Double_t y3)
1120 //-----------------------------------------------------------------
1121 // Initial approximation of the track curvature times center of curvature
1122 //-----------------------------------------------------------------
1123 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1124 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1125 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1126 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1127 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1129 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1131 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1134 //_____________________________________________________________________________
1135 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1136 Double_t x2,Double_t y2,
1137 Double_t z1,Double_t z2)
1139 //-----------------------------------------------------------------
1140 // Initial approximation of the tangent of the track dip angle
1141 //-----------------------------------------------------------------
1142 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1146 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1147 Double_t x2,Double_t y2,
1148 Double_t z1,Double_t z2, Double_t c)
1150 //-----------------------------------------------------------------
1151 // Initial approximation of the tangent of the track dip angle
1152 //-----------------------------------------------------------------
1156 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1158 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1159 if (TMath::Abs(d*c*0.5)>1) return 0;
1160 // Double_t angle2 = TMath::ASin(d*c*0.5);
1161 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1162 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1164 angle2 = (z1-z2)*c/(angle2*2.);
1168 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1169 {//-----------------------------------------------------------------
1170 // This function find proloncation of a track to a reference plane x=x2.
1171 //-----------------------------------------------------------------
1175 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1179 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1180 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1184 Double_t dy = dx*(c1+c2)/(r1+r2);
1187 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1189 if (TMath::Abs(delta)>0.01){
1190 dz = x[3]*TMath::ASin(delta)/x[4];
1192 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1195 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1203 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1208 return LoadClusters();
1211 Int_t AliTPCtrackerMI::LoadClusters()
1214 // load clusters to the memory
1215 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1216 clrow->SetClass("AliTPCclusterMI");
1218 clrow->GetArray()->ExpandCreateFast(10000);
1220 // TTree * tree = fClustersArray.GetTree();
1222 TTree * tree = fInput;
1223 TBranch * br = tree->GetBranch("Segment");
1224 br->SetAddress(&clrow);
1226 Int_t j=Int_t(tree->GetEntries());
1227 for (Int_t i=0; i<j; i++) {
1231 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1233 AliTPCRow * tpcrow=0;
1236 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1240 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1241 left = (sec-fkNIS*2)/fkNOS;
1244 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1245 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1246 for (Int_t i=0;i<tpcrow->fN1;i++)
1247 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1250 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1251 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1252 for (Int_t i=0;i<tpcrow->fN2;i++)
1253 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1264 void AliTPCtrackerMI::UnloadClusters()
1267 // unload clusters from the memory
1269 Int_t nrows = fOuterSec->GetNRows();
1270 for (Int_t sec = 0;sec<fkNOS;sec++)
1271 for (Int_t row = 0;row<nrows;row++){
1272 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1274 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1275 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1277 tpcrow->ResetClusters();
1280 nrows = fInnerSec->GetNRows();
1281 for (Int_t sec = 0;sec<fkNIS;sec++)
1282 for (Int_t row = 0;row<nrows;row++){
1283 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1285 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1286 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1288 tpcrow->ResetClusters();
1295 //_____________________________________________________________________________
1296 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1297 //-----------------------------------------------------------------
1298 // This function fills outer TPC sectors with clusters.
1299 //-----------------------------------------------------------------
1300 Int_t nrows = fOuterSec->GetNRows();
1302 for (Int_t sec = 0;sec<fkNOS;sec++)
1303 for (Int_t row = 0;row<nrows;row++){
1304 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1305 Int_t sec2 = sec+2*fkNIS;
1307 Int_t ncl = tpcrow->fN1;
1309 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1310 index=(((sec2<<8)+row)<<16)+ncl;
1311 tpcrow->InsertCluster(c,index);
1316 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1317 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1318 tpcrow->InsertCluster(c,index);
1321 // write indexes for fast acces
1323 for (Int_t i=0;i<510;i++)
1324 tpcrow->fFastCluster[i]=-1;
1325 for (Int_t i=0;i<tpcrow->GetN();i++){
1326 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1327 tpcrow->fFastCluster[zi]=i; // write index
1330 for (Int_t i=0;i<510;i++){
1331 if (tpcrow->fFastCluster[i]<0)
1332 tpcrow->fFastCluster[i] = last;
1334 last = tpcrow->fFastCluster[i];
1343 //_____________________________________________________________________________
1344 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1345 //-----------------------------------------------------------------
1346 // This function fills inner TPC sectors with clusters.
1347 //-----------------------------------------------------------------
1348 Int_t nrows = fInnerSec->GetNRows();
1350 for (Int_t sec = 0;sec<fkNIS;sec++)
1351 for (Int_t row = 0;row<nrows;row++){
1352 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1355 Int_t ncl = tpcrow->fN1;
1357 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1358 index=(((sec<<8)+row)<<16)+ncl;
1359 tpcrow->InsertCluster(c,index);
1364 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1365 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1366 tpcrow->InsertCluster(c,index);
1369 // write indexes for fast acces
1371 for (Int_t i=0;i<510;i++)
1372 tpcrow->fFastCluster[i]=-1;
1373 for (Int_t i=0;i<tpcrow->GetN();i++){
1374 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1375 tpcrow->fFastCluster[zi]=i; // write index
1378 for (Int_t i=0;i<510;i++){
1379 if (tpcrow->fFastCluster[i]<0)
1380 tpcrow->fFastCluster[i] = last;
1382 last = tpcrow->fFastCluster[i];
1394 //_________________________________________________________________________
1395 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1396 //--------------------------------------------------------------------
1397 // Return pointer to a given cluster
1398 //--------------------------------------------------------------------
1399 Int_t sec=(index&0xff000000)>>24;
1400 Int_t row=(index&0x00ff0000)>>16;
1401 Int_t ncl=(index&0x00007fff)>>00;
1403 const AliTPCRow * tpcrow=0;
1404 AliTPCclusterMI * clrow =0;
1406 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1408 clrow = tpcrow->fClusters1;
1410 clrow = tpcrow->fClusters2;
1413 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1414 if (sec-2*fkNIS<fkNOS)
1415 clrow = tpcrow->fClusters1;
1417 clrow = tpcrow->fClusters2;
1419 if (tpcrow==0) return 0;
1420 if (tpcrow->GetN()<=ncl) return 0;
1421 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1422 return &(clrow[ncl]);
1428 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1429 //-----------------------------------------------------------------
1430 // This function tries to find a track prolongation to next pad row
1431 //-----------------------------------------------------------------
1433 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1435 // if (t.GetRadius()>x+10 ) return 0;
1436 // t.PropagateTo(x+0.02);
1437 //t.PropagateTo(x+0.01);
1438 if (!t.PropagateTo(x)) {
1443 Double_t y=t.GetY(), z=t.GetZ();
1444 if (TMath::Abs(y)>ymax){
1446 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1447 if (!t.Rotate(fSectors->GetAlpha()))
1449 } else if (y <-ymax) {
1450 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1451 if (!t.Rotate(-fSectors->GetAlpha()))
1454 //if (!t.PropagateTo(x)) {
1460 // update current shape info every 3 pad-row
1461 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1462 //t.fCurrentSigmaY = GetSigmaY(&t);
1463 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1467 AliTPCclusterMI *cl=0;
1472 if (t.GetClusterIndex2(nr)>0){
1474 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1475 index = t.GetClusterIndex2(nr);
1476 cl = t.fClusterPointer[nr];
1477 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1478 t.fCurrentClusterIndex1 = index;
1481 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1482 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1484 Double_t roadz = 1.;
1486 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1488 t.SetClusterIndex2(nr,-1);
1493 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1499 t.fCurrentCluster = cl;
1501 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1502 if (fIteration>0) accept =0;
1504 //if founded cluster is acceptible
1505 UpdateTrack(&t,accept);
1511 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1512 cl = krow.FindNearest2(y,z,roady,roadz,index);
1513 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1518 t.fCurrentCluster = cl;
1520 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1522 if (t.fCurrentCluster->IsUsed(10)){
1527 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1533 if (accept<3) UpdateTrack(&t,accept);
1536 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1542 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1543 //-----------------------------------------------------------------
1544 // This function tries to find a track prolongation to next pad row
1545 //-----------------------------------------------------------------
1547 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1549 if (!t.GetProlongation(x,y,z)) {
1555 if (TMath::Abs(y)>ymax){
1558 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1559 if (!t.Rotate(fSectors->GetAlpha()))
1561 } else if (y <-ymax) {
1562 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1563 if (!t.Rotate(-fSectors->GetAlpha()))
1566 if (!t.PropagateTo(x)) {
1569 t.GetProlongation(x,y,z);
1572 // update current shape info every 3 pad-row
1573 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1574 // t.fCurrentSigmaY = GetSigmaY(&t);
1575 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1579 AliTPCclusterMI *cl=0;
1584 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1585 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1587 Double_t roadz = 1.;
1590 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1592 t.SetClusterIndex2(row,-1);
1597 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1601 if ((cl==0)&&(krow)) {
1602 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1603 cl = krow.FindNearest2(y,z,roady,roadz,index);
1605 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1609 t.fCurrentCluster = cl;
1610 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1612 t.SetClusterIndex2(row,index);
1613 t.fClusterPointer[row] = cl;
1621 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1622 //-----------------------------------------------------------------
1623 // This function tries to find a track prolongation to next pad row
1624 //-----------------------------------------------------------------
1625 t.fCurrentCluster = 0;
1626 t.fCurrentClusterIndex1 = 0;
1628 Double_t xt=t.GetX();
1629 Int_t row = GetRowNumber(xt)-1;
1630 Double_t ymax= GetMaxY(nr);
1632 if (row < nr) return 1; // don't prolongate if not information until now -
1633 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1635 return 0; // not prolongate strongly inclined tracks
1637 if (TMath::Abs(t.GetSnp())>0.95) {
1639 return 0; // not prolongate strongly inclined tracks
1642 Double_t x= GetXrow(nr);
1644 //t.PropagateTo(x+0.02);
1645 //t.PropagateTo(x+0.01);
1646 if (!t.PropagateTo(x)){
1653 if (TMath::Abs(y)>ymax){
1655 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1656 if (!t.Rotate(fSectors->GetAlpha()))
1658 } else if (y <-ymax) {
1659 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1660 if (!t.Rotate(-fSectors->GetAlpha()))
1663 // if (!t.PropagateTo(x)){
1671 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1673 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1675 t.SetClusterIndex2(nr,-1);
1680 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1686 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1687 // t.fCurrentSigmaY = GetSigmaY(&t);
1688 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1692 AliTPCclusterMI *cl=0;
1695 Double_t roady = 1.;
1696 Double_t roadz = 1.;
1700 index = t.GetClusterIndex2(nr);
1701 if ( (index>0) && (index&0x8000)==0){
1702 cl = t.fClusterPointer[nr];
1703 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1704 t.fCurrentClusterIndex1 = index;
1706 t.fCurrentCluster = cl;
1713 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1714 cl = krow.FindNearest2(y,z,roady,roadz,index);
1717 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1718 t.fCurrentCluster = cl;
1724 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1725 //-----------------------------------------------------------------
1726 // This function tries to find a track prolongation to next pad row
1727 //-----------------------------------------------------------------
1729 //update error according neighborhoud
1731 if (t.fCurrentCluster) {
1733 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1735 if (t.fCurrentCluster->IsUsed(10)){
1741 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1746 if (fIteration>0) accept = 0;
1747 if (accept<3) UpdateTrack(&t,accept);
1751 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1752 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1754 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1762 //_____________________________________________________________________________
1763 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1764 //-----------------------------------------------------------------
1765 // This function tries to find a track prolongation.
1766 //-----------------------------------------------------------------
1767 Double_t xt=t.GetX();
1769 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1770 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1771 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1773 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1775 Int_t first = GetRowNumber(xt)-1;
1776 for (Int_t nr= first; nr>=rf; nr-=step) {
1777 if (nr<fInnerSec->GetNRows())
1778 fSectors = fInnerSec;
1780 fSectors = fOuterSec;
1781 if (FollowToNext(t,nr)==0)
1782 if (!t.IsActive()) return 0;
1789 //_____________________________________________________________________________
1790 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1791 //-----------------------------------------------------------------
1792 // This function tries to find a track prolongation.
1793 //-----------------------------------------------------------------
1794 Double_t xt=t.GetX();
1796 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1797 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1798 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1799 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1801 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1803 if (FollowToNextFast(t,nr)==0)
1804 if (!t.IsActive()) return 0;
1814 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1815 //-----------------------------------------------------------------
1816 // This function tries to find a track prolongation.
1817 //-----------------------------------------------------------------
1818 // Double_t xt=t.GetX();
1820 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1821 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1822 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1823 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1826 first = t.fFirstPoint+3;
1828 if (first<0) first=0;
1829 for (Int_t nr=first+1; nr<=rf; nr++) {
1830 //if ( (t.GetSnp()<0.9))
1831 if (nr<fInnerSec->GetNRows())
1832 fSectors = fInnerSec;
1834 fSectors = fOuterSec;
1844 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1852 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1855 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1857 Float_t distance = TMath::Sqrt(dz2+dy2);
1858 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1861 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1862 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1867 if (firstpoint>lastpoint) {
1868 firstpoint =lastpoint;
1873 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1874 if (s1->GetClusterIndex2(i)>0) sum1++;
1875 if (s2->GetClusterIndex2(i)>0) sum2++;
1876 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1880 if (sum<5) return 0;
1882 Float_t summin = TMath::Min(sum1+1,sum2+1);
1883 Float_t ratio = (sum+1)/Float_t(summin);
1887 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1891 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1892 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1894 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1896 Float_t dy2 =(s1->GetY() - s2->GetY());
1898 Float_t distance = dz2+dy2;
1899 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1904 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1905 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1907 if (firstpoint>=lastpoint-5) return;;
1909 for (Int_t i=firstpoint;i<lastpoint;i++){
1910 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1911 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1918 for (Int_t i=firstpoint;i<lastpoint;i++){
1919 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1920 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1921 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1922 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1923 if (s1->IsActive()&&s2->IsActive()){
1924 p1->fIsShared = kTRUE;
1925 p2->fIsShared = kTRUE;
1932 for (Int_t i=0;i<4;i++){
1933 if (s1->fOverlapLabels[3*i]==0){
1934 s1->fOverlapLabels[3*i] = s2->GetLabel();
1935 s1->fOverlapLabels[3*i+1] = sumshared;
1936 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1940 for (Int_t i=0;i<4;i++){
1941 if (s2->fOverlapLabels[3*i]==0){
1942 s2->fOverlapLabels[3*i] = s1->GetLabel();
1943 s2->fOverlapLabels[3*i+1] = sumshared;
1944 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1952 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1955 //sort trackss according sectors
1957 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1958 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1960 //if (pt) RotateToLocal(pt);
1964 arr->Sort(); // sorting according z
1965 arr->Expand(arr->GetEntries());
1968 Int_t nseed=arr->GetEntriesFast();
1969 for (Int_t i=0; i<nseed; i++) {
1970 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1972 for (Int_t j=0;j<=12;j++){
1973 pt->fOverlapLabels[j] =0;
1976 for (Int_t i=0; i<nseed; i++) {
1977 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1979 if (pt->fRemoval>10) continue;
1980 for (Int_t j=i+1; j<nseed; j++){
1981 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1983 if (pt2->fRemoval<=10) {
1984 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1991 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1994 //sort trackss according sectors
1997 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2000 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2001 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2006 arr->Sort(); // sorting according z
2007 arr->Expand(arr->GetEntries());
2009 //reset overlap labels
2011 Int_t nseed=arr->GetEntriesFast();
2012 for (Int_t i=0; i<nseed; i++) {
2013 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2016 for (Int_t j=0;j<=12;j++){
2017 pt->fOverlapLabels[j] =0;
2021 //sign shared tracks
2022 for (Int_t i=0; i<nseed; i++) {
2023 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2025 if (pt->fRemoval>10) continue;
2026 Float_t deltac = pt->GetC()*0.1;
2027 for (Int_t j=i+1; j<nseed; j++){
2028 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2030 if (pt2->fRemoval<=10) {
2031 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2032 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2033 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2040 // remove highly shared tracks
2041 for (Int_t i=0; i<nseed; i++) {
2042 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2044 if (pt->fRemoval>10) continue;
2047 for (Int_t j=0;j<4;j++){
2048 sumshared = pt->fOverlapLabels[j*3+1];
2050 Float_t factor = factor1;
2051 if (pt->fRemoval>0) factor = factor2;
2052 if (sumshared/pt->GetNumberOfClusters()>factor){
2053 for (Int_t j=0;j<4;j++){
2054 if (pt->fOverlapLabels[3*j]==0) continue;
2055 if (pt->fOverlapLabels[3*j+1]<5) continue;
2056 if (pt->fRemoval==removalindex) continue;
2057 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2059 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2060 // pt->fRemoval = removalindex;
2061 delete arr->RemoveAt(i);
2069 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2078 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2081 //sort tracks in array according mode criteria
2082 Int_t nseed = arr->GetEntriesFast();
2083 for (Int_t i=0; i<nseed; i++) {
2084 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2094 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2097 //Loop over all tracks and remove "overlaps"
2100 Int_t nseed = arr->GetEntriesFast();
2103 for (Int_t i=0; i<nseed; i++) {
2104 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2106 delete arr->RemoveAt(i);
2110 pt->fBSigned = kFALSE;
2114 nseed = arr->GetEntriesFast();
2121 for (Int_t i=0; i<nseed; i++) {
2122 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2126 Int_t found,foundable,shared;
2128 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2130 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2132 Double_t factor = factor2;
2133 if (pt->fBConstrain) factor = factor1;
2135 if ((Float_t(shared)/Float_t(found))>factor){
2136 pt->Desactivate(removalindex);
2141 for (Int_t i=0; i<160; i++) {
2142 Int_t index=pt->GetClusterIndex2(i);
2143 if (index<0 || index&0x8000 ) continue;
2144 AliTPCclusterMI *c= pt->fClusterPointer[i];
2146 // if (!c->IsUsed(10)) c->Use(10);
2147 //if (pt->IsActive())
2156 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2160 void AliTPCtrackerMI::UnsignClusters()
2163 // loop over all clusters and unsign them
2166 for (Int_t sec=0;sec<fkNIS;sec++){
2167 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2168 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2169 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2170 // if (cl[icl].IsUsed(10))
2172 cl = fInnerSec[sec][row].fClusters2;
2173 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2174 //if (cl[icl].IsUsed(10))
2179 for (Int_t sec=0;sec<fkNOS;sec++){
2180 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2181 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2182 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2183 //if (cl[icl].IsUsed(10))
2185 cl = fOuterSec[sec][row].fClusters2;
2186 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2187 //if (cl[icl].IsUsed(10))
2196 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2199 //sign clusters to be "used"
2201 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2202 // loop over "primaries"
2216 Int_t nseed = arr->GetEntriesFast();
2217 for (Int_t i=0; i<nseed; i++) {
2218 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2222 if (!(pt->IsActive())) continue;
2223 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2224 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2226 sumdens2+= dens*dens;
2227 sumn += pt->GetNumberOfClusters();
2228 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2229 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2232 sumchi2 +=chi2*chi2;
2237 Float_t mdensity = 0.9;
2238 Float_t meann = 130;
2239 Float_t meanchi = 1;
2240 Float_t sdensity = 0.1;
2241 Float_t smeann = 10;
2242 Float_t smeanchi =0.4;
2246 mdensity = sumdens/sum;
2248 meanchi = sumchi/sum;
2250 sdensity = sumdens2/sum-mdensity*mdensity;
2251 sdensity = TMath::Sqrt(sdensity);
2253 smeann = sumn2/sum-meann*meann;
2254 smeann = TMath::Sqrt(smeann);
2256 smeanchi = sumchi2/sum - meanchi*meanchi;
2257 smeanchi = TMath::Sqrt(smeanchi);
2261 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2263 for (Int_t i=0; i<nseed; i++) {
2264 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2268 if (pt->fBSigned) continue;
2269 if (pt->fBConstrain) continue;
2270 //if (!(pt->IsActive())) continue;
2272 Int_t found,foundable,shared;
2273 pt->GetClusterStatistic(0,160,found, foundable,shared);
2274 if (shared/float(found)>0.3) {
2275 if (shared/float(found)>0.9 ){
2276 //delete arr->RemoveAt(i);
2281 Bool_t isok =kFALSE;
2282 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2284 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2286 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2288 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2292 for (Int_t i=0; i<160; i++) {
2293 Int_t index=pt->GetClusterIndex2(i);
2294 if (index<0) continue;
2295 AliTPCclusterMI *c= pt->fClusterPointer[i];
2297 //if (!(c->IsUsed(10))) c->Use();
2304 Double_t maxchi = meanchi+2.*smeanchi;
2306 for (Int_t i=0; i<nseed; i++) {
2307 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2311 //if (!(pt->IsActive())) continue;
2312 if (pt->fBSigned) continue;
2313 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2314 if (chi>maxchi) continue;
2317 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2319 //sign only tracks with enoug big density at the beginning
2321 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2324 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2325 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2327 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2328 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2331 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2332 //Int_t noc=pt->GetNumberOfClusters();
2333 pt->fBSigned = kTRUE;
2334 for (Int_t i=0; i<160; i++) {
2336 Int_t index=pt->GetClusterIndex2(i);
2337 if (index<0) continue;
2338 AliTPCclusterMI *c= pt->fClusterPointer[i];
2340 // if (!(c->IsUsed(10))) c->Use();
2345 // gLastCheck = nseed;
2353 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2355 // stop not active tracks
2356 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2357 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2358 Int_t nseed = arr->GetEntriesFast();
2360 for (Int_t i=0; i<nseed; i++) {
2361 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2365 if (!(pt->IsActive())) continue;
2366 StopNotActive(pt,row0,th0, th1,th2);
2372 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2375 // stop not active tracks
2376 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2377 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2380 Int_t foundable = 0;
2381 Int_t maxindex = seed->fLastPoint; //last foundable row
2382 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2383 seed->Desactivate(10) ;
2387 for (Int_t i=row0; i<maxindex; i++){
2388 Int_t index = seed->GetClusterIndex2(i);
2389 if (index!=-1) foundable++;
2391 if (foundable<=30) sumgood1++;
2392 if (foundable<=50) {
2399 if (foundable>=30.){
2400 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2403 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2407 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2410 // back propagation of ESD tracks
2416 //PrepareForProlongation(fSeeds,1);
2417 PropagateForward2(fSeeds);
2418 Int_t nseed = fSeeds->GetEntriesFast();
2419 for (Int_t i=0;i<nseed;i++){
2420 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2421 seed->PropagateTo(fParam->GetInnerRadiusLow());
2422 AliESDtrack *esd=event->GetTrack(i);
2423 seed->CookdEdx(0.02,0.6);
2424 CookLabel(seed,0.1); //For comparison only
2425 if (seed->GetNumberOfClusters()>20){
2426 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2429 //printf("problem\n");
2438 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2441 // back propagation of ESD tracks
2447 PropagateBack(fSeeds);
2448 Int_t nseed = fSeeds->GetEntriesFast();
2449 for (Int_t i=0;i<nseed;i++){
2450 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2451 AliESDtrack *esd=event->GetTrack(i);
2452 seed->CookdEdx(0.02,0.6);
2453 CookLabel(seed,0.1); //For comparison only
2454 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2462 void AliTPCtrackerMI::DeleteSeeds()
2466 Int_t nseed = fSeeds->GetEntriesFast();
2467 for (Int_t i=0;i<nseed;i++){
2468 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2469 if (seed) delete fSeeds->RemoveAt(i);
2475 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2478 //read seeds from the event
2480 Int_t nentr=event->GetNumberOfTracks();
2482 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2487 fSeeds = new TObjArray;
2491 for (Int_t i=0; i<nentr; i++) {
2492 AliESDtrack *esd=event->GetTrack(i);
2493 ULong_t status=esd->GetStatus();
2494 AliTPCtrack t(*esd);
2495 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2496 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2497 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2501 // rotate to the local coordinate system
2503 fSectors=fInnerSec; fN=fkNIS;
2505 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2506 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2507 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2508 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2509 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2510 alpha-=seed->GetAlpha();
2511 if (!seed->Rotate(alpha)) continue;
2514 //seed->PropagateTo(fSectors->GetX(0));
2516 // Int_t index = esd->GetTPCindex();
2517 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2518 //if (direction==2){
2519 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2526 fSeeds->AddLast(seed);
2532 //_____________________________________________________________________________
2533 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2534 Float_t deltay, Int_t ddsec) {
2535 //-----------------------------------------------------------------
2536 // This function creates track seeds.
2537 // SEEDING WITH VERTEX CONSTRAIN
2538 //-----------------------------------------------------------------
2539 // cuts[0] - fP4 cut
2540 // cuts[1] - tan(phi) cut
2541 // cuts[2] - zvertex cut
2542 // cuts[3] - fP3 cut
2550 Double_t x[5], c[15];
2551 // Int_t di = i1-i2;
2553 AliTPCseed * seed = new AliTPCseed;
2554 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2555 Double_t cs=cos(alpha), sn=sin(alpha);
2557 // Double_t x1 =fOuterSec->GetX(i1);
2558 //Double_t xx2=fOuterSec->GetX(i2);
2560 Double_t x1 =GetXrow(i1);
2561 Double_t xx2=GetXrow(i2);
2563 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2565 Int_t imiddle = (i2+i1)/2; //middle pad row index
2566 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2567 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2571 const AliTPCRow& kr1=GetRow(ns,i1);
2572 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2573 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2576 // change cut on curvature if it can't reach this layer
2577 // maximal curvature set to reach it
2578 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2579 if (dvertexmax*0.5*cuts[0]>0.85){
2580 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2582 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2585 if (deltay>0) ddsec = 0;
2586 // loop over clusters
2587 for (Int_t is=0; is < kr1; is++) {
2589 if (kr1[is]->IsUsed(10)) continue;
2590 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2591 //if (TMath::Abs(y1)>ymax) continue;
2593 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2595 // find possible directions
2596 Float_t anglez = (z1-z3)/(x1-x3);
2597 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2600 //find rotation angles relative to line given by vertex and point 1
2601 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2602 Double_t dvertex = TMath::Sqrt(dvertex2);
2603 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2604 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2607 // loop over 2 sectors
2613 Double_t dddz1=0; // direction of delta inclination in z axis
2620 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2621 Int_t sec2 = sec + dsec;
2623 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2624 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2625 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2626 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2627 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2628 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2630 // rotation angles to p1-p3
2631 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2632 Double_t x2, y2, z2;
2634 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2637 Double_t dxx0 = (xx2-x3)*cs13r;
2638 Double_t dyy0 = (xx2-x3)*sn13r;
2639 for (Int_t js=index1; js < index2; js++) {
2640 const AliTPCclusterMI *kcl = kr2[js];
2641 if (kcl->IsUsed(10)) continue;
2643 //calcutate parameters
2645 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2647 if (TMath::Abs(yy0)<0.000001) continue;
2648 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2649 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2650 Double_t r02 = (0.25+y0*y0)*dvertex2;
2651 //curvature (radius) cut
2652 if (r02<r2min) continue;
2656 Double_t c0 = 1/TMath::Sqrt(r02);
2660 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2661 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2662 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2663 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2666 Double_t z0 = kcl->GetZ();
2667 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2668 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2671 Double_t dip = (z1-z0)*c0/dfi1;
2672 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2683 x2= xx2*cs-y2*sn*dsec;
2684 y2=+xx2*sn*dsec+y2*cs;
2694 // do we have cluster at the middle ?
2696 GetProlongation(x1,xm,x,ym,zm);
2698 AliTPCclusterMI * cm=0;
2699 if (TMath::Abs(ym)-ymaxm<0){
2700 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2701 if ((!cm) || (cm->IsUsed(10))) {
2706 // rotate y1 to system 0
2707 // get state vector in rotated system
2708 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2709 Double_t xr2 = x0*cs+yr1*sn*dsec;
2710 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2712 GetProlongation(xx2,xm,xr,ym,zm);
2713 if (TMath::Abs(ym)-ymaxm<0){
2714 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2715 if ((!cm) || (cm->IsUsed(10))) {
2725 dym = ym - cm->GetY();
2726 dzm = zm - cm->GetZ();
2733 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2734 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2735 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2736 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2737 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2739 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2740 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2741 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2742 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2743 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2744 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2746 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2747 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2748 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2749 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2753 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2754 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2755 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2756 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2757 c[13]=f30*sy1*f40+f32*sy2*f42;
2758 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2760 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2762 UInt_t index=kr1.GetIndex(is);
2763 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2765 track->fIsSeeding = kTRUE;
2772 FollowProlongation(*track, (i1+i2)/2,1);
2773 Int_t foundable,found,shared;
2774 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2775 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2777 seed->~AliTPCseed();
2783 FollowProlongation(*track, i2,1);
2787 track->fBConstrain =1;
2788 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2789 track->fLastPoint = i1; // first cluster in track position
2790 track->fFirstPoint = track->fLastPoint;
2792 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2793 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2794 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2796 seed->~AliTPCseed();
2800 // Z VERTEX CONDITION
2802 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2803 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2804 if (TMath::Abs(zv-z3)>cuts[2]) {
2805 FollowProlongation(*track, TMath::Max(i2-20,0));
2806 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2807 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2808 if (TMath::Abs(zv-z3)>cuts[2]){
2809 FollowProlongation(*track, TMath::Max(i2-40,0));
2810 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2811 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2812 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2813 // make seed without constrain
2814 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2815 FollowProlongation(*track2, i2,1);
2816 track2->fBConstrain = kFALSE;
2817 track2->fSeedType = 1;
2818 arr->AddLast(track2);
2820 seed->~AliTPCseed();
2825 seed->~AliTPCseed();
2832 track->fSeedType =0;
2833 arr->AddLast(track);
2834 seed = new AliTPCseed;
2836 // don't consider other combinations
2837 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2843 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2849 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2854 //-----------------------------------------------------------------
2855 // This function creates track seeds.
2856 //-----------------------------------------------------------------
2857 // cuts[0] - fP4 cut
2858 // cuts[1] - tan(phi) cut
2859 // cuts[2] - zvertex cut
2860 // cuts[3] - fP3 cut
2870 Double_t x[5], c[15];
2872 // make temporary seed
2873 AliTPCseed * seed = new AliTPCseed;
2874 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2875 // Double_t cs=cos(alpha), sn=sin(alpha);
2880 Double_t x1 = GetXrow(i1-1);
2881 const AliTPCRow& kr1=GetRow(sec,i1-1);
2882 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2884 Double_t x1p = GetXrow(i1);
2885 const AliTPCRow& kr1p=GetRow(sec,i1);
2887 Double_t x1m = GetXrow(i1-2);
2888 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2891 //last 3 padrow for seeding
2892 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2893 Double_t x3 = GetXrow(i1-7);
2894 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2896 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2897 Double_t x3p = GetXrow(i1-6);
2899 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2900 Double_t x3m = GetXrow(i1-8);
2905 Int_t im = i1-4; //middle pad row index
2906 Double_t xm = GetXrow(im); // radius of middle pad-row
2907 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2908 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2911 Double_t deltax = x1-x3;
2912 Double_t dymax = deltax*cuts[1];
2913 Double_t dzmax = deltax*cuts[3];
2915 // loop over clusters
2916 for (Int_t is=0; is < kr1; is++) {
2918 if (kr1[is]->IsUsed(10)) continue;
2919 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2921 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2923 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2924 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2930 for (Int_t js=index1; js < index2; js++) {
2931 const AliTPCclusterMI *kcl = kr3[js];
2932 if (kcl->IsUsed(10)) continue;
2934 // apply angular cuts
2935 if (TMath::Abs(y1-y3)>dymax) continue;
2938 if (TMath::Abs(z1-z3)>dzmax) continue;
2940 Double_t angley = (y1-y3)/(x1-x3);
2941 Double_t anglez = (z1-z3)/(x1-x3);
2943 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2944 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2946 Double_t yyym = angley*(xm-x1)+y1;
2947 Double_t zzzm = anglez*(xm-x1)+z1;
2949 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2951 if (kcm->IsUsed(10)) continue;
2953 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2954 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2961 // look around first
2962 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2968 if (kc1m->IsUsed(10)) used++;
2970 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2976 if (kc1p->IsUsed(10)) used++;
2978 if (used>1) continue;
2979 if (found<1) continue;
2983 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2989 if (kc3m->IsUsed(10)) used++;
2993 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2999 if (kc3p->IsUsed(10)) used++;
3003 if (used>1) continue;
3004 if (found<3) continue;
3014 x[4]=F1(x1,y1,x2,y2,x3,y3);
3015 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3018 x[2]=F2(x1,y1,x2,y2,x3,y3);
3021 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3022 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3026 Double_t sy1=0.1, sz1=0.1;
3027 Double_t sy2=0.1, sz2=0.1;
3028 Double_t sy3=0.1, sy=0.1, sz=0.1;
3030 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3031 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3032 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3033 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3034 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3035 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3037 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3038 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3039 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3040 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3044 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3045 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3046 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3047 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3048 c[13]=f30*sy1*f40+f32*sy2*f42;
3049 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3051 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3053 UInt_t index=kr1.GetIndex(is);
3054 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3056 track->fIsSeeding = kTRUE;
3059 FollowProlongation(*track, i1-7,1);
3060 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3061 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3063 seed->~AliTPCseed();
3069 FollowProlongation(*track, i2,1);
3070 track->fBConstrain =0;
3071 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3072 track->fFirstPoint = track->fLastPoint;
3074 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3075 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3076 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3078 seed->~AliTPCseed();
3083 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3084 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3085 FollowProlongation(*track2, i2,1);
3086 track2->fBConstrain = kFALSE;
3087 track2->fSeedType = 4;
3088 arr->AddLast(track2);
3090 seed->~AliTPCseed();
3094 //arr->AddLast(track);
3095 //seed = new AliTPCseed;
3101 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3107 //_____________________________________________________________________________
3108 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3109 Float_t deltay, Bool_t /*bconstrain*/) {
3110 //-----------------------------------------------------------------
3111 // This function creates track seeds - without vertex constraint
3112 //-----------------------------------------------------------------
3113 // cuts[0] - fP4 cut - not applied
3114 // cuts[1] - tan(phi) cut
3115 // cuts[2] - zvertex cut - not applied
3116 // cuts[3] - fP3 cut
3126 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3127 // Double_t cs=cos(alpha), sn=sin(alpha);
3128 Int_t row0 = (i1+i2)/2;
3129 Int_t drow = (i1-i2)/2;
3130 const AliTPCRow& kr0=fSectors[sec][row0];
3133 AliTPCpolyTrack polytrack;
3134 Int_t nclusters=fSectors[sec][row0];
3135 AliTPCseed * seed = new AliTPCseed;
3140 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3142 Int_t nfoundable =0;
3143 for (Int_t iter =1; iter<2; iter++){ //iterations
3144 const AliTPCRow& krm=fSectors[sec][row0-iter];
3145 const AliTPCRow& krp=fSectors[sec][row0+iter];
3146 const AliTPCclusterMI * cl= kr0[is];
3148 if (cl->IsUsed(10)) {
3154 Double_t x = kr0.GetX();
3155 // Initialization of the polytrack
3160 Double_t y0= cl->GetY();
3161 Double_t z0= cl->GetZ();
3165 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3166 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3168 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3169 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3170 polytrack.AddPoint(x,y0,z0,erry, errz);
3173 if (cl->IsUsed(10)) sumused++;
3176 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3177 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3180 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3181 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3182 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3183 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3184 if (cl1->IsUsed(10)) sumused++;
3185 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3189 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3191 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3192 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3193 if (cl2->IsUsed(10)) sumused++;
3194 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3197 if (sumused>0) continue;
3199 polytrack.UpdateParameters();
3205 nfoundable = polytrack.GetN();
3206 nfound = nfoundable;
3208 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3209 Float_t maxdist = 0.8*(1.+3./(ddrow));
3210 for (Int_t delta = -1;delta<=1;delta+=2){
3211 Int_t row = row0+ddrow*delta;
3212 kr = &(fSectors[sec][row]);
3213 Double_t xn = kr->GetX();
3214 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3215 polytrack.GetFitPoint(xn,yn,zn);
3216 if (TMath::Abs(yn)>ymax) continue;
3218 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3220 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3223 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3224 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3225 if (cln->IsUsed(10)) {
3226 // printf("used\n");
3234 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3239 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3240 polytrack.UpdateParameters();
3243 if ( (sumused>3) || (sumused>0.5*nfound)) {
3244 //printf("sumused %d\n",sumused);
3249 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3250 AliTPCpolyTrack track2;
3252 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3253 if (track2.GetN()<0.5*nfoundable) continue;
3256 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3258 // test seed with and without constrain
3259 for (Int_t constrain=0; constrain<=0;constrain++){
3260 // add polytrack candidate
3262 Double_t x[5], c[15];
3263 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3264 track2.GetBoundaries(x3,x1);
3266 track2.GetFitPoint(x1,y1,z1);
3267 track2.GetFitPoint(x2,y2,z2);
3268 track2.GetFitPoint(x3,y3,z3);
3270 //is track pointing to the vertex ?
3273 polytrack.GetFitPoint(x0,y0,z0);
3286 x[4]=F1(x1,y1,x2,y2,x3,y3);
3288 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3289 x[2]=F2(x1,y1,x2,y2,x3,y3);
3291 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3292 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3293 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3294 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3297 Double_t sy =0.1, sz =0.1;
3298 Double_t sy1=0.02, sz1=0.02;
3299 Double_t sy2=0.02, sz2=0.02;
3303 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3306 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3307 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3308 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3309 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3310 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3311 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3313 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3314 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3315 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3316 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3321 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3322 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3323 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3324 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3325 c[13]=f30*sy1*f40+f32*sy2*f42;
3326 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3328 //Int_t row1 = fSectors->GetRowNumber(x1);
3329 Int_t row1 = GetRowNumber(x1);
3333 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3334 track->fIsSeeding = kTRUE;
3335 Int_t rc=FollowProlongation(*track, i2);
3336 if (constrain) track->fBConstrain =1;
3338 track->fBConstrain =0;
3339 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3340 track->fFirstPoint = track->fLastPoint;
3342 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3343 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3344 track->fNShared>0.4*track->GetNumberOfClusters()) {
3347 seed->~AliTPCseed();
3350 arr->AddLast(track);
3351 seed = new AliTPCseed;
3355 } // if accepted seed
3358 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3364 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3368 //reseed using track points
3369 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3370 Int_t p1 = int(r1*track->GetNumberOfClusters());
3371 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3373 Double_t x0[3],x1[3],x2[3];
3378 // find track position at given ratio of the length
3379 Int_t sec0, sec1, sec2;
3385 for (Int_t i=0;i<160;i++){
3386 if (track->fClusterPointer[i]){
3388 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3389 if ( (index<p0) || x0[0]<0 ){
3390 if (trpoint->GetX()>1){
3391 clindex = track->GetClusterIndex2(i);
3393 x0[0] = trpoint->GetX();
3394 x0[1] = trpoint->GetY();
3395 x0[2] = trpoint->GetZ();
3396 sec0 = ((clindex&0xff000000)>>24)%18;
3401 if ( (index<p1) &&(trpoint->GetX()>1)){
3402 clindex = track->GetClusterIndex2(i);
3404 x1[0] = trpoint->GetX();
3405 x1[1] = trpoint->GetY();
3406 x1[2] = trpoint->GetZ();
3407 sec1 = ((clindex&0xff000000)>>24)%18;
3410 if ( (index<p2) &&(trpoint->GetX()>1)){
3411 clindex = track->GetClusterIndex2(i);
3413 x2[0] = trpoint->GetX();
3414 x2[1] = trpoint->GetY();
3415 x2[2] = trpoint->GetZ();
3416 sec2 = ((clindex&0xff000000)>>24)%18;
3423 Double_t alpha, cs,sn, xx2,yy2;
3425 alpha = (sec1-sec2)*fSectors->GetAlpha();
3426 cs = TMath::Cos(alpha);
3427 sn = TMath::Sin(alpha);
3428 xx2= x1[0]*cs-x1[1]*sn;
3429 yy2= x1[0]*sn+x1[1]*cs;
3433 alpha = (sec0-sec2)*fSectors->GetAlpha();
3434 cs = TMath::Cos(alpha);
3435 sn = TMath::Sin(alpha);
3436 xx2= x0[0]*cs-x0[1]*sn;
3437 yy2= x0[0]*sn+x0[1]*cs;
3443 Double_t x[5],c[15];
3447 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3448 // if (x[4]>1) return 0;
3449 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3450 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3451 //if (TMath::Abs(x[3]) > 2.2) return 0;
3452 //if (TMath::Abs(x[2]) > 1.99) return 0;
3454 Double_t sy =0.1, sz =0.1;
3456 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3457 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3458 Double_t sy3=0.01+track->GetSigmaY2();
3460 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3461 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3462 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3463 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3464 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3465 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3467 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3468 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3469 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3470 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3475 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3476 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3477 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3478 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3479 c[13]=f30*sy1*f40+f32*sy2*f42;
3480 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3482 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3483 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3484 // Double_t y0,z0,y1,z1, y2,z2;
3485 //seed->GetProlongation(x0[0],y0,z0);
3486 // seed->GetProlongation(x1[0],y1,z1);
3487 //seed->GetProlongation(x2[0],y2,z2);
3489 seed->fLastPoint = pp2;
3490 seed->fFirstPoint = pp2;
3497 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3501 //reseed using founded clusters
3503 // Find the number of clusters
3504 Int_t nclusters = 0;
3505 for (Int_t irow=0;irow<160;irow++){
3506 if (track->GetClusterIndex(irow)>0) nclusters++;
3510 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3511 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3512 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3516 Int_t row[3],sec[3]={0,0,0};
3518 // find track row position at given ratio of the length
3520 for (Int_t irow=0;irow<160;irow++){
3521 if (track->GetClusterIndex2(irow)<0) continue;
3523 for (Int_t ipoint=0;ipoint<3;ipoint++){
3524 if (index<=ipos[ipoint]) row[ipoint] = irow;
3528 //Get cluster and sector position
3529 for (Int_t ipoint=0;ipoint<3;ipoint++){
3530 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3531 AliTPCclusterMI * cl = GetClusterMI(clindex);
3534 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3537 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3538 xyz[ipoint][0] = GetXrow(row[ipoint]);
3539 xyz[ipoint][1] = cl->GetY();
3540 xyz[ipoint][2] = cl->GetZ();
3544 // Calculate seed state vector and covariance matrix
3546 Double_t alpha, cs,sn, xx2,yy2;
3548 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3549 cs = TMath::Cos(alpha);
3550 sn = TMath::Sin(alpha);
3551 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3552 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3556 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3557 cs = TMath::Cos(alpha);
3558 sn = TMath::Sin(alpha);
3559 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3560 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3566 Double_t x[5],c[15];
3570 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3571 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3572 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3574 Double_t sy =0.1, sz =0.1;
3576 Double_t sy1=0.2, sz1=0.2;
3577 Double_t sy2=0.2, sz2=0.2;
3580 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;
3581 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;
3582 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;
3583 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;
3584 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;
3585 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;
3587 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;
3588 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;
3589 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;
3590 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;
3595 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3596 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3597 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3598 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3599 c[13]=f30*sy1*f40+f32*sy2*f42;
3600 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3602 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3603 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3604 seed->fLastPoint = row[2];
3605 seed->fFirstPoint = row[2];
3609 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3614 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3616 if (TMath::Abs(seed->GetC())>0.01) return 0;
3619 Float_t x[160], y[160], erry[160], z[160], errz[160];
3621 Float_t xt[160], yt[160], zt[160];
3626 Int_t middle = seed->GetNumberOfClusters()/2;
3629 // find central sector, get local cooordinates
3631 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3632 sec[i]= seed->GetClusterSector(i)%18;
3635 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3636 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3643 if (i>i2) i2 = i; //last point with cluster
3644 if (i2<i1) i1 = i; //first point with cluster
3647 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3649 yt[i] = point->GetY();
3650 zt[i] = point->GetZ();
3652 if (point->GetX()>0){
3653 erry[i] = point->GetErrY();
3654 errz[i] = point->GetErrZ();
3659 secm = sec[i]; //central sector
3660 padm = i; //middle point with cluster
3665 // rotate position to global coordinate system connected to sector at last the point
3667 for (Int_t i=i1;i<=i2;i++){
3669 if (sec[i]<0) continue;
3670 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3671 Double_t cs = TMath::Cos(alpha);
3672 Double_t sn = TMath::Sin(alpha);
3673 Float_t xx2= x[i]*cs+y[i]*sn;
3674 Float_t yy2= -x[i]*sn+y[i]*cs;
3678 xx2= xt[i]*cs+yt[i]*sn;
3679 yy2= -xt[i]*sn+yt[i]*cs;
3684 //get "state" vector
3685 Double_t xh[5],xm = x[padm];
3688 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3689 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3690 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3693 for (Int_t i=i1;i<=i2;i++){
3695 if (sec[i]<0) continue;
3696 GetProlongation(x[i2], x[i],xh,yy,zz);
3697 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3699 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3700 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3701 Error("AliTPCtrackerMI::CheckKinkPoint","problem\n");
3706 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3707 Float_t yup[160], ydown[160], zup[160], zdown[160];
3709 AliTPCpolyTrack ptrack1,ptrack2;
3712 for (Int_t i=i1;i<=i2;i++){
3713 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3715 if (cl->GetType()<0) continue;
3716 if (cl->GetType()>10) continue;
3719 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3721 if (ptrack1.GetN()>4.){
3722 ptrack1.UpdateParameters();
3724 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3726 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3735 dyup[i]=0.; //not enough points
3740 for (Int_t i=i2;i>=i1;i--){
3741 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3743 if (cl->GetType()<0) continue;
3744 if (cl->GetType()>10) continue;
3746 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3748 if (ptrack2.GetN()>4){
3749 ptrack2.UpdateParameters();
3751 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3753 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3761 dydown[i]=0.; //not enough points
3766 // find maximal difference of the derivation
3767 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3770 for (Int_t i=i1+10;i<i2-10;i++){
3771 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3772 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3774 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3775 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3776 if ( (ddy+ddz)> th){
3777 seed->fKinkPoint[0] = i;
3778 seed->fKinkPoint[1] = ddy;
3779 seed->fKinkPoint[2] = ddz;
3786 //write information to the debug tree
3787 TBranch * br = fTreeDebug->GetBranch("debug");
3788 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3789 arr->ExpandCreateFast(i2-i1);
3790 br->SetAddress(&arr);
3792 AliTPCclusterMI cldummy;
3794 AliTPCTrackPoint2 pdummy;
3795 pdummy.GetTPoint().fIsShared = 10;
3797 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3798 Double_t cs = TMath::Cos(alpha);
3799 Double_t sn = TMath::Sin(alpha);
3801 for (Int_t i=i1;i<i2;i++){
3802 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3804 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3806 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3809 Double_t x = GetXrow(i);
3810 trpoint->GetTPoint() = *point;
3811 trpoint->GetCPoint() = *cl0;
3812 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3813 trpoint->fID = seed->GetUniqueID();
3814 trpoint->fLab = seed->GetLabel();
3816 trpoint->fGX = cs *x + sn*point->GetY();
3817 trpoint->fGY = -sn *x + cs*point->GetY() ;
3818 trpoint->fGZ = point->GetZ();
3820 trpoint->fDY = y[i];
3821 trpoint->fDZ = z[i];
3823 trpoint->fDYU = dyup[i];
3824 trpoint->fDZU = dzup[i];
3826 trpoint->fDYD = dydown[i];
3827 trpoint->fDZD = dzdown[i];
3829 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3830 trpoint->fDDY = dydown[i]-dyup[i];
3831 trpoint->fDDZ = dzdown[i]-dzup[i];
3839 trpoint->GetCPoint()= cldummy;
3856 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3859 // reseed - refit - track
3862 // Int_t last = fSectors->GetNRows()-1;
3864 if (fSectors == fOuterSec){
3865 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3869 first = t->fFirstPoint;
3871 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3872 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3874 FollowProlongation(*t,first);
3884 //_____________________________________________________________________________
3885 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3886 //-----------------------------------------------------------------
3887 // This function reades track seeds.
3888 //-----------------------------------------------------------------
3889 TDirectory *savedir=gDirectory;
3891 TFile *in=(TFile*)inp;
3892 if (!in->IsOpen()) {
3893 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3898 TTree *seedTree=(TTree*)in->Get("Seeds");
3900 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3901 cerr<<"can't get a tree with track seeds !\n";
3904 AliTPCtrack *seed=new AliTPCtrack;
3905 seedTree->SetBranchAddress("tracks",&seed);
3907 if (fSeeds==0) fSeeds=new TObjArray(15000);
3909 Int_t n=(Int_t)seedTree->GetEntries();
3910 for (Int_t i=0; i<n; i++) {
3911 seedTree->GetEvent(i);
3912 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3921 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
3926 if (!fSeeds) return 1;
3933 //_____________________________________________________________________________
3934 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3935 //-----------------------------------------------------------------
3936 // This is a track finder.
3937 //-----------------------------------------------------------------
3938 TDirectory *savedir=gDirectory;
3942 fSeeds = Tracking();
3945 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
3947 //activate again some tracks
3948 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3949 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3951 Int_t nc=t.GetNumberOfClusters();
3953 delete fSeeds->RemoveAt(i);
3956 if (pt->fRemoval==10) {
3957 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3958 pt->Desactivate(10); // make track again active
3960 pt->Desactivate(20);
3961 delete fSeeds->RemoveAt(i);
3965 RemoveDouble(fSeeds,0.2,0.6,11);
3966 RemoveUsed(fSeeds,0.5,0.5,6);
3969 Int_t nseed=fSeeds->GetEntriesFast();
3971 for (Int_t i=0; i<nseed; i++) {
3972 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3974 Int_t nc=t.GetNumberOfClusters();
3976 delete fSeeds->RemoveAt(i);
3979 CookLabel(pt,0.1); //For comparison only
3980 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3981 if ((pt->IsActive() || (pt->fRemoval==10) )){
3982 cerr<<found++<<'\r';
3986 delete fSeeds->RemoveAt(i);
3990 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3992 //RemoveUsed(fSeeds,0.9,0.9,6);
3994 nseed=fSeeds->GetEntriesFast();
3996 for (Int_t i=0; i<nseed; i++) {
3997 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3999 Int_t nc=t.GetNumberOfClusters();
4001 delete fSeeds->RemoveAt(i);
4005 t.CookdEdx(0.02,0.6);
4006 // CheckKinkPoint(&t,0.05);
4007 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4008 if ((pt->IsActive() || (pt->fRemoval==10) )){
4016 delete fSeeds->RemoveAt(i);
4017 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
4019 // FollowProlongation(*seed1,0);
4020 // Int_t n = seed1->GetNumberOfClusters();
4021 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
4022 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
4025 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
4029 SortTracks(fSeeds, 1);
4033 PrepareForBackProlongation(fSeeds,5.);
4034 PropagateBack(fSeeds);
4035 printf("Time for back propagation: \t");timer.Print();timer.Start();
4039 PrepareForProlongation(fSeeds,5.);
4040 PropagateForward2(fSeeds);
4042 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
4043 // RemoveUsed(fSeeds,0.7,0.7,6);
4044 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
4046 nseed=fSeeds->GetEntriesFast();
4048 for (Int_t i=0; i<nseed; i++) {
4049 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4051 Int_t nc=t.GetNumberOfClusters();
4053 delete fSeeds->RemoveAt(i);
4056 t.CookdEdx(0.02,0.6);
4057 // CookLabel(pt,0.1); //For comparison only
4058 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4059 if ((pt->IsActive() || (pt->fRemoval==10) )){
4060 cerr<<found++<<'\r';
4063 delete fSeeds->RemoveAt(i);
4068 // fNTracks = found;
4070 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
4073 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
4074 Info("Clusters2Tracks","Number of found tracks %d",found);
4076 // UnloadClusters();
4081 void AliTPCtrackerMI::Tracking(TObjArray * arr)
4084 // tracking of the seeds
4087 fSectors = fOuterSec;
4088 ParallelTracking(arr,150,63);
4089 fSectors = fOuterSec;
4090 ParallelTracking(arr,63,0);
4093 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
4098 TObjArray * arr = new TObjArray;
4100 fSectors = fOuterSec;
4103 for (Int_t sec=0;sec<fkNOS;sec++){
4104 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
4105 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
4106 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
4109 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
4121 TObjArray * AliTPCtrackerMI::Tracking()
4127 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
4129 TObjArray * seeds = new TObjArray;
4138 Float_t fnumber = 3.0;
4139 Float_t fdensity = 3.0;
4144 for (Int_t delta = 0; delta<18; delta+=6){
4148 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
4149 SumTracks(seeds,arr);
4150 SignClusters(seeds,fnumber,fdensity);
4152 for (Int_t i=2;i<6;i+=2){
4153 // seed high pt tracks
4156 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
4157 SumTracks(seeds,arr);
4158 SignClusters(seeds,fnumber,fdensity);
4163 // RemoveUsed(seeds,0.9,0.9,1);
4164 // UnsignClusters();
4165 // SignClusters(seeds,fnumber,fdensity);
4169 for (Int_t delta = 20; delta<120; delta+=10){
4171 // seed high pt tracks
4175 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
4176 SumTracks(seeds,arr);
4177 SignClusters(seeds,fnumber,fdensity);
4182 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4183 SumTracks(seeds,arr);
4184 SignClusters(seeds,fnumber,fdensity);
4195 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4199 // RemoveUsed(seeds,0.75,0.75,1);
4201 //SignClusters(seeds,fnumber,fdensity);
4210 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4211 SumTracks(seeds,arr);
4212 SignClusters(seeds,fnumber,fdensity);
4214 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4215 SumTracks(seeds,arr);
4216 SignClusters(seeds,fnumber,fdensity);
4218 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4219 SumTracks(seeds,arr);
4220 SignClusters(seeds,fnumber,fdensity);
4224 for (Int_t delta = 3; delta<30; delta+=5){
4230 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4231 SumTracks(seeds,arr);
4232 SignClusters(seeds,fnumber,fdensity);
4234 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4235 SumTracks(seeds,arr);
4236 SignClusters(seeds,fnumber,fdensity);
4248 for (Int_t delta = 30; delta<70; delta+=10){
4254 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4255 SumTracks(seeds,arr);
4256 SignClusters(seeds,fnumber,fdensity);
4258 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4259 SumTracks(seeds,arr);
4260 SignClusters(seeds,fnumber,fdensity);
4264 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4275 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
4278 //sum tracks to common container
4279 //remove suspicious tracks
4280 Int_t nseed = arr2->GetEntriesFast();
4281 for (Int_t i=0;i<nseed;i++){
4282 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4285 // NORMAL ACTIVE TRACK
4286 if (pt->IsActive()){
4287 arr1->AddLast(arr2->RemoveAt(i));
4290 //remove not usable tracks
4291 if (pt->fRemoval!=10){
4292 delete arr2->RemoveAt(i);
4295 // REMOVE VERY SHORT TRACKS
4296 if (pt->GetNumberOfClusters()<20){
4297 delete arr2->RemoveAt(i);
4300 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4301 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4302 arr1->AddLast(arr2->RemoveAt(i));
4304 delete arr2->RemoveAt(i);
4313 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4316 // try to track in parralel
4318 Int_t nseed=arr->GetEntriesFast();
4319 //prepare seeds for tracking
4320 for (Int_t i=0; i<nseed; i++) {
4321 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4323 if (!t.IsActive()) continue;
4324 // follow prolongation to the first layer
4325 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4326 FollowProlongation(t, rfirst+1);
4331 for (Int_t nr=rfirst; nr>=rlast; nr--){
4332 if (nr<fInnerSec->GetNRows())
4333 fSectors = fInnerSec;
4335 fSectors = fOuterSec;
4336 // make indexes with the cluster tracks for given
4338 // find nearest cluster
4339 for (Int_t i=0; i<nseed; i++) {
4340 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4342 if (!pt->IsActive()) continue;
4343 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4344 if (pt->fRelativeSector>17) {
4347 UpdateClusters(t,nr);
4349 // prolonagate to the nearest cluster - if founded
4350 for (Int_t i=0; i<nseed; i++) {
4351 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4353 if (!pt->IsActive()) continue;
4354 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4355 if (pt->fRelativeSector>17) {
4358 FollowToNextCluster(*pt,nr);
4363 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
4367 // if we use TPC track itself we have to "update" covariance
4369 Int_t nseed= arr->GetEntriesFast();
4370 for (Int_t i=0;i<nseed;i++){
4371 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4375 //rotate to current local system at first accepted point
4376 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4377 Int_t sec = (index&0xff000000)>>24;
4379 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4380 if (angle1>TMath::Pi())
4381 angle1-=2.*TMath::Pi();
4382 Float_t angle2 = pt->GetAlpha();
4384 if (TMath::Abs(angle1-angle2)>0.001){
4385 pt->Rotate(angle1-angle2);
4386 //angle2 = pt->GetAlpha();
4387 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4388 //if (pt->GetAlpha()<0)
4389 // pt->fRelativeSector+=18;
4390 //sec = pt->fRelativeSector;
4399 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
4403 // if we use TPC track itself we have to "update" covariance
4405 Int_t nseed= arr->GetEntriesFast();
4406 for (Int_t i=0;i<nseed;i++){
4407 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4410 pt->fFirstPoint = pt->fLastPoint;
4418 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4421 // make back propagation
4423 Int_t nseed= arr->GetEntriesFast();
4424 for (Int_t i=0;i<nseed;i++){
4425 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4427 AliTPCseed *pt2 = new AliTPCseed(*pt);
4428 fSectors = fInnerSec;
4429 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
4430 //fSectors = fOuterSec;
4431 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4433 if (fDebug>1 && pt->GetNumberOfClusters()<20 && pt->GetLabel()>0 ){
4434 Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
4435 fSectors = fInnerSec;
4436 //FollowBackProlongation(*pt2,fInnerSec->GetNRows()-1);
4437 //fSectors = fOuterSec;
4438 FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4446 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4449 // make forward propagation
4451 Int_t nseed= arr->GetEntriesFast();
4452 for (Int_t i=0;i<nseed;i++){
4453 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4455 AliTPCseed *pt2 = new AliTPCseed(*pt);
4456 FollowProlongation(*pt,0);
4457 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4458 FollowProlongation(*pt2,0);
4467 Int_t AliTPCtrackerMI::PropagateForward()
4470 // propagate track forward
4472 Int_t nseed = fSeeds->GetEntriesFast();
4473 for (Int_t i=0;i<nseed;i++){
4474 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
4476 AliTPCseed &t = *pt;
4477 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
4478 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
4479 if (alpha < 0. ) alpha += 2.*TMath::Pi();
4480 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
4484 fSectors = fOuterSec;
4485 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
4486 fSectors = fInnerSec;
4487 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
4497 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4500 // make back propagation, in between row0 and row1
4504 fSectors = fInnerSec;
4507 if (row1<fSectors->GetNRows())
4510 r1 = fSectors->GetNRows()-1;
4512 if (row0<fSectors->GetNRows()&& r1>0 )
4513 FollowBackProlongation(*pt,r1);
4514 if (row1<=fSectors->GetNRows())
4517 r1 = row1 - fSectors->GetNRows();
4518 if (r1<=0) return 0;
4519 if (r1>=fOuterSec->GetNRows()) return 0;
4520 fSectors = fOuterSec;
4521 return FollowBackProlongation(*pt,r1);
4529 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4533 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4534 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4535 Float_t padlength = GetPadPitchLength(row);
4537 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4538 Float_t angulary = seed->GetSnp();
4539 angulary = angulary*angulary/(1-angulary*angulary);
4540 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4542 Float_t sresz = fParam->GetZSigma();
4543 Float_t angularz = seed->GetTgl();
4544 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4546 Float_t wy = GetSigmaY(seed);
4547 Float_t wz = GetSigmaZ(seed);
4550 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4551 printf("problem\n");
4557 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4561 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4562 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4563 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4564 Float_t angular = seed->GetSnp();
4565 angular = angular*angular/(1-angular*angular);
4566 // angular*=angular;
4567 //angular = TMath::Sqrt(angular/(1-angular));
4568 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4571 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4575 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4576 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4577 Float_t sres = fParam->GetZSigma();
4578 Float_t angular = seed->GetTgl();
4579 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4586 //__________________________________________________________________________
4587 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4588 //--------------------------------------------------------------------
4589 //This function "cooks" a track label. If label<0, this track is fake.
4590 //--------------------------------------------------------------------
4591 Int_t noc=t->GetNumberOfClusters();
4593 //printf("\nnot founded prolongation\n\n\n");
4599 AliTPCclusterMI *clusters[160];
4601 for (Int_t i=0;i<160;i++) {
4608 for (i=0; i<160 && current<noc; i++) {
4610 Int_t index=t->GetClusterIndex2(i);
4611 if (index<=0) continue;
4612 if (index&0x8000) continue;
4614 //clusters[current]=GetClusterMI(index);
4615 if (t->fClusterPointer[i]){
4616 clusters[current]=t->fClusterPointer[i];
4622 Int_t lab=123456789;
4623 for (i=0; i<noc; i++) {
4624 AliTPCclusterMI *c=clusters[i];
4626 lab=TMath::Abs(c->GetLabel(0));
4628 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4634 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4636 for (i=0; i<noc; i++) {
4637 AliTPCclusterMI *c=clusters[i];
4639 if (TMath::Abs(c->GetLabel(1)) == lab ||
4640 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4643 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4646 Int_t tail=Int_t(0.10*noc);
4649 for (i=1; i<=160&&ind<tail; i++) {
4650 // AliTPCclusterMI *c=clusters[noc-i];
4651 AliTPCclusterMI *c=clusters[i];
4653 if (lab == TMath::Abs(c->GetLabel(0)) ||
4654 lab == TMath::Abs(c->GetLabel(1)) ||
4655 lab == TMath::Abs(c->GetLabel(2))) max++;
4658 if (max < Int_t(0.5*tail)) lab=-lab;
4665 //delete[] clusters;
4669 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
4671 //return pad row number for this x
4674 r=fRow[fN-1].GetX();
4675 if (x > r) return fN;
4677 if (x < r) return -1;
4678 return Int_t((x-r)/fPadPitchLength + 0.5);}
4680 r=fRow[fN-1].GetX();
4681 if (x > r) return fN;
4683 if (x < r) return -1;
4684 Double_t r1=fRow[64].GetX();
4686 return Int_t((x-r)/f1PadPitchLength + 0.5);}
4688 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
4692 //_________________________________________________________________________
4693 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4694 //-----------------------------------------------------------------------
4695 // Setup inner sector
4696 //-----------------------------------------------------------------------
4698 fAlpha=par->GetInnerAngle();
4699 fAlphaShift=par->GetInnerAngleShift();
4700 fPadPitchWidth=par->GetInnerPadPitchWidth();
4701 fPadPitchLength=par->GetInnerPadPitchLength();
4702 fN=par->GetNRowLow();
4703 fRow=new AliTPCRow[fN];
4704 for (Int_t i=0; i<fN; i++) {
4705 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4706 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4709 fAlpha=par->GetOuterAngle();
4710 fAlphaShift=par->GetOuterAngleShift();
4711 fPadPitchWidth = par->GetOuterPadPitchWidth();
4712 fPadPitchLength = par->GetOuter1PadPitchLength();
4713 f1PadPitchLength = par->GetOuter1PadPitchLength();
4714 f2PadPitchLength = par->GetOuter2PadPitchLength();
4716 fN=par->GetNRowUp();
4717 fRow=new AliTPCRow[fN];
4718 for (Int_t i=0; i<fN; i++) {
4719 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4720 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4725 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
4727 // default constructor
4735 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4742 //_________________________________________________________________________
4744 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4745 //-----------------------------------------------------------------------
4746 // Insert a cluster into this pad row in accordence with its y-coordinate
4747 //-----------------------------------------------------------------------
4748 if (fN==kMaxClusterPerRow) {
4749 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4751 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4752 Int_t i=Find(c->GetZ());
4753 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4754 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4755 fIndex[i]=index; fClusters[i]=c; fN++;
4758 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
4764 //delete[] fClusterArray;
4765 if (fClusters1) delete []fClusters1;
4766 if (fClusters2) delete []fClusters2;
4773 //___________________________________________________________________
4774 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4775 //-----------------------------------------------------------------------
4776 // Return the index of the nearest cluster
4777 //-----------------------------------------------------------------------
4778 if (fN==0) return 0;
4779 if (z <= fClusters[0]->GetZ()) return 0;
4780 if (z > fClusters[fN-1]->GetZ()) return fN;
4781 Int_t b=0, e=fN-1, m=(b+e)/2;
4782 for (; b<e; m=(b+e)/2) {
4783 if (z > fClusters[m]->GetZ()) b=m+1;
4791 //___________________________________________________________________
4792 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4793 //-----------------------------------------------------------------------
4794 // Return the index of the nearest cluster in z y
4795 //-----------------------------------------------------------------------
4796 Float_t maxdistance = roady*roady + roadz*roadz;
4798 AliTPCclusterMI *cl =0;
4799 for (Int_t i=Find(z-roadz); i<fN; i++) {
4800 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4801 if (c->GetZ() > z+roadz) break;
4802 if ( (c->GetY()-y) > roady ) continue;
4803 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4804 if (maxdistance>distance) {
4805 maxdistance = distance;
4812 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4814 //-----------------------------------------------------------------------
4815 // Return the index of the nearest cluster in z y
4816 //-----------------------------------------------------------------------
4817 Float_t maxdistance = roady*roady + roadz*roadz;
4818 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4819 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4821 AliTPCclusterMI *cl =0;
4822 //FindNearest3(y,z,roady,roadz,index);
4823 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4824 for (Int_t i=iz1; i<iz2; i++) {
4825 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4826 if (c->GetZ() > z+roadz) break;
4827 if ( c->GetY()-y > roady ) continue;
4828 if ( y-c->GetY() > roady ) continue;
4829 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4830 if (maxdistance>distance) {
4831 maxdistance = distance;
4834 //roady = TMath::Sqrt(maxdistance);
4842 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4844 //-----------------------------------------------------------------------
4845 // Return the index of the nearest cluster in z y
4846 //-----------------------------------------------------------------------
4847 Float_t maxdistance = roady*roady + roadz*roadz;
4848 // Int_t iz = Int_t(z+255.);
4849 AliTPCclusterMI *cl =0;
4850 for (Int_t i=Find(z-roadz); i<fN; i++) {
4851 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4852 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4853 if (c->GetZ() > z+roadz) break;
4854 if ( c->GetY()-y > roady ) continue;
4855 if ( y-c->GetY() > roady ) continue;
4856 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4857 if (maxdistance>distance) {
4858 maxdistance = distance;
4861 //roady = TMath::Sqrt(maxdistance);
4870 AliTPCseed::AliTPCseed():AliTPCtrack(){
4874 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4875 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4891 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4900 for (Int_t i=0;i<160;i++) {
4901 fClusterPointer[i] = 0;
4902 Int_t index = t.GetClusterIndex(i);
4904 SetClusterIndex2(i,index);
4907 SetClusterIndex2(i,-3);
4919 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4923 for (Int_t i=0;i<160;i++) {
4924 fClusterPointer[i] = 0;
4925 Int_t index = t.GetClusterIndex(i);
4926 SetClusterIndex2(i,index);
4944 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4945 Double_t xr, Double_t alpha):
4946 AliTPCtrack(index, xx, cc, xr, alpha) {
4951 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4952 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4961 // fHelixIn = new TClonesArray("AliHelix",0);
4962 //fHelixOut = new TClonesArray("AliHelix",0);
4971 AliTPCseed::~AliTPCseed(){
4974 if (fPoints) delete fPoints;
4976 if (fEPoints) delete fEPoints;
4981 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4985 return &fTrackPoints[i];
4988 void AliTPCseed::RebuildSeed()
4991 // rebuild seed to be ready for storing
4992 AliTPCclusterMI cldummy;
4994 AliTPCTrackPoint pdummy;
4995 pdummy.GetTPoint().fIsShared = 10;
4996 for (Int_t i=0;i<160;i++){
4997 AliTPCclusterMI * cl0 = fClusterPointer[i];
4998 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
5000 trpoint->GetTPoint() = *(GetTrackPoint(i));
5001 trpoint->GetCPoint() = *cl0;
5002 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
5006 trpoint->GetCPoint()= cldummy;
5014 Double_t AliTPCseed::GetDensityFirst(Int_t n)
5018 // return cluster for n rows bellow first point
5019 Int_t nfoundable = 1;
5021 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
5022 Int_t index = GetClusterIndex2(i);
5023 if (index!=-1) nfoundable++;
5024 if (index>0) nfound++;
5026 if (nfoundable<n) return 0;
5027 return Double_t(nfound)/Double_t(nfoundable);
5032 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
5034 // get cluster stat. on given region
5039 for (Int_t i=first;i<last; i++){
5040 Int_t index = GetClusterIndex2(i);
5041 if (index!=-1) foundable++;
5042 if (fClusterPointer[i]) {
5048 if (fClusterPointer[i]->IsUsed(10)) {
5052 if (!plus2) continue; //take also neighborhoud
5054 if ( (i>0) && fClusterPointer[i-1]){
5055 if (fClusterPointer[i-1]->IsUsed(10)) {
5060 if ( fClusterPointer[i+1]){
5061 if (fClusterPointer[i+1]->IsUsed(10)) {
5068 //if (shared>found){
5069 //Error("AliTPCseed::GetClusterStatistic","problem\n");
5073 //_____________________________________________________________________________
5074 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
5075 //-----------------------------------------------------------------
5076 // This funtion calculates dE/dX within the "low" and "up" cuts.
5077 //-----------------------------------------------------------------
5080 Float_t angular[200];
5081 Float_t weight[200];
5084 // TClonesArray & arr = *fPoints;
5085 Float_t meanlog = 100.;
5087 Float_t mean[4] = {0,0,0,0};
5088 Float_t sigma[4] = {1000,1000,1000,1000};
5089 Int_t nc[4] = {0,0,0,0};
5090 Float_t norm[4] = {1000,1000,1000,1000};
5095 for (Int_t of =0; of<4; of++){
5096 for (Int_t i=of+i1;i<i2;i+=4)
5098 Int_t index = fIndex[i];
5099 if (index<0||index&0x8000) continue;
5101 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
5102 AliTPCTrackerPoint * point = GetTrackPoint(i);
5103 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
5104 //AliTPCTrackerPoint * pointp = 0;
5105 //if (i<159) pointp = GetTrackPoint(i+1);
5107 if (point==0) continue;
5108 AliTPCclusterMI * cl = fClusterPointer[i];
5109 if (cl==0) continue;
5110 if (onlyused && (!cl->IsUsed(10))) continue;
5111 if (cl->IsUsed(11)) {
5115 Int_t type = cl->GetType();
5116 //if (point->fIsShared){
5121 // if (pointm->fIsShared) continue;
5123 // if (pointp->fIsShared) continue;
5125 if (type<0) continue;
5126 //if (type>10) continue;
5127 //if (point->GetErrY()==0) continue;
5128 //if (point->GetErrZ()==0) continue;
5130 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
5131 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
5132 //if ((ddy*ddy+ddz*ddz)>10) continue;
5135 // if (point->GetCPoint().GetMax()<5) continue;
5136 if (cl->GetMax()<5) continue;
5137 Float_t angley = point->GetAngleY();
5138 Float_t anglez = point->GetAngleZ();
5140 Float_t rsigmay2 = point->GetSigmaY();
5141 Float_t rsigmaz2 = point->GetSigmaZ();
5145 rsigmay += pointm->GetTPoint().GetSigmaY();
5146 rsigmaz += pointm->GetTPoint().GetSigmaZ();
5150 rsigmay += pointp->GetTPoint().GetSigmaY();
5151 rsigmaz += pointp->GetTPoint().GetSigmaZ();
5158 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
5160 Float_t ampc = 0; // normalization to the number of electrons
5162 // ampc = 1.*point->GetCPoint().GetMax();
5163 ampc = 1.*cl->GetMax();
5164 //ampc = 1.*point->GetCPoint().GetQ();
5165 // AliTPCClusterPoint & p = point->GetCPoint();
5166 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
5167 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5169 // TMath::Abs( Int_t(iz) - iz + 0.5);
5170 //ampc *= 1.15*(1-0.3*dy);
5171 //ampc *= 1.15*(1-0.3*dz);
5172 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
5176 //ampc = 1.0*point->GetCPoint().GetMax();
5177 ampc = 1.0*cl->GetMax();
5178 //ampc = 1.0*point->GetCPoint().GetQ();
5179 //AliTPCClusterPoint & p = point->GetCPoint();
5180 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
5181 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5183 // TMath::Abs( Int_t(iz) - iz + 0.5);
5185 //ampc *= 1.15*(1-0.3*dy);
5186 //ampc *= 1.15*(1-0.3*dz);
5187 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
5191 ampc *= 2.0; // put mean value to channel 50
5192 //ampc *= 0.58; // put mean value to channel 50
5194 // if (type>0) w = 1./(type/2.-0.5);
5195 // Float_t z = TMath::Abs(cl->GetZ());
5198 //ampc /= (1+0.0008*z);
5202 //ampc /= (1+0.0008*z);
5204 //ampc /= (1+0.0008*z);
5207 if (type<0) { //amp at the border - lower weight
5212 if (rsigma>1.5) ampc/=1.3; // if big backround
5214 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5219 TMath::Sort(nc[of],amp,index,kFALSE);
5223 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
5225 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5226 Float_t ampl = amp[index[i]]/angular[index[i]];
5227 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5229 sumw += weight[index[i]];
5230 sumamp += weight[index[i]]*ampl;
5231 sumamp2 += weight[index[i]]*ampl*ampl;
5232 norm[of] += angular[index[i]]*weight[index[i]];
5239 mean[of] = sumamp/sumw;
5240 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5242 sigma[of] = TMath::Sqrt(sigma[of]);
5246 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5247 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5248 //mean *=(1-0.1*(norm-1.));
5255 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
5256 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
5259 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
5260 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
5264 for (Int_t i =0;i<4;i++){
5265 if (nc[i]>2&&nc[i]<1000){
5266 dedx += mean[i] *nc[i];
5267 fSdEdx += sigma[i]*(nc[i]-2);
5268 fMAngular += norm[i] *nc[i];
5273 fSDEDX[i] = sigma[i];
5286 // Float_t dedx1 =dedx;
5289 for (Int_t i =0;i<4;i++){
5290 if (nc[i]>2&&nc[i]<1000){
5291 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5292 dedx += mean[i] *nc[i];
5307 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5310 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5311 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5312 SetMass(0.93827); return;
5316 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5317 SetMass(0.93827); return;
5320 SetMass(0.13957); return;
5330 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5331 //-----------------------------------------------------------------
5332 // This funtion calculates dE/dX within the "low" and "up" cuts.
5333 //-----------------------------------------------------------------
5336 Float_t angular[200];
5337 Float_t weight[200];
5339 Bool_t inlimit[200];
5340 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5341 for (Int_t i=0;i<200;i++) amp[i]=10000;
5342 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5346 Float_t meanlog = 100.;
5347 Int_t indexde[4]={0,64,128,160};
5354 Float_t mean[4] = {0,0,0,0};
5355 Float_t sigma[4] = {1000,1000,1000,1000};
5356 Int_t nc[4] = {0,0,0,0};
5357 Float_t norm[4] = {1000,1000,1000,1000};
5362 // for (Int_t of =0; of<3; of++){
5363 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5364 for (Int_t i =0; i<160;i++)
5366 AliTPCTrackPoint * point = GetTrackPoint(i);
5367 if (point==0) continue;
5368 if (point->fIsShared){
5372 Int_t type = point->GetCPoint().GetType();
5373 if (type<0) continue;
5374 if (point->GetCPoint().GetMax()<5) continue;
5375 Float_t angley = point->GetTPoint().GetAngleY();
5376 Float_t anglez = point->GetTPoint().GetAngleZ();
5377 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5378 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5379 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5381 Float_t ampc = 0; // normalization to the number of electrons
5383 ampc = point->GetCPoint().GetMax();
5386 ampc = point->GetCPoint().GetMax();
5388 ampc *= 2.0; // put mean value to channel 50
5389 // ampc *= 0.565; // put mean value to channel 50
5392 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5399 if (type<0) { //amp at the border - lower weight
5402 if (rsigma>1.5) ampc/=1.3; // if big backround
5403 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5404 amp[i] = ampc/angular[i];
5409 TMath::Sort(159,amp,index,kFALSE);
5410 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5411 inlimit[index[i]] = kTRUE; // take all clusters
5414 // meanlog = amp[index[Int_t(anc*0.3)]];
5416 for (Int_t of =0; of<3; of++){
5420 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5422 if (inlimit[i]==kFALSE) continue;
5423 Float_t ampl = amp[i];
5425 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5428 sumamp += weight[i]*ampl;
5429 sumamp2 += weight[i]*ampl*ampl;
5430 norm[of] += angular[i]*weight[i];
5438 mean[of] = sumamp/sumw;
5439 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5441 sigma[of] = TMath::Sqrt(sigma[of]);
5444 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5454 Float_t www[3] = {12.,14.,17.};
5455 //Float_t www[3] = {1.,1.,1.};
5457 for (Int_t i =0;i<3;i++){
5458 if (nc[i]>2&&nc[i]<1000){
5459 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5460 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5461 fMAngular += norm[i] *nc[i];
5462 norm2 += nc[i]*www[i]/sigma[i];
5463 norm3 += (nc[i]-2)*www[i]/sigma[i];
5466 fSDEDX[i] = sigma[i];
5479 // Float_t dedx1 =dedx;
5483 for (Int_t i =0;i<3;i++){
5484 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5485 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5486 dedx += mean[i] *(nc[i])/(sigma[i]);
5487 norm4 += (nc[i])/(sigma[i]);
5491 if (norm4>0) dedx /= norm4;