From e7d83d38c2a8452b355f4184500b96604cb8f8b3 Mon Sep 17 00:00:00 2001 From: shahoian Date: Mon, 28 Jan 2013 18:45:17 +0000 Subject: [PATCH] RefitInward implemented --- ITS/UPGRADE/AliITSUSeed.cxx | 15 ++++++ ITS/UPGRADE/AliITSUSeed.h | 27 +++++++++-- ITS/UPGRADE/AliITSUTrackHyp.cxx | 36 ++++++++++++++- ITS/UPGRADE/AliITSUTrackHyp.h | 6 +-- ITS/UPGRADE/AliITSUTrackerGlo.cxx | 76 ++++++++++++++++++++++++------- ITS/UPGRADE/AliITSUTrackerGlo.h | 7 ++- 6 files changed, 139 insertions(+), 28 deletions(-) diff --git a/ITS/UPGRADE/AliITSUSeed.cxx b/ITS/UPGRADE/AliITSUSeed.cxx index 1cbe2fd1f8e..9ec1ef5932b 100644 --- a/ITS/UPGRADE/AliITSUSeed.cxx +++ b/ITS/UPGRADE/AliITSUSeed.cxx @@ -241,6 +241,20 @@ Bool_t AliITSUSeed::PropagateToX(Double_t xk, Double_t b) return kTRUE; } +//__________________________________________________________________ +Int_t AliITSUSeed::GetClusterIndex(Int_t ind) const +{ + // get ind-th cluster index + int ncl = 0; + const AliITSUSeed* seed = this; + while(seed) { + if ( HasCluster() && (ncl++==ind) ) return seed->GetClusterID(); + seed = (AliITSUSeed*)seed->GetParent(); + } + return -1; + // +} + //______________________________________________________________________________ Bool_t AliITSUSeed::RotateToAlpha(Double_t alpha) { @@ -718,3 +732,4 @@ Bool_t AliITSUSeed::Smooth(Double_t vecL[5],Double_t matL[15]) } */ + diff --git a/ITS/UPGRADE/AliITSUSeed.h b/ITS/UPGRADE/AliITSUSeed.h index ba23538a56e..90895e537ee 100644 --- a/ITS/UPGRADE/AliITSUSeed.h +++ b/ITS/UPGRADE/AliITSUSeed.h @@ -36,7 +36,10 @@ class AliITSUSeed: public AliExternalTrackParam Int_t GetLayerID() const {return UnpackLayer(fClID);} Int_t GetClusterID() const {return UnpackCluster(fClID);} Bool_t HasClusterOnLayer(Int_t lr) const {return fHitsPattern&(0x1<0) or penalty for missing cluster (if < 0) Float_t fChi2Penalty; // total penalty (e.g. for missing clusters) + Double_t fFMatrix[kNFElem]; // matrix of propagation from prev layer (non-trivial elements) + Double_t fKMatrix[kNKElem]; // Gain matrix non-trivial elements (note: standard MBF formula uses I-K*H) + Double_t fRMatrix[kNRElem]; // rotation matrix non-trivial elements + Double_t fCovIYZ[3]; // inverted matrix of propagation + meas errors = [Hi * Pi|i-1 * Hi^T + Ri]^-1 + Double_t fResid[2]; // residuals vector TObject* fParent; // parent track (in higher tree hierarchy) ClassDef(AliITSUSeed,1) @@ -145,4 +148,18 @@ inline const AliITSUSeed* AliITSUSeed::GetParent(Int_t lr) const return par; } +//__________________________________________________________________ +inline Int_t AliITSUSeed::GetNClusters() const +{ + // count number of clusters (some layers may have >1 hit) + int ncl = 0; + const AliITSUSeed* seed = this; + while(seed) { + if (seed->HasCluster()) ncl++; + seed = (AliITSUSeed*)seed->GetParent(); + } + return ncl; + // +} + #endif diff --git a/ITS/UPGRADE/AliITSUTrackHyp.cxx b/ITS/UPGRADE/AliITSUTrackHyp.cxx index d977f3f3226..5f974a9d89b 100644 --- a/ITS/UPGRADE/AliITSUTrackHyp.cxx +++ b/ITS/UPGRADE/AliITSUTrackHyp.cxx @@ -126,8 +126,12 @@ Int_t AliITSUTrackHyp::FetchClusterInfo(Int_t *clIDarr) const // fill cl.id's in the array. The clusters of layer L will be set at slots // clID[2L] (and clID[2L+1] if there is an extra cluster). for (int i=fNLayers<<1;i--;) clIDarr[i]=-1; - AliITSUSeed* seed = GetWinner(); Int_t lr,ncl=0; + AliITSUSeed* seed = GetWinner(); + if (!seed) { + AliFatal("The winner is not set"); + return ncl; + } while(seed) { int clID = seed->GetLrCluster(lr); if (clID>=0) { @@ -139,3 +143,33 @@ Int_t AliITSUTrackHyp::FetchClusterInfo(Int_t *clIDarr) const } return ncl; } + +//__________________________________________________________________ +Int_t AliITSUTrackHyp::GetNumberOfClusters() const +{ + // This is a temporary (slow) way of accessing number of clusters + // TODO: add dedicated data members filled by winner + AliITSUSeed* seed = GetWinner(); + int ncl = 0; + if (!seed) { + AliFatal("The winner is not set"); + return ncl; + } + return seed->GetNClusters(); + // +} + +//__________________________________________________________________ +Int_t AliITSUTrackHyp::GetClusterIndex(Int_t ind) const +{ + // This is a temporary (slow) way of accessing cluster index + // TODO: add dedicated data members filled by winner + AliITSUSeed* seed = GetWinner(); + int ncl = 0; + if (!seed) { + AliFatal("The winner is not set"); + return -1; + } + return seed->GetClusterIndex(ind); + // +} diff --git a/ITS/UPGRADE/AliITSUTrackHyp.h b/ITS/UPGRADE/AliITSUTrackHyp.h index 01eb0750430..ebc72b4aedb 100644 --- a/ITS/UPGRADE/AliITSUTrackHyp.h +++ b/ITS/UPGRADE/AliITSUTrackHyp.h @@ -37,9 +37,9 @@ class AliITSUTrackHyp: public AliKalmanTrack virtual Double_t GetPredictedChi2(const AliCluster *c) const; virtual Bool_t PropagateTo(Double_t xr, Double_t x0, Double_t rho); virtual Bool_t Update(const AliCluster* c, Double_t chi2, Int_t index); - virtual Int_t GetClusterIndex(Int_t) const { return -1;} - virtual Int_t GetNumberOfTracklets() const { return 0;} - virtual Int_t GetTrackletIndex(Int_t) const { return -1;} + virtual Int_t GetNumberOfClusters() const; + virtual Int_t GetClusterIndex(Int_t ind) const; + // virtual Int_t GetTrackletIndex(Int_t) const { return -1;} virtual Double_t GetPIDsignal() const { return 0;} // virtual void Print(Option_t* option = "") const; diff --git a/ITS/UPGRADE/AliITSUTrackerGlo.cxx b/ITS/UPGRADE/AliITSUTrackerGlo.cxx index a9f2aa27bf0..719493c12ce 100644 --- a/ITS/UPGRADE/AliITSUTrackerGlo.cxx +++ b/ITS/UPGRADE/AliITSUTrackerGlo.cxx @@ -118,8 +118,8 @@ Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv) { // // + SetTrackingPhase(kClus2Tracks); ResetSeedsPool(); - fTrackPhase = kClus2Tracks; int nTrESD = esdEv->GetNumberOfTracks(); AliInfo(Form("Will try to find prolongations for %d tracks",nTrESD)); AliITSUReconstructor::GetRecoParam()->Print(); @@ -148,9 +148,9 @@ Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent *esdEv) // // Do outward fits in ITS // - fTrackPhase = kPropBack; + SetTrackingPhase(kPropBack); int nTrESD = esdEv->GetNumberOfTracks(); - AliInfo(Form("Will fit %d tracks",nTrESD)); + AliInfo(Form("Will propagate back %d tracks",nTrESD)); // double bz0 = GetBz(); Double_t xyzTrk[3],xyzVtx[3]={GetX(),GetY(),GetZ()}; @@ -204,6 +204,9 @@ Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent *esdEv) if (RefitTrack(currTr,fITS->GetRMax())) { // propagate to exit from the ITS/TPC screen UpdateESDTrack(currTr,AliESDtrack::kITSout); } + else { + AliInfo(Form("Refit Failed for track %d",itr)); + } // } // @@ -211,13 +214,34 @@ Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent *esdEv) } //_________________________________________________________________________ -Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent * /*event*/) +Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent *esdEv) { // - // To be implemented + // refit the tracks inward, using current cov.matrix + // + SetTrackingPhase(kRefitInw); + Int_t nTrESD = esdEv->GetNumberOfTracks(); + AliInfo(Form("Will refit inward %d tracks",nTrESD)); + AliITSUTrackHyp *currTr=0; + // + for (int itr=0;itrGetTrack(itr); + // Start time integral and add distance from current position to vertex + UInt_t trStat = esdTr->GetStatus(); + if ( !(trStat & AliESDtrack::kITSout) ) continue; + if ( trStat & AliESDtrack::kITSrefit ) continue; // already done + if ( (trStat & AliESDtrack::kTPCout) && !(trStat & AliESDtrack::kTPCrefit) ) continue; + // + currTr = GetTrackHyp(itr); + currTr->AliExternalTrackParam::operator=(*esdTr); // fetch current ESDtrack kinematics + if (RefitTrack(currTr,fITS->GetRMin())) { // propagate up to inside radius of the beam pipe + UpdateESDTrack(currTr,AliESDtrack::kITSrefit); + } + else { + AliInfo(Form("Refit Failed for track %d",itr)); + } + } // - - Info("RefitInward","To be implemented"); return 0; } @@ -461,12 +485,14 @@ Bool_t AliITSUTrackerGlo::GoToExitFromLayer(AliITSUSeed* seed, AliITSURecoLayer* double xToGo = lr->GetR(dir); if (check) { // do we need to track till the surface of the current layer ? double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius + // AliInfo(Form(" dir:%d Cur: %e Tgt: %e",dir,Sqrt(curR2),xToGo)); if (dir>0) { if (curR2-xToGo*xToGo>fgkToler) return kTRUE; } // on the surface or outside of the layer else if (dir<0) { if (xToGo*xToGo-curR2>fgkToler) return kTRUE; } // on the surface or outside of the layer } if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; // go via layer to its boundary, applying material correction. if (!PropagateSeed(seed,xToGo,fCurrMass, lr->GetMaxStep())) return kFALSE; + // return kTRUE; // } @@ -485,6 +511,7 @@ Bool_t AliITSUTrackerGlo::GoToExitFromLayer(AliExternalTrackParam* seed, AliITSU if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; // go via layer to its boundary, applying material correction. if (!PropagateSeed(seed,xToGo,fCurrMass, lr->GetMaxStep())) return kFALSE; + // return kTRUE; // } @@ -860,7 +887,7 @@ Bool_t AliITSUTrackerGlo::RefitTrack(AliITSUTrackHyp* trc, Double_t rDest, Bool_ if (!lr->IsActive() || fClInfo[ilrA2=(ilrA<<1)]<0) continue; // if (ilr!=lrStart && !TransportToLayer(&tmpTr,lrStart,ilr)) { - printf("Failed to transport %d -> %d\n",lrStart,ilr); + AliInfo(Form("Failed to transport %d -> %d\n",lrStart,ilr)); return kFALSE; // go to the entrance to the layer } lrStart = ilr; @@ -879,11 +906,20 @@ Bool_t AliITSUTrackerGlo::RefitTrack(AliITSUTrackHyp* trc, Double_t rDest, Bool_ for (int icl=0;iclGetCluster(iclLr[icl]); AliITSURecoSens* sens = lr->GetSensorFromID(clus->GetVolumeId()); - if (!tmpTr.Rotate(sens->GetPhiTF())) return kFALSE; - printf("Refit cl:%d on lr %d Need to go %.4f -> %.4f\n",icl,ilrA,tmpTr.GetX(),sens->GetXTF()+clus->GetX()); - if (!PropagateSeed(&tmpTr,sens->GetXTF()+clus->GetX(),fCurrMass)) return kFALSE; - if (!tmpTr.Update(clus)) return kFALSE; - printf("AfterRefit: "); tmpTr.AliExternalTrackParam::Print(); + if (!tmpTr.Rotate(sens->GetPhiTF())) { + AliInfo(Form("Failed on rotate to %f",sens->GetPhiTF())); + return kFALSE; + } + //printf("Refit cl:%d on lr %d Need to go %.4f -> %.4f\n",icl,ilrA,tmpTr.GetX(),sens->GetXTF()+clus->GetX()); + if (!PropagateSeed(&tmpTr,sens->GetXTF()+clus->GetX(),fCurrMass)) { + AliInfo(Form("Failed on propagate to %f",sens->GetXTF()+clus->GetX())); + return kFALSE; + } + if (!tmpTr.Update(clus)) { + AliInfo(Form("Failed on Update")); + return kFALSE; + } + //printf("AfterRefit: "); tmpTr.AliExternalTrackParam::Print(); if (stopAtLastCl && ++clCount==ncl) return kTRUE; // it was requested to not propagate after last update } // @@ -892,11 +928,17 @@ Bool_t AliITSUTrackerGlo::RefitTrack(AliITSUTrackHyp* trc, Double_t rDest, Bool_ // Still, try to go as close as possible to rDest. // if (lrStart!=lrStop) { - printf("Going to last layer %d -> %d\n",lrStart,lrStop); - if (!TransportToLayer(&tmpTr,lrStart,lrStop)) return kTRUE; - if (!GoToExitFromLayer(&tmpTr,fITS->GetLayer(lrStop),dir)) return kFALSE; // go till the exit from layer + //printf("Going to last layer %d -> %d\n",lrStart,lrStop); + if (!TransportToLayer(&tmpTr,lrStart,lrStop)) { + AliInfo(Form("Failed on TransportToLayer %d->%d",lrStart,lrStop)); + return kTRUE; + } + if (!GoToExitFromLayer(&tmpTr,fITS->GetLayer(lrStop),dir)) { + AliFatal(Form("Failed on GoToExitFromLayer %d",lrStop)); + return kTRUE; // go till the exit from layer + } // - printf("On exit from last layer\n"); + //printf("On exit from last layer\n"); tmpTr.AliExternalTrackParam::Print(); // go to the destination radius if (!tmpTr.GetXatLabR(rDest,rDest,GetBz(),dir)) return kTRUE; diff --git a/ITS/UPGRADE/AliITSUTrackerGlo.h b/ITS/UPGRADE/AliITSUTrackerGlo.h index a1e7b71c066..3ee304e99f6 100644 --- a/ITS/UPGRADE/AliITSUTrackerGlo.h +++ b/ITS/UPGRADE/AliITSUTrackerGlo.h @@ -58,13 +58,15 @@ class AliITSUTrackerGlo : public AliTracker { Bool_t InitHypothesis(AliESDtrack *esdTr, Int_t esdID); Bool_t TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo); Bool_t TransportToLayer(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo); - Bool_t GoToExitFromLayer(AliITSUSeed* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kFALSE); - Bool_t GoToExitFromLayer(AliExternalTrackParam* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kFALSE); + Bool_t GoToExitFromLayer(AliITSUSeed* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kTRUE); + Bool_t GoToExitFromLayer(AliExternalTrackParam* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kTRUE); Bool_t GoToEntranceToLayer(AliITSUSeed* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kFALSE); Bool_t GoToEntranceToLayer(AliExternalTrackParam* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kFALSE); Bool_t PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep=1.0, Bool_t matCorr=kTRUE); Bool_t PropagateSeed(AliExternalTrackParam *seed, Double_t xToGo, Double_t mass, Double_t maxStep=1.0, Bool_t matCorr=kTRUE); Bool_t RefitTrack(AliITSUTrackHyp* trc, Double_t r, Bool_t stopAtLastCl=kFALSE); + Int_t GetTrackingPhase() const {return fTrackPhase;} + // void KillSeed(AliITSUSeed* seed, Bool_t branch=kFALSE); Bool_t NeedToKill(AliITSUSeed* seed, Int_t flag); @@ -83,6 +85,7 @@ class AliITSUTrackerGlo : public AliTracker { void FinalizeHypotheses(); void UpdateESDTrack(AliITSUTrackHyp* hyp,Int_t flag); void CookMCLabel(AliITSUTrackHyp* hyp); + void SetTrackingPhase(Int_t p) {fTrackPhase = p;} // protected: TObject*& NextFreeSeed(); -- 2.43.0