]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Made Track Hypothesis container to derive from AliKalmanTrack for ESD update
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jan 2013 19:08:19 +0000 (19:08 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jan 2013 19:08:19 +0000 (19:08 +0000)
ITS/UPGRADE/AliITSUSeed.cxx
ITS/UPGRADE/AliITSUSeed.h
ITS/UPGRADE/AliITSUTrackHyp.cxx
ITS/UPGRADE/AliITSUTrackHyp.h
ITS/UPGRADE/AliITSUTrackerGlo.cxx
ITS/UPGRADE/AliITSUTrackerGlo.h

index 66b3bad5614a9b70e9628cdd36d74125af805edf..2017cba1d9296a8e4655d44e04b48673239407df 100644 (file)
@@ -2,6 +2,7 @@
 #include <TMath.h>
 #include "AliITSUSeed.h"
 #include "AliLog.h"
+#include "AliESDtrack.h"
 using namespace TMath;
 
 ClassImp(AliITSUSeed)
@@ -82,6 +83,20 @@ void AliITSUSeed::Print(Option_t* opt) const
   if (opts.Contains("parent") && GetParent()) GetParent()->Print(opt);
 }
 
+//______________________________________________________________________________
+void AliITSUSeed::InitFromESDTrack(const AliESDtrack* esdTr)
+{
+  // init seed from ESD track
+  TObject::Clear();
+  AliExternalTrackParam::operator=(*esdTr);
+  ResetFMatrix();
+  fHitsPattern = 0;
+  fClID = 0;
+  fChi2Glo = fChi2Cl = fChi2Penalty = 0;
+  fParent = 0; //!!!
+}
+
+
 //______________________________________________________________________________
 Float_t AliITSUSeed::GetChi2GloNrm() const
 {
index c5b14509e3d98aae18f31cc6b4bd503cec202dba..eb09884e9f28151e3a26f04410edbd227b6ff807 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "AliExternalTrackParam.h"
 #include "AliITSUAux.h"
+class AliESDtrack;
+
 using namespace AliITSUAux;
 
 
@@ -51,6 +53,7 @@ class AliITSUSeed: public AliExternalTrackParam
   virtual Int_t          Compare(const TObject* obj)      const;
   //
   // test
+  void            InitFromESDTrack(const AliESDtrack* esdTr);
   void            ResetFMatrix();
   void            ApplyELoss2FMatrix(Double_t frac, Bool_t beforeProp);
   Bool_t          ApplyMaterialCorrection(Double_t xOverX0, Double_t xTimesRho, Double_t mass, Bool_t beforeProp);
index 80bbe99a0e0e5ebe6928e9cc8b5943ef1401950e..9173dd4133f8f2913a833b8e01f5cc40cbea9926 100644 (file)
@@ -1,4 +1,6 @@
 #include "AliITSUTrackHyp.h"
+#include "AliESDtrack.h"
+#include "AliCluster.h"
 
 ClassImp(AliITSUTrackHyp)
 
@@ -7,7 +9,7 @@ ClassImp(AliITSUTrackHyp)
 //__________________________________________________________________
 AliITSUTrackHyp::AliITSUTrackHyp(Int_t nlr) 
 : fNLayers(nlr)
-  ,fESDSeed(0)
+  ,fESDTrack(0)
   ,fLayerSeeds(0)
 {
   // def. c-tor
@@ -23,9 +25,9 @@ AliITSUTrackHyp::~AliITSUTrackHyp()
 
 //__________________________________________________________________
 AliITSUTrackHyp::AliITSUTrackHyp(const AliITSUTrackHyp &src)
-  : TObject(src)
+  : AliKalmanTrack(src)
   , fNLayers(src.fNLayers)
-  , fESDSeed(src.fESDSeed)
+  , fESDTrack(src.fESDTrack)
   , fLayerSeeds(0)
 {
   // copy c-tor
@@ -60,3 +62,57 @@ void AliITSUTrackHyp::Print(Option_t* ) const
   printf("Track Hyp.#%4d. NSeeds:",GetUniqueID());
   for (int i=0;i<fNLayers;i++) printf(" (%d) %3d",i,GetNSeeds(i)); printf("\n");
 }
+
+//__________________________________________________________________
+AliITSUSeed* AliITSUTrackHyp::GetWinner() const
+{
+  // Get best candidate
+  return fLayerSeeds[0].GetEntriesFast()>0 ? GetSeed(0,0) : 0;
+}
+
+//__________________________________________________________________
+void AliITSUTrackHyp::DefineWinner(int lr, int id)
+{
+  // assign best candidate
+  AliITSUSeed* winner = GetSeed(lr,id);
+  this->AliExternalTrackParam::operator=(*winner);
+  SetChi2(winner->GetChi2GloNrm());
+  SetNumberOfClusters(winner->GetNLayersHit());
+}
+
+//__________________________________________________________________
+void AliITSUTrackHyp::UpdateESD()
+{
+  // update ESD track
+  AliESDtrack* esdTr = GetESDTrack();
+  if (!esdTr) return;
+  AliITSUSeed* win = GetWinner();
+  if (!win) return;
+  esdTr->UpdateTrackParams(this,AliESDtrack::kITSin);
+}
+
+
+
+//__________________________________________________________________
+Double_t AliITSUTrackHyp::GetPredictedChi2(const AliCluster */*c*/) const
+{
+  // NA
+  AliFatal("Not to be used");
+  return 0;
+}
+
+//__________________________________________________________________
+Bool_t AliITSUTrackHyp::PropagateTo(Double_t /*xr*/, Double_t /*x0*/, Double_t /*rho*/)
+{
+  // NA
+  AliFatal("Not to be used");
+  return 0;
+}
+
+//__________________________________________________________________
+Bool_t AliITSUTrackHyp::Update(const AliCluster* /*c*/, Double_t /*chi2*/, Int_t /*index*/)
+{
+  // NA
+  AliFatal("Not to be used");
+  return kFALSE;
+}
index ffeb2d008ca52d1271b3ef03ba23c6e17cb23fde..9945c654b0f60044f0031711046d98b9f65c539e 100644 (file)
@@ -3,12 +3,14 @@
 
 #include <TObject.h>
 #include <TObjArray.h>
+#include "AliKalmanTrack.h"
 #include "AliITSUSeed.h"
-
+class AliESDtrack;
+class AliCluster;
 
 // Container for track hypotheses
 
-class AliITSUTrackHyp: public TObject
+class AliITSUTrackHyp: public AliKalmanTrack
 {
  public:
   AliITSUTrackHyp(Int_t nlr=0);
@@ -17,38 +19,35 @@ class AliITSUTrackHyp: public TObject
   virtual ~AliITSUTrackHyp();
   //
   Int_t              GetNLayers()        const {return fNLayers;}
-  Int_t              GetNSeeds(Int_t lr) const {return lr<fNLayers ? fLayerSeeds[lr].GetEntriesFast() : 1;}
-  AliITSUSeed*       GetSeed(Int_t lr, Int_t id) const;
-  AliITSUSeed*       GetESDSeed()        const {return fESDSeed;}
+  Int_t              GetNSeeds(Int_t lr) const {return fLayerSeeds[lr].GetEntriesFast();}
+  AliITSUSeed*       GetSeed(Int_t lr, Int_t id) const {return (AliITSUSeed*)fLayerSeeds[lr].UncheckedAt(id);}
+  AliITSUSeed*       GetWinner()         const;
+  AliESDtrack*       GetESDTrack()       const {return fESDTrack;}
+  void               DefineWinner(Int_t lr, Int_t id);
   const TObjArray*   GetLayerSeeds(Int_t lr) const {return lr<fNLayers ? &fLayerSeeds[lr] : 0;}
-  void               AddSeed(AliITSUSeed* seed, Int_t lr);
-  void               SetESDSeed(AliITSUSeed* seed) {fESDSeed = seed;}
+  void               AddSeed(AliITSUSeed* seed, Int_t lr) {fLayerSeeds[lr].AddLast(seed);}
+  void               SetESDTrack(AliESDtrack* esdtr) {fESDTrack = esdtr;}
+  void               UpdateESD();
+  //
+  void               SetChi2(Double_t chi2) {fChi2 = chi2;}
   //
-  
+  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 Double_t   GetPIDsignal()          const { return 0;}
   //
   virtual void       Print(Option_t* option = "") const;
   //
  protected:
   UChar_t          fNLayers;               // number of layers
-  AliITSUSeed*     fESDSeed;               // bare esd (TPC) seed
+  AliESDtrack*     fESDTrack;              // reference esd track
   TObjArray*       fLayerSeeds;            // seeds of given layer
   //
   ClassDef(AliITSUTrackHyp,1)
 };
 
-//___________________________________________________________________
-inline AliITSUSeed* AliITSUTrackHyp::GetSeed(Int_t lr, Int_t id) const
-{
-  //return requested seed of given layer, no check is done on seed index
-  return lr<fNLayers ? (AliITSUSeed*)fLayerSeeds[lr].UncheckedAt(id) : fESDSeed;
-}
-
-//___________________________________________________________________
-inline void AliITSUTrackHyp::AddSeed(AliITSUSeed* seed, Int_t lr)
-{
-  //return requested seed of given layer, no check is done
-  if (lr<fNLayers) fLayerSeeds[lr].AddLast(seed);
-  else             fESDSeed = seed;
-}
 
 #endif
index 7f838050955617bbf4d93fca395193d2041f2dae..dfb7b2f0afe4c81757cf6ad19ab5c0ce3ce56eb4 100644 (file)
@@ -119,6 +119,7 @@ Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv)
   //
   printf("Hypotheses for current event (N seeds in pool: %d, size: %d)\n",fSeedsPool.GetEntriesFast(),fSeedsPool.GetSize());
   fHypStore.Print();
+  FinalizeHypotheses();
   //
   return 0;
 }
@@ -201,22 +202,34 @@ void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr, Int_t esdID)
 {
   // find prolongaion candidates finding for single seed
   //
+  AliITSUSeed seedUC;  // copy of the seed from the upper layer
+  AliITSUSeed seedT;   // transient seed between the seedUC and new prolongation hypothesis
+  //
   if (!NeedToProlong(esdTr)) return;  // are we interested in this track?
-  if (!InitSeed(esdTr,esdID)) return;  // initialize prolongations hypotheses tree
+  if (!InitHypothesis(esdTr,esdID)) return;  // initialize prolongations hypotheses tree
   //
   AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1];
-  AliITSUSeed seedUC;  // copy of the seed from the upper layer
-  AliITSUSeed seedT;   // transient seed between the seedUC and new prolongation hypothesis
   //
   TObjArray clArr; // container for transfer of clusters matching to seed
   //
-  for (int ila=fITS->GetNLayersActive();ila--;) {
+  int nLrActive = fITS->GetNLayersActive();
+  for (int ila=nLrActive;ila--;) {
     int ilaUp = ila+1;                         // prolong seeds from layer above
-    int nSeedsUp = fCurrHyp->GetNSeeds(ilaUp);
+    //
+    // for the outermost layer the seed is created from the ESD track
+    int nSeedsUp = (ilaUp==nLrActive) ? 1 : fCurrHyp->GetNSeeds(ilaUp);
+    //
     for (int isd=0;isd<nSeedsUp;isd++) {
-      AliITSUSeed* seedU = fCurrHyp->GetSeed(ilaUp,isd);  // seed on prev.active layer to prolong
-      seedUC = *seedU;                          // its copy will be prolonged
-      seedUC.SetParent(seedU);
+      AliITSUSeed* seedU;
+      if (ilaUp==nLrActive) {
+       seedU = 0;
+       seedUC.InitFromESDTrack(esdTr);
+      }
+      else {
+       seedU = fCurrHyp->GetSeed(ilaUp,isd);  // seed on prev.active layer to prolong  
+       seedUC = *seedU;                       // its copy will be prolonged
+       seedUC.SetParent(seedU);
+      }
       seedUC.ResetFMatrix();                    // reset the matrix for propagation to next layer
       // go till next active layer
       AliInfo(Form("working on Lr:%d Seed:%d of %d",ila,isd,nSeedsUp));
@@ -224,12 +237,12 @@ void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr, Int_t esdID)
        //
        AliInfo("Transport failed");
        // Check if the seed satisfies to track definition
-       if (NeedToKill(&seedUC,kTransportFailed)) seedU->Kill(); 
+       if (NeedToKill(&seedUC,kTransportFailed) && seedU) seedU->Kill(); 
        continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing
       }
       AliITSURecoLayer* lrA = fITS->GetLayerActive(ila);
       if (!GetRoadWidth(&seedUC, ila)) { // failed to find road width on the layer
-       if (NeedToKill(&seedUC,kRWCheckFailed)) seedU->Kill(); 
+       if (NeedToKill(&seedUC,kRWCheckFailed) && seedU) seedU->Kill(); 
        continue;
       }
       int nsens = lrA->FindSensors(&fTrImpData[kTrPhi0], hitSens);  // find detectors which may be hit by the track
@@ -291,7 +304,7 @@ void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr, Int_t esdID)
 }
 
 //_________________________________________________________________________
-Bool_t AliITSUTrackerGlo::InitSeed(AliESDtrack *esdTr, Int_t esdID)
+Bool_t AliITSUTrackerGlo::InitHypothesis(AliESDtrack *esdTr, Int_t esdID)
 {
   // init prolongaion candidates finding for single seed
   fCurrHyp = GetTrackHyp(esdID);
@@ -301,16 +314,11 @@ Bool_t AliITSUTrackerGlo::InitSeed(AliESDtrack *esdTr, Int_t esdID)
   fCurrESDtrack = esdTr;
   if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin
   //
-  AliITSUSeed* seed = NewSeedFromPool();
-  seed->SetLr(fITS->GetNLayersActive());   // fake layer
-  seed->AliExternalTrackParam::operator=(*esdTr);
-  seed->SetParent(esdTr);
-  int nl = fITS->GetNLayersActive();
-  fCurrHyp = new AliITSUTrackHyp(nl);
-  fCurrHyp->SetESDSeed(seed);
-  AddProlongationHypothesis(seed,nl);
+  fCurrHyp = new AliITSUTrackHyp(fITS->GetNLayersActive());
+  fCurrHyp->SetESDTrack(esdTr);
   fCurrHyp->SetUniqueID(esdID);
   SetTrackHyp(fCurrHyp,esdID);
+  //
   return kTRUE;
   // TO DO
 }
@@ -354,6 +362,45 @@ Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t
   //
 }
 
+//_________________________________________________________________________
+Bool_t AliITSUTrackerGlo::TransportToLayer(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo)
+{
+  // transport track from layerFrom to the entrance of layerTo
+  //  
+  const double kToler = 1e-6; // tolerance for layer on-surface check
+  //
+  int dir = lTo > lFrom ? 1:-1;
+  AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested
+  Bool_t checkFirst = kTRUE;
+  while(lFrom!=lTo) {
+    double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius
+    if (lrFr) {
+      Bool_t doLayer = kTRUE;
+      double xToGo = dir>0 ? lrFr->GetRMax() : lrFr->GetRMin();
+      if (checkFirst) { // do we need to track till the surface of the current layer ?
+       checkFirst = kFALSE;
+       if      (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
+       else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
+      }
+      if (doLayer) {
+       if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
+       // go via layer to its boundary, applying material correction.
+       if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE;
+      }
+    }
+    AliITSURecoLayer* lrTo =  fITS->GetLayer( (lFrom+=dir) );
+    if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom));
+    //
+    // go the entrance of the layer, assuming no materials in between
+    double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax();
+    if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
+    if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE;
+    lrFr = lrTo;
+  }
+  return kTRUE;
+  //
+}
+
 //_________________________________________________________________________
 Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA)
 {
@@ -526,6 +573,50 @@ Bool_t AliITSUTrackerGlo::PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Doubl
   return kTRUE;
 }
 
+//______________________________________________________________________________
+Bool_t AliITSUTrackerGlo::PropagateSeed(AliExternalTrackParam *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr) 
+{
+  // propagate seed to given x applying material correction if requested
+  const Double_t kEpsilon = 1e-5;
+  Double_t xpos     = seed->GetX();
+  Int_t dir         = (xpos<xToGo) ? 1:-1;
+  Double_t xyz0[3],xyz1[3],param[7];
+  //
+  Bool_t updTime = dir>0 && seed->IsStartedTimeIntegral();
+  if (matCorr || updTime) seed->GetXYZ(xyz1);   //starting global position
+  while ( (xToGo-xpos)*dir > kEpsilon){
+    Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
+    Double_t x    = xpos+step;
+    Double_t bz=GetBz();   // getting the local Bz
+    if (!seed->PropagateTo(x,bz))  return kFALSE;
+    double ds = 0;
+    if (matCorr || updTime) {
+      xyz0[0]=xyz1[0]; // global pos at the beginning of step
+      xyz0[1]=xyz1[1];
+      xyz0[2]=xyz1[2];
+      seed->GetXYZ(xyz1);    //  // global pos at the end of step
+      //
+      if (matCorr) {
+       MeanMaterialBudget(xyz0,xyz1,param);    
+       Double_t xrho=param[0]*param[4], xx0=param[1];
+       if (dir>0) xrho = -xrho; // outward should be negative
+       if (!seed->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE;
+       ds = param[4];
+      }
+      else { // matCorr is not requested but time integral is
+       double d0 = xyz1[0]-xyz0[0];
+       double d1 = xyz1[1]-xyz0[1];
+       double d2 = xyz1[2]-xyz0[2];    
+       ds = TMath::Sqrt(d0*d0+d1*d1+d2*d2);
+      }
+    }
+    if (updTime) seed->AddTimeStep(ds);
+    //
+    xpos = seed->GetX();
+  }
+  return kTRUE;
+}
+
 //______________________________________________________________________________
 void AliITSUTrackerGlo::SaveCurrentTrackHypotheses()
 {
@@ -534,3 +625,18 @@ void AliITSUTrackerGlo::SaveCurrentTrackHypotheses()
   // TODO
   
 }
+
+//______________________________________________________________________________
+void AliITSUTrackerGlo::FinalizeHypotheses()
+{
+  // select winner for each hypothesis, remove cl. sharing conflicts
+  AliInfo("TODO");
+  //
+  int nh = fHypStore.GetEntriesFast();
+  for (int ih=0;ih<nh;ih++) {
+    AliITSUTrackHyp* hyp = (AliITSUTrackHyp*) fHypStore.UncheckedAt(ih); 
+    if (!hyp) continue;
+    hyp->UpdateESD();
+  }
+
+}
index 8b879364458941bff40f729c2be1603367415992..ad1105112705fb68a2bd85d9a236872b88561607 100644 (file)
@@ -53,9 +53,11 @@ class AliITSUTrackerGlo : public AliTracker {
   Bool_t                 NeedToProlong(AliESDtrack* estTr);
   void                   Init(AliITSUReconstructor* rec);
   void                   FindTrack(AliESDtrack* esdTr, Int_t esdID);
-  Bool_t                 InitSeed(AliESDtrack *esdTr, Int_t esdID);
+  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                 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                 NeedToKill(AliITSUSeed* seed, Int_t flag);
   Bool_t                 GetRoadWidth(AliITSUSeed* seed, int ilrA);
@@ -67,6 +69,7 @@ class AliITSUTrackerGlo : public AliTracker {
   void                   SetTrackHyp(AliITSUTrackHyp* hyp,Int_t id) {fHypStore.AddAtAndExpand(hyp,id);}
   void                   DeleteLastSeedFromPool()                   {fSeedsPool.RemoveLast();}
   void                   SaveCurrentTrackHypotheses();
+  void                   FinalizeHypotheses();
  //
 
  private: