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 "AliComplexCluster.h"
46 #include "AliTPCpolyTrack.h"
47 #include "TStopwatch.h"
51 #include "AliRunLoader.h"
53 #include "AliTPCreco.h"
54 #include "AliTPCtrackerMI.h"
59 ClassImp(AliTPCtrackerMI)
62 class AliTPCFastMath {
65 static Double_t FastAsin(Double_t x);
67 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
70 Double_t AliTPCFastMath::fgFastAsin[20000];
71 AliTPCFastMath gAliTPCFastMath;
73 AliTPCFastMath::AliTPCFastMath(){
75 // initialized lookup table;
76 for (Int_t i=0;i<10000;i++){
77 fgFastAsin[2*i] = TMath::ASin(i/10000.);
78 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
82 Double_t AliTPCFastMath::FastAsin(Double_t x){
84 // return asin using lookup table
86 Int_t index = int(x*10000);
87 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
90 Int_t index = int(x*10000);
91 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
97 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
99 //update track information using current cluster - track->fCurrentCluster
102 AliTPCclusterMI* c =track->fCurrentCluster;
103 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
105 UInt_t i = track->fCurrentClusterIndex1;
107 Int_t sec=(i&0xff000000)>>24;
108 //Int_t row = (i&0x00ff0000)>>16;
109 track->fRow=(i&0x00ff0000)>>16;
110 track->fSector = sec;
111 // Int_t index = i&0xFFFF;
112 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
113 track->SetClusterIndex2(track->fRow, i);
114 //track->fFirstPoint = row;
115 //if ( track->fLastPoint<row) track->fLastPoint =row;
116 // if (track->fRow<0 || track->fRow>160) {
117 // printf("problem\n");
119 if (track->fFirstPoint>track->fRow)
120 track->fFirstPoint = track->fRow;
121 if (track->fLastPoint<track->fRow)
122 track->fLastPoint = track->fRow;
125 track->fClusterPointer[track->fRow] = c;
128 Float_t angle2 = track->GetSnp()*track->GetSnp();
129 angle2 = TMath::Sqrt(angle2/(1-angle2));
131 //SET NEW Track Point
135 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
137 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
138 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
139 point.SetErrY(sqrt(track->fErrorY2));
140 point.SetErrZ(sqrt(track->fErrorZ2));
142 point.SetX(track->GetX());
143 point.SetY(track->GetY());
144 point.SetZ(track->GetZ());
145 point.SetAngleY(angle2);
146 point.SetAngleZ(track->GetTgl());
147 if (point.fIsShared){
148 track->fErrorY2 *= 4;
149 track->fErrorZ2 *= 4;
153 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
155 track->fErrorY2 *= 1.3;
156 track->fErrorY2 += 0.01;
157 track->fErrorZ2 *= 1.3;
158 track->fErrorZ2 += 0.005;
160 if (accept>0) return 0;
161 if (track->GetNumberOfClusters()%20==0){
162 // if (track->fHelixIn){
163 // TClonesArray & larr = *(track->fHelixIn);
164 // Int_t ihelix = larr.GetEntriesFast();
165 // new(larr[ihelix]) AliHelix(*track) ;
168 track->fNoCluster =0;
169 return track->Update(c,chi2,i);
174 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
175 Float_t cory, Float_t corz)
178 // decide according desired precision to accept given
179 // cluster for tracking
180 Double_t sy2=ErrY2(seed,cluster)*cory;
181 Double_t sz2=ErrZ2(seed,cluster)*corz;
182 //sy2=ErrY2(seed,cluster)*cory;
183 //sz2=ErrZ2(seed,cluster)*cory;
185 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
186 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
188 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
189 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
190 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
191 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
193 Double_t rdistance2 = rdistancey2+rdistancez2;
196 if (rdistance2>16) return 3;
199 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
200 return 2; //suspisiouce - will be changed
202 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
203 // strict cut on overlaped cluster
204 return 2; //suspisiouce - will be changed
206 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
207 && cluster->GetType()<0){
217 //_____________________________________________________________________________
218 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
219 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
221 //---------------------------------------------------------------------
222 // The main TPC tracker constructor
223 //---------------------------------------------------------------------
224 fInnerSec=new AliTPCSector[fkNIS];
225 fOuterSec=new AliTPCSector[fkNOS];
228 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
229 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
236 Int_t nrowlow = par->GetNRowLow();
237 Int_t nrowup = par->GetNRowUp();
240 for (Int_t i=0;i<nrowlow;i++){
241 fXRow[i] = par->GetPadRowRadiiLow(i);
242 fPadLength[i]= par->GetPadPitchLength(0,i);
243 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
247 for (Int_t i=0;i<nrowup;i++){
248 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
249 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
250 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
263 //_____________________________________________________________________________
264 AliTPCtrackerMI::~AliTPCtrackerMI() {
265 //------------------------------------------------------------------
266 // TPC tracker destructor
267 //------------------------------------------------------------------
276 void AliTPCtrackerMI::SetIO()
280 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
282 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
284 AliTPCtrack *iotrack= new AliTPCtrack;
285 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
291 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
307 AliTPCtrack *iotrack= new AliTPCtrack;
308 // iotrack->fHelixIn = new TClonesArray("AliHelix");
309 //iotrack->fHelixOut = new TClonesArray("AliHelix");
310 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
313 if (output && (fDebug&2)){
314 //write the full seed information if specified in debug mode
316 fSeedTree = new TTree("Seeds","Seeds");
317 AliTPCseed * vseed = new AliTPCseed;
319 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
320 arrtr->ExpandCreateFast(160);
321 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
323 vseed->fPoints = arrtr;
324 vseed->fEPoints = arre;
325 // vseed->fClusterPoints = arrcl;
326 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
329 fTreeDebug = new TTree("trackDebug","trackDebug");
330 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
331 fTreeDebug->Branch("debug",&arrd,32000,99);
339 void AliTPCtrackerMI::FillESD(TObjArray* arr)
343 //fill esds using updated tracks
345 // write tracks to the event
346 // store index of the track
347 Int_t nseed=arr->GetEntriesFast();
348 for (Int_t i=0; i<nseed; i++) {
349 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
351 pt->PropagateTo(fParam->GetInnerRadiusLow());
352 if (pt->GetNumberOfClusters()>70) {
354 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
355 //iotrack.SetTPCindex(i);
356 fEvent->AddTrack(&iotrack);
362 void AliTPCtrackerMI::WriteTracks(TTree * tree)
365 // write tracks from seed array to selected tree
369 AliTPCtrack *iotrack= new AliTPCtrack;
370 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
375 void AliTPCtrackerMI::WriteTracks()
378 // write tracks to the given output tree -
379 // output specified with SetIO routine
386 AliTPCtrack *iotrack= 0;
387 Int_t nseed=fSeeds->GetEntriesFast();
388 for (Int_t i=0; i<nseed; i++) {
389 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
393 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
394 TBranch * br = fOutput->GetBranch("tracks");
395 br->SetAddress(&iotrack);
397 for (Int_t i=0; i<nseed; i++) {
398 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
402 // br->SetAddress(&iotrack);
406 fOutput->GetDirectory()->cd();
412 //write the full seed information if specified in debug mode
414 AliTPCseed * vseed = new AliTPCseed;
416 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
417 arrtr->ExpandCreateFast(160);
418 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
419 //arrcl->ExpandCreateFast(160);
420 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
422 vseed->fPoints = arrtr;
423 vseed->fEPoints = arre;
424 // vseed->fClusterPoints = arrcl;
425 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
426 TBranch * brseed = fSeedTree->GetBranch("seeds");
428 Int_t nseed=fSeeds->GetEntriesFast();
430 for (Int_t i=0; i<nseed; i++) {
431 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
434 // pt->fClusterPoints = arrcl;
438 brseed->SetAddress(&vseed);
442 // pt->fClusterPoints = 0;
445 if (fTreeDebug) fTreeDebug->Write();
453 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
456 //seed->SetErrorY2(0.1);
458 //calculate look-up table at the beginning
459 static Bool_t ginit = kFALSE;
460 static Float_t gnoise1,gnoise2,gnoise3;
461 static Float_t ggg1[10000];
462 static Float_t ggg2[10000];
463 static Float_t ggg3[10000];
464 static Float_t glandau1[10000];
465 static Float_t glandau2[10000];
466 static Float_t glandau3[10000];
468 static Float_t gcor01[500];
469 static Float_t gcor02[500];
470 static Float_t gcorp[500];
475 for (Int_t i=1;i<500;i++){
476 Float_t rsigma = float(i)/100.;
477 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
478 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
479 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
483 for (Int_t i=3;i<10000;i++){
487 Float_t amp = float(i);
488 Float_t padlength =0.75;
489 gnoise1 = 0.0004/padlength;
490 Float_t nel = 0.268*amp;
491 Float_t nprim = 0.155*amp;
492 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
493 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
494 if (glandau1[i]>1) glandau1[i]=1;
495 glandau1[i]*=padlength*padlength/12.;
499 gnoise2 = 0.0004/padlength;
502 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
503 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
504 if (glandau2[i]>1) glandau2[i]=1;
505 glandau2[i]*=padlength*padlength/12.;
510 gnoise3 = 0.0004/padlength;
513 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
514 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
515 if (glandau3[i]>1) glandau3[i]=1;
516 glandau3[i]*=padlength*padlength/12.;
524 Int_t amp = int(TMath::Abs(cl->GetQ()));
526 seed->SetErrorY2(1.);
530 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
531 Int_t ctype = cl->GetType();
532 Float_t padlength= GetPadPitchLength(seed->fRow);
533 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
534 angle2 = angle2/(1-angle2);
537 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
540 if (fSectors==fInnerSec){
542 res = ggg1[amp]*z+glandau1[amp]*angle2;
543 if (ctype==0) res *= gcor01[rsigmay];
546 res*= gcorp[rsigmay];
552 res = ggg2[amp]*z+glandau2[amp]*angle2;
553 if (ctype==0) res *= gcor02[rsigmay];
556 res*= gcorp[rsigmay];
561 res = ggg3[amp]*z+glandau3[amp]*angle2;
562 if (ctype==0) res *= gcor02[rsigmay];
565 res*= gcorp[rsigmay];
572 res*=2.4; // overestimate error 2 times
579 seed->SetErrorY2(res);
587 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
590 //seed->SetErrorY2(0.1);
592 //calculate look-up table at the beginning
593 static Bool_t ginit = kFALSE;
594 static Float_t gnoise1,gnoise2,gnoise3;
595 static Float_t ggg1[10000];
596 static Float_t ggg2[10000];
597 static Float_t ggg3[10000];
598 static Float_t glandau1[10000];
599 static Float_t glandau2[10000];
600 static Float_t glandau3[10000];
602 static Float_t gcor01[1000];
603 static Float_t gcor02[1000];
604 static Float_t gcorp[1000];
609 for (Int_t i=1;i<1000;i++){
610 Float_t rsigma = float(i)/100.;
611 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
612 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
613 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
617 for (Int_t i=3;i<10000;i++){
621 Float_t amp = float(i);
622 Float_t padlength =0.75;
623 gnoise1 = 0.0004/padlength;
624 Float_t nel = 0.268*amp;
625 Float_t nprim = 0.155*amp;
626 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
627 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
628 if (glandau1[i]>1) glandau1[i]=1;
629 glandau1[i]*=padlength*padlength/12.;
633 gnoise2 = 0.0004/padlength;
636 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
637 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
638 if (glandau2[i]>1) glandau2[i]=1;
639 glandau2[i]*=padlength*padlength/12.;
644 gnoise3 = 0.0004/padlength;
647 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
648 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
649 if (glandau3[i]>1) glandau3[i]=1;
650 glandau3[i]*=padlength*padlength/12.;
658 Int_t amp = int(TMath::Abs(cl->GetQ()));
660 seed->SetErrorY2(1.);
664 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
665 Int_t ctype = cl->GetType();
666 Float_t padlength= GetPadPitchLength(seed->fRow);
668 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
669 // if (angle2<0.6) angle2 = 0.6;
670 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
673 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
676 if (fSectors==fInnerSec){
678 res = ggg1[amp]*z+glandau1[amp]*angle2;
679 if (ctype==0) res *= gcor01[rsigmaz];
682 res*= gcorp[rsigmaz];
688 res = ggg2[amp]*z+glandau2[amp]*angle2;
689 if (ctype==0) res *= gcor02[rsigmaz];
692 res*= gcorp[rsigmaz];
697 res = ggg3[amp]*z+glandau3[amp]*angle2;
698 if (ctype==0) res *= gcor02[rsigmaz];
701 res*= gcorp[rsigmaz];
710 if ((ctype<0) &&<70){
718 seed->SetErrorZ2(res);
725 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
728 //seed->SetErrorZ2(0.1);
732 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
734 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
735 Int_t ctype = cl->GetType();
736 Float_t amp = TMath::Abs(cl->GetQ());
741 Float_t landau=2 ; //landau fluctuation part
742 Float_t gg=2; // gg fluctuation part
743 Float_t padlength= GetPadPitchLength(seed->GetX());
745 if (fSectors==fInnerSec){
746 snoise2 = 0.0004/padlength;
749 gg = (2+0.001*nel/(padlength*padlength))/nel;
750 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
751 if (landau>1) landau=1;
754 snoise2 = 0.0004/padlength;
757 gg = (2+0.0008*nel/(padlength*padlength))/nel;
758 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
759 if (landau>1) landau=1;
761 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
764 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
765 angle2 = TMath::Sqrt((1-angle2));
766 if (angle2<0.6) angle2 = 0.6;
769 Float_t angle = seed->GetTgl()/angle2;
770 Float_t angular = landau*angle*angle*padlength*padlength/12.;
771 Float_t res = sdiff + angular;
774 if ((ctype==0) && (fSectors ==fOuterSec))
775 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
777 if ((ctype==0) && (fSectors ==fInnerSec))
778 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
782 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
788 if ((ctype<0) &&<70){
796 seed->SetErrorZ2(res);
803 void AliTPCseed::Reset(Bool_t all)
807 SetNumberOfClusters(0);
813 for (Int_t i=0;i<8;i++){
814 delete [] fTrackPoints[i];
822 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
823 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
829 void AliTPCseed::Modify(Double_t factor)
832 //------------------------------------------------------------------
833 //This function makes a track forget its history :)
834 //------------------------------------------------------------------
840 fC10*=factor; fC11*=factor;
841 fC20*=factor; fC21*=factor; fC22*=factor;
842 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
843 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
844 SetNumberOfClusters(0);
848 fCurrentSigmaY2 = 0.000005;
849 fCurrentSigmaZ2 = 0.000005;
858 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
860 //-----------------------------------------------------------------
861 // This function find proloncation of a track to a reference plane x=xk.
862 // doesn't change internal state of the track
863 //-----------------------------------------------------------------
865 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
867 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
871 // Double_t y1=fP0, z1=fP1;
872 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
873 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
877 //y += dx*(c1+c2)/(r1+r2);
878 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
880 Double_t dy = dx*(c1+c2)/(r1+r2);
883 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
885 if (TMath::Abs(delta)>0.0001){
886 dz = fP3*TMath::ASin(delta)/fP4;
888 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
891 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
901 //_____________________________________________________________________________
902 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
904 //-----------------------------------------------------------------
905 // This function calculates a predicted chi2 increment.
906 //-----------------------------------------------------------------
907 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
908 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
909 r00+=fC00; r01+=fC10; r11+=fC11;
911 Double_t det=r00*r11 - r01*r01;
912 if (TMath::Abs(det) < 1.e-10) {
913 Int_t n=GetNumberOfClusters();
914 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
917 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
919 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
921 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
925 //_________________________________________________________________________________________
928 Int_t AliTPCseed::Compare(const TObject *o) const {
929 //-----------------------------------------------------------------
930 // This function compares tracks according to the sector - for given sector according z
931 //-----------------------------------------------------------------
932 AliTPCseed *t=(AliTPCseed*)o;
935 if (t->fRelativeSector>fRelativeSector) return -1;
936 if (t->fRelativeSector<fRelativeSector) return 1;
937 Double_t z2 = t->GetZ();
938 Double_t z1 = GetZ();
940 if (z2<z1) return -1;
945 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
946 if (t->fBConstrain) f2=1.2;
949 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
951 if (fBConstrain) f1=1.2;
953 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
958 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
960 //rotate to track "local coordinata
961 Float_t x = seed->GetX();
962 Float_t y = seed->GetY();
963 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
966 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
967 if (!seed->Rotate(fSectors->GetAlpha()))
969 } else if (y <-ymax) {
970 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
971 if (!seed->Rotate(-fSectors->GetAlpha()))
980 //_____________________________________________________________________________
981 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
982 //-----------------------------------------------------------------
983 // This function associates a cluster with this track.
984 //-----------------------------------------------------------------
985 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
987 r00+=fC00; r01+=fC10; r11+=fC11;
988 Double_t det=r00*r11 - r01*r01;
989 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
991 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
992 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
993 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
994 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
995 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
997 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
998 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
999 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1003 fP0 += k00*dy + k01*dz;
1004 fP1 += k10*dy + k11*dz;
1006 fP3 += k30*dy + k31*dz;
1009 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1010 Double_t c12=fC21, c13=fC31, c14=fC41;
1012 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1013 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1014 fC40-=k00*c04+k01*c14;
1016 fC11-=k10*c01+k11*fC11;
1017 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1018 fC41-=k10*c04+k11*c14;
1020 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1021 fC42-=k20*c04+k21*c14;
1023 fC33-=k30*c03+k31*c13;
1024 fC43-=k40*c03+k41*c13;
1026 fC44-=k40*c04+k41*c14;
1028 Int_t n=GetNumberOfClusters();
1030 SetNumberOfClusters(n+1);
1031 SetChi2(GetChi2()+chisq);
1038 //_____________________________________________________________________________
1039 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1040 Double_t x2,Double_t y2,
1041 Double_t x3,Double_t y3)
1043 //-----------------------------------------------------------------
1044 // Initial approximation of the track curvature
1045 //-----------------------------------------------------------------
1046 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1047 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1048 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1049 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1050 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1052 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1053 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1054 return -xr*yr/sqrt(xr*xr+yr*yr);
1059 //_____________________________________________________________________________
1060 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1061 Double_t x2,Double_t y2,
1062 Double_t x3,Double_t y3)
1064 //-----------------------------------------------------------------
1065 // Initial approximation of the track curvature
1066 //-----------------------------------------------------------------
1072 Double_t det = x3*y2-x2*y3;
1077 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1078 Double_t x0 = x3*0.5-y3*u;
1079 Double_t y0 = y3*0.5+x3*u;
1080 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1086 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1087 Double_t x2,Double_t y2,
1088 Double_t x3,Double_t y3)
1090 //-----------------------------------------------------------------
1091 // Initial approximation of the track curvature
1092 //-----------------------------------------------------------------
1098 Double_t det = x3*y2-x2*y3;
1103 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1104 Double_t x0 = x3*0.5-y3*u;
1105 Double_t y0 = y3*0.5+x3*u;
1106 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1115 //_____________________________________________________________________________
1116 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1117 Double_t x2,Double_t y2,
1118 Double_t x3,Double_t y3)
1120 //-----------------------------------------------------------------
1121 // Initial approximation of the track curvature times center of curvature
1122 //-----------------------------------------------------------------
1123 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1124 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1125 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1126 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1127 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1129 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1131 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1134 //_____________________________________________________________________________
1135 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1136 Double_t x2,Double_t y2,
1137 Double_t z1,Double_t z2)
1139 //-----------------------------------------------------------------
1140 // Initial approximation of the tangent of the track dip angle
1141 //-----------------------------------------------------------------
1142 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1146 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1147 Double_t x2,Double_t y2,
1148 Double_t z1,Double_t z2, Double_t c)
1150 //-----------------------------------------------------------------
1151 // Initial approximation of the tangent of the track dip angle
1152 //-----------------------------------------------------------------
1156 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1158 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1159 if (TMath::Abs(d*c*0.5)>1) return 0;
1160 // Double_t angle2 = TMath::ASin(d*c*0.5);
1161 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1162 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1164 angle2 = (z1-z2)*c/(angle2*2.);
1168 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1169 {//-----------------------------------------------------------------
1170 // This function find proloncation of a track to a reference plane x=x2.
1171 //-----------------------------------------------------------------
1175 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1179 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1180 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1184 Double_t dy = dx*(c1+c2)/(r1+r2);
1187 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1189 if (TMath::Abs(delta)>0.01){
1190 dz = x[3]*TMath::ASin(delta)/x[4];
1192 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1195 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1203 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1208 return LoadClusters();
1211 Int_t AliTPCtrackerMI::LoadClusters()
1214 // load clusters to the memory
1215 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1216 clrow->SetClass("AliTPCclusterMI");
1218 clrow->GetArray()->ExpandCreateFast(10000);
1220 // TTree * tree = fClustersArray.GetTree();
1222 TTree * tree = fInput;
1223 TBranch * br = tree->GetBranch("Segment");
1224 br->SetAddress(&clrow);
1226 Int_t j=Int_t(tree->GetEntries());
1227 for (Int_t i=0; i<j; i++) {
1231 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1233 AliTPCRow * tpcrow=0;
1236 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1240 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1241 left = (sec-fkNIS*2)/fkNOS;
1244 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1245 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1246 for (Int_t i=0;i<tpcrow->fN1;i++)
1247 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1250 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1251 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1252 for (Int_t i=0;i<tpcrow->fN2;i++)
1253 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1264 void AliTPCtrackerMI::UnloadClusters()
1267 // unload clusters from the memory
1269 Int_t nrows = fOuterSec->GetNRows();
1270 for (Int_t sec = 0;sec<fkNOS;sec++)
1271 for (Int_t row = 0;row<nrows;row++){
1272 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1274 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1275 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1279 nrows = fInnerSec->GetNRows();
1280 for (Int_t sec = 0;sec<fkNIS;sec++)
1281 for (Int_t row = 0;row<nrows;row++){
1282 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1284 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1285 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1293 //_____________________________________________________________________________
1294 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1295 //-----------------------------------------------------------------
1296 // This function fills outer TPC sectors with clusters.
1297 //-----------------------------------------------------------------
1298 Int_t nrows = fOuterSec->GetNRows();
1300 for (Int_t sec = 0;sec<fkNOS;sec++)
1301 for (Int_t row = 0;row<nrows;row++){
1302 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1303 Int_t sec2 = sec+2*fkNIS;
1305 Int_t ncl = tpcrow->fN1;
1307 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1308 index=(((sec2<<8)+row)<<16)+ncl;
1309 tpcrow->InsertCluster(c,index);
1314 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1315 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1316 tpcrow->InsertCluster(c,index);
1319 // write indexes for fast acces
1321 for (Int_t i=0;i<510;i++)
1322 tpcrow->fFastCluster[i]=-1;
1323 for (Int_t i=0;i<tpcrow->GetN();i++){
1324 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1325 tpcrow->fFastCluster[zi]=i; // write index
1328 for (Int_t i=0;i<510;i++){
1329 if (tpcrow->fFastCluster[i]<0)
1330 tpcrow->fFastCluster[i] = last;
1332 last = tpcrow->fFastCluster[i];
1341 //_____________________________________________________________________________
1342 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1343 //-----------------------------------------------------------------
1344 // This function fills inner TPC sectors with clusters.
1345 //-----------------------------------------------------------------
1346 Int_t nrows = fInnerSec->GetNRows();
1348 for (Int_t sec = 0;sec<fkNIS;sec++)
1349 for (Int_t row = 0;row<nrows;row++){
1350 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1353 Int_t ncl = tpcrow->fN1;
1355 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1356 index=(((sec<<8)+row)<<16)+ncl;
1357 tpcrow->InsertCluster(c,index);
1362 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1363 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1364 tpcrow->InsertCluster(c,index);
1367 // write indexes for fast acces
1369 for (Int_t i=0;i<510;i++)
1370 tpcrow->fFastCluster[i]=-1;
1371 for (Int_t i=0;i<tpcrow->GetN();i++){
1372 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1373 tpcrow->fFastCluster[zi]=i; // write index
1376 for (Int_t i=0;i<510;i++){
1377 if (tpcrow->fFastCluster[i]<0)
1378 tpcrow->fFastCluster[i] = last;
1380 last = tpcrow->fFastCluster[i];
1392 //_________________________________________________________________________
1393 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1394 //--------------------------------------------------------------------
1395 // Return pointer to a given cluster
1396 //--------------------------------------------------------------------
1397 Int_t sec=(index&0xff000000)>>24;
1398 Int_t row=(index&0x00ff0000)>>16;
1399 Int_t ncl=(index&0x00007fff)>>00;
1401 const AliTPCRow * tpcrow=0;
1402 AliTPCclusterMI * clrow =0;
1404 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1406 clrow = tpcrow->fClusters1;
1408 clrow = tpcrow->fClusters2;
1411 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1412 if (sec-2*fkNIS<fkNOS)
1413 clrow = tpcrow->fClusters1;
1415 clrow = tpcrow->fClusters2;
1417 if (tpcrow==0) return 0;
1418 if (tpcrow->GetN()<=ncl) return 0;
1419 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1420 return &(clrow[ncl]);
1426 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1427 //-----------------------------------------------------------------
1428 // This function tries to find a track prolongation to next pad row
1429 //-----------------------------------------------------------------
1431 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1433 // if (t.GetRadius()>x+10 ) return 0;
1434 // t.PropagateTo(x+0.02);
1435 //t.PropagateTo(x+0.01);
1436 if (!t.PropagateTo(x)) {
1441 Double_t y=t.GetY(), z=t.GetZ();
1442 if (TMath::Abs(y)>ymax){
1444 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1445 if (!t.Rotate(fSectors->GetAlpha()))
1447 } else if (y <-ymax) {
1448 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1449 if (!t.Rotate(-fSectors->GetAlpha()))
1452 if (!t.PropagateTo(x)) {
1458 // update current shape info every 3 pad-row
1459 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1460 //t.fCurrentSigmaY = GetSigmaY(&t);
1461 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1465 AliTPCclusterMI *cl=0;
1470 if (t.GetClusterIndex2(nr)>0){
1472 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1473 index = t.GetClusterIndex2(nr);
1474 cl = t.fClusterPointer[nr];
1475 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1476 t.fCurrentClusterIndex1 = index;
1479 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1480 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1482 Double_t roadz = 1.;
1484 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1486 t.SetClusterIndex2(nr,-1);
1491 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1497 t.fCurrentCluster = cl;
1499 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1500 if (fIteration>0) accept =0;
1502 //if founded cluster is acceptible
1503 UpdateTrack(&t,accept);
1509 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1510 cl = krow.FindNearest2(y,z,roady,roadz,index);
1511 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1516 t.fCurrentCluster = cl;
1518 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1520 if (t.fCurrentCluster->IsUsed(10)){
1525 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1531 if (accept<3) UpdateTrack(&t,accept);
1534 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1540 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1541 //-----------------------------------------------------------------
1542 // This function tries to find a track prolongation to next pad row
1543 //-----------------------------------------------------------------
1545 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1547 if (!t.GetProlongation(x,y,z)) {
1553 if (TMath::Abs(y)>ymax){
1557 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1558 if (!t.Rotate(fSectors->GetAlpha()))
1560 } else if (y <-ymax) {
1561 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1562 if (!t.Rotate(-fSectors->GetAlpha()))
1565 if (!t.PropagateTo(x)) {
1568 t.GetProlongation(x,y,z);
1571 // update current shape info every 3 pad-row
1572 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1573 // t.fCurrentSigmaY = GetSigmaY(&t);
1574 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1578 AliTPCclusterMI *cl=0;
1583 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1584 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1586 Double_t roadz = 1.;
1589 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1591 t.SetClusterIndex2(row,-1);
1596 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1600 if ((cl==0)&&(krow)) {
1601 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1602 cl = krow.FindNearest2(y,z,roady,roadz,index);
1604 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1608 t.fCurrentCluster = cl;
1609 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1611 t.SetClusterIndex2(row,index);
1612 t.fClusterPointer[row] = cl;
1620 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1621 //-----------------------------------------------------------------
1622 // This function tries to find a track prolongation to next pad row
1623 //-----------------------------------------------------------------
1624 t.fCurrentCluster = 0;
1625 t.fCurrentClusterIndex1 = 0;
1627 Double_t xt=t.GetX();
1628 Int_t row = GetRowNumber(xt)-1;
1629 Double_t ymax= GetMaxY(nr);
1631 if (row < nr) return 1; // don't prolongate if not information until now -
1632 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1634 return 0; // not prolongate strongly inclined tracks
1636 if (TMath::Abs(t.GetSnp())>0.95) {
1638 return 0; // not prolongate strongly inclined tracks
1641 Double_t x= GetXrow(nr);
1643 //t.PropagateTo(x+0.02);
1644 //t.PropagateTo(x+0.01);
1645 if (!t.PropagateTo(x)){
1652 if (TMath::Abs(y)>ymax){
1654 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1655 if (!t.Rotate(fSectors->GetAlpha()))
1657 } else if (y <-ymax) {
1658 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1659 if (!t.Rotate(-fSectors->GetAlpha()))
1662 if (!t.PropagateTo(x)){
1669 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1671 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1673 t.SetClusterIndex2(nr,-1);
1678 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1684 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1685 // t.fCurrentSigmaY = GetSigmaY(&t);
1686 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1690 AliTPCclusterMI *cl=0;
1693 Double_t roady = 1.;
1694 Double_t roadz = 1.;
1698 index = t.GetClusterIndex2(nr);
1699 if ( (index>0) && (index&0x8000)==0){
1700 cl = t.fClusterPointer[nr];
1701 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1702 t.fCurrentClusterIndex1 = index;
1704 t.fCurrentCluster = cl;
1711 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1712 cl = krow.FindNearest2(y,z,roady,roadz,index);
1715 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1716 t.fCurrentCluster = cl;
1722 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1723 //-----------------------------------------------------------------
1724 // This function tries to find a track prolongation to next pad row
1725 //-----------------------------------------------------------------
1727 //update error according neighborhoud
1729 if (t.fCurrentCluster) {
1731 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1733 if (t.fCurrentCluster->IsUsed(10)){
1739 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1744 if (fIteration>0) accept = 0;
1745 if (accept<3) UpdateTrack(&t,accept);
1749 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1750 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1752 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1760 //_____________________________________________________________________________
1761 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1762 //-----------------------------------------------------------------
1763 // This function tries to find a track prolongation.
1764 //-----------------------------------------------------------------
1765 Double_t xt=t.GetX();
1767 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1768 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1769 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1771 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1773 Int_t first = GetRowNumber(xt)-1;
1774 for (Int_t nr= first; nr>=rf; nr-=step) {
1775 if (FollowToNext(t,nr)==0)
1776 if (!t.IsActive()) return 0;
1783 //_____________________________________________________________________________
1784 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1785 //-----------------------------------------------------------------
1786 // This function tries to find a track prolongation.
1787 //-----------------------------------------------------------------
1788 Double_t xt=t.GetX();
1790 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1791 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1792 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1793 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1795 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1797 if (FollowToNextFast(t,nr)==0)
1798 if (!t.IsActive()) return 0;
1808 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1809 //-----------------------------------------------------------------
1810 // This function tries to find a track prolongation.
1811 //-----------------------------------------------------------------
1812 // Double_t xt=t.GetX();
1814 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1815 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1816 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1817 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1820 first = t.fFirstPoint+3;
1822 if (first<0) first=0;
1823 for (Int_t nr=first+1; nr<=rf; nr++) {
1824 //if ( (t.GetSnp()<0.9))
1825 if (nr<fInnerSec->GetNRows())
1826 fSectors = fInnerSec;
1828 fSectors = fOuterSec;
1838 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1846 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1849 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1851 Float_t distance = TMath::Sqrt(dz2+dy2);
1852 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1855 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1856 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1861 if (firstpoint>lastpoint) {
1862 firstpoint =lastpoint;
1867 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1868 if (s1->GetClusterIndex2(i)>0) sum1++;
1869 if (s2->GetClusterIndex2(i)>0) sum2++;
1870 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1874 if (sum<5) return 0;
1876 Float_t summin = TMath::Min(sum1+1,sum2+1);
1877 Float_t ratio = (sum+1)/Float_t(summin);
1881 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1885 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1886 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1888 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1890 Float_t dy2 =(s1->GetY() - s2->GetY());
1892 Float_t distance = dz2+dy2;
1893 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1898 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1899 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1901 if (firstpoint>=lastpoint-5) return;;
1903 for (Int_t i=firstpoint;i<lastpoint;i++){
1904 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1905 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1912 for (Int_t i=firstpoint;i<lastpoint;i++){
1913 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1914 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1915 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1916 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1917 if (s1->IsActive()&&s2->IsActive()){
1918 p1->fIsShared = kTRUE;
1919 p2->fIsShared = kTRUE;
1926 for (Int_t i=0;i<4;i++){
1927 if (s1->fOverlapLabels[3*i]==0){
1928 s1->fOverlapLabels[3*i] = s2->GetLabel();
1929 s1->fOverlapLabels[3*i+1] = sumshared;
1930 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1934 for (Int_t i=0;i<4;i++){
1935 if (s2->fOverlapLabels[3*i]==0){
1936 s2->fOverlapLabels[3*i] = s1->GetLabel();
1937 s2->fOverlapLabels[3*i+1] = sumshared;
1938 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1946 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1949 //sort trackss according sectors
1951 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1952 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1954 //if (pt) RotateToLocal(pt);
1958 arr->Sort(); // sorting according z
1959 arr->Expand(arr->GetEntries());
1962 Int_t nseed=arr->GetEntriesFast();
1963 for (Int_t i=0; i<nseed; i++) {
1964 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1966 for (Int_t j=0;j<=12;j++){
1967 pt->fOverlapLabels[j] =0;
1970 for (Int_t i=0; i<nseed; i++) {
1971 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1973 if (pt->fRemoval>10) continue;
1974 for (Int_t j=i+1; j<nseed; j++){
1975 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1977 if (pt2->fRemoval<=10) {
1978 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1985 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1988 //sort trackss according sectors
1991 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1994 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1995 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2000 arr->Sort(); // sorting according z
2001 arr->Expand(arr->GetEntries());
2003 //reset overlap labels
2005 Int_t nseed=arr->GetEntriesFast();
2006 for (Int_t i=0; i<nseed; i++) {
2007 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2010 for (Int_t j=0;j<=12;j++){
2011 pt->fOverlapLabels[j] =0;
2015 //sign shared tracks
2016 for (Int_t i=0; i<nseed; i++) {
2017 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2019 if (pt->fRemoval>10) continue;
2020 Float_t deltac = pt->GetC()*0.1;
2021 for (Int_t j=i+1; j<nseed; j++){
2022 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2024 if (pt2->fRemoval<=10) {
2025 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2026 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2027 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2034 // remove highly shared tracks
2035 for (Int_t i=0; i<nseed; i++) {
2036 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2038 if (pt->fRemoval>10) continue;
2041 for (Int_t j=0;j<4;j++){
2042 sumshared = pt->fOverlapLabels[j*3+1];
2044 Float_t factor = factor1;
2045 if (pt->fRemoval>0) factor = factor2;
2046 if (sumshared/pt->GetNumberOfClusters()>factor){
2047 for (Int_t j=0;j<4;j++){
2048 if (pt->fOverlapLabels[3*j]==0) continue;
2049 if (pt->fOverlapLabels[3*j+1]<5) continue;
2050 if (pt->fRemoval==removalindex) continue;
2051 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2053 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2054 // pt->fRemoval = removalindex;
2055 delete arr->RemoveAt(i);
2063 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2072 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2075 //sort tracks in array according mode criteria
2076 Int_t nseed = arr->GetEntriesFast();
2077 for (Int_t i=0; i<nseed; i++) {
2078 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2088 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2091 //Loop over all tracks and remove "overlaps"
2094 Int_t nseed = arr->GetEntriesFast();
2097 for (Int_t i=0; i<nseed; i++) {
2098 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2100 delete arr->RemoveAt(i);
2104 pt->fBSigned = kFALSE;
2108 nseed = arr->GetEntriesFast();
2115 for (Int_t i=0; i<nseed; i++) {
2116 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2120 Int_t found,foundable,shared;
2122 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2124 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2126 Double_t factor = factor2;
2127 if (pt->fBConstrain) factor = factor1;
2129 if ((Float_t(shared)/Float_t(found))>factor){
2130 pt->Desactivate(removalindex);
2135 for (Int_t i=0; i<160; i++) {
2136 Int_t index=pt->GetClusterIndex2(i);
2137 if (index<0 || index&0x8000 ) continue;
2138 AliTPCclusterMI *c= pt->fClusterPointer[i];
2140 // if (!c->IsUsed(10)) c->Use(10);
2141 //if (pt->IsActive())
2150 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2153 void AliTPCtrackerMI::UnsignClusters()
2156 // loop over all clusters and unsign them
2159 for (Int_t sec=0;sec<fkNIS;sec++){
2160 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2161 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2162 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2163 // if (cl[icl].IsUsed(10))
2165 cl = fInnerSec[sec][row].fClusters2;
2166 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2167 //if (cl[icl].IsUsed(10))
2172 for (Int_t sec=0;sec<fkNOS;sec++){
2173 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2174 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2175 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2176 //if (cl[icl].IsUsed(10))
2178 cl = fOuterSec[sec][row].fClusters2;
2179 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2180 //if (cl[icl].IsUsed(10))
2189 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2192 //sign clusters to be "used"
2194 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2195 // loop over "primaries"
2209 Int_t nseed = arr->GetEntriesFast();
2210 for (Int_t i=0; i<nseed; i++) {
2211 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2215 if (!(pt->IsActive())) continue;
2216 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2217 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2219 sumdens2+= dens*dens;
2220 sumn += pt->GetNumberOfClusters();
2221 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2222 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2225 sumchi2 +=chi2*chi2;
2230 Float_t mdensity = 0.9;
2231 Float_t meann = 130;
2232 Float_t meanchi = 1;
2233 Float_t sdensity = 0.1;
2234 Float_t smeann = 10;
2235 Float_t smeanchi =0.4;
2239 mdensity = sumdens/sum;
2241 meanchi = sumchi/sum;
2243 sdensity = sumdens2/sum-mdensity*mdensity;
2244 sdensity = TMath::Sqrt(sdensity);
2246 smeann = sumn2/sum-meann*meann;
2247 smeann = TMath::Sqrt(smeann);
2249 smeanchi = sumchi2/sum - meanchi*meanchi;
2250 smeanchi = TMath::Sqrt(smeanchi);
2254 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2256 for (Int_t i=0; i<nseed; i++) {
2257 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2261 if (pt->fBSigned) continue;
2262 if (pt->fBConstrain) continue;
2263 //if (!(pt->IsActive())) continue;
2265 Int_t found,foundable,shared;
2266 pt->GetClusterStatistic(0,160,found, foundable,shared);
2267 if (shared/float(found)>0.3) {
2268 if (shared/float(found)>0.9 ){
2269 //delete arr->RemoveAt(i);
2274 Bool_t isok =kFALSE;
2275 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2277 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2279 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2281 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2285 for (Int_t i=0; i<160; i++) {
2286 Int_t index=pt->GetClusterIndex2(i);
2287 if (index<0) continue;
2288 AliTPCclusterMI *c= pt->fClusterPointer[i];
2290 //if (!(c->IsUsed(10))) c->Use();
2297 Double_t maxchi = meanchi+2.*smeanchi;
2299 for (Int_t i=0; i<nseed; i++) {
2300 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2304 //if (!(pt->IsActive())) continue;
2305 if (pt->fBSigned) continue;
2306 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2307 if (chi>maxchi) continue;
2310 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2312 //sign only tracks with enoug big density at the beginning
2314 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2317 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2318 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2320 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2321 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2324 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2325 //Int_t noc=pt->GetNumberOfClusters();
2326 pt->fBSigned = kTRUE;
2327 for (Int_t i=0; i<160; i++) {
2329 Int_t index=pt->GetClusterIndex2(i);
2330 if (index<0) continue;
2331 AliTPCclusterMI *c= pt->fClusterPointer[i];
2333 // if (!(c->IsUsed(10))) c->Use();
2338 // gLastCheck = nseed;
2346 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2348 // stop not active tracks
2349 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2350 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2351 Int_t nseed = arr->GetEntriesFast();
2353 for (Int_t i=0; i<nseed; i++) {
2354 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2358 if (!(pt->IsActive())) continue;
2359 StopNotActive(pt,row0,th0, th1,th2);
2365 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2368 // stop not active tracks
2369 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2370 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2373 Int_t foundable = 0;
2374 Int_t maxindex = seed->fLastPoint; //last foundable row
2375 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2376 seed->Desactivate(10) ;
2380 for (Int_t i=row0; i<maxindex; i++){
2381 Int_t index = seed->GetClusterIndex2(i);
2382 if (index!=-1) foundable++;
2384 if (foundable<=30) sumgood1++;
2385 if (foundable<=50) {
2392 if (foundable>=30.){
2393 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2396 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2400 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2403 // back propagation of ESD tracks
2409 PrepareForProlongation(fSeeds,1);
2411 Int_t nseed = fSeeds->GetEntriesFast();
2412 for (Int_t i=0;i<nseed;i++){
2413 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2414 seed->PropagateTo(fParam->GetInnerRadiusLow());
2415 AliESDtrack *esd=event->GetTrack(i);
2416 seed->CookdEdx(0.02,0.6);
2417 CookLabel(seed,0.1); //For comparison only
2418 if (seed->GetNumberOfClusters()>20){
2419 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2422 //printf("problem\n");
2431 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2434 // back propagation of ESD tracks
2440 PropagateBack(fSeeds);
2441 Int_t nseed = fSeeds->GetEntriesFast();
2442 for (Int_t i=0;i<nseed;i++){
2443 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2444 AliESDtrack *esd=event->GetTrack(i);
2445 seed->CookdEdx(0.02,0.6);
2446 CookLabel(seed,0.1); //For comparison only
2447 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2455 void AliTPCtrackerMI::DeleteSeeds()
2459 Int_t nseed = fSeeds->GetEntriesFast();
2460 for (Int_t i=0;i<nseed;i++){
2461 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2462 if (seed) delete fSeeds->RemoveAt(i);
2468 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2471 //read seeds from the event
2473 Int_t nentr=event->GetNumberOfTracks();
2474 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2478 fSeeds = new TObjArray;
2482 for (Int_t i=0; i<nentr; i++) {
2483 AliESDtrack *esd=event->GetTrack(i);
2484 ULong_t status=esd->GetStatus();
2485 AliTPCtrack t(*esd);
2486 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2487 if (status==AliESDtrack::kTPCin&&direction==1) seed->Modify(0.8);
2490 // rotate to the local coordinate system
2492 fSectors=fInnerSec; fN=fkNIS;
2494 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2495 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2496 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2497 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2498 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2499 alpha-=seed->GetAlpha();
2500 if (!seed->Rotate(alpha)) continue;
2503 //seed->PropagateTo(fSectors->GetX(0));
2505 // Int_t index = esd->GetTPCindex();
2506 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2507 //if (direction==2){
2508 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2515 fSeeds->AddLast(seed);
2521 //_____________________________________________________________________________
2522 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2523 Float_t deltay, Int_t ddsec) {
2524 //-----------------------------------------------------------------
2525 // This function creates track seeds.
2526 // SEEDING WITH VERTEX CONSTRAIN
2527 //-----------------------------------------------------------------
2528 // cuts[0] - fP4 cut
2529 // cuts[1] - tan(phi) cut
2530 // cuts[2] - zvertex cut
2531 // cuts[3] - fP3 cut
2539 Double_t x[5], c[15];
2540 // Int_t di = i1-i2;
2542 AliTPCseed * seed = new AliTPCseed;
2543 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2544 Double_t cs=cos(alpha), sn=sin(alpha);
2546 // Double_t x1 =fOuterSec->GetX(i1);
2547 //Double_t xx2=fOuterSec->GetX(i2);
2549 Double_t x1 =GetXrow(i1);
2550 Double_t xx2=GetXrow(i2);
2552 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2554 Int_t imiddle = (i2+i1)/2; //middle pad row index
2555 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2556 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2560 const AliTPCRow& kr1=GetRow(ns,i1);
2561 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2562 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2565 // change cut on curvature if it can't reach this layer
2566 // maximal curvature set to reach it
2567 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2568 if (dvertexmax*0.5*cuts[0]>0.85){
2569 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2571 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2574 if (deltay>0) ddsec = 0;
2575 // loop over clusters
2576 for (Int_t is=0; is < kr1; is++) {
2578 if (kr1[is]->IsUsed(10)) continue;
2579 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2580 //if (TMath::Abs(y1)>ymax) continue;
2582 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2584 // find possible directions
2585 Float_t anglez = (z1-z3)/(x1-x3);
2586 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2589 //find rotation angles relative to line given by vertex and point 1
2590 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2591 Double_t dvertex = TMath::Sqrt(dvertex2);
2592 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2593 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2596 // loop over 2 sectors
2602 Double_t dddz1=0; // direction of delta inclination in z axis
2609 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2610 Int_t sec2 = sec + dsec;
2612 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2613 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2614 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2615 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2616 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2617 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2619 // rotation angles to p1-p3
2620 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2621 Double_t x2, y2, z2;
2623 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2626 Double_t dxx0 = (xx2-x3)*cs13r;
2627 Double_t dyy0 = (xx2-x3)*sn13r;
2628 for (Int_t js=index1; js < index2; js++) {
2629 const AliTPCclusterMI *kcl = kr2[js];
2630 if (kcl->IsUsed(10)) continue;
2632 //calcutate parameters
2634 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2636 if (TMath::Abs(yy0)<0.000001) continue;
2637 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2638 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2639 Double_t r02 = (0.25+y0*y0)*dvertex2;
2640 //curvature (radius) cut
2641 if (r02<r2min) continue;
2645 Double_t c0 = 1/TMath::Sqrt(r02);
2649 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2650 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2651 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2652 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2655 Double_t z0 = kcl->GetZ();
2656 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2657 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2660 Double_t dip = (z1-z0)*c0/dfi1;
2661 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2672 x2= xx2*cs-y2*sn*dsec;
2673 y2=+xx2*sn*dsec+y2*cs;
2683 // do we have cluster at the middle ?
2685 GetProlongation(x1,xm,x,ym,zm);
2687 AliTPCclusterMI * cm=0;
2688 if (TMath::Abs(ym)-ymaxm<0){
2689 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2690 if ((!cm) || (cm->IsUsed(10))) {
2695 // rotate y1 to system 0
2696 // get state vector in rotated system
2697 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2698 Double_t xr2 = x0*cs+yr1*sn*dsec;
2699 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2701 GetProlongation(xx2,xm,xr,ym,zm);
2702 if (TMath::Abs(ym)-ymaxm<0){
2703 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2704 if ((!cm) || (cm->IsUsed(10))) {
2714 dym = ym - cm->GetY();
2715 dzm = zm - cm->GetZ();
2722 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2723 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2724 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2725 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2726 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2728 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2729 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2730 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2731 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2732 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2733 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2735 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2736 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2737 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2738 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2742 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2743 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2744 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2745 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2746 c[13]=f30*sy1*f40+f32*sy2*f42;
2747 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2749 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2751 UInt_t index=kr1.GetIndex(is);
2752 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2754 track->fIsSeeding = kTRUE;
2761 FollowProlongation(*track, (i1+i2)/2,1);
2762 Int_t foundable,found,shared;
2763 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2764 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2766 seed->~AliTPCseed();
2772 FollowProlongation(*track, i2,1);
2776 track->fBConstrain =1;
2777 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2778 track->fLastPoint = i1; // first cluster in track position
2779 track->fFirstPoint = track->fLastPoint;
2781 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2782 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2783 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2785 seed->~AliTPCseed();
2789 // Z VERTEX CONDITION
2791 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2792 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2793 if (TMath::Abs(zv-z3)>cuts[2]) {
2794 FollowProlongation(*track, TMath::Max(i2-20,0));
2795 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2796 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2797 if (TMath::Abs(zv-z3)>cuts[2]){
2798 FollowProlongation(*track, TMath::Max(i2-40,0));
2799 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2800 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2801 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2802 // make seed without constrain
2803 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2804 FollowProlongation(*track2, i2,1);
2805 track2->fBConstrain = kFALSE;
2806 track2->fSeedType = 1;
2807 arr->AddLast(track2);
2809 seed->~AliTPCseed();
2814 seed->~AliTPCseed();
2821 track->fSeedType =0;
2822 arr->AddLast(track);
2823 seed = new AliTPCseed;
2825 // don't consider other combinations
2826 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2832 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2838 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2843 //-----------------------------------------------------------------
2844 // This function creates track seeds.
2845 //-----------------------------------------------------------------
2846 // cuts[0] - fP4 cut
2847 // cuts[1] - tan(phi) cut
2848 // cuts[2] - zvertex cut
2849 // cuts[3] - fP3 cut
2859 Double_t x[5], c[15];
2861 // make temporary seed
2862 AliTPCseed * seed = new AliTPCseed;
2863 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2864 // Double_t cs=cos(alpha), sn=sin(alpha);
2869 Double_t x1 = GetXrow(i1-1);
2870 const AliTPCRow& kr1=GetRow(sec,i1-1);
2871 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2873 Double_t x1p = GetXrow(i1);
2874 const AliTPCRow& kr1p=GetRow(sec,i1);
2876 Double_t x1m = GetXrow(i1-2);
2877 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2880 //last 3 padrow for seeding
2881 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2882 Double_t x3 = GetXrow(i1-7);
2883 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2885 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2886 Double_t x3p = GetXrow(i1-6);
2888 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2889 Double_t x3m = GetXrow(i1-8);
2894 Int_t im = i1-4; //middle pad row index
2895 Double_t xm = GetXrow(im); // radius of middle pad-row
2896 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2897 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2900 Double_t deltax = x1-x3;
2901 Double_t dymax = deltax*cuts[1];
2902 Double_t dzmax = deltax*cuts[3];
2904 // loop over clusters
2905 for (Int_t is=0; is < kr1; is++) {
2907 if (kr1[is]->IsUsed(10)) continue;
2908 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2910 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2912 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2913 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2919 for (Int_t js=index1; js < index2; js++) {
2920 const AliTPCclusterMI *kcl = kr3[js];
2921 if (kcl->IsUsed(10)) continue;
2923 // apply angular cuts
2924 if (TMath::Abs(y1-y3)>dymax) continue;
2927 if (TMath::Abs(z1-z3)>dzmax) continue;
2929 Double_t angley = (y1-y3)/(x1-x3);
2930 Double_t anglez = (z1-z3)/(x1-x3);
2932 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2933 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2935 Double_t yyym = angley*(xm-x1)+y1;
2936 Double_t zzzm = anglez*(xm-x1)+z1;
2938 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2940 if (kcm->IsUsed(10)) continue;
2942 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2943 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2950 // look around first
2951 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2957 if (kc1m->IsUsed(10)) used++;
2959 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2965 if (kc1p->IsUsed(10)) used++;
2967 if (used>1) continue;
2968 if (found<1) continue;
2972 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2978 if (kc3m->IsUsed(10)) used++;
2982 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2988 if (kc3p->IsUsed(10)) used++;
2992 if (used>1) continue;
2993 if (found<3) continue;
3003 x[4]=F1(x1,y1,x2,y2,x3,y3);
3004 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3007 x[2]=F2(x1,y1,x2,y2,x3,y3);
3010 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3011 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3015 Double_t sy1=0.1, sz1=0.1;
3016 Double_t sy2=0.1, sz2=0.1;
3017 Double_t sy3=0.1, sy=0.1, sz=0.1;
3019 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3020 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3021 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3022 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3023 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3024 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3026 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3027 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3028 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3029 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3033 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3034 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3035 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3036 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3037 c[13]=f30*sy1*f40+f32*sy2*f42;
3038 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3040 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3042 UInt_t index=kr1.GetIndex(is);
3043 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3045 track->fIsSeeding = kTRUE;
3048 FollowProlongation(*track, i1-7,1);
3049 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3050 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3052 seed->~AliTPCseed();
3058 FollowProlongation(*track, i2,1);
3059 track->fBConstrain =0;
3060 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3061 track->fFirstPoint = track->fLastPoint;
3063 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3064 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3065 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3067 seed->~AliTPCseed();
3072 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3073 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3074 FollowProlongation(*track2, i2,1);
3075 track2->fBConstrain = kFALSE;
3076 track2->fSeedType = 4;
3077 arr->AddLast(track2);
3079 seed->~AliTPCseed();
3083 //arr->AddLast(track);
3084 //seed = new AliTPCseed;
3090 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3096 //_____________________________________________________________________________
3097 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3098 Float_t deltay, Bool_t /*bconstrain*/) {
3099 //-----------------------------------------------------------------
3100 // This function creates track seeds - without vertex constraint
3101 //-----------------------------------------------------------------
3102 // cuts[0] - fP4 cut - not applied
3103 // cuts[1] - tan(phi) cut
3104 // cuts[2] - zvertex cut - not applied
3105 // cuts[3] - fP3 cut
3115 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3116 // Double_t cs=cos(alpha), sn=sin(alpha);
3117 Int_t row0 = (i1+i2)/2;
3118 Int_t drow = (i1-i2)/2;
3119 const AliTPCRow& kr0=fSectors[sec][row0];
3122 AliTPCpolyTrack polytrack;
3123 Int_t nclusters=fSectors[sec][row0];
3124 AliTPCseed * seed = new AliTPCseed;
3129 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3131 Int_t nfoundable =0;
3132 for (Int_t iter =1; iter<2; iter++){ //iterations
3133 const AliTPCRow& krm=fSectors[sec][row0-iter];
3134 const AliTPCRow& krp=fSectors[sec][row0+iter];
3135 const AliTPCclusterMI * cl= kr0[is];
3137 if (cl->IsUsed(10)) {
3143 Double_t x = kr0.GetX();
3144 // Initialization of the polytrack
3149 Double_t y0= cl->GetY();
3150 Double_t z0= cl->GetZ();
3154 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3155 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3157 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3158 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3159 polytrack.AddPoint(x,y0,z0,erry, errz);
3162 if (cl->IsUsed(10)) sumused++;
3165 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3166 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3169 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3170 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3171 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3172 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3173 if (cl1->IsUsed(10)) sumused++;
3174 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3178 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3180 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3181 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3182 if (cl2->IsUsed(10)) sumused++;
3183 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3186 if (sumused>0) continue;
3188 polytrack.UpdateParameters();
3194 nfoundable = polytrack.GetN();
3195 nfound = nfoundable;
3197 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3198 Float_t maxdist = 0.8*(1.+3./(ddrow));
3199 for (Int_t delta = -1;delta<=1;delta+=2){
3200 Int_t row = row0+ddrow*delta;
3201 kr = &(fSectors[sec][row]);
3202 Double_t xn = kr->GetX();
3203 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3204 polytrack.GetFitPoint(xn,yn,zn);
3205 if (TMath::Abs(yn)>ymax) continue;
3207 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3209 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3212 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3213 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3214 if (cln->IsUsed(10)) {
3215 // printf("used\n");
3223 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3228 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3229 polytrack.UpdateParameters();
3232 if ( (sumused>3) || (sumused>0.5*nfound)) {
3233 //printf("sumused %d\n",sumused);
3238 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3239 AliTPCpolyTrack track2;
3241 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3242 if (track2.GetN()<0.5*nfoundable) continue;
3245 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3247 // test seed with and without constrain
3248 for (Int_t constrain=0; constrain<=0;constrain++){
3249 // add polytrack candidate
3251 Double_t x[5], c[15];
3252 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3253 track2.GetBoundaries(x3,x1);
3255 track2.GetFitPoint(x1,y1,z1);
3256 track2.GetFitPoint(x2,y2,z2);
3257 track2.GetFitPoint(x3,y3,z3);
3259 //is track pointing to the vertex ?
3262 polytrack.GetFitPoint(x0,y0,z0);
3275 x[4]=F1(x1,y1,x2,y2,x3,y3);
3277 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3278 x[2]=F2(x1,y1,x2,y2,x3,y3);
3280 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3281 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3282 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3283 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3286 Double_t sy =0.1, sz =0.1;
3287 Double_t sy1=0.02, sz1=0.02;
3288 Double_t sy2=0.02, sz2=0.02;
3292 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3295 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3296 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3297 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3298 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3299 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3300 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3302 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3303 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3304 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3305 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3310 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3311 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3312 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3313 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3314 c[13]=f30*sy1*f40+f32*sy2*f42;
3315 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3317 //Int_t row1 = fSectors->GetRowNumber(x1);
3318 Int_t row1 = GetRowNumber(x1);
3322 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3323 track->fIsSeeding = kTRUE;
3324 Int_t rc=FollowProlongation(*track, i2);
3325 if (constrain) track->fBConstrain =1;
3327 track->fBConstrain =0;
3328 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3329 track->fFirstPoint = track->fLastPoint;
3331 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3332 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3333 track->fNShared>0.4*track->GetNumberOfClusters()) {
3336 seed->~AliTPCseed();
3339 arr->AddLast(track);
3340 seed = new AliTPCseed;
3344 } // if accepted seed
3347 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3353 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3357 //reseed using track points
3358 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3359 Int_t p1 = int(r1*track->GetNumberOfClusters());
3360 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3362 Double_t x0[3],x1[3],x2[3];
3367 // find track position at given ratio of the length
3368 Int_t sec0, sec1, sec2;
3374 for (Int_t i=0;i<160;i++){
3375 if (track->fClusterPointer[i]){
3377 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3378 if ( (index<p0) || x0[0]<0 ){
3379 if (trpoint->GetX()>1){
3380 clindex = track->GetClusterIndex2(i);
3382 x0[0] = trpoint->GetX();
3383 x0[1] = trpoint->GetY();
3384 x0[2] = trpoint->GetZ();
3385 sec0 = ((clindex&0xff000000)>>24)%18;
3390 if ( (index<p1) &&(trpoint->GetX()>1)){
3391 clindex = track->GetClusterIndex2(i);
3393 x1[0] = trpoint->GetX();
3394 x1[1] = trpoint->GetY();
3395 x1[2] = trpoint->GetZ();
3396 sec1 = ((clindex&0xff000000)>>24)%18;
3399 if ( (index<p2) &&(trpoint->GetX()>1)){
3400 clindex = track->GetClusterIndex2(i);
3402 x2[0] = trpoint->GetX();
3403 x2[1] = trpoint->GetY();
3404 x2[2] = trpoint->GetZ();
3405 sec2 = ((clindex&0xff000000)>>24)%18;
3412 Double_t alpha, cs,sn, xx2,yy2;
3414 alpha = (sec1-sec2)*fSectors->GetAlpha();
3415 cs = TMath::Cos(alpha);
3416 sn = TMath::Sin(alpha);
3417 xx2= x1[0]*cs-x1[1]*sn;
3418 yy2= x1[0]*sn+x1[1]*cs;
3422 alpha = (sec0-sec2)*fSectors->GetAlpha();
3423 cs = TMath::Cos(alpha);
3424 sn = TMath::Sin(alpha);
3425 xx2= x0[0]*cs-x0[1]*sn;
3426 yy2= x0[0]*sn+x0[1]*cs;
3432 Double_t x[5],c[15];
3436 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3437 // if (x[4]>1) return 0;
3438 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3439 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3440 //if (TMath::Abs(x[3]) > 2.2) return 0;
3441 //if (TMath::Abs(x[2]) > 1.99) return 0;
3443 Double_t sy =0.1, sz =0.1;
3445 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3446 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3447 Double_t sy3=0.01+track->GetSigmaY2();
3449 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3450 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3451 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3452 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3453 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3454 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3456 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3457 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3458 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3459 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3464 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3465 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3466 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3467 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3468 c[13]=f30*sy1*f40+f32*sy2*f42;
3469 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3471 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3472 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3473 // Double_t y0,z0,y1,z1, y2,z2;
3474 //seed->GetProlongation(x0[0],y0,z0);
3475 // seed->GetProlongation(x1[0],y1,z1);
3476 //seed->GetProlongation(x2[0],y2,z2);
3478 seed->fLastPoint = pp2;
3479 seed->fFirstPoint = pp2;
3486 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3490 //reseed using founded clusters
3492 // Find the number of clusters
3493 Int_t nclusters = 0;
3494 for (Int_t irow=0;irow<160;irow++){
3495 if (track->GetClusterIndex(irow)>0) nclusters++;
3499 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3500 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3501 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3505 Int_t row[3],sec[3]={0,0,0};
3507 // find track row position at given ratio of the length
3509 for (Int_t irow=0;irow<160;irow++){
3510 if (track->GetClusterIndex2(irow)<0) continue;
3512 for (Int_t ipoint=0;ipoint<3;ipoint++){
3513 if (index<=ipos[ipoint]) row[ipoint] = irow;
3517 //Get cluster and sector position
3518 for (Int_t ipoint=0;ipoint<3;ipoint++){
3519 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3520 AliTPCclusterMI * cl = GetClusterMI(clindex);
3523 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3526 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3527 xyz[ipoint][0] = GetXrow(row[ipoint]);
3528 xyz[ipoint][1] = cl->GetY();
3529 xyz[ipoint][2] = cl->GetZ();
3533 // Calculate seed state vector and covariance matrix
3535 Double_t alpha, cs,sn, xx2,yy2;
3537 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3538 cs = TMath::Cos(alpha);
3539 sn = TMath::Sin(alpha);
3540 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3541 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3545 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3546 cs = TMath::Cos(alpha);
3547 sn = TMath::Sin(alpha);
3548 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3549 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3555 Double_t x[5],c[15];
3559 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3560 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3561 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3563 Double_t sy =0.1, sz =0.1;
3565 Double_t sy1=0.2, sz1=0.2;
3566 Double_t sy2=0.2, sz2=0.2;
3569 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;
3570 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;
3571 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;
3572 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;
3573 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;
3574 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;
3576 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;
3577 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;
3578 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;
3579 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;
3584 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3585 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3586 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3587 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3588 c[13]=f30*sy1*f40+f32*sy2*f42;
3589 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3591 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3592 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3593 seed->fLastPoint = row[2];
3594 seed->fFirstPoint = row[2];
3598 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3603 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3605 if (TMath::Abs(seed->GetC())>0.01) return 0;
3608 Float_t x[160], y[160], erry[160], z[160], errz[160];
3610 Float_t xt[160], yt[160], zt[160];
3615 Int_t middle = seed->GetNumberOfClusters()/2;
3618 // find central sector, get local cooordinates
3620 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3621 sec[i]= seed->GetClusterSector(i)%18;
3624 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3625 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3632 if (i>i2) i2 = i; //last point with cluster
3633 if (i2<i1) i1 = i; //first point with cluster
3636 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3638 yt[i] = point->GetY();
3639 zt[i] = point->GetZ();
3641 if (point->GetX()>0){
3642 erry[i] = point->GetErrY();
3643 errz[i] = point->GetErrZ();
3648 secm = sec[i]; //central sector
3649 padm = i; //middle point with cluster
3654 // rotate position to global coordinate system connected to sector at last the point
3656 for (Int_t i=i1;i<=i2;i++){
3658 if (sec[i]<0) continue;
3659 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3660 Double_t cs = TMath::Cos(alpha);
3661 Double_t sn = TMath::Sin(alpha);
3662 Float_t xx2= x[i]*cs+y[i]*sn;
3663 Float_t yy2= -x[i]*sn+y[i]*cs;
3667 xx2= xt[i]*cs+yt[i]*sn;
3668 yy2= -xt[i]*sn+yt[i]*cs;
3673 //get "state" vector
3674 Double_t xh[5],xm = x[padm];
3677 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3678 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3679 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3682 for (Int_t i=i1;i<=i2;i++){
3684 if (sec[i]<0) continue;
3685 GetProlongation(x[i2], x[i],xh,yy,zz);
3686 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3688 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3689 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3690 printf("problem\n");
3695 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3696 Float_t yup[160], ydown[160], zup[160], zdown[160];
3698 AliTPCpolyTrack ptrack1,ptrack2;
3701 for (Int_t i=i1;i<=i2;i++){
3702 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3704 if (cl->GetType()<0) continue;
3705 if (cl->GetType()>10) continue;
3708 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3710 if (ptrack1.GetN()>4.){
3711 ptrack1.UpdateParameters();
3713 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3715 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3724 dyup[i]=0.; //not enough points
3729 for (Int_t i=i2;i>=i1;i--){
3730 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3732 if (cl->GetType()<0) continue;
3733 if (cl->GetType()>10) continue;
3735 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3737 if (ptrack2.GetN()>4){
3738 ptrack2.UpdateParameters();
3740 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3742 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3750 dydown[i]=0.; //not enough points
3755 // find maximal difference of the derivation
3756 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3759 for (Int_t i=i1+10;i<i2-10;i++){
3760 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3761 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3763 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3764 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3765 if ( (ddy+ddz)> th){
3766 seed->fKinkPoint[0] = i;
3767 seed->fKinkPoint[1] = ddy;
3768 seed->fKinkPoint[2] = ddz;
3775 //write information to the debug tree
3776 TBranch * br = fTreeDebug->GetBranch("debug");
3777 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3778 arr->ExpandCreateFast(i2-i1);
3779 br->SetAddress(&arr);
3781 AliTPCclusterMI cldummy;
3783 AliTPCTrackPoint2 pdummy;
3784 pdummy.GetTPoint().fIsShared = 10;
3786 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3787 Double_t cs = TMath::Cos(alpha);
3788 Double_t sn = TMath::Sin(alpha);
3790 for (Int_t i=i1;i<i2;i++){
3791 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3793 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3795 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3798 Double_t x = GetXrow(i);
3799 trpoint->GetTPoint() = *point;
3800 trpoint->GetCPoint() = *cl0;
3801 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3802 trpoint->fID = seed->GetUniqueID();
3803 trpoint->fLab = seed->GetLabel();
3805 trpoint->fGX = cs *x + sn*point->GetY();
3806 trpoint->fGY = -sn *x + cs*point->GetY() ;
3807 trpoint->fGZ = point->GetZ();
3809 trpoint->fDY = y[i];
3810 trpoint->fDZ = z[i];
3812 trpoint->fDYU = dyup[i];
3813 trpoint->fDZU = dzup[i];
3815 trpoint->fDYD = dydown[i];
3816 trpoint->fDZD = dzdown[i];
3818 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3819 trpoint->fDDY = dydown[i]-dyup[i];
3820 trpoint->fDDZ = dzdown[i]-dzup[i];
3828 trpoint->GetCPoint()= cldummy;
3845 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3848 // reseed - refit - track
3851 // Int_t last = fSectors->GetNRows()-1;
3853 if (fSectors == fOuterSec){
3854 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3858 first = t->fFirstPoint;
3860 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3861 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3863 FollowProlongation(*t,first);
3873 //_____________________________________________________________________________
3874 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3875 //-----------------------------------------------------------------
3876 // This function reades track seeds.
3877 //-----------------------------------------------------------------
3878 TDirectory *savedir=gDirectory;
3880 TFile *in=(TFile*)inp;
3881 if (!in->IsOpen()) {
3882 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3887 TTree *seedTree=(TTree*)in->Get("Seeds");
3889 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3890 cerr<<"can't get a tree with track seeds !\n";
3893 AliTPCtrack *seed=new AliTPCtrack;
3894 seedTree->SetBranchAddress("tracks",&seed);
3896 if (fSeeds==0) fSeeds=new TObjArray(15000);
3898 Int_t n=(Int_t)seedTree->GetEntries();
3899 for (Int_t i=0; i<n; i++) {
3900 seedTree->GetEvent(i);
3901 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3910 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
3915 if (!fSeeds) return 1;
3922 //_____________________________________________________________________________
3923 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3924 //-----------------------------------------------------------------
3925 // This is a track finder.
3926 //-----------------------------------------------------------------
3927 TDirectory *savedir=gDirectory;
3931 fSeeds = Tracking();
3934 printf("Time for tracking: \t");timer.Print();timer.Start();
3936 //activate again some tracks
3937 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3938 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3940 Int_t nc=t.GetNumberOfClusters();
3942 delete fSeeds->RemoveAt(i);
3945 if (pt->fRemoval==10) {
3946 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3947 pt->Desactivate(10); // make track again active
3949 pt->Desactivate(20);
3950 delete fSeeds->RemoveAt(i);
3954 RemoveDouble(fSeeds,0.2,0.6,11);
3955 RemoveUsed(fSeeds,0.5,0.5,6);
3958 Int_t nseed=fSeeds->GetEntriesFast();
3960 for (Int_t i=0; i<nseed; i++) {
3961 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3963 Int_t nc=t.GetNumberOfClusters();
3965 delete fSeeds->RemoveAt(i);
3968 CookLabel(pt,0.1); //For comparison only
3969 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3970 if ((pt->IsActive() || (pt->fRemoval==10) )){
3971 cerr<<found++<<'\r';
3975 delete fSeeds->RemoveAt(i);
3979 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3981 //RemoveUsed(fSeeds,0.9,0.9,6);
3983 nseed=fSeeds->GetEntriesFast();
3985 for (Int_t i=0; i<nseed; i++) {
3986 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3988 Int_t nc=t.GetNumberOfClusters();
3990 delete fSeeds->RemoveAt(i);
3994 t.CookdEdx(0.02,0.6);
3995 // CheckKinkPoint(&t,0.05);
3996 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3997 if ((pt->IsActive() || (pt->fRemoval==10) )){
3998 cerr<<found++<<'\r';
4002 delete fSeeds->RemoveAt(i);
4003 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
4005 // FollowProlongation(*seed1,0);
4006 // Int_t n = seed1->GetNumberOfClusters();
4007 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
4008 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
4011 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
4015 SortTracks(fSeeds, 1);
4019 PrepareForBackProlongation(fSeeds,0.5);
4020 PropagateBack(fSeeds);
4021 printf("Time for back propagation: \t");timer.Print();timer.Start();
4025 PrepareForProlongation(fSeeds,1.);
4028 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
4029 // RemoveUsed(fSeeds,0.7,0.7,6);
4030 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
4032 nseed=fSeeds->GetEntriesFast();
4034 for (Int_t i=0; i<nseed; i++) {
4035 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4037 Int_t nc=t.GetNumberOfClusters();
4039 delete fSeeds->RemoveAt(i);
4042 t.CookdEdx(0.02,0.6);
4043 // CookLabel(pt,0.1); //For comparison only
4044 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4045 if ((pt->IsActive() || (pt->fRemoval==10) )){
4046 cerr<<found++<<'\r';
4049 delete fSeeds->RemoveAt(i);
4054 // fNTracks = found;
4055 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
4057 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
4059 // UnloadClusters();
4064 void AliTPCtrackerMI::Tracking(TObjArray * arr)
4067 // tracking of the seeds
4070 fSectors = fOuterSec;
4071 ParallelTracking(arr,150,63);
4072 fSectors = fOuterSec;
4073 ParallelTracking(arr,63,0);
4076 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
4081 TObjArray * arr = new TObjArray;
4083 fSectors = fOuterSec;
4086 for (Int_t sec=0;sec<fkNOS;sec++){
4087 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
4088 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
4089 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
4092 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
4104 TObjArray * AliTPCtrackerMI::Tracking()
4110 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
4112 TObjArray * seeds = new TObjArray;
4121 Float_t fnumber = 3.0;
4122 Float_t fdensity = 3.0;
4127 for (Int_t delta = 0; delta<18; delta+=6){
4131 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
4132 SumTracks(seeds,arr);
4133 SignClusters(seeds,fnumber,fdensity);
4135 for (Int_t i=2;i<6;i+=2){
4136 // seed high pt tracks
4139 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
4140 SumTracks(seeds,arr);
4141 SignClusters(seeds,fnumber,fdensity);
4146 // RemoveUsed(seeds,0.9,0.9,1);
4147 // UnsignClusters();
4148 // SignClusters(seeds,fnumber,fdensity);
4152 for (Int_t delta = 20; delta<120; delta+=10){
4154 // seed high pt tracks
4158 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
4159 SumTracks(seeds,arr);
4160 SignClusters(seeds,fnumber,fdensity);
4165 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4166 SumTracks(seeds,arr);
4167 SignClusters(seeds,fnumber,fdensity);
4178 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4182 // RemoveUsed(seeds,0.75,0.75,1);
4184 //SignClusters(seeds,fnumber,fdensity);
4193 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4194 SumTracks(seeds,arr);
4195 SignClusters(seeds,fnumber,fdensity);
4197 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4198 SumTracks(seeds,arr);
4199 SignClusters(seeds,fnumber,fdensity);
4201 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4202 SumTracks(seeds,arr);
4203 SignClusters(seeds,fnumber,fdensity);
4207 for (Int_t delta = 3; delta<30; delta+=5){
4213 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4214 SumTracks(seeds,arr);
4215 SignClusters(seeds,fnumber,fdensity);
4217 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4218 SumTracks(seeds,arr);
4219 SignClusters(seeds,fnumber,fdensity);
4231 for (Int_t delta = 30; delta<70; delta+=10){
4237 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4238 SumTracks(seeds,arr);
4239 SignClusters(seeds,fnumber,fdensity);
4241 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4242 SumTracks(seeds,arr);
4243 SignClusters(seeds,fnumber,fdensity);
4247 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4258 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
4261 //sum tracks to common container
4262 //remove suspicious tracks
4263 Int_t nseed = arr2->GetEntriesFast();
4264 for (Int_t i=0;i<nseed;i++){
4265 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4268 // NORMAL ACTIVE TRACK
4269 if (pt->IsActive()){
4270 arr1->AddLast(arr2->RemoveAt(i));
4273 //remove not usable tracks
4274 if (pt->fRemoval!=10){
4275 delete arr2->RemoveAt(i);
4278 // REMOVE VERY SHORT TRACKS
4279 if (pt->GetNumberOfClusters()<20){
4280 delete arr2->RemoveAt(i);
4283 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4284 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4285 arr1->AddLast(arr2->RemoveAt(i));
4287 delete arr2->RemoveAt(i);
4296 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4299 // try to track in parralel
4301 Int_t nseed=arr->GetEntriesFast();
4302 //prepare seeds for tracking
4303 for (Int_t i=0; i<nseed; i++) {
4304 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4306 if (!t.IsActive()) continue;
4307 // follow prolongation to the first layer
4308 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4309 FollowProlongation(t, rfirst+1);
4314 for (Int_t nr=rfirst; nr>=rlast; nr--){
4315 // make indexes with the cluster tracks for given
4317 // find nearest cluster
4318 for (Int_t i=0; i<nseed; i++) {
4319 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4321 if (!pt->IsActive()) continue;
4322 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4323 if (pt->fRelativeSector>17) {
4326 UpdateClusters(t,nr);
4328 // prolonagate to the nearest cluster - if founded
4329 for (Int_t i=0; i<nseed; i++) {
4330 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4332 if (!pt->IsActive()) continue;
4333 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4334 if (pt->fRelativeSector>17) {
4337 FollowToNextCluster(*pt,nr);
4342 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
4346 // if we use TPC track itself we have to "update" covariance
4348 Int_t nseed= arr->GetEntriesFast();
4349 for (Int_t i=0;i<nseed;i++){
4350 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4354 //rotate to current local system at first accepted point
4355 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4356 Int_t sec = (index&0xff000000)>>24;
4358 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4359 if (angle1>TMath::Pi())
4360 angle1-=2.*TMath::Pi();
4361 Float_t angle2 = pt->GetAlpha();
4363 if (TMath::Abs(angle1-angle2)>0.001){
4364 pt->Rotate(angle1-angle2);
4365 //angle2 = pt->GetAlpha();
4366 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4367 //if (pt->GetAlpha()<0)
4368 // pt->fRelativeSector+=18;
4369 //sec = pt->fRelativeSector;
4378 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
4382 // if we use TPC track itself we have to "update" covariance
4384 Int_t nseed= arr->GetEntriesFast();
4385 for (Int_t i=0;i<nseed;i++){
4386 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4389 pt->fFirstPoint = pt->fLastPoint;
4397 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4400 // make back propagation
4402 Int_t nseed= arr->GetEntriesFast();
4403 for (Int_t i=0;i<nseed;i++){
4404 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4406 AliTPCseed *pt2 = new AliTPCseed(*pt);
4407 fSectors = fInnerSec;
4408 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
4409 //fSectors = fOuterSec;
4410 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4412 if (pt->GetNumberOfClusters()<20 && pt->GetLabel()>0 ){
4413 printf("\n%d",pt->GetLabel());
4414 fSectors = fInnerSec;
4415 //FollowBackProlongation(*pt2,fInnerSec->GetNRows()-1);
4416 //fSectors = fOuterSec;
4417 FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4425 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4428 // make forward propagation
4430 Int_t nseed= arr->GetEntriesFast();
4431 for (Int_t i=0;i<nseed;i++){
4432 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4434 AliTPCseed *pt2 = new AliTPCseed(*pt);
4435 fSectors = fOuterSec;
4436 FollowProlongation(*pt,0);
4437 fSectors = fOuterSec;
4438 FollowProlongation(*pt,0);
4439 fSectors = fInnerSec;
4440 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4441 printf("\n%d",pt->GetLabel());
4442 fSectors = fOuterSec;
4443 FollowProlongation(*pt2,0);
4444 fSectors = fOuterSec;
4445 FollowProlongation(*pt2,0);
4446 fSectors = fOuterSec;
4454 Int_t AliTPCtrackerMI::PropagateForward()
4457 // propagate track forward
4459 Int_t nseed = fSeeds->GetEntriesFast();
4460 for (Int_t i=0;i<nseed;i++){
4461 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
4463 AliTPCseed &t = *pt;
4464 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
4465 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
4466 if (alpha < 0. ) alpha += 2.*TMath::Pi();
4467 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
4471 fSectors = fOuterSec;
4472 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
4473 fSectors = fInnerSec;
4474 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
4484 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4487 // make back propagation, in between row0 and row1
4491 fSectors = fInnerSec;
4494 if (row1<fSectors->GetNRows())
4497 r1 = fSectors->GetNRows()-1;
4499 if (row0<fSectors->GetNRows()&& r1>0 )
4500 FollowBackProlongation(*pt,r1);
4501 if (row1<=fSectors->GetNRows())
4504 r1 = row1 - fSectors->GetNRows();
4505 if (r1<=0) return 0;
4506 if (r1>=fOuterSec->GetNRows()) return 0;
4507 fSectors = fOuterSec;
4508 return FollowBackProlongation(*pt,r1);
4516 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4520 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4521 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4522 Float_t padlength = GetPadPitchLength(row);
4524 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4525 Float_t angulary = seed->GetSnp();
4526 angulary = angulary*angulary/(1-angulary*angulary);
4527 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4529 Float_t sresz = fParam->GetZSigma();
4530 Float_t angularz = seed->GetTgl();
4531 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4533 Float_t wy = GetSigmaY(seed);
4534 Float_t wz = GetSigmaZ(seed);
4537 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4538 printf("problem\n");
4544 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4548 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4549 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4550 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4551 Float_t angular = seed->GetSnp();
4552 angular = angular*angular/(1-angular*angular);
4553 // angular*=angular;
4554 //angular = TMath::Sqrt(angular/(1-angular));
4555 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4558 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4562 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4563 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4564 Float_t sres = fParam->GetZSigma();
4565 Float_t angular = seed->GetTgl();
4566 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4573 //__________________________________________________________________________
4574 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4575 //--------------------------------------------------------------------
4576 //This function "cooks" a track label. If label<0, this track is fake.
4577 //--------------------------------------------------------------------
4578 Int_t noc=t->GetNumberOfClusters();
4580 //printf("\nnot founded prolongation\n\n\n");
4586 AliTPCclusterMI *clusters[160];
4588 for (Int_t i=0;i<160;i++) {
4595 for (i=0; i<160 && current<noc; i++) {
4597 Int_t index=t->GetClusterIndex2(i);
4598 if (index<=0) continue;
4599 if (index&0x8000) continue;
4601 //clusters[current]=GetClusterMI(index);
4602 if (t->fClusterPointer[i]){
4603 clusters[current]=t->fClusterPointer[i];
4609 Int_t lab=123456789;
4610 for (i=0; i<noc; i++) {
4611 AliTPCclusterMI *c=clusters[i];
4613 lab=TMath::Abs(c->GetLabel(0));
4615 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4621 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4623 for (i=0; i<noc; i++) {
4624 AliTPCclusterMI *c=clusters[i];
4626 if (TMath::Abs(c->GetLabel(1)) == lab ||
4627 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4630 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4633 Int_t tail=Int_t(0.10*noc);
4636 for (i=1; i<=160&&ind<tail; i++) {
4637 // AliTPCclusterMI *c=clusters[noc-i];
4638 AliTPCclusterMI *c=clusters[i];
4640 if (lab == TMath::Abs(c->GetLabel(0)) ||
4641 lab == TMath::Abs(c->GetLabel(1)) ||
4642 lab == TMath::Abs(c->GetLabel(2))) max++;
4645 if (max < Int_t(0.5*tail)) lab=-lab;
4652 //delete[] clusters;
4656 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
4658 //return pad row number for this x
4661 r=fRow[fN-1].GetX();
4662 if (x > r) return fN;
4664 if (x < r) return -1;
4665 return Int_t((x-r)/fPadPitchLength + 0.5);}
4667 r=fRow[fN-1].GetX();
4668 if (x > r) return fN;
4670 if (x < r) return -1;
4671 Double_t r1=fRow[64].GetX();
4673 return Int_t((x-r)/f1PadPitchLength + 0.5);}
4675 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
4679 //_________________________________________________________________________
4680 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4681 //-----------------------------------------------------------------------
4682 // Setup inner sector
4683 //-----------------------------------------------------------------------
4685 fAlpha=par->GetInnerAngle();
4686 fAlphaShift=par->GetInnerAngleShift();
4687 fPadPitchWidth=par->GetInnerPadPitchWidth();
4688 fPadPitchLength=par->GetInnerPadPitchLength();
4689 fN=par->GetNRowLow();
4690 fRow=new AliTPCRow[fN];
4691 for (Int_t i=0; i<fN; i++) {
4692 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4693 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4696 fAlpha=par->GetOuterAngle();
4697 fAlphaShift=par->GetOuterAngleShift();
4698 fPadPitchWidth = par->GetOuterPadPitchWidth();
4699 fPadPitchLength = par->GetOuter1PadPitchLength();
4700 f1PadPitchLength = par->GetOuter1PadPitchLength();
4701 f2PadPitchLength = par->GetOuter2PadPitchLength();
4703 fN=par->GetNRowUp();
4704 fRow=new AliTPCRow[fN];
4705 for (Int_t i=0; i<fN; i++) {
4706 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4707 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4712 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
4714 // default constructor
4722 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4729 //_________________________________________________________________________
4731 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4732 //-----------------------------------------------------------------------
4733 // Insert a cluster into this pad row in accordence with its y-coordinate
4734 //-----------------------------------------------------------------------
4735 if (fN==kMaxClusterPerRow) {
4736 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4738 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4739 Int_t i=Find(c->GetZ());
4740 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4741 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4742 fIndex[i]=index; fClusters[i]=c; fN++;
4746 //___________________________________________________________________
4747 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4748 //-----------------------------------------------------------------------
4749 // Return the index of the nearest cluster
4750 //-----------------------------------------------------------------------
4751 if (fN==0) return 0;
4752 if (z <= fClusters[0]->GetZ()) return 0;
4753 if (z > fClusters[fN-1]->GetZ()) return fN;
4754 Int_t b=0, e=fN-1, m=(b+e)/2;
4755 for (; b<e; m=(b+e)/2) {
4756 if (z > fClusters[m]->GetZ()) b=m+1;
4764 //___________________________________________________________________
4765 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4766 //-----------------------------------------------------------------------
4767 // Return the index of the nearest cluster in z y
4768 //-----------------------------------------------------------------------
4769 Float_t maxdistance = roady*roady + roadz*roadz;
4771 AliTPCclusterMI *cl =0;
4772 for (Int_t i=Find(z-roadz); i<fN; i++) {
4773 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4774 if (c->GetZ() > z+roadz) break;
4775 if ( (c->GetY()-y) > roady ) continue;
4776 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4777 if (maxdistance>distance) {
4778 maxdistance = distance;
4785 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4787 //-----------------------------------------------------------------------
4788 // Return the index of the nearest cluster in z y
4789 //-----------------------------------------------------------------------
4790 Float_t maxdistance = roady*roady + roadz*roadz;
4791 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4792 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4794 AliTPCclusterMI *cl =0;
4795 //FindNearest3(y,z,roady,roadz,index);
4796 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4797 for (Int_t i=iz1; i<iz2; i++) {
4798 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4799 if (c->GetZ() > z+roadz) break;
4800 if ( c->GetY()-y > roady ) continue;
4801 if ( y-c->GetY() > roady ) continue;
4802 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4803 if (maxdistance>distance) {
4804 maxdistance = distance;
4807 //roady = TMath::Sqrt(maxdistance);
4815 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4817 //-----------------------------------------------------------------------
4818 // Return the index of the nearest cluster in z y
4819 //-----------------------------------------------------------------------
4820 Float_t maxdistance = roady*roady + roadz*roadz;
4821 // Int_t iz = Int_t(z+255.);
4822 AliTPCclusterMI *cl =0;
4823 for (Int_t i=Find(z-roadz); i<fN; i++) {
4824 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4825 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4826 if (c->GetZ() > z+roadz) break;
4827 if ( c->GetY()-y > roady ) continue;
4828 if ( y-c->GetY() > roady ) continue;
4829 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4830 if (maxdistance>distance) {
4831 maxdistance = distance;
4834 //roady = TMath::Sqrt(maxdistance);
4843 AliTPCseed::AliTPCseed():AliTPCtrack(){
4847 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4848 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4864 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4873 for (Int_t i=0;i<160;i++) {
4874 fClusterPointer[i] = 0;
4875 Int_t index = t.GetClusterIndex(i);
4877 SetClusterIndex2(i,index);
4880 SetClusterIndex2(i,-3);
4892 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4896 for (Int_t i=0;i<160;i++) {
4897 fClusterPointer[i] = 0;
4898 Int_t index = t.GetClusterIndex(i);
4899 SetClusterIndex2(i,index);
4917 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4918 Double_t xr, Double_t alpha):
4919 AliTPCtrack(index, xx, cc, xr, alpha) {
4924 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4925 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4934 // fHelixIn = new TClonesArray("AliHelix",0);
4935 //fHelixOut = new TClonesArray("AliHelix",0);
4944 AliTPCseed::~AliTPCseed(){
4947 if (fPoints) delete fPoints;
4949 if (fEPoints) delete fEPoints;
4954 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4958 return &fTrackPoints[i];
4961 void AliTPCseed::RebuildSeed()
4964 // rebuild seed to be ready for storing
4965 AliTPCclusterMI cldummy;
4967 AliTPCTrackPoint pdummy;
4968 pdummy.GetTPoint().fIsShared = 10;
4969 for (Int_t i=0;i<160;i++){
4970 AliTPCclusterMI * cl0 = fClusterPointer[i];
4971 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
4973 trpoint->GetTPoint() = *(GetTrackPoint(i));
4974 trpoint->GetCPoint() = *cl0;
4975 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4979 trpoint->GetCPoint()= cldummy;
4987 Double_t AliTPCseed::GetDensityFirst(Int_t n)
4991 // return cluster for n rows bellow first point
4992 Int_t nfoundable = 1;
4994 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
4995 Int_t index = GetClusterIndex2(i);
4996 if (index!=-1) nfoundable++;
4997 if (index>0) nfound++;
4999 if (nfoundable<n) return 0;
5000 return Double_t(nfound)/Double_t(nfoundable);
5005 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
5007 // get cluster stat. on given region
5012 for (Int_t i=first;i<last; i++){
5013 Int_t index = GetClusterIndex2(i);
5014 if (index!=-1) foundable++;
5015 if (fClusterPointer[i]) {
5021 if (fClusterPointer[i]->IsUsed(10)) {
5025 if (!plus2) continue; //take also neighborhoud
5027 if ( (i>0) && fClusterPointer[i-1]){
5028 if (fClusterPointer[i-1]->IsUsed(10)) {
5033 if ( fClusterPointer[i+1]){
5034 if (fClusterPointer[i+1]->IsUsed(10)) {
5042 printf("problem\n");
5046 //_____________________________________________________________________________
5047 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
5048 //-----------------------------------------------------------------
5049 // This funtion calculates dE/dX within the "low" and "up" cuts.
5050 //-----------------------------------------------------------------
5053 Float_t angular[200];
5054 Float_t weight[200];
5057 // TClonesArray & arr = *fPoints;
5058 Float_t meanlog = 100.;
5060 Float_t mean[4] = {0,0,0,0};
5061 Float_t sigma[4] = {1000,1000,1000,1000};
5062 Int_t nc[4] = {0,0,0,0};
5063 Float_t norm[4] = {1000,1000,1000,1000};
5068 for (Int_t of =0; of<4; of++){
5069 for (Int_t i=of+i1;i<i2;i+=4)
5071 Int_t index = fIndex[i];
5072 if (index<0||index&0x8000) continue;
5074 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
5075 AliTPCTrackerPoint * point = GetTrackPoint(i);
5076 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
5077 //AliTPCTrackerPoint * pointp = 0;
5078 //if (i<159) pointp = GetTrackPoint(i+1);
5080 if (point==0) continue;
5081 AliTPCclusterMI * cl = fClusterPointer[i];
5082 if (cl==0) continue;
5083 if (onlyused && (!cl->IsUsed(10))) continue;
5084 if (cl->IsUsed(11)) {
5088 Int_t type = cl->GetType();
5089 //if (point->fIsShared){
5094 // if (pointm->fIsShared) continue;
5096 // if (pointp->fIsShared) continue;
5098 if (type<0) continue;
5099 //if (type>10) continue;
5100 //if (point->GetErrY()==0) continue;
5101 //if (point->GetErrZ()==0) continue;
5103 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
5104 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
5105 //if ((ddy*ddy+ddz*ddz)>10) continue;
5108 // if (point->GetCPoint().GetMax()<5) continue;
5109 if (cl->GetMax()<5) continue;
5110 Float_t angley = point->GetAngleY();
5111 Float_t anglez = point->GetAngleZ();
5113 Float_t rsigmay2 = point->GetSigmaY();
5114 Float_t rsigmaz2 = point->GetSigmaZ();
5118 rsigmay += pointm->GetTPoint().GetSigmaY();
5119 rsigmaz += pointm->GetTPoint().GetSigmaZ();
5123 rsigmay += pointp->GetTPoint().GetSigmaY();
5124 rsigmaz += pointp->GetTPoint().GetSigmaZ();
5131 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
5133 Float_t ampc = 0; // normalization to the number of electrons
5135 // ampc = 1.*point->GetCPoint().GetMax();
5136 ampc = 1.*cl->GetMax();
5137 //ampc = 1.*point->GetCPoint().GetQ();
5138 // AliTPCClusterPoint & p = point->GetCPoint();
5139 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
5140 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5142 // TMath::Abs( Int_t(iz) - iz + 0.5);
5143 //ampc *= 1.15*(1-0.3*dy);
5144 //ampc *= 1.15*(1-0.3*dz);
5145 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
5149 //ampc = 1.0*point->GetCPoint().GetMax();
5150 ampc = 1.0*cl->GetMax();
5151 //ampc = 1.0*point->GetCPoint().GetQ();
5152 //AliTPCClusterPoint & p = point->GetCPoint();
5153 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
5154 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5156 // TMath::Abs( Int_t(iz) - iz + 0.5);
5158 //ampc *= 1.15*(1-0.3*dy);
5159 //ampc *= 1.15*(1-0.3*dz);
5160 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
5164 ampc *= 2.0; // put mean value to channel 50
5165 //ampc *= 0.58; // put mean value to channel 50
5167 // if (type>0) w = 1./(type/2.-0.5);
5168 // Float_t z = TMath::Abs(cl->GetZ());
5171 //ampc /= (1+0.0008*z);
5175 //ampc /= (1+0.0008*z);
5177 //ampc /= (1+0.0008*z);
5180 if (type<0) { //amp at the border - lower weight
5185 if (rsigma>1.5) ampc/=1.3; // if big backround
5187 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5192 TMath::Sort(nc[of],amp,index,kFALSE);
5196 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
5198 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5199 Float_t ampl = amp[index[i]]/angular[index[i]];
5200 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5202 sumw += weight[index[i]];
5203 sumamp += weight[index[i]]*ampl;
5204 sumamp2 += weight[index[i]]*ampl*ampl;
5205 norm[of] += angular[index[i]]*weight[index[i]];
5212 mean[of] = sumamp/sumw;
5213 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5215 sigma[of] = TMath::Sqrt(sigma[of]);
5219 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5220 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5221 //mean *=(1-0.1*(norm-1.));
5228 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
5229 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
5232 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
5233 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
5237 for (Int_t i =0;i<4;i++){
5238 if (nc[i]>2&&nc[i]<1000){
5239 dedx += mean[i] *nc[i];
5240 fSdEdx += sigma[i]*(nc[i]-2);
5241 fMAngular += norm[i] *nc[i];
5246 fSDEDX[i] = sigma[i];
5259 // Float_t dedx1 =dedx;
5262 for (Int_t i =0;i<4;i++){
5263 if (nc[i]>2&&nc[i]<1000){
5264 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5265 dedx += mean[i] *nc[i];
5280 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5283 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5284 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5285 SetMass(0.93827); return;
5289 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5290 SetMass(0.93827); return;
5293 SetMass(0.13957); return;
5303 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5304 //-----------------------------------------------------------------
5305 // This funtion calculates dE/dX within the "low" and "up" cuts.
5306 //-----------------------------------------------------------------
5309 Float_t angular[200];
5310 Float_t weight[200];
5312 Bool_t inlimit[200];
5313 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5314 for (Int_t i=0;i<200;i++) amp[i]=10000;
5315 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5319 Float_t meanlog = 100.;
5320 Int_t indexde[4]={0,64,128,160};
5327 Float_t mean[4] = {0,0,0,0};
5328 Float_t sigma[4] = {1000,1000,1000,1000};
5329 Int_t nc[4] = {0,0,0,0};
5330 Float_t norm[4] = {1000,1000,1000,1000};
5335 // for (Int_t of =0; of<3; of++){
5336 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5337 for (Int_t i =0; i<160;i++)
5339 AliTPCTrackPoint * point = GetTrackPoint(i);
5340 if (point==0) continue;
5341 if (point->fIsShared){
5345 Int_t type = point->GetCPoint().GetType();
5346 if (type<0) continue;
5347 if (point->GetCPoint().GetMax()<5) continue;
5348 Float_t angley = point->GetTPoint().GetAngleY();
5349 Float_t anglez = point->GetTPoint().GetAngleZ();
5350 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5351 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5352 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5354 Float_t ampc = 0; // normalization to the number of electrons
5356 ampc = point->GetCPoint().GetMax();
5359 ampc = point->GetCPoint().GetMax();
5361 ampc *= 2.0; // put mean value to channel 50
5362 // ampc *= 0.565; // put mean value to channel 50
5365 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5372 if (type<0) { //amp at the border - lower weight
5375 if (rsigma>1.5) ampc/=1.3; // if big backround
5376 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5377 amp[i] = ampc/angular[i];
5382 TMath::Sort(159,amp,index,kFALSE);
5383 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5384 inlimit[index[i]] = kTRUE; // take all clusters
5387 // meanlog = amp[index[Int_t(anc*0.3)]];
5389 for (Int_t of =0; of<3; of++){
5393 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5395 if (inlimit[i]==kFALSE) continue;
5396 Float_t ampl = amp[i];
5398 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5401 sumamp += weight[i]*ampl;
5402 sumamp2 += weight[i]*ampl*ampl;
5403 norm[of] += angular[i]*weight[i];
5411 mean[of] = sumamp/sumw;
5412 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5414 sigma[of] = TMath::Sqrt(sigma[of]);
5417 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5427 Float_t www[3] = {12.,14.,17.};
5428 //Float_t www[3] = {1.,1.,1.};
5430 for (Int_t i =0;i<3;i++){
5431 if (nc[i]>2&&nc[i]<1000){
5432 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5433 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5434 fMAngular += norm[i] *nc[i];
5435 norm2 += nc[i]*www[i]/sigma[i];
5436 norm3 += (nc[i]-2)*www[i]/sigma[i];
5439 fSDEDX[i] = sigma[i];
5452 // Float_t dedx1 =dedx;
5456 for (Int_t i =0;i<3;i++){
5457 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5458 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5459 dedx += mean[i] *(nc[i])/(sigma[i]);
5460 norm4 += (nc[i])/(sigma[i]);
5464 if (norm4>0) dedx /= norm4;