Update of non-siochronity by Christian. Removal of non-staggered geometry
[u/mrichter/AliRoot.git] / TPC / AliTPCtrackerMI.cxx
CommitLineData
1c53abe2 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
1c53abe2 16
17//-------------------------------------------------------
18// Implementation of the TPC tracker
19//
20// Origin: Marian Ivanov Marian.Ivanov@cern.ch
21//
47966a6d 22// AliTPC parallel tracker -
23// How to use? -
24// run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
25// run AliTPCFindTracksMI.C macro - to find tracks
26// tracks are written to AliTPCtracks.root file
27// for comparison also seeds are written to the same file - to special branch
1c53abe2 28//-------------------------------------------------------
47966a6d 29
30
31/* $Id$ */
32
33
b67e07dc 34
cc5e9db0 35#include "Riostream.h"
6d171107 36#include <TClonesArray.h>
37#include <TFile.h>
38#include <TObjArray.h>
39#include <TTree.h>
1c53abe2 40
47966a6d 41#include "AliComplexCluster.h"
91162307 42#include "AliESD.h"
43#include "AliHelix.h"
91162307 44#include "AliRunLoader.h"
6d171107 45#include "AliTPCClustersRow.h"
46#include "AliTPCParam.h"
47#include "AliTPCclusterMI.h"
48#include "AliTPCpolyTrack.h"
b67e07dc 49#include "AliTPCreco.h"
50#include "AliTPCtrackerMI.h"
6d171107 51#include "TStopwatch.h"
d7a11555 52
53#include "AliTPCReconstructor.h"
6d171107 54//
c9427e08 55
91162307 56ClassImp(AliTPCseed)
57ClassImp(AliTPCtrackerMI)
c9427e08 58
59
b67e07dc 60class AliTPCFastMath {
91162307 61public:
b67e07dc 62 AliTPCFastMath();
91162307 63 static Double_t FastAsin(Double_t x);
64 private:
b67e07dc 65 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
91162307 66};
c9427e08 67
b67e07dc 68Double_t AliTPCFastMath::fgFastAsin[20000];
2274b54b 69AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
c9427e08 70
b67e07dc 71AliTPCFastMath::AliTPCFastMath(){
72 //
73 // initialized lookup table;
91162307 74 for (Int_t i=0;i<10000;i++){
75 fgFastAsin[2*i] = TMath::ASin(i/10000.);
76 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
77 }
c9427e08 78}
79
b67e07dc 80Double_t AliTPCFastMath::FastAsin(Double_t x){
81 //
82 // return asin using lookup table
91162307 83 if (x>0){
84 Int_t index = int(x*10000);
85 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
86 }
87 x*=-1;
88 Int_t index = int(x*10000);
89 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
1c53abe2 90}
91
92
93
94
91162307 95Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
b67e07dc 96 //
97 //update track information using current cluster - track->fCurrentCluster
98
1c53abe2 99
91162307 100 AliTPCclusterMI* c =track->fCurrentCluster;
101 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
c9427e08 102
91162307 103 UInt_t i = track->fCurrentClusterIndex1;
1c53abe2 104
105 Int_t sec=(i&0xff000000)>>24;
91162307 106 //Int_t row = (i&0x00ff0000)>>16;
1c53abe2 107 track->fRow=(i&0x00ff0000)>>16;
108 track->fSector = sec;
109 // Int_t index = i&0xFFFF;
110 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
d26d9159 111 track->SetClusterIndex2(track->fRow, i);
91162307 112 //track->fFirstPoint = row;
113 //if ( track->fLastPoint<row) track->fLastPoint =row;
114 // if (track->fRow<0 || track->fRow>160) {
115 // printf("problem\n");
116 //}
117 if (track->fFirstPoint>track->fRow)
118 track->fFirstPoint = track->fRow;
119 if (track->fLastPoint<track->fRow)
120 track->fLastPoint = track->fRow;
121
122
123 track->fClusterPointer[track->fRow] = c;
1c53abe2 124 //
125
1c53abe2 126 Float_t angle2 = track->GetSnp()*track->GetSnp();
127 angle2 = TMath::Sqrt(angle2/(1-angle2));
128 //
129 //SET NEW Track Point
130 //
91162307 131 // if (debug)
132 {
133 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
1c53abe2 134 //
91162307 135 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
136 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
137 point.SetErrY(sqrt(track->fErrorY2));
138 point.SetErrZ(sqrt(track->fErrorZ2));
1c53abe2 139 //
91162307 140 point.SetX(track->GetX());
141 point.SetY(track->GetY());
142 point.SetZ(track->GetZ());
143 point.SetAngleY(angle2);
144 point.SetAngleZ(track->GetTgl());
145 if (point.fIsShared){
146 track->fErrorY2 *= 4;
147 track->fErrorZ2 *= 4;
148 }
149 }
150
151 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
152 //
153 track->fErrorY2 *= 1.3;
154 track->fErrorY2 += 0.01;
155 track->fErrorZ2 *= 1.3;
156 track->fErrorZ2 += 0.005;
157 //}
158 if (accept>0) return 0;
159 if (track->GetNumberOfClusters()%20==0){
160 // if (track->fHelixIn){
161 // TClonesArray & larr = *(track->fHelixIn);
162 // Int_t ihelix = larr.GetEntriesFast();
163 // new(larr[ihelix]) AliHelix(*track) ;
164 //}
1c53abe2 165 }
91162307 166 track->fNoCluster =0;
167 return track->Update(c,chi2,i);
168}
169
170
171
172Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
173 Float_t cory, Float_t corz)
174{
1c53abe2 175 //
91162307 176 // decide according desired precision to accept given
177 // cluster for tracking
178 Double_t sy2=ErrY2(seed,cluster)*cory;
179 Double_t sz2=ErrZ2(seed,cluster)*corz;
180 //sy2=ErrY2(seed,cluster)*cory;
181 //sz2=ErrZ2(seed,cluster)*cory;
1c53abe2 182
91162307 183 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
184 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
185
186 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
187 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
188 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
189 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
190
191 Double_t rdistance2 = rdistancey2+rdistancez2;
192 //Int_t accept =0;
1c53abe2 193
91162307 194 if (rdistance2>16) return 3;
195
196
197 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
198 return 2; //suspisiouce - will be changed
199
200 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
201 // strict cut on overlaped cluster
202 return 2; //suspisiouce - will be changed
203
204 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
205 && cluster->GetType()<0){
206 seed->fNFoundable--;
207 return 2;
1c53abe2 208 }
91162307 209 return 0;
210}
211
212
1c53abe2 213
1c53abe2 214
1c53abe2 215//_____________________________________________________________________________
f8aae377 216AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
1c53abe2 217AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
218{
219 //---------------------------------------------------------------------
220 // The main TPC tracker constructor
221 //---------------------------------------------------------------------
222 fInnerSec=new AliTPCSector[fkNIS];
223 fOuterSec=new AliTPCSector[fkNOS];
91162307 224
1c53abe2 225 Int_t i;
226 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
227 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
228
229 fN=0; fSectors=0;
230
1c53abe2 231 fSeeds=0;
232 fNtracks = 0;
91162307 233 fParam = par;
234 Int_t nrowlow = par->GetNRowLow();
235 Int_t nrowup = par->GetNRowUp();
236
237
238 for (Int_t i=0;i<nrowlow;i++){
239 fXRow[i] = par->GetPadRowRadiiLow(i);
240 fPadLength[i]= par->GetPadPitchLength(0,i);
241 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
242 }
243
244
245 for (Int_t i=0;i<nrowup;i++){
246 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
247 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
248 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
249 }
250 fSeeds=0;
251 //
252 fInput = 0;
253 fOutput = 0;
254 fSeedTree = 0;
255 fTreeDebug =0;
256 fNewIO =0;
257 fDebug =0;
258 fEvent =0;
1c53abe2 259}
2fc0c115 260//________________________________________________________________________
58251ea0 261AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
262 AliTracker(t),
263 fkNIS(t.fkNIS),
264 fkNOS(t.fkNOS)
265{
2fc0c115 266 //------------------------------------
267 // dummy copy constructor
268 //------------------------------------------------------------------
269}
270AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
271 //------------------------------
272 // dummy
273 //--------------------------------------------------------------
274 return *this;
275}
1c53abe2 276//_____________________________________________________________________________
277AliTPCtrackerMI::~AliTPCtrackerMI() {
278 //------------------------------------------------------------------
279 // TPC tracker destructor
280 //------------------------------------------------------------------
281 delete[] fInnerSec;
282 delete[] fOuterSec;
283 if (fSeeds) {
284 fSeeds->Delete();
285 delete fSeeds;
286 }
287}
288
91162307 289void AliTPCtrackerMI::SetIO()
290{
1c53abe2 291 //
91162307 292 fNewIO = kTRUE;
e191bb57 293 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
d26d9159 294
e191bb57 295 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
d26d9159 296 if (fOutput){
297 AliTPCtrack *iotrack= new AliTPCtrack;
298 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
299 delete iotrack;
300 }
91162307 301}
1c53abe2 302
d26d9159 303
91162307 304void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
305{
1c53abe2 306
91162307 307 // set input
308 fNewIO = kFALSE;
309 fInput = 0;
310 fOutput = 0;
311 fSeedTree = 0;
312 fTreeDebug =0;
313 fInput = input;
314 if (input==0){
315 return;
316 }
317 //set output
318 fOutput = output;
319 if (output){
320 AliTPCtrack *iotrack= new AliTPCtrack;
321 // iotrack->fHelixIn = new TClonesArray("AliHelix");
322 //iotrack->fHelixOut = new TClonesArray("AliHelix");
323 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
324 delete iotrack;
325 }
326 if (output && (fDebug&2)){
327 //write the full seed information if specified in debug mode
328 //
329 fSeedTree = new TTree("Seeds","Seeds");
330 AliTPCseed * vseed = new AliTPCseed;
331 //
332 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
333 arrtr->ExpandCreateFast(160);
334 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
335 //
336 vseed->fPoints = arrtr;
337 vseed->fEPoints = arre;
338 // vseed->fClusterPoints = arrcl;
339 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
340 delete arrtr;
341 delete arre;
342 fTreeDebug = new TTree("trackDebug","trackDebug");
343 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
344 fTreeDebug->Branch("debug",&arrd,32000,99);
1c53abe2 345 }
1c53abe2 346
1c53abe2 347
91162307 348 //set ESD event
349 fEvent = event;
350}
1c53abe2 351
d26d9159 352void AliTPCtrackerMI::FillESD(TObjArray* arr)
91162307 353{
47966a6d 354 //
355 //
356 //fill esds using updated tracks
91162307 357 if (fEvent){
358 // write tracks to the event
359 // store index of the track
d26d9159 360 Int_t nseed=arr->GetEntriesFast();
91162307 361 for (Int_t i=0; i<nseed; i++) {
d26d9159 362 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 363 if (!pt) continue;
d26d9159 364 pt->PropagateTo(fParam->GetInnerRadiusLow());
4d158c36 365 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
d26d9159 366 AliESDtrack iotrack;
367 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
368 //iotrack.SetTPCindex(i);
369 fEvent->AddTrack(&iotrack);
a42a6bae 370 continue;
371 }
372 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
373 Int_t found,foundable,shared;
374 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
375 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
376 AliESDtrack iotrack;
377 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
378 //iotrack.SetTPCindex(i);
379 fEvent->AddTrack(&iotrack);
380 continue;
381 }
382 }
383
384 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
385 Int_t found,foundable,shared;
386 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
387 if (found<20) continue;
388 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
389 //
390 AliESDtrack iotrack;
391 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
392 //iotrack.SetTPCindex(i);
393 fEvent->AddTrack(&iotrack);
394 continue;
395 }
91162307 396 }
1c53abe2 397 }
d26d9159 398}
399
47966a6d 400void AliTPCtrackerMI::WriteTracks(TTree * tree)
401{
d26d9159 402 //
47966a6d 403 // write tracks from seed array to selected tree
d26d9159 404 //
405 fOutput = tree;
406 if (fOutput){
407 AliTPCtrack *iotrack= new AliTPCtrack;
408 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
409 }
410 WriteTracks();
411}
412
413void AliTPCtrackerMI::WriteTracks()
414{
415 //
416 // write tracks to the given output tree -
417 // output specified with SetIO routine
418 if (!fSeeds) return;
419 if (!fOutput){
420 SetIO();
421 }
1c53abe2 422
91162307 423 if (fOutput){
424 AliTPCtrack *iotrack= 0;
425 Int_t nseed=fSeeds->GetEntriesFast();
982aff31 426 //for (Int_t i=0; i<nseed; i++) {
427 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
428 // if (iotrack) break;
429 //}
91162307 430 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
431 TBranch * br = fOutput->GetBranch("tracks");
432 br->SetAddress(&iotrack);
433 //
434 for (Int_t i=0; i<nseed; i++) {
435 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
436 if (!pt) continue;
982aff31 437 AliTPCtrack * track = new AliTPCtrack(*pt);
438 iotrack = track;
91162307 439 pt->fLab2 =i;
440 // br->SetAddress(&iotrack);
441 fOutput->Fill();
982aff31 442 delete track;
91162307 443 iotrack =0;
444 }
982aff31 445 //fOutput->GetDirectory()->cd();
446 //fOutput->Write();
91162307 447 }
d26d9159 448 // delete iotrack;
449 //
91162307 450 if (fSeedTree){
451 //write the full seed information if specified in debug mode
452
453 AliTPCseed * vseed = new AliTPCseed;
454 //
455 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
456 arrtr->ExpandCreateFast(160);
457 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
458 //arrcl->ExpandCreateFast(160);
459 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
460 //
461 vseed->fPoints = arrtr;
462 vseed->fEPoints = arre;
463 // vseed->fClusterPoints = arrcl;
464 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
465 TBranch * brseed = fSeedTree->GetBranch("seeds");
466
467 Int_t nseed=fSeeds->GetEntriesFast();
468
469 for (Int_t i=0; i<nseed; i++) {
470 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
471 if (!pt) continue;
472 pt->fPoints = arrtr;
473 // pt->fClusterPoints = arrcl;
474 pt->fEPoints = arre;
475 pt->RebuildSeed();
476 vseed = pt;
477 brseed->SetAddress(&vseed);
478 fSeedTree->Fill();
479 pt->fPoints = 0;
480 pt->fEPoints = 0;
481 // pt->fClusterPoints = 0;
482 }
483 fSeedTree->Write();
484 if (fTreeDebug) fTreeDebug->Write();
485 }
1c53abe2 486
91162307 487}
1c53abe2 488
1c53abe2 489
1c53abe2 490
491
91162307 492Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
493 //
494 //
495 //seed->SetErrorY2(0.1);
496 //return 0.1;
497 //calculate look-up table at the beginning
498 static Bool_t ginit = kFALSE;
499 static Float_t gnoise1,gnoise2,gnoise3;
500 static Float_t ggg1[10000];
501 static Float_t ggg2[10000];
502 static Float_t ggg3[10000];
503 static Float_t glandau1[10000];
504 static Float_t glandau2[10000];
505 static Float_t glandau3[10000];
506 //
507 static Float_t gcor01[500];
508 static Float_t gcor02[500];
509 static Float_t gcorp[500];
510 //
1c53abe2 511
91162307 512 //
513 if (ginit==kFALSE){
514 for (Int_t i=1;i<500;i++){
515 Float_t rsigma = float(i)/100.;
516 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
517 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
518 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
519 }
1c53abe2 520
91162307 521 //
522 for (Int_t i=3;i<10000;i++){
523 //
524 //
525 // inner sector
526 Float_t amp = float(i);
527 Float_t padlength =0.75;
528 gnoise1 = 0.0004/padlength;
529 Float_t nel = 0.268*amp;
530 Float_t nprim = 0.155*amp;
531 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
532 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
533 if (glandau1[i]>1) glandau1[i]=1;
534 glandau1[i]*=padlength*padlength/12.;
535 //
536 // outer short
537 padlength =1.;
538 gnoise2 = 0.0004/padlength;
539 nel = 0.3*amp;
540 nprim = 0.133*amp;
541 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
542 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
543 if (glandau2[i]>1) glandau2[i]=1;
544 glandau2[i]*=padlength*padlength/12.;
545 //
546 //
547 // outer long
548 padlength =1.5;
549 gnoise3 = 0.0004/padlength;
550 nel = 0.3*amp;
551 nprim = 0.133*amp;
552 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
553 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
554 if (glandau3[i]>1) glandau3[i]=1;
555 glandau3[i]*=padlength*padlength/12.;
556 //
557 }
558 ginit = kTRUE;
559 }
1c53abe2 560 //
561 //
91162307 562 //
563 Int_t amp = int(TMath::Abs(cl->GetQ()));
564 if (amp>9999) {
565 seed->SetErrorY2(1.);
566 return 1.;
567 }
1c53abe2 568 Float_t snoise2;
c9427e08 569 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
91162307 570 Int_t ctype = cl->GetType();
571 Float_t padlength= GetPadPitchLength(seed->fRow);
572 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
573 angle2 = angle2/(1-angle2);
574 //
575 //cluster "quality"
576 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
577 Float_t res;
1c53abe2 578 //
1c53abe2 579 if (fSectors==fInnerSec){
91162307 580 snoise2 = gnoise1;
581 res = ggg1[amp]*z+glandau1[amp]*angle2;
582 if (ctype==0) res *= gcor01[rsigmay];
583 if ((ctype>0)){
584 res+=0.002;
585 res*= gcorp[rsigmay];
586 }
1c53abe2 587 }
588 else {
91162307 589 if (padlength<1.1){
590 snoise2 = gnoise2;
591 res = ggg2[amp]*z+glandau2[amp]*angle2;
592 if (ctype==0) res *= gcor02[rsigmay];
593 if ((ctype>0)){
594 res+=0.002;
595 res*= gcorp[rsigmay];
596 }
597 }
598 else{
599 snoise2 = gnoise3;
600 res = ggg3[amp]*z+glandau3[amp]*angle2;
601 if (ctype==0) res *= gcor02[rsigmay];
602 if ((ctype>0)){
603 res+=0.002;
604 res*= gcorp[rsigmay];
605 }
606 }
607 }
1c53abe2 608
91162307 609 if (ctype<0){
610 res+=0.005;
611 res*=2.4; // overestimate error 2 times
612 }
613 res+= snoise2;
614
1c53abe2 615 if (res<2*snoise2)
91162307 616 res = 2*snoise2;
617
618 seed->SetErrorY2(res);
1c53abe2 619 return res;
1c53abe2 620
621
91162307 622}
c9427e08 623
624
625
91162307 626Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
627 //
628 //
629 //seed->SetErrorY2(0.1);
630 //return 0.1;
631 //calculate look-up table at the beginning
632 static Bool_t ginit = kFALSE;
633 static Float_t gnoise1,gnoise2,gnoise3;
634 static Float_t ggg1[10000];
635 static Float_t ggg2[10000];
636 static Float_t ggg3[10000];
637 static Float_t glandau1[10000];
638 static Float_t glandau2[10000];
639 static Float_t glandau3[10000];
640 //
641 static Float_t gcor01[1000];
642 static Float_t gcor02[1000];
643 static Float_t gcorp[1000];
1627d1c4 644 //
1627d1c4 645
91162307 646 //
647 if (ginit==kFALSE){
648 for (Int_t i=1;i<1000;i++){
649 Float_t rsigma = float(i)/100.;
650 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
651 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
652 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
653 }
1c53abe2 654
91162307 655 //
656 for (Int_t i=3;i<10000;i++){
657 //
658 //
659 // inner sector
660 Float_t amp = float(i);
661 Float_t padlength =0.75;
662 gnoise1 = 0.0004/padlength;
663 Float_t nel = 0.268*amp;
664 Float_t nprim = 0.155*amp;
665 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
666 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
667 if (glandau1[i]>1) glandau1[i]=1;
668 glandau1[i]*=padlength*padlength/12.;
669 //
670 // outer short
671 padlength =1.;
672 gnoise2 = 0.0004/padlength;
673 nel = 0.3*amp;
674 nprim = 0.133*amp;
675 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
676 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
677 if (glandau2[i]>1) glandau2[i]=1;
678 glandau2[i]*=padlength*padlength/12.;
679 //
680 //
681 // outer long
682 padlength =1.5;
683 gnoise3 = 0.0004/padlength;
684 nel = 0.3*amp;
685 nprim = 0.133*amp;
686 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
687 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
688 if (glandau3[i]>1) glandau3[i]=1;
689 glandau3[i]*=padlength*padlength/12.;
690 //
691 }
692 ginit = kTRUE;
693 }
694 //
695 //
696 //
697 Int_t amp = int(TMath::Abs(cl->GetQ()));
698 if (amp>9999) {
699 seed->SetErrorY2(1.);
700 return 1.;
701 }
702 Float_t snoise2;
703 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
704 Int_t ctype = cl->GetType();
705 Float_t padlength= GetPadPitchLength(seed->fRow);
706 //
707 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
708 // if (angle2<0.6) angle2 = 0.6;
709 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
710 //
711 //cluster "quality"
712 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
713 Float_t res;
714 //
715 if (fSectors==fInnerSec){
716 snoise2 = gnoise1;
717 res = ggg1[amp]*z+glandau1[amp]*angle2;
718 if (ctype==0) res *= gcor01[rsigmaz];
719 if ((ctype>0)){
720 res+=0.002;
721 res*= gcorp[rsigmaz];
722 }
723 }
724 else {
725 if (padlength<1.1){
726 snoise2 = gnoise2;
727 res = ggg2[amp]*z+glandau2[amp]*angle2;
728 if (ctype==0) res *= gcor02[rsigmaz];
729 if ((ctype>0)){
730 res+=0.002;
731 res*= gcorp[rsigmaz];
732 }
733 }
734 else{
735 snoise2 = gnoise3;
736 res = ggg3[amp]*z+glandau3[amp]*angle2;
737 if (ctype==0) res *= gcor02[rsigmaz];
738 if ((ctype>0)){
739 res+=0.002;
740 res*= gcorp[rsigmaz];
741 }
742 }
743 }
744
745 if (ctype<0){
746 res+=0.002;
747 res*=1.3;
748 }
749 if ((ctype<0) &&amp<70){
750 res+=0.002;
751 res*=1.3;
752 }
753 res += snoise2;
754 if (res<2*snoise2)
755 res = 2*snoise2;
756 if (res>3) res =3;
757 seed->SetErrorZ2(res);
758 return res;
759}
760
761
762
763/*
764Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
765 //
766 //
767 //seed->SetErrorZ2(0.1);
768 //return 0.1;
769
770 Float_t snoise2;
771 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
772 //
773 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
774 Int_t ctype = cl->GetType();
775 Float_t amp = TMath::Abs(cl->GetQ());
776
777 Float_t nel;
778 Float_t nprim;
779 //
780 Float_t landau=2 ; //landau fluctuation part
781 Float_t gg=2; // gg fluctuation part
782 Float_t padlength= GetPadPitchLength(seed->GetX());
783
784 if (fSectors==fInnerSec){
785 snoise2 = 0.0004/padlength;
786 nel = 0.268*amp;
787 nprim = 0.155*amp;
788 gg = (2+0.001*nel/(padlength*padlength))/nel;
789 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
790 if (landau>1) landau=1;
791 }
792 else {
793 snoise2 = 0.0004/padlength;
794 nel = 0.3*amp;
795 nprim = 0.133*amp;
796 gg = (2+0.0008*nel/(padlength*padlength))/nel;
797 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
798 if (landau>1) landau=1;
799 }
800 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
801
802 //
803 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
804 angle2 = TMath::Sqrt((1-angle2));
805 if (angle2<0.6) angle2 = 0.6;
806 //angle2 = 1;
807
808 Float_t angle = seed->GetTgl()/angle2;
809 Float_t angular = landau*angle*angle*padlength*padlength/12.;
810 Float_t res = sdiff + angular;
811
812
813 if ((ctype==0) && (fSectors ==fOuterSec))
814 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
815
816 if ((ctype==0) && (fSectors ==fInnerSec))
817 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
818
819 if ((ctype>0)){
820 res+=0.005;
821 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
822 }
823 if (ctype<0){
824 res+=0.002;
825 res*=1.3;
826 }
827 if ((ctype<0) &&amp<70){
828 res+=0.002;
829 res*=1.3;
830 }
831 res += snoise2;
832 if (res<2*snoise2)
833 res = 2*snoise2;
834
835 seed->SetErrorZ2(res);
836 return res;
837}
838*/
839
840
841
842void AliTPCseed::Reset(Bool_t all)
843{
844 //
845 //
846 SetNumberOfClusters(0);
847 fNFoundable = 0;
848 SetChi2(0);
849 ResetCovariance();
850 /*
851 if (fTrackPoints){
852 for (Int_t i=0;i<8;i++){
853 delete [] fTrackPoints[i];
854 }
855 delete fTrackPoints;
856 fTrackPoints =0;
857 }
858 */
859
860 if (all){
861 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
862 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
863 }
864
865}
866
867
868void AliTPCseed::Modify(Double_t factor)
869{
870
871 //------------------------------------------------------------------
872 //This function makes a track forget its history :)
873 //------------------------------------------------------------------
874 if (factor<=0) {
875 ResetCovariance();
876 return;
877 }
878 fC00*=factor;
982aff31 879 fC10*=0; fC11*=factor;
880 fC20*=0; fC21*=0; fC22*=factor;
881 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
882 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
91162307 883 SetNumberOfClusters(0);
884 fNFoundable =0;
885 SetChi2(0);
886 fRemoval = 0;
887 fCurrentSigmaY2 = 0.000005;
888 fCurrentSigmaZ2 = 0.000005;
889 fNoCluster = 0;
890 //fFirstPoint = 160;
891 //fLastPoint = 0;
892}
893
894
895
896
897Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
898{
899 //-----------------------------------------------------------------
900 // This function find proloncation of a track to a reference plane x=xk.
901 // doesn't change internal state of the track
902 //-----------------------------------------------------------------
903
1c53abe2 904 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
91162307 905
906 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
907 return 0;
908 }
909
1c53abe2 910 // Double_t y1=fP0, z1=fP1;
911 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
912 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
913
914 y = fP0;
915 z = fP1;
91162307 916 //y += dx*(c1+c2)/(r1+r2);
917 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
918
919 Double_t dy = dx*(c1+c2)/(r1+r2);
920 Double_t dz = 0;
921 //
922 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
923 /*
924 if (TMath::Abs(delta)>0.0001){
925 dz = fP3*TMath::ASin(delta)/fP4;
926 }else{
927 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
928 }
929 */
b67e07dc 930 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
91162307 931 //
932 y+=dy;
933 z+=dz;
934
935
936 return 1;
1c53abe2 937}
938
939
940//_____________________________________________________________________________
941Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
942{
943 //-----------------------------------------------------------------
944 // This function calculates a predicted chi2 increment.
945 //-----------------------------------------------------------------
946 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
947 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
948 r00+=fC00; r01+=fC10; r11+=fC11;
949
950 Double_t det=r00*r11 - r01*r01;
951 if (TMath::Abs(det) < 1.e-10) {
952 Int_t n=GetNumberOfClusters();
953 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
954 return 1e10;
955 }
956 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
957
958 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
959
960 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
961}
962
963
964//_________________________________________________________________________________________
965
966
967Int_t AliTPCseed::Compare(const TObject *o) const {
968 //-----------------------------------------------------------------
969 // This function compares tracks according to the sector - for given sector according z
970 //-----------------------------------------------------------------
971 AliTPCseed *t=(AliTPCseed*)o;
1c53abe2 972
91162307 973 if (fSort == 0){
974 if (t->fRelativeSector>fRelativeSector) return -1;
975 if (t->fRelativeSector<fRelativeSector) return 1;
976 Double_t z2 = t->GetZ();
977 Double_t z1 = GetZ();
978 if (z2>z1) return 1;
979 if (z2<z1) return -1;
980 return 0;
981 }
982 else {
983 Float_t f2 =1;
984 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
985 if (t->fBConstrain) f2=1.2;
986
987 Float_t f1 =1;
988 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
989
990 if (fBConstrain) f1=1.2;
991
992 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
993 else return +1;
994 }
1c53abe2 995}
996
c9427e08 997void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
998{
999 //rotate to track "local coordinata
1000 Float_t x = seed->GetX();
1001 Float_t y = seed->GetY();
1002 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
91162307 1003
c9427e08 1004 if (y > ymax) {
1005 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
1006 if (!seed->Rotate(fSectors->GetAlpha()))
1007 return;
1008 } else if (y <-ymax) {
1009 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
1010 if (!seed->Rotate(-fSectors->GetAlpha()))
1011 return;
1012 }
1c53abe2 1013
c9427e08 1014}
1c53abe2 1015
1016
1017
1018
1019//_____________________________________________________________________________
176aff27 1020Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
1c53abe2 1021 //-----------------------------------------------------------------
1022 // This function associates a cluster with this track.
1023 //-----------------------------------------------------------------
1c53abe2 1024 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
1025
1026 r00+=fC00; r01+=fC10; r11+=fC11;
1027 Double_t det=r00*r11 - r01*r01;
1028 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
1029
1030 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
1031 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
1032 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
1033 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
1034 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
1035
1036 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
1037 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
1627d1c4 1038 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1c53abe2 1039 return 0;
1040 }
1041
1042 fP0 += k00*dy + k01*dz;
1043 fP1 += k10*dy + k11*dz;
1044 fP2 = eta;
1045 fP3 += k30*dy + k31*dz;
1046 fP4 = cur;
1047
1048 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1049 Double_t c12=fC21, c13=fC31, c14=fC41;
1050
1051 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1052 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1053 fC40-=k00*c04+k01*c14;
1054
1055 fC11-=k10*c01+k11*fC11;
1056 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1057 fC41-=k10*c04+k11*c14;
1058
1059 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1060 fC42-=k20*c04+k21*c14;
1061
1062 fC33-=k30*c03+k31*c13;
1063 fC43-=k40*c03+k41*c13;
1064
1065 fC44-=k40*c04+k41*c14;
1066
1067 Int_t n=GetNumberOfClusters();
91162307 1068 // fIndex[n]=index;
1c53abe2 1069 SetNumberOfClusters(n+1);
1070 SetChi2(GetChi2()+chisq);
1071
1072 return 1;
1073}
1074
1075
1076
1077//_____________________________________________________________________________
b67e07dc 1078Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1c53abe2 1079 Double_t x2,Double_t y2,
1080 Double_t x3,Double_t y3)
1081{
1082 //-----------------------------------------------------------------
1083 // Initial approximation of the track curvature
1084 //-----------------------------------------------------------------
1085 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1086 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1087 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1088 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1089 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1090
1091 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
91162307 1092 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1c53abe2 1093 return -xr*yr/sqrt(xr*xr+yr*yr);
1094}
1095
1096
91162307 1097
1c53abe2 1098//_____________________________________________________________________________
b67e07dc 1099Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
91162307 1100 Double_t x2,Double_t y2,
1101 Double_t x3,Double_t y3)
1102{
1103 //-----------------------------------------------------------------
1104 // Initial approximation of the track curvature
1105 //-----------------------------------------------------------------
1106 x3 -=x1;
1107 x2 -=x1;
1108 y3 -=y1;
1109 y2 -=y1;
1110 //
1111 Double_t det = x3*y2-x2*y3;
1112 if (det==0) {
1113 return 100;
1114 }
1115 //
1116 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1117 Double_t x0 = x3*0.5-y3*u;
1118 Double_t y0 = y3*0.5+x3*u;
1119 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1120 if (det<0) c2*=-1;
1121 return c2;
1122}
1123
1124
b67e07dc 1125Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1c53abe2 1126 Double_t x2,Double_t y2,
1127 Double_t x3,Double_t y3)
91162307 1128{
1129 //-----------------------------------------------------------------
1130 // Initial approximation of the track curvature
1131 //-----------------------------------------------------------------
1132 x3 -=x1;
1133 x2 -=x1;
1134 y3 -=y1;
1135 y2 -=y1;
1136 //
1137 Double_t det = x3*y2-x2*y3;
1138 if (det==0) {
1139 return 100;
1140 }
1141 //
1142 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1143 Double_t x0 = x3*0.5-y3*u;
1144 Double_t y0 = y3*0.5+x3*u;
1145 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1146 if (det<0) c2*=-1;
1147 x0+=x1;
1148 x0*=c2;
1149 return x0;
1150}
1151
1152
1153
1154//_____________________________________________________________________________
b67e07dc 1155Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
91162307 1156 Double_t x2,Double_t y2,
1157 Double_t x3,Double_t y3)
1c53abe2 1158{
1159 //-----------------------------------------------------------------
1160 // Initial approximation of the track curvature times center of curvature
1161 //-----------------------------------------------------------------
1162 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1163 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1164 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1165 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1166 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1167
1168 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1169
1170 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1171}
1172
1173//_____________________________________________________________________________
b67e07dc 1174Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1c53abe2 1175 Double_t x2,Double_t y2,
1176 Double_t z1,Double_t z2)
1177{
1178 //-----------------------------------------------------------------
1179 // Initial approximation of the tangent of the track dip angle
1180 //-----------------------------------------------------------------
1181 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1182}
1183
1184
b67e07dc 1185Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
91162307 1186 Double_t x2,Double_t y2,
1187 Double_t z1,Double_t z2, Double_t c)
1c53abe2 1188{
91162307 1189 //-----------------------------------------------------------------
1190 // Initial approximation of the tangent of the track dip angle
1191 //-----------------------------------------------------------------
1192
1193 // Double_t angle1;
1194
1195 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1c53abe2 1196 //
91162307 1197 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1198 if (TMath::Abs(d*c*0.5)>1) return 0;
1199 // Double_t angle2 = TMath::ASin(d*c*0.5);
b67e07dc 1200 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1201 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
91162307 1202
1203 angle2 = (z1-z2)*c/(angle2*2.);
1204 return angle2;
1205}
1206
1207Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1208{//-----------------------------------------------------------------
1209 // This function find proloncation of a track to a reference plane x=x2.
1210 //-----------------------------------------------------------------
1211
1212 Double_t dx=x2-x1;
1213
1214 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1215 return kFALSE;
1c53abe2 1216 }
f8aae377 1217
91162307 1218 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1219 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1220 y = x[0];
1221 z = x[1];
1222
1223 Double_t dy = dx*(c1+c2)/(r1+r2);
1224 Double_t dz = 0;
1225 //
1226 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1227
1228 if (TMath::Abs(delta)>0.01){
1229 dz = x[3]*TMath::ASin(delta)/x[4];
1230 }else{
b67e07dc 1231 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
91162307 1232 }
1233
b67e07dc 1234 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
f8aae377 1235
91162307 1236 y+=dy;
1237 z+=dz;
1238
1239 return kTRUE;
1c53abe2 1240}
1241
d26d9159 1242Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1243{
1244 //
1245 //
1246 fInput = tree;
1247 return LoadClusters();
1248}
91162307 1249
1250Int_t AliTPCtrackerMI::LoadClusters()
1c53abe2 1251{
1252 //
1253 // load clusters to the memory
91162307 1254 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1255 clrow->SetClass("AliTPCclusterMI");
1256 clrow->SetArray(0);
1257 clrow->GetArray()->ExpandCreateFast(10000);
1258 //
1259 // TTree * tree = fClustersArray.GetTree();
1260
1261 TTree * tree = fInput;
1262 TBranch * br = tree->GetBranch("Segment");
1263 br->SetAddress(&clrow);
1264 //
1265 Int_t j=Int_t(tree->GetEntries());
1c53abe2 1266 for (Int_t i=0; i<j; i++) {
91162307 1267 br->GetEntry(i);
1268 //
1269 Int_t sec,row;
1270 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1271 //
1272 AliTPCRow * tpcrow=0;
1273 Int_t left=0;
1274 if (sec<fkNIS*2){
1275 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1276 left = sec/fkNIS;
1277 }
1278 else{
1279 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1280 left = (sec-fkNIS*2)/fkNOS;
1281 }
1282 if (left ==0){
1283 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1284 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1285 for (Int_t i=0;i<tpcrow->fN1;i++)
1286 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1287 }
1288 if (left ==1){
1289 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1290 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1291 for (Int_t i=0;i<tpcrow->fN2;i++)
1292 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1293 }
1c53abe2 1294 }
91162307 1295 //
1296 delete clrow;
1297 LoadOuterSectors();
1298 LoadInnerSectors();
1299 return 0;
1c53abe2 1300}
1301
1302
91162307 1303void AliTPCtrackerMI::UnloadClusters()
1304{
1305 //
1306 // unload clusters from the memory
1307 //
1308 Int_t nrows = fOuterSec->GetNRows();
1309 for (Int_t sec = 0;sec<fkNOS;sec++)
1310 for (Int_t row = 0;row<nrows;row++){
1311 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
982aff31 1312 // if (tpcrow){
1313 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1314 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1315 //}
1316 tpcrow->ResetClusters();
1c53abe2 1317 }
91162307 1318 //
1319 nrows = fInnerSec->GetNRows();
1320 for (Int_t sec = 0;sec<fkNIS;sec++)
1321 for (Int_t row = 0;row<nrows;row++){
1322 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
982aff31 1323 //if (tpcrow){
1324 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1325 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1326 //}
1327 tpcrow->ResetClusters();
91162307 1328 }
1329
1330 return ;
1c53abe2 1331}
1332
1333
1334//_____________________________________________________________________________
91162307 1335Int_t AliTPCtrackerMI::LoadOuterSectors() {
1c53abe2 1336 //-----------------------------------------------------------------
91162307 1337 // This function fills outer TPC sectors with clusters.
1c53abe2 1338 //-----------------------------------------------------------------
91162307 1339 Int_t nrows = fOuterSec->GetNRows();
1340 UInt_t index=0;
1341 for (Int_t sec = 0;sec<fkNOS;sec++)
1342 for (Int_t row = 0;row<nrows;row++){
1343 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1344 Int_t sec2 = sec+2*fkNIS;
1345 //left
1346 Int_t ncl = tpcrow->fN1;
1347 while (ncl--) {
1348 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1349 index=(((sec2<<8)+row)<<16)+ncl;
1350 tpcrow->InsertCluster(c,index);
1351 }
1352 //right
1353 ncl = tpcrow->fN2;
1354 while (ncl--) {
1355 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1356 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1357 tpcrow->InsertCluster(c,index);
1358 }
1359 //
1360 // write indexes for fast acces
1361 //
1362 for (Int_t i=0;i<510;i++)
1363 tpcrow->fFastCluster[i]=-1;
1364 for (Int_t i=0;i<tpcrow->GetN();i++){
1365 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1366 tpcrow->fFastCluster[zi]=i; // write index
1367 }
1368 Int_t last = 0;
1369 for (Int_t i=0;i<510;i++){
1370 if (tpcrow->fFastCluster[i]<0)
1371 tpcrow->fFastCluster[i] = last;
1372 else
1373 last = tpcrow->fFastCluster[i];
1374 }
1375 }
1376 fN=fkNOS;
1377 fSectors=fOuterSec;
1378 return 0;
1379}
1380
1381
1382//_____________________________________________________________________________
1383Int_t AliTPCtrackerMI::LoadInnerSectors() {
1384 //-----------------------------------------------------------------
1385 // This function fills inner TPC sectors with clusters.
1386 //-----------------------------------------------------------------
1387 Int_t nrows = fInnerSec->GetNRows();
1388 UInt_t index=0;
1389 for (Int_t sec = 0;sec<fkNIS;sec++)
1390 for (Int_t row = 0;row<nrows;row++){
1391 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1392 //
1393 //left
1394 Int_t ncl = tpcrow->fN1;
1395 while (ncl--) {
1396 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1397 index=(((sec<<8)+row)<<16)+ncl;
1398 tpcrow->InsertCluster(c,index);
1399 }
1400 //right
1401 ncl = tpcrow->fN2;
1402 while (ncl--) {
1403 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1404 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1405 tpcrow->InsertCluster(c,index);
1406 }
1407 //
1408 // write indexes for fast acces
1409 //
1410 for (Int_t i=0;i<510;i++)
1411 tpcrow->fFastCluster[i]=-1;
1412 for (Int_t i=0;i<tpcrow->GetN();i++){
1413 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1414 tpcrow->fFastCluster[zi]=i; // write index
1415 }
1416 Int_t last = 0;
1417 for (Int_t i=0;i<510;i++){
1418 if (tpcrow->fFastCluster[i]<0)
1419 tpcrow->fFastCluster[i] = last;
1420 else
1421 last = tpcrow->fFastCluster[i];
1422 }
1c53abe2 1423
91162307 1424 }
1425
1c53abe2 1426 fN=fkNIS;
1427 fSectors=fInnerSec;
91162307 1428 return 0;
1429}
1430
1431
1432
1433//_________________________________________________________________________
1434AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1435 //--------------------------------------------------------------------
1436 // Return pointer to a given cluster
1437 //--------------------------------------------------------------------
1438 Int_t sec=(index&0xff000000)>>24;
1439 Int_t row=(index&0x00ff0000)>>16;
d26d9159 1440 Int_t ncl=(index&0x00007fff)>>00;
91162307 1441
1442 const AliTPCRow * tpcrow=0;
1443 AliTPCclusterMI * clrow =0;
3da363a1 1444
91162307 1445 if (sec<fkNIS*2){
1446 tpcrow = &(fInnerSec[sec%fkNIS][row]);
3da363a1 1447 if (tpcrow==0) return 0;
1448
1449 if (sec<fkNIS) {
1450 if (tpcrow->fN1<=ncl) return 0;
91162307 1451 clrow = tpcrow->fClusters1;
3da363a1 1452 }
1453 else {
1454 if (tpcrow->fN2<=ncl) return 0;
91162307 1455 clrow = tpcrow->fClusters2;
3da363a1 1456 }
91162307 1457 }
3da363a1 1458 else {
91162307 1459 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
3da363a1 1460 if (tpcrow==0) return 0;
1461
1462 if (sec-2*fkNIS<fkNOS) {
1463 if (tpcrow->fN1<=ncl) return 0;
91162307 1464 clrow = tpcrow->fClusters1;
3da363a1 1465 }
1466 else {
1467 if (tpcrow->fN2<=ncl) return 0;
91162307 1468 clrow = tpcrow->fClusters2;
3da363a1 1469 }
91162307 1470 }
3da363a1 1471
91162307 1472 return &(clrow[ncl]);
1473
1c53abe2 1474}
1475
91162307 1476
1477
1c53abe2 1478Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1479 //-----------------------------------------------------------------
1480 // This function tries to find a track prolongation to next pad row
1481 //-----------------------------------------------------------------
1c53abe2 1482 //
91162307 1483 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
4d158c36 1484 AliTPCclusterMI *cl=0;
1485 Int_t tpcindex= t.GetClusterIndex2(nr);
1486 //
1487 // update current shape info every 5 pad-row
1488 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1489 GetShape(&t,nr);
1490 //}
1491 //
1492 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1493 //
1494 if (tpcindex==-1) return 0; //track in dead zone
1495 if (tpcindex>0){ //
1496 cl = t.fClusterPointer[nr];
e0656451 1497 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
4d158c36 1498 t.fCurrentClusterIndex1 = tpcindex;
1499 }
1500 if (cl){
1501 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1502 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1503 //
1504 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1505 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1506
1507 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1508 Double_t rotation = angle-t.GetAlpha();
1509 t.fRelativeSector= relativesector;
1510 t.Rotate(rotation);
1511 }
1512 t.PropagateTo(x);
1513 //
1514 t.fCurrentCluster = cl;
1515 t.fRow = nr;
1516 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1517 if ((tpcindex&0x8000)==0) accept =0;
1518 if (accept<3) {
1519 //if founded cluster is acceptible
1520 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1521 t.fErrorY2 += 0.03;
1522 t.fErrorZ2 += 0.03;
1523 t.fErrorY2 *= 3;
1524 t.fErrorZ2 *= 3;
1525 }
1526 t.fNFoundable++;
1527 UpdateTrack(&t,accept);
1528 return 1;
1529 }
1530 }
1627d1c4 1531 }
4d158c36 1532 if (fIteration>1) return 0; // not look for new cluster during refitting
91162307 1533 //
4d158c36 1534 UInt_t index=0;
1535 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1536 Double_t y=t.GetYat(x);
91162307 1537 if (TMath::Abs(y)>ymax){
1538 if (y > ymax) {
1539 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1540 if (!t.Rotate(fSectors->GetAlpha()))
1541 return 0;
1542 } else if (y <-ymax) {
1543 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1544 if (!t.Rotate(-fSectors->GetAlpha()))
1545 return 0;
1546 }
4d158c36 1547 //return 1;
91162307 1548 }
1549 //
4d158c36 1550 if (!t.PropagateTo(x)) {
1551 if (fIteration==0) t.fRemoval = 10;
1552 return 0;
91162307 1553 }
4d158c36 1554 y=t.GetY();
1555 Double_t z=t.GetZ();
1556 //
91162307 1557 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1558 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1559 Double_t roady =1.;
1560 Double_t roadz = 1.;
1561 //
1c53abe2 1562 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1563 t.fInDead = kTRUE;
91162307 1564 t.SetClusterIndex2(nr,-1);
1c53abe2 1565 return 0;
1566 }
1567 else
1568 {
d7a11555 1569 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10)) t.fNFoundable++;
1627d1c4 1570 else
1571 return 0;
1c53abe2 1572 }
1573 //calculate
91162307 1574 if (krow) {
1575 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1576 cl = krow.FindNearest2(y,z,roady,roadz,index);
1577 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1578 }
91162307 1579 if (cl) {
1580 t.fCurrentCluster = cl;
1581 t.fRow = nr;
4d158c36 1582 if (fIteration==2&&cl->IsUsed(10)) return 0;
91162307 1583 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
4d158c36 1584 if (fIteration==2&&cl->IsUsed(11)) {
1585 t.fErrorY2 += 0.03;
1586 t.fErrorZ2 += 0.03;
1587 t.fErrorY2 *= 3;
1588 t.fErrorZ2 *= 3;
1589 }
d26d9159 1590 /*
91162307 1591 if (t.fCurrentCluster->IsUsed(10)){
1592 //
1593 //
c9427e08 1594
91162307 1595 t.fNShared++;
1596 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1597 t.fRemoval =10;
1598 return 0;
1599 }
1600 }
d26d9159 1601 */
91162307 1602 if (accept<3) UpdateTrack(&t,accept);
c9427e08 1603
91162307 1604 } else {
982aff31 1605 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
91162307 1606
1607 }
1608 return 1;
1609}
c9427e08 1610
91162307 1611Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1612 //-----------------------------------------------------------------
1613 // This function tries to find a track prolongation to next pad row
1614 //-----------------------------------------------------------------
1615 //
1616 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1617 Double_t y,z;
1618 if (!t.GetProlongation(x,y,z)) {
1619 t.fRemoval = 10;
1620 return 0;
1621 }
1622 //
1623 //
1624 if (TMath::Abs(y)>ymax){
91162307 1625
1c53abe2 1626 if (y > ymax) {
1627 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1628 if (!t.Rotate(fSectors->GetAlpha()))
1629 return 0;
1630 } else if (y <-ymax) {
1631 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1632 if (!t.Rotate(-fSectors->GetAlpha()))
1633 return 0;
91162307 1634 }
1635 if (!t.PropagateTo(x)) {
1636 return 0;
1637 }
1638 t.GetProlongation(x,y,z);
1639 }
1640 //
1641 // update current shape info every 3 pad-row
1642 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1643 // t.fCurrentSigmaY = GetSigmaY(&t);
1644 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1645 GetShape(&t,nr);
1646 }
1647 //
1648 AliTPCclusterMI *cl=0;
1649 UInt_t index=0;
1650
1651
1652 //Int_t nr2 = nr;
1653 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1654 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1655 Double_t roady =1.;
1656 Double_t roadz = 1.;
1657 //
1658 Int_t row = nr;
1659 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1660 t.fInDead = kTRUE;
1661 t.SetClusterIndex2(row,-1);
1662 return 0;
1663 }
1664 else
1665 {
d7a11555 1666 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1c53abe2 1667 }
91162307 1668 //calculate
1669
1670 if ((cl==0)&&(krow)) {
1671 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1672 cl = krow.FindNearest2(y,z,roady,roadz,index);
1673
1674 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1675 }
1676
1677 if (cl) {
1678 t.fCurrentCluster = cl;
1679 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1680 //if (accept<3){
1681 t.SetClusterIndex2(row,index);
1682 t.fClusterPointer[row] = cl;
1683 //}
1c53abe2 1684 }
1685 return 1;
1686}
1687
1688
91162307 1689
1690Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1c53abe2 1691 //-----------------------------------------------------------------
1692 // This function tries to find a track prolongation to next pad row
1693 //-----------------------------------------------------------------
1694 t.fCurrentCluster = 0;
1695 t.fCurrentClusterIndex1 = 0;
1c53abe2 1696
1697 Double_t xt=t.GetX();
91162307 1698 Int_t row = GetRowNumber(xt)-1;
1699 Double_t ymax= GetMaxY(nr);
1700
1c53abe2 1701 if (row < nr) return 1; // don't prolongate if not information until now -
91162307 1702 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1703 t.fRemoval =10;
1704 return 0; // not prolongate strongly inclined tracks
1705 }
1706 if (TMath::Abs(t.GetSnp())>0.95) {
1707 t.fRemoval =10;
1708 return 0; // not prolongate strongly inclined tracks
1709 }
1710
1711 Double_t x= GetXrow(nr);
1712 Double_t y,z;
1713 //t.PropagateTo(x+0.02);
1714 //t.PropagateTo(x+0.01);
1627d1c4 1715 if (!t.PropagateTo(x)){
1627d1c4 1716 return 0;
1717 }
1c53abe2 1718 //
91162307 1719 y=t.GetY();
1720 z=t.GetZ();
1c53abe2 1721
91162307 1722 if (TMath::Abs(y)>ymax){
1723 if (y > ymax) {
1724 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1725 if (!t.Rotate(fSectors->GetAlpha()))
1726 return 0;
1727 } else if (y <-ymax) {
1728 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1729 if (!t.Rotate(-fSectors->GetAlpha()))
1730 return 0;
1731 }
982aff31 1732 // if (!t.PropagateTo(x)){
1733 // return 0;
1734 //}
1735 return 1;
1736 //y = t.GetY();
1c53abe2 1737 }
91162307 1738 //
1c53abe2 1739
91162307 1740 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1c53abe2 1741
1742 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1743 t.fInDead = kTRUE;
91162307 1744 t.SetClusterIndex2(nr,-1);
1c53abe2 1745 return 0;
1746 }
1747 else
1748 {
d7a11555 1749 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1627d1c4 1750 else
1751 return 0;
1c53abe2 1752 }
1c53abe2 1753
91162307 1754 // update current
1755 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1756 // t.fCurrentSigmaY = GetSigmaY(&t);
1757 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1758 GetShape(&t,nr);
1759 }
1c53abe2 1760
91162307 1761 AliTPCclusterMI *cl=0;
1762 UInt_t index=0;
1763 //
1764 Double_t roady = 1.;
1765 Double_t roadz = 1.;
1766 //
d26d9159 1767
1768 if (!cl){
1769 index = t.GetClusterIndex2(nr);
1770 if ( (index>0) && (index&0x8000)==0){
1771 cl = t.fClusterPointer[nr];
1772 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1773 t.fCurrentClusterIndex1 = index;
1774 if (cl) {
1775 t.fCurrentCluster = cl;
1776 return 1;
1777 }
1778 }
1779 }
1780
91162307 1781 if (krow) {
1782 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1783 cl = krow.FindNearest2(y,z,roady,roadz,index);
1784 }
d26d9159 1785
91162307 1786 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
d26d9159 1787 t.fCurrentCluster = cl;
1788
91162307 1789 return 1;
1790}
1c53abe2 1791
1c53abe2 1792
91162307 1793Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1794 //-----------------------------------------------------------------
1795 // This function tries to find a track prolongation to next pad row
1796 //-----------------------------------------------------------------
1c53abe2 1797
91162307 1798 //update error according neighborhoud
1c53abe2 1799
91162307 1800 if (t.fCurrentCluster) {
1801 t.fRow = nr;
8c51a605 1802 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
91162307 1803
1804 if (t.fCurrentCluster->IsUsed(10)){
1805 //
1806 //
1807 // t.fErrorZ2*=2;
1808 // t.fErrorY2*=2;
1809 t.fNShared++;
1810 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1811 t.fRemoval =10;
1812 return 0;
1813 }
b364ca79 1814 }
d26d9159 1815 if (fIteration>0) accept = 0;
b364ca79 1816 if (accept<3) UpdateTrack(&t,accept);
1817
1c53abe2 1818 } else {
91162307 1819 if (fIteration==0){
1820 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1821 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1822
1823 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1c53abe2 1824 }
1825 }
1826 return 1;
1827}
1828
1829
1830
91162307 1831//_____________________________________________________________________________
1832Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1833 //-----------------------------------------------------------------
91162307 1834 // This function tries to find a track prolongation.
1c53abe2 1835 //-----------------------------------------------------------------
1836 Double_t xt=t.GetX();
1837 //
91162307 1838 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1c53abe2 1839 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1840 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1841 //
1842 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1843
91162307 1844 Int_t first = GetRowNumber(xt)-1;
1845 for (Int_t nr= first; nr>=rf; nr-=step) {
982aff31 1846 if (nr<fInnerSec->GetNRows())
1847 fSectors = fInnerSec;
1848 else
1849 fSectors = fOuterSec;
91162307 1850 if (FollowToNext(t,nr)==0)
4d158c36 1851 if (!t.IsActive())
1852 return 0;
91162307 1853
1854 }
1855 return 1;
1856}
1857
1c53abe2 1858
1859//_____________________________________________________________________________
91162307 1860Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1861 //-----------------------------------------------------------------
1862 // This function tries to find a track prolongation.
1863 //-----------------------------------------------------------------
1864 Double_t xt=t.GetX();
1865 //
1866 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1867 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1868 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1869 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1870
1871 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1872
1873 if (FollowToNextFast(t,nr)==0)
1874 if (!t.IsActive()) return 0;
1c53abe2 1875
1c53abe2 1876 }
1877 return 1;
1878}
1879
1880
91162307 1881
1882
1883
1c53abe2 1884Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1885 //-----------------------------------------------------------------
1886 // This function tries to find a track prolongation.
1887 //-----------------------------------------------------------------
91162307 1888 // Double_t xt=t.GetX();
1c53abe2 1889 //
1890 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1891 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1892 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1893 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1894
4d158c36 1895 Int_t first = t.fFirstPoint;
91162307 1896 //
1897 if (first<0) first=0;
4d158c36 1898 for (Int_t nr=first; nr<=rf; nr++) {
91162307 1899 //if ( (t.GetSnp()<0.9))
d26d9159 1900 if (nr<fInnerSec->GetNRows())
1901 fSectors = fInnerSec;
1902 else
1903 fSectors = fOuterSec;
1904 FollowToNext(t,nr);
1c53abe2 1905 }
1906 return 1;
1907}
1908
1909
1910
1911
1912
1913Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1914{
1915 //
1916 //
1917 sum1=0;
1918 sum2=0;
1919 Int_t sum=0;
1c53abe2 1920 //
1921 Float_t dz2 =(s1->GetZ() - s2->GetZ());
c9427e08 1922 dz2*=dz2;
91162307 1923
c9427e08 1924 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1c53abe2 1925 dy2*=dy2;
1926 Float_t distance = TMath::Sqrt(dz2+dy2);
c9427e08 1927 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1c53abe2 1928
91162307 1929 // Int_t offset =0;
c9427e08 1930 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1931 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
c9427e08 1932 if (lastpoint>160)
1933 lastpoint =160;
1934 if (firstpoint<0)
1935 firstpoint = 0;
91162307 1936 if (firstpoint>lastpoint) {
1937 firstpoint =lastpoint;
1938 // lastpoint =160;
c9427e08 1939 }
1940
1941
91162307 1942 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1943 if (s1->GetClusterIndex2(i)>0) sum1++;
1944 if (s2->GetClusterIndex2(i)>0) sum2++;
1945 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1c53abe2 1946 sum++;
1947 }
1948 }
91162307 1949 if (sum<5) return 0;
1950
1627d1c4 1951 Float_t summin = TMath::Min(sum1+1,sum2+1);
1952 Float_t ratio = (sum+1)/Float_t(summin);
1c53abe2 1953 return ratio;
1954}
1955
1956void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1957{
1958 //
1959 //
91162307 1960 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1961 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1962
1c53abe2 1963 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1964 dz2*=dz2;
1965 Float_t dy2 =(s1->GetY() - s2->GetY());
1966 dy2*=dy2;
91162307 1967 Float_t distance = dz2+dy2;
1968 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1969
1c53abe2 1970 //
91162307 1971 Int_t sumshared=0;
1972 //
1973 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1974 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1975 //
1976 if (firstpoint>=lastpoint-5) return;;
1c53abe2 1977
91162307 1978 for (Int_t i=firstpoint;i<lastpoint;i++){
1979 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1980 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1981 sumshared++;
1982 }
1983 }
1984 if (sumshared>4){
1985 // sign clusters
1986 //
1987 for (Int_t i=firstpoint;i<lastpoint;i++){
1988 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1989 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1990 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1991 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1992 if (s1->IsActive()&&s2->IsActive()){
1993 p1->fIsShared = kTRUE;
1994 p2->fIsShared = kTRUE;
1995 }
1996 }
1997 }
1998 }
1999 //
2000 if (sumshared>10){
2001 for (Int_t i=0;i<4;i++){
2002 if (s1->fOverlapLabels[3*i]==0){
2003 s1->fOverlapLabels[3*i] = s2->GetLabel();
2004 s1->fOverlapLabels[3*i+1] = sumshared;
2005 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
2006 break;
2007 }
2008 }
2009 for (Int_t i=0;i<4;i++){
2010 if (s2->fOverlapLabels[3*i]==0){
2011 s2->fOverlapLabels[3*i] = s1->GetLabel();
2012 s2->fOverlapLabels[3*i+1] = sumshared;
2013 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2014 break;
2015 }
2016 }
2017 }
1c53abe2 2018
91162307 2019}
1c53abe2 2020
91162307 2021void AliTPCtrackerMI::SignShared(TObjArray * arr)
2022{
1c53abe2 2023 //
91162307 2024 //sort trackss according sectors
2025 //
c9427e08 2026 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2027 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2028 if (!pt) continue;
2029 //if (pt) RotateToLocal(pt);
2030 pt->fSort = 0;
c9427e08 2031 }
91162307 2032 arr->UnSort();
1c53abe2 2033 arr->Sort(); // sorting according z
2034 arr->Expand(arr->GetEntries());
91162307 2035 //
2036 //
1c53abe2 2037 Int_t nseed=arr->GetEntriesFast();
1c53abe2 2038 for (Int_t i=0; i<nseed; i++) {
2039 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2040 if (!pt) continue;
2041 for (Int_t j=0;j<=12;j++){
2042 pt->fOverlapLabels[j] =0;
1c53abe2 2043 }
91162307 2044 }
2045 for (Int_t i=0; i<nseed; i++) {
2046 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2047 if (!pt) continue;
2048 if (pt->fRemoval>10) continue;
1c53abe2 2049 for (Int_t j=i+1; j<nseed; j++){
2050 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
91162307 2051 // if (pt2){
2052 if (pt2->fRemoval<=10) {
2053 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2054 SignShared(pt,pt2);
c9427e08 2055 }
91162307 2056 }
2057 }
2058}
2059
2060void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2061{
2062 //
2063 //sort trackss according sectors
2064 //
2065 if (fDebug&1) {
6bdc18d6 2066 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
91162307 2067 }
2068 //
2069 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2070 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2071 if (!pt) continue;
2072 pt->fSort = 0;
2073 }
2074 arr->UnSort();
2075 arr->Sort(); // sorting according z
2076 arr->Expand(arr->GetEntries());
2077 //
2078 //reset overlap labels
2079 //
2080 Int_t nseed=arr->GetEntriesFast();
2081 for (Int_t i=0; i<nseed; i++) {
2082 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2083 if (!pt) continue;
2084 pt->SetUniqueID(i);
2085 for (Int_t j=0;j<=12;j++){
2086 pt->fOverlapLabels[j] =0;
1c53abe2 2087 }
2088 }
91162307 2089 //
2090 //sign shared tracks
1c53abe2 2091 for (Int_t i=0; i<nseed; i++) {
2092 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2093 if (!pt) continue;
2094 if (pt->fRemoval>10) continue;
2095 Float_t deltac = pt->GetC()*0.1;
2096 for (Int_t j=i+1; j<nseed; j++){
2097 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2098 // if (pt2){
2099 if (pt2->fRemoval<=10) {
2100 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2101 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2102 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2103 //
2104 SignShared(pt,pt2);
2105 }
1c53abe2 2106 }
1c53abe2 2107 }
91162307 2108 //
2109 // remove highly shared tracks
2110 for (Int_t i=0; i<nseed; i++) {
2111 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2112 if (!pt) continue;
2113 if (pt->fRemoval>10) continue;
2114 //
2115 Int_t sumshared =0;
2116 for (Int_t j=0;j<4;j++){
2117 sumshared = pt->fOverlapLabels[j*3+1];
2118 }
2119 Float_t factor = factor1;
2120 if (pt->fRemoval>0) factor = factor2;
2121 if (sumshared/pt->GetNumberOfClusters()>factor){
2122 for (Int_t j=0;j<4;j++){
2123 if (pt->fOverlapLabels[3*j]==0) continue;
2124 if (pt->fOverlapLabels[3*j+1]<5) continue;
2125 if (pt->fRemoval==removalindex) continue;
2126 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2127 if (!pt2) continue;
2128 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2129 // pt->fRemoval = removalindex;
2130 delete arr->RemoveAt(i);
2131 break;
1c53abe2 2132 }
91162307 2133 }
1c53abe2 2134 }
91162307 2135 }
2136 arr->Compress();
2137 if (fDebug&1) {
6bdc18d6 2138 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
91162307 2139 }
2140}
2141
2142
2143
1c53abe2 2144
2145
91162307 2146
47966a6d 2147void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
91162307 2148{
2149 //
2150 //sort tracks in array according mode criteria
2151 Int_t nseed = arr->GetEntriesFast();
2152 for (Int_t i=0; i<nseed; i++) {
2153 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2154 if (!pt) {
2155 continue;
2156 }
2157 pt->fSort = mode;
2158 }
2159 arr->UnSort();
2160 arr->Sort();
1c53abe2 2161}
c9427e08 2162
91162307 2163void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
c9427e08 2164{
2165
2166 //Loop over all tracks and remove "overlaps"
2167 //
2168 //
2169 Int_t nseed = arr->GetEntriesFast();
2170 Int_t good =0;
91162307 2171
c9427e08 2172 for (Int_t i=0; i<nseed; i++) {
2173 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2174 if (!pt) {
91162307 2175 delete arr->RemoveAt(i);
c9427e08 2176 }
91162307 2177 else{
2178 pt->fSort =1;
2179 pt->fBSigned = kFALSE;
c9427e08 2180 }
91162307 2181 }
2182 arr->Compress();
2183 nseed = arr->GetEntriesFast();
2184 arr->UnSort();
2185 arr->Sort();
2186 //
2187 //unsign used
2188 UnsignClusters();
2189 //
2190 for (Int_t i=0; i<nseed; i++) {
2191 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2192 if (!pt) {
2193 continue;
2194 }
2195 Int_t found,foundable,shared;
2196 if (pt->IsActive())
2197 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2198 else
2199 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2200 //
2201 Double_t factor = factor2;
2202 if (pt->fBConstrain) factor = factor1;
2203
2204 if ((Float_t(shared)/Float_t(found))>factor){
c9427e08 2205 pt->Desactivate(removalindex);
91162307 2206 continue;
2207 }
2208
2209 good++;
2210 for (Int_t i=0; i<160; i++) {
2211 Int_t index=pt->GetClusterIndex2(i);
2212 if (index<0 || index&0x8000 ) continue;
2213 AliTPCclusterMI *c= pt->fClusterPointer[i];
2214 if (!c) continue;
2215 // if (!c->IsUsed(10)) c->Use(10);
2216 //if (pt->IsActive())
2217 c->Use(10);
2218 //else
2219 // c->Use(5);
c9427e08 2220 }
91162307 2221
c9427e08 2222 }
2223 fNtracks = good;
6bdc18d6 2224 if (fDebug>0){
2225 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2226 }
c9427e08 2227}
2228
91162307 2229void AliTPCtrackerMI::UnsignClusters()
1c53abe2 2230{
91162307 2231 //
2232 // loop over all clusters and unsign them
2233 //
2234
2235 for (Int_t sec=0;sec<fkNIS;sec++){
2236 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2237 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2238 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2239 // if (cl[icl].IsUsed(10))
2240 cl[icl].Use(-1);
2241 cl = fInnerSec[sec][row].fClusters2;
2242 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2243 //if (cl[icl].IsUsed(10))
2244 cl[icl].Use(-1);
2245 }
2246 }
2247
2248 for (Int_t sec=0;sec<fkNOS;sec++){
2249 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2250 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2251 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2252 //if (cl[icl].IsUsed(10))
2253 cl[icl].Use(-1);
2254 cl = fOuterSec[sec][row].fClusters2;
2255 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2256 //if (cl[icl].IsUsed(10))
2257 cl[icl].Use(-1);
2258 }
2259 }
2260
1c53abe2 2261}
2262
91162307 2263
2264
732b9e78 2265void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
1c53abe2 2266{
2267 //
91162307 2268 //sign clusters to be "used"
2269 //
2270 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2271 // loop over "primaries"
2272
2273 Float_t sumdens=0;
2274 Float_t sumdens2=0;
2275 Float_t sumn =0;
2276 Float_t sumn2 =0;
2277 Float_t sumchi =0;
2278 Float_t sumchi2 =0;
2279
2280 Float_t sum =0;
2281
1c53abe2 2282 TStopwatch timer;
91162307 2283 timer.Start();
1c53abe2 2284
91162307 2285 Int_t nseed = arr->GetEntriesFast();
2286 for (Int_t i=0; i<nseed; i++) {
2287 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2288 if (!pt) {
2289 continue;
2290 }
2291 if (!(pt->IsActive())) continue;
2292 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2293 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2294 sumdens += dens;
2295 sumdens2+= dens*dens;
2296 sumn += pt->GetNumberOfClusters();
2297 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2298 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2299 if (chi2>5) chi2=5;
2300 sumchi +=chi2;
2301 sumchi2 +=chi2*chi2;
2302 sum++;
2303 }
1627d1c4 2304 }
91162307 2305
2306 Float_t mdensity = 0.9;
2307 Float_t meann = 130;
2308 Float_t meanchi = 1;
2309 Float_t sdensity = 0.1;
2310 Float_t smeann = 10;
2311 Float_t smeanchi =0.4;
1627d1c4 2312
91162307 2313
2314 if (sum>20){
2315 mdensity = sumdens/sum;
2316 meann = sumn/sum;
2317 meanchi = sumchi/sum;
2318 //
2319 sdensity = sumdens2/sum-mdensity*mdensity;
2320 sdensity = TMath::Sqrt(sdensity);
2321 //
2322 smeann = sumn2/sum-meann*meann;
2323 smeann = TMath::Sqrt(smeann);
2324 //
2325 smeanchi = sumchi2/sum - meanchi*meanchi;
2326 smeanchi = TMath::Sqrt(smeanchi);
2327 }
2328
2329
2330 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2331 //
2332 for (Int_t i=0; i<nseed; i++) {
2333 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2334 if (!pt) {
2335 continue;
1c53abe2 2336 }
91162307 2337 if (pt->fBSigned) continue;
2338 if (pt->fBConstrain) continue;
2339 //if (!(pt->IsActive())) continue;
2340 /*
2341 Int_t found,foundable,shared;
2342 pt->GetClusterStatistic(0,160,found, foundable,shared);
2343 if (shared/float(found)>0.3) {
2344 if (shared/float(found)>0.9 ){
2345 //delete arr->RemoveAt(i);
2346 }
2347 continue;
c9427e08 2348 }
91162307 2349 */
2350 Bool_t isok =kFALSE;
2351 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2352 isok = kTRUE;
2353 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2354 isok =kTRUE;
2355 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2356 isok =kTRUE;
2357 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2358 isok =kTRUE;
2359
2360 if (isok)
2361 for (Int_t i=0; i<160; i++) {
2362 Int_t index=pt->GetClusterIndex2(i);
2363 if (index<0) continue;
2364 AliTPCclusterMI *c= pt->fClusterPointer[i];
2365 if (!c) continue;
2366 //if (!(c->IsUsed(10))) c->Use();
2367 c->Use(10);
2368 }
2369 }
2370
c9427e08 2371
1c53abe2 2372 //
91162307 2373 Double_t maxchi = meanchi+2.*smeanchi;
2374
2375 for (Int_t i=0; i<nseed; i++) {
2376 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2377 if (!pt) {
1c53abe2 2378 continue;
91162307 2379 }
2380 //if (!(pt->IsActive())) continue;
2381 if (pt->fBSigned) continue;
2382 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2383 if (chi>maxchi) continue;
2384
2385 Float_t bfactor=1;
2386 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2387
2388 //sign only tracks with enoug big density at the beginning
2389
2390 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2391
2392
3e5d0aa2 2393 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
91162307 2394 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2395
2396 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2397 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2398 minn=0;
2399
2400 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2401 //Int_t noc=pt->GetNumberOfClusters();
2402 pt->fBSigned = kTRUE;
2403 for (Int_t i=0; i<160; i++) {
2404
2405 Int_t index=pt->GetClusterIndex2(i);
2406 if (index<0) continue;
2407 AliTPCclusterMI *c= pt->fClusterPointer[i];
2408 if (!c) continue;
2409 // if (!(c->IsUsed(10))) c->Use();
2410 c->Use(10);
2411 }
1c53abe2 2412 }
91162307 2413 }
2414 // gLastCheck = nseed;
2415 // arr->Compress();
2416 if (fDebug>0){
2417 timer.Print();
2418 }
1c53abe2 2419}
2420
2421
47966a6d 2422void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
91162307 2423{
2424 // stop not active tracks
2425 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2426 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2427 Int_t nseed = arr->GetEntriesFast();
2428 //
2429 for (Int_t i=0; i<nseed; i++) {
2430 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2431 if (!pt) {
2432 continue;
2433 }
2434 if (!(pt->IsActive())) continue;
2435 StopNotActive(pt,row0,th0, th1,th2);
2436 }
2437}
1c53abe2 2438
1c53abe2 2439
1c53abe2 2440
91162307 2441void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
47966a6d 2442 Float_t th2) const
91162307 2443{
2444 // stop not active tracks
2445 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2446 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2447 Int_t sumgood1 = 0;
2448 Int_t sumgood2 = 0;
2449 Int_t foundable = 0;
2450 Int_t maxindex = seed->fLastPoint; //last foundable row
2451 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2452 seed->Desactivate(10) ;
2453 return;
2454 }
1c53abe2 2455
3e5d0aa2 2456 for (Int_t i=row0; i<maxindex; i++){
91162307 2457 Int_t index = seed->GetClusterIndex2(i);
2458 if (index!=-1) foundable++;
2459 //if (!c) continue;
2460 if (foundable<=30) sumgood1++;
2461 if (foundable<=50) {
2462 sumgood2++;
2463 }
2464 else{
2465 break;
2466 }
2467 }
2468 if (foundable>=30.){
2469 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2470 }
2471 if (foundable>=50)
2472 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2473}
1c53abe2 2474
1c53abe2 2475
d26d9159 2476Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2477{
2478 //
2479 // back propagation of ESD tracks
2480 //
2481 //return 0;
2482 fEvent = event;
2483 ReadSeeds(event,2);
2484 fIteration=2;
982aff31 2485 //PrepareForProlongation(fSeeds,1);
2486 PropagateForward2(fSeeds);
4d158c36 2487 Int_t ntracks=0;
d26d9159 2488 Int_t nseed = fSeeds->GetEntriesFast();
2489 for (Int_t i=0;i<nseed;i++){
2490 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
4d158c36 2491 if (!seed) continue;
d26d9159 2492 seed->PropagateTo(fParam->GetInnerRadiusLow());
2493 AliESDtrack *esd=event->GetTrack(i);
2494 seed->CookdEdx(0.02,0.6);
2495 CookLabel(seed,0.1); //For comparison only
4d158c36 2496 if (seed->GetNumberOfClusters()>60){
2497 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2498 ntracks++;
d26d9159 2499 }
2500 else{
2501 //printf("problem\n");
2502 }
2503 }
4d158c36 2504 Info("RefitInward","Number of refitted tracks %d",ntracks);
d26d9159 2505 fEvent =0;
2506 //WriteTracks();
2507 return 0;
2508}
2509
1c53abe2 2510
91162307 2511Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2512{
2513 //
2514 // back propagation of ESD tracks
2515 //
1c53abe2 2516
91162307 2517 fEvent = event;
d26d9159 2518 fIteration = 1;
2519 ReadSeeds(event,0);
91162307 2520 PropagateBack(fSeeds);
2521 Int_t nseed = fSeeds->GetEntriesFast();
4d158c36 2522 Int_t ntracks=0;
91162307 2523 for (Int_t i=0;i<nseed;i++){
2524 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
d9e62e7e 2525 if (!seed) continue;
91162307 2526 AliESDtrack *esd=event->GetTrack(i);
d26d9159 2527 seed->CookdEdx(0.02,0.6);
91162307 2528 CookLabel(seed,0.1); //For comparison only
4d158c36 2529 if (seed->GetNumberOfClusters()>60){
2530 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2531 ntracks++;
2532 }
91162307 2533 }
4d158c36 2534 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
91162307 2535 fEvent =0;
d26d9159 2536 //WriteTracks();
91162307 2537 return 0;
2538}
2539
2540
2541void AliTPCtrackerMI::DeleteSeeds()
2542{
b67e07dc 2543 //
2544 //delete Seeds
91162307 2545 Int_t nseed = fSeeds->GetEntriesFast();
2546 for (Int_t i=0;i<nseed;i++){
2547 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2548 if (seed) delete fSeeds->RemoveAt(i);
2549 }
2550 delete fSeeds;
2551 fSeeds =0;
2552}
2553
d26d9159 2554void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
91162307 2555{
2556 //
2557 //read seeds from the event
2558
2559 Int_t nentr=event->GetNumberOfTracks();
6bdc18d6 2560 if (fDebug>0){
2561 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2562 }
91162307 2563 if (fSeeds)
2564 DeleteSeeds();
2565 if (!fSeeds){
4d158c36 2566 fSeeds = new TObjArray(nentr);
91162307 2567 }
4d158c36 2568 UnsignClusters();
2569 // Int_t ntrk=0;
91162307 2570 for (Int_t i=0; i<nentr; i++) {
2571 AliESDtrack *esd=event->GetTrack(i);
2572 ULong_t status=esd->GetStatus();
b67e07dc 2573 AliTPCtrack t(*esd);
91162307 2574 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
982aff31 2575 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2576 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
4d158c36 2577 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2578 fSeeds->AddAt(0,i);
2579 delete seed;
2580 continue;
2581 }
2582 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2583 Double_t par0[5],par1[5],x;
2584 esd->GetInnerExternalParameters(x,par0);
2585 esd->GetExternalParameters(x,par1);
2586 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2587 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2588 //reset covariance if suspicious
2589 if ( (delta1>0.1) || (delta2>0.006))
2590 seed->ResetCovariance();
2591 }
982aff31 2592
91162307 2593 //
2594 //
2595 // rotate to the local coordinate system
2596
2597 fSectors=fInnerSec; fN=fkNIS;
2598
2599 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2600 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2601 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2602 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2603 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
4d158c36 2604 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2605 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
91162307 2606 alpha-=seed->GetAlpha();
d9b8978b 2607 if (!seed->Rotate(alpha)) {
2608 delete seed;
2609 continue;
2610 }
d26d9159 2611 seed->fEsd = esd;
91162307 2612 //
d26d9159 2613 //seed->PropagateTo(fSectors->GetX(0));
91162307 2614 //
2615 // Int_t index = esd->GetTPCindex();
2616 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
d26d9159 2617 //if (direction==2){
2618 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2619 // if (seed2) {
2620 // delete seed;
2621 // seed = seed2;
2622 // }
2623 //}
4d158c36 2624 //
2625 // sign clusters
2626 for (Int_t irow=0;irow<160;irow++){
2627 Int_t index = seed->GetClusterIndex2(irow);
2628 if (index>0){
2629 //
2630 AliTPCclusterMI * cl = GetClusterMI(index);
2631 seed->fClusterPointer[irow] = cl;
2632 if (cl){
2633 if ((index & 0x8000)==0){
2634 cl->Use(10); // accepted cluster
2635 }else{
2636 cl->Use(6); // close cluster not accepted
2637 }
2638 }else{
2639 Info("ReadSeeds","Not found cluster");
2640 }
2641 }
2642 }
2643 fSeeds->AddAt(seed,i);
91162307 2644 }
2645}
2646
2647
2648
2649//_____________________________________________________________________________
2650void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2651 Float_t deltay, Int_t ddsec) {
2652 //-----------------------------------------------------------------
2653 // This function creates track seeds.
2654 // SEEDING WITH VERTEX CONSTRAIN
2655 //-----------------------------------------------------------------
2656 // cuts[0] - fP4 cut
2657 // cuts[1] - tan(phi) cut
2658 // cuts[2] - zvertex cut
2659 // cuts[3] - fP3 cut
2660 Int_t nin0 = 0;
2661 Int_t nin1 = 0;
2662 Int_t nin2 = 0;
2663 Int_t nin = 0;
2664 Int_t nout1 = 0;
2665 Int_t nout2 = 0;
2666
2667 Double_t x[5], c[15];
2668 // Int_t di = i1-i2;
2669 //
2670 AliTPCseed * seed = new AliTPCseed;
2671 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2672 Double_t cs=cos(alpha), sn=sin(alpha);
2673 //
2674 // Double_t x1 =fOuterSec->GetX(i1);
2675 //Double_t xx2=fOuterSec->GetX(i2);
2676
2677 Double_t x1 =GetXrow(i1);
2678 Double_t xx2=GetXrow(i2);
2679
2680 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2681
2682 Int_t imiddle = (i2+i1)/2; //middle pad row index
2683 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2684 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2685 //
2686 Int_t ns =sec;
2687
2688 const AliTPCRow& kr1=GetRow(ns,i1);
2689 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2690 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2691
2692 //
2693 // change cut on curvature if it can't reach this layer
2694 // maximal curvature set to reach it
2695 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2696 if (dvertexmax*0.5*cuts[0]>0.85){
2697 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2698 }
2699 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2700
2701 // Int_t ddsec = 1;
2702 if (deltay>0) ddsec = 0;
2703 // loop over clusters
2704 for (Int_t is=0; is < kr1; is++) {
2705 //
2706 if (kr1[is]->IsUsed(10)) continue;
2707 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2708 //if (TMath::Abs(y1)>ymax) continue;
2709
2710 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2711
2712 // find possible directions
2713 Float_t anglez = (z1-z3)/(x1-x3);
2714 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2715 //
2716 //
2717 //find rotation angles relative to line given by vertex and point 1
2718 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2719 Double_t dvertex = TMath::Sqrt(dvertex2);
2720 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2721 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2722
2723 //
2724 // loop over 2 sectors
2725 Int_t dsec1=-ddsec;
2726 Int_t dsec2= ddsec;
2727 if (y1<0) dsec2= 0;
2728 if (y1>0) dsec1= 0;
2729
2730 Double_t dddz1=0; // direction of delta inclination in z axis
2731 Double_t dddz2=0;
2732 if ( (z1-z3)>0)
2733 dddz1 =1;
2734 else
2735 dddz2 =1;
2736 //
2737 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2738 Int_t sec2 = sec + dsec;
2739 //
2740 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2741 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2742 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2743 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2744 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2745 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2746
2747 // rotation angles to p1-p3
2748 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2749 Double_t x2, y2, z2;
2750 //
2751 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2752
2753 //
2754 Double_t dxx0 = (xx2-x3)*cs13r;
2755 Double_t dyy0 = (xx2-x3)*sn13r;
2756 for (Int_t js=index1; js < index2; js++) {
2757 const AliTPCclusterMI *kcl = kr2[js];
2758 if (kcl->IsUsed(10)) continue;
2759 //
2760 //calcutate parameters
2761 //
2762 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2763 // stright track
2764 if (TMath::Abs(yy0)<0.000001) continue;
2765 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2766 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2767 Double_t r02 = (0.25+y0*y0)*dvertex2;
2768 //curvature (radius) cut
2769 if (r02<r2min) continue;
2770
2771 nin0++;
2772 //
2773 Double_t c0 = 1/TMath::Sqrt(r02);
2774 if (yy0>0) c0*=-1.;
2775
2776
2777 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2778 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
b67e07dc 2779 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2780 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
91162307 2781 //
2782 //
2783 Double_t z0 = kcl->GetZ();
2784 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2785 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2786 nin1++;
2787 //
2788 Double_t dip = (z1-z0)*c0/dfi1;
2789 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2790 //
2791 y2 = kcl->GetY();
2792 if (dsec==0){
2793 x2 = xx2;
2794 z2 = kcl->GetZ();
2795 }
2796 else
2797 {
2798 // rotation
2799 z2 = kcl->GetZ();
2800 x2= xx2*cs-y2*sn*dsec;
2801 y2=+xx2*sn*dsec+y2*cs;
2802 }
2803
2804 x[0] = y1;
2805 x[1] = z1;
2806 x[2] = x0;
2807 x[3] = dip;
2808 x[4] = c0;
2809 //
2810 //
2811 // do we have cluster at the middle ?
2812 Double_t ym,zm;
2813 GetProlongation(x1,xm,x,ym,zm);
2814 UInt_t dummy;
2815 AliTPCclusterMI * cm=0;
2816 if (TMath::Abs(ym)-ymaxm<0){
2817 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2818 if ((!cm) || (cm->IsUsed(10))) {
2819 continue;
2820 }
2821 }
2822 else{
2823 // rotate y1 to system 0
2824 // get state vector in rotated system
2825 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2826 Double_t xr2 = x0*cs+yr1*sn*dsec;
2827 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2828 //
2829 GetProlongation(xx2,xm,xr,ym,zm);
2830 if (TMath::Abs(ym)-ymaxm<0){
2831 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2832 if ((!cm) || (cm->IsUsed(10))) {
2833 continue;
2834 }
2835 }
2836 }
2837
2838
2839 Double_t dym = 0;
2840 Double_t dzm = 0;
2841 if (cm){
2842 dym = ym - cm->GetY();
2843 dzm = zm - cm->GetZ();
2844 }
2845 nin2++;
2846
2847
2848 //
2849 //
2850 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2851 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2852 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2853 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2854 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2855
b67e07dc 2856 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2857 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2858 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2859 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2860 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2861 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 2862
b67e07dc 2863 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2864 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2865 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2866 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
91162307 2867
1c53abe2 2868 c[0]=sy1;
2869 c[1]=0.; c[2]=sz1;
2870 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2871 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2872 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2873 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2874 c[13]=f30*sy1*f40+f32*sy2*f42;
2875 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
91162307 2876
2877 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2878
1c53abe2 2879 UInt_t index=kr1.GetIndex(is);
91162307 2880 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2881
1c53abe2 2882 track->fIsSeeding = kTRUE;
91162307 2883 track->fSeed1 = i1;
2884 track->fSeed2 = i2;
2885 track->fSeedType=3;
c9427e08 2886
91162307 2887
2888 //if (dsec==0) {
2889 FollowProlongation(*track, (i1+i2)/2,1);
2890 Int_t foundable,found,shared;
2891 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2892 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2893 seed->Reset();
2894 seed->~AliTPCseed();
2895 continue;
2896 }
2897 //}
2898
2899 nin++;
2900 FollowProlongation(*track, i2,1);
2901
2902
2903 //Int_t rc = 1;
2904 track->fBConstrain =1;
2905 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2906 track->fLastPoint = i1; // first cluster in track position
2907 track->fFirstPoint = track->fLastPoint;
2908
2909 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2910 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2911 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2912 seed->Reset();
2913 seed->~AliTPCseed();
c9427e08 2914 continue;
2915 }
91162307 2916 nout1++;
2917 // Z VERTEX CONDITION
2918 Double_t zv;
2919 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2920 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2921 if (TMath::Abs(zv-z3)>cuts[2]) {
2922 FollowProlongation(*track, TMath::Max(i2-20,0));
2923 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2924 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2925 if (TMath::Abs(zv-z3)>cuts[2]){
2926 FollowProlongation(*track, TMath::Max(i2-40,0));
2927 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2928 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2929 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2930 // make seed without constrain
2931 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2932 FollowProlongation(*track2, i2,1);
2933 track2->fBConstrain = kFALSE;
2934 track2->fSeedType = 1;
2935 arr->AddLast(track2);
2936 seed->Reset();
2937 seed->~AliTPCseed();
2938 continue;
2939 }
2940 else{
2941 seed->Reset();
2942 seed->~AliTPCseed();
2943 continue;
2944
2945 }
2946 }
c9427e08 2947 }
1c53abe2 2948
91162307 2949 track->fSeedType =0;
2950 arr->AddLast(track);
2951 seed = new AliTPCseed;
2952 nout2++;
2953 // don't consider other combinations
2954 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2955 break;
1c53abe2 2956 }
2957 }
2958 }
6bdc18d6 2959 if (fDebug>3){
2960 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
91162307 2961 }
2962 delete seed;
1c53abe2 2963}
2964
1627d1c4 2965
91162307 2966void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2967 Float_t deltay) {
2968
2969
2970
1627d1c4 2971 //-----------------------------------------------------------------
91162307 2972 // This function creates track seeds.
1627d1c4 2973 //-----------------------------------------------------------------
91162307 2974 // cuts[0] - fP4 cut
2975 // cuts[1] - tan(phi) cut
2976 // cuts[2] - zvertex cut
2977 // cuts[3] - fP3 cut
2978
2979
2980 Int_t nin0 = 0;
2981 Int_t nin1 = 0;
2982 Int_t nin2 = 0;
2983 Int_t nin = 0;
2984 Int_t nout1 = 0;
2985 Int_t nout2 = 0;
2986 Int_t nout3 =0;
2987 Double_t x[5], c[15];
2988 //
2989 // make temporary seed
2990 AliTPCseed * seed = new AliTPCseed;
1627d1c4 2991 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2992 // Double_t cs=cos(alpha), sn=sin(alpha);
91162307 2993 //
2994 //
1627d1c4 2995
91162307 2996 // first 3 padrows
2997 Double_t x1 = GetXrow(i1-1);
2998 const AliTPCRow& kr1=GetRow(sec,i1-1);
2999 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3000 //
3001 Double_t x1p = GetXrow(i1);
3002 const AliTPCRow& kr1p=GetRow(sec,i1);
3003 //
3004 Double_t x1m = GetXrow(i1-2);
3005 const AliTPCRow& kr1m=GetRow(sec,i1-2);
1627d1c4 3006
91162307 3007 //
3008 //last 3 padrow for seeding
3009 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3010 Double_t x3 = GetXrow(i1-7);
3011 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3012 //
3013 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3014 Double_t x3p = GetXrow(i1-6);
3015 //
3016 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3017 Double_t x3m = GetXrow(i1-8);
1627d1c4 3018
91162307 3019 //
3020 //
3021 // middle padrow
3022 Int_t im = i1-4; //middle pad row index
3023 Double_t xm = GetXrow(im); // radius of middle pad-row
3024 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3025 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3026 //
3027 //
3028 Double_t deltax = x1-x3;
3029 Double_t dymax = deltax*cuts[1];
3030 Double_t dzmax = deltax*cuts[3];
3031 //
3032 // loop over clusters
3033 for (Int_t is=0; is < kr1; is++) {
1627d1c4 3034 //
91162307 3035 if (kr1[is]->IsUsed(10)) continue;
3036 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
1627d1c4 3037 //
91162307 3038 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3039 //
3040 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3041 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3042 //
3043 Double_t y3, z3;
1627d1c4 3044 //
1627d1c4 3045 //
91162307 3046 UInt_t index;
3047 for (Int_t js=index1; js < index2; js++) {
3048 const AliTPCclusterMI *kcl = kr3[js];
3049 if (kcl->IsUsed(10)) continue;
3050 y3 = kcl->GetY();
3051 // apply angular cuts
3052 if (TMath::Abs(y1-y3)>dymax) continue;
3053 x3 = x3;
3054 z3 = kcl->GetZ();
3055 if (TMath::Abs(z1-z3)>dzmax) continue;
3056 //
3057 Double_t angley = (y1-y3)/(x1-x3);
3058 Double_t anglez = (z1-z3)/(x1-x3);
3059 //
3060 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3061 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3062 //
3063 Double_t yyym = angley*(xm-x1)+y1;
3064 Double_t zzzm = anglez*(xm-x1)+z1;
3065
3066 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3067 if (!kcm) continue;
3068 if (kcm->IsUsed(10)) continue;
3069
3070 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3071 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3072 //
3073 //
3074 //
3075 Int_t used =0;
3076 Int_t found =0;
3077 //
3078 // look around first
3079 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3080 anglez*(x1m-x1)+z1,
3081 erry,errz,index);
3082 //
3083 if (kc1m){
3084 found++;
3085 if (kc1m->IsUsed(10)) used++;
1627d1c4 3086 }
91162307 3087 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3088 anglez*(x1p-x1)+z1,
3089 erry,errz,index);
1627d1c4 3090 //
91162307 3091 if (kc1p){
3092 found++;
3093 if (kc1p->IsUsed(10)) used++;
1627d1c4 3094 }
91162307 3095 if (used>1) continue;
3096 if (found<1) continue;
1627d1c4 3097
91162307 3098 //
3099 // look around last
3100 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3101 anglez*(x3m-x3)+z3,
3102 erry,errz,index);
3103 //
3104 if (kc3m){
3105 found++;
3106 if (kc3m->IsUsed(10)) used++;
3107 }
3108 else
3109 continue;
3110 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3111 anglez*(x3p-x3)+z3,
3112 erry,errz,index);
3113 //
3114 if (kc3p){
3115 found++;
3116 if (kc3p->IsUsed(10)) used++;
3117 }
3118 else
3119 continue;
3120 if (used>1) continue;
3121 if (found<3) continue;
3122 //
3123 Double_t x2,y2,z2;
3124 x2 = xm;
3125 y2 = kcm->GetY();
3126 z2 = kcm->GetZ();
3127 //
3128
1627d1c4 3129 x[0]=y1;
3130 x[1]=z1;
b67e07dc 3131 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3132 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3133 nin0++;
3134 //
b67e07dc 3135 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3136 nin1++;
3137 //
b67e07dc 3138 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
91162307 3139 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3140 nin2++;
3141 //
3142 //
3143 Double_t sy1=0.1, sz1=0.1;
3144 Double_t sy2=0.1, sz2=0.1;
3145 Double_t sy3=0.1, sy=0.1, sz=0.1;
1627d1c4 3146
b67e07dc 3147 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3148 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3149 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3150 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3151 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3152 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 3153
b67e07dc 3154 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3155 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3156 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3157 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1627d1c4 3158
3159 c[0]=sy1;
91162307 3160 c[1]=0.; c[2]=sz1;
1627d1c4 3161 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3162 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3163 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3164 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3165 c[13]=f30*sy1*f40+f32*sy2*f42;
3166 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3167
91162307 3168 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3169
3170 UInt_t index=kr1.GetIndex(is);
3171 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3172
3173 track->fIsSeeding = kTRUE;
3174
3175 nin++;
3176 FollowProlongation(*track, i1-7,1);
3177 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3178 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3179 seed->Reset();
3180 seed->~AliTPCseed();
3181 continue;
3182 }
3183 nout1++;
3184 nout2++;
3185 //Int_t rc = 1;
3186 FollowProlongation(*track, i2,1);
3187 track->fBConstrain =0;
3188 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3189 track->fFirstPoint = track->fLastPoint;
3190
3191 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3192 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3193 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3194 seed->Reset();
3195 seed->~AliTPCseed();
3196 continue;
3197 }
3198
3199 {
3200 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3201 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3202 FollowProlongation(*track2, i2,1);
3203 track2->fBConstrain = kFALSE;
3204 track2->fSeedType = 4;
3205 arr->AddLast(track2);
3206 seed->Reset();
3207 seed->~AliTPCseed();
3208 }
3209
3210
3211 //arr->AddLast(track);
3212 //seed = new AliTPCseed;
3213 nout3++;
3214 }
3215 }
3216
6bdc18d6 3217 if (fDebug>3){
3218 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
91162307 3219 }
3220 delete seed;
3221}
3222
3223
3224//_____________________________________________________________________________
176aff27 3225void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3226 Float_t deltay, Bool_t /*bconstrain*/) {
91162307 3227 //-----------------------------------------------------------------
3228 // This function creates track seeds - without vertex constraint
3229 //-----------------------------------------------------------------
3230 // cuts[0] - fP4 cut - not applied
3231 // cuts[1] - tan(phi) cut
3232 // cuts[2] - zvertex cut - not applied
3233 // cuts[3] - fP3 cut
3234 Int_t nin0=0;
3235 Int_t nin1=0;
3236 Int_t nin2=0;
3237 Int_t nin3=0;
3238 // Int_t nin4=0;
3239 //Int_t nin5=0;
3240
3241
3242
3243 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3244 // Double_t cs=cos(alpha), sn=sin(alpha);
3245 Int_t row0 = (i1+i2)/2;
3246 Int_t drow = (i1-i2)/2;
3247 const AliTPCRow& kr0=fSectors[sec][row0];
3248 AliTPCRow * kr=0;
3249
3250 AliTPCpolyTrack polytrack;
3251 Int_t nclusters=fSectors[sec][row0];
3252 AliTPCseed * seed = new AliTPCseed;
3253
3254 Int_t sumused=0;
3255 Int_t cused=0;
3256 Int_t cnused=0;
3257 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3258 Int_t nfound =0;
3259 Int_t nfoundable =0;
3260 for (Int_t iter =1; iter<2; iter++){ //iterations
3261 const AliTPCRow& krm=fSectors[sec][row0-iter];
3262 const AliTPCRow& krp=fSectors[sec][row0+iter];
3263 const AliTPCclusterMI * cl= kr0[is];
3264
3265 if (cl->IsUsed(10)) {
3266 cused++;
3267 }
3268 else{
3269 cnused++;
3270 }
3271 Double_t x = kr0.GetX();
3272 // Initialization of the polytrack
3273 nfound =0;
3274 nfoundable =0;
3275 polytrack.Reset();
3276 //
3277 Double_t y0= cl->GetY();
3278 Double_t z0= cl->GetZ();
3279 Float_t erry = 0;
3280 Float_t errz = 0;
3281
3282 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3283 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3284
3285 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3286 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3287 polytrack.AddPoint(x,y0,z0,erry, errz);
3288
3289 sumused=0;
3290 if (cl->IsUsed(10)) sumused++;
3291
3292
3293 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3294 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3295 //
3296 x = krm.GetX();
3297 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3298 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3299 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3300 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3301 if (cl1->IsUsed(10)) sumused++;
3302 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3303 }
3304 //
3305 x = krp.GetX();
3306 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3307 if (cl2) {
3308 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3309 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3310 if (cl2->IsUsed(10)) sumused++;
3311 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3312 }
3313 //
3314 if (sumused>0) continue;
3315 nin0++;
3316 polytrack.UpdateParameters();
3317 // follow polytrack
3318 roadz = 1.2;
3319 roady = 1.2;
3320 //
3321 Double_t yn,zn;
3322 nfoundable = polytrack.GetN();
3323 nfound = nfoundable;
3324 //
3325 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3326 Float_t maxdist = 0.8*(1.+3./(ddrow));
3327 for (Int_t delta = -1;delta<=1;delta+=2){
3328 Int_t row = row0+ddrow*delta;
3329 kr = &(fSectors[sec][row]);
3330 Double_t xn = kr->GetX();
3331 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3332 polytrack.GetFitPoint(xn,yn,zn);
3333 if (TMath::Abs(yn)>ymax) continue;
3334 nfoundable++;
3335 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3336 if (cln) {
3337 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3338 if (dist<maxdist){
3339 /*
3340 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3341 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3342 if (cln->IsUsed(10)) {
3343 // printf("used\n");
3344 sumused++;
3345 erry*=2;
3346 errz*=2;
3347 }
3348 */
3349 erry=0.1;
3350 errz=0.1;
3351 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3352 nfound++;
3353 }
3354 }
3355 }
3356 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3357 polytrack.UpdateParameters();
3358 }
3359 }
3360 if ( (sumused>3) || (sumused>0.5*nfound)) {
3361 //printf("sumused %d\n",sumused);
3362 continue;
3363 }
3364 nin1++;
3365 Double_t dy,dz;
3366 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3367 AliTPCpolyTrack track2;
3368
3369 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3370 if (track2.GetN()<0.5*nfoundable) continue;
3371 nin2++;
3372
3373 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3374 //
3375 // test seed with and without constrain
3376 for (Int_t constrain=0; constrain<=0;constrain++){
3377 // add polytrack candidate
3378
3379 Double_t x[5], c[15];
3380 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3381 track2.GetBoundaries(x3,x1);
3382 x2 = (x1+x3)/2.;
3383 track2.GetFitPoint(x1,y1,z1);
3384 track2.GetFitPoint(x2,y2,z2);
3385 track2.GetFitPoint(x3,y3,z3);
3386 //
3387 //is track pointing to the vertex ?
3388 Double_t x0,y0,z0;
3389 x0=0;
3390 polytrack.GetFitPoint(x0,y0,z0);
3391
3392 if (constrain) {
3393 x2 = x3;
3394 y2 = y3;
3395 z2 = z3;
3396
3397 x3 = 0;
3398 y3 = 0;
3399 z3 = 0;
3400 }
3401 x[0]=y1;
3402 x[1]=z1;
b67e07dc 3403 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3404
3405 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
b67e07dc 3406 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3407
3408 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
b67e07dc 3409 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3410 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
91162307 3411 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3412
3413
3414 Double_t sy =0.1, sz =0.1;
3415 Double_t sy1=0.02, sz1=0.02;
3416 Double_t sy2=0.02, sz2=0.02;
3417 Double_t sy3=0.02;
3418
3419 if (constrain){
3420 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3421 }
3422
b67e07dc 3423 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3424 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3425 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3426 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3427 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3428 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3429
3430 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3431 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3432 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3433 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
91162307 3434
3435
3436 c[0]=sy1;
3437 c[1]=0.; c[2]=sz1;
3438 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3439 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3440 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3441 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3442 c[13]=f30*sy1*f40+f32*sy2*f42;
3443 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3444
3445 //Int_t row1 = fSectors->GetRowNumber(x1);
3446 Int_t row1 = GetRowNumber(x1);
3447
3448 UInt_t index=0;
3449 //kr0.GetIndex(is);
3450 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3451 track->fIsSeeding = kTRUE;
3452 Int_t rc=FollowProlongation(*track, i2);
3453 if (constrain) track->fBConstrain =1;
3454 else
3455 track->fBConstrain =0;
3456 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3457 track->fFirstPoint = track->fLastPoint;
3458
3459 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3460 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3461 track->fNShared>0.4*track->GetNumberOfClusters()) {
3462 //delete track;
3463 seed->Reset();
3464 seed->~AliTPCseed();
3465 }
3466 else {
3467 arr->AddLast(track);
3468 seed = new AliTPCseed;
3469 }
3470 nin3++;
3471 }
3472 } // if accepted seed
3473 }
6bdc18d6 3474 if (fDebug>3){
3475 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
91162307 3476 }
3477 delete seed;
3478}
3479
3480
3481AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3482{
3483 //
3484 //
d26d9159 3485 //reseed using track points
91162307 3486 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3487 Int_t p1 = int(r1*track->GetNumberOfClusters());
3488 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
176aff27 3489 Int_t pp2=0;
91162307 3490 Double_t x0[3],x1[3],x2[3];
3491 x0[0]=-1;
3492 x0[0]=-1;
3493 x0[0]=-1;
3494
3495 // find track position at given ratio of the length
3496 Int_t sec0, sec1, sec2;
176aff27 3497 sec0=0;
3498 sec1=0;
3499 sec2=0;
91162307 3500 Int_t index=-1;
3501 Int_t clindex;
3502 for (Int_t i=0;i<160;i++){
3503 if (track->fClusterPointer[i]){
3504 index++;
3505 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3506 if ( (index<p0) || x0[0]<0 ){
3507 if (trpoint->GetX()>1){
3508 clindex = track->GetClusterIndex2(i);
3509 if (clindex>0){
3510 x0[0] = trpoint->GetX();
3511 x0[1] = trpoint->GetY();
3512 x0[2] = trpoint->GetZ();
3513 sec0 = ((clindex&0xff000000)>>24)%18;
3514 }
3515 }
3516 }