1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
22 //-------------------------------------------------------------------------
23 // Implementation of the ITS Upgrade tracker mother class.
24 //-------------------------------------------------------------------------
26 #include <Riostream.h>
29 #include "AliITSUTrackerGlo.h"
30 #include "AliESDEvent.h"
31 #include "AliESDtrack.h"
32 #include "AliITSURecoDet.h"
33 #include "AliITSURecoSens.h"
34 #include "AliITSUReconstructor.h"
35 #include "AliITSReconstructor.h"
36 #include "AliITSUSeed.h"
37 #include "AliITSUAux.h"
38 #include "AliITSUClusterPix.h"
39 using namespace AliITSUAux;
40 using namespace TMath;
43 //----------------- tmp stuff -----------------
45 ClassImp(AliITSUTrackerGlo)
46 //_________________________________________________________________________
47 AliITSUTrackerGlo::AliITSUTrackerGlo(AliITSUReconstructor* rec)
54 ,fSeedsPool("AliITSUSeed",0)
58 // Default constructor
62 //_________________________________________________________________________
63 AliITSUTrackerGlo::~AliITSUTrackerGlo()
71 //_________________________________________________________________________
72 void AliITSUTrackerGlo::Init(AliITSUReconstructor* rec)
74 // init with external reconstructor
76 fITS = new AliITSURecoDet(rec->GetGeom(),"ITSURecoInterface");
77 for (int ilr=fITS->GetNLayersActive();ilr--;) {
78 fITS->GetLayerActive(ilr)->SetClusters(rec->GetClusters(ilr));
81 fSeedsPool.ExpandCreateFast(1000); // RS TOCHECK
83 fTrCond.SetNLayers(fITS->GetNLayersActive());
84 fTrCond.AddNewCondition(5);
85 fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<1) );
86 fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) );
87 fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) );
89 fTrCond.AddNewCondition(5);
90 fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<2) );
91 fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) );
92 fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) );
94 fTrCond.AddNewCondition(5);
95 fTrCond.AddGroupPattern( (0x1<<1)|(0x1<<2) );
96 fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) );
97 fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) );
99 printf("Tracking Conditions: ");
103 //_________________________________________________________________________
104 Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv)
108 fTrackPhase = kClus2Tracks;
109 int nTrESD = esdEv->GetNumberOfTracks();
110 AliInfo(Form("Will try to find prolongations for %d tracks",nTrESD));
111 AliITSUReconstructor::GetRecoParam()->Print();
113 if (fHypStore.GetSize()<nTrESD) fHypStore.Expand(nTrESD+100);
115 fITS->ProcessClusters();
116 // select ESD tracks to propagate
117 for (int itr=0;itr<nTrESD;itr++) {
118 AliESDtrack *esdTr = esdEv->GetTrack(itr);
119 AliInfo(Form("Processing track %d | MCLabel: %d",itr,esdTr->GetTPCLabel()));
120 if (!NeedToProlong(esdTr)) continue; // are we interested in this track?
121 FindTrack(esdTr, itr);
124 printf("Hypotheses for current event (N seeds in pool: %d, size: %d)\n",fSeedsPool.GetEntriesFast(),fSeedsPool.GetSize());
126 FinalizeHypotheses();
131 //_________________________________________________________________________
132 Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent *esdEv)
135 // Do outward fits in ITS
137 fTrackPhase = kPropBack;
138 int nTrESD = esdEv->GetNumberOfTracks();
139 AliInfo(Form("Will fit %d tracks",nTrESD));
141 double bz0 = GetBz();
142 Double_t xyzTrk[3],xyzVtx[3]={GetX(),GetY(),GetZ()};
143 AliITSUTrackHyp dummyTr,*currTr=0;
144 const double kWatchStep=10.; // for larger steps watch arc vs segment difference
145 Double_t times[AliPID::kSPECIES];
148 for (int itr=0;itr<nTrESD;itr++) {
149 AliESDtrack *esdTr = esdEv->GetTrack(itr);
150 // Start time integral and add distance from current position to vertex
151 if (esdTr->IsOn(AliESDtrack::kITSout)) continue; // already done
153 esdTr->GetXYZ(xyzTrk);
154 Double_t dst = 0.; // set initial track lenght, tof
156 double dxs = xyzTrk[0] - xyzVtx[0];
157 double dys = xyzTrk[1] - xyzVtx[1];
158 double dzs = xyzTrk[2] - xyzVtx[2];
159 // RS: for large segment steps d use approximation of cicrular arc s by
160 // s = 2R*asin(d/2R) = d/p asin(p) \approx d/p (p + 1/6 p^3) = d (1+1/6 p^2)
161 // where R is the track radius, p = d/2R = 2C*d (C is the abs curvature)
162 // Hence s^2/d^2 = (1+1/6 p^2)^2
163 dst = dxs*dxs + dys*dys;
164 if (dst > kWatchStep*kWatchStep) { // correct circular part for arc/segment factor
165 double crv = Abs(esdTr->GetC(bz0));
166 double fcarc = 1.+crv*crv*dst/6.;
173 esdTr->SetStatus(AliESDtrack::kTIME);
175 if (!esdTr->IsOn(AliESDtrack::kITSin)) { // case of tracks w/o ITS prolongation: just set the time integration
176 dummyTr.StartTimeIntegral();
177 dummyTr.AddTimeStep(TMath::Sqrt(dst));
178 dummyTr.GetIntegratedTimes(times);
179 esdTr->SetIntegratedTimes(times);
180 esdTr->SetIntegratedLength(dummyTr.GetIntegratedLength());
184 currTr = GetTrackHyp(itr);
185 currTr->StartTimeIntegral();
186 currTr->AddTimeStep(dst);
187 currTr->ResetCovariance(10.);
188 RefitTrack(currTr,fITS->GetRMax()); // propagate to exit from the ITS/TPC screen
195 //_________________________________________________________________________
196 Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent * /*event*/)
202 Info("RefitInward","To be implemented");
206 //_________________________________________________________________________
207 Int_t AliITSUTrackerGlo::LoadClusters(TTree * treeRP)
209 // read from tree (if pointer provided) or directly from the ITS reco interface
211 return fReconstructor->LoadClusters(treeRP);
214 //_________________________________________________________________________
215 void AliITSUTrackerGlo::UnloadClusters()
221 Info("UnloadClusters","To be implemented");
223 //_________________________________________________________________________
224 AliCluster * AliITSUTrackerGlo::GetCluster(Int_t /*index*/) const
230 Info("GetCluster","To be implemented");
234 //_________________________________________________________________________
235 Bool_t AliITSUTrackerGlo::NeedToProlong(AliESDtrack* esdTr)
237 // do we need to match this track to ITS?
239 static double bz = GetBz();
240 if (!esdTr->IsOn(AliESDtrack::kTPCin) ||
241 esdTr->IsOn(AliESDtrack::kTPCout) ||
242 esdTr->IsOn(AliESDtrack::kITSin) ||
243 esdTr->GetKinkIndex(0)>0) return kFALSE;
245 if (esdTr->Pt()<AliITSUReconstructor::GetRecoParam()->GetMinPtForProlongation()) return kFALSE;
248 esdTr->GetDZ(GetX(),GetY(),GetZ(),bz,dtz);
249 // if track is not V0 candidata but has large offset wrt IP, reject it. RS TOCHECK
250 if ( !(esdTr->GetV0Index(0)>0 && dtz[0]>AliITSUReconstructor::GetRecoParam()->GetMaxDforV0dghtrForProlongation())
251 && (Abs(dtz[0])>AliITSUReconstructor::GetRecoParam()->GetMaxDForProlongation() ||
252 Abs(dtz[1])>AliITSUReconstructor::GetRecoParam()->GetMaxDZForProlongation())) return kFALSE;
257 //_________________________________________________________________________
258 void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr, Int_t esdID)
260 // find prolongaion candidates finding for single seed
262 AliITSUSeed seedUC; // copy of the seed from the upper layer
263 AliITSUSeed seedT; // transient seed between the seedUC and new prolongation hypothesis
265 if (!InitHypothesis(esdTr,esdID)) return; // initialize prolongations hypotheses tree
267 AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1];
269 TObjArray clArr; // container for transfer of clusters matching to seed
271 int nLrActive = fITS->GetNLayersActive();
272 for (int ila=nLrActive;ila--;) {
273 int ilaUp = ila+1; // prolong seeds from layer above
275 // for the outermost layer the seed is created from the ESD track
276 int nSeedsUp = (ilaUp==nLrActive) ? 1 : fCurrHyp->GetNSeeds(ilaUp);
278 for (int isd=0;isd<nSeedsUp;isd++) {
280 if (ilaUp==nLrActive) {
282 seedUC.InitFromESDTrack(esdTr);
285 seedU = fCurrHyp->GetSeed(ilaUp,isd); // seed on prev.active layer to prolong
286 seedUC = *seedU; // its copy will be prolonged
287 seedUC.SetParent(seedU);
289 seedUC.ResetFMatrix(); // reset the matrix for propagation to next layer
290 // go till next active layer
291 AliInfo(Form("working on Lr:%d Seed:%d of %d",ila,isd,nSeedsUp));
292 if (!TransportToLayer(&seedUC, fITS->GetLrIDActive(ilaUp), fITS->GetLrIDActive(ila)) ) {
294 AliInfo("Transport failed");
295 // Check if the seed satisfies to track definition
296 if (NeedToKill(&seedUC,kTransportFailed) && seedU) seedU->Kill();
297 continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing
299 AliITSURecoLayer* lrA = fITS->GetLayerActive(ila);
300 if (!GetRoadWidth(&seedUC, ila)) { // failed to find road width on the layer
301 if (NeedToKill(&seedUC,kRWCheckFailed) && seedU) seedU->Kill();
304 int nsens = lrA->FindSensors(&fTrImpData[kTrPhi0], hitSens); // find detectors which may be hit by the track
305 AliInfo(Form("Will check %d sensors on lr:%d ",nsens,ila));
308 for (int isn=nsens;isn--;) {
310 AliITSURecoSens* sens = hitSens[isn];
312 // We need to propagate the seed to sensor on lrA staying the frame of the sensor from prev.layer,
313 // since the transport matrix should be defined in this frame.
314 double xs; // X in the TF of current seed, corresponding to intersection with sensor plane
315 if (!seedT.GetTrackingXAtXAlpha(sens->GetXTF(),sens->GetPhiTF(),bz, xs)) continue;
316 if (!seedT.PropagateToX(xs,bz)) continue;
317 // if (!seedT.Rotate(sens->GetPhiTF())) continue;
318 if (!seedT.RotateToAlpha(sens->GetPhiTF())) continue;
320 int clID0 = sens->GetFirstClusterId();
321 for (int icl=sens->GetNClusters();icl--;) {
322 int res = CheckCluster(&seedT,ila,clID0+icl);
324 if (res==kStopSearchOnSensor) break; // stop looking on this sensor
325 if (res==kClusterNotMatching) continue; // cluster does not match
326 // cluster is matching and it was added to the hypotheses tree
329 // cluster search is done. Do we need ta have a version of this seed skipping current layer
331 if (!NeedToKill(&seedT,kMissingCluster)) {
332 AliITSUSeed* seedSkp = NewSeedFromPool(&seedT);
333 double penalty = -AliITSUReconstructor::GetRecoParam()->GetMissPenalty(ila);
334 // to do: make penalty to account for probability to miss the cluster for good reason
335 seedSkp->SetChi2Cl(penalty);
336 AddProlongationHypothesis(seedSkp,ila);
339 ((TObjArray*)fCurrHyp->GetLayerSeeds(ila))->Sort();
340 printf(">>> All hypotheses on lr %d: \n",ila);
341 for (int ih=0;ih<fCurrHyp->GetNSeeds(ila);ih++) {
342 printf(" #%3d ",ih); fCurrHyp->GetSeed(ila,ih)->Print();
345 if (ila!=0) continue;
346 double vecL[5] = {0};
347 double matL[15] = {0};
348 AliITSUSeed* sp = fCurrHyp->GetSeed(ila,ih);
349 while(sp->GetParent()) {
350 sp->Smooth(vecL,matL);
351 if (sp->GetLayerID()>=fITS->GetNLayersActive()-1) break;
352 sp = (AliITSUSeed*)sp->GetParent();
358 SaveCurrentTrackHypotheses();
362 //_________________________________________________________________________
363 Bool_t AliITSUTrackerGlo::InitHypothesis(AliESDtrack *esdTr, Int_t esdID)
365 // init prolongaion candidates finding for single seed
366 fCurrHyp = GetTrackHyp(esdID);
367 if (fCurrHyp) return kTRUE;
369 fCurrMass = esdTr->GetMass();
370 fCurrESDtrack = esdTr;
371 if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin
373 fCurrHyp = new AliITSUTrackHyp(fITS->GetNLayersActive());
374 fCurrHyp->SetESDTrack(esdTr);
375 fCurrHyp->SetUniqueID(esdID);
376 fCurrHyp->SetMass(fCurrMass);
377 SetTrackHyp(fCurrHyp,esdID);
383 //_________________________________________________________________________
384 Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo)
386 // transport seed from layerFrom to the entrance of layerTo
388 const double kToler = 1e-6; // tolerance for layer on-surface check
390 int dir = lTo > lFrom ? 1:-1;
391 AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested
392 Bool_t checkFirst = kTRUE;
394 double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius
396 Bool_t doLayer = kTRUE;
397 double xToGo = dir>0 ? lrFr->GetRMax() : lrFr->GetRMin();
398 if (checkFirst) { // do we need to track till the surface of the current layer ?
400 if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
401 else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
404 if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
405 // go via layer to its boundary, applying material correction.
406 if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE;
409 AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) );
410 if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom));
412 // go the entrance of the layer, assuming no materials in between
413 double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax();
414 if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
415 if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE;
422 //_________________________________________________________________________
423 Bool_t AliITSUTrackerGlo::TransportToLayer(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo)
425 // transport track from layerFrom to the entrance of layerTo
427 const double kToler = 1e-6; // tolerance for layer on-surface check
429 int dir = lTo > lFrom ? 1:-1;
430 AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested
431 Bool_t checkFirst = kTRUE;
433 double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius
435 Bool_t doLayer = kTRUE;
436 double xToGo = dir>0 ? lrFr->GetRMax() : lrFr->GetRMin();
437 if (checkFirst) { // do we need to track till the surface of the current layer ?
439 if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
440 else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
443 if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
444 // go via layer to its boundary, applying material correction.
445 if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE;
448 AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) );
449 if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom));
451 // go the entrance of the layer, assuming no materials in between
452 double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax();
453 if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
454 if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE;
461 //_________________________________________________________________________
462 Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA)
464 // calculate road width in terms of phi and z for the track which MUST be on the external radius of the layer
465 // as well as some aux info
467 AliITSURecoLayer* lrA = fITS->GetLayerActive(ilrA);
468 seed->GetXYZ(&fTrImpData[kTrXIn]); // lab position at the entrance from above
469 static AliExternalTrackParam sc; // seed copy for manipalitions
472 fTrImpData[kTrPhiIn] = ATan2(fTrImpData[kTrYIn],fTrImpData[kTrXIn]);
473 if (!sc.Rotate(fTrImpData[kTrPhiIn])) return kFALSE; // go to the frame of the entry point into the layer
474 double dr = lrA->GetDR(); // approximate X dist at the inner radius
475 if (!sc.GetXYZAt(sc.GetX()-dr, bz, fTrImpData + kTrXOut)) {
476 // special case: track does not reach inner radius, might be tangential
477 double r = sc.GetD(0,0,bz);
479 if (!sc.GetXatLabR(r,x,bz,-1)) {
481 AliFatal(Form("This should not happen: r=%f",r));
483 dr = Abs(sc.GetX() - x);
484 if (!sc.GetXYZAt(x, bz, fTrImpData + kTrXOut)) {
486 AliFatal(Form("This should not happen: x=%f",x));
490 fTrImpData[kTrPhiOut] = ATan2(fTrImpData[kTrYOut],fTrImpData[kTrXOut]);
491 double sgy = sc.GetSigmaY2() + dr*dr*sc.GetSigmaSnp2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(ilrA);
492 double sgz = sc.GetSigmaZ2() + dr*dr*sc.GetSigmaTgl2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(ilrA);
493 sgy = Sqrt(sgy)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY();
494 sgz = Sqrt(sgz)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ();
495 fTrImpData[kTrPhi0] = 0.5*(fTrImpData[kTrPhiOut]+fTrImpData[kTrPhiIn]);
496 fTrImpData[kTrZ0] = 0.5*(fTrImpData[kTrZOut]+fTrImpData[kTrZIn]);
497 fTrImpData[kTrDPhi] = 0.5*Abs(fTrImpData[kTrPhiOut]-fTrImpData[kTrPhiIn]) + sgy/lrA->GetR();
498 fTrImpData[kTrDZ] = 0.5*Abs(fTrImpData[kTrZOut]-fTrImpData[kTrZIn]) + sgz;
503 //_________________________________________________________________________
504 AliITSUSeed* AliITSUTrackerGlo::NewSeedFromPool(const AliITSUSeed* src)
506 // create new seed, optionally copying from the source
508 new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed(*src) :
509 new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed();
512 //_________________________________________________________________________
513 Int_t AliITSUTrackerGlo::CheckCluster(AliITSUSeed* track, Int_t lr, Int_t clID)
515 // Check if the cluster (in tracking frame!) is matching to track.
516 // The track must be already propagated to sensor tracking frame.
517 // Returns: kStopSearchOnSensor if the search on given sensor should be stopped,
518 // kClusterMatching if the cluster is matching
519 // kClusterMatching otherwise
521 const double kTolerX = 5e-4;
522 AliCluster *cl = fITS->GetLayerActive(lr)->GetCluster(clID);
524 Bool_t goodCl = kFALSE;
525 int currLabel = Abs(fCurrESDtrack->GetTPCLabel());
527 if (cl->GetLabel(0)>=0) {for (int i=0;i<3;i++) if (cl->GetLabel(i)>=0 && cl->GetLabel(i)==currLabel) {goodCl = kTRUE; break;}}
530 if (TMath::Abs(cl->GetX())>kTolerX) { // if due to the misalingment X is large, propagate track only
531 if (!track->PropagateParamOnlyTo(track->GetX()+cl->GetX(),GetBz())) {
532 if (goodCl) {printf("Loose good cl: Failed propagation. |"); cl->Print();}
533 return kStopSearchOnSensor; // propagation failed, seedT is intact
536 double dy = cl->GetY()-track->GetY();
537 double dz = cl->GetZ()-track->GetZ();
540 double tol2 = (track->GetSigmaY2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(lr))*
541 AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); // RS TOOPTIMIZE
542 if (dy2>tol2) { // the clusters are sorted in Z(col) then in Y(row).
543 if (goodCl) {printf("Loose good cl: dy2=%e > tol2=%e |",dy2,tol2); cl->Print();}
544 if (dy>0) return kStopSearchOnSensor; // No chance that other cluster of this sensor will match (all Y's will be even larger)
545 else return kClusterNotMatching; // Other clusters may match
548 tol2 = (track->GetSigmaZ2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(lr))*
549 AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); // RS TOOPTIMIZE
551 if (goodCl) {printf("Loose good cl: dz2=%e > tol2=%e |",dz2,tol2); cl->Print();}
552 return kClusterNotMatching; // Other clusters may match
556 Double_t p[2]={cl->GetY(), cl->GetZ()};
557 Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
558 double chi2 = track->GetPredictedChi2(p,cov);
559 if (chi2>AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr)) {
561 printf("Loose good cl: Chi2=%e > Chi2Max=%e |dy: %+.3e dz: %+.3e\n",
562 chi2,AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr),dy,dz);
566 return kClusterNotMatching;
569 track = NewSeedFromPool(track); // input track will be reused, use its clone for updates
570 if (!track->Update()) {
571 if (goodCl) {printf("Loose good cl: Failed update |"); cl->Print();}
572 return kClusterNotMatching;
574 track->SetChi2Cl(chi2);
575 track->SetLrClusterID(lr,clID);
576 cl->IncreaseClusterUsage();
578 track->SetFake(!goodCl);
580 AliInfo(Form("AddCl(%d) Cl%d lr:%d: dY:%+8.4f dZ:%+8.4f (MC: %5d %5d %5d) |Chi2=%f(%c)",
581 goodCl,clID,lr,dy,dz2,cl->GetLabel(0),cl->GetLabel(1),cl->GetLabel(2), chi2, track->IsFake() ? '-':'+'));
583 AddProlongationHypothesis(track,lr);
585 return kClusterMatching;
588 //_________________________________________________________________________
589 Bool_t AliITSUTrackerGlo::NeedToKill(AliITSUSeed *seed, Int_t flag)
591 // check if the seed should not be discarded
592 const UShort_t kMask = 0xffff;
593 if (flag==kMissingCluster) {
594 int lastChecked = seed->GetLayerID();
595 UShort_t patt = seed->GetHitsPattern();
596 if (lastChecked) patt |= ~(kMask<<lastChecked); // not all layers were checked, complete unchecked once by potential hits
597 Bool_t seedOK = fTrCond.CheckPattern(patt);
603 //______________________________________________________________________________
604 Bool_t AliITSUTrackerGlo::PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr)
606 // propagate seed to given x applying material correction if requested
607 const Double_t kEpsilon = 1e-5;
608 Double_t xpos = seed->GetX();
609 Int_t dir = (xpos<xToGo) ? 1:-1;
610 Double_t xyz0[3],xyz1[3],param[7];
612 if (matCorr) seed->GetXYZ(xyz1); //starting global position
613 while ( (xToGo-xpos)*dir > kEpsilon){
614 Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
615 Double_t x = xpos+step;
616 Double_t bz=GetBz(); // getting the local Bz
617 if (!seed->PropagateToX(x,bz)) return kFALSE;
619 xyz0[0]=xyz1[0]; // global pos at the beginning of step
622 seed->GetXYZ(xyz1); // // global pos at the end of step
623 MeanMaterialBudget(xyz0,xyz1,param);
624 Double_t xrho=param[0]*param[4], xx0=param[1];
625 if (dir>0) xrho = -xrho; // outward should be negative
626 if (!seed->ApplyMaterialCorrection(xx0,xrho,mass,kFALSE)) return kFALSE;
633 //______________________________________________________________________________
634 Bool_t AliITSUTrackerGlo::PropagateSeed(AliExternalTrackParam *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr)
636 // propagate seed to given x applying material correction if requested
637 const Double_t kEpsilon = 1e-5;
638 Double_t xpos = seed->GetX();
639 Int_t dir = (xpos<xToGo) ? 1:-1;
640 Double_t xyz0[3],xyz1[3],param[7];
642 Bool_t updTime = dir>0 && seed->IsStartedTimeIntegral();
643 if (matCorr || updTime) seed->GetXYZ(xyz1); //starting global position
644 while ( (xToGo-xpos)*dir > kEpsilon){
645 Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
646 Double_t x = xpos+step;
647 Double_t bz=GetBz(); // getting the local Bz
648 if (!seed->PropagateTo(x,bz)) return kFALSE;
650 if (matCorr || updTime) {
651 xyz0[0]=xyz1[0]; // global pos at the beginning of step
654 seed->GetXYZ(xyz1); // // global pos at the end of step
657 MeanMaterialBudget(xyz0,xyz1,param);
658 Double_t xrho=param[0]*param[4], xx0=param[1];
659 if (dir>0) xrho = -xrho; // outward should be negative
660 if (!seed->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE;
663 else { // matCorr is not requested but time integral is
664 double d0 = xyz1[0]-xyz0[0];
665 double d1 = xyz1[1]-xyz0[1];
666 double d2 = xyz1[2]-xyz0[2];
667 ds = TMath::Sqrt(d0*d0+d1*d1+d2*d2);
670 if (updTime) seed->AddTimeStep(ds);
677 //______________________________________________________________________________
678 void AliITSUTrackerGlo::SaveCurrentTrackHypotheses()
680 // RS: shall we clean up killed seeds?
686 //______________________________________________________________________________
687 void AliITSUTrackerGlo::FinalizeHypotheses()
689 // select winner for each hypothesis, remove cl. sharing conflicts
692 int nh = fHypStore.GetEntriesFast();
693 for (int ih=0;ih<nh;ih++) {
694 AliITSUTrackHyp* hyp = (AliITSUTrackHyp*) fHypStore.UncheckedAt(ih);
696 hyp->DefineWinner(); // TODO
702 //______________________________________________________________________________
703 void AliITSUTrackerGlo::UpdateESDTrack(AliITSUTrackHyp* hyp)
705 // update ESD track with current best hypothesis
706 AliESDtrack* esdTr = hyp->GetESDTrack();
708 AliITSUSeed* win = hyp->GetWinner();
710 esdTr->UpdateTrackParams(hyp,AliESDtrack::kITSin);
712 // transfer module indices
716 //______________________________________________________________________________
717 Bool_t AliITSUTrackerGlo::RefitTrack(AliITSUTrackHyp* trc, Double_t rDest)
719 // refit track till radius rDest
720 double rCurr = Sqrt(trc->GetX()*trc->GetX() + trc->GetY()*trc->GetY());
721 int dir,lrStart,lrStop;
726 lrStop = fITS->GetNLayers()-1;
730 lrStart = fITS->GetNLayers()-1;
734 for (int ilr=lrStart;ilr!=lrStop;ilr+=dir) {
735 AliITSURecoLayer* lr = fITS->GetLayer(ilr);
736 if ( dir*(rCurr-lr->GetR(dir))>0) continue; // this layer is already passed