+void AliTrack::SetFitDetails(TObject* obj)
+{
+// Enter the object containing the fit details.
+// In case an object to hold fit details was already present, this
+// will be deleted first before the new one is stored.
+// This means that SetFitDetails(0) can be used to just remove the
+// existing object with the fit details.
+// All objects derived from TObject can be entered in this way.
+// Obvious candidates for objects containing detailed fit information
+// are functions (e.g. TF1) and histograms (e.g. TH1F).
+// However, using an AliDevice object provides a very versatile facility
+// to store the parameters of various fit procedures.
+// In such a case the AliDevice can be used to provide the various fit
+// definitions and the corresponding fit parameters can be entered as
+// separate AliSignal objects which are stored as hits to the AliDevice.
+// In addition various functions and histograms can be linked to the
+// various AliSignal instances
+// The latter procedure is based on the original idea of Adam Bouchta.
+//
+// Note : The entered object is owned by this AliTrack instance.
+// As such, a private copy of obj will be stored using the Clone()
+// memberfunction.
+// In case the entered object contains pointers to other objects,
+// the user has to provide the appropriate Clone() memberfunction
+// for the class to which the entered object belongs.
+// An example can be seen from AliTrack::Clone().
+//
+ if (fFit)
+ {
+ delete fFit;
+ fFit=0;
+ }
+
+ if (obj) fFit=obj->Clone();
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliTrack::GetFitDetails()
+{
+// Provide the pointer to the object containing the fit details.
+ return fFit;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetTimestamp(AliTimestamp& t)
+{
+// Store the timestamp for this track.
+ if (fTstamp) delete fTstamp;
+ fTstamp=new AliTimestamp(t);
+}
+///////////////////////////////////////////////////////////////////////////
+AliTimestamp* AliTrack::GetTimestamp()
+{
+// Provide the timestamp of this track.
+ return fTstamp;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::RemoveTimestamp()
+{
+// Remove the timestamp from this track.
+ if (fTstamp)
+ {
+ delete fTstamp;
+ fTstamp=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliTrack::GetDistance(AliPosition* p,Float_t scale)
+{
+// Provide distance of the current track to the position p.
+// The error on the result can be obtained as usual by invoking
+// GetResultError() afterwards.
+//
+// By default the distance will be provided in the metric unit scale of
+// the AliPosition p.
+// However, the user can select a different metric unit scale by
+// specification of the scale parameter.
+// The convention is that scale=1 corresponds to meter, so specification
+// of scale=0.01 will provide the distance in cm.
+// As such it is possible to obtain a correctly computed distance even in case
+// the track parameters have a different unit scale.
+// However, it is recommended to work always with one single unit scale.
+//
+// Note : In case of incomplete information, a distance value of -1 is
+// returned.
+
+ Double_t dist=-1.;
+ fDresult=0.;
+
+ if (!p) return dist;
+
+ // Obtain a defined position on this track
+ AliPosition* rx=fRef;
+ if (!rx) rx=fBegin;
+ if (!rx) rx=fEnd;
+
+ if (!rx) return dist;
+
+ Ali3Vector p1=Get3Momentum();
+
+ if (p1.GetNorm() <= 0.) return dist;
+
+ Ali3Vector r0=(Ali3Vector)(*rx);
+
+ Float_t tscale=rx->GetUnitScale();
+ Float_t pscale=p->GetUnitScale();
+ if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale);
+
+ // Obtain the direction unit vector of this track
+ Double_t vec[3];
+ Double_t err[3];
+ p1.GetVector(vec,"sph");
+ p1.GetErrors(err,"sph");
+ vec[0]=1.;
+ err[0]=0.;
+ p1.SetVector(vec,"sph");
+ p1.SetErrors(err,"sph");
+
+ Ali3Vector q=(Ali3Vector)(*p);
+ Ali3Vector r=q-r0;
+ Ali3Vector d=r.Cross(p1);
+ dist=d.GetNorm();
+ fDresult=d.GetResultError();
+ if (scale>0)
+ {
+ dist*=pscale/scale;
+ fDresult*=pscale/scale;
+ }
+ return dist;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliTrack::GetDistance(AliTrack* t,Float_t scale)
+{
+// Provide distance of the current track to the track t.
+// The error on the result can be obtained as usual by invoking
+// GetResultError() afterwards.
+//
+// By default the distance will be provided in the metric unit scale of
+// the current track.
+// This implies that the results of t1.GetDistance(t2) and t2.GetDistance(t1)
+// may be numerically different in case t1 and t2 have different metric units.
+// However, the user can specify a required metric unit scale by specification
+// of the scale parameter.
+// The convention is that scale=1 corresponds to meter, so specification
+// of scale=0.01 will provide the distance in cm.
+// As such it is possible to obtain a correctly computed distance even in case
+// the track parameters have a different unit scale.
+// However, it is recommended to work always with one single unit scale.
+//
+// Note : In case of incomplete information, a distance value of -1 is
+// returned.
+
+ Double_t dist=-1.;
+ fDresult=0.;
+
+ if (!t) return dist;
+
+ // Obtain a defined position on this track
+ AliPosition* rx=fRef;
+ if (!rx) rx=fBegin;
+ if (!rx) rx=fEnd;
+
+ if (!rx) return dist;
+
+ // Obtain a defined position on track t
+ AliPosition* ry=t->GetReferencePoint();
+ if (!ry) ry=t->GetBeginPoint();
+ if (!ry) ry=t->GetEndPoint();
+
+ if (!ry) return dist;
+
+ Ali3Vector p1=Get3Momentum();
+ Ali3Vector p2=t->Get3Momentum();
+
+ if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist;
+
+ // The vector normal to both track directions
+ Ali3Vector n=p1.Cross(p2);
+
+ Float_t scalex=rx->GetUnitScale();
+ Float_t scaley=ry->GetUnitScale();
+
+ if (n.GetNorm() > 1.e-10)
+ {
+ // Normalise n to a unit vector
+ Double_t vec[3];
+ Double_t err[3];
+ n.GetVector(vec,"sph");
+ n.GetErrors(err,"sph");
+ vec[0]=1.;
+ err[0]=0.;
+ n.SetVector(vec,"sph");
+ n.SetErrors(err,"sph");
+ Ali3Vector r1=(Ali3Vector)(*rx);
+ Ali3Vector r2=(Ali3Vector)(*ry);
+ // Correct components of r2 in case of different unit scales
+ if ((scaley/scalex > 1.1) || (scalex/scaley > 1.1)) r2=r2*(scaley/scalex);
+ Ali3Vector r=r1-r2;
+ dist=fabs(r.Dot(n));
+ fDresult=r.GetResultError();
+ }
+ else // Parallel tracks
+ {
+ dist=t->GetDistance(rx);
+ fDresult=t->GetResultError();
+ }
+
+ if (scale>0)
+ {
+ dist*=scalex/scale;
+ fDresult*=scalex/scale;
+ }
+ return dist;
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliTrack::Clone(const char* name) const