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