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