1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-------------------------------------------------------
18 // Implementation of the TPC tracker
20 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // AliTPC parallel tracker -
24 // run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25 // run AliTPCFindTracksMI.C macro - to find tracks
26 // tracks are written to AliTPCtracks.root file
27 // for comparison also seeds are written to the same file - to special branch
28 //-------------------------------------------------------
35 #include "Riostream.h"
36 #include <TClonesArray.h>
38 #include <TObjArray.h>
41 #include "AliComplexCluster.h"
44 #include "AliRunLoader.h"
45 #include "AliTPCClustersRow.h"
46 #include "AliTPCParam.h"
47 #include "AliTPCclusterMI.h"
48 #include "AliTPCpolyTrack.h"
49 #include "AliTPCreco.h"
50 #include "AliTPCtrackerMI.h"
51 #include "TStopwatch.h"
53 #include "AliTPCReconstructor.h"
54 #include "AliESDkink.h"
58 ClassImp(AliTPCtrackerMI)
61 class AliTPCFastMath {
64 static Double_t FastAsin(Double_t x);
66 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
69 Double_t AliTPCFastMath::fgFastAsin[20000];
70 AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
72 AliTPCFastMath::AliTPCFastMath(){
74 // initialized lookup table;
75 for (Int_t i=0;i<10000;i++){
76 fgFastAsin[2*i] = TMath::ASin(i/10000.);
77 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
81 Double_t AliTPCFastMath::FastAsin(Double_t x){
83 // return asin using lookup table
85 Int_t index = int(x*10000);
86 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
89 Int_t index = int(x*10000);
90 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
96 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
98 //update track information using current cluster - track->fCurrentCluster
101 AliTPCclusterMI* c =track->fCurrentCluster;
102 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
104 UInt_t i = track->fCurrentClusterIndex1;
106 Int_t sec=(i&0xff000000)>>24;
107 //Int_t row = (i&0x00ff0000)>>16;
108 track->fRow=(i&0x00ff0000)>>16;
109 track->fSector = sec;
110 // Int_t index = i&0xFFFF;
111 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
112 track->SetClusterIndex2(track->fRow, i);
113 //track->fFirstPoint = row;
114 //if ( track->fLastPoint<row) track->fLastPoint =row;
115 // if (track->fRow<0 || track->fRow>160) {
116 // printf("problem\n");
118 if (track->fFirstPoint>track->fRow)
119 track->fFirstPoint = track->fRow;
120 if (track->fLastPoint<track->fRow)
121 track->fLastPoint = track->fRow;
124 track->fClusterPointer[track->fRow] = c;
127 Float_t angle2 = track->GetSnp()*track->GetSnp();
128 angle2 = TMath::Sqrt(angle2/(1-angle2));
130 //SET NEW Track Point
134 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
136 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
137 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
138 point.SetErrY(sqrt(track->fErrorY2));
139 point.SetErrZ(sqrt(track->fErrorZ2));
141 point.SetX(track->GetX());
142 point.SetY(track->GetY());
143 point.SetZ(track->GetZ());
144 point.SetAngleY(angle2);
145 point.SetAngleZ(track->GetTgl());
146 if (point.fIsShared){
147 track->fErrorY2 *= 4;
148 track->fErrorZ2 *= 4;
152 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
154 track->fErrorY2 *= 1.3;
155 track->fErrorY2 += 0.01;
156 track->fErrorZ2 *= 1.3;
157 track->fErrorZ2 += 0.005;
159 if (accept>0) return 0;
160 if (track->GetNumberOfClusters()%20==0){
161 // if (track->fHelixIn){
162 // TClonesArray & larr = *(track->fHelixIn);
163 // Int_t ihelix = larr.GetEntriesFast();
164 // new(larr[ihelix]) AliHelix(*track) ;
167 track->fNoCluster =0;
168 return track->Update(c,chi2,i);
173 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
174 Float_t cory, Float_t corz)
177 // decide according desired precision to accept given
178 // cluster for tracking
179 Double_t sy2=ErrY2(seed,cluster)*cory;
180 Double_t sz2=ErrZ2(seed,cluster)*corz;
181 //sy2=ErrY2(seed,cluster)*cory;
182 //sz2=ErrZ2(seed,cluster)*cory;
184 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
185 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
187 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
188 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
189 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
190 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
192 Double_t rdistance2 = rdistancey2+rdistancez2;
195 if (rdistance2>16) return 3;
198 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
199 return 2; //suspisiouce - will be changed
201 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
202 // strict cut on overlaped cluster
203 return 2; //suspisiouce - will be changed
205 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
206 && cluster->GetType()<0){
216 //_____________________________________________________________________________
217 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
218 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
220 //---------------------------------------------------------------------
221 // The main TPC tracker constructor
222 //---------------------------------------------------------------------
223 fInnerSec=new AliTPCSector[fkNIS];
224 fOuterSec=new AliTPCSector[fkNOS];
227 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
228 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
235 Int_t nrowlow = par->GetNRowLow();
236 Int_t nrowup = par->GetNRowUp();
239 for (Int_t i=0;i<nrowlow;i++){
240 fXRow[i] = par->GetPadRowRadiiLow(i);
241 fPadLength[i]= par->GetPadPitchLength(0,i);
242 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
246 for (Int_t i=0;i<nrowup;i++){
247 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
248 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
249 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
261 //________________________________________________________________________
262 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
267 //------------------------------------
268 // dummy copy constructor
269 //------------------------------------------------------------------
271 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
272 //------------------------------
274 //--------------------------------------------------------------
277 //_____________________________________________________________________________
278 AliTPCtrackerMI::~AliTPCtrackerMI() {
279 //------------------------------------------------------------------
280 // TPC tracker destructor
281 //------------------------------------------------------------------
290 void AliTPCtrackerMI::SetIO()
294 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
296 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
298 AliTPCtrack *iotrack= new AliTPCtrack;
299 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
305 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
321 AliTPCtrack *iotrack= new AliTPCtrack;
322 // iotrack->fHelixIn = new TClonesArray("AliHelix");
323 //iotrack->fHelixOut = new TClonesArray("AliHelix");
324 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
327 if (output && (fDebug&2)){
328 //write the full seed information if specified in debug mode
330 fSeedTree = new TTree("Seeds","Seeds");
331 AliTPCseed * vseed = new AliTPCseed;
333 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
334 arrtr->ExpandCreateFast(160);
335 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
337 vseed->fPoints = arrtr;
338 vseed->fEPoints = arre;
339 // vseed->fClusterPoints = arrcl;
340 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
343 fTreeDebug = new TTree("trackDebug","trackDebug");
344 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
345 fTreeDebug->Branch("debug",&arrd,32000,99);
353 void AliTPCtrackerMI::FillESD(TObjArray* arr)
357 //fill esds using updated tracks
359 // write tracks to the event
360 // store index of the track
361 Int_t nseed=arr->GetEntriesFast();
362 //FindKinks(arr,fEvent);
363 for (Int_t i=0; i<nseed; i++) {
364 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
367 pt->PropagateTo(fParam->GetInnerRadiusLow());
369 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
371 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
372 iotrack.SetTPCPoints(pt->GetPoints());
373 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
374 //iotrack.SetTPCindex(i);
375 fEvent->AddTrack(&iotrack);
379 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
381 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
382 iotrack.SetTPCPoints(pt->GetPoints());
383 //iotrack.SetTPCindex(i);
384 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
385 fEvent->AddTrack(&iotrack);
389 // short tracks - maybe decays
391 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
392 Int_t found,foundable,shared;
393 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
394 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
396 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
397 //iotrack.SetTPCindex(i);
398 iotrack.SetTPCPoints(pt->GetPoints());
399 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
400 fEvent->AddTrack(&iotrack);
405 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
406 Int_t found,foundable,shared;
407 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
408 if (found<20) continue;
409 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
412 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
413 iotrack.SetTPCPoints(pt->GetPoints());
414 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
415 //iotrack.SetTPCindex(i);
416 fEvent->AddTrack(&iotrack);
419 // short tracks - secondaties
421 if ( (pt->GetNumberOfClusters()>30) ) {
422 Int_t found,foundable,shared;
423 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
424 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
426 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
427 iotrack.SetTPCPoints(pt->GetPoints());
428 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
429 //iotrack.SetTPCindex(i);
430 fEvent->AddTrack(&iotrack);
435 if ( (pt->GetNumberOfClusters()>15)) {
436 Int_t found,foundable,shared;
437 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
438 if (found<15) continue;
439 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
440 if (float(found)/float(foundable)<0.8) continue;
443 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
444 iotrack.SetTPCPoints(pt->GetPoints());
445 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
446 //iotrack.SetTPCindex(i);
447 fEvent->AddTrack(&iotrack);
452 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
455 void AliTPCtrackerMI::WriteTracks(TTree * tree)
458 // write tracks from seed array to selected tree
462 AliTPCtrack *iotrack= new AliTPCtrack;
463 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
468 void AliTPCtrackerMI::WriteTracks()
471 // write tracks to the given output tree -
472 // output specified with SetIO routine
479 AliTPCtrack *iotrack= 0;
480 Int_t nseed=fSeeds->GetEntriesFast();
481 //for (Int_t i=0; i<nseed; i++) {
482 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
483 // if (iotrack) break;
485 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
486 TBranch * br = fOutput->GetBranch("tracks");
487 br->SetAddress(&iotrack);
489 for (Int_t i=0; i<nseed; i++) {
490 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
492 AliTPCtrack * track = new AliTPCtrack(*pt);
495 // br->SetAddress(&iotrack);
500 //fOutput->GetDirectory()->cd();
506 //write the full seed information if specified in debug mode
508 AliTPCseed * vseed = new AliTPCseed;
510 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
511 arrtr->ExpandCreateFast(160);
512 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
513 //arrcl->ExpandCreateFast(160);
514 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
516 vseed->fPoints = arrtr;
517 vseed->fEPoints = arre;
518 // vseed->fClusterPoints = arrcl;
519 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
520 TBranch * brseed = fSeedTree->GetBranch("seeds");
522 Int_t nseed=fSeeds->GetEntriesFast();
524 for (Int_t i=0; i<nseed; i++) {
525 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
528 // pt->fClusterPoints = arrcl;
532 brseed->SetAddress(&vseed);
536 // pt->fClusterPoints = 0;
539 if (fTreeDebug) fTreeDebug->Write();
547 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
550 //seed->SetErrorY2(0.1);
552 //calculate look-up table at the beginning
553 static Bool_t ginit = kFALSE;
554 static Float_t gnoise1,gnoise2,gnoise3;
555 static Float_t ggg1[10000];
556 static Float_t ggg2[10000];
557 static Float_t ggg3[10000];
558 static Float_t glandau1[10000];
559 static Float_t glandau2[10000];
560 static Float_t glandau3[10000];
562 static Float_t gcor01[500];
563 static Float_t gcor02[500];
564 static Float_t gcorp[500];
569 for (Int_t i=1;i<500;i++){
570 Float_t rsigma = float(i)/100.;
571 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
572 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
573 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
577 for (Int_t i=3;i<10000;i++){
581 Float_t amp = float(i);
582 Float_t padlength =0.75;
583 gnoise1 = 0.0004/padlength;
584 Float_t nel = 0.268*amp;
585 Float_t nprim = 0.155*amp;
586 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
587 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
588 if (glandau1[i]>1) glandau1[i]=1;
589 glandau1[i]*=padlength*padlength/12.;
593 gnoise2 = 0.0004/padlength;
596 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
597 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
598 if (glandau2[i]>1) glandau2[i]=1;
599 glandau2[i]*=padlength*padlength/12.;
604 gnoise3 = 0.0004/padlength;
607 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
608 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
609 if (glandau3[i]>1) glandau3[i]=1;
610 glandau3[i]*=padlength*padlength/12.;
618 Int_t amp = int(TMath::Abs(cl->GetQ()));
620 seed->SetErrorY2(1.);
624 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
625 Int_t ctype = cl->GetType();
626 Float_t padlength= GetPadPitchLength(seed->fRow);
627 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
628 angle2 = angle2/(1-angle2);
631 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
634 if (fSectors==fInnerSec){
636 res = ggg1[amp]*z+glandau1[amp]*angle2;
637 if (ctype==0) res *= gcor01[rsigmay];
640 res*= gcorp[rsigmay];
646 res = ggg2[amp]*z+glandau2[amp]*angle2;
647 if (ctype==0) res *= gcor02[rsigmay];
650 res*= gcorp[rsigmay];
655 res = ggg3[amp]*z+glandau3[amp]*angle2;
656 if (ctype==0) res *= gcor02[rsigmay];
659 res*= gcorp[rsigmay];
666 res*=2.4; // overestimate error 2 times
673 seed->SetErrorY2(res);
681 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
684 //seed->SetErrorY2(0.1);
686 //calculate look-up table at the beginning
687 static Bool_t ginit = kFALSE;
688 static Float_t gnoise1,gnoise2,gnoise3;
689 static Float_t ggg1[10000];
690 static Float_t ggg2[10000];
691 static Float_t ggg3[10000];
692 static Float_t glandau1[10000];
693 static Float_t glandau2[10000];
694 static Float_t glandau3[10000];
696 static Float_t gcor01[1000];
697 static Float_t gcor02[1000];
698 static Float_t gcorp[1000];
703 for (Int_t i=1;i<1000;i++){
704 Float_t rsigma = float(i)/100.;
705 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
706 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
707 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
711 for (Int_t i=3;i<10000;i++){
715 Float_t amp = float(i);
716 Float_t padlength =0.75;
717 gnoise1 = 0.0004/padlength;
718 Float_t nel = 0.268*amp;
719 Float_t nprim = 0.155*amp;
720 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
721 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
722 if (glandau1[i]>1) glandau1[i]=1;
723 glandau1[i]*=padlength*padlength/12.;
727 gnoise2 = 0.0004/padlength;
730 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
731 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
732 if (glandau2[i]>1) glandau2[i]=1;
733 glandau2[i]*=padlength*padlength/12.;
738 gnoise3 = 0.0004/padlength;
741 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
742 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
743 if (glandau3[i]>1) glandau3[i]=1;
744 glandau3[i]*=padlength*padlength/12.;
752 Int_t amp = int(TMath::Abs(cl->GetQ()));
754 seed->SetErrorY2(1.);
758 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
759 Int_t ctype = cl->GetType();
760 Float_t padlength= GetPadPitchLength(seed->fRow);
762 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
763 // if (angle2<0.6) angle2 = 0.6;
764 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
767 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
770 if (fSectors==fInnerSec){
772 res = ggg1[amp]*z+glandau1[amp]*angle2;
773 if (ctype==0) res *= gcor01[rsigmaz];
776 res*= gcorp[rsigmaz];
782 res = ggg2[amp]*z+glandau2[amp]*angle2;
783 if (ctype==0) res *= gcor02[rsigmaz];
786 res*= gcorp[rsigmaz];
791 res = ggg3[amp]*z+glandau3[amp]*angle2;
792 if (ctype==0) res *= gcor02[rsigmaz];
795 res*= gcorp[rsigmaz];
804 if ((ctype<0) &&<70){
812 seed->SetErrorZ2(res);
819 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
822 //seed->SetErrorZ2(0.1);
826 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
828 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
829 Int_t ctype = cl->GetType();
830 Float_t amp = TMath::Abs(cl->GetQ());
835 Float_t landau=2 ; //landau fluctuation part
836 Float_t gg=2; // gg fluctuation part
837 Float_t padlength= GetPadPitchLength(seed->GetX());
839 if (fSectors==fInnerSec){
840 snoise2 = 0.0004/padlength;
843 gg = (2+0.001*nel/(padlength*padlength))/nel;
844 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
845 if (landau>1) landau=1;
848 snoise2 = 0.0004/padlength;
851 gg = (2+0.0008*nel/(padlength*padlength))/nel;
852 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
853 if (landau>1) landau=1;
855 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
858 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
859 angle2 = TMath::Sqrt((1-angle2));
860 if (angle2<0.6) angle2 = 0.6;
863 Float_t angle = seed->GetTgl()/angle2;
864 Float_t angular = landau*angle*angle*padlength*padlength/12.;
865 Float_t res = sdiff + angular;
868 if ((ctype==0) && (fSectors ==fOuterSec))
869 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
871 if ((ctype==0) && (fSectors ==fInnerSec))
872 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
876 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
882 if ((ctype<0) &&<70){
890 seed->SetErrorZ2(res);
897 void AliTPCseed::Reset(Bool_t all)
901 SetNumberOfClusters(0);
907 for (Int_t i=0;i<8;i++){
908 delete [] fTrackPoints[i];
916 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
917 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
923 void AliTPCseed::Modify(Double_t factor)
926 //------------------------------------------------------------------
927 //This function makes a track forget its history :)
928 //------------------------------------------------------------------
934 fC10*=0; fC11*=factor;
935 fC20*=0; fC21*=0; fC22*=factor;
936 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
937 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
938 SetNumberOfClusters(0);
942 fCurrentSigmaY2 = 0.000005;
943 fCurrentSigmaZ2 = 0.000005;
952 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
954 //-----------------------------------------------------------------
955 // This function find proloncation of a track to a reference plane x=xk.
956 // doesn't change internal state of the track
957 //-----------------------------------------------------------------
959 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
961 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
965 // Double_t y1=fP0, z1=fP1;
966 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
967 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
971 //y += dx*(c1+c2)/(r1+r2);
972 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
974 Double_t dy = dx*(c1+c2)/(r1+r2);
977 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
979 if (TMath::Abs(delta)>0.0001){
980 dz = fP3*TMath::ASin(delta)/fP4;
982 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
985 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
995 //_____________________________________________________________________________
996 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
998 //-----------------------------------------------------------------
999 // This function calculates a predicted chi2 increment.
1000 //-----------------------------------------------------------------
1001 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
1002 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
1003 r00+=fC00; r01+=fC10; r11+=fC11;
1005 Double_t det=r00*r11 - r01*r01;
1006 if (TMath::Abs(det) < 1.e-10) {
1007 Int_t n=GetNumberOfClusters();
1008 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
1011 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
1013 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
1015 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
1019 //_________________________________________________________________________________________
1022 Int_t AliTPCseed::Compare(const TObject *o) const {
1023 //-----------------------------------------------------------------
1024 // This function compares tracks according to the sector - for given sector according z
1025 //-----------------------------------------------------------------
1026 AliTPCseed *t=(AliTPCseed*)o;
1029 if (t->fRelativeSector>fRelativeSector) return -1;
1030 if (t->fRelativeSector<fRelativeSector) return 1;
1031 Double_t z2 = t->GetZ();
1032 Double_t z1 = GetZ();
1033 if (z2>z1) return 1;
1034 if (z2<z1) return -1;
1039 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
1040 if (t->fBConstrain) f2=1.2;
1043 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
1045 if (fBConstrain) f1=1.2;
1047 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
1052 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
1054 //rotate to track "local coordinata
1055 Float_t x = seed->GetX();
1056 Float_t y = seed->GetY();
1057 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
1060 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
1061 if (!seed->Rotate(fSectors->GetAlpha()))
1063 } else if (y <-ymax) {
1064 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
1065 if (!seed->Rotate(-fSectors->GetAlpha()))
1074 //_____________________________________________________________________________
1075 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
1076 //-----------------------------------------------------------------
1077 // This function associates a cluster with this track.
1078 //-----------------------------------------------------------------
1079 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
1081 r00+=fC00; r01+=fC10; r11+=fC11;
1082 Double_t det=r00*r11 - r01*r01;
1083 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
1085 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
1086 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
1087 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
1088 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
1089 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
1091 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
1092 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
1093 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1097 fP0 += k00*dy + k01*dz;
1098 fP1 += k10*dy + k11*dz;
1100 fP3 += k30*dy + k31*dz;
1103 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1104 Double_t c12=fC21, c13=fC31, c14=fC41;
1106 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1107 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1108 fC40-=k00*c04+k01*c14;
1110 fC11-=k10*c01+k11*fC11;
1111 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1112 fC41-=k10*c04+k11*c14;
1114 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1115 fC42-=k20*c04+k21*c14;
1117 fC33-=k30*c03+k31*c13;
1118 fC43-=k40*c03+k41*c13;
1120 fC44-=k40*c04+k41*c14;
1122 Int_t n=GetNumberOfClusters();
1124 SetNumberOfClusters(n+1);
1125 SetChi2(GetChi2()+chisq);
1132 //_____________________________________________________________________________
1133 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1134 Double_t x2,Double_t y2,
1135 Double_t x3,Double_t y3)
1137 //-----------------------------------------------------------------
1138 // Initial approximation of the track curvature
1139 //-----------------------------------------------------------------
1140 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1141 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1142 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1143 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1144 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1146 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1147 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1148 return -xr*yr/sqrt(xr*xr+yr*yr);
1153 //_____________________________________________________________________________
1154 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1155 Double_t x2,Double_t y2,
1156 Double_t x3,Double_t y3)
1158 //-----------------------------------------------------------------
1159 // Initial approximation of the track curvature
1160 //-----------------------------------------------------------------
1166 Double_t det = x3*y2-x2*y3;
1171 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1172 Double_t x0 = x3*0.5-y3*u;
1173 Double_t y0 = y3*0.5+x3*u;
1174 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1180 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1181 Double_t x2,Double_t y2,
1182 Double_t x3,Double_t y3)
1184 //-----------------------------------------------------------------
1185 // Initial approximation of the track curvature
1186 //-----------------------------------------------------------------
1192 Double_t det = x3*y2-x2*y3;
1197 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1198 Double_t x0 = x3*0.5-y3*u;
1199 Double_t y0 = y3*0.5+x3*u;
1200 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1209 //_____________________________________________________________________________
1210 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1211 Double_t x2,Double_t y2,
1212 Double_t x3,Double_t y3)
1214 //-----------------------------------------------------------------
1215 // Initial approximation of the track curvature times center of curvature
1216 //-----------------------------------------------------------------
1217 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1218 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1219 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1220 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1221 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1223 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1225 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1228 //_____________________________________________________________________________
1229 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1230 Double_t x2,Double_t y2,
1231 Double_t z1,Double_t z2)
1233 //-----------------------------------------------------------------
1234 // Initial approximation of the tangent of the track dip angle
1235 //-----------------------------------------------------------------
1236 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1240 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1241 Double_t x2,Double_t y2,
1242 Double_t z1,Double_t z2, Double_t c)
1244 //-----------------------------------------------------------------
1245 // Initial approximation of the tangent of the track dip angle
1246 //-----------------------------------------------------------------
1250 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1252 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1253 if (TMath::Abs(d*c*0.5)>1) return 0;
1254 // Double_t angle2 = TMath::ASin(d*c*0.5);
1255 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1256 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1258 angle2 = (z1-z2)*c/(angle2*2.);
1262 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1263 {//-----------------------------------------------------------------
1264 // This function find proloncation of a track to a reference plane x=x2.
1265 //-----------------------------------------------------------------
1269 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1273 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1274 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1278 Double_t dy = dx*(c1+c2)/(r1+r2);
1281 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1283 if (TMath::Abs(delta)>0.01){
1284 dz = x[3]*TMath::ASin(delta)/x[4];
1286 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1289 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1297 Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1302 return LoadClusters();
1305 Int_t AliTPCtrackerMI::LoadClusters()
1308 // load clusters to the memory
1309 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1310 clrow->SetClass("AliTPCclusterMI");
1312 clrow->GetArray()->ExpandCreateFast(10000);
1314 // TTree * tree = fClustersArray.GetTree();
1316 TTree * tree = fInput;
1317 TBranch * br = tree->GetBranch("Segment");
1318 br->SetAddress(&clrow);
1320 Int_t j=Int_t(tree->GetEntries());
1321 for (Int_t i=0; i<j; i++) {
1325 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1327 AliTPCRow * tpcrow=0;
1330 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1334 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1335 left = (sec-fkNIS*2)/fkNOS;
1338 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1339 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1340 for (Int_t i=0;i<tpcrow->fN1;i++)
1341 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1344 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1345 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1346 for (Int_t i=0;i<tpcrow->fN2;i++)
1347 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1358 void AliTPCtrackerMI::UnloadClusters()
1361 // unload clusters from the memory
1363 Int_t nrows = fOuterSec->GetNRows();
1364 for (Int_t sec = 0;sec<fkNOS;sec++)
1365 for (Int_t row = 0;row<nrows;row++){
1366 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1368 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1369 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1371 tpcrow->ResetClusters();
1374 nrows = fInnerSec->GetNRows();
1375 for (Int_t sec = 0;sec<fkNIS;sec++)
1376 for (Int_t row = 0;row<nrows;row++){
1377 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1379 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1380 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1382 tpcrow->ResetClusters();
1389 //_____________________________________________________________________________
1390 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1391 //-----------------------------------------------------------------
1392 // This function fills outer TPC sectors with clusters.
1393 //-----------------------------------------------------------------
1394 Int_t nrows = fOuterSec->GetNRows();
1396 for (Int_t sec = 0;sec<fkNOS;sec++)
1397 for (Int_t row = 0;row<nrows;row++){
1398 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1399 Int_t sec2 = sec+2*fkNIS;
1401 Int_t ncl = tpcrow->fN1;
1403 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1404 index=(((sec2<<8)+row)<<16)+ncl;
1405 tpcrow->InsertCluster(c,index);
1410 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1411 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1412 tpcrow->InsertCluster(c,index);
1415 // write indexes for fast acces
1417 for (Int_t i=0;i<510;i++)
1418 tpcrow->fFastCluster[i]=-1;
1419 for (Int_t i=0;i<tpcrow->GetN();i++){
1420 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1421 tpcrow->fFastCluster[zi]=i; // write index
1424 for (Int_t i=0;i<510;i++){
1425 if (tpcrow->fFastCluster[i]<0)
1426 tpcrow->fFastCluster[i] = last;
1428 last = tpcrow->fFastCluster[i];
1437 //_____________________________________________________________________________
1438 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1439 //-----------------------------------------------------------------
1440 // This function fills inner TPC sectors with clusters.
1441 //-----------------------------------------------------------------
1442 Int_t nrows = fInnerSec->GetNRows();
1444 for (Int_t sec = 0;sec<fkNIS;sec++)
1445 for (Int_t row = 0;row<nrows;row++){
1446 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1449 Int_t ncl = tpcrow->fN1;
1451 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1452 index=(((sec<<8)+row)<<16)+ncl;
1453 tpcrow->InsertCluster(c,index);
1458 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1459 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1460 tpcrow->InsertCluster(c,index);
1463 // write indexes for fast acces
1465 for (Int_t i=0;i<510;i++)
1466 tpcrow->fFastCluster[i]=-1;
1467 for (Int_t i=0;i<tpcrow->GetN();i++){
1468 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1469 tpcrow->fFastCluster[zi]=i; // write index
1472 for (Int_t i=0;i<510;i++){
1473 if (tpcrow->fFastCluster[i]<0)
1474 tpcrow->fFastCluster[i] = last;
1476 last = tpcrow->fFastCluster[i];
1488 //_________________________________________________________________________
1489 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1490 //--------------------------------------------------------------------
1491 // Return pointer to a given cluster
1492 //--------------------------------------------------------------------
1493 Int_t sec=(index&0xff000000)>>24;
1494 Int_t row=(index&0x00ff0000)>>16;
1495 Int_t ncl=(index&0x00007fff)>>00;
1497 const AliTPCRow * tpcrow=0;
1498 AliTPCclusterMI * clrow =0;
1501 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1502 if (tpcrow==0) return 0;
1505 if (tpcrow->fN1<=ncl) return 0;
1506 clrow = tpcrow->fClusters1;
1509 if (tpcrow->fN2<=ncl) return 0;
1510 clrow = tpcrow->fClusters2;
1514 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1515 if (tpcrow==0) return 0;
1517 if (sec-2*fkNIS<fkNOS) {
1518 if (tpcrow->fN1<=ncl) return 0;
1519 clrow = tpcrow->fClusters1;
1522 if (tpcrow->fN2<=ncl) return 0;
1523 clrow = tpcrow->fClusters2;
1527 return &(clrow[ncl]);
1533 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1534 //-----------------------------------------------------------------
1535 // This function tries to find a track prolongation to next pad row
1536 //-----------------------------------------------------------------
1538 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1539 AliTPCclusterMI *cl=0;
1540 Int_t tpcindex= t.GetClusterIndex2(nr);
1542 // update current shape info every 5 pad-row
1543 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1547 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1549 if (tpcindex==-1) return 0; //track in dead zone
1551 cl = t.fClusterPointer[nr];
1552 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
1553 t.fCurrentClusterIndex1 = tpcindex;
1556 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1557 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1559 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1560 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1562 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1563 Double_t rotation = angle-t.GetAlpha();
1564 t.fRelativeSector= relativesector;
1569 t.fCurrentCluster = cl;
1571 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1572 if ((tpcindex&0x8000)==0) accept =0;
1574 //if founded cluster is acceptible
1575 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1582 UpdateTrack(&t,accept);
1587 if (fIteration>1) return 0; // not look for new cluster during refitting
1590 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1591 Double_t y=t.GetYat(x);
1592 if (TMath::Abs(y)>ymax){
1594 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1595 if (!t.Rotate(fSectors->GetAlpha()))
1597 } else if (y <-ymax) {
1598 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1599 if (!t.Rotate(-fSectors->GetAlpha()))
1605 if (!t.PropagateTo(x)) {
1606 if (fIteration==0) t.fRemoval = 10;
1610 Double_t z=t.GetZ();
1612 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1613 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1615 Double_t roadz = 1.;
1617 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1619 t.SetClusterIndex2(nr,-1);
1624 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10)) t.fNFoundable++;
1630 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1631 cl = krow.FindNearest2(y,z,roady,roadz,index);
1632 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1635 t.fCurrentCluster = cl;
1637 if (fIteration==2&&cl->IsUsed(10)) return 0;
1638 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1639 if (fIteration==2&&cl->IsUsed(11)) {
1646 if (t.fCurrentCluster->IsUsed(10)){
1651 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1657 if (accept<3) UpdateTrack(&t,accept);
1660 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1666 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1667 //-----------------------------------------------------------------
1668 // This function tries to find a track prolongation to next pad row
1669 //-----------------------------------------------------------------
1671 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1673 if (!t.GetProlongation(x,y,z)) {
1679 if (TMath::Abs(y)>ymax){
1682 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1683 if (!t.Rotate(fSectors->GetAlpha()))
1685 } else if (y <-ymax) {
1686 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1687 if (!t.Rotate(-fSectors->GetAlpha()))
1690 if (!t.PropagateTo(x)) {
1693 t.GetProlongation(x,y,z);
1696 // update current shape info every 3 pad-row
1697 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1698 // t.fCurrentSigmaY = GetSigmaY(&t);
1699 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1703 AliTPCclusterMI *cl=0;
1708 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1709 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1711 Double_t roadz = 1.;
1714 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1716 t.SetClusterIndex2(row,-1);
1721 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1725 if ((cl==0)&&(krow)) {
1726 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1727 cl = krow.FindNearest2(y,z,roady,roadz,index);
1729 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1733 t.fCurrentCluster = cl;
1734 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1736 t.SetClusterIndex2(row,index);
1737 t.fClusterPointer[row] = cl;
1745 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1746 //-----------------------------------------------------------------
1747 // This function tries to find a track prolongation to next pad row
1748 //-----------------------------------------------------------------
1749 t.fCurrentCluster = 0;
1750 t.fCurrentClusterIndex1 = 0;
1752 Double_t xt=t.GetX();
1753 Int_t row = GetRowNumber(xt)-1;
1754 Double_t ymax= GetMaxY(nr);
1756 if (row < nr) return 1; // don't prolongate if not information until now -
1757 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1759 return 0; // not prolongate strongly inclined tracks
1761 if (TMath::Abs(t.GetSnp())>0.95) {
1763 return 0; // not prolongate strongly inclined tracks
1766 Double_t x= GetXrow(nr);
1768 //t.PropagateTo(x+0.02);
1769 //t.PropagateTo(x+0.01);
1770 if (!t.PropagateTo(x)){
1777 if (TMath::Abs(y)>ymax){
1779 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1780 if (!t.Rotate(fSectors->GetAlpha()))
1782 } else if (y <-ymax) {
1783 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1784 if (!t.Rotate(-fSectors->GetAlpha()))
1787 // if (!t.PropagateTo(x)){
1795 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1797 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1799 t.SetClusterIndex2(nr,-1);
1804 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1810 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1811 // t.fCurrentSigmaY = GetSigmaY(&t);
1812 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1816 AliTPCclusterMI *cl=0;
1819 Double_t roady = 1.;
1820 Double_t roadz = 1.;
1824 index = t.GetClusterIndex2(nr);
1825 if ( (index>0) && (index&0x8000)==0){
1826 cl = t.fClusterPointer[nr];
1827 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1828 t.fCurrentClusterIndex1 = index;
1830 t.fCurrentCluster = cl;
1837 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1838 cl = krow.FindNearest2(y,z,roady,roadz,index);
1841 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1842 t.fCurrentCluster = cl;
1848 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1849 //-----------------------------------------------------------------
1850 // This function tries to find a track prolongation to next pad row
1851 //-----------------------------------------------------------------
1853 //update error according neighborhoud
1855 if (t.fCurrentCluster) {
1857 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1859 if (t.fCurrentCluster->IsUsed(10)){
1865 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1870 if (fIteration>0) accept = 0;
1871 if (accept<3) UpdateTrack(&t,accept);
1875 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1876 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1878 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1886 //_____________________________________________________________________________
1887 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1888 //-----------------------------------------------------------------
1889 // This function tries to find a track prolongation.
1890 //-----------------------------------------------------------------
1891 Double_t xt=t.GetX();
1893 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1894 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1895 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1897 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1899 Int_t first = GetRowNumber(xt)-1;
1900 for (Int_t nr= first; nr>=rf; nr-=step) {
1902 if (t.GetKinkIndexes()[0]>0){
1903 for (Int_t i=0;i<3;i++){
1904 Int_t index = t.GetKinkIndexes()[i];
1905 if (index==0) break;
1906 if (index<0) continue;
1908 AliESDkink * kink = fEvent->GetKink(index-1);
1910 printf("PROBLEM\n");
1913 Int_t kinkrow = kink->fRow0+Int_t(1./(0.1+kink->fAngle[2]));
1915 AliExternalTrackParam paramd(t);
1916 kink->SetDaughter(paramd);
1924 if (nr==80) t.UpdateReference();
1925 if (nr<fInnerSec->GetNRows())
1926 fSectors = fInnerSec;
1928 fSectors = fOuterSec;
1929 if (FollowToNext(t,nr)==0)
1938 //_____________________________________________________________________________
1939 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1940 //-----------------------------------------------------------------
1941 // This function tries to find a track prolongation.
1942 //-----------------------------------------------------------------
1943 Double_t xt=t.GetX();
1945 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1946 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1947 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1948 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1950 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1952 if (FollowToNextFast(t,nr)==0)
1953 if (!t.IsActive()) return 0;
1963 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1964 //-----------------------------------------------------------------
1965 // This function tries to find a track prolongation.
1966 //-----------------------------------------------------------------
1967 // Double_t xt=t.GetX();
1969 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1970 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1971 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1972 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1974 Int_t first = t.fFirstPoint;
1976 if (first<0) first=0;
1977 for (Int_t nr=first; nr<=rf; nr++) {
1978 //if ( (t.GetSnp()<0.9))
1979 if (t.GetKinkIndexes()[0]<0){
1980 for (Int_t i=0;i<3;i++){
1981 Int_t index = t.GetKinkIndexes()[i];
1982 if (index==0) break;
1983 if (index>0) continue;
1984 index = TMath::Abs(index);
1985 AliESDkink * kink = fEvent->GetKink(index-1);
1987 printf("PROBLEM\n");
1990 Int_t kinkrow = kink->fRow0-Int_t(1./(0.1+kink->fAngle[2]));
1992 AliExternalTrackParam paramm(t);
1993 kink->SetMother(paramm);
2000 if (nr<fInnerSec->GetNRows())
2001 fSectors = fInnerSec;
2003 fSectors = fOuterSec;
2013 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
2021 Float_t dz2 =(s1->GetZ() - s2->GetZ());
2024 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
2026 Float_t distance = TMath::Sqrt(dz2+dy2);
2027 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
2030 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
2031 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
2036 if (firstpoint>lastpoint) {
2037 firstpoint =lastpoint;
2042 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
2043 if (s1->GetClusterIndex2(i)>0) sum1++;
2044 if (s2->GetClusterIndex2(i)>0) sum2++;
2045 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
2049 if (sum<5) return 0;
2051 Float_t summin = TMath::Min(sum1+1,sum2+1);
2052 Float_t ratio = (sum+1)/Float_t(summin);
2056 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
2060 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
2061 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
2063 Float_t dz2 =(s1->GetZ() - s2->GetZ());
2065 Float_t dy2 =(s1->GetY() - s2->GetY());
2067 Float_t distance = dz2+dy2;
2068 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
2073 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
2074 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
2076 if (firstpoint>=lastpoint-5) return;;
2078 for (Int_t i=firstpoint;i<lastpoint;i++){
2079 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
2080 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
2087 for (Int_t i=firstpoint;i<lastpoint;i++){
2088 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
2089 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
2090 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
2091 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
2092 if (s1->IsActive()&&s2->IsActive()){
2093 p1->fIsShared = kTRUE;
2094 p2->fIsShared = kTRUE;
2101 for (Int_t i=0;i<4;i++){
2102 if (s1->fOverlapLabels[3*i]==0){
2103 s1->fOverlapLabels[3*i] = s2->GetLabel();
2104 s1->fOverlapLabels[3*i+1] = sumshared;
2105 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
2109 for (Int_t i=0;i<4;i++){
2110 if (s2->fOverlapLabels[3*i]==0){
2111 s2->fOverlapLabels[3*i] = s1->GetLabel();
2112 s2->fOverlapLabels[3*i+1] = sumshared;
2113 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2121 void AliTPCtrackerMI::SignShared(TObjArray * arr)
2124 //sort trackss according sectors
2126 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2127 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2129 //if (pt) RotateToLocal(pt);
2133 arr->Sort(); // sorting according z
2134 arr->Expand(arr->GetEntries());
2137 Int_t nseed=arr->GetEntriesFast();
2138 for (Int_t i=0; i<nseed; i++) {
2139 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2141 for (Int_t j=0;j<=12;j++){
2142 pt->fOverlapLabels[j] =0;
2145 for (Int_t i=0; i<nseed; i++) {
2146 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2148 if (pt->fRemoval>10) continue;
2149 for (Int_t j=i+1; j<nseed; j++){
2150 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2152 if (pt2->fRemoval<=10) {
2153 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2160 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2163 //sort trackss according sectors
2166 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
2169 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2170 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2175 arr->Sort(); // sorting according z
2176 arr->Expand(arr->GetEntries());
2178 //reset overlap labels
2180 Int_t nseed=arr->GetEntriesFast();
2181 for (Int_t i=0; i<nseed; i++) {
2182 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2185 for (Int_t j=0;j<=12;j++){
2186 pt->fOverlapLabels[j] =0;
2190 //sign shared tracks
2191 for (Int_t i=0; i<nseed; i++) {
2192 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2194 if (pt->fRemoval>10) continue;
2195 Float_t deltac = pt->GetC()*0.1;
2196 for (Int_t j=i+1; j<nseed; j++){
2197 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2199 if (pt2->fRemoval<=10) {
2200 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2201 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2202 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2209 // remove highly shared tracks
2210 for (Int_t i=0; i<nseed; i++) {
2211 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2213 if (pt->fRemoval>10) continue;
2216 for (Int_t j=0;j<4;j++){
2217 sumshared = pt->fOverlapLabels[j*3+1];
2219 Float_t factor = factor1;
2220 if (pt->fRemoval>0) factor = factor2;
2221 if (sumshared/pt->GetNumberOfClusters()>factor){
2222 for (Int_t j=0;j<4;j++){
2223 if (pt->fOverlapLabels[3*j]==0) continue;
2224 if (pt->fOverlapLabels[3*j+1]<5) continue;
2225 if (pt->fRemoval==removalindex) continue;
2226 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2228 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2229 // pt->fRemoval = removalindex;
2230 delete arr->RemoveAt(i);
2238 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
2247 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
2250 //sort tracks in array according mode criteria
2251 Int_t nseed = arr->GetEntriesFast();
2252 for (Int_t i=0; i<nseed; i++) {
2253 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2263 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2266 //Loop over all tracks and remove "overlaps"
2269 Int_t nseed = arr->GetEntriesFast();
2272 for (Int_t i=0; i<nseed; i++) {
2273 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2275 delete arr->RemoveAt(i);
2279 pt->fBSigned = kFALSE;
2283 nseed = arr->GetEntriesFast();
2290 for (Int_t i=0; i<nseed; i++) {
2291 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2295 Int_t found,foundable,shared;
2297 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2299 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2301 Double_t factor = factor2;
2302 if (pt->fBConstrain) factor = factor1;
2304 if ((Float_t(shared)/Float_t(found))>factor){
2305 pt->Desactivate(removalindex);
2310 for (Int_t i=0; i<160; i++) {
2311 Int_t index=pt->GetClusterIndex2(i);
2312 if (index<0 || index&0x8000 ) continue;
2313 AliTPCclusterMI *c= pt->fClusterPointer[i];
2315 // if (!c->IsUsed(10)) c->Use(10);
2316 //if (pt->IsActive())
2325 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2330 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2333 //Loop over all tracks and remove "overlaps"
2338 Int_t nseed = arr->GetEntriesFast();
2339 Float_t * quality = new Float_t[nseed];
2340 Int_t * indexes = new Int_t[nseed];
2344 for (Int_t i=0; i<nseed; i++) {
2345 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2350 pt->UpdatePoints(); //select first last max dens points
2351 Float_t * points = pt->GetPoints();
2352 if (points[3]<0.8) quality[i] =-1;
2354 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2356 TMath::Sort(nseed,quality,indexes);
2359 for (Int_t itrack=0; itrack<nseed; itrack++) {
2360 Int_t trackindex = indexes[itrack];
2361 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2362 if (quality[trackindex]<0){
2364 delete arr->RemoveAt(trackindex);
2367 arr->RemoveAt(trackindex);
2372 Int_t first = Int_t(pt->GetPoints()[0]);
2373 Int_t last = Int_t(pt->GetPoints()[2]);
2374 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2376 Int_t found,foundable,shared;
2377 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
2378 Float_t sharedfactor = Float_t(shared)/Float_t(found);
2380 if (Float_t(shared)/Float_t(found)>factor){
2381 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2382 delete arr->RemoveAt(trackindex);
2386 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2387 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2388 delete arr->RemoveAt(trackindex);
2393 if (sharedfactor>0.4) continue;
2394 for (Int_t i=first; i<last; i++) {
2395 Int_t index=pt->GetClusterIndex2(i);
2396 // if (index<0 || index&0x8000 ) continue;
2397 if (index<0 || index&0x8000 ) continue;
2398 AliTPCclusterMI *c= pt->fClusterPointer[i];
2405 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2411 void AliTPCtrackerMI::UnsignClusters()
2414 // loop over all clusters and unsign them
2417 for (Int_t sec=0;sec<fkNIS;sec++){
2418 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2419 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2420 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2421 // if (cl[icl].IsUsed(10))
2423 cl = fInnerSec[sec][row].fClusters2;
2424 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2425 //if (cl[icl].IsUsed(10))
2430 for (Int_t sec=0;sec<fkNOS;sec++){
2431 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2432 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2433 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2434 //if (cl[icl].IsUsed(10))
2436 cl = fOuterSec[sec][row].fClusters2;
2437 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2438 //if (cl[icl].IsUsed(10))
2447 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2450 //sign clusters to be "used"
2452 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2453 // loop over "primaries"
2467 Int_t nseed = arr->GetEntriesFast();
2468 for (Int_t i=0; i<nseed; i++) {
2469 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2473 if (!(pt->IsActive())) continue;
2474 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2475 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2477 sumdens2+= dens*dens;
2478 sumn += pt->GetNumberOfClusters();
2479 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2480 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2483 sumchi2 +=chi2*chi2;
2488 Float_t mdensity = 0.9;
2489 Float_t meann = 130;
2490 Float_t meanchi = 1;
2491 Float_t sdensity = 0.1;
2492 Float_t smeann = 10;
2493 Float_t smeanchi =0.4;
2497 mdensity = sumdens/sum;
2499 meanchi = sumchi/sum;
2501 sdensity = sumdens2/sum-mdensity*mdensity;
2502 sdensity = TMath::Sqrt(sdensity);
2504 smeann = sumn2/sum-meann*meann;
2505 smeann = TMath::Sqrt(smeann);
2507 smeanchi = sumchi2/sum - meanchi*meanchi;
2508 smeanchi = TMath::Sqrt(smeanchi);
2512 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2514 for (Int_t i=0; i<nseed; i++) {
2515 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2519 if (pt->fBSigned) continue;
2520 if (pt->fBConstrain) continue;
2521 //if (!(pt->IsActive())) continue;
2523 Int_t found,foundable,shared;
2524 pt->GetClusterStatistic(0,160,found, foundable,shared);
2525 if (shared/float(found)>0.3) {
2526 if (shared/float(found)>0.9 ){
2527 //delete arr->RemoveAt(i);
2532 Bool_t isok =kFALSE;
2533 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2535 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2537 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2539 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2543 for (Int_t i=0; i<160; i++) {
2544 Int_t index=pt->GetClusterIndex2(i);
2545 if (index<0) continue;
2546 AliTPCclusterMI *c= pt->fClusterPointer[i];
2548 //if (!(c->IsUsed(10))) c->Use();
2555 Double_t maxchi = meanchi+2.*smeanchi;
2557 for (Int_t i=0; i<nseed; i++) {
2558 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2562 //if (!(pt->IsActive())) continue;
2563 if (pt->fBSigned) continue;
2564 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2565 if (chi>maxchi) continue;
2568 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2570 //sign only tracks with enoug big density at the beginning
2572 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2575 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2576 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2578 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2579 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2582 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2583 //Int_t noc=pt->GetNumberOfClusters();
2584 pt->fBSigned = kTRUE;
2585 for (Int_t i=0; i<160; i++) {
2587 Int_t index=pt->GetClusterIndex2(i);
2588 if (index<0) continue;
2589 AliTPCclusterMI *c= pt->fClusterPointer[i];
2591 // if (!(c->IsUsed(10))) c->Use();
2596 // gLastCheck = nseed;
2604 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
2606 // stop not active tracks
2607 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2608 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2609 Int_t nseed = arr->GetEntriesFast();
2611 for (Int_t i=0; i<nseed; i++) {
2612 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2616 if (!(pt->IsActive())) continue;
2617 StopNotActive(pt,row0,th0, th1,th2);
2623 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2626 // stop not active tracks
2627 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2628 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2631 Int_t foundable = 0;
2632 Int_t maxindex = seed->fLastPoint; //last foundable row
2633 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2634 seed->Desactivate(10) ;
2638 for (Int_t i=row0; i<maxindex; i++){
2639 Int_t index = seed->GetClusterIndex2(i);
2640 if (index!=-1) foundable++;
2642 if (foundable<=30) sumgood1++;
2643 if (foundable<=50) {
2650 if (foundable>=30.){
2651 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2654 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2658 Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2661 // back propagation of ESD tracks
2667 //PrepareForProlongation(fSeeds,1);
2668 PropagateForward2(fSeeds);
2670 Int_t nseed = fSeeds->GetEntriesFast();
2671 for (Int_t i=0;i<nseed;i++){
2672 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2673 if (!seed) continue;
2674 seed->PropagateTo(fParam->GetInnerRadiusLow());
2675 seed->UpdatePoints();
2676 AliESDtrack *esd=event->GetTrack(i);
2677 seed->CookdEdx(0.02,0.6);
2678 CookLabel(seed,0.1); //For comparison only
2679 if (seed->GetNumberOfClusters()>15){
2680 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2681 esd->SetTPCPoints(seed->GetPoints());
2685 //printf("problem\n");
2688 //FindKinks(fSeeds,event);
2689 Info("RefitInward","Number of refitted tracks %d",ntracks);
2696 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2699 // back propagation of ESD tracks
2705 PropagateBack(fSeeds);
2706 Int_t nseed = fSeeds->GetEntriesFast();
2708 for (Int_t i=0;i<nseed;i++){
2709 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2710 if (!seed) continue;
2711 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2712 seed->UpdatePoints();
2713 AliESDtrack *esd=event->GetTrack(i);
2714 seed->CookdEdx(0.02,0.6);
2715 CookLabel(seed,0.1); //For comparison only
2716 if (seed->GetNumberOfClusters()>15){
2717 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2718 esd->SetTPCPoints(seed->GetPoints());
2722 //FindKinks(fSeeds,event);
2723 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
2730 void AliTPCtrackerMI::DeleteSeeds()
2734 Int_t nseed = fSeeds->GetEntriesFast();
2735 for (Int_t i=0;i<nseed;i++){
2736 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2737 if (seed) delete fSeeds->RemoveAt(i);
2743 void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
2746 //read seeds from the event
2748 Int_t nentr=event->GetNumberOfTracks();
2750 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2755 fSeeds = new TObjArray(nentr);
2759 for (Int_t i=0; i<nentr; i++) {
2760 AliESDtrack *esd=event->GetTrack(i);
2761 ULong_t status=esd->GetStatus();
2762 if (!(status&AliESDtrack::kTPCin)) continue;
2763 AliTPCtrack t(*esd);
2764 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2765 for (Int_t ikink=0;ikink<3;ikink++) seed->GetKinkIndexes()[ikink] = esd->GetKinkIndex(ikink);
2766 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2767 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
2768 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2773 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2774 Double_t par0[5],par1[5],x;
2775 esd->GetInnerExternalParameters(x,par0);
2776 esd->GetExternalParameters(x,par1);
2777 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2778 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2780 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
2781 //reset covariance if suspicious
2782 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
2783 seed->ResetCovariance();
2788 // rotate to the local coordinate system
2790 fSectors=fInnerSec; fN=fkNIS;
2792 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2793 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2794 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2795 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2796 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2797 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2798 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
2799 alpha-=seed->GetAlpha();
2800 if (!seed->Rotate(alpha)) {
2806 //seed->PropagateTo(fSectors->GetX(0));
2808 // Int_t index = esd->GetTPCindex();
2809 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2810 //if (direction==2){
2811 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2819 for (Int_t irow=0;irow<160;irow++){
2820 Int_t index = seed->GetClusterIndex2(irow);
2823 AliTPCclusterMI * cl = GetClusterMI(index);
2824 seed->fClusterPointer[irow] = cl;
2826 if ((index & 0x8000)==0){
2827 cl->Use(10); // accepted cluster
2829 cl->Use(6); // close cluster not accepted
2832 Info("ReadSeeds","Not found cluster");
2836 fSeeds->AddAt(seed,i);
2842 //_____________________________________________________________________________
2843 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2844 Float_t deltay, Int_t ddsec) {
2845 //-----------------------------------------------------------------
2846 // This function creates track seeds.
2847 // SEEDING WITH VERTEX CONSTRAIN
2848 //-----------------------------------------------------------------
2849 // cuts[0] - fP4 cut
2850 // cuts[1] - tan(phi) cut
2851 // cuts[2] - zvertex cut
2852 // cuts[3] - fP3 cut
2860 Double_t x[5], c[15];
2861 // Int_t di = i1-i2;
2863 AliTPCseed * seed = new AliTPCseed;
2864 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2865 Double_t cs=cos(alpha), sn=sin(alpha);
2867 // Double_t x1 =fOuterSec->GetX(i1);
2868 //Double_t xx2=fOuterSec->GetX(i2);
2870 Double_t x1 =GetXrow(i1);
2871 Double_t xx2=GetXrow(i2);
2873 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2875 Int_t imiddle = (i2+i1)/2; //middle pad row index
2876 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2877 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2881 const AliTPCRow& kr1=GetRow(ns,i1);
2882 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2883 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2886 // change cut on curvature if it can't reach this layer
2887 // maximal curvature set to reach it
2888 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2889 if (dvertexmax*0.5*cuts[0]>0.85){
2890 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2892 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2895 if (deltay>0) ddsec = 0;
2896 // loop over clusters
2897 for (Int_t is=0; is < kr1; is++) {
2899 if (kr1[is]->IsUsed(10)) continue;
2900 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2901 //if (TMath::Abs(y1)>ymax) continue;
2903 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2905 // find possible directions
2906 Float_t anglez = (z1-z3)/(x1-x3);
2907 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2910 //find rotation angles relative to line given by vertex and point 1
2911 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2912 Double_t dvertex = TMath::Sqrt(dvertex2);
2913 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2914 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2917 // loop over 2 sectors
2923 Double_t dddz1=0; // direction of delta inclination in z axis
2930 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2931 Int_t sec2 = sec + dsec;
2933 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2934 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2935 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2936 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2937 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2938 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2940 // rotation angles to p1-p3
2941 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2942 Double_t x2, y2, z2;
2944 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2947 Double_t dxx0 = (xx2-x3)*cs13r;
2948 Double_t dyy0 = (xx2-x3)*sn13r;
2949 for (Int_t js=index1; js < index2; js++) {
2950 const AliTPCclusterMI *kcl = kr2[js];
2951 if (kcl->IsUsed(10)) continue;
2953 //calcutate parameters
2955 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2957 if (TMath::Abs(yy0)<0.000001) continue;
2958 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2959 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2960 Double_t r02 = (0.25+y0*y0)*dvertex2;
2961 //curvature (radius) cut
2962 if (r02<r2min) continue;
2966 Double_t c0 = 1/TMath::Sqrt(r02);
2970 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2971 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2972 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2973 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2976 Double_t z0 = kcl->GetZ();
2977 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2978 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2981 Double_t dip = (z1-z0)*c0/dfi1;
2982 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2993 x2= xx2*cs-y2*sn*dsec;
2994 y2=+xx2*sn*dsec+y2*cs;
3004 // do we have cluster at the middle ?
3006 GetProlongation(x1,xm,x,ym,zm);
3008 AliTPCclusterMI * cm=0;
3009 if (TMath::Abs(ym)-ymaxm<0){
3010 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
3011 if ((!cm) || (cm->IsUsed(10))) {
3016 // rotate y1 to system 0
3017 // get state vector in rotated system
3018 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
3019 Double_t xr2 = x0*cs+yr1*sn*dsec;
3020 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
3022 GetProlongation(xx2,xm,xr,ym,zm);
3023 if (TMath::Abs(ym)-ymaxm<0){
3024 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
3025 if ((!cm) || (cm->IsUsed(10))) {
3035 dym = ym - cm->GetY();
3036 dzm = zm - cm->GetZ();
3043 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
3044 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
3045 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
3046 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3047 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
3049 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3050 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3051 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3052 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3053 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3054 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3056 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3057 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3058 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3059 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3063 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3064 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3065 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3066 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3067 c[13]=f30*sy1*f40+f32*sy2*f42;
3068 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3070 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3072 UInt_t index=kr1.GetIndex(is);
3073 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
3075 track->fIsSeeding = kTRUE;
3082 FollowProlongation(*track, (i1+i2)/2,1);
3083 Int_t foundable,found,shared;
3084 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3085 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3087 seed->~AliTPCseed();
3093 FollowProlongation(*track, i2,1);
3097 track->fBConstrain =1;
3098 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3099 track->fLastPoint = i1; // first cluster in track position
3100 track->fFirstPoint = track->fLastPoint;
3102 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3103 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3104 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3106 seed->~AliTPCseed();
3110 // Z VERTEX CONDITION
3112 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3113 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3114 if (TMath::Abs(zv-z3)>cuts[2]) {
3115 FollowProlongation(*track, TMath::Max(i2-20,0));
3116 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3117 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3118 if (TMath::Abs(zv-z3)>cuts[2]){
3119 FollowProlongation(*track, TMath::Max(i2-40,0));
3120 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3121 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3122 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3123 // make seed without constrain
3124 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3125 FollowProlongation(*track2, i2,1);
3126 track2->fBConstrain = kFALSE;
3127 track2->fSeedType = 1;
3128 arr->AddLast(track2);
3130 seed->~AliTPCseed();
3135 seed->~AliTPCseed();
3142 track->fSeedType =0;
3143 arr->AddLast(track);
3144 seed = new AliTPCseed;
3146 // don't consider other combinations
3147 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3153 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
3159 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3164 //-----------------------------------------------------------------
3165 // This function creates track seeds.
3166 //-----------------------------------------------------------------
3167 // cuts[0] - fP4 cut
3168 // cuts[1] - tan(phi) cut
3169 // cuts[2] - zvertex cut
3170 // cuts[3] - fP3 cut
3180 Double_t x[5], c[15];
3182 // make temporary seed
3183 AliTPCseed * seed = new AliTPCseed;
3184 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3185 // Double_t cs=cos(alpha), sn=sin(alpha);
3190 Double_t x1 = GetXrow(i1-1);
3191 const AliTPCRow& kr1=GetRow(sec,i1-1);
3192 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3194 Double_t x1p = GetXrow(i1);
3195 const AliTPCRow& kr1p=GetRow(sec,i1);
3197 Double_t x1m = GetXrow(i1-2);
3198 const AliTPCRow& kr1m=GetRow(sec,i1-2);
3201 //last 3 padrow for seeding
3202 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3203 Double_t x3 = GetXrow(i1-7);
3204 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3206 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3207 Double_t x3p = GetXrow(i1-6);
3209 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3210 Double_t x3m = GetXrow(i1-8);
3215 Int_t im = i1-4; //middle pad row index
3216 Double_t xm = GetXrow(im); // radius of middle pad-row
3217 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3218 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3221 Double_t deltax = x1-x3;
3222 Double_t dymax = deltax*cuts[1];
3223 Double_t dzmax = deltax*cuts[3];
3225 // loop over clusters
3226 for (Int_t is=0; is < kr1; is++) {
3228 if (kr1[is]->IsUsed(10)) continue;
3229 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
3231 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3233 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3234 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3240 for (Int_t js=index1; js < index2; js++) {
3241 const AliTPCclusterMI *kcl = kr3[js];
3242 if (kcl->IsUsed(10)) continue;
3244 // apply angular cuts
3245 if (TMath::Abs(y1-y3)>dymax) continue;
3248 if (TMath::Abs(z1-z3)>dzmax) continue;
3250 Double_t angley = (y1-y3)/(x1-x3);
3251 Double_t anglez = (z1-z3)/(x1-x3);
3253 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3254 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3256 Double_t yyym = angley*(xm-x1)+y1;
3257 Double_t zzzm = anglez*(xm-x1)+z1;
3259 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3261 if (kcm->IsUsed(10)) continue;
3263 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3264 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3271 // look around first
3272 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3278 if (kc1m->IsUsed(10)) used++;
3280 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3286 if (kc1p->IsUsed(10)) used++;
3288 if (used>1) continue;
3289 if (found<1) continue;
3293 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3299 if (kc3m->IsUsed(10)) used++;
3303 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3309 if (kc3p->IsUsed(10)) used++;
3313 if (used>1) continue;
3314 if (found<3) continue;
3324 x[4]=F1(x1,y1,x2,y2,x3,y3);
3325 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3328 x[2]=F2(x1,y1,x2,y2,x3,y3);
3331 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
3332 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3336 Double_t sy1=0.1, sz1=0.1;
3337 Double_t sy2=0.1, sz2=0.1;
3338 Double_t sy3=0.1, sy=0.1, sz=0.1;
3340 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3341 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3342 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3343 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3344 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3345 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3347 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3348 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3349 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3350 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
3354 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3355 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3356 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3357 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3358 c[13]=f30*sy1*f40+f32*sy2*f42;
3359 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3361 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3363 UInt_t index=kr1.GetIndex(is);
3364 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3366 track->fIsSeeding = kTRUE;
3369 FollowProlongation(*track, i1-7,1);
3370 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3371 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3373 seed->~AliTPCseed();
3379 FollowProlongation(*track, i2,1);
3380 track->fBConstrain =0;
3381 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3382 track->fFirstPoint = track->fLastPoint;
3384 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3385 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3386 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3388 seed->~AliTPCseed();
3393 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3394 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3395 FollowProlongation(*track2, i2,1);
3396 track2->fBConstrain = kFALSE;
3397 track2->fSeedType = 4;
3398 arr->AddLast(track2);
3400 seed->~AliTPCseed();
3404 //arr->AddLast(track);
3405 //seed = new AliTPCseed;
3411 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3417 //_____________________________________________________________________________
3418 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3419 Float_t deltay, Bool_t /*bconstrain*/) {
3420 //-----------------------------------------------------------------
3421 // This function creates track seeds - without vertex constraint
3422 //-----------------------------------------------------------------
3423 // cuts[0] - fP4 cut - not applied
3424 // cuts[1] - tan(phi) cut
3425 // cuts[2] - zvertex cut - not applied
3426 // cuts[3] - fP3 cut
3436 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3437 // Double_t cs=cos(alpha), sn=sin(alpha);
3438 Int_t row0 = (i1+i2)/2;
3439 Int_t drow = (i1-i2)/2;
3440 const AliTPCRow& kr0=fSectors[sec][row0];
3443 AliTPCpolyTrack polytrack;
3444 Int_t nclusters=fSectors[sec][row0];
3445 AliTPCseed * seed = new AliTPCseed;
3450 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3452 Int_t nfoundable =0;
3453 for (Int_t iter =1; iter<2; iter++){ //iterations
3454 const AliTPCRow& krm=fSectors[sec][row0-iter];
3455 const AliTPCRow& krp=fSectors[sec][row0+iter];
3456 const AliTPCclusterMI * cl= kr0[is];
3458 if (cl->IsUsed(10)) {
3464 Double_t x = kr0.GetX();
3465 // Initialization of the polytrack
3470 Double_t y0= cl->GetY();
3471 Double_t z0= cl->GetZ();
3475 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3476 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3478 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3479 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3480 polytrack.AddPoint(x,y0,z0,erry, errz);
3483 if (cl->IsUsed(10)) sumused++;
3486 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3487 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3490 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3491 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3492 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3493 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3494 if (cl1->IsUsed(10)) sumused++;
3495 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3499 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3501 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3502 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3503 if (cl2->IsUsed(10)) sumused++;
3504 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3507 if (sumused>0) continue;
3509 polytrack.UpdateParameters();
3515 nfoundable = polytrack.GetN();
3516 nfound = nfoundable;
3518 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3519 Float_t maxdist = 0.8*(1.+3./(ddrow));
3520 for (Int_t delta = -1;delta<=1;delta+=2){
3521 Int_t row = row0+ddrow*delta;
3522 kr = &(fSectors[sec][row]);
3523 Double_t xn = kr->GetX();
3524 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3525 polytrack.GetFitPoint(xn,yn,zn);
3526 if (TMath::Abs(yn)>ymax) continue;
3528 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3530 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3533 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3534 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3535 if (cln->IsUsed(10)) {
3536 // printf("used\n");
3544 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3549 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3550 polytrack.UpdateParameters();
3553 if ( (sumused>3) || (sumused>0.5*nfound)) {
3554 //printf("sumused %d\n",sumused);
3559 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3560 AliTPCpolyTrack track2;
3562 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3563 if (track2.GetN()<0.5*nfoundable) continue;
3566 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3568 // test seed with and without constrain
3569 for (Int_t constrain=0; constrain<=0;constrain++){
3570 // add polytrack candidate
3572 Double_t x[5], c[15];
3573 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3574 track2.GetBoundaries(x3,x1);
3576 track2.GetFitPoint(x1,y1,z1);
3577 track2.GetFitPoint(x2,y2,z2);
3578 track2.GetFitPoint(x3,y3,z3);
3580 //is track pointing to the vertex ?
3583 polytrack.GetFitPoint(x0,y0,z0);
3596 x[4]=F1(x1,y1,x2,y2,x3,y3);
3598 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3599 x[2]=F2(x1,y1,x2,y2,x3,y3);
3601 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3602 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3603 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3604 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3607 Double_t sy =0.1, sz =0.1;
3608 Double_t sy1=0.02, sz1=0.02;
3609 Double_t sy2=0.02, sz2=0.02;
3613 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3616 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3617 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3618 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3619 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3620 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3621 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3623 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3624 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3625 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3626 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3631 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3632 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3633 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3634 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3635 c[13]=f30*sy1*f40+f32*sy2*f42;
3636 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3638 //Int_t row1 = fSectors->GetRowNumber(x1);
3639 Int_t row1 = GetRowNumber(x1);
3643 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3644 track->fIsSeeding = kTRUE;
3645 Int_t rc=FollowProlongation(*track, i2);
3646 if (constrain) track->fBConstrain =1;
3648 track->fBConstrain =0;
3649 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3650 track->fFirstPoint = track->fLastPoint;
3652 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3653 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3654 track->fNShared>0.4*track->GetNumberOfClusters()) {
3657 seed->~AliTPCseed();
3660 arr->AddLast(track);
3661 seed = new AliTPCseed;
3665 } // if accepted seed
3668 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3674 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3678 //reseed using track points
3679 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3680 Int_t p1 = int(r1*track->GetNumberOfClusters());
3681 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3683 Double_t x0[3],x1[3],x2[3];
3688 // find track position at given ratio of the length
3689 Int_t sec0, sec1, sec2;
3695 for (Int_t i=0;i<160;i++){
3696 if (track->fClusterPointer[i]){
3698 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3699 if ( (index<p0) || x0[0]<0 ){
3700 if (trpoint->GetX()>1){
3701 clindex = track->GetClusterIndex2(i);
3703 x0[0] = trpoint->GetX();
3704 x0[1] = trpoint->GetY();
3705 x0[2] = trpoint->GetZ();
3706 sec0 = ((clindex&0xff000000)>>24)%18;
3711 if ( (index<p1) &&(trpoint->GetX()>1)){
3712 clindex = track->GetClusterIndex2(i);
3714 x1[0] = trpoint->GetX();
3715 x1[1] = trpoint->GetY();
3716 x1[2] = trpoint->GetZ();
3717 sec1 = ((clindex&0xff000000)>>24)%18;
3720 if ( (index<p2) &&(trpoint->GetX()>1)){
3721 clindex = track->GetClusterIndex2(i);
3723 x2[0] = trpoint->GetX();
3724 x2[1] = trpoint->GetY();
3725 x2[2] = trpoint->GetZ();
3726 sec2 = ((clindex&0xff000000)>>24)%18;
3733 Double_t alpha, cs,sn, xx2,yy2;
3735 alpha = (sec1-sec2)*fSectors->GetAlpha();
3736 cs = TMath::Cos(alpha);
3737 sn = TMath::Sin(alpha);
3738 xx2= x1[0]*cs-x1[1]*sn;
3739 yy2= x1[0]*sn+x1[1]*cs;
3743 alpha = (sec0-sec2)*fSectors->GetAlpha();
3744 cs = TMath::Cos(alpha);
3745 sn = TMath::Sin(alpha);
3746 xx2= x0[0]*cs-x0[1]*sn;
3747 yy2= x0[0]*sn+x0[1]*cs;
3753 Double_t x[5],c[15];
3757 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3758 // if (x[4]>1) return 0;
3759 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3760 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3761 //if (TMath::Abs(x[3]) > 2.2) return 0;
3762 //if (TMath::Abs(x[2]) > 1.99) return 0;
3764 Double_t sy =0.1, sz =0.1;
3766 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3767 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3768 Double_t sy3=0.01+track->GetSigmaY2();
3770 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3771 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3772 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3773 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3774 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3775 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3777 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3778 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3779 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3780 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3785 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3786 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3787 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3788 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3789 c[13]=f30*sy1*f40+f32*sy2*f42;
3790 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3792 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3793 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3794 // Double_t y0,z0,y1,z1, y2,z2;
3795 //seed->GetProlongation(x0[0],y0,z0);
3796 // seed->GetProlongation(x1[0],y1,z1);
3797 //seed->GetProlongation(x2[0],y2,z2);
3799 seed->fLastPoint = pp2;
3800 seed->fFirstPoint = pp2;
3807 AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3811 //reseed using founded clusters
3813 // Find the number of clusters
3814 Int_t nclusters = 0;
3815 for (Int_t irow=0;irow<160;irow++){
3816 if (track->GetClusterIndex(irow)>0) nclusters++;
3820 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3821 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3822 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3826 Int_t row[3],sec[3]={0,0,0};
3828 // find track row position at given ratio of the length
3830 for (Int_t irow=0;irow<160;irow++){
3831 if (track->GetClusterIndex2(irow)<0) continue;
3833 for (Int_t ipoint=0;ipoint<3;ipoint++){
3834 if (index<=ipos[ipoint]) row[ipoint] = irow;
3838 //Get cluster and sector position
3839 for (Int_t ipoint=0;ipoint<3;ipoint++){
3840 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3841 AliTPCclusterMI * cl = GetClusterMI(clindex);
3844 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3847 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3848 xyz[ipoint][0] = GetXrow(row[ipoint]);
3849 xyz[ipoint][1] = cl->GetY();
3850 xyz[ipoint][2] = cl->GetZ();
3854 // Calculate seed state vector and covariance matrix
3856 Double_t alpha, cs,sn, xx2,yy2;
3858 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3859 cs = TMath::Cos(alpha);
3860 sn = TMath::Sin(alpha);
3861 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3862 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3866 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3867 cs = TMath::Cos(alpha);
3868 sn = TMath::Sin(alpha);
3869 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3870 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3876 Double_t x[5],c[15];
3880 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3881 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3882 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3884 Double_t sy =0.1, sz =0.1;
3886 Double_t sy1=0.2, sz1=0.2;
3887 Double_t sy2=0.2, sz2=0.2;
3890 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;
3891 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;
3892 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;
3893 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;
3894 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;
3895 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;
3897 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;
3898 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;
3899 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;
3900 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;
3905 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3906 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3907 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3908 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3909 c[13]=f30*sy1*f40+f32*sy2*f42;
3910 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3912 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3913 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3914 seed->fLastPoint = row[2];
3915 seed->fFirstPoint = row[2];
3919 void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
3925 TObjArray *kinks= new TObjArray(10000);
3926 Int_t nentries = array->GetEntriesFast();
3927 AliHelix *helixes = new AliHelix[nentries];
3928 Int_t *sign = new Int_t[nentries];
3929 Int_t *nclusters = new Int_t[nentries];
3930 Float_t *alpha = new Float_t[nentries];
3931 AliESDkink * kink = new AliESDkink();
3932 Int_t * usage = new Int_t[nentries];
3933 Float_t *zm = new Float_t[nentries];
3934 Float_t *fim = new Float_t[nentries];
3938 for (Int_t i=0;i<nentries;i++){
3941 AliTPCseed* track = (AliTPCseed*)array->At(i);
3942 if (!track) continue;
3943 track->UpdatePoints();
3944 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
3945 nclusters[i]=track->GetNumberOfClusters();
3946 alpha[i] = track->GetAlpha();
3947 new (&helixes[i]) AliHelix(*track);
3948 sign[i] = (track->GetC()>0) ? -1:1;
3951 if (track->GetProlongation(x,y,z)){
3953 fim[i] = alpha[i]+TMath::ATan2(y,x);
3956 zm[i] = track->GetZ();
3965 Int_t ncandidates =0;
3968 Double_t phase[2][2],radius[2];
3971 for (Int_t i =0;i<nentries;i++){
3972 if (sign[i]==0) continue;
3973 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
3976 Double_t cradius0 = 40*40;
3977 Double_t cradius1 = 270*270;
3980 Double_t cdist3=0.55;
3981 for (Int_t j =i+1;j<nentries;j++){
3983 if (sign[j]*sign[i]<1) continue;
3984 if ( (nclusters[i]+nclusters[j])>200) continue;
3985 if ( (nclusters[i]+nclusters[j])<80) continue;
3986 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
3987 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
3988 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
3989 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
3990 if (npoints<1) continue;
3993 if (radius[0]<cradius0||radius[0]>cradius1) continue;
3996 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
3999 Double_t delta1=10000,delta2=10000;
4000 // cuts on the intersection radius
4001 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4002 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4003 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4005 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4006 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4007 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4010 Double_t distance1 = TMath::Min(delta1,delta2);
4011 if (distance1>cdist1) continue; // cut on DCA linear approximation
4013 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4014 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4015 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4016 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4019 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4020 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4021 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4023 distance1 = TMath::Min(delta1,delta2);
4026 rkink = TMath::Sqrt(radius[0]);
4029 rkink = TMath::Sqrt(radius[1]);
4031 if (distance1>cdist2) continue;
4034 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4037 Int_t row0 = GetRowNumber(rkink);
4038 if (row0<10) continue;
4039 if (row0>150) continue;
4042 Float_t dens00=-1,dens01=-1;
4043 Float_t dens10=-1,dens11=-1;
4045 Int_t found,foundable,shared;
4046 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4047 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4048 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4049 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4051 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4052 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4053 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4054 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
4056 if (dens00<dens10 && dens01<dens11) continue;
4057 if (dens00>dens10 && dens01>dens11) continue;
4058 if (TMath::Max(dens00,dens10)<0.1) continue;
4059 if (TMath::Max(dens01,dens11)<0.3) continue;
4061 if (TMath::Min(dens00,dens10)>0.6) continue;
4062 if (TMath::Min(dens01,dens11)>0.6) continue;
4065 AliTPCseed * ktrack0, *ktrack1;
4074 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4075 AliExternalTrackParam paramm(*ktrack0);
4076 AliExternalTrackParam paramd(*ktrack1);
4077 if (row0>60&&ktrack1->GetReference().X()>90.) new (¶md) AliExternalTrackParam(ktrack1->GetReference());
4080 kink->SetMother(paramm);
4081 kink->SetDaughter(paramd);
4084 Float_t x[3] = { kink->fXr[0],kink->fXr[1],kink->fXr[2]};
4086 fParam->Transform0to1(x,index);
4087 fParam->Transform1to2(x,index);
4088 row0 = GetRowNumber(x[0]);
4090 if (kink->fRr<100) continue;
4091 if (kink->fRr>240) continue;
4092 if (kink->fDist2>cdist3) continue;
4093 Float_t dird = kink->fPdr[0]*kink->fXr[0]+kink->fPdr[1]*kink->fXr[1]; // rough direction estimate
4094 if (dird<0) continue;
4096 Float_t dirm = kink->fPm[0]*kink->fXr[0]+kink->fPm[1]*kink->fXr[1]; // rough direction estimate
4097 if (dirm<0) continue;
4098 Float_t mpt = TMath::Sqrt(kink->fPm[0]*kink->fPm[0]+kink->fPm[1]*kink->fPm[1]);
4099 if (mpt<0.2) continue;
4102 Double_t qt = TMath::Sin(kink->fAngle[2])*ktrack1->P();
4103 if (qt>0.35) continue;
4105 kink->fLab[0] = CookLabel(ktrack0,0.4,0,row0);
4106 kink->fLab[1] = CookLabel(ktrack1,0.4,row0,160);
4108 kink->fTPCdensity[0][0] = dens00;
4109 kink->fTPCdensity[0][1] = dens01;
4110 kink->fTPCdensity[1][0] = dens10;
4111 kink->fTPCdensity[1][1] = dens11;
4112 kink->fIndex[0] = i;
4113 kink->fIndex[1] = j;
4114 kink->fZm[0] = zm[i];
4115 kink->fZm[1] = zm[j];
4116 kink->fFi[0] = fim[i];
4117 kink->fFi[1] = fim[j];
4120 kink->fTPCdensity[0][0] = dens10;
4121 kink->fTPCdensity[0][1] = dens11;
4122 kink->fTPCdensity[1][0] = dens00;
4123 kink->fTPCdensity[1][1] = dens01;
4124 kink->fIndex[0] = j;
4125 kink->fIndex[1] = i;
4126 kink->fZm[0] = zm[j];
4127 kink->fZm[1] = zm[i];
4128 kink->fFi[0] = fim[j];
4129 kink->fFi[1] = fim[i];
4132 if (kink->GetTPCDensityFactor()<0.8) continue;
4133 if ((2-kink->GetTPCDensityFactor())*kink->fDist2 >0.25) continue;
4134 if (kink->fAngle[2]*ktrack0->P()<0.003) continue; //too small angle
4135 if (kink->fAngle[2]>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4136 if (kink->fAngle[2]>0.2&&kink->fTPCdensity[0][1]) continue;
4137 if (kink->fAngle[2]<0.02) continue;
4141 Int_t drow = Int_t(2./TMath::Tan(0.3+kink->fAngle[2])); // overlap region defined
4143 Float_t shapesum =0;
4145 for ( Int_t row = row0-drow; row<row0+drow;row++){
4146 if (row<0) continue;
4147 if (row>155) continue;
4148 if (ktrack0->fClusterPointer[row]){
4149 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4150 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4153 if (ktrack1->fClusterPointer[row]){
4154 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4155 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4160 kink->fShapeFactor=-1;
4163 kink->fShapeFactor = shapesum/sum;
4166 // esd->AddKink(kink);
4167 kinks->AddLast(kink);
4168 kink = new AliESDkink;
4172 Int_t nkinks = kinks->GetEntriesFast();
4173 Float_t *quality = new Float_t[nkinks];
4174 Int_t * indexes = new Int_t[nkinks];
4175 for (Int_t i=0;i<nkinks;i++){
4177 AliESDkink *kink = (AliESDkink*)kinks->At(i);
4178 if (kink) quality[i] = kink->fDist2*(2.-kink->GetTPCDensityFactor());
4180 TMath::Sort(nkinks,quality,indexes,kFALSE);
4182 for (Int_t i=0;i<nkinks;i++){
4183 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
4184 Int_t index0 = kink->fIndex[0];
4185 Int_t index1 = kink->fIndex[1];
4186 kink->fMultiple[0] = usage[index0];
4187 kink->fMultiple[1] = usage[index1];
4188 if (kink->fMultiple[0]+kink->fMultiple[1]>2) continue;
4189 if (kink->fMultiple[0]+kink->fMultiple[1]>0 && quality[indexes[i]]>0.2) continue;
4191 Int_t index = esd->AddKink(kink);
4192 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4193 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4194 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4195 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4212 printf("Ncandidates=\t%d\t%d\t%d\n",ncandidates,ntracks,nall);
4218 void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
4220 // update Kink quality information for mother after back propagation
4222 if (seed->GetKinkIndex(0)>=0) return;
4223 for (Int_t ikink=0;ikink<3;ikink++){
4224 Int_t index = seed->GetKinkIndex(ikink);
4225 if (index>=0) break;
4226 index = TMath::Abs(index)-1;
4227 AliESDkink * kink = fEvent->GetKink(index);
4228 kink->fTPCdensity2[0][0]=-1;
4229 kink->fTPCdensity2[0][1]=-1;
4231 Int_t row0 = kink->fRow0 - Int_t( 2./ (0.05+kink->fAngle[2]));
4232 if (row0<15) row0=15;
4234 Int_t row1 = kink->fRow0 + Int_t( 2./ (0.05+kink->fAngle[2]));
4235 if (row1>145) row1=145;
4237 Int_t found,foundable,shared;
4238 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
4239 if (foundable>5) kink->fTPCdensity2[0][0] = Float_t(found)/Float_t(foundable);
4240 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
4241 if (foundable>5) kink->fTPCdensity2[0][1] = Float_t(found)/Float_t(foundable);
4242 if (kink->fTPCdensity2[0][1]>0.5) kink->fStatus=-100000;
4243 if (kink->fTPCdensity2[0][0]<0.5) kink->fStatus=-100000;
4244 if (kink->fTPCdensity2[0][0]-kink->fTPCdensity2[0][1]<0.2) kink->fStatus=-100000;
4246 if (kink->fDist2>1) kink->fStatus=-10000;
4251 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
4256 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
4258 if (TMath::Abs(seed->GetC())>0.01) return 0;
4261 Float_t x[160], y[160], erry[160], z[160], errz[160];
4263 Float_t xt[160], yt[160], zt[160];
4268 Int_t middle = seed->GetNumberOfClusters()/2;
4271 // find central sector, get local cooordinates
4273 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
4274 sec[i]= seed->GetClusterSector(i)%18;
4277 AliTPCclusterMI * cl = seed->fClusterPointer[i];
4278 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
4285 if (i>i2) i2 = i; //last point with cluster
4286 if (i2<i1) i1 = i; //first point with cluster
4289 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
4291 yt[i] = point->GetY();
4292 zt[i] = point->GetZ();
4294 if (point->GetX()>0){
4295 erry[i] = point->GetErrY();
4296 errz[i] = point->GetErrZ();
4301 secm = sec[i]; //central sector
4302 padm = i; //middle point with cluster
4307 // rotate position to global coordinate system connected to sector at last the point
4309 for (Int_t i=i1;i<=i2;i++){
4311 if (sec[i]<0) continue;
4312 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
4313 Double_t cs = TMath::Cos(alpha);
4314 Double_t sn = TMath::Sin(alpha);
4315 Float_t xx2= x[i]*cs+y[i]*sn;
4316 Float_t yy2= -x[i]*sn+y[i]*cs;
4320 xx2= xt[i]*cs+yt[i]*sn;
4321 yy2= -xt[i]*sn+yt[i]*cs;
4326 //get "state" vector
4327 Double_t xh[5],xm = x[padm];
4330 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
4331 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
4332 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
4335 for (Int_t i=i1;i<=i2;i++){
4337 if (sec[i]<0) continue;
4338 GetProlongation(x[i2], x[i],xh,yy,zz);
4339 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
4341 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
4342 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
4343 Error("AliTPCtrackerMI::CheckKinkPoint","problem\n");
4348 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
4349 Float_t yup[160], ydown[160], zup[160], zdown[160];
4351 AliTPCpolyTrack ptrack1,ptrack2;
4354 for (Int_t i=i1;i<=i2;i++){
4355 AliTPCclusterMI * cl = seed->fClusterPointer[i];
4357 if (cl->GetType()<0) continue;
4358 if (cl->GetType()>10) continue;
4361 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
4363 if (ptrack1.GetN()>4.){
4364 ptrack1.UpdateParameters();
4366 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
4368 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
4377 dyup[i]=0.; //not enough points
4382 for (Int_t i=i2;i>=i1;i--){
4383 AliTPCclusterMI * cl = seed->fClusterPointer[i];
4385 if (cl->GetType()<0) continue;
4386 if (cl->GetType()>10) continue;
4388 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
4390 if (ptrack2.GetN()>4){
4391 ptrack2.UpdateParameters();
4393 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
4395 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
4403 dydown[i]=0.; //not enough points
4408 // find maximal difference of the derivation
4409 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
4412 for (Int_t i=i1+10;i<i2-10;i++){
4413 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
4414 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
4416 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
4417 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
4418 if ( (ddy+ddz)> th){
4419 seed->fKinkPoint[0] = i;
4420 seed->fKinkPoint[1] = ddy;
4421 seed->fKinkPoint[2] = ddz;
4428 //write information to the debug tree
4429 TBranch * br = fTreeDebug->GetBranch("debug");
4430 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
4431 arr->ExpandCreateFast(i2-i1);
4432 br->SetAddress(&arr);
4434 AliTPCclusterMI cldummy;
4436 AliTPCTrackPoint2 pdummy;
4437 pdummy.GetTPoint().fIsShared = 10;
4439 Double_t alpha = sec[i2]*fSectors->GetAlpha();
4440 Double_t cs = TMath::Cos(alpha);
4441 Double_t sn = TMath::Sin(alpha);
4443 for (Int_t i=i1;i<i2;i++){
4444 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
4446 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
4448 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
4451 Double_t x = GetXrow(i);
4452 trpoint->GetTPoint() = *point;
4453 trpoint->GetCPoint() = *cl0;
4454 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4455 trpoint->fID = seed->GetUniqueID();
4456 trpoint->fLab = seed->GetLabel();
4458 trpoint->fGX = cs *x + sn*point->GetY();
4459 trpoint->fGY = -sn *x + cs*point->GetY() ;
4460 trpoint->fGZ = point->GetZ();
4462 trpoint->fDY = y[i];
4463 trpoint->fDZ = z[i];
4465 trpoint->fDYU = dyup[i];
4466 trpoint->fDZU = dzup[i];
4468 trpoint->fDYD = dydown[i];
4469 trpoint->fDZD = dzdown[i];
4471 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
4472 trpoint->fDDY = dydown[i]-dyup[i];
4473 trpoint->fDDZ = dzdown[i]-dzup[i];
4481 trpoint->GetCPoint()= cldummy;
4498 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
4501 // reseed - refit - track
4504 // Int_t last = fSectors->GetNRows()-1;
4506 if (fSectors == fOuterSec){
4507 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
4511 first = t->fFirstPoint;
4513 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
4514 FollowBackProlongation(*t,fSectors->GetNRows()-1);
4516 FollowProlongation(*t,first);
4526 //_____________________________________________________________________________
4527 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
4528 //-----------------------------------------------------------------
4529 // This function reades track seeds.
4530 //-----------------------------------------------------------------
4531 TDirectory *savedir=gDirectory;
4533 TFile *in=(TFile*)inp;
4534 if (!in->IsOpen()) {
4535 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
4540 TTree *seedTree=(TTree*)in->Get("Seeds");
4542 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
4543 cerr<<"can't get a tree with track seeds !\n";
4546 AliTPCtrack *seed=new AliTPCtrack;
4547 seedTree->SetBranchAddress("tracks",&seed);
4549 if (fSeeds==0) fSeeds=new TObjArray(15000);
4551 Int_t n=(Int_t)seedTree->GetEntries();
4552 for (Int_t i=0; i<n; i++) {
4553 seedTree->GetEvent(i);
4554 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
4563 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
4566 if (fSeeds) DeleteSeeds();
4569 if (!fSeeds) return 1;
4576 //_____________________________________________________________________________
4577 Int_t AliTPCtrackerMI::Clusters2Tracks() {
4578 //-----------------------------------------------------------------
4579 // This is a track finder.
4580 //-----------------------------------------------------------------
4581 TDirectory *savedir=gDirectory;
4585 fSeeds = Tracking();
4588 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
4590 //activate again some tracks
4591 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
4592 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4594 Int_t nc=t.GetNumberOfClusters();
4596 delete fSeeds->RemoveAt(i);
4599 if (pt->fRemoval==10) {
4600 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4601 pt->Desactivate(10); // make track again active
4603 pt->Desactivate(20);
4604 delete fSeeds->RemoveAt(i);
4609 RemoveUsed2(fSeeds,0.85,0.85,0);
4610 FindKinks(fSeeds,fEvent);
4611 RemoveUsed2(fSeeds,0.5,0.4,30);
4612 //RemoveDouble(fSeeds,0.2,0.6,11);
4613 // RemoveUsed(fSeeds,0.5,0.5,6);
4616 Int_t nseed=fSeeds->GetEntriesFast();
4618 for (Int_t i=0; i<nseed; i++) {
4619 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4621 Int_t nc=t.GetNumberOfClusters();
4623 delete fSeeds->RemoveAt(i);
4626 CookLabel(pt,0.1); //For comparison only
4627 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4628 if ((pt->IsActive() || (pt->fRemoval==10) )){
4630 if (fDebug>0) cerr<<found<<'\r';
4634 delete fSeeds->RemoveAt(i);
4638 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
4640 //RemoveUsed(fSeeds,0.9,0.9,6);
4642 nseed=fSeeds->GetEntriesFast();
4644 for (Int_t i=0; i<nseed; i++) {
4645 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4647 Int_t nc=t.GetNumberOfClusters();
4649 delete fSeeds->RemoveAt(i);
4653 t.CookdEdx(0.02,0.6);
4654 // CheckKinkPoint(&t,0.05);
4655 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4656 if ((pt->IsActive() || (pt->fRemoval==10) )){
4664 delete fSeeds->RemoveAt(i);
4665 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
4667 // FollowProlongation(*seed1,0);
4668 // Int_t n = seed1->GetNumberOfClusters();
4669 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
4670 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
4673 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
4677 SortTracks(fSeeds, 1);
4681 PrepareForBackProlongation(fSeeds,5.);
4682 PropagateBack(fSeeds);
4683 printf("Time for back propagation: \t");timer.Print();timer.Start();
4687 PrepareForProlongation(fSeeds,5.);
4688 PropagateForward2(fSeeds);
4690 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
4691 // RemoveUsed(fSeeds,0.7,0.7,6);
4692 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
4694 nseed=fSeeds->GetEntriesFast();
4696 for (Int_t i=0; i<nseed; i++) {
4697 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4699 Int_t nc=t.GetNumberOfClusters();
4701 delete fSeeds->RemoveAt(i);
4704 t.CookdEdx(0.02,0.6);
4705 // CookLabel(pt,0.1); //For comparison only
4706 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4707 if ((pt->IsActive() || (pt->fRemoval==10) )){
4708 cerr<<found++<<'\r';
4711 delete fSeeds->RemoveAt(i);
4716 // fNTracks = found;
4718 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
4721 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
4722 Info("Clusters2Tracks","Number of found tracks %d",found);
4724 // UnloadClusters();
4729 void AliTPCtrackerMI::Tracking(TObjArray * arr)
4732 // tracking of the seeds
4735 fSectors = fOuterSec;
4736 ParallelTracking(arr,150,63);
4737 fSectors = fOuterSec;
4738 ParallelTracking(arr,63,0);
4741 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
4746 TObjArray * arr = new TObjArray;
4748 fSectors = fOuterSec;
4751 for (Int_t sec=0;sec<fkNOS;sec++){
4752 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
4753 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
4754 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
4757 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
4769 TObjArray * AliTPCtrackerMI::Tracking()
4775 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
4777 TObjArray * seeds = new TObjArray;
4786 Float_t fnumber = 3.0;
4787 Float_t fdensity = 3.0;
4792 for (Int_t delta = 0; delta<18; delta+=6){
4796 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
4797 SumTracks(seeds,arr);
4798 SignClusters(seeds,fnumber,fdensity);
4800 for (Int_t i=2;i<6;i+=2){
4801 // seed high pt tracks
4804 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
4805 SumTracks(seeds,arr);
4806 SignClusters(seeds,fnumber,fdensity);
4811 // RemoveUsed(seeds,0.9,0.9,1);
4812 // UnsignClusters();
4813 // SignClusters(seeds,fnumber,fdensity);
4817 for (Int_t delta = 20; delta<120; delta+=10){
4819 // seed high pt tracks
4823 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
4824 SumTracks(seeds,arr);
4825 SignClusters(seeds,fnumber,fdensity);
4830 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4831 SumTracks(seeds,arr);
4832 SignClusters(seeds,fnumber,fdensity);
4843 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4847 // RemoveUsed(seeds,0.75,0.75,1);
4849 //SignClusters(seeds,fnumber,fdensity);
4858 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4859 SumTracks(seeds,arr);
4860 SignClusters(seeds,fnumber,fdensity);
4862 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4863 SumTracks(seeds,arr);
4864 SignClusters(seeds,fnumber,fdensity);
4866 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4867 SumTracks(seeds,arr);
4868 SignClusters(seeds,fnumber,fdensity);
4872 for (Int_t delta = 3; delta<30; delta+=5){
4878 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4879 SumTracks(seeds,arr);
4880 SignClusters(seeds,fnumber,fdensity);
4882 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4883 SumTracks(seeds,arr);
4884 SignClusters(seeds,fnumber,fdensity);
4896 for (Int_t delta = 30; delta<70; delta+=10){
4902 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4903 SumTracks(seeds,arr);
4904 SignClusters(seeds,fnumber,fdensity);
4906 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4907 SumTracks(seeds,arr);
4908 SignClusters(seeds,fnumber,fdensity);
4912 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4923 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
4926 //sum tracks to common container
4927 //remove suspicious tracks
4928 Int_t nseed = arr2->GetEntriesFast();
4929 for (Int_t i=0;i<nseed;i++){
4930 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4933 // NORMAL ACTIVE TRACK
4934 if (pt->IsActive()){
4935 arr1->AddLast(arr2->RemoveAt(i));
4938 //remove not usable tracks
4939 if (pt->fRemoval!=10){
4940 delete arr2->RemoveAt(i);
4943 // REMOVE VERY SHORT TRACKS
4944 if (pt->GetNumberOfClusters()<20){
4945 delete arr2->RemoveAt(i);
4948 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4949 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4950 arr1->AddLast(arr2->RemoveAt(i));
4952 delete arr2->RemoveAt(i);
4961 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4964 // try to track in parralel
4966 Int_t nseed=arr->GetEntriesFast();
4967 //prepare seeds for tracking
4968 for (Int_t i=0; i<nseed; i++) {
4969 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4971 if (!t.IsActive()) continue;
4972 // follow prolongation to the first layer
4973 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4974 FollowProlongation(t, rfirst+1);
4979 for (Int_t nr=rfirst; nr>=rlast; nr--){
4980 if (nr<fInnerSec->GetNRows())
4981 fSectors = fInnerSec;
4983 fSectors = fOuterSec;
4984 // make indexes with the cluster tracks for given
4986 // find nearest cluster
4987 for (Int_t i=0; i<nseed; i++) {
4988 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4990 if (nr==80) pt->UpdateReference();
4991 if (!pt->IsActive()) continue;
4992 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4993 if (pt->fRelativeSector>17) {
4996 UpdateClusters(t,nr);
4998 // prolonagate to the nearest cluster - if founded
4999 for (Int_t i=0; i<nseed; i++) {
5000 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
5002 if (!pt->IsActive()) continue;
5003 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
5004 if (pt->fRelativeSector>17) {
5007 FollowToNextCluster(*pt,nr);
5012 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
5016 // if we use TPC track itself we have to "update" covariance
5018 Int_t nseed= arr->GetEntriesFast();
5019 for (Int_t i=0;i<nseed;i++){
5020 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5024 //rotate to current local system at first accepted point
5025 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5026 Int_t sec = (index&0xff000000)>>24;
5028 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5029 if (angle1>TMath::Pi())
5030 angle1-=2.*TMath::Pi();
5031 Float_t angle2 = pt->GetAlpha();
5033 if (TMath::Abs(angle1-angle2)>0.001){
5034 pt->Rotate(angle1-angle2);
5035 //angle2 = pt->GetAlpha();
5036 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5037 //if (pt->GetAlpha()<0)
5038 // pt->fRelativeSector+=18;
5039 //sec = pt->fRelativeSector;
5048 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
5052 // if we use TPC track itself we have to "update" covariance
5054 Int_t nseed= arr->GetEntriesFast();
5055 for (Int_t i=0;i<nseed;i++){
5056 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5059 pt->fFirstPoint = pt->fLastPoint;
5067 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5070 // make back propagation
5072 Int_t nseed= arr->GetEntriesFast();
5073 for (Int_t i=0;i<nseed;i++){
5074 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5075 if (pt&& pt->GetKinkIndex(0)<=0) {
5076 //AliTPCseed *pt2 = new AliTPCseed(*pt);
5077 fSectors = fInnerSec;
5078 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5079 //fSectors = fOuterSec;
5080 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5081 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
5082 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
5083 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5086 if (pt&& pt->GetKinkIndex(0)>0) {
5087 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
5088 pt->fFirstPoint = kink->fRow0;
5089 fSectors = fInnerSec;
5090 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5098 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5101 // make forward propagation
5103 Int_t nseed= arr->GetEntriesFast();
5105 for (Int_t i=0;i<nseed;i++){
5106 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5108 FollowProlongation(*pt,0);
5115 Int_t AliTPCtrackerMI::PropagateForward()
5118 // propagate track forward
5120 Int_t nseed = fSeeds->GetEntriesFast();
5121 for (Int_t i=0;i<nseed;i++){
5122 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5124 AliTPCseed &t = *pt;
5125 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5126 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5127 if (alpha < 0. ) alpha += 2.*TMath::Pi();
5128 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
5132 fSectors = fOuterSec;
5133 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
5134 fSectors = fInnerSec;
5135 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
5145 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
5148 // make back propagation, in between row0 and row1
5152 fSectors = fInnerSec;
5155 if (row1<fSectors->GetNRows())
5158 r1 = fSectors->GetNRows()-1;
5160 if (row0<fSectors->GetNRows()&& r1>0 )
5161 FollowBackProlongation(*pt,r1);
5162 if (row1<=fSectors->GetNRows())
5165 r1 = row1 - fSectors->GetNRows();
5166 if (r1<=0) return 0;
5167 if (r1>=fOuterSec->GetNRows()) return 0;
5168 fSectors = fOuterSec;
5169 return FollowBackProlongation(*pt,r1);
5177 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
5181 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
5182 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
5183 Float_t padlength = GetPadPitchLength(row);
5185 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
5186 Float_t angulary = seed->GetSnp();
5187 angulary = angulary*angulary/(1-angulary*angulary);
5188 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
5190 Float_t sresz = fParam->GetZSigma();
5191 Float_t angularz = seed->GetTgl();
5192 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
5194 Float_t wy = GetSigmaY(seed);
5195 Float_t wz = GetSigmaZ(seed);
5198 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
5199 printf("problem\n");
5205 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
5209 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
5210 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
5211 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
5212 Float_t angular = seed->GetSnp();
5213 angular = angular*angular/(1-angular*angular);
5214 // angular*=angular;
5215 //angular = TMath::Sqrt(angular/(1-angular));
5216 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
5219 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
5223 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
5224 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
5225 Float_t sres = fParam->GetZSigma();
5226 Float_t angular = seed->GetTgl();
5227 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
5232 //__________________________________________________________________________
5233 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
5234 //--------------------------------------------------------------------
5235 //This function "cooks" a track label. If label<0, this track is fake.
5236 //--------------------------------------------------------------------
5237 Int_t noc=t->GetNumberOfClusters();
5239 //printf("\nnot founded prolongation\n\n\n");
5245 AliTPCclusterMI *clusters[160];
5247 for (Int_t i=0;i<160;i++) {
5254 for (i=0; i<160 && current<noc; i++) {
5256 Int_t index=t->GetClusterIndex2(i);
5257 if (index<=0) continue;
5258 if (index&0x8000) continue;
5260 //clusters[current]=GetClusterMI(index);
5261 if (t->fClusterPointer[i]){
5262 clusters[current]=t->fClusterPointer[i];
5268 Int_t lab=123456789;
5269 for (i=0; i<noc; i++) {
5270 AliTPCclusterMI *c=clusters[i];
5272 lab=TMath::Abs(c->GetLabel(0));
5274 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
5280 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
5282 for (i=0; i<noc; i++) {
5283 AliTPCclusterMI *c=clusters[i];
5285 if (TMath::Abs(c->GetLabel(1)) == lab ||
5286 TMath::Abs(c->GetLabel(2)) == lab ) max++;
5289 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
5292 Int_t tail=Int_t(0.10*noc);
5295 for (i=1; i<=160&&ind<tail; i++) {
5296 // AliTPCclusterMI *c=clusters[noc-i];
5297 AliTPCclusterMI *c=clusters[i];
5299 if (lab == TMath::Abs(c->GetLabel(0)) ||
5300 lab == TMath::Abs(c->GetLabel(1)) ||
5301 lab == TMath::Abs(c->GetLabel(2))) max++;
5304 if (max < Int_t(0.5*tail)) lab=-lab;
5311 //delete[] clusters;
5315 //__________________________________________________________________________
5316 Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
5317 //--------------------------------------------------------------------
5318 //This function "cooks" a track label. If label<0, this track is fake.
5319 //--------------------------------------------------------------------
5320 Int_t noc=t->GetNumberOfClusters();
5322 //printf("\nnot founded prolongation\n\n\n");
5328 AliTPCclusterMI *clusters[160];
5330 for (Int_t i=0;i<160;i++) {
5337 for (i=0; i<160 && current<noc; i++) {
5338 if (i<first) continue;
5339 if (i>last) continue;
5340 Int_t index=t->GetClusterIndex2(i);
5341 if (index<=0) continue;
5342 if (index&0x8000) continue;
5344 //clusters[current]=GetClusterMI(index);
5345 if (t->fClusterPointer[i]){
5346 clusters[current]=t->fClusterPointer[i];
5351 if (noc<5) return -1;
5352 Int_t lab=123456789;
5353 for (i=0; i<noc; i++) {
5354 AliTPCclusterMI *c=clusters[i];
5356 lab=TMath::Abs(c->GetLabel(0));
5358 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
5364 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
5366 for (i=0; i<noc; i++) {
5367 AliTPCclusterMI *c=clusters[i];
5369 if (TMath::Abs(c->GetLabel(1)) == lab ||
5370 TMath::Abs(c->GetLabel(2)) == lab ) max++;
5373 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
5376 Int_t tail=Int_t(0.10*noc);
5379 for (i=1; i<=160&&ind<tail; i++) {
5380 // AliTPCclusterMI *c=clusters[noc-i];
5381 AliTPCclusterMI *c=clusters[i];
5383 if (lab == TMath::Abs(c->GetLabel(0)) ||
5384 lab == TMath::Abs(c->GetLabel(1)) ||
5385 lab == TMath::Abs(c->GetLabel(2))) max++;
5388 if (max < Int_t(0.5*tail)) lab=-lab;
5391 // t->SetLabel(lab);
5395 //delete[] clusters;
5399 Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
5401 //return pad row number for this x
5404 r=fRow[fN-1].GetX();
5405 if (x > r) return fN;
5407 if (x < r) return -1;
5408 return Int_t((x-r)/fPadPitchLength + 0.5);}
5410 r=fRow[fN-1].GetX();
5411 if (x > r) return fN;
5413 if (x < r) return -1;
5414 Double_t r1=fRow[64].GetX();
5416 return Int_t((x-r)/f1PadPitchLength + 0.5);}
5418 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
5422 //_________________________________________________________________________
5423 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
5424 //-----------------------------------------------------------------------
5425 // Setup inner sector
5426 //-----------------------------------------------------------------------
5428 fAlpha=par->GetInnerAngle();
5429 fAlphaShift=par->GetInnerAngleShift();
5430 fPadPitchWidth=par->GetInnerPadPitchWidth();
5431 fPadPitchLength=par->GetInnerPadPitchLength();
5432 fN=par->GetNRowLow();
5433 fRow=new AliTPCRow[fN];
5434 for (Int_t i=0; i<fN; i++) {
5435 fRow[i].SetX(par->GetPadRowRadiiLow(i));
5436 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
5439 fAlpha=par->GetOuterAngle();
5440 fAlphaShift=par->GetOuterAngleShift();
5441 fPadPitchWidth = par->GetOuterPadPitchWidth();
5442 fPadPitchLength = par->GetOuter1PadPitchLength();
5443 f1PadPitchLength = par->GetOuter1PadPitchLength();
5444 f2PadPitchLength = par->GetOuter2PadPitchLength();
5446 fN=par->GetNRowUp();
5447 fRow=new AliTPCRow[fN];
5448 for (Int_t i=0; i<fN; i++) {
5449 fRow[i].SetX(par->GetPadRowRadiiUp(i));
5450 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
5455 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
5457 // default constructor
5465 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
5472 //_________________________________________________________________________
5474 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
5475 //-----------------------------------------------------------------------
5476 // Insert a cluster into this pad row in accordence with its y-coordinate
5477 //-----------------------------------------------------------------------
5478 if (fN==kMaxClusterPerRow) {
5479 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
5481 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
5482 Int_t i=Find(c->GetZ());
5483 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
5484 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
5485 fIndex[i]=index; fClusters[i]=c; fN++;
5488 void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
5494 //delete[] fClusterArray;
5495 if (fClusters1) delete []fClusters1;
5496 if (fClusters2) delete []fClusters2;
5503 //___________________________________________________________________
5504 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
5505 //-----------------------------------------------------------------------
5506 // Return the index of the nearest cluster
5507 //-----------------------------------------------------------------------
5508 if (fN==0) return 0;
5509 if (z <= fClusters[0]->GetZ()) return 0;
5510 if (z > fClusters[fN-1]->GetZ()) return fN;
5511 Int_t b=0, e=fN-1, m=(b+e)/2;
5512 for (; b<e; m=(b+e)/2) {
5513 if (z > fClusters[m]->GetZ()) b=m+1;
5521 //___________________________________________________________________
5522 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
5523 //-----------------------------------------------------------------------
5524 // Return the index of the nearest cluster in z y
5525 //-----------------------------------------------------------------------
5526 Float_t maxdistance = roady*roady + roadz*roadz;
5528 AliTPCclusterMI *cl =0;
5529 for (Int_t i=Find(z-roadz); i<fN; i++) {
5530 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
5531 if (c->GetZ() > z+roadz) break;
5532 if ( (c->GetY()-y) > roady ) continue;
5533 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
5534 if (maxdistance>distance) {
5535 maxdistance = distance;
5542 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
5544 //-----------------------------------------------------------------------
5545 // Return the index of the nearest cluster in z y
5546 //-----------------------------------------------------------------------
5547 Float_t maxdistance = roady*roady + roadz*roadz;
5548 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
5549 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
5551 AliTPCclusterMI *cl =0;
5552 //FindNearest3(y,z,roady,roadz,index);
5553 // for (Int_t i=Find(z-roadz); i<fN; i++) {
5554 for (Int_t i=iz1; i<iz2; i++) {
5555 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
5556 if (c->GetZ() > z+roadz) break;
5557 if ( c->GetY()-y > roady ) continue;
5558 if ( y-c->GetY() > roady ) continue;
5559 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
5560 if (maxdistance>distance) {
5561 maxdistance = distance;
5564 //roady = TMath::Sqrt(maxdistance);
5572 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
5574 //-----------------------------------------------------------------------
5575 // Return the index of the nearest cluster in z y
5576 //-----------------------------------------------------------------------
5577 Float_t maxdistance = roady*roady + roadz*roadz;
5578 // Int_t iz = Int_t(z+255.);
5579 AliTPCclusterMI *cl =0;
5580 for (Int_t i=Find(z-roadz); i<fN; i++) {
5581 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
5582 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
5583 if (c->GetZ() > z+roadz) break;
5584 if ( c->GetY()-y > roady ) continue;
5585 if ( y-c->GetY() > roady ) continue;
5586 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
5587 if (maxdistance>distance) {
5588 maxdistance = distance;
5591 //roady = TMath::Sqrt(maxdistance);
5600 AliTPCseed::AliTPCseed():AliTPCtrack(){
5604 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
5605 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
5606 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
5622 AliTPCseed::AliTPCseed(const AliTPCseed &s):AliTPCtrack(s){
5623 //---------------------
5624 // dummy copy constructor
5625 //-------------------------
5627 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
5636 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=t.GetKinkIndex(i);
5638 for (Int_t i=0;i<160;i++) {
5639 fClusterPointer[i] = 0;
5640 Int_t index = t.GetClusterIndex(i);
5642 SetClusterIndex2(i,index);
5645 SetClusterIndex2(i,-3);
5658 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
5662 for (Int_t i=0;i<160;i++) {
5663 fClusterPointer[i] = 0;
5664 Int_t index = t.GetClusterIndex(i);
5665 SetClusterIndex2(i,index);
5667 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
5687 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
5688 Double_t xr, Double_t alpha):
5689 AliTPCtrack(index, xx, cc, xr, alpha) {
5694 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
5695 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
5696 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
5705 // fHelixIn = new TClonesArray("AliHelix",0);
5706 //fHelixOut = new TClonesArray("AliHelix",0);
5716 AliTPCseed::~AliTPCseed(){
5719 if (fPoints) delete fPoints;
5721 if (fEPoints) delete fEPoints;
5726 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
5730 return &fTrackPoints[i];
5733 void AliTPCseed::RebuildSeed()
5736 // rebuild seed to be ready for storing
5737 AliTPCclusterMI cldummy;
5739 AliTPCTrackPoint pdummy;
5740 pdummy.GetTPoint().fIsShared = 10;
5741 for (Int_t i=0;i<160;i++){
5742 AliTPCclusterMI * cl0 = fClusterPointer[i];
5743 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
5745 trpoint->GetTPoint() = *(GetTrackPoint(i));
5746 trpoint->GetCPoint() = *cl0;
5747 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
5751 trpoint->GetCPoint()= cldummy;
5759 Double_t AliTPCseed::GetDensityFirst(Int_t n)
5763 // return cluster for n rows bellow first point
5764 Int_t nfoundable = 1;
5766 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
5767 Int_t index = GetClusterIndex2(i);
5768 if (index!=-1) nfoundable++;
5769 if (index>0) nfound++;
5771 if (nfoundable<n) return 0;
5772 return Double_t(nfound)/Double_t(nfoundable);
5777 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
5779 // get cluster stat. on given region
5784 for (Int_t i=first;i<last; i++){
5785 Int_t index = GetClusterIndex2(i);
5786 if (index!=-1) foundable++;
5787 if (fClusterPointer[i]) {
5793 if (fClusterPointer[i]->IsUsed(10)) {
5797 if (!plus2) continue; //take also neighborhoud
5799 if ( (i>0) && fClusterPointer[i-1]){
5800 if (fClusterPointer[i-1]->IsUsed(10)) {
5805 if ( fClusterPointer[i+1]){
5806 if (fClusterPointer[i+1]->IsUsed(10)) {
5813 //if (shared>found){
5814 //Error("AliTPCseed::GetClusterStatistic","problem\n");
5818 //_____________________________________________________________________________
5819 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
5820 //-----------------------------------------------------------------
5821 // This funtion calculates dE/dX within the "low" and "up" cuts.
5822 //-----------------------------------------------------------------
5825 Float_t angular[200];
5826 Float_t weight[200];
5829 // TClonesArray & arr = *fPoints;
5830 Float_t meanlog = 100.;
5832 Float_t mean[4] = {0,0,0,0};
5833 Float_t sigma[4] = {1000,1000,1000,1000};
5834 Int_t nc[4] = {0,0,0,0};
5835 Float_t norm[4] = {1000,1000,1000,1000};
5840 for (Int_t of =0; of<4; of++){
5841 for (Int_t i=of+i1;i<i2;i+=4)
5843 Int_t index = fIndex[i];
5844 if (index<0||index&0x8000) continue;
5846 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
5847 AliTPCTrackerPoint * point = GetTrackPoint(i);
5848 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
5849 //AliTPCTrackerPoint * pointp = 0;
5850 //if (i<159) pointp = GetTrackPoint(i+1);
5852 if (point==0) continue;
5853 AliTPCclusterMI * cl = fClusterPointer[i];
5854 if (cl==0) continue;
5855 if (onlyused && (!cl->IsUsed(10))) continue;
5856 if (cl->IsUsed(11)) {
5860 Int_t type = cl->GetType();
5861 //if (point->fIsShared){
5866 // if (pointm->fIsShared) continue;
5868 // if (pointp->fIsShared) continue;
5870 if (type<0) continue;
5871 //if (type>10) continue;
5872 //if (point->GetErrY()==0) continue;
5873 //if (point->GetErrZ()==0) continue;
5875 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
5876 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
5877 //if ((ddy*ddy+ddz*ddz)>10) continue;
5880 // if (point->GetCPoint().GetMax()<5) continue;
5881 if (cl->GetMax()<5) continue;
5882 Float_t angley = point->GetAngleY();
5883 Float_t anglez = point->GetAngleZ();
5885 Float_t rsigmay2 = point->GetSigmaY();
5886 Float_t rsigmaz2 = point->GetSigmaZ();
5890 rsigmay += pointm->GetTPoint().GetSigmaY();
5891 rsigmaz += pointm->GetTPoint().GetSigmaZ();
5895 rsigmay += pointp->GetTPoint().GetSigmaY();
5896 rsigmaz += pointp->GetTPoint().GetSigmaZ();
5903 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
5905 Float_t ampc = 0; // normalization to the number of electrons
5907 // ampc = 1.*point->GetCPoint().GetMax();
5908 ampc = 1.*cl->GetMax();
5909 //ampc = 1.*point->GetCPoint().GetQ();
5910 // AliTPCClusterPoint & p = point->GetCPoint();
5911 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
5912 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5914 // TMath::Abs( Int_t(iz) - iz + 0.5);
5915 //ampc *= 1.15*(1-0.3*dy);
5916 //ampc *= 1.15*(1-0.3*dz);
5917 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
5921 //ampc = 1.0*point->GetCPoint().GetMax();
5922 ampc = 1.0*cl->GetMax();
5923 //ampc = 1.0*point->GetCPoint().GetQ();
5924 //AliTPCClusterPoint & p = point->GetCPoint();
5925 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
5926 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5928 // TMath::Abs( Int_t(iz) - iz + 0.5);
5930 //ampc *= 1.15*(1-0.3*dy);
5931 //ampc *= 1.15*(1-0.3*dz);
5932 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
5936 ampc *= 2.0; // put mean value to channel 50
5937 //ampc *= 0.58; // put mean value to channel 50
5939 // if (type>0) w = 1./(type/2.-0.5);
5940 // Float_t z = TMath::Abs(cl->GetZ());
5943 //ampc /= (1+0.0008*z);
5947 //ampc /= (1+0.0008*z);
5949 //ampc /= (1+0.0008*z);
5952 if (type<0) { //amp at the border - lower weight
5957 if (rsigma>1.5) ampc/=1.3; // if big backround
5959 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5964 TMath::Sort(nc[of],amp,index,kFALSE);
5968 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
5970 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5971 Float_t ampl = amp[index[i]]/angular[index[i]];
5972 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5974 sumw += weight[index[i]];
5975 sumamp += weight[index[i]]*ampl;
5976 sumamp2 += weight[index[i]]*ampl*ampl;
5977 norm[of] += angular[index[i]]*weight[index[i]];
5984 mean[of] = sumamp/sumw;
5985 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5987 sigma[of] = TMath::Sqrt(sigma[of]);
5991 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5992 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5993 //mean *=(1-0.1*(norm-1.));
6000 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
6001 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
6004 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
6005 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
6009 for (Int_t i =0;i<4;i++){
6010 if (nc[i]>2&&nc[i]<1000){
6011 dedx += mean[i] *nc[i];
6012 fSdEdx += sigma[i]*(nc[i]-2);
6013 fMAngular += norm[i] *nc[i];
6018 fSDEDX[i] = sigma[i];
6031 // Float_t dedx1 =dedx;
6034 for (Int_t i =0;i<4;i++){
6035 if (nc[i]>2&&nc[i]<1000){
6036 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
6037 dedx += mean[i] *nc[i];
6052 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
6055 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
6056 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
6057 SetMass(0.93827); return;
6061 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
6062 SetMass(0.93827); return;
6065 SetMass(0.13957); return;
6075 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
6076 //-----------------------------------------------------------------
6077 // This funtion calculates dE/dX within the "low" and "up" cuts.
6078 //-----------------------------------------------------------------
6081 Float_t angular[200];
6082 Float_t weight[200];
6084 Bool_t inlimit[200];
6085 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
6086 for (Int_t i=0;i<200;i++) amp[i]=10000;
6087 for (Int_t i=0;i<200;i++) angular[i]= 1;;
6091 Float_t meanlog = 100.;
6092 Int_t indexde[4]={0,64,128,160};
6099 Float_t mean[4] = {0,0,0,0};
6100 Float_t sigma[4] = {1000,1000,1000,1000};
6101 Int_t nc[4] = {0,0,0,0};
6102 Float_t norm[4] = {1000,1000,1000,1000};
6107 // for (Int_t of =0; of<3; of++){
6108 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
6109 for (Int_t i =0; i<160;i++)
6111 AliTPCTrackPoint * point = GetTrackPoint(i);
6112 if (point==0) continue;
6113 if (point->fIsShared){
6117 Int_t type = point->GetCPoint().GetType();
6118 if (type<0) continue;
6119 if (point->GetCPoint().GetMax()<5) continue;
6120 Float_t angley = point->GetTPoint().GetAngleY();
6121 Float_t anglez = point->GetTPoint().GetAngleZ();
6122 Float_t rsigmay = point->GetCPoint().GetSigmaY();
6123 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
6124 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
6126 Float_t ampc = 0; // normalization to the number of electrons
6128 ampc = point->GetCPoint().GetMax();
6131 ampc = point->GetCPoint().GetMax();
6133 ampc *= 2.0; // put mean value to channel 50
6134 // ampc *= 0.565; // put mean value to channel 50
6137 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
6144 if (type<0) { //amp at the border - lower weight
6147 if (rsigma>1.5) ampc/=1.3; // if big backround
6148 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
6149 amp[i] = ampc/angular[i];
6154 TMath::Sort(159,amp,index,kFALSE);
6155 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
6156 inlimit[index[i]] = kTRUE; // take all clusters
6159 // meanlog = amp[index[Int_t(anc*0.3)]];
6161 for (Int_t of =0; of<3; of++){
6165 for (Int_t i=indexde[of];i<indexde[of+1];i++)
6167 if (inlimit[i]==kFALSE) continue;
6168 Float_t ampl = amp[i];
6170 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
6173 sumamp += weight[i]*ampl;
6174 sumamp2 += weight[i]*ampl*ampl;
6175 norm[of] += angular[i]*weight[i];
6183 mean[of] = sumamp/sumw;
6184 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
6186 sigma[of] = TMath::Sqrt(sigma[of]);
6189 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
6199 Float_t www[3] = {12.,14.,17.};
6200 //Float_t www[3] = {1.,1.,1.};
6202 for (Int_t i =0;i<3;i++){
6203 if (nc[i]>2&&nc[i]<1000){
6204 dedx += mean[i] *nc[i]*www[i]/sigma[i];
6205 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
6206 fMAngular += norm[i] *nc[i];
6207 norm2 += nc[i]*www[i]/sigma[i];
6208 norm3 += (nc[i]-2)*www[i]/sigma[i];
6211 fSDEDX[i] = sigma[i];
6224 // Float_t dedx1 =dedx;
6228 for (Int_t i =0;i<3;i++){
6229 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
6230 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
6231 dedx += mean[i] *(nc[i])/(sigma[i]);
6232 norm4 += (nc[i])/(sigma[i]);
6236 if (norm4>0) dedx /= norm4;