]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCtrackerMI.cxx
Check if the sector is Active (Marian)
[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//
34acb742 22// AliTPC parallel tracker
1c53abe2 23//-------------------------------------------------------
47966a6d 24
25
26/* $Id$ */
27
cc5e9db0 28#include "Riostream.h"
6d171107 29#include <TClonesArray.h>
30#include <TFile.h>
31#include <TObjArray.h>
32#include <TTree.h>
1c53abe2 33
47966a6d 34#include "AliComplexCluster.h"
91162307 35#include "AliESD.h"
9996a03b 36#include "AliESDkink.h"
91162307 37#include "AliHelix.h"
91162307 38#include "AliRunLoader.h"
6d171107 39#include "AliTPCClustersRow.h"
40#include "AliTPCParam.h"
9996a03b 41#include "AliTPCReconstructor.h"
6d171107 42#include "AliTPCclusterMI.h"
43#include "AliTPCpolyTrack.h"
81e97e0d 44#include "AliTPCreco.h"
45#include "AliTPCseed.h"
b67e07dc 46#include "AliTPCtrackerMI.h"
6d171107 47#include "TStopwatch.h"
81e97e0d 48#include "AliTPCReconstructor.h"
49#include "AliESDkink.h"
50#include "AliPID.h"
eea478d3 51#include "TTreeStream.h"
5d837844 52#include "AliAlignObj.h"
53#include "AliTrackPointArray.h"
54
6d171107 55//
c9427e08 56
91162307 57ClassImp(AliTPCtrackerMI)
c9427e08 58
59
b67e07dc 60class AliTPCFastMath {
91162307 61public:
b67e07dc 62 AliTPCFastMath();
91162307 63 static Double_t FastAsin(Double_t x);
64 private:
b67e07dc 65 static Double_t fgFastAsin[20000]; //lookup table for fast asin computation
91162307 66};
c9427e08 67
b67e07dc 68Double_t AliTPCFastMath::fgFastAsin[20000];
2274b54b 69AliTPCFastMath gAliTPCFastMath; // needed to fill the LUT
c9427e08 70
b67e07dc 71AliTPCFastMath::AliTPCFastMath(){
72 //
73 // initialized lookup table;
91162307 74 for (Int_t i=0;i<10000;i++){
75 fgFastAsin[2*i] = TMath::ASin(i/10000.);
76 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
77 }
c9427e08 78}
79
b67e07dc 80Double_t AliTPCFastMath::FastAsin(Double_t x){
81 //
82 // return asin using lookup table
91162307 83 if (x>0){
84 Int_t index = int(x*10000);
85 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
86 }
87 x*=-1;
88 Int_t index = int(x*10000);
89 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
1c53abe2 90}
91
92
93
94
91162307 95Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
b67e07dc 96 //
97 //update track information using current cluster - track->fCurrentCluster
98
1c53abe2 99
91162307 100 AliTPCclusterMI* c =track->fCurrentCluster;
101 if (accept>0) track->fCurrentClusterIndex1 |=0x8000; //sign not accepted clusters
c9427e08 102
91162307 103 UInt_t i = track->fCurrentClusterIndex1;
1c53abe2 104
105 Int_t sec=(i&0xff000000)>>24;
91162307 106 //Int_t row = (i&0x00ff0000)>>16;
1c53abe2 107 track->fRow=(i&0x00ff0000)>>16;
108 track->fSector = sec;
109 // Int_t index = i&0xFFFF;
110 if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow();
d26d9159 111 track->SetClusterIndex2(track->fRow, i);
91162307 112 //track->fFirstPoint = row;
113 //if ( track->fLastPoint<row) track->fLastPoint =row;
114 // if (track->fRow<0 || track->fRow>160) {
115 // printf("problem\n");
116 //}
117 if (track->fFirstPoint>track->fRow)
118 track->fFirstPoint = track->fRow;
119 if (track->fLastPoint<track->fRow)
120 track->fLastPoint = track->fRow;
121
122
123 track->fClusterPointer[track->fRow] = c;
1c53abe2 124 //
125
3f82c4f2 126 Double_t angle2 = track->GetSnp()*track->GetSnp();
1c53abe2 127 //
128 //SET NEW Track Point
129 //
85e2b57d 130 if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
91162307 131 {
85e2b57d 132 angle2 = TMath::Sqrt(angle2/(1-angle2));
91162307 133 AliTPCTrackerPoint &point =*(track->GetTrackPoint(track->fRow));
1c53abe2 134 //
91162307 135 point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
136 point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
137 point.SetErrY(sqrt(track->fErrorY2));
138 point.SetErrZ(sqrt(track->fErrorZ2));
1c53abe2 139 //
91162307 140 point.SetX(track->GetX());
141 point.SetY(track->GetY());
142 point.SetZ(track->GetZ());
143 point.SetAngleY(angle2);
144 point.SetAngleZ(track->GetTgl());
145 if (point.fIsShared){
146 track->fErrorY2 *= 4;
147 track->fErrorZ2 *= 4;
148 }
149 }
150
151 Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
152 //
153 track->fErrorY2 *= 1.3;
154 track->fErrorY2 += 0.01;
155 track->fErrorZ2 *= 1.3;
156 track->fErrorZ2 += 0.005;
157 //}
158 if (accept>0) return 0;
159 if (track->GetNumberOfClusters()%20==0){
160 // if (track->fHelixIn){
161 // TClonesArray & larr = *(track->fHelixIn);
162 // Int_t ihelix = larr.GetEntriesFast();
163 // new(larr[ihelix]) AliHelix(*track) ;
164 //}
1c53abe2 165 }
91162307 166 track->fNoCluster =0;
167 return track->Update(c,chi2,i);
168}
169
170
171
172Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor,
173 Float_t cory, Float_t corz)
174{
1c53abe2 175 //
91162307 176 // decide according desired precision to accept given
177 // cluster for tracking
178 Double_t sy2=ErrY2(seed,cluster)*cory;
179 Double_t sz2=ErrZ2(seed,cluster)*corz;
180 //sy2=ErrY2(seed,cluster)*cory;
181 //sz2=ErrZ2(seed,cluster)*cory;
1c53abe2 182
91162307 183 Double_t sdistancey2 = sy2+seed->GetSigmaY2();
184 Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
185
186 Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
187 (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
188 Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
189 (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
190
191 Double_t rdistance2 = rdistancey2+rdistancez2;
192 //Int_t accept =0;
1c53abe2 193
91162307 194 if (rdistance2>16) return 3;
195
196
197 if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)
198 return 2; //suspisiouce - will be changed
199
200 if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)
201 // strict cut on overlaped cluster
202 return 2; //suspisiouce - will be changed
203
204 if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor )
205 && cluster->GetType()<0){
206 seed->fNFoundable--;
207 return 2;
1c53abe2 208 }
91162307 209 return 0;
210}
211
212
1c53abe2 213
1c53abe2 214
1c53abe2 215//_____________________________________________________________________________
f8aae377 216AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par):
1c53abe2 217AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
218{
219 //---------------------------------------------------------------------
220 // The main TPC tracker constructor
221 //---------------------------------------------------------------------
222 fInnerSec=new AliTPCSector[fkNIS];
223 fOuterSec=new AliTPCSector[fkNOS];
91162307 224
1c53abe2 225 Int_t i;
226 for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
227 for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
228
229 fN=0; fSectors=0;
230
1c53abe2 231 fSeeds=0;
232 fNtracks = 0;
91162307 233 fParam = par;
234 Int_t nrowlow = par->GetNRowLow();
235 Int_t nrowup = par->GetNRowUp();
236
237
238 for (Int_t i=0;i<nrowlow;i++){
239 fXRow[i] = par->GetPadRowRadiiLow(i);
240 fPadLength[i]= par->GetPadPitchLength(0,i);
241 fYMax[i] = fXRow[i]*TMath::Tan(0.5*par->GetInnerAngle());
242 }
243
244
245 for (Int_t i=0;i<nrowup;i++){
246 fXRow[i+nrowlow] = par->GetPadRowRadiiUp(i);
247 fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
248 fYMax[i+nrowlow] = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
249 }
250 fSeeds=0;
251 //
252 fInput = 0;
253 fOutput = 0;
254 fSeedTree = 0;
255 fTreeDebug =0;
256 fNewIO =0;
257 fDebug =0;
258 fEvent =0;
81e97e0d 259 fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
1c53abe2 260}
2fc0c115 261//________________________________________________________________________
58251ea0 262AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
263 AliTracker(t),
264 fkNIS(t.fkNIS),
265 fkNOS(t.fkNOS)
266{
2fc0c115 267 //------------------------------------
268 // dummy copy constructor
269 //------------------------------------------------------------------
270}
271AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
272 //------------------------------
273 // dummy
274 //--------------------------------------------------------------
275 return *this;
276}
1c53abe2 277//_____________________________________________________________________________
278AliTPCtrackerMI::~AliTPCtrackerMI() {
279 //------------------------------------------------------------------
280 // TPC tracker destructor
281 //------------------------------------------------------------------
282 delete[] fInnerSec;
283 delete[] fOuterSec;
284 if (fSeeds) {
285 fSeeds->Delete();
286 delete fSeeds;
287 }
81e97e0d 288 if (fDebugStreamer) delete fDebugStreamer;
1c53abe2 289}
290
91162307 291void AliTPCtrackerMI::SetIO()
292{
1c53abe2 293 //
91162307 294 fNewIO = kTRUE;
e191bb57 295 fInput = AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
d26d9159 296
e191bb57 297 fOutput = AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
d26d9159 298 if (fOutput){
299 AliTPCtrack *iotrack= new AliTPCtrack;
300 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
301 delete iotrack;
302 }
91162307 303}
1c53abe2 304
d26d9159 305
91162307 306void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
307{
1c53abe2 308
91162307 309 // set input
310 fNewIO = kFALSE;
311 fInput = 0;
312 fOutput = 0;
313 fSeedTree = 0;
314 fTreeDebug =0;
315 fInput = input;
316 if (input==0){
317 return;
318 }
319 //set output
320 fOutput = output;
321 if (output){
322 AliTPCtrack *iotrack= new AliTPCtrack;
323 // iotrack->fHelixIn = new TClonesArray("AliHelix");
324 //iotrack->fHelixOut = new TClonesArray("AliHelix");
325 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
326 delete iotrack;
327 }
328 if (output && (fDebug&2)){
329 //write the full seed information if specified in debug mode
330 //
331 fSeedTree = new TTree("Seeds","Seeds");
332 AliTPCseed * vseed = new AliTPCseed;
333 //
334 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
335 arrtr->ExpandCreateFast(160);
336 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
337 //
338 vseed->fPoints = arrtr;
339 vseed->fEPoints = arre;
340 // vseed->fClusterPoints = arrcl;
341 fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
342 delete arrtr;
343 delete arre;
344 fTreeDebug = new TTree("trackDebug","trackDebug");
345 TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
346 fTreeDebug->Branch("debug",&arrd,32000,99);
1c53abe2 347 }
1c53abe2 348
1c53abe2 349
91162307 350 //set ESD event
351 fEvent = event;
352}
1c53abe2 353
d26d9159 354void AliTPCtrackerMI::FillESD(TObjArray* arr)
91162307 355{
47966a6d 356 //
357 //
358 //fill esds using updated tracks
91162307 359 if (fEvent){
360 // write tracks to the event
361 // store index of the track
d26d9159 362 Int_t nseed=arr->GetEntriesFast();
51ad6848 363 //FindKinks(arr,fEvent);
91162307 364 for (Int_t i=0; i<nseed; i++) {
d26d9159 365 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 366 if (!pt) continue;
51ad6848 367 pt->UpdatePoints();
eea478d3 368 // pt->PropagateTo(fParam->GetInnerRadiusLow());
369 if (pt->GetKinkIndex(0)<=0){ //don't propagate daughter tracks
370 pt->PropagateTo(fParam->GetInnerRadiusLow());
371 }
51ad6848 372
373 if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
374 AliESDtrack iotrack;
375 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
376 iotrack.SetTPCPoints(pt->GetPoints());
377 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
81e97e0d 378 iotrack.SetV0Indexes(pt->GetV0Indexes());
379 // iotrack.SetTPCpid(pt->fTPCr);
51ad6848 380 //iotrack.SetTPCindex(i);
381 fEvent->AddTrack(&iotrack);
382 continue;
383 }
384
4d158c36 385 if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
d26d9159 386 AliESDtrack iotrack;
51ad6848 387 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
388 iotrack.SetTPCPoints(pt->GetPoints());
d26d9159 389 //iotrack.SetTPCindex(i);
51ad6848 390 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
81e97e0d 391 iotrack.SetV0Indexes(pt->GetV0Indexes());
392 // iotrack.SetTPCpid(pt->fTPCr);
d26d9159 393 fEvent->AddTrack(&iotrack);
a42a6bae 394 continue;
395 }
51ad6848 396 //
397 // short tracks - maybe decays
398
a42a6bae 399 if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
400 Int_t found,foundable,shared;
401 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
402 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
403 AliESDtrack iotrack;
404 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
405 //iotrack.SetTPCindex(i);
51ad6848 406 iotrack.SetTPCPoints(pt->GetPoints());
407 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
81e97e0d 408 iotrack.SetV0Indexes(pt->GetV0Indexes());
409 //iotrack.SetTPCpid(pt->fTPCr);
a42a6bae 410 fEvent->AddTrack(&iotrack);
411 continue;
412 }
413 }
414
415 if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
416 Int_t found,foundable,shared;
417 pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
418 if (found<20) continue;
419 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
420 //
421 AliESDtrack iotrack;
422 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
51ad6848 423 iotrack.SetTPCPoints(pt->GetPoints());
424 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
81e97e0d 425 iotrack.SetV0Indexes(pt->GetV0Indexes());
426 //iotrack.SetTPCpid(pt->fTPCr);
51ad6848 427 //iotrack.SetTPCindex(i);
428 fEvent->AddTrack(&iotrack);
429 continue;
430 }
431 // short tracks - secondaties
432 //
433 if ( (pt->GetNumberOfClusters()>30) ) {
434 Int_t found,foundable,shared;
435 pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
436 if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
437 AliESDtrack iotrack;
438 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
439 iotrack.SetTPCPoints(pt->GetPoints());
440 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
81e97e0d 441 iotrack.SetV0Indexes(pt->GetV0Indexes());
442 //iotrack.SetTPCpid(pt->fTPCr);
51ad6848 443 //iotrack.SetTPCindex(i);
444 fEvent->AddTrack(&iotrack);
445 continue;
446 }
447 }
448
449 if ( (pt->GetNumberOfClusters()>15)) {
450 Int_t found,foundable,shared;
451 pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
452 if (found<15) continue;
e7eb17e4 453 if (foundable<=0) continue;
51ad6848 454 if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
455 if (float(found)/float(foundable)<0.8) continue;
456 //
457 AliESDtrack iotrack;
458 iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
459 iotrack.SetTPCPoints(pt->GetPoints());
460 iotrack.SetKinkIndexes(pt->GetKinkIndexes());
81e97e0d 461 iotrack.SetV0Indexes(pt->GetV0Indexes());
462 // iotrack.SetTPCpid(pt->fTPCr);
a42a6bae 463 //iotrack.SetTPCindex(i);
464 fEvent->AddTrack(&iotrack);
465 continue;
466 }
91162307 467 }
1c53abe2 468 }
51ad6848 469 printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
d26d9159 470}
471
47966a6d 472void AliTPCtrackerMI::WriteTracks(TTree * tree)
473{
d26d9159 474 //
47966a6d 475 // write tracks from seed array to selected tree
d26d9159 476 //
477 fOutput = tree;
478 if (fOutput){
479 AliTPCtrack *iotrack= new AliTPCtrack;
480 fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
481 }
482 WriteTracks();
483}
484
485void AliTPCtrackerMI::WriteTracks()
486{
487 //
488 // write tracks to the given output tree -
489 // output specified with SetIO routine
490 if (!fSeeds) return;
491 if (!fOutput){
492 SetIO();
493 }
1c53abe2 494
91162307 495 if (fOutput){
496 AliTPCtrack *iotrack= 0;
497 Int_t nseed=fSeeds->GetEntriesFast();
982aff31 498 //for (Int_t i=0; i<nseed; i++) {
499 // iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
500 // if (iotrack) break;
501 //}
91162307 502 //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
503 TBranch * br = fOutput->GetBranch("tracks");
504 br->SetAddress(&iotrack);
505 //
506 for (Int_t i=0; i<nseed; i++) {
507 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
508 if (!pt) continue;
982aff31 509 AliTPCtrack * track = new AliTPCtrack(*pt);
510 iotrack = track;
91162307 511 pt->fLab2 =i;
512 // br->SetAddress(&iotrack);
513 fOutput->Fill();
982aff31 514 delete track;
91162307 515 iotrack =0;
516 }
982aff31 517 //fOutput->GetDirectory()->cd();
518 //fOutput->Write();
91162307 519 }
d26d9159 520 // delete iotrack;
521 //
91162307 522 if (fSeedTree){
523 //write the full seed information if specified in debug mode
524
525 AliTPCseed * vseed = new AliTPCseed;
526 //
527 TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
528 arrtr->ExpandCreateFast(160);
529 //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
530 //arrcl->ExpandCreateFast(160);
531 TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
532 //
533 vseed->fPoints = arrtr;
534 vseed->fEPoints = arre;
535 // vseed->fClusterPoints = arrcl;
536 //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
537 TBranch * brseed = fSeedTree->GetBranch("seeds");
538
539 Int_t nseed=fSeeds->GetEntriesFast();
540
541 for (Int_t i=0; i<nseed; i++) {
542 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);
543 if (!pt) continue;
544 pt->fPoints = arrtr;
545 // pt->fClusterPoints = arrcl;
546 pt->fEPoints = arre;
547 pt->RebuildSeed();
548 vseed = pt;
549 brseed->SetAddress(&vseed);
550 fSeedTree->Fill();
551 pt->fPoints = 0;
552 pt->fEPoints = 0;
553 // pt->fClusterPoints = 0;
554 }
555 fSeedTree->Write();
556 if (fTreeDebug) fTreeDebug->Write();
557 }
1c53abe2 558
91162307 559}
1c53abe2 560
1c53abe2 561
1c53abe2 562
563
91162307 564Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
565 //
566 //
567 //seed->SetErrorY2(0.1);
568 //return 0.1;
569 //calculate look-up table at the beginning
570 static Bool_t ginit = kFALSE;
571 static Float_t gnoise1,gnoise2,gnoise3;
572 static Float_t ggg1[10000];
573 static Float_t ggg2[10000];
574 static Float_t ggg3[10000];
575 static Float_t glandau1[10000];
576 static Float_t glandau2[10000];
577 static Float_t glandau3[10000];
578 //
579 static Float_t gcor01[500];
580 static Float_t gcor02[500];
581 static Float_t gcorp[500];
582 //
1c53abe2 583
91162307 584 //
585 if (ginit==kFALSE){
586 for (Int_t i=1;i<500;i++){
587 Float_t rsigma = float(i)/100.;
588 gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
589 gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
590 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
591 }
1c53abe2 592
91162307 593 //
594 for (Int_t i=3;i<10000;i++){
595 //
596 //
597 // inner sector
598 Float_t amp = float(i);
599 Float_t padlength =0.75;
600 gnoise1 = 0.0004/padlength;
601 Float_t nel = 0.268*amp;
602 Float_t nprim = 0.155*amp;
603 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
604 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
605 if (glandau1[i]>1) glandau1[i]=1;
606 glandau1[i]*=padlength*padlength/12.;
607 //
608 // outer short
609 padlength =1.;
610 gnoise2 = 0.0004/padlength;
611 nel = 0.3*amp;
612 nprim = 0.133*amp;
613 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
614 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
615 if (glandau2[i]>1) glandau2[i]=1;
616 glandau2[i]*=padlength*padlength/12.;
617 //
618 //
619 // outer long
620 padlength =1.5;
621 gnoise3 = 0.0004/padlength;
622 nel = 0.3*amp;
623 nprim = 0.133*amp;
624 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
625 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
626 if (glandau3[i]>1) glandau3[i]=1;
627 glandau3[i]*=padlength*padlength/12.;
628 //
629 }
630 ginit = kTRUE;
631 }
1c53abe2 632 //
633 //
91162307 634 //
635 Int_t amp = int(TMath::Abs(cl->GetQ()));
636 if (amp>9999) {
637 seed->SetErrorY2(1.);
638 return 1.;
639 }
1c53abe2 640 Float_t snoise2;
c9427e08 641 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
91162307 642 Int_t ctype = cl->GetType();
643 Float_t padlength= GetPadPitchLength(seed->fRow);
3f82c4f2 644 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
91162307 645 angle2 = angle2/(1-angle2);
646 //
647 //cluster "quality"
648 Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
649 Float_t res;
1c53abe2 650 //
1c53abe2 651 if (fSectors==fInnerSec){
91162307 652 snoise2 = gnoise1;
653 res = ggg1[amp]*z+glandau1[amp]*angle2;
654 if (ctype==0) res *= gcor01[rsigmay];
655 if ((ctype>0)){
656 res+=0.002;
657 res*= gcorp[rsigmay];
658 }
1c53abe2 659 }
660 else {
91162307 661 if (padlength<1.1){
662 snoise2 = gnoise2;
663 res = ggg2[amp]*z+glandau2[amp]*angle2;
664 if (ctype==0) res *= gcor02[rsigmay];
665 if ((ctype>0)){
666 res+=0.002;
667 res*= gcorp[rsigmay];
668 }
669 }
670 else{
671 snoise2 = gnoise3;
672 res = ggg3[amp]*z+glandau3[amp]*angle2;
673 if (ctype==0) res *= gcor02[rsigmay];
674 if ((ctype>0)){
675 res+=0.002;
676 res*= gcorp[rsigmay];
677 }
678 }
679 }
1c53abe2 680
91162307 681 if (ctype<0){
682 res+=0.005;
683 res*=2.4; // overestimate error 2 times
684 }
685 res+= snoise2;
686
1c53abe2 687 if (res<2*snoise2)
91162307 688 res = 2*snoise2;
689
690 seed->SetErrorY2(res);
1c53abe2 691 return res;
1c53abe2 692
693
91162307 694}
c9427e08 695
696
697
91162307 698Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
699 //
700 //
701 //seed->SetErrorY2(0.1);
702 //return 0.1;
703 //calculate look-up table at the beginning
704 static Bool_t ginit = kFALSE;
705 static Float_t gnoise1,gnoise2,gnoise3;
706 static Float_t ggg1[10000];
707 static Float_t ggg2[10000];
708 static Float_t ggg3[10000];
709 static Float_t glandau1[10000];
710 static Float_t glandau2[10000];
711 static Float_t glandau3[10000];
712 //
713 static Float_t gcor01[1000];
714 static Float_t gcor02[1000];
715 static Float_t gcorp[1000];
1627d1c4 716 //
1627d1c4 717
91162307 718 //
719 if (ginit==kFALSE){
720 for (Int_t i=1;i<1000;i++){
721 Float_t rsigma = float(i)/100.;
722 gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
723 gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
724 gcorp[i] = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
725 }
1c53abe2 726
91162307 727 //
728 for (Int_t i=3;i<10000;i++){
729 //
730 //
731 // inner sector
732 Float_t amp = float(i);
733 Float_t padlength =0.75;
734 gnoise1 = 0.0004/padlength;
735 Float_t nel = 0.268*amp;
736 Float_t nprim = 0.155*amp;
737 ggg1[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
738 glandau1[i] = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
739 if (glandau1[i]>1) glandau1[i]=1;
740 glandau1[i]*=padlength*padlength/12.;
741 //
742 // outer short
743 padlength =1.;
744 gnoise2 = 0.0004/padlength;
745 nel = 0.3*amp;
746 nprim = 0.133*amp;
747 ggg2[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
748 glandau2[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
749 if (glandau2[i]>1) glandau2[i]=1;
750 glandau2[i]*=padlength*padlength/12.;
751 //
752 //
753 // outer long
754 padlength =1.5;
755 gnoise3 = 0.0004/padlength;
756 nel = 0.3*amp;
757 nprim = 0.133*amp;
758 ggg3[i] = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
759 glandau3[i] = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
760 if (glandau3[i]>1) glandau3[i]=1;
761 glandau3[i]*=padlength*padlength/12.;
762 //
763 }
764 ginit = kTRUE;
765 }
766 //
767 //
768 //
769 Int_t amp = int(TMath::Abs(cl->GetQ()));
770 if (amp>9999) {
771 seed->SetErrorY2(1.);
772 return 1.;
773 }
774 Float_t snoise2;
775 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
776 Int_t ctype = cl->GetType();
777 Float_t padlength= GetPadPitchLength(seed->fRow);
778 //
3f82c4f2 779 Double_t angle2 = seed->GetSnp()*seed->GetSnp();
91162307 780 // if (angle2<0.6) angle2 = 0.6;
781 angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2));
782 //
783 //cluster "quality"
784 Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
785 Float_t res;
786 //
787 if (fSectors==fInnerSec){
788 snoise2 = gnoise1;
789 res = ggg1[amp]*z+glandau1[amp]*angle2;
790 if (ctype==0) res *= gcor01[rsigmaz];
791 if ((ctype>0)){
792 res+=0.002;
793 res*= gcorp[rsigmaz];
794 }
795 }
796 else {
797 if (padlength<1.1){
798 snoise2 = gnoise2;
799 res = ggg2[amp]*z+glandau2[amp]*angle2;
800 if (ctype==0) res *= gcor02[rsigmaz];
801 if ((ctype>0)){
802 res+=0.002;
803 res*= gcorp[rsigmaz];
804 }
805 }
806 else{
807 snoise2 = gnoise3;
808 res = ggg3[amp]*z+glandau3[amp]*angle2;
809 if (ctype==0) res *= gcor02[rsigmaz];
810 if ((ctype>0)){
811 res+=0.002;
812 res*= gcorp[rsigmaz];
813 }
814 }
815 }
816
817 if (ctype<0){
818 res+=0.002;
819 res*=1.3;
820 }
821 if ((ctype<0) &&amp<70){
822 res+=0.002;
823 res*=1.3;
824 }
825 res += snoise2;
826 if (res<2*snoise2)
827 res = 2*snoise2;
828 if (res>3) res =3;
829 seed->SetErrorZ2(res);
830 return res;
831}
832
833
834
835/*
836Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
837 //
838 //
839 //seed->SetErrorZ2(0.1);
840 //return 0.1;
841
842 Float_t snoise2;
843 Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
844 //
845 Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
846 Int_t ctype = cl->GetType();
847 Float_t amp = TMath::Abs(cl->GetQ());
848
849 Float_t nel;
850 Float_t nprim;
851 //
852 Float_t landau=2 ; //landau fluctuation part
853 Float_t gg=2; // gg fluctuation part
854 Float_t padlength= GetPadPitchLength(seed->GetX());
855
856 if (fSectors==fInnerSec){
857 snoise2 = 0.0004/padlength;
858 nel = 0.268*amp;
859 nprim = 0.155*amp;
860 gg = (2+0.001*nel/(padlength*padlength))/nel;
861 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
862 if (landau>1) landau=1;
863 }
864 else {
865 snoise2 = 0.0004/padlength;
866 nel = 0.3*amp;
867 nprim = 0.133*amp;
868 gg = (2+0.0008*nel/(padlength*padlength))/nel;
869 landau = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
870 if (landau>1) landau=1;
871 }
872 Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
873
874 //
875 Float_t angle2 = seed->GetSnp()*seed->GetSnp();
876 angle2 = TMath::Sqrt((1-angle2));
877 if (angle2<0.6) angle2 = 0.6;
878 //angle2 = 1;
879
880 Float_t angle = seed->GetTgl()/angle2;
881 Float_t angular = landau*angle*angle*padlength*padlength/12.;
882 Float_t res = sdiff + angular;
883
884
885 if ((ctype==0) && (fSectors ==fOuterSec))
886 res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
887
888 if ((ctype==0) && (fSectors ==fInnerSec))
889 res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
890
891 if ((ctype>0)){
892 res+=0.005;
893 res*= TMath::Power(rsigmaz+0.5,1.5); //0.31+0.147*ctype;
894 }
895 if (ctype<0){
896 res+=0.002;
897 res*=1.3;
898 }
899 if ((ctype<0) &&amp<70){
900 res+=0.002;
901 res*=1.3;
902 }
903 res += snoise2;
904 if (res<2*snoise2)
905 res = 2*snoise2;
906
907 seed->SetErrorZ2(res);
908 return res;
909}
910*/
911
912
913
1c53abe2 914
c9427e08 915void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
916{
917 //rotate to track "local coordinata
918 Float_t x = seed->GetX();
919 Float_t y = seed->GetY();
920 Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
91162307 921
c9427e08 922 if (y > ymax) {
923 seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
924 if (!seed->Rotate(fSectors->GetAlpha()))
925 return;
926 } else if (y <-ymax) {
927 seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
928 if (!seed->Rotate(-fSectors->GetAlpha()))
929 return;
930 }
1c53abe2 931
c9427e08 932}
1c53abe2 933
934
935
1c53abe2 936//_____________________________________________________________________________
b67e07dc 937Double_t AliTPCtrackerMI::F1old(Double_t x1,Double_t y1,
1c53abe2 938 Double_t x2,Double_t y2,
939 Double_t x3,Double_t y3)
940{
941 //-----------------------------------------------------------------
942 // Initial approximation of the track curvature
943 //-----------------------------------------------------------------
944 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
945 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
946 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
947 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
948 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
949
950 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
91162307 951 if ( xr*xr+yr*yr<=0.00000000000001) return 100;
1c53abe2 952 return -xr*yr/sqrt(xr*xr+yr*yr);
953}
954
955
91162307 956
1c53abe2 957//_____________________________________________________________________________
b67e07dc 958Double_t AliTPCtrackerMI::F1(Double_t x1,Double_t y1,
91162307 959 Double_t x2,Double_t y2,
960 Double_t x3,Double_t y3)
961{
962 //-----------------------------------------------------------------
963 // Initial approximation of the track curvature
964 //-----------------------------------------------------------------
965 x3 -=x1;
966 x2 -=x1;
967 y3 -=y1;
968 y2 -=y1;
969 //
970 Double_t det = x3*y2-x2*y3;
971 if (det==0) {
972 return 100;
973 }
974 //
975 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
976 Double_t x0 = x3*0.5-y3*u;
977 Double_t y0 = y3*0.5+x3*u;
978 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
979 if (det<0) c2*=-1;
980 return c2;
981}
982
983
b67e07dc 984Double_t AliTPCtrackerMI::F2(Double_t x1,Double_t y1,
1c53abe2 985 Double_t x2,Double_t y2,
986 Double_t x3,Double_t y3)
91162307 987{
988 //-----------------------------------------------------------------
989 // Initial approximation of the track curvature
990 //-----------------------------------------------------------------
991 x3 -=x1;
992 x2 -=x1;
993 y3 -=y1;
994 y2 -=y1;
995 //
996 Double_t det = x3*y2-x2*y3;
997 if (det==0) {
998 return 100;
999 }
1000 //
1001 Double_t u = 0.5* (x2*(x2-x3)+y2*(y2-y3))/det;
1002 Double_t x0 = x3*0.5-y3*u;
1003 Double_t y0 = y3*0.5+x3*u;
1004 Double_t c2 = 1/TMath::Sqrt(x0*x0+y0*y0);
1005 if (det<0) c2*=-1;
1006 x0+=x1;
1007 x0*=c2;
1008 return x0;
1009}
1010
1011
1012
1013//_____________________________________________________________________________
b67e07dc 1014Double_t AliTPCtrackerMI::F2old(Double_t x1,Double_t y1,
91162307 1015 Double_t x2,Double_t y2,
1016 Double_t x3,Double_t y3)
1c53abe2 1017{
1018 //-----------------------------------------------------------------
1019 // Initial approximation of the track curvature times center of curvature
1020 //-----------------------------------------------------------------
1021 Double_t d=(x2-x1)*(y3-y2)-(x3-x2)*(y2-y1);
1022 Double_t a=0.5*((y3-y2)*(y2*y2-y1*y1+x2*x2-x1*x1)-
1023 (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
1024 Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
1025 (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
1026
1027 Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
1028
1029 return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
1030}
1031
1032//_____________________________________________________________________________
b67e07dc 1033Double_t AliTPCtrackerMI::F3(Double_t x1,Double_t y1,
1c53abe2 1034 Double_t x2,Double_t y2,
1035 Double_t z1,Double_t z2)
1036{
1037 //-----------------------------------------------------------------
1038 // Initial approximation of the tangent of the track dip angle
1039 //-----------------------------------------------------------------
1040 return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1041}
1042
1043
b67e07dc 1044Double_t AliTPCtrackerMI::F3n(Double_t x1,Double_t y1,
91162307 1045 Double_t x2,Double_t y2,
1046 Double_t z1,Double_t z2, Double_t c)
1c53abe2 1047{
91162307 1048 //-----------------------------------------------------------------
1049 // Initial approximation of the tangent of the track dip angle
1050 //-----------------------------------------------------------------
1051
1052 // Double_t angle1;
1053
1054 //angle1 = (z1-z2)*c/(TMath::ASin(c*x1-ni)-TMath::ASin(c*x2-ni));
1c53abe2 1055 //
91162307 1056 Double_t d = TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
1057 if (TMath::Abs(d*c*0.5)>1) return 0;
1058 // Double_t angle2 = TMath::ASin(d*c*0.5);
b67e07dc 1059 // Double_t angle2 = AliTPCFastMath::FastAsin(d*c*0.5);
1060 Double_t angle2 = (d*c*0.5>0.1)? TMath::ASin(d*c*0.5): AliTPCFastMath::FastAsin(d*c*0.5);
91162307 1061
1062 angle2 = (z1-z2)*c/(angle2*2.);
1063 return angle2;
1064}
1065
1066Bool_t AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z)
1067{//-----------------------------------------------------------------
1068 // This function find proloncation of a track to a reference plane x=x2.
1069 //-----------------------------------------------------------------
1070
1071 Double_t dx=x2-x1;
1072
1073 if (TMath::Abs(x[4]*x1 - x[2]) >= 0.999) {
1074 return kFALSE;
1c53abe2 1075 }
f8aae377 1076
91162307 1077 Double_t c1=x[4]*x1 - x[2], r1=sqrt(1.- c1*c1);
1078 Double_t c2=x[4]*x2 - x[2], r2=sqrt(1.- c2*c2);
1079 y = x[0];
1080 z = x[1];
1081
1082 Double_t dy = dx*(c1+c2)/(r1+r2);
1083 Double_t dz = 0;
1084 //
1085 Double_t delta = x[4]*dx*(c1+c2)/(c1*r2 + c2*r1);
1086
1087 if (TMath::Abs(delta)>0.01){
1088 dz = x[3]*TMath::ASin(delta)/x[4];
1089 }else{
b67e07dc 1090 dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
91162307 1091 }
1092
b67e07dc 1093 //dz = x[3]*AliTPCFastMath::FastAsin(delta)/x[4];
f8aae377 1094
91162307 1095 y+=dy;
1096 z+=dz;
1097
1098 return kTRUE;
1c53abe2 1099}
1100
d26d9159 1101Int_t AliTPCtrackerMI::LoadClusters (TTree *tree)
1102{
1103 //
1104 //
1105 fInput = tree;
1106 return LoadClusters();
1107}
91162307 1108
1109Int_t AliTPCtrackerMI::LoadClusters()
1c53abe2 1110{
1111 //
1112 // load clusters to the memory
91162307 1113 AliTPCClustersRow *clrow= new AliTPCClustersRow;
1114 clrow->SetClass("AliTPCclusterMI");
1115 clrow->SetArray(0);
1116 clrow->GetArray()->ExpandCreateFast(10000);
1117 //
1118 // TTree * tree = fClustersArray.GetTree();
1119
1120 TTree * tree = fInput;
1121 TBranch * br = tree->GetBranch("Segment");
1122 br->SetAddress(&clrow);
1123 //
1124 Int_t j=Int_t(tree->GetEntries());
1c53abe2 1125 for (Int_t i=0; i<j; i++) {
91162307 1126 br->GetEntry(i);
1127 //
1128 Int_t sec,row;
1129 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
0201b65c 1130 for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
1131 Transform((AliCluster*)(clrow->GetArray()->At(icl)));
1132 }
91162307 1133 //
1134 AliTPCRow * tpcrow=0;
1135 Int_t left=0;
1136 if (sec<fkNIS*2){
1137 tpcrow = &(fInnerSec[sec%fkNIS][row]);
1138 left = sec/fkNIS;
1139 }
1140 else{
1141 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
1142 left = (sec-fkNIS*2)/fkNOS;
1143 }
1144 if (left ==0){
1145 tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
1146 tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
1147 for (Int_t i=0;i<tpcrow->fN1;i++)
1148 tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1149 }
1150 if (left ==1){
1151 tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
1152 tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
1153 for (Int_t i=0;i<tpcrow->fN2;i++)
1154 tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
1155 }
1c53abe2 1156 }
91162307 1157 //
1158 delete clrow;
1159 LoadOuterSectors();
1160 LoadInnerSectors();
1161 return 0;
1c53abe2 1162}
1163
1164
91162307 1165void AliTPCtrackerMI::UnloadClusters()
1166{
1167 //
1168 // unload clusters from the memory
1169 //
1170 Int_t nrows = fOuterSec->GetNRows();
1171 for (Int_t sec = 0;sec<fkNOS;sec++)
1172 for (Int_t row = 0;row<nrows;row++){
1173 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
982aff31 1174 // if (tpcrow){
1175 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1176 // if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1177 //}
1178 tpcrow->ResetClusters();
1c53abe2 1179 }
91162307 1180 //
1181 nrows = fInnerSec->GetNRows();
1182 for (Int_t sec = 0;sec<fkNIS;sec++)
1183 for (Int_t row = 0;row<nrows;row++){
1184 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
982aff31 1185 //if (tpcrow){
1186 // if (tpcrow->fClusters1) delete []tpcrow->fClusters1;
1187 //if (tpcrow->fClusters2) delete []tpcrow->fClusters2;
1188 //}
1189 tpcrow->ResetClusters();
91162307 1190 }
1191
1192 return ;
1c53abe2 1193}
1194
0201b65c 1195void AliTPCtrackerMI::Transform(AliCluster * cluster){
1196 //
1197 //
1198 //
1199 //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
1200 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
e7eb17e4 1201 //TGeoHMatrix mat;
0201b65c 1202 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1203 Double_t posC[3];
e7eb17e4 1204 //mat.LocalToMaster(pos,posC);
0201b65c 1205 mat->LocalToMaster(pos,posC);
1206 cluster->SetX(posC[0]);
1207 cluster->SetY(posC[1]);
1208 cluster->SetZ(posC[2]);
1209}
1c53abe2 1210
1211//_____________________________________________________________________________
91162307 1212Int_t AliTPCtrackerMI::LoadOuterSectors() {
1c53abe2 1213 //-----------------------------------------------------------------
91162307 1214 // This function fills outer TPC sectors with clusters.
1c53abe2 1215 //-----------------------------------------------------------------
91162307 1216 Int_t nrows = fOuterSec->GetNRows();
1217 UInt_t index=0;
1218 for (Int_t sec = 0;sec<fkNOS;sec++)
1219 for (Int_t row = 0;row<nrows;row++){
1220 AliTPCRow* tpcrow = &(fOuterSec[sec%fkNOS][row]);
1221 Int_t sec2 = sec+2*fkNIS;
1222 //left
1223 Int_t ncl = tpcrow->fN1;
1224 while (ncl--) {
1225 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1226 index=(((sec2<<8)+row)<<16)+ncl;
1227 tpcrow->InsertCluster(c,index);
1228 }
1229 //right
1230 ncl = tpcrow->fN2;
1231 while (ncl--) {
1232 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1233 index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
1234 tpcrow->InsertCluster(c,index);
1235 }
1236 //
1237 // write indexes for fast acces
1238 //
1239 for (Int_t i=0;i<510;i++)
1240 tpcrow->fFastCluster[i]=-1;
1241 for (Int_t i=0;i<tpcrow->GetN();i++){
1242 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1243 tpcrow->fFastCluster[zi]=i; // write index
1244 }
1245 Int_t last = 0;
1246 for (Int_t i=0;i<510;i++){
1247 if (tpcrow->fFastCluster[i]<0)
1248 tpcrow->fFastCluster[i] = last;
1249 else
1250 last = tpcrow->fFastCluster[i];
1251 }
1252 }
1253 fN=fkNOS;
1254 fSectors=fOuterSec;
1255 return 0;
1256}
1257
1258
1259//_____________________________________________________________________________
1260Int_t AliTPCtrackerMI::LoadInnerSectors() {
1261 //-----------------------------------------------------------------
1262 // This function fills inner TPC sectors with clusters.
1263 //-----------------------------------------------------------------
1264 Int_t nrows = fInnerSec->GetNRows();
1265 UInt_t index=0;
1266 for (Int_t sec = 0;sec<fkNIS;sec++)
1267 for (Int_t row = 0;row<nrows;row++){
1268 AliTPCRow* tpcrow = &(fInnerSec[sec%fkNIS][row]);
1269 //
1270 //left
1271 Int_t ncl = tpcrow->fN1;
1272 while (ncl--) {
1273 AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
1274 index=(((sec<<8)+row)<<16)+ncl;
1275 tpcrow->InsertCluster(c,index);
1276 }
1277 //right
1278 ncl = tpcrow->fN2;
1279 while (ncl--) {
1280 AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
1281 index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
1282 tpcrow->InsertCluster(c,index);
1283 }
1284 //
1285 // write indexes for fast acces
1286 //
1287 for (Int_t i=0;i<510;i++)
1288 tpcrow->fFastCluster[i]=-1;
1289 for (Int_t i=0;i<tpcrow->GetN();i++){
1290 Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
1291 tpcrow->fFastCluster[zi]=i; // write index
1292 }
1293 Int_t last = 0;
1294 for (Int_t i=0;i<510;i++){
1295 if (tpcrow->fFastCluster[i]<0)
1296 tpcrow->fFastCluster[i] = last;
1297 else
1298 last = tpcrow->fFastCluster[i];
1299 }
1c53abe2 1300
91162307 1301 }
1302
1c53abe2 1303 fN=fkNIS;
1304 fSectors=fInnerSec;
91162307 1305 return 0;
1306}
1307
1308
1309
1310//_________________________________________________________________________
1311AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
1312 //--------------------------------------------------------------------
1313 // Return pointer to a given cluster
1314 //--------------------------------------------------------------------
e7eb17e4 1315 if (index<0) return 0; // no cluster
91162307 1316 Int_t sec=(index&0xff000000)>>24;
1317 Int_t row=(index&0x00ff0000)>>16;
d26d9159 1318 Int_t ncl=(index&0x00007fff)>>00;
91162307 1319
1320 const AliTPCRow * tpcrow=0;
1321 AliTPCclusterMI * clrow =0;
3da363a1 1322
ad23441a 1323 if (sec<0 || sec>=fkNIS*4) {
1324 AliWarning(Form("Wrong sector %d",sec));
1325 return 0x0;
1326 }
1327
91162307 1328 if (sec<fkNIS*2){
1329 tpcrow = &(fInnerSec[sec%fkNIS][row]);
3da363a1 1330 if (tpcrow==0) return 0;
1331
1332 if (sec<fkNIS) {
1333 if (tpcrow->fN1<=ncl) return 0;
91162307 1334 clrow = tpcrow->fClusters1;
3da363a1 1335 }
1336 else {
1337 if (tpcrow->fN2<=ncl) return 0;
91162307 1338 clrow = tpcrow->fClusters2;
3da363a1 1339 }
91162307 1340 }
3da363a1 1341 else {
91162307 1342 tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
3da363a1 1343 if (tpcrow==0) return 0;
1344
1345 if (sec-2*fkNIS<fkNOS) {
1346 if (tpcrow->fN1<=ncl) return 0;
91162307 1347 clrow = tpcrow->fClusters1;
3da363a1 1348 }
1349 else {
1350 if (tpcrow->fN2<=ncl) return 0;
91162307 1351 clrow = tpcrow->fClusters2;
3da363a1 1352 }
91162307 1353 }
3da363a1 1354
91162307 1355 return &(clrow[ncl]);
1356
1c53abe2 1357}
1358
91162307 1359
1360
1c53abe2 1361Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
1362 //-----------------------------------------------------------------
1363 // This function tries to find a track prolongation to next pad row
1364 //-----------------------------------------------------------------
1c53abe2 1365 //
91162307 1366 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
4d158c36 1367 AliTPCclusterMI *cl=0;
1368 Int_t tpcindex= t.GetClusterIndex2(nr);
1369 //
1370 // update current shape info every 5 pad-row
1371 // if ( (nr%5==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1372 GetShape(&t,nr);
1373 //}
1374 //
1375 if (fIteration>0 && tpcindex>=-1){ //if we have already clusters
1376 //
1377 if (tpcindex==-1) return 0; //track in dead zone
1378 if (tpcindex>0){ //
1379 cl = t.fClusterPointer[nr];
e0656451 1380 if ( (cl==0) ) cl = GetClusterMI(tpcindex);
4d158c36 1381 t.fCurrentClusterIndex1 = tpcindex;
1382 }
1383 if (cl){
1384 Int_t relativesector = ((tpcindex&0xff000000)>>24)%18; // if previously accepted cluster in different sector
1385 Float_t angle = relativesector*fSectors->GetAlpha()+fSectors->GetAlphaShift();
1386 //
1387 if (angle<-TMath::Pi()) angle += 2*TMath::Pi();
1388 if (angle>=TMath::Pi()) angle -= 2*TMath::Pi();
1389
1390 if (TMath::Abs(angle-t.GetAlpha())>0.001){
1391 Double_t rotation = angle-t.GetAlpha();
1392 t.fRelativeSector= relativesector;
3f82c4f2 1393 if (!t.Rotate(rotation)) return 0;
4d158c36 1394 }
3f82c4f2 1395 if (!t.PropagateTo(x)) return 0;
4d158c36 1396 //
1397 t.fCurrentCluster = cl;
1398 t.fRow = nr;
1399 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1400 if ((tpcindex&0x8000)==0) accept =0;
1401 if (accept<3) {
1402 //if founded cluster is acceptible
1403 if (cl->IsUsed(11)) { // id cluster is shared inrease uncertainty
1404 t.fErrorY2 += 0.03;
1405 t.fErrorZ2 += 0.03;
1406 t.fErrorY2 *= 3;
1407 t.fErrorZ2 *= 3;
1408 }
1409 t.fNFoundable++;
1410 UpdateTrack(&t,accept);
1411 return 1;
1412 }
1413 }
1627d1c4 1414 }
3f82c4f2 1415 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0; // cut on angle
1416 if (fIteration>1){
1417 // not look for new cluster during refitting
1418 t.fNFoundable++;
1419 return 0;
1420 }
91162307 1421 //
4d158c36 1422 UInt_t index=0;
ca142b1f 1423 // if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
4d158c36 1424 Double_t y=t.GetYat(x);
91162307 1425 if (TMath::Abs(y)>ymax){
1426 if (y > ymax) {
1427 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1428 if (!t.Rotate(fSectors->GetAlpha()))
1429 return 0;
1430 } else if (y <-ymax) {
1431 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1432 if (!t.Rotate(-fSectors->GetAlpha()))
1433 return 0;
1434 }
4d158c36 1435 //return 1;
91162307 1436 }
1437 //
4d158c36 1438 if (!t.PropagateTo(x)) {
1439 if (fIteration==0) t.fRemoval = 10;
1440 return 0;
91162307 1441 }
4d158c36 1442 y=t.GetY();
1443 Double_t z=t.GetZ();
1444 //
5afd7dbd 1445 if (!IsActive(t.fRelativeSector,nr)) return 0;
91162307 1446 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1447 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1448 Double_t roady =1.;
1449 Double_t roadz = 1.;
1450 //
1c53abe2 1451 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1452 t.fInDead = kTRUE;
91162307 1453 t.SetClusterIndex2(nr,-1);
1c53abe2 1454 return 0;
1455 }
1456 else
1457 {
3f82c4f2 1458 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1459 t.fNFoundable++;
1627d1c4 1460 else
1461 return 0;
1c53abe2 1462 }
1463 //calculate
91162307 1464 if (krow) {
1465 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1466 cl = krow.FindNearest2(y,z,roady,roadz,index);
1467 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1468 }
91162307 1469 if (cl) {
1470 t.fCurrentCluster = cl;
1471 t.fRow = nr;
4d158c36 1472 if (fIteration==2&&cl->IsUsed(10)) return 0;
91162307 1473 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
4d158c36 1474 if (fIteration==2&&cl->IsUsed(11)) {
1475 t.fErrorY2 += 0.03;
1476 t.fErrorZ2 += 0.03;
1477 t.fErrorY2 *= 3;
1478 t.fErrorZ2 *= 3;
1479 }
d26d9159 1480 /*
91162307 1481 if (t.fCurrentCluster->IsUsed(10)){
1482 //
1483 //
c9427e08 1484
91162307 1485 t.fNShared++;
1486 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1487 t.fRemoval =10;
1488 return 0;
1489 }
1490 }
d26d9159 1491 */
91162307 1492 if (accept<3) UpdateTrack(&t,accept);
c9427e08 1493
91162307 1494 } else {
982aff31 1495 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
91162307 1496
1497 }
1498 return 1;
1499}
c9427e08 1500
91162307 1501Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1502 //-----------------------------------------------------------------
1503 // This function tries to find a track prolongation to next pad row
1504 //-----------------------------------------------------------------
1505 //
1506 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1507 Double_t y,z;
1508 if (!t.GetProlongation(x,y,z)) {
1509 t.fRemoval = 10;
1510 return 0;
1511 }
1512 //
1513 //
1514 if (TMath::Abs(y)>ymax){
91162307 1515
1c53abe2 1516 if (y > ymax) {
1517 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1518 if (!t.Rotate(fSectors->GetAlpha()))
1519 return 0;
1520 } else if (y <-ymax) {
1521 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1522 if (!t.Rotate(-fSectors->GetAlpha()))
1523 return 0;
91162307 1524 }
1525 if (!t.PropagateTo(x)) {
1526 return 0;
1527 }
1528 t.GetProlongation(x,y,z);
1529 }
1530 //
1531 // update current shape info every 3 pad-row
1532 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1533 // t.fCurrentSigmaY = GetSigmaY(&t);
1534 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1535 GetShape(&t,nr);
1536 }
1537 //
1538 AliTPCclusterMI *cl=0;
1539 UInt_t index=0;
1540
1541
1542 //Int_t nr2 = nr;
1543 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1544 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1545 Double_t roady =1.;
1546 Double_t roadz = 1.;
1547 //
1548 Int_t row = nr;
1549 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1550 t.fInDead = kTRUE;
1551 t.SetClusterIndex2(row,-1);
1552 return 0;
1553 }
1554 else
1555 {
d7a11555 1556 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1c53abe2 1557 }
91162307 1558 //calculate
1559
1560 if ((cl==0)&&(krow)) {
1561 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1562 cl = krow.FindNearest2(y,z,roady,roadz,index);
1563
1564 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1565 }
1566
1567 if (cl) {
1568 t.fCurrentCluster = cl;
1569 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1570 //if (accept<3){
1571 t.SetClusterIndex2(row,index);
1572 t.fClusterPointer[row] = cl;
1573 //}
1c53abe2 1574 }
1575 return 1;
1576}
1577
1578
91162307 1579
5d837844 1580//_________________________________________________________________________
1581Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1582{
1583 // Get track space point by index
1584 // return false in case the cluster doesn't exist
1585 AliTPCclusterMI *cl = GetClusterMI(index);
1586 if (!cl) return kFALSE;
1587 Int_t sector = (index&0xff000000)>>24;
0201b65c 1588 // Int_t row = (index&0x00ff0000)>>16;
5d837844 1589 Float_t xyz[3];
0201b65c 1590 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1591 xyz[0] = cl->GetX();
5d837844 1592 xyz[1] = cl->GetY();
1593 xyz[2] = cl->GetZ();
1594 Float_t sin,cos;
1595 fParam->AdjustCosSin(sector,cos,sin);
1596 Float_t x = cos*xyz[0]-sin*xyz[1];
1597 Float_t y = cos*xyz[1]+sin*xyz[0];
1598 Float_t cov[6];
1599 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1600 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1601 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1602 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1603 cov[0] = sin*sin*sigmaY2;
1604 cov[1] = -sin*cos*sigmaY2;
1605 cov[2] = 0.;
1606 cov[3] = cos*cos*sigmaY2;
1607 cov[4] = 0.;
1608 cov[5] = sigmaZ2;
1609 p.SetXYZ(x,y,xyz[2],cov);
1610 AliAlignObj::ELayerID iLayer;
1611 Int_t idet;
1612 if (sector < fParam->GetNInnerSector()) {
1613 iLayer = AliAlignObj::kTPC1;
1614 idet = sector;
1615 }
1616 else {
1617 iLayer = AliAlignObj::kTPC2;
1618 idet = sector - fParam->GetNInnerSector();
1619 }
1620 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1621 p.SetVolumeID(volid);
1622 return kTRUE;
1623}
1624
1625
1626
91162307 1627Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1c53abe2 1628 //-----------------------------------------------------------------
1629 // This function tries to find a track prolongation to next pad row
1630 //-----------------------------------------------------------------
1631 t.fCurrentCluster = 0;
1632 t.fCurrentClusterIndex1 = 0;
1c53abe2 1633
1634 Double_t xt=t.GetX();
91162307 1635 Int_t row = GetRowNumber(xt)-1;
1636 Double_t ymax= GetMaxY(nr);
1637
1c53abe2 1638 if (row < nr) return 1; // don't prolongate if not information until now -
ca142b1f 1639// if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1640// t.fRemoval =10;
1641// return 0; // not prolongate strongly inclined tracks
1642// }
1643// if (TMath::Abs(t.GetSnp())>0.95) {
1644// t.fRemoval =10;
1645// return 0; // not prolongate strongly inclined tracks
1646// }// patch 28 fev 06
91162307 1647
1648 Double_t x= GetXrow(nr);
1649 Double_t y,z;
1650 //t.PropagateTo(x+0.02);
1651 //t.PropagateTo(x+0.01);
1627d1c4 1652 if (!t.PropagateTo(x)){
1627d1c4 1653 return 0;
1654 }
1c53abe2 1655 //
91162307 1656 y=t.GetY();
1657 z=t.GetZ();
1c53abe2 1658
91162307 1659 if (TMath::Abs(y)>ymax){
1660 if (y > ymax) {
1661 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1662 if (!t.Rotate(fSectors->GetAlpha()))
1663 return 0;
1664 } else if (y <-ymax) {
1665 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1666 if (!t.Rotate(-fSectors->GetAlpha()))
1667 return 0;
1668 }
982aff31 1669 // if (!t.PropagateTo(x)){
1670 // return 0;
1671 //}
1672 return 1;
1673 //y = t.GetY();
1c53abe2 1674 }
91162307 1675 //
3f82c4f2 1676 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
5afd7dbd 1677 if (!IsActive(t.fRelativeSector,nr)) return 0;
91162307 1678 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1c53abe2 1679
1680 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1681 t.fInDead = kTRUE;
91162307 1682 t.SetClusterIndex2(nr,-1);
1c53abe2 1683 return 0;
1684 }
1685 else
1686 {
3f82c4f2 1687 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.fNFoundable++;
1627d1c4 1688 else
1689 return 0;
1c53abe2 1690 }
1c53abe2 1691
91162307 1692 // update current
1693 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1694 // t.fCurrentSigmaY = GetSigmaY(&t);
1695 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1696 GetShape(&t,nr);
1697 }
1c53abe2 1698
91162307 1699 AliTPCclusterMI *cl=0;
d184f295 1700 Int_t index=0;
91162307 1701 //
1702 Double_t roady = 1.;
1703 Double_t roadz = 1.;
1704 //
d26d9159 1705
1706 if (!cl){
1707 index = t.GetClusterIndex2(nr);
1708 if ( (index>0) && (index&0x8000)==0){
1709 cl = t.fClusterPointer[nr];
1710 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1711 t.fCurrentClusterIndex1 = index;
1712 if (cl) {
1713 t.fCurrentCluster = cl;
1714 return 1;
1715 }
1716 }
1717 }
1718
3d172d79 1719 // if (index<0) return 0;
1720 UInt_t uindex = TMath::Abs(index);
d184f295 1721
91162307 1722 if (krow) {
d184f295 1723 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1724 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
91162307 1725 }
d26d9159 1726
d184f295 1727 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
d26d9159 1728 t.fCurrentCluster = cl;
1729
91162307 1730 return 1;
1731}
1c53abe2 1732
1c53abe2 1733
91162307 1734Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1735 //-----------------------------------------------------------------
1736 // This function tries to find a track prolongation to next pad row
1737 //-----------------------------------------------------------------
1c53abe2 1738
91162307 1739 //update error according neighborhoud
1c53abe2 1740
91162307 1741 if (t.fCurrentCluster) {
1742 t.fRow = nr;
8c51a605 1743 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
91162307 1744
1745 if (t.fCurrentCluster->IsUsed(10)){
1746 //
1747 //
1748 // t.fErrorZ2*=2;
1749 // t.fErrorY2*=2;
1750 t.fNShared++;
1751 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1752 t.fRemoval =10;
1753 return 0;
1754 }
b364ca79 1755 }
d26d9159 1756 if (fIteration>0) accept = 0;
b364ca79 1757 if (accept<3) UpdateTrack(&t,accept);
1758
1c53abe2 1759 } else {
91162307 1760 if (fIteration==0){
1761 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1762 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1763
1764 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1c53abe2 1765 }
1766 }
1767 return 1;
1768}
1769
1770
1771
91162307 1772//_____________________________________________________________________________
1773Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1774 //-----------------------------------------------------------------
91162307 1775 // This function tries to find a track prolongation.
1c53abe2 1776 //-----------------------------------------------------------------
1777 Double_t xt=t.GetX();
1778 //
91162307 1779 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1c53abe2 1780 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1781 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1782 //
1783 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1784
91162307 1785 Int_t first = GetRowNumber(xt)-1;
51ad6848 1786 for (Int_t nr= first; nr>=rf; nr-=step) {
1787 // update kink info
1788 if (t.GetKinkIndexes()[0]>0){
1789 for (Int_t i=0;i<3;i++){
1790 Int_t index = t.GetKinkIndexes()[i];
1791 if (index==0) break;
1792 if (index<0) continue;
1793 //
1794 AliESDkink * kink = fEvent->GetKink(index-1);
1795 if (!kink){
1796 printf("PROBLEM\n");
1797 }
1798 else{
eea478d3 1799 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
51ad6848 1800 if (kinkrow==nr){
1801 AliExternalTrackParam paramd(t);
1802 kink->SetDaughter(paramd);
eea478d3 1803 kink->SetStatus(2,5);
51ad6848 1804 kink->Update();
51ad6848 1805 }
1806 }
1807 }
1808 }
1809
1810 if (nr==80) t.UpdateReference();
982aff31 1811 if (nr<fInnerSec->GetNRows())
1812 fSectors = fInnerSec;
1813 else
1814 fSectors = fOuterSec;
91162307 1815 if (FollowToNext(t,nr)==0)
4d158c36 1816 if (!t.IsActive())
1817 return 0;
91162307 1818
1819 }
1820 return 1;
1821}
1822
1c53abe2 1823
1824//_____________________________________________________________________________
91162307 1825Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1826 //-----------------------------------------------------------------
1827 // This function tries to find a track prolongation.
1828 //-----------------------------------------------------------------
1829 Double_t xt=t.GetX();
1830 //
1831 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1832 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1833 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1834 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1835
1836 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1837
1838 if (FollowToNextFast(t,nr)==0)
1839 if (!t.IsActive()) return 0;
1c53abe2 1840
1c53abe2 1841 }
1842 return 1;
1843}
1844
1845
91162307 1846
1847
1848
1c53abe2 1849Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1850 //-----------------------------------------------------------------
1851 // This function tries to find a track prolongation.
1852 //-----------------------------------------------------------------
1c53abe2 1853 //
eea478d3 1854 Double_t xt=t.GetX();
1c53abe2 1855 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1856 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1857 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1858 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1859
4d158c36 1860 Int_t first = t.fFirstPoint;
eea478d3 1861 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
91162307 1862 //
1863 if (first<0) first=0;
4d158c36 1864 for (Int_t nr=first; nr<=rf; nr++) {
ca142b1f 1865 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
51ad6848 1866 if (t.GetKinkIndexes()[0]<0){
1867 for (Int_t i=0;i<3;i++){
1868 Int_t index = t.GetKinkIndexes()[i];
1869 if (index==0) break;
1870 if (index>0) continue;
1871 index = TMath::Abs(index);
1872 AliESDkink * kink = fEvent->GetKink(index-1);
1873 if (!kink){
1874 printf("PROBLEM\n");
1875 }
1876 else{
eea478d3 1877 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
51ad6848 1878 if (kinkrow==nr){
1879 AliExternalTrackParam paramm(t);
1880 kink->SetMother(paramm);
eea478d3 1881 kink->SetStatus(2,1);
51ad6848 1882 kink->Update();
51ad6848 1883 }
1884 }
eea478d3 1885 }
51ad6848 1886 }
eea478d3 1887 //
d26d9159 1888 if (nr<fInnerSec->GetNRows())
1889 fSectors = fInnerSec;
1890 else
1891 fSectors = fOuterSec;
1892 FollowToNext(t,nr);
1c53abe2 1893 }
1894 return 1;
1895}
1896
1897
1898
1899
1900
1901Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1902{
1903 //
1904 //
1905 sum1=0;
1906 sum2=0;
1907 Int_t sum=0;
1c53abe2 1908 //
1909 Float_t dz2 =(s1->GetZ() - s2->GetZ());
c9427e08 1910 dz2*=dz2;
91162307 1911
c9427e08 1912 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1c53abe2 1913 dy2*=dy2;
1914 Float_t distance = TMath::Sqrt(dz2+dy2);
c9427e08 1915 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1c53abe2 1916
91162307 1917 // Int_t offset =0;
c9427e08 1918 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1919 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
c9427e08 1920 if (lastpoint>160)
1921 lastpoint =160;
1922 if (firstpoint<0)
1923 firstpoint = 0;
91162307 1924 if (firstpoint>lastpoint) {
1925 firstpoint =lastpoint;
1926 // lastpoint =160;
c9427e08 1927 }
1928
1929
91162307 1930 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1931 if (s1->GetClusterIndex2(i)>0) sum1++;
1932 if (s2->GetClusterIndex2(i)>0) sum2++;
1933 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1c53abe2 1934 sum++;
1935 }
1936 }
91162307 1937 if (sum<5) return 0;
1938
1627d1c4 1939 Float_t summin = TMath::Min(sum1+1,sum2+1);
1940 Float_t ratio = (sum+1)/Float_t(summin);
1c53abe2 1941 return ratio;
1942}
1943
1944void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1945{
1946 //
1947 //
91162307 1948 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1949 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1950
1c53abe2 1951 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1952 dz2*=dz2;
1953 Float_t dy2 =(s1->GetY() - s2->GetY());
1954 dy2*=dy2;
91162307 1955 Float_t distance = dz2+dy2;
1956 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1957
1c53abe2 1958 //
91162307 1959 Int_t sumshared=0;
1960 //
1961 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1962 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1963 //
1964 if (firstpoint>=lastpoint-5) return;;
1c53abe2 1965
91162307 1966 for (Int_t i=firstpoint;i<lastpoint;i++){
1967 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1968 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1969 sumshared++;
1970 }
1971 }
1972 if (sumshared>4){
1973 // sign clusters
1974 //
1975 for (Int_t i=firstpoint;i<lastpoint;i++){
1976 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1977 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1978 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1979 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1980 if (s1->IsActive()&&s2->IsActive()){
1981 p1->fIsShared = kTRUE;
1982 p2->fIsShared = kTRUE;
1983 }
1984 }
1985 }
1986 }
1987 //
1988 if (sumshared>10){
1989 for (Int_t i=0;i<4;i++){
1990 if (s1->fOverlapLabels[3*i]==0){
1991 s1->fOverlapLabels[3*i] = s2->GetLabel();
1992 s1->fOverlapLabels[3*i+1] = sumshared;
1993 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1994 break;
1995 }
1996 }
1997 for (Int_t i=0;i<4;i++){
1998 if (s2->fOverlapLabels[3*i]==0){
1999 s2->fOverlapLabels[3*i] = s1->GetLabel();
2000 s2->fOverlapLabels[3*i+1] = sumshared;
2001 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2002 break;
2003 }
2004 }
2005 }
1c53abe2 2006
91162307 2007}
1c53abe2 2008
91162307 2009void AliTPCtrackerMI::SignShared(TObjArray * arr)
2010{
1c53abe2 2011 //
91162307 2012 //sort trackss according sectors
2013 //
c9427e08 2014 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2015 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2016 if (!pt) continue;
2017 //if (pt) RotateToLocal(pt);
2018 pt->fSort = 0;
c9427e08 2019 }
91162307 2020 arr->UnSort();
1c53abe2 2021 arr->Sort(); // sorting according z
2022 arr->Expand(arr->GetEntries());
91162307 2023 //
2024 //
1c53abe2 2025 Int_t nseed=arr->GetEntriesFast();
1c53abe2 2026 for (Int_t i=0; i<nseed; i++) {
2027 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2028 if (!pt) continue;
2029 for (Int_t j=0;j<=12;j++){
2030 pt->fOverlapLabels[j] =0;
1c53abe2 2031 }
91162307 2032 }
2033 for (Int_t i=0; i<nseed; i++) {
2034 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2035 if (!pt) continue;
2036 if (pt->fRemoval>10) continue;
1c53abe2 2037 for (Int_t j=i+1; j<nseed; j++){
2038 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
91162307 2039 // if (pt2){
2040 if (pt2->fRemoval<=10) {
2041 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2042 SignShared(pt,pt2);
c9427e08 2043 }
91162307 2044 }
2045 }
2046}
2047
2048void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2049{
2050 //
2051 //sort trackss according sectors
2052 //
2053 if (fDebug&1) {
6bdc18d6 2054 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
91162307 2055 }
2056 //
2057 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2058 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2059 if (!pt) continue;
2060 pt->fSort = 0;
2061 }
2062 arr->UnSort();
2063 arr->Sort(); // sorting according z
2064 arr->Expand(arr->GetEntries());
2065 //
2066 //reset overlap labels
2067 //
2068 Int_t nseed=arr->GetEntriesFast();
2069 for (Int_t i=0; i<nseed; i++) {
2070 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2071 if (!pt) continue;
2072 pt->SetUniqueID(i);
2073 for (Int_t j=0;j<=12;j++){
2074 pt->fOverlapLabels[j] =0;
1c53abe2 2075 }
2076 }
91162307 2077 //
2078 //sign shared tracks
1c53abe2 2079 for (Int_t i=0; i<nseed; i++) {
2080 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2081 if (!pt) continue;
2082 if (pt->fRemoval>10) continue;
2083 Float_t deltac = pt->GetC()*0.1;
2084 for (Int_t j=i+1; j<nseed; j++){
2085 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2086 // if (pt2){
2087 if (pt2->fRemoval<=10) {
2088 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2089 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2090 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2091 //
2092 SignShared(pt,pt2);
2093 }
1c53abe2 2094 }
1c53abe2 2095 }
91162307 2096 //
2097 // remove highly shared tracks
2098 for (Int_t i=0; i<nseed; i++) {
2099 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2100 if (!pt) continue;
2101 if (pt->fRemoval>10) continue;
2102 //
2103 Int_t sumshared =0;
2104 for (Int_t j=0;j<4;j++){
2105 sumshared = pt->fOverlapLabels[j*3+1];
2106 }
2107 Float_t factor = factor1;
2108 if (pt->fRemoval>0) factor = factor2;
2109 if (sumshared/pt->GetNumberOfClusters()>factor){
2110 for (Int_t j=0;j<4;j++){
2111 if (pt->fOverlapLabels[3*j]==0) continue;
2112 if (pt->fOverlapLabels[3*j+1]<5) continue;
2113 if (pt->fRemoval==removalindex) continue;
2114 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2115 if (!pt2) continue;
2116 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2117 // pt->fRemoval = removalindex;
2118 delete arr->RemoveAt(i);
2119 break;
1c53abe2 2120 }
91162307 2121 }
1c53abe2 2122 }
91162307 2123 }
2124 arr->Compress();
2125 if (fDebug&1) {
6bdc18d6 2126 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
91162307 2127 }
2128}
2129
2130
2131
1c53abe2 2132
2133
91162307 2134
47966a6d 2135void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
91162307 2136{
2137 //
2138 //sort tracks in array according mode criteria
2139 Int_t nseed = arr->GetEntriesFast();
2140 for (Int_t i=0; i<nseed; i++) {
2141 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2142 if (!pt) {
2143 continue;
2144 }
2145 pt->fSort = mode;
2146 }
2147 arr->UnSort();
2148 arr->Sort();
1c53abe2 2149}
c9427e08 2150
91162307 2151void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
c9427e08 2152{
2153
2154 //Loop over all tracks and remove "overlaps"
2155 //
2156 //
2157 Int_t nseed = arr->GetEntriesFast();
2158 Int_t good =0;
91162307 2159
c9427e08 2160 for (Int_t i=0; i<nseed; i++) {
2161 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2162 if (!pt) {
91162307 2163 delete arr->RemoveAt(i);
c9427e08 2164 }
91162307 2165 else{
2166 pt->fSort =1;
2167 pt->fBSigned = kFALSE;
c9427e08 2168 }
91162307 2169 }
2170 arr->Compress();
2171 nseed = arr->GetEntriesFast();
2172 arr->UnSort();
2173 arr->Sort();
2174 //
2175 //unsign used
2176 UnsignClusters();
2177 //
2178 for (Int_t i=0; i<nseed; i++) {
2179 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2180 if (!pt) {
2181 continue;
2182 }
2183 Int_t found,foundable,shared;
2184 if (pt->IsActive())
2185 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2186 else
2187 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2188 //
2189 Double_t factor = factor2;
2190 if (pt->fBConstrain) factor = factor1;
2191
2192 if ((Float_t(shared)/Float_t(found))>factor){
c9427e08 2193 pt->Desactivate(removalindex);
91162307 2194 continue;
2195 }
2196
2197 good++;
2198 for (Int_t i=0; i<160; i++) {
2199 Int_t index=pt->GetClusterIndex2(i);
2200 if (index<0 || index&0x8000 ) continue;
2201 AliTPCclusterMI *c= pt->fClusterPointer[i];
2202 if (!c) continue;
2203 // if (!c->IsUsed(10)) c->Use(10);
2204 //if (pt->IsActive())
2205 c->Use(10);
2206 //else
2207 // c->Use(5);
c9427e08 2208 }
91162307 2209
c9427e08 2210 }
2211 fNtracks = good;
6bdc18d6 2212 if (fDebug>0){
2213 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2214 }
c9427e08 2215}
2216
51ad6848 2217
2218void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2219{
2220
2221 //Loop over all tracks and remove "overlaps"
2222 //
2223 //
2224 UnsignClusters();
2225 //
2226 Int_t nseed = arr->GetEntriesFast();
2227 Float_t * quality = new Float_t[nseed];
2228 Int_t * indexes = new Int_t[nseed];
2229 Int_t good =0;
2230 //
2231 //
2232 for (Int_t i=0; i<nseed; i++) {
2233 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2234 if (!pt){
2235 quality[i]=-1;
2236 continue;
2237 }
2238 pt->UpdatePoints(); //select first last max dens points
2239 Float_t * points = pt->GetPoints();
2240 if (points[3]<0.8) quality[i] =-1;
2241 //
2242 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2243 }
2244 TMath::Sort(nseed,quality,indexes);
2245 //
2246 //
2247 for (Int_t itrack=0; itrack<nseed; itrack++) {
2248 Int_t trackindex = indexes[itrack];
2249 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2250 if (quality[trackindex]<0){
2251 if (pt) {
2252 delete arr->RemoveAt(trackindex);
2253 }
2254 else{
2255 arr->RemoveAt(trackindex);
2256 }
2257 continue;
2258 }
2259 //
2260 Int_t first = Int_t(pt->GetPoints()[0]);
2261 Int_t last = Int_t(pt->GetPoints()[2]);
2262 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2263 //
2264 Int_t found,foundable,shared;
2265 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
eea478d3 2266 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
b406fdb0 2267 Bool_t itsgold =kFALSE;
2268 if (pt->fEsd){
ef7253ac 2269 Int_t dummy[12];
b406fdb0 2270 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
51ad6848 2271 }
b406fdb0 2272 if (!itsgold){
2273 //
2274 if (Float_t(shared+1)/Float_t(found+1)>factor){
2275 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2276 delete arr->RemoveAt(trackindex);
2277 continue;
2278 }
2279 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2280 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2281 delete arr->RemoveAt(trackindex);
2282 continue;
2283 }
51ad6848 2284 }
2285
2286 good++;
2287 if (sharedfactor>0.4) continue;
b406fdb0 2288 if (pt->GetKinkIndexes()[0]>0) continue;
51ad6848 2289 for (Int_t i=first; i<last; i++) {
2290 Int_t index=pt->GetClusterIndex2(i);
2291 // if (index<0 || index&0x8000 ) continue;
2292 if (index<0 || index&0x8000 ) continue;
2293 AliTPCclusterMI *c= pt->fClusterPointer[i];
2294 if (!c) continue;
2295 c->Use(10);
2296 }
2297 }
2298 fNtracks = good;
2299 if (fDebug>0){
2300 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2301 }
2302 delete []quality;
2303 delete []indexes;
2304}
2305
91162307 2306void AliTPCtrackerMI::UnsignClusters()
1c53abe2 2307{
91162307 2308 //
2309 // loop over all clusters and unsign them
2310 //
2311
2312 for (Int_t sec=0;sec<fkNIS;sec++){
2313 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2314 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2315 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2316 // if (cl[icl].IsUsed(10))
2317 cl[icl].Use(-1);
2318 cl = fInnerSec[sec][row].fClusters2;
2319 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2320 //if (cl[icl].IsUsed(10))
2321 cl[icl].Use(-1);
2322 }
2323 }
2324
2325 for (Int_t sec=0;sec<fkNOS;sec++){
2326 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2327 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2328 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2329 //if (cl[icl].IsUsed(10))
2330 cl[icl].Use(-1);
2331 cl = fOuterSec[sec][row].fClusters2;
2332 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2333 //if (cl[icl].IsUsed(10))
2334 cl[icl].Use(-1);
2335 }
2336 }
2337
1c53abe2 2338}
2339
91162307 2340
2341
732b9e78 2342void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
1c53abe2 2343{
2344 //
91162307 2345 //sign clusters to be "used"
2346 //
2347 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2348 // loop over "primaries"
2349
2350 Float_t sumdens=0;
2351 Float_t sumdens2=0;
2352 Float_t sumn =0;
2353 Float_t sumn2 =0;
2354 Float_t sumchi =0;
2355 Float_t sumchi2 =0;
2356
2357 Float_t sum =0;
2358
1c53abe2 2359 TStopwatch timer;
91162307 2360 timer.Start();
1c53abe2 2361
91162307 2362 Int_t nseed = arr->GetEntriesFast();
2363 for (Int_t i=0; i<nseed; i++) {
2364 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2365 if (!pt) {
2366 continue;
2367 }
2368 if (!(pt->IsActive())) continue;
2369 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2370 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2371 sumdens += dens;
2372 sumdens2+= dens*dens;
2373 sumn += pt->GetNumberOfClusters();
2374 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2375 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2376 if (chi2>5) chi2=5;
2377 sumchi +=chi2;
2378 sumchi2 +=chi2*chi2;
2379 sum++;
2380 }
1627d1c4 2381 }
91162307 2382
2383 Float_t mdensity = 0.9;
2384 Float_t meann = 130;
2385 Float_t meanchi = 1;
2386 Float_t sdensity = 0.1;
2387 Float_t smeann = 10;
2388 Float_t smeanchi =0.4;
1627d1c4 2389
91162307 2390
2391 if (sum>20){
2392 mdensity = sumdens/sum;
2393 meann = sumn/sum;
2394 meanchi = sumchi/sum;
2395 //
2396 sdensity = sumdens2/sum-mdensity*mdensity;
2397 sdensity = TMath::Sqrt(sdensity);
2398 //
2399 smeann = sumn2/sum-meann*meann;
2400 smeann = TMath::Sqrt(smeann);
2401 //
2402 smeanchi = sumchi2/sum - meanchi*meanchi;
2403 smeanchi = TMath::Sqrt(smeanchi);
2404 }
2405
2406
2407 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2408 //
2409 for (Int_t i=0; i<nseed; i++) {
2410 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2411 if (!pt) {
2412 continue;
1c53abe2 2413 }
91162307 2414 if (pt->fBSigned) continue;
2415 if (pt->fBConstrain) continue;
2416 //if (!(pt->IsActive())) continue;
2417 /*
2418 Int_t found,foundable,shared;
2419 pt->GetClusterStatistic(0,160,found, foundable,shared);
2420 if (shared/float(found)>0.3) {
2421 if (shared/float(found)>0.9 ){
2422 //delete arr->RemoveAt(i);
2423 }
2424 continue;
c9427e08 2425 }
91162307 2426 */
2427 Bool_t isok =kFALSE;
2428 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2429 isok = kTRUE;
2430 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2431 isok =kTRUE;
2432 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2433 isok =kTRUE;
2434 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2435 isok =kTRUE;
2436
2437 if (isok)
2438 for (Int_t i=0; i<160; i++) {
2439 Int_t index=pt->GetClusterIndex2(i);
2440 if (index<0) continue;
2441 AliTPCclusterMI *c= pt->fClusterPointer[i];
2442 if (!c) continue;
2443 //if (!(c->IsUsed(10))) c->Use();
2444 c->Use(10);
2445 }
2446 }
2447
c9427e08 2448
1c53abe2 2449 //
91162307 2450 Double_t maxchi = meanchi+2.*smeanchi;
2451
2452 for (Int_t i=0; i<nseed; i++) {
2453 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2454 if (!pt) {
1c53abe2 2455 continue;
91162307 2456 }
2457 //if (!(pt->IsActive())) continue;
2458 if (pt->fBSigned) continue;
2459 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2460 if (chi>maxchi) continue;
2461
2462 Float_t bfactor=1;
2463 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2464
2465 //sign only tracks with enoug big density at the beginning
2466
2467 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2468
2469
3e5d0aa2 2470 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
91162307 2471 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2472
2473 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2474 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2475 minn=0;
2476
2477 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2478 //Int_t noc=pt->GetNumberOfClusters();
2479 pt->fBSigned = kTRUE;
2480 for (Int_t i=0; i<160; i++) {
2481
2482 Int_t index=pt->GetClusterIndex2(i);
2483 if (index<0) continue;
2484 AliTPCclusterMI *c= pt->fClusterPointer[i];
2485 if (!c) continue;
2486 // if (!(c->IsUsed(10))) c->Use();
2487 c->Use(10);
2488 }
1c53abe2 2489 }
91162307 2490 }
2491 // gLastCheck = nseed;
2492 // arr->Compress();
2493 if (fDebug>0){
2494 timer.Print();
2495 }
1c53abe2 2496}
2497
2498
47966a6d 2499void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
91162307 2500{
2501 // stop not active tracks
2502 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2503 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2504 Int_t nseed = arr->GetEntriesFast();
2505 //
2506 for (Int_t i=0; i<nseed; i++) {
2507 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2508 if (!pt) {
2509 continue;
2510 }
2511 if (!(pt->IsActive())) continue;
2512 StopNotActive(pt,row0,th0, th1,th2);
2513 }
2514}
1c53abe2 2515
1c53abe2 2516
1c53abe2 2517
91162307 2518void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
47966a6d 2519 Float_t th2) const
91162307 2520{
2521 // stop not active tracks
2522 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2523 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2524 Int_t sumgood1 = 0;
2525 Int_t sumgood2 = 0;
2526 Int_t foundable = 0;
2527 Int_t maxindex = seed->fLastPoint; //last foundable row
2528 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2529 seed->Desactivate(10) ;
2530 return;
2531 }
1c53abe2 2532
3e5d0aa2 2533 for (Int_t i=row0; i<maxindex; i++){
91162307 2534 Int_t index = seed->GetClusterIndex2(i);
2535 if (index!=-1) foundable++;
2536 //if (!c) continue;
2537 if (foundable<=30) sumgood1++;
2538 if (foundable<=50) {
2539 sumgood2++;
2540 }
2541 else{
2542 break;
2543 }
2544 }
2545 if (foundable>=30.){
2546 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2547 }
2548 if (foundable>=50)
2549 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2550}
1c53abe2 2551
1c53abe2 2552
d26d9159 2553Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2554{
2555 //
2556 // back propagation of ESD tracks
2557 //
2558 //return 0;
2559 fEvent = event;
2560 ReadSeeds(event,2);
2561 fIteration=2;
982aff31 2562 //PrepareForProlongation(fSeeds,1);
2563 PropagateForward2(fSeeds);
af32720d 2564
4d158c36 2565 Int_t ntracks=0;
d26d9159 2566 Int_t nseed = fSeeds->GetEntriesFast();
2567 for (Int_t i=0;i<nseed;i++){
2568 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
4d158c36 2569 if (!seed) continue;
eea478d3 2570 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2571
d26d9159 2572 seed->PropagateTo(fParam->GetInnerRadiusLow());
51ad6848 2573 seed->UpdatePoints();
d26d9159 2574 AliESDtrack *esd=event->GetTrack(i);
2575 seed->CookdEdx(0.02,0.6);
2576 CookLabel(seed,0.1); //For comparison only
af32720d 2577 //
34acb742 2578 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
af32720d 2579 TTreeSRedirector &cstream = *fDebugStreamer;
2580 cstream<<"Crefit"<<
2581 "Esd.="<<esd<<
2582 "Track.="<<seed<<
2583 "\n";
2584 }
51ad6848 2585 if (seed->GetNumberOfClusters()>15){
4d158c36 2586 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
51ad6848 2587 esd->SetTPCPoints(seed->GetPoints());
b406fdb0 2588 esd->SetTPCPointsF(seed->fNFoundable);
2589 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2590 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2591 Float_t dedx = seed->GetdEdx();
2592 esd->SetTPCsignal(dedx, sdedx, ndedx);
fdedfdec 2593 //
2594 // add seed to the esd track in Calib level
2595 //
2596 if (AliTPCReconstructor::StreamLevel()>0){
2597 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2598 esd->AddCalibObject(seedCopy);
2599 }
4d158c36 2600 ntracks++;
d26d9159 2601 }
2602 else{
2603 //printf("problem\n");
2604 }
2605 }
51ad6848 2606 //FindKinks(fSeeds,event);
4d158c36 2607 Info("RefitInward","Number of refitted tracks %d",ntracks);
d26d9159 2608 fEvent =0;
2609 //WriteTracks();
2610 return 0;
2611}
2612
1c53abe2 2613
91162307 2614Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2615{
2616 //
2617 // back propagation of ESD tracks
2618 //
1c53abe2 2619
91162307 2620 fEvent = event;
d26d9159 2621 fIteration = 1;
5d837844 2622 ReadSeeds(event,1);
b406fdb0 2623 PropagateBack(fSeeds);
2624 RemoveUsed2(fSeeds,0.4,0.4,20);
2625 //
91162307 2626 Int_t nseed = fSeeds->GetEntriesFast();
4d158c36 2627 Int_t ntracks=0;
91162307 2628 for (Int_t i=0;i<nseed;i++){
2629 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
d9e62e7e 2630 if (!seed) continue;
51ad6848 2631 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2632 seed->UpdatePoints();
91162307 2633 AliESDtrack *esd=event->GetTrack(i);
d26d9159 2634 seed->CookdEdx(0.02,0.6);
91162307 2635 CookLabel(seed,0.1); //For comparison only
51ad6848 2636 if (seed->GetNumberOfClusters()>15){
4d158c36 2637 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
51ad6848 2638 esd->SetTPCPoints(seed->GetPoints());
167c41ab 2639 esd->SetTPCPointsF(seed->fNFoundable);
2640 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2641 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2642 Float_t dedx = seed->GetdEdx();
2643 esd->SetTPCsignal(dedx, sdedx, ndedx);
4d158c36 2644 ntracks++;
ca142b1f 2645 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2646 (*fDebugStreamer)<<"Cback"<<
2647 "Tr0.="<<seed<<
2648 "EventNr="<<eventnumber<<
2649 "\n"; // patch 28 fev 06
4d158c36 2650 }
91162307 2651 }
51ad6848 2652 //FindKinks(fSeeds,event);
4d158c36 2653 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
91162307 2654 fEvent =0;
d26d9159 2655 //WriteTracks();
91162307 2656 return 0;
2657}
2658
2659
2660void AliTPCtrackerMI::DeleteSeeds()
2661{
b67e07dc 2662 //
2663 //delete Seeds
91162307 2664 Int_t nseed = fSeeds->GetEntriesFast();
2665 for (Int_t i=0;i<nseed;i++){
2666 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2667 if (seed) delete fSeeds->RemoveAt(i);
2668 }
2669 delete fSeeds;
2670 fSeeds =0;
2671}
2672
d26d9159 2673void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
91162307 2674{
2675 //
2676 //read seeds from the event
2677
2678 Int_t nentr=event->GetNumberOfTracks();
6bdc18d6 2679 if (fDebug>0){
2680 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2681 }
91162307 2682 if (fSeeds)
2683 DeleteSeeds();
2684 if (!fSeeds){
4d158c36 2685 fSeeds = new TObjArray(nentr);
91162307 2686 }
4d158c36 2687 UnsignClusters();
2688 // Int_t ntrk=0;
91162307 2689 for (Int_t i=0; i<nentr; i++) {
2690 AliESDtrack *esd=event->GetTrack(i);
51ad6848 2691 ULong_t status=esd->GetStatus();
2692 if (!(status&AliESDtrack::kTPCin)) continue;
b67e07dc 2693 AliTPCtrack t(*esd);
5d837844 2694 t.SetNumberOfClusters(0);
eea478d3 2695 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2696 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2697 for (Int_t ikink=0;ikink<3;ikink++) {
2698 Int_t index = esd->GetKinkIndex(ikink);
2699 seed->GetKinkIndexes()[ikink] = index;
2700 if (index==0) continue;
2701 index = TMath::Abs(index);
2702 AliESDkink * kink = fEvent->GetKink(index-1);
2703 if (kink&&esd->GetKinkIndex(ikink)<0){
2704 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2705 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2706 }
2707 if (kink&&esd->GetKinkIndex(ikink)>0){
2708 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2709 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2710 }
2711
2712 }
5d837844 2713 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance();
982aff31 2714 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
4d158c36 2715 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2716 fSeeds->AddAt(0,i);
2717 delete seed;
2718 continue;
2719 }
2720 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
c0b978f0 2721 Double_t par0[5],par1[5],alpha,x;
2722 esd->GetInnerExternalParameters(alpha,x,par0);
4d158c36 2723 esd->GetExternalParameters(x,par1);
2724 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2725 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
51ad6848 2726 Double_t trdchi2=0;
2727 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
4d158c36 2728 //reset covariance if suspicious
51ad6848 2729 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
4d158c36 2730 seed->ResetCovariance();
2731 }
982aff31 2732
91162307 2733 //
2734 //
2735 // rotate to the local coordinate system
eea478d3 2736 //
2737 fSectors=fInnerSec; fN=fkNIS;
91162307 2738 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2739 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2740 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2741 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2742 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
4d158c36 2743 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2744 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
91162307 2745 alpha-=seed->GetAlpha();
d9b8978b 2746 if (!seed->Rotate(alpha)) {
2747 delete seed;
2748 continue;
2749 }
d26d9159 2750 seed->fEsd = esd;
4d158c36 2751 // sign clusters
b406fdb0 2752 if (esd->GetKinkIndex(0)<=0){
2753 for (Int_t irow=0;irow<160;irow++){
2754 Int_t index = seed->GetClusterIndex2(irow);
2755 if (index>0){
2756 //
2757 AliTPCclusterMI * cl = GetClusterMI(index);
2758 seed->fClusterPointer[irow] = cl;
2759 if (cl){
2760 if ((index & 0x8000)==0){
2761 cl->Use(10); // accepted cluster
2762 }else{
2763 cl->Use(6); // close cluster not accepted
2764 }
4d158c36 2765 }else{
b406fdb0 2766 Info("ReadSeeds","Not found cluster");
2767 }
4d158c36 2768 }
2769 }
2770 }
2771 fSeeds->AddAt(seed,i);
91162307 2772 }
2773}
2774
2775
2776
2777//_____________________________________________________________________________
2778void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2779 Float_t deltay, Int_t ddsec) {
2780 //-----------------------------------------------------------------
2781 // This function creates track seeds.
2782 // SEEDING WITH VERTEX CONSTRAIN
2783 //-----------------------------------------------------------------
2784 // cuts[0] - fP4 cut
2785 // cuts[1] - tan(phi) cut
2786 // cuts[2] - zvertex cut
2787 // cuts[3] - fP3 cut
2788 Int_t nin0 = 0;
2789 Int_t nin1 = 0;
2790 Int_t nin2 = 0;
2791 Int_t nin = 0;
2792 Int_t nout1 = 0;
2793 Int_t nout2 = 0;
2794
2795 Double_t x[5], c[15];
2796 // Int_t di = i1-i2;
2797 //
2798 AliTPCseed * seed = new AliTPCseed;
2799 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2800 Double_t cs=cos(alpha), sn=sin(alpha);
2801 //
2802 // Double_t x1 =fOuterSec->GetX(i1);
2803 //Double_t xx2=fOuterSec->GetX(i2);
2804
2805 Double_t x1 =GetXrow(i1);
2806 Double_t xx2=GetXrow(i2);
2807
2808 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2809
2810 Int_t imiddle = (i2+i1)/2; //middle pad row index
2811 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2812 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2813 //
2814 Int_t ns =sec;
2815
2816 const AliTPCRow& kr1=GetRow(ns,i1);
2817 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2818 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2819
2820 //
2821 // change cut on curvature if it can't reach this layer
2822 // maximal curvature set to reach it
2823 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2824 if (dvertexmax*0.5*cuts[0]>0.85){
2825 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2826 }
2827 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2828
2829 // Int_t ddsec = 1;
2830 if (deltay>0) ddsec = 0;
2831 // loop over clusters
2832 for (Int_t is=0; is < kr1; is++) {
2833 //
2834 if (kr1[is]->IsUsed(10)) continue;
2835 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2836 //if (TMath::Abs(y1)>ymax) continue;
2837
2838 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2839
2840 // find possible directions
2841 Float_t anglez = (z1-z3)/(x1-x3);
2842 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2843 //
2844 //
2845 //find rotation angles relative to line given by vertex and point 1
2846 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2847 Double_t dvertex = TMath::Sqrt(dvertex2);
2848 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2849 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2850
2851 //
2852 // loop over 2 sectors
2853 Int_t dsec1=-ddsec;
2854 Int_t dsec2= ddsec;
2855 if (y1<0) dsec2= 0;
2856 if (y1>0) dsec1= 0;
2857
2858 Double_t dddz1=0; // direction of delta inclination in z axis
2859 Double_t dddz2=0;
2860 if ( (z1-z3)>0)
2861 dddz1 =1;
2862 else
2863 dddz2 =1;
2864 //
2865 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2866 Int_t sec2 = sec + dsec;
2867 //
2868 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2869 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2870 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2871 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2872 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2873 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2874
2875 // rotation angles to p1-p3
2876 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2877 Double_t x2, y2, z2;
2878 //
2879 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2880
2881 //
2882 Double_t dxx0 = (xx2-x3)*cs13r;
2883 Double_t dyy0 = (xx2-x3)*sn13r;
2884 for (Int_t js=index1; js < index2; js++) {
2885 const AliTPCclusterMI *kcl = kr2[js];
2886 if (kcl->IsUsed(10)) continue;
2887 //
2888 //calcutate parameters
2889 //
2890 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2891 // stright track
2892 if (TMath::Abs(yy0)<0.000001) continue;
2893 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2894 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2895 Double_t r02 = (0.25+y0*y0)*dvertex2;
2896 //curvature (radius) cut
2897 if (r02<r2min) continue;
2898
2899 nin0++;
2900 //
2901 Double_t c0 = 1/TMath::Sqrt(r02);
2902 if (yy0>0) c0*=-1.;
2903
2904
2905 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2906 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
b67e07dc 2907 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2908 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
91162307 2909 //
2910 //
2911 Double_t z0 = kcl->GetZ();
2912 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2913 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2914 nin1++;
2915 //
2916 Double_t dip = (z1-z0)*c0/dfi1;
2917 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2918 //
2919 y2 = kcl->GetY();
2920 if (dsec==0){
2921 x2 = xx2;
2922 z2 = kcl->GetZ();
2923 }
2924 else
2925 {
2926 // rotation
2927 z2 = kcl->GetZ();
2928 x2= xx2*cs-y2*sn*dsec;
2929 y2=+xx2*sn*dsec+y2*cs;
2930 }
2931
2932 x[0] = y1;
2933 x[1] = z1;
2934 x[2] = x0;
2935 x[3] = dip;
2936 x[4] = c0;
2937 //
2938 //
2939 // do we have cluster at the middle ?
2940 Double_t ym,zm;
2941 GetProlongation(x1,xm,x,ym,zm);
2942 UInt_t dummy;
2943 AliTPCclusterMI * cm=0;
2944 if (TMath::Abs(ym)-ymaxm<0){
2945 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2946 if ((!cm) || (cm->IsUsed(10))) {
2947 continue;
2948 }
2949 }
2950 else{
2951 // rotate y1 to system 0
2952 // get state vector in rotated system
2953 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2954 Double_t xr2 = x0*cs+yr1*sn*dsec;
2955 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2956 //
2957 GetProlongation(xx2,xm,xr,ym,zm);
2958 if (TMath::Abs(ym)-ymaxm<0){
2959 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2960 if ((!cm) || (cm->IsUsed(10))) {
2961 continue;
2962 }
2963 }
2964 }
2965
2966
2967 Double_t dym = 0;
2968 Double_t dzm = 0;
2969 if (cm){
2970 dym = ym - cm->GetY();
2971 dzm = zm - cm->GetZ();
2972 }
2973 nin2++;
2974
2975
2976 //
2977 //
2978 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2979 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2980 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2981 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2982 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2983
b67e07dc 2984 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2985 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2986 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2987 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2988 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2989 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 2990
b67e07dc 2991 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2992 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2993 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2994 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
91162307 2995
1c53abe2 2996 c[0]=sy1;
2997 c[1]=0.; c[2]=sz1;
2998 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2999 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3000 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3001 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3002 c[13]=f30*sy1*f40+f32*sy2*f42;
3003 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
91162307 3004
3005 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3006
1c53abe2 3007 UInt_t index=kr1.GetIndex(is);
91162307 3008 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
3009
1c53abe2 3010 track->fIsSeeding = kTRUE;
91162307 3011 track->fSeed1 = i1;
3012 track->fSeed2 = i2;
3013 track->fSeedType=3;
c9427e08 3014
91162307 3015
3016 //if (dsec==0) {
3017 FollowProlongation(*track, (i1+i2)/2,1);
3018 Int_t foundable,found,shared;
3019 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3020 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3021 seed->Reset();
3022 seed->~AliTPCseed();
3023 continue;
3024 }
3025 //}
3026
3027 nin++;
3028 FollowProlongation(*track, i2,1);
3029
3030
3031 //Int_t rc = 1;
3032 track->fBConstrain =1;
3033 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3034 track->fLastPoint = i1; // first cluster in track position
3035 track->fFirstPoint = track->fLastPoint;
3036
3037 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3038 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3039 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3040 seed->Reset();
3041 seed->~AliTPCseed();
c9427e08 3042 continue;
3043 }
91162307 3044 nout1++;
3045 // Z VERTEX CONDITION
3046 Double_t zv;
3047 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3048 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3049 if (TMath::Abs(zv-z3)>cuts[2]) {
3050 FollowProlongation(*track, TMath::Max(i2-20,0));
3051 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3052 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3053 if (TMath::Abs(zv-z3)>cuts[2]){
3054 FollowProlongation(*track, TMath::Max(i2-40,0));
3055 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3056 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3057 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3058 // make seed without constrain
3059 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3060 FollowProlongation(*track2, i2,1);
3061 track2->fBConstrain = kFALSE;
3062 track2->fSeedType = 1;
3063 arr->AddLast(track2);
3064 seed->Reset();
3065 seed->~AliTPCseed();
3066 continue;
3067 }
3068 else{
3069 seed->Reset();
3070 seed->~AliTPCseed();
3071 continue;
3072
3073 }
3074 }
c9427e08 3075 }
1c53abe2 3076
91162307 3077 track->fSeedType =0;
3078 arr->AddLast(track);
3079 seed = new AliTPCseed;
3080 nout2++;
3081 // don't consider other combinations
3082 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3083 break;
1c53abe2 3084 }
3085 }
3086 }
6bdc18d6 3087 if (fDebug>3){
3088 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
91162307 3089 }
3090 delete seed;
1c53abe2 3091}
3092
1627d1c4 3093
91162307 3094void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3095 Float_t deltay) {
3096
3097
3098
1627d1c4 3099 //-----------------------------------------------------------------
91162307 3100 // This function creates track seeds.
1627d1c4 3101 //-----------------------------------------------------------------
91162307 3102 // cuts[0] - fP4 cut
3103 // cuts[1] - tan(phi) cut
3104 // cuts[2] - zvertex cut
3105 // cuts[3] - fP3 cut
3106
3107
3108 Int_t nin0 = 0;
3109 Int_t nin1 = 0;
3110 Int_t nin2 = 0;
3111 Int_t nin = 0;
3112 Int_t nout1 = 0;
3113 Int_t nout2 = 0;
3114 Int_t nout3 =0;
3115 Double_t x[5], c[15];
3116 //
3117 // make temporary seed
3118 AliTPCseed * seed = new AliTPCseed;
1627d1c4 3119 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3120 // Double_t cs=cos(alpha), sn=sin(alpha);
91162307 3121 //
3122 //
1627d1c4 3123
91162307 3124 // first 3 padrows
3125 Double_t x1 = GetXrow(i1-1);
3126 const AliTPCRow& kr1=GetRow(sec,i1-1);
3127 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3128 //
3129 Double_t x1p = GetXrow(i1);
3130 const AliTPCRow& kr1p=GetRow(sec,i1);
3131 //
3132 Double_t x1m = GetXrow(i1-2);
3133 const AliTPCRow& kr1m=GetRow(sec,i1-2);
1627d1c4 3134
91162307 3135 //
3136 //last 3 padrow for seeding
3137 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3138 Double_t x3 = GetXrow(i1-7);
3139 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3140 //
3141 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3142 Double_t x3p = GetXrow(i1-6);
3143 //
3144 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3145 Double_t x3m = GetXrow(i1-8);
1627d1c4 3146
91162307 3147 //
3148 //
3149 // middle padrow
3150 Int_t im = i1-4; //middle pad row index
3151 Double_t xm = GetXrow(im); // radius of middle pad-row
3152 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3153 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3154 //
3155 //
3156 Double_t deltax = x1-x3;
3157 Double_t dymax = deltax*cuts[1];
3158 Double_t dzmax = deltax*cuts[3];
3159 //
3160 // loop over clusters
3161 for (Int_t is=0; is < kr1; is++) {
1627d1c4 3162 //
91162307 3163 if (kr1[is]->IsUsed(10)) continue;
3164 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
1627d1c4 3165 //
91162307 3166 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3167 //
3168 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3169 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3170 //
3171 Double_t y3, z3;
1627d1c4 3172 //
1627d1c4 3173 //
91162307 3174 UInt_t index;
3175 for (Int_t js=index1; js < index2; js++) {
3176 const AliTPCclusterMI *kcl = kr3[js];
3177 if (kcl->IsUsed(10)) continue;
3178 y3 = kcl->GetY();
3179 // apply angular cuts
3180 if (TMath::Abs(y1-y3)>dymax) continue;
3181 x3 = x3;
3182 z3 = kcl->GetZ();
3183 if (TMath::Abs(z1-z3)>dzmax) continue;
3184 //
3185 Double_t angley = (y1-y3)/(x1-x3);
3186 Double_t anglez = (z1-z3)/(x1-x3);
3187 //
3188 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3189 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3190 //
3191 Double_t yyym = angley*(xm-x1)+y1;
3192 Double_t zzzm = anglez*(xm-x1)+z1;
3193
3194 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3195 if (!kcm) continue;
3196 if (kcm->IsUsed(10)) continue;
3197
3198 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3199 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3200 //
3201 //
3202 //
3203 Int_t used =0;
3204 Int_t found =0;
3205 //
3206 // look around first
3207 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3208 anglez*(x1m-x1)+z1,
3209 erry,errz,index);
3210 //
3211 if (kc1m){
3212 found++;
3213 if (kc1m->IsUsed(10)) used++;
1627d1c4 3214 }
91162307 3215 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3216 anglez*(x1p-x1)+z1,
3217 erry,errz,index);
1627d1c4 3218 //
91162307 3219 if (kc1p){
3220 found++;
3221 if (kc1p->IsUsed(10)) used++;
1627d1c4 3222 }
91162307 3223 if (used>1) continue;
3224 if (found<1) continue;
1627d1c4 3225
91162307 3226 //
3227 // look around last
3228 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3229 anglez*(x3m-x3)+z3,
3230 erry,errz,index);
3231 //
3232 if (kc3m){
3233 found++;
3234 if (kc3m->IsUsed(10)) used++;
3235 }
3236 else
3237 continue;
3238 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3239 anglez*(x3p-x3)+z3,
3240 erry,errz,index);
3241 //
3242 if (kc3p){
3243 found++;
3244 if (kc3p->IsUsed(10)) used++;
3245 }
3246 else
3247 continue;
3248 if (used>1) continue;
3249 if (found<3) continue;
3250 //
3251 Double_t x2,y2,z2;
3252 x2 = xm;
3253 y2 = kcm->GetY();
3254 z2 = kcm->GetZ();
3255 //
3256
1627d1c4 3257 x[0]=y1;
3258 x[1]=z1;
b67e07dc 3259 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3260 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3261 nin0++;
3262 //
b67e07dc 3263 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3264 nin1++;
3265 //
b67e07dc 3266 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
91162307 3267 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3268 nin2++;
3269 //
3270 //
3271 Double_t sy1=0.1, sz1=0.1;
3272 Double_t sy2=0.1, sz2=0.1;
3273 Double_t sy3=0.1, sy=0.1, sz=0.1;
1627d1c4 3274
b67e07dc 3275 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3276 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3277 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3278 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3279 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3280 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 3281
b67e07dc 3282 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3283 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3284 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3285 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1627d1c4 3286
3287 c[0]=sy1;
91162307 3288 c[1]=0.; c[2]=sz1;
1627d1c4 3289 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3290 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3291 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3292 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3293 c[13]=f30*sy1*f40+f32*sy2*f42;
3294 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3295
91162307 3296 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3297
3298 UInt_t index=kr1.GetIndex(is);
3299 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3300
3301 track->fIsSeeding = kTRUE;
3302
3303 nin++;
3304 FollowProlongation(*track, i1-7,1);
3305 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3306 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3307 seed->Reset();
3308 seed->~AliTPCseed();
3309 continue;
3310 }
3311 nout1++;
3312 nout2++;
3313 //Int_t rc = 1;
3314 FollowProlongation(*track, i2,1);
3315 track->fBConstrain =0;
3316 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3317 track->fFirstPoint = track->fLastPoint;
3318
3319 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3320 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3321 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3322 seed->Reset();
3323 seed->~AliTPCseed();
3324 continue;
3325 }
3326
3327 {
3328 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3329 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3330 FollowProlongation(*track2, i2,1);
3331 track2->fBConstrain = kFALSE;
3332 track2->fSeedType = 4;
3333 arr->AddLast(track2);
3334 seed->Reset();
3335 seed->~AliTPCseed();
3336 }
3337
3338
3339 //arr->AddLast(track);
3340 //seed = new AliTPCseed;
3341 nout3++;
3342 }
3343 }
3344
6bdc18d6 3345 if (fDebug>3){
3346 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
91162307 3347 }
3348 delete seed;
3349}
3350
3351
3352//_____________________________________________________________________________
176aff27 3353void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3354 Float_t deltay, Bool_t /*bconstrain*/) {
91162307 3355 //-----------------------------------------------------------------
3356 // This function creates track seeds - without vertex constraint
3357 //-----------------------------------------------------------------
3358 // cuts[0] - fP4 cut - not applied
3359 // cuts[1] - tan(phi) cut
3360 // cuts[2] - zvertex cut - not applied
3361 // cuts[3] - fP3 cut
3362 Int_t nin0=0;
3363 Int_t nin1=0;
3364 Int_t nin2=0;
3365 Int_t nin3=0;
3366 // Int_t nin4=0;
3367 //Int_t nin5=0;
3368
3369
3370
3371 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3372 // Double_t cs=cos(alpha), sn=sin(alpha);
3373 Int_t row0 = (i1+i2)/2;
3374 Int_t drow = (i1-i2)/2;
3375 const AliTPCRow& kr0=fSectors[sec][row0];
3376 AliTPCRow * kr=0;
3377
3378 AliTPCpolyTrack polytrack;
3379 Int_t nclusters=fSectors[sec][row0];
3380 AliTPCseed * seed = new AliTPCseed;
3381
3382 Int_t sumused=0;
3383 Int_t cused=0;
3384 Int_t cnused=0;
3385 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3386 Int_t nfound =0;
3387 Int_t nfoundable =0;
3388 for (Int_t iter =1; iter<2; iter++){ //iterations
3389 const AliTPCRow& krm=fSectors[sec][row0-iter];
3390 const AliTPCRow& krp=fSectors[sec][row0+iter];
3391 const AliTPCclusterMI * cl= kr0[is];
3392
3393 if (cl->IsUsed(10)) {
3394 cused++;
3395 }
3396 else{
3397 cnused++;
3398 }
3399 Double_t x = kr0.GetX();
3400 // Initialization of the polytrack
3401 nfound =0;
3402 nfoundable =0;
3403 polytrack.Reset();
3404 //
3405 Double_t y0= cl->GetY();
3406 Double_t z0= cl->GetZ();
3407 Float_t erry = 0;
3408 Float_t errz = 0;
3409
3410 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3411 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3412
3413 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3414 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3415 polytrack.AddPoint(x,y0,z0,erry, errz);
3416
3417 sumused=0;
3418 if (cl->IsUsed(10)) sumused++;
3419
3420
3421 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3422 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3423 //
3424 x = krm.GetX();
3425 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3426 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3427 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3428 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3429 if (cl1->IsUsed(10)) sumused++;
3430 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3431 }
3432 //
3433 x = krp.GetX();
3434 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3435 if (cl2) {
3436 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3437 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3438 if (cl2->IsUsed(10)) sumused++;
3439 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3440 }
3441 //
3442 if (sumused>0) continue;
3443 nin0++;
3444 polytrack.UpdateParameters();
3445 // follow polytrack
3446 roadz = 1.2;
3447 roady = 1.2;
3448 //
3449 Double_t yn,zn;
3450 nfoundable = polytrack.GetN();
3451 nfound = nfoundable;
3452 //
3453 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3454 Float_t maxdist = 0.8*(1.+3./(ddrow));
3455 for (Int_t delta = -1;delta<=1;delta+=2){
3456 Int_t row = row0+ddrow*delta;
3457 kr = &(fSectors[sec][row]);
3458 Double_t xn = kr->GetX();
3459 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3460 polytrack.GetFitPoint(xn,yn,zn);
3461 if (TMath::Abs(yn)>ymax) continue;
3462 nfoundable++;
3463 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3464 if (cln) {
3465 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3466 if (dist<maxdist){
3467 /*
3468 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3469 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3470 if (cln->IsUsed(10)) {
3471 // printf("used\n");
3472 sumused++;
3473 erry*=2;
3474 errz*=2;
3475 }
3476 */
3477 erry=0.1;
3478 errz=0.1;
3479 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3480 nfound++;
3481 }
3482 }
3483 }
3484 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3485 polytrack.UpdateParameters();
3486 }
3487 }
3488 if ( (sumused>3) || (sumused>0.5*nfound)) {
3489 //printf("sumused %d\n",sumused);
3490 continue;
3491 }
3492 nin1++;
3493 Double_t dy,dz;
3494 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3495 AliTPCpolyTrack track2;
3496
3497 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3498 if (track2.GetN()<0.5*nfoundable) continue;
3499 nin2++;
3500
3501 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3502 //
3503 // test seed with and without constrain
3504 for (Int_t constrain=0; constrain<=0;constrain++){
3505 // add polytrack candidate
3506
3507 Double_t x[5], c[15];
3508 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3509 track2.GetBoundaries(x3,x1);
3510 x2 = (x1+x3)/2.;
3511 track2.GetFitPoint(x1,y1,z1);
3512 track2.GetFitPoint(x2,y2,z2);
3513 track2.GetFitPoint(x3,y3,z3);
3514 //
3515 //is track pointing to the vertex ?
3516 Double_t x0,y0,z0;
3517 x0=0;
3518 polytrack.GetFitPoint(x0,y0,z0);
3519
3520 if (constrain) {
3521 x2 = x3;
3522 y2 = y3;
3523 z2 = z3;
3524
3525 x3 = 0;
3526 y3 = 0;
3527 z3 = 0;
3528 }
3529 x[0]=y1;
3530 x[1]=z1;
b67e07dc 3531 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3532
3533 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
b67e07dc 3534 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3535
3536 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
b67e07dc 3537 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3538 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
91162307 3539 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3540
3541
3542 Double_t sy =0.1, sz =0.1;
3543 Double_t sy1=0.02, sz1=0.02;
3544 Double_t sy2=0.02, sz2=0.02;
3545 Double_t sy3=0.02;
3546
3547 if (constrain){
3548 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3549 }
3550
b67e07dc 3551 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3552 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3553 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3554 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3555 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3556 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3557
3558 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3559 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3560 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3561 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
91162307 3562
3563
3564 c[0]=sy1;
3565 c[1]=0.; c[2]=sz1;
3566 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3567 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3568 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3569 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3570 c[13]=f30*sy1*f40+f32*sy2*f42;
3571 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3572
3573 //Int_t row1 = fSectors->GetRowNumber(x1);
3574 Int_t row1 = GetRowNumber(x1);
3575
3576 UInt_t index=0;
3577 //kr0.GetIndex(is);
3578 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3579 track->fIsSeeding = kTRUE;
3580 Int_t rc=FollowProlongation(*track, i2);
3581 if (constrain) track->fBConstrain =1;
3582 else
3583 track->fBConstrain =0;
3584 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3585 track->fFirstPoint = track->fLastPoint;
3586
3587 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3588 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3589 track->fNShared>0.4*track->GetNumberOfClusters()) {
3590 //delete track;
3591 seed->Reset();
3592 seed->~AliTPCseed();
3593 }
3594 else {
3595 arr->AddLast(track);
3596 seed = new AliTPCseed;
3597 }
3598 nin3++;
3599 }
3600 } // if accepted seed
3601 }
6bdc18d6 3602 if (fDebug>3){
3603 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
91162307 3604 }
3605 delete seed;
3606}
3607
3608
3609AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3610{
3611 //
3612 //
d26d9159 3613 //reseed using track points
91162307 3614 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3615 Int_t p1 = int(r1*track->GetNumberOfClusters());
3616 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
176aff27 3617 Int_t pp2=0;
91162307 3618 Double_t x0[3],x1[3],x2[3];
89e09524 3619 for (Int_t i=0;i<3;i++){
3620 x0[i]=-1;
3621 x1[i]=-1;
3622 x2[i]=-1;
3623 }
91162307 3624
3625 // find track position at given ratio of the length
89e09524 3626 Int_t sec0=0, sec1=0, sec2=0;
91162307 3627 Int_t index=-1;
3628 Int_t clindex;
3629 for (Int_t i=0;i<160;i++){
3630 if (track->fClusterPointer[i]){
3631 index++;
3632 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3633 if ( (index<p0) || x0[0]<0 ){
3634 if (trpoint->GetX()>1){
3635 clindex = track->GetClusterIndex2(i);
3636 if (clindex>0){
3637 x0[0] = trpoint->GetX();
3638 x0[1] = trpoint->GetY();
3639 x0[2] = trpoint->GetZ();
3640 sec0 = ((clindex&0xff000000)>>24)%18;
3641 }
3642 }
3643 }
3644
3645 if ( (index<p1) &&(trpoint->GetX()>1)){
3646 clindex = track->GetClusterIndex2(i);
3647 if (clindex>0){
3648 x1[0] = trpoint->GetX();
3649 x1[1] = trpoint->GetY();
3650 x1[2] = trpoint->GetZ();
3651 sec1 = ((clindex&0xff000000)>>24)%18;
3652 }
3653 }
3654 if ( (index<p2) &&(trpoint->GetX()>1)){
3655 clindex = track->GetClusterIndex2(i);
3656 if (clindex>0){
3657 x2[0] = trpoint->GetX();
3658 x2[1] = trpoint->GetY();
3659 x2[2] = trpoint->GetZ();
3660 sec2 = ((clindex&0xff000000)>>24)%18;
3661 pp2 = i;
3662 }
3663 }
3664 }
3665 }
3666
3667 Double_t alpha, cs,sn, xx2,yy2;
3668 //
3669 alpha = (sec1-sec2)*fSectors->GetAlpha();
3670 cs = TMath::Cos(alpha);
3671 sn = TMath::Sin(alpha);
3672 xx2= x1[0]*cs-x1[1]*sn;
3673 yy2= x1[0]*sn+x1[1]*cs;
3674 x1[0] = xx2;
3675 x1[1] = yy2;
3676 //
3677 alpha = (sec0-sec2)*fSectors->GetAlpha();
3678 cs = TMath::Cos(alpha);
3679 sn = TMath::Sin(alpha);
3680 xx2= x0[0]*cs-x0[1]*sn;
3681 yy2= x0[0]*sn+x0[1]*cs;
3682 x0[0] = xx2;
3683 x0[1] = yy2;
3684 //
3685 //
3686 //
3687 Double_t x[5],c[15];
3688 //
3689 x[0]=x2[1];
3690 x[1]=x2[2];
b67e07dc 3691 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
91162307 3692 // if (x[4]>1) return 0;
b67e07dc 3693 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3694 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
91162307 3695 //if (TMath::Abs(x[3]) > 2.2) return 0;
3696 //if (TMath::Abs(x[2]) > 1.99) return 0;
3697 //
3698 Double_t sy =0.1, sz =0.1;
3699 //
3700 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3701 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3702 Double_t sy3=0.01+track->GetSigmaY2();
3703 //
b67e07dc 3704 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3705 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3706 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3707 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3708 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3709 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3710 //
3711 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3712 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3713 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3714 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
91162307 3715
3716
3717 c[0]=sy1;
3718 c[1]=0.; c[2]=sz1;
3719 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3720 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3721 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3722 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3723 c[13]=f30*sy1*f40+f32*sy2*f42;
3724 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3725
3726 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3727 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3728 // Double_t y0,z0,y1,z1, y2,z2;
3729 //seed->GetProlongation(x0[0],y0,z0);
3730 // seed->GetProlongation(x1[0],y1,z1);
3731 //seed->GetProlongation(x2[0],y2,z2);
3732 // seed =0;
3733 seed->fLastPoint = pp2;
3734 seed->fFirstPoint = pp2;
3735
3736
3737 return seed;
3738}
3739
d26d9159 3740
3741AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3742{
3743 //
3744 //
3745 //reseed using founded clusters
3746 //
3747 // Find the number of clusters
3748 Int_t nclusters = 0;
3749 for (Int_t irow=0;irow<160;irow++){
3750 if (track->GetClusterIndex(irow)>0) nclusters++;
3751 }
3752 //
3753 Int_t ipos[3];
3754 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3755 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3756 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3757 //
3758 //
3759 Double_t xyz[3][3];
3760 Int_t row[3],sec[3]={0,0,0};
3761 //
3762 // find track row position at given ratio of the length
3763 Int_t index=-1;
3764 for (Int_t irow=0;irow<160;irow++){
3765 if (track->GetClusterIndex2(irow)<0) continue;
3766 index++;
3767 for (Int_t ipoint=0;ipoint<3;ipoint++){
3768 if (index<=ipos[ipoint]) row[ipoint] = irow;
3769 }
3770 }
3771 //
3772 //Get cluster and sector position
3773 for (Int_t ipoint=0;ipoint<3;ipoint++){
3774 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3775 AliTPCclusterMI * cl = GetClusterMI(clindex);
3776 if (cl==0) {
6bdc18d6 3777 //Error("Bug\n");
47966a6d 3778 // AliTPCclusterMI * cl = GetClusterMI(clindex);
d26d9159 3779 return 0;
3780 }
3781 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3782 xyz[ipoint][0] = GetXrow(row[ipoint]);
3783 xyz[ipoint][1] = cl->GetY();
3784 xyz[ipoint][2] = cl->GetZ();
3785 }
3786 //
3787 //
3788 // Calculate seed state vector and covariance matrix
3789
3790 Double_t alpha, cs,sn, xx2,yy2;
3791 //
3792 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3793 cs = TMath::Cos(alpha);
3794 sn = TMath::Sin(alpha);
3795 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3796 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3797 xyz[1][0] = xx2;
3798 xyz[1][1] = yy2;
3799 //
3800 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3801 cs = TMath::Cos(alpha);
3802 sn = TMath::Sin(alpha);
3803 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3804 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3805 xyz[0][0] = xx2;
3806 xyz[0][1] = yy2;
3807 //
3808 //
3809 //
3810 Double_t x[5],c[15];
3811 //
3812 x[0]=xyz[2][1];
3813 x[1]=xyz[2][2];
3814 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3815 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3816 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3817 //
3818 Double_t sy =0.1, sz =0.1;
3819 //
3820 Double_t sy1=0.2, sz1=0.2;
3821 Double_t sy2=0.2, sz2=0.2;
3822 Double_t sy3=0.2;
3823 //
3824 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;
3825 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;
3826 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;
3827 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;
3828 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;
3829 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;
3830 //
3831 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;
3832 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;
3833 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;
3834 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;
3835
3836
3837 c[0]=sy1;
3838 c[1]=0.; c[2]=sz1;
3839 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3840 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3841 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3842 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3843 c[13]=f30*sy1*f40+f32*sy2*f42;
3844 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3845
3846 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3847 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3848 seed->fLastPoint = row[2];
3849 seed->fFirstPoint = row[2];
3850 return seed;
3851}
3852
eea478d3 3853
3854AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3855{
3856 //
3857 //
3858 //reseed using founded clusters
3859 //
3860 Double_t xyz[3][3];
4a12af72 3861 Int_t row[3]={0,0,0};
3862 Int_t sec[3]={0,0,0};
eea478d3 3863 //
3864 // forward direction
3865 if (forward){
3866 for (Int_t irow=r0;irow<160;irow++){
3867 if (track->GetClusterIndex(irow)>0){
3868 row[0] = irow;
3869 break;
3870 }
3871 }
3872 for (Int_t irow=160;irow>r0;irow--){
3873 if (track->GetClusterIndex(irow)>0){
3874 row[2] = irow;
3875 break;
3876 }
3877 }
3878 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3879 if (track->GetClusterIndex(irow)>0){
3880 row[1] = irow;
3881 break;
3882 }
3883 }
3884 //
3885 }
3886 if (!forward){
3887 for (Int_t irow=0;irow<r0;irow++){
3888 if (track->GetClusterIndex(irow)>0){
3889 row[0] = irow;
3890 break;
3891 }
3892 }
3893 for (Int_t irow=r0;irow>0;irow--){
3894 if (track->GetClusterIndex(irow)>0){
3895 row[2] = irow;
3896 break;
3897 }
3898 }
3899 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3900 if (track->GetClusterIndex(irow)>0){
3901 row[1] = irow;
3902 break;
3903 }
3904 }
3905 }
3906 //
3907 if ((row[2]-row[0])<20) return 0;
3908 if (row[1]==0) return 0;
3909 //
3910 //
3911 //Get cluster and sector position
3912 for (Int_t ipoint=0;ipoint<3;ipoint++){
3913 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3914 AliTPCclusterMI * cl = GetClusterMI(clindex);
3915 if (cl==0) {
3916 //Error("Bug\n");
3917 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3918 return 0;
3919 }
3920 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3921 xyz[ipoint][0] = GetXrow(row[ipoint]);
3922 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3923 if (point&&ipoint<2){
3924 //
3925 xyz[ipoint][1] = point->GetY();
3926 xyz[ipoint][2] = point->GetZ();
3927 }
3928 else{
3929 xyz[ipoint][1] = cl->GetY();
3930 xyz[ipoint][2] = cl->GetZ();
3931 }
3932 }
3933 //
3934 //
3935 //
3936 //
3937 // Calculate seed state vector and covariance matrix
3938
3939 Double_t alpha, cs,sn, xx2,yy2;
3940 //
3941 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3942 cs = TMath::Cos(alpha);
3943 sn = TMath::Sin(alpha);
3944 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3945 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3946 xyz[1][0] = xx2;
3947 xyz[1][1] = yy2;
3948 //
3949 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3950 cs = TMath::Cos(alpha);
3951 sn = TMath::Sin(alpha);
3952 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3953 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3954 xyz[0][0] = xx2;
3955 xyz[0][1] = yy2;
3956 //
3957 //
3958 //
3959 Double_t x[5],c[15];
3960 //
3961 x[0]=xyz[2][1];
3962 x[1]=xyz[2][2];
3963 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3964 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3965 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3966 //
3967 Double_t sy =0.1, sz =0.1;
3968 //
3969 Double_t sy1=0.2, sz1=0.2;
3970 Double_t sy2=0.2, sz2=0.2;
3971 Double_t sy3=0.2;
3972 //
3973 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;
3974 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;
3975 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;
3976 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;
3977 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;
3978 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;
3979 //
3980 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;
3981 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;
3982 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;
3983 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;
3984
3985
3986 c[0]=sy1;
3987 c[1]=0.; c[2]=sz1;
3988 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3989 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3990 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3991 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3992 c[13]=f30*sy1*f40+f32*sy2*f42;
3993 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3994
3995 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3996 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3997 seed->fLastPoint = row[2];
3998 seed->fFirstPoint = row[2];
3999 for (Int_t i=row[0];i<row[2];i++){
4000 seed->fIndex[i] = track->fIndex[i];
4001 }
4002
4003 return seed;
4004}
4005
51ad6848 4006void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4007{
4008 //
4009 // find kinks
4010 //
4011 //
eea478d3 4012
51ad6848 4013 TObjArray *kinks= new TObjArray(10000);
81e97e0d 4014 // TObjArray *v0s= new TObjArray(10000);
51ad6848 4015 Int_t nentries = array->GetEntriesFast();
4016 AliHelix *helixes = new AliHelix[nentries];
4017 Int_t *sign = new Int_t[nentries];
4018 Int_t *nclusters = new Int_t[nentries];
4019 Float_t *alpha = new Float_t[nentries];
4020 AliESDkink * kink = new AliESDkink();
4021 Int_t * usage = new Int_t[nentries];
eea478d3 4022 Float_t *zm = new Float_t[nentries];
4023 Float_t *z0 = new Float_t[nentries];
4024 Float_t *fim = new Float_t[nentries];
4025 Float_t *shared = new Float_t[nentries];
4026 Bool_t *circular = new Bool_t[nentries];
81e97e0d 4027 Float_t *dca = new Float_t[nentries];
4028 //const AliESDVertex * primvertex = esd->GetVertex();
eea478d3 4029 //
4030 // nentries = array->GetEntriesFast();
4031 //
4032
51ad6848 4033 //
4034 //
4035 for (Int_t i=0;i<nentries;i++){
4036 sign[i]=0;
4037 usage[i]=0;
4038 AliTPCseed* track = (AliTPCseed*)array->At(i);
4039 if (!track) continue;
81e97e0d 4040 track->fCircular =0;
eea478d3 4041 shared[i] = kFALSE;
51ad6848 4042 track->UpdatePoints();
4043 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
51ad6848 4044 }
eea478d3 4045 nclusters[i]=track->GetNumberOfClusters();
4046 alpha[i] = track->GetAlpha();
4047 new (&helixes[i]) AliHelix(*track);
4048 Double_t xyz[3];
4049 helixes[i].Evaluate(0,xyz);
4050 sign[i] = (track->GetC()>0) ? -1:1;
4051 Double_t x,y,z;
4052 x=160;
4053 if (track->GetProlongation(x,y,z)){
4054 zm[i] = z;
4055 fim[i] = alpha[i]+TMath::ATan2(y,x);
4056 }
4057 else{
4058 zm[i] = track->GetZ();
4059 fim[i] = alpha[i];
4060 }
4061 z0[i]=1000;
4062 circular[i]= kFALSE;
81e97e0d 4063 if (track->GetProlongation(0,y,z)) z0[i] = z;
4064 dca[i] = track->GetD(0,0);
51ad6848 4065 }
4066 //
4067 //
4068 TStopwatch timer;
4069 timer.Start();
4070 Int_t ncandidates =0;
4071 Int_t nall =0;
4072 Int_t ntracks=0;
4073 Double_t phase[2][2],radius[2];
eea478d3 4074
4075 //
4076 // Find circling track
81e97e0d 4077 TTreeSRedirector &cstream = *fDebugStreamer;
eea478d3 4078 //
4079 for (Int_t i0=0;i0<nentries;i0++){
4080 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4081 if (!track0) continue;
4082 if (track0->fN<40) continue;
4083 if (TMath::Abs(1./track0->fP4)>200) continue;
4084 for (Int_t i1=i0+1;i1<nentries;i1++){
4085 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4086 if (!track1) continue;
81e97e0d 4087 if (track1->fN<40) continue;
4088 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
eea478d3 4089 if (track0->fBConstrain&&track1->fBConstrain) continue;
81e97e0d 4090 if (TMath::Abs(1./track1->fP4)>200) continue;
4091 if (track1->fP4*track0->fP4>0) continue;
4092 if (track1->fP3*track0->fP3>0) continue;
eea478d3 4093 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
4094 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
4095 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
4096 //
81e97e0d 4097 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4098 if (mindcar<5) continue;
4099 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4100 if (mindcaz<5) continue;
4101 if (mindcar+mindcaz<20) continue;
4102 //
4103 //
eea478d3 4104 Float_t xc0 = helixes[i0].GetHelix(6);
4105 Float_t yc0 = helixes[i0].GetHelix(7);
4106 Float_t r0 = helixes[i0].GetHelix(8);
4107 Float_t xc1 = helixes[i1].GetHelix(6);
4108 Float_t yc1 = helixes[i1].GetHelix(7);
4109 Float_t r1 = helixes[i1].GetHelix(8);
4110
4111 Float_t rmean = (r0+r1)*0.5;
4112 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
81e97e0d 4113 //if (delta>30) continue;
eea478d3 4114 if (delta>rmean*0.25) continue;
4115 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4116 //
4117 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4118 if (npoints==0) continue;
4119 helixes[i0].GetClosestPhases(helixes[i1], phase);
4120 //
4121 Double_t xyz0[3];
4122 Double_t xyz1[3];
4123 Double_t hangles[3];
4124 helixes[i0].Evaluate(phase[0][0],xyz0);
4125 helixes[i1].Evaluate(phase[0][1],xyz1);
4126
4127 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4128 Double_t deltah[2],deltabest;
4129 if (hangles[2]<2.8) continue;
4130 /*
4131 cstream<<"C"<<track0->fLab<<track1->fLab<<
4132 track0->fP3<<track1->fP3<<
4133 track0->fP4<<track1->fP4<<
4134 delta<<rmean<<npoints<<
4135 hangles[0]<<hangles[2]<<
4136 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4137 */
4138 if (npoints>0){
4139 Int_t ibest=0;
81e97e0d 4140 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
eea478d3 4141 if (npoints==2){
81e97e0d 4142 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
eea478d3 4143 if (deltah[1]<deltah[0]) ibest=1;
4144 }
4145 deltabest = TMath::Sqrt(deltah[ibest]);
4146 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4147 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4148 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
81e97e0d 4149 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
eea478d3 4150 //
81e97e0d 4151 if (deltabest>6) continue;
4152 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
eea478d3 4153 Bool_t sign =kFALSE;
81e97e0d 4154 if (hangles[2]>3.06) sign =kTRUE;
4155 //
eea478d3 4156 if (sign){
4157 circular[i0] = kTRUE;
81e97e0d 4158 circular[i1] = kTRUE;
4159 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4160 track0->fCircular += 1;
4161 track1->fCircular += 2;
4162 }
4163 else{
4164 track1->fCircular += 1;
4165 track0->fCircular += 2;
4166 }
4167 }
34acb742 4168 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4169 //debug stream
81e97e0d 4170 cstream<<"Curling"<<
4171 "lab0="<<track0->fLab<<
4172 "lab1="<<track1->fLab<<
4173 "Tr0.="<<track0<<
4174 "Tr1.="<<track1<<
4175 "dca0="<<dca[i0]<<
4176 "dca1="<<dca[i1]<<
4177 "mindcar="<<mindcar<<
4178 "mindcaz="<<mindcaz<<
4179 "delta="<<delta<<
4180 "rmean="<<rmean<<
4181 "npoints="<<npoints<<
4182 "hangles0="<<hangles[0]<<
4183 "hangles2="<<hangles[2]<<
4184 "xyz0="<<xyz0[2]<<
4185 "xyzz1="<<xyz1[2]<<
4186 "z0="<<z0[i0]<<
4187 "z1="<<z0[i1]<<
4188 "radius="<<radiusbest<<
4189 "deltabest="<<deltabest<<
4190 "phase0="<<phase[ibest][0]<<
4191 "phase1="<<phase[ibest][1]<<
4192 "\n";
eea478d3 4193 }
4194 }
4195 }
4196 }
4197 //
81e97e0d 4198 // Finf kinks loop
4199 //
51ad6848 4200 //
4201 for (Int_t i =0;i<nentries;i++){
4202 if (sign[i]==0) continue;
4203 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4204 ntracks++;
4205 //
4206 Double_t cradius0 = 40*40;
4207 Double_t cradius1 = 270*270;
4208 Double_t cdist1=8.;
4209 Double_t cdist2=8.;
4210 Double_t cdist3=0.55;
4211 for (Int_t j =i+1;j<nentries;j++){
4212 nall++;
4213 if (sign[j]*sign[i]<1) continue;
4214 if ( (nclusters[i]+nclusters[j])>200) continue;
4215 if ( (nclusters[i]+nclusters[j])<80) continue;
4216 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4217 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4218 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4219 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4220 if (npoints<1) continue;
4221 // cuts on radius
4222 if (npoints==1){
4223 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4224 }
4225 else{
4226 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4227 }
4228 //
4229 Double_t delta1=10000,delta2=10000;
4230 // cuts on the intersection radius
4231 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4232 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4233 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4234 if (npoints==2){
4235 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4236 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4237 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4238 }
4239 //
4240 Double_t distance1 = TMath::Min(delta1,delta2);
4241 if (distance1>cdist1) continue; // cut on DCA linear approximation
4242 //
4243 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4244 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4245 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4246 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4247 //
4248 if (npoints==2){
4249 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4250 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4251 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4252 }
4253 distance1 = TMath::Min(delta1,delta2);
4254 Float_t rkink =0;
4255 if (delta1<delta2){
4256 rkink = TMath::Sqrt(radius[0]);
4257 }
4258 else{
4259 rkink = TMath::Sqrt(radius[1]);
4260 }
4261 if (distance1>cdist2) continue;
4262 //
4263 //
4264 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4265 //
4266 //
4267 Int_t row0 = GetRowNumber(rkink);
4268 if (row0<10) continue;
4269 if (row0>150) continue;
4270 //
4271 //
4272 Float_t dens00=-1,dens01=-1;
4273 Float_t dens10=-1,dens11=-1;
4274 //
4275 Int_t found,foundable,shared;
4276 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4277 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4278 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4279 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4280 //
4281 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4282 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4283 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4284 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
eea478d3 4285 //
51ad6848 4286 if (dens00<dens10 && dens01<dens11) continue;
4287 if (dens00>dens10 && dens01>dens11) continue;
4288 if (TMath::Max(dens00,dens10)<0.1) continue;
4289 if (TMath::Max(dens01,dens11)<0.3) continue;
4290 //
4291 if (TMath::Min(dens00,dens10)>0.6) continue;
4292 if (TMath::Min(dens01,dens11)>0.6) continue;
4293
4294 //
4295 AliTPCseed * ktrack0, *ktrack1;
4296 if (dens00>dens10){
4297 ktrack0 = track0;
4298 ktrack1 = track1;
4299 }
4300 else{
4301 ktrack0 = track1;
4302 ktrack1 = track0;
4303 }
4304 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4305 AliExternalTrackParam paramm(*ktrack0);
4306 AliExternalTrackParam paramd(*ktrack1);
c9ec41e8 4307 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (&paramd) AliExternalTrackParam(ktrack1->GetReference());
51ad6848 4308 //
4309 //
4310 kink->SetMother(paramm);
4311 kink->SetDaughter(paramd);
4312 kink->Update();
4313
eea478d3 4314 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
51ad6848 4315 Int_t index[4];
4316 fParam->Transform0to1(x,index);
4317 fParam->Transform1to2(x,index);
4318 row0 = GetRowNumber(x[0]);
4319
eea478d3 4320 if (kink->GetR()<100) continue;
4321 if (kink->GetR()>240) continue;
4322 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4323 if (kink->GetDistance()>cdist3) continue;
4324 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
51ad6848 4325 if (dird<0) continue;
4326
eea478d3 4327 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
51ad6848 4328 if (dirm<0) continue;
eea478d3 4329 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
51ad6848 4330 if (mpt<0.2) continue;
4331
eea478d3 4332 if (mpt<1){
4333 //for high momenta momentum not defined well in first iteration
4334 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4335 if (qt>0.35) continue;
4336 }
51ad6848 4337
eea478d3 4338 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4339 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
51ad6848 4340 if (dens00>dens10){
eea478d3 4341 kink->SetTPCDensity(dens00,0,0);
4342 kink->SetTPCDensity(dens01,0,1);
4343 kink->SetTPCDensity(dens10,1,0);
4344 kink->SetTPCDensity(dens11,1,1);
4345 kink->SetIndex(i,0);
4346 kink->SetIndex(j,1);
51ad6848 4347 }
4348 else{
eea478d3 4349 kink->SetTPCDensity(dens10,0,0);
4350 kink->SetTPCDensity(dens11,0,1);
4351 kink->SetTPCDensity(dens00,1,0);
4352 kink->SetTPCDensity(dens01,1,1);
4353 kink->SetIndex(j,0);
4354 kink->SetIndex(i,1);
51ad6848 4355 }
51ad6848 4356
eea478d3 4357 if (mpt<1||kink->GetAngle(2)>0.1){
4358 // angle and densities not defined yet
4359 if (kink->GetTPCDensityFactor()<0.8) continue;
4360 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4361 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4362 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4363 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4364
4365 Float_t criticalangle = track0->fC22+track0->fC33;
4366 criticalangle+= track1->fC22+track1->fC33;
4367 criticalangle= 3*TMath::Sqrt(criticalangle);
4368 if (criticalangle>0.02) criticalangle=0.02;
4369 if (kink->GetAngle(2)<criticalangle) continue;
4370 }
51ad6848 4371 //
eea478d3 4372 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
51ad6848 4373 Float_t shapesum =0;
4374 Float_t sum = 0;
4375 for ( Int_t row = row0-drow; row<row0+drow;row++){
4376 if (row<0) continue;
4377 if (row>155) continue;
4378 if (ktrack0->fClusterPointer[row]){
4379 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4380 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4381 sum++;
4382 }
4383 if (ktrack1->fClusterPointer[row]){
4384 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4385 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4386 sum++;
4387 }
4388 }
4389 if (sum<4){
eea478d3 4390 kink->SetShapeFactor(-1.);
51ad6848 4391 }
4392 else{
eea478d3 4393 kink->SetShapeFactor(shapesum/sum);
4394 }
51ad6848 4395 // esd->AddKink(kink);
4396 kinks->AddLast(kink);
4397 kink = new AliESDkink;
4398 ncandidates++;
4399 }
4400 }
eea478d3 4401 //
4402 // sort the kinks according quality - and refit them towards vertex
4403 //
4404 Int_t nkinks = kinks->GetEntriesFast();
4405 Float_t *quality = new Float_t[nkinks];
4406 Int_t *indexes = new Int_t[nkinks];
4407 AliTPCseed *mothers = new AliTPCseed[nkinks];
4408 AliTPCseed *daughters = new AliTPCseed[nkinks];
4409 //
4410 //
51ad6848 4411 for (Int_t i=0;i<nkinks;i++){
4412 quality[i] =100000;
4413 AliESDkink *kink = (AliESDkink*)kinks->At(i);
eea478d3 4414 //
4415 // refit kinks towards vertex
4416 //
4417 Int_t index0 = kink->GetIndex(0);
4418 Int_t index1 = kink->GetIndex(1);
4419 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4420 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4421 //
4422 Int_t sumn=ktrack0->fN+ktrack1->fN;
4423 //
4424 // Refit Kink under if too small angle
4425 //
4426 if (kink->GetAngle(2)<0.05){
4427 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4428 Int_t row0 = kink->GetTPCRow0();
4429 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4430 //
4431 //
4432 Int_t last = row0-drow;
4433 if (last<40) last=40;
4434 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4435 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4436 //
4437 //
4438 Int_t first = row0+drow;
4439 if (first>130) first=130;
4440 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4441 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4442 //
4443 if (seed0 && seed1){
4444 kink->SetStatus(1,8);
4445 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4446 row0 = GetRowNumber(kink->GetR());
4447 sumn = seed0->fN+seed1->fN;
4448 new (&mothers[i]) AliTPCseed(*seed0);
4449 new (&daughters[i]) AliTPCseed(*seed1);
4450 }
4451 else{
4452 delete kinks->RemoveAt(i);
4453 if (seed0) delete seed0;
4454 if (seed1) delete seed1;
4455 continue;
4456 }
4457 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4458 delete kinks->RemoveAt(i);
4459 if (seed0) delete seed0;
4460 if (seed1) delete seed1;
4461 continue;
4462 }
4463 //
4464 delete seed0;
4465 delete seed1;
4466 }
4467 //
4468 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
51ad6848 4469 }
4470 TMath::Sort(nkinks,quality,indexes,kFALSE);
eea478d3 4471 //
4472 //remove double find kinks
4473 //
4474 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4475 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4476 if (!kink0) continue;
4477 //
4478 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4479 if (!kink0) continue;
4480 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4481 if (!kink1) continue;
4482 // if not close kink continue
4483 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4484 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4485 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4486 //
4487 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4488 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4489 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4490 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4491 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4492 //
4493 Int_t same = 0;
4494 Int_t both = 0;
4495 Int_t samem = 0;
4496 Int_t bothm = 0;
4497 Int_t samed = 0;
4498 Int_t bothd = 0;
4499 //
4500 for (Int_t i=0;i<row0;i++){
4501 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4502 both++;
4503 bothm++;
4504 if (mother0.fIndex[i]==mother1.fIndex[i]){
4505 same++;
4506 samem++;
4507 }
4508 }
4509 }
4510
4511 for (Int_t i=row0;i<158;i++){
4512 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4513 both++;
4514 bothd++;
4515 if (mother0.fIndex[i]==mother1.fIndex[i]){
4516 same++;
4517 samed++;
4518 }
4519 }
4520 }
4521 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4522 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4523 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4524 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4525 Int_t sum0 = mother0.fN+daughter0.fN;
4526 Int_t sum1 = mother1.fN+daughter1.fN;
4527 if (sum1>sum0){
4528 shared[kink0->GetIndex(0)]= kTRUE;
4529 shared[kink0->GetIndex(1)]= kTRUE;
4530 delete kinks->RemoveAt(indexes[ikink0]);
4531 }
4532 else{
4533 shared[kink1->GetIndex(0)]= kTRUE;
4534 shared[kink1->GetIndex(1)]= kTRUE;
4535 delete kinks->RemoveAt(indexes[ikink1]);
4536 }
4537 }
4538 }
4539 }
4540
4541
51ad6848 4542 for (Int_t i=0;i<nkinks;i++){
4543 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
eea478d3 4544 if (!kink) continue;
4545 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4546 Int_t index0 = kink->GetIndex(0);
4547 Int_t index1 = kink->GetIndex(1);
4548 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4549 kink->SetMultiple(usage[index0],0);
4550 kink->SetMultiple(usage[index1],1);
4551 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4552 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4553 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4554 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
51ad6848 4555
51ad6848 4556 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4557 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
eea478d3 4558 if (!ktrack0 || !ktrack1) continue;
4559 Int_t index = esd->AddKink(kink);
4560 //
4561 //
4562 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4563 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4564 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4565 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4566 }
4567 }
4568 //
51ad6848 4569 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4570 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4571 usage[index0]++;
4572 usage[index1]++;
4573 }
eea478d3 4574 //
4575 // Remove tracks corresponding to shared kink's
4576 //
4577 for (Int_t i=0;i<nentries;i++){
4578 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4579 if (!track0) continue;
4580 if (track0->fKinkIndexes[0]!=0) continue;
4581 if (shared[i]) delete array->RemoveAt(i);
4582 }
51ad6848 4583
eea478d3 4584 //
4585 //
4586 RemoveUsed2(array,0.5,0.4,30);
4587 UnsignClusters();
81e97e0d 4588 for (Int_t i=0;i<nentries;i++){
4589 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4590 if (!track0) continue;
4591 track0->CookdEdx(0.02,0.6);
4592 track0->CookPID();
4593 }
eea478d3 4594 //
4595 for (Int_t i=0;i<nentries;i++){
4596 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4597 if (!track0) continue;
4598 if (track0->Pt()<1.4) continue;
4599 //remove double high momenta tracks - overlapped with kink candidates
4600 Int_t shared=0;
4601 Int_t all =0;
4602 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4603 if (track0->fClusterPointer[icl]!=0){
4604 all++;
4605 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4606 }
4607 }
4608 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4609 delete array->RemoveAt(i);
f99dc368 4610 continue;
eea478d3 4611 }
4612 //
4613 if (track0->fKinkIndexes[0]!=0) continue;
4614 if (track0->GetNumberOfClusters()<80) continue;
4a12af72 4615
4616 AliTPCseed *pmother = new AliTPCseed();
4617 AliTPCseed *pdaughter = new AliTPCseed();
4618 AliESDkink *pkink = new AliESDkink;
4619
4620 AliTPCseed & mother = *pmother;
4621 AliTPCseed & daughter = *pdaughter;
4622 AliESDkink & kink = *pkink;
eea478d3 4623 if (CheckKinkPoint(track0,mother,daughter, kink)){
4a12af72 4624 if (mother.fN<30||daughter.fN<20) {
4625 delete pmother;
4626 delete pdaughter;
4627 delete pkink;
4628 continue; //too short tracks
4629 }
4630 if (mother.Pt()<1.4) {
4631 delete pmother;
4632 delete pdaughter;
4633 delete pkink;
4634 continue;
4635 }
eea478d3 4636 Int_t row0= kink.GetTPCRow0();
4637 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4a12af72 4638 delete pmother;
4639 delete pdaughter;
4640 delete pkink;
eea478d3 4641 continue;
4642 }
4643 //
4644 Int_t index = esd->AddKink(&kink);
4645 mother.fKinkIndexes[0] = -(index+1);
4646 daughter.fKinkIndexes[0] = index+1;
4647 if (mother.fN>50) {
4648 delete array->RemoveAt(i);
4649 array->AddAt(new AliTPCseed(mother),i);
4650 }
4651 else{
4652 array->AddLast(new AliTPCseed(mother));
4653 }
4654 array->AddLast(new AliTPCseed(daughter));
4655 for (Int_t icl=0;icl<row0;icl++) {
4656 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4657 }
4658 //
4659 for (Int_t icl=row0;icl<158;icl++) {
4660 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4661 }
4662 //
4663 }
4a12af72 4664 delete pmother;
4665 delete pdaughter;
4666 delete pkink;
eea478d3 4667 }
4668
4669 delete [] daughters;
4670 delete [] mothers;
4671 //
4672 //
81e97e0d 4673 delete [] dca;
eea478d3 4674 delete []circular;
4675 delete []shared;
4676 delete []quality;
4677 delete []indexes;
4678 //
4679 delete kink;
4680 delete[]fim;
51ad6848 4681 delete[] zm;
eea478d3 4682 delete[] z0;
51ad6848 4683 delete [] usage;
4684 delete[] alpha;
4685 delete[] nclusters;
4686 delete[] sign;
4687 delete[] helixes;
4688 kinks->Delete();
4689 delete kinks;
4690
eea478d3 4691 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
51ad6848 4692 timer.Print();
4693}
4694
81e97e0d 4695void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4696{
4697 //
4698 // find V0s
4699 //
4700 //
4701 TObjArray *tpcv0s = new TObjArray(100000);
4702 Int_t nentries = array->GetEntriesFast();
4703 AliHelix *helixes = new AliHelix[nentries];
4704 Int_t *sign = new Int_t[nentries];
4705 Float_t *alpha = new Float_t[nentries];
4706 Float_t *z0 = new Float_t[nentries];
4707 Float_t *dca = new Float_t[nentries];
4708 Float_t *sdcar = new Float_t[nentries];
4709 Float_t *cdcar = new Float_t[nentries];
4710 Float_t *pulldcar = new Float_t[nentries];
4711 Float_t *pulldcaz = new Float_t[nentries];
4712 Float_t *pulldca = new Float_t[nentries];
4713 Bool_t *isPrim = new Bool_t[nentries];
4714 const AliESDVertex * primvertex = esd->GetVertex();
4715 Double_t zvertex = primvertex->GetZv();
4716 //
4717 // nentries = array->GetEntriesFast();
4718 //
4719 for (Int_t i=0;i<nentries;i++){
4720 sign[i]=0;
4721 isPrim[i]=0;
4722 AliTPCseed* track = (AliTPCseed*)array->At(i);
4723 if (!track) continue;
4724 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4725 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4726 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4727 //
4728 alpha[i] = track->GetAlpha();
4729 new (&helixes[i]) AliHelix(*track);
4730 Double_t xyz[3];
4731 helixes[i].Evaluate(0,xyz);
4732 sign[i] = (track->GetC()>0) ? -1:1;
4733 Double_t x,y,z;
4734 x=160;
4735 z0[i]=1000;
4736 if (track->GetProlongation(0,y,z)) z0[i] = z;
4737 dca[i] = track->GetD(0,0);
4738 //
4739 // dca error parrameterezation + pulls
4740 //
4741 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4742 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4743 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4744 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4745 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4746 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4747 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4748 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4749 }
4750 if (track->fTPCr[4]>0.5) {
4751 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4752 }
4753 if (track->fTPCr[0]>0.4) {
4754 isPrim[i]=kFALSE; //electron no sigma cut
4755 }
4756 }
4757 //
4758 //
4759 TStopwatch timer;
4760 timer.Start();
4761 Int_t ncandidates =0;
4762 Int_t nall =0;
4763 Int_t ntracks=0;
4764 Double_t phase[2][2],radius[2];
4765 //
4766 // Finf V0s loop
4767 //
4768 //
4769 // //
4770 TTreeSRedirector &cstream = *fDebugStreamer;
4771 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4772 AliESDV0MI vertex;
4773 Double_t cradius0 = 10*10;
4774 Double_t cradius1 = 200*200;
4775 Double_t cdist1=3.;
4776 Double_t cdist2=4.;
4777 Double_t cpointAngle = 0.95;
4778 //
4779 Double_t delta[2]={10000,10000};
4780 for (Int_t i =0;i<nentries;i++){
4781 if (sign[i]==0) continue;
4782 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4783 if (!track0) continue;
34acb742 4784 if (AliTPCReconstructor::StreamLevel()>0){
4785 cstream<<"Tracks"<<
4786 "Tr0.="<<track0<<
4787 "dca="<<dca[i]<<
4788 "z0="<<z0[i]<<
4789 "zvertex="<<zvertex<<
4790 "sdcar0="<<sdcar[i]<<
4791 "cdcar0="<<cdcar[i]<<
4792 "pulldcar0="<<pulldcar[i]<<
4793 "pulldcaz0="<<pulldcaz[i]<<
4794 "pulldca0="<<pulldca[i]<<
4795 "isPrim="<<isPrim[i]<<
4796 "\n";
4797 }
81e97e0d 4798 //
4799 if (track0->fP4<0) continue;
4800 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4801 //
4802 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4803 ntracks++;
4804 // debug output
4805
4806
4807 for (Int_t j =0;j<nentries;j++){
4808 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4809 if (!track1) continue;
4810 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4811 if (sign[j]*sign[i]>0) continue;
4812 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4813 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4814 nall++;
4815 //
4816 // DCA to prim vertex cut
4817 //
4818 //
4819 delta[0]=10000;
4820 delta[1]=10000;
4821
4822 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4823 if (npoints<1) continue;
4824 Int_t iclosest=0;
4825 // cuts on radius
4826 if (npoints==1){
4827 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4828 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4829 if (delta[0]>cdist1) continue;
4830 }
4831 else{
4832 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4833 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4834 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4835 if (delta[1]<delta[0]) iclosest=1;
4836 if (delta[iclosest]>cdist1) continue;
4837 }
4838 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4839 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4840 //
4841 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4842 if (pointAngle<cpointAngle) continue;
4843 //
4844 Bool_t isGamma = kFALSE;
4845 vertex.SetP(*track0); //track0 - plus
4846 vertex.SetM(*track1); //track1 - minus
4847 vertex.Update(fprimvertex);
4848 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4849 Double_t pointAngle2 = vertex.GetPointAngle();
4850 //continue;
4851 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4852 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4853 Float_t sigmae = 0.15*0.15;
4854 if (vertex.GetRr()<80)
4855 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4856 sigmae+= TMath::Sqrt(sigmae);
4857 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4858 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4859 Int_t row0 = GetRowNumber(vertex.GetRr());
4860 if (row0>15){
4861 if (vertex.GetDist2()>0.2) continue;
4862 densb0 = track0->Density2(0,row0-5);
4863 densb1 = track1->Density2(0,row0-5);
4864 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4865 densa0 = track0->Density2(row0+5,row0+40);
4866 densa1 = track1->Density2(row0+5,row0+40);
4867 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4868 }
4869 else{
4870 densa0 = track0->Density2(0,40); //cluster density
4871 densa1 = track1->Density2(0,40); //cluster density
4872 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4873 }
4874 vertex.SetLab(0,track0->GetLabel());
4875 vertex.SetLab(1,track1->GetLabel());
4876 vertex.SetChi2After((densa0+densa1)*0.5);
4877 vertex.SetChi2Before((densb0+densb1)*0.5);
4878 vertex.SetIndex(0,i);
4879 vertex.SetIndex(1,j);
4880 vertex.SetStatus(1); // TPC v0 candidate
4881 vertex.SetRp(track0->fTPCr);
4882 vertex.SetRm(track1->fTPCr);
4883 tpcv0s->AddLast(new AliESDV0MI(vertex));
4884 ncandidates++;
4885 {
4886 Int_t eventNr = esd->GetEventNumber();
4887 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4888 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
34acb742 4889 if (AliTPCReconstructor::StreamLevel()>0)
4890 cstream<<"V0"<<
81e97e0d 4891 "Event="<<eventNr<<
4892 "vertex.="<<&vertex<<
4893 "Tr0.="<<track0<<
4894 "lab0="<<track0->fLab<<
4895 "Helix0.="<<&helixes[i]<<
4896 "Tr1.="<<track1<<
4897 "lab1="<<track1->fLab<<
4898 "Helix1.="<<&helixes[j]<<
4899 "pointAngle="<<pointAngle<<
4900 "pointAngle2="<<pointAngle2<<
4901 "dca0="<<dca[i]<<
4902 "dca1="<<dca[j]<<
4903 "z0="<<z0[i]<<
4904 "z1="<<z0[j]<<
4905 "zvertex="<<zvertex<<
4906 "circular0="<<track0->fCircular<<
4907 "circular1="<<track1->fCircular<<
4908 "npoints="<<npoints<<
4909 "radius0="<<radius[0]<<
4910 "delta0="<<delta[0]<<
4911 "radius1="<<radius[1]<<
4912 "delta1="<<delta[1]<<
4913 "radiusm="<<radiusm<<
4914 "deltam="<<deltam<<
4915 "sdcar0="<<sdcar[i]<<
4916 "sdcar1="<<sdcar[j]<<
4917 "cdcar0="<<cdcar[i]<<
4918 "cdcar1="<<cdcar[j]<<
4919 "pulldcar0="<<pulldcar[i]<<
4920 "pulldcar1="<<pulldcar[j]<<
4921 "pulldcaz0="<<pulldcaz[i]<<
4922 "pulldcaz1="<<pulldcaz[j]<<
4923 "pulldca0="<<pulldca[i]<<
4924 "pulldca1="<<pulldca[j]<<
4925 "densb0="<<densb0<<
4926 "densb1="<<densb1<<
4927 "densa0="<<densa0<<
4928 "densa1="<<densa1<<
4929 "sigmae="<<sigmae<<
4930 "\n";
4931 }
4932 }
4933 }
4934 Float_t *quality = new Float_t[ncandidates];
4935 Int_t *indexes = new Int_t[ncandidates];
4936 Int_t naccepted =0;
4937 for (Int_t i=0;i<ncandidates;i++){
4938 quality[i] = 0;
4939 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4940 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4941 // quality[i] /= (0.5+v0->GetDist2());
4942 // quality[i] *= v0->GetChi2After(); //density factor
4943 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4944 Int_t index0 = v0->GetIndex(0);
4945 Int_t index1 = v0->GetIndex(1);
4946 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4947 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4948 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4949 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4950 }
4951
4952 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4953 //
4954 //
4955 for (Int_t i=0;i<ncandidates;i++){
4956 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4957 if (!v0) continue;
4958 Int_t index0 = v0->GetIndex(0);
4959 Int_t index1 = v0->GetIndex(1);
4960 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4961 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4962 if (!track0||!track1) {
4963 printf("Bug\n");
4964 continue;
4965 }
4966 Bool_t accept =kTRUE; //default accept
4967 Int_t *v0indexes0 = track0->GetV0Indexes();
4968 Int_t *v0indexes1 = track1->GetV0Indexes();
4969 //
4970 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4971 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4972 if (v0indexes0[1]!=0) order0 =2;
4973 if (v0indexes1[1]!=0) order1 =2;
4974 //
4975 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4976 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4977 //
4978 AliESDV0MI * v02 = v0;
4979 if (accept){
4980 v0->SetOrder(0,order0);
4981 v0->SetOrder(1,order1);
4982 v0->SetOrder(1,order0+order1);
4983 Int_t index = esd->AddV0MI(v0);
4984 v02 = esd->GetV0MI(index);
4985 v0indexes0[order0]=index;
4986 v0indexes1[order1]=index;
4987 naccepted++;
4988 }
4989 {
4990 Int_t eventNr = esd->GetEventNumber();
34acb742 4991 if (AliTPCReconstructor::StreamLevel()>0)
4992 cstream<<"V02"<<
81e97e0d 4993 "Event="<<eventNr<<
4994 "vertex.="<<v0<<
4995 "vertex2.="<<v02<<
4996 "Tr0.="<<track0<<
4997 "lab0="<<track0->fLab<<
4998 "Tr1.="<<track1<<
4999 "lab1="<<track1->fLab<<
5000 "dca0="<<dca[index0]<<
5001 "dca1="<<dca[index1]<<
5002 "order0="<<order0<<
5003 "order1="<<order1<<
5004 "accept="<<accept<<
5005 "quality="<<quality[i]<<
5006 "pulldca0="<<pulldca[index0]<<
5007 "pulldca1="<<pulldca[index1]<<
5008 "index="<<i<<
5009 "\n";
5010 }
5011 }
5012
5013
5014 //
5015 //
5016 delete []quality;
5017 delete []indexes;
5018//
5019 delete [] isPrim;
5020 delete [] pulldca;
5021 delete [] pulldcaz;
5022 delete [] pulldcar;
5023 delete [] cdcar;
5024 delete [] sdcar;
5025 delete [] dca;
5026 //
5027 delete[] z0;
5028 delete[] alpha;
5029 delete[] sign;
5030 delete[] helixes;
5031 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5032 timer.Print();
5033}
5034
eea478d3 5035Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5036{
5037 //
5038 // refit kink towards to the vertex
5039 //
5040 //
5041 Int_t row0 = GetRowNumber(kink.GetR());
5042 FollowProlongation(mother,0);
5043 mother.Reset(kFALSE);
5044 //
5045 FollowProlongation(daughter,row0);
5046 daughter.Reset(kFALSE);
5047 FollowBackProlongation(daughter,158);
5048 daughter.Reset(kFALSE);
5049 Int_t first = TMath::Max(row0-20,30);
5050 Int_t last = TMath::Min(row0+20,140);
5051 //
5052 const Int_t kNdiv =5;
5053 AliTPCseed param0[kNdiv]; // parameters along the track
5054 AliTPCseed param1[kNdiv]; // parameters along the track
5055 AliESDkink kinks[kNdiv]; // corresponding kink parameters
5056 //
5057 Int_t rows[kNdiv];
5058 for (Int_t irow=0; irow<kNdiv;irow++){
5059 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5060 }
5061 // store parameters along the track
5062 //
5063 for (Int_t irow=0;irow<kNdiv;irow++){
5064 FollowBackProlongation(mother, rows[irow]);
5065 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5066 new(&param0[irow]) AliTPCseed(mother);
5067 new(&param1[kNdiv-1-irow]) AliTPCseed(daughter);
5068 }
5069 //
5070 // define kinks
5071 for (Int_t irow=0; irow<kNdiv-1;irow++){
5072 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5073 kinks[irow].SetMother(param0[irow]);
5074 kinks[irow].SetDaughter(param1[irow]);
5075 kinks[irow].Update();
5076 }
5077 //
5078 // choose kink with best "quality"
5079 Int_t index =-1;
5080 Double_t mindist = 10000;
5081 for (Int_t irow=0;irow<kNdiv;irow++){
5082 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5083 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5084 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5085 //
5086 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
5087 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5088 if (normdist < mindist){
5089 mindist = normdist;
5090 index = irow;
5091 }
5092 }
5093 //
5094 if (index==-1) return 0;
5095 //
5096 //
5097 param0[index].Reset(kTRUE);
5098 FollowProlongation(param0[index],0);
5099 //
5100 new (&mother) AliTPCseed(param0[index]);
5101 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5102 //
5103 kink.SetMother(mother);
5104 kink.SetDaughter(daughter);
5105 kink.Update();
5106 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5107 kink.SetTPCncls(param0[index].fN,0);
5108 kink.SetTPCncls(param1[index].fN,1);
5109 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5110 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5111 mother.SetLabel(kink.GetLabel(0));
5112 daughter.SetLabel(kink.GetLabel(1));
5113
5114 return 1;
5115}
51ad6848 5116
5117
5118void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5119 //
5120 // update Kink quality information for mother after back propagation
5121 //
5122 if (seed->GetKinkIndex(0)>=0) return;
5123 for (Int_t ikink=0;ikink<3;ikink++){
5124 Int_t index = seed->GetKinkIndex(ikink);
5125 if (index>=0) break;
5126 index = TMath::Abs(index)-1;
5127 AliESDkink * kink = fEvent->GetKink(index);
eea478d3 5128 //kink->fTPCdensity2[0][0]=-1;
5129 //kink->fTPCdensity2[0][1]=-1;
5130 kink->SetTPCDensity2(-1,0,0);
5131 kink->SetTPCDensity2(1,0,1);
51ad6848 5132 //
eea478d3 5133 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
51ad6848 5134 if (row0<15) row0=15;
5135 //
eea478d3 5136 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
51ad6848 5137 if (row1>145) row1=145;
5138 //
5139 Int_t found,foundable,shared;
5140 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
eea478d3 5141 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
51ad6848 5142 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
eea478d3 5143 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
51ad6848 5144 }
5145
5146}
5147
eea478d3 5148void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
91162307 5149 //
eea478d3 5150 // update Kink quality information for daughter after refit
91162307 5151 //
eea478d3 5152 if (seed->GetKinkIndex(0)<=0) return;
5153 for (Int_t ikink=0;ikink<3;ikink++){
5154 Int_t index = seed->GetKinkIndex(ikink);
5155 if (index<=0) break;
5156 index = TMath::Abs(index)-1;
5157 AliESDkink * kink = fEvent->GetKink(index);
5158 kink->SetTPCDensity2(-1,1,0);
5159 kink->SetTPCDensity2(-1,1,1);
91162307 5160 //
eea478d3 5161 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5162 if (row0<15) row0=15;
5163 //
5164 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5165 if (row1>145) row1=145;
5166 //
5167 Int_t found,foundable,shared;
5168 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5169 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5170 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5171 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
91162307 5172 }
eea478d3 5173
5174}
5175
5176
5177Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5178{
91162307 5179 //
eea478d3 5180 // check kink point for given track
5181 // if return value=0 kink point not found
5182 // otherwise seed0 correspond to mother particle
5183 // seed1 correspond to daughter particle
5184 // kink parameter of kink point
91162307 5185
eea478d3 5186 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5187 Int_t first = seed->fFirstPoint;
5188 Int_t last = seed->fLastPoint;
5189 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
91162307 5190
eea478d3 5191
5192 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5193 if (!seed1) return 0;
5194 FollowProlongation(*seed1,seed->fLastPoint-20);
5195 seed1->Reset(kTRUE);
5196 FollowProlongation(*seed1,158);
5197 seed1->Reset(kTRUE);
5198 last = seed1->fLastPoint;
5199 //
5200 AliTPCseed *seed0 = new AliTPCseed(*seed);
5201 seed0->Reset(kFALSE);
5202 seed0->Reset();
5203 //
5204 AliTPCseed param0[20]; // parameters along the track
5205 AliTPCseed param1[20]; // parameters along the track
5206 AliESDkink kinks[20]; // corresponding kink parameters
5207 Int_t rows[20];
5208 for (Int_t irow=0; irow<20;irow++){
5209 rows[irow] = first +((last-first)*irow)/19;
5210 }
5211 // store parameters along the track
5212 //
5213 for (Int_t irow=0;irow<20;irow++){
5214 FollowBackProlongation(*seed0, rows[irow]);
5215 FollowProlongation(*seed1,rows[19-irow]);
5216 new(&param0[irow]) AliTPCseed(*seed0);
5217 new(&param1[19-irow]) AliTPCseed(*seed1);
5218 }
5219 //
5220 // define kinks
5221 for (Int_t irow=0; irow<19;irow++){
5222 kinks[irow].SetMother(param0[irow]);
5223 kinks[irow].SetDaughter(param1[irow]);
5224 kinks[irow].Update();
5225 }
5226 //
5227 // choose kink with biggest change of angle
5228 Int_t index =-1;
5229 Double_t maxchange= 0;
5230 for (Int_t irow=1;irow<19;irow++){
5231 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5232 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5233 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5234 if ( quality > maxchange){
5235 maxchange = quality;
5236 index = irow;
5237 //
91162307 5238 }
5239 }
eea478d3 5240 delete seed0;
5241 delete seed1;
5242 if (index<0) return 0;
5243 //
5244 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5245 seed0 = new AliTPCseed(param0[index]);
5246 seed1 = new AliTPCseed(param1[index]);
5247 seed0->Reset(kFALSE);
5248 seed1->Reset(kFALSE);
5249 seed0->ResetCovariance();
5250 seed1->ResetCovariance();
5251 FollowProlongation(*seed0,0);
5252 FollowBackProlongation(*seed1,158);
5253 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5254 seed0->Reset(kFALSE);
5255 seed1->Reset(kFALSE);
5256 seed0->ResetCovariance();
5257 seed1->ResetCovariance();
5258 //
5259 first = TMath::Max(row0-20,0);
5260 last = TMath::Min(row0+20,158);
5261 //
5262 for (Int_t irow=0; irow<20;irow++){
5263 rows[irow] = first +((last-first)*irow)/19;
5264 }
5265 // store parameters along the track
5266 //
5267 for (Int_t irow=0;irow<20;irow++){
5268 FollowBackProlongation(*seed0, rows[irow]);
5269 FollowProlongation(*seed1,rows[19-irow]);
5270 new(&param0[irow]) AliTPCseed(*seed0);
5271 new(&param1[19-irow]) AliTPCseed(*seed1);
5272 }
5273 //
5274 // define kinks
5275 for (Int_t irow=0; irow<19;irow++){
5276 kinks[irow].SetMother(param0[irow]);
5277 kinks[irow].SetDaughter(param1[irow]);
5278 // param0[irow].Dump();
5279 //param1[irow].Dump();
5280 kinks[irow].Update();
5281 }
5282 //
5283 // choose kink with biggest change of angle
5284 index =-1;
5285 maxchange= 0;
5286 for (Int_t irow=0;irow<20;irow++){
5287 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5288 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5289 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5290 if ( quality > maxchange){
5291 maxchange = quality;
5292 index = irow;
5293 //
91162307 5294 }
5295 }
5296 //
5297 //
eea478d3 5298 if (index==-1 || param0[index].fN+param1[index].fN<100){
5299 delete seed0;
5300 delete seed1;
5301 return 0;
1627d1c4 5302 }
eea478d3 5303 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
1627d1c4 5304
eea478d3 5305 kink.SetMother(param0[index]);
5306 kink.SetDaughter(param1[index]);
5307 kink.Update();
5308 row0 = GetRowNumber(kink.GetR());
5309 kink.SetTPCRow0(row0);
5310 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5311 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5312 kink.SetIndex(-10,0);
5313 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5314 kink.SetTPCncls(param0[index].fN,0);
5315 kink.SetTPCncls(param1[index].fN,1);
5316 //
5317 //
5318 // new (&mother) AliTPCseed(param0[index]);
5319 new (&daughter) AliTPCseed(param1[index]);
5320 daughter.SetLabel(kink.GetLabel(1));
5321 param0[index].Reset(kTRUE);
5322 FollowProlongation(param0[index],0);
5323 new (&mother) AliTPCseed(param0[index]);
5324 mother.SetLabel(kink.GetLabel(0));
5325 delete seed0;
5326 delete seed1;
5327 //
5328 return 1;
1627d1c4 5329}
5330
5331
5332
5333
91162307 5334AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5335{
5336 //
5337 // reseed - refit - track
5338 //
5339 Int_t first = 0;
5340 // Int_t last = fSectors->GetNRows()-1;
5341 //
5342 if (fSectors == fOuterSec){
5343 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5344 //last =
5345 }
5346 else
5347 first = t->fFirstPoint;
5348 //
5349 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5350 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5351 t->Reset(kFALSE);
5352 FollowProlongation(*t,first);
5353 return seed;
5354}
5355
5356
5357
5358
5359
5360
5361
1c53abe2 5362//_____________________________________________________________________________
5363Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5364 //-----------------------------------------------------------------
5365 // This function reades track seeds.
5366 //-----------------------------------------------------------------
5367 TDirectory *savedir=gDirectory;
5368
5369 TFile *in=(TFile*)inp;
5370 if (!in->IsOpen()) {
5371 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5372 return 1;
5373 }
5374
5375 in->cd();
5376 TTree *seedTree=(TTree*)in->Get("Seeds");
5377 if (!seedTree) {
5378 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5379 cerr<<"can't get a tree with track seeds !\n";
5380 return 2;
5381 }
5382 AliTPCtrack *seed=new AliTPCtrack;
5383 seedTree->SetBranchAddress("tracks",&seed);
5384
5385 if (fSeeds==0) fSeeds=new TObjArray(15000);
5386
5387 Int_t n=(Int_t)seedTree->GetEntries();
5388 for (Int_t i=0; i<n; i++) {
5389 seedTree->GetEvent(i);
bbc6cd2c 5390 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
1c53abe2 5391 }
5392
5393 delete seed;
5394 delete seedTree;
5395 savedir->cd();
5396 return 0;
5397}
5398
d26d9159 5399Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5400{
5401 //
d9b8978b 5402 if (fSeeds) DeleteSeeds();
d26d9159 5403 fEvent = esd;
5404 Clusters2Tracks();
5405 if (!fSeeds) return 1;
5406 FillESD(fSeeds);
5407 return 0;
5408 //
5409}
5410
5411
1c53abe2 5412//_____________________________________________________________________________
f8aae377 5413Int_t AliTPCtrackerMI::Clusters2Tracks() {
1c53abe2 5414 //-----------------------------------------------------------------
5415 // This is a track finder.
5416 //-----------------------------------------------------------------
91162307 5417 TDirectory *savedir=gDirectory;
1c53abe2 5418 TStopwatch timer;
d26d9159 5419
91162307 5420 fIteration = 0;
5421 fSeeds = Tracking();
1c53abe2 5422
6bdc18d6 5423 if (fDebug>0){
5424 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5425 }
91162307 5426 //activate again some tracks
5427 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5428 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5429 if (!pt) continue;
5430 Int_t nc=t.GetNumberOfClusters();
5431 if (nc<20) {
5432 delete fSeeds->RemoveAt(i);
5433 continue;
eea478d3 5434 }
5435 CookLabel(pt,0.1);
91162307 5436 if (pt->fRemoval==10) {
5437 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5438 pt->Desactivate(10); // make track again active
5439 else{
5440 pt->Desactivate(20);
5441 delete fSeeds->RemoveAt(i);
5442 }
5443 }
5444 }
51ad6848 5445 //
5446 RemoveUsed2(fSeeds,0.85,0.85,0);
5447 FindKinks(fSeeds,fEvent);
81e97e0d 5448 RemoveUsed2(fSeeds,0.5,0.4,20);
5449 // //
5450// // refit short tracks
5451// //
5452 Int_t nseed=fSeeds->GetEntriesFast();
5453// for (Int_t i=0; i<nseed; i++) {
5454// AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5455// if (!pt) continue;
5456// Int_t nc=t.GetNumberOfClusters();
5457// if (nc<15) {
5458// delete fSeeds->RemoveAt(i);
5459// continue;
5460// }
5461// if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5462// if (nc>100) continue; // hopefully, enough for ITS
5463// AliTPCseed *seed2 = new AliTPCseed(*pt);
5464// //seed2->Reset(kFALSE);
5465// //pt->ResetCovariance();
5466// seed2->Modify(1);
5467// FollowBackProlongation(*seed2,158);
5468// //seed2->Reset(kFALSE);
5469// seed2->Modify(10);
5470// FollowProlongation(*seed2,0);
5471// TTreeSRedirector &cstream = *fDebugStreamer;
5472// cstream<<"Crefit"<<
5473// "Tr0.="<<pt<<
5474// "Tr1.="<<seed2<<
5475// "\n";
5476// if (seed2->fN>pt->fN){
5477// delete fSeeds->RemoveAt(i);
5478// fSeeds->AddAt(seed2,i);
5479// }else{
5480// delete seed2;
5481// }
5482// }
5483// RemoveUsed2(fSeeds,0.6,0.6,50);
5484
5485// FindV0s(fSeeds,fEvent);
51ad6848 5486 //RemoveDouble(fSeeds,0.2,0.6,11);
c9427e08 5487
1c53abe2 5488 //
91162307 5489 Int_t found = 0;
5490 for (Int_t i=0; i<nseed; i++) {
5491 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5492 if (!pt) continue;
5493 Int_t nc=t.GetNumberOfClusters();
5494 if (nc<15) {
5495 delete fSeeds->RemoveAt(i);
5496 continue;
5497 }
5498 CookLabel(pt,0.1); //For comparison only
5499 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5500 if ((pt->IsActive() || (pt->fRemoval==10) )){
d9b8978b 5501 found++;
5502 if (fDebug>0) cerr<<found<<'\r';
d26d9159 5503 pt->fLab2 = i;
91162307 5504 }
5505 else
5506 delete fSeeds->RemoveAt(i);
91162307 5507 }
5508
5509
5510 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5511 SignShared(fSeeds);
5512 //RemoveUsed(fSeeds,0.9,0.9,6);
1c53abe2 5513 //
91162307 5514 nseed=fSeeds->GetEntriesFast();
5515 found = 0;
5516 for (Int_t i=0; i<nseed; i++) {
5517 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5518 if (!pt) continue;
5519 Int_t nc=t.GetNumberOfClusters();
5520 if (nc<15) {
5521 delete fSeeds->RemoveAt(i);
5522 continue;
5523 }
5524 t.SetUniqueID(i);
5525 t.CookdEdx(0.02,0.6);
5526 // CheckKinkPoint(&t,0.05);
5527 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5528 if ((pt->IsActive() || (pt->fRemoval==10) )){
6bdc18d6 5529 found++;
5530 if (fDebug>0){
5531 cerr<<found<<'\r';
5532 }
d26d9159 5533 pt->fLab2 = i;
91162307 5534 }
5535 else
5536 delete fSeeds->RemoveAt(i);
d26d9159 5537 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5538 //if (seed1){
5539 // FollowProlongation(*seed1,0);
5540 // Int_t n = seed1->GetNumberOfClusters();
5541 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5542 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5543 //
5544 //}
5545 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5546
91162307 5547 }
5548
5549 SortTracks(fSeeds, 1);
1c53abe2 5550
982aff31 5551 /*
91162307 5552 fIteration = 1;
982aff31 5553 PrepareForBackProlongation(fSeeds,5.);
91162307 5554 PropagateBack(fSeeds);
5555 printf("Time for back propagation: \t");timer.Print();timer.Start();
5556
5557 fIteration = 2;
1c53abe2 5558
982aff31 5559 PrepareForProlongation(fSeeds,5.);
5560 PropagateForward2(fSeeds);
d26d9159 5561
91162307 5562 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5563 // RemoveUsed(fSeeds,0.7,0.7,6);
5564 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
d26d9159 5565
1c53abe2 5566 nseed=fSeeds->GetEntriesFast();
91162307 5567 found = 0;
5568 for (Int_t i=0; i<nseed; i++) {
1c53abe2 5569 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5570 if (!pt) continue;
5571 Int_t nc=t.GetNumberOfClusters();
91162307 5572 if (nc<15) {
5573 delete fSeeds->RemoveAt(i);
5574 continue;
5575 }
1c53abe2 5576 t.CookdEdx(0.02,0.6);
91162307 5577 // CookLabel(pt,0.1); //For comparison only
5578 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5579 if ((pt->IsActive() || (pt->fRemoval==10) )){
5580 cerr<<found++<<'\r';
5581 }
5582 else
5583 delete fSeeds->RemoveAt(i);
5584 pt->fLab2 = i;
1c53abe2 5585 }
91162307 5586 */
5587
c9427e08 5588 // fNTracks = found;
6bdc18d6 5589 if (fDebug>0){
5590 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5591 }
91162307 5592 //
6bdc18d6 5593 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5594 Info("Clusters2Tracks","Number of found tracks %d",found);
91162307 5595 savedir->cd();
91162307 5596 // UnloadClusters();
d26d9159 5597 //
1c53abe2 5598 return 0;
5599}
5600
91162307 5601void AliTPCtrackerMI::Tracking(TObjArray * arr)
5602{
5603 //
5604 // tracking of the seeds
5605 //
5606
5607 fSectors = fOuterSec;
5608 ParallelTracking(arr,150,63);
5609 fSectors = fOuterSec;
5610 ParallelTracking(arr,63,0);
5611}
5612
5613TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5614{
5615 //
5616 //
5617 //tracking routine
5618 TObjArray * arr = new TObjArray;
5619 //
5620 fSectors = fOuterSec;
5621 TStopwatch timer;
5622 timer.Start();
5623 for (Int_t sec=0;sec<fkNOS;sec++){
5624 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5625 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5626 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5627 }
5628 if (fDebug>0){
6bdc18d6 5629 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
91162307 5630 timer.Print();
5631 timer.Start();
5632 }
5633 Tracking(arr);
5634 if (fDebug>0){
5635 timer.Print();
5636 }
5637
5638 return arr;
5639}
5640
5641TObjArray * AliTPCtrackerMI::Tracking()
5642{
5643 //
5644 //
5645 TStopwatch timer;
5646 timer.Start();
5647 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5648
5649 TObjArray * seeds = new TObjArray;
5650 TObjArray * arr=0;
5651
5652 Int_t gap =20;
5653 Float_t cuts[4];
5654 cuts[0] = 0.002;
5655 cuts[1] = 1.5;
5656 cuts[2] = 3.;
5657 cuts[3] = 3.;
5658 Float_t fnumber = 3.0;
5659 Float_t fdensity = 3.0;
5660
5661 //
5662 //find primaries
5663 cuts[0]=0.0066;
5664 for (Int_t delta = 0; delta<18; delta+=6){
5665 //
5666 cuts[0]=0.0070;
5667 cuts[1] = 1.5;
5668 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5669 SumTracks(seeds,arr);
5670 SignClusters(seeds,fnumber,fdensity);
5671 //
5672 for (Int_t i=2;i<6;i+=2){
5673 // seed high pt tracks
5674 cuts[0]=0.0022;
5675 cuts[1]=0.3;
5676 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5677 SumTracks(seeds,arr);
5678 SignClusters(seeds,fnumber,fdensity);
5679 }
5680 }
5681 fnumber = 4;
5682 fdensity = 4.;
5683 // RemoveUsed(seeds,0.9,0.9,1);
5684 // UnsignClusters();
5685 // SignClusters(seeds,fnumber,fdensity);
5686
5687 //find primaries
5688 cuts[0]=0.0077;
5689 for (Int_t delta = 20; delta<120; delta+=10){
5690 //
5691 // seed high pt tracks
5692 cuts[0]=0.0060;
5693 cuts[1]=0.3;
5694 cuts[2]=6.;
5695 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5696 SumTracks(seeds,arr);
5697 SignClusters(seeds,fnumber,fdensity);
5698
5699 cuts[0]=0.003;
5700 cuts[1]=0.3;
5701 cuts[2]=6.;
5702 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5703 SumTracks(seeds,arr);
5704 SignClusters(seeds,fnumber,fdensity);
5705 }
5706
5707 cuts[0] = 0.01;
5708 cuts[1] = 2.0;
5709 cuts[2] = 3.;
5710 cuts[3] = 2.0;
5711 fnumber = 2.;
5712 fdensity = 2.;
5713
5714 if (fDebug>0){
6bdc18d6 5715 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
91162307 5716 timer.Print();
5717 timer.Start();
5718 }
5719 // RemoveUsed(seeds,0.75,0.75,1);
5720 //UnsignClusters();
5721 //SignClusters(seeds,fnumber,fdensity);
5722
5723 // find secondaries
5724
5725 cuts[0] = 0.3;
5726 cuts[1] = 1.5;
5727 cuts[2] = 3.;
5728 cuts[3] = 1.5;
5729
5730 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5731 SumTracks(seeds,arr);
5732 SignClusters(seeds,fnumber,fdensity);
5733 //
5734 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5735 SumTracks(seeds,arr);
5736 SignClusters(seeds,fnumber,fdensity);
5737 //
5738 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5739 SumTracks(seeds,arr);
5740 SignClusters(seeds,fnumber,fdensity);
5741 //
5742
5743
5744 for (Int_t delta = 3; delta<30; delta+=5){
5745 //
5746 cuts[0] = 0.3;
5747 cuts[1] = 1.5;
5748 cuts[2] = 3.;
5749 cuts[3] = 1.5;
5750 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5751 SumTracks(seeds,arr);
5752 SignClusters(seeds,fnumber,fdensity);
5753 //
5754 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5755 SumTracks(seeds,arr);
5756 SignClusters(seeds,fnumber,fdensity);
5757 //
5758 }
5759 fnumber = 1;
5760 fdensity = 1;
5761 //
5762 // change cuts
5763 fnumber = 2.;
5764 fdensity = 2.;
5765 cuts[0]=0.0080;
5766
5767 // find secondaries
2bd61959 5768 for (Int_t delta = 30; delta<90; delta+=10){
91162307 5769 //
5770 cuts[0] = 0.3;
2bd61959 5771 cuts[1] = 3.5;
91162307 5772 cuts[2] = 3.;
2bd61959 5773 cuts[3] = 3.5;
91162307 5774 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5775 SumTracks(seeds,arr);
5776 SignClusters(seeds,fnumber,fdensity);
5777 //
5778 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5779 SumTracks(seeds,arr);
5780 SignClusters(seeds,fnumber,fdensity);
5781 }
5782
5783 if (fDebug>0){
6bdc18d6 5784 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
91162307 5785 timer.Print();
5786 timer.Start();
5787 }
5788
5789 return seeds;
5790 //
5791
5792}
5793
5794
47966a6d 5795void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
91162307 5796{
5797 //
5798 //sum tracks to common container
5799 //remove suspicious tracks
5800 Int_t nseed = arr2->GetEntriesFast();
5801 for (Int_t i=0;i<nseed;i++){
5802 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5803 if (pt){
ca142b1f 5804 // REMOVE VERY SHORT TRACKS
5805 if (pt->GetNumberOfClusters()<20){
5806 delete arr2->RemoveAt(i);
5807 continue;
5808 }// patch 28 fev06
91162307 5809 // NORMAL ACTIVE TRACK
5810 if (pt->IsActive()){
5811 arr1->AddLast(arr2->RemoveAt(i));
5812 continue;
5813 }
5814 //remove not usable tracks
5815 if (pt->fRemoval!=10){
5816 delete arr2->RemoveAt(i);
5817 continue;
5818 }
ca142b1f 5819
91162307 5820 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5821 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5822 arr1->AddLast(arr2->RemoveAt(i));
5823 else{
5824 delete arr2->RemoveAt(i);
5825 }
5826 }
5827 }
5828 delete arr2;
5829}
5830
5831
1c53abe2 5832
91162307 5833void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
1c53abe2 5834{
5835 //
5836 // try to track in parralel
5837
91162307 5838 Int_t nseed=arr->GetEntriesFast();
1c53abe2 5839 //prepare seeds for tracking
5840 for (Int_t i=0; i<nseed; i++) {
91162307 5841 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
1c53abe2 5842 if (!pt) continue;
5843 if (!t.IsActive()) continue;
5844 // follow prolongation to the first layer
91162307 5845 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
c9427e08 5846 FollowProlongation(t, rfirst+1);
1c53abe2 5847 }
5848
5849
5850 //
982aff31 5851 for (Int_t nr=rfirst; nr>=rlast; nr--){
5852 if (nr<fInnerSec->GetNRows())
5853 fSectors = fInnerSec;
5854 else
5855 fSectors = fOuterSec;
1c53abe2 5856 // make indexes with the cluster tracks for given
1c53abe2 5857
5858 // find nearest cluster
5859 for (Int_t i=0; i<nseed; i++) {
91162307 5860 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
1c53abe2 5861 if (!pt) continue;
51ad6848 5862 if (nr==80) pt->UpdateReference();
1c53abe2 5863 if (!pt->IsActive()) continue;
91162307 5864 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
1627d1c4 5865 if (pt->fRelativeSector>17) {
5866 continue;
5867 }
91162307 5868 UpdateClusters(t,nr);
1c53abe2 5869 }
5870 // prolonagate to the nearest cluster - if founded
5871 for (Int_t i=0; i<nseed; i++) {
91162307 5872 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1c53abe2 5873 if (!pt) continue;
1627d1c4 5874 if (!pt->IsActive()) continue;
91162307 5875 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
1627d1c4 5876 if (pt->fRelativeSector>17) {
5877 continue;
5878 }
91162307 5879 FollowToNextCluster(*pt,nr);
1c53abe2 5880 }
91162307 5881 }
5882}
5883
47966a6d 5884void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
91162307 5885{
5886 //
5887 //
5888 // if we use TPC track itself we have to "update" covariance
5889 //
5890 Int_t nseed= arr->GetEntriesFast();
5891 for (Int_t i=0;i<nseed;i++){
5892 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5893 if (pt) {
5894 pt->Modify(fac);
5895 //
5896 //rotate to current local system at first accepted point
5897 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5898 Int_t sec = (index&0xff000000)>>24;
5899 sec = sec%18;
5900 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5901 if (angle1>TMath::Pi())
5902 angle1-=2.*TMath::Pi();
5903 Float_t angle2 = pt->GetAlpha();
5904
5905 if (TMath::Abs(angle1-angle2)>0.001){
5906 pt->Rotate(angle1-angle2);
5907 //angle2 = pt->GetAlpha();
5908 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5909 //if (pt->GetAlpha()<0)
5910 // pt->fRelativeSector+=18;
5911 //sec = pt->fRelativeSector;
5912 }
5913
5914 }
5915
5916 }
5917
5918
5919}
47966a6d 5920void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
91162307 5921{
5922 //
5923 //
5924 // if we use TPC track itself we have to "update" covariance
5925 //
5926 Int_t nseed= arr->GetEntriesFast();
5927 for (Int_t i=0;i<nseed;i++){
5928 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5929 if (pt) {
5930 pt->Modify(fac);
5931 pt->fFirstPoint = pt->fLastPoint;
5932 }
5933
5934 }
5935
5936
5937}
5938
5939Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5940{
5941 //
5942 // make back propagation
5943 //
5944 Int_t nseed= arr->GetEntriesFast();
5945 for (Int_t i=0;i<nseed;i++){
5946 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
51ad6848 5947 if (pt&& pt->GetKinkIndex(0)<=0) {
d9b8978b 5948 //AliTPCseed *pt2 = new AliTPCseed(*pt);
91162307 5949 fSectors = fInnerSec;
d26d9159 5950 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5951 //fSectors = fOuterSec;
4d158c36 5952 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5953 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
d9b8978b 5954 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
4d158c36 5955 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
d9b8978b 5956 //}
51ad6848 5957 }
5958 if (pt&& pt->GetKinkIndex(0)>0) {
5959 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
eea478d3 5960 pt->fFirstPoint = kink->GetTPCRow0();
51ad6848 5961 fSectors = fInnerSec;
5962 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5963 }
5964
91162307 5965 }
5966 return 0;
5967}
5968
5969
5970Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5971{
5972 //
5973 // make forward propagation
5974 //
5975 Int_t nseed= arr->GetEntriesFast();
4d158c36 5976 //
91162307 5977 for (Int_t i=0;i<nseed;i++){
5978 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5979 if (pt) {
91162307 5980 FollowProlongation(*pt,0);
4d158c36 5981 }
91162307 5982 }
5983 return 0;
5984}
5985
5986
5987Int_t AliTPCtrackerMI::PropagateForward()
5988{
b67e07dc 5989 //
5990 // propagate track forward
4d158c36 5991 //UnsignClusters();
d26d9159 5992 Int_t nseed = fSeeds->GetEntriesFast();
5993 for (Int_t i=0;i<nseed;i++){
5994 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5995 if (pt){
5996 AliTPCseed &t = *pt;
5997 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5998 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5999 if (alpha < 0. ) alpha += 2.*TMath::Pi();
6000 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
6001 }
6002 }
6003
91162307 6004 fSectors = fOuterSec;
d26d9159 6005 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
91162307 6006 fSectors = fInnerSec;
d26d9159 6007 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
91162307 6008 //WriteTracks();
6009 return 1;
6010}
6011
6012
6013
6014
6015
6016
6017Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6018{
6019 //
6020 // make back propagation, in between row0 and row1
6021 //
1c53abe2 6022
91162307 6023 if (pt) {
6024 fSectors = fInnerSec;
6025 Int_t r1;
6026 //
6027 if (row1<fSectors->GetNRows())
6028 r1 = row1;
6029 else
6030 r1 = fSectors->GetNRows()-1;
6031
6032 if (row0<fSectors->GetNRows()&& r1>0 )
6033 FollowBackProlongation(*pt,r1);
6034 if (row1<=fSectors->GetNRows())
6035 return 0;
6036 //
6037 r1 = row1 - fSectors->GetNRows();
6038 if (r1<=0) return 0;
6039 if (r1>=fOuterSec->GetNRows()) return 0;
6040 fSectors = fOuterSec;
6041 return FollowBackProlongation(*pt,r1);
6042 }
6043 return 0;
6044}
6045
6046
6047
6048
6049void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6050{
6051 //
6052 //
6053 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6054 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6055 Float_t padlength = GetPadPitchLength(row);
6056 //
6057 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
3f82c4f2 6058 Double_t angulary = seed->GetSnp();
91162307 6059 angulary = angulary*angulary/(1-angulary*angulary);
6060 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6061 //
6062 Float_t sresz = fParam->GetZSigma();
6063 Float_t angularz = seed->GetTgl();
6064 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6065 /*
6066 Float_t wy = GetSigmaY(seed);
6067 Float_t wz = GetSigmaZ(seed);
6068 wy*=wy;
6069 wz*=wz;
6070 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6071 printf("problem\n");
6072 }
6073 */
1c53abe2 6074}
6075
91162307 6076
1c53abe2 6077Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6078{
6079 //
6080 //
c9427e08 6081 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
1c53abe2 6082 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6083 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6084 Float_t angular = seed->GetSnp();
6085 angular = angular*angular/(1-angular*angular);
6086 // angular*=angular;
6087 //angular = TMath::Sqrt(angular/(1-angular));
6088 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6089 return res;
6090}
6091Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6092{
6093 //
6094 //
c9427e08 6095 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
1c53abe2 6096 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6097 Float_t sres = fParam->GetZSigma();
6098 Float_t angular = seed->GetTgl();
6099 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6100 return res;
6101}
6102
6103
1c53abe2 6104//__________________________________________________________________________
af32720d 6105void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
1c53abe2 6106 //--------------------------------------------------------------------
6107 //This function "cooks" a track label. If label<0, this track is fake.
6108 //--------------------------------------------------------------------
af32720d 6109 AliTPCseed * t = (AliTPCseed*)tk;
1c53abe2 6110 Int_t noc=t->GetNumberOfClusters();
91162307 6111 if (noc<10){
d26d9159 6112 //printf("\nnot founded prolongation\n\n\n");
6113 //t->Dump();
91162307 6114 return ;
6115 }
6116 Int_t lb[160];
6117 Int_t mx[160];
6118 AliTPCclusterMI *clusters[160];
6119 //
6120 for (Int_t i=0;i<160;i++) {
6121 clusters[i]=0;
6122 lb[i]=mx[i]=0;
6123 }
1c53abe2 6124
6125 Int_t i;
91162307 6126 Int_t current=0;
6127 for (i=0; i<160 && current<noc; i++) {
6128
6129 Int_t index=t->GetClusterIndex2(i);
6130 if (index<=0) continue;
6131 if (index&0x8000) continue;
6132 //
6133 //clusters[current]=GetClusterMI(index);
6134 if (t->fClusterPointer[i]){
6135 clusters[current]=t->fClusterPointer[i];
6136 current++;
6137 }
1c53abe2 6138 }
91162307 6139 noc = current;
1c53abe2 6140
6141 Int_t lab=123456789;
6142 for (i=0; i<noc; i++) {
6143 AliTPCclusterMI *c=clusters[i];
91162307 6144 if (!c) continue;
1c53abe2 6145 lab=TMath::Abs(c->GetLabel(0));
6146 Int_t j;
6147 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6148 lb[j]=lab;
6149 (mx[j])++;
6150 }
6151
6152 Int_t max=0;
6153 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6154
6155 for (i=0; i<noc; i++) {
9918f10a 6156 AliTPCclusterMI *c=clusters[i];
91162307 6157 if (!c) continue;
1c53abe2 6158 if (TMath::Abs(c->GetLabel(1)) == lab ||
6159 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6160 }
6161
6162 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6163
6164 else {
6165 Int_t tail=Int_t(0.10*noc);
6166 max=0;
91162307 6167 Int_t ind=0;
6168 for (i=1; i<=160&&ind<tail; i++) {
6169 // AliTPCclusterMI *c=clusters[noc-i];
6170 AliTPCclusterMI *c=clusters[i];
6171 if (!c) continue;
1c53abe2 6172 if (lab == TMath::Abs(c->GetLabel(0)) ||
6173 lab == TMath::Abs(c->GetLabel(1)) ||
6174 lab == TMath::Abs(c->GetLabel(2))) max++;
91162307 6175 ind++;
1c53abe2 6176 }
6177 if (max < Int_t(0.5*tail)) lab=-lab;
6178 }
6179
6180 t->SetLabel(lab);
6181
91162307 6182 // delete[] lb;
6183 //delete[] mx;
6184 //delete[] clusters;
1c53abe2 6185}
6186
47966a6d 6187
51ad6848 6188//__________________________________________________________________________
6189Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6190 //--------------------------------------------------------------------
6191 //This function "cooks" a track label. If label<0, this track is fake.
6192 //--------------------------------------------------------------------
6193 Int_t noc=t->GetNumberOfClusters();
6194 if (noc<10){
6195 //printf("\nnot founded prolongation\n\n\n");
6196 //t->Dump();
6197 return -1;
6198 }
6199 Int_t lb[160];
6200 Int_t mx[160];
6201 AliTPCclusterMI *clusters[160];
6202 //
6203 for (Int_t i=0;i<160;i++) {
6204 clusters[i]=0;
6205 lb[i]=mx[i]=0;
6206 }
6207
6208 Int_t i;
6209 Int_t current=0;
6210 for (i=0; i<160 && current<noc; i++) {
6211 if (i<first) continue;
6212 if (i>last) continue;
6213 Int_t index=t->GetClusterIndex2(i);
6214 if (index<=0) continue;
6215 if (index&0x8000) continue;
6216 //
6217 //clusters[current]=GetClusterMI(index);
6218 if (t->fClusterPointer[i]){
6219 clusters[current]=t->fClusterPointer[i];
6220 current++;
6221 }
6222 }
6223 noc = current;
6224 if (noc<5) return -1;
6225 Int_t lab=123456789;
6226 for (i=0; i<noc; i++) {
6227 AliTPCclusterMI *c=clusters[i];
6228 if (!c) continue;
6229 lab=TMath::Abs(c->GetLabel(0));
6230 Int_t j;
6231 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6232 lb[j]=lab;
6233 (mx[j])++;
6234 }
6235
6236 Int_t max=0;
6237 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6238
6239 for (i=0; i<noc; i++) {
6240 AliTPCclusterMI *c=clusters[i];
6241 if (!c) continue;
6242 if (TMath::Abs(c->GetLabel(1)) == lab ||
6243 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6244 }
6245
6246 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6247
6248 else {
6249 Int_t tail=Int_t(0.10*noc);
6250 max=0;
6251 Int_t ind=0;
6252 for (i=1; i<=160&&ind<tail; i++) {
6253 // AliTPCclusterMI *c=clusters[noc-i];
6254 AliTPCclusterMI *c=clusters[i];
6255 if (!c) continue;
6256 if (lab == TMath::Abs(c->GetLabel(0)) ||
6257 lab == TMath::Abs(c->GetLabel(1)) ||
6258 lab == TMath::Abs(c->GetLabel(2))) max++;
6259 ind++;
6260 }
6261 if (max < Int_t(0.5*tail)) lab=-lab;
6262 }
6263
6264 // t->SetLabel(lab);
6265 return lab;
6266 // delete[] lb;
6267 //delete[] mx;
6268 //delete[] clusters;
6269}
6270
6271
47966a6d 6272Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6273{
6274 //return pad row number for this x
6275 Double_t r;
6276 if (fN < 64){
6277 r=fRow[fN-1].GetX();
6278 if (x > r) return fN;
6279 r=fRow[0].GetX();
6280 if (x < r) return -1;
6281 return Int_t((x-r)/fPadPitchLength + 0.5);}
6282 else{
6283 r=fRow[fN-1].GetX();
6284 if (x > r) return fN;
6285 r=fRow[0].GetX();
6286 if (x < r) return -1;
6287 Double_t r1=fRow[64].GetX();
6288 if(x<r1){
6289 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6290 else{
6291 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6292 }
6293}
6294
eea478d3 6295Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6296{
6297 //return pad row number for given x vector
6298 Float_t phi = TMath::ATan2(x[1],x[0]);
6299 if(phi<0) phi=2.*TMath::Pi()+phi;
6300 // Get the local angle in the sector philoc
6301 const Float_t kRaddeg = 180/3.14159265358979312;
6302 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6303 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6304 return GetRowNumber(localx);
6305}
6306
1c53abe2 6307//_________________________________________________________________________
6308void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6309 //-----------------------------------------------------------------------
6310 // Setup inner sector
6311 //-----------------------------------------------------------------------
6312 if (f==0) {
6313 fAlpha=par->GetInnerAngle();
6314 fAlphaShift=par->GetInnerAngleShift();
6315 fPadPitchWidth=par->GetInnerPadPitchWidth();
6316 fPadPitchLength=par->GetInnerPadPitchLength();
6317 fN=par->GetNRowLow();
6318 fRow=new AliTPCRow[fN];
6319 for (Int_t i=0; i<fN; i++) {
6320 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6321 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6322 }
6323 } else {
6324 fAlpha=par->GetOuterAngle();
6325 fAlphaShift=par->GetOuterAngleShift();
6326 fPadPitchWidth = par->GetOuterPadPitchWidth();
6327 fPadPitchLength = par->GetOuter1PadPitchLength();
6328 f1PadPitchLength = par->GetOuter1PadPitchLength();
6329 f2PadPitchLength = par->GetOuter2PadPitchLength();
6330
6331 fN=par->GetNRowUp();
6332 fRow=new AliTPCRow[fN];
6333 for (Int_t i=0; i<fN; i++) {
6334 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6335 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6336 }
6337 }
6338}
6339
b67e07dc 6340AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6341 //
6342 // default constructor
6343 fN=0;
6344 fN1=0;
6345 fN2=0;
6346 fClusters1=0;
6347 fClusters2=0;
6348}
1c53abe2 6349
6350AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6351 //
b67e07dc 6352
1c53abe2 6353}
6354
6355
6356
1c53abe2 6357//_________________________________________________________________________
6358void
6359AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6360 //-----------------------------------------------------------------------
6361 // Insert a cluster into this pad row in accordence with its y-coordinate
6362 //-----------------------------------------------------------------------
6363 if (fN==kMaxClusterPerRow) {
6364 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6365 }
6366 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6367 Int_t i=Find(c->GetZ());
6368 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6369 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6370 fIndex[i]=index; fClusters[i]=c; fN++;
6371}
6372
982aff31 6373void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6374 //
6375 // reset clusters
6376 fN = 0;
6377 fN1 = 0;
6378 fN2 = 0;
6379 //delete[] fClusterArray;
6380 if (fClusters1) delete []fClusters1;
6381 if (fClusters2) delete []fClusters2;
6382 //fClusterArray=0;
6383 fClusters1 = 0;
6384 fClusters2 = 0;
6385}
6386
91162307 6387
1c53abe2 6388//___________________________________________________________________
6389Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6390 //-----------------------------------------------------------------------
6391 // Return the index of the nearest cluster
6392 //-----------------------------------------------------------------------
6393 if (fN==0) return 0;
6394 if (z <= fClusters[0]->GetZ()) return 0;
6395 if (z > fClusters[fN-1]->GetZ()) return fN;
6396 Int_t b=0, e=fN-1, m=(b+e)/2;
6397 for (; b<e; m=(b+e)/2) {
6398 if (z > fClusters[m]->GetZ()) b=m+1;
6399 else e=m;
6400 }
6401 return m;
6402}
6403
6404
6405
1627d1c4 6406//___________________________________________________________________
6407AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6408 //-----------------------------------------------------------------------
6409 // Return the index of the nearest cluster in z y
6410 //-----------------------------------------------------------------------
6411 Float_t maxdistance = roady*roady + roadz*roadz;
6412
6413 AliTPCclusterMI *cl =0;
6414 for (Int_t i=Find(z-roadz); i<fN; i++) {
6415 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6416 if (c->GetZ() > z+roadz) break;
6417 if ( (c->GetY()-y) > roady ) continue;
6418 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6419 if (maxdistance>distance) {
6420 maxdistance = distance;
6421 cl=c;
6422 }
6423 }
6424 return cl;
6425}
6426
91162307 6427AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6428{
6429 //-----------------------------------------------------------------------
6430 // Return the index of the nearest cluster in z y
6431 //-----------------------------------------------------------------------
6432 Float_t maxdistance = roady*roady + roadz*roadz;
91162307 6433 AliTPCclusterMI *cl =0;
3381b665 6434
6435 //PH Check boundaries. 510 is the size of fFastCluster
6436 Int_t iz1 = Int_t(z-roadz+254.5);
6437 if (iz1<0 || iz1>=510) return cl;
6438 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6439 Int_t iz2 = Int_t(z+roadz+255.5);
6440 if (iz2<0 || iz2>=510) return cl;
6441 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6442
91162307 6443 //FindNearest3(y,z,roady,roadz,index);
6444 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6445 for (Int_t i=iz1; i<iz2; i++) {
6446 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6447 if (c->GetZ() > z+roadz) break;
6448 if ( c->GetY()-y > roady ) continue;
6449 if ( y-c->GetY() > roady ) continue;
6450 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6451 if (maxdistance>distance) {
6452 maxdistance = distance;
6453 cl=c;
6454 index =i;
6455 //roady = TMath::Sqrt(maxdistance);
6456 }
6457 }
6458 return cl;
6459}
6460
6461
6462
6463AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6464{
6465 //-----------------------------------------------------------------------
6466 // Return the index of the nearest cluster in z y
6467 //-----------------------------------------------------------------------
6468 Float_t maxdistance = roady*roady + roadz*roadz;
6469 // Int_t iz = Int_t(z+255.);
6470 AliTPCclusterMI *cl =0;
6471 for (Int_t i=Find(z-roadz); i<fN; i++) {
6472 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6473 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6474 if (c->GetZ() > z+roadz) break;
6475 if ( c->GetY()-y > roady ) continue;
6476 if ( y-c->GetY() > roady ) continue;
6477 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6478 if (maxdistance>distance) {
6479 maxdistance = distance;
6480 cl=c;
6481 index =i;
6482 //roady = TMath::Sqrt(maxdistance);
6483 }
6484 }
6485 return cl;
6486}
1627d1c4 6487
6488
6489
6490
91162307 6491
81e97e0d 6492// AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6493// {
6494// //
6495// //
6496// return &fTrackPoints[i];
6497// }
91162307 6498
91162307 6499