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.14 2003/09/29 11:39:43 kowal2
21 Revision 1.13 2003/09/29 11:28:19 kowal2
24 Revision 1.9.4.3 2003/06/23 14:47:10 hristov
27 Revision 1.9.4.2 2003/06/23 10:06:13 hristov
28 Updated information about the overlapping clusters (M.Ivanov)
30 Revision 1.9.4.1 2003/06/19 06:59:58 hristov
31 Updated version of parallel tracking (M.Ivanov)
33 Revision 1.9 2003/03/19 17:14:11 hristov
34 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)
36 Revision 1.8 2003/03/05 11:16:15 kowal2
48 AliTPC parallel tracker -
50 run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
51 run AliTPCFindTracksMI.C macro - to find tracks
52 tracks are written to AliTPCtracks.root file
53 for comparison also seeds are written to the same file - to special branch
56 //-------------------------------------------------------
57 // Implementation of the TPC tracker
59 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
61 //-------------------------------------------------------
62 #include <TObjArray.h>
65 #include "Riostream.h"
67 #include "AliTPCtrackerMI.h"
68 #include "AliTPCclusterMI.h"
69 #include "AliTPCParam.h"
70 #include "AliTPCClustersRow.h"
71 #include "AliComplexCluster.h"
72 #include "AliTPCpolyTrack.h"
73 #include "TStopwatch.h"
78 #include "AliRunLoader.h"
83 ClassImp(AliTPCtrackerMI)
89 static Double_t FastAsin(Double_t x);
91 static Double_t fgFastAsin[20000];
94 Double_t TPCFastMath::fgFastAsin[20000];
96 TPCFastMath::TPCFastMath(){
97 for (Int_t i=0;i<10000;i++){
98 fgFastAsin[2*i] = TMath::ASin(i/10000.);
99 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
103 Double_t TPCFastMath::FastAsin(Double_t x){
105 Int_t index = int(x*10000);
106 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
109 Int_t index = int(x*10000);
110 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
113 TPCFastMath gTPCMath;
117 Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
119 AliTPCclusterMI* c =track->fCurrentCluster;
120 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
122 UInt_t i = track->fCurrentClusterIndex1;
124 Int_t sec=(i&0xff000000)>>24;
125 //Int_t row = (i&0x00ff0000)>>16;
126 track->fRow=(i&0x00ff0000)>>16;
127 track->fSector = sec;
128 // Int_t index = i&0xFFFF;
129 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
130 track->SetClusterIndex2(track->fRow, i);
132 //track->fFirstPoint = row;
133 //if ( track->fLastPoint<row) track->fLastPoint =row;
134 // if (track->fRow<0 || track->fRow>160) {
135 // printf("problem\n");
137 if (track->fFirstPoint>track->fRow)
138 track->fFirstPoint = track->fRow;
139 if (track->fLastPoint<track->fRow)
140 track->fLastPoint = track->fRow;
143 track->fClusterPointer[track->fRow] = c;
146 Float_t angle2 = track->GetSnp()*track->GetSnp();
147 angle2 = TMath::Sqrt(angle2/(1-angle2));
149 //SET NEW Track Point
153 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
155 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
156 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
157 point.SetErrY(sqrt(track->fErrorY2));
158 point.SetErrZ(sqrt(track->fErrorZ2));
160 point.SetX(track->GetX());
161 point.SetY(track->GetY());
162 point.SetZ(track->GetZ());
163 point.SetAngleY(angle2);
164 point.SetAngleZ(track->GetTgl());
165 if (point.fIsShared){
166 track->fErrorY2 *= 4;
167 track->fErrorZ2 *= 4;
171 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
173 track->fErrorY2 *= 1.3;
174 track->fErrorY2 += 0.01;
175 track->fErrorZ2 *= 1.3;
176 track->fErrorZ2 += 0.005;
178 if (accept>0) return 0;
179 if (track->GetNumberOfClusters()%20==0){
180 // if (track->fHelixIn){
181 // TClonesArray & larr = *(track->fHelixIn);
182 // Int_t ihelix = larr.GetEntriesFast();
183 // new(larr[ihelix]) AliHelix(*track) ;
186 track->fNoCluster =0;
187 return track->Update(c,chi2,i);
192 Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
193 Float_t cory, Float_t corz)
196 // decide according desired precision to accept given
197 // cluster for tracking
198 Double_t sy2=ErrY2(seed,cluster)*cory;
199 Double_t sz2=ErrZ2(seed,cluster)*corz;
200 //sy2=ErrY2(seed,cluster)*cory;
201 //sz2=ErrZ2(seed,cluster)*cory;
203 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
204 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
206 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
207 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
208 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
209 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
211 Double_t rdistance2 = rdistancey2+rdistancez2;
214 if (rdistance2>16) return 3;
217 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
218 return 2; //suspisiouce - will be changed
220 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
221 // strict cut on overlaped cluster
222 return 2; //suspisiouce - will be changed
224 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
225 && cluster->GetType()<0){
235 //_____________________________________________________________________________
236 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
237 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
239 //---------------------------------------------------------------------
240 // The main TPC tracker constructor
241 //---------------------------------------------------------------------
242 fInnerSec=new AliTPCSector[fkNIS];
243 fOuterSec=new AliTPCSector[fkNOS];
246 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
247 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
254 Int_t nrowlow = par->GetNRowLow();
255 Int_t nrowup = par->GetNRowUp();
258 for (Int_t i=0;i<nrowlow;i++){
259 fXRow[i] = par->GetPadRowRadiiLow(i);
260 fPadLength[i]= par->GetPadPitchLength(0,i);
261 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
265 for (Int_t i=0;i<nrowup;i++){
266 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
267 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
268 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
281 //_____________________________________________________________________________
282 AliTPCtrackerMI::~AliTPCtrackerMI() {
283 //------------------------------------------------------------------
284 // TPC tracker destructor
285 //------------------------------------------------------------------
294 void AliTPCtrackerMI::SetIO()
298 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::fgkDefaultEventFolderName);
299 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::fgkDefaultEventFolderName);
300 AliTPCtrack *iotrack= new AliTPCtrack;
301 // iotrack->fHelixIn = new TClonesArray("AliHelix");
302 //iotrack->fHelixOut = new TClonesArray("AliHelix");
303 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
307 void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
323 AliTPCtrack *iotrack= new AliTPCtrack;
324 // iotrack->fHelixIn = new TClonesArray("AliHelix");
325 //iotrack->fHelixOut = new TClonesArray("AliHelix");
326 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
329 if (output && (fDebug&2)){
330 //write the full seed information if specified in debug mode
332 fSeedTree = new TTree("Seeds","Seeds");
333 AliTPCseed * vseed = new AliTPCseed;
335 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
336 arrtr->ExpandCreateFast(160);
337 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
339 vseed->fPoints = arrtr;
340 vseed->fEPoints = arre;
341 // vseed->fClusterPoints = arrcl;
342 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
345 fTreeDebug = new TTree("trackDebug","trackDebug");
346 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
347 fTreeDebug->Branch("debug",&arrd,32000,99);
355 void AliTPCtrackerMI::WriteTracks()
358 // write tracks to the given output tree -
359 // output specified with SetIO routine
362 // write tracks to the event
363 // store index of the track
364 Int_t nseed=fSeeds->GetEntriesFast();
365 for (Int_t i=0; i<nseed; i++) {
366 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
369 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
370 //iotrack.SetTPCindex(i);
371 fEvent->AddTrack(&iotrack);
377 AliTPCtrack *iotrack= 0;
378 Int_t nseed=fSeeds->GetEntriesFast();
379 for (Int_t i=0; i<nseed; i++) {
380 iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
384 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
385 TBranch * br = fOutput->GetBranch("tracks");
386 br->SetAddress(&iotrack);
388 for (Int_t i=0; i<nseed; i++) {
389 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
393 // br->SetAddress(&iotrack);
401 //write the full seed information if specified in debug mode
403 AliTPCseed * vseed = new AliTPCseed;
405 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
406 arrtr->ExpandCreateFast(160);
407 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
408 //arrcl->ExpandCreateFast(160);
409 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
411 vseed->fPoints = arrtr;
412 vseed->fEPoints = arre;
413 // vseed->fClusterPoints = arrcl;
414 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
415 TBranch * brseed = fSeedTree->GetBranch("seeds");
417 Int_t nseed=fSeeds->GetEntriesFast();
419 for (Int_t i=0; i<nseed; i++) {
420 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
423 // pt->fClusterPoints = arrcl;
427 brseed->SetAddress(&vseed);
431 // pt->fClusterPoints = 0;
434 if (fTreeDebug) fTreeDebug->Write();
442 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
445 //seed->SetErrorY2(0.1);
447 //calculate look-up table at the beginning
448 static Bool_t ginit = kFALSE;
449 static Float_t gnoise1,gnoise2,gnoise3;
450 static Float_t ggg1[10000];
451 static Float_t ggg2[10000];
452 static Float_t ggg3[10000];
453 static Float_t glandau1[10000];
454 static Float_t glandau2[10000];
455 static Float_t glandau3[10000];
457 static Float_t gcor01[500];
458 static Float_t gcor02[500];
459 static Float_t gcorp[500];
464 for (Int_t i=1;i<500;i++){
465 Float_t rsigma = float(i)/100.;
466 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
467 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
468 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
472 for (Int_t i=3;i<10000;i++){
476 Float_t amp = float(i);
477 Float_t padlength =0.75;
478 gnoise1 = 0.0004/padlength;
479 Float_t nel = 0.268*amp;
480 Float_t nprim = 0.155*amp;
481 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
482 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
483 if (glandau1[i]>1) glandau1[i]=1;
484 glandau1[i]*=padlength*padlength/12.;
488 gnoise2 = 0.0004/padlength;
491 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
492 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
493 if (glandau2[i]>1) glandau2[i]=1;
494 glandau2[i]*=padlength*padlength/12.;
499 gnoise3 = 0.0004/padlength;
502 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
503 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
504 if (glandau3[i]>1) glandau3[i]=1;
505 glandau3[i]*=padlength*padlength/12.;
513 Int_t amp = int(TMath::Abs(cl->GetQ()));
515 seed->SetErrorY2(1.);
519 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
520 Int_t ctype = cl->GetType();
521 Float_t padlength= GetPadPitchLength(seed->fRow);
522 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
523 angle2 = angle2/(1-angle2);
526 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
529 if (fSectors==fInnerSec){
531 res = ggg1[amp]*z+glandau1[amp]*angle2;
532 if (ctype==0) res *= gcor01[rsigmay];
535 res*= gcorp[rsigmay];
541 res = ggg2[amp]*z+glandau2[amp]*angle2;
542 if (ctype==0) res *= gcor02[rsigmay];
545 res*= gcorp[rsigmay];
550 res = ggg3[amp]*z+glandau3[amp]*angle2;
551 if (ctype==0) res *= gcor02[rsigmay];
554 res*= gcorp[rsigmay];
561 res*=2.4; // overestimate error 2 times
568 seed->SetErrorY2(res);
576 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
579 //seed->SetErrorY2(0.1);
581 //calculate look-up table at the beginning
582 static Bool_t ginit = kFALSE;
583 static Float_t gnoise1,gnoise2,gnoise3;
584 static Float_t ggg1[10000];
585 static Float_t ggg2[10000];
586 static Float_t ggg3[10000];
587 static Float_t glandau1[10000];
588 static Float_t glandau2[10000];
589 static Float_t glandau3[10000];
591 static Float_t gcor01[1000];
592 static Float_t gcor02[1000];
593 static Float_t gcorp[1000];
598 for (Int_t i=1;i<1000;i++){
599 Float_t rsigma = float(i)/100.;
600 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
601 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
602 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
606 for (Int_t i=3;i<10000;i++){
610 Float_t amp = float(i);
611 Float_t padlength =0.75;
612 gnoise1 = 0.0004/padlength;
613 Float_t nel = 0.268*amp;
614 Float_t nprim = 0.155*amp;
615 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
616 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
617 if (glandau1[i]>1) glandau1[i]=1;
618 glandau1[i]*=padlength*padlength/12.;
622 gnoise2 = 0.0004/padlength;
625 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
626 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
627 if (glandau2[i]>1) glandau2[i]=1;
628 glandau2[i]*=padlength*padlength/12.;
633 gnoise3 = 0.0004/padlength;
636 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
637 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
638 if (glandau3[i]>1) glandau3[i]=1;
639 glandau3[i]*=padlength*padlength/12.;
647 Int_t amp = int(TMath::Abs(cl->GetQ()));
649 seed->SetErrorY2(1.);
653 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
654 Int_t ctype = cl->GetType();
655 Float_t padlength= GetPadPitchLength(seed->fRow);
657 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
658 // if (angle2<0.6) angle2 = 0.6;
659 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
662 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
665 if (fSectors==fInnerSec){
667 res = ggg1[amp]*z+glandau1[amp]*angle2;
668 if (ctype==0) res *= gcor01[rsigmaz];
671 res*= gcorp[rsigmaz];
677 res = ggg2[amp]*z+glandau2[amp]*angle2;
678 if (ctype==0) res *= gcor02[rsigmaz];
681 res*= gcorp[rsigmaz];
686 res = ggg3[amp]*z+glandau3[amp]*angle2;
687 if (ctype==0) res *= gcor02[rsigmaz];
690 res*= gcorp[rsigmaz];
699 if ((ctype<0) &&<70){
707 seed->SetErrorZ2(res);
714 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
717 //seed->SetErrorZ2(0.1);
721 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
723 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
724 Int_t ctype = cl->GetType();
725 Float_t amp = TMath::Abs(cl->GetQ());
730 Float_t landau=2 ; //landau fluctuation part
731 Float_t gg=2; // gg fluctuation part
732 Float_t padlength= GetPadPitchLength(seed->GetX());
734 if (fSectors==fInnerSec){
735 snoise2 = 0.0004/padlength;
738 gg = (2+0.001*nel/(padlength*padlength))/nel;
739 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
740 if (landau>1) landau=1;
743 snoise2 = 0.0004/padlength;
746 gg = (2+0.0008*nel/(padlength*padlength))/nel;
747 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
748 if (landau>1) landau=1;
750 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
753 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
754 angle2 = TMath::Sqrt((1-angle2));
755 if (angle2<0.6) angle2 = 0.6;
758 Float_t angle = seed->GetTgl()/angle2;
759 Float_t angular = landau*angle*angle*padlength*padlength/12.;
760 Float_t res = sdiff + angular;
763 if ((ctype==0) && (fSectors ==fOuterSec))
764 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
766 if ((ctype==0) && (fSectors ==fInnerSec))
767 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
771 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
777 if ((ctype<0) &&<70){
785 seed->SetErrorZ2(res);
792 void AliTPCseed::Reset(Bool_t all)
796 SetNumberOfClusters(0);
802 for (Int_t i=0;i<8;i++){
803 delete [] fTrackPoints[i];
811 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
812 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
818 void AliTPCseed::Modify(Double_t factor)
821 //------------------------------------------------------------------
822 //This function makes a track forget its history :)
823 //------------------------------------------------------------------
829 fC10*=factor; fC11*=factor;
830 fC20*=factor; fC21*=factor; fC22*=factor;
831 fC30*=factor; fC31*=factor; fC32*=factor; fC33*=factor;
832 fC40*=factor; fC41*=factor; fC42*=factor; fC43*=factor; fC44*=factor;
833 SetNumberOfClusters(0);
837 fCurrentSigmaY2 = 0.000005;
838 fCurrentSigmaZ2 = 0.000005;
847 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
849 //-----------------------------------------------------------------
850 // This function find proloncation of a track to a reference plane x=xk.
851 // doesn't change internal state of the track
852 //-----------------------------------------------------------------
854 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
856 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
860 // Double_t y1=fP0, z1=fP1;
861 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
862 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
866 //y += dx*(c1+c2)/(r1+r2);
867 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
869 Double_t dy = dx*(c1+c2)/(r1+r2);
872 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
874 if (TMath::Abs(delta)>0.0001){
875 dz = fP3*TMath::ASin(delta)/fP4;
877 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
880 dz = fP3*TPCFastMath::FastAsin(delta)/fP4;
890 //_____________________________________________________________________________
891 Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
893 //-----------------------------------------------------------------
894 // This function calculates a predicted chi2 increment.
895 //-----------------------------------------------------------------
896 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
897 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
898 r00+=fC00; r01+=fC10; r11+=fC11;
900 Double_t det=r00*r11 - r01*r01;
901 if (TMath::Abs(det) < 1.e-10) {
902 Int_t n=GetNumberOfClusters();
903 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
906 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
908 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
910 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
914 //_________________________________________________________________________________________
917 Int_t AliTPCseed::Compare(const TObject *o) const {
918 //-----------------------------------------------------------------
919 // This function compares tracks according to the sector - for given sector according z
920 //-----------------------------------------------------------------
921 AliTPCseed *t=(AliTPCseed*)o;
924 if (t->fRelativeSector>fRelativeSector) return -1;
925 if (t->fRelativeSector<fRelativeSector) return 1;
926 Double_t z2 = t->GetZ();
927 Double_t z1 = GetZ();
929 if (z2<z1) return -1;
934 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
935 if (t->fBConstrain) f2=1.2;
938 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
940 if (fBConstrain) f1=1.2;
942 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
947 void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
949 //rotate to track "local coordinata
950 Float_t x = seed->GetX();
951 Float_t y = seed->GetY();
952 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
955 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
956 if (!seed->Rotate(fSectors->GetAlpha()))
958 } else if (y <-ymax) {
959 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
960 if (!seed->Rotate(-fSectors->GetAlpha()))
969 //_____________________________________________________________________________
970 Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t index) {
971 //-----------------------------------------------------------------
972 // This function associates a cluster with this track.
973 //-----------------------------------------------------------------
974 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
976 r00+=fC00; r01+=fC10; r11+=fC11;
977 Double_t det=r00*r11 - r01*r01;
978 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
980 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
981 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
982 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
983 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
984 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
986 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
987 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
988 if (TMath::Abs(cur*fX-eta) >= 0.9) {
992 fP0 += k00*dy + k01*dz;
993 fP1 += k10*dy + k11*dz;
995 fP3 += k30*dy + k31*dz;
998 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
999 Double_t c12=fC21, c13=fC31, c14=fC41;
1001 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1002 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1003 fC40-=k00*c04+k01*c14;
1005 fC11-=k10*c01+k11*fC11;
1006 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1007 fC41-=k10*c04+k11*c14;
1009 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1010 fC42-=k20*c04+k21*c14;
1012 fC33-=k30*c03+k31*c13;
1013 fC43-=k40*c03+k41*c13;
1015 fC44-=k40*c04+k41*c14;
1017 Int_t n=GetNumberOfClusters();
1019 SetNumberOfClusters(n+1);
1020 SetChi2(GetChi2()+chisq);
1027 //_____________________________________________________________________________
1028 Double_t AliTPCtrackerMI::f1old(Double_t x1,Double_t y1,
1029 Double_t x2,Double_t y2,
1030 Double_t x3,Double_t y3)
1032 //-----------------------------------------------------------------
1033 // Initial approximation of the track curvature
1034 //-----------------------------------------------------------------
1035 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1036 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1037 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1038 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1039 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1041 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1042 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1043 return -xr*yr/sqrt(xr*xr+yr*yr);
1048 //_____________________________________________________________________________
1049 Double_t AliTPCtrackerMI::f1(Double_t x1,Double_t y1,
1050 Double_t x2,Double_t y2,
1051 Double_t x3,Double_t y3)
1053 //-----------------------------------------------------------------
1054 // Initial approximation of the track curvature
1055 //-----------------------------------------------------------------
1061 Double_t det = x3*y2-x2*y3;
1066 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1067 Double_t x0 = x3*0.5-y3*u;
1068 Double_t y0 = y3*0.5+x3*u;
1069 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1075 Double_t AliTPCtrackerMI::f2(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);
1104 //_____________________________________________________________________________
1105 Double_t AliTPCtrackerMI::f2old(Double_t x1,Double_t y1,
1106 Double_t x2,Double_t y2,
1107 Double_t x3,Double_t y3)
1109 //-----------------------------------------------------------------
1110 // Initial approximation of the track curvature times center of curvature
1111 //-----------------------------------------------------------------
1112 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1113 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1114 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1115 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1116 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1118 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1120 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1123 //_____________________________________________________________________________
1124 Double_t AliTPCtrackerMI::f3(Double_t x1,Double_t y1,
1125 Double_t x2,Double_t y2,
1126 Double_t z1,Double_t z2)
1128 //-----------------------------------------------------------------
1129 // Initial approximation of the tangent of the track dip angle
1130 //-----------------------------------------------------------------
1131 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1135 Double_t AliTPCtrackerMI::f3n(Double_t x1,Double_t y1,
1136 Double_t x2,Double_t y2,
1137 Double_t z1,Double_t z2, Double_t c)
1139 //-----------------------------------------------------------------
1140 // Initial approximation of the tangent of the track dip angle
1141 //-----------------------------------------------------------------
1145 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1147 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1148 if (TMath::Abs(d*c*0.5)>1) return 0;
1149 // Double_t angle2 = TMath::ASin(d*c*0.5);
1150 // Double_t angle2 = TPCFastMath::FastAsin(d*c*0.5);
1151 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): TPCFastMath::FastAsin(d*c*0.5);
1153 angle2 = (z1-z2)*c/(angle2*2.);
1157 Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1158 {//-----------------------------------------------------------------
1159 // This function find proloncation of a track to a reference plane x=x2.
1160 //-----------------------------------------------------------------
1164 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1168 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1169 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1173 Double_t dy = dx*(c1+c2)/(r1+r2);
1176 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1178 if (TMath::Abs(delta)>0.01){
1179 dz = x[3]*TMath::ASin(delta)/x[4];
1181 dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1184 //dz = x[3]*TPCFastMath::FastAsin(delta)/x[4];
1194 Int_t AliTPCtrackerMI::LoadClusters()
1197 // load clusters to the memory
1198 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1199 clrow->SetClass("AliTPCclusterMI");
1201 clrow->GetArray()->ExpandCreateFast(10000);
1203 // TTree * tree = fClustersArray.GetTree();
1205 TTree * tree = fInput;
1206 TBranch * br = tree->GetBranch("Segment");
1207 br->SetAddress(&clrow);
1209 Int_t j=Int_t(tree->GetEntries());
1210 for (Int_t i=0; i<j; i++) {
1214 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1216 AliTPCRow * tpcrow=0;
1219 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1223 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1224 left = (sec-fkNIS*2)/fkNOS;
1227 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1228 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1229 for (Int_t i=0;i<tpcrow->fN1;i++)
1230 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1233 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1234 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1235 for (Int_t i=0;i<tpcrow->fN2;i++)
1236 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1247 void AliTPCtrackerMI::UnloadClusters()
1250 // unload clusters from the memory
1252 Int_t nrows = fOuterSec->GetNRows();
1253 for (Int_t sec = 0;sec<fkNOS;sec++)
1254 for (Int_t row = 0;row<nrows;row++){
1255 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1257 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1258 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1262 nrows = fInnerSec->GetNRows();
1263 for (Int_t sec = 0;sec<fkNIS;sec++)
1264 for (Int_t row = 0;row<nrows;row++){
1265 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1267 if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1268 if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1276 //_____________________________________________________________________________
1277 Int_t AliTPCtrackerMI::LoadOuterSectors() {
1278 //-----------------------------------------------------------------
1279 // This function fills outer TPC sectors with clusters.
1280 //-----------------------------------------------------------------
1281 Int_t nrows = fOuterSec->GetNRows();
1283 for (Int_t sec = 0;sec<fkNOS;sec++)
1284 for (Int_t row = 0;row<nrows;row++){
1285 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1286 Int_t sec2 = sec+2*fkNIS;
1288 Int_t ncl = tpcrow->fN1;
1290 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1291 index=(((sec2<<8)+row)<<16)+ncl;
1292 tpcrow->InsertCluster(c,index);
1297 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1298 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1299 tpcrow->InsertCluster(c,index);
1302 // write indexes for fast acces
1304 for (Int_t i=0;i<510;i++)
1305 tpcrow->fFastCluster[i]=-1;
1306 for (Int_t i=0;i<tpcrow->GetN();i++){
1307 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1308 tpcrow->fFastCluster[zi]=i; // write index
1311 for (Int_t i=0;i<510;i++){
1312 if (tpcrow->fFastCluster[i]<0)
1313 tpcrow->fFastCluster[i] = last;
1315 last = tpcrow->fFastCluster[i];
1324 //_____________________________________________________________________________
1325 Int_t AliTPCtrackerMI::LoadInnerSectors() {
1326 //-----------------------------------------------------------------
1327 // This function fills inner TPC sectors with clusters.
1328 //-----------------------------------------------------------------
1329 Int_t nrows = fInnerSec->GetNRows();
1331 for (Int_t sec = 0;sec<fkNIS;sec++)
1332 for (Int_t row = 0;row<nrows;row++){
1333 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1336 Int_t ncl = tpcrow->fN1;
1338 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1339 index=(((sec<<8)+row)<<16)+ncl;
1340 tpcrow->InsertCluster(c,index);
1345 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1346 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1347 tpcrow->InsertCluster(c,index);
1350 // write indexes for fast acces
1352 for (Int_t i=0;i<510;i++)
1353 tpcrow->fFastCluster[i]=-1;
1354 for (Int_t i=0;i<tpcrow->GetN();i++){
1355 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1356 tpcrow->fFastCluster[zi]=i; // write index
1359 for (Int_t i=0;i<510;i++){
1360 if (tpcrow->fFastCluster[i]<0)
1361 tpcrow->fFastCluster[i] = last;
1363 last = tpcrow->fFastCluster[i];
1375 //_________________________________________________________________________
1376 AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1377 //--------------------------------------------------------------------
1378 // Return pointer to a given cluster
1379 //--------------------------------------------------------------------
1380 Int_t sec=(index&0xff000000)>>24;
1381 Int_t row=(index&0x00ff0000)>>16;
1382 Int_t ncl=(index&0x0000ffff)>>00;
1384 const AliTPCRow * tpcrow=0;
1385 AliTPCclusterMI * clrow =0;
1387 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1389 clrow = tpcrow->fClusters1;
1391 clrow = tpcrow->fClusters2;
1394 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1395 if (sec-2*fkNIS<fkNOS)
1396 clrow = tpcrow->fClusters1;
1398 clrow = tpcrow->fClusters2;
1400 if (tpcrow==0) return 0;
1401 if (tpcrow->GetN()<=ncl) return 0;
1402 // return (AliTPCclusterMI*)(*tpcrow)[ncl];
1403 return &(clrow[ncl]);
1409 Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1410 //-----------------------------------------------------------------
1411 // This function tries to find a track prolongation to next pad row
1412 //-----------------------------------------------------------------
1414 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1416 // if (t.GetRadius()>x+10 ) return 0;
1417 // t.PropagateTo(x+0.02);
1418 //t.PropagateTo(x+0.01);
1419 if (!t.PropagateTo(x)) {
1424 Double_t y=t.GetY(), z=t.GetZ();
1425 if (TMath::Abs(y)>ymax){
1427 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1428 if (!t.Rotate(fSectors->GetAlpha()))
1430 } else if (y <-ymax) {
1431 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1432 if (!t.Rotate(-fSectors->GetAlpha()))
1435 if (!t.PropagateTo(x)) {
1441 // update current shape info every 3 pad-row
1442 if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1443 //t.fCurrentSigmaY = GetSigmaY(&t);
1444 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1448 AliTPCclusterMI *cl=0;
1453 if (t.GetClusterIndex2(nr)>0){
1455 //cl = GetClusterMI(t.GetClusterIndex2(nr));
1456 index = t.GetClusterIndex2(nr);
1457 cl = t.fClusterPointer[nr];
1458 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1459 t.fCurrentClusterIndex1 = index;
1462 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1463 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1465 Double_t roadz = 1.;
1467 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1469 t.SetClusterIndex2(nr,-1);
1474 if (TMath::Abs(z)<(1.05*x+10)) t.fNFoundable++;
1480 t.fCurrentCluster = cl;
1482 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1484 //if founded cluster is acceptible
1485 UpdateTrack(&t,accept);
1491 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1492 cl = krow.FindNearest2(y,z,roady,roadz,index);
1493 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1498 t.fCurrentCluster = cl;
1500 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1502 if (t.fCurrentCluster->IsUsed(10)){
1507 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1513 if (accept<3) UpdateTrack(&t,accept);
1516 if (t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
1522 Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1523 //-----------------------------------------------------------------
1524 // This function tries to find a track prolongation to next pad row
1525 //-----------------------------------------------------------------
1527 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1529 if (!t.GetProlongation(x,y,z)) {
1535 if (TMath::Abs(y)>ymax){
1539 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1540 if (!t.Rotate(fSectors->GetAlpha()))
1542 } else if (y <-ymax) {
1543 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1544 if (!t.Rotate(-fSectors->GetAlpha()))
1547 if (!t.PropagateTo(x)) {
1550 t.GetProlongation(x,y,z);
1553 // update current shape info every 3 pad-row
1554 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1555 // t.fCurrentSigmaY = GetSigmaY(&t);
1556 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1560 AliTPCclusterMI *cl=0;
1565 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1566 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1568 Double_t roadz = 1.;
1571 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1573 t.SetClusterIndex2(row,-1);
1578 if (TMath::Abs(z)>(1.05*x+10)) t.SetClusterIndex2(row,-1);
1582 if ((cl==0)&&(krow)) {
1583 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1584 cl = krow.FindNearest2(y,z,roady,roadz,index);
1586 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1590 t.fCurrentCluster = cl;
1591 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1593 t.SetClusterIndex2(row,index);
1594 t.fClusterPointer[row] = cl;
1602 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1603 //-----------------------------------------------------------------
1604 // This function tries to find a track prolongation to next pad row
1605 //-----------------------------------------------------------------
1606 t.fCurrentCluster = 0;
1607 t.fCurrentClusterIndex1 = 0;
1609 Double_t xt=t.GetX();
1610 Int_t row = GetRowNumber(xt)-1;
1611 Double_t ymax= GetMaxY(nr);
1613 if (row < nr) return 1; // don't prolongate if not information until now -
1614 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1616 return 0; // not prolongate strongly inclined tracks
1618 if (TMath::Abs(t.GetSnp())>0.95) {
1620 return 0; // not prolongate strongly inclined tracks
1623 Double_t x= GetXrow(nr);
1625 //t.PropagateTo(x+0.02);
1626 //t.PropagateTo(x+0.01);
1627 if (!t.PropagateTo(x)){
1634 if (TMath::Abs(y)>ymax){
1636 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1637 if (!t.Rotate(fSectors->GetAlpha()))
1639 } else if (y <-ymax) {
1640 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1641 if (!t.Rotate(-fSectors->GetAlpha()))
1644 if (!t.PropagateTo(x)){
1651 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1653 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1655 t.SetClusterIndex2(nr,-1);
1660 if (TMath::Abs(t.GetZ())<(1.05*t.GetX()+10)) t.fNFoundable++;
1666 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1667 // t.fCurrentSigmaY = GetSigmaY(&t);
1668 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1672 AliTPCclusterMI *cl=0;
1675 Double_t roady = 1.;
1676 Double_t roadz = 1.;
1679 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1680 cl = krow.FindNearest2(y,z,roady,roadz,index);
1682 t.fCurrentCluster = cl;
1683 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1688 Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1689 //-----------------------------------------------------------------
1690 // This function tries to find a track prolongation to next pad row
1691 //-----------------------------------------------------------------
1693 //update error according neighborhoud
1695 if (t.fCurrentCluster) {
1697 Bool_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1699 if (t.fCurrentCluster->IsUsed(10)){
1705 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1711 if (accept<3) UpdateTrack(&t,accept);
1715 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1716 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1718 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1726 //_____________________________________________________________________________
1727 Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1728 //-----------------------------------------------------------------
1729 // This function tries to find a track prolongation.
1730 //-----------------------------------------------------------------
1731 Double_t xt=t.GetX();
1733 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1734 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1735 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1737 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1739 Int_t first = GetRowNumber(xt)-1;
1740 for (Int_t nr= first; nr>=rf; nr-=step) {
1741 if (FollowToNext(t,nr)==0)
1742 if (!t.IsActive()) return 0;
1749 //_____________________________________________________________________________
1750 Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1751 //-----------------------------------------------------------------
1752 // This function tries to find a track prolongation.
1753 //-----------------------------------------------------------------
1754 Double_t xt=t.GetX();
1756 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1757 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1758 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1759 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1761 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1763 if (FollowToNextFast(t,nr)==0)
1764 if (!t.IsActive()) return 0;
1774 Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1775 //-----------------------------------------------------------------
1776 // This function tries to find a track prolongation.
1777 //-----------------------------------------------------------------
1778 // Double_t xt=t.GetX();
1780 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1781 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1782 if (alpha < 0. ) alpha += 2.*TMath::Pi();
1783 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1786 first = t.fFirstPoint+3;
1788 if (first<0) first=0;
1789 for (Int_t nr=first+1; nr<=rf; nr++) {
1790 //if ( (t.GetSnp()<0.9))
1800 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1808 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1811 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1813 Float_t distance = TMath::Sqrt(dz2+dy2);
1814 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1817 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1818 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
1823 if (firstpoint>lastpoint) {
1824 firstpoint =lastpoint;
1829 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1830 if (s1->GetClusterIndex2(i)>0) sum1++;
1831 if (s2->GetClusterIndex2(i)>0) sum2++;
1832 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1836 if (sum<5) return 0;
1838 Float_t summin = TMath::Min(sum1+1,sum2+1);
1839 Float_t ratio = (sum+1)/Float_t(summin);
1843 void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1847 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1848 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1850 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1852 Float_t dy2 =(s1->GetY() - s2->GetY());
1854 Float_t distance = dz2+dy2;
1855 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1860 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1861 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1863 if (firstpoint>=lastpoint-5) return;;
1865 for (Int_t i=firstpoint;i<lastpoint;i++){
1866 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1867 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1874 for (Int_t i=firstpoint;i<lastpoint;i++){
1875 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1876 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1877 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1878 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1879 if (s1->IsActive()&&s2->IsActive()){
1880 p1->fIsShared = kTRUE;
1881 p2->fIsShared = kTRUE;
1888 for (Int_t i=0;i<4;i++){
1889 if (s1->fOverlapLabels[3*i]==0){
1890 s1->fOverlapLabels[3*i] = s2->GetLabel();
1891 s1->fOverlapLabels[3*i+1] = sumshared;
1892 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1896 for (Int_t i=0;i<4;i++){
1897 if (s2->fOverlapLabels[3*i]==0){
1898 s2->fOverlapLabels[3*i] = s1->GetLabel();
1899 s2->fOverlapLabels[3*i+1] = sumshared;
1900 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1908 void AliTPCtrackerMI::SignShared(TObjArray * arr)
1911 //sort trackss according sectors
1913 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1914 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1916 //if (pt) RotateToLocal(pt);
1920 arr->Sort(); // sorting according z
1921 arr->Expand(arr->GetEntries());
1924 Int_t nseed=arr->GetEntriesFast();
1925 for (Int_t i=0; i<nseed; i++) {
1926 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1928 for (Int_t j=0;j<=12;j++){
1929 pt->fOverlapLabels[j] =0;
1932 for (Int_t i=0; i<nseed; i++) {
1933 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1935 if (pt->fRemoval>10) continue;
1936 for (Int_t j=i+1; j<nseed; j++){
1937 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1939 if (pt2->fRemoval<=10) {
1940 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1947 void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1950 //sort trackss according sectors
1953 printf("Number of tracks before double removal- %d\n",arr->GetEntries());
1956 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1957 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1962 arr->Sort(); // sorting according z
1963 arr->Expand(arr->GetEntries());
1965 //reset overlap labels
1967 Int_t nseed=arr->GetEntriesFast();
1968 for (Int_t i=0; i<nseed; i++) {
1969 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1972 for (Int_t j=0;j<=12;j++){
1973 pt->fOverlapLabels[j] =0;
1977 //sign shared tracks
1978 for (Int_t i=0; i<nseed; i++) {
1979 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1981 if (pt->fRemoval>10) continue;
1982 Float_t deltac = pt->GetC()*0.1;
1983 for (Int_t j=i+1; j<nseed; j++){
1984 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
1986 if (pt2->fRemoval<=10) {
1987 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1988 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
1989 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
1996 // remove highly shared tracks
1997 for (Int_t i=0; i<nseed; i++) {
1998 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2000 if (pt->fRemoval>10) continue;
2003 for (Int_t j=0;j<4;j++){
2004 sumshared = pt->fOverlapLabels[j*3+1];
2006 Float_t factor = factor1;
2007 if (pt->fRemoval>0) factor = factor2;
2008 if (sumshared/pt->GetNumberOfClusters()>factor){
2009 for (Int_t j=0;j<4;j++){
2010 if (pt->fOverlapLabels[3*j]==0) continue;
2011 if (pt->fOverlapLabels[3*j+1]<5) continue;
2012 if (pt->fRemoval==removalindex) continue;
2013 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2015 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2016 // pt->fRemoval = removalindex;
2017 delete arr->RemoveAt(i);
2025 printf("Number of tracks after double removal- %d\n",arr->GetEntries());
2034 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode)
2037 //sort tracks in array according mode criteria
2038 Int_t nseed = arr->GetEntriesFast();
2039 for (Int_t i=0; i<nseed; i++) {
2040 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2050 void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2053 //Loop over all tracks and remove "overlaps"
2056 Int_t nseed = arr->GetEntriesFast();
2059 for (Int_t i=0; i<nseed; i++) {
2060 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2062 delete arr->RemoveAt(i);
2066 pt->fBSigned = kFALSE;
2070 nseed = arr->GetEntriesFast();
2077 for (Int_t i=0; i<nseed; i++) {
2078 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2082 Int_t found,foundable,shared;
2084 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2086 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2088 Double_t factor = factor2;
2089 if (pt->fBConstrain) factor = factor1;
2091 if ((Float_t(shared)/Float_t(found))>factor){
2092 pt->Desactivate(removalindex);
2097 for (Int_t i=0; i<160; i++) {
2098 Int_t index=pt->GetClusterIndex2(i);
2099 if (index<0 || index&0x8000 ) continue;
2100 AliTPCclusterMI *c= pt->fClusterPointer[i];
2102 // if (!c->IsUsed(10)) c->Use(10);
2103 //if (pt->IsActive())
2112 printf("\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2115 void AliTPCtrackerMI::UnsignClusters()
2118 // loop over all clusters and unsign them
2121 for (Int_t sec=0;sec<fkNIS;sec++){
2122 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2123 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2124 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2125 // if (cl[icl].IsUsed(10))
2127 cl = fInnerSec[sec][row].fClusters2;
2128 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2129 //if (cl[icl].IsUsed(10))
2134 for (Int_t sec=0;sec<fkNOS;sec++){
2135 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2136 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2137 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2138 //if (cl[icl].IsUsed(10))
2140 cl = fOuterSec[sec][row].fClusters2;
2141 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2142 //if (cl[icl].IsUsed(10))
2151 void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
2154 //sign clusters to be "used"
2156 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2157 // loop over "primaries"
2171 Int_t nseed = arr->GetEntriesFast();
2172 for (Int_t i=0; i<nseed; i++) {
2173 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2177 if (!(pt->IsActive())) continue;
2178 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2179 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2181 sumdens2+= dens*dens;
2182 sumn += pt->GetNumberOfClusters();
2183 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2184 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2187 sumchi2 +=chi2*chi2;
2192 Float_t mdensity = 0.9;
2193 Float_t meann = 130;
2194 Float_t meanchi = 1;
2195 Float_t sdensity = 0.1;
2196 Float_t smeann = 10;
2197 Float_t smeanchi =0.4;
2201 mdensity = sumdens/sum;
2203 meanchi = sumchi/sum;
2205 sdensity = sumdens2/sum-mdensity*mdensity;
2206 sdensity = TMath::Sqrt(sdensity);
2208 smeann = sumn2/sum-meann*meann;
2209 smeann = TMath::Sqrt(smeann);
2211 smeanchi = sumchi2/sum - meanchi*meanchi;
2212 smeanchi = TMath::Sqrt(smeanchi);
2216 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2218 for (Int_t i=0; i<nseed; i++) {
2219 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2223 if (pt->fBSigned) continue;
2224 if (pt->fBConstrain) continue;
2225 //if (!(pt->IsActive())) continue;
2227 Int_t found,foundable,shared;
2228 pt->GetClusterStatistic(0,160,found, foundable,shared);
2229 if (shared/float(found)>0.3) {
2230 if (shared/float(found)>0.9 ){
2231 //delete arr->RemoveAt(i);
2236 Bool_t isok =kFALSE;
2237 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2239 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2241 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2243 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2247 for (Int_t i=0; i<160; i++) {
2248 Int_t index=pt->GetClusterIndex2(i);
2249 if (index<0) continue;
2250 AliTPCclusterMI *c= pt->fClusterPointer[i];
2252 //if (!(c->IsUsed(10))) c->Use();
2259 Double_t maxchi = meanchi+2.*smeanchi;
2261 for (Int_t i=0; i<nseed; i++) {
2262 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2266 //if (!(pt->IsActive())) continue;
2267 if (pt->fBSigned) continue;
2268 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2269 if (chi>maxchi) continue;
2272 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2274 //sign only tracks with enoug big density at the beginning
2276 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2279 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
2280 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2282 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2283 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2286 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2287 //Int_t noc=pt->GetNumberOfClusters();
2288 pt->fBSigned = kTRUE;
2289 for (Int_t i=0; i<160; i++) {
2291 Int_t index=pt->GetClusterIndex2(i);
2292 if (index<0) continue;
2293 AliTPCclusterMI *c= pt->fClusterPointer[i];
2295 // if (!(c->IsUsed(10))) c->Use();
2300 // gLastCheck = nseed;
2308 void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2)
2310 // stop not active tracks
2311 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2312 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2313 Int_t nseed = arr->GetEntriesFast();
2315 for (Int_t i=0; i<nseed; i++) {
2316 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2320 if (!(pt->IsActive())) continue;
2321 StopNotActive(pt,row0,th0, th1,th2);
2327 void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
2330 // stop not active tracks
2331 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2332 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2335 Int_t foundable = 0;
2336 Int_t maxindex = seed->fLastPoint; //last foundable row
2337 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2338 seed->Desactivate(10) ;
2342 for (Int_t i=row0; i<maxindex; i++){
2343 Int_t index = seed->GetClusterIndex2(i);
2344 if (index!=-1) foundable++;
2346 if (foundable<=30) sumgood1++;
2347 if (foundable<=50) {
2354 if (foundable>=30.){
2355 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2358 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2363 Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2366 // back propagation of ESD tracks
2371 PropagateBack(fSeeds);
2372 Int_t nseed = fSeeds->GetEntriesFast();
2373 for (Int_t i=0;i<nseed;i++){
2374 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
2375 AliESDtrack *esd=event->GetTrack(i);
2376 seed->CookdEdx(0.02,0.06);
2377 CookLabel(seed,0.1); //For comparison only
2378 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2386 void AliTPCtrackerMI::DeleteSeeds()
2388 Int_t nseed = fSeeds->GetEntriesFast();
2389 for (Int_t i=0;i<nseed;i++){
2390 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2391 if (seed) delete fSeeds->RemoveAt(i);
2397 void AliTPCtrackerMI::ReadSeeds(AliESD *event)
2400 //read seeds from the event
2402 Int_t nentr=event->GetNumberOfTracks();
2403 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
2407 fSeeds = new TObjArray;
2411 for (Int_t i=0; i<nentr; i++) {
2412 AliESDtrack *esd=event->GetTrack(i);
2413 ULong_t status=esd->GetStatus();
2414 const AliTPCtrack t(*esd);
2415 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2416 if (status==AliESDtrack::kTPCin) seed->Modify(0.8);
2419 // rotate to the local coordinate system
2421 fSectors=fInnerSec; fN=fkNIS;
2423 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2424 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2425 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2426 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2427 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
2428 alpha-=seed->GetAlpha();
2429 if (!seed->Rotate(alpha)) continue;
2431 seed->PropagateTo(fSectors->GetX(0));
2433 // Int_t index = esd->GetTPCindex();
2434 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
2436 fSeeds->AddLast(seed);
2442 //_____________________________________________________________________________
2443 void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2444 Float_t deltay, Int_t ddsec) {
2445 //-----------------------------------------------------------------
2446 // This function creates track seeds.
2447 // SEEDING WITH VERTEX CONSTRAIN
2448 //-----------------------------------------------------------------
2449 // cuts[0] - fP4 cut
2450 // cuts[1] - tan(phi) cut
2451 // cuts[2] - zvertex cut
2452 // cuts[3] - fP3 cut
2460 Double_t x[5], c[15];
2461 // Int_t di = i1-i2;
2463 AliTPCseed * seed = new AliTPCseed;
2464 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2465 Double_t cs=cos(alpha), sn=sin(alpha);
2467 // Double_t x1 =fOuterSec->GetX(i1);
2468 //Double_t xx2=fOuterSec->GetX(i2);
2470 Double_t x1 =GetXrow(i1);
2471 Double_t xx2=GetXrow(i2);
2473 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2475 Int_t imiddle = (i2+i1)/2; //middle pad row index
2476 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2477 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2481 const AliTPCRow& kr1=GetRow(ns,i1);
2482 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2483 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2486 // change cut on curvature if it can't reach this layer
2487 // maximal curvature set to reach it
2488 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2489 if (dvertexmax*0.5*cuts[0]>0.85){
2490 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2492 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2495 if (deltay>0) ddsec = 0;
2496 // loop over clusters
2497 for (Int_t is=0; is < kr1; is++) {
2499 if (kr1[is]->IsUsed(10)) continue;
2500 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2501 //if (TMath::Abs(y1)>ymax) continue;
2503 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2505 // find possible directions
2506 Float_t anglez = (z1-z3)/(x1-x3);
2507 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2510 //find rotation angles relative to line given by vertex and point 1
2511 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2512 Double_t dvertex = TMath::Sqrt(dvertex2);
2513 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2514 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2517 // loop over 2 sectors
2523 Double_t dddz1=0; // direction of delta inclination in z axis
2530 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2531 Int_t sec2 = sec + dsec;
2533 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2534 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2535 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2536 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2537 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2538 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2540 // rotation angles to p1-p3
2541 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2542 Double_t x2, y2, z2;
2544 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2547 Double_t dxx0 = (xx2-x3)*cs13r;
2548 Double_t dyy0 = (xx2-x3)*sn13r;
2549 for (Int_t js=index1; js < index2; js++) {
2550 const AliTPCclusterMI *kcl = kr2[js];
2551 if (kcl->IsUsed(10)) continue;
2553 //calcutate parameters
2555 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2557 if (TMath::Abs(yy0)<0.000001) continue;
2558 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2559 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2560 Double_t r02 = (0.25+y0*y0)*dvertex2;
2561 //curvature (radius) cut
2562 if (r02<r2min) continue;
2566 Double_t c0 = 1/TMath::Sqrt(r02);
2570 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2571 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2572 Double_t dfi0 = 2.*TPCFastMath::FastAsin(dvertex*c0*0.5);
2573 Double_t dfi1 = 2.*TPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
2576 Double_t z0 = kcl->GetZ();
2577 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2578 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2581 Double_t dip = (z1-z0)*c0/dfi1;
2582 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2593 x2= xx2*cs-y2*sn*dsec;
2594 y2=+xx2*sn*dsec+y2*cs;
2604 // do we have cluster at the middle ?
2606 GetProlongation(x1,xm,x,ym,zm);
2608 AliTPCclusterMI * cm=0;
2609 if (TMath::Abs(ym)-ymaxm<0){
2610 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2611 if ((!cm) || (cm->IsUsed(10))) {
2616 // rotate y1 to system 0
2617 // get state vector in rotated system
2618 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2619 Double_t xr2 = x0*cs+yr1*sn*dsec;
2620 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2622 GetProlongation(xx2,xm,xr,ym,zm);
2623 if (TMath::Abs(ym)-ymaxm<0){
2624 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2625 if ((!cm) || (cm->IsUsed(10))) {
2635 dym = ym - cm->GetY();
2636 dzm = zm - cm->GetZ();
2643 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2644 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2645 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2646 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2647 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2649 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2650 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2651 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2652 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2653 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2654 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2656 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2657 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2658 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2659 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2663 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2664 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2665 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2666 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2667 c[13]=f30*sy1*f40+f32*sy2*f42;
2668 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2670 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2672 UInt_t index=kr1.GetIndex(is);
2673 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2675 track->fIsSeeding = kTRUE;
2682 FollowProlongation(*track, (i1+i2)/2,1);
2683 Int_t foundable,found,shared;
2684 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2685 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2687 seed->~AliTPCseed();
2693 FollowProlongation(*track, i2,1);
2697 track->fBConstrain =1;
2698 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2699 track->fLastPoint = i1; // first cluster in track position
2700 track->fFirstPoint = track->fLastPoint;
2702 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2703 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2704 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2706 seed->~AliTPCseed();
2710 // Z VERTEX CONDITION
2712 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2713 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2714 if (TMath::Abs(zv-z3)>cuts[2]) {
2715 FollowProlongation(*track, TMath::Max(i2-20,0));
2716 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2717 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2718 if (TMath::Abs(zv-z3)>cuts[2]){
2719 FollowProlongation(*track, TMath::Max(i2-40,0));
2720 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2721 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2722 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2723 // make seed without constrain
2724 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2725 FollowProlongation(*track2, i2,1);
2726 track2->fBConstrain = kFALSE;
2727 track2->fSeedType = 1;
2728 arr->AddLast(track2);
2730 seed->~AliTPCseed();
2735 seed->~AliTPCseed();
2742 track->fSeedType =0;
2743 arr->AddLast(track);
2744 seed = new AliTPCseed;
2746 // don't consider other combinations
2747 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2753 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
2759 void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2764 //-----------------------------------------------------------------
2765 // This function creates track seeds.
2766 //-----------------------------------------------------------------
2767 // cuts[0] - fP4 cut
2768 // cuts[1] - tan(phi) cut
2769 // cuts[2] - zvertex cut
2770 // cuts[3] - fP3 cut
2780 Double_t x[5], c[15];
2782 // make temporary seed
2783 AliTPCseed * seed = new AliTPCseed;
2784 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2785 // Double_t cs=cos(alpha), sn=sin(alpha);
2790 Double_t x1 = GetXrow(i1-1);
2791 const AliTPCRow& kr1=GetRow(sec,i1-1);
2792 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2794 Double_t x1p = GetXrow(i1);
2795 const AliTPCRow& kr1p=GetRow(sec,i1);
2797 Double_t x1m = GetXrow(i1-2);
2798 const AliTPCRow& kr1m=GetRow(sec,i1-2);
2801 //last 3 padrow for seeding
2802 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2803 Double_t x3 = GetXrow(i1-7);
2804 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2806 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2807 Double_t x3p = GetXrow(i1-6);
2809 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2810 Double_t x3m = GetXrow(i1-8);
2815 Int_t im = i1-4; //middle pad row index
2816 Double_t xm = GetXrow(im); // radius of middle pad-row
2817 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
2818 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
2821 Double_t deltax = x1-x3;
2822 Double_t dymax = deltax*cuts[1];
2823 Double_t dzmax = deltax*cuts[3];
2825 // loop over clusters
2826 for (Int_t is=0; is < kr1; is++) {
2828 if (kr1[is]->IsUsed(10)) continue;
2829 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2831 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2833 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
2834 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
2840 for (Int_t js=index1; js < index2; js++) {
2841 const AliTPCclusterMI *kcl = kr3[js];
2842 if (kcl->IsUsed(10)) continue;
2844 // apply angular cuts
2845 if (TMath::Abs(y1-y3)>dymax) continue;
2848 if (TMath::Abs(z1-z3)>dzmax) continue;
2850 Double_t angley = (y1-y3)/(x1-x3);
2851 Double_t anglez = (z1-z3)/(x1-x3);
2853 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
2854 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
2856 Double_t yyym = angley*(xm-x1)+y1;
2857 Double_t zzzm = anglez*(xm-x1)+z1;
2859 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
2861 if (kcm->IsUsed(10)) continue;
2863 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
2864 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
2871 // look around first
2872 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
2878 if (kc1m->IsUsed(10)) used++;
2880 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
2886 if (kc1p->IsUsed(10)) used++;
2888 if (used>1) continue;
2889 if (found<1) continue;
2893 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
2899 if (kc3m->IsUsed(10)) used++;
2903 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
2909 if (kc3p->IsUsed(10)) used++;
2913 if (used>1) continue;
2914 if (found<3) continue;
2924 x[4]=f1(x1,y1,x2,y2,x3,y3);
2925 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
2928 x[2]=f2(x1,y1,x2,y2,x3,y3);
2931 x[3]=f3n(x1,y1,x2,y2,z1,z2,x[4]);
2932 //if (TMath::Abs(x[3]) > cuts[3]) continue;
2936 Double_t sy1=0.1, sz1=0.1;
2937 Double_t sy2=0.1, sz2=0.1;
2938 Double_t sy3=0.1, sy=0.1, sz=0.1;
2940 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2941 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2942 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2943 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2944 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2945 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
2947 Double_t f30=(f3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2948 Double_t f31=(f3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2949 Double_t f32=(f3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2950 Double_t f34=(f3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
2954 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2955 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2956 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2957 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2958 c[13]=f30*sy1*f40+f32*sy2*f42;
2959 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
2961 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2963 UInt_t index=kr1.GetIndex(is);
2964 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
2966 track->fIsSeeding = kTRUE;
2969 FollowProlongation(*track, i1-7,1);
2970 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
2971 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
2973 seed->~AliTPCseed();
2979 FollowProlongation(*track, i2,1);
2980 track->fBConstrain =0;
2981 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2982 track->fFirstPoint = track->fLastPoint;
2984 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2985 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
2986 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
2988 seed->~AliTPCseed();
2993 FollowProlongation(*track, TMath::Max(i2-10,0),1);
2994 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
2995 FollowProlongation(*track2, i2,1);
2996 track2->fBConstrain = kFALSE;
2997 track2->fSeedType = 4;
2998 arr->AddLast(track2);
3000 seed->~AliTPCseed();
3004 //arr->AddLast(track);
3005 //seed = new AliTPCseed;
3011 // printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
3017 //_____________________________________________________________________________
3018 void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3019 Float_t deltay, Bool_t bconstrain) {
3020 //-----------------------------------------------------------------
3021 // This function creates track seeds - without vertex constraint
3022 //-----------------------------------------------------------------
3023 // cuts[0] - fP4 cut - not applied
3024 // cuts[1] - tan(phi) cut
3025 // cuts[2] - zvertex cut - not applied
3026 // cuts[3] - fP3 cut
3036 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3037 // Double_t cs=cos(alpha), sn=sin(alpha);
3038 Int_t row0 = (i1+i2)/2;
3039 Int_t drow = (i1-i2)/2;
3040 const AliTPCRow& kr0=fSectors[sec][row0];
3043 AliTPCpolyTrack polytrack;
3044 Int_t nclusters=fSectors[sec][row0];
3045 AliTPCseed * seed = new AliTPCseed;
3050 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3052 Int_t nfoundable =0;
3053 for (Int_t iter =1; iter<2; iter++){ //iterations
3054 const AliTPCRow& krm=fSectors[sec][row0-iter];
3055 const AliTPCRow& krp=fSectors[sec][row0+iter];
3056 const AliTPCclusterMI * cl= kr0[is];
3058 if (cl->IsUsed(10)) {
3064 Double_t x = kr0.GetX();
3065 // Initialization of the polytrack
3070 Double_t y0= cl->GetY();
3071 Double_t z0= cl->GetZ();
3075 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3076 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3078 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3079 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3080 polytrack.AddPoint(x,y0,z0,erry, errz);
3083 if (cl->IsUsed(10)) sumused++;
3086 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3087 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3090 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3091 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3092 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3093 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3094 if (cl1->IsUsed(10)) sumused++;
3095 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3099 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3101 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3102 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3103 if (cl2->IsUsed(10)) sumused++;
3104 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3107 if (sumused>0) continue;
3109 polytrack.UpdateParameters();
3115 nfoundable = polytrack.GetN();
3116 nfound = nfoundable;
3118 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3119 Float_t maxdist = 0.8*(1.+3./(ddrow));
3120 for (Int_t delta = -1;delta<=1;delta+=2){
3121 Int_t row = row0+ddrow*delta;
3122 kr = &(fSectors[sec][row]);
3123 Double_t xn = kr->GetX();
3124 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3125 polytrack.GetFitPoint(xn,yn,zn);
3126 if (TMath::Abs(yn)>ymax) continue;
3128 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3130 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3133 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3134 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3135 if (cln->IsUsed(10)) {
3136 // printf("used\n");
3144 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3149 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3150 polytrack.UpdateParameters();
3153 if ( (sumused>3) || (sumused>0.5*nfound)) {
3154 //printf("sumused %d\n",sumused);
3159 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3160 AliTPCpolyTrack track2;
3162 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3163 if (track2.GetN()<0.5*nfoundable) continue;
3166 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3168 // test seed with and without constrain
3169 for (Int_t constrain=0; constrain<=0;constrain++){
3170 // add polytrack candidate
3172 Double_t x[5], c[15];
3173 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3174 track2.GetBoundaries(x3,x1);
3176 track2.GetFitPoint(x1,y1,z1);
3177 track2.GetFitPoint(x2,y2,z2);
3178 track2.GetFitPoint(x3,y3,z3);
3180 //is track pointing to the vertex ?
3183 polytrack.GetFitPoint(x0,y0,z0);
3196 x[4]=f1(x1,y1,x2,y2,x3,y3);
3198 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
3199 x[2]=f2(x1,y1,x2,y2,x3,y3);
3201 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
3202 //x[3]=f3(x1,y1,x2,y2,z1,z2);
3203 x[3]=f3n(x1,y1,x3,y3,z1,z3,x[4]);
3204 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3207 Double_t sy =0.1, sz =0.1;
3208 Double_t sy1=0.02, sz1=0.02;
3209 Double_t sy2=0.02, sz2=0.02;
3213 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3216 Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3217 Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3218 Double_t f43=(f1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3219 Double_t f20=(f2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3220 Double_t f22=(f2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3221 Double_t f23=(f2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3223 Double_t f30=(f3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3224 Double_t f31=(f3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3225 Double_t f32=(f3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3226 Double_t f34=(f3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
3231 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3232 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3233 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3234 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3235 c[13]=f30*sy1*f40+f32*sy2*f42;
3236 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3238 //Int_t row1 = fSectors->GetRowNumber(x1);
3239 Int_t row1 = GetRowNumber(x1);
3243 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3244 track->fIsSeeding = kTRUE;
3245 Int_t rc=FollowProlongation(*track, i2);
3246 if (constrain) track->fBConstrain =1;
3248 track->fBConstrain =0;
3249 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3250 track->fFirstPoint = track->fLastPoint;
3252 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3253 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3254 track->fNShared>0.4*track->GetNumberOfClusters()) {
3257 seed->~AliTPCseed();
3260 arr->AddLast(track);
3261 seed = new AliTPCseed;
3265 } // if accepted seed
3268 printf("\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
3274 AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3279 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3280 Int_t p1 = int(r1*track->GetNumberOfClusters());
3281 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
3283 Double_t x0[3],x1[3],x2[3];
3288 // find track position at given ratio of the length
3289 Int_t sec0, sec1, sec2;
3292 for (Int_t i=0;i<160;i++){
3293 if (track->fClusterPointer[i]){
3295 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3296 if ( (index<p0) || x0[0]<0 ){
3297 if (trpoint->GetX()>1){
3298 clindex = track->GetClusterIndex2(i);
3300 x0[0] = trpoint->GetX();
3301 x0[1] = trpoint->GetY();
3302 x0[2] = trpoint->GetZ();
3303 sec0 = ((clindex&0xff000000)>>24)%18;
3308 if ( (index<p1) &&(trpoint->GetX()>1)){
3309 clindex = track->GetClusterIndex2(i);
3311 x1[0] = trpoint->GetX();
3312 x1[1] = trpoint->GetY();
3313 x1[2] = trpoint->GetZ();
3314 sec1 = ((clindex&0xff000000)>>24)%18;
3317 if ( (index<p2) &&(trpoint->GetX()>1)){
3318 clindex = track->GetClusterIndex2(i);
3320 x2[0] = trpoint->GetX();
3321 x2[1] = trpoint->GetY();
3322 x2[2] = trpoint->GetZ();
3323 sec2 = ((clindex&0xff000000)>>24)%18;
3330 Double_t alpha, cs,sn, xx2,yy2;
3332 alpha = (sec1-sec2)*fSectors->GetAlpha();
3333 cs = TMath::Cos(alpha);
3334 sn = TMath::Sin(alpha);
3335 xx2= x1[0]*cs-x1[1]*sn;
3336 yy2= x1[0]*sn+x1[1]*cs;
3340 alpha = (sec0-sec2)*fSectors->GetAlpha();
3341 cs = TMath::Cos(alpha);
3342 sn = TMath::Sin(alpha);
3343 xx2= x0[0]*cs-x0[1]*sn;
3344 yy2= x0[0]*sn+x0[1]*cs;
3350 Double_t x[5],c[15];
3354 x[4]=f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3355 // if (x[4]>1) return 0;
3356 x[2]=f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3357 x[3]=f3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
3358 //if (TMath::Abs(x[3]) > 2.2) return 0;
3359 //if (TMath::Abs(x[2]) > 1.99) return 0;
3361 Double_t sy =0.1, sz =0.1;
3363 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3364 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3365 Double_t sy3=0.01+track->GetSigmaY2();
3367 Double_t f40=(f1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3368 Double_t f42=(f1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3369 Double_t f43=(f1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3370 Double_t f20=(f2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3371 Double_t f22=(f2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3372 Double_t f23=(f2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3374 Double_t f30=(f3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3375 Double_t f31=(f3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3376 Double_t f32=(f3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3377 Double_t f34=(f3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
3382 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3383 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3384 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3385 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3386 c[13]=f30*sy1*f40+f32*sy2*f42;
3387 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3389 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3390 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3391 // Double_t y0,z0,y1,z1, y2,z2;
3392 //seed->GetProlongation(x0[0],y0,z0);
3393 // seed->GetProlongation(x1[0],y1,z1);
3394 //seed->GetProlongation(x2[0],y2,z2);
3396 seed->fLastPoint = pp2;
3397 seed->fFirstPoint = pp2;
3403 Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3408 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3410 if (TMath::Abs(seed->GetC())>0.01) return 0;
3413 Float_t x[160], y[160], erry[160], z[160], errz[160];
3415 Float_t xt[160], yt[160], zt[160];
3420 Int_t middle = seed->GetNumberOfClusters()/2;
3423 // find central sector, get local cooordinates
3425 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3426 sec[i]= seed->GetClusterSector(i)%18;
3429 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3430 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3437 if (i>i2) i2 = i; //last point with cluster
3438 if (i2<i1) i1 = i; //first point with cluster
3441 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3443 yt[i] = point->GetY();
3444 zt[i] = point->GetZ();
3446 if (point->GetX()>0){
3447 erry[i] = point->GetErrY();
3448 errz[i] = point->GetErrZ();
3453 secm = sec[i]; //central sector
3454 padm = i; //middle point with cluster
3459 // rotate position to global coordinate system connected to sector at last the point
3461 for (Int_t i=i1;i<=i2;i++){
3463 if (sec[i]<0) continue;
3464 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3465 Double_t cs = TMath::Cos(alpha);
3466 Double_t sn = TMath::Sin(alpha);
3467 Float_t xx2= x[i]*cs+y[i]*sn;
3468 Float_t yy2= -x[i]*sn+y[i]*cs;
3472 xx2= xt[i]*cs+yt[i]*sn;
3473 yy2= -xt[i]*sn+yt[i]*cs;
3478 //get "state" vector
3479 Double_t xh[5],xm = x[padm];
3482 xh[4]=f1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3483 xh[2]=f2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3484 xh[3]=f3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
3487 for (Int_t i=i1;i<=i2;i++){
3489 if (sec[i]<0) continue;
3490 GetProlongation(x[i2], x[i],xh,yy,zz);
3491 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3493 //xxh[4]=f1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3494 //xxh[2]=f2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3495 printf("problem\n");
3500 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3501 Float_t yup[160], ydown[160], zup[160], zdown[160];
3503 AliTPCpolyTrack ptrack1,ptrack2;
3506 for (Int_t i=i1;i<=i2;i++){
3507 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3509 if (cl->GetType()<0) continue;
3510 if (cl->GetType()>10) continue;
3513 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3515 if (ptrack1.GetN()>4.){
3516 ptrack1.UpdateParameters();
3518 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3520 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3529 dyup[i]=0.; //not enough points
3534 for (Int_t i=i2;i>=i1;i--){
3535 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3537 if (cl->GetType()<0) continue;
3538 if (cl->GetType()>10) continue;
3540 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3542 if (ptrack2.GetN()>4){
3543 ptrack2.UpdateParameters();
3545 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3547 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3555 dydown[i]=0.; //not enough points
3560 // find maximal difference of the derivation
3561 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3564 for (Int_t i=i1+10;i<i2-10;i++){
3565 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3566 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3568 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3569 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3570 if ( (ddy+ddz)> th){
3571 seed->fKinkPoint[0] = i;
3572 seed->fKinkPoint[1] = ddy;
3573 seed->fKinkPoint[2] = ddz;
3580 //write information to the debug tree
3581 TBranch * br = fTreeDebug->GetBranch("debug");
3582 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3583 arr->ExpandCreateFast(i2-i1);
3584 br->SetAddress(&arr);
3586 AliTPCclusterMI cldummy;
3588 AliTPCTrackPoint2 pdummy;
3589 pdummy.GetTPoint().fIsShared = 10;
3591 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3592 Double_t cs = TMath::Cos(alpha);
3593 Double_t sn = TMath::Sin(alpha);
3595 for (Int_t i=i1;i<i2;i++){
3596 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3598 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3600 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3603 Double_t x = GetXrow(i);
3604 trpoint->GetTPoint() = *point;
3605 trpoint->GetCPoint() = *cl0;
3606 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3607 trpoint->fID = seed->GetUniqueID();
3608 trpoint->fLab = seed->GetLabel();
3610 trpoint->fGX = cs *x + sn*point->GetY();
3611 trpoint->fGY = -sn *x + cs*point->GetY() ;
3612 trpoint->fGZ = point->GetZ();
3614 trpoint->fDY = y[i];
3615 trpoint->fDZ = z[i];
3617 trpoint->fDYU = dyup[i];
3618 trpoint->fDZU = dzup[i];
3620 trpoint->fDYD = dydown[i];
3621 trpoint->fDZD = dzdown[i];
3623 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3624 trpoint->fDDY = dydown[i]-dyup[i];
3625 trpoint->fDDZ = dzdown[i]-dzup[i];
3633 trpoint->GetCPoint()= cldummy;
3650 AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3653 // reseed - refit - track
3656 // Int_t last = fSectors->GetNRows()-1;
3658 if (fSectors == fOuterSec){
3659 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3663 first = t->fFirstPoint;
3665 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3666 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3668 FollowProlongation(*t,first);
3678 //_____________________________________________________________________________
3679 Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3680 //-----------------------------------------------------------------
3681 // This function reades track seeds.
3682 //-----------------------------------------------------------------
3683 TDirectory *savedir=gDirectory;
3685 TFile *in=(TFile*)inp;
3686 if (!in->IsOpen()) {
3687 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3692 TTree *seedTree=(TTree*)in->Get("Seeds");
3694 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3695 cerr<<"can't get a tree with track seeds !\n";
3698 AliTPCtrack *seed=new AliTPCtrack;
3699 seedTree->SetBranchAddress("tracks",&seed);
3701 if (fSeeds==0) fSeeds=new TObjArray(15000);
3703 Int_t n=(Int_t)seedTree->GetEntries();
3704 for (Int_t i=0; i<n; i++) {
3705 seedTree->GetEvent(i);
3706 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
3715 //_____________________________________________________________________________
3716 Int_t AliTPCtrackerMI::Clusters2Tracks() {
3717 //-----------------------------------------------------------------
3718 // This is a track finder.
3719 //-----------------------------------------------------------------
3720 TDirectory *savedir=gDirectory;
3723 if (!fInput) SetIO(); //set default IO using loaders
3725 cerr<<"AliTPCtrackerMI::Clusters2Tracks(): input file is not open !\n";
3731 fSeeds = Tracking();
3734 printf("Time for tracking: \t");timer.Print();timer.Start();
3736 //activate again some tracks
3737 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
3738 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3740 Int_t nc=t.GetNumberOfClusters();
3742 delete fSeeds->RemoveAt(i);
3745 if (pt->fRemoval==10) {
3746 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
3747 pt->Desactivate(10); // make track again active
3749 pt->Desactivate(20);
3750 delete fSeeds->RemoveAt(i);
3754 RemoveDouble(fSeeds,0.2,0.6,11);
3755 //RemoveUsed(fSeeds,0.9,0.9,6);
3756 //RemoveUsed(fSeeds,0.8,0.8,6);
3757 //RemoveUsed(fSeeds,0.7,0.7,6);
3758 RemoveUsed(fSeeds,0.5,0.5,6);
3761 Int_t nseed=fSeeds->GetEntriesFast();
3763 for (Int_t i=0; i<nseed; i++) {
3764 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3766 Int_t nc=t.GetNumberOfClusters();
3768 delete fSeeds->RemoveAt(i);
3771 CookLabel(pt,0.1); //For comparison only
3772 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3773 if ((pt->IsActive() || (pt->fRemoval==10) )){
3774 cerr<<found++<<'\r';
3777 delete fSeeds->RemoveAt(i);
3782 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
3784 //RemoveUsed(fSeeds,0.9,0.9,6);
3786 nseed=fSeeds->GetEntriesFast();
3788 for (Int_t i=0; i<nseed; i++) {
3789 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3791 Int_t nc=t.GetNumberOfClusters();
3793 delete fSeeds->RemoveAt(i);
3797 t.CookdEdx(0.02,0.6);
3798 // CheckKinkPoint(&t,0.05);
3799 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3800 if ((pt->IsActive() || (pt->fRemoval==10) )){
3801 cerr<<found++<<'\r';
3804 delete fSeeds->RemoveAt(i);
3808 SortTracks(fSeeds, 1);
3812 PrepareForBackProlongation(fSeeds,0.5);
3813 PropagateBack(fSeeds);
3814 printf("Time for back propagation: \t");timer.Print();timer.Start();
3818 PrepareForProlongation(fSeeds,1.);
3821 fSectors = fOuterSec;
3822 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3823 fSectors = fInnerSec;
3824 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
3825 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
3826 // RemoveUsed(fSeeds,0.7,0.7,6);
3827 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
3829 nseed=fSeeds->GetEntriesFast();
3831 for (Int_t i=0; i<nseed; i++) {
3832 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
3834 Int_t nc=t.GetNumberOfClusters();
3836 delete fSeeds->RemoveAt(i);
3839 t.CookdEdx(0.02,0.6);
3840 // CookLabel(pt,0.1); //For comparison only
3841 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
3842 if ((pt->IsActive() || (pt->fRemoval==10) )){
3843 cerr<<found++<<'\r';
3846 delete fSeeds->RemoveAt(i);
3851 // fNTracks = found;
3852 printf("Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
3857 if (!fNewIO) fOutput->Write();
3859 AliRunLoader::GetDetectorLoader("TPC",AliConfig::fgkDefaultEventFolderName)->WriteTracks("OVERWRITE");
3862 cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
3864 //if (seedtree) delete seedtree;
3865 // UnloadClusters();
3866 //printf("Time for unloading cluster: \t"); timer.Print();timer.Start();
3871 void AliTPCtrackerMI::Tracking(TObjArray * arr)
3874 // tracking of the seeds
3877 fSectors = fOuterSec;
3878 ParallelTracking(arr,150,63);
3879 fSectors = fOuterSec;
3880 ParallelTracking(arr,63,0);
3883 TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
3888 TObjArray * arr = new TObjArray;
3890 fSectors = fOuterSec;
3893 for (Int_t sec=0;sec<fkNOS;sec++){
3894 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
3895 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
3896 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
3899 printf("\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
3911 TObjArray * AliTPCtrackerMI::Tracking()
3917 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
3919 TObjArray * seeds = new TObjArray;
3928 Float_t fnumber = 3.0;
3929 Float_t fdensity = 3.0;
3934 for (Int_t delta = 0; delta<18; delta+=6){
3938 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
3939 SumTracks(seeds,arr);
3940 SignClusters(seeds,fnumber,fdensity);
3942 for (Int_t i=2;i<6;i+=2){
3943 // seed high pt tracks
3946 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
3947 SumTracks(seeds,arr);
3948 SignClusters(seeds,fnumber,fdensity);
3953 // RemoveUsed(seeds,0.9,0.9,1);
3954 // UnsignClusters();
3955 // SignClusters(seeds,fnumber,fdensity);
3959 for (Int_t delta = 20; delta<120; delta+=10){
3961 // seed high pt tracks
3965 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
3966 SumTracks(seeds,arr);
3967 SignClusters(seeds,fnumber,fdensity);
3972 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
3973 SumTracks(seeds,arr);
3974 SignClusters(seeds,fnumber,fdensity);
3985 printf("\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
3989 // RemoveUsed(seeds,0.75,0.75,1);
3991 //SignClusters(seeds,fnumber,fdensity);
4000 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4001 SumTracks(seeds,arr);
4002 SignClusters(seeds,fnumber,fdensity);
4004 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4005 SumTracks(seeds,arr);
4006 SignClusters(seeds,fnumber,fdensity);
4008 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4009 SumTracks(seeds,arr);
4010 SignClusters(seeds,fnumber,fdensity);
4014 for (Int_t delta = 3; delta<30; delta+=5){
4020 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4021 SumTracks(seeds,arr);
4022 SignClusters(seeds,fnumber,fdensity);
4024 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4025 SumTracks(seeds,arr);
4026 SignClusters(seeds,fnumber,fdensity);
4038 for (Int_t delta = 30; delta<70; delta+=10){
4044 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4045 SumTracks(seeds,arr);
4046 SignClusters(seeds,fnumber,fdensity);
4048 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4049 SumTracks(seeds,arr);
4050 SignClusters(seeds,fnumber,fdensity);
4054 printf("\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
4065 void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2)
4068 //sum tracks to common container
4069 //remove suspicious tracks
4070 Int_t nseed = arr2->GetEntriesFast();
4071 for (Int_t i=0;i<nseed;i++){
4072 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4075 // NORMAL ACTIVE TRACK
4076 if (pt->IsActive()){
4077 arr1->AddLast(arr2->RemoveAt(i));
4080 //remove not usable tracks
4081 if (pt->fRemoval!=10){
4082 delete arr2->RemoveAt(i);
4085 // REMOVE VERY SHORT TRACKS
4086 if (pt->GetNumberOfClusters()<20){
4087 delete arr2->RemoveAt(i);
4090 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4091 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4092 arr1->AddLast(arr2->RemoveAt(i));
4094 delete arr2->RemoveAt(i);
4103 void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
4106 // try to track in parralel
4108 Int_t nseed=arr->GetEntriesFast();
4109 //prepare seeds for tracking
4110 for (Int_t i=0; i<nseed; i++) {
4111 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4113 if (!t.IsActive()) continue;
4114 // follow prolongation to the first layer
4115 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
4116 FollowProlongation(t, rfirst+1);
4121 for (Int_t nr=rfirst; nr>=rlast; nr--){
4122 // make indexes with the cluster tracks for given
4124 // find nearest cluster
4125 for (Int_t i=0; i<nseed; i++) {
4126 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
4128 if (!pt->IsActive()) continue;
4129 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4130 if (pt->fRelativeSector>17) {
4133 UpdateClusters(t,nr);
4135 // prolonagate to the nearest cluster - if founded
4136 for (Int_t i=0; i<nseed; i++) {
4137 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
4139 if (!pt->IsActive()) continue;
4140 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
4141 if (pt->fRelativeSector>17) {
4144 FollowToNextCluster(*pt,nr);
4149 void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac)
4153 // if we use TPC track itself we have to "update" covariance
4155 Int_t nseed= arr->GetEntriesFast();
4156 for (Int_t i=0;i<nseed;i++){
4157 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4161 //rotate to current local system at first accepted point
4162 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4163 Int_t sec = (index&0xff000000)>>24;
4165 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4166 if (angle1>TMath::Pi())
4167 angle1-=2.*TMath::Pi();
4168 Float_t angle2 = pt->GetAlpha();
4170 if (TMath::Abs(angle1-angle2)>0.001){
4171 pt->Rotate(angle1-angle2);
4172 //angle2 = pt->GetAlpha();
4173 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4174 //if (pt->GetAlpha()<0)
4175 // pt->fRelativeSector+=18;
4176 //sec = pt->fRelativeSector;
4185 void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac)
4189 // if we use TPC track itself we have to "update" covariance
4191 Int_t nseed= arr->GetEntriesFast();
4192 for (Int_t i=0;i<nseed;i++){
4193 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4196 pt->fFirstPoint = pt->fLastPoint;
4204 Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4207 // make back propagation
4209 Int_t nseed= arr->GetEntriesFast();
4210 for (Int_t i=0;i<nseed;i++){
4211 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4213 AliTPCseed *pt2 = new AliTPCseed(*pt);
4214 fSectors = fInnerSec;
4215 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4216 fSectors = fOuterSec;
4217 FollowBackProlongation(*pt,fSectors->GetNRows()-1);
4218 fSectors = fOuterSec;
4219 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4220 printf("\n%d",pt->GetLabel());
4221 fSectors = fInnerSec;
4222 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4223 fSectors = fOuterSec;
4224 FollowBackProlongation(*pt2,fSectors->GetNRows()-1);
4225 fSectors = fOuterSec;
4233 Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4236 // make forward propagation
4238 Int_t nseed= arr->GetEntriesFast();
4239 for (Int_t i=0;i<nseed;i++){
4240 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4242 AliTPCseed *pt2 = new AliTPCseed(*pt);
4243 fSectors = fOuterSec;
4244 FollowProlongation(*pt,0);
4245 fSectors = fOuterSec;
4246 FollowProlongation(*pt,0);
4247 fSectors = fInnerSec;
4248 if (pt->GetNumberOfClusters()<35 && pt->GetLabel()>0 ){
4249 printf("\n%d",pt->GetLabel());
4250 fSectors = fOuterSec;
4251 FollowProlongation(*pt2,0);
4252 fSectors = fOuterSec;
4253 FollowProlongation(*pt2,0);
4254 fSectors = fOuterSec;
4262 Int_t AliTPCtrackerMI::PropagateForward()
4264 fSectors = fOuterSec;
4265 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4266 fSectors = fInnerSec;
4267 ParallelTracking(fSeeds,fSectors->GetNRows()-1,0);
4277 Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4280 // make back propagation, in between row0 and row1
4284 fSectors = fInnerSec;
4287 if (row1<fSectors->GetNRows())
4290 r1 = fSectors->GetNRows()-1;
4292 if (row0<fSectors->GetNRows()&& r1>0 )
4293 FollowBackProlongation(*pt,r1);
4294 if (row1<=fSectors->GetNRows())
4297 r1 = row1 - fSectors->GetNRows();
4298 if (r1<=0) return 0;
4299 if (r1>=fOuterSec->GetNRows()) return 0;
4300 fSectors = fOuterSec;
4301 return FollowBackProlongation(*pt,r1);
4309 void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4313 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4314 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4315 Float_t padlength = GetPadPitchLength(row);
4317 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4318 Float_t angulary = seed->GetSnp();
4319 angulary = angulary*angulary/(1-angulary*angulary);
4320 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4322 Float_t sresz = fParam->GetZSigma();
4323 Float_t angularz = seed->GetTgl();
4324 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4326 Float_t wy = GetSigmaY(seed);
4327 Float_t wz = GetSigmaZ(seed);
4330 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4331 printf("problem\n");
4337 Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4341 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4342 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4343 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4344 Float_t angular = seed->GetSnp();
4345 angular = angular*angular/(1-angular*angular);
4346 // angular*=angular;
4347 //angular = TMath::Sqrt(angular/(1-angular));
4348 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4351 Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4355 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4356 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4357 Float_t sres = fParam->GetZSigma();
4358 Float_t angular = seed->GetTgl();
4359 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4366 //__________________________________________________________________________
4367 void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
4368 //--------------------------------------------------------------------
4369 //This function "cooks" a track label. If label<0, this track is fake.
4370 //--------------------------------------------------------------------
4371 Int_t noc=t->GetNumberOfClusters();
4373 printf("\nnot founded prolongation\n\n\n");
4379 AliTPCclusterMI *clusters[160];
4381 for (Int_t i=0;i<160;i++) {
4388 for (i=0; i<160 && current<noc; i++) {
4390 Int_t index=t->GetClusterIndex2(i);
4391 if (index<=0) continue;
4392 if (index&0x8000) continue;
4394 //clusters[current]=GetClusterMI(index);
4395 if (t->fClusterPointer[i]){
4396 clusters[current]=t->fClusterPointer[i];
4402 Int_t lab=123456789;
4403 for (i=0; i<noc; i++) {
4404 AliTPCclusterMI *c=clusters[i];
4406 lab=TMath::Abs(c->GetLabel(0));
4408 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4414 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4416 for (i=0; i<noc; i++) {
4417 AliTPCclusterMI *c=clusters[i];
4419 if (TMath::Abs(c->GetLabel(1)) == lab ||
4420 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4423 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4426 Int_t tail=Int_t(0.10*noc);
4429 for (i=1; i<=160&&ind<tail; i++) {
4430 // AliTPCclusterMI *c=clusters[noc-i];
4431 AliTPCclusterMI *c=clusters[i];
4433 if (lab == TMath::Abs(c->GetLabel(0)) ||
4434 lab == TMath::Abs(c->GetLabel(1)) ||
4435 lab == TMath::Abs(c->GetLabel(2))) max++;
4438 if (max < Int_t(0.5*tail)) lab=-lab;
4445 //delete[] clusters;
4448 //_________________________________________________________________________
4449 void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4450 //-----------------------------------------------------------------------
4451 // Setup inner sector
4452 //-----------------------------------------------------------------------
4454 fAlpha=par->GetInnerAngle();
4455 fAlphaShift=par->GetInnerAngleShift();
4456 fPadPitchWidth=par->GetInnerPadPitchWidth();
4457 fPadPitchLength=par->GetInnerPadPitchLength();
4458 fN=par->GetNRowLow();
4459 fRow=new AliTPCRow[fN];
4460 for (Int_t i=0; i<fN; i++) {
4461 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4462 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4465 fAlpha=par->GetOuterAngle();
4466 fAlphaShift=par->GetOuterAngleShift();
4467 fPadPitchWidth = par->GetOuterPadPitchWidth();
4468 fPadPitchLength = par->GetOuter1PadPitchLength();
4469 f1PadPitchLength = par->GetOuter1PadPitchLength();
4470 f2PadPitchLength = par->GetOuter2PadPitchLength();
4472 fN=par->GetNRowUp();
4473 fRow=new AliTPCRow[fN];
4474 for (Int_t i=0; i<fN; i++) {
4475 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4476 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4482 AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4488 //_________________________________________________________________________
4490 AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4491 //-----------------------------------------------------------------------
4492 // Insert a cluster into this pad row in accordence with its y-coordinate
4493 //-----------------------------------------------------------------------
4494 if (fN==kMaxClusterPerRow) {
4495 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4497 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4498 Int_t i=Find(c->GetZ());
4499 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4500 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4501 fIndex[i]=index; fClusters[i]=c; fN++;
4505 //___________________________________________________________________
4506 Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4507 //-----------------------------------------------------------------------
4508 // Return the index of the nearest cluster
4509 //-----------------------------------------------------------------------
4510 if (fN==0) return 0;
4511 if (z <= fClusters[0]->GetZ()) return 0;
4512 if (z > fClusters[fN-1]->GetZ()) return fN;
4513 Int_t b=0, e=fN-1, m=(b+e)/2;
4514 for (; b<e; m=(b+e)/2) {
4515 if (z > fClusters[m]->GetZ()) b=m+1;
4523 //___________________________________________________________________
4524 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4525 //-----------------------------------------------------------------------
4526 // Return the index of the nearest cluster in z y
4527 //-----------------------------------------------------------------------
4528 Float_t maxdistance = roady*roady + roadz*roadz;
4530 AliTPCclusterMI *cl =0;
4531 for (Int_t i=Find(z-roadz); i<fN; i++) {
4532 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4533 if (c->GetZ() > z+roadz) break;
4534 if ( (c->GetY()-y) > roady ) continue;
4535 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4536 if (maxdistance>distance) {
4537 maxdistance = distance;
4544 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4546 //-----------------------------------------------------------------------
4547 // Return the index of the nearest cluster in z y
4548 //-----------------------------------------------------------------------
4549 Float_t maxdistance = roady*roady + roadz*roadz;
4550 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4551 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4553 AliTPCclusterMI *cl =0;
4554 //FindNearest3(y,z,roady,roadz,index);
4555 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4556 for (Int_t i=iz1; i<iz2; i++) {
4557 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4558 if (c->GetZ() > z+roadz) break;
4559 if ( c->GetY()-y > roady ) continue;
4560 if ( y-c->GetY() > roady ) continue;
4561 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4562 if (maxdistance>distance) {
4563 maxdistance = distance;
4566 //roady = TMath::Sqrt(maxdistance);
4574 AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4576 //-----------------------------------------------------------------------
4577 // Return the index of the nearest cluster in z y
4578 //-----------------------------------------------------------------------
4579 Float_t maxdistance = roady*roady + roadz*roadz;
4580 // Int_t iz = Int_t(z+255.);
4581 AliTPCclusterMI *cl =0;
4582 for (Int_t i=Find(z-roadz); i<fN; i++) {
4583 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4584 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4585 if (c->GetZ() > z+roadz) break;
4586 if ( c->GetY()-y > roady ) continue;
4587 if ( y-c->GetY() > roady ) continue;
4588 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4589 if (maxdistance>distance) {
4590 maxdistance = distance;
4593 //roady = TMath::Sqrt(maxdistance);
4602 AliTPCseed::AliTPCseed():AliTPCtrack(){
4606 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4607 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4623 AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
4630 for (Int_t i=0;i<160;i++) {
4631 fClusterPointer[i] = 0;
4632 Int_t index = t.GetClusterIndex(i);
4634 SetClusterIndex2(i,index);
4637 SetClusterIndex2(i,-3);
4647 AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
4649 for (Int_t i=0;i<160;i++) {
4650 fClusterPointer[i] = 0;
4651 Int_t index = t.GetClusterIndex(i);
4652 SetClusterIndex2(i,index);
4669 AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
4670 Double_t xr, Double_t alpha):
4671 AliTPCtrack(index, xx, cc, xr, alpha) {
4675 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4676 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4685 // fHelixIn = new TClonesArray("AliHelix",0);
4686 //fHelixOut = new TClonesArray("AliHelix",0);
4693 AliTPCseed::~AliTPCseed(){
4694 if (fPoints) delete fPoints;
4696 if (fEPoints) delete fEPoints;
4701 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
4705 return &fTrackPoints[i];
4708 void AliTPCseed::RebuildSeed()
4711 // rebuild seed to be ready for storing
4712 AliTPCclusterMI cldummy;
4714 AliTPCTrackPoint pdummy;
4715 pdummy.GetTPoint().fIsShared = 10;
4716 for (Int_t i=0;i<160;i++){
4717 AliTPCclusterMI * cl0 = fClusterPointer[i];
4718 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
4720 trpoint->GetTPoint() = *(GetTrackPoint(i));
4721 trpoint->GetCPoint() = *cl0;
4722 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
4726 trpoint->GetCPoint()= cldummy;
4734 Double_t AliTPCseed::GetDensityFirst(Int_t n)
4738 // return cluster for n rows bellow first point
4739 Int_t nfoundable = 1;
4741 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
4742 Int_t index = GetClusterIndex2(i);
4743 if (index!=-1) nfoundable++;
4744 if (index>0) nfound++;
4746 if (nfoundable<n) return 0;
4747 return Double_t(nfound)/Double_t(nfoundable);
4752 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
4754 // get cluster stat. on given region
4759 for (Int_t i=first;i<last; i++){
4760 Int_t index = GetClusterIndex2(i);
4761 if (index!=-1) foundable++;
4762 if (fClusterPointer[i]) {
4768 if (fClusterPointer[i]->IsUsed(10)) {
4772 if (!plus2) continue; //take also neighborhoud
4774 if ( (i>0) && fClusterPointer[i-1]){
4775 if (fClusterPointer[i-1]->IsUsed(10)) {
4780 if ( fClusterPointer[i+1]){
4781 if (fClusterPointer[i+1]->IsUsed(10)) {
4789 printf("problem\n");
4793 //_____________________________________________________________________________
4794 void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
4795 //-----------------------------------------------------------------
4796 // This funtion calculates dE/dX within the "low" and "up" cuts.
4797 //-----------------------------------------------------------------
4800 Float_t angular[200];
4801 Float_t weight[200];
4804 // TClonesArray & arr = *fPoints;
4805 Float_t meanlog = 100.;
4807 Float_t mean[4] = {0,0,0,0};
4808 Float_t sigma[4] = {1000,1000,1000,1000};
4809 Int_t nc[4] = {0,0,0,0};
4810 Float_t norm[4] = {1000,1000,1000,1000};
4815 for (Int_t of =0; of<4; of++){
4816 for (Int_t i=of+i1;i<i2;i+=4)
4818 Int_t index = fIndex[i];
4819 if (index<0||index&0x8000) continue;
4821 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
4822 AliTPCTrackerPoint * point = GetTrackPoint(i);
4823 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
4824 //AliTPCTrackerPoint * pointp = 0;
4825 //if (i<159) pointp = GetTrackPoint(i+1);
4827 if (point==0) continue;
4828 AliTPCclusterMI * cl = fClusterPointer[i];
4829 if (cl==0) continue;
4830 if (onlyused && (!cl->IsUsed(10))) continue;
4831 if (cl->IsUsed(11)) {
4835 Int_t type = cl->GetType();
4836 //if (point->fIsShared){
4841 // if (pointm->fIsShared) continue;
4843 // if (pointp->fIsShared) continue;
4845 if (type<0) continue;
4846 //if (type>10) continue;
4847 //if (point->GetErrY()==0) continue;
4848 //if (point->GetErrZ()==0) continue;
4850 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
4851 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
4852 //if ((ddy*ddy+ddz*ddz)>10) continue;
4855 // if (point->GetCPoint().GetMax()<5) continue;
4856 if (cl->GetMax()<5) continue;
4857 Float_t angley = point->GetAngleY();
4858 Float_t anglez = point->GetAngleZ();
4860 Float_t rsigmay2 = point->GetSigmaY();
4861 Float_t rsigmaz2 = point->GetSigmaZ();
4865 rsigmay += pointm->GetTPoint().GetSigmaY();
4866 rsigmaz += pointm->GetTPoint().GetSigmaZ();
4870 rsigmay += pointp->GetTPoint().GetSigmaY();
4871 rsigmaz += pointp->GetTPoint().GetSigmaZ();
4878 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
4880 Float_t ampc = 0; // normalization to the number of electrons
4882 // ampc = 1.*point->GetCPoint().GetMax();
4883 ampc = 1.*cl->GetMax();
4884 //ampc = 1.*point->GetCPoint().GetQ();
4885 // AliTPCClusterPoint & p = point->GetCPoint();
4886 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
4887 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4889 // TMath::Abs( Int_t(iz) - iz + 0.5);
4890 //ampc *= 1.15*(1-0.3*dy);
4891 //ampc *= 1.15*(1-0.3*dz);
4892 // Float_t zfactor = (1.05-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
4896 //ampc = 1.0*point->GetCPoint().GetMax();
4897 ampc = 1.0*cl->GetMax();
4898 //ampc = 1.0*point->GetCPoint().GetQ();
4899 //AliTPCClusterPoint & p = point->GetCPoint();
4900 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
4901 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
4903 // TMath::Abs( Int_t(iz) - iz + 0.5);
4905 //ampc *= 1.15*(1-0.3*dy);
4906 //ampc *= 1.15*(1-0.3*dz);
4907 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
4911 ampc *= 2.0; // put mean value to channel 50
4912 //ampc *= 0.58; // put mean value to channel 50
4914 // if (type>0) w = 1./(type/2.-0.5);
4915 // Float_t z = TMath::Abs(cl->GetZ());
4918 //ampc /= (1+0.0008*z);
4922 //ampc /= (1+0.0008*z);
4924 //ampc /= (1+0.0008*z);
4927 if (type<0) { //amp at the border - lower weight
4932 if (rsigma>1.5) ampc/=1.3; // if big backround
4934 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
4939 TMath::Sort(nc[of],amp,index,kFALSE);
4943 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
4945 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
4946 Float_t ampl = amp[index[i]]/angular[index[i]];
4947 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
4949 sumw += weight[index[i]];
4950 sumamp += weight[index[i]]*ampl;
4951 sumamp2 += weight[index[i]]*ampl*ampl;
4952 norm[of] += angular[index[i]]*weight[index[i]];
4959 mean[of] = sumamp/sumw;
4960 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
4962 sigma[of] = TMath::Sqrt(sigma[of]);
4966 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
4967 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
4968 //mean *=(1-0.1*(norm-1.));
4975 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
4976 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
4979 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
4980 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
4984 for (Int_t i =0;i<4;i++){
4985 if (nc[i]>2&&nc[i]<1000){
4986 dedx += mean[i] *nc[i];
4987 fSdEdx += sigma[i]*(nc[i]-2);
4988 fMAngular += norm[i] *nc[i];
4993 fSDEDX[i] = sigma[i];
5006 // Float_t dedx1 =dedx;
5009 for (Int_t i =0;i<4;i++){
5010 if (nc[i]>2&&nc[i]<1000){
5011 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5012 dedx += mean[i] *nc[i];
5027 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5030 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5031 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5032 SetMass(0.93827); return;
5036 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5037 SetMass(0.93827); return;
5040 SetMass(0.13957); return;
5050 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5051 //-----------------------------------------------------------------
5052 // This funtion calculates dE/dX within the "low" and "up" cuts.
5053 //-----------------------------------------------------------------
5056 Float_t angular[200];
5057 Float_t weight[200];
5059 Bool_t inlimit[200];
5060 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5061 for (Int_t i=0;i<200;i++) amp[i]=10000;
5062 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5066 Float_t meanlog = 100.;
5067 Int_t indexde[4]={0,64,128,160};
5074 Float_t mean[4] = {0,0,0,0};
5075 Float_t sigma[4] = {1000,1000,1000,1000};
5076 Int_t nc[4] = {0,0,0,0};
5077 Float_t norm[4] = {1000,1000,1000,1000};
5082 // for (Int_t of =0; of<3; of++){
5083 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5084 for (Int_t i =0; i<160;i++)
5086 AliTPCTrackPoint * point = GetTrackPoint(i);
5087 if (point==0) continue;
5088 if (point->fIsShared){
5092 Int_t type = point->GetCPoint().GetType();
5093 if (type<0) continue;
5094 if (point->GetCPoint().GetMax()<5) continue;
5095 Float_t angley = point->GetTPoint().GetAngleY();
5096 Float_t anglez = point->GetTPoint().GetAngleZ();
5097 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5098 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5099 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5101 Float_t ampc = 0; // normalization to the number of electrons
5103 ampc = point->GetCPoint().GetMax();
5106 ampc = point->GetCPoint().GetMax();
5108 ampc *= 2.0; // put mean value to channel 50
5109 // ampc *= 0.565; // put mean value to channel 50
5112 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5119 if (type<0) { //amp at the border - lower weight
5122 if (rsigma>1.5) ampc/=1.3; // if big backround
5123 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5124 amp[i] = ampc/angular[i];
5129 TMath::Sort(159,amp,index,kFALSE);
5130 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5131 inlimit[index[i]] = kTRUE; // take all clusters
5134 // meanlog = amp[index[Int_t(anc*0.3)]];
5136 for (Int_t of =0; of<3; of++){
5140 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5142 if (inlimit[i]==kFALSE) continue;
5143 Float_t ampl = amp[i];
5145 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5148 sumamp += weight[i]*ampl;
5149 sumamp2 += weight[i]*ampl*ampl;
5150 norm[of] += angular[i]*weight[i];
5158 mean[of] = sumamp/sumw;
5159 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5161 sigma[of] = TMath::Sqrt(sigma[of]);
5164 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5174 Float_t www[3] = {12.,14.,17.};
5175 //Float_t www[3] = {1.,1.,1.};
5177 for (Int_t i =0;i<3;i++){
5178 if (nc[i]>2&&nc[i]<1000){
5179 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5180 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5181 fMAngular += norm[i] *nc[i];
5182 norm2 += nc[i]*www[i]/sigma[i];
5183 norm3 += (nc[i]-2)*www[i]/sigma[i];
5186 fSDEDX[i] = sigma[i];
5199 // Float_t dedx1 =dedx;
5203 for (Int_t i =0;i<3;i++){
5204 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5205 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5206 dedx += mean[i] *(nc[i])/(sigma[i]);
5207 norm4 += (nc[i])/(sigma[i]);
5211 if (norm4>0) dedx /= norm4;