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);
392 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
393 TBranch * br = fOutput->GetBranch("tracks");
394 br->SetAddress(&iotrack);
396 for (Int_t i=0; i<nseed; i++) {
397 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
401 // br->SetAddress(&iotrack);
405 fOutput->GetDirectory()->cd();
411 //write the full seed information if specified in debug mode
413 AliTPCseed * vseed = new AliTPCseed;
415 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
416 arrtr->ExpandCreateFast(160);
417 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
418 //arrcl->ExpandCreateFast(160);
419 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
421 vseed->fPoints = arrtr;
422 vseed->fEPoints = arre;
423 // vseed->fClusterPoints = arrcl;
424 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
425 TBranch * brseed = fSeedTree->GetBranch("seeds");
427 Int_t nseed=fSeeds->GetEntriesFast();
429 for (Int_t i=0; i<nseed; i++) {
430 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
433 // pt->fClusterPoints = arrcl;
437 brseed->SetAddress(&vseed);
441 // pt->fClusterPoints = 0;
444 if (fTreeDebug) fTreeDebug->Write();
452 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
455 //seed->SetErrorY2(0.1);
457 //calculate look-up table at the beginning
458 static Bool_t ginit = kFALSE;
459 static Float_t gnoise1,gnoise2,gnoise3;
460 static Float_t ggg1[10000];
461 static Float_t ggg2[10000];
462 static Float_t ggg3[10000];
463 static Float_t glandau1[10000];
464 static Float_t glandau2[10000];
465 static Float_t glandau3[10000];
467 static Float_t gcor01[500];
468 static Float_t gcor02[500];
469 static Float_t gcorp[500];
474 for (Int_t i=1;i<500;i++){
475 Float_t rsigma = float(i)/100.;
476 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
477 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
478 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
482 for (Int_t i=3;i<10000;i++){
486 Float_t amp = float(i);
487 Float_t padlength =0.75;
488 gnoise1 = 0.0004/padlength;
489 Float_t nel = 0.268*amp;
490 Float_t nprim = 0.155*amp;
491 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
492 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
493 if (glandau1[i]>1) glandau1[i]=1;
494 glandau1[i]*=padlength*padlength/12.;
498 gnoise2 = 0.0004/padlength;
501 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
502 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
503 if (glandau2[i]>1) glandau2[i]=1;
504 glandau2[i]*=padlength*padlength/12.;
509 gnoise3 = 0.0004/padlength;
512 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
513 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
514 if (glandau3[i]>1) glandau3[i]=1;
515 glandau3[i]*=padlength*padlength/12.;
523 Int_t amp = int(TMath::Abs(cl->GetQ()));
525 seed->SetErrorY2(1.);
529 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
530 Int_t ctype = cl->GetType();
531 Float_t padlength= GetPadPitchLength(seed->fRow);
532 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
533 angle2 = angle2/(1-angle2);
536 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
539 if (fSectors==fInnerSec){
541 res = ggg1[amp]*z+glandau1[amp]*angle2;
542 if (ctype==0) res *= gcor01[rsigmay];
545 res*= gcorp[rsigmay];
551 res = ggg2[amp]*z+glandau2[amp]*angle2;
552 if (ctype==0) res *= gcor02[rsigmay];
555 res*= gcorp[rsigmay];
560 res = ggg3[amp]*z+glandau3[amp]*angle2;
561 if (ctype==0) res *= gcor02[rsigmay];
564 res*= gcorp[rsigmay];
571 res*=2.4; // overestimate error 2 times
578 seed->SetErrorY2(res);
586 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
589 //seed->SetErrorY2(0.1);
591 //calculate look-up table at the beginning
592 static Bool_t ginit = kFALSE;
593 static Float_t gnoise1,gnoise2,gnoise3;
594 static Float_t ggg1[10000];
595 static Float_t ggg2[10000];
596 static Float_t ggg3[10000];
597 static Float_t glandau1[10000];
598 static Float_t glandau2[10000];
599 static Float_t glandau3[10000];
601 static Float_t gcor01[1000];
602 static Float_t gcor02[1000];
603 static Float_t gcorp[1000];
608 for (Int_t i=1;i<1000;i++){
609 Float_t rsigma = float(i)/100.;
610 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
611 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
612 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
616 for (Int_t i=3;i<10000;i++){
620 Float_t amp = float(i);
621 Float_t padlength =0.75;
622 gnoise1 = 0.0004/padlength;
623 Float_t nel = 0.268*amp;
624 Float_t nprim = 0.155*amp;
625 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
626 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
627 if (glandau1[i]>1) glandau1[i]=1;
628 glandau1[i]*=padlength*padlength/12.;
632 gnoise2 = 0.0004/padlength;
635 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
636 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
637 if (glandau2[i]>1) glandau2[i]=1;
638 glandau2[i]*=padlength*padlength/12.;
643 gnoise3 = 0.0004/padlength;
646 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
647 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
648 if (glandau3[i]>1) glandau3[i]=1;
649 glandau3[i]*=padlength*padlength/12.;
657 Int_t amp = int(TMath::Abs(cl->GetQ()));
659 seed->SetErrorY2(1.);
663 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
664 Int_t ctype = cl->GetType();
665 Float_t padlength= GetPadPitchLength(seed->fRow);
667 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
668 // if (angle2<0.6) angle2 = 0.6;
669 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
672 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
675 if (fSectors==fInnerSec){
677 res = ggg1[amp]*z+glandau1[amp]*angle2;
678 if (ctype==0) res *= gcor01[rsigmaz];
681 res*= gcorp[rsigmaz];
687 res = ggg2[amp]*z+glandau2[amp]*angle2;
688 if (ctype==0) res *= gcor02[rsigmaz];
691 res*= gcorp[rsigmaz];
696 res = ggg3[amp]*z+glandau3[amp]*angle2;
697 if (ctype==0) res *= gcor02[rsigmaz];
700 res*= gcorp[rsigmaz];
709 if ((ctype<0) &&<70){
717 seed->SetErrorZ2(res);
724 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
727 //seed->SetErrorZ2(0.1);
731 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
733 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
734 Int_t ctype = cl->GetType();
735 Float_t amp = TMath::Abs(cl->GetQ());
740 Float_t landau=2 ; //landau fluctuation part
741 Float_t gg=2; // gg fluctuation part
742 Float_t padlength= GetPadPitchLength(seed->GetX());
744 if (fSectors==fInnerSec){
745 snoise2 = 0.0004/padlength;
748 gg = (2+0.001*nel/(padlength*padlength))/nel;
749 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
750 if (landau>1) landau=1;
753 snoise2 = 0.0004/padlength;
756 gg = (2+0.0008*nel/(padlength*padlength))/nel;
757 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
758 if (landau>1) landau=1;
760 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
763 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
764 angle2 = TMath::Sqrt((1-angle2));
765 if (angle2<0.6) angle2 = 0.6;
768 Float_t angle = seed->GetTgl()/angle2;
769 Float_t angular = landau*angle*angle*padlength*padlength/12.;
770 Float_t res = sdiff + angular;
773 if ((ctype==0) && (fSectors ==fOuterSec))
774 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
776 if ((ctype==0) && (fSectors ==fInnerSec))
777 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
781 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
787 if ((ctype<0) &&<70){
795 seed->SetErrorZ2(res);
802 void AliTPCseed::Reset(Bool_t all)
806 SetNumberOfClusters(0);
812 for (Int_t i=0;i<8;i++){
813 delete [] fTrackPoints[i];
821 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
822 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
828 void AliTPCseed::Modify(Double_t factor)
831 //------------------------------------------------------------------
832 //This function makes a track forget its history :)
833 //------------------------------------------------------------------
839 fC10*=factor; fC11*=factor;
840 fC20*=factor; fC21*=factor; fC22*=factor;
841 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
842 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
843 SetNumberOfClusters(0);
847 fCurrentSigmaY2 = 0.000005;
848 fCurrentSigmaZ2 = 0.000005;
857 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
859 //-----------------------------------------------------------------
860 // This function find proloncation of a track to a reference plane x=xk.
861 // doesn't change internal state of the track
862 //-----------------------------------------------------------------
864 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
866 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
870 // Double_t y1=fP0, z1=fP1;
871 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
872 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
876 //y += dx*(c1+c2)/(r1+r2);
877 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
879 Double_t dy = dx*(c1+c2)/(r1+r2);
882 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
884 if (TMath::Abs(delta)>0.0001){
885 dz = fP3*TMath::ASin(delta)/fP4;
887 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
890 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
900 //_____________________________________________________________________________
901 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
903 //-----------------------------------------------------------------
904 // This function calculates a predicted chi2 increment.
905 //-----------------------------------------------------------------
906 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
907 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
908 r00+=fC00; r01+=fC10; r11+=fC11;
910 Double_t det=r00*r11 - r01*r01;
911 if (TMath::Abs(det) < 1.e-10) {
912 Int_t n=GetNumberOfClusters();
913 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
916 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
918 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
920 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
924 //_________________________________________________________________________________________
927 Int_t AliTPCseed::Compare(const TObject *o) const {
928 //-----------------------------------------------------------------
929 // This function compares tracks according to the sector - for given sector according z
930 //-----------------------------------------------------------------
931 AliTPCseed *t=(AliTPCseed*)o;
934 if (t->fRelativeSector>fRelativeSector) return -1;
935 if (t->fRelativeSector<fRelativeSector) return 1;
936 Double_t z2 = t->GetZ();
937 Double_t z1 = GetZ();
939 if (z2<z1) return -1;
944 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
945 if (t->fBConstrain) f2=1.2;
948 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
950 if (fBConstrain) f1=1.2;
952 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
957 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
959 //rotate to track "local coordinata
960 Float_t x = seed->GetX();
961 Float_t y = seed->GetY();
962 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
965 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
966 if (!seed->Rotate(fSectors->GetAlpha()))
968 } else if (y <-ymax) {
969 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
970 if (!seed->Rotate(-fSectors->GetAlpha()))
979 //_____________________________________________________________________________
980 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
981 //-----------------------------------------------------------------
982 // This function associates a cluster with this track.
983 //-----------------------------------------------------------------
984 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
986 r00+=fC00; r01+=fC10; r11+=fC11;
987 Double_t det=r00*r11 - r01*r01;
988 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
990 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
991 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
992 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
993 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
994 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
996 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
997 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
998 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1002 fP0 += k00*dy + k01*dz;
1003 fP1 += k10*dy + k11*dz;
1005 fP3 += k30*dy + k31*dz;
1008 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1009 Double_t c12=fC21, c13=fC31, c14=fC41;
1011 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1012 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1013 fC40-=k00*c04+k01*c14;
1015 fC11-=k10*c01+k11*fC11;
1016 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1017 fC41-=k10*c04+k11*c14;
1019 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1020 fC42-=k20*c04+k21*c14;
1022 fC33-=k30*c03+k31*c13;
1023 fC43-=k40*c03+k41*c13;
1025 fC44-=k40*c04+k41*c14;
1027 Int_t n=GetNumberOfClusters();
1029 SetNumberOfClusters(n+1);
1030 SetChi2(GetChi2()+chisq);
1037 //_____________________________________________________________________________
1038 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1039 Double_t x2,Double_t y2,
1040 Double_t x3,Double_t y3)
1042 //-----------------------------------------------------------------
1043 // Initial approximation of the track curvature
1044 //-----------------------------------------------------------------
1045 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1046 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1047 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1048 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1049 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1051 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1052 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1053 return -xr*yr/sqrt(xr*xr+yr*yr);
1058 //_____________________________________________________________________________
1059 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1060 Double_t x2,Double_t y2,
1061 Double_t x3,Double_t y3)
1063 //-----------------------------------------------------------------
1064 // Initial approximation of the track curvature
1065 //-----------------------------------------------------------------
1071 Double_t det = x3*y2-x2*y3;
1076 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1077 Double_t x0 = x3*0.5-y3*u;
1078 Double_t y0 = y3*0.5+x3*u;
1079 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1085 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1086 Double_t x2,Double_t y2,
1087 Double_t x3,Double_t y3)
1089 //-----------------------------------------------------------------
1090 // Initial approximation of the track curvature
1091 //-----------------------------------------------------------------
1097 Double_t det = x3*y2-x2*y3;
1102 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1103 Double_t x0 = x3*0.5-y3*u;
1104 Double_t y0 = y3*0.5+x3*u;
1105 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1114 //_____________________________________________________________________________
1115 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1116 Double_t x2,Double_t y2,
1117 Double_t x3,Double_t y3)
1119 //-----------------------------------------------------------------
1120 // Initial approximation of the track curvature times center of curvature
1121 //-----------------------------------------------------------------
1122 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1123 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1124 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1125 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1126 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1128 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1130 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1133 //_____________________________________________________________________________
1134 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1135 Double_t x2,Double_t y2,
1136 Double_t z1,Double_t z2)
1138 //-----------------------------------------------------------------
1139 // Initial approximation of the tangent of the track dip angle
1140 //-----------------------------------------------------------------
1141 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1145 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1146 Double_t x2,Double_t y2,
1147 Double_t z1,Double_t z2, Double_t c)
1149 //-----------------------------------------------------------------
1150 // Initial approximation of the tangent of the track dip angle
1151 //-----------------------------------------------------------------
1155 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1157 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1158 if (TMath::Abs(d*c*0.5)>1) return 0;
1159 // Double_t angle2 = TMath::ASin(d*c*0.5);
1160 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1161 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1163 angle2 = (z1-z2)*c/(angle2*2.);
1167 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1168 {//-----------------------------------------------------------------
1169 // This function find proloncation of a track to a reference plane x=x2.
1170 //-----------------------------------------------------------------
1174 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1178 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1179 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1183 Double_t dy = dx*(c1+c2)/(r1+r2);
1186 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1188 if (TMath::Abs(delta)>0.01){
1189 dz = x[3]*TMath::ASin(delta)/x[4];
1191 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1194 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1202 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1207 return LoadClusters();
1210 Int_t AliTPCtrackerMI::LoadClusters()
1213 // load clusters to the memory
1214 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1215 clrow->SetClass("AliTPCclusterMI");
1217 clrow->GetArray()->ExpandCreateFast(10000);
1219 // TTree * tree = fClustersArray.GetTree();
1221 TTree * tree = fInput;
1222 TBranch * br = tree->GetBranch("Segment");
1223 br->SetAddress(&clrow);
1225 Int_t j=Int_t(tree->GetEntries());
1226 for (Int_t i=0; i<j; i++) {
1230 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1232 AliTPCRow * tpcrow=0;
1235 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1239 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1240 left = (sec-fkNIS*2)/fkNOS;
1243 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1244 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1245 for (Int_t i=0;i<tpcrow->fN1;i++)
1246 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1249 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1250 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1251 for (Int_t i=0;i<tpcrow->fN2;i++)
1252 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1263 void AliTPCtrackerMI::UnloadClusters()
1266 // unload clusters from the memory
1268 Int_t nrows = fOuterSec->GetNRows();
1269 for (Int_t sec = 0;sec<fkNOS;sec++)
1270 for (Int_t row = 0;row<nrows;row++){
1271 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1273 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1274 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1278 nrows = fInnerSec->GetNRows();
1279 for (Int_t sec = 0;sec<fkNIS;sec++)
1280 for (Int_t row = 0;row<nrows;row++){
1281 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1283 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1284 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1292 //_____________________________________________________________________________
1293 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1294 //-----------------------------------------------------------------
1295 // This function fills outer TPC sectors with clusters.
1296 //-----------------------------------------------------------------
1297 Int_t nrows = fOuterSec->GetNRows();
1299 for (Int_t sec = 0;sec<fkNOS;sec++)
1300 for (Int_t row = 0;row<nrows;row++){
1301 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1302 Int_t sec2 = sec+2*fkNIS;
1304 Int_t ncl = tpcrow->fN1;
1306 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1307 index=(((sec2<<8)+row)<<16)+ncl;
1308 tpcrow->InsertCluster(c,index);
1313 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1314 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1315 tpcrow->InsertCluster(c,index);
1318 // write indexes for fast acces
1320 for (Int_t i=0;i<510;i++)
1321 tpcrow->fFastCluster[i]=-1;
1322 for (Int_t i=0;i<tpcrow->GetN();i++){
1323 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1324 tpcrow->fFastCluster[zi]=i; // write index
1327 for (Int_t i=0;i<510;i++){
1328 if (tpcrow->fFastCluster[i]<0)
1329 tpcrow->fFastCluster[i] = last;
1331 last = tpcrow->fFastCluster[i];
1340 //_____________________________________________________________________________
1341 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1342 //-----------------------------------------------------------------
1343 // This function fills inner TPC sectors with clusters.
1344 //-----------------------------------------------------------------
1345 Int_t nrows = fInnerSec->GetNRows();
1347 for (Int_t sec = 0;sec<fkNIS;sec++)
1348 for (Int_t row = 0;row<nrows;row++){
1349 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1352 Int_t ncl = tpcrow->fN1;
1354 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1355 index=(((sec<<8)+row)<<16)+ncl;
1356 tpcrow->InsertCluster(c,index);
1361 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1362 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1363 tpcrow->InsertCluster(c,index);
1366 // write indexes for fast acces
1368 for (Int_t i=0;i<510;i++)
1369 tpcrow->fFastCluster[i]=-1;
1370 for (Int_t i=0;i<tpcrow->GetN();i++){
1371 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1372 tpcrow->fFastCluster[zi]=i; // write index
1375 for (Int_t i=0;i<510;i++){
1376 if (tpcrow->fFastCluster[i]<0)
1377 tpcrow->fFastCluster[i] = last;
1379 last = tpcrow->fFastCluster[i];
1391 //_________________________________________________________________________
1392 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1393 //--------------------------------------------------------------------
1394 // Return pointer to a given cluster
1395 //--------------------------------------------------------------------
1396 Int_t sec=(index&0xff000000)>>24;
1397 Int_t row=(index&0x00ff0000)>>16;
1398 Int_t ncl=(index&0x00007fff)>>00;
1400 const AliTPCRow * tpcrow=0;
1401 AliTPCclusterMI * clrow =0;
1403 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1405 clrow = tpcrow->fClusters1;
1407 clrow = tpcrow->fClusters2;
1410 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1411 if (sec-2*fkNIS<fkNOS)
1412 clrow = tpcrow->fClusters1;
1414 clrow = tpcrow->fClusters2;
1416 if (tpcrow==0) return 0;
1417 if (tpcrow->GetN()<=ncl) return 0;
1418 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1419 return &(clrow[ncl]);
1425 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1426 //-----------------------------------------------------------------
1427 // This function tries to find a track prolongation to next pad row
1428 //-----------------------------------------------------------------
1430 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1432 // if (t.GetRadius()>x+10 ) return 0;
1433 // t.PropagateTo(x+0.02);
1434 //t.PropagateTo(x+0.01);
1435 if (!t.PropagateTo(x)) {
1440 Double_t y=t.GetY(), z=t.GetZ();
1441 if (TMath::Abs(y)>ymax){
1443 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1444 if (!t.Rotate(fSectors->GetAlpha()))
1446 } else if (y <-ymax) {
1447 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1448 if (!t.Rotate(-fSectors->GetAlpha()))
1451 if (!t.PropagateTo(x)) {
1457 // update current shape info every 3 pad-row
1458 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1459 //t.fCurrentSigmaY = GetSigmaY(&t);
1460 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1464 AliTPCclusterMI *cl=0;
1469 if (t.GetClusterIndex2(nr)>0){
1471 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1472 index = t.GetClusterIndex2(nr);
1473 cl = t.fClusterPointer[nr];
1474 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1475 t.fCurrentClusterIndex1 = index;
1478 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1479 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1481 Double_t roadz = 1.;
1483 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1485 t.SetClusterIndex2(nr,-1);
1490 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1496 t.fCurrentCluster = cl;
1498 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1499 if (fIteration>0) accept =0;
1501 //if founded cluster is acceptible
1502 UpdateTrack(&t,accept);
1508 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1509 cl = krow.FindNearest2(y,z,roady,roadz,index);
1510 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1515 t.fCurrentCluster = cl;
1517 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1519 if (t.fCurrentCluster->IsUsed(10)){
1524 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1530 if (accept<3) UpdateTrack(&t,accept);
1533 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1539 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1540 //-----------------------------------------------------------------
1541 // This function tries to find a track prolongation to next pad row
1542 //-----------------------------------------------------------------
1544 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1546 if (!t.GetProlongation(x,y,z)) {
1552 if (TMath::Abs(y)>ymax){
1556 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1557 if (!t.Rotate(fSectors->GetAlpha()))
1559 } else if (y <-ymax) {
1560 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1561 if (!t.Rotate(-fSectors->GetAlpha()))
1564 if (!t.PropagateTo(x)) {
1567 t.GetProlongation(x,y,z);
1570 // update current shape info every 3 pad-row
1571 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1572 // t.fCurrentSigmaY = GetSigmaY(&t);
1573 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1577 AliTPCclusterMI *cl=0;
1582 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1583 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1585 Double_t roadz = 1.;
1588 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1590 t.SetClusterIndex2(row,-1);
1595 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1599 if ((cl==0)&&(krow)) {
1600 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1601 cl = krow.FindNearest2(y,z,roady,roadz,index);
1603 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1607 t.fCurrentCluster = cl;
1608 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1610 t.SetClusterIndex2(row,index);
1611 t.fClusterPointer[row] = cl;
1619 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1620 //-----------------------------------------------------------------
1621 // This function tries to find a track prolongation to next pad row
1622 //-----------------------------------------------------------------
1623 t.fCurrentCluster = 0;
1624 t.fCurrentClusterIndex1 = 0;
1626 Double_t xt=t.GetX();
1627 Int_t row = GetRowNumber(xt)-1;
1628 Double_t ymax= GetMaxY(nr);
1630 if (row < nr) return 1; // don't prolongate if not information until now -
1631 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1633 return 0; // not prolongate strongly inclined tracks
1635 if (TMath::Abs(t.GetSnp())>0.95) {
1637 return 0; // not prolongate strongly inclined tracks
1640 Double_t x= GetXrow(nr);
1642 //t.PropagateTo(x+0.02);
1643 //t.PropagateTo(x+0.01);
1644 if (!t.PropagateTo(x)){
1651 if (TMath::Abs(y)>ymax){
1653 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1654 if (!t.Rotate(fSectors->GetAlpha()))
1656 } else if (y <-ymax) {
1657 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1658 if (!t.Rotate(-fSectors->GetAlpha()))
1661 if (!t.PropagateTo(x)){
1668 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1670 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1672 t.SetClusterIndex2(nr,-1);
1677 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1683 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1684 // t.fCurrentSigmaY = GetSigmaY(&t);
1685 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1689 AliTPCclusterMI *cl=0;
1692 Double_t roady = 1.;
1693 Double_t roadz = 1.;
1697 index = t.GetClusterIndex2(nr);
1698 if ( (index>0) && (index&0x8000)==0){
1699 cl = t.fClusterPointer[nr];
1700 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1701 t.fCurrentClusterIndex1 = index;
1703 t.fCurrentCluster = cl;
1710 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1711 cl = krow.FindNearest2(y,z,roady,roadz,index);
1714 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1715 t.fCurrentCluster = cl;
1721 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1722 //-----------------------------------------------------------------
1723 // This function tries to find a track prolongation to next pad row
1724 //-----------------------------------------------------------------
1726 //update error according neighborhoud
1728 if (t.fCurrentCluster) {
1730 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1732 if (t.fCurrentCluster->IsUsed(10)){
1738 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1743 if (fIteration>0) accept = 0;
1744 if (accept<3) UpdateTrack(&t,accept);
1748 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1749 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1751 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1759 //_____________________________________________________________________________
1760 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1761 //-----------------------------------------------------------------
1762 // This function tries to find a track prolongation.
1763 //-----------------------------------------------------------------
1764 Double_t xt=t.GetX();
1766 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1767 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1768 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1770 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1772 Int_t first = GetRowNumber(xt)-1;
1773 for (Int_t nr= first; nr>=rf; nr-=step) {
1774 if (FollowToNext(t,nr)==0)
1775 if (!t.IsActive()) return 0;
1782 //_____________________________________________________________________________
1783 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1784 //-----------------------------------------------------------------
1785 // This function tries to find a track prolongation.
1786 //-----------------------------------------------------------------
1787 Double_t xt=t.GetX();
1789 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1790 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1791 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1792 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1794 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1796 if (FollowToNextFast(t,nr)==0)
1797 if (!t.IsActive()) return 0;
1807 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1808 //-----------------------------------------------------------------
1809 // This function tries to find a track prolongation.
1810 //-----------------------------------------------------------------
1811 // Double_t xt=t.GetX();
1813 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1814 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1815 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1816 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1819 first = t.fFirstPoint+3;
1821 if (first<0) first=0;
1822 for (Int_t nr=first+1; nr<=rf; nr++) {
1823 //if ( (t.GetSnp()<0.9))
1824 if (nr<fInnerSec->GetNRows())
1825 fSectors = fInnerSec;
1827 fSectors = fOuterSec;
1837 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1845 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1848 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1850 Float_t distance = TMath::Sqrt(dz2+dy2);
1851 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1854 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1855 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1860 if (firstpoint>lastpoint) {
1861 firstpoint =lastpoint;
1866 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1867 if (s1->GetClusterIndex2(i)>0) sum1++;
1868 if (s2->GetClusterIndex2(i)>0) sum2++;
1869 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1873 if (sum<5) return 0;
1875 Float_t summin = TMath::Min(sum1+1,sum2+1);
1876 Float_t ratio = (sum+1)/Float_t(summin);
1880 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1884 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1885 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1887 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1889 Float_t dy2 =(s1->GetY() - s2->GetY());
1891 Float_t distance = dz2+dy2;
1892 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1897 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1898 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1900 if (firstpoint>=lastpoint-5) return;;
1902 for (Int_t i=firstpoint;i<lastpoint;i++){
1903 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1904 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1911 for (Int_t i=firstpoint;i<lastpoint;i++){
1912 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1913 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1914 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1915 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1916 if (s1->IsActive()&&s2->IsActive()){
1917 p1->fIsShared = kTRUE;
1918 p2->fIsShared = kTRUE;
1925 for (Int_t i=0;i<4;i++){
1926 if (s1->fOverlapLabels[3*i]==0){
1927 s1->fOverlapLabels[3*i] = s2->GetLabel();
1928 s1->fOverlapLabels[3*i+1] = sumshared;
1929 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1933 for (Int_t i=0;i<4;i++){
1934 if (s2->fOverlapLabels[3*i]==0){
1935 s2->fOverlapLabels[3*i] = s1->GetLabel();
1936 s2->fOverlapLabels[3*i+1] = sumshared;
1937 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1945 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1948 //sort trackss according sectors
1950 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1951 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1953 //if (pt) RotateToLocal(pt);
1957 arr->Sort(); // sorting according z
1958 arr->Expand(arr->GetEntries());
1961 Int_t nseed=arr->GetEntriesFast();
1962 for (Int_t i=0; i<nseed; i++) {
1963 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1965 for (Int_t j=0;j<=12;j++){
1966 pt->fOverlapLabels[j] =0;
1969 for (Int_t i=0; i<nseed; i++) {
1970 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1972 if (pt->fRemoval>10) continue;
1973 for (Int_t j=i+1; j<nseed; j++){
1974 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1976 if (pt2->fRemoval<=10) {
1977 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1984 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1987 //sort trackss according sectors
1990 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1993 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1994 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1999 arr->Sort(); // sorting according z
2000 arr->Expand(arr->GetEntries());
2002 //reset overlap labels
2004 Int_t nseed=arr->GetEntriesFast();
2005 for (Int_t i=0; i<nseed; i++) {
2006 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2009 for (Int_t j=0;j<=12;j++){
2010 pt->fOverlapLabels[j] =0;
2014 //sign shared tracks
2015 for (Int_t i=0; i<nseed; i++) {
2016 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2018 if (pt->fRemoval>10) continue;
2019 Float_t deltac = pt->GetC()*0.1;
2020 for (Int_t j=i+1; j<nseed; j++){
2021 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2023 if (pt2->fRemoval<=10) {
2024 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2025 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2026 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2033 // remove highly shared tracks
2034 for (Int_t i=0; i<nseed; i++) {
2035 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2037 if (pt->fRemoval>10) continue;
2040 for (Int_t j=0;j<4;j++){
2041 sumshared = pt->fOverlapLabels[j*3+1];
2043 Float_t factor = factor1;
2044 if (pt->fRemoval>0) factor = factor2;
2045 if (sumshared/pt->GetNumberOfClusters()>factor){
2046 for (Int_t j=0;j<4;j++){
2047 if (pt->fOverlapLabels[3*j]==0) continue;
2048 if (pt->fOverlapLabels[3*j+1]<5) continue;
2049 if (pt->fRemoval==removalindex) continue;
2050 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2052 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2053 // pt->fRemoval = removalindex;
2054 delete arr->RemoveAt(i);
2062 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2071 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2074 //sort tracks in array according mode criteria
2075 Int_t nseed = arr->GetEntriesFast();
2076 for (Int_t i=0; i<nseed; i++) {
2077 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2087 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2090 //Loop over all tracks and remove "overlaps"
2093 Int_t nseed = arr->GetEntriesFast();
2096 for (Int_t i=0; i<nseed; i++) {
2097 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2099 delete arr->RemoveAt(i);
2103 pt->fBSigned = kFALSE;
2107 nseed = arr->GetEntriesFast();
2114 for (Int_t i=0; i<nseed; i++) {
2115 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2119 Int_t found,foundable,shared;
2121 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2123 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2125 Double_t factor = factor2;
2126 if (pt->fBConstrain) factor = factor1;
2128 if ((Float_t(shared)/Float_t(found))>factor){
2129 pt->Desactivate(removalindex);
2134 for (Int_t i=0; i<160; i++) {
2135 Int_t index=pt->GetClusterIndex2(i);
2136 if (index<0 || index&0x8000 ) continue;
2137 AliTPCclusterMI *c= pt->fClusterPointer[i];
2139 // if (!c->IsUsed(10)) c->Use(10);
2140 //if (pt->IsActive())
2149 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2152 void AliTPCtrackerMI::UnsignClusters()
2155 // loop over all clusters and unsign them
2158 for (Int_t sec=0;sec<fkNIS;sec++){
2159 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2160 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2161 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2162 // if (cl[icl].IsUsed(10))
2164 cl = fInnerSec[sec][row].fClusters2;
2165 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2166 //if (cl[icl].IsUsed(10))
2171 for (Int_t sec=0;sec<fkNOS;sec++){
2172 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2173 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2174 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2175 //if (cl[icl].IsUsed(10))
2177 cl = fOuterSec[sec][row].fClusters2;
2178 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2179 //if (cl[icl].IsUsed(10))
2188 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2191 //sign clusters to be "used"
2193 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2194 // loop over "primaries"
2208 Int_t nseed = arr->GetEntriesFast();
2209 for (Int_t i=0; i<nseed; i++) {
2210 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2214 if (!(pt->IsActive())) continue;
2215 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2216 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2218 sumdens2+= dens*dens;
2219 sumn += pt->GetNumberOfClusters();
2220 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2221 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2224 sumchi2 +=chi2*chi2;
2229 Float_t mdensity = 0.9;
2230 Float_t meann = 130;
2231 Float_t meanchi = 1;
2232 Float_t sdensity = 0.1;
2233 Float_t smeann = 10;
2234 Float_t smeanchi =0.4;
2238 mdensity = sumdens/sum;
2240 meanchi = sumchi/sum;
2242 sdensity = sumdens2/sum-mdensity*mdensity;
2243 sdensity = TMath::Sqrt(sdensity);
2245 smeann = sumn2/sum-meann*meann;
2246 smeann = TMath::Sqrt(smeann);
2248 smeanchi = sumchi2/sum - meanchi*meanchi;
2249 smeanchi = TMath::Sqrt(smeanchi);
2253 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2255 for (Int_t i=0; i<nseed; i++) {
2256 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2260 if (pt->fBSigned) continue;
2261 if (pt->fBConstrain) continue;
2262 //if (!(pt->IsActive())) continue;
2264 Int_t found,foundable,shared;
2265 pt->GetClusterStatistic(0,160,found, foundable,shared);
2266 if (shared/float(found)>0.3) {
2267 if (shared/float(found)>0.9 ){
2268 //delete arr->RemoveAt(i);
2273 Bool_t isok =kFALSE;
2274 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2276 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2278 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2280 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2284 for (Int_t i=0; i<160; i++) {
2285 Int_t index=pt->GetClusterIndex2(i);
2286 if (index<0) continue;
2287 AliTPCclusterMI *c= pt->fClusterPointer[i];
2289 //if (!(c->IsUsed(10))) c->Use();
2296 Double_t maxchi = meanchi+2.*smeanchi;
2298 for (Int_t i=0; i<nseed; i++) {
2299 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2303 //if (!(pt->IsActive())) continue;
2304 if (pt->fBSigned) continue;
2305 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2306 if (chi>maxchi) continue;
2309 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2311 //sign only tracks with enoug big density at the beginning
2313 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2316 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2317 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2319 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2320 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2323 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2324 //Int_t noc=pt->GetNumberOfClusters();
2325 pt->fBSigned = kTRUE;
2326 for (Int_t i=0; i<160; i++) {
2328 Int_t index=pt->GetClusterIndex2(i);
2329 if (index<0) continue;
2330 AliTPCclusterMI *c= pt->fClusterPointer[i];
2332 // if (!(c->IsUsed(10))) c->Use();
2337 // gLastCheck = nseed;
2345 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2347 // stop not active tracks
2348 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2349 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2350 Int_t nseed = arr->GetEntriesFast();
2352 for (Int_t i=0; i<nseed; i++) {
2353 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2357 if (!(pt->IsActive())) continue;
2358 StopNotActive(pt,row0,th0, th1,th2);
2364 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2367 // stop not active tracks
2368 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2369 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2372 Int_t foundable = 0;
2373 Int_t maxindex = seed->fLastPoint; //last foundable row
2374 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2375 seed->Desactivate(10) ;
2379 for (Int_t i=row0; i<maxindex; i++){
2380 Int_t index = seed->GetClusterIndex2(i);
2381 if (index!=-1) foundable++;
2383 if (foundable<=30) sumgood1++;
2384 if (foundable<=50) {
2391 if (foundable>=30.){
2392 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2395 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2399 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2402 // back propagation of ESD tracks
2408 PrepareForProlongation(fSeeds,1);
2410 Int_t nseed = fSeeds->GetEntriesFast();
2411 for (Int_t i=0;i<nseed;i++){
2412 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2413 seed->PropagateTo(fParam->GetInnerRadiusLow());
2414 AliESDtrack *esd=event->GetTrack(i);
2415 seed->CookdEdx(0.02,0.6);
2416 CookLabel(seed,0.1); //For comparison only
2417 if (seed->GetNumberOfClusters()>20){
2418 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2421 //printf("problem\n");
2430 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2433 // back propagation of ESD tracks
2439 PropagateBack(fSeeds);
2440 Int_t nseed = fSeeds->GetEntriesFast();
2441 for (Int_t i=0;i<nseed;i++){
2442 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2443 AliESDtrack *esd=event->GetTrack(i);
2444 seed->CookdEdx(0.02,0.6);
2445 CookLabel(seed,0.1); //For comparison only
2446 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2454 void AliTPCtrackerMI::DeleteSeeds()
2458 Int_t nseed = fSeeds->GetEntriesFast();
2459 for (Int_t i=0;i<nseed;i++){
2460 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2461 if (seed) delete fSeeds->RemoveAt(i);
2467 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2470 //read seeds from the event
2472 Int_t nentr=event->GetNumberOfTracks();
2473 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2477 fSeeds = new TObjArray;
2481 for (Int_t i=0; i<nentr; i++) {
2482 AliESDtrack *esd=event->GetTrack(i);
2483 ULong_t status=esd->GetStatus();
2484 AliTPCtrack t(*esd);
2485 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2486 if (status==AliESDtrack::kTPCin&&direction==1) seed->Modify(0.8);
2489 // rotate to the local coordinate system
2491 fSectors=fInnerSec; fN=fkNIS;
2493 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2494 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2495 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2496 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2497 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2498 alpha-=seed->GetAlpha();
2499 if (!seed->Rotate(alpha)) continue;
2502 //seed->PropagateTo(fSectors->GetX(0));
2504 // Int_t index = esd->GetTPCindex();
2505 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2506 //if (direction==2){
2507 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2514 fSeeds->AddLast(seed);
2520 //_____________________________________________________________________________
2521 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2522 Float_t deltay, Int_t ddsec) {
2523 //-----------------------------------------------------------------
2524 // This function creates track seeds.
2525 // SEEDING WITH VERTEX CONSTRAIN
2526 //-----------------------------------------------------------------
2527 // cuts[0] - fP4 cut
2528 // cuts[1] - tan(phi) cut
2529 // cuts[2] - zvertex cut
2530 // cuts[3] - fP3 cut
2538 Double_t x[5], c[15];
2539 // Int_t di = i1-i2;
2541 AliTPCseed * seed = new AliTPCseed;
2542 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2543 Double_t cs=cos(alpha), sn=sin(alpha);
2545 // Double_t x1 =fOuterSec->GetX(i1);
2546 //Double_t xx2=fOuterSec->GetX(i2);
2548 Double_t x1 =GetXrow(i1);
2549 Double_t xx2=GetXrow(i2);
2551 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2553 Int_t imiddle = (i2+i1)/2; //middle pad row index
2554 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2555 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2559 const AliTPCRow& kr1=GetRow(ns,i1);
2560 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2561 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2564 // change cut on curvature if it can't reach this layer
2565 // maximal curvature set to reach it
2566 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2567 if (dvertexmax*0.5*cuts[0]>0.85){
2568 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2570 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2573 if (deltay>0) ddsec = 0;
2574 // loop over clusters
2575 for (Int_t is=0; is < kr1; is++) {
2577 if (kr1[is]->IsUsed(10)) continue;
2578 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2579 //if (TMath::Abs(y1)>ymax) continue;
2581 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2583 // find possible directions
2584 Float_t anglez = (z1-z3)/(x1-x3);
2585 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2588 //find rotation angles relative to line given by vertex and point 1
2589 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2590 Double_t dvertex = TMath::Sqrt(dvertex2);
2591 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2592 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2595 // loop over 2 sectors
2601 Double_t dddz1=0; // direction of delta inclination in z axis
2608 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2609 Int_t sec2 = sec + dsec;
2611 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2612 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2613 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2614 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2615 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2616 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2618 // rotation angles to p1-p3
2619 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2620 Double_t x2, y2, z2;
2622 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2625 Double_t dxx0 = (xx2-x3)*cs13r;
2626 Double_t dyy0 = (xx2-x3)*sn13r;
2627 for (Int_t js=index1; js < index2; js++) {
2628 const AliTPCclusterMI *kcl = kr2[js];
2629 if (kcl->IsUsed(10)) continue;
2631 //calcutate parameters
2633 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2635 if (TMath::Abs(yy0)<0.000001) continue;
2636 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2637 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2638 Double_t r02 = (0.25+y0*y0)*dvertex2;
2639 //curvature (radius) cut
2640 if (r02<r2min) continue;
2644 Double_t c0 = 1/TMath::Sqrt(r02);
2648 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2649 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2650 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2651 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2654 Double_t z0 = kcl->GetZ();
2655 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2656 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2659 Double_t dip = (z1-z0)*c0/dfi1;
2660 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2671 x2= xx2*cs-y2*sn*dsec;
2672 y2=+xx2*sn*dsec+y2*cs;
2682 // do we have cluster at the middle ?
2684 GetProlongation(x1,xm,x,ym,zm);
2686 AliTPCclusterMI * cm=0;
2687 if (TMath::Abs(ym)-ymaxm<0){
2688 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2689 if ((!cm) || (cm->IsUsed(10))) {
2694 // rotate y1 to system 0
2695 // get state vector in rotated system
2696 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2697 Double_t xr2 = x0*cs+yr1*sn*dsec;
2698 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2700 GetProlongation(xx2,xm,xr,ym,zm);
2701 if (TMath::Abs(ym)-ymaxm<0){
2702 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2703 if ((!cm) || (cm->IsUsed(10))) {
2713 dym = ym - cm->GetY();
2714 dzm = zm - cm->GetZ();
2721 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2722 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2723 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2724 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2725 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2727 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2728 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2729 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2730 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2731 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2732 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2734 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2735 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2736 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2737 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2741 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2742 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2743 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2744 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2745 c[13]=f30*sy1*f40+f32*sy2*f42;
2746 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2748 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2750 UInt_t index=kr1.GetIndex(is);
2751 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2753 track->fIsSeeding = kTRUE;
2760 FollowProlongation(*track, (i1+i2)/2,1);
2761 Int_t foundable,found,shared;
2762 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2763 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2765 seed->~AliTPCseed();
2771 FollowProlongation(*track, i2,1);
2775 track->fBConstrain =1;
2776 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2777 track->fLastPoint = i1; // first cluster in track position
2778 track->fFirstPoint = track->fLastPoint;
2780 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2781 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2782 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2784 seed->~AliTPCseed();
2788 // Z VERTEX CONDITION
2790 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2791 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2792 if (TMath::Abs(zv-z3)>cuts[2]) {
2793 FollowProlongation(*track, TMath::Max(i2-20,0));
2794 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2795 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2796 if (TMath::Abs(zv-z3)>cuts[2]){
2797 FollowProlongation(*track, TMath::Max(i2-40,0));
2798 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2799 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2800 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2801 // make seed without constrain
2802 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2803 FollowProlongation(*track2, i2,1);
2804 track2->fBConstrain = kFALSE;
2805 track2->fSeedType = 1;
2806 arr->AddLast(track2);
2808 seed->~AliTPCseed();
2813 seed->~AliTPCseed();
2820 track->fSeedType =0;
2821 arr->AddLast(track);
2822 seed = new AliTPCseed;
2824 // don't consider other combinations
2825 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2831 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2837 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2842 //-----------------------------------------------------------------
2843 // This function creates track seeds.
2844 //-----------------------------------------------------------------
2845 // cuts[0] - fP4 cut
2846 // cuts[1] - tan(phi) cut
2847 // cuts[2] - zvertex cut
2848 // cuts[3] - fP3 cut
2858 Double_t x[5], c[15];
2860 // make temporary seed
2861 AliTPCseed * seed = new AliTPCseed;
2862 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2863 // Double_t cs=cos(alpha), sn=sin(alpha);
2868 Double_t x1 = GetXrow(i1-1);
2869 const AliTPCRow& kr1=GetRow(sec,i1-1);
2870 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2872 Double_t x1p = GetXrow(i1);
2873 const AliTPCRow& kr1p=GetRow(sec,i1);
2875 Double_t x1m = GetXrow(i1-2);
2876 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2879 //last 3 padrow for seeding
2880 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2881 Double_t x3 = GetXrow(i1-7);
2882 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2884 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2885 Double_t x3p = GetXrow(i1-6);
2887 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2888 Double_t x3m = GetXrow(i1-8);
2893 Int_t im = i1-4; //middle pad row index
2894 Double_t xm = GetXrow(im); // radius of middle pad-row
2895 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2896 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2899 Double_t deltax = x1-x3;
2900 Double_t dymax = deltax*cuts[1];
2901 Double_t dzmax = deltax*cuts[3];
2903 // loop over clusters
2904 for (Int_t is=0; is < kr1; is++) {
2906 if (kr1[is]->IsUsed(10)) continue;
2907 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2909 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2911 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2912 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2918 for (Int_t js=index1; js < index2; js++) {
2919 const AliTPCclusterMI *kcl = kr3[js];
2920 if (kcl->IsUsed(10)) continue;
2922 // apply angular cuts
2923 if (TMath::Abs(y1-y3)>dymax) continue;
2926 if (TMath::Abs(z1-z3)>dzmax) continue;
2928 Double_t angley = (y1-y3)/(x1-x3);
2929 Double_t anglez = (z1-z3)/(x1-x3);
2931 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2932 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2934 Double_t yyym = angley*(xm-x1)+y1;
2935 Double_t zzzm = anglez*(xm-x1)+z1;
2937 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2939 if (kcm->IsUsed(10)) continue;
2941 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2942 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2949 // look around first
2950 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2956 if (kc1m->IsUsed(10)) used++;
2958 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2964 if (kc1p->IsUsed(10)) used++;
2966 if (used>1) continue;
2967 if (found<1) continue;
2971 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2977 if (kc3m->IsUsed(10)) used++;
2981 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2987 if (kc3p->IsUsed(10)) used++;
2991 if (used>1) continue;
2992 if (found<3) continue;
3002 x[4]=F1(x1,y1,x2,y2,x3,y3);
3003 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3006 x[2]=F2(x1,y1,x2,y2,x3,y3);
3009 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3010 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3014 Double_t sy1=0.1, sz1=0.1;
3015 Double_t sy2=0.1, sz2=0.1;
3016 Double_t sy3=0.1, sy=0.1, sz=0.1;
3018 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3019 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3020 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3021 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3022 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3023 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3025 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3026 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3027 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3028 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3032 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3033 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3034 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3035 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3036 c[13]=f30*sy1*f40+f32*sy2*f42;
3037 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3039 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3041 UInt_t index=kr1.GetIndex(is);
3042 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3044 track->fIsSeeding = kTRUE;
3047 FollowProlongation(*track, i1-7,1);
3048 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3049 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3051 seed->~AliTPCseed();
3057 FollowProlongation(*track, i2,1);
3058 track->fBConstrain =0;
3059 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3060 track->fFirstPoint = track->fLastPoint;
3062 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3063 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3064 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3066 seed->~AliTPCseed();
3071 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3072 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3073 FollowProlongation(*track2, i2,1);
3074 track2->fBConstrain = kFALSE;
3075 track2->fSeedType = 4;
3076 arr->AddLast(track2);
3078 seed->~AliTPCseed();
3082 //arr->AddLast(track);
3083 //seed = new AliTPCseed;
3089 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3095 //_____________________________________________________________________________
3096 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3097 Float_t deltay, Bool_t /*bconstrain*/) {
3098 //-----------------------------------------------------------------
3099 // This function creates track seeds - without vertex constraint
3100 //-----------------------------------------------------------------
3101 // cuts[0] - fP4 cut - not applied
3102 // cuts[1] - tan(phi) cut
3103 // cuts[2] - zvertex cut - not applied
3104 // cuts[3] - fP3 cut
3114 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3115 // Double_t cs=cos(alpha), sn=sin(alpha);
3116 Int_t row0 = (i1+i2)/2;
3117 Int_t drow = (i1-i2)/2;
3118 const AliTPCRow& kr0=fSectors[sec][row0];
3121 AliTPCpolyTrack polytrack;
3122 Int_t nclusters=fSectors[sec][row0];
3123 AliTPCseed * seed = new AliTPCseed;
3128 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3130 Int_t nfoundable =0;
3131 for (Int_t iter =1; iter<2; iter++){ //iterations
3132 const AliTPCRow& krm=fSectors[sec][row0-iter];
3133 const AliTPCRow& krp=fSectors[sec][row0+iter];
3134 const AliTPCclusterMI * cl= kr0[is];
3136 if (cl->IsUsed(10)) {
3142 Double_t x = kr0.GetX();
3143 // Initialization of the polytrack
3148 Double_t y0= cl->GetY();
3149 Double_t z0= cl->GetZ();
3153 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3154 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3156 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3157 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3158 polytrack.AddPoint(x,y0,z0,erry, errz);
3161 if (cl->IsUsed(10)) sumused++;
3164 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3165 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3168 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3169 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3170 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3171 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3172 if (cl1->IsUsed(10)) sumused++;
3173 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3177 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3179 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3180 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3181 if (cl2->IsUsed(10)) sumused++;
3182 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3185 if (sumused>0) continue;
3187 polytrack.UpdateParameters();
3193 nfoundable = polytrack.GetN();
3194 nfound = nfoundable;
3196 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3197 Float_t maxdist = 0.8*(1.+3./(ddrow));
3198 for (Int_t delta = -1;delta<=1;delta+=2){
3199 Int_t row = row0+ddrow*delta;
3200 kr = &(fSectors[sec][row]);
3201 Double_t xn = kr->GetX();
3202 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3203 polytrack.GetFitPoint(xn,yn,zn);
3204 if (TMath::Abs(yn)>ymax) continue;
3206 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3208 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3211 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3212 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3213 if (cln->IsUsed(10)) {
3214 // printf("used\n");
3222 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3227 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3228 polytrack.UpdateParameters();
3231 if ( (sumused>3) || (sumused>0.5*nfound)) {
3232 //printf("sumused %d\n",sumused);
3237 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3238 AliTPCpolyTrack track2;
3240 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3241 if (track2.GetN()<0.5*nfoundable) continue;
3244 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3246 // test seed with and without constrain
3247 for (Int_t constrain=0; constrain<=0;constrain++){
3248 // add polytrack candidate
3250 Double_t x[5], c[15];
3251 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3252 track2.GetBoundaries(x3,x1);
3254 track2.GetFitPoint(x1,y1,z1);
3255 track2.GetFitPoint(x2,y2,z2);
3256 track2.GetFitPoint(x3,y3,z3);
3258 //is track pointing to the vertex ?
3261 polytrack.GetFitPoint(x0,y0,z0);
3274 x[4]=F1(x1,y1,x2,y2,x3,y3);
3276 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3277 x[2]=F2(x1,y1,x2,y2,x3,y3);
3279 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3280 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3281 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3282 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3285 Double_t sy =0.1, sz =0.1;
3286 Double_t sy1=0.02, sz1=0.02;
3287 Double_t sy2=0.02, sz2=0.02;
3291 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3294 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3295 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3296 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3297 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3298 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3299 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3301 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3302 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3303 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3304 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3309 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3310 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3311 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3312 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3313 c[13]=f30*sy1*f40+f32*sy2*f42;
3314 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3316 //Int_t row1 = fSectors->GetRowNumber(x1);
3317 Int_t row1 = GetRowNumber(x1);
3321 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3322 track->fIsSeeding = kTRUE;
3323 Int_t rc=FollowProlongation(*track, i2);
3324 if (constrain) track->fBConstrain =1;
3326 track->fBConstrain =0;
3327 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3328 track->fFirstPoint = track->fLastPoint;
3330 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3331 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3332 track->fNShared>0.4*track->GetNumberOfClusters()) {
3335 seed->~AliTPCseed();
3338 arr->AddLast(track);
3339 seed = new AliTPCseed;
3343 } // if accepted seed
3346 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3352 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3356 //reseed using track points
3357 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3358 Int_t p1 = int(r1*track->GetNumberOfClusters());
3359 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3361 Double_t x0[3],x1[3],x2[3];
3366 // find track position at given ratio of the length
3367 Int_t sec0, sec1, sec2;
3373 for (Int_t i=0;i<160;i++){
3374 if (track->fClusterPointer[i]){
3376 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3377 if ( (index<p0) || x0[0]<0 ){
3378 if (trpoint->GetX()>1){
3379 clindex = track->GetClusterIndex2(i);
3381 x0[0] = trpoint->GetX();
3382 x0[1] = trpoint->GetY();
3383 x0[2] = trpoint->GetZ();
3384 sec0 = ((clindex&0xff000000)>>24)%18;
3389 if ( (index<p1) &&(trpoint->GetX()>1)){
3390 clindex = track->GetClusterIndex2(i);
3392 x1[0] = trpoint->GetX();
3393 x1[1] = trpoint->GetY();
3394 x1[2] = trpoint->GetZ();
3395 sec1 = ((clindex&0xff000000)>>24)%18;
3398 if ( (index<p2) &&(trpoint->GetX()>1)){
3399 clindex = track->GetClusterIndex2(i);
3401 x2[0] = trpoint->GetX();
3402 x2[1] = trpoint->GetY();
3403 x2[2] = trpoint->GetZ();
3404 sec2 = ((clindex&0xff000000)>>24)%18;
3411 Double_t alpha, cs,sn, xx2,yy2;
3413 alpha = (sec1-sec2)*fSectors->GetAlpha();
3414 cs = TMath::Cos(alpha);
3415 sn = TMath::Sin(alpha);
3416 xx2= x1[0]*cs-x1[1]*sn;
3417 yy2= x1[0]*sn+x1[1]*cs;
3421 alpha = (sec0-sec2)*fSectors->GetAlpha();
3422 cs = TMath::Cos(alpha);
3423 sn = TMath::Sin(alpha);
3424 xx2= x0[0]*cs-x0[1]*sn;
3425 yy2= x0[0]*sn+x0[1]*cs;
3431 Double_t x[5],c[15];
3435 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3436 // if (x[4]>1) return 0;
3437 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3438 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3439 //if (TMath::Abs(x[3]) > 2.2) return 0;
3440 //if (TMath::Abs(x[2]) > 1.99) return 0;
3442 Double_t sy =0.1, sz =0.1;
3444 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3445 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3446 Double_t sy3=0.01+track->GetSigmaY2();
3448 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3449 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3450 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3451 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3452 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3453 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3455 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3456 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3457 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3458 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3463 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3464 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3465 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3466 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3467 c[13]=f30*sy1*f40+f32*sy2*f42;
3468 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3470 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3471 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3472 // Double_t y0,z0,y1,z1, y2,z2;
3473 //seed->GetProlongation(x0[0],y0,z0);
3474 // seed->GetProlongation(x1[0],y1,z1);
3475 //seed->GetProlongation(x2[0],y2,z2);
3477 seed->fLastPoint = pp2;
3478 seed->fFirstPoint = pp2;
3485 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3489 //reseed using founded clusters
3491 // Find the number of clusters
3492 Int_t nclusters = 0;
3493 for (Int_t irow=0;irow<160;irow++){
3494 if (track->GetClusterIndex(irow)>0) nclusters++;
3498 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3499 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3500 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3504 Int_t row[3],sec[3]={0,0,0};
3506 // find track row position at given ratio of the length
3508 for (Int_t irow=0;irow<160;irow++){
3509 if (track->GetClusterIndex2(irow)<0) continue;
3511 for (Int_t ipoint=0;ipoint<3;ipoint++){
3512 if (index<=ipos[ipoint]) row[ipoint] = irow;
3516 //Get cluster and sector position
3517 for (Int_t ipoint=0;ipoint<3;ipoint++){
3518 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3519 AliTPCclusterMI * cl = GetClusterMI(clindex);
3522 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3525 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3526 xyz[ipoint][0] = GetXrow(row[ipoint]);
3527 xyz[ipoint][1] = cl->GetY();
3528 xyz[ipoint][2] = cl->GetZ();
3532 // Calculate seed state vector and covariance matrix
3534 Double_t alpha, cs,sn, xx2,yy2;
3536 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3537 cs = TMath::Cos(alpha);
3538 sn = TMath::Sin(alpha);
3539 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3540 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3544 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3545 cs = TMath::Cos(alpha);
3546 sn = TMath::Sin(alpha);
3547 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3548 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3554 Double_t x[5],c[15];
3558 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3559 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3560 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3562 Double_t sy =0.1, sz =0.1;
3564 Double_t sy1=0.2, sz1=0.2;
3565 Double_t sy2=0.2, sz2=0.2;
3568 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;
3569 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;
3570 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;
3571 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;
3572 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;
3573 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;
3575 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;
3576 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;
3577 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;
3578 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;
3583 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3584 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3585 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3586 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3587 c[13]=f30*sy1*f40+f32*sy2*f42;
3588 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3590 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3591 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3592 seed->fLastPoint = row[2];
3593 seed->fFirstPoint = row[2];
3597 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3602 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3604 if (TMath::Abs(seed->GetC())>0.01) return 0;
3607 Float_t x[160], y[160], erry[160], z[160], errz[160];
3609 Float_t xt[160], yt[160], zt[160];
3614 Int_t middle = seed->GetNumberOfClusters()/2;
3617 // find central sector, get local cooordinates
3619 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3620 sec[i]= seed->GetClusterSector(i)%18;
3623 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3624 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3631 if (i>i2) i2 = i; //last point with cluster
3632 if (i2<i1) i1 = i; //first point with cluster
3635 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3637 yt[i] = point->GetY();
3638 zt[i] = point->GetZ();
3640 if (point->GetX()>0){
3641 erry[i] = point->GetErrY();
3642 errz[i] = point->GetErrZ();
3647 secm = sec[i]; //central sector
3648 padm = i; //middle point with cluster
3653 // rotate position to global coordinate system connected to sector at last the point
3655 for (Int_t i=i1;i<=i2;i++){
3657 if (sec[i]<0) continue;
3658 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3659 Double_t cs = TMath::Cos(alpha);
3660 Double_t sn = TMath::Sin(alpha);
3661 Float_t xx2= x[i]*cs+y[i]*sn;
3662 Float_t yy2= -x[i]*sn+y[i]*cs;
3666 xx2= xt[i]*cs+yt[i]*sn;
3667 yy2= -xt[i]*sn+yt[i]*cs;
3672 //get "state" vector
3673 Double_t xh[5],xm = x[padm];
3676 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3677 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3678 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3681 for (Int_t i=i1;i<=i2;i++){
3683 if (sec[i]<0) continue;
3684 GetProlongation(x[i2], x[i],xh,yy,zz);
3685 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3687 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3688 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3689 printf("problem\n");
3694 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3695 Float_t yup[160], ydown[160], zup[160], zdown[160];
3697 AliTPCpolyTrack ptrack1,ptrack2;
3700 for (Int_t i=i1;i<=i2;i++){
3701 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3703 if (cl->GetType()<0) continue;
3704 if (cl->GetType()>10) continue;
3707 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3709 if (ptrack1.GetN()>4.){
3710 ptrack1.UpdateParameters();
3712 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3714 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3723 dyup[i]=0.; //not enough points
3728 for (Int_t i=i2;i>=i1;i--){
3729 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3731 if (cl->GetType()<0) continue;
3732 if (cl->GetType()>10) continue;
3734 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3736 if (ptrack2.GetN()>4){
3737 ptrack2.UpdateParameters();
3739 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3741 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3749 dydown[i]=0.; //not enough points
3754 // find maximal difference of the derivation
3755 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3758 for (Int_t i=i1+10;i<i2-10;i++){
3759 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3760 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3762 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3763 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3764 if ( (ddy+ddz)> th){
3765 seed->fKinkPoint[0] = i;
3766 seed->fKinkPoint[1] = ddy;
3767 seed->fKinkPoint[2] = ddz;
3774 //write information to the debug tree
3775 TBranch * br = fTreeDebug->GetBranch("debug");
3776 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3777 arr->ExpandCreateFast(i2-i1);
3778 br->SetAddress(&arr);
3780 AliTPCclusterMI cldummy;
3782 AliTPCTrackPoint2 pdummy;
3783 pdummy.GetTPoint().fIsShared = 10;
3785 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3786 Double_t cs = TMath::Cos(alpha);
3787 Double_t sn = TMath::Sin(alpha);
3789 for (Int_t i=i1;i<i2;i++){
3790 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3792 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3794 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3797 Double_t x = GetXrow(i);
3798 trpoint->GetTPoint() = *point;
3799 trpoint->GetCPoint() = *cl0;
3800 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3801 trpoint->fID = seed->GetUniqueID();
3802 trpoint->fLab = seed->GetLabel();
3804 trpoint->fGX = cs *x + sn*point->GetY();
3805 trpoint->fGY = -sn *x + cs*point->GetY() ;
3806 trpoint->fGZ = point->GetZ();
3808 trpoint->fDY = y[i];
3809 trpoint->fDZ = z[i];
3811 trpoint->fDYU = dyup[i];
3812 trpoint->fDZU = dzup[i];
3814 trpoint->fDYD = dydown[i];
3815 trpoint->fDZD = dzdown[i];
3817 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3818 trpoint->fDDY = dydown[i]-dyup[i];
3819 trpoint->fDDZ = dzdown[i]-dzup[i];
3827 trpoint->GetCPoint()= cldummy;
3844 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3847 // reseed - refit - track
3850 // Int_t last = fSectors->GetNRows()-1;
3852 if (fSectors == fOuterSec){
3853 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3857 first = t->fFirstPoint;
3859 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3860 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3862 FollowProlongation(*t,first);
3872 //_____________________________________________________________________________
3873 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3874 //-----------------------------------------------------------------
3875 // This function reades track seeds.
3876 //-----------------------------------------------------------------
3877 TDirectory *savedir=gDirectory;
3879 TFile *in=(TFile*)inp;
3880 if (!in->IsOpen()) {
3881 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3886 TTree *seedTree=(TTree*)in->Get("Seeds");
3888 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3889 cerr<<"can't get a tree with track seeds !\n";
3892 AliTPCtrack *seed=new AliTPCtrack;
3893 seedTree->SetBranchAddress("tracks",&seed);
3895 if (fSeeds==0) fSeeds=new TObjArray(15000);
3897 Int_t n=(Int_t)seedTree->GetEntries();
3898 for (Int_t i=0; i<n; i++) {
3899 seedTree->GetEvent(i);
3900 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3909 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
3914 if (!fSeeds) return 1;
3921 //_____________________________________________________________________________
3922 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3923 //-----------------------------------------------------------------
3924 // This is a track finder.
3925 //-----------------------------------------------------------------
3926 TDirectory *savedir=gDirectory;
3930 fSeeds = Tracking();
3933 printf("Time for tracking: \t");timer.Print();timer.Start();
3935 //activate again some tracks
3936 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3937 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3939 Int_t nc=t.GetNumberOfClusters();
3941 delete fSeeds->RemoveAt(i);
3944 if (pt->fRemoval==10) {
3945 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3946 pt->Desactivate(10); // make track again active
3948 pt->Desactivate(20);
3949 delete fSeeds->RemoveAt(i);
3953 RemoveDouble(fSeeds,0.2,0.6,11);
3954 RemoveUsed(fSeeds,0.5,0.5,6);
3957 Int_t nseed=fSeeds->GetEntriesFast();
3959 for (Int_t i=0; i<nseed; i++) {
3960 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3962 Int_t nc=t.GetNumberOfClusters();
3964 delete fSeeds->RemoveAt(i);
3967 CookLabel(pt,0.1); //For comparison only
3968 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3969 if ((pt->IsActive() || (pt->fRemoval==10) )){
3970 cerr<<found++<<'\r';
3974 delete fSeeds->RemoveAt(i);
3978 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3980 //RemoveUsed(fSeeds,0.9,0.9,6);
3982 nseed=fSeeds->GetEntriesFast();
3984 for (Int_t i=0; i<nseed; i++) {
3985 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3987 Int_t nc=t.GetNumberOfClusters();
3989 delete fSeeds->RemoveAt(i);
3993 t.CookdEdx(0.02,0.6);
3994 // CheckKinkPoint(&t,0.05);
3995 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3996 if ((pt->IsActive() || (pt->fRemoval==10) )){
3997 cerr<<found++<<'\r';
4001 delete fSeeds->RemoveAt(i);
4002 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
4004 // FollowProlongation(*seed1,0);
4005 // Int_t n = seed1->GetNumberOfClusters();
4006 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
4007 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
4010 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
4014 SortTracks(fSeeds, 1);
4018 PrepareForBackProlongation(fSeeds,0.5);
4019 PropagateBack(fSeeds);
4020 printf("Time for back propagation: \t");timer.Print();timer.Start();
4024 PrepareForProlongation(fSeeds,1.);
4027 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
4028 // RemoveUsed(fSeeds,0.7,0.7,6);
4029 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
4031 nseed=fSeeds->GetEntriesFast();
4033 for (Int_t i=0; i<nseed; i++) {
4034 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4036 Int_t nc=t.GetNumberOfClusters();
4038 delete fSeeds->RemoveAt(i);
4041 t.CookdEdx(0.02,0.6);
4042 // CookLabel(pt,0.1); //For comparison only
4043 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4044 if ((pt->IsActive() || (pt->fRemoval==10) )){
4045 cerr<<found++<<'\r';
4048 delete fSeeds->RemoveAt(i);
4053 // fNTracks = found;
4054 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
4056 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
4058 // UnloadClusters();
4063 void AliTPCtrackerMI::Tracking(TObjArray * arr)
4066 // tracking of the seeds
4069 fSectors = fOuterSec;
4070 ParallelTracking(arr,150,63);
4071 fSectors = fOuterSec;
4072 ParallelTracking(arr,63,0);
4075 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
4080 TObjArray * arr = new TObjArray;
4082 fSectors = fOuterSec;
4085 for (Int_t sec=0;sec<fkNOS;sec++){
4086 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
4087 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
4088 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
4091 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
4103 TObjArray * AliTPCtrackerMI::Tracking()
4109 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
4111 TObjArray * seeds = new TObjArray;
4120 Float_t fnumber = 3.0;
4121 Float_t fdensity = 3.0;
4126 for (Int_t delta = 0; delta<18; delta+=6){
4130 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
4131 SumTracks(seeds,arr);
4132 SignClusters(seeds,fnumber,fdensity);
4134 for (Int_t i=2;i<6;i+=2){
4135 // seed high pt tracks
4138 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
4139 SumTracks(seeds,arr);
4140 SignClusters(seeds,fnumber,fdensity);
4145 // RemoveUsed(seeds,0.9,0.9,1);
4146 // UnsignClusters();
4147 // SignClusters(seeds,fnumber,fdensity);
4151 for (Int_t delta = 20; delta<120; delta+=10){
4153 // seed high pt tracks
4157 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
4158 SumTracks(seeds,arr);
4159 SignClusters(seeds,fnumber,fdensity);
4164 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4165 SumTracks(seeds,arr);
4166 SignClusters(seeds,fnumber,fdensity);
4177 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4181 // RemoveUsed(seeds,0.75,0.75,1);
4183 //SignClusters(seeds,fnumber,fdensity);
4192 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4193 SumTracks(seeds,arr);
4194 SignClusters(seeds,fnumber,fdensity);
4196 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4197 SumTracks(seeds,arr);
4198 SignClusters(seeds,fnumber,fdensity);
4200 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4201 SumTracks(seeds,arr);
4202 SignClusters(seeds,fnumber,fdensity);
4206 for (Int_t delta = 3; delta<30; delta+=5){
4212 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4213 SumTracks(seeds,arr);
4214 SignClusters(seeds,fnumber,fdensity);
4216 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4217 SumTracks(seeds,arr);
4218 SignClusters(seeds,fnumber,fdensity);
4230 for (Int_t delta = 30; delta<70; delta+=10){
4236 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4237 SumTracks(seeds,arr);
4238 SignClusters(seeds,fnumber,fdensity);
4240 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4241 SumTracks(seeds,arr);
4242 SignClusters(seeds,fnumber,fdensity);
4246 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4257 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
4260 //sum tracks to common container
4261 //remove suspicious tracks
4262 Int_t nseed = arr2->GetEntriesFast();
4263 for (Int_t i=0;i<nseed;i++){
4264 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4267 // NORMAL ACTIVE TRACK
4268 if (pt->IsActive()){
4269 arr1->AddLast(arr2->RemoveAt(i));
4272 //remove not usable tracks
4273 if (pt->fRemoval!=10){
4274 delete arr2->RemoveAt(i);
4277 // REMOVE VERY SHORT TRACKS
4278 if (pt->GetNumberOfClusters()<20){
4279 delete arr2->RemoveAt(i);
4282 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4283 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4284 arr1->AddLast(arr2->RemoveAt(i));
4286 delete arr2->RemoveAt(i);
4295 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4298 // try to track in parralel
4300 Int_t nseed=arr->GetEntriesFast();
4301 //prepare seeds for tracking
4302 for (Int_t i=0; i<nseed; i++) {
4303 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4305 if (!t.IsActive()) continue;
4306 // follow prolongation to the first layer
4307 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4308 FollowProlongation(t, rfirst+1);
4313 for (Int_t nr=rfirst; nr>=rlast; nr--){
4314 // make indexes with the cluster tracks for given
4316 // find nearest cluster
4317 for (Int_t i=0; i<nseed; i++) {
4318 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4320 if (!pt->IsActive()) continue;
4321 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4322 if (pt->fRelativeSector>17) {
4325 UpdateClusters(t,nr);
4327 // prolonagate to the nearest cluster - if founded
4328 for (Int_t i=0; i<nseed; i++) {
4329 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4331 if (!pt->IsActive()) continue;
4332 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4333 if (pt->fRelativeSector>17) {
4336 FollowToNextCluster(*pt,nr);
4341 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
4345 // if we use TPC track itself we have to "update" covariance
4347 Int_t nseed= arr->GetEntriesFast();
4348 for (Int_t i=0;i<nseed;i++){
4349 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4353 //rotate to current local system at first accepted point
4354 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4355 Int_t sec = (index&0xff000000)>>24;
4357 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4358 if (angle1>TMath::Pi())
4359 angle1-=2.*TMath::Pi();
4360 Float_t angle2 = pt->GetAlpha();
4362 if (TMath::Abs(angle1-angle2)>0.001){
4363 pt->Rotate(angle1-angle2);
4364 //angle2 = pt->GetAlpha();
4365 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4366 //if (pt->GetAlpha()<0)
4367 // pt->fRelativeSector+=18;
4368 //sec = pt->fRelativeSector;
4377 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
4381 // if we use TPC track itself we have to "update" covariance
4383 Int_t nseed= arr->GetEntriesFast();
4384 for (Int_t i=0;i<nseed;i++){
4385 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4388 pt->fFirstPoint = pt->fLastPoint;
4396 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4399 // make back propagation
4401 Int_t nseed= arr->GetEntriesFast();
4402 for (Int_t i=0;i<nseed;i++){
4403 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4405 AliTPCseed *pt2 = new AliTPCseed(*pt);
4406 fSectors = fInnerSec;
4407 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
4408 //fSectors = fOuterSec;
4409 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4411 if (pt->GetNumberOfClusters()<20 && pt->GetLabel()>0 ){
4412 printf("\n%d",pt->GetLabel());
4413 fSectors = fInnerSec;
4414 //FollowBackProlongation(*pt2,fInnerSec->GetNRows()-1);
4415 //fSectors = fOuterSec;
4416 FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4424 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4427 // make forward propagation
4429 Int_t nseed= arr->GetEntriesFast();
4430 for (Int_t i=0;i<nseed;i++){
4431 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4433 AliTPCseed *pt2 = new AliTPCseed(*pt);
4434 fSectors = fOuterSec;
4435 FollowProlongation(*pt,0);
4436 fSectors = fOuterSec;
4437 FollowProlongation(*pt,0);
4438 fSectors = fInnerSec;
4439 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4440 printf("\n%d",pt->GetLabel());
4441 fSectors = fOuterSec;
4442 FollowProlongation(*pt2,0);
4443 fSectors = fOuterSec;
4444 FollowProlongation(*pt2,0);
4445 fSectors = fOuterSec;
4453 Int_t AliTPCtrackerMI::PropagateForward()
4456 // propagate track forward
4458 Int_t nseed = fSeeds->GetEntriesFast();
4459 for (Int_t i=0;i<nseed;i++){
4460 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
4462 AliTPCseed &t = *pt;
4463 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
4464 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
4465 if (alpha < 0. ) alpha += 2.*TMath::Pi();
4466 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
4470 fSectors = fOuterSec;
4471 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
4472 fSectors = fInnerSec;
4473 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
4483 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4486 // make back propagation, in between row0 and row1
4490 fSectors = fInnerSec;
4493 if (row1<fSectors->GetNRows())
4496 r1 = fSectors->GetNRows()-1;
4498 if (row0<fSectors->GetNRows()&& r1>0 )
4499 FollowBackProlongation(*pt,r1);
4500 if (row1<=fSectors->GetNRows())
4503 r1 = row1 - fSectors->GetNRows();
4504 if (r1<=0) return 0;
4505 if (r1>=fOuterSec->GetNRows()) return 0;
4506 fSectors = fOuterSec;
4507 return FollowBackProlongation(*pt,r1);
4515 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4519 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4520 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4521 Float_t padlength = GetPadPitchLength(row);
4523 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4524 Float_t angulary = seed->GetSnp();
4525 angulary = angulary*angulary/(1-angulary*angulary);
4526 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4528 Float_t sresz = fParam->GetZSigma();
4529 Float_t angularz = seed->GetTgl();
4530 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4532 Float_t wy = GetSigmaY(seed);
4533 Float_t wz = GetSigmaZ(seed);
4536 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4537 printf("problem\n");
4543 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4547 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4548 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4549 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4550 Float_t angular = seed->GetSnp();
4551 angular = angular*angular/(1-angular*angular);
4552 // angular*=angular;
4553 //angular = TMath::Sqrt(angular/(1-angular));
4554 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4557 Float_t AliTPCtrackerMI::GetSigmaZ(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 = fParam->GetZSigma();
4564 Float_t angular = seed->GetTgl();
4565 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4572 //__________________________________________________________________________
4573 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4574 //--------------------------------------------------------------------
4575 //This function "cooks" a track label. If label<0, this track is fake.
4576 //--------------------------------------------------------------------
4577 Int_t noc=t->GetNumberOfClusters();
4579 //printf("\nnot founded prolongation\n\n\n");
4585 AliTPCclusterMI *clusters[160];
4587 for (Int_t i=0;i<160;i++) {
4594 for (i=0; i<160 && current<noc; i++) {
4596 Int_t index=t->GetClusterIndex2(i);
4597 if (index<=0) continue;
4598 if (index&0x8000) continue;
4600 //clusters[current]=GetClusterMI(index);
4601 if (t->fClusterPointer[i]){
4602 clusters[current]=t->fClusterPointer[i];
4608 Int_t lab=123456789;
4609 for (i=0; i<noc; i++) {
4610 AliTPCclusterMI *c=clusters[i];
4612 lab=TMath::Abs(c->GetLabel(0));
4614 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4620 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4622 for (i=0; i<noc; i++) {
4623 AliTPCclusterMI *c=clusters[i];
4625 if (TMath::Abs(c->GetLabel(1)) == lab ||
4626 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4629 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4632 Int_t tail=Int_t(0.10*noc);
4635 for (i=1; i<=160&&ind<tail; i++) {
4636 // AliTPCclusterMI *c=clusters[noc-i];
4637 AliTPCclusterMI *c=clusters[i];
4639 if (lab == TMath::Abs(c->GetLabel(0)) ||
4640 lab == TMath::Abs(c->GetLabel(1)) ||
4641 lab == TMath::Abs(c->GetLabel(2))) max++;
4644 if (max < Int_t(0.5*tail)) lab=-lab;
4651 //delete[] clusters;
4655 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
4657 //return pad row number for this x
4660 r=fRow[fN-1].GetX();
4661 if (x > r) return fN;
4663 if (x < r) return -1;
4664 return Int_t((x-r)/fPadPitchLength + 0.5);}
4666 r=fRow[fN-1].GetX();
4667 if (x > r) return fN;
4669 if (x < r) return -1;
4670 Double_t r1=fRow[64].GetX();
4672 return Int_t((x-r)/f1PadPitchLength + 0.5);}
4674 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
4678 //_________________________________________________________________________
4679 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4680 //-----------------------------------------------------------------------
4681 // Setup inner sector
4682 //-----------------------------------------------------------------------
4684 fAlpha=par->GetInnerAngle();
4685 fAlphaShift=par->GetInnerAngleShift();
4686 fPadPitchWidth=par->GetInnerPadPitchWidth();
4687 fPadPitchLength=par->GetInnerPadPitchLength();
4688 fN=par->GetNRowLow();
4689 fRow=new AliTPCRow[fN];
4690 for (Int_t i=0; i<fN; i++) {
4691 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4692 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4695 fAlpha=par->GetOuterAngle();
4696 fAlphaShift=par->GetOuterAngleShift();
4697 fPadPitchWidth = par->GetOuterPadPitchWidth();
4698 fPadPitchLength = par->GetOuter1PadPitchLength();
4699 f1PadPitchLength = par->GetOuter1PadPitchLength();
4700 f2PadPitchLength = par->GetOuter2PadPitchLength();
4702 fN=par->GetNRowUp();
4703 fRow=new AliTPCRow[fN];
4704 for (Int_t i=0; i<fN; i++) {
4705 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4706 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4711 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
4713 // default constructor
4721 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4728 //_________________________________________________________________________
4730 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4731 //-----------------------------------------------------------------------
4732 // Insert a cluster into this pad row in accordence with its y-coordinate
4733 //-----------------------------------------------------------------------
4734 if (fN==kMaxClusterPerRow) {
4735 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4737 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4738 Int_t i=Find(c->GetZ());
4739 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4740 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4741 fIndex[i]=index; fClusters[i]=c; fN++;
4745 //___________________________________________________________________
4746 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4747 //-----------------------------------------------------------------------
4748 // Return the index of the nearest cluster
4749 //-----------------------------------------------------------------------
4750 if (fN==0) return 0;
4751 if (z <= fClusters[0]->GetZ()) return 0;
4752 if (z > fClusters[fN-1]->GetZ()) return fN;
4753 Int_t b=0, e=fN-1, m=(b+e)/2;
4754 for (; b<e; m=(b+e)/2) {
4755 if (z > fClusters[m]->GetZ()) b=m+1;
4763 //___________________________________________________________________
4764 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4765 //-----------------------------------------------------------------------
4766 // Return the index of the nearest cluster in z y
4767 //-----------------------------------------------------------------------
4768 Float_t maxdistance = roady*roady + roadz*roadz;
4770 AliTPCclusterMI *cl =0;
4771 for (Int_t i=Find(z-roadz); i<fN; i++) {
4772 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4773 if (c->GetZ() > z+roadz) break;
4774 if ( (c->GetY()-y) > roady ) continue;
4775 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4776 if (maxdistance>distance) {
4777 maxdistance = distance;
4784 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4786 //-----------------------------------------------------------------------
4787 // Return the index of the nearest cluster in z y
4788 //-----------------------------------------------------------------------
4789 Float_t maxdistance = roady*roady + roadz*roadz;
4790 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4791 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4793 AliTPCclusterMI *cl =0;
4794 //FindNearest3(y,z,roady,roadz,index);
4795 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4796 for (Int_t i=iz1; i<iz2; i++) {
4797 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4798 if (c->GetZ() > z+roadz) break;
4799 if ( c->GetY()-y > roady ) continue;
4800 if ( y-c->GetY() > roady ) continue;
4801 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4802 if (maxdistance>distance) {
4803 maxdistance = distance;
4806 //roady = TMath::Sqrt(maxdistance);
4814 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4816 //-----------------------------------------------------------------------
4817 // Return the index of the nearest cluster in z y
4818 //-----------------------------------------------------------------------
4819 Float_t maxdistance = roady*roady + roadz*roadz;
4820 // Int_t iz = Int_t(z+255.);
4821 AliTPCclusterMI *cl =0;
4822 for (Int_t i=Find(z-roadz); i<fN; i++) {
4823 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4824 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4825 if (c->GetZ() > z+roadz) break;
4826 if ( c->GetY()-y > roady ) continue;
4827 if ( y-c->GetY() > roady ) continue;
4828 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4829 if (maxdistance>distance) {
4830 maxdistance = distance;
4833 //roady = TMath::Sqrt(maxdistance);
4842 AliTPCseed::AliTPCseed():AliTPCtrack(){
4846 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4847 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4863 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4872 for (Int_t i=0;i<160;i++) {
4873 fClusterPointer[i] = 0;
4874 Int_t index = t.GetClusterIndex(i);
4876 SetClusterIndex2(i,index);
4879 SetClusterIndex2(i,-3);
4891 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4895 for (Int_t i=0;i<160;i++) {
4896 fClusterPointer[i] = 0;
4897 Int_t index = t.GetClusterIndex(i);
4898 SetClusterIndex2(i,index);
4916 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4917 Double_t xr, Double_t alpha):
4918 AliTPCtrack(index, xx, cc, xr, alpha) {
4923 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4924 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4933 // fHelixIn = new TClonesArray("AliHelix",0);
4934 //fHelixOut = new TClonesArray("AliHelix",0);
4943 AliTPCseed::~AliTPCseed(){
4946 if (fPoints) delete fPoints;
4948 if (fEPoints) delete fEPoints;
4953 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4957 return &fTrackPoints[i];
4960 void AliTPCseed::RebuildSeed()
4963 // rebuild seed to be ready for storing
4964 AliTPCclusterMI cldummy;
4966 AliTPCTrackPoint pdummy;
4967 pdummy.GetTPoint().fIsShared = 10;
4968 for (Int_t i=0;i<160;i++){
4969 AliTPCclusterMI * cl0 = fClusterPointer[i];
4970 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
4972 trpoint->GetTPoint() = *(GetTrackPoint(i));
4973 trpoint->GetCPoint() = *cl0;
4974 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4978 trpoint->GetCPoint()= cldummy;
4986 Double_t AliTPCseed::GetDensityFirst(Int_t n)
4990 // return cluster for n rows bellow first point
4991 Int_t nfoundable = 1;
4993 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
4994 Int_t index = GetClusterIndex2(i);
4995 if (index!=-1) nfoundable++;
4996 if (index>0) nfound++;
4998 if (nfoundable<n) return 0;
4999 return Double_t(nfound)/Double_t(nfoundable);
5004 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
5006 // get cluster stat. on given region
5011 for (Int_t i=first;i<last; i++){
5012 Int_t index = GetClusterIndex2(i);
5013 if (index!=-1) foundable++;
5014 if (fClusterPointer[i]) {
5020 if (fClusterPointer[i]->IsUsed(10)) {
5024 if (!plus2) continue; //take also neighborhoud
5026 if ( (i>0) && fClusterPointer[i-1]){
5027 if (fClusterPointer[i-1]->IsUsed(10)) {
5032 if ( fClusterPointer[i+1]){
5033 if (fClusterPointer[i+1]->IsUsed(10)) {
5041 printf("problem\n");
5045 //_____________________________________________________________________________
5046 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
5047 //-----------------------------------------------------------------
5048 // This funtion calculates dE/dX within the "low" and "up" cuts.
5049 //-----------------------------------------------------------------
5052 Float_t angular[200];
5053 Float_t weight[200];
5056 // TClonesArray & arr = *fPoints;
5057 Float_t meanlog = 100.;
5059 Float_t mean[4] = {0,0,0,0};
5060 Float_t sigma[4] = {1000,1000,1000,1000};
5061 Int_t nc[4] = {0,0,0,0};
5062 Float_t norm[4] = {1000,1000,1000,1000};
5067 for (Int_t of =0; of<4; of++){
5068 for (Int_t i=of+i1;i<i2;i+=4)
5070 Int_t index = fIndex[i];
5071 if (index<0||index&0x8000) continue;
5073 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
5074 AliTPCTrackerPoint * point = GetTrackPoint(i);
5075 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
5076 //AliTPCTrackerPoint * pointp = 0;
5077 //if (i<159) pointp = GetTrackPoint(i+1);
5079 if (point==0) continue;
5080 AliTPCclusterMI * cl = fClusterPointer[i];
5081 if (cl==0) continue;
5082 if (onlyused && (!cl->IsUsed(10))) continue;
5083 if (cl->IsUsed(11)) {
5087 Int_t type = cl->GetType();
5088 //if (point->fIsShared){
5093 // if (pointm->fIsShared) continue;
5095 // if (pointp->fIsShared) continue;
5097 if (type<0) continue;
5098 //if (type>10) continue;
5099 //if (point->GetErrY()==0) continue;
5100 //if (point->GetErrZ()==0) continue;
5102 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
5103 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
5104 //if ((ddy*ddy+ddz*ddz)>10) continue;
5107 // if (point->GetCPoint().GetMax()<5) continue;
5108 if (cl->GetMax()<5) continue;
5109 Float_t angley = point->GetAngleY();
5110 Float_t anglez = point->GetAngleZ();
5112 Float_t rsigmay2 = point->GetSigmaY();
5113 Float_t rsigmaz2 = point->GetSigmaZ();
5117 rsigmay += pointm->GetTPoint().GetSigmaY();
5118 rsigmaz += pointm->GetTPoint().GetSigmaZ();
5122 rsigmay += pointp->GetTPoint().GetSigmaY();
5123 rsigmaz += pointp->GetTPoint().GetSigmaZ();
5130 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
5132 Float_t ampc = 0; // normalization to the number of electrons
5134 // ampc = 1.*point->GetCPoint().GetMax();
5135 ampc = 1.*cl->GetMax();
5136 //ampc = 1.*point->GetCPoint().GetQ();
5137 // AliTPCClusterPoint & p = point->GetCPoint();
5138 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
5139 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5141 // TMath::Abs( Int_t(iz) - iz + 0.5);
5142 //ampc *= 1.15*(1-0.3*dy);
5143 //ampc *= 1.15*(1-0.3*dz);
5144 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
5148 //ampc = 1.0*point->GetCPoint().GetMax();
5149 ampc = 1.0*cl->GetMax();
5150 //ampc = 1.0*point->GetCPoint().GetQ();
5151 //AliTPCClusterPoint & p = point->GetCPoint();
5152 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
5153 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5155 // TMath::Abs( Int_t(iz) - iz + 0.5);
5157 //ampc *= 1.15*(1-0.3*dy);
5158 //ampc *= 1.15*(1-0.3*dz);
5159 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
5163 ampc *= 2.0; // put mean value to channel 50
5164 //ampc *= 0.58; // put mean value to channel 50
5166 // if (type>0) w = 1./(type/2.-0.5);
5167 // Float_t z = TMath::Abs(cl->GetZ());
5170 //ampc /= (1+0.0008*z);
5174 //ampc /= (1+0.0008*z);
5176 //ampc /= (1+0.0008*z);
5179 if (type<0) { //amp at the border - lower weight
5184 if (rsigma>1.5) ampc/=1.3; // if big backround
5186 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5191 TMath::Sort(nc[of],amp,index,kFALSE);
5195 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
5197 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5198 Float_t ampl = amp[index[i]]/angular[index[i]];
5199 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5201 sumw += weight[index[i]];
5202 sumamp += weight[index[i]]*ampl;
5203 sumamp2 += weight[index[i]]*ampl*ampl;
5204 norm[of] += angular[index[i]]*weight[index[i]];
5211 mean[of] = sumamp/sumw;
5212 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5214 sigma[of] = TMath::Sqrt(sigma[of]);
5218 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5219 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5220 //mean *=(1-0.1*(norm-1.));
5227 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
5228 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
5231 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
5232 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
5236 for (Int_t i =0;i<4;i++){
5237 if (nc[i]>2&&nc[i]<1000){
5238 dedx += mean[i] *nc[i];
5239 fSdEdx += sigma[i]*(nc[i]-2);
5240 fMAngular += norm[i] *nc[i];
5245 fSDEDX[i] = sigma[i];
5258 // Float_t dedx1 =dedx;
5261 for (Int_t i =0;i<4;i++){
5262 if (nc[i]>2&&nc[i]<1000){
5263 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5264 dedx += mean[i] *nc[i];
5279 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5282 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5283 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5284 SetMass(0.93827); return;
5288 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5289 SetMass(0.93827); return;
5292 SetMass(0.13957); return;
5302 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5303 //-----------------------------------------------------------------
5304 // This funtion calculates dE/dX within the "low" and "up" cuts.
5305 //-----------------------------------------------------------------
5308 Float_t angular[200];
5309 Float_t weight[200];
5311 Bool_t inlimit[200];
5312 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5313 for (Int_t i=0;i<200;i++) amp[i]=10000;
5314 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5318 Float_t meanlog = 100.;
5319 Int_t indexde[4]={0,64,128,160};
5326 Float_t mean[4] = {0,0,0,0};
5327 Float_t sigma[4] = {1000,1000,1000,1000};
5328 Int_t nc[4] = {0,0,0,0};
5329 Float_t norm[4] = {1000,1000,1000,1000};
5334 // for (Int_t of =0; of<3; of++){
5335 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5336 for (Int_t i =0; i<160;i++)
5338 AliTPCTrackPoint * point = GetTrackPoint(i);
5339 if (point==0) continue;
5340 if (point->fIsShared){
5344 Int_t type = point->GetCPoint().GetType();
5345 if (type<0) continue;
5346 if (point->GetCPoint().GetMax()<5) continue;
5347 Float_t angley = point->GetTPoint().GetAngleY();
5348 Float_t anglez = point->GetTPoint().GetAngleZ();
5349 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5350 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5351 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5353 Float_t ampc = 0; // normalization to the number of electrons
5355 ampc = point->GetCPoint().GetMax();
5358 ampc = point->GetCPoint().GetMax();
5360 ampc *= 2.0; // put mean value to channel 50
5361 // ampc *= 0.565; // put mean value to channel 50
5364 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5371 if (type<0) { //amp at the border - lower weight
5374 if (rsigma>1.5) ampc/=1.3; // if big backround
5375 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5376 amp[i] = ampc/angular[i];
5381 TMath::Sort(159,amp,index,kFALSE);
5382 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5383 inlimit[index[i]] = kTRUE; // take all clusters
5386 // meanlog = amp[index[Int_t(anc*0.3)]];
5388 for (Int_t of =0; of<3; of++){
5392 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5394 if (inlimit[i]==kFALSE) continue;
5395 Float_t ampl = amp[i];
5397 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5400 sumamp += weight[i]*ampl;
5401 sumamp2 += weight[i]*ampl*ampl;
5402 norm[of] += angular[i]*weight[i];
5410 mean[of] = sumamp/sumw;
5411 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5413 sigma[of] = TMath::Sqrt(sigma[of]);
5416 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5426 Float_t www[3] = {12.,14.,17.};
5427 //Float_t www[3] = {1.,1.,1.};
5429 for (Int_t i =0;i<3;i++){
5430 if (nc[i]>2&&nc[i]<1000){
5431 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5432 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5433 fMAngular += norm[i] *nc[i];
5434 norm2 += nc[i]*www[i]/sigma[i];
5435 norm3 += (nc[i]-2)*www[i]/sigma[i];
5438 fSDEDX[i] = sigma[i];
5451 // Float_t dedx1 =dedx;
5455 for (Int_t i =0;i<3;i++){
5456 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5457 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5458 dedx += mean[i] *(nc[i])/(sigma[i]);
5459 norm4 += (nc[i])/(sigma[i]);
5463 if (norm4>0) dedx /= norm4;