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 **************************************************************************/
18 Revision 1.19 2003/10/21 11:11:52 kowal2
19 Removed compiler warning (Bool_t accept changed to Int_t accept)
21 Revision 1.18 2003/10/17 15:42:14 kowal2
22 Back to the previous version. The warning was erronously generated
25 Revision 1.17 2003/10/17 12:28:02 kowal2
26 Removed "always true" comparison
28 Revision 1.16 2003/10/17 12:01:16 kowal2
29 Removed compiler warning.
31 Revision 1.15 2003/09/29 11:56:58 kowal2
34 Revision 1.14 2003/09/29 11:39:43 kowal2
37 Revision 1.13 2003/09/29 11:28:19 kowal2
40 Revision 1.9.4.3 2003/06/23 14:47:10 hristov
43 Revision 1.9.4.2 2003/06/23 10:06:13 hristov
44 Updated information about the overlapping clusters (M.Ivanov)
46 Revision 1.9.4.1 2003/06/19 06:59:58 hristov
47 Updated version of parallel tracking (M.Ivanov)
49 Revision 1.9 2003/03/19 17:14:11 hristov
50 Load/UnloadClusters added to the base class and the derived classes changed correspondingly. Possibility to give 2 input files for ITS and TPC tracks in PropagateBack. TRD tracker uses fEventN from the base class (T.Kuhr)
52 Revision 1.8 2003/03/05 11:16:15 kowal2
64 AliTPC parallel tracker -
66 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
67 run AliTPCFindTracksMI.C macro - to find tracks
68 tracks are written to AliTPCtracks.root file
69 for comparison also seeds are written to the same file - to special branch
72 //-------------------------------------------------------
73 // Implementation of the TPC tracker
75 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
77 //-------------------------------------------------------
78 #include <TObjArray.h>
81 #include <TClonesArray.h>
83 #include "Riostream.h"
85 #include "AliTPCclusterMI.h"
86 #include "AliTPCParam.h"
87 #include "AliTPCClustersRow.h"
88 #include "AliComplexCluster.h"
89 #include "AliTPCpolyTrack.h"
90 #include "TStopwatch.h"
94 #include "AliRunLoader.h"
96 #include "AliTPCreco.h"
97 #include "AliTPCtrackerMI.h"
102 ClassImp(AliTPCtrackerMI)
105 class AliTPCFastMath {
108 static Double_t FastAsin(Double_t x);
110 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
113 Double_t AliTPCFastMath::fgFastAsin[20000];
114 AliTPCFastMath gAliTPCFastMath;
116 AliTPCFastMath::AliTPCFastMath(){
118 // initialized lookup table;
119 for (Int_t i=0;i<10000;i++){
120 fgFastAsin[2*i] = TMath::ASin(i/10000.);
121 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
125 Double_t AliTPCFastMath::FastAsin(Double_t x){
127 // return asin using lookup table
129 Int_t index = int(x*10000);
130 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
133 Int_t index = int(x*10000);
134 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
140 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
142 //update track information using current cluster - track->fCurrentCluster
145 AliTPCclusterMI* c =track->fCurrentCluster;
146 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
148 UInt_t i = track->fCurrentClusterIndex1;
150 Int_t sec=(i&0xff000000)>>24;
151 //Int_t row = (i&0x00ff0000)>>16;
152 track->fRow=(i&0x00ff0000)>>16;
153 track->fSector = sec;
154 // Int_t index = i&0xFFFF;
155 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
156 track->SetClusterIndex2(track->fRow, i);
158 //track->fFirstPoint = row;
159 //if ( track->fLastPoint<row) track->fLastPoint =row;
160 // if (track->fRow<0 || track->fRow>160) {
161 // printf("problem\n");
163 if (track->fFirstPoint>track->fRow)
164 track->fFirstPoint = track->fRow;
165 if (track->fLastPoint<track->fRow)
166 track->fLastPoint = track->fRow;
169 track->fClusterPointer[track->fRow] = c;
172 Float_t angle2 = track->GetSnp()*track->GetSnp();
173 angle2 = TMath::Sqrt(angle2/(1-angle2));
175 //SET NEW Track Point
179 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
181 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
182 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
183 point.SetErrY(sqrt(track->fErrorY2));
184 point.SetErrZ(sqrt(track->fErrorZ2));
186 point.SetX(track->GetX());
187 point.SetY(track->GetY());
188 point.SetZ(track->GetZ());
189 point.SetAngleY(angle2);
190 point.SetAngleZ(track->GetTgl());
191 if (point.fIsShared){
192 track->fErrorY2 *= 4;
193 track->fErrorZ2 *= 4;
197 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
199 track->fErrorY2 *= 1.3;
200 track->fErrorY2 += 0.01;
201 track->fErrorZ2 *= 1.3;
202 track->fErrorZ2 += 0.005;
204 if (accept>0) return 0;
205 if (track->GetNumberOfClusters()%20==0){
206 // if (track->fHelixIn){
207 // TClonesArray & larr = *(track->fHelixIn);
208 // Int_t ihelix = larr.GetEntriesFast();
209 // new(larr[ihelix]) AliHelix(*track) ;
212 track->fNoCluster =0;
213 return track->Update(c,chi2,i);
218 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
219 Float_t cory, Float_t corz)
222 // decide according desired precision to accept given
223 // cluster for tracking
224 Double_t sy2=ErrY2(seed,cluster)*cory;
225 Double_t sz2=ErrZ2(seed,cluster)*corz;
226 //sy2=ErrY2(seed,cluster)*cory;
227 //sz2=ErrZ2(seed,cluster)*cory;
229 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
230 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
232 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
233 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
234 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
235 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
237 Double_t rdistance2 = rdistancey2+rdistancez2;
240 if (rdistance2>16) return 3;
243 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
244 return 2; //suspisiouce - will be changed
246 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
247 // strict cut on overlaped cluster
248 return 2; //suspisiouce - will be changed
250 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
251 && cluster->GetType()<0){
261 //_____________________________________________________________________________
262 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
263 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
265 //---------------------------------------------------------------------
266 // The main TPC tracker constructor
267 //---------------------------------------------------------------------
268 fInnerSec=new AliTPCSector[fkNIS];
269 fOuterSec=new AliTPCSector[fkNOS];
272 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
273 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
280 Int_t nrowlow = par->GetNRowLow();
281 Int_t nrowup = par->GetNRowUp();
284 for (Int_t i=0;i<nrowlow;i++){
285 fXRow[i] = par->GetPadRowRadiiLow(i);
286 fPadLength[i]= par->GetPadPitchLength(0,i);
287 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
291 for (Int_t i=0;i<nrowup;i++){
292 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
293 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
294 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
307 //_____________________________________________________________________________
308 AliTPCtrackerMI::~AliTPCtrackerMI() {
309 //------------------------------------------------------------------
310 // TPC tracker destructor
311 //------------------------------------------------------------------
320 void AliTPCtrackerMI::SetIO()
324 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
325 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
326 AliTPCtrack *iotrack= new AliTPCtrack;
327 // iotrack->fHelixIn = new TClonesArray("AliHelix");
328 //iotrack->fHelixOut = new TClonesArray("AliHelix");
329 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
333 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
349 AliTPCtrack *iotrack= new AliTPCtrack;
350 // iotrack->fHelixIn = new TClonesArray("AliHelix");
351 //iotrack->fHelixOut = new TClonesArray("AliHelix");
352 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
355 if (output && (fDebug&2)){
356 //write the full seed information if specified in debug mode
358 fSeedTree = new TTree("Seeds","Seeds");
359 AliTPCseed * vseed = new AliTPCseed;
361 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
362 arrtr->ExpandCreateFast(160);
363 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
365 vseed->fPoints = arrtr;
366 vseed->fEPoints = arre;
367 // vseed->fClusterPoints = arrcl;
368 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
371 fTreeDebug = new TTree("trackDebug","trackDebug");
372 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
373 fTreeDebug->Branch("debug",&arrd,32000,99);
381 void AliTPCtrackerMI::WriteTracks()
384 // write tracks to the given output tree -
385 // output specified with SetIO routine
388 // write tracks to the event
389 // store index of the track
390 Int_t nseed=fSeeds->GetEntriesFast();
391 for (Int_t i=0; i<nseed; i++) {
392 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
395 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
396 //iotrack.SetTPCindex(i);
397 fEvent->AddTrack(&iotrack);
403 AliTPCtrack *iotrack= 0;
404 Int_t nseed=fSeeds->GetEntriesFast();
405 for (Int_t i=0; i<nseed; i++) {
406 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
410 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
411 TBranch * br = fOutput->GetBranch("tracks");
412 br->SetAddress(&iotrack);
414 for (Int_t i=0; i<nseed; i++) {
415 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
419 // br->SetAddress(&iotrack);
427 //write the full seed information if specified in debug mode
429 AliTPCseed * vseed = new AliTPCseed;
431 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
432 arrtr->ExpandCreateFast(160);
433 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
434 //arrcl->ExpandCreateFast(160);
435 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
437 vseed->fPoints = arrtr;
438 vseed->fEPoints = arre;
439 // vseed->fClusterPoints = arrcl;
440 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
441 TBranch * brseed = fSeedTree->GetBranch("seeds");
443 Int_t nseed=fSeeds->GetEntriesFast();
445 for (Int_t i=0; i<nseed; i++) {
446 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
449 // pt->fClusterPoints = arrcl;
453 brseed->SetAddress(&vseed);
457 // pt->fClusterPoints = 0;
460 if (fTreeDebug) fTreeDebug->Write();
468 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
471 //seed->SetErrorY2(0.1);
473 //calculate look-up table at the beginning
474 static Bool_t ginit = kFALSE;
475 static Float_t gnoise1,gnoise2,gnoise3;
476 static Float_t ggg1[10000];
477 static Float_t ggg2[10000];
478 static Float_t ggg3[10000];
479 static Float_t glandau1[10000];
480 static Float_t glandau2[10000];
481 static Float_t glandau3[10000];
483 static Float_t gcor01[500];
484 static Float_t gcor02[500];
485 static Float_t gcorp[500];
490 for (Int_t i=1;i<500;i++){
491 Float_t rsigma = float(i)/100.;
492 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
493 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
494 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
498 for (Int_t i=3;i<10000;i++){
502 Float_t amp = float(i);
503 Float_t padlength =0.75;
504 gnoise1 = 0.0004/padlength;
505 Float_t nel = 0.268*amp;
506 Float_t nprim = 0.155*amp;
507 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
508 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
509 if (glandau1[i]>1) glandau1[i]=1;
510 glandau1[i]*=padlength*padlength/12.;
514 gnoise2 = 0.0004/padlength;
517 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
518 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
519 if (glandau2[i]>1) glandau2[i]=1;
520 glandau2[i]*=padlength*padlength/12.;
525 gnoise3 = 0.0004/padlength;
528 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
529 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
530 if (glandau3[i]>1) glandau3[i]=1;
531 glandau3[i]*=padlength*padlength/12.;
539 Int_t amp = int(TMath::Abs(cl->GetQ()));
541 seed->SetErrorY2(1.);
545 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
546 Int_t ctype = cl->GetType();
547 Float_t padlength= GetPadPitchLength(seed->fRow);
548 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
549 angle2 = angle2/(1-angle2);
552 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
555 if (fSectors==fInnerSec){
557 res = ggg1[amp]*z+glandau1[amp]*angle2;
558 if (ctype==0) res *= gcor01[rsigmay];
561 res*= gcorp[rsigmay];
567 res = ggg2[amp]*z+glandau2[amp]*angle2;
568 if (ctype==0) res *= gcor02[rsigmay];
571 res*= gcorp[rsigmay];
576 res = ggg3[amp]*z+glandau3[amp]*angle2;
577 if (ctype==0) res *= gcor02[rsigmay];
580 res*= gcorp[rsigmay];
587 res*=2.4; // overestimate error 2 times
594 seed->SetErrorY2(res);
602 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
605 //seed->SetErrorY2(0.1);
607 //calculate look-up table at the beginning
608 static Bool_t ginit = kFALSE;
609 static Float_t gnoise1,gnoise2,gnoise3;
610 static Float_t ggg1[10000];
611 static Float_t ggg2[10000];
612 static Float_t ggg3[10000];
613 static Float_t glandau1[10000];
614 static Float_t glandau2[10000];
615 static Float_t glandau3[10000];
617 static Float_t gcor01[1000];
618 static Float_t gcor02[1000];
619 static Float_t gcorp[1000];
624 for (Int_t i=1;i<1000;i++){
625 Float_t rsigma = float(i)/100.;
626 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
627 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
628 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
632 for (Int_t i=3;i<10000;i++){
636 Float_t amp = float(i);
637 Float_t padlength =0.75;
638 gnoise1 = 0.0004/padlength;
639 Float_t nel = 0.268*amp;
640 Float_t nprim = 0.155*amp;
641 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
642 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
643 if (glandau1[i]>1) glandau1[i]=1;
644 glandau1[i]*=padlength*padlength/12.;
648 gnoise2 = 0.0004/padlength;
651 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
652 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
653 if (glandau2[i]>1) glandau2[i]=1;
654 glandau2[i]*=padlength*padlength/12.;
659 gnoise3 = 0.0004/padlength;
662 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
663 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
664 if (glandau3[i]>1) glandau3[i]=1;
665 glandau3[i]*=padlength*padlength/12.;
673 Int_t amp = int(TMath::Abs(cl->GetQ()));
675 seed->SetErrorY2(1.);
679 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
680 Int_t ctype = cl->GetType();
681 Float_t padlength= GetPadPitchLength(seed->fRow);
683 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
684 // if (angle2<0.6) angle2 = 0.6;
685 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
688 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
691 if (fSectors==fInnerSec){
693 res = ggg1[amp]*z+glandau1[amp]*angle2;
694 if (ctype==0) res *= gcor01[rsigmaz];
697 res*= gcorp[rsigmaz];
703 res = ggg2[amp]*z+glandau2[amp]*angle2;
704 if (ctype==0) res *= gcor02[rsigmaz];
707 res*= gcorp[rsigmaz];
712 res = ggg3[amp]*z+glandau3[amp]*angle2;
713 if (ctype==0) res *= gcor02[rsigmaz];
716 res*= gcorp[rsigmaz];
725 if ((ctype<0) &&<70){
733 seed->SetErrorZ2(res);
740 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
743 //seed->SetErrorZ2(0.1);
747 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
749 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
750 Int_t ctype = cl->GetType();
751 Float_t amp = TMath::Abs(cl->GetQ());
756 Float_t landau=2 ; //landau fluctuation part
757 Float_t gg=2; // gg fluctuation part
758 Float_t padlength= GetPadPitchLength(seed->GetX());
760 if (fSectors==fInnerSec){
761 snoise2 = 0.0004/padlength;
764 gg = (2+0.001*nel/(padlength*padlength))/nel;
765 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
766 if (landau>1) landau=1;
769 snoise2 = 0.0004/padlength;
772 gg = (2+0.0008*nel/(padlength*padlength))/nel;
773 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
774 if (landau>1) landau=1;
776 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
779 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
780 angle2 = TMath::Sqrt((1-angle2));
781 if (angle2<0.6) angle2 = 0.6;
784 Float_t angle = seed->GetTgl()/angle2;
785 Float_t angular = landau*angle*angle*padlength*padlength/12.;
786 Float_t res = sdiff + angular;
789 if ((ctype==0) && (fSectors ==fOuterSec))
790 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
792 if ((ctype==0) && (fSectors ==fInnerSec))
793 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
797 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
803 if ((ctype<0) &&<70){
811 seed->SetErrorZ2(res);
818 void AliTPCseed::Reset(Bool_t all)
822 SetNumberOfClusters(0);
828 for (Int_t i=0;i<8;i++){
829 delete [] fTrackPoints[i];
837 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
838 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
844 void AliTPCseed::Modify(Double_t factor)
847 //------------------------------------------------------------------
848 //This function makes a track forget its history :)
849 //------------------------------------------------------------------
855 fC10*=factor; fC11*=factor;
856 fC20*=factor; fC21*=factor; fC22*=factor;
857 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
858 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
859 SetNumberOfClusters(0);
863 fCurrentSigmaY2 = 0.000005;
864 fCurrentSigmaZ2 = 0.000005;
873 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
875 //-----------------------------------------------------------------
876 // This function find proloncation of a track to a reference plane x=xk.
877 // doesn't change internal state of the track
878 //-----------------------------------------------------------------
880 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
882 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
886 // Double_t y1=fP0, z1=fP1;
887 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
888 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
892 //y += dx*(c1+c2)/(r1+r2);
893 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
895 Double_t dy = dx*(c1+c2)/(r1+r2);
898 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
900 if (TMath::Abs(delta)>0.0001){
901 dz = fP3*TMath::ASin(delta)/fP4;
903 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
906 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
916 //_____________________________________________________________________________
917 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
919 //-----------------------------------------------------------------
920 // This function calculates a predicted chi2 increment.
921 //-----------------------------------------------------------------
922 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
923 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
924 r00+=fC00; r01+=fC10; r11+=fC11;
926 Double_t det=r00*r11 - r01*r01;
927 if (TMath::Abs(det) < 1.e-10) {
928 Int_t n=GetNumberOfClusters();
929 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
932 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
934 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
936 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
940 //_________________________________________________________________________________________
943 Int_t AliTPCseed::Compare(const TObject *o) const {
944 //-----------------------------------------------------------------
945 // This function compares tracks according to the sector - for given sector according z
946 //-----------------------------------------------------------------
947 AliTPCseed *t=(AliTPCseed*)o;
950 if (t->fRelativeSector>fRelativeSector) return -1;
951 if (t->fRelativeSector<fRelativeSector) return 1;
952 Double_t z2 = t->GetZ();
953 Double_t z1 = GetZ();
955 if (z2<z1) return -1;
960 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
961 if (t->fBConstrain) f2=1.2;
964 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
966 if (fBConstrain) f1=1.2;
968 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
973 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
975 //rotate to track "local coordinata
976 Float_t x = seed->GetX();
977 Float_t y = seed->GetY();
978 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
981 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
982 if (!seed->Rotate(fSectors->GetAlpha()))
984 } else if (y <-ymax) {
985 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
986 if (!seed->Rotate(-fSectors->GetAlpha()))
995 //_____________________________________________________________________________
996 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
997 //-----------------------------------------------------------------
998 // This function associates a cluster with this track.
999 //-----------------------------------------------------------------
1000 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
1002 r00+=fC00; r01+=fC10; r11+=fC11;
1003 Double_t det=r00*r11 - r01*r01;
1004 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
1006 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
1007 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
1008 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
1009 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
1010 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
1012 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
1013 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
1014 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1018 fP0 += k00*dy + k01*dz;
1019 fP1 += k10*dy + k11*dz;
1021 fP3 += k30*dy + k31*dz;
1024 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1025 Double_t c12=fC21, c13=fC31, c14=fC41;
1027 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1028 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1029 fC40-=k00*c04+k01*c14;
1031 fC11-=k10*c01+k11*fC11;
1032 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1033 fC41-=k10*c04+k11*c14;
1035 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1036 fC42-=k20*c04+k21*c14;
1038 fC33-=k30*c03+k31*c13;
1039 fC43-=k40*c03+k41*c13;
1041 fC44-=k40*c04+k41*c14;
1043 Int_t n=GetNumberOfClusters();
1045 SetNumberOfClusters(n+1);
1046 SetChi2(GetChi2()+chisq);
1053 //_____________________________________________________________________________
1054 Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1055 Double_t x2,Double_t y2,
1056 Double_t x3,Double_t y3)
1058 //-----------------------------------------------------------------
1059 // Initial approximation of the track curvature
1060 //-----------------------------------------------------------------
1061 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1062 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1063 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1064 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1065 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1067 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1068 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1069 return -xr*yr/sqrt(xr*xr+yr*yr);
1074 //_____________________________________________________________________________
1075 Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
1076 Double_t x2,Double_t y2,
1077 Double_t x3,Double_t y3)
1079 //-----------------------------------------------------------------
1080 // Initial approximation of the track curvature
1081 //-----------------------------------------------------------------
1087 Double_t det = x3*y2-x2*y3;
1092 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1093 Double_t x0 = x3*0.5-y3*u;
1094 Double_t y0 = y3*0.5+x3*u;
1095 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1101 Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1102 Double_t x2,Double_t y2,
1103 Double_t x3,Double_t y3)
1105 //-----------------------------------------------------------------
1106 // Initial approximation of the track curvature
1107 //-----------------------------------------------------------------
1113 Double_t det = x3*y2-x2*y3;
1118 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1119 Double_t x0 = x3*0.5-y3*u;
1120 Double_t y0 = y3*0.5+x3*u;
1121 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1130 //_____________________________________________________________________________
1131 Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
1132 Double_t x2,Double_t y2,
1133 Double_t x3,Double_t y3)
1135 //-----------------------------------------------------------------
1136 // Initial approximation of the track curvature times center of curvature
1137 //-----------------------------------------------------------------
1138 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1139 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1140 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1141 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1142 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1144 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1146 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1149 //_____________________________________________________________________________
1150 Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1151 Double_t x2,Double_t y2,
1152 Double_t z1,Double_t z2)
1154 //-----------------------------------------------------------------
1155 // Initial approximation of the tangent of the track dip angle
1156 //-----------------------------------------------------------------
1157 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1161 Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
1162 Double_t x2,Double_t y2,
1163 Double_t z1,Double_t z2, Double_t c)
1165 //-----------------------------------------------------------------
1166 // Initial approximation of the tangent of the track dip angle
1167 //-----------------------------------------------------------------
1171 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1173 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1174 if (TMath::Abs(d*c*0.5)>1) return 0;
1175 // Double_t angle2 = TMath::ASin(d*c*0.5);
1176 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1177 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
1179 angle2 = (z1-z2)*c/(angle2*2.);
1183 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1184 {//-----------------------------------------------------------------
1185 // This function find proloncation of a track to a reference plane x=x2.
1186 //-----------------------------------------------------------------
1190 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1194 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1195 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1199 Double_t dy = dx*(c1+c2)/(r1+r2);
1202 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1204 if (TMath::Abs(delta)>0.01){
1205 dz = x[3]*TMath::ASin(delta)/x[4];
1207 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1210 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
1220 Int_t AliTPCtrackerMI::LoadClusters()
1223 // load clusters to the memory
1224 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1225 clrow->SetClass("AliTPCclusterMI");
1227 clrow->GetArray()->ExpandCreateFast(10000);
1229 // TTree * tree = fClustersArray.GetTree();
1231 TTree * tree = fInput;
1232 TBranch * br = tree->GetBranch("Segment");
1233 br->SetAddress(&clrow);
1235 Int_t j=Int_t(tree->GetEntries());
1236 for (Int_t i=0; i<j; i++) {
1240 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1242 AliTPCRow * tpcrow=0;
1245 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1249 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1250 left = (sec-fkNIS*2)/fkNOS;
1253 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1254 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1255 for (Int_t i=0;i<tpcrow->fN1;i++)
1256 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1259 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1260 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1261 for (Int_t i=0;i<tpcrow->fN2;i++)
1262 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1273 void AliTPCtrackerMI::UnloadClusters()
1276 // unload clusters from the memory
1278 Int_t nrows = fOuterSec->GetNRows();
1279 for (Int_t sec = 0;sec<fkNOS;sec++)
1280 for (Int_t row = 0;row<nrows;row++){
1281 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1283 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1284 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1288 nrows = fInnerSec->GetNRows();
1289 for (Int_t sec = 0;sec<fkNIS;sec++)
1290 for (Int_t row = 0;row<nrows;row++){
1291 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1293 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1294 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1302 //_____________________________________________________________________________
1303 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1304 //-----------------------------------------------------------------
1305 // This function fills outer TPC sectors with clusters.
1306 //-----------------------------------------------------------------
1307 Int_t nrows = fOuterSec->GetNRows();
1309 for (Int_t sec = 0;sec<fkNOS;sec++)
1310 for (Int_t row = 0;row<nrows;row++){
1311 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1312 Int_t sec2 = sec+2*fkNIS;
1314 Int_t ncl = tpcrow->fN1;
1316 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1317 index=(((sec2<<8)+row)<<16)+ncl;
1318 tpcrow->InsertCluster(c,index);
1323 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1324 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1325 tpcrow->InsertCluster(c,index);
1328 // write indexes for fast acces
1330 for (Int_t i=0;i<510;i++)
1331 tpcrow->fFastCluster[i]=-1;
1332 for (Int_t i=0;i<tpcrow->GetN();i++){
1333 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1334 tpcrow->fFastCluster[zi]=i; // write index
1337 for (Int_t i=0;i<510;i++){
1338 if (tpcrow->fFastCluster[i]<0)
1339 tpcrow->fFastCluster[i] = last;
1341 last = tpcrow->fFastCluster[i];
1350 //_____________________________________________________________________________
1351 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1352 //-----------------------------------------------------------------
1353 // This function fills inner TPC sectors with clusters.
1354 //-----------------------------------------------------------------
1355 Int_t nrows = fInnerSec->GetNRows();
1357 for (Int_t sec = 0;sec<fkNIS;sec++)
1358 for (Int_t row = 0;row<nrows;row++){
1359 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1362 Int_t ncl = tpcrow->fN1;
1364 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1365 index=(((sec<<8)+row)<<16)+ncl;
1366 tpcrow->InsertCluster(c,index);
1371 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1372 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1373 tpcrow->InsertCluster(c,index);
1376 // write indexes for fast acces
1378 for (Int_t i=0;i<510;i++)
1379 tpcrow->fFastCluster[i]=-1;
1380 for (Int_t i=0;i<tpcrow->GetN();i++){
1381 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1382 tpcrow->fFastCluster[zi]=i; // write index
1385 for (Int_t i=0;i<510;i++){
1386 if (tpcrow->fFastCluster[i]<0)
1387 tpcrow->fFastCluster[i] = last;
1389 last = tpcrow->fFastCluster[i];
1401 //_________________________________________________________________________
1402 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1403 //--------------------------------------------------------------------
1404 // Return pointer to a given cluster
1405 //--------------------------------------------------------------------
1406 Int_t sec=(index&0xff000000)>>24;
1407 Int_t row=(index&0x00ff0000)>>16;
1408 Int_t ncl=(index&0x0000ffff)>>00;
1410 const AliTPCRow * tpcrow=0;
1411 AliTPCclusterMI * clrow =0;
1413 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1415 clrow = tpcrow->fClusters1;
1417 clrow = tpcrow->fClusters2;
1420 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1421 if (sec-2*fkNIS<fkNOS)
1422 clrow = tpcrow->fClusters1;
1424 clrow = tpcrow->fClusters2;
1426 if (tpcrow==0) return 0;
1427 if (tpcrow->GetN()<=ncl) return 0;
1428 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1429 return &(clrow[ncl]);
1435 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1436 //-----------------------------------------------------------------
1437 // This function tries to find a track prolongation to next pad row
1438 //-----------------------------------------------------------------
1440 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1442 // if (t.GetRadius()>x+10 ) return 0;
1443 // t.PropagateTo(x+0.02);
1444 //t.PropagateTo(x+0.01);
1445 if (!t.PropagateTo(x)) {
1450 Double_t y=t.GetY(), z=t.GetZ();
1451 if (TMath::Abs(y)>ymax){
1453 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1454 if (!t.Rotate(fSectors->GetAlpha()))
1456 } else if (y <-ymax) {
1457 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1458 if (!t.Rotate(-fSectors->GetAlpha()))
1461 if (!t.PropagateTo(x)) {
1467 // update current shape info every 3 pad-row
1468 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1469 //t.fCurrentSigmaY = GetSigmaY(&t);
1470 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1474 AliTPCclusterMI *cl=0;
1479 if (t.GetClusterIndex2(nr)>0){
1481 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1482 index = t.GetClusterIndex2(nr);
1483 cl = t.fClusterPointer[nr];
1484 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1485 t.fCurrentClusterIndex1 = index;
1488 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1489 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1491 Double_t roadz = 1.;
1493 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1495 t.SetClusterIndex2(nr,-1);
1500 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1506 t.fCurrentCluster = cl;
1508 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1510 //if founded cluster is acceptible
1511 UpdateTrack(&t,accept);
1517 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1518 cl = krow.FindNearest2(y,z,roady,roadz,index);
1519 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1524 t.fCurrentCluster = cl;
1526 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1528 if (t.fCurrentCluster->IsUsed(10)){
1533 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1539 if (accept<3) UpdateTrack(&t,accept);
1542 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1548 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1549 //-----------------------------------------------------------------
1550 // This function tries to find a track prolongation to next pad row
1551 //-----------------------------------------------------------------
1553 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1555 if (!t.GetProlongation(x,y,z)) {
1561 if (TMath::Abs(y)>ymax){
1565 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1566 if (!t.Rotate(fSectors->GetAlpha()))
1568 } else if (y <-ymax) {
1569 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1570 if (!t.Rotate(-fSectors->GetAlpha()))
1573 if (!t.PropagateTo(x)) {
1576 t.GetProlongation(x,y,z);
1579 // update current shape info every 3 pad-row
1580 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1581 // t.fCurrentSigmaY = GetSigmaY(&t);
1582 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1586 AliTPCclusterMI *cl=0;
1591 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1592 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1594 Double_t roadz = 1.;
1597 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1599 t.SetClusterIndex2(row,-1);
1604 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1608 if ((cl==0)&&(krow)) {
1609 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1610 cl = krow.FindNearest2(y,z,roady,roadz,index);
1612 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1616 t.fCurrentCluster = cl;
1617 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1619 t.SetClusterIndex2(row,index);
1620 t.fClusterPointer[row] = cl;
1628 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1629 //-----------------------------------------------------------------
1630 // This function tries to find a track prolongation to next pad row
1631 //-----------------------------------------------------------------
1632 t.fCurrentCluster = 0;
1633 t.fCurrentClusterIndex1 = 0;
1635 Double_t xt=t.GetX();
1636 Int_t row = GetRowNumber(xt)-1;
1637 Double_t ymax= GetMaxY(nr);
1639 if (row < nr) return 1; // don't prolongate if not information until now -
1640 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1642 return 0; // not prolongate strongly inclined tracks
1644 if (TMath::Abs(t.GetSnp())>0.95) {
1646 return 0; // not prolongate strongly inclined tracks
1649 Double_t x= GetXrow(nr);
1651 //t.PropagateTo(x+0.02);
1652 //t.PropagateTo(x+0.01);
1653 if (!t.PropagateTo(x)){
1660 if (TMath::Abs(y)>ymax){
1662 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1663 if (!t.Rotate(fSectors->GetAlpha()))
1665 } else if (y <-ymax) {
1666 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1667 if (!t.Rotate(-fSectors->GetAlpha()))
1670 if (!t.PropagateTo(x)){
1677 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1679 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1681 t.SetClusterIndex2(nr,-1);
1686 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1692 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1693 // t.fCurrentSigmaY = GetSigmaY(&t);
1694 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1698 AliTPCclusterMI *cl=0;
1701 Double_t roady = 1.;
1702 Double_t roadz = 1.;
1705 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1706 cl = krow.FindNearest2(y,z,roady,roadz,index);
1708 t.fCurrentCluster = cl;
1709 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1714 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1715 //-----------------------------------------------------------------
1716 // This function tries to find a track prolongation to next pad row
1717 //-----------------------------------------------------------------
1719 //update error according neighborhoud
1721 if (t.fCurrentCluster) {
1723 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1725 if (t.fCurrentCluster->IsUsed(10)){
1731 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1737 if (accept<3) UpdateTrack(&t,accept);
1741 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1742 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1744 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1752 //_____________________________________________________________________________
1753 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1754 //-----------------------------------------------------------------
1755 // This function tries to find a track prolongation.
1756 //-----------------------------------------------------------------
1757 Double_t xt=t.GetX();
1759 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1760 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1761 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1763 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1765 Int_t first = GetRowNumber(xt)-1;
1766 for (Int_t nr= first; nr>=rf; nr-=step) {
1767 if (FollowToNext(t,nr)==0)
1768 if (!t.IsActive()) return 0;
1775 //_____________________________________________________________________________
1776 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1777 //-----------------------------------------------------------------
1778 // This function tries to find a track prolongation.
1779 //-----------------------------------------------------------------
1780 Double_t xt=t.GetX();
1782 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1783 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1784 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1785 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1787 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1789 if (FollowToNextFast(t,nr)==0)
1790 if (!t.IsActive()) return 0;
1800 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1801 //-----------------------------------------------------------------
1802 // This function tries to find a track prolongation.
1803 //-----------------------------------------------------------------
1804 // Double_t xt=t.GetX();
1806 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1807 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1808 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1809 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1812 first = t.fFirstPoint+3;
1814 if (first<0) first=0;
1815 for (Int_t nr=first+1; nr<=rf; nr++) {
1816 //if ( (t.GetSnp()<0.9))
1826 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1834 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1837 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1839 Float_t distance = TMath::Sqrt(dz2+dy2);
1840 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1843 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1844 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1849 if (firstpoint>lastpoint) {
1850 firstpoint =lastpoint;
1855 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1856 if (s1->GetClusterIndex2(i)>0) sum1++;
1857 if (s2->GetClusterIndex2(i)>0) sum2++;
1858 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1862 if (sum<5) return 0;
1864 Float_t summin = TMath::Min(sum1+1,sum2+1);
1865 Float_t ratio = (sum+1)/Float_t(summin);
1869 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1873 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1874 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1876 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1878 Float_t dy2 =(s1->GetY() - s2->GetY());
1880 Float_t distance = dz2+dy2;
1881 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1886 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1887 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1889 if (firstpoint>=lastpoint-5) return;;
1891 for (Int_t i=firstpoint;i<lastpoint;i++){
1892 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1893 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1900 for (Int_t i=firstpoint;i<lastpoint;i++){
1901 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1902 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1903 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1904 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1905 if (s1->IsActive()&&s2->IsActive()){
1906 p1->fIsShared = kTRUE;
1907 p2->fIsShared = kTRUE;
1914 for (Int_t i=0;i<4;i++){
1915 if (s1->fOverlapLabels[3*i]==0){
1916 s1->fOverlapLabels[3*i] = s2->GetLabel();
1917 s1->fOverlapLabels[3*i+1] = sumshared;
1918 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1922 for (Int_t i=0;i<4;i++){
1923 if (s2->fOverlapLabels[3*i]==0){
1924 s2->fOverlapLabels[3*i] = s1->GetLabel();
1925 s2->fOverlapLabels[3*i+1] = sumshared;
1926 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1934 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1937 //sort trackss according sectors
1939 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1940 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1942 //if (pt) RotateToLocal(pt);
1946 arr->Sort(); // sorting according z
1947 arr->Expand(arr->GetEntries());
1950 Int_t nseed=arr->GetEntriesFast();
1951 for (Int_t i=0; i<nseed; i++) {
1952 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1954 for (Int_t j=0;j<=12;j++){
1955 pt->fOverlapLabels[j] =0;
1958 for (Int_t i=0; i<nseed; i++) {
1959 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1961 if (pt->fRemoval>10) continue;
1962 for (Int_t j=i+1; j<nseed; j++){
1963 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1965 if (pt2->fRemoval<=10) {
1966 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1973 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1976 //sort trackss according sectors
1979 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1982 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1983 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1988 arr->Sort(); // sorting according z
1989 arr->Expand(arr->GetEntries());
1991 //reset overlap labels
1993 Int_t nseed=arr->GetEntriesFast();
1994 for (Int_t i=0; i<nseed; i++) {
1995 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1998 for (Int_t j=0;j<=12;j++){
1999 pt->fOverlapLabels[j] =0;
2003 //sign shared tracks
2004 for (Int_t i=0; i<nseed; i++) {
2005 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2007 if (pt->fRemoval>10) continue;
2008 Float_t deltac = pt->GetC()*0.1;
2009 for (Int_t j=i+1; j<nseed; j++){
2010 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2012 if (pt2->fRemoval<=10) {
2013 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2014 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2015 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2022 // remove highly shared tracks
2023 for (Int_t i=0; i<nseed; i++) {
2024 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2026 if (pt->fRemoval>10) continue;
2029 for (Int_t j=0;j<4;j++){
2030 sumshared = pt->fOverlapLabels[j*3+1];
2032 Float_t factor = factor1;
2033 if (pt->fRemoval>0) factor = factor2;
2034 if (sumshared/pt->GetNumberOfClusters()>factor){
2035 for (Int_t j=0;j<4;j++){
2036 if (pt->fOverlapLabels[3*j]==0) continue;
2037 if (pt->fOverlapLabels[3*j+1]<5) continue;
2038 if (pt->fRemoval==removalindex) continue;
2039 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2041 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2042 // pt->fRemoval = removalindex;
2043 delete arr->RemoveAt(i);
2051 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2060 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode)
2063 //sort tracks in array according mode criteria
2064 Int_t nseed = arr->GetEntriesFast();
2065 for (Int_t i=0; i<nseed; i++) {
2066 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2076 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2079 //Loop over all tracks and remove "overlaps"
2082 Int_t nseed = arr->GetEntriesFast();
2085 for (Int_t i=0; i<nseed; i++) {
2086 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2088 delete arr->RemoveAt(i);
2092 pt->fBSigned = kFALSE;
2096 nseed = arr->GetEntriesFast();
2103 for (Int_t i=0; i<nseed; i++) {
2104 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2108 Int_t found,foundable,shared;
2110 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2112 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2114 Double_t factor = factor2;
2115 if (pt->fBConstrain) factor = factor1;
2117 if ((Float_t(shared)/Float_t(found))>factor){
2118 pt->Desactivate(removalindex);
2123 for (Int_t i=0; i<160; i++) {
2124 Int_t index=pt->GetClusterIndex2(i);
2125 if (index<0 || index&0x8000 ) continue;
2126 AliTPCclusterMI *c= pt->fClusterPointer[i];
2128 // if (!c->IsUsed(10)) c->Use(10);
2129 //if (pt->IsActive())
2138 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2141 void AliTPCtrackerMI::UnsignClusters()
2144 // loop over all clusters and unsign them
2147 for (Int_t sec=0;sec<fkNIS;sec++){
2148 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2149 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2150 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2151 // if (cl[icl].IsUsed(10))
2153 cl = fInnerSec[sec][row].fClusters2;
2154 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2155 //if (cl[icl].IsUsed(10))
2160 for (Int_t sec=0;sec<fkNOS;sec++){
2161 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2162 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2163 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2164 //if (cl[icl].IsUsed(10))
2166 cl = fOuterSec[sec][row].fClusters2;
2167 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2168 //if (cl[icl].IsUsed(10))
2177 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2180 //sign clusters to be "used"
2182 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2183 // loop over "primaries"
2197 Int_t nseed = arr->GetEntriesFast();
2198 for (Int_t i=0; i<nseed; i++) {
2199 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2203 if (!(pt->IsActive())) continue;
2204 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2205 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2207 sumdens2+= dens*dens;
2208 sumn += pt->GetNumberOfClusters();
2209 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2210 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2213 sumchi2 +=chi2*chi2;
2218 Float_t mdensity = 0.9;
2219 Float_t meann = 130;
2220 Float_t meanchi = 1;
2221 Float_t sdensity = 0.1;
2222 Float_t smeann = 10;
2223 Float_t smeanchi =0.4;
2227 mdensity = sumdens/sum;
2229 meanchi = sumchi/sum;
2231 sdensity = sumdens2/sum-mdensity*mdensity;
2232 sdensity = TMath::Sqrt(sdensity);
2234 smeann = sumn2/sum-meann*meann;
2235 smeann = TMath::Sqrt(smeann);
2237 smeanchi = sumchi2/sum - meanchi*meanchi;
2238 smeanchi = TMath::Sqrt(smeanchi);
2242 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2244 for (Int_t i=0; i<nseed; i++) {
2245 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2249 if (pt->fBSigned) continue;
2250 if (pt->fBConstrain) continue;
2251 //if (!(pt->IsActive())) continue;
2253 Int_t found,foundable,shared;
2254 pt->GetClusterStatistic(0,160,found, foundable,shared);
2255 if (shared/float(found)>0.3) {
2256 if (shared/float(found)>0.9 ){
2257 //delete arr->RemoveAt(i);
2262 Bool_t isok =kFALSE;
2263 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2265 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2267 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2269 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2273 for (Int_t i=0; i<160; i++) {
2274 Int_t index=pt->GetClusterIndex2(i);
2275 if (index<0) continue;
2276 AliTPCclusterMI *c= pt->fClusterPointer[i];
2278 //if (!(c->IsUsed(10))) c->Use();
2285 Double_t maxchi = meanchi+2.*smeanchi;
2287 for (Int_t i=0; i<nseed; i++) {
2288 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2292 //if (!(pt->IsActive())) continue;
2293 if (pt->fBSigned) continue;
2294 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2295 if (chi>maxchi) continue;
2298 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2300 //sign only tracks with enoug big density at the beginning
2302 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2305 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2306 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2308 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2309 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2312 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2313 //Int_t noc=pt->GetNumberOfClusters();
2314 pt->fBSigned = kTRUE;
2315 for (Int_t i=0; i<160; i++) {
2317 Int_t index=pt->GetClusterIndex2(i);
2318 if (index<0) continue;
2319 AliTPCclusterMI *c= pt->fClusterPointer[i];
2321 // if (!(c->IsUsed(10))) c->Use();
2326 // gLastCheck = nseed;
2334 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2)
2336 // stop not active tracks
2337 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2338 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2339 Int_t nseed = arr->GetEntriesFast();
2341 for (Int_t i=0; i<nseed; i++) {
2342 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2346 if (!(pt->IsActive())) continue;
2347 StopNotActive(pt,row0,th0, th1,th2);
2353 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2356 // stop not active tracks
2357 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2358 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2361 Int_t foundable = 0;
2362 Int_t maxindex = seed->fLastPoint; //last foundable row
2363 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2364 seed->Desactivate(10) ;
2368 for (Int_t i=row0; i<maxindex; i++){
2369 Int_t index = seed->GetClusterIndex2(i);
2370 if (index!=-1) foundable++;
2372 if (foundable<=30) sumgood1++;
2373 if (foundable<=50) {
2380 if (foundable>=30.){
2381 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2384 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2389 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2392 // back propagation of ESD tracks
2397 PropagateBack(fSeeds);
2398 Int_t nseed = fSeeds->GetEntriesFast();
2399 for (Int_t i=0;i<nseed;i++){
2400 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2401 AliESDtrack *esd=event->GetTrack(i);
2402 seed->CookdEdx(0.02,0.06);
2403 CookLabel(seed,0.1); //For comparison only
2404 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2412 void AliTPCtrackerMI::DeleteSeeds()
2416 Int_t nseed = fSeeds->GetEntriesFast();
2417 for (Int_t i=0;i<nseed;i++){
2418 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2419 if (seed) delete fSeeds->RemoveAt(i);
2425 void AliTPCtrackerMI::ReadSeeds(AliESD *event)
2428 //read seeds from the event
2430 Int_t nentr=event->GetNumberOfTracks();
2431 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2435 fSeeds = new TObjArray;
2439 for (Int_t i=0; i<nentr; i++) {
2440 AliESDtrack *esd=event->GetTrack(i);
2441 ULong_t status=esd->GetStatus();
2442 AliTPCtrack t(*esd);
2443 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2444 if (status==AliESDtrack::kTPCin) seed->Modify(0.8);
2447 // rotate to the local coordinate system
2449 fSectors=fInnerSec; fN=fkNIS;
2451 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2452 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2453 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2454 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2455 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2456 alpha-=seed->GetAlpha();
2457 if (!seed->Rotate(alpha)) continue;
2459 seed->PropagateTo(fSectors->GetX(0));
2461 // Int_t index = esd->GetTPCindex();
2462 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2464 fSeeds->AddLast(seed);
2470 //_____________________________________________________________________________
2471 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2472 Float_t deltay, Int_t ddsec) {
2473 //-----------------------------------------------------------------
2474 // This function creates track seeds.
2475 // SEEDING WITH VERTEX CONSTRAIN
2476 //-----------------------------------------------------------------
2477 // cuts[0] - fP4 cut
2478 // cuts[1] - tan(phi) cut
2479 // cuts[2] - zvertex cut
2480 // cuts[3] - fP3 cut
2488 Double_t x[5], c[15];
2489 // Int_t di = i1-i2;
2491 AliTPCseed * seed = new AliTPCseed;
2492 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2493 Double_t cs=cos(alpha), sn=sin(alpha);
2495 // Double_t x1 =fOuterSec->GetX(i1);
2496 //Double_t xx2=fOuterSec->GetX(i2);
2498 Double_t x1 =GetXrow(i1);
2499 Double_t xx2=GetXrow(i2);
2501 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2503 Int_t imiddle = (i2+i1)/2; //middle pad row index
2504 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2505 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2509 const AliTPCRow& kr1=GetRow(ns,i1);
2510 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2511 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2514 // change cut on curvature if it can't reach this layer
2515 // maximal curvature set to reach it
2516 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2517 if (dvertexmax*0.5*cuts[0]>0.85){
2518 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2520 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2523 if (deltay>0) ddsec = 0;
2524 // loop over clusters
2525 for (Int_t is=0; is < kr1; is++) {
2527 if (kr1[is]->IsUsed(10)) continue;
2528 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2529 //if (TMath::Abs(y1)>ymax) continue;
2531 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2533 // find possible directions
2534 Float_t anglez = (z1-z3)/(x1-x3);
2535 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2538 //find rotation angles relative to line given by vertex and point 1
2539 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2540 Double_t dvertex = TMath::Sqrt(dvertex2);
2541 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2542 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2545 // loop over 2 sectors
2551 Double_t dddz1=0; // direction of delta inclination in z axis
2558 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2559 Int_t sec2 = sec + dsec;
2561 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2562 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2563 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2564 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2565 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2566 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2568 // rotation angles to p1-p3
2569 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2570 Double_t x2, y2, z2;
2572 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2575 Double_t dxx0 = (xx2-x3)*cs13r;
2576 Double_t dyy0 = (xx2-x3)*sn13r;
2577 for (Int_t js=index1; js < index2; js++) {
2578 const AliTPCclusterMI *kcl = kr2[js];
2579 if (kcl->IsUsed(10)) continue;
2581 //calcutate parameters
2583 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2585 if (TMath::Abs(yy0)<0.000001) continue;
2586 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2587 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2588 Double_t r02 = (0.25+y0*y0)*dvertex2;
2589 //curvature (radius) cut
2590 if (r02<r2min) continue;
2594 Double_t c0 = 1/TMath::Sqrt(r02);
2598 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2599 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2600 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2601 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2604 Double_t z0 = kcl->GetZ();
2605 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2606 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2609 Double_t dip = (z1-z0)*c0/dfi1;
2610 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2621 x2= xx2*cs-y2*sn*dsec;
2622 y2=+xx2*sn*dsec+y2*cs;
2632 // do we have cluster at the middle ?
2634 GetProlongation(x1,xm,x,ym,zm);
2636 AliTPCclusterMI * cm=0;
2637 if (TMath::Abs(ym)-ymaxm<0){
2638 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2639 if ((!cm) || (cm->IsUsed(10))) {
2644 // rotate y1 to system 0
2645 // get state vector in rotated system
2646 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2647 Double_t xr2 = x0*cs+yr1*sn*dsec;
2648 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2650 GetProlongation(xx2,xm,xr,ym,zm);
2651 if (TMath::Abs(ym)-ymaxm<0){
2652 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2653 if ((!cm) || (cm->IsUsed(10))) {
2663 dym = ym - cm->GetY();
2664 dzm = zm - cm->GetZ();
2671 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2672 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2673 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2674 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2675 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2677 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2678 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2679 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2680 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2681 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2682 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2684 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2685 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2686 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2687 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2691 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2692 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2693 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2694 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2695 c[13]=f30*sy1*f40+f32*sy2*f42;
2696 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2698 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2700 UInt_t index=kr1.GetIndex(is);
2701 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2703 track->fIsSeeding = kTRUE;
2710 FollowProlongation(*track, (i1+i2)/2,1);
2711 Int_t foundable,found,shared;
2712 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2713 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2715 seed->~AliTPCseed();
2721 FollowProlongation(*track, i2,1);
2725 track->fBConstrain =1;
2726 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2727 track->fLastPoint = i1; // first cluster in track position
2728 track->fFirstPoint = track->fLastPoint;
2730 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2731 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2732 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2734 seed->~AliTPCseed();
2738 // Z VERTEX CONDITION
2740 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2741 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2742 if (TMath::Abs(zv-z3)>cuts[2]) {
2743 FollowProlongation(*track, TMath::Max(i2-20,0));
2744 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2745 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2746 if (TMath::Abs(zv-z3)>cuts[2]){
2747 FollowProlongation(*track, TMath::Max(i2-40,0));
2748 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2749 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2750 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2751 // make seed without constrain
2752 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2753 FollowProlongation(*track2, i2,1);
2754 track2->fBConstrain = kFALSE;
2755 track2->fSeedType = 1;
2756 arr->AddLast(track2);
2758 seed->~AliTPCseed();
2763 seed->~AliTPCseed();
2770 track->fSeedType =0;
2771 arr->AddLast(track);
2772 seed = new AliTPCseed;
2774 // don't consider other combinations
2775 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2781 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2787 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2792 //-----------------------------------------------------------------
2793 // This function creates track seeds.
2794 //-----------------------------------------------------------------
2795 // cuts[0] - fP4 cut
2796 // cuts[1] - tan(phi) cut
2797 // cuts[2] - zvertex cut
2798 // cuts[3] - fP3 cut
2808 Double_t x[5], c[15];
2810 // make temporary seed
2811 AliTPCseed * seed = new AliTPCseed;
2812 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2813 // Double_t cs=cos(alpha), sn=sin(alpha);
2818 Double_t x1 = GetXrow(i1-1);
2819 const AliTPCRow& kr1=GetRow(sec,i1-1);
2820 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2822 Double_t x1p = GetXrow(i1);
2823 const AliTPCRow& kr1p=GetRow(sec,i1);
2825 Double_t x1m = GetXrow(i1-2);
2826 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2829 //last 3 padrow for seeding
2830 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2831 Double_t x3 = GetXrow(i1-7);
2832 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2834 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2835 Double_t x3p = GetXrow(i1-6);
2837 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2838 Double_t x3m = GetXrow(i1-8);
2843 Int_t im = i1-4; //middle pad row index
2844 Double_t xm = GetXrow(im); // radius of middle pad-row
2845 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2846 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2849 Double_t deltax = x1-x3;
2850 Double_t dymax = deltax*cuts[1];
2851 Double_t dzmax = deltax*cuts[3];
2853 // loop over clusters
2854 for (Int_t is=0; is < kr1; is++) {
2856 if (kr1[is]->IsUsed(10)) continue;
2857 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2859 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2861 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2862 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2868 for (Int_t js=index1; js < index2; js++) {
2869 const AliTPCclusterMI *kcl = kr3[js];
2870 if (kcl->IsUsed(10)) continue;
2872 // apply angular cuts
2873 if (TMath::Abs(y1-y3)>dymax) continue;
2876 if (TMath::Abs(z1-z3)>dzmax) continue;
2878 Double_t angley = (y1-y3)/(x1-x3);
2879 Double_t anglez = (z1-z3)/(x1-x3);
2881 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2882 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2884 Double_t yyym = angley*(xm-x1)+y1;
2885 Double_t zzzm = anglez*(xm-x1)+z1;
2887 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2889 if (kcm->IsUsed(10)) continue;
2891 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2892 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2899 // look around first
2900 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2906 if (kc1m->IsUsed(10)) used++;
2908 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2914 if (kc1p->IsUsed(10)) used++;
2916 if (used>1) continue;
2917 if (found<1) continue;
2921 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2927 if (kc3m->IsUsed(10)) used++;
2931 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2937 if (kc3p->IsUsed(10)) used++;
2941 if (used>1) continue;
2942 if (found<3) continue;
2952 x[4]=F1(x1,y1,x2,y2,x3,y3);
2953 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
2956 x[2]=F2(x1,y1,x2,y2,x3,y3);
2959 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
2960 //if (TMath::Abs(x[3]) > cuts[3]) continue;
2964 Double_t sy1=0.1, sz1=0.1;
2965 Double_t sy2=0.1, sz2=0.1;
2966 Double_t sy3=0.1, sy=0.1, sz=0.1;
2968 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2969 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2970 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2971 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2972 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2973 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2975 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2976 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2977 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2978 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2982 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2983 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2984 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2985 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2986 c[13]=f30*sy1*f40+f32*sy2*f42;
2987 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2989 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2991 UInt_t index=kr1.GetIndex(is);
2992 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
2994 track->fIsSeeding = kTRUE;
2997 FollowProlongation(*track, i1-7,1);
2998 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
2999 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3001 seed->~AliTPCseed();
3007 FollowProlongation(*track, i2,1);
3008 track->fBConstrain =0;
3009 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3010 track->fFirstPoint = track->fLastPoint;
3012 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3013 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3014 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3016 seed->~AliTPCseed();
3021 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3022 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3023 FollowProlongation(*track2, i2,1);
3024 track2->fBConstrain = kFALSE;
3025 track2->fSeedType = 4;
3026 arr->AddLast(track2);
3028 seed->~AliTPCseed();
3032 //arr->AddLast(track);
3033 //seed = new AliTPCseed;
3039 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3045 //_____________________________________________________________________________
3046 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3047 Float_t deltay, Bool_t /*bconstrain*/) {
3048 //-----------------------------------------------------------------
3049 // This function creates track seeds - without vertex constraint
3050 //-----------------------------------------------------------------
3051 // cuts[0] - fP4 cut - not applied
3052 // cuts[1] - tan(phi) cut
3053 // cuts[2] - zvertex cut - not applied
3054 // cuts[3] - fP3 cut
3064 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3065 // Double_t cs=cos(alpha), sn=sin(alpha);
3066 Int_t row0 = (i1+i2)/2;
3067 Int_t drow = (i1-i2)/2;
3068 const AliTPCRow& kr0=fSectors[sec][row0];
3071 AliTPCpolyTrack polytrack;
3072 Int_t nclusters=fSectors[sec][row0];
3073 AliTPCseed * seed = new AliTPCseed;
3078 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3080 Int_t nfoundable =0;
3081 for (Int_t iter =1; iter<2; iter++){ //iterations
3082 const AliTPCRow& krm=fSectors[sec][row0-iter];
3083 const AliTPCRow& krp=fSectors[sec][row0+iter];
3084 const AliTPCclusterMI * cl= kr0[is];
3086 if (cl->IsUsed(10)) {
3092 Double_t x = kr0.GetX();
3093 // Initialization of the polytrack
3098 Double_t y0= cl->GetY();
3099 Double_t z0= cl->GetZ();
3103 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3104 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3106 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3107 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3108 polytrack.AddPoint(x,y0,z0,erry, errz);
3111 if (cl->IsUsed(10)) sumused++;
3114 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3115 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3118 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3119 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3120 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3121 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3122 if (cl1->IsUsed(10)) sumused++;
3123 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3127 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3129 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3130 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3131 if (cl2->IsUsed(10)) sumused++;
3132 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3135 if (sumused>0) continue;
3137 polytrack.UpdateParameters();
3143 nfoundable = polytrack.GetN();
3144 nfound = nfoundable;
3146 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3147 Float_t maxdist = 0.8*(1.+3./(ddrow));
3148 for (Int_t delta = -1;delta<=1;delta+=2){
3149 Int_t row = row0+ddrow*delta;
3150 kr = &(fSectors[sec][row]);
3151 Double_t xn = kr->GetX();
3152 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3153 polytrack.GetFitPoint(xn,yn,zn);
3154 if (TMath::Abs(yn)>ymax) continue;
3156 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3158 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3161 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3162 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3163 if (cln->IsUsed(10)) {
3164 // printf("used\n");
3172 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3177 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3178 polytrack.UpdateParameters();
3181 if ( (sumused>3) || (sumused>0.5*nfound)) {
3182 //printf("sumused %d\n",sumused);
3187 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3188 AliTPCpolyTrack track2;
3190 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3191 if (track2.GetN()<0.5*nfoundable) continue;
3194 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3196 // test seed with and without constrain
3197 for (Int_t constrain=0; constrain<=0;constrain++){
3198 // add polytrack candidate
3200 Double_t x[5], c[15];
3201 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3202 track2.GetBoundaries(x3,x1);
3204 track2.GetFitPoint(x1,y1,z1);
3205 track2.GetFitPoint(x2,y2,z2);
3206 track2.GetFitPoint(x3,y3,z3);
3208 //is track pointing to the vertex ?
3211 polytrack.GetFitPoint(x0,y0,z0);
3224 x[4]=F1(x1,y1,x2,y2,x3,y3);
3226 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3227 x[2]=F2(x1,y1,x2,y2,x3,y3);
3229 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3230 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3231 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
3232 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3235 Double_t sy =0.1, sz =0.1;
3236 Double_t sy1=0.02, sz1=0.02;
3237 Double_t sy2=0.02, sz2=0.02;
3241 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3244 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3245 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3246 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3247 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3248 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3249 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3251 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3252 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3253 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3254 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3259 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3260 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3261 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3262 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3263 c[13]=f30*sy1*f40+f32*sy2*f42;
3264 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3266 //Int_t row1 = fSectors->GetRowNumber(x1);
3267 Int_t row1 = GetRowNumber(x1);
3271 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3272 track->fIsSeeding = kTRUE;
3273 Int_t rc=FollowProlongation(*track, i2);
3274 if (constrain) track->fBConstrain =1;
3276 track->fBConstrain =0;
3277 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3278 track->fFirstPoint = track->fLastPoint;
3280 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3281 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3282 track->fNShared>0.4*track->GetNumberOfClusters()) {
3285 seed->~AliTPCseed();
3288 arr->AddLast(track);
3289 seed = new AliTPCseed;
3293 } // if accepted seed
3296 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3302 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3307 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3308 Int_t p1 = int(r1*track->GetNumberOfClusters());
3309 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3311 Double_t x0[3],x1[3],x2[3];
3316 // find track position at given ratio of the length
3317 Int_t sec0, sec1, sec2;
3323 for (Int_t i=0;i<160;i++){
3324 if (track->fClusterPointer[i]){
3326 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3327 if ( (index<p0) || x0[0]<0 ){
3328 if (trpoint->GetX()>1){
3329 clindex = track->GetClusterIndex2(i);
3331 x0[0] = trpoint->GetX();
3332 x0[1] = trpoint->GetY();
3333 x0[2] = trpoint->GetZ();
3334 sec0 = ((clindex&0xff000000)>>24)%18;
3339 if ( (index<p1) &&(trpoint->GetX()>1)){
3340 clindex = track->GetClusterIndex2(i);
3342 x1[0] = trpoint->GetX();
3343 x1[1] = trpoint->GetY();
3344 x1[2] = trpoint->GetZ();
3345 sec1 = ((clindex&0xff000000)>>24)%18;
3348 if ( (index<p2) &&(trpoint->GetX()>1)){
3349 clindex = track->GetClusterIndex2(i);
3351 x2[0] = trpoint->GetX();
3352 x2[1] = trpoint->GetY();
3353 x2[2] = trpoint->GetZ();
3354 sec2 = ((clindex&0xff000000)>>24)%18;
3361 Double_t alpha, cs,sn, xx2,yy2;
3363 alpha = (sec1-sec2)*fSectors->GetAlpha();
3364 cs = TMath::Cos(alpha);
3365 sn = TMath::Sin(alpha);
3366 xx2= x1[0]*cs-x1[1]*sn;
3367 yy2= x1[0]*sn+x1[1]*cs;
3371 alpha = (sec0-sec2)*fSectors->GetAlpha();
3372 cs = TMath::Cos(alpha);
3373 sn = TMath::Sin(alpha);
3374 xx2= x0[0]*cs-x0[1]*sn;
3375 yy2= x0[0]*sn+x0[1]*cs;
3381 Double_t x[5],c[15];
3385 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3386 // if (x[4]>1) return 0;
3387 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3388 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3389 //if (TMath::Abs(x[3]) > 2.2) return 0;
3390 //if (TMath::Abs(x[2]) > 1.99) return 0;
3392 Double_t sy =0.1, sz =0.1;
3394 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3395 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3396 Double_t sy3=0.01+track->GetSigmaY2();
3398 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3399 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3400 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3401 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3402 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3403 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3405 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3406 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3407 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3408 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3413 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3414 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3415 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3416 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3417 c[13]=f30*sy1*f40+f32*sy2*f42;
3418 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3420 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3421 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3422 // Double_t y0,z0,y1,z1, y2,z2;
3423 //seed->GetProlongation(x0[0],y0,z0);
3424 // seed->GetProlongation(x1[0],y1,z1);
3425 //seed->GetProlongation(x2[0],y2,z2);
3427 seed->fLastPoint = pp2;
3428 seed->fFirstPoint = pp2;
3434 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3439 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3441 if (TMath::Abs(seed->GetC())>0.01) return 0;
3444 Float_t x[160], y[160], erry[160], z[160], errz[160];
3446 Float_t xt[160], yt[160], zt[160];
3451 Int_t middle = seed->GetNumberOfClusters()/2;
3454 // find central sector, get local cooordinates
3456 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3457 sec[i]= seed->GetClusterSector(i)%18;
3460 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3461 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3468 if (i>i2) i2 = i; //last point with cluster
3469 if (i2<i1) i1 = i; //first point with cluster
3472 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3474 yt[i] = point->GetY();
3475 zt[i] = point->GetZ();
3477 if (point->GetX()>0){
3478 erry[i] = point->GetErrY();
3479 errz[i] = point->GetErrZ();
3484 secm = sec[i]; //central sector
3485 padm = i; //middle point with cluster
3490 // rotate position to global coordinate system connected to sector at last the point
3492 for (Int_t i=i1;i<=i2;i++){
3494 if (sec[i]<0) continue;
3495 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3496 Double_t cs = TMath::Cos(alpha);
3497 Double_t sn = TMath::Sin(alpha);
3498 Float_t xx2= x[i]*cs+y[i]*sn;
3499 Float_t yy2= -x[i]*sn+y[i]*cs;
3503 xx2= xt[i]*cs+yt[i]*sn;
3504 yy2= -xt[i]*sn+yt[i]*cs;
3509 //get "state" vector
3510 Double_t xh[5],xm = x[padm];
3513 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3514 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3515 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3518 for (Int_t i=i1;i<=i2;i++){
3520 if (sec[i]<0) continue;
3521 GetProlongation(x[i2], x[i],xh,yy,zz);
3522 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3524 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3525 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3526 printf("problem\n");
3531 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3532 Float_t yup[160], ydown[160], zup[160], zdown[160];
3534 AliTPCpolyTrack ptrack1,ptrack2;
3537 for (Int_t i=i1;i<=i2;i++){
3538 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3540 if (cl->GetType()<0) continue;
3541 if (cl->GetType()>10) continue;
3544 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3546 if (ptrack1.GetN()>4.){
3547 ptrack1.UpdateParameters();
3549 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3551 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3560 dyup[i]=0.; //not enough points
3565 for (Int_t i=i2;i>=i1;i--){
3566 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3568 if (cl->GetType()<0) continue;
3569 if (cl->GetType()>10) continue;
3571 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3573 if (ptrack2.GetN()>4){
3574 ptrack2.UpdateParameters();
3576 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3578 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3586 dydown[i]=0.; //not enough points
3591 // find maximal difference of the derivation
3592 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3595 for (Int_t i=i1+10;i<i2-10;i++){
3596 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3597 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3599 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3600 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3601 if ( (ddy+ddz)> th){
3602 seed->fKinkPoint[0] = i;
3603 seed->fKinkPoint[1] = ddy;
3604 seed->fKinkPoint[2] = ddz;
3611 //write information to the debug tree
3612 TBranch * br = fTreeDebug->GetBranch("debug");
3613 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3614 arr->ExpandCreateFast(i2-i1);
3615 br->SetAddress(&arr);
3617 AliTPCclusterMI cldummy;
3619 AliTPCTrackPoint2 pdummy;
3620 pdummy.GetTPoint().fIsShared = 10;
3622 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3623 Double_t cs = TMath::Cos(alpha);
3624 Double_t sn = TMath::Sin(alpha);
3626 for (Int_t i=i1;i<i2;i++){
3627 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3629 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3631 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3634 Double_t x = GetXrow(i);
3635 trpoint->GetTPoint() = *point;
3636 trpoint->GetCPoint() = *cl0;
3637 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3638 trpoint->fID = seed->GetUniqueID();
3639 trpoint->fLab = seed->GetLabel();
3641 trpoint->fGX = cs *x + sn*point->GetY();
3642 trpoint->fGY = -sn *x + cs*point->GetY() ;
3643 trpoint->fGZ = point->GetZ();
3645 trpoint->fDY = y[i];
3646 trpoint->fDZ = z[i];
3648 trpoint->fDYU = dyup[i];
3649 trpoint->fDZU = dzup[i];
3651 trpoint->fDYD = dydown[i];
3652 trpoint->fDZD = dzdown[i];
3654 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3655 trpoint->fDDY = dydown[i]-dyup[i];
3656 trpoint->fDDZ = dzdown[i]-dzup[i];
3664 trpoint->GetCPoint()= cldummy;
3681 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3684 // reseed - refit - track
3687 // Int_t last = fSectors->GetNRows()-1;
3689 if (fSectors == fOuterSec){
3690 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3694 first = t->fFirstPoint;
3696 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3697 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3699 FollowProlongation(*t,first);
3709 //_____________________________________________________________________________
3710 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3711 //-----------------------------------------------------------------
3712 // This function reades track seeds.
3713 //-----------------------------------------------------------------
3714 TDirectory *savedir=gDirectory;
3716 TFile *in=(TFile*)inp;
3717 if (!in->IsOpen()) {
3718 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3723 TTree *seedTree=(TTree*)in->Get("Seeds");
3725 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3726 cerr<<"can't get a tree with track seeds !\n";
3729 AliTPCtrack *seed=new AliTPCtrack;
3730 seedTree->SetBranchAddress("tracks",&seed);
3732 if (fSeeds==0) fSeeds=new TObjArray(15000);
3734 Int_t n=(Int_t)seedTree->GetEntries();
3735 for (Int_t i=0; i<n; i++) {
3736 seedTree->GetEvent(i);
3737 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3746 //_____________________________________________________________________________
3747 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3748 //-----------------------------------------------------------------
3749 // This is a track finder.
3750 //-----------------------------------------------------------------
3751 TDirectory *savedir=gDirectory;
3754 if (!fInput) SetIO(); //set default IO using loaders
3756 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
3762 fSeeds = Tracking();
3765 printf("Time for tracking: \t");timer.Print();timer.Start();
3767 //activate again some tracks
3768 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3769 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3771 Int_t nc=t.GetNumberOfClusters();
3773 delete fSeeds->RemoveAt(i);
3776 if (pt->fRemoval==10) {
3777 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3778 pt->Desactivate(10); // make track again active
3780 pt->Desactivate(20);
3781 delete fSeeds->RemoveAt(i);
3785 RemoveDouble(fSeeds,0.2,0.6,11);
3786 //RemoveUsed(fSeeds,0.9,0.9,6);
3787 //RemoveUsed(fSeeds,0.8,0.8,6);
3788 //RemoveUsed(fSeeds,0.7,0.7,6);
3789 RemoveUsed(fSeeds,0.5,0.5,6);
3792 Int_t nseed=fSeeds->GetEntriesFast();
3794 for (Int_t i=0; i<nseed; i++) {
3795 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3797 Int_t nc=t.GetNumberOfClusters();
3799 delete fSeeds->RemoveAt(i);
3802 CookLabel(pt,0.1); //For comparison only
3803 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3804 if ((pt->IsActive() || (pt->fRemoval==10) )){
3805 cerr<<found++<<'\r';
3808 delete fSeeds->RemoveAt(i);
3813 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3815 //RemoveUsed(fSeeds,0.9,0.9,6);
3817 nseed=fSeeds->GetEntriesFast();
3819 for (Int_t i=0; i<nseed; i++) {
3820 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3822 Int_t nc=t.GetNumberOfClusters();
3824 delete fSeeds->RemoveAt(i);
3828 t.CookdEdx(0.02,0.6);
3829 // CheckKinkPoint(&t,0.05);
3830 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3831 if ((pt->IsActive() || (pt->fRemoval==10) )){
3832 cerr<<found++<<'\r';
3835 delete fSeeds->RemoveAt(i);
3839 SortTracks(fSeeds, 1);
3843 PrepareForBackProlongation(fSeeds,0.5);
3844 PropagateBack(fSeeds);
3845 printf("Time for back propagation: \t");timer.Print();timer.Start();
3849 PrepareForProlongation(fSeeds,1.);
3852 fSectors = fOuterSec;
3853 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3854 fSectors = fInnerSec;
3855 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3856 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
3857 // RemoveUsed(fSeeds,0.7,0.7,6);
3858 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
3860 nseed=fSeeds->GetEntriesFast();
3862 for (Int_t i=0; i<nseed; i++) {
3863 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3865 Int_t nc=t.GetNumberOfClusters();
3867 delete fSeeds->RemoveAt(i);
3870 t.CookdEdx(0.02,0.6);
3871 // CookLabel(pt,0.1); //For comparison only
3872 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3873 if ((pt->IsActive() || (pt->fRemoval==10) )){
3874 cerr<<found++<<'\r';
3877 delete fSeeds->RemoveAt(i);
3882 // fNTracks = found;
3883 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
3888 if (!fNewIO) fOutput->Write();
3890 AliRunLoader::GetDetectorLoader("TPC",AliConfig::fgkDefaultEventFolderName)->WriteTracks("OVERWRITE");
3893 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
3895 //if (seedtree) delete seedtree;
3896 // UnloadClusters();
3897 //printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
3902 void AliTPCtrackerMI::Tracking(TObjArray * arr)
3905 // tracking of the seeds
3908 fSectors = fOuterSec;
3909 ParallelTracking(arr,150,63);
3910 fSectors = fOuterSec;
3911 ParallelTracking(arr,63,0);
3914 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
3919 TObjArray * arr = new TObjArray;
3921 fSectors = fOuterSec;
3924 for (Int_t sec=0;sec<fkNOS;sec++){
3925 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
3926 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
3927 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
3930 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
3942 TObjArray * AliTPCtrackerMI::Tracking()
3948 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
3950 TObjArray * seeds = new TObjArray;
3959 Float_t fnumber = 3.0;
3960 Float_t fdensity = 3.0;
3965 for (Int_t delta = 0; delta<18; delta+=6){
3969 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
3970 SumTracks(seeds,arr);
3971 SignClusters(seeds,fnumber,fdensity);
3973 for (Int_t i=2;i<6;i+=2){
3974 // seed high pt tracks
3977 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
3978 SumTracks(seeds,arr);
3979 SignClusters(seeds,fnumber,fdensity);
3984 // RemoveUsed(seeds,0.9,0.9,1);
3985 // UnsignClusters();
3986 // SignClusters(seeds,fnumber,fdensity);
3990 for (Int_t delta = 20; delta<120; delta+=10){
3992 // seed high pt tracks
3996 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
3997 SumTracks(seeds,arr);
3998 SignClusters(seeds,fnumber,fdensity);
4003 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4004 SumTracks(seeds,arr);
4005 SignClusters(seeds,fnumber,fdensity);
4016 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
4020 // RemoveUsed(seeds,0.75,0.75,1);
4022 //SignClusters(seeds,fnumber,fdensity);
4031 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4032 SumTracks(seeds,arr);
4033 SignClusters(seeds,fnumber,fdensity);
4035 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4036 SumTracks(seeds,arr);
4037 SignClusters(seeds,fnumber,fdensity);
4039 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4040 SumTracks(seeds,arr);
4041 SignClusters(seeds,fnumber,fdensity);
4045 for (Int_t delta = 3; delta<30; delta+=5){
4051 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4052 SumTracks(seeds,arr);
4053 SignClusters(seeds,fnumber,fdensity);
4055 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4056 SumTracks(seeds,arr);
4057 SignClusters(seeds,fnumber,fdensity);
4069 for (Int_t delta = 30; delta<70; delta+=10){
4075 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4076 SumTracks(seeds,arr);
4077 SignClusters(seeds,fnumber,fdensity);
4079 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4080 SumTracks(seeds,arr);
4081 SignClusters(seeds,fnumber,fdensity);
4085 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4096 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2)
4099 //sum tracks to common container
4100 //remove suspicious tracks
4101 Int_t nseed = arr2->GetEntriesFast();
4102 for (Int_t i=0;i<nseed;i++){
4103 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4106 // NORMAL ACTIVE TRACK
4107 if (pt->IsActive()){
4108 arr1->AddLast(arr2->RemoveAt(i));
4111 //remove not usable tracks
4112 if (pt->fRemoval!=10){
4113 delete arr2->RemoveAt(i);
4116 // REMOVE VERY SHORT TRACKS
4117 if (pt->GetNumberOfClusters()<20){
4118 delete arr2->RemoveAt(i);
4121 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4122 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4123 arr1->AddLast(arr2->RemoveAt(i));
4125 delete arr2->RemoveAt(i);
4134 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4137 // try to track in parralel
4139 Int_t nseed=arr->GetEntriesFast();
4140 //prepare seeds for tracking
4141 for (Int_t i=0; i<nseed; i++) {
4142 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4144 if (!t.IsActive()) continue;
4145 // follow prolongation to the first layer
4146 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4147 FollowProlongation(t, rfirst+1);
4152 for (Int_t nr=rfirst; nr>=rlast; nr--){
4153 // make indexes with the cluster tracks for given
4155 // find nearest cluster
4156 for (Int_t i=0; i<nseed; i++) {
4157 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4159 if (!pt->IsActive()) continue;
4160 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4161 if (pt->fRelativeSector>17) {
4164 UpdateClusters(t,nr);
4166 // prolonagate to the nearest cluster - if founded
4167 for (Int_t i=0; i<nseed; i++) {
4168 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4170 if (!pt->IsActive()) continue;
4171 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4172 if (pt->fRelativeSector>17) {
4175 FollowToNextCluster(*pt,nr);
4180 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac)
4184 // if we use TPC track itself we have to "update" covariance
4186 Int_t nseed= arr->GetEntriesFast();
4187 for (Int_t i=0;i<nseed;i++){
4188 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4192 //rotate to current local system at first accepted point
4193 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4194 Int_t sec = (index&0xff000000)>>24;
4196 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4197 if (angle1>TMath::Pi())
4198 angle1-=2.*TMath::Pi();
4199 Float_t angle2 = pt->GetAlpha();
4201 if (TMath::Abs(angle1-angle2)>0.001){
4202 pt->Rotate(angle1-angle2);
4203 //angle2 = pt->GetAlpha();
4204 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4205 //if (pt->GetAlpha()<0)
4206 // pt->fRelativeSector+=18;
4207 //sec = pt->fRelativeSector;
4216 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac)
4220 // if we use TPC track itself we have to "update" covariance
4222 Int_t nseed= arr->GetEntriesFast();
4223 for (Int_t i=0;i<nseed;i++){
4224 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4227 pt->fFirstPoint = pt->fLastPoint;
4235 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4238 // make back propagation
4240 Int_t nseed= arr->GetEntriesFast();
4241 for (Int_t i=0;i<nseed;i++){
4242 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4244 AliTPCseed *pt2 = new AliTPCseed(*pt);
4245 fSectors = fInnerSec;
4246 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4247 fSectors = fOuterSec;
4248 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4249 fSectors = fOuterSec;
4250 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4251 printf("\n%d",pt->GetLabel());
4252 fSectors = fInnerSec;
4253 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4254 fSectors = fOuterSec;
4255 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4256 fSectors = fOuterSec;
4264 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4267 // make forward propagation
4269 Int_t nseed= arr->GetEntriesFast();
4270 for (Int_t i=0;i<nseed;i++){
4271 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4273 AliTPCseed *pt2 = new AliTPCseed(*pt);
4274 fSectors = fOuterSec;
4275 FollowProlongation(*pt,0);
4276 fSectors = fOuterSec;
4277 FollowProlongation(*pt,0);
4278 fSectors = fInnerSec;
4279 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4280 printf("\n%d",pt->GetLabel());
4281 fSectors = fOuterSec;
4282 FollowProlongation(*pt2,0);
4283 fSectors = fOuterSec;
4284 FollowProlongation(*pt2,0);
4285 fSectors = fOuterSec;
4293 Int_t AliTPCtrackerMI::PropagateForward()
4296 // propagate track forward
4297 fSectors = fOuterSec;
4298 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4299 fSectors = fInnerSec;
4300 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4310 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4313 // make back propagation, in between row0 and row1
4317 fSectors = fInnerSec;
4320 if (row1<fSectors->GetNRows())
4323 r1 = fSectors->GetNRows()-1;
4325 if (row0<fSectors->GetNRows()&& r1>0 )
4326 FollowBackProlongation(*pt,r1);
4327 if (row1<=fSectors->GetNRows())
4330 r1 = row1 - fSectors->GetNRows();
4331 if (r1<=0) return 0;
4332 if (r1>=fOuterSec->GetNRows()) return 0;
4333 fSectors = fOuterSec;
4334 return FollowBackProlongation(*pt,r1);
4342 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4346 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4347 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4348 Float_t padlength = GetPadPitchLength(row);
4350 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4351 Float_t angulary = seed->GetSnp();
4352 angulary = angulary*angulary/(1-angulary*angulary);
4353 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4355 Float_t sresz = fParam->GetZSigma();
4356 Float_t angularz = seed->GetTgl();
4357 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4359 Float_t wy = GetSigmaY(seed);
4360 Float_t wz = GetSigmaZ(seed);
4363 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4364 printf("problem\n");
4370 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4374 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4375 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4376 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4377 Float_t angular = seed->GetSnp();
4378 angular = angular*angular/(1-angular*angular);
4379 // angular*=angular;
4380 //angular = TMath::Sqrt(angular/(1-angular));
4381 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4384 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4388 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4389 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4390 Float_t sres = fParam->GetZSigma();
4391 Float_t angular = seed->GetTgl();
4392 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4399 //__________________________________________________________________________
4400 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4401 //--------------------------------------------------------------------
4402 //This function "cooks" a track label. If label<0, this track is fake.
4403 //--------------------------------------------------------------------
4404 Int_t noc=t->GetNumberOfClusters();
4406 printf("\nnot founded prolongation\n\n\n");
4412 AliTPCclusterMI *clusters[160];
4414 for (Int_t i=0;i<160;i++) {
4421 for (i=0; i<160 && current<noc; i++) {
4423 Int_t index=t->GetClusterIndex2(i);
4424 if (index<=0) continue;
4425 if (index&0x8000) continue;
4427 //clusters[current]=GetClusterMI(index);
4428 if (t->fClusterPointer[i]){
4429 clusters[current]=t->fClusterPointer[i];
4435 Int_t lab=123456789;
4436 for (i=0; i<noc; i++) {
4437 AliTPCclusterMI *c=clusters[i];
4439 lab=TMath::Abs(c->GetLabel(0));
4441 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4447 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4449 for (i=0; i<noc; i++) {
4450 AliTPCclusterMI *c=clusters[i];
4452 if (TMath::Abs(c->GetLabel(1)) == lab ||
4453 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4456 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4459 Int_t tail=Int_t(0.10*noc);
4462 for (i=1; i<=160&&ind<tail; i++) {
4463 // AliTPCclusterMI *c=clusters[noc-i];
4464 AliTPCclusterMI *c=clusters[i];
4466 if (lab == TMath::Abs(c->GetLabel(0)) ||
4467 lab == TMath::Abs(c->GetLabel(1)) ||
4468 lab == TMath::Abs(c->GetLabel(2))) max++;
4471 if (max < Int_t(0.5*tail)) lab=-lab;
4478 //delete[] clusters;
4481 //_________________________________________________________________________
4482 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4483 //-----------------------------------------------------------------------
4484 // Setup inner sector
4485 //-----------------------------------------------------------------------
4487 fAlpha=par->GetInnerAngle();
4488 fAlphaShift=par->GetInnerAngleShift();
4489 fPadPitchWidth=par->GetInnerPadPitchWidth();
4490 fPadPitchLength=par->GetInnerPadPitchLength();
4491 fN=par->GetNRowLow();
4492 fRow=new AliTPCRow[fN];
4493 for (Int_t i=0; i<fN; i++) {
4494 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4495 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4498 fAlpha=par->GetOuterAngle();
4499 fAlphaShift=par->GetOuterAngleShift();
4500 fPadPitchWidth = par->GetOuterPadPitchWidth();
4501 fPadPitchLength = par->GetOuter1PadPitchLength();
4502 f1PadPitchLength = par->GetOuter1PadPitchLength();
4503 f2PadPitchLength = par->GetOuter2PadPitchLength();
4505 fN=par->GetNRowUp();
4506 fRow=new AliTPCRow[fN];
4507 for (Int_t i=0; i<fN; i++) {
4508 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4509 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4514 AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
4516 // default constructor
4524 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4531 //_________________________________________________________________________
4533 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4534 //-----------------------------------------------------------------------
4535 // Insert a cluster into this pad row in accordence with its y-coordinate
4536 //-----------------------------------------------------------------------
4537 if (fN==kMaxClusterPerRow) {
4538 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4540 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4541 Int_t i=Find(c->GetZ());
4542 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4543 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4544 fIndex[i]=index; fClusters[i]=c; fN++;
4548 //___________________________________________________________________
4549 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4550 //-----------------------------------------------------------------------
4551 // Return the index of the nearest cluster
4552 //-----------------------------------------------------------------------
4553 if (fN==0) return 0;
4554 if (z <= fClusters[0]->GetZ()) return 0;
4555 if (z > fClusters[fN-1]->GetZ()) return fN;
4556 Int_t b=0, e=fN-1, m=(b+e)/2;
4557 for (; b<e; m=(b+e)/2) {
4558 if (z > fClusters[m]->GetZ()) b=m+1;
4566 //___________________________________________________________________
4567 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4568 //-----------------------------------------------------------------------
4569 // Return the index of the nearest cluster in z y
4570 //-----------------------------------------------------------------------
4571 Float_t maxdistance = roady*roady + roadz*roadz;
4573 AliTPCclusterMI *cl =0;
4574 for (Int_t i=Find(z-roadz); i<fN; i++) {
4575 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4576 if (c->GetZ() > z+roadz) break;
4577 if ( (c->GetY()-y) > roady ) continue;
4578 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4579 if (maxdistance>distance) {
4580 maxdistance = distance;
4587 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4589 //-----------------------------------------------------------------------
4590 // Return the index of the nearest cluster in z y
4591 //-----------------------------------------------------------------------
4592 Float_t maxdistance = roady*roady + roadz*roadz;
4593 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4594 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4596 AliTPCclusterMI *cl =0;
4597 //FindNearest3(y,z,roady,roadz,index);
4598 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4599 for (Int_t i=iz1; i<iz2; i++) {
4600 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4601 if (c->GetZ() > z+roadz) break;
4602 if ( c->GetY()-y > roady ) continue;
4603 if ( y-c->GetY() > roady ) continue;
4604 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4605 if (maxdistance>distance) {
4606 maxdistance = distance;
4609 //roady = TMath::Sqrt(maxdistance);
4617 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4619 //-----------------------------------------------------------------------
4620 // Return the index of the nearest cluster in z y
4621 //-----------------------------------------------------------------------
4622 Float_t maxdistance = roady*roady + roadz*roadz;
4623 // Int_t iz = Int_t(z+255.);
4624 AliTPCclusterMI *cl =0;
4625 for (Int_t i=Find(z-roadz); i<fN; i++) {
4626 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4627 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4628 if (c->GetZ() > z+roadz) break;
4629 if ( c->GetY()-y > roady ) continue;
4630 if ( y-c->GetY() > roady ) continue;
4631 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4632 if (maxdistance>distance) {
4633 maxdistance = distance;
4636 //roady = TMath::Sqrt(maxdistance);
4645 AliTPCseed::AliTPCseed():AliTPCtrack(){
4649 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4650 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4666 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4675 for (Int_t i=0;i<160;i++) {
4676 fClusterPointer[i] = 0;
4677 Int_t index = t.GetClusterIndex(i);
4679 SetClusterIndex2(i,index);
4682 SetClusterIndex2(i,-3);
4694 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4698 for (Int_t i=0;i<160;i++) {
4699 fClusterPointer[i] = 0;
4700 Int_t index = t.GetClusterIndex(i);
4701 SetClusterIndex2(i,index);
4719 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4720 Double_t xr, Double_t alpha):
4721 AliTPCtrack(index, xx, cc, xr, alpha) {
4726 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4727 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4736 // fHelixIn = new TClonesArray("AliHelix",0);
4737 //fHelixOut = new TClonesArray("AliHelix",0);
4746 AliTPCseed::~AliTPCseed(){
4749 if (fPoints) delete fPoints;
4751 if (fEPoints) delete fEPoints;
4756 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4760 return &fTrackPoints[i];
4763 void AliTPCseed::RebuildSeed()
4766 // rebuild seed to be ready for storing
4767 AliTPCclusterMI cldummy;
4769 AliTPCTrackPoint pdummy;
4770 pdummy.GetTPoint().fIsShared = 10;
4771 for (Int_t i=0;i<160;i++){
4772 AliTPCclusterMI * cl0 = fClusterPointer[i];
4773 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
4775 trpoint->GetTPoint() = *(GetTrackPoint(i));
4776 trpoint->GetCPoint() = *cl0;
4777 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4781 trpoint->GetCPoint()= cldummy;
4789 Double_t AliTPCseed::GetDensityFirst(Int_t n)
4793 // return cluster for n rows bellow first point
4794 Int_t nfoundable = 1;
4796 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
4797 Int_t index = GetClusterIndex2(i);
4798 if (index!=-1) nfoundable++;
4799 if (index>0) nfound++;
4801 if (nfoundable<n) return 0;
4802 return Double_t(nfound)/Double_t(nfoundable);
4807 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
4809 // get cluster stat. on given region
4814 for (Int_t i=first;i<last; i++){
4815 Int_t index = GetClusterIndex2(i);
4816 if (index!=-1) foundable++;
4817 if (fClusterPointer[i]) {
4823 if (fClusterPointer[i]->IsUsed(10)) {
4827 if (!plus2) continue; //take also neighborhoud
4829 if ( (i>0) && fClusterPointer[i-1]){
4830 if (fClusterPointer[i-1]->IsUsed(10)) {
4835 if ( fClusterPointer[i+1]){
4836 if (fClusterPointer[i+1]->IsUsed(10)) {
4844 printf("problem\n");
4848 //_____________________________________________________________________________
4849 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
4850 //-----------------------------------------------------------------
4851 // This funtion calculates dE/dX within the "low" and "up" cuts.
4852 //-----------------------------------------------------------------
4855 Float_t angular[200];
4856 Float_t weight[200];
4859 // TClonesArray & arr = *fPoints;
4860 Float_t meanlog = 100.;
4862 Float_t mean[4] = {0,0,0,0};
4863 Float_t sigma[4] = {1000,1000,1000,1000};
4864 Int_t nc[4] = {0,0,0,0};
4865 Float_t norm[4] = {1000,1000,1000,1000};
4870 for (Int_t of =0; of<4; of++){
4871 for (Int_t i=of+i1;i<i2;i+=4)
4873 Int_t index = fIndex[i];
4874 if (index<0||index&0x8000) continue;
4876 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
4877 AliTPCTrackerPoint * point = GetTrackPoint(i);
4878 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
4879 //AliTPCTrackerPoint * pointp = 0;
4880 //if (i<159) pointp = GetTrackPoint(i+1);
4882 if (point==0) continue;
4883 AliTPCclusterMI * cl = fClusterPointer[i];
4884 if (cl==0) continue;
4885 if (onlyused && (!cl->IsUsed(10))) continue;
4886 if (cl->IsUsed(11)) {
4890 Int_t type = cl->GetType();
4891 //if (point->fIsShared){
4896 // if (pointm->fIsShared) continue;
4898 // if (pointp->fIsShared) continue;
4900 if (type<0) continue;
4901 //if (type>10) continue;
4902 //if (point->GetErrY()==0) continue;
4903 //if (point->GetErrZ()==0) continue;
4905 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
4906 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
4907 //if ((ddy*ddy+ddz*ddz)>10) continue;
4910 // if (point->GetCPoint().GetMax()<5) continue;
4911 if (cl->GetMax()<5) continue;
4912 Float_t angley = point->GetAngleY();
4913 Float_t anglez = point->GetAngleZ();
4915 Float_t rsigmay2 = point->GetSigmaY();
4916 Float_t rsigmaz2 = point->GetSigmaZ();
4920 rsigmay += pointm->GetTPoint().GetSigmaY();
4921 rsigmaz += pointm->GetTPoint().GetSigmaZ();
4925 rsigmay += pointp->GetTPoint().GetSigmaY();
4926 rsigmaz += pointp->GetTPoint().GetSigmaZ();
4933 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
4935 Float_t ampc = 0; // normalization to the number of electrons
4937 // ampc = 1.*point->GetCPoint().GetMax();
4938 ampc = 1.*cl->GetMax();
4939 //ampc = 1.*point->GetCPoint().GetQ();
4940 // AliTPCClusterPoint & p = point->GetCPoint();
4941 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
4942 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4944 // TMath::Abs( Int_t(iz) - iz + 0.5);
4945 //ampc *= 1.15*(1-0.3*dy);
4946 //ampc *= 1.15*(1-0.3*dz);
4947 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
4951 //ampc = 1.0*point->GetCPoint().GetMax();
4952 ampc = 1.0*cl->GetMax();
4953 //ampc = 1.0*point->GetCPoint().GetQ();
4954 //AliTPCClusterPoint & p = point->GetCPoint();
4955 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
4956 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4958 // TMath::Abs( Int_t(iz) - iz + 0.5);
4960 //ampc *= 1.15*(1-0.3*dy);
4961 //ampc *= 1.15*(1-0.3*dz);
4962 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
4966 ampc *= 2.0; // put mean value to channel 50
4967 //ampc *= 0.58; // put mean value to channel 50
4969 // if (type>0) w = 1./(type/2.-0.5);
4970 // Float_t z = TMath::Abs(cl->GetZ());
4973 //ampc /= (1+0.0008*z);
4977 //ampc /= (1+0.0008*z);
4979 //ampc /= (1+0.0008*z);
4982 if (type<0) { //amp at the border - lower weight
4987 if (rsigma>1.5) ampc/=1.3; // if big backround
4989 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
4994 TMath::Sort(nc[of],amp,index,kFALSE);
4998 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
5000 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5001 Float_t ampl = amp[index[i]]/angular[index[i]];
5002 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5004 sumw += weight[index[i]];
5005 sumamp += weight[index[i]]*ampl;
5006 sumamp2 += weight[index[i]]*ampl*ampl;
5007 norm[of] += angular[index[i]]*weight[index[i]];
5014 mean[of] = sumamp/sumw;
5015 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5017 sigma[of] = TMath::Sqrt(sigma[of]);
5021 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5022 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5023 //mean *=(1-0.1*(norm-1.));
5030 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
5031 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
5034 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
5035 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
5039 for (Int_t i =0;i<4;i++){
5040 if (nc[i]>2&&nc[i]<1000){
5041 dedx += mean[i] *nc[i];
5042 fSdEdx += sigma[i]*(nc[i]-2);
5043 fMAngular += norm[i] *nc[i];
5048 fSDEDX[i] = sigma[i];
5061 // Float_t dedx1 =dedx;
5064 for (Int_t i =0;i<4;i++){
5065 if (nc[i]>2&&nc[i]<1000){
5066 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5067 dedx += mean[i] *nc[i];
5082 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5085 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5086 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5087 SetMass(0.93827); return;
5091 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5092 SetMass(0.93827); return;
5095 SetMass(0.13957); return;
5105 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5106 //-----------------------------------------------------------------
5107 // This funtion calculates dE/dX within the "low" and "up" cuts.
5108 //-----------------------------------------------------------------
5111 Float_t angular[200];
5112 Float_t weight[200];
5114 Bool_t inlimit[200];
5115 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5116 for (Int_t i=0;i<200;i++) amp[i]=10000;
5117 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5121 Float_t meanlog = 100.;
5122 Int_t indexde[4]={0,64,128,160};
5129 Float_t mean[4] = {0,0,0,0};
5130 Float_t sigma[4] = {1000,1000,1000,1000};
5131 Int_t nc[4] = {0,0,0,0};
5132 Float_t norm[4] = {1000,1000,1000,1000};
5137 // for (Int_t of =0; of<3; of++){
5138 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5139 for (Int_t i =0; i<160;i++)
5141 AliTPCTrackPoint * point = GetTrackPoint(i);
5142 if (point==0) continue;
5143 if (point->fIsShared){
5147 Int_t type = point->GetCPoint().GetType();
5148 if (type<0) continue;
5149 if (point->GetCPoint().GetMax()<5) continue;
5150 Float_t angley = point->GetTPoint().GetAngleY();
5151 Float_t anglez = point->GetTPoint().GetAngleZ();
5152 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5153 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5154 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5156 Float_t ampc = 0; // normalization to the number of electrons
5158 ampc = point->GetCPoint().GetMax();
5161 ampc = point->GetCPoint().GetMax();
5163 ampc *= 2.0; // put mean value to channel 50
5164 // ampc *= 0.565; // put mean value to channel 50
5167 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5174 if (type<0) { //amp at the border - lower weight
5177 if (rsigma>1.5) ampc/=1.3; // if big backround
5178 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5179 amp[i] = ampc/angular[i];
5184 TMath::Sort(159,amp,index,kFALSE);
5185 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5186 inlimit[index[i]] = kTRUE; // take all clusters
5189 // meanlog = amp[index[Int_t(anc*0.3)]];
5191 for (Int_t of =0; of<3; of++){
5195 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5197 if (inlimit[i]==kFALSE) continue;
5198 Float_t ampl = amp[i];
5200 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5203 sumamp += weight[i]*ampl;
5204 sumamp2 += weight[i]*ampl*ampl;
5205 norm[of] += angular[i]*weight[i];
5213 mean[of] = sumamp/sumw;
5214 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5216 sigma[of] = TMath::Sqrt(sigma[of]);
5219 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5229 Float_t www[3] = {12.,14.,17.};
5230 //Float_t www[3] = {1.,1.,1.};
5232 for (Int_t i =0;i<3;i++){
5233 if (nc[i]>2&&nc[i]<1000){
5234 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5235 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5236 fMAngular += norm[i] *nc[i];
5237 norm2 += nc[i]*www[i]/sigma[i];
5238 norm3 += (nc[i]-2)*www[i]/sigma[i];
5241 fSDEDX[i] = sigma[i];
5254 // Float_t dedx1 =dedx;
5258 for (Int_t i =0;i<3;i++){
5259 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5260 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5261 dedx += mean[i] *(nc[i])/(sigma[i]);
5262 norm4 += (nc[i])/(sigma[i]);
5266 if (norm4>0) dedx /= norm4;