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