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