]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCtrackerMI.cxx
TPC parameters and Pedestals added to the database (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 //
91162307 1445 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1446 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1447 Double_t roady =1.;
1448 Double_t roadz = 1.;
1449 //
1c53abe2 1450 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1451 t.fInDead = kTRUE;
91162307 1452 t.SetClusterIndex2(nr,-1);
1c53abe2 1453 return 0;
1454 }
1455 else
1456 {
3f82c4f2 1457 if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength() && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker()))
1458 t.fNFoundable++;
1627d1c4 1459 else
1460 return 0;
1c53abe2 1461 }
1462 //calculate
91162307 1463 if (krow) {
1464 // cl = krow.FindNearest2(y+10.,z,roady,roadz,index);
1465 cl = krow.FindNearest2(y,z,roady,roadz,index);
1466 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1467 }
91162307 1468 if (cl) {
1469 t.fCurrentCluster = cl;
1470 t.fRow = nr;
4d158c36 1471 if (fIteration==2&&cl->IsUsed(10)) return 0;
91162307 1472 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
4d158c36 1473 if (fIteration==2&&cl->IsUsed(11)) {
1474 t.fErrorY2 += 0.03;
1475 t.fErrorZ2 += 0.03;
1476 t.fErrorY2 *= 3;
1477 t.fErrorZ2 *= 3;
1478 }
d26d9159 1479 /*
91162307 1480 if (t.fCurrentCluster->IsUsed(10)){
1481 //
1482 //
c9427e08 1483
91162307 1484 t.fNShared++;
1485 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1486 t.fRemoval =10;
1487 return 0;
1488 }
1489 }
d26d9159 1490 */
91162307 1491 if (accept<3) UpdateTrack(&t,accept);
c9427e08 1492
91162307 1493 } else {
982aff31 1494 if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
91162307 1495
1496 }
1497 return 1;
1498}
c9427e08 1499
91162307 1500Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
1501 //-----------------------------------------------------------------
1502 // This function tries to find a track prolongation to next pad row
1503 //-----------------------------------------------------------------
1504 //
1505 Double_t x= GetXrow(nr), ymax=GetMaxY(nr);
1506 Double_t y,z;
1507 if (!t.GetProlongation(x,y,z)) {
1508 t.fRemoval = 10;
1509 return 0;
1510 }
1511 //
1512 //
1513 if (TMath::Abs(y)>ymax){
91162307 1514
1c53abe2 1515 if (y > ymax) {
1516 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1517 if (!t.Rotate(fSectors->GetAlpha()))
1518 return 0;
1519 } else if (y <-ymax) {
1520 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1521 if (!t.Rotate(-fSectors->GetAlpha()))
1522 return 0;
91162307 1523 }
1524 if (!t.PropagateTo(x)) {
1525 return 0;
1526 }
1527 t.GetProlongation(x,y,z);
1528 }
1529 //
1530 // update current shape info every 3 pad-row
1531 if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
1532 // t.fCurrentSigmaY = GetSigmaY(&t);
1533 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1534 GetShape(&t,nr);
1535 }
1536 //
1537 AliTPCclusterMI *cl=0;
1538 UInt_t index=0;
1539
1540
1541 //Int_t nr2 = nr;
1542 const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1543 if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
1544 Double_t roady =1.;
1545 Double_t roadz = 1.;
1546 //
1547 Int_t row = nr;
1548 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1549 t.fInDead = kTRUE;
1550 t.SetClusterIndex2(row,-1);
1551 return 0;
1552 }
1553 else
1554 {
d7a11555 1555 if (TMath::Abs(z)>(AliTPCReconstructor::GetCtgRange()*x+10)) t.SetClusterIndex2(row,-1);
1c53abe2 1556 }
91162307 1557 //calculate
1558
1559 if ((cl==0)&&(krow)) {
1560 // cl = krow.FindNearest2(y+10,z,roady,roadz,index);
1561 cl = krow.FindNearest2(y,z,roady,roadz,index);
1562
1563 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);
1564 }
1565
1566 if (cl) {
1567 t.fCurrentCluster = cl;
1568 // Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
1569 //if (accept<3){
1570 t.SetClusterIndex2(row,index);
1571 t.fClusterPointer[row] = cl;
1572 //}
1c53abe2 1573 }
1574 return 1;
1575}
1576
1577
91162307 1578
5d837844 1579//_________________________________________________________________________
1580Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
1581{
1582 // Get track space point by index
1583 // return false in case the cluster doesn't exist
1584 AliTPCclusterMI *cl = GetClusterMI(index);
1585 if (!cl) return kFALSE;
1586 Int_t sector = (index&0xff000000)>>24;
0201b65c 1587 // Int_t row = (index&0x00ff0000)>>16;
5d837844 1588 Float_t xyz[3];
0201b65c 1589 // xyz[0] = fParam->GetPadRowRadii(sector,row);
1590 xyz[0] = cl->GetX();
5d837844 1591 xyz[1] = cl->GetY();
1592 xyz[2] = cl->GetZ();
1593 Float_t sin,cos;
1594 fParam->AdjustCosSin(sector,cos,sin);
1595 Float_t x = cos*xyz[0]-sin*xyz[1];
1596 Float_t y = cos*xyz[1]+sin*xyz[0];
1597 Float_t cov[6];
1598 Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
1599 if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
1600 Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
1601 if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
1602 cov[0] = sin*sin*sigmaY2;
1603 cov[1] = -sin*cos*sigmaY2;
1604 cov[2] = 0.;
1605 cov[3] = cos*cos*sigmaY2;
1606 cov[4] = 0.;
1607 cov[5] = sigmaZ2;
1608 p.SetXYZ(x,y,xyz[2],cov);
1609 AliAlignObj::ELayerID iLayer;
1610 Int_t idet;
1611 if (sector < fParam->GetNInnerSector()) {
1612 iLayer = AliAlignObj::kTPC1;
1613 idet = sector;
1614 }
1615 else {
1616 iLayer = AliAlignObj::kTPC2;
1617 idet = sector - fParam->GetNInnerSector();
1618 }
1619 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet);
1620 p.SetVolumeID(volid);
1621 return kTRUE;
1622}
1623
1624
1625
91162307 1626Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t, Int_t nr) {
1c53abe2 1627 //-----------------------------------------------------------------
1628 // This function tries to find a track prolongation to next pad row
1629 //-----------------------------------------------------------------
1630 t.fCurrentCluster = 0;
1631 t.fCurrentClusterIndex1 = 0;
1c53abe2 1632
1633 Double_t xt=t.GetX();
91162307 1634 Int_t row = GetRowNumber(xt)-1;
1635 Double_t ymax= GetMaxY(nr);
1636
1c53abe2 1637 if (row < nr) return 1; // don't prolongate if not information until now -
ca142b1f 1638// if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
1639// t.fRemoval =10;
1640// return 0; // not prolongate strongly inclined tracks
1641// }
1642// if (TMath::Abs(t.GetSnp())>0.95) {
1643// t.fRemoval =10;
1644// return 0; // not prolongate strongly inclined tracks
1645// }// patch 28 fev 06
91162307 1646
1647 Double_t x= GetXrow(nr);
1648 Double_t y,z;
1649 //t.PropagateTo(x+0.02);
1650 //t.PropagateTo(x+0.01);
1627d1c4 1651 if (!t.PropagateTo(x)){
1627d1c4 1652 return 0;
1653 }
1c53abe2 1654 //
91162307 1655 y=t.GetY();
1656 z=t.GetZ();
1c53abe2 1657
91162307 1658 if (TMath::Abs(y)>ymax){
1659 if (y > ymax) {
1660 t.fRelativeSector= (t.fRelativeSector+1) % fN;
1661 if (!t.Rotate(fSectors->GetAlpha()))
1662 return 0;
1663 } else if (y <-ymax) {
1664 t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
1665 if (!t.Rotate(-fSectors->GetAlpha()))
1666 return 0;
1667 }
982aff31 1668 // if (!t.PropagateTo(x)){
1669 // return 0;
1670 //}
1671 return 1;
1672 //y = t.GetY();
1c53abe2 1673 }
91162307 1674 //
3f82c4f2 1675 if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
91162307 1676 AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
1c53abe2 1677
1678 if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
1679 t.fInDead = kTRUE;
91162307 1680 t.SetClusterIndex2(nr,-1);
1c53abe2 1681 return 0;
1682 }
1683 else
1684 {
3f82c4f2 1685 if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.fNFoundable++;
1627d1c4 1686 else
1687 return 0;
1c53abe2 1688 }
1c53abe2 1689
91162307 1690 // update current
1691 if ( (nr%6==0) || t.GetNumberOfClusters()<2){
1692 // t.fCurrentSigmaY = GetSigmaY(&t);
1693 //t.fCurrentSigmaZ = GetSigmaZ(&t);
1694 GetShape(&t,nr);
1695 }
1c53abe2 1696
91162307 1697 AliTPCclusterMI *cl=0;
d184f295 1698 Int_t index=0;
91162307 1699 //
1700 Double_t roady = 1.;
1701 Double_t roadz = 1.;
1702 //
d26d9159 1703
1704 if (!cl){
1705 index = t.GetClusterIndex2(nr);
1706 if ( (index>0) && (index&0x8000)==0){
1707 cl = t.fClusterPointer[nr];
1708 if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
1709 t.fCurrentClusterIndex1 = index;
1710 if (cl) {
1711 t.fCurrentCluster = cl;
1712 return 1;
1713 }
1714 }
1715 }
1716
3d172d79 1717 // if (index<0) return 0;
1718 UInt_t uindex = TMath::Abs(index);
d184f295 1719
91162307 1720 if (krow) {
d184f295 1721 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1722 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
91162307 1723 }
d26d9159 1724
d184f295 1725 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
d26d9159 1726 t.fCurrentCluster = cl;
1727
91162307 1728 return 1;
1729}
1c53abe2 1730
1c53abe2 1731
91162307 1732Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1733 //-----------------------------------------------------------------
1734 // This function tries to find a track prolongation to next pad row
1735 //-----------------------------------------------------------------
1c53abe2 1736
91162307 1737 //update error according neighborhoud
1c53abe2 1738
91162307 1739 if (t.fCurrentCluster) {
1740 t.fRow = nr;
8c51a605 1741 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
91162307 1742
1743 if (t.fCurrentCluster->IsUsed(10)){
1744 //
1745 //
1746 // t.fErrorZ2*=2;
1747 // t.fErrorY2*=2;
1748 t.fNShared++;
1749 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1750 t.fRemoval =10;
1751 return 0;
1752 }
b364ca79 1753 }
d26d9159 1754 if (fIteration>0) accept = 0;
b364ca79 1755 if (accept<3) UpdateTrack(&t,accept);
1756
1c53abe2 1757 } else {
91162307 1758 if (fIteration==0){
1759 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1760 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1761
1762 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1c53abe2 1763 }
1764 }
1765 return 1;
1766}
1767
1768
1769
91162307 1770//_____________________________________________________________________________
1771Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1772 //-----------------------------------------------------------------
91162307 1773 // This function tries to find a track prolongation.
1c53abe2 1774 //-----------------------------------------------------------------
1775 Double_t xt=t.GetX();
1776 //
91162307 1777 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1c53abe2 1778 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1779 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1780 //
1781 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1782
91162307 1783 Int_t first = GetRowNumber(xt)-1;
51ad6848 1784 for (Int_t nr= first; nr>=rf; nr-=step) {
1785 // update kink info
1786 if (t.GetKinkIndexes()[0]>0){
1787 for (Int_t i=0;i<3;i++){
1788 Int_t index = t.GetKinkIndexes()[i];
1789 if (index==0) break;
1790 if (index<0) continue;
1791 //
1792 AliESDkink * kink = fEvent->GetKink(index-1);
1793 if (!kink){
1794 printf("PROBLEM\n");
1795 }
1796 else{
eea478d3 1797 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
51ad6848 1798 if (kinkrow==nr){
1799 AliExternalTrackParam paramd(t);
1800 kink->SetDaughter(paramd);
eea478d3 1801 kink->SetStatus(2,5);
51ad6848 1802 kink->Update();
51ad6848 1803 }
1804 }
1805 }
1806 }
1807
1808 if (nr==80) t.UpdateReference();
982aff31 1809 if (nr<fInnerSec->GetNRows())
1810 fSectors = fInnerSec;
1811 else
1812 fSectors = fOuterSec;
91162307 1813 if (FollowToNext(t,nr)==0)
4d158c36 1814 if (!t.IsActive())
1815 return 0;
91162307 1816
1817 }
1818 return 1;
1819}
1820
1c53abe2 1821
1822//_____________________________________________________________________________
91162307 1823Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1824 //-----------------------------------------------------------------
1825 // This function tries to find a track prolongation.
1826 //-----------------------------------------------------------------
1827 Double_t xt=t.GetX();
1828 //
1829 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1830 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1831 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1832 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1833
1834 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1835
1836 if (FollowToNextFast(t,nr)==0)
1837 if (!t.IsActive()) return 0;
1c53abe2 1838
1c53abe2 1839 }
1840 return 1;
1841}
1842
1843
91162307 1844
1845
1846
1c53abe2 1847Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1848 //-----------------------------------------------------------------
1849 // This function tries to find a track prolongation.
1850 //-----------------------------------------------------------------
1c53abe2 1851 //
eea478d3 1852 Double_t xt=t.GetX();
1c53abe2 1853 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1854 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1855 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1856 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1857
4d158c36 1858 Int_t first = t.fFirstPoint;
eea478d3 1859 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
91162307 1860 //
1861 if (first<0) first=0;
4d158c36 1862 for (Int_t nr=first; nr<=rf; nr++) {
ca142b1f 1863 // if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
51ad6848 1864 if (t.GetKinkIndexes()[0]<0){
1865 for (Int_t i=0;i<3;i++){
1866 Int_t index = t.GetKinkIndexes()[i];
1867 if (index==0) break;
1868 if (index>0) continue;
1869 index = TMath::Abs(index);
1870 AliESDkink * kink = fEvent->GetKink(index-1);
1871 if (!kink){
1872 printf("PROBLEM\n");
1873 }
1874 else{
eea478d3 1875 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
51ad6848 1876 if (kinkrow==nr){
1877 AliExternalTrackParam paramm(t);
1878 kink->SetMother(paramm);
eea478d3 1879 kink->SetStatus(2,1);
51ad6848 1880 kink->Update();
51ad6848 1881 }
1882 }
eea478d3 1883 }
51ad6848 1884 }
eea478d3 1885 //
d26d9159 1886 if (nr<fInnerSec->GetNRows())
1887 fSectors = fInnerSec;
1888 else
1889 fSectors = fOuterSec;
1890 FollowToNext(t,nr);
1c53abe2 1891 }
1892 return 1;
1893}
1894
1895
1896
1897
1898
1899Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1900{
1901 //
1902 //
1903 sum1=0;
1904 sum2=0;
1905 Int_t sum=0;
1c53abe2 1906 //
1907 Float_t dz2 =(s1->GetZ() - s2->GetZ());
c9427e08 1908 dz2*=dz2;
91162307 1909
c9427e08 1910 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1c53abe2 1911 dy2*=dy2;
1912 Float_t distance = TMath::Sqrt(dz2+dy2);
c9427e08 1913 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1c53abe2 1914
91162307 1915 // Int_t offset =0;
c9427e08 1916 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1917 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
c9427e08 1918 if (lastpoint>160)
1919 lastpoint =160;
1920 if (firstpoint<0)
1921 firstpoint = 0;
91162307 1922 if (firstpoint>lastpoint) {
1923 firstpoint =lastpoint;
1924 // lastpoint =160;
c9427e08 1925 }
1926
1927
91162307 1928 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1929 if (s1->GetClusterIndex2(i)>0) sum1++;
1930 if (s2->GetClusterIndex2(i)>0) sum2++;
1931 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1c53abe2 1932 sum++;
1933 }
1934 }
91162307 1935 if (sum<5) return 0;
1936
1627d1c4 1937 Float_t summin = TMath::Min(sum1+1,sum2+1);
1938 Float_t ratio = (sum+1)/Float_t(summin);
1c53abe2 1939 return ratio;
1940}
1941
1942void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1943{
1944 //
1945 //
91162307 1946 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1947 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1948
1c53abe2 1949 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1950 dz2*=dz2;
1951 Float_t dy2 =(s1->GetY() - s2->GetY());
1952 dy2*=dy2;
91162307 1953 Float_t distance = dz2+dy2;
1954 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1955
1c53abe2 1956 //
91162307 1957 Int_t sumshared=0;
1958 //
1959 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1960 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1961 //
1962 if (firstpoint>=lastpoint-5) return;;
1c53abe2 1963
91162307 1964 for (Int_t i=firstpoint;i<lastpoint;i++){
1965 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1966 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1967 sumshared++;
1968 }
1969 }
1970 if (sumshared>4){
1971 // sign clusters
1972 //
1973 for (Int_t i=firstpoint;i<lastpoint;i++){
1974 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1975 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1976 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1977 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1978 if (s1->IsActive()&&s2->IsActive()){
1979 p1->fIsShared = kTRUE;
1980 p2->fIsShared = kTRUE;
1981 }
1982 }
1983 }
1984 }
1985 //
1986 if (sumshared>10){
1987 for (Int_t i=0;i<4;i++){
1988 if (s1->fOverlapLabels[3*i]==0){
1989 s1->fOverlapLabels[3*i] = s2->GetLabel();
1990 s1->fOverlapLabels[3*i+1] = sumshared;
1991 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1992 break;
1993 }
1994 }
1995 for (Int_t i=0;i<4;i++){
1996 if (s2->fOverlapLabels[3*i]==0){
1997 s2->fOverlapLabels[3*i] = s1->GetLabel();
1998 s2->fOverlapLabels[3*i+1] = sumshared;
1999 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
2000 break;
2001 }
2002 }
2003 }
1c53abe2 2004
91162307 2005}
1c53abe2 2006
91162307 2007void AliTPCtrackerMI::SignShared(TObjArray * arr)
2008{
1c53abe2 2009 //
91162307 2010 //sort trackss according sectors
2011 //
c9427e08 2012 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2013 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2014 if (!pt) continue;
2015 //if (pt) RotateToLocal(pt);
2016 pt->fSort = 0;
c9427e08 2017 }
91162307 2018 arr->UnSort();
1c53abe2 2019 arr->Sort(); // sorting according z
2020 arr->Expand(arr->GetEntries());
91162307 2021 //
2022 //
1c53abe2 2023 Int_t nseed=arr->GetEntriesFast();
1c53abe2 2024 for (Int_t i=0; i<nseed; i++) {
2025 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2026 if (!pt) continue;
2027 for (Int_t j=0;j<=12;j++){
2028 pt->fOverlapLabels[j] =0;
1c53abe2 2029 }
91162307 2030 }
2031 for (Int_t i=0; i<nseed; i++) {
2032 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2033 if (!pt) continue;
2034 if (pt->fRemoval>10) continue;
1c53abe2 2035 for (Int_t j=i+1; j<nseed; j++){
2036 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
91162307 2037 // if (pt2){
2038 if (pt2->fRemoval<=10) {
2039 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2040 SignShared(pt,pt2);
c9427e08 2041 }
91162307 2042 }
2043 }
2044}
2045
2046void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
2047{
2048 //
2049 //sort trackss according sectors
2050 //
2051 if (fDebug&1) {
6bdc18d6 2052 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
91162307 2053 }
2054 //
2055 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
2056 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2057 if (!pt) continue;
2058 pt->fSort = 0;
2059 }
2060 arr->UnSort();
2061 arr->Sort(); // sorting according z
2062 arr->Expand(arr->GetEntries());
2063 //
2064 //reset overlap labels
2065 //
2066 Int_t nseed=arr->GetEntriesFast();
2067 for (Int_t i=0; i<nseed; i++) {
2068 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2069 if (!pt) continue;
2070 pt->SetUniqueID(i);
2071 for (Int_t j=0;j<=12;j++){
2072 pt->fOverlapLabels[j] =0;
1c53abe2 2073 }
2074 }
91162307 2075 //
2076 //sign shared tracks
1c53abe2 2077 for (Int_t i=0; i<nseed; i++) {
2078 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2079 if (!pt) continue;
2080 if (pt->fRemoval>10) continue;
2081 Float_t deltac = pt->GetC()*0.1;
2082 for (Int_t j=i+1; j<nseed; j++){
2083 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2084 // if (pt2){
2085 if (pt2->fRemoval<=10) {
2086 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2087 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2088 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2089 //
2090 SignShared(pt,pt2);
2091 }
1c53abe2 2092 }
1c53abe2 2093 }
91162307 2094 //
2095 // remove highly shared tracks
2096 for (Int_t i=0; i<nseed; i++) {
2097 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2098 if (!pt) continue;
2099 if (pt->fRemoval>10) continue;
2100 //
2101 Int_t sumshared =0;
2102 for (Int_t j=0;j<4;j++){
2103 sumshared = pt->fOverlapLabels[j*3+1];
2104 }
2105 Float_t factor = factor1;
2106 if (pt->fRemoval>0) factor = factor2;
2107 if (sumshared/pt->GetNumberOfClusters()>factor){
2108 for (Int_t j=0;j<4;j++){
2109 if (pt->fOverlapLabels[3*j]==0) continue;
2110 if (pt->fOverlapLabels[3*j+1]<5) continue;
2111 if (pt->fRemoval==removalindex) continue;
2112 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2113 if (!pt2) continue;
2114 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2115 // pt->fRemoval = removalindex;
2116 delete arr->RemoveAt(i);
2117 break;
1c53abe2 2118 }
91162307 2119 }
1c53abe2 2120 }
91162307 2121 }
2122 arr->Compress();
2123 if (fDebug&1) {
6bdc18d6 2124 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
91162307 2125 }
2126}
2127
2128
2129
1c53abe2 2130
2131
91162307 2132
47966a6d 2133void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
91162307 2134{
2135 //
2136 //sort tracks in array according mode criteria
2137 Int_t nseed = arr->GetEntriesFast();
2138 for (Int_t i=0; i<nseed; i++) {
2139 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2140 if (!pt) {
2141 continue;
2142 }
2143 pt->fSort = mode;
2144 }
2145 arr->UnSort();
2146 arr->Sort();
1c53abe2 2147}
c9427e08 2148
91162307 2149void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
c9427e08 2150{
2151
2152 //Loop over all tracks and remove "overlaps"
2153 //
2154 //
2155 Int_t nseed = arr->GetEntriesFast();
2156 Int_t good =0;
91162307 2157
c9427e08 2158 for (Int_t i=0; i<nseed; i++) {
2159 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2160 if (!pt) {
91162307 2161 delete arr->RemoveAt(i);
c9427e08 2162 }
91162307 2163 else{
2164 pt->fSort =1;
2165 pt->fBSigned = kFALSE;
c9427e08 2166 }
91162307 2167 }
2168 arr->Compress();
2169 nseed = arr->GetEntriesFast();
2170 arr->UnSort();
2171 arr->Sort();
2172 //
2173 //unsign used
2174 UnsignClusters();
2175 //
2176 for (Int_t i=0; i<nseed; i++) {
2177 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2178 if (!pt) {
2179 continue;
2180 }
2181 Int_t found,foundable,shared;
2182 if (pt->IsActive())
2183 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2184 else
2185 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2186 //
2187 Double_t factor = factor2;
2188 if (pt->fBConstrain) factor = factor1;
2189
2190 if ((Float_t(shared)/Float_t(found))>factor){
c9427e08 2191 pt->Desactivate(removalindex);
91162307 2192 continue;
2193 }
2194
2195 good++;
2196 for (Int_t i=0; i<160; i++) {
2197 Int_t index=pt->GetClusterIndex2(i);
2198 if (index<0 || index&0x8000 ) continue;
2199 AliTPCclusterMI *c= pt->fClusterPointer[i];
2200 if (!c) continue;
2201 // if (!c->IsUsed(10)) c->Use(10);
2202 //if (pt->IsActive())
2203 c->Use(10);
2204 //else
2205 // c->Use(5);
c9427e08 2206 }
91162307 2207
c9427e08 2208 }
2209 fNtracks = good;
6bdc18d6 2210 if (fDebug>0){
2211 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2212 }
c9427e08 2213}
2214
51ad6848 2215
2216void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2217{
2218
2219 //Loop over all tracks and remove "overlaps"
2220 //
2221 //
2222 UnsignClusters();
2223 //
2224 Int_t nseed = arr->GetEntriesFast();
2225 Float_t * quality = new Float_t[nseed];
2226 Int_t * indexes = new Int_t[nseed];
2227 Int_t good =0;
2228 //
2229 //
2230 for (Int_t i=0; i<nseed; i++) {
2231 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2232 if (!pt){
2233 quality[i]=-1;
2234 continue;
2235 }
2236 pt->UpdatePoints(); //select first last max dens points
2237 Float_t * points = pt->GetPoints();
2238 if (points[3]<0.8) quality[i] =-1;
2239 //
2240 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2241 }
2242 TMath::Sort(nseed,quality,indexes);
2243 //
2244 //
2245 for (Int_t itrack=0; itrack<nseed; itrack++) {
2246 Int_t trackindex = indexes[itrack];
2247 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2248 if (quality[trackindex]<0){
2249 if (pt) {
2250 delete arr->RemoveAt(trackindex);
2251 }
2252 else{
2253 arr->RemoveAt(trackindex);
2254 }
2255 continue;
2256 }
2257 //
2258 Int_t first = Int_t(pt->GetPoints()[0]);
2259 Int_t last = Int_t(pt->GetPoints()[2]);
2260 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2261 //
2262 Int_t found,foundable,shared;
2263 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
eea478d3 2264 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
b406fdb0 2265 Bool_t itsgold =kFALSE;
2266 if (pt->fEsd){
ef7253ac 2267 Int_t dummy[12];
b406fdb0 2268 if (pt->fEsd->GetITSclusters(dummy)>4) itsgold= kTRUE;
51ad6848 2269 }
b406fdb0 2270 if (!itsgold){
2271 //
2272 if (Float_t(shared+1)/Float_t(found+1)>factor){
2273 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2274 delete arr->RemoveAt(trackindex);
2275 continue;
2276 }
2277 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2278 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2279 delete arr->RemoveAt(trackindex);
2280 continue;
2281 }
51ad6848 2282 }
2283
2284 good++;
2285 if (sharedfactor>0.4) continue;
b406fdb0 2286 if (pt->GetKinkIndexes()[0]>0) continue;
51ad6848 2287 for (Int_t i=first; i<last; i++) {
2288 Int_t index=pt->GetClusterIndex2(i);
2289 // if (index<0 || index&0x8000 ) continue;
2290 if (index<0 || index&0x8000 ) continue;
2291 AliTPCclusterMI *c= pt->fClusterPointer[i];
2292 if (!c) continue;
2293 c->Use(10);
2294 }
2295 }
2296 fNtracks = good;
2297 if (fDebug>0){
2298 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2299 }
2300 delete []quality;
2301 delete []indexes;
2302}
2303
91162307 2304void AliTPCtrackerMI::UnsignClusters()
1c53abe2 2305{
91162307 2306 //
2307 // loop over all clusters and unsign them
2308 //
2309
2310 for (Int_t sec=0;sec<fkNIS;sec++){
2311 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2312 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2313 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2314 // if (cl[icl].IsUsed(10))
2315 cl[icl].Use(-1);
2316 cl = fInnerSec[sec][row].fClusters2;
2317 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2318 //if (cl[icl].IsUsed(10))
2319 cl[icl].Use(-1);
2320 }
2321 }
2322
2323 for (Int_t sec=0;sec<fkNOS;sec++){
2324 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2325 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2326 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2327 //if (cl[icl].IsUsed(10))
2328 cl[icl].Use(-1);
2329 cl = fOuterSec[sec][row].fClusters2;
2330 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2331 //if (cl[icl].IsUsed(10))
2332 cl[icl].Use(-1);
2333 }
2334 }
2335
1c53abe2 2336}
2337
91162307 2338
2339
732b9e78 2340void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
1c53abe2 2341{
2342 //
91162307 2343 //sign clusters to be "used"
2344 //
2345 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2346 // loop over "primaries"
2347
2348 Float_t sumdens=0;
2349 Float_t sumdens2=0;
2350 Float_t sumn =0;
2351 Float_t sumn2 =0;
2352 Float_t sumchi =0;
2353 Float_t sumchi2 =0;
2354
2355 Float_t sum =0;
2356
1c53abe2 2357 TStopwatch timer;
91162307 2358 timer.Start();
1c53abe2 2359
91162307 2360 Int_t nseed = arr->GetEntriesFast();
2361 for (Int_t i=0; i<nseed; i++) {
2362 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2363 if (!pt) {
2364 continue;
2365 }
2366 if (!(pt->IsActive())) continue;
2367 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2368 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2369 sumdens += dens;
2370 sumdens2+= dens*dens;
2371 sumn += pt->GetNumberOfClusters();
2372 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2373 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2374 if (chi2>5) chi2=5;
2375 sumchi +=chi2;
2376 sumchi2 +=chi2*chi2;
2377 sum++;
2378 }
1627d1c4 2379 }
91162307 2380
2381 Float_t mdensity = 0.9;
2382 Float_t meann = 130;
2383 Float_t meanchi = 1;
2384 Float_t sdensity = 0.1;
2385 Float_t smeann = 10;
2386 Float_t smeanchi =0.4;
1627d1c4 2387
91162307 2388
2389 if (sum>20){
2390 mdensity = sumdens/sum;
2391 meann = sumn/sum;
2392 meanchi = sumchi/sum;
2393 //
2394 sdensity = sumdens2/sum-mdensity*mdensity;
2395 sdensity = TMath::Sqrt(sdensity);
2396 //
2397 smeann = sumn2/sum-meann*meann;
2398 smeann = TMath::Sqrt(smeann);
2399 //
2400 smeanchi = sumchi2/sum - meanchi*meanchi;
2401 smeanchi = TMath::Sqrt(smeanchi);
2402 }
2403
2404
2405 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2406 //
2407 for (Int_t i=0; i<nseed; i++) {
2408 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2409 if (!pt) {
2410 continue;
1c53abe2 2411 }
91162307 2412 if (pt->fBSigned) continue;
2413 if (pt->fBConstrain) continue;
2414 //if (!(pt->IsActive())) continue;
2415 /*
2416 Int_t found,foundable,shared;
2417 pt->GetClusterStatistic(0,160,found, foundable,shared);
2418 if (shared/float(found)>0.3) {
2419 if (shared/float(found)>0.9 ){
2420 //delete arr->RemoveAt(i);
2421 }
2422 continue;
c9427e08 2423 }
91162307 2424 */
2425 Bool_t isok =kFALSE;
2426 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2427 isok = kTRUE;
2428 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2429 isok =kTRUE;
2430 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2431 isok =kTRUE;
2432 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2433 isok =kTRUE;
2434
2435 if (isok)
2436 for (Int_t i=0; i<160; i++) {
2437 Int_t index=pt->GetClusterIndex2(i);
2438 if (index<0) continue;
2439 AliTPCclusterMI *c= pt->fClusterPointer[i];
2440 if (!c) continue;
2441 //if (!(c->IsUsed(10))) c->Use();
2442 c->Use(10);
2443 }
2444 }
2445
c9427e08 2446
1c53abe2 2447 //
91162307 2448 Double_t maxchi = meanchi+2.*smeanchi;
2449
2450 for (Int_t i=0; i<nseed; i++) {
2451 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2452 if (!pt) {
1c53abe2 2453 continue;
91162307 2454 }
2455 //if (!(pt->IsActive())) continue;
2456 if (pt->fBSigned) continue;
2457 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2458 if (chi>maxchi) continue;
2459
2460 Float_t bfactor=1;
2461 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2462
2463 //sign only tracks with enoug big density at the beginning
2464
2465 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2466
2467
3e5d0aa2 2468 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
91162307 2469 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2470
2471 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2472 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2473 minn=0;
2474
2475 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2476 //Int_t noc=pt->GetNumberOfClusters();
2477 pt->fBSigned = kTRUE;
2478 for (Int_t i=0; i<160; i++) {
2479
2480 Int_t index=pt->GetClusterIndex2(i);
2481 if (index<0) continue;
2482 AliTPCclusterMI *c= pt->fClusterPointer[i];
2483 if (!c) continue;
2484 // if (!(c->IsUsed(10))) c->Use();
2485 c->Use(10);
2486 }
1c53abe2 2487 }
91162307 2488 }
2489 // gLastCheck = nseed;
2490 // arr->Compress();
2491 if (fDebug>0){
2492 timer.Print();
2493 }
1c53abe2 2494}
2495
2496
47966a6d 2497void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
91162307 2498{
2499 // stop not active tracks
2500 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2501 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2502 Int_t nseed = arr->GetEntriesFast();
2503 //
2504 for (Int_t i=0; i<nseed; i++) {
2505 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2506 if (!pt) {
2507 continue;
2508 }
2509 if (!(pt->IsActive())) continue;
2510 StopNotActive(pt,row0,th0, th1,th2);
2511 }
2512}
1c53abe2 2513
1c53abe2 2514
1c53abe2 2515
91162307 2516void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
47966a6d 2517 Float_t th2) const
91162307 2518{
2519 // stop not active tracks
2520 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2521 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2522 Int_t sumgood1 = 0;
2523 Int_t sumgood2 = 0;
2524 Int_t foundable = 0;
2525 Int_t maxindex = seed->fLastPoint; //last foundable row
2526 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2527 seed->Desactivate(10) ;
2528 return;
2529 }
1c53abe2 2530
3e5d0aa2 2531 for (Int_t i=row0; i<maxindex; i++){
91162307 2532 Int_t index = seed->GetClusterIndex2(i);
2533 if (index!=-1) foundable++;
2534 //if (!c) continue;
2535 if (foundable<=30) sumgood1++;
2536 if (foundable<=50) {
2537 sumgood2++;
2538 }
2539 else{
2540 break;
2541 }
2542 }
2543 if (foundable>=30.){
2544 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2545 }
2546 if (foundable>=50)
2547 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2548}
1c53abe2 2549
1c53abe2 2550
d26d9159 2551Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2552{
2553 //
2554 // back propagation of ESD tracks
2555 //
2556 //return 0;
2557 fEvent = event;
2558 ReadSeeds(event,2);
2559 fIteration=2;
982aff31 2560 //PrepareForProlongation(fSeeds,1);
2561 PropagateForward2(fSeeds);
af32720d 2562
4d158c36 2563 Int_t ntracks=0;
d26d9159 2564 Int_t nseed = fSeeds->GetEntriesFast();
2565 for (Int_t i=0;i<nseed;i++){
2566 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
4d158c36 2567 if (!seed) continue;
eea478d3 2568 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2569
d26d9159 2570 seed->PropagateTo(fParam->GetInnerRadiusLow());
51ad6848 2571 seed->UpdatePoints();
d26d9159 2572 AliESDtrack *esd=event->GetTrack(i);
2573 seed->CookdEdx(0.02,0.6);
2574 CookLabel(seed,0.1); //For comparison only
af32720d 2575 //
34acb742 2576 if (AliTPCReconstructor::StreamLevel()>0 && seed!=0&&esd!=0) {
af32720d 2577 TTreeSRedirector &cstream = *fDebugStreamer;
2578 cstream<<"Crefit"<<
2579 "Esd.="<<esd<<
2580 "Track.="<<seed<<
2581 "\n";
2582 }
51ad6848 2583 if (seed->GetNumberOfClusters()>15){
4d158c36 2584 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
51ad6848 2585 esd->SetTPCPoints(seed->GetPoints());
b406fdb0 2586 esd->SetTPCPointsF(seed->fNFoundable);
2587 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2588 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2589 Float_t dedx = seed->GetdEdx();
2590 esd->SetTPCsignal(dedx, sdedx, ndedx);
fdedfdec 2591 //
2592 // add seed to the esd track in Calib level
2593 //
2594 if (AliTPCReconstructor::StreamLevel()>0){
2595 AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE);
2596 esd->AddCalibObject(seedCopy);
2597 }
4d158c36 2598 ntracks++;
d26d9159 2599 }
2600 else{
2601 //printf("problem\n");
2602 }
2603 }
51ad6848 2604 //FindKinks(fSeeds,event);
4d158c36 2605 Info("RefitInward","Number of refitted tracks %d",ntracks);
d26d9159 2606 fEvent =0;
2607 //WriteTracks();
2608 return 0;
2609}
2610
1c53abe2 2611
91162307 2612Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2613{
2614 //
2615 // back propagation of ESD tracks
2616 //
1c53abe2 2617
91162307 2618 fEvent = event;
d26d9159 2619 fIteration = 1;
5d837844 2620 ReadSeeds(event,1);
b406fdb0 2621 PropagateBack(fSeeds);
2622 RemoveUsed2(fSeeds,0.4,0.4,20);
2623 //
91162307 2624 Int_t nseed = fSeeds->GetEntriesFast();
4d158c36 2625 Int_t ntracks=0;
91162307 2626 for (Int_t i=0;i<nseed;i++){
2627 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
d9e62e7e 2628 if (!seed) continue;
51ad6848 2629 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2630 seed->UpdatePoints();
91162307 2631 AliESDtrack *esd=event->GetTrack(i);
d26d9159 2632 seed->CookdEdx(0.02,0.6);
91162307 2633 CookLabel(seed,0.1); //For comparison only
51ad6848 2634 if (seed->GetNumberOfClusters()>15){
4d158c36 2635 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
51ad6848 2636 esd->SetTPCPoints(seed->GetPoints());
167c41ab 2637 esd->SetTPCPointsF(seed->fNFoundable);
2638 Int_t ndedx = seed->fNCDEDX[0]+seed->fNCDEDX[1]+seed->fNCDEDX[2]+seed->fNCDEDX[3];
2639 Float_t sdedx = (seed->fSDEDX[0]+seed->fSDEDX[1]+seed->fSDEDX[2]+seed->fSDEDX[3])*0.25;
2640 Float_t dedx = seed->GetdEdx();
2641 esd->SetTPCsignal(dedx, sdedx, ndedx);
4d158c36 2642 ntracks++;
ca142b1f 2643 Int_t eventnumber = event->GetEventNumber();// patch 28 fev 06
2644 (*fDebugStreamer)<<"Cback"<<
2645 "Tr0.="<<seed<<
2646 "EventNr="<<eventnumber<<
2647 "\n"; // patch 28 fev 06
4d158c36 2648 }
91162307 2649 }
51ad6848 2650 //FindKinks(fSeeds,event);
4d158c36 2651 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
91162307 2652 fEvent =0;
d26d9159 2653 //WriteTracks();
91162307 2654 return 0;
2655}
2656
2657
2658void AliTPCtrackerMI::DeleteSeeds()
2659{
b67e07dc 2660 //
2661 //delete Seeds
91162307 2662 Int_t nseed = fSeeds->GetEntriesFast();
2663 for (Int_t i=0;i<nseed;i++){
2664 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2665 if (seed) delete fSeeds->RemoveAt(i);
2666 }
2667 delete fSeeds;
2668 fSeeds =0;
2669}
2670
d26d9159 2671void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
91162307 2672{
2673 //
2674 //read seeds from the event
2675
2676 Int_t nentr=event->GetNumberOfTracks();
6bdc18d6 2677 if (fDebug>0){
2678 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2679 }
91162307 2680 if (fSeeds)
2681 DeleteSeeds();
2682 if (!fSeeds){
4d158c36 2683 fSeeds = new TObjArray(nentr);
91162307 2684 }
4d158c36 2685 UnsignClusters();
2686 // Int_t ntrk=0;
91162307 2687 for (Int_t i=0; i<nentr; i++) {
2688 AliESDtrack *esd=event->GetTrack(i);
51ad6848 2689 ULong_t status=esd->GetStatus();
2690 if (!(status&AliESDtrack::kTPCin)) continue;
b67e07dc 2691 AliTPCtrack t(*esd);
5d837844 2692 t.SetNumberOfClusters(0);
eea478d3 2693 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2694 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2695 for (Int_t ikink=0;ikink<3;ikink++) {
2696 Int_t index = esd->GetKinkIndex(ikink);
2697 seed->GetKinkIndexes()[ikink] = index;
2698 if (index==0) continue;
2699 index = TMath::Abs(index);
2700 AliESDkink * kink = fEvent->GetKink(index-1);
2701 if (kink&&esd->GetKinkIndex(ikink)<0){
2702 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2703 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2704 }
2705 if (kink&&esd->GetKinkIndex(ikink)>0){
2706 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2707 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2708 }
2709
2710 }
5d837844 2711 if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance();
982aff31 2712 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
4d158c36 2713 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2714 fSeeds->AddAt(0,i);
2715 delete seed;
2716 continue;
2717 }
2718 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
c0b978f0 2719 Double_t par0[5],par1[5],alpha,x;
2720 esd->GetInnerExternalParameters(alpha,x,par0);
4d158c36 2721 esd->GetExternalParameters(x,par1);
2722 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2723 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
51ad6848 2724 Double_t trdchi2=0;
2725 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
4d158c36 2726 //reset covariance if suspicious
51ad6848 2727 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
4d158c36 2728 seed->ResetCovariance();
2729 }
982aff31 2730
91162307 2731 //
2732 //
2733 // rotate to the local coordinate system
eea478d3 2734 //
2735 fSectors=fInnerSec; fN=fkNIS;
91162307 2736 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2737 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2738 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2739 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2740 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
4d158c36 2741 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2742 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
91162307 2743 alpha-=seed->GetAlpha();
d9b8978b 2744 if (!seed->Rotate(alpha)) {
2745 delete seed;
2746 continue;
2747 }
d26d9159 2748 seed->fEsd = esd;
4d158c36 2749 // sign clusters
b406fdb0 2750 if (esd->GetKinkIndex(0)<=0){
2751 for (Int_t irow=0;irow<160;irow++){
2752 Int_t index = seed->GetClusterIndex2(irow);
2753 if (index>0){
2754 //
2755 AliTPCclusterMI * cl = GetClusterMI(index);
2756 seed->fClusterPointer[irow] = cl;
2757 if (cl){
2758 if ((index & 0x8000)==0){
2759 cl->Use(10); // accepted cluster
2760 }else{
2761 cl->Use(6); // close cluster not accepted
2762 }
4d158c36 2763 }else{
b406fdb0 2764 Info("ReadSeeds","Not found cluster");
2765 }
4d158c36 2766 }
2767 }
2768 }
2769 fSeeds->AddAt(seed,i);
91162307 2770 }
2771}
2772
2773
2774
2775//_____________________________________________________________________________
2776void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2777 Float_t deltay, Int_t ddsec) {
2778 //-----------------------------------------------------------------
2779 // This function creates track seeds.
2780 // SEEDING WITH VERTEX CONSTRAIN
2781 //-----------------------------------------------------------------
2782 // cuts[0] - fP4 cut
2783 // cuts[1] - tan(phi) cut
2784 // cuts[2] - zvertex cut
2785 // cuts[3] - fP3 cut
2786 Int_t nin0 = 0;
2787 Int_t nin1 = 0;
2788 Int_t nin2 = 0;
2789 Int_t nin = 0;
2790 Int_t nout1 = 0;
2791 Int_t nout2 = 0;
2792
2793 Double_t x[5], c[15];
2794 // Int_t di = i1-i2;
2795 //
2796 AliTPCseed * seed = new AliTPCseed;
2797 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2798 Double_t cs=cos(alpha), sn=sin(alpha);
2799 //
2800 // Double_t x1 =fOuterSec->GetX(i1);
2801 //Double_t xx2=fOuterSec->GetX(i2);
2802
2803 Double_t x1 =GetXrow(i1);
2804 Double_t xx2=GetXrow(i2);
2805
2806 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2807
2808 Int_t imiddle = (i2+i1)/2; //middle pad row index
2809 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2810 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2811 //
2812 Int_t ns =sec;
2813
2814 const AliTPCRow& kr1=GetRow(ns,i1);
2815 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2816 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2817
2818 //
2819 // change cut on curvature if it can't reach this layer
2820 // maximal curvature set to reach it
2821 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2822 if (dvertexmax*0.5*cuts[0]>0.85){
2823 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2824 }
2825 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2826
2827 // Int_t ddsec = 1;
2828 if (deltay>0) ddsec = 0;
2829 // loop over clusters
2830 for (Int_t is=0; is < kr1; is++) {
2831 //
2832 if (kr1[is]->IsUsed(10)) continue;
2833 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2834 //if (TMath::Abs(y1)>ymax) continue;
2835
2836 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2837
2838 // find possible directions
2839 Float_t anglez = (z1-z3)/(x1-x3);
2840 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2841 //
2842 //
2843 //find rotation angles relative to line given by vertex and point 1
2844 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2845 Double_t dvertex = TMath::Sqrt(dvertex2);
2846 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2847 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2848
2849 //
2850 // loop over 2 sectors
2851 Int_t dsec1=-ddsec;
2852 Int_t dsec2= ddsec;
2853 if (y1<0) dsec2= 0;
2854 if (y1>0) dsec1= 0;
2855
2856 Double_t dddz1=0; // direction of delta inclination in z axis
2857 Double_t dddz2=0;
2858 if ( (z1-z3)>0)
2859 dddz1 =1;
2860 else
2861 dddz2 =1;
2862 //
2863 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2864 Int_t sec2 = sec + dsec;
2865 //
2866 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2867 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2868 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2869 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2870 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2871 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2872
2873 // rotation angles to p1-p3
2874 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2875 Double_t x2, y2, z2;
2876 //
2877 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2878
2879 //
2880 Double_t dxx0 = (xx2-x3)*cs13r;
2881 Double_t dyy0 = (xx2-x3)*sn13r;
2882 for (Int_t js=index1; js < index2; js++) {
2883 const AliTPCclusterMI *kcl = kr2[js];
2884 if (kcl->IsUsed(10)) continue;
2885 //
2886 //calcutate parameters
2887 //
2888 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2889 // stright track
2890 if (TMath::Abs(yy0)<0.000001) continue;
2891 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2892 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2893 Double_t r02 = (0.25+y0*y0)*dvertex2;
2894 //curvature (radius) cut
2895 if (r02<r2min) continue;
2896
2897 nin0++;
2898 //
2899 Double_t c0 = 1/TMath::Sqrt(r02);
2900 if (yy0>0) c0*=-1.;
2901
2902
2903 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2904 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
b67e07dc 2905 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2906 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
91162307 2907 //
2908 //
2909 Double_t z0 = kcl->GetZ();
2910 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2911 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2912 nin1++;
2913 //
2914 Double_t dip = (z1-z0)*c0/dfi1;
2915 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2916 //
2917 y2 = kcl->GetY();
2918 if (dsec==0){
2919 x2 = xx2;
2920 z2 = kcl->GetZ();
2921 }
2922 else
2923 {
2924 // rotation
2925 z2 = kcl->GetZ();
2926 x2= xx2*cs-y2*sn*dsec;
2927 y2=+xx2*sn*dsec+y2*cs;
2928 }
2929
2930 x[0] = y1;
2931 x[1] = z1;
2932 x[2] = x0;
2933 x[3] = dip;
2934 x[4] = c0;
2935 //
2936 //
2937 // do we have cluster at the middle ?
2938 Double_t ym,zm;
2939 GetProlongation(x1,xm,x,ym,zm);
2940 UInt_t dummy;
2941 AliTPCclusterMI * cm=0;
2942 if (TMath::Abs(ym)-ymaxm<0){
2943 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2944 if ((!cm) || (cm->IsUsed(10))) {
2945 continue;
2946 }
2947 }
2948 else{
2949 // rotate y1 to system 0
2950 // get state vector in rotated system
2951 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2952 Double_t xr2 = x0*cs+yr1*sn*dsec;
2953 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2954 //
2955 GetProlongation(xx2,xm,xr,ym,zm);
2956 if (TMath::Abs(ym)-ymaxm<0){
2957 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2958 if ((!cm) || (cm->IsUsed(10))) {
2959 continue;
2960 }
2961 }
2962 }
2963
2964
2965 Double_t dym = 0;
2966 Double_t dzm = 0;
2967 if (cm){
2968 dym = ym - cm->GetY();
2969 dzm = zm - cm->GetZ();
2970 }
2971 nin2++;
2972
2973
2974 //
2975 //
2976 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2977 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2978 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2979 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2980 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2981
b67e07dc 2982 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2983 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2984 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2985 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2986 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2987 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 2988
b67e07dc 2989 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2990 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2991 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2992 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
91162307 2993
1c53abe2 2994 c[0]=sy1;
2995 c[1]=0.; c[2]=sz1;
2996 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2997 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2998 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2999 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3000 c[13]=f30*sy1*f40+f32*sy2*f42;
3001 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
91162307 3002
3003 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3004
1c53abe2 3005 UInt_t index=kr1.GetIndex(is);
91162307 3006 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
3007
1c53abe2 3008 track->fIsSeeding = kTRUE;
91162307 3009 track->fSeed1 = i1;
3010 track->fSeed2 = i2;
3011 track->fSeedType=3;
c9427e08 3012
91162307 3013
3014 //if (dsec==0) {
3015 FollowProlongation(*track, (i1+i2)/2,1);
3016 Int_t foundable,found,shared;
3017 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
3018 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
3019 seed->Reset();
3020 seed->~AliTPCseed();
3021 continue;
3022 }
3023 //}
3024
3025 nin++;
3026 FollowProlongation(*track, i2,1);
3027
3028
3029 //Int_t rc = 1;
3030 track->fBConstrain =1;
3031 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3032 track->fLastPoint = i1; // first cluster in track position
3033 track->fFirstPoint = track->fLastPoint;
3034
3035 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3036 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3037 track->fNShared>0.4*track->GetNumberOfClusters() ) {
3038 seed->Reset();
3039 seed->~AliTPCseed();
c9427e08 3040 continue;
3041 }
91162307 3042 nout1++;
3043 // Z VERTEX CONDITION
3044 Double_t zv;
3045 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3046 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3047 if (TMath::Abs(zv-z3)>cuts[2]) {
3048 FollowProlongation(*track, TMath::Max(i2-20,0));
3049 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3050 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3051 if (TMath::Abs(zv-z3)>cuts[2]){
3052 FollowProlongation(*track, TMath::Max(i2-40,0));
3053 zv = track->GetZ()+track->GetTgl()/track->GetC()*
3054 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
3055 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
3056 // make seed without constrain
3057 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
3058 FollowProlongation(*track2, i2,1);
3059 track2->fBConstrain = kFALSE;
3060 track2->fSeedType = 1;
3061 arr->AddLast(track2);
3062 seed->Reset();
3063 seed->~AliTPCseed();
3064 continue;
3065 }
3066 else{
3067 seed->Reset();
3068 seed->~AliTPCseed();
3069 continue;
3070
3071 }
3072 }
c9427e08 3073 }
1c53abe2 3074
91162307 3075 track->fSeedType =0;
3076 arr->AddLast(track);
3077 seed = new AliTPCseed;
3078 nout2++;
3079 // don't consider other combinations
3080 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
3081 break;
1c53abe2 3082 }
3083 }
3084 }
6bdc18d6 3085 if (fDebug>3){
3086 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
91162307 3087 }
3088 delete seed;
1c53abe2 3089}
3090
1627d1c4 3091
91162307 3092void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
3093 Float_t deltay) {
3094
3095
3096
1627d1c4 3097 //-----------------------------------------------------------------
91162307 3098 // This function creates track seeds.
1627d1c4 3099 //-----------------------------------------------------------------
91162307 3100 // cuts[0] - fP4 cut
3101 // cuts[1] - tan(phi) cut
3102 // cuts[2] - zvertex cut
3103 // cuts[3] - fP3 cut
3104
3105
3106 Int_t nin0 = 0;
3107 Int_t nin1 = 0;
3108 Int_t nin2 = 0;
3109 Int_t nin = 0;
3110 Int_t nout1 = 0;
3111 Int_t nout2 = 0;
3112 Int_t nout3 =0;
3113 Double_t x[5], c[15];
3114 //
3115 // make temporary seed
3116 AliTPCseed * seed = new AliTPCseed;
1627d1c4 3117 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3118 // Double_t cs=cos(alpha), sn=sin(alpha);
91162307 3119 //
3120 //
1627d1c4 3121
91162307 3122 // first 3 padrows
3123 Double_t x1 = GetXrow(i1-1);
3124 const AliTPCRow& kr1=GetRow(sec,i1-1);
3125 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3126 //
3127 Double_t x1p = GetXrow(i1);
3128 const AliTPCRow& kr1p=GetRow(sec,i1);
3129 //
3130 Double_t x1m = GetXrow(i1-2);
3131 const AliTPCRow& kr1m=GetRow(sec,i1-2);
1627d1c4 3132
91162307 3133 //
3134 //last 3 padrow for seeding
3135 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3136 Double_t x3 = GetXrow(i1-7);
3137 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3138 //
3139 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3140 Double_t x3p = GetXrow(i1-6);
3141 //
3142 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3143 Double_t x3m = GetXrow(i1-8);
1627d1c4 3144
91162307 3145 //
3146 //
3147 // middle padrow
3148 Int_t im = i1-4; //middle pad row index
3149 Double_t xm = GetXrow(im); // radius of middle pad-row
3150 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3151 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3152 //
3153 //
3154 Double_t deltax = x1-x3;
3155 Double_t dymax = deltax*cuts[1];
3156 Double_t dzmax = deltax*cuts[3];
3157 //
3158 // loop over clusters
3159 for (Int_t is=0; is < kr1; is++) {
1627d1c4 3160 //
91162307 3161 if (kr1[is]->IsUsed(10)) continue;
3162 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
1627d1c4 3163 //
91162307 3164 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3165 //
3166 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3167 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3168 //
3169 Double_t y3, z3;
1627d1c4 3170 //
1627d1c4 3171 //
91162307 3172 UInt_t index;
3173 for (Int_t js=index1; js < index2; js++) {
3174 const AliTPCclusterMI *kcl = kr3[js];
3175 if (kcl->IsUsed(10)) continue;
3176 y3 = kcl->GetY();
3177 // apply angular cuts
3178 if (TMath::Abs(y1-y3)>dymax) continue;
3179 x3 = x3;
3180 z3 = kcl->GetZ();
3181 if (TMath::Abs(z1-z3)>dzmax) continue;
3182 //
3183 Double_t angley = (y1-y3)/(x1-x3);
3184 Double_t anglez = (z1-z3)/(x1-x3);
3185 //
3186 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3187 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3188 //
3189 Double_t yyym = angley*(xm-x1)+y1;
3190 Double_t zzzm = anglez*(xm-x1)+z1;
3191
3192 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3193 if (!kcm) continue;
3194 if (kcm->IsUsed(10)) continue;
3195
3196 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3197 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3198 //
3199 //
3200 //
3201 Int_t used =0;
3202 Int_t found =0;
3203 //
3204 // look around first
3205 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3206 anglez*(x1m-x1)+z1,
3207 erry,errz,index);
3208 //
3209 if (kc1m){
3210 found++;
3211 if (kc1m->IsUsed(10)) used++;
1627d1c4 3212 }
91162307 3213 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3214 anglez*(x1p-x1)+z1,
3215 erry,errz,index);
1627d1c4 3216 //
91162307 3217 if (kc1p){
3218 found++;
3219 if (kc1p->IsUsed(10)) used++;
1627d1c4 3220 }
91162307 3221 if (used>1) continue;
3222 if (found<1) continue;
1627d1c4 3223
91162307 3224 //
3225 // look around last
3226 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3227 anglez*(x3m-x3)+z3,
3228 erry,errz,index);
3229 //
3230 if (kc3m){
3231 found++;
3232 if (kc3m->IsUsed(10)) used++;
3233 }
3234 else
3235 continue;
3236 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3237 anglez*(x3p-x3)+z3,
3238 erry,errz,index);
3239 //
3240 if (kc3p){
3241 found++;
3242 if (kc3p->IsUsed(10)) used++;
3243 }
3244 else
3245 continue;
3246 if (used>1) continue;
3247 if (found<3) continue;
3248 //
3249 Double_t x2,y2,z2;
3250 x2 = xm;
3251 y2 = kcm->GetY();
3252 z2 = kcm->GetZ();
3253 //
3254
1627d1c4 3255 x[0]=y1;
3256 x[1]=z1;
b67e07dc 3257 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3258 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3259 nin0++;
3260 //
b67e07dc 3261 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3262 nin1++;
3263 //
b67e07dc 3264 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
91162307 3265 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3266 nin2++;
3267 //
3268 //
3269 Double_t sy1=0.1, sz1=0.1;
3270 Double_t sy2=0.1, sz2=0.1;
3271 Double_t sy3=0.1, sy=0.1, sz=0.1;
1627d1c4 3272
b67e07dc 3273 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3274 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3275 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3276 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3277 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3278 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 3279
b67e07dc 3280 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3281 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3282 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3283 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1627d1c4 3284
3285 c[0]=sy1;
91162307 3286 c[1]=0.; c[2]=sz1;
1627d1c4 3287 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3288 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3289 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3290 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3291 c[13]=f30*sy1*f40+f32*sy2*f42;
3292 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3293
91162307 3294 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3295
3296 UInt_t index=kr1.GetIndex(is);
3297 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3298
3299 track->fIsSeeding = kTRUE;
3300
3301 nin++;
3302 FollowProlongation(*track, i1-7,1);
3303 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3304 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3305 seed->Reset();
3306 seed->~AliTPCseed();
3307 continue;
3308 }
3309 nout1++;
3310 nout2++;
3311 //Int_t rc = 1;
3312 FollowProlongation(*track, i2,1);
3313 track->fBConstrain =0;
3314 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3315 track->fFirstPoint = track->fLastPoint;
3316
3317 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3318 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3319 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3320 seed->Reset();
3321 seed->~AliTPCseed();
3322 continue;
3323 }
3324
3325 {
3326 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3327 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3328 FollowProlongation(*track2, i2,1);
3329 track2->fBConstrain = kFALSE;
3330 track2->fSeedType = 4;
3331 arr->AddLast(track2);
3332 seed->Reset();
3333 seed->~AliTPCseed();
3334 }
3335
3336
3337 //arr->AddLast(track);
3338 //seed = new AliTPCseed;
3339 nout3++;
3340 }
3341 }
3342
6bdc18d6 3343 if (fDebug>3){
3344 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
91162307 3345 }
3346 delete seed;
3347}
3348
3349
3350//_____________________________________________________________________________
176aff27 3351void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3352 Float_t deltay, Bool_t /*bconstrain*/) {
91162307 3353 //-----------------------------------------------------------------
3354 // This function creates track seeds - without vertex constraint
3355 //-----------------------------------------------------------------
3356 // cuts[0] - fP4 cut - not applied
3357 // cuts[1] - tan(phi) cut
3358 // cuts[2] - zvertex cut - not applied
3359 // cuts[3] - fP3 cut
3360 Int_t nin0=0;
3361 Int_t nin1=0;
3362 Int_t nin2=0;
3363 Int_t nin3=0;
3364 // Int_t nin4=0;
3365 //Int_t nin5=0;
3366
3367
3368
3369 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3370 // Double_t cs=cos(alpha), sn=sin(alpha);
3371 Int_t row0 = (i1+i2)/2;
3372 Int_t drow = (i1-i2)/2;
3373 const AliTPCRow& kr0=fSectors[sec][row0];
3374 AliTPCRow * kr=0;
3375
3376 AliTPCpolyTrack polytrack;
3377 Int_t nclusters=fSectors[sec][row0];
3378 AliTPCseed * seed = new AliTPCseed;
3379
3380 Int_t sumused=0;
3381 Int_t cused=0;
3382 Int_t cnused=0;
3383 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3384 Int_t nfound =0;
3385 Int_t nfoundable =0;
3386 for (Int_t iter =1; iter<2; iter++){ //iterations
3387 const AliTPCRow& krm=fSectors[sec][row0-iter];
3388 const AliTPCRow& krp=fSectors[sec][row0+iter];
3389 const AliTPCclusterMI * cl= kr0[is];
3390
3391 if (cl->IsUsed(10)) {
3392 cused++;
3393 }
3394 else{
3395 cnused++;
3396 }
3397 Double_t x = kr0.GetX();
3398 // Initialization of the polytrack
3399 nfound =0;
3400 nfoundable =0;
3401 polytrack.Reset();
3402 //
3403 Double_t y0= cl->GetY();
3404 Double_t z0= cl->GetZ();
3405 Float_t erry = 0;
3406 Float_t errz = 0;
3407
3408 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3409 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3410
3411 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3412 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3413 polytrack.AddPoint(x,y0,z0,erry, errz);
3414
3415 sumused=0;
3416 if (cl->IsUsed(10)) sumused++;
3417
3418
3419 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3420 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3421 //
3422 x = krm.GetX();
3423 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3424 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3425 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3426 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3427 if (cl1->IsUsed(10)) sumused++;
3428 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3429 }
3430 //
3431 x = krp.GetX();
3432 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3433 if (cl2) {
3434 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3435 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3436 if (cl2->IsUsed(10)) sumused++;
3437 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3438 }
3439 //
3440 if (sumused>0) continue;
3441 nin0++;
3442 polytrack.UpdateParameters();
3443 // follow polytrack
3444 roadz = 1.2;
3445 roady = 1.2;
3446 //
3447 Double_t yn,zn;
3448 nfoundable = polytrack.GetN();
3449 nfound = nfoundable;
3450 //
3451 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3452 Float_t maxdist = 0.8*(1.+3./(ddrow));
3453 for (Int_t delta = -1;delta<=1;delta+=2){
3454 Int_t row = row0+ddrow*delta;
3455 kr = &(fSectors[sec][row]);
3456 Double_t xn = kr->GetX();
3457 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3458 polytrack.GetFitPoint(xn,yn,zn);
3459 if (TMath::Abs(yn)>ymax) continue;
3460 nfoundable++;
3461 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3462 if (cln) {
3463 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3464 if (dist<maxdist){
3465 /*
3466 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3467 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3468 if (cln->IsUsed(10)) {
3469 // printf("used\n");
3470 sumused++;
3471 erry*=2;
3472 errz*=2;
3473 }
3474 */
3475 erry=0.1;
3476 errz=0.1;
3477 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3478 nfound++;
3479 }
3480 }
3481 }
3482 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3483 polytrack.UpdateParameters();
3484 }
3485 }
3486 if ( (sumused>3) || (sumused>0.5*nfound)) {
3487 //printf("sumused %d\n",sumused);
3488 continue;
3489 }
3490 nin1++;
3491 Double_t dy,dz;
3492 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3493 AliTPCpolyTrack track2;
3494
3495 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3496 if (track2.GetN()<0.5*nfoundable) continue;
3497 nin2++;
3498
3499 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3500 //
3501 // test seed with and without constrain
3502 for (Int_t constrain=0; constrain<=0;constrain++){
3503 // add polytrack candidate
3504
3505 Double_t x[5], c[15];
3506 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3507 track2.GetBoundaries(x3,x1);
3508 x2 = (x1+x3)/2.;
3509 track2.GetFitPoint(x1,y1,z1);
3510 track2.GetFitPoint(x2,y2,z2);
3511 track2.GetFitPoint(x3,y3,z3);
3512 //
3513 //is track pointing to the vertex ?
3514 Double_t x0,y0,z0;
3515 x0=0;
3516 polytrack.GetFitPoint(x0,y0,z0);
3517
3518 if (constrain) {
3519 x2 = x3;
3520 y2 = y3;
3521 z2 = z3;
3522
3523 x3 = 0;
3524 y3 = 0;
3525 z3 = 0;
3526 }
3527 x[0]=y1;
3528 x[1]=z1;
b67e07dc 3529 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3530
3531 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
b67e07dc 3532 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3533
3534 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
b67e07dc 3535 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3536 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
91162307 3537 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3538
3539
3540 Double_t sy =0.1, sz =0.1;
3541 Double_t sy1=0.02, sz1=0.02;
3542 Double_t sy2=0.02, sz2=0.02;
3543 Double_t sy3=0.02;
3544
3545 if (constrain){
3546 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3547 }
3548
b67e07dc 3549 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3550 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3551 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3552 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3553 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3554 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3555
3556 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3557 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3558 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3559 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
91162307 3560
3561
3562 c[0]=sy1;
3563 c[1]=0.; c[2]=sz1;
3564 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3565 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3566 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3567 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3568 c[13]=f30*sy1*f40+f32*sy2*f42;
3569 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3570
3571 //Int_t row1 = fSectors->GetRowNumber(x1);
3572 Int_t row1 = GetRowNumber(x1);
3573
3574 UInt_t index=0;
3575 //kr0.GetIndex(is);
3576 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3577 track->fIsSeeding = kTRUE;
3578 Int_t rc=FollowProlongation(*track, i2);
3579 if (constrain) track->fBConstrain =1;
3580 else
3581 track->fBConstrain =0;
3582 track->fLastPoint = row1+fInnerSec->GetNRows(); // first cluster in track position
3583 track->fFirstPoint = track->fLastPoint;
3584
3585 if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3586 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
3587 track->fNShared>0.4*track->GetNumberOfClusters()) {
3588 //delete track;
3589 seed->Reset();
3590 seed->~AliTPCseed();
3591 }
3592 else {
3593 arr->AddLast(track);
3594 seed = new AliTPCseed;
3595 }
3596 nin3++;
3597 }
3598 } // if accepted seed
3599 }
6bdc18d6 3600 if (fDebug>3){
3601 Info("MakeSeeds2","\nSeeding statiistic:\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin3);
91162307 3602 }
3603 delete seed;
3604}
3605
3606
3607AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3608{
3609 //
3610 //
d26d9159 3611 //reseed using track points
91162307 3612 Int_t p0 = int(r0*track->GetNumberOfClusters()); // point 0
3613 Int_t p1 = int(r1*track->GetNumberOfClusters());
3614 Int_t p2 = int(r2*track->GetNumberOfClusters()); // last point
176aff27 3615 Int_t pp2=0;
91162307 3616 Double_t x0[3],x1[3],x2[3];
89e09524 3617 for (Int_t i=0;i<3;i++){
3618 x0[i]=-1;
3619 x1[i]=-1;
3620 x2[i]=-1;
3621 }
91162307 3622
3623 // find track position at given ratio of the length
89e09524 3624 Int_t sec0=0, sec1=0, sec2=0;
91162307 3625 Int_t index=-1;
3626 Int_t clindex;
3627 for (Int_t i=0;i<160;i++){
3628 if (track->fClusterPointer[i]){
3629 index++;
3630 AliTPCTrackerPoint *trpoint =track->GetTrackPoint(i);
3631 if ( (index<p0) || x0[0]<0 ){
3632 if (trpoint->GetX()>1){
3633 clindex = track->GetClusterIndex2(i);
3634 if (clindex>0){
3635 x0[0] = trpoint->GetX();
3636 x0[1] = trpoint->GetY();
3637 x0[2] = trpoint->GetZ();
3638 sec0 = ((clindex&0xff000000)>>24)%18;
3639 }
3640 }
3641 }
3642
3643 if ( (index<p1) &&(trpoint->GetX()>1)){
3644 clindex = track->GetClusterIndex2(i);
3645 if (clindex>0){
3646 x1[0] = trpoint->GetX();
3647 x1[1] = trpoint->GetY();
3648 x1[2] = trpoint->GetZ();
3649 sec1 = ((clindex&0xff000000)>>24)%18;
3650 }
3651 }
3652 if ( (index<p2) &&(trpoint->GetX()>1)){
3653 clindex = track->GetClusterIndex2(i);
3654 if (clindex>0){
3655 x2[0] = trpoint->GetX();
3656 x2[1] = trpoint->GetY();
3657 x2[2] = trpoint->GetZ();
3658 sec2 = ((clindex&0xff000000)>>24)%18;
3659 pp2 = i;
3660 }
3661 }
3662 }
3663 }
3664
3665 Double_t alpha, cs,sn, xx2,yy2;
3666 //
3667 alpha = (sec1-sec2)*fSectors->GetAlpha();
3668 cs = TMath::Cos(alpha);
3669 sn = TMath::Sin(alpha);
3670 xx2= x1[0]*cs-x1[1]*sn;
3671 yy2= x1[0]*sn+x1[1]*cs;
3672 x1[0] = xx2;
3673 x1[1] = yy2;
3674 //
3675 alpha = (sec0-sec2)*fSectors->GetAlpha();
3676 cs = TMath::Cos(alpha);
3677 sn = TMath::Sin(alpha);
3678 xx2= x0[0]*cs-x0[1]*sn;
3679 yy2= x0[0]*sn+x0[1]*cs;
3680 x0[0] = xx2;
3681 x0[1] = yy2;
3682 //
3683 //
3684 //
3685 Double_t x[5],c[15];
3686 //
3687 x[0]=x2[1];
3688 x[1]=x2[2];
b67e07dc 3689 x[4]=F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
91162307 3690 // if (x[4]>1) return 0;
b67e07dc 3691 x[2]=F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]);
3692 x[3]=F3n(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2],x[4]);
91162307 3693 //if (TMath::Abs(x[3]) > 2.2) return 0;
3694 //if (TMath::Abs(x[2]) > 1.99) return 0;
3695 //
3696 Double_t sy =0.1, sz =0.1;
3697 //
3698 Double_t sy1=0.02+track->GetSigmaY2(), sz1=0.02+track->GetSigmaZ2();
3699 Double_t sy2=0.01+track->GetSigmaY2(), sz2=0.01+track->GetSigmaZ2();
3700 Double_t sy3=0.01+track->GetSigmaY2();
3701 //
b67e07dc 3702 Double_t f40=(F1(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[4])/sy;
3703 Double_t f42=(F1(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[4])/sy;
3704 Double_t f43=(F1(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[4])/sy;
3705 Double_t f20=(F2(x2[0],x2[1]+sy,x1[0],x1[1],x0[0],x0[1])-x[2])/sy;
3706 Double_t f22=(F2(x2[0],x2[1],x1[0],x1[1]+sy,x0[0],x0[1])-x[2])/sy;
3707 Double_t f23=(F2(x2[0],x2[1],x1[0],x1[1],x0[0],x0[1]+sy)-x[2])/sy;
3708 //
3709 Double_t f30=(F3(x2[0],x2[1]+sy,x0[0],x0[1],x2[2],x0[2])-x[3])/sy;
3710 Double_t f31=(F3(x2[0],x2[1],x0[0],x0[1],x2[2]+sz,x0[2])-x[3])/sz;
3711 Double_t f32=(F3(x2[0],x2[1],x0[0],x0[1]+sy,x2[2],x0[2])-x[3])/sy;
3712 Double_t f34=(F3(x2[0],x2[1],x0[0],x0[1],x2[2],x0[2]+sz)-x[3])/sz;
91162307 3713
3714
3715 c[0]=sy1;
3716 c[1]=0.; c[2]=sz1;
3717 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3718 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3719 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3720 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3721 c[13]=f30*sy1*f40+f32*sy2*f42;
3722 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3723
3724 // Int_t row1 = fSectors->GetRowNumber(x2[0]);
3725 AliTPCseed *seed=new AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3726 // Double_t y0,z0,y1,z1, y2,z2;
3727 //seed->GetProlongation(x0[0],y0,z0);
3728 // seed->GetProlongation(x1[0],y1,z1);
3729 //seed->GetProlongation(x2[0],y2,z2);
3730 // seed =0;
3731 seed->fLastPoint = pp2;
3732 seed->fFirstPoint = pp2;
3733
3734
3735 return seed;
3736}
3737
d26d9159 3738
3739AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, Float_t r2)
3740{
3741 //
3742 //
3743 //reseed using founded clusters
3744 //
3745 // Find the number of clusters
3746 Int_t nclusters = 0;
3747 for (Int_t irow=0;irow<160;irow++){
3748 if (track->GetClusterIndex(irow)>0) nclusters++;
3749 }
3750 //
3751 Int_t ipos[3];
3752 ipos[0] = TMath::Max(int(r0*nclusters),0); // point 0 cluster
3753 ipos[1] = TMath::Min(int(r1*nclusters),nclusters-1); //
3754 ipos[2] = TMath::Min(int(r2*nclusters),nclusters-1); // last point
3755 //
3756 //
3757 Double_t xyz[3][3];
3758 Int_t row[3],sec[3]={0,0,0};
3759 //
3760 // find track row position at given ratio of the length
3761 Int_t index=-1;
3762 for (Int_t irow=0;irow<160;irow++){
3763 if (track->GetClusterIndex2(irow)<0) continue;
3764 index++;
3765 for (Int_t ipoint=0;ipoint<3;ipoint++){
3766 if (index<=ipos[ipoint]) row[ipoint] = irow;
3767 }
3768 }
3769 //
3770 //Get cluster and sector position
3771 for (Int_t ipoint=0;ipoint<3;ipoint++){
3772 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3773 AliTPCclusterMI * cl = GetClusterMI(clindex);
3774 if (cl==0) {
6bdc18d6 3775 //Error("Bug\n");
47966a6d 3776 // AliTPCclusterMI * cl = GetClusterMI(clindex);
d26d9159 3777 return 0;
3778 }
3779 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3780 xyz[ipoint][0] = GetXrow(row[ipoint]);
3781 xyz[ipoint][1] = cl->GetY();
3782 xyz[ipoint][2] = cl->GetZ();
3783 }
3784 //
3785 //
3786 // Calculate seed state vector and covariance matrix
3787
3788 Double_t alpha, cs,sn, xx2,yy2;
3789 //
3790 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3791 cs = TMath::Cos(alpha);
3792 sn = TMath::Sin(alpha);
3793 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3794 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3795 xyz[1][0] = xx2;
3796 xyz[1][1] = yy2;
3797 //
3798 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3799 cs = TMath::Cos(alpha);
3800 sn = TMath::Sin(alpha);
3801 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3802 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3803 xyz[0][0] = xx2;
3804 xyz[0][1] = yy2;
3805 //
3806 //
3807 //
3808 Double_t x[5],c[15];
3809 //
3810 x[0]=xyz[2][1];
3811 x[1]=xyz[2][2];
3812 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3813 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3814 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3815 //
3816 Double_t sy =0.1, sz =0.1;
3817 //
3818 Double_t sy1=0.2, sz1=0.2;
3819 Double_t sy2=0.2, sz2=0.2;
3820 Double_t sy3=0.2;
3821 //
3822 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;
3823 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;
3824 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;
3825 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;
3826 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;
3827 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;
3828 //
3829 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;
3830 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;
3831 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;
3832 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;
3833
3834
3835 c[0]=sy1;
3836 c[1]=0.; c[2]=sz1;
3837 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3838 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3839 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3840 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3841 c[13]=f30*sy1*f40+f32*sy2*f42;
3842 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3843
3844 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3845 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3846 seed->fLastPoint = row[2];
3847 seed->fFirstPoint = row[2];
3848 return seed;
3849}
3850
eea478d3 3851
3852AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
3853{
3854 //
3855 //
3856 //reseed using founded clusters
3857 //
3858 Double_t xyz[3][3];
4a12af72 3859 Int_t row[3]={0,0,0};
3860 Int_t sec[3]={0,0,0};
eea478d3 3861 //
3862 // forward direction
3863 if (forward){
3864 for (Int_t irow=r0;irow<160;irow++){
3865 if (track->GetClusterIndex(irow)>0){
3866 row[0] = irow;
3867 break;
3868 }
3869 }
3870 for (Int_t irow=160;irow>r0;irow--){
3871 if (track->GetClusterIndex(irow)>0){
3872 row[2] = irow;
3873 break;
3874 }
3875 }
3876 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3877 if (track->GetClusterIndex(irow)>0){
3878 row[1] = irow;
3879 break;
3880 }
3881 }
3882 //
3883 }
3884 if (!forward){
3885 for (Int_t irow=0;irow<r0;irow++){
3886 if (track->GetClusterIndex(irow)>0){
3887 row[0] = irow;
3888 break;
3889 }
3890 }
3891 for (Int_t irow=r0;irow>0;irow--){
3892 if (track->GetClusterIndex(irow)>0){
3893 row[2] = irow;
3894 break;
3895 }
3896 }
3897 for (Int_t irow=row[2]-15;irow>row[0];irow--){
3898 if (track->GetClusterIndex(irow)>0){
3899 row[1] = irow;
3900 break;
3901 }
3902 }
3903 }
3904 //
3905 if ((row[2]-row[0])<20) return 0;
3906 if (row[1]==0) return 0;
3907 //
3908 //
3909 //Get cluster and sector position
3910 for (Int_t ipoint=0;ipoint<3;ipoint++){
3911 Int_t clindex = track->GetClusterIndex2(row[ipoint]);
3912 AliTPCclusterMI * cl = GetClusterMI(clindex);
3913 if (cl==0) {
3914 //Error("Bug\n");
3915 // AliTPCclusterMI * cl = GetClusterMI(clindex);
3916 return 0;
3917 }
3918 sec[ipoint] = ((clindex&0xff000000)>>24)%18;
3919 xyz[ipoint][0] = GetXrow(row[ipoint]);
3920 AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);
3921 if (point&&ipoint<2){
3922 //
3923 xyz[ipoint][1] = point->GetY();
3924 xyz[ipoint][2] = point->GetZ();
3925 }
3926 else{
3927 xyz[ipoint][1] = cl->GetY();
3928 xyz[ipoint][2] = cl->GetZ();
3929 }
3930 }
3931 //
3932 //
3933 //
3934 //
3935 // Calculate seed state vector and covariance matrix
3936
3937 Double_t alpha, cs,sn, xx2,yy2;
3938 //
3939 alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
3940 cs = TMath::Cos(alpha);
3941 sn = TMath::Sin(alpha);
3942 xx2= xyz[1][0]*cs-xyz[1][1]*sn;
3943 yy2= xyz[1][0]*sn+xyz[1][1]*cs;
3944 xyz[1][0] = xx2;
3945 xyz[1][1] = yy2;
3946 //
3947 alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
3948 cs = TMath::Cos(alpha);
3949 sn = TMath::Sin(alpha);
3950 xx2= xyz[0][0]*cs-xyz[0][1]*sn;
3951 yy2= xyz[0][0]*sn+xyz[0][1]*cs;
3952 xyz[0][0] = xx2;
3953 xyz[0][1] = yy2;
3954 //
3955 //
3956 //
3957 Double_t x[5],c[15];
3958 //
3959 x[0]=xyz[2][1];
3960 x[1]=xyz[2][2];
3961 x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3962 x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
3963 x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
3964 //
3965 Double_t sy =0.1, sz =0.1;
3966 //
3967 Double_t sy1=0.2, sz1=0.2;
3968 Double_t sy2=0.2, sz2=0.2;
3969 Double_t sy3=0.2;
3970 //
3971 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;
3972 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;
3973 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;
3974 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;
3975 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;
3976 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;
3977 //
3978 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;
3979 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;
3980 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;
3981 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;
3982
3983
3984 c[0]=sy1;
3985 c[1]=0.; c[2]=sz1;
3986 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3987 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3988 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3989 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3990 c[13]=f30*sy1*f40+f32*sy2*f42;
3991 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3992
3993 // Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
3994 AliTPCseed *seed=new AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
3995 seed->fLastPoint = row[2];
3996 seed->fFirstPoint = row[2];
3997 for (Int_t i=row[0];i<row[2];i++){
3998 seed->fIndex[i] = track->fIndex[i];
3999 }
4000
4001 return seed;
4002}
4003
51ad6848 4004void AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
4005{
4006 //
4007 // find kinks
4008 //
4009 //
eea478d3 4010
51ad6848 4011 TObjArray *kinks= new TObjArray(10000);
81e97e0d 4012 // TObjArray *v0s= new TObjArray(10000);
51ad6848 4013 Int_t nentries = array->GetEntriesFast();
4014 AliHelix *helixes = new AliHelix[nentries];
4015 Int_t *sign = new Int_t[nentries];
4016 Int_t *nclusters = new Int_t[nentries];
4017 Float_t *alpha = new Float_t[nentries];
4018 AliESDkink * kink = new AliESDkink();
4019 Int_t * usage = new Int_t[nentries];
eea478d3 4020 Float_t *zm = new Float_t[nentries];
4021 Float_t *z0 = new Float_t[nentries];
4022 Float_t *fim = new Float_t[nentries];
4023 Float_t *shared = new Float_t[nentries];
4024 Bool_t *circular = new Bool_t[nentries];
81e97e0d 4025 Float_t *dca = new Float_t[nentries];
4026 //const AliESDVertex * primvertex = esd->GetVertex();
eea478d3 4027 //
4028 // nentries = array->GetEntriesFast();
4029 //
4030
51ad6848 4031 //
4032 //
4033 for (Int_t i=0;i<nentries;i++){
4034 sign[i]=0;
4035 usage[i]=0;
4036 AliTPCseed* track = (AliTPCseed*)array->At(i);
4037 if (!track) continue;
81e97e0d 4038 track->fCircular =0;
eea478d3 4039 shared[i] = kFALSE;
51ad6848 4040 track->UpdatePoints();
4041 if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
51ad6848 4042 }
eea478d3 4043 nclusters[i]=track->GetNumberOfClusters();
4044 alpha[i] = track->GetAlpha();
4045 new (&helixes[i]) AliHelix(*track);
4046 Double_t xyz[3];
4047 helixes[i].Evaluate(0,xyz);
4048 sign[i] = (track->GetC()>0) ? -1:1;
4049 Double_t x,y,z;
4050 x=160;
4051 if (track->GetProlongation(x,y,z)){
4052 zm[i] = z;
4053 fim[i] = alpha[i]+TMath::ATan2(y,x);
4054 }
4055 else{
4056 zm[i] = track->GetZ();
4057 fim[i] = alpha[i];
4058 }
4059 z0[i]=1000;
4060 circular[i]= kFALSE;
81e97e0d 4061 if (track->GetProlongation(0,y,z)) z0[i] = z;
4062 dca[i] = track->GetD(0,0);
51ad6848 4063 }
4064 //
4065 //
4066 TStopwatch timer;
4067 timer.Start();
4068 Int_t ncandidates =0;
4069 Int_t nall =0;
4070 Int_t ntracks=0;
4071 Double_t phase[2][2],radius[2];
eea478d3 4072
4073 //
4074 // Find circling track
81e97e0d 4075 TTreeSRedirector &cstream = *fDebugStreamer;
eea478d3 4076 //
4077 for (Int_t i0=0;i0<nentries;i0++){
4078 AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
4079 if (!track0) continue;
4080 if (track0->fN<40) continue;
4081 if (TMath::Abs(1./track0->fP4)>200) continue;
4082 for (Int_t i1=i0+1;i1<nentries;i1++){
4083 AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
4084 if (!track1) continue;
81e97e0d 4085 if (track1->fN<40) continue;
4086 if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
eea478d3 4087 if (track0->fBConstrain&&track1->fBConstrain) continue;
81e97e0d 4088 if (TMath::Abs(1./track1->fP4)>200) continue;
4089 if (track1->fP4*track0->fP4>0) continue;
4090 if (track1->fP3*track0->fP3>0) continue;
eea478d3 4091 if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
4092 if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
4093 if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
4094 //
81e97e0d 4095 Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
4096 if (mindcar<5) continue;
4097 Float_t mindcaz = TMath::Min(TMath::Abs(z0[i0]-GetZ()),TMath::Abs(z0[i1]-GetZ()));
4098 if (mindcaz<5) continue;
4099 if (mindcar+mindcaz<20) continue;
4100 //
4101 //
eea478d3 4102 Float_t xc0 = helixes[i0].GetHelix(6);
4103 Float_t yc0 = helixes[i0].GetHelix(7);
4104 Float_t r0 = helixes[i0].GetHelix(8);
4105 Float_t xc1 = helixes[i1].GetHelix(6);
4106 Float_t yc1 = helixes[i1].GetHelix(7);
4107 Float_t r1 = helixes[i1].GetHelix(8);
4108
4109 Float_t rmean = (r0+r1)*0.5;
4110 Float_t delta =TMath::Sqrt((xc1-xc0)*(xc1-xc0)+(yc1-yc0)*(yc1-yc0));
81e97e0d 4111 //if (delta>30) continue;
eea478d3 4112 if (delta>rmean*0.25) continue;
4113 if (TMath::Abs(r0-r1)/rmean>0.3) continue;
4114 //
4115 Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
4116 if (npoints==0) continue;
4117 helixes[i0].GetClosestPhases(helixes[i1], phase);
4118 //
4119 Double_t xyz0[3];
4120 Double_t xyz1[3];
4121 Double_t hangles[3];
4122 helixes[i0].Evaluate(phase[0][0],xyz0);
4123 helixes[i1].Evaluate(phase[0][1],xyz1);
4124
4125 helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
4126 Double_t deltah[2],deltabest;
4127 if (hangles[2]<2.8) continue;
4128 /*
4129 cstream<<"C"<<track0->fLab<<track1->fLab<<
4130 track0->fP3<<track1->fP3<<
4131 track0->fP4<<track1->fP4<<
4132 delta<<rmean<<npoints<<
4133 hangles[0]<<hangles[2]<<
4134 xyz0[2]<<xyz1[2]<<radius[0]<<"\n";
4135 */
4136 if (npoints>0){
4137 Int_t ibest=0;
81e97e0d 4138 helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
eea478d3 4139 if (npoints==2){
81e97e0d 4140 helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
eea478d3 4141 if (deltah[1]<deltah[0]) ibest=1;
4142 }
4143 deltabest = TMath::Sqrt(deltah[ibest]);
4144 helixes[i0].Evaluate(phase[ibest][0],xyz0);
4145 helixes[i1].Evaluate(phase[ibest][1],xyz1);
4146 helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
81e97e0d 4147 Double_t radiusbest = TMath::Sqrt(radius[ibest]);
eea478d3 4148 //
81e97e0d 4149 if (deltabest>6) continue;
4150 if (mindcar+mindcaz<40 && (hangles[2]<3.12||deltabest>3)) continue;
eea478d3 4151 Bool_t sign =kFALSE;
81e97e0d 4152 if (hangles[2]>3.06) sign =kTRUE;
4153 //
eea478d3 4154 if (sign){
4155 circular[i0] = kTRUE;
81e97e0d 4156 circular[i1] = kTRUE;
4157 if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
4158 track0->fCircular += 1;
4159 track1->fCircular += 2;
4160 }
4161 else{
4162 track1->fCircular += 1;
4163 track0->fCircular += 2;
4164 }
4165 }
34acb742 4166 if (sign&&AliTPCReconstructor::StreamLevel()>1){
4167 //debug stream
81e97e0d 4168 cstream<<"Curling"<<
4169 "lab0="<<track0->fLab<<
4170 "lab1="<<track1->fLab<<
4171 "Tr0.="<<track0<<
4172 "Tr1.="<<track1<<
4173 "dca0="<<dca[i0]<<
4174 "dca1="<<dca[i1]<<
4175 "mindcar="<<mindcar<<
4176 "mindcaz="<<mindcaz<<
4177 "delta="<<delta<<
4178 "rmean="<<rmean<<
4179 "npoints="<<npoints<<
4180 "hangles0="<<hangles[0]<<
4181 "hangles2="<<hangles[2]<<
4182 "xyz0="<<xyz0[2]<<
4183 "xyzz1="<<xyz1[2]<<
4184 "z0="<<z0[i0]<<
4185 "z1="<<z0[i1]<<
4186 "radius="<<radiusbest<<
4187 "deltabest="<<deltabest<<
4188 "phase0="<<phase[ibest][0]<<
4189 "phase1="<<phase[ibest][1]<<
4190 "\n";
eea478d3 4191 }
4192 }
4193 }
4194 }
4195 //
81e97e0d 4196 // Finf kinks loop
4197 //
51ad6848 4198 //
4199 for (Int_t i =0;i<nentries;i++){
4200 if (sign[i]==0) continue;
4201 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4202 ntracks++;
4203 //
4204 Double_t cradius0 = 40*40;
4205 Double_t cradius1 = 270*270;
4206 Double_t cdist1=8.;
4207 Double_t cdist2=8.;
4208 Double_t cdist3=0.55;
4209 for (Int_t j =i+1;j<nentries;j++){
4210 nall++;
4211 if (sign[j]*sign[i]<1) continue;
4212 if ( (nclusters[i]+nclusters[j])>200) continue;
4213 if ( (nclusters[i]+nclusters[j])<80) continue;
4214 if ( TMath::Abs(zm[i]-zm[j])>60.) continue;
4215 if ( TMath::Abs(fim[i]-fim[j])>0.6 && TMath::Abs(fim[i]-fim[j])<5.7 ) continue;
4216 //AliTPCseed * track1 = (AliTPCseed*)array->At(j); Double_t phase[2][2],radius[2];
4217 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4218 if (npoints<1) continue;
4219 // cuts on radius
4220 if (npoints==1){
4221 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4222 }
4223 else{
4224 if ( (radius[0]<cradius0||radius[0]>cradius1) && (radius[1]<cradius0||radius[1]>cradius1) ) continue;
4225 }
4226 //
4227 Double_t delta1=10000,delta2=10000;
4228 // cuts on the intersection radius
4229 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4230 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4231 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4232 if (npoints==2){
4233 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4234 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4235 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4236 }
4237 //
4238 Double_t distance1 = TMath::Min(delta1,delta2);
4239 if (distance1>cdist1) continue; // cut on DCA linear approximation
4240 //
4241 npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,20);
4242 helixes[i].ParabolicDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta1);
4243 if (radius[0]<20&&delta1<1) continue; //intersection at vertex
4244 if (radius[0]<10&&delta1<3) continue; //intersection at vertex
4245 //
4246 if (npoints==2){
4247 helixes[i].ParabolicDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta2);
4248 if (radius[1]<20&&delta2<1) continue; //intersection at vertex
4249 if (radius[1]<10&&delta2<3) continue; //intersection at vertex
4250 }
4251 distance1 = TMath::Min(delta1,delta2);
4252 Float_t rkink =0;
4253 if (delta1<delta2){
4254 rkink = TMath::Sqrt(radius[0]);
4255 }
4256 else{
4257 rkink = TMath::Sqrt(radius[1]);
4258 }
4259 if (distance1>cdist2) continue;
4260 //
4261 //
4262 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4263 //
4264 //
4265 Int_t row0 = GetRowNumber(rkink);
4266 if (row0<10) continue;
4267 if (row0>150) continue;
4268 //
4269 //
4270 Float_t dens00=-1,dens01=-1;
4271 Float_t dens10=-1,dens11=-1;
4272 //
4273 Int_t found,foundable,shared;
4274 track0->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4275 if (foundable>5) dens00 = Float_t(found)/Float_t(foundable);
4276 track0->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4277 if (foundable>5) dens01 = Float_t(found)/Float_t(foundable);
4278 //
4279 track1->GetClusterStatistic(0,row0-5, found, foundable,shared,kFALSE);
4280 if (foundable>10) dens10 = Float_t(found)/Float_t(foundable);
4281 track1->GetClusterStatistic(row0+5,155, found, foundable,shared,kFALSE);
4282 if (foundable>10) dens11 = Float_t(found)/Float_t(foundable);
eea478d3 4283 //
51ad6848 4284 if (dens00<dens10 && dens01<dens11) continue;
4285 if (dens00>dens10 && dens01>dens11) continue;
4286 if (TMath::Max(dens00,dens10)<0.1) continue;
4287 if (TMath::Max(dens01,dens11)<0.3) continue;
4288 //
4289 if (TMath::Min(dens00,dens10)>0.6) continue;
4290 if (TMath::Min(dens01,dens11)>0.6) continue;
4291
4292 //
4293 AliTPCseed * ktrack0, *ktrack1;
4294 if (dens00>dens10){
4295 ktrack0 = track0;
4296 ktrack1 = track1;
4297 }
4298 else{
4299 ktrack0 = track1;
4300 ktrack1 = track0;
4301 }
4302 if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
4303 AliExternalTrackParam paramm(*ktrack0);
4304 AliExternalTrackParam paramd(*ktrack1);
c9ec41e8 4305 if (row0>60&&ktrack1->GetReference().GetX()>90.) new (&paramd) AliExternalTrackParam(ktrack1->GetReference());
51ad6848 4306 //
4307 //
4308 kink->SetMother(paramm);
4309 kink->SetDaughter(paramd);
4310 kink->Update();
4311
eea478d3 4312 Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
51ad6848 4313 Int_t index[4];
4314 fParam->Transform0to1(x,index);
4315 fParam->Transform1to2(x,index);
4316 row0 = GetRowNumber(x[0]);
4317
eea478d3 4318 if (kink->GetR()<100) continue;
4319 if (kink->GetR()>240) continue;
4320 if (kink->GetPosition()[2]/kink->GetR()>AliTPCReconstructor::GetCtgRange()) continue; //out of fiducial volume
4321 if (kink->GetDistance()>cdist3) continue;
4322 Float_t dird = kink->GetDaughterP()[0]*kink->GetPosition()[0]+kink->GetDaughterP()[1]*kink->GetPosition()[1]; // rough direction estimate
51ad6848 4323 if (dird<0) continue;
4324
eea478d3 4325 Float_t dirm = kink->GetMotherP()[0]*kink->GetPosition()[0]+kink->GetMotherP()[1]*kink->GetPosition()[1]; // rough direction estimate
51ad6848 4326 if (dirm<0) continue;
eea478d3 4327 Float_t mpt = TMath::Sqrt(kink->GetMotherP()[0]*kink->GetMotherP()[0]+kink->GetMotherP()[1]*kink->GetMotherP()[1]);
51ad6848 4328 if (mpt<0.2) continue;
4329
eea478d3 4330 if (mpt<1){
4331 //for high momenta momentum not defined well in first iteration
4332 Double_t qt = TMath::Sin(kink->GetAngle(2))*ktrack1->P();
4333 if (qt>0.35) continue;
4334 }
51ad6848 4335
eea478d3 4336 kink->SetLabel(CookLabel(ktrack0,0.4,0,row0),0);
4337 kink->SetLabel(CookLabel(ktrack1,0.4,row0,160),1);
51ad6848 4338 if (dens00>dens10){
eea478d3 4339 kink->SetTPCDensity(dens00,0,0);
4340 kink->SetTPCDensity(dens01,0,1);
4341 kink->SetTPCDensity(dens10,1,0);
4342 kink->SetTPCDensity(dens11,1,1);
4343 kink->SetIndex(i,0);
4344 kink->SetIndex(j,1);
51ad6848 4345 }
4346 else{
eea478d3 4347 kink->SetTPCDensity(dens10,0,0);
4348 kink->SetTPCDensity(dens11,0,1);
4349 kink->SetTPCDensity(dens00,1,0);
4350 kink->SetTPCDensity(dens01,1,1);
4351 kink->SetIndex(j,0);
4352 kink->SetIndex(i,1);
51ad6848 4353 }
51ad6848 4354
eea478d3 4355 if (mpt<1||kink->GetAngle(2)>0.1){
4356 // angle and densities not defined yet
4357 if (kink->GetTPCDensityFactor()<0.8) continue;
4358 if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
4359 if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
4360 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
4361 if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
4362
4363 Float_t criticalangle = track0->fC22+track0->fC33;
4364 criticalangle+= track1->fC22+track1->fC33;
4365 criticalangle= 3*TMath::Sqrt(criticalangle);
4366 if (criticalangle>0.02) criticalangle=0.02;
4367 if (kink->GetAngle(2)<criticalangle) continue;
4368 }
51ad6848 4369 //
eea478d3 4370 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2))); // overlap region defined
51ad6848 4371 Float_t shapesum =0;
4372 Float_t sum = 0;
4373 for ( Int_t row = row0-drow; row<row0+drow;row++){
4374 if (row<0) continue;
4375 if (row>155) continue;
4376 if (ktrack0->fClusterPointer[row]){
4377 AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
4378 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4379 sum++;
4380 }
4381 if (ktrack1->fClusterPointer[row]){
4382 AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
4383 shapesum+=point->GetSigmaY()+point->GetSigmaZ();
4384 sum++;
4385 }
4386 }
4387 if (sum<4){
eea478d3 4388 kink->SetShapeFactor(-1.);
51ad6848 4389 }
4390 else{
eea478d3 4391 kink->SetShapeFactor(shapesum/sum);
4392 }
51ad6848 4393 // esd->AddKink(kink);
4394 kinks->AddLast(kink);
4395 kink = new AliESDkink;
4396 ncandidates++;
4397 }
4398 }
eea478d3 4399 //
4400 // sort the kinks according quality - and refit them towards vertex
4401 //
4402 Int_t nkinks = kinks->GetEntriesFast();
4403 Float_t *quality = new Float_t[nkinks];
4404 Int_t *indexes = new Int_t[nkinks];
4405 AliTPCseed *mothers = new AliTPCseed[nkinks];
4406 AliTPCseed *daughters = new AliTPCseed[nkinks];
4407 //
4408 //
51ad6848 4409 for (Int_t i=0;i<nkinks;i++){
4410 quality[i] =100000;
4411 AliESDkink *kink = (AliESDkink*)kinks->At(i);
eea478d3 4412 //
4413 // refit kinks towards vertex
4414 //
4415 Int_t index0 = kink->GetIndex(0);
4416 Int_t index1 = kink->GetIndex(1);
4417 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4418 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
4419 //
4420 Int_t sumn=ktrack0->fN+ktrack1->fN;
4421 //
4422 // Refit Kink under if too small angle
4423 //
4424 if (kink->GetAngle(2)<0.05){
4425 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4426 Int_t row0 = kink->GetTPCRow0();
4427 Int_t drow = Int_t(2.+0.5/(0.05+kink->GetAngle(2)));
4428 //
4429 //
4430 Int_t last = row0-drow;
4431 if (last<40) last=40;
4432 if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
4433 AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
4434 //
4435 //
4436 Int_t first = row0+drow;
4437 if (first>130) first=130;
4438 if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
4439 AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
4440 //
4441 if (seed0 && seed1){
4442 kink->SetStatus(1,8);
4443 if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
4444 row0 = GetRowNumber(kink->GetR());
4445 sumn = seed0->fN+seed1->fN;
4446 new (&mothers[i]) AliTPCseed(*seed0);
4447 new (&daughters[i]) AliTPCseed(*seed1);
4448 }
4449 else{
4450 delete kinks->RemoveAt(i);
4451 if (seed0) delete seed0;
4452 if (seed1) delete seed1;
4453 continue;
4454 }
4455 if (kink->GetDistance()>0.5 || kink->GetR()<110 || kink->GetR()>240) {
4456 delete kinks->RemoveAt(i);
4457 if (seed0) delete seed0;
4458 if (seed1) delete seed1;
4459 continue;
4460 }
4461 //
4462 delete seed0;
4463 delete seed1;
4464 }
4465 //
4466 if (kink) quality[i] = 160*((0.1+kink->GetDistance())*(2.-kink->GetTPCDensityFactor()))/(sumn+40.); //the longest -clossest will win
51ad6848 4467 }
4468 TMath::Sort(nkinks,quality,indexes,kFALSE);
eea478d3 4469 //
4470 //remove double find kinks
4471 //
4472 for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
4473 AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
4474 if (!kink0) continue;
4475 //
4476 for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
4477 if (!kink0) continue;
4478 AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
4479 if (!kink1) continue;
4480 // if not close kink continue
4481 if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
4482 if (TMath::Abs(kink1->GetPosition()[1]-kink0->GetPosition()[1])>10) continue;
4483 if (TMath::Abs(kink1->GetPosition()[0]-kink0->GetPosition()[0])>10) continue;
4484 //
4485 AliTPCseed &mother0 = mothers[indexes[ikink0]];
4486 AliTPCseed &daughter0 = daughters[indexes[ikink0]];
4487 AliTPCseed &mother1 = mothers[indexes[ikink1]];
4488 AliTPCseed &daughter1 = daughters[indexes[ikink1]];
4489 Int_t row0 = (kink0->GetTPCRow0()+kink1->GetTPCRow0())/2;
4490 //
4491 Int_t same = 0;
4492 Int_t both = 0;
4493 Int_t samem = 0;
4494 Int_t bothm = 0;
4495 Int_t samed = 0;
4496 Int_t bothd = 0;
4497 //
4498 for (Int_t i=0;i<row0;i++){
4499 if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
4500 both++;
4501 bothm++;
4502 if (mother0.fIndex[i]==mother1.fIndex[i]){
4503 same++;
4504 samem++;
4505 }
4506 }
4507 }
4508
4509 for (Int_t i=row0;i<158;i++){
4510 if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
4511 both++;
4512 bothd++;
4513 if (mother0.fIndex[i]==mother1.fIndex[i]){
4514 same++;
4515 samed++;
4516 }
4517 }
4518 }
4519 Float_t ratio = Float_t(same+1)/Float_t(both+1);
4520 Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
4521 Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
4522 if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
4523 Int_t sum0 = mother0.fN+daughter0.fN;
4524 Int_t sum1 = mother1.fN+daughter1.fN;
4525 if (sum1>sum0){
4526 shared[kink0->GetIndex(0)]= kTRUE;
4527 shared[kink0->GetIndex(1)]= kTRUE;
4528 delete kinks->RemoveAt(indexes[ikink0]);
4529 }
4530 else{
4531 shared[kink1->GetIndex(0)]= kTRUE;
4532 shared[kink1->GetIndex(1)]= kTRUE;
4533 delete kinks->RemoveAt(indexes[ikink1]);
4534 }
4535 }
4536 }
4537 }
4538
4539
51ad6848 4540 for (Int_t i=0;i<nkinks;i++){
4541 AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
eea478d3 4542 if (!kink) continue;
4543 kink->SetTPCRow0(GetRowNumber(kink->GetR()));
4544 Int_t index0 = kink->GetIndex(0);
4545 Int_t index1 = kink->GetIndex(1);
4546 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.2) continue;
4547 kink->SetMultiple(usage[index0],0);
4548 kink->SetMultiple(usage[index1],1);
4549 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>2) continue;
4550 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && quality[indexes[i]]>0.2) continue;
4551 if (kink->GetMultiple()[0]+kink->GetMultiple()[1]>0 && kink->GetDistance()>0.2) continue;
4552 if (circular[index0]||circular[index1]&&kink->GetDistance()>0.1) continue;
51ad6848 4553
51ad6848 4554 AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
4555 AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
eea478d3 4556 if (!ktrack0 || !ktrack1) continue;
4557 Int_t index = esd->AddKink(kink);
4558 //
4559 //
4560 if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) { //best kink
4561 if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
4562 new (ktrack0) AliTPCseed(mothers[indexes[i]]);
4563 new (ktrack1) AliTPCseed(daughters[indexes[i]]);
4564 }
4565 }
4566 //
51ad6848 4567 ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
4568 ktrack1->fKinkIndexes[usage[index1]] = (index+1);
4569 usage[index0]++;
4570 usage[index1]++;
4571 }
eea478d3 4572 //
4573 // Remove tracks corresponding to shared kink's
4574 //
4575 for (Int_t i=0;i<nentries;i++){
4576 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4577 if (!track0) continue;
4578 if (track0->fKinkIndexes[0]!=0) continue;
4579 if (shared[i]) delete array->RemoveAt(i);
4580 }
51ad6848 4581
eea478d3 4582 //
4583 //
4584 RemoveUsed2(array,0.5,0.4,30);
4585 UnsignClusters();
81e97e0d 4586 for (Int_t i=0;i<nentries;i++){
4587 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4588 if (!track0) continue;
4589 track0->CookdEdx(0.02,0.6);
4590 track0->CookPID();
4591 }
eea478d3 4592 //
4593 for (Int_t i=0;i<nentries;i++){
4594 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4595 if (!track0) continue;
4596 if (track0->Pt()<1.4) continue;
4597 //remove double high momenta tracks - overlapped with kink candidates
4598 Int_t shared=0;
4599 Int_t all =0;
4600 for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
4601 if (track0->fClusterPointer[icl]!=0){
4602 all++;
4603 if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
4604 }
4605 }
4606 if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
4607 delete array->RemoveAt(i);
f99dc368 4608 continue;
eea478d3 4609 }
4610 //
4611 if (track0->fKinkIndexes[0]!=0) continue;
4612 if (track0->GetNumberOfClusters()<80) continue;
4a12af72 4613
4614 AliTPCseed *pmother = new AliTPCseed();
4615 AliTPCseed *pdaughter = new AliTPCseed();
4616 AliESDkink *pkink = new AliESDkink;
4617
4618 AliTPCseed & mother = *pmother;
4619 AliTPCseed & daughter = *pdaughter;
4620 AliESDkink & kink = *pkink;
eea478d3 4621 if (CheckKinkPoint(track0,mother,daughter, kink)){
4a12af72 4622 if (mother.fN<30||daughter.fN<20) {
4623 delete pmother;
4624 delete pdaughter;
4625 delete pkink;
4626 continue; //too short tracks
4627 }
4628 if (mother.Pt()<1.4) {
4629 delete pmother;
4630 delete pdaughter;
4631 delete pkink;
4632 continue;
4633 }
eea478d3 4634 Int_t row0= kink.GetTPCRow0();
4635 if (kink.GetDistance()>0.5 || kink.GetR()<110. || kink.GetR()>240.) {
4a12af72 4636 delete pmother;
4637 delete pdaughter;
4638 delete pkink;
eea478d3 4639 continue;
4640 }
4641 //
4642 Int_t index = esd->AddKink(&kink);
4643 mother.fKinkIndexes[0] = -(index+1);
4644 daughter.fKinkIndexes[0] = index+1;
4645 if (mother.fN>50) {
4646 delete array->RemoveAt(i);
4647 array->AddAt(new AliTPCseed(mother),i);
4648 }
4649 else{
4650 array->AddLast(new AliTPCseed(mother));
4651 }
4652 array->AddLast(new AliTPCseed(daughter));
4653 for (Int_t icl=0;icl<row0;icl++) {
4654 if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
4655 }
4656 //
4657 for (Int_t icl=row0;icl<158;icl++) {
4658 if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
4659 }
4660 //
4661 }
4a12af72 4662 delete pmother;
4663 delete pdaughter;
4664 delete pkink;
eea478d3 4665 }
4666
4667 delete [] daughters;
4668 delete [] mothers;
4669 //
4670 //
81e97e0d 4671 delete [] dca;
eea478d3 4672 delete []circular;
4673 delete []shared;
4674 delete []quality;
4675 delete []indexes;
4676 //
4677 delete kink;
4678 delete[]fim;
51ad6848 4679 delete[] zm;
eea478d3 4680 delete[] z0;
51ad6848 4681 delete [] usage;
4682 delete[] alpha;
4683 delete[] nclusters;
4684 delete[] sign;
4685 delete[] helixes;
4686 kinks->Delete();
4687 delete kinks;
4688
eea478d3 4689 printf("Ncandidates=\t%d\t%d\t%d\t%d\n",esd->GetNumberOfKinks(),ncandidates,ntracks,nall);
51ad6848 4690 timer.Print();
4691}
4692
81e97e0d 4693void AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
4694{
4695 //
4696 // find V0s
4697 //
4698 //
4699 TObjArray *tpcv0s = new TObjArray(100000);
4700 Int_t nentries = array->GetEntriesFast();
4701 AliHelix *helixes = new AliHelix[nentries];
4702 Int_t *sign = new Int_t[nentries];
4703 Float_t *alpha = new Float_t[nentries];
4704 Float_t *z0 = new Float_t[nentries];
4705 Float_t *dca = new Float_t[nentries];
4706 Float_t *sdcar = new Float_t[nentries];
4707 Float_t *cdcar = new Float_t[nentries];
4708 Float_t *pulldcar = new Float_t[nentries];
4709 Float_t *pulldcaz = new Float_t[nentries];
4710 Float_t *pulldca = new Float_t[nentries];
4711 Bool_t *isPrim = new Bool_t[nentries];
4712 const AliESDVertex * primvertex = esd->GetVertex();
4713 Double_t zvertex = primvertex->GetZv();
4714 //
4715 // nentries = array->GetEntriesFast();
4716 //
4717 for (Int_t i=0;i<nentries;i++){
4718 sign[i]=0;
4719 isPrim[i]=0;
4720 AliTPCseed* track = (AliTPCseed*)array->At(i);
4721 if (!track) continue;
4722 track->GetV0Indexes()[0] = 0; //rest v0 indexes
4723 track->GetV0Indexes()[1] = 0; //rest v0 indexes
4724 track->GetV0Indexes()[2] = 0; //rest v0 indexes
4725 //
4726 alpha[i] = track->GetAlpha();
4727 new (&helixes[i]) AliHelix(*track);
4728 Double_t xyz[3];
4729 helixes[i].Evaluate(0,xyz);
4730 sign[i] = (track->GetC()>0) ? -1:1;
4731 Double_t x,y,z;
4732 x=160;
4733 z0[i]=1000;
4734 if (track->GetProlongation(0,y,z)) z0[i] = z;
4735 dca[i] = track->GetD(0,0);
4736 //
4737 // dca error parrameterezation + pulls
4738 //
4739 sdcar[i] = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
4740 if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
4741 cdcar[i] = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
4742 pulldcar[i] = (dca[i]-cdcar[i])/sdcar[i];
4743 pulldcaz[i] = (z0[i]-zvertex)/sdcar[i];
4744 pulldca[i] = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
4745 if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
4746 if (pulldca[i]<3.) isPrim[i]=kTRUE; //pion, muon and Kaon 3 sigma cut
4747 }
4748 if (track->fTPCr[4]>0.5) {
4749 if (pulldca[i]<0.5) isPrim[i]=kTRUE; //proton 0.5 sigma cut
4750 }
4751 if (track->fTPCr[0]>0.4) {
4752 isPrim[i]=kFALSE; //electron no sigma cut
4753 }
4754 }
4755 //
4756 //
4757 TStopwatch timer;
4758 timer.Start();
4759 Int_t ncandidates =0;
4760 Int_t nall =0;
4761 Int_t ntracks=0;
4762 Double_t phase[2][2],radius[2];
4763 //
4764 // Finf V0s loop
4765 //
4766 //
4767 // //
4768 TTreeSRedirector &cstream = *fDebugStreamer;
4769 Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
4770 AliESDV0MI vertex;
4771 Double_t cradius0 = 10*10;
4772 Double_t cradius1 = 200*200;
4773 Double_t cdist1=3.;
4774 Double_t cdist2=4.;
4775 Double_t cpointAngle = 0.95;
4776 //
4777 Double_t delta[2]={10000,10000};
4778 for (Int_t i =0;i<nentries;i++){
4779 if (sign[i]==0) continue;
4780 AliTPCseed * track0 = (AliTPCseed*)array->At(i);
4781 if (!track0) continue;
34acb742 4782 if (AliTPCReconstructor::StreamLevel()>0){
4783 cstream<<"Tracks"<<
4784 "Tr0.="<<track0<<
4785 "dca="<<dca[i]<<
4786 "z0="<<z0[i]<<
4787 "zvertex="<<zvertex<<
4788 "sdcar0="<<sdcar[i]<<
4789 "cdcar0="<<cdcar[i]<<
4790 "pulldcar0="<<pulldcar[i]<<
4791 "pulldcaz0="<<pulldcaz[i]<<
4792 "pulldca0="<<pulldca[i]<<
4793 "isPrim="<<isPrim[i]<<
4794 "\n";
4795 }
81e97e0d 4796 //
4797 if (track0->fP4<0) continue;
4798 if (track0->GetKinkIndex(0)>0||isPrim[i]) continue; //daughter kink
4799 //
4800 if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
4801 ntracks++;
4802 // debug output
4803
4804
4805 for (Int_t j =0;j<nentries;j++){
4806 AliTPCseed * track1 = (AliTPCseed*)array->At(j);
4807 if (!track1) continue;
4808 if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
4809 if (sign[j]*sign[i]>0) continue;
4810 if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
4811 if (track0->fCircular+track1->fCircular>1) continue; //circling -returning track
4812 nall++;
4813 //
4814 // DCA to prim vertex cut
4815 //
4816 //
4817 delta[0]=10000;
4818 delta[1]=10000;
4819
4820 Int_t npoints = helixes[i].GetRPHIintersections(helixes[j], phase, radius,cdist2);
4821 if (npoints<1) continue;
4822 Int_t iclosest=0;
4823 // cuts on radius
4824 if (npoints==1){
4825 if (radius[0]<cradius0||radius[0]>cradius1) continue;
4826 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4827 if (delta[0]>cdist1) continue;
4828 }
4829 else{
4830 if (TMath::Max(radius[0],radius[1])<cradius0|| TMath::Min(radius[0],radius[1])>cradius1) continue;
4831 helixes[i].LinearDCA(helixes[j],phase[0][0],phase[0][1],radius[0],delta[0]);
4832 helixes[i].LinearDCA(helixes[j],phase[1][0],phase[1][1],radius[1],delta[1]);
4833 if (delta[1]<delta[0]) iclosest=1;
4834 if (delta[iclosest]>cdist1) continue;
4835 }
4836 helixes[i].ParabolicDCA(helixes[j],phase[iclosest][0],phase[iclosest][1],radius[iclosest],delta[iclosest]);
4837 if (radius[iclosest]<cradius0 || radius[iclosest]>cradius1 || delta[iclosest]>cdist1) continue;
4838 //
4839 Double_t pointAngle = helixes[i].GetPointAngle(helixes[j],phase[iclosest],fprimvertex);
4840 if (pointAngle<cpointAngle) continue;
4841 //
4842 Bool_t isGamma = kFALSE;
4843 vertex.SetP(*track0); //track0 - plus
4844 vertex.SetM(*track1); //track1 - minus
4845 vertex.Update(fprimvertex);
4846 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE; // gamma conversion candidate
4847 Double_t pointAngle2 = vertex.GetPointAngle();
4848 //continue;
4849 if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
4850 if (vertex.GetDist2()>2&&(!isGamma)) continue; // point angle cut
4851 Float_t sigmae = 0.15*0.15;
4852 if (vertex.GetRr()<80)
4853 sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
4854 sigmae+= TMath::Sqrt(sigmae);
4855 if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue;
4856 Float_t densb0=0,densb1=0,densa0=0,densa1=0;
4857 Int_t row0 = GetRowNumber(vertex.GetRr());
4858 if (row0>15){
4859 if (vertex.GetDist2()>0.2) continue;
4860 densb0 = track0->Density2(0,row0-5);
4861 densb1 = track1->Density2(0,row0-5);
4862 if (densb0>0.3|| densb1>0.3) continue; //clusters before vertex
4863 densa0 = track0->Density2(row0+5,row0+40);
4864 densa1 = track1->Density2(row0+5,row0+40);
4865 if ((densa0<0.4|| densa1<0.4)&&(!isGamma)) continue; //missing clusters after vertex
4866 }
4867 else{
4868 densa0 = track0->Density2(0,40); //cluster density
4869 densa1 = track1->Density2(0,40); //cluster density
4870 if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
4871 }
4872 vertex.SetLab(0,track0->GetLabel());
4873 vertex.SetLab(1,track1->GetLabel());
4874 vertex.SetChi2After((densa0+densa1)*0.5);
4875 vertex.SetChi2Before((densb0+densb1)*0.5);
4876 vertex.SetIndex(0,i);
4877 vertex.SetIndex(1,j);
4878 vertex.SetStatus(1); // TPC v0 candidate
4879 vertex.SetRp(track0->fTPCr);
4880 vertex.SetRm(track1->fTPCr);
4881 tpcv0s->AddLast(new AliESDV0MI(vertex));
4882 ncandidates++;
4883 {
4884 Int_t eventNr = esd->GetEventNumber();
4885 Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);
4886 Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);
34acb742 4887 if (AliTPCReconstructor::StreamLevel()>0)
4888 cstream<<"V0"<<
81e97e0d 4889 "Event="<<eventNr<<
4890 "vertex.="<<&vertex<<
4891 "Tr0.="<<track0<<
4892 "lab0="<<track0->fLab<<
4893 "Helix0.="<<&helixes[i]<<
4894 "Tr1.="<<track1<<
4895 "lab1="<<track1->fLab<<
4896 "Helix1.="<<&helixes[j]<<
4897 "pointAngle="<<pointAngle<<
4898 "pointAngle2="<<pointAngle2<<
4899 "dca0="<<dca[i]<<
4900 "dca1="<<dca[j]<<
4901 "z0="<<z0[i]<<
4902 "z1="<<z0[j]<<
4903 "zvertex="<<zvertex<<
4904 "circular0="<<track0->fCircular<<
4905 "circular1="<<track1->fCircular<<
4906 "npoints="<<npoints<<
4907 "radius0="<<radius[0]<<
4908 "delta0="<<delta[0]<<
4909 "radius1="<<radius[1]<<
4910 "delta1="<<delta[1]<<
4911 "radiusm="<<radiusm<<
4912 "deltam="<<deltam<<
4913 "sdcar0="<<sdcar[i]<<
4914 "sdcar1="<<sdcar[j]<<
4915 "cdcar0="<<cdcar[i]<<
4916 "cdcar1="<<cdcar[j]<<
4917 "pulldcar0="<<pulldcar[i]<<
4918 "pulldcar1="<<pulldcar[j]<<
4919 "pulldcaz0="<<pulldcaz[i]<<
4920 "pulldcaz1="<<pulldcaz[j]<<
4921 "pulldca0="<<pulldca[i]<<
4922 "pulldca1="<<pulldca[j]<<
4923 "densb0="<<densb0<<
4924 "densb1="<<densb1<<
4925 "densa0="<<densa0<<
4926 "densa1="<<densa1<<
4927 "sigmae="<<sigmae<<
4928 "\n";
4929 }
4930 }
4931 }
4932 Float_t *quality = new Float_t[ncandidates];
4933 Int_t *indexes = new Int_t[ncandidates];
4934 Int_t naccepted =0;
4935 for (Int_t i=0;i<ncandidates;i++){
4936 quality[i] = 0;
4937 AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
4938 quality[i] = 1./(1.00001-v0->GetPointAngle()); //base point angle
4939 // quality[i] /= (0.5+v0->GetDist2());
4940 // quality[i] *= v0->GetChi2After(); //density factor
4941 Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) ); //pull
4942 Int_t index0 = v0->GetIndex(0);
4943 Int_t index1 = v0->GetIndex(1);
4944 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4945 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4946 if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000; // gamma conversion candidate
4947 if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10; // lambda candidate candidate
4948 }
4949
4950 TMath::Sort(ncandidates,quality,indexes,kTRUE);
4951 //
4952 //
4953 for (Int_t i=0;i<ncandidates;i++){
4954 AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
4955 if (!v0) continue;
4956 Int_t index0 = v0->GetIndex(0);
4957 Int_t index1 = v0->GetIndex(1);
4958 AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
4959 AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
4960 if (!track0||!track1) {
4961 printf("Bug\n");
4962 continue;
4963 }
4964 Bool_t accept =kTRUE; //default accept
4965 Int_t *v0indexes0 = track0->GetV0Indexes();
4966 Int_t *v0indexes1 = track1->GetV0Indexes();
4967 //
4968 Int_t order0 = (v0indexes0[0]!=0) ? 1:0;
4969 Int_t order1 = (v0indexes1[0]!=0) ? 1:0;
4970 if (v0indexes0[1]!=0) order0 =2;
4971 if (v0indexes1[1]!=0) order1 =2;
4972 //
4973 if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
4974 if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
4975 //
4976 AliESDV0MI * v02 = v0;
4977 if (accept){
4978 v0->SetOrder(0,order0);
4979 v0->SetOrder(1,order1);
4980 v0->SetOrder(1,order0+order1);
4981 Int_t index = esd->AddV0MI(v0);
4982 v02 = esd->GetV0MI(index);
4983 v0indexes0[order0]=index;
4984 v0indexes1[order1]=index;
4985 naccepted++;
4986 }
4987 {
4988 Int_t eventNr = esd->GetEventNumber();
34acb742 4989 if (AliTPCReconstructor::StreamLevel()>0)
4990 cstream<<"V02"<<
81e97e0d 4991 "Event="<<eventNr<<
4992 "vertex.="<<v0<<
4993 "vertex2.="<<v02<<
4994 "Tr0.="<<track0<<
4995 "lab0="<<track0->fLab<<
4996 "Tr1.="<<track1<<
4997 "lab1="<<track1->fLab<<
4998 "dca0="<<dca[index0]<<
4999 "dca1="<<dca[index1]<<
5000 "order0="<<order0<<
5001 "order1="<<order1<<
5002 "accept="<<accept<<
5003 "quality="<<quality[i]<<
5004 "pulldca0="<<pulldca[index0]<<
5005 "pulldca1="<<pulldca[index1]<<
5006 "index="<<i<<
5007 "\n";
5008 }
5009 }
5010
5011
5012 //
5013 //
5014 delete []quality;
5015 delete []indexes;
5016//
5017 delete [] isPrim;
5018 delete [] pulldca;
5019 delete [] pulldcaz;
5020 delete [] pulldcar;
5021 delete [] cdcar;
5022 delete [] sdcar;
5023 delete [] dca;
5024 //
5025 delete[] z0;
5026 delete[] alpha;
5027 delete[] sign;
5028 delete[] helixes;
5029 printf("TPC V0 finder : naccepted\t%d\tncandidates\t%d\tntracks\t%d\tnall\t%d\n",naccepted,ncandidates,ntracks,nall);
5030 timer.Print();
5031}
5032
eea478d3 5033Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5034{
5035 //
5036 // refit kink towards to the vertex
5037 //
5038 //
5039 Int_t row0 = GetRowNumber(kink.GetR());
5040 FollowProlongation(mother,0);
5041 mother.Reset(kFALSE);
5042 //
5043 FollowProlongation(daughter,row0);
5044 daughter.Reset(kFALSE);
5045 FollowBackProlongation(daughter,158);
5046 daughter.Reset(kFALSE);
5047 Int_t first = TMath::Max(row0-20,30);
5048 Int_t last = TMath::Min(row0+20,140);
5049 //
5050 const Int_t kNdiv =5;
5051 AliTPCseed param0[kNdiv]; // parameters along the track
5052 AliTPCseed param1[kNdiv]; // parameters along the track
5053 AliESDkink kinks[kNdiv]; // corresponding kink parameters
5054 //
5055 Int_t rows[kNdiv];
5056 for (Int_t irow=0; irow<kNdiv;irow++){
5057 rows[irow] = first +((last-first)*irow)/(kNdiv-1);
5058 }
5059 // store parameters along the track
5060 //
5061 for (Int_t irow=0;irow<kNdiv;irow++){
5062 FollowBackProlongation(mother, rows[irow]);
5063 FollowProlongation(daughter,rows[kNdiv-1-irow]);
5064 new(&param0[irow]) AliTPCseed(mother);
5065 new(&param1[kNdiv-1-irow]) AliTPCseed(daughter);
5066 }
5067 //
5068 // define kinks
5069 for (Int_t irow=0; irow<kNdiv-1;irow++){
5070 if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
5071 kinks[irow].SetMother(param0[irow]);
5072 kinks[irow].SetDaughter(param1[irow]);
5073 kinks[irow].Update();
5074 }
5075 //
5076 // choose kink with best "quality"
5077 Int_t index =-1;
5078 Double_t mindist = 10000;
5079 for (Int_t irow=0;irow<kNdiv;irow++){
5080 if (param0[irow].fN<20||param1[irow].fN<20) continue;
5081 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5082 if (TMath::Abs(kinks[irow].GetR())<100.) continue;
5083 //
5084 Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
5085 normdist/= (param0[irow].fN+param1[irow].fN+40.);
5086 if (normdist < mindist){
5087 mindist = normdist;
5088 index = irow;
5089 }
5090 }
5091 //
5092 if (index==-1) return 0;
5093 //
5094 //
5095 param0[index].Reset(kTRUE);
5096 FollowProlongation(param0[index],0);
5097 //
5098 new (&mother) AliTPCseed(param0[index]);
5099 new (&daughter) AliTPCseed(param1[index]); // daughter in vertex
5100 //
5101 kink.SetMother(mother);
5102 kink.SetDaughter(daughter);
5103 kink.Update();
5104 kink.SetTPCRow0(GetRowNumber(kink.GetR()));
5105 kink.SetTPCncls(param0[index].fN,0);
5106 kink.SetTPCncls(param1[index].fN,1);
5107 kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
5108 kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
5109 mother.SetLabel(kink.GetLabel(0));
5110 daughter.SetLabel(kink.GetLabel(1));
5111
5112 return 1;
5113}
51ad6848 5114
5115
5116void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
5117 //
5118 // update Kink quality information for mother after back propagation
5119 //
5120 if (seed->GetKinkIndex(0)>=0) return;
5121 for (Int_t ikink=0;ikink<3;ikink++){
5122 Int_t index = seed->GetKinkIndex(ikink);
5123 if (index>=0) break;
5124 index = TMath::Abs(index)-1;
5125 AliESDkink * kink = fEvent->GetKink(index);
eea478d3 5126 //kink->fTPCdensity2[0][0]=-1;
5127 //kink->fTPCdensity2[0][1]=-1;
5128 kink->SetTPCDensity2(-1,0,0);
5129 kink->SetTPCDensity2(1,0,1);
51ad6848 5130 //
eea478d3 5131 Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
51ad6848 5132 if (row0<15) row0=15;
5133 //
eea478d3 5134 Int_t row1 = kink->GetTPCRow0() + 2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
51ad6848 5135 if (row1>145) row1=145;
5136 //
5137 Int_t found,foundable,shared;
5138 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
eea478d3 5139 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
51ad6848 5140 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
eea478d3 5141 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
51ad6848 5142 }
5143
5144}
5145
eea478d3 5146void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
91162307 5147 //
eea478d3 5148 // update Kink quality information for daughter after refit
91162307 5149 //
eea478d3 5150 if (seed->GetKinkIndex(0)<=0) return;
5151 for (Int_t ikink=0;ikink<3;ikink++){
5152 Int_t index = seed->GetKinkIndex(ikink);
5153 if (index<=0) break;
5154 index = TMath::Abs(index)-1;
5155 AliESDkink * kink = fEvent->GetKink(index);
5156 kink->SetTPCDensity2(-1,1,0);
5157 kink->SetTPCDensity2(-1,1,1);
91162307 5158 //
eea478d3 5159 Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5160 if (row0<15) row0=15;
5161 //
5162 Int_t row1 = kink->GetTPCRow0() +2 + Int_t( 0.5/ (0.05+kink->GetAngle(2)));
5163 if (row1>145) row1=145;
5164 //
5165 Int_t found,foundable,shared;
5166 seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
5167 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
5168 seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
5169 if (foundable>5) kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
91162307 5170 }
eea478d3 5171
5172}
5173
5174
5175Int_t AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
5176{
91162307 5177 //
eea478d3 5178 // check kink point for given track
5179 // if return value=0 kink point not found
5180 // otherwise seed0 correspond to mother particle
5181 // seed1 correspond to daughter particle
5182 // kink parameter of kink point
91162307 5183
eea478d3 5184 Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
5185 Int_t first = seed->fFirstPoint;
5186 Int_t last = seed->fLastPoint;
5187 if (last-first<20) return 0; // shortest length - 2*30 = 60 pad-rows
91162307 5188
eea478d3 5189
5190 AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE); //middle of chamber
5191 if (!seed1) return 0;
5192 FollowProlongation(*seed1,seed->fLastPoint-20);
5193 seed1->Reset(kTRUE);
5194 FollowProlongation(*seed1,158);
5195 seed1->Reset(kTRUE);
5196 last = seed1->fLastPoint;
5197 //
5198 AliTPCseed *seed0 = new AliTPCseed(*seed);
5199 seed0->Reset(kFALSE);
5200 seed0->Reset();
5201 //
5202 AliTPCseed param0[20]; // parameters along the track
5203 AliTPCseed param1[20]; // parameters along the track
5204 AliESDkink kinks[20]; // corresponding kink parameters
5205 Int_t rows[20];
5206 for (Int_t irow=0; irow<20;irow++){
5207 rows[irow] = first +((last-first)*irow)/19;
5208 }
5209 // store parameters along the track
5210 //
5211 for (Int_t irow=0;irow<20;irow++){
5212 FollowBackProlongation(*seed0, rows[irow]);
5213 FollowProlongation(*seed1,rows[19-irow]);
5214 new(&param0[irow]) AliTPCseed(*seed0);
5215 new(&param1[19-irow]) AliTPCseed(*seed1);
5216 }
5217 //
5218 // define kinks
5219 for (Int_t irow=0; irow<19;irow++){
5220 kinks[irow].SetMother(param0[irow]);
5221 kinks[irow].SetDaughter(param1[irow]);
5222 kinks[irow].Update();
5223 }
5224 //
5225 // choose kink with biggest change of angle
5226 Int_t index =-1;
5227 Double_t maxchange= 0;
5228 for (Int_t irow=1;irow<19;irow++){
5229 if (TMath::Abs(kinks[irow].GetR())>240.) continue;
5230 if (TMath::Abs(kinks[irow].GetR())<110.) continue;
5231 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5232 if ( quality > maxchange){
5233 maxchange = quality;
5234 index = irow;
5235 //
91162307 5236 }
5237 }
eea478d3 5238 delete seed0;
5239 delete seed1;
5240 if (index<0) return 0;
5241 //
5242 Int_t row0 = GetRowNumber(kinks[index].GetR()); //row 0 estimate
5243 seed0 = new AliTPCseed(param0[index]);
5244 seed1 = new AliTPCseed(param1[index]);
5245 seed0->Reset(kFALSE);
5246 seed1->Reset(kFALSE);
5247 seed0->ResetCovariance();
5248 seed1->ResetCovariance();
5249 FollowProlongation(*seed0,0);
5250 FollowBackProlongation(*seed1,158);
5251 new (&mother) AliTPCseed(*seed0); // backup mother at position 0
5252 seed0->Reset(kFALSE);
5253 seed1->Reset(kFALSE);
5254 seed0->ResetCovariance();
5255 seed1->ResetCovariance();
5256 //
5257 first = TMath::Max(row0-20,0);
5258 last = TMath::Min(row0+20,158);
5259 //
5260 for (Int_t irow=0; irow<20;irow++){
5261 rows[irow] = first +((last-first)*irow)/19;
5262 }
5263 // store parameters along the track
5264 //
5265 for (Int_t irow=0;irow<20;irow++){
5266 FollowBackProlongation(*seed0, rows[irow]);
5267 FollowProlongation(*seed1,rows[19-irow]);
5268 new(&param0[irow]) AliTPCseed(*seed0);
5269 new(&param1[19-irow]) AliTPCseed(*seed1);
5270 }
5271 //
5272 // define kinks
5273 for (Int_t irow=0; irow<19;irow++){
5274 kinks[irow].SetMother(param0[irow]);
5275 kinks[irow].SetDaughter(param1[irow]);
5276 // param0[irow].Dump();
5277 //param1[irow].Dump();
5278 kinks[irow].Update();
5279 }
5280 //
5281 // choose kink with biggest change of angle
5282 index =-1;
5283 maxchange= 0;
5284 for (Int_t irow=0;irow<20;irow++){
5285 if (TMath::Abs(kinks[irow].GetR())>250.) continue;
5286 if (TMath::Abs(kinks[irow].GetR())<90.) continue;
5287 Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
5288 if ( quality > maxchange){
5289 maxchange = quality;
5290 index = irow;
5291 //
91162307 5292 }
5293 }
5294 //
5295 //
eea478d3 5296 if (index==-1 || param0[index].fN+param1[index].fN<100){
5297 delete seed0;
5298 delete seed1;
5299 return 0;
1627d1c4 5300 }
eea478d3 5301 // Float_t anglesigma = TMath::Sqrt(param0[index].fC22+param0[index].fC33+param1[index].fC22+param1[index].fC33);
1627d1c4 5302
eea478d3 5303 kink.SetMother(param0[index]);
5304 kink.SetDaughter(param1[index]);
5305 kink.Update();
5306 row0 = GetRowNumber(kink.GetR());
5307 kink.SetTPCRow0(row0);
5308 kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
5309 kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
5310 kink.SetIndex(-10,0);
5311 kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
5312 kink.SetTPCncls(param0[index].fN,0);
5313 kink.SetTPCncls(param1[index].fN,1);
5314 //
5315 //
5316 // new (&mother) AliTPCseed(param0[index]);
5317 new (&daughter) AliTPCseed(param1[index]);
5318 daughter.SetLabel(kink.GetLabel(1));
5319 param0[index].Reset(kTRUE);
5320 FollowProlongation(param0[index],0);
5321 new (&mother) AliTPCseed(param0[index]);
5322 mother.SetLabel(kink.GetLabel(0));
5323 delete seed0;
5324 delete seed1;
5325 //
5326 return 1;
1627d1c4 5327}
5328
5329
5330
5331
91162307 5332AliTPCseed* AliTPCtrackerMI::ReSeed(AliTPCseed *t)
5333{
5334 //
5335 // reseed - refit - track
5336 //
5337 Int_t first = 0;
5338 // Int_t last = fSectors->GetNRows()-1;
5339 //
5340 if (fSectors == fOuterSec){
5341 first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
5342 //last =
5343 }
5344 else
5345 first = t->fFirstPoint;
5346 //
5347 AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
5348 FollowBackProlongation(*t,fSectors->GetNRows()-1);
5349 t->Reset(kFALSE);
5350 FollowProlongation(*t,first);
5351 return seed;
5352}
5353
5354
5355
5356
5357
5358
5359
1c53abe2 5360//_____________________________________________________________________________
5361Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
5362 //-----------------------------------------------------------------
5363 // This function reades track seeds.
5364 //-----------------------------------------------------------------
5365 TDirectory *savedir=gDirectory;
5366
5367 TFile *in=(TFile*)inp;
5368 if (!in->IsOpen()) {
5369 cerr<<"AliTPCtrackerMI::ReadSeeds(): input file is not open !\n";
5370 return 1;
5371 }
5372
5373 in->cd();
5374 TTree *seedTree=(TTree*)in->Get("Seeds");
5375 if (!seedTree) {
5376 cerr<<"AliTPCtrackerMI::ReadSeeds(): ";
5377 cerr<<"can't get a tree with track seeds !\n";
5378 return 2;
5379 }
5380 AliTPCtrack *seed=new AliTPCtrack;
5381 seedTree->SetBranchAddress("tracks",&seed);
5382
5383 if (fSeeds==0) fSeeds=new TObjArray(15000);
5384
5385 Int_t n=(Int_t)seedTree->GetEntries();
5386 for (Int_t i=0; i<n; i++) {
5387 seedTree->GetEvent(i);
bbc6cd2c 5388 fSeeds->AddLast(new AliTPCseed(*seed/*,seed->GetAlpha()*/));
1c53abe2 5389 }
5390
5391 delete seed;
5392 delete seedTree;
5393 savedir->cd();
5394 return 0;
5395}
5396
d26d9159 5397Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
5398{
5399 //
d9b8978b 5400 if (fSeeds) DeleteSeeds();
d26d9159 5401 fEvent = esd;
5402 Clusters2Tracks();
5403 if (!fSeeds) return 1;
5404 FillESD(fSeeds);
5405 return 0;
5406 //
5407}
5408
5409
1c53abe2 5410//_____________________________________________________________________________
f8aae377 5411Int_t AliTPCtrackerMI::Clusters2Tracks() {
1c53abe2 5412 //-----------------------------------------------------------------
5413 // This is a track finder.
5414 //-----------------------------------------------------------------
91162307 5415 TDirectory *savedir=gDirectory;
1c53abe2 5416 TStopwatch timer;
d26d9159 5417
91162307 5418 fIteration = 0;
5419 fSeeds = Tracking();
1c53abe2 5420
6bdc18d6 5421 if (fDebug>0){
5422 Info("Clusters2Tracks","Time for tracking: \t");timer.Print();timer.Start();
5423 }
91162307 5424 //activate again some tracks
5425 for (Int_t i=0; i<fSeeds->GetEntriesFast(); i++) {
5426 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5427 if (!pt) continue;
5428 Int_t nc=t.GetNumberOfClusters();
5429 if (nc<20) {
5430 delete fSeeds->RemoveAt(i);
5431 continue;
eea478d3 5432 }
5433 CookLabel(pt,0.1);
91162307 5434 if (pt->fRemoval==10) {
5435 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5436 pt->Desactivate(10); // make track again active
5437 else{
5438 pt->Desactivate(20);
5439 delete fSeeds->RemoveAt(i);
5440 }
5441 }
5442 }
51ad6848 5443 //
5444 RemoveUsed2(fSeeds,0.85,0.85,0);
5445 FindKinks(fSeeds,fEvent);
81e97e0d 5446 RemoveUsed2(fSeeds,0.5,0.4,20);
5447 // //
5448// // refit short tracks
5449// //
5450 Int_t nseed=fSeeds->GetEntriesFast();
5451// for (Int_t i=0; i<nseed; i++) {
5452// AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5453// if (!pt) continue;
5454// Int_t nc=t.GetNumberOfClusters();
5455// if (nc<15) {
5456// delete fSeeds->RemoveAt(i);
5457// continue;
5458// }
5459// if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
5460// if (nc>100) continue; // hopefully, enough for ITS
5461// AliTPCseed *seed2 = new AliTPCseed(*pt);
5462// //seed2->Reset(kFALSE);
5463// //pt->ResetCovariance();
5464// seed2->Modify(1);
5465// FollowBackProlongation(*seed2,158);
5466// //seed2->Reset(kFALSE);
5467// seed2->Modify(10);
5468// FollowProlongation(*seed2,0);
5469// TTreeSRedirector &cstream = *fDebugStreamer;
5470// cstream<<"Crefit"<<
5471// "Tr0.="<<pt<<
5472// "Tr1.="<<seed2<<
5473// "\n";
5474// if (seed2->fN>pt->fN){
5475// delete fSeeds->RemoveAt(i);
5476// fSeeds->AddAt(seed2,i);
5477// }else{
5478// delete seed2;
5479// }
5480// }
5481// RemoveUsed2(fSeeds,0.6,0.6,50);
5482
5483// FindV0s(fSeeds,fEvent);
51ad6848 5484 //RemoveDouble(fSeeds,0.2,0.6,11);
c9427e08 5485
1c53abe2 5486 //
91162307 5487 Int_t found = 0;
5488 for (Int_t i=0; i<nseed; i++) {
5489 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5490 if (!pt) continue;
5491 Int_t nc=t.GetNumberOfClusters();
5492 if (nc<15) {
5493 delete fSeeds->RemoveAt(i);
5494 continue;
5495 }
5496 CookLabel(pt,0.1); //For comparison only
5497 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5498 if ((pt->IsActive() || (pt->fRemoval==10) )){
d9b8978b 5499 found++;
5500 if (fDebug>0) cerr<<found<<'\r';
d26d9159 5501 pt->fLab2 = i;
91162307 5502 }
5503 else
5504 delete fSeeds->RemoveAt(i);
91162307 5505 }
5506
5507
5508 //RemoveOverlap(fSeeds,0.99,7,kTRUE);
5509 SignShared(fSeeds);
5510 //RemoveUsed(fSeeds,0.9,0.9,6);
1c53abe2 5511 //
91162307 5512 nseed=fSeeds->GetEntriesFast();
5513 found = 0;
5514 for (Int_t i=0; i<nseed; i++) {
5515 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5516 if (!pt) continue;
5517 Int_t nc=t.GetNumberOfClusters();
5518 if (nc<15) {
5519 delete fSeeds->RemoveAt(i);
5520 continue;
5521 }
5522 t.SetUniqueID(i);
5523 t.CookdEdx(0.02,0.6);
5524 // CheckKinkPoint(&t,0.05);
5525 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5526 if ((pt->IsActive() || (pt->fRemoval==10) )){
6bdc18d6 5527 found++;
5528 if (fDebug>0){
5529 cerr<<found<<'\r';
5530 }
d26d9159 5531 pt->fLab2 = i;
91162307 5532 }
5533 else
5534 delete fSeeds->RemoveAt(i);
d26d9159 5535 //AliTPCseed * seed1 = ReSeed(pt,0.05,0.5,1);
5536 //if (seed1){
5537 // FollowProlongation(*seed1,0);
5538 // Int_t n = seed1->GetNumberOfClusters();
5539 // printf("fP4\t%f\t%f\n",seed1->GetC(),pt->GetC());
5540 // printf("fN\t%d\t%d\n", seed1->GetNumberOfClusters(),pt->GetNumberOfClusters());
5541 //
5542 //}
5543 //AliTPCseed * seed2 = ReSeed(pt,0.95,0.5,0.05);
5544
91162307 5545 }
5546
5547 SortTracks(fSeeds, 1);
1c53abe2 5548
982aff31 5549 /*
91162307 5550 fIteration = 1;
982aff31 5551 PrepareForBackProlongation(fSeeds,5.);
91162307 5552 PropagateBack(fSeeds);
5553 printf("Time for back propagation: \t");timer.Print();timer.Start();
5554
5555 fIteration = 2;
1c53abe2 5556
982aff31 5557 PrepareForProlongation(fSeeds,5.);
5558 PropagateForward2(fSeeds);
d26d9159 5559
91162307 5560 printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
5561 // RemoveUsed(fSeeds,0.7,0.7,6);
5562 //RemoveOverlap(fSeeds,0.9,7,kTRUE);
d26d9159 5563
1c53abe2 5564 nseed=fSeeds->GetEntriesFast();
91162307 5565 found = 0;
5566 for (Int_t i=0; i<nseed; i++) {
1c53abe2 5567 AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
5568 if (!pt) continue;
5569 Int_t nc=t.GetNumberOfClusters();
91162307 5570 if (nc<15) {
5571 delete fSeeds->RemoveAt(i);
5572 continue;
5573 }
1c53abe2 5574 t.CookdEdx(0.02,0.6);
91162307 5575 // CookLabel(pt,0.1); //For comparison only
5576 //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
5577 if ((pt->IsActive() || (pt->fRemoval==10) )){
5578 cerr<<found++<<'\r';
5579 }
5580 else
5581 delete fSeeds->RemoveAt(i);
5582 pt->fLab2 = i;
1c53abe2 5583 }
91162307 5584 */
5585
c9427e08 5586 // fNTracks = found;
6bdc18d6 5587 if (fDebug>0){
5588 Info("Clusters2Tracks","Time for overlap removal, track writing and dedx cooking: \t"); timer.Print();timer.Start();
5589 }
91162307 5590 //
6bdc18d6 5591 // cerr<<"Number of found tracks : "<<"\t"<<found<<endl;
5592 Info("Clusters2Tracks","Number of found tracks %d",found);
91162307 5593 savedir->cd();
91162307 5594 // UnloadClusters();
d26d9159 5595 //
1c53abe2 5596 return 0;
5597}
5598
91162307 5599void AliTPCtrackerMI::Tracking(TObjArray * arr)
5600{
5601 //
5602 // tracking of the seeds
5603 //
5604
5605 fSectors = fOuterSec;
5606 ParallelTracking(arr,150,63);
5607 fSectors = fOuterSec;
5608 ParallelTracking(arr,63,0);
5609}
5610
5611TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy, Int_t dsec)
5612{
5613 //
5614 //
5615 //tracking routine
5616 TObjArray * arr = new TObjArray;
5617 //
5618 fSectors = fOuterSec;
5619 TStopwatch timer;
5620 timer.Start();
5621 for (Int_t sec=0;sec<fkNOS;sec++){
5622 if (seedtype==3) MakeSeeds3(arr,sec,i1,i2,cuts,dy, dsec);
5623 if (seedtype==4) MakeSeeds5(arr,sec,i1,i2,cuts,dy);
5624 if (seedtype==2) MakeSeeds2(arr,sec,i1,i2,cuts,dy);
5625 }
5626 if (fDebug>0){
6bdc18d6 5627 Info("Tracking","\nSeeding - %d\t%d\t%d\t%d\n",seedtype,i1,i2,arr->GetEntriesFast());
91162307 5628 timer.Print();
5629 timer.Start();
5630 }
5631 Tracking(arr);
5632 if (fDebug>0){
5633 timer.Print();
5634 }
5635
5636 return arr;
5637}
5638
5639TObjArray * AliTPCtrackerMI::Tracking()
5640{
5641 //
5642 //
5643 TStopwatch timer;
5644 timer.Start();
5645 Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
5646
5647 TObjArray * seeds = new TObjArray;
5648 TObjArray * arr=0;
5649
5650 Int_t gap =20;
5651 Float_t cuts[4];
5652 cuts[0] = 0.002;
5653 cuts[1] = 1.5;
5654 cuts[2] = 3.;
5655 cuts[3] = 3.;
5656 Float_t fnumber = 3.0;
5657 Float_t fdensity = 3.0;
5658
5659 //
5660 //find primaries
5661 cuts[0]=0.0066;
5662 for (Int_t delta = 0; delta<18; delta+=6){
5663 //
5664 cuts[0]=0.0070;
5665 cuts[1] = 1.5;
5666 arr = Tracking(3,nup-1-delta,nup-1-delta-gap,cuts,-1,1);
5667 SumTracks(seeds,arr);
5668 SignClusters(seeds,fnumber,fdensity);
5669 //
5670 for (Int_t i=2;i<6;i+=2){
5671 // seed high pt tracks
5672 cuts[0]=0.0022;
5673 cuts[1]=0.3;
5674 arr = Tracking(3,nup-i-delta,nup-i-delta-gap,cuts,-1,0);
5675 SumTracks(seeds,arr);
5676 SignClusters(seeds,fnumber,fdensity);
5677 }
5678 }
5679 fnumber = 4;
5680 fdensity = 4.;
5681 // RemoveUsed(seeds,0.9,0.9,1);
5682 // UnsignClusters();
5683 // SignClusters(seeds,fnumber,fdensity);
5684
5685 //find primaries
5686 cuts[0]=0.0077;
5687 for (Int_t delta = 20; delta<120; delta+=10){
5688 //
5689 // seed high pt tracks
5690 cuts[0]=0.0060;
5691 cuts[1]=0.3;
5692 cuts[2]=6.;
5693 arr = Tracking(3,nup-delta,nup-delta-gap,cuts,-1);
5694 SumTracks(seeds,arr);
5695 SignClusters(seeds,fnumber,fdensity);
5696
5697 cuts[0]=0.003;
5698 cuts[1]=0.3;
5699 cuts[2]=6.;
5700 arr = Tracking(3,nup-delta-5,nup-delta-5-gap,cuts,-1);
5701 SumTracks(seeds,arr);
5702 SignClusters(seeds,fnumber,fdensity);
5703 }
5704
5705 cuts[0] = 0.01;
5706 cuts[1] = 2.0;
5707 cuts[2] = 3.;
5708 cuts[3] = 2.0;
5709 fnumber = 2.;
5710 fdensity = 2.;
5711
5712 if (fDebug>0){
6bdc18d6 5713 Info("Tracking()","\n\nPrimary seeding\t%d\n\n",seeds->GetEntriesFast());
91162307 5714 timer.Print();
5715 timer.Start();
5716 }
5717 // RemoveUsed(seeds,0.75,0.75,1);
5718 //UnsignClusters();
5719 //SignClusters(seeds,fnumber,fdensity);
5720
5721 // find secondaries
5722
5723 cuts[0] = 0.3;
5724 cuts[1] = 1.5;
5725 cuts[2] = 3.;
5726 cuts[3] = 1.5;
5727
5728 arr = Tracking(4,nup-1,nup-1-gap,cuts,-1);
5729 SumTracks(seeds,arr);
5730 SignClusters(seeds,fnumber,fdensity);
5731 //
5732 arr = Tracking(4,nup-2,nup-2-gap,cuts,-1);
5733 SumTracks(seeds,arr);
5734 SignClusters(seeds,fnumber,fdensity);
5735 //
5736 arr = Tracking(4,nup-3,nup-3-gap,cuts,-1);
5737 SumTracks(seeds,arr);
5738 SignClusters(seeds,fnumber,fdensity);
5739 //
5740
5741
5742 for (Int_t delta = 3; delta<30; delta+=5){
5743 //
5744 cuts[0] = 0.3;
5745 cuts[1] = 1.5;
5746 cuts[2] = 3.;
5747 cuts[3] = 1.5;
5748 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5749 SumTracks(seeds,arr);
5750 SignClusters(seeds,fnumber,fdensity);
5751 //
5752 arr = Tracking(4,nup-3-delta,nup-5-delta-gap,cuts,4);
5753 SumTracks(seeds,arr);
5754 SignClusters(seeds,fnumber,fdensity);
5755 //
5756 }
5757 fnumber = 1;
5758 fdensity = 1;
5759 //
5760 // change cuts
5761 fnumber = 2.;
5762 fdensity = 2.;
5763 cuts[0]=0.0080;
5764
5765 // find secondaries
2bd61959 5766 for (Int_t delta = 30; delta<90; delta+=10){
91162307 5767 //
5768 cuts[0] = 0.3;
2bd61959 5769 cuts[1] = 3.5;
91162307 5770 cuts[2] = 3.;
2bd61959 5771 cuts[3] = 3.5;
91162307 5772 arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
5773 SumTracks(seeds,arr);
5774 SignClusters(seeds,fnumber,fdensity);
5775 //
5776 arr = Tracking(4,nup-5-delta,nup-5-delta-gap,cuts,5 );
5777 SumTracks(seeds,arr);
5778 SignClusters(seeds,fnumber,fdensity);
5779 }
5780
5781 if (fDebug>0){
6bdc18d6 5782 Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
91162307 5783 timer.Print();
5784 timer.Start();
5785 }
5786
5787 return seeds;
5788 //
5789
5790}
5791
5792
47966a6d 5793void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
91162307 5794{
5795 //
5796 //sum tracks to common container
5797 //remove suspicious tracks
5798 Int_t nseed = arr2->GetEntriesFast();
5799 for (Int_t i=0;i<nseed;i++){
5800 AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);
5801 if (pt){
ca142b1f 5802 // REMOVE VERY SHORT TRACKS
5803 if (pt->GetNumberOfClusters()<20){
5804 delete arr2->RemoveAt(i);
5805 continue;
5806 }// patch 28 fev06
91162307 5807 // NORMAL ACTIVE TRACK
5808 if (pt->IsActive()){
5809 arr1->AddLast(arr2->RemoveAt(i));
5810 continue;
5811 }
5812 //remove not usable tracks
5813 if (pt->fRemoval!=10){
5814 delete arr2->RemoveAt(i);
5815 continue;
5816 }
ca142b1f 5817
91162307 5818 // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
5819 if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
5820 arr1->AddLast(arr2->RemoveAt(i));
5821 else{
5822 delete arr2->RemoveAt(i);
5823 }
5824 }
5825 }
5826 delete arr2;
5827}
5828
5829
1c53abe2 5830
91162307 5831void AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast)
1c53abe2 5832{
5833 //
5834 // try to track in parralel
5835
91162307 5836 Int_t nseed=arr->GetEntriesFast();
1c53abe2 5837 //prepare seeds for tracking
5838 for (Int_t i=0; i<nseed; i++) {
91162307 5839 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
1c53abe2 5840 if (!pt) continue;
5841 if (!t.IsActive()) continue;
5842 // follow prolongation to the first layer
91162307 5843 if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )
c9427e08 5844 FollowProlongation(t, rfirst+1);
1c53abe2 5845 }
5846
5847
5848 //
982aff31 5849 for (Int_t nr=rfirst; nr>=rlast; nr--){
5850 if (nr<fInnerSec->GetNRows())
5851 fSectors = fInnerSec;
5852 else
5853 fSectors = fOuterSec;
1c53abe2 5854 // make indexes with the cluster tracks for given
1c53abe2 5855
5856 // find nearest cluster
5857 for (Int_t i=0; i<nseed; i++) {
91162307 5858 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i), &t=*pt;
1c53abe2 5859 if (!pt) continue;
51ad6848 5860 if (nr==80) pt->UpdateReference();
1c53abe2 5861 if (!pt->IsActive()) continue;
91162307 5862 // if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
1627d1c4 5863 if (pt->fRelativeSector>17) {
5864 continue;
5865 }
91162307 5866 UpdateClusters(t,nr);
1c53abe2 5867 }
5868 // prolonagate to the nearest cluster - if founded
5869 for (Int_t i=0; i<nseed; i++) {
91162307 5870 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1c53abe2 5871 if (!pt) continue;
1627d1c4 5872 if (!pt->IsActive()) continue;
91162307 5873 // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
1627d1c4 5874 if (pt->fRelativeSector>17) {
5875 continue;
5876 }
91162307 5877 FollowToNextCluster(*pt,nr);
1c53abe2 5878 }
91162307 5879 }
5880}
5881
47966a6d 5882void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) const
91162307 5883{
5884 //
5885 //
5886 // if we use TPC track itself we have to "update" covariance
5887 //
5888 Int_t nseed= arr->GetEntriesFast();
5889 for (Int_t i=0;i<nseed;i++){
5890 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5891 if (pt) {
5892 pt->Modify(fac);
5893 //
5894 //rotate to current local system at first accepted point
5895 Int_t index = pt->GetClusterIndex2(pt->fFirstPoint);
5896 Int_t sec = (index&0xff000000)>>24;
5897 sec = sec%18;
5898 Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
5899 if (angle1>TMath::Pi())
5900 angle1-=2.*TMath::Pi();
5901 Float_t angle2 = pt->GetAlpha();
5902
5903 if (TMath::Abs(angle1-angle2)>0.001){
5904 pt->Rotate(angle1-angle2);
5905 //angle2 = pt->GetAlpha();
5906 //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
5907 //if (pt->GetAlpha()<0)
5908 // pt->fRelativeSector+=18;
5909 //sec = pt->fRelativeSector;
5910 }
5911
5912 }
5913
5914 }
5915
5916
5917}
47966a6d 5918void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
91162307 5919{
5920 //
5921 //
5922 // if we use TPC track itself we have to "update" covariance
5923 //
5924 Int_t nseed= arr->GetEntriesFast();
5925 for (Int_t i=0;i<nseed;i++){
5926 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5927 if (pt) {
5928 pt->Modify(fac);
5929 pt->fFirstPoint = pt->fLastPoint;
5930 }
5931
5932 }
5933
5934
5935}
5936
5937Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
5938{
5939 //
5940 // make back propagation
5941 //
5942 Int_t nseed= arr->GetEntriesFast();
5943 for (Int_t i=0;i<nseed;i++){
5944 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
51ad6848 5945 if (pt&& pt->GetKinkIndex(0)<=0) {
d9b8978b 5946 //AliTPCseed *pt2 = new AliTPCseed(*pt);
91162307 5947 fSectors = fInnerSec;
d26d9159 5948 //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
5949 //fSectors = fOuterSec;
4d158c36 5950 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5951 //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
d9b8978b 5952 // Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
4d158c36 5953 // FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
d9b8978b 5954 //}
51ad6848 5955 }
5956 if (pt&& pt->GetKinkIndex(0)>0) {
5957 AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
eea478d3 5958 pt->fFirstPoint = kink->GetTPCRow0();
51ad6848 5959 fSectors = fInnerSec;
5960 FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
5961 }
5962
91162307 5963 }
5964 return 0;
5965}
5966
5967
5968Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
5969{
5970 //
5971 // make forward propagation
5972 //
5973 Int_t nseed= arr->GetEntriesFast();
4d158c36 5974 //
91162307 5975 for (Int_t i=0;i<nseed;i++){
5976 AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
5977 if (pt) {
91162307 5978 FollowProlongation(*pt,0);
4d158c36 5979 }
91162307 5980 }
5981 return 0;
5982}
5983
5984
5985Int_t AliTPCtrackerMI::PropagateForward()
5986{
b67e07dc 5987 //
5988 // propagate track forward
4d158c36 5989 //UnsignClusters();
d26d9159 5990 Int_t nseed = fSeeds->GetEntriesFast();
5991 for (Int_t i=0;i<nseed;i++){
5992 AliTPCseed *pt = (AliTPCseed*)fSeeds->UncheckedAt(i);
5993 if (pt){
5994 AliTPCseed &t = *pt;
5995 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
5996 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
5997 if (alpha < 0. ) alpha += 2.*TMath::Pi();
5998 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
5999 }
6000 }
6001
91162307 6002 fSectors = fOuterSec;
d26d9159 6003 ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
91162307 6004 fSectors = fInnerSec;
d26d9159 6005 ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
91162307 6006 //WriteTracks();
6007 return 1;
6008}
6009
6010
6011
6012
6013
6014
6015Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
6016{
6017 //
6018 // make back propagation, in between row0 and row1
6019 //
1c53abe2 6020
91162307 6021 if (pt) {
6022 fSectors = fInnerSec;
6023 Int_t r1;
6024 //
6025 if (row1<fSectors->GetNRows())
6026 r1 = row1;
6027 else
6028 r1 = fSectors->GetNRows()-1;
6029
6030 if (row0<fSectors->GetNRows()&& r1>0 )
6031 FollowBackProlongation(*pt,r1);
6032 if (row1<=fSectors->GetNRows())
6033 return 0;
6034 //
6035 r1 = row1 - fSectors->GetNRows();
6036 if (r1<=0) return 0;
6037 if (r1>=fOuterSec->GetNRows()) return 0;
6038 fSectors = fOuterSec;
6039 return FollowBackProlongation(*pt,r1);
6040 }
6041 return 0;
6042}
6043
6044
6045
6046
6047void AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
6048{
6049 //
6050 //
6051 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
6052 // Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6053 Float_t padlength = GetPadPitchLength(row);
6054 //
6055 Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
3f82c4f2 6056 Double_t angulary = seed->GetSnp();
91162307 6057 angulary = angulary*angulary/(1-angulary*angulary);
6058 seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;
6059 //
6060 Float_t sresz = fParam->GetZSigma();
6061 Float_t angularz = seed->GetTgl();
6062 seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
6063 /*
6064 Float_t wy = GetSigmaY(seed);
6065 Float_t wz = GetSigmaZ(seed);
6066 wy*=wy;
6067 wz*=wz;
6068 if (TMath::Abs(wy/seed->fCurrentSigmaY2-1)>0.0001 || TMath::Abs(wz/seed->fCurrentSigmaZ2-1)>0.0001 ){
6069 printf("problem\n");
6070 }
6071 */
1c53abe2 6072}
6073
91162307 6074
1c53abe2 6075Float_t AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
6076{
6077 //
6078 //
c9427e08 6079 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
1c53abe2 6080 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6081 Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
6082 Float_t angular = seed->GetSnp();
6083 angular = angular*angular/(1-angular*angular);
6084 // angular*=angular;
6085 //angular = TMath::Sqrt(angular/(1-angular));
6086 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
6087 return res;
6088}
6089Float_t AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
6090{
6091 //
6092 //
c9427e08 6093 Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
1c53abe2 6094 Float_t padlength = fParam->GetPadPitchLength(seed->fSector);
6095 Float_t sres = fParam->GetZSigma();
6096 Float_t angular = seed->GetTgl();
6097 Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
6098 return res;
6099}
6100
6101
1c53abe2 6102//__________________________________________________________________________
af32720d 6103void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
1c53abe2 6104 //--------------------------------------------------------------------
6105 //This function "cooks" a track label. If label<0, this track is fake.
6106 //--------------------------------------------------------------------
af32720d 6107 AliTPCseed * t = (AliTPCseed*)tk;
1c53abe2 6108 Int_t noc=t->GetNumberOfClusters();
91162307 6109 if (noc<10){
d26d9159 6110 //printf("\nnot founded prolongation\n\n\n");
6111 //t->Dump();
91162307 6112 return ;
6113 }
6114 Int_t lb[160];
6115 Int_t mx[160];
6116 AliTPCclusterMI *clusters[160];
6117 //
6118 for (Int_t i=0;i<160;i++) {
6119 clusters[i]=0;
6120 lb[i]=mx[i]=0;
6121 }
1c53abe2 6122
6123 Int_t i;
91162307 6124 Int_t current=0;
6125 for (i=0; i<160 && current<noc; i++) {
6126
6127 Int_t index=t->GetClusterIndex2(i);
6128 if (index<=0) continue;
6129 if (index&0x8000) continue;
6130 //
6131 //clusters[current]=GetClusterMI(index);
6132 if (t->fClusterPointer[i]){
6133 clusters[current]=t->fClusterPointer[i];
6134 current++;
6135 }
1c53abe2 6136 }
91162307 6137 noc = current;
1c53abe2 6138
6139 Int_t lab=123456789;
6140 for (i=0; i<noc; i++) {
6141 AliTPCclusterMI *c=clusters[i];
91162307 6142 if (!c) continue;
1c53abe2 6143 lab=TMath::Abs(c->GetLabel(0));
6144 Int_t j;
6145 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6146 lb[j]=lab;
6147 (mx[j])++;
6148 }
6149
6150 Int_t max=0;
6151 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6152
6153 for (i=0; i<noc; i++) {
9918f10a 6154 AliTPCclusterMI *c=clusters[i];
91162307 6155 if (!c) continue;
1c53abe2 6156 if (TMath::Abs(c->GetLabel(1)) == lab ||
6157 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6158 }
6159
6160 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6161
6162 else {
6163 Int_t tail=Int_t(0.10*noc);
6164 max=0;
91162307 6165 Int_t ind=0;
6166 for (i=1; i<=160&&ind<tail; i++) {
6167 // AliTPCclusterMI *c=clusters[noc-i];
6168 AliTPCclusterMI *c=clusters[i];
6169 if (!c) continue;
1c53abe2 6170 if (lab == TMath::Abs(c->GetLabel(0)) ||
6171 lab == TMath::Abs(c->GetLabel(1)) ||
6172 lab == TMath::Abs(c->GetLabel(2))) max++;
91162307 6173 ind++;
1c53abe2 6174 }
6175 if (max < Int_t(0.5*tail)) lab=-lab;
6176 }
6177
6178 t->SetLabel(lab);
6179
91162307 6180 // delete[] lb;
6181 //delete[] mx;
6182 //delete[] clusters;
1c53abe2 6183}
6184
47966a6d 6185
51ad6848 6186//__________________________________________________________________________
6187Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t last) const {
6188 //--------------------------------------------------------------------
6189 //This function "cooks" a track label. If label<0, this track is fake.
6190 //--------------------------------------------------------------------
6191 Int_t noc=t->GetNumberOfClusters();
6192 if (noc<10){
6193 //printf("\nnot founded prolongation\n\n\n");
6194 //t->Dump();
6195 return -1;
6196 }
6197 Int_t lb[160];
6198 Int_t mx[160];
6199 AliTPCclusterMI *clusters[160];
6200 //
6201 for (Int_t i=0;i<160;i++) {
6202 clusters[i]=0;
6203 lb[i]=mx[i]=0;
6204 }
6205
6206 Int_t i;
6207 Int_t current=0;
6208 for (i=0; i<160 && current<noc; i++) {
6209 if (i<first) continue;
6210 if (i>last) continue;
6211 Int_t index=t->GetClusterIndex2(i);
6212 if (index<=0) continue;
6213 if (index&0x8000) continue;
6214 //
6215 //clusters[current]=GetClusterMI(index);
6216 if (t->fClusterPointer[i]){
6217 clusters[current]=t->fClusterPointer[i];
6218 current++;
6219 }
6220 }
6221 noc = current;
6222 if (noc<5) return -1;
6223 Int_t lab=123456789;
6224 for (i=0; i<noc; i++) {
6225 AliTPCclusterMI *c=clusters[i];
6226 if (!c) continue;
6227 lab=TMath::Abs(c->GetLabel(0));
6228 Int_t j;
6229 for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
6230 lb[j]=lab;
6231 (mx[j])++;
6232 }
6233
6234 Int_t max=0;
6235 for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
6236
6237 for (i=0; i<noc; i++) {
6238 AliTPCclusterMI *c=clusters[i];
6239 if (!c) continue;
6240 if (TMath::Abs(c->GetLabel(1)) == lab ||
6241 TMath::Abs(c->GetLabel(2)) == lab ) max++;
6242 }
6243
6244 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
6245
6246 else {
6247 Int_t tail=Int_t(0.10*noc);
6248 max=0;
6249 Int_t ind=0;
6250 for (i=1; i<=160&&ind<tail; i++) {
6251 // AliTPCclusterMI *c=clusters[noc-i];
6252 AliTPCclusterMI *c=clusters[i];
6253 if (!c) continue;
6254 if (lab == TMath::Abs(c->GetLabel(0)) ||
6255 lab == TMath::Abs(c->GetLabel(1)) ||
6256 lab == TMath::Abs(c->GetLabel(2))) max++;
6257 ind++;
6258 }
6259 if (max < Int_t(0.5*tail)) lab=-lab;
6260 }
6261
6262 // t->SetLabel(lab);
6263 return lab;
6264 // delete[] lb;
6265 //delete[] mx;
6266 //delete[] clusters;
6267}
6268
6269
47966a6d 6270Int_t AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const
6271{
6272 //return pad row number for this x
6273 Double_t r;
6274 if (fN < 64){
6275 r=fRow[fN-1].GetX();
6276 if (x > r) return fN;
6277 r=fRow[0].GetX();
6278 if (x < r) return -1;
6279 return Int_t((x-r)/fPadPitchLength + 0.5);}
6280 else{
6281 r=fRow[fN-1].GetX();
6282 if (x > r) return fN;
6283 r=fRow[0].GetX();
6284 if (x < r) return -1;
6285 Double_t r1=fRow[64].GetX();
6286 if(x<r1){
6287 return Int_t((x-r)/f1PadPitchLength + 0.5);}
6288 else{
6289 return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);}
6290 }
6291}
6292
eea478d3 6293Int_t AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
6294{
6295 //return pad row number for given x vector
6296 Float_t phi = TMath::ATan2(x[1],x[0]);
6297 if(phi<0) phi=2.*TMath::Pi()+phi;
6298 // Get the local angle in the sector philoc
6299 const Float_t kRaddeg = 180/3.14159265358979312;
6300 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
6301 Double_t localx = x[0]*TMath::Cos(phiangle)-x[1]*TMath::Sin(phiangle);
6302 return GetRowNumber(localx);
6303}
6304
1c53abe2 6305//_________________________________________________________________________
6306void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
6307 //-----------------------------------------------------------------------
6308 // Setup inner sector
6309 //-----------------------------------------------------------------------
6310 if (f==0) {
6311 fAlpha=par->GetInnerAngle();
6312 fAlphaShift=par->GetInnerAngleShift();
6313 fPadPitchWidth=par->GetInnerPadPitchWidth();
6314 fPadPitchLength=par->GetInnerPadPitchLength();
6315 fN=par->GetNRowLow();
6316 fRow=new AliTPCRow[fN];
6317 for (Int_t i=0; i<fN; i++) {
6318 fRow[i].SetX(par->GetPadRowRadiiLow(i));
6319 fRow[i].fDeadZone =1.5; //1.5 cm of dead zone
6320 }
6321 } else {
6322 fAlpha=par->GetOuterAngle();
6323 fAlphaShift=par->GetOuterAngleShift();
6324 fPadPitchWidth = par->GetOuterPadPitchWidth();
6325 fPadPitchLength = par->GetOuter1PadPitchLength();
6326 f1PadPitchLength = par->GetOuter1PadPitchLength();
6327 f2PadPitchLength = par->GetOuter2PadPitchLength();
6328
6329 fN=par->GetNRowUp();
6330 fRow=new AliTPCRow[fN];
6331 for (Int_t i=0; i<fN; i++) {
6332 fRow[i].SetX(par->GetPadRowRadiiUp(i));
6333 fRow[i].fDeadZone =1.5; // 1.5 cm of dead zone
6334 }
6335 }
6336}
6337
b67e07dc 6338AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
6339 //
6340 // default constructor
6341 fN=0;
6342 fN1=0;
6343 fN2=0;
6344 fClusters1=0;
6345 fClusters2=0;
6346}
1c53abe2 6347
6348AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
6349 //
b67e07dc 6350
1c53abe2 6351}
6352
6353
6354
1c53abe2 6355//_________________________________________________________________________
6356void
6357AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
6358 //-----------------------------------------------------------------------
6359 // Insert a cluster into this pad row in accordence with its y-coordinate
6360 //-----------------------------------------------------------------------
6361 if (fN==kMaxClusterPerRow) {
6362 cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
6363 }
6364 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
6365 Int_t i=Find(c->GetZ());
6366 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
6367 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
6368 fIndex[i]=index; fClusters[i]=c; fN++;
6369}
6370
982aff31 6371void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
6372 //
6373 // reset clusters
6374 fN = 0;
6375 fN1 = 0;
6376 fN2 = 0;
6377 //delete[] fClusterArray;
6378 if (fClusters1) delete []fClusters1;
6379 if (fClusters2) delete []fClusters2;
6380 //fClusterArray=0;
6381 fClusters1 = 0;
6382 fClusters2 = 0;
6383}
6384
91162307 6385
1c53abe2 6386//___________________________________________________________________
6387Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
6388 //-----------------------------------------------------------------------
6389 // Return the index of the nearest cluster
6390 //-----------------------------------------------------------------------
6391 if (fN==0) return 0;
6392 if (z <= fClusters[0]->GetZ()) return 0;
6393 if (z > fClusters[fN-1]->GetZ()) return fN;
6394 Int_t b=0, e=fN-1, m=(b+e)/2;
6395 for (; b<e; m=(b+e)/2) {
6396 if (z > fClusters[m]->GetZ()) b=m+1;
6397 else e=m;
6398 }
6399 return m;
6400}
6401
6402
6403
1627d1c4 6404//___________________________________________________________________
6405AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
6406 //-----------------------------------------------------------------------
6407 // Return the index of the nearest cluster in z y
6408 //-----------------------------------------------------------------------
6409 Float_t maxdistance = roady*roady + roadz*roadz;
6410
6411 AliTPCclusterMI *cl =0;
6412 for (Int_t i=Find(z-roadz); i<fN; i++) {
6413 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6414 if (c->GetZ() > z+roadz) break;
6415 if ( (c->GetY()-y) > roady ) continue;
6416 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6417 if (maxdistance>distance) {
6418 maxdistance = distance;
6419 cl=c;
6420 }
6421 }
6422 return cl;
6423}
6424
91162307 6425AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6426{
6427 //-----------------------------------------------------------------------
6428 // Return the index of the nearest cluster in z y
6429 //-----------------------------------------------------------------------
6430 Float_t maxdistance = roady*roady + roadz*roadz;
91162307 6431 AliTPCclusterMI *cl =0;
3381b665 6432
6433 //PH Check boundaries. 510 is the size of fFastCluster
6434 Int_t iz1 = Int_t(z-roadz+254.5);
6435 if (iz1<0 || iz1>=510) return cl;
6436 iz1 = TMath::Max(fFastCluster[iz1]-1,0);
6437 Int_t iz2 = Int_t(z+roadz+255.5);
6438 if (iz2<0 || iz2>=510) return cl;
6439 iz2 = TMath::Min(fFastCluster[iz2]+1,fN);
6440
91162307 6441 //FindNearest3(y,z,roady,roadz,index);
6442 // for (Int_t i=Find(z-roadz); i<fN; i++) {
6443 for (Int_t i=iz1; i<iz2; i++) {
6444 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6445 if (c->GetZ() > z+roadz) break;
6446 if ( c->GetY()-y > roady ) continue;
6447 if ( y-c->GetY() > roady ) continue;
6448 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6449 if (maxdistance>distance) {
6450 maxdistance = distance;
6451 cl=c;
6452 index =i;
6453 //roady = TMath::Sqrt(maxdistance);
6454 }
6455 }
6456 return cl;
6457}
6458
6459
6460
6461AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const
6462{
6463 //-----------------------------------------------------------------------
6464 // Return the index of the nearest cluster in z y
6465 //-----------------------------------------------------------------------
6466 Float_t maxdistance = roady*roady + roadz*roadz;
6467 // Int_t iz = Int_t(z+255.);
6468 AliTPCclusterMI *cl =0;
6469 for (Int_t i=Find(z-roadz); i<fN; i++) {
6470 //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
6471 AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
6472 if (c->GetZ() > z+roadz) break;
6473 if ( c->GetY()-y > roady ) continue;
6474 if ( y-c->GetY() > roady ) continue;
6475 Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
6476 if (maxdistance>distance) {
6477 maxdistance = distance;
6478 cl=c;
6479 index =i;
6480 //roady = TMath::Sqrt(maxdistance);
6481 }
6482 }
6483 return cl;
6484}
1627d1c4 6485
6486
6487
6488
91162307 6489
81e97e0d 6490// AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
6491// {
6492// //
6493// //
6494// return &fTrackPoints[i];
6495// }
91162307 6496
91162307 6497