]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliTrack.cxx
Coding Convention Violation correction
[u/mrichter/AliRoot.git] / RALICE / AliTrack.cxx
index f51f08637e405b1f0257479b56f18091134949b3..80c75d5323c69ec691d0ec589df50e9e50606789 100644 (file)
@@ -36,8 +36,8 @@
 // t2.SetCharge(0);
 // t2.SetMass(1.115);
 //
-// t1.Info();
-// t2.Info();
+// t1.Data();
+// t2.Data();
 //
 // Float_t pi=acos(-1.);
 // Float_t thcms=0.2*pi; // decay theta angle in cms
 ///////////////////////////////////////////////////////////////////////////
 
 #include "AliTrack.h"
+#include "Riostream.h"
  
 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
  
-AliTrack::AliTrack()
+AliTrack::AliTrack() : TNamed(),Ali4Vector()
 {
 // Default constructor
 // All variables initialised to 0
+ Init();
+ Reset();
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::Init()
+{
+// Initialisation of pointers etc...
  fDecays=0;
  fSignals=0;
- fMasses=0;
- fDmasses=0;
- fPmasses=0;
- Reset();
+ fHypotheses=0;
+ fBegin=0;
+ fEnd=0;
+ fImpactXY=0;
+ fImpactXZ=0;
+ fImpactYZ=0;
+ fClosest=0;
+ fParent=0;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTrack::~AliTrack()
 {
-// Destructor to delete memory allocated for decay tracks array
+// Destructor to delete memory allocated for decay tracks array.
+// This destructor automatically cleares the pointer of this AliTrack
+// from all the link slots of the related AliSignal objects.
+
+ Int_t nsig=GetNsignals();
+ for (Int_t i=1; i<=nsig; i++)
+ {
+  AliSignal* s=GetSignal(i);
+  if (s) s->ResetLinks(this);
+ }
  if (fDecays)
  {
-  fDecays->Delete();
   delete fDecays;
   fDecays=0;
  }
@@ -120,20 +141,112 @@ AliTrack::~AliTrack()
   delete fSignals;
   fSignals=0;
  }
+ if (fHypotheses)
+ {
+  delete fHypotheses;
+  fHypotheses=0;
+ }
+ if (fBegin)
+ {
+  delete fBegin;
+  fBegin=0;
+ }
+ if (fEnd)
+ {
+  delete fEnd;
+  fEnd=0;
+ }
+ if (fImpactXY)
+ {
+  delete fImpactXY;
+  fImpactXY=0;
+ }
+ if (fImpactXZ)
+ {
+  delete fImpactXZ;
+  fImpactXZ=0;
+ }
+ if (fImpactYZ)
+ {
+  delete fImpactYZ;
+  fImpactYZ=0;
+ }
+ if (fClosest)
+ {
+  delete fClosest;
+  fClosest=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliTrack::AliTrack(AliTrack& t) : TNamed(t),Ali4Vector(t)
+{
+// Copy constructor
+ Init();
+
+ fQ=t.fQ;
+ fProb=t.fProb;
+ if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin));
+ if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd));
+ if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY));
+ if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ));
+ if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ));
+ if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest));
+ fUserId=t.fUserId;
+ fChi2=t.fChi2;
+ fNdf=t.fNdf;
+ fCode=t.fCode;
+ fParent=t.fParent;
+
+ Int_t ndec=t.GetNdecay();
+ if (ndec)
+ {
+  fDecays=new TObjArray(ndec);
+  fDecays->SetOwner();
+  for (Int_t it=1; it<=ndec; it++)
+  {
+   AliTrack* tx=t.GetDecayTrack(it);
+   fDecays->Add(new AliTrack(*tx));
+  }
+ }
+
+ Int_t nsig=t.GetNsignals();
+ if (nsig)
+ {
+  fSignals=new TObjArray(nsig);
+  for (Int_t is=1; is<=nsig; is++)
+  {
+   AliSignal* sx=t.GetSignal(is);
+   fSignals->Add(sx);
+  }
+ }
+
+ Int_t nhyp=t.GetNhypotheses();
+ if (nhyp)
+ {
+  fHypotheses=new TObjArray(nhyp);
+  fHypotheses->SetOwner();
+  for (Int_t ih=1; ih<=nhyp; ih++)
+  {
+   AliTrack* tx=t.GetTrackHypothesis(ih);
+   fHypotheses->Add(new AliTrack(*tx));
+  }
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliTrack::Reset()
 {
-// Reset all variables to 0
+// Reset all variables to 0 and delete all auto-generated decay tracks.
  fQ=0;
- fNdec=0;
- fNsig=0;
- fNmasses=0;
+ fChi2=0;
+ fNdf=0;
+ fUserId=0;
+ fCode=0;
+ fProb=0;
  Double_t a[4]={0,0,0,0};
  SetVector(a,"sph");
+ fParent=0;
  if (fDecays)
  {
-  fDecays->Delete();
   delete fDecays;
   fDecays=0;
  }
@@ -143,23 +256,40 @@ void AliTrack::Reset()
   delete fSignals;
   fSignals=0;
  }
- Double_t b[3]={0,0,0};
- fBegin.SetPosition(b,"sph");
- fEnd.SetPosition(b,"sph");
- if (fMasses)
+ if (fHypotheses)
+ {
+  delete fHypotheses;
+  fHypotheses=0;
+ }
+ if (fBegin)
+ {
+  delete fBegin;
+  fBegin=0;
+ }
+ if (fEnd)
+ {
+  delete fEnd;
+  fEnd=0;
+ }
+ if (fImpactXY)
  {
-  delete fMasses;
-  fMasses=0;
+  delete fImpactXY;
+  fImpactXY=0;
  }
- if (fDmasses)
+ if (fImpactXZ)
  {
-  delete fDmasses;
-  fDmasses=0;
+  delete fImpactXZ;
+  fImpactXZ=0;
  }
- if (fPmasses)
+ if (fImpactYZ)
  {
-  delete fPmasses;
-  fPmasses=0;
+  delete fImpactYZ;
+  fImpactYZ=0;
+ }
+ if (fClosest)
+ {
+  delete fClosest;
+  fClosest=0;
  }
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -194,43 +324,45 @@ void AliTrack::SetCharge(Float_t q)
  fQ=q;
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTrack::Info(TString f)
+void AliTrack::Data(TString f)
 {
 // Provide track information within the coordinate frame f
  Double_t m=GetMass();
  Double_t dm=GetResultError();
- cout << " *AliTrack::Info* Mass : " << m
-      << " error : " << dm << " Charge : " << fQ
-      << " Momentum : " << GetMomentum() << " Nmass hyp. : " << fNmasses
-      << " Ntracks : " << fNdec << " Nsignals : " << fNsig << endl;
- for (Int_t i=0; i<fNmasses; i++)
- {
-  cout << " Mass hypothesis " << (i+1) << " Mass : " << fMasses->At(i)
-       << " error : " << fDmasses->At(i) << " prob. : " << fPmasses->At(i)
-       << endl;
- }
- Ali4Vector::Info(f); 
+ const char* name=GetName();
+ const char* title=GetTitle();
+
+ cout << " *" << ClassName() << "::Data*";
+ if (strlen(name))  cout << " Name : " << GetName();
+ if (strlen(title)) cout << " Title : " << GetTitle();
+ cout << endl;
+ cout << " Id : " << fUserId << " Code : " << fCode
+      << " m : " << m << " dm : " << dm << " Charge : " << fQ
+      << " p : " << GetMomentum() << endl;
+ cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
+      << " Nsignals : " << GetNsignals() << endl;
+ Ali4Vector::Data(f); 
 } 
 ///////////////////////////////////////////////////////////////////////////
 void AliTrack::List(TString f)
 {
 // Provide current track and decay level 1 information within coordinate frame f
 
Info(f); // Information of the current track
Data(f); // Information of the current track
 
  // Decay products of this track
  AliTrack* td; 
- for (Int_t id=1; id<=fNdec; id++)
+ for (Int_t id=1; id<=GetNdecay(); id++)
  {
   td=GetDecayTrack(id);
   if (td)
   {
    cout << "  ---Level 1 sec. track no. " << id << endl;
-   td->Info(f); 
+   td->Data(f); 
   }
   else
   {
-   cout << " *AliTrack::List* Error : No decay track present." << endl; 
+   cout << " *AliTrack::List* Error : Empty decay track slot." << endl; 
   }
  }
 } 
@@ -239,19 +371,52 @@ void AliTrack::ListAll(TString f)
 {
 // Provide complete track and decay information within the coordinate frame f
 
- Info(f); // Information of the current track
- cout << " Begin-point :"; fBegin.Info(f);
- cout << " End-point   :"; fEnd.Info(f);
- for (Int_t is=1; is<=GetNsignals(); is++)
+ Data(f); // Information of the current track
+ if (fBegin) { cout << " Begin-point :"; fBegin->Data(f); }
+ if (fEnd)   { cout << " End-point   :"; fEnd->Data(f); }
+
+ Int_t nhyp=GetNhypotheses();
+ if (nhyp)
+ {
+  cout << " List of the " << nhyp << " track hypotheses : " << endl;
+  for (Int_t ih=1; ih<=nhyp; ih++)
+  {
+   AliTrack* tx=GetTrackHypothesis(ih);
+   if (tx) tx->Data(f);
+  }
+ }
+
+ Int_t nsig=GetNsignals();
+ if (nsig)
  {
-  ((AliSignal*)GetSignal(is))->Info(f);
+  cout << " List of the corresponding slots for the " << nsig
+       << " related signals : " << endl;
+  AliPosition r;
+  Int_t nrefs,jslot;
+  TArrayI slotarr;
+  for (Int_t is=1; is<=nsig; is++)
+  {
+   AliSignal* sx=GetSignal(is);
+   if (sx)
+   {
+    nrefs=sx->GetIndices(this,slotarr,0);
+    for (Int_t jref=0; jref<nrefs; jref++)
+    {
+     jslot=slotarr.At(jref);
+     sx->List(jslot);
+    }
+    r=sx->GetPosition();
+    cout << "   Position";
+    r.Data(f);
+   }
+  }
  }
 
  AliTrack* t=this;
- Dump(t,1,f); // Information of all decay products
+ Dumps(t,1,f); // Information of all decay products
 }
 //////////////////////////////////////////////////////////////////////////
-void AliTrack::Dump(AliTrack* t,Int_t n,TString f)
+void AliTrack::Dumps(AliTrack* t,Int_t n,TString f)
 {
 // Recursively provide the info of all decay levels of this track
  AliTrack* td; 
@@ -261,18 +426,36 @@ void AliTrack::Dump(AliTrack* t,Int_t n,TString f)
   if (td)
   {
    cout << "  ---Level " << n << " sec. track no. " << id << endl;
-   td->Info(f); 
-   for (Int_t is=1; is<=td->GetNsignals(); is++)
+   td->Data(f); 
+
+   Int_t nhyp=td->GetNhypotheses();
+   if (nhyp)
    {
-    ((AliSignal*)td->GetSignal(is))->Info(f);
+    cout << " List of the " << nhyp << " track hypotheses : " << endl;
+    for (Int_t ih=1; ih<=nhyp; ih++)
+    {
+     AliTrack* tx=td->GetTrackHypothesis(ih);
+     if (tx) tx->Data(f);
+    }
+   }
+
+   Int_t nsig=td->GetNsignals();
+   if (nsig)
+   {
+    cout << " List of the " << nsig << " related signals : " << endl;
+    for (Int_t is=1; is<=nsig; is++)
+    {
+     AliSignal* sx=td->GetSignal(is);
+     if (sx) sx->Data(f);
+    }
    }
 
    // Go for next decay level of this decay track recursively
-   Dump(td,n+1,f);
+   Dumps(td,n+1,f);
   }
   else
   {
-   cout << " *AliTrack::Dump* Error : No decay track present." << endl; 
+   cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl; 
   }
  }
 } 
@@ -282,10 +465,8 @@ Double_t AliTrack::GetMomentum()
 // Provide the value of the track 3-momentum.
 // The error can be obtained by invoking GetResultError() after
 // invokation of GetMomentum().
-
-// Ali3Vector p=Get3Vector();
-// return sqrt(p.Dot(p));
  Double_t norm=fV.GetNorm();
+ fDresult=fV.GetResultError();
  return norm;
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -351,8 +532,6 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
 // thcms  : cms theta decay angle (in rad.) of m1
 // phicms : cms phi decay angle (in rad.) of m1
  
- fNdec=2; // it's a 2-body decay
-
  Double_t M=GetMass();
  
 // Compute the 4-momenta of the decay products in the cms
@@ -402,10 +581,11 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
  // Enter the boosted data into the decay tracks array
  if (fDecays)
  {
-  fDecays->Delete();
   delete fDecays;
+  fDecays=0;
  }
- fDecays=new TObjArray();
+ fDecays=new TObjArray(2);
+ fDecays->SetOwner();
 
  fDecays->Add(new AliTrack);
  ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
@@ -418,219 +598,268 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
 Int_t AliTrack::GetNdecay()
 {
 // Provide the number of decay produced tracks
- return fNdec;
+ Int_t ndec=0;
+ if (fDecays) ndec=fDecays->GetEntries();
+ return ndec;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTrack* AliTrack::GetDecayTrack(Int_t j)
 {
 // Provide decay produced track number j
 // Note : j=1 denotes the first decay track
- if ((j >= 1) && (j <= fNdec))
+ if (!fDecays)
  {
-  return (AliTrack*)fDecays->At(j-1);
+  cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
+  return 0;
  }
  else
  {
-  cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
-  cout << " -- Decay track number 1 (if any) returned." << endl;
-  return (AliTrack*)fDecays->At(0);
+  if ((j >= 1) && (j <= GetNdecay()))
+  {
+   return (AliTrack*)fDecays->At(j-1);
+  }
+  else
+  {
+   cout << " *AliTrack* decay track number : " << j << " out of range."
+        << " Ndec = " << GetNdecay() << endl;
+   return 0;  
+  }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::RemoveDecays()
+{
+// Remove all decay tracks from this track.
+ if (fDecays)
+ {
+  delete fDecays;
+  fDecays=0;
  }
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliTrack::AddSignal(AliSignal& s)
 {
 // Relate an AliSignal object to this track.
- if (!fSignals) fSignals=new TObjArray();
- fNsig++;
+ if (!fSignals) fSignals=new TObjArray(1);
+
+ // Check if this signal is already stored for this track
+ Int_t nsig=GetNsignals();
+ for (Int_t i=0; i<nsig; i++)
+ {
+  if (&s==fSignals->At(i)) return; 
+ }
+
  fSignals->Add(&s);
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliTrack::RemoveSignal(AliSignal& s)
 {
-// Remove related AliSignal object to this track.
+// Remove related AliSignal object from this track.
  if (fSignals)
  {
   AliSignal* test=(AliSignal*)fSignals->Remove(&s);
-  if (test)
-  {
-   fNsig--;
-   fSignals->Compress();
-  }
+  if (test) fSignals->Compress();
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::RemoveSignals()
+{
+// Remove all related AliSignal objects from this track.
+ if (fSignals)
+ {
+  fSignals->Clear();
+  delete fSignals;
+  fSignals=0;
  }
 }
 ///////////////////////////////////////////////////////////////////////////
 Int_t AliTrack::GetNsignals()
 {
 // Provide the number of related AliSignals.
- return fNsig;
+ Int_t nsig=0;
+ if (fSignals) nsig=fSignals->GetEntries();
+ return nsig;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliSignal* AliTrack::GetSignal(Int_t j)
 {
 // Provide the related AliSignal number j.
 // Note : j=1 denotes the first signal.
- if ((j >= 1) && (j <= fNsig))
+ if (!fSignals)
  {
-  return (AliSignal*)fSignals->At(j-1);
+  cout << " *AliTrack::GetSignal* No signals present." << endl;
+  return 0;
  }
  else
  {
-  cout << " *AliTrack* signal number : " << j << " out of range." << endl;
-  cout << " -- Signal number 1 (if any) returned." << endl;
-  return (AliSignal*)fDecays->At(0);
+  if ((j >= 1) && (j <= GetNsignals()))
+  {
+   return (AliSignal*)fSignals->At(j-1);
+  }
+  else
+  {
+   cout << " *AliTrack* signal number : " << j << " out of range."
+        << " Nsig = " << GetNsignals() << endl;
+   return 0;
+  }
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTrack::SetBeginPoint(AliPosition p)
+void AliTrack::AddTrackHypothesis(AliTrack& t)
 {
-// Store the position of the track begin-point.
- fBegin=p;
-}
-///////////////////////////////////////////////////////////////////////////
-AliPosition AliTrack::GetBeginPoint()
-{
-// Provide the position of the track begin-point.
- return fBegin;
+// Relate a track hypothesis to this track.
+// Note : a private copy of the input track will be made via the Clone()
+//        facility.
+ if (!fHypotheses)
+ {
+  fHypotheses=new TObjArray(1);
+  fHypotheses->SetOwner();
+ }
+ fHypotheses->Add(t.Clone());
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTrack::SetEndPoint(AliPosition p)
+void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
 {
-// Store the position of the track end-point.
- fEnd=p;
+// Add a track hypothesis by explicitly setting the mass and probability.
+// This will affect e.g. the hypothesis track's energy, since the momentum
+// and all other attributes will be copied from the current track.
+//
+// Input arguments :
+// ----------------- 
+// prob=probalility  m=mass value  dm=error on the mass value.
+// The default value for the mass error dm is 0.
+
+ AliTrack t(*this);
+ t.RemoveDecays();
+ t.RemoveTrackHypotheses();
+ t.RemoveSignals();
+ t.SetTitle("Mass hypothesis");
+ t.SetMass(m,dm);
+ t.SetProb(prob);
+ AddTrackHypothesis(t);
 }
 ///////////////////////////////////////////////////////////////////////////
-AliPosition AliTrack::GetEndPoint()
+void AliTrack::RemoveTrackHypothesis(AliTrack& t)
 {
-// Provide the position of the track end-point.
- return fEnd;
+// Remove the specified track hypothesis from this track.
+ if (fHypotheses)
+ {
+  AliTrack* test=(AliTrack*)fHypotheses->Remove(&t);
+  if (test) fHypotheses->Compress();
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTrack::AddMassHypothesis(Double_t prob,Double_t m,Double_t dm)
+void AliTrack::RemoveTrackHypotheses()
 {
-// Add a mass hypothesis for this current track.
-// prob=probalility  m=mass value  dm=error on the mass value.
-// The default value for the mass error dm is 0.
- if (!fMasses) fMasses=new TArrayD();
- if (!fDmasses) fDmasses=new TArrayD();
- if (!fPmasses) fPmasses=new TArrayD();
-
- fNmasses++;
- fMasses->Set(fNmasses);
- fDmasses->Set(fNmasses);
- fPmasses->Set(fNmasses);
-
- fMasses->AddAt(m,fNmasses-1);
- fDmasses->AddAt(dm,fNmasses-1);
- fPmasses->AddAt(prob,fNmasses-1);
+// Remove all track hypotheses from this track.
+ if (fHypotheses)
+ {
+  delete fHypotheses;
+  fHypotheses=0;
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliTrack::GetNMassHypotheses()
+Int_t AliTrack::GetNhypotheses()
 {
-// Provide the number of mass hypotheses for this track.
- return fNmasses;
+// Provide the number of track hypotheses.
+ Int_t nhyp=0;
+ if (fHypotheses) nhyp=fHypotheses->GetEntries();
+ return nhyp;
 }
 ///////////////////////////////////////////////////////////////////////////
-Double_t AliTrack::GetMassHypothesis(Int_t j)
+AliTrack* AliTrack::GetTrackHypothesis(Int_t j)
 {
-// Provide the mass of the jth hypothesis for this track.
-// Note : the first hypothesis is indicated by j=1.
+// Provide the j-th track hypothesis.
+// Note : j=1 denotes the first hypothesis.
 // Default : j=0 ==> Hypothesis with highest probability.
-// The error on the mass can be obtained by invoking GetResultError()
-// after invokation of GetMassHypothesis(j).
 
- Double_t m=0,dm=0,prob=0;
+ if (!fHypotheses) return 0;
+
+ Int_t nhyp=GetNhypotheses();
 
  // Check validity of index j
- if (j<0 || j>fNmasses)
+ if (j<0 || j>nhyp)
  {
-  cout << " *AliTrack::GetMassHypothesis* Invalid index j : " << j
-       << " Number of mass hypotheses : " << fNmasses << endl;
-  fDresult=0;
-  return 0;
- }
+   cout << " *AliTrack* hypothesis number : " << j << " out of range."
+        << " Nhyp = " << nhyp << endl;
+   return 0;
+ } 
 
- // Select mass hypothesis with highest probability
- if (j==0) 
+ AliTrack* t=0;
+
+ if (j==0) // Provide track hypothesis with highest probability
  {
-  if (fNmasses) 
+  Float_t prob=0;   
+  t=(AliTrack*)fHypotheses->At(0);
+  if (t) prob=t->GetProb();
+  Float_t probx=0;
+  for (Int_t ih=1; ih<nhyp; ih++)
   {
-   m=fMasses->At(0);
-   dm=fDmasses->At(0);
-   prob=fPmasses->At(0);
-   for (Int_t i=1; i<fNmasses; i++)
+   AliTrack* tx=(AliTrack*)fHypotheses->At(ih);
+   if (tx)
    {
-    if (fPmasses->At(i)>prob)
-    {
-     m=fMasses->At(i);
-     dm=fDmasses->At(i);
-    }
+    probx=tx->GetProb();
+    if (probx > prob) t=tx; 
    }
   }
-  fDresult=dm;
-  return m;  
+  return t;
+ }
+ else // Provide requested j-th track hypothesis
+ {
+  return (AliTrack*)fHypotheses->At(j-1);
  }
-
- // Provide data of requested mass hypothesis
- m=fMasses->At(j-1);
- fDresult=fDmasses->At(j-1);
- return m;
 }
 ///////////////////////////////////////////////////////////////////////////
-Double_t AliTrack::GetMassHypothesisProb(Int_t j)
+void AliTrack::SetBeginPoint(AliPosition& p)
 {
-// Provide the probability of the jth hypothesis for this track.
-// Note : the first hypothesis is indicated by j=1.
-// Default : j=0 ==> Hypothesis with highest probability.
-
- Double_t prob=0;
-
- // Check validity of index j
- if (j<0 || j>fNmasses)
+// Store the position of the track begin-point.
+ if (!fBegin)
  {
-  cout << " *AliTrack::GetMassHypothesisProb* Invalid index j : " << j
-       << " Number of mass hypotheses : " << fNmasses << endl;
-  return 0;
+  fBegin=new AliPositionObj(p);
  }
-
- // Select mass hypothesis with highest probability
- if (j==0) 
+ else
  {
-  if (fNmasses) 
-  {
-   prob=fPmasses->At(0);
-   for (Int_t i=1; i<fNmasses; i++)
-   {
-    if (fPmasses->At(i)>prob) prob=fPmasses->At(i);
-   }
-  }
-  return prob;  
+  fBegin->Load(p);
  }
-
- // Provide probability of requested mass hypothesis
- prob=fPmasses->At(j-1);
- return prob;
+}
+///////////////////////////////////////////////////////////////////////////
+AliPosition* AliTrack::GetBeginPoint()
+{
+// Provide the position of the track begin-point.
+ return fBegin;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetEndPoint(AliPosition& p)
+{
+// Store the position of the track end-point.
+ if (!fEnd)
+ {
+  fEnd=new AliPositionObj(p);
+ }
+ else
+ {
+  fEnd->Load(p);
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliPosition* AliTrack::GetEndPoint()
+{
+// Provide the position of the track end-point.
+ return fEnd;
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliTrack::SetMass()
 {
 // Set the mass and error to the value of the hypothesis with highest prob.
 
- Double_t m=0,dm=0,prob=0;
+ Double_t m=0,dm=0;
 
  // Select mass hypothesis with highest probability
- if (fNmasses) 
+ AliTrack* t=GetTrackHypothesis(0);
+ if (t) 
  {
-  m=fMasses->At(0);
-  dm=fDmasses->At(0);
-  prob=fPmasses->At(0);
-  for (Int_t i=1; i<fNmasses; i++)
-  {
-   if (fPmasses->At(i)>prob)
-   {
-    m=fMasses->At(i);
-    dm=fDmasses->At(i);
-   }
-  }
+  m=t->GetMass();
+  dm=t->GetResultError();
   SetMass(m,dm);
  }
  else
@@ -639,31 +868,302 @@ void AliTrack::SetMass()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliTrack::RemoveMassHypothesis(Int_t j)
+Double_t AliTrack::GetPt()
+{
+// Provide trans. momentum value w.r.t. z-axis.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetPt().
+ Ali3Vector v;
+ v=GetVecTrans();
+ Double_t norm=v.GetNorm();
+ fDresult=v.GetResultError();
+
+ return norm;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliTrack::GetPl()
+{
+// Provide long. momentum value w.r.t. z-axis.
+// Note : the returned value can also be negative.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetPl().
+ Ali3Vector v;
+ v=GetVecLong();
+
+ Double_t pl=v.GetNorm();
+ fDresult=v.GetResultError();
+
+ Double_t a[3];
+ v.GetVector(a,"sph");
+ if (cos(a[1])<0) pl=-pl;
+
+ return pl;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliTrack::GetEt()
+{
+// Provide trans. energy value w.r.t. z-axis.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetEt().
+ Double_t et=GetScaTrans();
+
+ return et;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliTrack::GetEl()
+{
+// Provide long. energy value w.r.t. z-axis.
+// Note : the returned value can also be negative.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetEl().
+ Double_t el=GetScaLong();
+
+ return el;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliTrack::GetMt()
+{
+// Provide transverse mass value w.r.t. z-axis.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetMt().
+ Double_t pt=GetPt();
+ Double_t dpt=GetResultError();
+ Double_t m=GetMass();
+ Double_t dm=GetResultError();
+
+ Double_t mt=sqrt(pt*pt+m*m);
+ Double_t dmt2=0;
+ if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
+
+ fDresult=sqrt(dmt2);
+ return mt;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliTrack::GetRapidity()
+{
+// Provide rapidity value w.r.t. z-axis.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetRapidity().
+// Note : Also GetPseudoRapidity() is available since this class is
+//        derived from Ali4Vector.
+ Double_t e=GetEnergy();
+ Double_t de=GetResultError();
+ Double_t pl=GetPl();
+ Double_t dpl=GetResultError();
+ Double_t sum=e+pl;
+ Double_t dif=e-pl;
+
+ Double_t y=9999,dy2=0;
+ if (sum && dif) y=0.5*log(sum/dif);
+
+ if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
+
+ fDresult=sqrt(dy2);
+ return y;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetImpactPoint(AliPosition& p,TString q)
 {
-// Remove the jth mass hypothesis for this track.
-// Note : the first hypothesis is indicated by j=1.
+// Store the position of the impact-point in the plane "q=0".
+// Here q denotes one of the axes X, Y or Z.
+// Note : The character to denote the axis may be entered in lower or
+//        in uppercase.
+ Int_t axis=0;
+ if (q=="x" || q=="X") axis=1;
+ if (q=="y" || q=="Y") axis=2;
+ if (q=="z" || q=="Z") axis=3;
 
- if (j<=0 || j>fNmasses) // Check validity of index j
+ switch (axis)
  {
-  cout << " *AliTrack::RemoveMassHypothesis* Invalid index j : " << j
-       << " Number of mass hypotheses : " << fNmasses << endl;
+  case 1: // Impact-point in the plane X=0
+   if (!fImpactYZ)
+   {
+    fImpactYZ=new AliPositionObj(p);
+   }
+   else
+   {
+    fImpactYZ->Load(p);
+   }
+   break;
+
+  case 2: // Impact-point in the plane Y=0
+   if (!fImpactXZ)
+   {
+    fImpactXZ=new AliPositionObj(p);
+   }
+   else
+   {
+    fImpactXZ->Load(p);
+   }
+   break;
+
+  case 3: // Impact-point in the plane Z=0
+   if (!fImpactXY)
+   {
+    fImpactXY=new AliPositionObj(p);
+   }
+   else
+   {
+    fImpactXY->Load(p);
+   }
+   break;
+
+  default: // Unsupported axis
+   cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
+        << " Possible axes are 'X', 'Y' and 'Z'." << endl; 
+   break;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliPosition* AliTrack::GetImpactPoint(TString q)
+{
+// Provide the position of the impact-point in the plane "q=0".
+// Here q denotes one of the axes X, Y or Z.
+// Note : The character to denote the axis may be entered in lower or
+//        in uppercase.
+ Int_t axis=0;
+ if (q=="x" || q=="X") axis=1;
+ if (q=="y" || q=="Y") axis=2;
+ if (q=="z" || q=="Z") axis=3;
+
+ switch (axis)
+ {
+  case 1: // Impact-point in the plane X=0
+   return fImpactYZ;
+
+  case 2: // Impact-point in the plane Y=0
+   return fImpactXZ;
+
+  case 3: // Impact-point in the plane Z=0
+   return fImpactXY;
+
+  default: // Unsupported axis
+   cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
+        << " Possible axes are 'X', 'Y' and 'Z'." << endl; 
+   return 0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetId(Int_t id)
+{
+// Set a user defined unique identifier for this track.
+ fUserId=id;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliTrack::GetId()
+{
+// Provide the user defined unique identifier of this track.
+ return fUserId;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetClosestPoint(AliPosition& p)
+{
+// Set position p as the point of closest approach w.r.t. some reference
+ if (!fClosest)
+ {
+  fClosest=new AliPositionObj(p);
  }
  else
  {
-  if (j != fNmasses)
-  {
-   fMasses->AddAt(fMasses->At(fNmasses-1),j-1);
-   fDmasses->AddAt(fDmasses->At(fNmasses-1),j-1);
-   fPmasses->AddAt(fPmasses->At(fNmasses-1),j-1);
-  }
-  fMasses->AddAt(0,fNmasses-1);
-  fDmasses->AddAt(0,fNmasses-1);
-  fPmasses->AddAt(0,fNmasses-1);
-  fNmasses--;
-  fMasses->Set(fNmasses);
-  fDmasses->Set(fNmasses);
-  fPmasses->Set(fNmasses);
+  fClosest->Load(p);
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliPosition* AliTrack::GetClosestPoint()
+{
+// Provide the point of closest approach w.r.t. some reference
+ return fClosest;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetChi2(Float_t chi2)
+{
+// Set the chi-squared value of the track fit.
+ if (chi2<0)
+ {
+  cout << " *AliTrack::SetChi2* Invalid chi2 value : " << chi2 << endl;
+ }
+ else
+ {
+  fChi2=chi2;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetNdf(Int_t ndf)
+{
+// Set the number of degrees of freedom for the track fit.
+ if (ndf<0)
+ {
+  cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl;
+ }
+ else
+ {
+  fNdf=ndf;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Float_t AliTrack::GetChi2()
+{
+// Provide the chi-squared value of the track fit.
+ return fChi2;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliTrack::GetNdf()
+{
+// Provide the number of degrees of freedom for the track fit.
+ return fNdf;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetParticleCode(Int_t code)
+{
+// Set the user defined particle id code (e.g. the PDF convention).
+ fCode=code;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliTrack::GetParticleCode()
+{
+// Provide the user defined particle id code.
+ return fCode;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetParentTrack(AliTrack* t)
+{
+// Set pointer to the parent track.
+ fParent=t;
+}
+///////////////////////////////////////////////////////////////////////////
+AliTrack* AliTrack::GetParentTrack()
+{
+// Provide pointer to the parent track.
+ return fParent;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetProb(Double_t prob)
+{
+// Set hypothesis probability for this track.
+ fProb=prob;
+}
+///////////////////////////////////////////////////////////////////////////
+Float_t AliTrack::GetProb()
+{
+// Provide the hypothesis probability for this track.
+ return fProb;
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliTrack::Clone(const char* name)
+{
+// Make a deep copy of the current object and provide the pointer to the copy.
+// This memberfunction enables automatic creation of new objects of the
+// correct type depending on the object type, a feature which may be very useful
+// for containers when adding objects in case the container owns the objects.
+// This feature allows e.g. AliJet to store either AliTrack objects or
+// objects derived from AliTrack via the AddTrack memberfunction, provided
+// these derived classes also have a proper Clone memberfunction. 
+
+ AliTrack* trk=new AliTrack(*this);
+ if (name)
+ {
+  if (strlen(name)) trk->SetName(name);
  }
+ return trk;
 }
 ///////////////////////////////////////////////////////////////////////////