Additional protection and change in the interface (Yu.Belikov)
[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;
d184f295 1622 Int_t index=0;
91162307 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
3d172d79 1641 // if (index<0) return 0;
1642 UInt_t uindex = TMath::Abs(index);
d184f295 1643
91162307 1644 if (krow) {
d184f295 1645 //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);
1646 cl = krow.FindNearest2(y,z,roady,roadz,uindex);
91162307 1647 }
d26d9159 1648
d184f295 1649 if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(uindex);
d26d9159 1650 t.fCurrentCluster = cl;
1651
91162307 1652 return 1;
1653}
1c53abe2 1654
1c53abe2 1655
91162307 1656Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
1657 //-----------------------------------------------------------------
1658 // This function tries to find a track prolongation to next pad row
1659 //-----------------------------------------------------------------
1c53abe2 1660
91162307 1661 //update error according neighborhoud
1c53abe2 1662
91162307 1663 if (t.fCurrentCluster) {
1664 t.fRow = nr;
8c51a605 1665 Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
91162307 1666
1667 if (t.fCurrentCluster->IsUsed(10)){
1668 //
1669 //
1670 // t.fErrorZ2*=2;
1671 // t.fErrorY2*=2;
1672 t.fNShared++;
1673 if (t.fNShared>0.7*t.GetNumberOfClusters()) {
1674 t.fRemoval =10;
1675 return 0;
1676 }
b364ca79 1677 }
d26d9159 1678 if (fIteration>0) accept = 0;
b364ca79 1679 if (accept<3) UpdateTrack(&t,accept);
1680
1c53abe2 1681 } else {
91162307 1682 if (fIteration==0){
1683 if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;
1684 if ( t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;
1685
1686 if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
1c53abe2 1687 }
1688 }
1689 return 1;
1690}
1691
1692
1693
91162307 1694//_____________________________________________________________________________
1695Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1696 //-----------------------------------------------------------------
91162307 1697 // This function tries to find a track prolongation.
1c53abe2 1698 //-----------------------------------------------------------------
1699 Double_t xt=t.GetX();
1700 //
91162307 1701 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1c53abe2 1702 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1703 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1704 //
1705 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1706
91162307 1707 Int_t first = GetRowNumber(xt)-1;
51ad6848 1708 for (Int_t nr= first; nr>=rf; nr-=step) {
1709 // update kink info
1710 if (t.GetKinkIndexes()[0]>0){
1711 for (Int_t i=0;i<3;i++){
1712 Int_t index = t.GetKinkIndexes()[i];
1713 if (index==0) break;
1714 if (index<0) continue;
1715 //
1716 AliESDkink * kink = fEvent->GetKink(index-1);
1717 if (!kink){
1718 printf("PROBLEM\n");
1719 }
1720 else{
eea478d3 1721 Int_t kinkrow = kink->GetTPCRow0()+2+Int_t(0.5/(0.05+kink->GetAngle(2)));
51ad6848 1722 if (kinkrow==nr){
1723 AliExternalTrackParam paramd(t);
1724 kink->SetDaughter(paramd);
eea478d3 1725 kink->SetStatus(2,5);
51ad6848 1726 kink->Update();
51ad6848 1727 }
1728 }
1729 }
1730 }
1731
1732 if (nr==80) t.UpdateReference();
982aff31 1733 if (nr<fInnerSec->GetNRows())
1734 fSectors = fInnerSec;
1735 else
1736 fSectors = fOuterSec;
91162307 1737 if (FollowToNext(t,nr)==0)
4d158c36 1738 if (!t.IsActive())
1739 return 0;
91162307 1740
1741 }
1742 return 1;
1743}
1744
1c53abe2 1745
1746//_____________________________________________________________________________
91162307 1747Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t step) {
1c53abe2 1748 //-----------------------------------------------------------------
1749 // This function tries to find a track prolongation.
1750 //-----------------------------------------------------------------
1751 Double_t xt=t.GetX();
1752 //
1753 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1754 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1755 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1756 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1757
1758 for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
1759
1760 if (FollowToNextFast(t,nr)==0)
1761 if (!t.IsActive()) return 0;
1c53abe2 1762
1c53abe2 1763 }
1764 return 1;
1765}
1766
1767
91162307 1768
1769
1770
1c53abe2 1771Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
1772 //-----------------------------------------------------------------
1773 // This function tries to find a track prolongation.
1774 //-----------------------------------------------------------------
1c53abe2 1775 //
eea478d3 1776 Double_t xt=t.GetX();
1c53abe2 1777 Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
1778 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
1779 if (alpha < 0. ) alpha += 2.*TMath::Pi();
91162307 1780 t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
1c53abe2 1781
4d158c36 1782 Int_t first = t.fFirstPoint;
eea478d3 1783 if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
91162307 1784 //
1785 if (first<0) first=0;
4d158c36 1786 for (Int_t nr=first; nr<=rf; nr++) {
2bd61959 1787 if ( (TMath::Abs(t.GetSnp())>0.95)) break;
51ad6848 1788 if (t.GetKinkIndexes()[0]<0){
1789 for (Int_t i=0;i<3;i++){
1790 Int_t index = t.GetKinkIndexes()[i];
1791 if (index==0) break;
1792 if (index>0) continue;
1793 index = TMath::Abs(index);
1794 AliESDkink * kink = fEvent->GetKink(index-1);
1795 if (!kink){
1796 printf("PROBLEM\n");
1797 }
1798 else{
eea478d3 1799 Int_t kinkrow = kink->GetTPCRow0()-2-Int_t(0.5/(0.05+kink->GetAngle(2)));
51ad6848 1800 if (kinkrow==nr){
1801 AliExternalTrackParam paramm(t);
1802 kink->SetMother(paramm);
eea478d3 1803 kink->SetStatus(2,1);
51ad6848 1804 kink->Update();
51ad6848 1805 }
1806 }
eea478d3 1807 }
51ad6848 1808 }
eea478d3 1809 //
d26d9159 1810 if (nr<fInnerSec->GetNRows())
1811 fSectors = fInnerSec;
1812 else
1813 fSectors = fOuterSec;
1814 FollowToNext(t,nr);
1c53abe2 1815 }
1816 return 1;
1817}
1818
1819
1820
1821
1822
1823Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
1824{
1825 //
1826 //
1827 sum1=0;
1828 sum2=0;
1829 Int_t sum=0;
1c53abe2 1830 //
1831 Float_t dz2 =(s1->GetZ() - s2->GetZ());
c9427e08 1832 dz2*=dz2;
91162307 1833
c9427e08 1834 Float_t dy2 =TMath::Abs((s1->GetY() - s2->GetY()));
1c53abe2 1835 dy2*=dy2;
1836 Float_t distance = TMath::Sqrt(dz2+dy2);
c9427e08 1837 if (distance>4.) return 0; // if there are far away - not overlap - to reduce combinatorics
1c53abe2 1838
91162307 1839 // Int_t offset =0;
c9427e08 1840 Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
1841 Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
c9427e08 1842 if (lastpoint>160)
1843 lastpoint =160;
1844 if (firstpoint<0)
1845 firstpoint = 0;
91162307 1846 if (firstpoint>lastpoint) {
1847 firstpoint =lastpoint;
1848 // lastpoint =160;
c9427e08 1849 }
1850
1851
91162307 1852 for (Int_t i=firstpoint-1;i<lastpoint+1;i++){
1853 if (s1->GetClusterIndex2(i)>0) sum1++;
1854 if (s2->GetClusterIndex2(i)>0) sum2++;
1855 if (s1->GetClusterIndex2(i)==s2->GetClusterIndex2(i) && s1->GetClusterIndex2(i)>0) {
1c53abe2 1856 sum++;
1857 }
1858 }
91162307 1859 if (sum<5) return 0;
1860
1627d1c4 1861 Float_t summin = TMath::Min(sum1+1,sum2+1);
1862 Float_t ratio = (sum+1)/Float_t(summin);
1c53abe2 1863 return ratio;
1864}
1865
1866void AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
1867{
1868 //
1869 //
91162307 1870 if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
1871 if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
1872
1c53abe2 1873 Float_t dz2 =(s1->GetZ() - s2->GetZ());
1874 dz2*=dz2;
1875 Float_t dy2 =(s1->GetY() - s2->GetY());
1876 dy2*=dy2;
91162307 1877 Float_t distance = dz2+dy2;
1878 if (distance>325.) return ; // if there are far away - not overlap - to reduce combinatorics
1879
1c53abe2 1880 //
91162307 1881 Int_t sumshared=0;
1882 //
1883 Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
1884 Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
1885 //
1886 if (firstpoint>=lastpoint-5) return;;
1c53abe2 1887
91162307 1888 for (Int_t i=firstpoint;i<lastpoint;i++){
1889 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1890 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1891 sumshared++;
1892 }
1893 }
1894 if (sumshared>4){
1895 // sign clusters
1896 //
1897 for (Int_t i=firstpoint;i<lastpoint;i++){
1898 // if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
1899 if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
1900 AliTPCTrackerPoint *p1 = s1->GetTrackPoint(i);
1901 AliTPCTrackerPoint *p2 = s2->GetTrackPoint(i);;
1902 if (s1->IsActive()&&s2->IsActive()){
1903 p1->fIsShared = kTRUE;
1904 p2->fIsShared = kTRUE;
1905 }
1906 }
1907 }
1908 }
1909 //
1910 if (sumshared>10){
1911 for (Int_t i=0;i<4;i++){
1912 if (s1->fOverlapLabels[3*i]==0){
1913 s1->fOverlapLabels[3*i] = s2->GetLabel();
1914 s1->fOverlapLabels[3*i+1] = sumshared;
1915 s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
1916 break;
1917 }
1918 }
1919 for (Int_t i=0;i<4;i++){
1920 if (s2->fOverlapLabels[3*i]==0){
1921 s2->fOverlapLabels[3*i] = s1->GetLabel();
1922 s2->fOverlapLabels[3*i+1] = sumshared;
1923 s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
1924 break;
1925 }
1926 }
1927 }
1c53abe2 1928
91162307 1929}
1c53abe2 1930
91162307 1931void AliTPCtrackerMI::SignShared(TObjArray * arr)
1932{
1c53abe2 1933 //
91162307 1934 //sort trackss according sectors
1935 //
c9427e08 1936 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1937 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 1938 if (!pt) continue;
1939 //if (pt) RotateToLocal(pt);
1940 pt->fSort = 0;
c9427e08 1941 }
91162307 1942 arr->UnSort();
1c53abe2 1943 arr->Sort(); // sorting according z
1944 arr->Expand(arr->GetEntries());
91162307 1945 //
1946 //
1c53abe2 1947 Int_t nseed=arr->GetEntriesFast();
1c53abe2 1948 for (Int_t i=0; i<nseed; i++) {
1949 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 1950 if (!pt) continue;
1951 for (Int_t j=0;j<=12;j++){
1952 pt->fOverlapLabels[j] =0;
1c53abe2 1953 }
91162307 1954 }
1955 for (Int_t i=0; i<nseed; i++) {
1956 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1957 if (!pt) continue;
1958 if (pt->fRemoval>10) continue;
1c53abe2 1959 for (Int_t j=i+1; j<nseed; j++){
1960 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
91162307 1961 // if (pt2){
1962 if (pt2->fRemoval<=10) {
1963 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
1964 SignShared(pt,pt2);
c9427e08 1965 }
91162307 1966 }
1967 }
1968}
1969
1970void AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
1971{
1972 //
1973 //sort trackss according sectors
1974 //
1975 if (fDebug&1) {
6bdc18d6 1976 Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
91162307 1977 }
1978 //
1979 for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
1980 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1981 if (!pt) continue;
1982 pt->fSort = 0;
1983 }
1984 arr->UnSort();
1985 arr->Sort(); // sorting according z
1986 arr->Expand(arr->GetEntries());
1987 //
1988 //reset overlap labels
1989 //
1990 Int_t nseed=arr->GetEntriesFast();
1991 for (Int_t i=0; i<nseed; i++) {
1992 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
1993 if (!pt) continue;
1994 pt->SetUniqueID(i);
1995 for (Int_t j=0;j<=12;j++){
1996 pt->fOverlapLabels[j] =0;
1c53abe2 1997 }
1998 }
91162307 1999 //
2000 //sign shared tracks
1c53abe2 2001 for (Int_t i=0; i<nseed; i++) {
2002 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
91162307 2003 if (!pt) continue;
2004 if (pt->fRemoval>10) continue;
2005 Float_t deltac = pt->GetC()*0.1;
2006 for (Int_t j=i+1; j<nseed; j++){
2007 AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
2008 // if (pt2){
2009 if (pt2->fRemoval<=10) {
2010 if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
2011 if (TMath::Abs(pt->GetC() -pt2->GetC())>deltac) continue;
2012 if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
2013 //
2014 SignShared(pt,pt2);
2015 }
1c53abe2 2016 }
1c53abe2 2017 }
91162307 2018 //
2019 // remove highly shared tracks
2020 for (Int_t i=0; i<nseed; i++) {
2021 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2022 if (!pt) continue;
2023 if (pt->fRemoval>10) continue;
2024 //
2025 Int_t sumshared =0;
2026 for (Int_t j=0;j<4;j++){
2027 sumshared = pt->fOverlapLabels[j*3+1];
2028 }
2029 Float_t factor = factor1;
2030 if (pt->fRemoval>0) factor = factor2;
2031 if (sumshared/pt->GetNumberOfClusters()>factor){
2032 for (Int_t j=0;j<4;j++){
2033 if (pt->fOverlapLabels[3*j]==0) continue;
2034 if (pt->fOverlapLabels[3*j+1]<5) continue;
2035 if (pt->fRemoval==removalindex) continue;
2036 AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
2037 if (!pt2) continue;
2038 if (pt2->GetSigma2C()<pt->GetSigma2C()){
2039 // pt->fRemoval = removalindex;
2040 delete arr->RemoveAt(i);
2041 break;
1c53abe2 2042 }
91162307 2043 }
1c53abe2 2044 }
91162307 2045 }
2046 arr->Compress();
2047 if (fDebug&1) {
6bdc18d6 2048 Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
91162307 2049 }
2050}
2051
2052
2053
1c53abe2 2054
2055
91162307 2056
47966a6d 2057void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
91162307 2058{
2059 //
2060 //sort tracks in array according mode criteria
2061 Int_t nseed = arr->GetEntriesFast();
2062 for (Int_t i=0; i<nseed; i++) {
2063 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2064 if (!pt) {
2065 continue;
2066 }
2067 pt->fSort = mode;
2068 }
2069 arr->UnSort();
2070 arr->Sort();
1c53abe2 2071}
c9427e08 2072
91162307 2073void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t removalindex)
c9427e08 2074{
2075
2076 //Loop over all tracks and remove "overlaps"
2077 //
2078 //
2079 Int_t nseed = arr->GetEntriesFast();
2080 Int_t good =0;
91162307 2081
c9427e08 2082 for (Int_t i=0; i<nseed; i++) {
2083 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2084 if (!pt) {
91162307 2085 delete arr->RemoveAt(i);
c9427e08 2086 }
91162307 2087 else{
2088 pt->fSort =1;
2089 pt->fBSigned = kFALSE;
c9427e08 2090 }
91162307 2091 }
2092 arr->Compress();
2093 nseed = arr->GetEntriesFast();
2094 arr->UnSort();
2095 arr->Sort();
2096 //
2097 //unsign used
2098 UnsignClusters();
2099 //
2100 for (Int_t i=0; i<nseed; i++) {
2101 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2102 if (!pt) {
2103 continue;
2104 }
2105 Int_t found,foundable,shared;
2106 if (pt->IsActive())
2107 pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
2108 else
2109 pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE);
2110 //
2111 Double_t factor = factor2;
2112 if (pt->fBConstrain) factor = factor1;
2113
2114 if ((Float_t(shared)/Float_t(found))>factor){
c9427e08 2115 pt->Desactivate(removalindex);
91162307 2116 continue;
2117 }
2118
2119 good++;
2120 for (Int_t i=0; i<160; i++) {
2121 Int_t index=pt->GetClusterIndex2(i);
2122 if (index<0 || index&0x8000 ) continue;
2123 AliTPCclusterMI *c= pt->fClusterPointer[i];
2124 if (!c) continue;
2125 // if (!c->IsUsed(10)) c->Use(10);
2126 //if (pt->IsActive())
2127 c->Use(10);
2128 //else
2129 // c->Use(5);
c9427e08 2130 }
91162307 2131
c9427e08 2132 }
2133 fNtracks = good;
6bdc18d6 2134 if (fDebug>0){
2135 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2136 }
c9427e08 2137}
2138
51ad6848 2139
2140void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal)
2141{
2142
2143 //Loop over all tracks and remove "overlaps"
2144 //
2145 //
2146 UnsignClusters();
2147 //
2148 Int_t nseed = arr->GetEntriesFast();
2149 Float_t * quality = new Float_t[nseed];
2150 Int_t * indexes = new Int_t[nseed];
2151 Int_t good =0;
2152 //
2153 //
2154 for (Int_t i=0; i<nseed; i++) {
2155 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2156 if (!pt){
2157 quality[i]=-1;
2158 continue;
2159 }
2160 pt->UpdatePoints(); //select first last max dens points
2161 Float_t * points = pt->GetPoints();
2162 if (points[3]<0.8) quality[i] =-1;
2163 //
2164 quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
2165 }
2166 TMath::Sort(nseed,quality,indexes);
2167 //
2168 //
2169 for (Int_t itrack=0; itrack<nseed; itrack++) {
2170 Int_t trackindex = indexes[itrack];
2171 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);
2172 if (quality[trackindex]<0){
2173 if (pt) {
2174 delete arr->RemoveAt(trackindex);
2175 }
2176 else{
2177 arr->RemoveAt(trackindex);
2178 }
2179 continue;
2180 }
2181 //
2182 Int_t first = Int_t(pt->GetPoints()[0]);
2183 Int_t last = Int_t(pt->GetPoints()[2]);
2184 Double_t factor = (pt->fBConstrain) ? factor1: factor2;
2185 //
2186 Int_t found,foundable,shared;
2187 pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
eea478d3 2188 Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
51ad6848 2189 //
eea478d3 2190 if (Float_t(shared+1)/Float_t(found+1)>factor){
51ad6848 2191 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2192 delete arr->RemoveAt(trackindex);
2193 continue;
2194 }
2195
2196 if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){ //remove short tracks
2197 if (pt->GetKinkIndexes()[0]!=0) continue; //don't remove tracks - part of the kinks
2198 delete arr->RemoveAt(trackindex);
2199 continue;
2200 }
2201
2202 good++;
2203 if (sharedfactor>0.4) continue;
2204 for (Int_t i=first; i<last; i++) {
2205 Int_t index=pt->GetClusterIndex2(i);
2206 // if (index<0 || index&0x8000 ) continue;
2207 if (index<0 || index&0x8000 ) continue;
2208 AliTPCclusterMI *c= pt->fClusterPointer[i];
2209 if (!c) continue;
2210 c->Use(10);
2211 }
2212 }
2213 fNtracks = good;
2214 if (fDebug>0){
2215 Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
2216 }
2217 delete []quality;
2218 delete []indexes;
2219}
2220
91162307 2221void AliTPCtrackerMI::UnsignClusters()
1c53abe2 2222{
91162307 2223 //
2224 // loop over all clusters and unsign them
2225 //
2226
2227 for (Int_t sec=0;sec<fkNIS;sec++){
2228 for (Int_t row=0;row<fInnerSec->GetNRows();row++){
2229 AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
2230 for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
2231 // if (cl[icl].IsUsed(10))
2232 cl[icl].Use(-1);
2233 cl = fInnerSec[sec][row].fClusters2;
2234 for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
2235 //if (cl[icl].IsUsed(10))
2236 cl[icl].Use(-1);
2237 }
2238 }
2239
2240 for (Int_t sec=0;sec<fkNOS;sec++){
2241 for (Int_t row=0;row<fOuterSec->GetNRows();row++){
2242 AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
2243 for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
2244 //if (cl[icl].IsUsed(10))
2245 cl[icl].Use(-1);
2246 cl = fOuterSec[sec][row].fClusters2;
2247 for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
2248 //if (cl[icl].IsUsed(10))
2249 cl[icl].Use(-1);
2250 }
2251 }
2252
1c53abe2 2253}
2254
91162307 2255
2256
732b9e78 2257void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fdensity)
1c53abe2 2258{
2259 //
91162307 2260 //sign clusters to be "used"
2261 //
2262 // snumber and sdensity sign number of sigmas - bellow mean value to be accepted
2263 // loop over "primaries"
2264
2265 Float_t sumdens=0;
2266 Float_t sumdens2=0;
2267 Float_t sumn =0;
2268 Float_t sumn2 =0;
2269 Float_t sumchi =0;
2270 Float_t sumchi2 =0;
2271
2272 Float_t sum =0;
2273
1c53abe2 2274 TStopwatch timer;
91162307 2275 timer.Start();
1c53abe2 2276
91162307 2277 Int_t nseed = arr->GetEntriesFast();
2278 for (Int_t i=0; i<nseed; i++) {
2279 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2280 if (!pt) {
2281 continue;
2282 }
2283 if (!(pt->IsActive())) continue;
2284 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2285 if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
2286 sumdens += dens;
2287 sumdens2+= dens*dens;
2288 sumn += pt->GetNumberOfClusters();
2289 sumn2 += pt->GetNumberOfClusters()*pt->GetNumberOfClusters();
2290 Float_t chi2 = pt->GetChi2()/pt->GetNumberOfClusters();
2291 if (chi2>5) chi2=5;
2292 sumchi +=chi2;
2293 sumchi2 +=chi2*chi2;
2294 sum++;
2295 }
1627d1c4 2296 }
91162307 2297
2298 Float_t mdensity = 0.9;
2299 Float_t meann = 130;
2300 Float_t meanchi = 1;
2301 Float_t sdensity = 0.1;
2302 Float_t smeann = 10;
2303 Float_t smeanchi =0.4;
1627d1c4 2304
91162307 2305
2306 if (sum>20){
2307 mdensity = sumdens/sum;
2308 meann = sumn/sum;
2309 meanchi = sumchi/sum;
2310 //
2311 sdensity = sumdens2/sum-mdensity*mdensity;
2312 sdensity = TMath::Sqrt(sdensity);
2313 //
2314 smeann = sumn2/sum-meann*meann;
2315 smeann = TMath::Sqrt(smeann);
2316 //
2317 smeanchi = sumchi2/sum - meanchi*meanchi;
2318 smeanchi = TMath::Sqrt(smeanchi);
2319 }
2320
2321
2322 //REMOVE SHORT DELTAS or tracks going out of sensitive volume of TPC
2323 //
2324 for (Int_t i=0; i<nseed; i++) {
2325 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2326 if (!pt) {
2327 continue;
1c53abe2 2328 }
91162307 2329 if (pt->fBSigned) continue;
2330 if (pt->fBConstrain) continue;
2331 //if (!(pt->IsActive())) continue;
2332 /*
2333 Int_t found,foundable,shared;
2334 pt->GetClusterStatistic(0,160,found, foundable,shared);
2335 if (shared/float(found)>0.3) {
2336 if (shared/float(found)>0.9 ){
2337 //delete arr->RemoveAt(i);
2338 }
2339 continue;
c9427e08 2340 }
91162307 2341 */
2342 Bool_t isok =kFALSE;
2343 if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
2344 isok = kTRUE;
2345 if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
2346 isok =kTRUE;
2347 if (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
2348 isok =kTRUE;
2349 if ( (TMath::Abs(pt->GetSnp()>0.7) && pt->GetD(0,0)>60.))
2350 isok =kTRUE;
2351
2352 if (isok)
2353 for (Int_t i=0; i<160; i++) {
2354 Int_t index=pt->GetClusterIndex2(i);
2355 if (index<0) continue;
2356 AliTPCclusterMI *c= pt->fClusterPointer[i];
2357 if (!c) continue;
2358 //if (!(c->IsUsed(10))) c->Use();
2359 c->Use(10);
2360 }
2361 }
2362
c9427e08 2363
1c53abe2 2364 //
91162307 2365 Double_t maxchi = meanchi+2.*smeanchi;
2366
2367 for (Int_t i=0; i<nseed; i++) {
2368 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2369 if (!pt) {
1c53abe2 2370 continue;
91162307 2371 }
2372 //if (!(pt->IsActive())) continue;
2373 if (pt->fBSigned) continue;
2374 Double_t chi = pt->GetChi2()/pt->GetNumberOfClusters();
2375 if (chi>maxchi) continue;
2376
2377 Float_t bfactor=1;
2378 Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
2379
2380 //sign only tracks with enoug big density at the beginning
2381
2382 if ((pt->GetDensityFirst(40)<0.75) && pt->GetNumberOfClusters()<meann) continue;
2383
2384
3e5d0aa2 2385 Double_t mindens = TMath::Max(double(mdensity-sdensity*fdensity*bfactor),0.65);
91162307 2386 Double_t minn = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
2387
2388 // if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
2389 if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
2390 minn=0;
2391
2392 if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
2393 //Int_t noc=pt->GetNumberOfClusters();
2394 pt->fBSigned = kTRUE;
2395 for (Int_t i=0; i<160; i++) {
2396
2397 Int_t index=pt->GetClusterIndex2(i);
2398 if (index<0) continue;
2399 AliTPCclusterMI *c= pt->fClusterPointer[i];
2400 if (!c) continue;
2401 // if (!(c->IsUsed(10))) c->Use();
2402 c->Use(10);
2403 }
1c53abe2 2404 }
91162307 2405 }
2406 // gLastCheck = nseed;
2407 // arr->Compress();
2408 if (fDebug>0){
2409 timer.Print();
2410 }
1c53abe2 2411}
2412
2413
47966a6d 2414void AliTPCtrackerMI::StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
91162307 2415{
2416 // stop not active tracks
2417 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2418 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2419 Int_t nseed = arr->GetEntriesFast();
2420 //
2421 for (Int_t i=0; i<nseed; i++) {
2422 AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);
2423 if (!pt) {
2424 continue;
2425 }
2426 if (!(pt->IsActive())) continue;
2427 StopNotActive(pt,row0,th0, th1,th2);
2428 }
2429}
1c53abe2 2430
1c53abe2 2431
1c53abe2 2432
91162307 2433void AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
47966a6d 2434 Float_t th2) const
91162307 2435{
2436 // stop not active tracks
2437 // take th1 as threshold for number of founded to number of foundable on last 10 active rows
2438 // take th2 as threshold for number of founded to number of foundable on last 20 active rows
2439 Int_t sumgood1 = 0;
2440 Int_t sumgood2 = 0;
2441 Int_t foundable = 0;
2442 Int_t maxindex = seed->fLastPoint; //last foundable row
2443 if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
2444 seed->Desactivate(10) ;
2445 return;
2446 }
1c53abe2 2447
3e5d0aa2 2448 for (Int_t i=row0; i<maxindex; i++){
91162307 2449 Int_t index = seed->GetClusterIndex2(i);
2450 if (index!=-1) foundable++;
2451 //if (!c) continue;
2452 if (foundable<=30) sumgood1++;
2453 if (foundable<=50) {
2454 sumgood2++;
2455 }
2456 else{
2457 break;
2458 }
2459 }
2460 if (foundable>=30.){
2461 if (sumgood1<(th1*30.)) seed->Desactivate(10);
2462 }
2463 if (foundable>=50)
2464 if (sumgood2<(th2*50.)) seed->Desactivate(10);
2465}
1c53abe2 2466
1c53abe2 2467
d26d9159 2468Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
2469{
2470 //
2471 // back propagation of ESD tracks
2472 //
2473 //return 0;
2474 fEvent = event;
2475 ReadSeeds(event,2);
2476 fIteration=2;
982aff31 2477 //PrepareForProlongation(fSeeds,1);
2478 PropagateForward2(fSeeds);
af32720d 2479
4d158c36 2480 Int_t ntracks=0;
d26d9159 2481 Int_t nseed = fSeeds->GetEntriesFast();
2482 for (Int_t i=0;i<nseed;i++){
2483 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
4d158c36 2484 if (!seed) continue;
eea478d3 2485 if (seed->GetKinkIndex(0)>0) UpdateKinkQualityD(seed); // update quality informations for kinks
2486
d26d9159 2487 seed->PropagateTo(fParam->GetInnerRadiusLow());
51ad6848 2488 seed->UpdatePoints();
d26d9159 2489 AliESDtrack *esd=event->GetTrack(i);
2490 seed->CookdEdx(0.02,0.6);
2491 CookLabel(seed,0.1); //For comparison only
af32720d 2492 //
2493 if (0 && seed!=0&&esd!=0) {
2494 TTreeSRedirector &cstream = *fDebugStreamer;
2495 cstream<<"Crefit"<<
2496 "Esd.="<<esd<<
2497 "Track.="<<seed<<
2498 "\n";
2499 }
51ad6848 2500 if (seed->GetNumberOfClusters()>15){
4d158c36 2501 esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit);
51ad6848 2502 esd->SetTPCPoints(seed->GetPoints());
4d158c36 2503 ntracks++;
d26d9159 2504 }
2505 else{
2506 //printf("problem\n");
2507 }
2508 }
51ad6848 2509 //FindKinks(fSeeds,event);
4d158c36 2510 Info("RefitInward","Number of refitted tracks %d",ntracks);
d26d9159 2511 fEvent =0;
2512 //WriteTracks();
2513 return 0;
2514}
2515
1c53abe2 2516
91162307 2517Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
2518{
2519 //
2520 // back propagation of ESD tracks
2521 //
1c53abe2 2522
91162307 2523 fEvent = event;
d26d9159 2524 fIteration = 1;
2525 ReadSeeds(event,0);
91162307 2526 PropagateBack(fSeeds);
2527 Int_t nseed = fSeeds->GetEntriesFast();
4d158c36 2528 Int_t ntracks=0;
91162307 2529 for (Int_t i=0;i<nseed;i++){
2530 AliTPCseed * seed = (AliTPCseed*) fSeeds->UncheckedAt(i);
d9e62e7e 2531 if (!seed) continue;
51ad6848 2532 if (seed->GetKinkIndex(0)<0) UpdateKinkQualityM(seed); // update quality informations for kinks
2533 seed->UpdatePoints();
91162307 2534 AliESDtrack *esd=event->GetTrack(i);
d26d9159 2535 seed->CookdEdx(0.02,0.6);
91162307 2536 CookLabel(seed,0.1); //For comparison only
51ad6848 2537 if (seed->GetNumberOfClusters()>15){
4d158c36 2538 esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
51ad6848 2539 esd->SetTPCPoints(seed->GetPoints());
4d158c36 2540 ntracks++;
2541 }
91162307 2542 }
51ad6848 2543 //FindKinks(fSeeds,event);
4d158c36 2544 Info("PropagateBack","Number of back propagated tracks %d",ntracks);
91162307 2545 fEvent =0;
d26d9159 2546 //WriteTracks();
91162307 2547 return 0;
2548}
2549
2550
2551void AliTPCtrackerMI::DeleteSeeds()
2552{
b67e07dc 2553 //
2554 //delete Seeds
91162307 2555 Int_t nseed = fSeeds->GetEntriesFast();
2556 for (Int_t i=0;i<nseed;i++){
2557 AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
2558 if (seed) delete fSeeds->RemoveAt(i);
2559 }
2560 delete fSeeds;
2561 fSeeds =0;
2562}
2563
d26d9159 2564void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
91162307 2565{
2566 //
2567 //read seeds from the event
2568
2569 Int_t nentr=event->GetNumberOfTracks();
6bdc18d6 2570 if (fDebug>0){
2571 Info("ReadSeeds", "Number of ESD tracks: %d\n", nentr);
2572 }
91162307 2573 if (fSeeds)
2574 DeleteSeeds();
2575 if (!fSeeds){
4d158c36 2576 fSeeds = new TObjArray(nentr);
91162307 2577 }
4d158c36 2578 UnsignClusters();
2579 // Int_t ntrk=0;
91162307 2580 for (Int_t i=0; i<nentr; i++) {
2581 AliESDtrack *esd=event->GetTrack(i);
51ad6848 2582 ULong_t status=esd->GetStatus();
2583 if (!(status&AliESDtrack::kTPCin)) continue;
b67e07dc 2584 AliTPCtrack t(*esd);
eea478d3 2585 // AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
2586 AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
2587 for (Int_t ikink=0;ikink<3;ikink++) {
2588 Int_t index = esd->GetKinkIndex(ikink);
2589 seed->GetKinkIndexes()[ikink] = index;
2590 if (index==0) continue;
2591 index = TMath::Abs(index);
2592 AliESDkink * kink = fEvent->GetKink(index-1);
2593 if (kink&&esd->GetKinkIndex(ikink)<0){
2594 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,2);
2595 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,0);
2596 }
2597 if (kink&&esd->GetKinkIndex(ikink)>0){
2598 if ((status & AliESDtrack::kTRDrefit) != 0) kink->SetStatus(1,6);
2599 if ((status & AliESDtrack::kITSout) != 0) kink->SetStatus(1,4);
2600 }
2601
2602 }
982aff31 2603 if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance();
2604 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
4d158c36 2605 if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
2606 fSeeds->AddAt(0,i);
2607 delete seed;
2608 continue;
2609 }
2610 if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 ) {
c0b978f0 2611 Double_t par0[5],par1[5],alpha,x;
2612 esd->GetInnerExternalParameters(alpha,x,par0);
4d158c36 2613 esd->GetExternalParameters(x,par1);
2614 Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
2615 Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
51ad6848 2616 Double_t trdchi2=0;
2617 if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
4d158c36 2618 //reset covariance if suspicious
51ad6848 2619 if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
4d158c36 2620 seed->ResetCovariance();
2621 }
982aff31 2622
91162307 2623 //
2624 //
2625 // rotate to the local coordinate system
eea478d3 2626 //
2627 fSectors=fInnerSec; fN=fkNIS;
91162307 2628 Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
2629 if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
2630 if (alpha < 0. ) alpha += 2.*TMath::Pi();
2631 Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
2632 alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
4d158c36 2633 if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
2634 if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
91162307 2635 alpha-=seed->GetAlpha();
d9b8978b 2636 if (!seed->Rotate(alpha)) {
2637 delete seed;
2638 continue;
2639 }
d26d9159 2640 seed->fEsd = esd;
4d158c36 2641 // sign clusters
2642 for (Int_t irow=0;irow<160;irow++){
2643 Int_t index = seed->GetClusterIndex2(irow);
2644 if (index>0){
2645 //
2646 AliTPCclusterMI * cl = GetClusterMI(index);
2647 seed->fClusterPointer[irow] = cl;
2648 if (cl){
2649 if ((index & 0x8000)==0){
2650 cl->Use(10); // accepted cluster
2651 }else{
2652 cl->Use(6); // close cluster not accepted
2653 }
2654 }else{
2655 Info("ReadSeeds","Not found cluster");
2656 }
2657 }
2658 }
2659 fSeeds->AddAt(seed,i);
91162307 2660 }
2661}
2662
2663
2664
2665//_____________________________________________________________________________
2666void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2667 Float_t deltay, Int_t ddsec) {
2668 //-----------------------------------------------------------------
2669 // This function creates track seeds.
2670 // SEEDING WITH VERTEX CONSTRAIN
2671 //-----------------------------------------------------------------
2672 // cuts[0] - fP4 cut
2673 // cuts[1] - tan(phi) cut
2674 // cuts[2] - zvertex cut
2675 // cuts[3] - fP3 cut
2676 Int_t nin0 = 0;
2677 Int_t nin1 = 0;
2678 Int_t nin2 = 0;
2679 Int_t nin = 0;
2680 Int_t nout1 = 0;
2681 Int_t nout2 = 0;
2682
2683 Double_t x[5], c[15];
2684 // Int_t di = i1-i2;
2685 //
2686 AliTPCseed * seed = new AliTPCseed;
2687 Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
2688 Double_t cs=cos(alpha), sn=sin(alpha);
2689 //
2690 // Double_t x1 =fOuterSec->GetX(i1);
2691 //Double_t xx2=fOuterSec->GetX(i2);
2692
2693 Double_t x1 =GetXrow(i1);
2694 Double_t xx2=GetXrow(i2);
2695
2696 Double_t x3=GetX(), y3=GetY(), z3=GetZ();
2697
2698 Int_t imiddle = (i2+i1)/2; //middle pad row index
2699 Double_t xm = GetXrow(imiddle); // radius of middle pad-row
2700 const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
2701 //
2702 Int_t ns =sec;
2703
2704 const AliTPCRow& kr1=GetRow(ns,i1);
2705 Double_t ymax = GetMaxY(i1)-kr1.fDeadZone-1.5;
2706 Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;
2707
2708 //
2709 // change cut on curvature if it can't reach this layer
2710 // maximal curvature set to reach it
2711 Double_t dvertexmax = TMath::Sqrt((x1-x3)*(x1-x3)+(ymax+5-y3)*(ymax+5-y3));
2712 if (dvertexmax*0.5*cuts[0]>0.85){
2713 cuts[0] = 0.85/(dvertexmax*0.5+1.);
2714 }
2715 Double_t r2min = 1/(cuts[0]*cuts[0]); //minimal square of radius given by cut
2716
2717 // Int_t ddsec = 1;
2718 if (deltay>0) ddsec = 0;
2719 // loop over clusters
2720 for (Int_t is=0; is < kr1; is++) {
2721 //
2722 if (kr1[is]->IsUsed(10)) continue;
2723 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
2724 //if (TMath::Abs(y1)>ymax) continue;
2725
2726 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
2727
2728 // find possible directions
2729 Float_t anglez = (z1-z3)/(x1-x3);
2730 Float_t extraz = z1 - anglez*(x1-xx2); // extrapolated z
2731 //
2732 //
2733 //find rotation angles relative to line given by vertex and point 1
2734 Double_t dvertex2 = (x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
2735 Double_t dvertex = TMath::Sqrt(dvertex2);
2736 Double_t angle13 = TMath::ATan((y1-y3)/(x1-x3));
2737 Double_t cs13 = cos(-angle13), sn13 = sin(-angle13);
2738
2739 //
2740 // loop over 2 sectors
2741 Int_t dsec1=-ddsec;
2742 Int_t dsec2= ddsec;
2743 if (y1<0) dsec2= 0;
2744 if (y1>0) dsec1= 0;
2745
2746 Double_t dddz1=0; // direction of delta inclination in z axis
2747 Double_t dddz2=0;
2748 if ( (z1-z3)>0)
2749 dddz1 =1;
2750 else
2751 dddz2 =1;
2752 //
2753 for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
2754 Int_t sec2 = sec + dsec;
2755 //
2756 // AliTPCRow& kr2 = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
2757 //AliTPCRow& kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
2758 AliTPCRow& kr2 = GetRow((sec2+fkNOS)%fkNOS,i2);
2759 AliTPCRow& kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
2760 Int_t index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
2761 Int_t index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
2762
2763 // rotation angles to p1-p3
2764 Double_t cs13r = cos(-angle13+dsec*alpha)/dvertex, sn13r = sin(-angle13+dsec*alpha)/dvertex;
2765 Double_t x2, y2, z2;
2766 //
2767 // Double_t dymax = maxangle*TMath::Abs(x1-xx2);
2768
2769 //
2770 Double_t dxx0 = (xx2-x3)*cs13r;
2771 Double_t dyy0 = (xx2-x3)*sn13r;
2772 for (Int_t js=index1; js < index2; js++) {
2773 const AliTPCclusterMI *kcl = kr2[js];
2774 if (kcl->IsUsed(10)) continue;
2775 //
2776 //calcutate parameters
2777 //
2778 Double_t yy0 = dyy0 +(kcl->GetY()-y3)*cs13r;
2779 // stright track
2780 if (TMath::Abs(yy0)<0.000001) continue;
2781 Double_t xx0 = dxx0 -(kcl->GetY()-y3)*sn13r;
2782 Double_t y0 = 0.5*(xx0*xx0+yy0*yy0-xx0)/yy0;
2783 Double_t r02 = (0.25+y0*y0)*dvertex2;
2784 //curvature (radius) cut
2785 if (r02<r2min) continue;
2786
2787 nin0++;
2788 //
2789 Double_t c0 = 1/TMath::Sqrt(r02);
2790 if (yy0>0) c0*=-1.;
2791
2792
2793 //Double_t dfi0 = 2.*TMath::ASin(dvertex*c0*0.5);
2794 //Double_t dfi1 = 2.*TMath::ASin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
b67e07dc 2795 Double_t dfi0 = 2.*AliTPCFastMath::FastAsin(dvertex*c0*0.5);
2796 Double_t dfi1 = 2.*AliTPCFastMath::FastAsin(TMath::Sqrt(yy0*yy0+(1-xx0)*(1-xx0))*dvertex*c0*0.5);
91162307 2797 //
2798 //
2799 Double_t z0 = kcl->GetZ();
2800 Double_t zzzz2 = z1-(z1-z3)*dfi1/dfi0;
2801 if (TMath::Abs(zzzz2-z0)>0.5) continue;
2802 nin1++;
2803 //
2804 Double_t dip = (z1-z0)*c0/dfi1;
2805 Double_t x0 = (0.5*cs13+y0*sn13)*dvertex*c0;
2806 //
2807 y2 = kcl->GetY();
2808 if (dsec==0){
2809 x2 = xx2;
2810 z2 = kcl->GetZ();
2811 }
2812 else
2813 {
2814 // rotation
2815 z2 = kcl->GetZ();
2816 x2= xx2*cs-y2*sn*dsec;
2817 y2=+xx2*sn*dsec+y2*cs;
2818 }
2819
2820 x[0] = y1;
2821 x[1] = z1;
2822 x[2] = x0;
2823 x[3] = dip;
2824 x[4] = c0;
2825 //
2826 //
2827 // do we have cluster at the middle ?
2828 Double_t ym,zm;
2829 GetProlongation(x1,xm,x,ym,zm);
2830 UInt_t dummy;
2831 AliTPCclusterMI * cm=0;
2832 if (TMath::Abs(ym)-ymaxm<0){
2833 cm = krm.FindNearest2(ym,zm,1.0,0.6,dummy);
2834 if ((!cm) || (cm->IsUsed(10))) {
2835 continue;
2836 }
2837 }
2838 else{
2839 // rotate y1 to system 0
2840 // get state vector in rotated system
2841 Double_t yr1 = (-0.5*sn13+y0*cs13)*dvertex*c0;
2842 Double_t xr2 = x0*cs+yr1*sn*dsec;
2843 Double_t xr[5]={kcl->GetY(),kcl->GetZ(), xr2, dip, c0};
2844 //
2845 GetProlongation(xx2,xm,xr,ym,zm);
2846 if (TMath::Abs(ym)-ymaxm<0){
2847 cm = kr2m.FindNearest2(ym,zm,1.0,0.6,dummy);
2848 if ((!cm) || (cm->IsUsed(10))) {
2849 continue;
2850 }
2851 }
2852 }
2853
2854
2855 Double_t dym = 0;
2856 Double_t dzm = 0;
2857 if (cm){
2858 dym = ym - cm->GetY();
2859 dzm = zm - cm->GetZ();
2860 }
2861 nin2++;
2862
2863
2864 //
2865 //
2866 Double_t sy1=kr1[is]->GetSigmaY2()*2., sz1=kr1[is]->GetSigmaZ2()*2.;
2867 Double_t sy2=kcl->GetSigmaY2()*2., sz2=kcl->GetSigmaZ2()*2.;
2868 //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
2869 Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
2870 //Double_t sy3=25000*x[4]*x[4]*60+0.5, sy=0.1, sz=0.1;
2871
b67e07dc 2872 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
2873 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
2874 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
2875 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
2876 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
2877 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 2878
b67e07dc 2879 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
2880 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
2881 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
2882 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
91162307 2883
1c53abe2 2884 c[0]=sy1;
2885 c[1]=0.; c[2]=sz1;
2886 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
2887 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
2888 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
2889 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
2890 c[13]=f30*sy1*f40+f32*sy2*f42;
2891 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
91162307 2892
2893 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
2894
1c53abe2 2895 UInt_t index=kr1.GetIndex(is);
91162307 2896 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
2897
1c53abe2 2898 track->fIsSeeding = kTRUE;
91162307 2899 track->fSeed1 = i1;
2900 track->fSeed2 = i2;
2901 track->fSeedType=3;
c9427e08 2902
91162307 2903
2904 //if (dsec==0) {
2905 FollowProlongation(*track, (i1+i2)/2,1);
2906 Int_t foundable,found,shared;
2907 track->GetClusterStatistic((i1+i2)/2,i1, found, foundable, shared, kTRUE);
2908 if ((found<0.55*foundable) || shared>0.5*found || (track->GetSigmaY2()+track->GetSigmaZ2())>0.5){
2909 seed->Reset();
2910 seed->~AliTPCseed();
2911 continue;
2912 }
2913 //}
2914
2915 nin++;
2916 FollowProlongation(*track, i2,1);
2917
2918
2919 //Int_t rc = 1;
2920 track->fBConstrain =1;
2921 // track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
2922 track->fLastPoint = i1; // first cluster in track position
2923 track->fFirstPoint = track->fLastPoint;
2924
2925 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
2926 track->GetNumberOfClusters() < track->fNFoundable*0.6 ||
2927 track->fNShared>0.4*track->GetNumberOfClusters() ) {
2928 seed->Reset();
2929 seed->~AliTPCseed();
c9427e08 2930 continue;
2931 }
91162307 2932 nout1++;
2933 // Z VERTEX CONDITION
2934 Double_t zv;
2935 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2936 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2937 if (TMath::Abs(zv-z3)>cuts[2]) {
2938 FollowProlongation(*track, TMath::Max(i2-20,0));
2939 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2940 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2941 if (TMath::Abs(zv-z3)>cuts[2]){
2942 FollowProlongation(*track, TMath::Max(i2-40,0));
2943 zv = track->GetZ()+track->GetTgl()/track->GetC()*
2944 ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
2945 if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
2946 // make seed without constrain
2947 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
2948 FollowProlongation(*track2, i2,1);
2949 track2->fBConstrain = kFALSE;
2950 track2->fSeedType = 1;
2951 arr->AddLast(track2);
2952 seed->Reset();
2953 seed->~AliTPCseed();
2954 continue;
2955 }
2956 else{
2957 seed->Reset();
2958 seed->~AliTPCseed();
2959 continue;
2960
2961 }
2962 }
c9427e08 2963 }
1c53abe2 2964
91162307 2965 track->fSeedType =0;
2966 arr->AddLast(track);
2967 seed = new AliTPCseed;
2968 nout2++;
2969 // don't consider other combinations
2970 if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
2971 break;
1c53abe2 2972 }
2973 }
2974 }
6bdc18d6 2975 if (fDebug>3){
2976 Info("MakeSeeds3","\nSeeding statistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2);
91162307 2977 }
2978 delete seed;
1c53abe2 2979}
2980
1627d1c4 2981
91162307 2982void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4],
2983 Float_t deltay) {
2984
2985
2986
1627d1c4 2987 //-----------------------------------------------------------------
91162307 2988 // This function creates track seeds.
1627d1c4 2989 //-----------------------------------------------------------------
91162307 2990 // cuts[0] - fP4 cut
2991 // cuts[1] - tan(phi) cut
2992 // cuts[2] - zvertex cut
2993 // cuts[3] - fP3 cut
2994
2995
2996 Int_t nin0 = 0;
2997 Int_t nin1 = 0;
2998 Int_t nin2 = 0;
2999 Int_t nin = 0;
3000 Int_t nout1 = 0;
3001 Int_t nout2 = 0;
3002 Int_t nout3 =0;
3003 Double_t x[5], c[15];
3004 //
3005 // make temporary seed
3006 AliTPCseed * seed = new AliTPCseed;
1627d1c4 3007 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3008 // Double_t cs=cos(alpha), sn=sin(alpha);
91162307 3009 //
3010 //
1627d1c4 3011
91162307 3012 // first 3 padrows
3013 Double_t x1 = GetXrow(i1-1);
3014 const AliTPCRow& kr1=GetRow(sec,i1-1);
3015 Double_t y1max = GetMaxY(i1-1)-kr1.fDeadZone-1.5;
3016 //
3017 Double_t x1p = GetXrow(i1);
3018 const AliTPCRow& kr1p=GetRow(sec,i1);
3019 //
3020 Double_t x1m = GetXrow(i1-2);
3021 const AliTPCRow& kr1m=GetRow(sec,i1-2);
1627d1c4 3022
91162307 3023 //
3024 //last 3 padrow for seeding
3025 AliTPCRow& kr3 = GetRow((sec+fkNOS)%fkNOS,i1-7);
3026 Double_t x3 = GetXrow(i1-7);
3027 // Double_t y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;
3028 //
3029 AliTPCRow& kr3p = GetRow((sec+fkNOS)%fkNOS,i1-6);
3030 Double_t x3p = GetXrow(i1-6);
3031 //
3032 AliTPCRow& kr3m = GetRow((sec+fkNOS)%fkNOS,i1-8);
3033 Double_t x3m = GetXrow(i1-8);
1627d1c4 3034
91162307 3035 //
3036 //
3037 // middle padrow
3038 Int_t im = i1-4; //middle pad row index
3039 Double_t xm = GetXrow(im); // radius of middle pad-row
3040 const AliTPCRow& krm=GetRow(sec,im); //middle pad -row
3041 // Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;
3042 //
3043 //
3044 Double_t deltax = x1-x3;
3045 Double_t dymax = deltax*cuts[1];
3046 Double_t dzmax = deltax*cuts[3];
3047 //
3048 // loop over clusters
3049 for (Int_t is=0; is < kr1; is++) {
1627d1c4 3050 //
91162307 3051 if (kr1[is]->IsUsed(10)) continue;
3052 Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
1627d1c4 3053 //
91162307 3054 if (deltay>0 && TMath::Abs(y1max-TMath::Abs(y1))> deltay ) continue; // seed only at the edge
3055 //
3056 Int_t index1 = TMath::Max(kr3.Find(z1-dzmax)-1,0);
3057 Int_t index2 = TMath::Min(kr3.Find(z1+dzmax)+1,kr3);
3058 //
3059 Double_t y3, z3;
1627d1c4 3060 //
1627d1c4 3061 //
91162307 3062 UInt_t index;
3063 for (Int_t js=index1; js < index2; js++) {
3064 const AliTPCclusterMI *kcl = kr3[js];
3065 if (kcl->IsUsed(10)) continue;
3066 y3 = kcl->GetY();
3067 // apply angular cuts
3068 if (TMath::Abs(y1-y3)>dymax) continue;
3069 x3 = x3;
3070 z3 = kcl->GetZ();
3071 if (TMath::Abs(z1-z3)>dzmax) continue;
3072 //
3073 Double_t angley = (y1-y3)/(x1-x3);
3074 Double_t anglez = (z1-z3)/(x1-x3);
3075 //
3076 Double_t erry = TMath::Abs(angley)*(x1-x1m)*0.5+0.5;
3077 Double_t errz = TMath::Abs(anglez)*(x1-x1m)*0.5+0.5;
3078 //
3079 Double_t yyym = angley*(xm-x1)+y1;
3080 Double_t zzzm = anglez*(xm-x1)+z1;
3081
3082 const AliTPCclusterMI *kcm = krm.FindNearest2(yyym,zzzm,erry,errz,index);
3083 if (!kcm) continue;
3084 if (kcm->IsUsed(10)) continue;
3085
3086 erry = TMath::Abs(angley)*(x1-x1m)*0.4+0.5;
3087 errz = TMath::Abs(anglez)*(x1-x1m)*0.4+0.5;
3088 //
3089 //
3090 //
3091 Int_t used =0;
3092 Int_t found =0;
3093 //
3094 // look around first
3095 const AliTPCclusterMI *kc1m = kr1m.FindNearest2(angley*(x1m-x1)+y1,
3096 anglez*(x1m-x1)+z1,
3097 erry,errz,index);
3098 //
3099 if (kc1m){
3100 found++;
3101 if (kc1m->IsUsed(10)) used++;
1627d1c4 3102 }
91162307 3103 const AliTPCclusterMI *kc1p = kr1p.FindNearest2(angley*(x1p-x1)+y1,
3104 anglez*(x1p-x1)+z1,
3105 erry,errz,index);
1627d1c4 3106 //
91162307 3107 if (kc1p){
3108 found++;
3109 if (kc1p->IsUsed(10)) used++;
1627d1c4 3110 }
91162307 3111 if (used>1) continue;
3112 if (found<1) continue;
1627d1c4 3113
91162307 3114 //
3115 // look around last
3116 const AliTPCclusterMI *kc3m = kr3m.FindNearest2(angley*(x3m-x3)+y3,
3117 anglez*(x3m-x3)+z3,
3118 erry,errz,index);
3119 //
3120 if (kc3m){
3121 found++;
3122 if (kc3m->IsUsed(10)) used++;
3123 }
3124 else
3125 continue;
3126 const AliTPCclusterMI *kc3p = kr3p.FindNearest2(angley*(x3p-x3)+y3,
3127 anglez*(x3p-x3)+z3,
3128 erry,errz,index);
3129 //
3130 if (kc3p){
3131 found++;
3132 if (kc3p->IsUsed(10)) used++;
3133 }
3134 else
3135 continue;
3136 if (used>1) continue;
3137 if (found<3) continue;
3138 //
3139 Double_t x2,y2,z2;
3140 x2 = xm;
3141 y2 = kcm->GetY();
3142 z2 = kcm->GetZ();
3143 //
3144
1627d1c4 3145 x[0]=y1;
3146 x[1]=z1;
b67e07dc 3147 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3148 //if (TMath::Abs(x[4]) >= cuts[0]) continue;
3149 nin0++;
3150 //
b67e07dc 3151 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3152 nin1++;
3153 //
b67e07dc 3154 x[3]=F3n(x1,y1,x2,y2,z1,z2,x[4]);
91162307 3155 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3156 nin2++;
3157 //
3158 //
3159 Double_t sy1=0.1, sz1=0.1;
3160 Double_t sy2=0.1, sz2=0.1;
3161 Double_t sy3=0.1, sy=0.1, sz=0.1;
1627d1c4 3162
b67e07dc 3163 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3164 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3165 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3166 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3167 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3168 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
91162307 3169
b67e07dc 3170 Double_t f30=(F3(x1,y1+sy,x2,y2,z1,z2)-x[3])/sy;
3171 Double_t f31=(F3(x1,y1,x2,y2,z1+sz,z2)-x[3])/sz;
3172 Double_t f32=(F3(x1,y1,x2,y2+sy,z1,z2)-x[3])/sy;
3173 Double_t f34=(F3(x1,y1,x2,y2,z1,z2+sz)-x[3])/sz;
1627d1c4 3174
3175 c[0]=sy1;
91162307 3176 c[1]=0.; c[2]=sz1;
1627d1c4 3177 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3178 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3179 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3180 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3181 c[13]=f30*sy1*f40+f32*sy2*f42;
3182 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3183
91162307 3184 // if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
3185
3186 UInt_t index=kr1.GetIndex(is);
3187 AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3188
3189 track->fIsSeeding = kTRUE;
3190
3191 nin++;
3192 FollowProlongation(*track, i1-7,1);
3193 if (track->GetNumberOfClusters() < track->fNFoundable*0.75 ||
3194 track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
3195 seed->Reset();
3196 seed->~AliTPCseed();
3197 continue;
3198 }
3199 nout1++;
3200 nout2++;
3201 //Int_t rc = 1;
3202 FollowProlongation(*track, i2,1);
3203 track->fBConstrain =0;
3204 track->fLastPoint = i1+fInnerSec->GetNRows(); // first cluster in track position
3205 track->fFirstPoint = track->fLastPoint;
3206
3207 if (track->GetNumberOfClusters()<(i1-i2)*0.5 ||
3208 track->GetNumberOfClusters()<track->fNFoundable*0.7 ||
3209 track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
3210 seed->Reset();
3211 seed->~AliTPCseed();
3212 continue;
3213 }
3214
3215 {
3216 FollowProlongation(*track, TMath::Max(i2-10,0),1);
3217 AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
3218 FollowProlongation(*track2, i2,1);
3219 track2->fBConstrain = kFALSE;
3220 track2->fSeedType = 4;
3221 arr->AddLast(track2);
3222 seed->Reset();
3223 seed->~AliTPCseed();
3224 }
3225
3226
3227 //arr->AddLast(track);
3228 //seed = new AliTPCseed;
3229 nout3++;
3230 }
3231 }
3232
6bdc18d6 3233 if (fDebug>3){
3234 Info("MakeSeeds5","\nSeeding statiistic:\t%d\t%d\t%d\t%d\t%d\t%d",nin0,nin1,nin2,nin,nout1,nout2,nout3);
91162307 3235 }
3236 delete seed;
3237}
3238
3239
3240//_____________________________________________________________________________
176aff27 3241void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t */*cuts[4]*/,
3242 Float_t deltay, Bool_t /*bconstrain*/) {
91162307 3243 //-----------------------------------------------------------------
3244 // This function creates track seeds - without vertex constraint
3245 //-----------------------------------------------------------------
3246 // cuts[0] - fP4 cut - not applied
3247 // cuts[1] - tan(phi) cut
3248 // cuts[2] - zvertex cut - not applied
3249 // cuts[3] - fP3 cut
3250 Int_t nin0=0;
3251 Int_t nin1=0;
3252 Int_t nin2=0;
3253 Int_t nin3=0;
3254 // Int_t nin4=0;
3255 //Int_t nin5=0;
3256
3257
3258
3259 Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
3260 // Double_t cs=cos(alpha), sn=sin(alpha);
3261 Int_t row0 = (i1+i2)/2;
3262 Int_t drow = (i1-i2)/2;
3263 const AliTPCRow& kr0=fSectors[sec][row0];
3264 AliTPCRow * kr=0;
3265
3266 AliTPCpolyTrack polytrack;
3267 Int_t nclusters=fSectors[sec][row0];
3268 AliTPCseed * seed = new AliTPCseed;
3269
3270 Int_t sumused=0;
3271 Int_t cused=0;
3272 Int_t cnused=0;
3273 for (Int_t is=0; is < nclusters; is++) { //LOOP over clusters
3274 Int_t nfound =0;
3275 Int_t nfoundable =0;
3276 for (Int_t iter =1; iter<2; iter++){ //iterations
3277 const AliTPCRow& krm=fSectors[sec][row0-iter];
3278 const AliTPCRow& krp=fSectors[sec][row0+iter];
3279 const AliTPCclusterMI * cl= kr0[is];
3280
3281 if (cl->IsUsed(10)) {
3282 cused++;
3283 }
3284 else{
3285 cnused++;
3286 }
3287 Double_t x = kr0.GetX();
3288 // Initialization of the polytrack
3289 nfound =0;
3290 nfoundable =0;
3291 polytrack.Reset();
3292 //
3293 Double_t y0= cl->GetY();
3294 Double_t z0= cl->GetZ();
3295 Float_t erry = 0;
3296 Float_t errz = 0;
3297
3298 Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
3299 if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue; // seed only at the edge
3300
3301 erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;
3302 errz = (0.5)*cl->GetSigmaZ2()/TMath::Sqrt(cl->GetQ())*6;
3303 polytrack.AddPoint(x,y0,z0,erry, errz);
3304
3305 sumused=0;
3306 if (cl->IsUsed(10)) sumused++;
3307
3308
3309 Float_t roady = (5*TMath::Sqrt(cl->GetSigmaY2()+0.2)+1.)*iter;
3310 Float_t roadz = (5*TMath::Sqrt(cl->GetSigmaZ2()+0.2)+1.)*iter;
3311 //
3312 x = krm.GetX();
3313 AliTPCclusterMI * cl1 = krm.FindNearest(y0,z0,roady,roadz);
3314 if (cl1 && TMath::Abs(ymax-TMath::Abs(y0))) {
3315 erry = (0.5)*cl1->GetSigmaY2()/TMath::Sqrt(cl1->GetQ())*3;
3316 errz = (0.5)*cl1->GetSigmaZ2()/TMath::Sqrt(cl1->GetQ())*3;
3317 if (cl1->IsUsed(10)) sumused++;
3318 polytrack.AddPoint(x,cl1->GetY(),cl1->GetZ(),erry,errz);
3319 }
3320 //
3321 x = krp.GetX();
3322 AliTPCclusterMI * cl2 = krp.FindNearest(y0,z0,roady,roadz);
3323 if (cl2) {
3324 erry = (0.5)*cl2->GetSigmaY2()/TMath::Sqrt(cl2->GetQ())*3;
3325 errz = (0.5)*cl2->GetSigmaZ2()/TMath::Sqrt(cl2->GetQ())*3;
3326 if (cl2->IsUsed(10)) sumused++;
3327 polytrack.AddPoint(x,cl2->GetY(),cl2->GetZ(),erry,errz);
3328 }
3329 //
3330 if (sumused>0) continue;
3331 nin0++;
3332 polytrack.UpdateParameters();
3333 // follow polytrack
3334 roadz = 1.2;
3335 roady = 1.2;
3336 //
3337 Double_t yn,zn;
3338 nfoundable = polytrack.GetN();
3339 nfound = nfoundable;
3340 //
3341 for (Int_t ddrow = iter+1; ddrow<drow;ddrow++){
3342 Float_t maxdist = 0.8*(1.+3./(ddrow));
3343 for (Int_t delta = -1;delta<=1;delta+=2){
3344 Int_t row = row0+ddrow*delta;
3345 kr = &(fSectors[sec][row]);
3346 Double_t xn = kr->GetX();
3347 Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
3348 polytrack.GetFitPoint(xn,yn,zn);
3349 if (TMath::Abs(yn)>ymax) continue;
3350 nfoundable++;
3351 AliTPCclusterMI * cln = kr->FindNearest(yn,zn,roady,roadz);
3352 if (cln) {
3353 Float_t dist = TMath::Sqrt( (yn-cln->GetY())*(yn-cln->GetY())+(zn-cln->GetZ())*(zn-cln->GetZ()));
3354 if (dist<maxdist){
3355 /*
3356 erry = (dist+0.3)*cln->GetSigmaY2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3357 errz = (dist+0.3)*cln->GetSigmaZ2()/TMath::Sqrt(cln->GetQ())*(1.+1./(ddrow));
3358 if (cln->IsUsed(10)) {
3359 // printf("used\n");
3360 sumused++;
3361 erry*=2;
3362 errz*=2;
3363 }
3364 */
3365 erry=0.1;
3366 errz=0.1;
3367 polytrack.AddPoint(xn,cln->GetY(),cln->GetZ(),erry, errz);
3368 nfound++;
3369 }
3370 }
3371 }
3372 if ( (sumused>3) || (sumused>0.5*nfound) || (nfound<0.6*nfoundable)) break;
3373 polytrack.UpdateParameters();
3374 }
3375 }
3376 if ( (sumused>3) || (sumused>0.5*nfound)) {
3377 //printf("sumused %d\n",sumused);
3378 continue;
3379 }
3380 nin1++;
3381 Double_t dy,dz;
3382 polytrack.GetFitDerivation(kr0.GetX(),dy,dz);
3383 AliTPCpolyTrack track2;
3384
3385 polytrack.Refit(track2,0.5+TMath::Abs(dy)*0.3,0.4+TMath::Abs(dz)*0.3);
3386 if (track2.GetN()<0.5*nfoundable) continue;
3387 nin2++;
3388
3389 if ((nfound>0.6*nfoundable) &&( nfoundable>0.4*(i1-i2))) {
3390 //
3391 // test seed with and without constrain
3392 for (Int_t constrain=0; constrain<=0;constrain++){
3393 // add polytrack candidate
3394
3395 Double_t x[5], c[15];
3396 Double_t x1,x2,x3,y1,y2,y3,z1,z2,z3;
3397 track2.GetBoundaries(x3,x1);
3398 x2 = (x1+x3)/2.;
3399 track2.GetFitPoint(x1,y1,z1);
3400 track2.GetFitPoint(x2,y2,z2);
3401 track2.GetFitPoint(x3,y3,z3);
3402 //
3403 //is track pointing to the vertex ?
3404 Double_t x0,y0,z0;
3405 x0=0;
3406 polytrack.GetFitPoint(x0,y0,z0);
3407
3408 if (constrain) {
3409 x2 = x3;
3410 y2 = y3;
3411 z2 = z3;
3412
3413 x3 = 0;
3414 y3 = 0;
3415 z3 = 0;
3416 }
3417 x[0]=y1;
3418 x[1]=z1;
b67e07dc 3419 x[4]=F1(x1,y1,x2,y2,x3,y3);
91162307 3420
3421 // if (TMath::Abs(x[4]) >= cuts[0]) continue; //
b67e07dc 3422 x[2]=F2(x1,y1,x2,y2,x3,y3);
91162307 3423
3424 //if (TMath::Abs(x[4]*x1-x[2]) >= cuts[1]) continue;
b67e07dc 3425 //x[3]=F3(x1,y1,x2,y2,z1,z2);
3426 x[3]=F3n(x1,y1,x3,y3,z1,z3,x[4]);
91162307 3427 //if (TMath::Abs(x[3]) > cuts[3]) continue;
3428
3429
3430 Double_t sy =0.1, sz =0.1;
3431 Double_t sy1=0.02, sz1=0.02;
3432 Double_t sy2=0.02, sz2=0.02;
3433 Double_t sy3=0.02;
3434
3435 if (constrain){
3436 sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
3437 }
3438
b67e07dc 3439 Double_t f40=(F1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
3440 Double_t f42=(F1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
3441 Double_t f43=(F1(x1,y1,x2,y2,x3,y3+sy)-x[4])/sy;
3442 Double_t f20=(F2(x1,y1+sy,x2,y2,x3,y3)-x[2])/sy;
3443 Double_t f22=(F2(x1,y1,x2,y2+sy,x3,y3)-x[2])/sy;
3444 Double_t f23=(F2(x1,y1,x2,y2,x3,y3+sy)-x[2])/sy;
3445
3446 Double_t f30=(F3(x1,y1+sy,x3,y3,z1,z3)-x[3])/sy;
3447 Double_t f31=(F3(x1,y1,x3,y3,z1+sz,z3)-x[3])/sz;
3448 Double_t f32=(F3(x1,y1,x3,y3+sy,z1,z3)-x[3])/sy;
3449 Double_t f34=(F3(x1,y1,x3,y3,z1,z3+sz)-x[3])/sz;
91162307 3450
3451
3452 c[0]=sy1;
3453 c[1]=0.; c[2]=sz1;
3454 c[3]=f20*sy1; c[4]=0.; c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
3455 c[6]=f30*sy1; c[7]=f31*sz1; c[8]=f30*sy1*f20+f32*sy2*f22;
3456 c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
3457 c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
3458 c[13]=f30*sy1*f40+f32*sy2*f42;
3459 c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
3460
3461 //Int_t row1 = fSectors->GetRowNumber(x1);
3462 Int_t row1 = GetRowNumber(x1);
3463
3464 UInt_t index=0;
3465 //kr0.GetIndex(is);
3466 AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
3467 track->fIsSeeding = kTRUE;
3468 Int_t rc=FollowProlongation(*track, i2);
3469 if (constrain) track->fBConstrain =1;
3470 else