]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/UPGRADE/AliITSUTrackHyp.cxx
Integrating the Cooked Matrix tracker into the commom reconstruction framework
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUTrackHyp.cxx
index 5f974a9d89b027322ad24dfa1737954d37cf711f..394ac47f0d41bf914d06d8c23d04bd78d6aa7bb8 100644 (file)
@@ -2,6 +2,7 @@
 #include "AliESDtrack.h"
 #include "AliCluster.h"
 #include "AliITSUAux.h"
+#include <TString.h>
 
 ClassImp(AliITSUTrackHyp)
 
@@ -12,6 +13,8 @@ AliITSUTrackHyp::AliITSUTrackHyp(Int_t nlr)
 : fNLayers(nlr)
   ,fITSLabel(0)
   ,fESDTrack(0)
+  ,fWinner(0)
+  ,fTPCSeed(0)
   ,fLayerSeeds(0)
 {
   // def. c-tor
@@ -23,6 +26,7 @@ AliITSUTrackHyp::~AliITSUTrackHyp()
 {
   // d-tor
   delete[] fLayerSeeds;
+  delete fTPCSeed;
 }
 
 //__________________________________________________________________
@@ -31,9 +35,11 @@ AliITSUTrackHyp::AliITSUTrackHyp(const AliITSUTrackHyp &src)
   , fNLayers(src.fNLayers)
   , fITSLabel(src.fITSLabel)
   , fESDTrack(src.fESDTrack)
+  , fWinner(0)
+  , fTPCSeed(src.fTPCSeed)
   , fLayerSeeds(0)
 {
-  // copy c-tor
+  // copy c-tor. Note: it is shallow
   if (fNLayers>0) {
     fLayerSeeds = new TObjArray[fNLayers];
     for (int ilr=fNLayers;ilr--;) {
@@ -44,10 +50,60 @@ AliITSUTrackHyp::AliITSUTrackHyp(const AliITSUTrackHyp &src)
        AddSeed(sd,ilr);
       }      
     }
+    fWinner = src.fWinner;
   }
   //
 }
 
+//__________________________________________________________________
+AliITSUTrackHyp::AliITSUTrackHyp(const AliKalmanTrack &src)
+  : AliKalmanTrack(src)
+  , fNLayers(0)
+  , fITSLabel(0)
+  , fESDTrack(0)
+  , fWinner(0)
+  , fTPCSeed(0)
+  , fLayerSeeds(0)
+{
+  // copy c-tor. from KalmanTrack
+  //
+}
+
+//__________________________________________________________________
+AliITSUTrackHyp::AliITSUTrackHyp(const AliESDtrack &src)
+  : AliKalmanTrack()
+  , fNLayers(0)
+  , fITSLabel(0)
+  , fESDTrack(0)
+  , fWinner(0)
+  , fTPCSeed(0)
+  , fLayerSeeds(0)
+{
+  // copy c-tor. from ESD track: take only kinematics, mass and time integral
+  AliExternalTrackParam::operator=((const AliExternalTrackParam&)src);
+  SetMass(src.GetMassForTracking());
+  if (src.IsOn(AliESDtrack::kTIME)) {
+    StartTimeIntegral();
+    SetIntegratedLength(src.GetIntegratedLength());
+    double times[AliPID::kSPECIESC];
+    src.GetIntegratedTimes(times,AliPID::kSPECIESC);
+    SetIntegratedTimes(times);
+  }
+  //
+}
+
+//__________________________________________________________________
+void AliITSUTrackHyp::InitFrom(const AliITSUTrackHyp *src)
+{
+  // copy initial params
+  fNLayers = src->fNLayers;
+  fITSLabel = src->fITSLabel;
+  fESDTrack = src->fESDTrack;
+  fWinner = src->fWinner;
+  fTPCSeed = src->fTPCSeed;
+  //
+}
+
 //__________________________________________________________________
 AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliITSUTrackHyp &src)
 {
@@ -60,27 +116,73 @@ AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliITSUTrackHyp &src)
 }
 
 //__________________________________________________________________
-void AliITSUTrackHyp::Print(Option_t* ) const
+AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliKalmanTrack &src)
+{ 
+  // copy kinematics only
+  if (this == &src) return *this;
+  AliKalmanTrack::operator=(src);
+  return *this;
+  //
+}
+
+//__________________________________________________________________
+AliITSUTrackHyp &AliITSUTrackHyp::operator=(const AliESDtrack &src)
+{
+  // copy oparator from ESD track: take only kinematics, mass and time integral
+  AliExternalTrackParam::operator=((const AliExternalTrackParam&)src);
+  SetMass(src.GetMassForTracking());
+  if (src.IsOn(AliESDtrack::kTIME)) {
+    StartTimeIntegral();
+    SetIntegratedLength(src.GetIntegratedLength());
+    double times[AliPID::kSPECIESC];
+    src.GetIntegratedTimes(times,AliPID::kSPECIESC);
+    SetIntegratedTimes(times);
+  }
+  //
+  return *this;
+}
+
+
+//__________________________________________________________________
+void AliITSUTrackHyp::Print(Option_t* opt) const
 {
   printf("Track Hyp.#%4d. NSeeds:",GetUniqueID());
-  for (int i=0;i<fNLayers;i++) printf(" (%d) %3d",i,GetNSeeds(i)); printf("\n");
+  TString opts = opt;
+  opts.ToLower();
+  Bool_t prSeeds = opts.Contains("l");
+  for (int i=0;i<fNLayers;i++) {
+    printf("Lr (%d) %3d ",i,GetNSeeds(i)); 
+    if (prSeeds) {
+      printf("\n");
+      for (int isd=0;isd<GetNSeeds(i);isd++) ((AliITSUSeed*)GetSeed(i,isd))->Print(opt);
+    }
+  }
+  if (!prSeeds) printf("\n");
 }
 
 //__________________________________________________________________
 AliITSUSeed* AliITSUTrackHyp::GetWinner() const
 {
-  // Get best candidate
-  return fLayerSeeds[0].GetEntriesFast()>0 ? GetSeed(0,0) : 0;
+  // Get best candidate. TODO
+  return fWinner;
 }
 
 //__________________________________________________________________
-void AliITSUTrackHyp::DefineWinner(int lr, int id)
+AliITSUSeed* AliITSUTrackHyp::DefineWinner(int lr, int id)
 {
   // assign best candidate
-  AliITSUSeed* winner = GetSeed(lr,id);
-  this->AliExternalTrackParam::operator=(*winner);
-  SetChi2(winner->GetChi2GloNrm());
-  SetNumberOfClusters(winner->GetNLayersHit());
+  int nsd = GetNSeeds(lr);
+  while ( id<nsd && ( !(fWinner=GetSeed(lr,id)) || fWinner->IsKilled() ) ) {id++; fWinner=0;}
+  if (!fWinner) {
+    //    AliInfo(Form("No winner candidates out of %d for %d",nsd,GetUniqueID()));
+    return 0;
+  }
+  UInt_t idESD = GetUniqueID(); // retain ESDtrackID
+  this->AliExternalTrackParam::operator=(*fWinner);
+  SetUniqueID(idESD);
+  SetChi2(fWinner->GetChi2GloNrm());
+  SetNumberOfClusters(fWinner->GetNLayersHit());
+  return fWinner;
 }
 
 //__________________________________________________________________
@@ -109,15 +211,15 @@ Bool_t AliITSUTrackHyp::Update(const AliCluster* /*c*/, Double_t /*chi2*/, Int_t
 }
 
 //__________________________________________________________________
-Bool_t AliITSUTrackHyp::Update(const AliCluster* cl)
+Double_t AliITSUTrackHyp::Update(const AliCluster* cl)
 {
   // update with cluster
   Double_t p[2]={cl->GetY(), cl->GetZ()};
   Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
   double chi2 = AliExternalTrackParam::GetPredictedChi2(p,cov);
-  if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
+  if (!AliExternalTrackParam::Update(p,cov)) return -1;
   SetChi2(GetChi2()+chi2);
-  return kTRUE;
+  return chi2;
 }
 
 //__________________________________________________________________
@@ -126,22 +228,7 @@ 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;
-  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) {
-      int slotLr = lr<<1;
-      clIDarr[ clIDarr[slotLr]<0 ? slotLr : slotLr+1 ] = clID;
-      ncl++;
-    }
-    seed = (AliITSUSeed*)seed->GetParent();
-  }
-  return ncl;
+  return GetWinner() ? GetWinner()->FetchClusterInfo(clIDarr) : 0;
 }
 
 //__________________________________________________________________
@@ -165,7 +252,7 @@ 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;
+  //  int ncl = 0;
   if (!seed) {
     AliFatal("The winner is not set");
     return -1;