]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCtrackerMI.cxx
Reconstruction of raw data (T.Kuhr)
[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);
370 }
91162307 371 }
1c53abe2 372 }
d26d9159 373}
374
47966a6d 375void AliTPCtrackerMI::WriteTracks(TTree * tree)
376{
d26d9159 377 //
47966a6d 378 // write tracks from seed array to selected tree
d26d9159 379 //
380 fOutput = tree;
381 if (fOutput){
382 AliTPCtrack *iotrack= new AliTPCtrack;
383 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
384 }
385 WriteTracks();
386}
387
388void AliTPCtrackerMI::WriteTracks()
389{
390 //
391 // write tracks to the given output tree -
392 // output specified with SetIO routine
393 if (!fSeeds) return;
394 if (!fOutput){
395 SetIO();
396 }
1c53abe2 397
91162307 398 if (fOutput){
399 AliTPCtrack *iotrack= 0;
400 Int_t nseed=fSeeds->GetEntriesFast();
982aff31 401 //for (Int_t i=0; i<nseed; i++) {
402 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
403 // if (iotrack) break;
404 //}
91162307 405 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
406 TBranch * br = fOutput->GetBranch("tracks");
407 br->SetAddress(&iotrack);
408 //
409 for (Int_t i=0; i<nseed; i++) {
410 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
411 if (!pt) continue;
982aff31 412 AliTPCtrack * track = new AliTPCtrack(*pt);
413 iotrack = track;
91162307 414 pt->fLab2 =i;
415 // br->SetAddress(&iotrack);
416 fOutput->Fill();
982aff31 417 delete track;
91162307 418 iotrack =0;
419 }
982aff31 420 //fOutput->GetDirectory()->cd();
421 //fOutput->Write();
91162307 422 }
d26d9159 423 // delete iotrack;
424 //
91162307 425 if (fSeedTree){
426 //write the full seed information if specified in debug mode
427
428 AliTPCseed * vseed = new AliTPCseed;
429 //
430 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
431 arrtr->ExpandCreateFast(160);
432 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
433 //arrcl->ExpandCreateFast(160);
434 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
435 //
436 vseed->fPoints = arrtr;
437 vseed->fEPoints = arre;
438 // vseed->fClusterPoints = arrcl;
439 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
440 TBranch * brseed = fSeedTree->GetBranch("seeds");
441
442 Int_t nseed=fSeeds->GetEntriesFast();
443
444 for (Int_t i=0; i<nseed; i++) {
445 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
446 if (!pt) continue;
447 pt->fPoints = arrtr;
448 // pt->fClusterPoints = arrcl;
449 pt->fEPoints = arre;
450 pt->RebuildSeed();
451 vseed = pt;
452 brseed->SetAddress(&vseed);
453 fSeedTree->Fill();
454 pt->fPoints = 0;
455 pt->fEPoints = 0;
456 // pt->fClusterPoints = 0;
457 }
458 fSeedTree->Write();
459 if (fTreeDebug) fTreeDebug->Write();
460 }
1c53abe2 461
91162307 462}
1c53abe2 463
1c53abe2 464
1c53abe2 465
466
91162307 467Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
468 //
469 //
470 //seed->SetErrorY2(0.1);
471 //return 0.1;
472 //calculate look-up table at the beginning
473 static Bool_t ginit = kFALSE;
474 static Float_t gnoise1,gnoise2,gnoise3;
475 static Float_t ggg1[10000];
476 static Float_t ggg2[10000];
477 static Float_t ggg3[10000];
478 static Float_t glandau1[10000];
479 static Float_t glandau2[10000];
480 static Float_t glandau3[10000];
481 //
482 static Float_t gcor01[500];
483 static Float_t gcor02[500];
484 static Float_t gcorp[500];
485 //
1c53abe2 486
91162307 487 //
488 if (ginit==kFALSE){
489 for (Int_t i=1;i<500;i++){
490 Float_t rsigma = float(i)/100.;
491 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
492 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
493 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
494 }
1c53abe2 495
91162307 496 //
497 for (Int_t i=3;i<10000;i++){
498 //
499 //
500 // inner sector
501 Float_t amp = float(i);
502 Float_t padlength =0.75;
503 gnoise1 = 0.0004/padlength;
504 Float_t nel = 0.268*amp;
505 Float_t nprim = 0.155*amp;
506 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
507 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
508 if (glandau1[i]>1) glandau1[i]=1;
509 glandau1[i]*=padlength*padlength/12.;
510 //
511 // outer short
512 padlength =1.;
513 gnoise2 = 0.0004/padlength;
514 nel = 0.3*amp;
515 nprim = 0.133*amp;
516 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
517 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
518 if (glandau2[i]>1) glandau2[i]=1;
519 glandau2[i]*=padlength*padlength/12.;
520 //
521 //
522 // outer long
523 padlength =1.5;
524 gnoise3 = 0.0004/padlength;
525 nel = 0.3*amp;
526 nprim = 0.133*amp;
527 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
528 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
529 if (glandau3[i]>1) glandau3[i]=1;
530 glandau3[i]*=padlength*padlength/12.;
531 //
532 }
533 ginit = kTRUE;
534 }
1c53abe2 535 //
536 //
91162307 537 //
538 Int_t amp = int(TMath::Abs(cl->GetQ()));
539 if (amp>9999) {
540 seed->SetErrorY2(1.);
541 return 1.;
542 }
1c53abe2 543 Float_t snoise2;
c9427e08 544 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
91162307 545 Int_t ctype = cl->GetType();
546 Float_t padlength= GetPadPitchLength(seed->fRow);
547 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
548 angle2 = angle2/(1-angle2);
549 //
550 //cluster "quality"
551 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
552 Float_t res;
1c53abe2 553 //
1c53abe2 554 if (fSectors==fInnerSec){
91162307 555 snoise2 = gnoise1;
556 res = ggg1[amp]*z+glandau1[amp]*angle2;
557 if (ctype==0) res *= gcor01[rsigmay];
558 if ((ctype>0)){
559 res+=0.002;
560 res*= gcorp[rsigmay];
561 }
1c53abe2 562 }
563 else {
91162307 564 if (padlength<1.1){
565 snoise2 = gnoise2;
566 res = ggg2[amp]*z+glandau2[amp]*angle2;
567 if (ctype==0) res *= gcor02[rsigmay];
568 if ((ctype>0)){
569 res+=0.002;
570 res*= gcorp[rsigmay];
571 }
572 }
573 else{
574 snoise2 = gnoise3;
575 res = ggg3[amp]*z+glandau3[amp]*angle2;
576 if (ctype==0) res *= gcor02[rsigmay];
577 if ((ctype>0)){
578 res+=0.002;
579 res*= gcorp[rsigmay];
580 }
581 }
582 }
1c53abe2 583
91162307 584 if (ctype<0){
585 res+=0.005;
586 res*=2.4; // overestimate error 2 times
587 }
588 res+= snoise2;
589
1c53abe2 590 if (res<2*snoise2)
91162307 591 res = 2*snoise2;
592
593 seed->SetErrorY2(res);
1c53abe2 594 return res;
1c53abe2 595
596
91162307 597}
c9427e08 598
599
600
91162307 601Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
602 //
603 //
604 //seed->SetErrorY2(0.1);
605 //return 0.1;
606 //calculate look-up table at the beginning
607 static Bool_t ginit = kFALSE;
608 static Float_t gnoise1,gnoise2,gnoise3;
609 static Float_t ggg1[10000];
610 static Float_t ggg2[10000];
611 static Float_t ggg3[10000];
612 static Float_t glandau1[10000];
613 static Float_t glandau2[10000];
614 static Float_t glandau3[10000];
615 //
616 static Float_t gcor01[1000];
617 static Float_t gcor02[1000];
618 static Float_t gcorp[1000];
1627d1c4 619 //
1627d1c4 620
91162307 621 //
622 if (ginit==kFALSE){
623 for (Int_t i=1;i<1000;i++){
624 Float_t rsigma = float(i)/100.;
625 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
626 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
627 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
628 }
1c53abe2 629
91162307 630 //
631 for (Int_t i=3;i<10000;i++){
632 //
633 //
634 // inner sector
635 Float_t amp = float(i);
636 Float_t padlength =0.75;
637 gnoise1 = 0.0004/padlength;
638 Float_t nel = 0.268*amp;
639 Float_t nprim = 0.155*amp;
640 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
641 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
642 if (glandau1[i]>1) glandau1[i]=1;
643 glandau1[i]*=padlength*padlength/12.;
644 //
645 // outer short
646 padlength =1.;
647 gnoise2 = 0.0004/padlength;
648 nel = 0.3*amp;
649 nprim = 0.133*amp;
650 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
651 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
652 if (glandau2[i]>1) glandau2[i]=1;
653 glandau2[i]*=padlength*padlength/12.;
654 //
655 //
656 // outer long
657 padlength =1.5;
658 gnoise3 = 0.0004/padlength;
659 nel = 0.3*amp;
660 nprim = 0.133*amp;
661 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
662 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
663 if (glandau3[i]>1) glandau3[i]=1;
664 glandau3[i]*=padlength*padlength/12.;
665 //
666 }
667 ginit = kTRUE;
668 }
669 //
670 //
671 //
672 Int_t amp = int(TMath::Abs(cl->GetQ()));
673 if (amp>9999) {
674 seed->SetErrorY2(1.);
675 return 1.;
676 }
677 Float_t snoise2;
678 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
679 Int_t ctype = cl->GetType();
680 Float_t padlength= GetPadPitchLength(seed->fRow);
681 //
682 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
683 // if (angle2<0.6) angle2 = 0.6;
684 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
685 //
686 //cluster "quality"
687 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
688 Float_t res;
689 //
690 if (fSectors==fInnerSec){
691 snoise2 = gnoise1;
692 res = ggg1[amp]*z+glandau1[amp]*angle2;
693 if (ctype==0) res *= gcor01[rsigmaz];
694 if ((ctype>0)){
695 res+=0.002;
696 res*= gcorp[rsigmaz];
697 }
698 }
699 else {
700 if (padlength<1.1){
701 snoise2 = gnoise2;
702 res = ggg2[amp]*z+glandau2[amp]*angle2;
703 if (ctype==0) res *= gcor02[rsigmaz];
704 if ((ctype>0)){
705 res+=0.002;
706 res*= gcorp[rsigmaz];
707 }
708 }
709 else{
710 snoise2 = gnoise3;
711 res = ggg3[amp]*z+glandau3[amp]*angle2;
712 if (ctype==0) res *= gcor02[rsigmaz];
713 if ((ctype>0)){
714 res+=0.002;
715 res*= gcorp[rsigmaz];
716 }
717 }
718 }
719
720 if (ctype<0){
721 res+=0.002;
722 res*=1.3;
723 }
724 if ((ctype<0) &&amp<70){
725 res+=0.002;
726 res*=1.3;
727 }
728 res += snoise2;
729 if (res<2*snoise2)
730 res = 2*snoise2;
731 if (res>3) res =3;
732 seed->SetErrorZ2(res);
733 return res;
734}
735
736
737
738/*
739Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
740 //
741 //
742 //seed->SetErrorZ2(0.1);
743 //return 0.1;
744
745 Float_t snoise2;
746 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
747 //
748 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
749 Int_t ctype = cl->GetType();
750 Float_t amp = TMath::Abs(cl->GetQ());
751
752 Float_t nel;
753 Float_t nprim;
754 //
755 Float_t landau=2 ; //landau fluctuation part
756 Float_t gg=2; // gg fluctuation part
757 Float_t padlength= GetPadPitchLength(seed->GetX());
758
759 if (fSectors==fInnerSec){
760 snoise2 = 0.0004/padlength;
761 nel = 0.268*amp;
762 nprim = 0.155*amp;
763 gg = (2+0.001*nel/(padlength*padlength))/nel;
764 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
765 if (landau>1) landau=1;
766 }
767 else {
768 snoise2 = 0.0004/padlength;
769 nel = 0.3*amp;
770 nprim = 0.133*amp;
771 gg = (2+0.0008*nel/(padlength*padlength))/nel;
772 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
773 if (landau>1) landau=1;
774 }
775 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
776
777 //
778 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
779 angle2 = TMath::Sqrt((1-angle2));
780 if (angle2<0.6) angle2 = 0.6;
781 //angle2 = 1;
782
783 Float_t angle = seed->GetTgl()/angle2;
784 Float_t angular = landau*angle*angle*padlength*padlength/12.;
785 Float_t res = sdiff + angular;
786
787
788 if ((ctype==0) && (fSectors ==fOuterSec))
789 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
790
791 if ((ctype==0) && (fSectors ==fInnerSec))
792 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
793
794 if ((ctype>0)){
795 res+=0.005;
796 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
797 }
798 if (ctype<0){
799 res+=0.002;
800 res*=1.3;
801 }
802 if ((ctype<0) &&amp<70){
803 res+=0.002;
804 res*=1.3;
805 }
806 res += snoise2;
807 if (res<2*snoise2)
808 res = 2*snoise2;
809
810 seed->SetErrorZ2(res);
811 return res;
812}
813*/
814
815
816
817void AliTPCseed::Reset(Bool_t all)
818{
819 //
820 //
821 SetNumberOfClusters(0);
822 fNFoundable = 0;
823 SetChi2(0);
824 ResetCovariance();
825 /*
826 if (fTrackPoints){
827 for (Int_t i=0;i<8;i++){
828 delete [] fTrackPoints[i];
829 }
830 delete fTrackPoints;
831 fTrackPoints =0;
832 }
833 */
834
835 if (all){
836 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
837 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
838 }
839
840}
841
842
843void AliTPCseed::Modify(Double_t factor)
844{
845
846 //------------------------------------------------------------------
847 //This function makes a track forget its history :)
848 //------------------------------------------------------------------
849 if (factor<=0) {
850 ResetCovariance();
851 return;
852 }
853 fC00*=factor;
982aff31 854 fC10*=0; fC11*=factor;
855 fC20*=0; fC21*=0; fC22*=factor;
856 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
857 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
91162307 858 SetNumberOfClusters(0);
859 fNFoundable =0;
860 SetChi2(0);
861 fRemoval = 0;
862 fCurrentSigmaY2 = 0.000005;
863 fCurrentSigmaZ2 = 0.000005;
864 fNoCluster = 0;
865 //fFirstPoint = 160;
866 //fLastPoint = 0;
867}
868
869
870
871
872Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
873{
874 //-----------------------------------------------------------------
875 // This function find proloncation of a track to a reference plane x=xk.
876 // doesn't change internal state of the track
877 //-----------------------------------------------------------------
878
1c53abe2 879 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
91162307 880
881 if (TMath::Abs(fP4*xk - fP2) >= 0.999) {
882 return 0;
883 }
884
1c53abe2 885 // Double_t y1=fP0, z1=fP1;
886 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
887 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
888
889 y = fP0;
890 z = fP1;
91162307 891 //y += dx*(c1+c2)/(r1+r2);
892 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
893
894 Double_t dy = dx*(c1+c2)/(r1+r2);
895 Double_t dz = 0;
896 //
897 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
898 /*
899 if (TMath::Abs(delta)>0.0001){
900 dz = fP3*TMath::ASin(delta)/fP4;
901 }else{
902 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
903 }
904 */
b67e07dc 905 dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
91162307 906 //
907 y+=dy;
908 z+=dz;
909
910
911 return 1;
1c53abe2 912}
913
914
915//_____________________________________________________________________________
916Double_t AliTPCseed::GetPredictedChi2(const AliTPCclusterMI *c) const
917{
918 //-----------------------------------------------------------------
919 // This function calculates a predicted chi2 increment.
920 //-----------------------------------------------------------------
921 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
922 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
923 r00+=fC00; r01+=fC10; r11+=fC11;
924
925 Double_t det=r00*r11 - r01*r01;
926 if (TMath::Abs(det) < 1.e-10) {
927 Int_t n=GetNumberOfClusters();
928 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
929 return 1e10;
930 }
931 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
932
933 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
934
935 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
936}
937
938
939//_________________________________________________________________________________________
940
941
942Int_t AliTPCseed::Compare(const TObject *o) const {
943 //-----------------------------------------------------------------
944 // This function compares tracks according to the sector - for given sector according z
945 //-----------------------------------------------------------------
946 AliTPCseed *t=(AliTPCseed*)o;
1c53abe2 947
91162307 948 if (fSort == 0){
949 if (t->fRelativeSector>fRelativeSector) return -1;
950 if (t->fRelativeSector<fRelativeSector) return 1;
951 Double_t z2 = t->GetZ();
952 Double_t z1 = GetZ();
953 if (z2>z1) return 1;
954 if (z2<z1) return -1;
955 return 0;
956 }
957 else {
958 Float_t f2 =1;
959 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
960 if (t->fBConstrain) f2=1.2;
961
962 Float_t f1 =1;
963 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
964
965 if (fBConstrain) f1=1.2;
966
967 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
968 else return +1;
969 }
1c53abe2 970}
971
c9427e08 972void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
973{
974 //rotate to track "local coordinata
975 Float_t x = seed->GetX();
976 Float_t y = seed->GetY();
977 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
91162307 978
c9427e08 979 if (y > ymax) {
980 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
981 if (!seed->Rotate(fSectors->GetAlpha()))
982 return;
983 } else if (y <-ymax) {
984 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
985 if (!seed->Rotate(-fSectors->GetAlpha()))
986 return;
987 }
1c53abe2 988
c9427e08 989}
1c53abe2 990
991
992
993
994//_____________________________________________________________________________
176aff27 995Int_t AliTPCseed::Update(const AliTPCclusterMI *c, Double_t chisq, UInt_t /*index*/) {
1c53abe2 996 //-----------------------------------------------------------------
997 // This function associates a cluster with this track.
998 //-----------------------------------------------------------------
1c53abe2 999 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
1000
1001 r00+=fC00; r01+=fC10; r11+=fC11;
1002 Double_t det=r00*r11 - r01*r01;
1003 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
1004
1005 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
1006 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
1007 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
1008 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
1009 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
1010
1011 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
1012 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
1627d1c4 1013 if (TMath::Abs(cur*fX-eta) >= 0.9) {
1c53abe2 1014 return 0;
1015 }
1016
1017 fP0 += k00*dy + k01*dz;
1018 fP1 += k10*dy + k11*dz;
1019 fP2 = eta;
1020 fP3 += k30*dy + k31*dz;
1021 fP4 = cur;
1022
1023 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
1024 Double_t c12=fC21, c13=fC31, c14=fC41;
1025
1026 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
1027 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
1028 fC40-=k00*c04+k01*c14;
1029
1030 fC11-=k10*c01+k11*fC11;
1031 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
1032 fC41-=k10*c04+k11*c14;
1033
1034 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
1035 fC42-=k20*c04+k21*c14;
1036
1037 fC33-=k30*c03+k31*c13;
1038 fC43-=k40*c03+k41*c13;
1039
1040 fC44-=k40*c04+k41*c14;
1041
1042 Int_t n=GetNumberOfClusters();
91162307 1043 // fIndex[n]=index;
1c53abe2 1044 SetNumberOfClusters(n+1);
1045 SetChi2(GetChi2()+chisq);
1046
1047 return 1;
1048}
1049
1050
1051
1052//_____________________________________________________________________________
b67e07dc 1053Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1c53abe2 1054 Double_t x2,Double_t y2,
1055 Double_t x3,Double_t y3)
1056{
1057 //-----------------------------------------------------------------
1058 // Initial approximation of the track curvature
1059 //-----------------------------------------------------------------
1060 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1061 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1062 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1063 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1064 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1065
1066 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
91162307 1067 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1c53abe2 1068 return -xr*yr/sqrt(xr*xr+yr*yr);
1069}
1070
1071
91162307 1072
1c53abe2 1073//_____________________________________________________________________________
b67e07dc 1074Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
91162307 1075 Double_t x2,Double_t y2,
1076 Double_t x3,Double_t y3)
1077{
1078 //-----------------------------------------------------------------
1079 // Initial approximation of the track curvature
1080 //-----------------------------------------------------------------
1081 x3 -=x1;
1082 x2 -=x1;
1083 y3 -=y1;
1084 y2 -=y1;
1085 //
1086 Double_t det = x3*y2-x2*y3;
1087 if (det==0) {
1088 return 100;
1089 }
1090 //
1091 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1092 Double_t x0 = x3*0.5-y3*u;
1093 Double_t y0 = y3*0.5+x3*u;
1094 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1095 if (det<0) c2*=-1;
1096 return c2;
1097}
1098
1099
b67e07dc 1100Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1c53abe2 1101 Double_t x2,Double_t y2,
1102 Double_t x3,Double_t y3)
91162307 1103{
1104 //-----------------------------------------------------------------
1105 // Initial approximation of the track curvature
1106 //-----------------------------------------------------------------
1107 x3 -=x1;
1108 x2 -=x1;
1109 y3 -=y1;
1110 y2 -=y1;
1111 //
1112 Double_t det = x3*y2-x2*y3;
1113 if (det==0) {
1114 return 100;
1115 }
1116 //
1117 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1118 Double_t x0 = x3*0.5-y3*u;
1119 Double_t y0 = y3*0.5+x3*u;
1120 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1121 if (det<0) c2*=-1;
1122 x0+=x1;
1123 x0*=c2;
1124 return x0;
1125}
1126
1127
1128
1129//_____________________________________________________________________________
b67e07dc 1130Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
91162307 1131 Double_t x2,Double_t y2,
1132 Double_t x3,Double_t y3)
1c53abe2 1133{
1134 //-----------------------------------------------------------------
1135 // Initial approximation of the track curvature times center of curvature
1136 //-----------------------------------------------------------------
1137 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1138 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1139 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1140 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1141 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1142
1143 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1144
1145 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1146}
1147
1148//_____________________________________________________________________________
b67e07dc 1149Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1c53abe2 1150 Double_t x2,Double_t y2,
1151 Double_t z1,Double_t z2)
1152{
1153 //-----------------------------------------------------------------
1154 // Initial approximation of the tangent of the track dip angle
1155 //-----------------------------------------------------------------
1156 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1157}
1158
1159
b67e07dc 1160Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
91162307 1161 Double_t x2,Double_t y2,
1162 Double_t z1,Double_t z2, Double_t c)
1c53abe2 1163{
91162307 1164 //-----------------------------------------------------------------
1165 // Initial approximation of the tangent of the track dip angle
1166 //-----------------------------------------------------------------
1167
1168 // Double_t angle1;
1169
1170 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1c53abe2 1171 //
91162307 1172 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1173 if (TMath::Abs(d*c*0.5)>1) return 0;
1174 // Double_t angle2 = TMath::ASin(d*c*0.5);
b67e07dc 1175 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1176 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
91162307 1177
1178 angle2 = (z1-z2)*c/(angle2*2.);
1179 return angle2;
1180}
1181
1182Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1183{//-----------------------------------------------------------------
1184 // This function find proloncation of a track to a reference plane x=x2.
1185 //-----------------------------------------------------------------
1186
1187 Double_t dx=x2-x1;
1188
1189 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1190 return kFALSE;
1c53abe2 1191 }
f8aae377 1192
91162307 1193 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1194 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1195 y = x[0];
1196 z = x[1];
1197
1198 Double_t dy = dx*(c1+c2)/(r1+r2);
1199 Double_t dz = 0;
1200 //
1201 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1202
1203 if (TMath::Abs(delta)>0.01){
1204 dz = x[3]*TMath::ASin(delta)/x[4];
1205 }else{
b67e07dc 1206 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
91162307 1207 }
1208
b67e07dc 1209 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
f8aae377 1210
91162307 1211 y+=dy;
1212 z+=dz;
1213
1214 return kTRUE;
1c53abe2 1215}
1216
d26d9159 1217Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1218{
1219 //
1220 //
1221 fInput = tree;
1222 return LoadClusters();
1223}
91162307 1224
1225Int_t AliTPCtrackerMI::LoadClusters()
1c53abe2 1226{
1227 //
1228 // load clusters to the memory
91162307 1229 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1230 clrow->SetClass("AliTPCclusterMI");
1231 clrow->SetArray(0);
1232 clrow->GetArray()->ExpandCreateFast(10000);
1233 //
1234 // TTree * tree = fClustersArray.GetTree();
1235
1236 TTree * tree = fInput;
1237 TBranch * br = tree->GetBranch("Segment");
1238 br->SetAddress(&clrow);
1239 //
1240 Int_t j=Int_t(tree->GetEntries());
1c53abe2 1241 for (Int_t i=0; i<j; i++) {
91162307 1242 br->GetEntry(i);
1243 //
1244 Int_t sec,row;
1245 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
1246 //
1247 AliTPCRow * tpcrow=0;
1248 Int_t left=0;
1249 if (sec<fkNIS*2){
1250 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1251 left = sec/fkNIS;
1252 }
1253 else{
1254 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1255 left = (sec-fkNIS*2)/fkNOS;
1256 }
1257 if (left ==0){
1258 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1259 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1260 for (Int_t i=0;i<tpcrow->fN1;i++)
1261 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1262 }
1263 if (left ==1){
1264 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1265 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1266 for (Int_t i=0;i<tpcrow->fN2;i++)
1267 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1268 }
1c53abe2 1269 }
91162307 1270 //
1271 delete clrow;
1272 LoadOuterSectors();
1273 LoadInnerSectors();
1274 return 0;
1c53abe2 1275}
1276
1277
91162307 1278void AliTPCtrackerMI::UnloadClusters()
1279{
1280 //
1281 // unload clusters from the memory
1282 //
1283 Int_t nrows = fOuterSec->GetNRows();
1284 for (Int_t sec = 0;sec<fkNOS;sec++)
1285 for (Int_t row = 0;row<nrows;row++){
1286 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
982aff31 1287 // if (tpcrow){
1288 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1289 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1290 //}
1291 tpcrow->ResetClusters();
1c53abe2 1292 }
91162307 1293 //
1294 nrows = fInnerSec->GetNRows();
1295 for (Int_t sec = 0;sec<fkNIS;sec++)
1296 for (Int_t row = 0;row<nrows;row++){
1297 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
982aff31 1298 //if (tpcrow){
1299 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1300 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1301 //}
1302 tpcrow->ResetClusters();
91162307 1303 }
1304
1305 return ;
1c53abe2 1306}
1307
1308
1309//_____________________________________________________________________________
91162307 1310Int_t AliTPCtrackerMI::LoadOuterSectors() {
1c53abe2 1311 //-----------------------------------------------------------------
91162307 1312 // This function fills outer TPC sectors with clusters.
1c53abe2 1313 //-----------------------------------------------------------------
91162307 1314 Int_t nrows = fOuterSec->GetNRows();
1315 UInt_t index=0;
1316 for (Int_t sec = 0;sec<fkNOS;sec++)
1317 for (Int_t row = 0;row<nrows;row++){
1318 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1319 Int_t sec2 = sec+2*fkNIS;
1320 //left
1321 Int_t ncl = tpcrow->fN1;
1322 while (ncl--) {
1323 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1324 index=(((sec2<<8)+row)<<16)+ncl;
1325 tpcrow->InsertCluster(c,index);
1326 }
1327 //right
1328 ncl = tpcrow->fN2;
1329 while (ncl--) {
1330 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1331 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1332 tpcrow->InsertCluster(c,index);
1333 }
1334 //
1335 // write indexes for fast acces
1336 //
1337 for (Int_t i=0;i<510;i++)
1338 tpcrow->fFastCluster[i]=-1;
1339 for (Int_t i=0;i<tpcrow->GetN();i++){
1340 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1341 tpcrow->fFastCluster[zi]=i; // write index
1342 }
1343 Int_t last = 0;
1344 for (Int_t i=0;i<510;i++){
1345 if (tpcrow->fFastCluster[i]<0)
1346 tpcrow->fFastCluster[i] = last;
1347 else
1348 last = tpcrow->fFastCluster[i];
1349 }
1350 }
1351 fN=fkNOS;
1352 fSectors=fOuterSec;
1353 return 0;
1354}
1355
1356
1357//_____________________________________________________________________________
1358Int_t AliTPCtrackerMI::LoadInnerSectors() {
1359 //-----------------------------------------------------------------
1360 // This function fills inner TPC sectors with clusters.
1361 //-----------------------------------------------------------------
1362 Int_t nrows = fInnerSec->GetNRows();
1363 UInt_t index=0;
1364 for (Int_t sec = 0;sec<fkNIS;sec++)
1365 for (Int_t row = 0;row<nrows;row++){
1366 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1367 //
1368 //left
1369 Int_t ncl = tpcrow->fN1;
1370 while (ncl--) {
1371 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1372 index=(((sec<<8)+row)<<16)+ncl;
1373 tpcrow->InsertCluster(c,index);
1374 }
1375 //right
1376 ncl = tpcrow->fN2;
1377 while (ncl--) {
1378 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1379 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1380 tpcrow->InsertCluster(c,index);
1381 }
1382 //
1383 // write indexes for fast acces
1384 //
1385 for (Int_t i=0;i<510;i++)
1386 tpcrow->fFastCluster[i]=-1;
1387 for (Int_t i=0;i<tpcrow->GetN();i++){
1388 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1389 tpcrow->fFastCluster[zi]=i; // write index
1390 }
1391 Int_t last = 0;
1392 for (Int_t i=0;i<510;i++){
1393 if (tpcrow->fFastCluster[i]<0)
1394 tpcrow->fFastCluster[i] = last;
1395 else
1396 last = tpcrow->fFastCluster[i];
1397 }
1c53abe2 1398
91162307 1399 }
1400
1c53abe2 1401 fN=fkNIS;
1402 fSectors=fInnerSec;
91162307 1403 return 0;
1404}
1405
1406
1407
1408//_________________________________________________________________________
1409AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1410 //--------------------------------------------------------------------
1411 // Return pointer to a given cluster
1412 //--------------------------------------------------------------------
1413 Int_t sec=(index&0xff000000)>>24;
1414 Int_t row=(index&0x00ff0000)>>16;
d26d9159 1415 Int_t ncl=(index&0x00007fff)>>00;
91162307 1416
1417 const AliTPCRow * tpcrow=0;
1418 AliTPCclusterMI * clrow =0;
3da363a1 1419
91162307 1420 if (sec<fkNIS*2){
1421 tpcrow = &(fInnerSec[sec%fkNIS][row]);
3da363a1 1422 if (tpcrow==0) return 0;
1423
1424 if (sec<fkNIS) {
1425 if (tpcrow->fN1<=ncl) return 0;
91162307 1426 clrow = tpcrow->fClusters1;
3da363a1 1427 }
1428 else {
1429 if (tpcrow->fN2<=ncl) return 0;
91162307 1430 clrow = tpcrow->fClusters2;
3da363a1 1431 }
91162307 1432 }
3da363a1 1433 else {
91162307 1434 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
3da363a1 1435 if (tpcrow==0) return 0;
1436
1437 if (sec-2*fkNIS<fkNOS) {
1438 if (tpcrow->fN1<=ncl) return 0;
91162307 1439 clrow = tpcrow->fClusters1;
3da363a1 1440 }
1441 else {
1442 if (tpcrow->fN2<=ncl) return 0;
91162307 1443 clrow = tpcrow->fClusters2;
3da363a1 1444 }
91162307 1445 }
3da363a1 1446
91162307 1447 return &(clrow[ncl]);
1448
1c53abe2 1449}
1450
91162307 1451
1452
1c53abe2 1453Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1454 //-----------------------------------------------------------------
1455 // This function tries to find a track prolongation to next pad row
1456 //-----------------------------------------------------------------
1c53abe2 1457 //
91162307 1458 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
4d158c36 1459 AliTPCclusterMI *cl=0;
1460 Int_t tpcindex= t.GetClusterIndex2(nr);
1461 //
1462 // update current shape info every 5 pad-row
1463 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1464 GetShape(&t,nr);
1465 //}
1466 //
1467 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1468 //
1469 if (tpcindex==-1) return 0; //track in dead zone
1470 if (tpcindex>0){ //
1471 cl = t.fClusterPointer[nr];
e0656451 1472 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
4d158c36 1473 t.fCurrentClusterIndex1 = tpcindex;
1474 }
1475 if (cl){
1476 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1477 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1478 //
1479 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1480 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1481
1482 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1483 Double_t rotation = angle-t.GetAlpha();
1484 t.fRelativeSector= relativesector;
1485 t.Rotate(rotation);
1486 }
1487 t.PropagateTo(x);
1488 //
1489 t.fCurrentCluster = cl;
1490 t.fRow = nr;
1491 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1492 if ((tpcindex&0x8000)==0) accept =0;
1493 if (accept<3) {
1494 //if founded cluster is acceptible
1495 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1496 t.fErrorY2 += 0.03;
1497 t.fErrorZ2 += 0.03;
1498 t.fErrorY2 *= 3;
1499 t.fErrorZ2 *= 3;
1500 }
1501 t.fNFoundable++;
1502 UpdateTrack(&t,accept);
1503 return 1;
1504 }
1505 }
1627d1c4 1506 }
4d158c36 1507 if (fIteration>1) return 0; // not look for new cluster during refitting
91162307 1508 //
4d158c36 1509 UInt_t index=0;
1510 if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
1511 Double_t y=t.GetYat(x);
91162307 1512 if (TMath::Abs(y)>ymax){
1513 if (y > ymax) {
1514 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1515 if (!t.Rotate(fSectors->GetAlpha()))
1516 return 0;
1517 } else if (y <-ymax) {
1518 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1519 if (!t.Rotate(-fSectors->GetAlpha()))
1520 return 0;
1521 }
4d158c36 1522 //return 1;
91162307 1523 }
1524 //
4d158c36 1525 if (!t.PropagateTo(x)) {
1526 if (fIteration==0) t.fRemoval = 10;
1527 return 0;
91162307 1528 }
4d158c36 1529 y=t.GetY();
1530 Double_t z=t.GetZ();
1531 //
91162307 1532 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1533 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1534 Double_t roady =1.;
1535 Double_t roadz = 1.;
1536 //
1c53abe2 1537 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1538 t.fInDead = kTRUE;
91162307 1539 t.SetClusterIndex2(nr,-1);
1c53abe2 1540 return 0;
1541 }
1542 else
1543 {
d7a11555 1544 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10)) t.fNFoundable++;
1627d1c4 1545 else
1546 return 0;
1c53abe2 1547 }
1548 //calculate
91162307 1549 if (krow) {
1550 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1551 cl = krow.FindNearest2(y,z,roady,roadz,index);
1552 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1553 }
91162307 1554 if (cl) {
1555 t.fCurrentCluster = cl;
1556 t.fRow = nr;
4d158c36 1557 if (fIteration==2&&cl->IsUsed(10)) return 0;
91162307 1558 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
4d158c36 1559 if (fIteration==2&&cl->IsUsed(11)) {
1560 t.fErrorY2 += 0.03;
1561 t.fErrorZ2 += 0.03;
1562 t.fErrorY2 *= 3;
1563 t.fErrorZ2 *= 3;
1564 }
d26d9159 1565 /*
91162307 1566 if (t.fCurrentCluster->IsUsed(10)){
1567 //
1568 //
c9427e08 1569
91162307 1570 t.fNShared++;
1571 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1572 t.fRemoval =10;
1573 return 0;
1574 }
1575 }
d26d9159 1576 */
91162307 1577 if (accept<3) UpdateTrack(&t,accept);
c9427e08 1578
91162307 1579 } else {
982aff31 1580 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
91162307 1581
1582 }
1583 return 1;
1584}
c9427e08 1585
91162307 1586Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1587 //-----------------------------------------------------------------
1588 // This function tries to find a track prolongation to next pad row
1589 //-----------------------------------------------------------------
1590 //
1591 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1592 Double_t y,z;
1593 if (!t.GetProlongation(x,y,z)) {
1594 t.fRemoval = 10;
1595 return 0;
1596 }
1597 //
1598 //
1599 if (TMath::Abs(y)>ymax){
91162307 1600
1c53abe2 1601 if (y > ymax) {
1602 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1603 if (!t.Rotate(fSectors->GetAlpha()))
1604 return 0;
1605 } else if (y <-ymax) {
1606 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1607 if (!t.Rotate(-fSectors->GetAlpha()))
1608 return 0;
91162307 1609 }
1610 if (!t.PropagateTo(x)) {
1611 return 0;
1612 }
1613 t.GetProlongation(x,y,z);
1614 }
1615 //
1616 // update current shape info every 3 pad-row
1617 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1618 // t.fCurrentSigmaY = GetSigmaY(&t);
1619 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1620 GetShape(&t,nr);
1621 }
1622 //
1623 AliTPCclusterMI *cl=0;
1624 UInt_t index=0;
1625
1626
1627 //Int_t nr2 = nr;
1628 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1629 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1630 Double_t roady =1.;
1631 Double_t roadz = 1.;
1632 //
1633 Int_t row = nr;
1634 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1635 t.fInDead = kTRUE;
1636 t.SetClusterIndex2(row,-1);
1637 return 0;
1638 }
1639 else
1640 {
d7a11555 1641 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1c53abe2 1642 }
91162307 1643 //calculate
1644
1645 if ((cl==0)&&(krow)) {
1646 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1647 cl = krow.FindNearest2(y,z,roady,roadz,index);
1648
1649 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1650 }
1651
1652 if (cl) {
1653 t.fCurrentCluster = cl;
1654 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1655 //if (accept<3){
1656 t.SetClusterIndex2(row,index);
1657 t.fClusterPointer[row] = cl;
1658 //}
1c53abe2 1659 }
1660 return 1;
1661}
1662
1663
91162307 1664
1665Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1c53abe2 1666 //-----------------------------------------------------------------
1667 // This function tries to find a track prolongation to next pad row
1668 //-----------------------------------------------------------------
1669 t.fCurrentCluster = 0;
1670 t.fCurrentClusterIndex1 = 0;
1c53abe2 1671
1672 Double_t xt=t.GetX();
91162307 1673 Int_t row = GetRowNumber(xt)-1;
1674 Double_t ymax= GetMaxY(nr);
1675
1c53abe2 1676 if (row < nr) return 1; // don't prolongate if not information until now -
91162307 1677 if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1678 t.fRemoval =10;
1679 return 0; // not prolongate strongly inclined tracks
1680 }
1681 if (TMath::Abs(t.GetSnp())>0.95) {
1682 t.fRemoval =10;
1683 return 0; // not prolongate strongly inclined tracks
1684 }
1685
1686 Double_t x= GetXrow(nr);
1687 Double_t y,z;
1688 //t.PropagateTo(x+0.02);
1689 //t.PropagateTo(x+0.01);
1627d1c4 1690 if (!t.PropagateTo(x)){
1627d1c4 1691 return 0;
1692 }
1c53abe2 1693 //
91162307 1694 y=t.GetY();
1695 z=t.GetZ();
1c53abe2 1696
91162307 1697 if (TMath::Abs(y)>ymax){
1698 if (y > ymax) {
1699 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1700 if (!t.Rotate(fSectors->GetAlpha()))
1701 return 0;
1702 } else if (y <-ymax) {
1703 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1704 if (!t.Rotate(-fSectors->GetAlpha()))
1705 return 0;
1706 }
982aff31 1707 // if (!t.PropagateTo(x)){
1708 // return 0;
1709 //}
1710 return 1;
1711 //y = t.GetY();
1c53abe2 1712 }
91162307 1713 //
1c53abe2 1714
91162307 1715 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1c53abe2 1716
1717 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1718 t.fInDead = kTRUE;
91162307 1719 t.SetClusterIndex2(nr,-1);
1c53abe2 1720 return 0;
1721 }
1722 else
1723 {
d7a11555 1724 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
1627d1c4 1725 else
1726 return 0;
1c53abe2 1727 }
1c53abe2 1728
91162307 1729 // update current
1730 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1731 // t.fCurrentSigmaY = GetSigmaY(&t);
1732 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1733 GetShape(&t,nr);
1734 }
1c53abe2 1735
91162307 1736 AliTPCclusterMI *cl=0;
1737 UInt_t index=0;
1738 //
1739 Double_t roady = 1.;
1740 Double_t roadz = 1.;
1741 //
d26d9159 1742
1743 if (!cl){
1744 index = t.GetClusterIndex2(nr);
1745 if ( (index>0) && (index&0x8000)==0){
1746 cl = t.fClusterPointer[nr];
1747 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1748 t.fCurrentClusterIndex1 = index;
1749 if (cl) {
1750 t.fCurrentCluster = cl;
1751 return 1;
1752 }
1753 }
1754 }
1755
91162307 1756 if (krow) {
1757 //cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1758 cl = krow.FindNearest2(y,z,roady,roadz,index);
1759 }
d26d9159 1760
91162307 1761 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
d26d9159 1762 t.fCurrentCluster = cl;
1763
91162307 1764 return 1;
1765}
1c53abe2 1766
1c53abe2 1767
91162307 1768Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1769 //-----------------------------------------------------------------
1770 // This function tries to find a track prolongation to next pad row
1771 //-----------------------------------------------------------------
1c53abe2 1772
91162307 1773 //update error according neighborhoud
1c53abe2 1774
91162307 1775 if (t.fCurrentCluster) {
1776 t.fRow = nr;
8c51a605 1777 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
91162307 1778
1779 if (t.fCurrentCluster->IsUsed(10)){
1780 //
1781 //
1782 // t.fErrorZ2*=2;
1783 // t.fErrorY2*=2;
1784 t.fNShared++;
1785 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1786 t.fRemoval =10;
1787 return 0;
1788 }
b364ca79 1789 }
d26d9159 1790 if (fIteration>0) accept = 0;
b364ca79 1791 if (accept<3) UpdateTrack(&t,accept);
1792
1c53abe2 1793 } else {
91162307 1794 if (fIteration==0){
1795 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1796 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1797
1798 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1c53abe2 1799 }
1800 }
1801 return 1;
1802}
1803
1804
1805
91162307 1806//_____________________________________________________________________________
1807Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1808 //-----------------------------------------------------------------
91162307 1809 // This function tries to find a track prolongation.
1c53abe2 1810 //-----------------------------------------------------------------
1811 Double_t xt=t.GetX();
1812 //
91162307 1813 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1c53abe2 1814 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1815 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1816 //
1817 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1818
91162307 1819 Int_t first = GetRowNumber(xt)-1;
1820 for (Int_t nr= first; nr>=rf; nr-=step) {
982aff31 1821 if (nr<fInnerSec->GetNRows())
1822 fSectors = fInnerSec;
1823 else
1824 fSectors = fOuterSec;
91162307 1825 if (FollowToNext(t,nr)==0)
4d158c36 1826 if (!t.IsActive())
1827 return 0;
91162307 1828
1829 }
1830 return 1;
1831}
1832
1c53abe2 1833
1834//_____________________________________________________________________________
91162307 1835Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1836 //-----------------------------------------------------------------
1837 // This function tries to find a track prolongation.
1838 //-----------------------------------------------------------------
1839 Double_t xt=t.GetX();
1840 //
1841 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1842 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1843 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1844 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1845
1846 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1847
1848 if (FollowToNextFast(t,nr)==0)
1849 if (!t.IsActive()) return 0;
1c53abe2 1850
1c53abe2 1851 }
1852 return 1;
1853}
1854
1855
91162307 1856
1857
1858
1c53abe2 1859Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1860 //-----------------------------------------------------------------
1861 // This function tries to find a track prolongation.
1862 //-----------------------------------------------------------------
91162307 1863 // Double_t xt=t.GetX();
1c53abe2 1864 //
1865 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1866 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1867 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1868 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1869
4d158c36 1870 Int_t first = t.fFirstPoint;
91162307 1871 //
1872 if (first<0) first=0;
4d158c36 1873 for (Int_t nr=first; nr<=rf; nr++) {
91162307 1874 //if ( (t.GetSnp()<0.9))
d26d9159 1875 if (nr<fInnerSec->GetNRows())
1876 fSectors = fInnerSec;
1877 else
1878 fSectors = fOuterSec;
1879 FollowToNext(t,nr);
1c53abe2 1880 }
1881 return 1;
1882}
1883
1884
1885
1886
1887
1888Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1889{
1890 //
1891 //
1892 sum1=0;
1893 sum2=0;
1894 Int_t sum=0;
1c53abe2 1895 //
1896 Float_t dz2 =(s1->GetZ() - s2->GetZ());
c9427e08 1897 dz2*=dz2;
91162307 1898
c9427e08 1899 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1c53abe2 1900 dy2*=dy2;
1901 Float_t distance = TMath::Sqrt(dz2+dy2);
c9427e08 1902 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1c53abe2 1903
91162307 1904 // Int_t offset =0;
c9427e08 1905 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1906 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
c9427e08 1907 if (lastpoint>160)
1908 lastpoint =160;
1909 if (firstpoint<0)
1910 firstpoint = 0;
91162307 1911 if (firstpoint>lastpoint) {
1912 firstpoint =lastpoint;
1913 // lastpoint =160;
c9427e08 1914 }
1915
1916
91162307 1917 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1918 if (s1->GetClusterIndex2(i)>0) sum1++;
1919 if (s2->GetClusterIndex2(i)>0) sum2++;
1920 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1c53abe2 1921 sum++;
1922 }
1923 }
91162307 1924 if (sum<5) return 0;
1925
1627d1c4 1926 Float_t summin = TMath::Min(sum1+1,sum2+1);
1927 Float_t ratio = (sum+1)/Float_t(summin);
1c53abe2 1928 return ratio;
1929}
1930
1931void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1932{
1933 //
1934 //
91162307 1935 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1936 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1937
1c53abe2 1938 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1939 dz2*=dz2;
1940 Float_t dy2 =(s1->GetY() - s2->GetY());
1941 dy2*=dy2;
91162307 1942 Float_t distance = dz2+dy2;
1943 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1944
1c53abe2 1945 //
91162307 1946 Int_t sumshared=0;
1947 //
1948 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1949 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1950 //
1951 if (firstpoint>=lastpoint-5) return;;
1c53abe2 1952
91162307 1953 for (Int_t i=firstpoint;i<lastpoint;i++){
1954 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1955 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1956 sumshared++;
1957 }
1958 }
1959 if (sumshared>4){
1960 // sign clusters
1961 //
1962 for (Int_t i=firstpoint;i<lastpoint;i++){
1963 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1964 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1965 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1966 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1967 if (s1->IsActive()&&s2->IsActive()){
1968 p1->fIsShared = kTRUE;
1969 p2->fIsShared = kTRUE;
1970 }
1971 }
1972 }
1973 }
1974 //
1975 if (sumshared>10){
1976 for (Int_t i=0;i<4;i++){
1977 if (s1->fOverlapLabels[3*i]==0){
1978 s1->fOverlapLabels[3*i] = s2->GetLabel();
1979 s1->fOverlapLabels[3*i+1] = sumshared;
1980 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1981 break;
1982 }
1983 }
1984 for (Int_t i=0;i<4;i++){
1985 if (s2->fOverlapLabels[3*i]==0){
1986 s2->fOverlapLabels[3*i] = s1->GetLabel();
1987 s2->fOverlapLabels[3*i+1] = sumshared;
1988 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1989 break;
1990 }
1991 }
1992 }
1c53abe2 1993
91162307 1994}
1c53abe2 1995
91162307 1996void AliTPCtrackerMI::SignShared(TObjArray * arr)
1997{
1c53abe2 1998 //
91162307 1999 //sort trackss according sectors
2000 //
c9427e08 2001 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2002 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2003 if (!pt) continue;
2004 //if (pt) RotateToLocal(pt);
2005 pt->fSort = 0;
c9427e08 2006 }
91162307 2007 arr->UnSort();
1c53abe2 2008 arr->Sort(); // sorting according z
2009 arr->Expand(arr->GetEntries());
91162307 2010 //
2011 //
1c53abe2 2012 Int_t nseed=arr->GetEntriesFast();
1c53abe2 2013 for (Int_t i=0; i<nseed; i++) {
2014 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2015 if (!pt) continue;
2016 for (Int_t j=0;j<=12;j++){
2017 pt->fOverlapLabels[j] =0;
1c53abe2 2018 }
91162307 2019 }
2020 for (Int_t i=0; i<nseed; i++) {
2021 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2022 if (!pt) continue;
2023 if (pt->fRemoval>10) continue;
1c53abe2 2024 for (Int_t j=i+1; j<nseed; j++){
2025 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
91162307 2026 // if (pt2){
2027 if (pt2->fRemoval<=10) {
2028 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2029 SignShared(pt,pt2);
c9427e08 2030 }
91162307 2031 }
2032 }
2033}
2034
2035void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2036{
2037 //
2038 //sort trackss according sectors
2039 //
2040 if (fDebug&1) {
6bdc18d6 2041 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
91162307 2042 }
2043 //
2044 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2045 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2046 if (!pt) continue;
2047 pt->fSort = 0;
2048 }
2049 arr->UnSort();
2050 arr->Sort(); // sorting according z
2051 arr->Expand(arr->GetEntries());
2052 //
2053 //reset overlap labels
2054 //
2055 Int_t nseed=arr->GetEntriesFast();
2056 for (Int_t i=0; i<nseed; i++) {
2057 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2058 if (!pt) continue;
2059 pt->SetUniqueID(i);
2060 for (Int_t j=0;j<=12;j++){
2061 pt->fOverlapLabels[j] =0;
1c53abe2 2062 }
2063 }
91162307 2064 //
2065 //sign shared tracks
1c53abe2 2066 for (Int_t i=0; i<nseed; i++) {
2067 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2068 if (!pt) continue;
2069 if (pt->fRemoval>10) continue;
2070 Float_t deltac = pt->GetC()*0.1;
2071 for (Int_t j=i+1; j<nseed; j++){
2072 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2073 // if (pt2){
2074 if (pt2->fRemoval<=10) {
2075 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2076 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2077 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2078 //
2079 SignShared(pt,pt2);
2080 }
1c53abe2 2081 }
1c53abe2 2082 }
91162307 2083 //
2084 // remove highly shared tracks
2085 for (Int_t i=0; i<nseed; i++) {
2086 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2087 if (!pt) continue;
2088 if (pt->fRemoval>10) continue;
2089 //
2090 Int_t sumshared =0;
2091 for (Int_t j=0;j<4;j++){
2092 sumshared = pt->fOverlapLabels[j*3+1];
2093 }
2094 Float_t factor = factor1;
2095 if (pt->fRemoval>0) factor = factor2;
2096 if (sumshared/pt->GetNumberOfClusters()>factor){
2097 for (Int_t j=0;j<4;j++){
2098 if (pt->fOverlapLabels[3*j]==0) continue;
2099 if (pt->fOverlapLabels[3*j+1]<5) continue;
2100 if (pt->fRemoval==removalindex) continue;
2101 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2102 if (!pt2) continue;
2103 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2104 // pt->fRemoval = removalindex;
2105 delete arr->RemoveAt(i);
2106 break;
1c53abe2 2107 }
91162307 2108 }
1c53abe2 2109 }
91162307 2110 }
2111 arr->Compress();
2112 if (fDebug&1) {
6bdc18d6 2113 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
91162307 2114 }
2115}
2116
2117
2118
1c53abe2 2119
2120
91162307 2121
47966a6d 2122void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
91162307 2123{
2124 //
2125 //sort tracks in array according mode criteria
2126 Int_t nseed = arr->GetEntriesFast();
2127 for (Int_t i=0; i<nseed; i++) {
2128 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2129 if (!pt) {
2130 continue;
2131 }
2132 pt->fSort = mode;
2133 }
2134 arr->UnSort();
2135 arr->Sort();
1c53abe2 2136}
c9427e08 2137
91162307 2138void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
c9427e08 2139{
2140
2141 //Loop over all tracks and remove "overlaps"
2142 //
2143 //
2144 Int_t nseed = arr->GetEntriesFast();
2145 Int_t good =0;
91162307 2146
c9427e08 2147 for (Int_t i=0; i<nseed; i++) {
2148 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2149 if (!pt) {
91162307 2150 delete arr->RemoveAt(i);
c9427e08 2151 }
91162307 2152 else{
2153 pt->fSort =1;
2154 pt->fBSigned = kFALSE;
c9427e08 2155 }
91162307 2156 }
2157 arr->Compress();
2158 nseed = arr->GetEntriesFast();
2159 arr->UnSort();
2160 arr->Sort();
2161 //
2162 //unsign used
2163 UnsignClusters();
2164 //
2165 for (Int_t i=0; i<nseed; i++) {
2166 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2167 if (!pt) {
2168 continue;
2169 }
2170 Int_t found,foundable,shared;
2171 if (pt->IsActive())
2172 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2173 else
2174 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2175 //
2176 Double_t factor = factor2;
2177 if (pt->fBConstrain) factor = factor1;
2178
2179 if ((Float_t(shared)/Float_t(found))>factor){
c9427e08 2180 pt->Desactivate(removalindex);
91162307 2181 continue;
2182 }
2183
2184 good++;
2185 for (Int_t i=0; i<160; i++) {
2186 Int_t index=pt->GetClusterIndex2(i);
2187 if (index<0 || index&0x8000 ) continue;
2188 AliTPCclusterMI *c= pt->fClusterPointer[i];
2189 if (!c) continue;
2190 // if (!c->IsUsed(10)) c->Use(10);
2191 //if (pt->IsActive())
2192 c->Use(10);
2193 //else
2194 // c->Use(5);
c9427e08 2195 }
91162307 2196
c9427e08 2197 }
2198 fNtracks = good;
6bdc18d6 2199 if (fDebug>0){
2200 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2201 }
c9427e08 2202}
2203
91162307 2204void AliTPCtrackerMI::UnsignClusters()
1c53abe2 2205{
91162307 2206 //
2207 // loop over all clusters and unsign them
2208 //
2209
2210 for (Int_t sec=0;sec<fkNIS;sec++){
2211 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2212 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2213 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2214 // if (cl[icl].IsUsed(10))
2215 cl[icl].Use(-1);
2216 cl = fInnerSec[sec][row].fClusters2;
2217 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2218 //if (cl[icl].IsUsed(10))
2219 cl[icl].Use(-1);
2220 }
2221 }
2222
2223 for (Int_t sec=0;sec<fkNOS;sec++){
2224 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2225 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2226 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2227 //if (cl[icl].IsUsed(10))
2228 cl[icl].Use(-1);
2229 cl = fOuterSec[sec][row].fClusters2;
2230 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2231 //if (cl[icl].IsUsed(10))
2232 cl[icl].Use(-1);
2233 }
2234 }
2235
1c53abe2 2236}
2237
91162307 2238
2239
732b9e78 2240void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
1c53abe2 2241{
2242 //
91162307 2243 //sign clusters to be "used"
2244 //
2245 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2246 // loop over "primaries"
2247
2248 Float_t sumdens=0;
2249 Float_t sumdens2=0;
2250 Float_t sumn =0;
2251 Float_t sumn2 =0;
2252 Float_t sumchi =0;
2253 Float_t sumchi2 =0;
2254
2255 Float_t sum =0;
2256
1c53abe2 2257 TStopwatch timer;
91162307 2258 timer.Start();
1c53abe2 2259
91162307 2260 Int_t nseed = arr->GetEntriesFast();
2261 for (Int_t i=0; i<nseed; i++) {
2262 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2263 if (!pt) {
2264 continue;
2265 }
2266 if (!(pt->IsActive())) continue;
2267 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2268 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2269 sumdens += dens;
2270 sumdens2+= dens*dens;
2271 sumn += pt->GetNumberOfClusters();
2272 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2273 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2274 if (chi2>5) chi2=5;
2275 sumchi +=chi2;
2276 sumchi2 +=chi2*chi2;
2277 sum++;
2278 }
1627d1c4 2279 }
91162307 2280
2281 Float_t mdensity = 0.9;
2282 Float_t meann = 130;
2283 Float_t meanchi = 1;
2284 Float_t sdensity = 0.1;
2285 Float_t smeann = 10;
2286 Float_t smeanchi =0.4;
1627d1c4 2287
91162307 2288
2289 if (sum>20){
2290 mdensity = sumdens/sum;
2291 meann = sumn/sum;
2292 meanchi = sumchi/sum;
2293 //
2294 sdensity = sumdens2/sum-mdensity*mdensity;
2295 sdensity = TMath::Sqrt(sdensity);
2296 //
2297 smeann = sumn2/sum-meann*meann;
2298 smeann = TMath::Sqrt(smeann);
2299 //
2300 smeanchi = sumchi2/sum - meanchi*meanchi;
2301 smeanchi = TMath::Sqrt(smeanchi);
2302 }
2303
2304
2305 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2306 //
2307 for (Int_t i=0; i<nseed; i++) {
2308 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2309 if (!pt) {
2310 continue;
1c53abe2 2311 }
91162307 2312 if (pt->fBSigned) continue;
2313 if (pt->fBConstrain) continue;
2314 //if (!(pt->IsActive())) continue;
2315 /*
2316 Int_t found,foundable,shared;
2317 pt->GetClusterStatistic(0,160,found, foundable,shared);
2318 if (shared/float(found)>0.3) {
2319 if (shared/float(found)>0.9 ){
2320 //delete arr->RemoveAt(i);
2321 }
2322 continue;
c9427e08 2323 }
91162307 2324 */
2325 Bool_t isok =kFALSE;
2326 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2327 isok = kTRUE;
2328 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2329 isok =kTRUE;
2330 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2331 isok =kTRUE;
2332 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2333 isok =kTRUE;
2334
2335 if (isok)
2336 for (Int_t i=0; i<160; i++) {
2337 Int_t index=pt->GetClusterIndex2(i);
2338 if (index<0) continue;
2339 AliTPCclusterMI *c= pt->fClusterPointer[i];
2340 if (!c) continue;
2341 //if (!(c->IsUsed(10))) c->Use();
2342 c->Use(10);
2343 }
2344 }
2345
c9427e08 2346
1c53abe2 2347 //
91162307 2348 Double_t maxchi = meanchi+2.*smeanchi;
2349
2350 for (Int_t i=0; i<nseed; i++) {
2351 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2352 if (!pt) {
1c53abe2 2353 continue;
91162307 2354 }
2355 //if (!(pt->IsActive())) continue;
2356 if (pt->fBSigned) continue;
2357 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2358 if (chi>maxchi) continue;
2359
2360 Float_t bfactor=1;
2361 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2362
2363 //sign only tracks with enoug big density at the beginning
2364
2365 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2366
2367
3e5d0aa2 2368 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
91162307 2369 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2370
2371 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2372 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2373 minn=0;
2374
2375 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2376 //Int_t noc=pt->GetNumberOfClusters();
2377 pt->fBSigned = kTRUE;
2378 for (Int_t i=0; i<160; i++) {
2379
2380 Int_t index=pt->GetClusterIndex2(i);
2381 if (index<0) continue;
2382 AliTPCclusterMI *c= pt->fClusterPointer[i];
2383 if (!c) continue;
2384 // if (!(c->IsUsed(10))) c->Use();
2385 c->Use(10);
2386 }
1c53abe2 2387 }
91162307 2388 }
2389 // gLastCheck = nseed;
2390 // arr->Compress();
2391 if (fDebug>0){
2392 timer.Print();
2393 }
1c53abe2 2394}
2395
2396
47966a6d 2397void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
91162307 2398{
2399 // stop not active tracks
2400 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2401 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2402 Int_t nseed = arr->GetEntriesFast();
2403 //
2404 for (Int_t i=0; i<nseed; i++) {
2405 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2406 if (!pt) {
2407 continue;
2408 }
2409 if (!(pt->IsActive())) continue;
2410 StopNotActive(pt,row0,th0, th1,th2);
2411 }
2412}
1c53abe2 2413
1c53abe2 2414
1c53abe2 2415
91162307 2416void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
47966a6d 2417 Float_t th2) const
91162307 2418{
2419 // stop not active tracks
2420 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2421 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2422 Int_t sumgood1 = 0;
2423 Int_t sumgood2 = 0;
2424 Int_t foundable = 0;
2425 Int_t maxindex = seed->fLastPoint; //last foundable row
2426 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2427 seed->Desactivate(10) ;
2428 return;
2429 }
1c53abe2 2430
3e5d0aa2 2431 for (Int_t i=row0; i<maxindex; i++){
91162307 2432 Int_t index = seed->GetClusterIndex2(i);
2433 if (index!=-1) foundable++;
2434 //if (!c) continue;
2435 if (foundable<=30) sumgood1++;
2436 if (foundable<=50) {
2437 sumgood2++;
2438 }
2439 else{
2440 break;
2441 }
2442 }
2443 if (foundable>=30.){
2444 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2445 }
2446 if (foundable>=50)
2447 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2448}
1c53abe2 2449
1c53abe2 2450
d26d9159 2451Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2452{
2453 //
2454 // back propagation of ESD tracks
2455 //
2456 //return 0;
2457 fEvent = event;
2458 ReadSeeds(event,2);
2459 fIteration=2;
982aff31 2460 //PrepareForProlongation(fSeeds,1);
2461 PropagateForward2(fSeeds);
4d158c36 2462 Int_t ntracks=0;
d26d9159 2463 Int_t nseed = fSeeds->GetEntriesFast();
2464 for (Int_t i=0;i<nseed;i++){
2465 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
4d158c36 2466 if (!seed) continue;
d26d9159 2467 seed->PropagateTo(fParam->GetInnerRadiusLow());
2468 AliESDtrack *esd=event->GetTrack(i);
2469 seed->CookdEdx(0.02,0.6);
2470 CookLabel(seed,0.1); //For comparison only
4d158c36 2471 if (seed->GetNumberOfClusters()>60){
2472 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
2473 ntracks++;
d26d9159 2474 }
2475 else{
2476 //printf("problem\n");
2477 }
2478 }
4d158c36 2479 Info("RefitInward","Number of refitted tracks %d",ntracks);
d26d9159 2480 fEvent =0;
2481 //WriteTracks();
2482 return 0;
2483}
2484
1c53abe2 2485
91162307 2486Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2487{
2488 //
2489 // back propagation of ESD tracks
2490 //
1c53abe2 2491
91162307 2492 fEvent = event;
d26d9159 2493 fIteration = 1;
2494 ReadSeeds(event,0);
91162307 2495 PropagateBack(fSeeds);
2496 Int_t nseed = fSeeds->GetEntriesFast();
4d158c36 2497 Int_t ntracks=0;
91162307 2498 for (Int_t i=0;i<nseed;i++){
2499 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
d9e62e7e 2500 if (!seed) continue;
91162307 2501 AliESDtrack *esd=event->GetTrack(i);
d26d9159 2502 seed->CookdEdx(0.02,0.6);
91162307 2503 CookLabel(seed,0.1); //For comparison only
4d158c36 2504 if (seed->GetNumberOfClusters()>60){
2505 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
2506 ntracks++;
2507 }
91162307 2508 }
4d158c36 2509 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
91162307 2510 fEvent =0;
d26d9159 2511 //WriteTracks();
91162307 2512 return 0;
2513}
2514
2515
2516void AliTPCtrackerMI::DeleteSeeds()
2517{
b67e07dc 2518 //
2519 //delete Seeds
91162307 2520 Int_t nseed = fSeeds->GetEntriesFast();
2521 for (Int_t i=0;i<nseed;i++){
2522 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2523 if (seed) delete fSeeds->RemoveAt(i);
2524 }
2525 delete fSeeds;
2526 fSeeds =0;
2527}
2528
d26d9159 2529void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
91162307 2530{
2531 //
2532 //read seeds from the event
2533
2534 Int_t nentr=event->GetNumberOfTracks();
6bdc18d6 2535 if (fDebug>0){
2536 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2537 }
91162307 2538 if (fSeeds)
2539 DeleteSeeds();
2540 if (!fSeeds){
4d158c36 2541 fSeeds = new TObjArray(nentr);
91162307 2542 }
4d158c36 2543 UnsignClusters();
2544 // Int_t ntrk=0;
91162307 2545 for (Int_t i=0; i<nentr; i++) {
2546 AliESDtrack *esd=event->GetTrack(i);
2547 ULong_t status=esd->GetStatus();
b67e07dc 2548 AliTPCtrack t(*esd);
91162307 2549 AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
982aff31 2550 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2551 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
4d158c36 2552 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2553 fSeeds->AddAt(0,i);
2554 delete seed;
2555 continue;
2556 }
2557 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
2558 Double_t par0[5],par1[5],x;
2559 esd->GetInnerExternalParameters(x,par0);
2560 esd->GetExternalParameters(x,par1);
2561 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2562 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
2563 //reset covariance if suspicious
2564 if ( (delta1>0.1) || (delta2>0.006))
2565 seed->ResetCovariance();
2566 }
982aff31 2567
91162307 2568 //
2569 //
2570 // rotate to the local coordinate system
2571
2572 fSectors=fInnerSec; fN=fkNIS;
2573
2574 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2575 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2576 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2577 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2578 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
4d158c36 2579 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2580 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
91162307 2581 alpha-=seed->GetAlpha();
d9b8978b 2582 if (!seed->Rotate(alpha)) {
2583 delete seed;
2584 continue;
2585 }
d26d9159 2586 seed->fEsd = esd;
91162307 2587 //
d26d9159 2588 //seed->PropagateTo(fSectors->GetX(0));
91162307 2589 //
2590 // Int_t index = esd->GetTPCindex();
2591 //AliTPCseed * seed2= (AliTPCseed*)fSeeds->At(index);
d26d9159 2592 //if (direction==2){
2593 // AliTPCseed * seed2 = ReSeed(seed,0.,0.5,1.);
2594 // if (seed2) {
2595 // delete seed;
2596 // seed = seed2;
2597 // }
2598 //}
4d158c36 2599 //
2600 // sign clusters
2601 for (Int_t irow=0;irow<160;irow++){
2602 Int_t index = seed->GetClusterIndex2(irow);
2603 if (index>0){
2604 //
2605 AliTPCclusterMI * cl = GetClusterMI(index);
2606 seed->fClusterPointer[irow] = cl;
2607 if (cl){
2608 if ((index & 0x8000)==0){
2609 cl->Use(10); // accepted cluster
2610 }else{
2611 cl->Use(6); // close cluster not accepted
2612 }
2613 }else{
2614 Info("ReadSeeds","Not found cluster");
2615 }
2616 }
2617 }
2618 fSeeds->AddAt(seed,i);
91162307 2619 }
2620}
2621
2622
2623
2624//_____________________________________________________________________________
2625void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2626 Float_t deltay, Int_t ddsec) {
2627 //-----------------------------------------------------------------
2628 // This function creates track seeds.
2629 // SEEDING WITH VERTEX CONSTRAIN
2630 //-----------------------------------------------------------------
2631 // cuts[0] - fP4 cut
2632 // cuts[1] - tan(phi) cut
2633 // cuts[2] - zvertex cut
2634 // cuts[3] - fP3 cut
2635 Int_t nin0 = 0;
2636 Int_t nin1 = 0;
2637 Int_t nin2 = 0;
2638 Int_t nin = 0;
2639 Int_t nout1 = 0;
2640 Int_t nout2 = 0;
2641
2642 Double_t x[5], c[15];
2643 // Int_t di = i1-i2;
2644 //
2645 AliTPCseed * seed = new AliTPCseed;
2646 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2647 Double_t cs=cos(alpha), sn=sin(alpha);
2648 //
2649 // Double_t x1 =fOuterSec->GetX(i1);
2650 //Double_t xx2=fOuterSec->GetX(i2);
2651
2652 Double_t x1 =GetXrow(i1);
2653 Double_t xx2=GetXrow(i2);
2654
2655 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2656
2657 Int_t imiddle = (i2+i1)/2; //middle pad row index
2658 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2659 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2660 //
2661 Int_t ns =sec;
2662
2663 const AliTPCRow& kr1=GetRow(ns,i1);
2664 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2665 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2666
2667 //
2668 // change cut on curvature if it can't reach this layer
2669 // maximal curvature set to reach it
2670 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2671 if (dvertexmax*0.5*cuts[0]>0.85){
2672 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2673 }
2674 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2675
2676 // Int_t ddsec = 1;
2677 if (deltay>0) ddsec = 0;
2678 // loop over clusters
2679 for (Int_t is=0; is < kr1; is++) {
2680 //
2681 if (kr1[is]->IsUsed(10)) continue;
2682 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2683 //if (TMath::Abs(y1)>ymax) continue;
2684
2685 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2686
2687 // find possible directions
2688 Float_t anglez = (z1-z3)/(x1-x3);
2689 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2690 //
2691 //
2692 //find rotation angles relative to line given by vertex and point 1
2693 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2694 Double_t dvertex = TMath::Sqrt(dvertex2);
2695 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2696 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2697
2698 //
2699 // loop over 2 sectors
2700 Int_t dsec1=-ddsec;
2701 Int_t dsec2= ddsec;
2702 if (y1<0) dsec2= 0;
2703 if (y1>0) dsec1= 0;
2704
2705 Double_t dddz1=0; // direction of delta inclination in z axis
2706 Double_t dddz2=0;
2707 if ( (z1-z3)>0)
2708 dddz1 =1;
2709 else
2710 dddz2 =1;
2711 //
2712 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2713 Int_t sec2 = sec + dsec;
2714 //
2715 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2716 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2717 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2718 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2719 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2720 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2721
2722 // rotation angles to p1-p3
2723 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2724 Double_t x2, y2, z2;
2725 //
2726 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2727
2728 //
2729 Double_t dxx0 = (xx2-x3)*cs13r;
2730 Double_t dyy0 = (xx2-x3)*sn13r;
2731 for (Int_t js=index1; js < index2; js++) {
2732 const AliTPCclusterMI *kcl = kr2[js];
2733 if (kcl->IsUsed(10)) continue;
2734 //
2735 //calcutate parameters
2736 //
2737 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2738 // stright track
2739 if (TMath::Abs(yy0)<0.000001) continue;
2740 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2741 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2742 Double_t r02 = (0.25+y0*y0)*dvertex2;
2743 //curvature (radius) cut
2744 if (r02<r2min) continue;
2745
2746 nin0++;
2747 //
2748 Double_t c0 = 1/TMath::Sqrt(r02);
2749 if (yy0>0) c0*=-1.;
2750
2751
2752 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2753 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
b67e07dc 2754 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2755 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
91162307 2756 //
2757 //
2758 Double_t z0 = kcl->GetZ();
2759 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2760 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2761 nin1++;
2762 //
2763 Double_t dip = (z1-z0)*c0/dfi1;
2764 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2765 //
2766 y2 = kcl->GetY();
2767 if (dsec==0){
2768 x2 = xx2;
2769 z2 = kcl->GetZ();
2770 }
2771 else
2772 {
2773 // rotation
2774 z2 = kcl->GetZ();
2775 x2= xx2*cs-y2*sn*dsec;
2776 y2=+xx2*sn*dsec+y2*cs;
2777 }
2778
2779 x[0] = y1;
2780 x[1] = z1;
2781 x[2] = x0;
2782 x[3] = dip;
2783 x[4] = c0;
2784 //
2785 //
2786 // do we have cluster at the middle ?
2787 Double_t ym,zm;
2788 GetProlongation(x1,xm,x,ym,zm);
2789 UInt_t dummy;
2790 AliTPCclusterMI * cm=0;
2791 if (TMath::Abs(ym)-ymaxm<0){
2792 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2793 if ((!cm) || (cm->IsUsed(10))) {
2794 continue;
2795 }
2796 }
2797 else{
2798 // rotate y1 to system 0
2799 // get state vector in rotated system
2800 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2801 Double_t xr2 = x0*cs+yr1*sn*dsec;
2802 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2803 //
2804 GetProlongation(xx2,xm,xr,ym,zm);
2805 if (TMath::Abs(ym)-ymaxm<0){
2806 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2807 if ((!cm) || (cm->IsUsed(10))) {
2808 continue;
2809 }
2810 }
2811 }
2812
2813
2814 Double_t dym = 0;
2815 Double_t dzm = 0;
2816 if (cm){
2817 dym = ym - cm->GetY();
2818 dzm = zm - cm->GetZ();
2819 }
2820 nin2++;
2821
2822
2823 //
2824 //
2825 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2826 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2827 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2828 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2829 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2830
b67e07dc 2831 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2832 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2833 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2834 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2835 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2836 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 2837
b67e07dc 2838 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2839 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2840 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2841 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
91162307 2842
1c53abe2 2843 c[0]=sy1;
2844 c[1]=0.; c[2]=sz1;
2845 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2846 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2847 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2848 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2849 c[13]=f30*sy1*f40+f32*sy2*f42;
2850 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
91162307 2851
2852 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2853
1c53abe2 2854 UInt_t index=kr1.GetIndex(is);
91162307 2855 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2856
1c53abe2 2857 track->fIsSeeding = kTRUE;
91162307 2858 track->fSeed1 = i1;
2859 track->fSeed2 = i2;
2860 track->fSeedType=3;
c9427e08 2861
91162307 2862
2863 //if (dsec==0) {
2864 FollowProlongation(*track, (i1+i2)/2,1);
2865 Int_t foundable,found,shared;
2866 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2867 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2868 seed->Reset();
2869 seed->~AliTPCseed();
2870 continue;
2871 }
2872 //}
2873
2874 nin++;
2875 FollowProlongation(*track, i2,1);
2876
2877
2878 //Int_t rc = 1;
2879 track->fBConstrain =1;
2880 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2881 track->fLastPoint = i1; // first cluster in track position
2882 track->fFirstPoint = track->fLastPoint;
2883
2884 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2885 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2886 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2887 seed->Reset();
2888 seed->~AliTPCseed();
c9427e08 2889 continue;
2890 }
91162307 2891 nout1++;
2892 // Z VERTEX CONDITION
2893 Double_t zv;
2894 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2895 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2896 if (TMath::Abs(zv-z3)>cuts[2]) {
2897 FollowProlongation(*track, TMath::Max(i2-20,0));
2898 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2899 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2900 if (TMath::Abs(zv-z3)>cuts[2]){
2901 FollowProlongation(*track, TMath::Max(i2-40,0));
2902 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2903 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2904 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2905 // make seed without constrain
2906 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2907 FollowProlongation(*track2, i2,1);
2908 track2->fBConstrain = kFALSE;
2909 track2->fSeedType = 1;
2910 arr->AddLast(track2);
2911 seed->Reset();
2912 seed->~AliTPCseed();
2913 continue;
2914 }
2915 else{
2916 seed->Reset();
2917 seed->~AliTPCseed();
2918 continue;
2919
2920 }
2921 }
c9427e08 2922 }
1c53abe2 2923
91162307 2924 track->fSeedType =0;
2925 arr->AddLast(track);
2926 seed = new AliTPCseed;
2927 nout2++;
2928 // don't consider other combinations
2929 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2930 break;
1c53abe2 2931 }
2932 }
2933 }
6bdc18d6 2934 if (fDebug>3){
2935 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
91162307 2936 }
2937 delete seed;
1c53abe2 2938}
2939
1627d1c4 2940
91162307 2941void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2942 Float_t deltay) {
2943
2944
2945
1627d1c4 2946 //-----------------------------------------------------------------
91162307 2947 // This function creates track seeds.
1627d1c4 2948 //-----------------------------------------------------------------
91162307 2949 // cuts[0] - fP4 cut
2950 // cuts[1] - tan(phi) cut
2951 // cuts[2] - zvertex cut
2952 // cuts[3] - fP3 cut
2953
2954
2955 Int_t nin0 = 0;
2956 Int_t nin1 = 0;
2957 Int_t nin2 = 0;
2958 Int_t nin = 0;
2959 Int_t nout1 = 0;
2960 Int_t nout2 = 0;
2961 Int_t nout3 =0;
2962 Double_t x[5], c[15];
2963 //
2964 // make temporary seed
2965 AliTPCseed * seed = new AliTPCseed;
1627d1c4 2966 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
2967 // Double_t cs=cos(alpha), sn=sin(alpha);
91162307 2968 //
2969 //
1627d1c4 2970
91162307 2971 // first 3 padrows
2972 Double_t x1 = GetXrow(i1-1);
2973 const AliTPCRow& kr1=GetRow(sec,i1-1);
2974 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
2975 //
2976 Double_t x1p = GetXrow(i1);
2977 const AliTPCRow& kr1p=GetRow(sec,i1);
2978 //
2979 Double_t x1m = GetXrow(i1-2);
2980 const AliTPCRow& kr1m=GetRow(sec,i1-2);
1627d1c4 2981
91162307 2982 //
2983 //last 3 padrow for seeding
2984 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
2985 Double_t x3 = GetXrow(i1-7);
2986 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
2987 //
2988 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
2989 Double_t x3p = GetXrow(i1-6);
2990 //
2991 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
2992 Double_t x3m = GetXrow(i1-8);
1627d1c4 2993
91162307 2994 //
2995 //
2996 // middle padrow
2997 Int_t im = i1-4; //middle pad row index
2998 Double_t xm = GetXrow(im); // radius of middle pad-row
2999 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3000 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3001 //
3002 //
3003 Double_t deltax = x1-x3;
3004 Double_t dymax = deltax*cuts[1];
3005 Double_t dzmax = deltax*cuts[3];
3006 //
3007 // loop over clusters
3008 for (Int_t is=0; is < kr1; is++) {
1627d1c4 3009 //
91162307 3010 if (kr1[is]->IsUsed(10)) continue;
3011 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
1627d1c4 3012 //
91162307 3013 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3014 //
3015 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3016 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3017 //
3018 Double_t y3, z3;
1627d1c4 3019 //
1627d1c4 3020 //
91162307 3021 UInt_t index;
3022 for (Int_t js=index1; js < index2; js++) {
3023 const AliTPCclusterMI *kcl = kr3[js];
3024 if (kcl->IsUsed(10)) continue;
3025 y3 = kcl->GetY();
3026 // apply angular cuts
3027 if (TMath::Abs(y1-y3)>dymax) continue;
3028 x3 = x3;
3029 z3 = kcl->GetZ();
3030 if (TMath::Abs(z1-z3)>dzmax) continue;
3031 //
3032 Double_t angley = (y1-y3)/(x1-x3);
3033 Double_t anglez = (z1-z3)/(x1-x3);
3034 //
3035 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3036 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3037 //
3038 Double_t yyym = angley*(xm-x1)+y1;
3039 Double_t zzzm = anglez*(xm-x1)+z1;
3040
3041 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3042 if (!kcm) continue;
3043 if (kcm->IsUsed(10)) continue;
3044
3045 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3046 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3047 //
3048 //
3049 //
3050 Int_t used =0;
3051 Int_t found =0;
3052 //
3053 // look around first
3054 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3055 anglez*(x1m-x1)+z1,
3056 erry,errz,index);
3057 //
3058 if (kc1m){
3059 found++;
3060 if (kc1m->IsUsed(10)) used++;
1627d1c4 3061 }
91162307 3062 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3063 anglez*(x1p-x1)+z1,
3064 erry,errz,index);
1627d1c4 3065 //
91162307 3066 if (kc1p){
3067 found++;
3068 if (kc1p->IsUsed(10)) used++;
1627d1c4 3069 }
91162307 3070 if (used>1) continue;
3071 if (found<1) continue;
1627d1c4 3072
91162307 3073 //
3074 // look around last
3075 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3076 anglez*(x3m-x3)+z3,
3077 erry,errz,index);
3078 //
3079 if (kc3m){
3080 found++;
3081 if (kc3m->IsUsed(10)) used++;
3082 }
3083 else
3084 continue;
3085 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3086 anglez*(x3p-x3)+z3,
3087 erry,errz,index);
3088 //
3089 if (kc3p){
3090 found++;
3091 if (kc3p->IsUsed(10)) used++;
3092 }
3093 else
3094 continue;
3095 if (used>1) continue;
3096 if (found<3) continue;
3097 //
3098 Double_t x2,y2,z2;
3099 x2 = xm;
3100 y2 = kcm->GetY();
3101 z2 = kcm->GetZ();
3102 //
3103
1627d1c4 3104 x[0]=y1;
3105 x[1]=z1;
b67e07dc 3106 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3107 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3108 nin0++;
3109 //
b67e07dc 3110 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3111 nin1++;
3112 //
b67e07dc 3113 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
91162307 3114 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3115 nin2++;
3116 //
3117 //
3118 Double_t sy1=0.1, sz1=0.1;
3119 Double_t sy2=0.1, sz2=0.1;
3120 Double_t sy3=0.1, sy=0.1, sz=0.1;
1627d1c4 3121
b67e07dc 3122 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3123 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3124 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3125 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3126 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3127 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 3128
b67e07dc 3129 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3130 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3131 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3132 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1627d1c4 3133
3134 c[0]=sy1;
91162307 3135 c[1]=0.; c[2]=sz1;
1627d1c4 3136 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3137 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3138 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3139 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3140 c[13]=f30*sy1*f40+f32*sy2*f42;
3141 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3142
91162307 3143 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3144
3145 UInt_t index=kr1.GetIndex(is);
3146 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3147
3148 track->fIsSeeding = kTRUE;
3149
3150 nin++;
3151 FollowProlongation(*track, i1-7,1);
3152 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3153 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3154 seed->Reset();
3155 seed->~AliTPCseed();
3156 continue;
3157 }
3158 nout1++;
3159 nout2++;
3160 //Int_t rc = 1;
3161 FollowProlongation(*track, i2,1);
3162 track->fBConstrain =0;
3163 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3164 track->fFirstPoint = track->fLastPoint;
3165
3166 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3167 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3168 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3169 seed->Reset();
3170 seed->~AliTPCseed();
3171 continue;
3172 }
3173
3174 {
3175 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3176 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3177 FollowProlongation(*track2, i2,1);
3178 track2->fBConstrain = kFALSE;
3179 track2->fSeedType = 4;
3180 arr->AddLast(track2);
3181 seed->Reset();
3182 seed->~AliTPCseed();
3183 }
3184
3185
3186 //arr->AddLast(track);
3187 //seed = new AliTPCseed;
3188 nout3++;
3189 }
3190 }
3191
6bdc18d6 3192 if (fDebug>3){
3193 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
91162307 3194 }
3195 delete seed;
3196}
3197
3198
3199//_____________________________________________________________________________
176aff27 3200void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3201 Float_t deltay, Bool_t /*bconstrain*/) {
91162307 3202 //-----------------------------------------------------------------
3203 // This function creates track seeds - without vertex constraint
3204 //-----------------------------------------------------------------
3205 // cuts[0] - fP4 cut - not applied
3206 // cuts[1] - tan(phi) cut
3207 // cuts[2] - zvertex cut - not applied
3208 // cuts[3] - fP3 cut
3209 Int_t nin0=0;
3210 Int_t nin1=0;
3211 Int_t nin2=0;
3212 Int_t nin3=0;
3213 // Int_t nin4=0;
3214 //Int_t nin5=0;
3215
3216
3217
3218 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3219 // Double_t cs=cos(alpha), sn=sin(alpha);
3220 Int_t row0 = (i1+i2)/2;
3221 Int_t drow = (i1-i2)/2;
3222 const AliTPCRow& kr0=fSectors[sec][row0];
3223 AliTPCRow * kr=0;
3224
3225 AliTPCpolyTrack polytrack;
3226 Int_t nclusters=fSectors[sec][row0];
3227 AliTPCseed * seed = new AliTPCseed;
3228
3229 Int_t sumused=0;
3230 Int_t cused=0;
3231 Int_t cnused=0;
3232 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3233 Int_t nfound =0;
3234 Int_t nfoundable =0;
3235 for (Int_t iter =1; iter<2; iter++){ //iterations
3236 const AliTPCRow& krm=fSectors[sec][row0-iter];
3237 const AliTPCRow& krp=fSectors[sec][row0+iter];
3238 const AliTPCclusterMI * cl= kr0[is];
3239
3240 if (cl->IsUsed(10)) {
3241 cused++;
3242 }
3243 else{
3244 cnused++;
3245 }
3246 Double_t x = kr0.GetX();
3247 // Initialization of the polytrack
3248 nfound =0;
3249 nfoundable =0;
3250 polytrack.Reset();
3251 //
3252 Double_t y0= cl->GetY();
3253 Double_t z0= cl->GetZ();
3254 Float_t erry = 0;
3255 Float_t errz = 0;
3256
3257 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3258 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3259
3260 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3261 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3262 polytrack.AddPoint(x,y0,z0,erry, errz);
3263
3264 sumused=0;
3265 if (cl->IsUsed(10)) sumused++;
3266
3267
3268 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3269 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3270 //
3271 x = krm.GetX();
3272 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3273 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3274 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3275 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3276 if (cl1->IsUsed(10)) sumused++;
3277 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3278 }
3279 //
3280 x = krp.GetX();
3281 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3282 if (cl2) {
3283 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3284 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3285 if (cl2->IsUsed(10)) sumused++;
3286 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3287 }
3288 //
3289 if (sumused>0) continue;
3290 nin0++;
3291 polytrack.UpdateParameters();
3292 // follow polytrack
3293 roadz = 1.2;
3294 roady = 1.2;
3295 //
3296 Double_t yn,zn;
3297 nfoundable = polytrack.GetN();
3298 nfound = nfoundable;
3299 //
3300 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3301 Float_t maxdist = 0.8*(1.+3./(ddrow));
3302 for (Int_t delta = -1;delta<=1;delta+=2){
3303 Int_t row = row0+ddrow*delta;
3304 kr = &(fSectors[sec][row]);
3305 Double_t xn = kr->GetX();
3306 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3307 polytrack.GetFitPoint(xn,yn,zn);
3308 if (TMath::Abs(yn)>ymax) continue;
3309 nfoundable++;
3310 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3311 if (cln) {
3312 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3313 if (dist<maxdist){
3314 /*
3315 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3316 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3317 if (cln->IsUsed(10)) {
3318 // printf("used\n");
3319 sumused++;
3320 erry*=2;
3321 errz*=2;
3322 }
3323 */
3324 erry=0.1;
3325 errz=0.1;
3326 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3327 nfound++;
3328 }
3329 }
3330 }
3331 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3332 polytrack.UpdateParameters();
3333 }
3334 }
3335 if ( (sumused>3) || (sumused>0.5*nfound)) {
3336 //printf("sumused %d\n",sumused);
3337 continue;
3338 }
3339 nin1++;
3340 Double_t dy,dz;
3341 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3342 AliTPCpolyTrack track2;
3343
3344 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3345 if (track2.GetN()<0.5*nfoundable) continue;
3346 nin2++;
3347
3348 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3349 //
3350 // test seed with and without constrain
3351 for (Int_t constrain=0; constrain<=0;constrain++){
3352 // add polytrack candidate
3353
3354 Double_t x[5], c[15];
3355 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3356 track2.GetBoundaries(x3,x1);
3357 x2 = (x1+x3)/2.;
3358 track2.GetFitPoint(x1,y1,z1);
3359 track2.GetFitPoint(x2,y2,z2);
3360 track2.GetFitPoint(x3,y3,z3);
3361 //
3362 //is track pointing to the vertex ?
3363 Double_t x0,y0,z0;
3364 x0=0;
3365 polytrack.GetFitPoint(x0,y0,z0);
3366
3367 if (constrain) {
3368 x2 = x3;
3369 y2 = y3;
3370 z2 = z3;
3371
3372 x3 = 0;
3373 y3 = 0;
3374 z3 = 0;
3375 }
3376 x[0]=y1;
3377 x[1]=z1;
b67e07dc 3378 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3379
3380 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
b67e07dc 3381 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3382
3383 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
b67e07dc 3384 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3385 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
91162307 3386 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3387
3388
3389 Double_t sy =0.1, sz =0.1;
3390 Double_t sy1=0.02, sz1=0.02;
3391 Double_t sy2=0.02, sz2=0.02;
3392 Double_t sy3=0.02;
3393
3394 if (constrain){
3395 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3396 }
3397
b67e07dc 3398 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3399 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3400 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3401 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3402 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3403 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3404
3405 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3406 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3407 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3408 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
91162307 3409
3410
3411 c[0]=sy1;
3412 c[1]=0.; c[2]=sz1;
3413 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3414 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3415 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3416 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3417 c[13]=f30*sy1*f40+f32*sy2*f42;
3418 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3419
3420 //Int_t row1 = fSectors->GetRowNumber(x1);
3421 Int_t row1 = GetRowNumber(x1);
3422
3423 UInt_t index=0;
3424 //kr0.GetIndex(is);
3425 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3426 track->fIsSeeding = kTRUE;
3427 Int_t rc=FollowProlongation(*track, i2);
3428 if (constrain) track->fBConstrain =1;
3429 else
3430 track->fBConstrain =0;
3431 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3432 track->fFirstPoint = track->fLastPoint;
3433
3434 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3435 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3436 track->fNShared>0.4*track->GetNumberOfClusters()) {
3437 //delete track;
3438 seed->Reset();
3439 seed->~AliTPCseed();
3440 }
3441 else {
3442 arr->AddLast(track);
3443 seed = new AliTPCseed;
3444 }
3445 nin3++;
3446 }
3447 } // if accepted seed
3448 }
6bdc18d6 3449 if (fDebug>3){
3450 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
91162307 3451 }
3452 delete seed;
3453}
3454
3455
3456AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3457{
3458 //
3459 //
d26d9159 3460 //reseed using track points
91162307 3461 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3462 Int_t p1 = int(r1*track->GetNumberOfClusters());
3463 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
176aff27 3464 Int_t pp2=0;
91162307 3465 Double_t x0[3],x1[3],x2[3];
3466 x0[0]=-1;
3467 x0[0]=-1;
3468 x0[0]=-1;
3469
3470 // find track position at given ratio of the length
3471 Int_t sec0, sec1, sec2;
176aff27 3472 sec0=0;
3473 sec1=0;
3474 sec2=0;
91162307 3475 Int_t index=-1;
3476 Int_t clindex;
3477 for (Int_t i=0;i<160;i++){
3478 if (track->fClusterPointer[i]){
3479 index++;
3480 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3481 if ( (index<p0) || x0[0]<0 ){
3482 if (trpoint->GetX()>1){
3483 clindex = track->GetClusterIndex2(i);
3484 if (clindex>0){
3485 x0[0] = trpoint->GetX();
3486 x0[1] = trpoint->GetY();
3487 x0[2] = trpoint->GetZ();
3488 sec0 = ((clindex&0xff000000)>>24)%18;
3489 }
3490 }
3491 }
3492
3493 if ( (index<p1) &&(trpoint->GetX()>1)){
3494 clindex = track->GetClusterIndex2(i);
3495 if (clindex>0){
3496 x1[0] = trpoint->GetX();
3497 x1[1] = trpoint->GetY();
3498 x1[2] = trpoint->GetZ();
3499 sec1 = ((clindex&0xff000000)>>24)%18;
3500 }
3501 }
3502 if ( (index<p2) &&(trpoint->GetX()>1)){
3503 clindex = track->GetClusterIndex2(i);
3504 if (clindex>0){
3505 x2[0] = trpoint->GetX();
3506 x2[1] = trpoint->GetY();
3507 x2[2] = trpoint->GetZ();
3508 sec2 = ((clindex&0xff000000)>>24)%18;
3509 pp2 = i;
3510 }
3511 }
3512 }
3513 }
3514
3515 Double_t alpha, cs,sn, xx2,yy2;
3516 //
3517 alpha = (sec1-sec2)*fSectors->GetAlpha();
3518 cs = TMath::Cos(alpha);
3519 sn = TMath::Sin(alpha);
3520 xx2= x1[0]*cs-x1[1]*sn;
3521 yy2= x1[0]*sn+x1[1]*cs;
3522 x1[0] = xx2;
3523 x1[1] = yy2;
3524 //
3525 alpha = (sec0-sec2)*fSectors->GetAlpha();
3526 cs = TMath::Cos(alpha);
3527 sn = TMath::Sin(alpha);
3528 xx2= x0[0]*cs-x0[1]*sn;
3529 yy2= x0[0]*sn+x0[1]*cs;
3530 x0[0] = xx2;
3531 x0[1] = yy2;
3532 //
3533 //
3534 //
3535 Double_t x[5],c[15];
3536 //
3537 x[0]=x2[1];
3538 x[1]=x2[2];
b67e07dc 3539 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
91162307 3540 // if (x[4]>1) return 0;
b67e07dc 3541 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3542 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
91162307 3543 //if (TMath::Abs(x[3]) > 2.2) return 0;
3544 //if (TMath::Abs(x[2]) > 1.99) return 0;
3545 //
3546 Double_t sy =0.1, sz =0.1;
3547 //
3548 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3549 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3550 Double_t sy3=0.01+track->GetSigmaY2();
3551 //
b67e07dc 3552 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3553 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3554 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3555 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3556 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3557 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3558 //
3559 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3560 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3561 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3562 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
91162307 3563
3564
3565 c[0]=sy1;
3566 c[1]=0.; c[2]=sz1;
3567 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3568 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3569 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3570 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3571 c[13]=f30*sy1*f40+f32*sy2*f42;
3572 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3573
3574 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3575 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3576 // Double_t y0,z0,y1,z1, y2,z2;
3577 //seed->GetProlongation(x0[0],y0,z0);
3578 // seed->GetProlongation(x1[0],y1,z1);
3579 //seed->GetProlongation(x2[0],y2,z2);
3580 // seed =0;
3581 seed->fLastPoint = pp2;
3582 seed->fFirstPoint = pp2;
3583
3584
3585 return seed;
3586}
3587
d26d9159 3588
3589AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3590{
3591 //
3592 //
3593 //reseed using founded clusters
3594 //
3595 // Find the number of clusters
3596 Int_t nclusters = 0;
3597 for (Int_t irow=0;irow<160;irow++){
3598 if (track->GetClusterIndex(irow)>0) nclusters++;
3599 }
3600 //
3601 Int_t ipos[3];
3602 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3603 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3604 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3605 //
3606 //
3607 Double_t xyz[3][3];
3608 Int_t row[3],sec[3]={0,0,0};
3609 //
3610 // find track row position at given ratio of the length
3611 Int_t index=-1;
3612 for (Int_t irow=0;irow<160;irow++){
3613 if (track->GetClusterIndex2(irow)<0) continue;
3614 index++;
3615 for (Int_t ipoint=0;ipoint<3;ipoint++){
3616 if (index<=ipos[ipoint]) row[ipoint] = irow;
3617 }
3618 }
3619 //
3620 //Get cluster and sector position
3621 for (Int_t ipoint=0;ipoint<3;ipoint++){
3622 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3623 AliTPCclusterMI * cl = GetClusterMI(clindex);
3624 if (cl==0) {
6bdc18d6 3625 //Error("Bug\n");
47966a6d 3626 // AliTPCclusterMI * cl = GetClusterMI(clindex);
d26d9159 3627 return 0;
3628 }
3629 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3630 xyz[ipoint][0] = GetXrow(row[ipoint]);
3631 xyz[ipoint][1] = cl->GetY();
3632 xyz[ipoint][2] = cl->GetZ();
3633 }
3634 //
3635 //
3636 // Calculate seed state vector and covariance matrix
3637
3638 Double_t alpha, cs,sn, xx2,yy2;
3639 //
3640 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3641 cs = TMath::Cos(alpha);
3642 sn = TMath::Sin(alpha);
3643 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3644 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3645 xyz[1][0] = xx2;
3646 xyz[1][1] = yy2;
3647 //
3648 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3649 cs = TMath::Cos(alpha);
3650 sn = TMath::Sin(alpha);
3651 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3652 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3653 xyz[0][0] = xx2;
3654 xyz[0][1] = yy2;
3655 //
3656 //
3657 //
3658 Double_t x[5],c[15];
3659 //
3660 x[0]=xyz[2][1];
3661 x[1]=xyz[2][2];
3662 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3663 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3664 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3665 //
3666 Double_t sy =0.1, sz =0.1;
3667 //
3668 Double_t sy1=0.2, sz1=0.2;
3669 Double_t sy2=0.2, sz2=0.2;
3670 Double_t sy3=0.2;
3671 //
3672 Double_t f40=(F1(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[4])/sy;
3673 Double_t f42=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[4])/sy;
3674 Double_t f43=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[4])/sy;
3675 Double_t f20=(F2(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[2])/sy;
3676 Double_t f22=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[2])/sy;
3677 Double_t f23=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[2])/sy;
3678 //
3679 Double_t f30=(F3(xyz[2][0],xyz[2][1]+sy,xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2])-x[3])/sy;
3680 Double_t f31=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2]+sz,xyz[0][2])-x[3])/sz;
3681 Double_t f32=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1]+sy,xyz[2][2],xyz[0][2])-x[3])/sy;
3682 Double_t f34=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2]+sz)-x[3])/sz;
3683
3684
3685 c[0]=sy1;
3686 c[1]=0.; c[2]=sz1;
3687 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3688 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3689 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3690 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3691 c[13]=f30*sy1*f40+f32*sy2*f42;
3692 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3693
3694 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3695 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3696 seed->fLastPoint = row[2];
3697 seed->fFirstPoint = row[2];
3698 return seed;
3699}
3700
91162307 3701Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed, Float_t th)
3702{
3703 //
3704 //
3705 //
3706 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3707 //
3708 if (TMath::Abs(seed->GetC())>0.01) return 0;
3709 //
3710
3711 Float_t x[160], y[160], erry[160], z[160], errz[160];
3712 Int_t sec[160];
3713 Float_t xt[160], yt[160], zt[160];
3714 Int_t i1 = 200;
3715 Int_t i2 = 0;
3716 Int_t secm = -1;
3717 Int_t padm = -1;
3718 Int_t middle = seed->GetNumberOfClusters()/2;
3719 //
3720 //
3721 // find central sector, get local cooordinates
3722 Int_t count = 0;
3723 for (Int_t i=seed->fFirstPoint;i<=seed->fLastPoint;i++) {
3724 sec[i]= seed->GetClusterSector(i)%18;
3725 x[i] = GetXrow(i);
3726 if (sec[i]>=0) {
3727 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3728 // if (cl==0) cl = GetClusterMI(seed->GetClusterIndex2(i));
3729 if (cl==0) {
3730 sec[i] = -1;
3731 continue;
3732 }
3733 //
3734 //
3735 if (i>i2) i2 = i; //last point with cluster
3736 if (i2<i1) i1 = i; //first point with cluster
3737 y[i] = cl->GetY();
3738 z[i] = cl->GetZ();
3739 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3740 xt[i] = x[i];
3741 yt[i] = point->GetY();
3742 zt[i] = point->GetZ();
3743
3744 if (point->GetX()>0){
3745 erry[i] = point->GetErrY();
3746 errz[i] = point->GetErrZ();
3747 }
3748
3749 count++;
3750 if (count<middle) {
3751 secm = sec[i]; //central sector
3752 padm = i; //middle point with cluster
3753 }
3754 }
3755 }
3756 //
3757 // rotate position to global coordinate system connected to sector at last the point
3758 //
3759 for (Int_t i=i1;i<=i2;i++){
3760 //
3761 if (sec[i]<0) continue;
3762 Double_t alpha = (sec[i2]-sec[i])*fSectors->GetAlpha();
3763 Double_t cs = TMath::Cos(alpha);
3764 Double_t sn = TMath::Sin(alpha);
3765 Float_t xx2= x[i]*cs+y[i]*sn;
3766 Float_t yy2= -x[i]*sn+y[i]*cs;
3767 x[i] = xx2;
3768 y[i] = yy2;
3769 //
3770 xx2= xt[i]*cs+yt[i]*sn;
3771 yy2= -xt[i]*sn+yt[i]*cs;
3772 xt[i] = xx2;
3773 yt[i] = yy2;
3774
3775 }
3776 //get "state" vector
3777 Double_t xh[5],xm = x[padm];
3778 xh[0]=yt[i2];
3779 xh[1]=zt[i2];
b67e07dc 3780 xh[4]=F1(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3781 xh[2]=F2(xt[i2],yt[i2],xt[padm],yt[padm],xt[i1],yt[i1]);
3782 xh[3]=F3n(xt[i2],yt[i2],xt[i1],yt[i1],zt[i2],zt[i1],xh[4]);
91162307 3783 //
3784 //
3785 for (Int_t i=i1;i<=i2;i++){
3786 Double_t yy,zz;
3787 if (sec[i]<0) continue;
3788 GetProlongation(x[i2], x[i],xh,yy,zz);
3789 if (TMath::Abs(y[i]-yy)>4||TMath::Abs(z[i]-zz)>4){
3790 //Double_t xxh[5];
b67e07dc 3791 //xxh[4]=F1old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
3792 //xxh[2]=F2old(x[i2],y[i2],x[padm],y[padm],x[i1],y[i1]);
6bdc18d6 3793 Error("AliTPCtrackerMI::CheckKinkPoint","problem\n");
91162307 3794 }
3795 y[i] = y[i] - yy;
3796 z[i] = z[i] - zz;
3797 }
3798 Float_t dyup[160],dydown[160], dzup[160], dzdown[160];
3799 Float_t yup[160], ydown[160], zup[160], zdown[160];
3800
3801 AliTPCpolyTrack ptrack1,ptrack2;
3802 //
3803 // derivation up
3804 for (Int_t i=i1;i<=i2;i++){
3805 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3806 if (!cl) continue;
3807 if (cl->GetType()<0) continue;
3808 if (cl->GetType()>10) continue;
3809
3810 if (sec[i]>=0){
3811 ptrack1.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3812 }
3813 if (ptrack1.GetN()>4.){
3814 ptrack1.UpdateParameters();
3815 Double_t ddy,ddz;
3816 ptrack1.GetFitDerivation(x[i]-xm,ddy,ddz);
3817 Double_t yy,zz;
3818 ptrack1.GetFitPoint(x[i]-xm,yy,zz);
3819
3820 dyup[i] = ddy;
3821 dzup[i] = ddz;
3822 yup[i] = yy;
3823 zup[i] = zz;
3824
3825 }
3826 else{
3827 dyup[i]=0.; //not enough points
3828 }
3829 }
3830 //
3831 // derivation down
3832 for (Int_t i=i2;i>=i1;i--){
3833 AliTPCclusterMI * cl = seed->fClusterPointer[i];
3834 if (!cl) continue;
3835 if (cl->GetType()<0) continue;
3836 if (cl->GetType()>10) continue;
3837 if (sec[i]>=0){
3838 ptrack2.AddPoint(x[i]-xm,y[i],z[i],0.1,0.1);
3839 }
3840 if (ptrack2.GetN()>4){
3841 ptrack2.UpdateParameters();
3842 Double_t ddy,ddz;
3843 ptrack2.GetFitDerivation(x[i]-xm,ddy,ddz);
3844 Double_t yy,zz;
3845 ptrack2.GetFitPoint(x[i]-xm,yy,zz);
3846
3847 dydown[i] = ddy;
3848 dzdown[i] = ddz;
3849 ydown[i] = yy;
3850 zdown[i] = zz;
3851 }
3852 else{
3853 dydown[i]=0.; //not enough points
3854 }
3855 }
3856 //
3857 //
3858 // find maximal difference of the derivation
3859 for (Int_t i=0;i<12;i++) seed->fKinkPoint[i]=0;
3860
3861
3862 for (Int_t i=i1+10;i<i2-10;i++){
3863 if ( (TMath::Abs(dydown[i])<0.00000001) || (TMath::Abs(dyup[i])<0.00000001) ||i<30)continue;
3864 // printf("%f\t%f\t%f\t%f\t%f\n",x[i],dydown[i],dyup[i],dzdown[i],dzup[i]);
3865 //
3866 Float_t ddy = TMath::Abs(dydown[i]-dyup[i]);
3867 Float_t ddz = TMath::Abs(dzdown[i]-dzup[i]);
3868 if ( (ddy+ddz)> th){
3869 seed->fKinkPoint[0] = i;
3870 seed->fKinkPoint[1] = ddy;
3871 seed->fKinkPoint[2] = ddz;
3872 th = ddy+ddz;
3873 }
3874 }
3875
3876 if (fTreeDebug){
3877 //
3878 //write information to the debug tree
3879 TBranch * br = fTreeDebug->GetBranch("debug");
3880 TClonesArray * arr = new TClonesArray("AliTPCTrackPoint2");
3881 arr->ExpandCreateFast(i2-i1);
3882 br->SetAddress(&arr);
3883 //
3884 AliTPCclusterMI cldummy;
3885 cldummy.SetQ(0);
3886 AliTPCTrackPoint2 pdummy;
3887 pdummy.GetTPoint().fIsShared = 10;
3888 //
3889 Double_t alpha = sec[i2]*fSectors->GetAlpha();
3890 Double_t cs = TMath::Cos(alpha);
3891 Double_t sn = TMath::Sin(alpha);
3892
3893 for (Int_t i=i1;i<i2;i++){
3894 AliTPCTrackPoint2 *trpoint = (AliTPCTrackPoint2*)arr->UncheckedAt(i-i1);
3895 //cluster info
3896 AliTPCclusterMI * cl0 = seed->fClusterPointer[i];
3897 //
3898 AliTPCTrackerPoint * point = seed->GetTrackPoint(i);
3899
3900 if (cl0){
3901 Double_t x = GetXrow(i);
3902 trpoint->GetTPoint() = *point;
3903 trpoint->GetCPoint() = *cl0;
3904 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
3905 trpoint->fID = seed->GetUniqueID();
3906 trpoint->fLab = seed->GetLabel();
3907 //
3908 trpoint->fGX = cs *x + sn*point->GetY();
3909 trpoint->fGY = -sn *x + cs*point->GetY() ;
3910 trpoint->fGZ = point->GetZ();
3911 //
3912 trpoint->fDY = y[i];
3913 trpoint->fDZ = z[i];
3914 //
3915 trpoint->fDYU = dyup[i];
3916 trpoint->fDZU = dzup[i];
3917 //
3918 trpoint->fDYD = dydown[i];
3919 trpoint->fDZD = dzdown[i];
3920 //
3921 if (TMath::Abs(dyup[i])>0.00000000001 &&TMath::Abs(dydown[i])>0.00000000001){
3922 trpoint->fDDY = dydown[i]-dyup[i];
3923 trpoint->fDDZ = dzdown[i]-dzup[i];
3924 }else{
3925 trpoint->fDDY = 0.;
3926 trpoint->fDDZ = 0.;
3927 }
3928 }
3929 else{
3930 *trpoint = pdummy;
3931 trpoint->GetCPoint()= cldummy;
3932 trpoint->fID = -1;
3933 }
3934 //
1627d1c4 3935 }
91162307 3936 fTreeDebug->Fill();
1627d1c4 3937 }
3938
3939
91162307 3940 return 0;
1627d1c4 3941
3942}
3943
3944
3945
3946
3947
91162307 3948AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
3949{
3950 //
3951 // reseed - refit - track
3952 //
3953 Int_t first = 0;
3954 // Int_t last = fSectors->GetNRows()-1;
3955 //
3956 if (fSectors == fOuterSec){
3957 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
3958 //last =
3959 }
3960 else
3961 first = t->fFirstPoint;
3962 //
3963 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
3964 FollowBackProlongation(*t,fSectors->GetNRows()-1);
3965 t->Reset(kFALSE);
3966 FollowProlongation(*t,first);
3967 return seed;
3968}
3969
3970
3971
3972
3973
3974
3975
1c53abe2 3976//_____________________________________________________________________________
3977Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
3978 //-----------------------------------------------------------------
3979 // This function reades track seeds.
3980 //-----------------------------------------------------------------
3981 TDirectory *savedir=gDirectory;
3982
3983 TFile *in=(TFile*)inp;
3984 if (!in->IsOpen()) {
3985 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
3986 return 1;
3987 }
3988
3989 in->cd();
3990 TTree *seedTree=(TTree*)in->Get("Seeds");
3991 if (!seedTree) {
3992 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
3993 cerr<<"can't get a tree with track seeds !\n";
3994 return 2;
3995 }
3996 AliTPCtrack *seed=new AliTPCtrack;
3997 seedTree->SetBranchAddress("tracks",&seed);
3998
3999 if (fSeeds==0) fSeeds=new TObjArray(15000);
4000
4001 Int_t n=(Int_t)seedTree->GetEntries();
4002 for (Int_t i=0; i<n; i++) {
4003 seedTree->GetEvent(i);
4004 fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
4005 }
4006
4007 delete seed;
4008 delete seedTree;
4009 savedir->cd();
4010 return 0;
4011}
4012
d26d9159 4013Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
4014{
4015 //
d9b8978b 4016 if (fSeeds) DeleteSeeds();
d26d9159 4017 fEvent = esd;
4018 Clusters2Tracks();
4019 if (!fSeeds) return 1;
4020 FillESD(fSeeds);
4021 return 0;
4022 //
4023}
4024
4025
1c53abe2 4026//_____________________________________________________________________________
f8aae377 4027Int_t AliTPCtrackerMI::Clusters2Tracks() {
1c53abe2 4028 //-----------------------------------------------------------------
4029 // This is a track finder.
4030 //-----------------------------------------------------------------
91162307 4031 TDirectory *savedir=gDirectory;
1c53abe2 4032 TStopwatch timer;
d26d9159 4033
91162307 4034 fIteration = 0;
4035 fSeeds = Tracking();
1c53abe2 4036
6bdc18d6 4037 if (fDebug>0){
4038 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
4039 }
91162307 4040 //activate again some tracks
4041 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
4042 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4043 if (!pt) continue;
4044 Int_t nc=t.GetNumberOfClusters();
4045 if (nc<20) {
4046 delete fSeeds->RemoveAt(i);
4047 continue;
4048 }
4049 if (pt->fRemoval==10) {
4050 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4051 pt->Desactivate(10); // make track again active
4052 else{
4053 pt->Desactivate(20);
4054 delete fSeeds->RemoveAt(i);
4055 }
4056 }
4057 }
4058 RemoveDouble(fSeeds,0.2,0.6,11);
91162307 4059 RemoveUsed(fSeeds,0.5,0.5,6);
c9427e08 4060
1c53abe2 4061 //
91162307 4062 Int_t nseed=fSeeds->GetEntriesFast();
4063 Int_t found = 0;
4064 for (Int_t i=0; i<nseed; i++) {
4065 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4066 if (!pt) continue;
4067 Int_t nc=t.GetNumberOfClusters();
4068 if (nc<15) {
4069 delete fSeeds->RemoveAt(i);
4070 continue;
4071 }
4072 CookLabel(pt,0.1); //For comparison only
4073 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4074 if ((pt->IsActive() || (pt->fRemoval==10) )){
d9b8978b 4075 found++;
4076 if (fDebug>0) cerr<<found<<'\r';
d26d9159 4077 pt->fLab2 = i;
91162307 4078 }
4079 else
4080 delete fSeeds->RemoveAt(i);
91162307 4081 }
4082
4083
4084 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
4085 SignShared(fSeeds);
4086 //RemoveUsed(fSeeds,0.9,0.9,6);
1c53abe2 4087 //
91162307 4088 nseed=fSeeds->GetEntriesFast();
4089 found = 0;
4090 for (Int_t i=0; i<nseed; i++) {
4091 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4092 if (!pt) continue;
4093 Int_t nc=t.GetNumberOfClusters();
4094 if (nc<15) {
4095 delete fSeeds->RemoveAt(i);
4096 continue;
4097 }
4098 t.SetUniqueID(i);
4099 t.CookdEdx(0.02,0.6);
4100 // CheckKinkPoint(&t,0.05);
4101 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4102 if ((pt->IsActive() || (pt->fRemoval==10) )){
6bdc18d6 4103 found++;
4104 if (fDebug>0){
4105 cerr<<found<<'\r';
4106 }
d26d9159 4107 pt->fLab2 = i;
91162307 4108 }
4109 else
4110 delete fSeeds->RemoveAt(i);
d26d9159 4111 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
4112 //if (seed1){
4113 // FollowProlongation(*seed1,0);
4114 // Int_t n = seed1->GetNumberOfClusters();
4115 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
4116 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
4117 //
4118 //}
4119 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
4120
91162307 4121 }
4122
4123 SortTracks(fSeeds, 1);
1c53abe2 4124
982aff31 4125 /*
91162307 4126 fIteration = 1;
982aff31 4127 PrepareForBackProlongation(fSeeds,5.);
91162307 4128 PropagateBack(fSeeds);
4129 printf("Time for back propagation: \t");timer.Print();timer.Start();
4130
4131 fIteration = 2;
1c53abe2 4132
982aff31 4133 PrepareForProlongation(fSeeds,5.);
4134 PropagateForward2(fSeeds);
d26d9159 4135
91162307 4136 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
4137 // RemoveUsed(fSeeds,0.7,0.7,6);
4138 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
d26d9159 4139
1c53abe2 4140 nseed=fSeeds->GetEntriesFast();
91162307 4141 found = 0;
4142 for (Int_t i=0; i<nseed; i++) {
1c53abe2 4143 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
4144 if (!pt) continue;
4145 Int_t nc=t.GetNumberOfClusters();
91162307 4146 if (nc<15) {
4147 delete fSeeds->RemoveAt(i);
4148 continue;
4149 }
1c53abe2 4150 t.CookdEdx(0.02,0.6);
91162307 4151 // CookLabel(pt,0.1); //For comparison only
4152 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
4153 if ((pt->IsActive() || (pt->fRemoval==10) )){
4154 cerr<<found++<<'\r';
4155 }
4156 else
4157 delete fSeeds->RemoveAt(i);
4158 pt->fLab2 = i;
1c53abe2 4159 }
91162307 4160 */
4161
c9427e08 4162 // fNTracks = found;
6bdc18d6 4163 if (fDebug>0){
4164 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
4165 }
91162307 4166 //
6bdc18d6 4167 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
4168 Info("Clusters2Tracks","Number of found tracks %d",found);
91162307 4169 savedir->cd();
91162307 4170 // UnloadClusters();
d26d9159 4171 //
1c53abe2 4172 return 0;
4173}
4174
91162307 4175void AliTPCtrackerMI::Tracking(TObjArray * arr)
4176{
4177 //
4178 // tracking of the seeds
4179 //
4180
4181 fSectors = fOuterSec;
4182 ParallelTracking(arr,150,63);
4183 fSectors = fOuterSec;
4184 ParallelTracking(arr,63,0);
4185}
4186
4187TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
4188{
4189 //
4190 //
4191 //tracking routine
4192 TObjArray * arr = new TObjArray;
4193 //
4194 fSectors = fOuterSec;
4195 TStopwatch timer;
4196 timer.Start();
4197 for (Int_t sec=0;sec<fkNOS;sec++){
4198 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
4199 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
4200 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
4201 }
4202 if (fDebug>0){
6bdc18d6 4203 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
91162307 4204 timer.Print();
4205 timer.Start();
4206 }
4207 Tracking(arr);
4208 if (fDebug>0){
4209 timer.Print();
4210 }
4211
4212 return arr;
4213}
4214
4215TObjArray * AliTPCtrackerMI::Tracking()
4216{
4217 //
4218 //
4219 TStopwatch timer;
4220 timer.Start();
4221 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
4222
4223 TObjArray * seeds = new TObjArray;
4224 TObjArray * arr=0;
4225
4226 Int_t gap =20;
4227 Float_t cuts[4];
4228 cuts[0] = 0.002;
4229 cuts[1] = 1.5;
4230 cuts[2] = 3.;
4231 cuts[3] = 3.;
4232 Float_t fnumber = 3.0;
4233 Float_t fdensity = 3.0;
4234
4235 //
4236 //find primaries
4237 cuts[0]=0.0066;
4238 for (Int_t delta = 0; delta<18; delta+=6){
4239 //
4240 cuts[0]=0.0070;
4241 cuts[1] = 1.5;
4242 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
4243 SumTracks(seeds,arr);
4244 SignClusters(seeds,fnumber,fdensity);
4245 //
4246 for (Int_t i=2;i<6;i+=2){
4247 // seed high pt tracks
4248 cuts[0]=0.0022;
4249 cuts[1]=0.3;
4250 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
4251 SumTracks(seeds,arr);
4252 SignClusters(seeds,fnumber,fdensity);
4253 }
4254 }
4255 fnumber = 4;
4256 fdensity = 4.;
4257 // RemoveUsed(seeds,0.9,0.9,1);
4258 // UnsignClusters();
4259 // SignClusters(seeds,fnumber,fdensity);
4260
4261 //find primaries
4262 cuts[0]=0.0077;
4263 for (Int_t delta = 20; delta<120; delta+=10){
4264 //
4265 // seed high pt tracks
4266 cuts[0]=0.0060;
4267 cuts[1]=0.3;
4268 cuts[2]=6.;
4269 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
4270 SumTracks(seeds,arr);
4271 SignClusters(seeds,fnumber,fdensity);
4272
4273 cuts[0]=0.003;
4274 cuts[1]=0.3;
4275 cuts[2]=6.;
4276 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
4277 SumTracks(seeds,arr);
4278 SignClusters(seeds,fnumber,fdensity);
4279 }
4280
4281 cuts[0] = 0.01;
4282 cuts[1] = 2.0;
4283 cuts[2] = 3.;
4284 cuts[3] = 2.0;
4285 fnumber = 2.;
4286 fdensity = 2.;
4287
4288 if (fDebug>0){
6bdc18d6 4289 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
91162307 4290 timer.Print();
4291 timer.Start();
4292 }
4293 // RemoveUsed(seeds,0.75,0.75,1);
4294 //UnsignClusters();
4295 //SignClusters(seeds,fnumber,fdensity);
4296
4297 // find secondaries
4298
4299 cuts[0] = 0.3;
4300 cuts[1] = 1.5;
4301 cuts[2] = 3.;
4302 cuts[3] = 1.5;
4303
4304 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
4305 SumTracks(seeds,arr);
4306 SignClusters(seeds,fnumber,fdensity);
4307 //
4308 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
4309 SumTracks(seeds,arr);
4310 SignClusters(seeds,fnumber,fdensity);
4311 //
4312 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
4313 SumTracks(seeds,arr);
4314 SignClusters(seeds,fnumber,fdensity);
4315 //
4316
4317
4318 for (Int_t delta = 3; delta<30; delta+=5){
4319 //
4320 cuts[0] = 0.3;
4321 cuts[1] = 1.5;
4322 cuts[2] = 3.;
4323 cuts[3] = 1.5;
4324 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4325 SumTracks(seeds,arr);
4326 SignClusters(seeds,fnumber,fdensity);
4327 //
4328 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
4329 SumTracks(seeds,arr);
4330 SignClusters(seeds,fnumber,fdensity);
4331 //
4332 }
4333 fnumber = 1;
4334 fdensity = 1;
4335 //
4336 // change cuts
4337 fnumber = 2.;
4338 fdensity = 2.;
4339 cuts[0]=0.0080;
4340
4341 // find secondaries
4342 for (Int_t delta = 30; delta<70; delta+=10){
4343 //
4344 cuts[0] = 0.3;
4345 cuts[1] = 1.5;
4346 cuts[2] = 3.;
4347 cuts[3] = 1.5;
4348 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
4349 SumTracks(seeds,arr);
4350 SignClusters(seeds,fnumber,fdensity);
4351 //
4352 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
4353 SumTracks(seeds,arr);
4354 SignClusters(seeds,fnumber,fdensity);
4355 }
4356
4357 if (fDebug>0){
6bdc18d6 4358 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
91162307 4359 timer.Print();
4360 timer.Start();
4361 }
4362
4363 return seeds;
4364 //
4365
4366}
4367
4368
47966a6d 4369void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
91162307 4370{
4371 //
4372 //sum tracks to common container
4373 //remove suspicious tracks
4374 Int_t nseed = arr2->GetEntriesFast();
4375 for (Int_t i=0;i<nseed;i++){
4376 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
4377 if (pt){
4378
4379 // NORMAL ACTIVE TRACK
4380 if (pt->IsActive()){
4381 arr1->AddLast(arr2->RemoveAt(i));
4382 continue;
4383 }
4384 //remove not usable tracks
4385 if (pt->fRemoval!=10){
4386 delete arr2->RemoveAt(i);
4387 continue;
4388 }
4389 // REMOVE VERY SHORT TRACKS
4390 if (pt->GetNumberOfClusters()<20){
4391 delete arr2->RemoveAt(i);
4392 continue;
4393 }
4394 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
4395 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
4396 arr1->AddLast(arr2->RemoveAt(i));
4397 else{
4398 delete arr2->RemoveAt(i);
4399 }
4400 }
4401 }
4402 delete arr2;
4403}
4404
4405
1c53abe2 4406
91162307 4407void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
1c53abe2 4408{
4409 //
4410 // try to track in parralel
4411
91162307 4412 Int_t nseed=arr->GetEntriesFast();
1c53abe2 4413 //prepare seeds for tracking
4414 for (Int_t i=0; i<nseed; i++) {
91162307 4415 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
1c53abe2 4416 if (!pt) continue;
4417 if (!t.IsActive()) continue;
4418 // follow prolongation to the first layer
91162307 4419 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
c9427e08 4420 FollowProlongation(t, rfirst+1);
1c53abe2 4421 }
4422
4423
4424 //
982aff31 4425 for (Int_t nr=rfirst; nr>=rlast; nr--){
4426 if (nr<fInnerSec->GetNRows())
4427 fSectors = fInnerSec;
4428 else
4429 fSectors = fOuterSec;
1c53abe2 4430 // make indexes with the cluster tracks for given
1c53abe2 4431
4432 // find nearest cluster
4433 for (Int_t i=0; i<nseed; i++) {
91162307 4434 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
1c53abe2 4435 if (!pt) continue;
4436 if (!pt->IsActive()) continue;
91162307 4437 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
1627d1c4 4438 if (pt->fRelativeSector>17) {
4439 continue;
4440 }
91162307 4441 UpdateClusters(t,nr);
1c53abe2 4442 }
4443 // prolonagate to the nearest cluster - if founded
4444 for (Int_t i=0; i<nseed; i++) {
91162307 4445 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1c53abe2 4446 if (!pt) continue;
1627d1c4 4447 if (!pt->IsActive()) continue;
91162307 4448 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
1627d1c4 4449 if (pt->fRelativeSector>17) {
4450 continue;
4451 }
91162307 4452 FollowToNextCluster(*pt,nr);
1c53abe2 4453 }
91162307 4454 }
4455}
4456
47966a6d 4457void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
91162307 4458{
4459 //
4460 //
4461 // if we use TPC track itself we have to "update" covariance
4462 //
4463 Int_t nseed= arr->GetEntriesFast();
4464 for (Int_t i=0;i<nseed;i++){
4465 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4466 if (pt) {
4467 pt->Modify(fac);
4468 //
4469 //rotate to current local system at first accepted point
4470 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
4471 Int_t sec = (index&0xff000000)>>24;
4472 sec = sec%18;
4473 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
4474 if (angle1>TMath::Pi())
4475 angle1-=2.*TMath::Pi();
4476 Float_t angle2 = pt->GetAlpha();
4477
4478 if (TMath::Abs(angle1-angle2)>0.001){
4479 pt->Rotate(angle1-angle2);
4480 //angle2 = pt->GetAlpha();
4481 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
4482 //if (pt->GetAlpha()<0)
4483 // pt->fRelativeSector+=18;
4484 //sec = pt->fRelativeSector;
4485 }
4486
4487 }
4488
4489 }
4490
4491
4492}
47966a6d 4493void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
91162307 4494{
4495 //
4496 //
4497 // if we use TPC track itself we have to "update" covariance
4498 //
4499 Int_t nseed= arr->GetEntriesFast();
4500 for (Int_t i=0;i<nseed;i++){
4501 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4502 if (pt) {
4503 pt->Modify(fac);
4504 pt->fFirstPoint = pt->fLastPoint;
4505 }
4506
4507 }
4508
4509
4510}
4511
4512Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
4513{
4514 //
4515 // make back propagation
4516 //
4517 Int_t nseed= arr->GetEntriesFast();
4518 for (Int_t i=0;i<nseed;i++){
4519 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4520 if (pt) {
d9b8978b 4521 //AliTPCseed *pt2 = new AliTPCseed(*pt);
91162307 4522 fSectors = fInnerSec;
d26d9159 4523 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
4524 //fSectors = fOuterSec;
4d158c36 4525 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
4526 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
d9b8978b 4527 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
4d158c36 4528 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
d9b8978b 4529 //}
91162307 4530 }
4531 }
4532 return 0;
4533}
4534
4535
4536Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
4537{
4538 //
4539 // make forward propagation
4540 //
4541 Int_t nseed= arr->GetEntriesFast();
4d158c36 4542 //
91162307 4543 for (Int_t i=0;i<nseed;i++){
4544 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
4545 if (pt) {
91162307 4546 FollowProlongation(*pt,0);
4d158c36 4547 }
91162307 4548 }
4549 return 0;
4550}
4551
4552
4553Int_t AliTPCtrackerMI::PropagateForward()
4554{
b67e07dc 4555 //
4556 // propagate track forward
4d158c36 4557 //UnsignClusters();
d26d9159 4558 Int_t nseed = fSeeds->GetEntriesFast();
4559 for (Int_t i=0;i<nseed;i++){
4560 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
4561 if (pt){
4562 AliTPCseed &t = *pt;
4563 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
4564 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
4565 if (alpha < 0. ) alpha += 2.*TMath::Pi();
4566 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
4567 }
4568 }
4569
91162307 4570 fSectors = fOuterSec;
d26d9159 4571 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
91162307 4572 fSectors = fInnerSec;
d26d9159 4573 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
91162307 4574 //WriteTracks();
4575 return 1;
4576}
4577
4578
4579
4580
4581
4582
4583Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
4584{
4585 //
4586 // make back propagation, in between row0 and row1
4587 //
1c53abe2 4588
91162307 4589 if (pt) {
4590 fSectors = fInnerSec;
4591 Int_t r1;
4592 //
4593 if (row1<fSectors->GetNRows())
4594 r1 = row1;
4595 else
4596 r1 = fSectors->GetNRows()-1;
4597
4598 if (row0<fSectors->GetNRows()&& r1>0 )
4599 FollowBackProlongation(*pt,r1);
4600 if (row1<=fSectors->GetNRows())
4601 return 0;
4602 //
4603 r1 = row1 - fSectors->GetNRows();
4604 if (r1<=0) return 0;
4605 if (r1>=fOuterSec->GetNRows()) return 0;
4606 fSectors = fOuterSec;
4607 return FollowBackProlongation(*pt,r1);
4608 }
4609 return 0;
4610}
4611
4612
4613
4614
4615void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
4616{
4617 //
4618 //
4619 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
4620 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4621 Float_t padlength = GetPadPitchLength(row);
4622 //
4623 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4624 Float_t angulary = seed->GetSnp();
4625 angulary = angulary*angulary/(1-angulary*angulary);
4626 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
4627 //
4628 Float_t sresz = fParam->GetZSigma();
4629 Float_t angularz = seed->GetTgl();
4630 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
4631 /*
4632 Float_t wy = GetSigmaY(seed);
4633 Float_t wz = GetSigmaZ(seed);
4634 wy*=wy;
4635 wz*=wz;
4636 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
4637 printf("problem\n");
4638 }
4639 */
1c53abe2 4640}
4641
91162307 4642
1c53abe2 4643Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
4644{
4645 //
4646 //
c9427e08 4647 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
1c53abe2 4648 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4649 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
4650 Float_t angular = seed->GetSnp();
4651 angular = angular*angular/(1-angular*angular);
4652 // angular*=angular;
4653 //angular = TMath::Sqrt(angular/(1-angular));
4654 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
4655 return res;
4656}
4657Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
4658{
4659 //
4660 //
c9427e08 4661 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
1c53abe2 4662 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
4663 Float_t sres = fParam->GetZSigma();
4664 Float_t angular = seed->GetTgl();
4665 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
4666 return res;
4667}
4668
4669
4670
1c53abe2 4671
4672//__________________________________________________________________________
91162307 4673void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
1c53abe2 4674 //--------------------------------------------------------------------
4675 //This function "cooks" a track label. If label<0, this track is fake.
4676 //--------------------------------------------------------------------
4677 Int_t noc=t->GetNumberOfClusters();
91162307 4678 if (noc<10){
d26d9159 4679 //printf("\nnot founded prolongation\n\n\n");
4680 //t->Dump();
91162307 4681 return ;
4682 }
4683 Int_t lb[160];
4684 Int_t mx[160];
4685 AliTPCclusterMI *clusters[160];
4686 //
4687 for (Int_t i=0;i<160;i++) {
4688 clusters[i]=0;
4689 lb[i]=mx[i]=0;
4690 }
1c53abe2 4691
4692 Int_t i;
91162307 4693 Int_t current=0;
4694 for (i=0; i<160 && current<noc; i++) {
4695
4696 Int_t index=t->GetClusterIndex2(i);
4697 if (index<=0) continue;
4698 if (index&0x8000) continue;
4699 //
4700 //clusters[current]=GetClusterMI(index);
4701 if (t->fClusterPointer[i]){
4702 clusters[current]=t->fClusterPointer[i];
4703 current++;
4704 }
1c53abe2 4705 }
91162307 4706 noc = current;
1c53abe2 4707
4708 Int_t lab=123456789;
4709 for (i=0; i<noc; i++) {
4710 AliTPCclusterMI *c=clusters[i];
91162307 4711 if (!c) continue;
1c53abe2 4712 lab=TMath::Abs(c->GetLabel(0));
4713 Int_t j;
4714 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
4715 lb[j]=lab;
4716 (mx[j])++;
4717 }
4718
4719 Int_t max=0;
4720 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
4721
4722 for (i=0; i<noc; i++) {
9918f10a 4723 AliTPCclusterMI *c=clusters[i];
91162307 4724 if (!c) continue;
1c53abe2 4725 if (TMath::Abs(c->GetLabel(1)) == lab ||
4726 TMath::Abs(c->GetLabel(2)) == lab ) max++;
4727 }
4728
4729 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
4730
4731 else {
4732 Int_t tail=Int_t(0.10*noc);
4733 max=0;
91162307 4734 Int_t ind=0;
4735 for (i=1; i<=160&&ind<tail; i++) {
4736 // AliTPCclusterMI *c=clusters[noc-i];
4737 AliTPCclusterMI *c=clusters[i];
4738 if (!c) continue;
1c53abe2 4739 if (lab == TMath::Abs(c->GetLabel(0)) ||
4740 lab == TMath::Abs(c->GetLabel(1)) ||
4741 lab == TMath::Abs(c->GetLabel(2))) max++;
91162307 4742 ind++;
1c53abe2 4743 }
4744 if (max < Int_t(0.5*tail)) lab=-lab;
4745 }
4746
4747 t->SetLabel(lab);
4748
91162307 4749 // delete[] lb;
4750 //delete[] mx;
4751 //delete[] clusters;
1c53abe2 4752}
4753
47966a6d 4754
4755Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
4756{
4757 //return pad row number for this x
4758 Double_t r;
4759 if (fN < 64){
4760 r=fRow[fN-1].GetX();
4761 if (x > r) return fN;
4762 r=fRow[0].GetX();
4763 if (x < r) return -1;
4764 return Int_t((x-r)/fPadPitchLength + 0.5);}
4765 else{
4766 r=fRow[fN-1].GetX();
4767 if (x > r) return fN;
4768 r=fRow[0].GetX();
4769 if (x < r) return -1;
4770 Double_t r1=fRow[64].GetX();
4771 if(x<r1){
4772 return Int_t((x-r)/f1PadPitchLength + 0.5);}
4773 else{
4774 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
4775 }
4776}
4777
1c53abe2 4778//_________________________________________________________________________
4779void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
4780 //-----------------------------------------------------------------------
4781 // Setup inner sector
4782 //-----------------------------------------------------------------------
4783 if (f==0) {
4784 fAlpha=par->GetInnerAngle();
4785 fAlphaShift=par->GetInnerAngleShift();
4786 fPadPitchWidth=par->GetInnerPadPitchWidth();
4787 fPadPitchLength=par->GetInnerPadPitchLength();
4788 fN=par->GetNRowLow();
4789 fRow=new AliTPCRow[fN];
4790 for (Int_t i=0; i<fN; i++) {
4791 fRow[i].SetX(par->GetPadRowRadiiLow(i));
4792 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
4793 }
4794 } else {
4795 fAlpha=par->GetOuterAngle();
4796 fAlphaShift=par->GetOuterAngleShift();
4797 fPadPitchWidth = par->GetOuterPadPitchWidth();
4798 fPadPitchLength = par->GetOuter1PadPitchLength();
4799 f1PadPitchLength = par->GetOuter1PadPitchLength();
4800 f2PadPitchLength = par->GetOuter2PadPitchLength();
4801
4802 fN=par->GetNRowUp();
4803 fRow=new AliTPCRow[fN];
4804 for (Int_t i=0; i<fN; i++) {
4805 fRow[i].SetX(par->GetPadRowRadiiUp(i));
4806 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
4807 }
4808 }
4809}
4810
b67e07dc 4811AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
4812 //
4813 // default constructor
4814 fN=0;
4815 fN1=0;
4816 fN2=0;
4817 fClusters1=0;
4818 fClusters2=0;
4819}
1c53abe2 4820
4821AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
4822 //
b67e07dc 4823
1c53abe2 4824}
4825
4826
4827
1c53abe2 4828//_________________________________________________________________________
4829void
4830AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
4831 //-----------------------------------------------------------------------
4832 // Insert a cluster into this pad row in accordence with its y-coordinate
4833 //-----------------------------------------------------------------------
4834 if (fN==kMaxClusterPerRow) {
4835 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
4836 }
4837 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
4838 Int_t i=Find(c->GetZ());
4839 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
4840 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
4841 fIndex[i]=index; fClusters[i]=c; fN++;
4842}
4843
982aff31 4844void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
4845 //
4846 // reset clusters
4847 fN = 0;
4848 fN1 = 0;
4849 fN2 = 0;
4850 //delete[] fClusterArray;
4851 if (fClusters1) delete []fClusters1;
4852 if (fClusters2) delete []fClusters2;
4853 //fClusterArray=0;
4854 fClusters1 = 0;
4855 fClusters2 = 0;
4856}
4857
91162307 4858
1c53abe2 4859//___________________________________________________________________
4860Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
4861 //-----------------------------------------------------------------------
4862 // Return the index of the nearest cluster
4863 //-----------------------------------------------------------------------
4864 if (fN==0) return 0;
4865 if (z <= fClusters[0]->GetZ()) return 0;
4866 if (z > fClusters[fN-1]->GetZ()) return fN;
4867 Int_t b=0, e=fN-1, m=(b+e)/2;
4868 for (; b<e; m=(b+e)/2) {
4869 if (z > fClusters[m]->GetZ()) b=m+1;
4870 else e=m;
4871 }
4872 return m;
4873}
4874
4875
4876
1627d1c4 4877//___________________________________________________________________
4878AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
4879 //-----------------------------------------------------------------------
4880 // Return the index of the nearest cluster in z y
4881 //-----------------------------------------------------------------------
4882 Float_t maxdistance = roady*roady + roadz*roadz;
4883
4884 AliTPCclusterMI *cl =0;
4885 for (Int_t i=Find(z-roadz); i<fN; i++) {
4886 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4887 if (c->GetZ() > z+roadz) break;
4888 if ( (c->GetY()-y) > roady ) continue;
4889 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4890 if (maxdistance>distance) {
4891 maxdistance = distance;
4892 cl=c;
4893 }
4894 }
4895 return cl;
4896}
4897
91162307 4898AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4899{
4900 //-----------------------------------------------------------------------
4901 // Return the index of the nearest cluster in z y
4902 //-----------------------------------------------------------------------
4903 Float_t maxdistance = roady*roady + roadz*roadz;
4904 Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
4905 Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
4906
4907 AliTPCclusterMI *cl =0;
4908 //FindNearest3(y,z,roady,roadz,index);
4909 // for (Int_t i=Find(z-roadz); i<fN; i++) {
4910 for (Int_t i=iz1; i<iz2; i++) {
4911 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4912 if (c->GetZ() > z+roadz) break;
4913 if ( c->GetY()-y > roady ) continue;
4914 if ( y-c->GetY() > roady ) continue;
4915 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4916 if (maxdistance>distance) {
4917 maxdistance = distance;
4918 cl=c;
4919 index =i;
4920 //roady = TMath::Sqrt(maxdistance);
4921 }
4922 }
4923 return cl;
4924}
4925
4926
4927
4928AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
4929{
4930 //-----------------------------------------------------------------------
4931 // Return the index of the nearest cluster in z y
4932 //-----------------------------------------------------------------------
4933 Float_t maxdistance = roady*roady + roadz*roadz;
4934 // Int_t iz = Int_t(z+255.);
4935 AliTPCclusterMI *cl =0;
4936 for (Int_t i=Find(z-roadz); i<fN; i++) {
4937 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
4938 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
4939 if (c->GetZ() > z+roadz) break;
4940 if ( c->GetY()-y > roady ) continue;
4941 if ( y-c->GetY() > roady ) continue;
4942 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
4943 if (maxdistance>distance) {
4944 maxdistance = distance;
4945 cl=c;
4946 index =i;
4947 //roady = TMath::Sqrt(maxdistance);
4948 }
4949 }
4950 return cl;
4951}
1627d1c4 4952
4953
4954
4955
1c53abe2 4956AliTPCseed::AliTPCseed():AliTPCtrack(){
4957 //
4958 fRow=0;
4959 fRemoval =0;
91162307 4960 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
4961 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
4962
1c53abe2 4963 fPoints = 0;
4964 fEPoints = 0;
4965 fNFoundable =0;
4966 fNShared =0;
1c53abe2 4967 fRemoval = 0;
91162307 4968 fSort =0;
4969 fFirstPoint =0;
4970 fNoCluster =0;
4971 fBSigned = kFALSE;
4972 fSeed1 =-1;
4973 fSeed2 =-1;
b67e07dc 4974 fCurrentCluster =0;
4d158c36 4975 fCurrentSigmaY2=0;
4976 fCurrentSigmaZ2=0;
1c53abe2 4977}
2fc0c115 4978AliTPCseed::AliTPCseed(const AliTPCseed &s):AliTPCtrack(s){
4979 //---------------------
4980 // dummy copy constructor
4981 //-------------------------
4982}
1c53abe2 4983AliTPCseed::AliTPCseed(const AliTPCtrack &t):AliTPCtrack(t){
b67e07dc 4984 //
4985 //copy constructor
1c53abe2 4986 fPoints = 0;
4987 fEPoints = 0;
4988 fNShared =0;
91162307 4989 // fTrackPoints =0;
1c53abe2 4990 fRemoval =0;
91162307 4991 fSort =0;
4992 for (Int_t i=0;i<160;i++) {
4993 fClusterPointer[i] = 0;
4994 Int_t index = t.GetClusterIndex(i);
4d158c36 4995 if (index>=-1){
91162307 4996 SetClusterIndex2(i,index);
4997 }
4998 else{
4999 SetClusterIndex2(i,-3);
5000 }
5001 }
5002 fFirstPoint =0;
5003 fNoCluster =0;
5004 fBSigned = kFALSE;
5005 fSeed1 =-1;
5006 fSeed2 =-1;
b67e07dc 5007 fCurrentCluster =0;
4d158c36 5008 fCurrentSigmaY2=0;
5009 fCurrentSigmaZ2=0;
1c53abe2 5010}
5011
5012AliTPCseed::AliTPCseed(const AliKalmanTrack &t, Double_t a):AliTPCtrack(t,a){
b67e07dc 5013 //
5014 //copy constructor
1c53abe2 5015 fRow=0;
91162307 5016 for (Int_t i=0;i<160;i++) {
5017 fClusterPointer[i] = 0;
5018 Int_t index = t.GetClusterIndex(i);
5019 SetClusterIndex2(i,index);
5020 }
5021
1c53abe2 5022 fPoints = 0;
5023 fEPoints = 0;
5024 fNFoundable =0;
5025 fNShared =0;
91162307 5026 // fTrackPoints =0;
1c53abe2 5027 fRemoval =0;
91162307 5028 fSort = 0;
5029 fFirstPoint =0;
5030 fNoCluster =0;
5031 fBSigned = kFALSE;
5032 fSeed1 =-1;
5033 fSeed2 =-1;
b67e07dc 5034 fCurrentCluster =0;
4d158c36 5035 fCurrentSigmaY2=0;
5036 fCurrentSigmaZ2=0;
5037
1c53abe2 5038}
5039
5040AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5], const Double_t cc[15],
5041 Double_t xr, Double_t alpha):
5042 AliTPCtrack(index, xx, cc, xr, alpha) {
5043 //
5044 //
b67e07dc 5045 //constructor
1c53abe2 5046 fRow =0;
91162307 5047 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
5048 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
1c53abe2 5049 fPoints = 0;
5050 fEPoints = 0;
5051 fNFoundable =0;
5052 fNShared = 0;
91162307 5053 // fTrackPoints =0;
1c53abe2 5054 fRemoval =0;
91162307 5055 fSort =0;
5056 fFirstPoint =0;
5057 // fHelixIn = new TClonesArray("AliHelix",0);
5058 //fHelixOut = new TClonesArray("AliHelix",0);
5059 fNoCluster =0;
5060 fBSigned = kFALSE;
5061 fSeed1 =-1;
5062 fSeed2 =-1;
b67e07dc 5063 fCurrentCluster =0;
4d158c36 5064 fCurrentSigmaY2=0;
5065 fCurrentSigmaZ2=0;
1c53abe2 5066}
5067
5068AliTPCseed::~AliTPCseed(){
b67e07dc 5069 //
5070 // destructor
1c53abe2 5071 if (fPoints) delete fPoints;
5072 fPoints =0;
91162307 5073 if (fEPoints) delete fEPoints;
1c53abe2 5074 fEPoints = 0;
91162307 5075 fNoCluster =0;
1c53abe2 5076}
5077
91162307 5078AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
1c53abe2 5079{
5080 //
5081 //
91162307 5082 return &fTrackPoints[i];
1c53abe2 5083}
5084
5085void AliTPCseed::RebuildSeed()
5086{
5087 //
5088 // rebuild seed to be ready for storing
91162307 5089 AliTPCclusterMI cldummy;
5090 cldummy.SetQ(0);
5091 AliTPCTrackPoint pdummy;
5092 pdummy.GetTPoint().fIsShared = 10;
1c53abe2 5093 for (Int_t i=0;i<160;i++){
91162307 5094 AliTPCclusterMI * cl0 = fClusterPointer[i];
5095 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
5096 if (cl0){
5097 trpoint->GetTPoint() = *(GetTrackPoint(i));
5098 trpoint->GetCPoint() = *cl0;
5099 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
5100 }
5101 else{
5102 *trpoint = pdummy;
5103 trpoint->GetCPoint()= cldummy;
5104 }
5105
5106 }
5107
5108}
5109
5110
5111Double_t AliTPCseed::GetDensityFirst(Int_t n)
5112{
5113 //
5114 //
5115 // return cluster for n rows bellow first point
5116 Int_t nfoundable = 1;
5117 Int_t nfound = 1;
5118 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
5119 Int_t index = GetClusterIndex2(i);
5120 if (index!=-1) nfoundable++;
5121 if (index>0) nfound++;
1c53abe2 5122 }
91162307 5123 if (nfoundable<n) return 0;
5124 return Double_t(nfound)/Double_t(nfoundable);
5125
5126}
1c53abe2 5127
91162307 5128
5129void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
5130{
5131 // get cluster stat. on given region
5132 //
5133 found = 0;
5134 foundable = 0;
5135 shared =0;
5136 for (Int_t i=first;i<last; i++){
5137 Int_t index = GetClusterIndex2(i);
5138 if (index!=-1) foundable++;
5139 if (fClusterPointer[i]) {
5140 found++;
5141 }
5142 else
5143 continue;
5144
5145 if (fClusterPointer[i]->IsUsed(10)) {
5146 shared++;
5147 continue;
5148 }
5149 if (!plus2) continue; //take also neighborhoud
5150 //
5151 if ( (i>0) && fClusterPointer[i-1]){
5152 if (fClusterPointer[i-1]->IsUsed(10)) {
5153 shared++;
5154 continue;
5155 }
5156 }
5157 if ( fClusterPointer[i+1]){
5158 if (fClusterPointer[i+1]->IsUsed(10)) {
5159 shared++;
5160 continue;
5161 }
5162 }
5163
5164 }
6bdc18d6 5165 //if (shared>found){
5166 //Error("AliTPCseed::GetClusterStatistic","problem\n");
5167 //}
1c53abe2 5168}
5169
5170//_____________________________________________________________________________
91162307 5171void AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
1c53abe2 5172 //-----------------------------------------------------------------
5173 // This funtion calculates dE/dX within the "low" and "up" cuts.
5174 //-----------------------------------------------------------------
5175
5176 Float_t amp[200];
5177 Float_t angular[200];
5178 Float_t weight[200];
5179 Int_t index[200];
5180 //Int_t nc = 0;
5181 // TClonesArray & arr = *fPoints;
5182 Float_t meanlog = 100.;
5183
5184 Float_t mean[4] = {0,0,0,0};
5185 Float_t sigma[4] = {1000,1000,1000,1000};
5186 Int_t nc[4] = {0,0,0,0};
5187 Float_t norm[4] = {1000,1000,1000,1000};
5188 //
5189 //
5190 fNShared =0;
5191
5192 for (Int_t of =0; of<4; of++){
91162307 5193 for (Int_t i=of+i1;i<i2;i+=4)
1c53abe2 5194 {
91162307 5195 Int_t index = fIndex[i];
5196 if (index<0||index&0x8000) continue;
5197
1c53abe2 5198 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
91162307 5199 AliTPCTrackerPoint * point = GetTrackPoint(i);
5200 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
5201 //AliTPCTrackerPoint * pointp = 0;
5202 //if (i<159) pointp = GetTrackPoint(i+1);
5203
1c53abe2 5204 if (point==0) continue;
91162307 5205 AliTPCclusterMI * cl = fClusterPointer[i];
5206 if (cl==0) continue;
5207 if (onlyused && (!cl->IsUsed(10))) continue;
5208 if (cl->IsUsed(11)) {
1c53abe2 5209 fNShared++;
5210 continue;
5211 }
91162307 5212 Int_t type = cl->GetType();
5213 //if (point->fIsShared){
5214 // fNShared++;
5215 // continue;
5216 //}
5217 //if (pointm)
5218 // if (pointm->fIsShared) continue;
5219 //if (pointp)
5220 // if (pointp->fIsShared) continue;
5221
5222 if (type<0) continue;
5223 //if (type>10) continue;
5224 //if (point->GetErrY()==0) continue;
5225 //if (point->GetErrZ()==0) continue;
5226
5227 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
5228 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
5229 //if ((ddy*ddy+ddz*ddz)>10) continue;
5230
5231
5232 // if (point->GetCPoint().GetMax()<5) continue;
5233 if (cl->GetMax()<5) continue;
5234 Float_t angley = point->GetAngleY();
5235 Float_t anglez = point->GetAngleZ();
5236
5237 Float_t rsigmay2 = point->GetSigmaY();
5238 Float_t rsigmaz2 = point->GetSigmaZ();
5239 /*
5240 Float_t ns = 1.;
5241 if (pointm){
5242 rsigmay += pointm->GetTPoint().GetSigmaY();
5243 rsigmaz += pointm->GetTPoint().GetSigmaZ();
5244 ns+=1.;
5245 }
5246 if (pointp){
5247 rsigmay += pointp->GetTPoint().GetSigmaY();
5248 rsigmaz += pointp->GetTPoint().GetSigmaZ();
5249 ns+=1.;
5250 }
5251 rsigmay/=ns;
5252 rsigmaz/=ns;
5253 */
5254
5255 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
1c53abe2 5256
5257 Float_t ampc = 0; // normalization to the number of electrons
5258 if (i>64){
91162307 5259 // ampc = 1.*point->GetCPoint().GetMax();
5260 ampc = 1.*cl->GetMax();
1c53abe2 5261 //ampc = 1.*point->GetCPoint().GetQ();
5262 // AliTPCClusterPoint & p = point->GetCPoint();
5263 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
5264 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5265 //Float_t dz =
5266 // TMath::Abs( Int_t(iz) - iz + 0.5);
5267 //ampc *= 1.15*(1-0.3*dy);
5268 //ampc *= 1.15*(1-0.3*dz);
d7a11555 5269 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
1627d1c4 5270 //ampc *=zfactor;
1c53abe2 5271 }
5272 else{
91162307 5273 //ampc = 1.0*point->GetCPoint().GetMax();
5274 ampc = 1.0*cl->GetMax();
1c53abe2 5275 //ampc = 1.0*point->GetCPoint().GetQ();
5276 //AliTPCClusterPoint & p = point->GetCPoint();
5277 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
5278 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
5279 //Float_t dz =
5280 // TMath::Abs( Int_t(iz) - iz + 0.5);
5281
5282 //ampc *= 1.15*(1-0.3*dy);
5283 //ampc *= 1.15*(1-0.3*dz);
1627d1c4 5284 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
5285 //ampc *=zfactor;
1c53abe2 5286
5287 }
5288 ampc *= 2.0; // put mean value to channel 50
5289 //ampc *= 0.58; // put mean value to channel 50
5290 Float_t w = 1.;
5291 // if (type>0) w = 1./(type/2.-0.5);
91162307 5292 // Float_t z = TMath::Abs(cl->GetZ());
1c53abe2 5293 if (i<64) {
5294 ampc /= 0.6;
1627d1c4 5295 //ampc /= (1+0.0008*z);
5296 } else
5297 if (i>128){
5298 ampc /=1.5;
5299 //ampc /= (1+0.0008*z);
5300 }else{
5301 //ampc /= (1+0.0008*z);
5302 }
5303
1c53abe2 5304 if (type<0) { //amp at the border - lower weight
5305 // w*= 2.;
1627d1c4 5306
1c53abe2 5307 continue;
5308 }
5309 if (rsigma>1.5) ampc/=1.3; // if big backround
5310 amp[nc[of]] = ampc;
5311 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5312 weight[nc[of]] = w;
5313 nc[of]++;
5314 }
5315
5316 TMath::Sort(nc[of],amp,index,kFALSE);
5317 Float_t sumamp=0;
5318 Float_t sumamp2=0;
5319 Float_t sumw=0;
5320 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
91162307 5321 meanlog = 50;
1c53abe2 5322 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
5323 Float_t ampl = amp[index[i]]/angular[index[i]];
5324 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5325 //
5326 sumw += weight[index[i]];
5327 sumamp += weight[index[i]]*ampl;
5328 sumamp2 += weight[index[i]]*ampl*ampl;
5329 norm[of] += angular[index[i]]*weight[index[i]];
5330 }
5331 if (sumw<1){
5332 SetdEdx(0);
5333 }
5334 else {
5335 norm[of] /= sumw;
5336 mean[of] = sumamp/sumw;
5337 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5338 if (sigma[of]>0.1)
5339 sigma[of] = TMath::Sqrt(sigma[of]);
5340 else
5341 sigma[of] = 1000;
5342
5343 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5344 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
5345 //mean *=(1-0.1*(norm-1.));
5346 }
5347 }
5348
5349 Float_t dedx =0;
5350 fSdEdx =0;
5351 fMAngular =0;
5352 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
5353 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
5354
5355
5356 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
5357 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
5358
5359 Int_t norm2 = 0;
5360 Int_t norm3 = 0;
5361 for (Int_t i =0;i<4;i++){
5362 if (nc[i]>2&&nc[i]<1000){
5363 dedx += mean[i] *nc[i];
5364 fSdEdx += sigma[i]*(nc[i]-2);
5365 fMAngular += norm[i] *nc[i];
5366 norm2 += nc[i];
5367 norm3 += nc[i]-2;
5368 }
5369 fDEDX[i] = mean[i];
5370 fSDEDX[i] = sigma[i];
5371 fNCDEDX[i]= nc[i];
5372 }
5373
5374 if (norm3>0){
5375 dedx /=norm2;
5376 fSdEdx /=norm3;
5377 fMAngular/=norm2;
5378 }
5379 else{
5380 SetdEdx(0);
5381 return;
5382 }
5383 // Float_t dedx1 =dedx;
91162307 5384 /*
1c53abe2 5385 dedx =0;
5386 for (Int_t i =0;i<4;i++){
5387 if (nc[i]>2&&nc[i]<1000){
5388 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
5389 dedx += mean[i] *nc[i];
5390 }
5391 fDEDX[i] = mean[i];
5392 }
5393 dedx /= norm2;
91162307 5394 */
1c53abe2 5395
5396
5397 SetdEdx(dedx);
5398
5399 //mi deDX
5400
5401
5402
5403 //Very rough PID
5404 Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
5405
5406 if (p<0.6) {
5407 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5408 if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
5409 SetMass(0.93827); return;
5410 }
5411
5412 if (p<1.2) {
5413 if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
5414 SetMass(0.93827); return;
5415 }
5416
5417 SetMass(0.13957); return;
5418
5419}
5420
5421
91162307 5422
5423/*
5424
5425
5426
5427void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
5428 //-----------------------------------------------------------------
5429 // This funtion calculates dE/dX within the "low" and "up" cuts.
5430 //-----------------------------------------------------------------
5431
5432 Float_t amp[200];
5433 Float_t angular[200];
5434 Float_t weight[200];
5435 Int_t index[200];
5436 Bool_t inlimit[200];
5437 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
5438 for (Int_t i=0;i<200;i++) amp[i]=10000;
5439 for (Int_t i=0;i<200;i++) angular[i]= 1;;
5440
5441
5442 //
5443 Float_t meanlog = 100.;
5444 Int_t indexde[4]={0,64,128,160};
5445
5446 Float_t amean =0;
5447 Float_t asigma =0;
5448 Float_t anc =0;
5449 Float_t anorm =0;
5450
5451 Float_t mean[4] = {0,0,0,0};
5452 Float_t sigma[4] = {1000,1000,1000,1000};
5453 Int_t nc[4] = {0,0,0,0};
5454 Float_t norm[4] = {1000,1000,1000,1000};
5455 //
5456 //
5457 fNShared =0;
5458
5459 // for (Int_t of =0; of<3; of++){
5460 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
5461 for (Int_t i =0; i<160;i++)
5462 {
5463 AliTPCTrackPoint * point = GetTrackPoint(i);
5464 if (point==0) continue;
5465 if (point->fIsShared){
5466 fNShared++;
5467 continue;
5468 }
5469 Int_t type = point->GetCPoint().GetType();
5470 if (type<0) continue;
5471 if (point->GetCPoint().GetMax()<5) continue;
5472 Float_t angley = point->GetTPoint().GetAngleY();
5473 Float_t anglez = point->GetTPoint().GetAngleZ();
5474 Float_t rsigmay = point->GetCPoint().GetSigmaY();
5475 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
5476 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
5477
5478 Float_t ampc = 0; // normalization to the number of electrons
5479 if (i>64){
5480 ampc = point->GetCPoint().GetMax();
5481 }
5482 else{
5483 ampc = point->GetCPoint().GetMax();
5484 }
5485 ampc *= 2.0; // put mean value to channel 50
5486 // ampc *= 0.565; // put mean value to channel 50
5487
5488 Float_t w = 1.;
5489 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
5490 if (i<64) {
5491 ampc /= 0.63;
5492 } else
5493 if (i>128){
5494 ampc /=1.51;
5495 }
5496 if (type<0) { //amp at the border - lower weight
5497 continue;
5498 }
5499 if (rsigma>1.5) ampc/=1.3; // if big backround
5500 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
5501 amp[i] = ampc/angular[i];
5502 weight[i] = w;
5503 anc++;
5504 }
5505
5506 TMath::Sort(159,amp,index,kFALSE);
5507 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
5508 inlimit[index[i]] = kTRUE; // take all clusters
5509 }
5510
5511 // meanlog = amp[index[Int_t(anc*0.3)]];
5512 meanlog =10000.;
5513 for (Int_t of =0; of<3; of++){
5514 Float_t sumamp=0;
5515 Float_t sumamp2=0;
5516 Float_t sumw=0;
5517 for (Int_t i=indexde[of];i<indexde[of+1];i++)
5518 {
5519 if (inlimit[i]==kFALSE) continue;
5520 Float_t ampl = amp[i];
5521 ///angular[i];
5522 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
5523 //
5524 sumw += weight[i];
5525 sumamp += weight[i]*ampl;
5526 sumamp2 += weight[i]*ampl*ampl;
5527 norm[of] += angular[i]*weight[i];
5528 nc[of]++;
5529 }
5530 if (sumw<1){
5531 SetdEdx(0);
5532 }
5533 else {
5534 norm[of] /= sumw;
5535 mean[of] = sumamp/sumw;
5536 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
5537 if (sigma[of]>0.1)
5538 sigma[of] = TMath::Sqrt(sigma[of]);
5539 else
5540 sigma[of] = 1000;
5541 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
5542 }
5543 }
5544
5545 Float_t dedx =0;
5546 fSdEdx =0;
5547 fMAngular =0;
5548 //
5549 Int_t norm2 = 0;
5550 Int_t norm3 = 0;
5551 Float_t www[3] = {12.,14.,17.};
5552 //Float_t www[3] = {1.,1.,1.};
5553
5554 for (Int_t i =0;i<3;i++){
5555 if (nc[i]>2&&nc[i]<1000){
5556 dedx += mean[i] *nc[i]*www[i]/sigma[i];
5557 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
5558 fMAngular += norm[i] *nc[i];
5559 norm2 += nc[i]*www[i]/sigma[i];
5560 norm3 += (nc[i]-2)*www[i]/sigma[i];
5561 }
5562 fDEDX[i] = mean[i];
5563 fSDEDX[i] = sigma[i];
5564 fNCDEDX[i]= nc[i];
5565 }
5566
5567 if (norm3>0){
5568 dedx /=norm2;
5569 fSdEdx /=norm3;
5570 fMAngular/=norm2;
5571 }
5572 else{
5573 SetdEdx(0);
5574 return;
5575 }
5576 // Float_t dedx1 =dedx;
5577
5578 dedx =0;
5579 Float_t norm4 = 0;
5580 for (Int_t i =0;i<3;i++){
5581 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
5582 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
5583 dedx += mean[i] *(nc[i])/(sigma[i]);
5584 norm4 += (nc[i])/(sigma[i]);
5585 }
5586 fDEDX[i] = mean[i];
5587 }
5588 if (norm4>0) dedx /= norm4;
5589
5590
5591
5592 SetdEdx(dedx);
5593
5594 //mi deDX
5595
5596}
5597
5598*/