X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=RALICE%2FAliTrack.cxx;h=e260e808b231cefbd4a2aa1c6a946cb6a8ee1264;hb=a05adbe9a6af7c1a8fe38ba2adc85d3c57fedabe;hp=672059497a026036d0b54edbeb7956c1ba3a6152;hpb=1f241680a2749a27e9674b93ebb6e7d4f60d4701;p=u%2Fmrichter%2FAliRoot.git diff --git a/RALICE/AliTrack.cxx b/RALICE/AliTrack.cxx index 672059497a0..e260e808b23 100644 --- a/RALICE/AliTrack.cxx +++ b/RALICE/AliTrack.cxx @@ -83,14 +83,24 @@ // trec.SetBeginPoint(begin); // trec.SetEndPoint(end); // -// Note : All quantities are in GeV, GeV/c or GeV/c**2 +// Note : By default all quantities are in GeV, GeV/c or GeV/c**2 +// but the user can indicate the usage of a different scale +// for the energy-momentum units via the SetEscale() memberfunction. +// The actual energy-momentum unit scale can be obtained via the +// GetEscale() memberfunction. // //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht //- Modified: NvE $Date$ UU-SAP Utrecht /////////////////////////////////////////////////////////////////////////// -#include "AliTrack.h" #include "Riostream.h" +#include "TObjArray.h" + +#include "AliBoost.h" +#include "AliPositionObj.h" +#include "AliSignal.h" +#include "AliTimestamp.h" +#include "AliTrack.h" ClassImp(AliTrack) // Class implementation to enable ROOT I/O @@ -118,18 +128,19 @@ void AliTrack::Init() fParent=0; fFit=0; fTstamp=0; + fEscale=1; } /////////////////////////////////////////////////////////////////////////// AliTrack::~AliTrack() { // 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. +// This destructor automatically cleares all references to this AliTrack +// from all 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 (s) s->RemoveTrack(*this,0); } if (fDecays) @@ -139,7 +150,6 @@ AliTrack::~AliTrack() } if (fSignals) { - fSignals->Clear(); delete fSignals; fSignals=0; } @@ -212,8 +222,7 @@ AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t) if (t.fFit) fFit=t.fFit->Clone(); if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp)); fUserId=t.fUserId; - fChi2=t.fChi2; - fNdf=t.fNdf; + fEscale=t.fEscale; fCode=t.fCode; fParent=t.fParent; @@ -256,9 +265,8 @@ AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t) void AliTrack::Reset() { // Reset all variables to 0 and delete all auto-generated decay tracks. +// Note : The scale for the energy/momentum units will not be changed. fQ=0; - fChi2=0; - fNdf=0; fUserId=0; fCode=0; fProb=0; @@ -272,7 +280,6 @@ void AliTrack::Reset() } if (fSignals) { - fSignals->Clear(); delete fSignals; fSignals=0; } @@ -340,10 +347,10 @@ void AliTrack::Set3Momentum(Ali3Vector& p) void AliTrack::Set4Momentum(Ali4Vector& p) { // Set the track parameters according to the 4-momentum p - Double_t E=p.GetScalar(); + Double_t eE=p.GetScalar(); Double_t dE=p.GetResultError(); Ali3Vector pv=p.Get3Vector(); - SetVector(E,pv); + SetVector(eE,pv); SetScalarError(dE); } /////////////////////////////////////////////////////////////////////////// @@ -387,7 +394,7 @@ void AliTrack::Data(TString f,TString u) << " m : " << m << " dm : " << dm << " Charge : " << fQ << " p : " << GetMomentum() << endl; cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay() - << " Nsignals : " << GetNsignals() << endl; + << " Nsignals : " << GetNsignals() << " Energy scale : " << fEscale << " GeV" << endl; if (fParent) { cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode() @@ -419,6 +426,9 @@ void AliTrack::List(TString f,TString u) // The defaults are f="car" and u="rad". Data(f,u); // Information of the current track + if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); } + if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); } + if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); } // Decay products of this track AliTrack* td; @@ -449,9 +459,9 @@ void AliTrack::ListAll(TString f,TString u) // The defaults are f="car" and u="rad". Data(f,u); // Information of the current track - if (fBegin) { cout << " Begin-point :"; fBegin->Data(f); } - if (fEnd) { cout << " End-point :"; fEnd->Data(f); } - if (fRef) { cout << " Ref-point :"; fRef->Data(f); } + if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); } + if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); } + if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); } Int_t nhyp=GetNhypotheses(); if (nhyp) @@ -494,7 +504,7 @@ void AliTrack::ListAll(TString f,TString u) Dumps(t,1,f,u); // Information of all decay products } ////////////////////////////////////////////////////////////////////////// -void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u) +void AliTrack::Dumps(const AliTrack* t,Int_t n,TString f,TString u) { // Recursively provide the info of all decay levels of this track AliTrack* td; @@ -538,27 +548,53 @@ void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u) } } ////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetMomentum() +Double_t AliTrack::GetMomentum(Float_t scale) { // Provide the value of the track 3-momentum. +// By default the momentum is returned in the units as it was stored in the track +// structure. However, the user can select a different momentum unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV/c, so specification +// of scale=0.001 will provide the momentum in MeV/c. // The error can be obtained by invoking GetResultError() after // invokation of GetMomentum(). + Double_t norm=fV.GetNorm(); fDresult=fV.GetResultError(); + if (scale>0) + { + norm*=fEscale/scale; + fDresult*=fEscale/scale; + } return norm; } /////////////////////////////////////////////////////////////////////////// -Ali3Vector AliTrack::Get3Momentum() const +Ali3Vector AliTrack::Get3Momentum(Float_t scale) const { -// Provide the track 3-momentum - return (Ali3Vector)Get3Vector(); +// Provide the track 3-momentum. +// By default the components of the 3-momentum are returned in the units +// as they were stored in the track structure. +// However, the user can select a different momentum unit scale for the +// components by specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV/c, so specification +// of scale=0.001 will provide the 3-momentum in MeV/c. + + Ali3Vector p=Get3Vector(); + if (scale>0) p*=fEscale/scale; + return p; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetMass() +Double_t AliTrack::GetMass(Float_t scale) { // Provide the particle mass. +// By default the mass is returned in the units as it was stored in the track +// structure. However, the user can select a different mass unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV/c**2, so specification +// of scale=0.001 will provide the mass in MeV/c**2. // The error can be obtained by invoking GetResultError() after // invokation of GetMass(). + Double_t inv=GetInvariant(); Double_t dinv=GetResultError(); Double_t dm=0; @@ -566,6 +602,11 @@ Double_t AliTrack::GetMass() { Double_t m=sqrt(inv); if (m) dm=dinv/(2.*m); + if (scale>0) + { + m*=fEscale/scale; + dm*=fEscale/scale; + } fDresult=dm; return m; } @@ -584,19 +625,29 @@ Float_t AliTrack::GetCharge() const return fQ; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetEnergy() +Double_t AliTrack::GetEnergy(Float_t scale) { // Provide the particle's energy. +// By default the energy is returned in the units as it was stored in the track +// structure. However, the user can select a different energy unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV, so specification +// of scale=0.001 will provide the energy in MeV. // The error can be obtained by invoking GetResultError() after // invokation of GetEnergy(). - Double_t E=GetScalar(); - if (E>0) + Double_t eE=GetScalar(); + if (eE>0) { - return E; + if (scale>0) + { + eE*=fEscale/scale; + fDresult*=fEscale/scale; + } + return eE; } else { - cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl; + cout << "*AliTrack::GetEnergy* Unphysical situation E = " << eE << endl; cout << " Value 0 will be returned." << endl; return 0; } @@ -610,14 +661,14 @@ 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 - Double_t M=GetMass(); + Double_t mM=GetMass(); // Compute the 4-momenta of the decay products in the cms // Note : p2=p1=pnorm for a 2-body decay Double_t e1=0; - if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M); + if (mM) e1=((mM*mM)+(m1*m1)-(m2*m2))/(2.*mM); Double_t e2=0; - if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M); + if (mM) e2=((mM*mM)+(m2*m2)-(m1*m1))/(2.*mM); Double_t pnorm=(e1*e1)-(m1*m1); if (pnorm>0.) { @@ -645,10 +696,10 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) pprim2.SetInvariant(m2*m2); // Determine boost parameters from the parent particle - Double_t E=GetEnergy(); + Double_t eE=GetEnergy(); p=Get3Vector(); Ali4Vector pmu; - pmu.SetVector(E,p); + pmu.SetVector(eE,p); AliBoost q; q.Set4Momentum(pmu); @@ -715,9 +766,19 @@ void AliTrack::RemoveDecays() } } /////////////////////////////////////////////////////////////////////////// -void AliTrack::AddSignal(AliSignal& s) +void AliTrack::AddSignal(AliSignal& s,Int_t mode) { // Relate an AliSignal object to this track. +// +// mode = 0 : Only the reference to the specified signal is stored in +// the current track, without storing the (backward) reference +// to this track into the AliSignal structure. +// 1 : The (backward) reference to the current track is also automatically +// stored into the AliSignal (or derived) object specified in the +// input argument. +// +// The default is mode=0. + if (!fSignals) fSignals=new TObjArray(1); // Check if this signal is already stored for this track @@ -728,27 +789,53 @@ void AliTrack::AddSignal(AliSignal& s) } fSignals->Add(&s); + if (mode==1) s.AddTrack(*this,0); } /////////////////////////////////////////////////////////////////////////// -void AliTrack::RemoveSignal(AliSignal& s) +void AliTrack::RemoveSignal(AliSignal& s,Int_t mode) { // Remove related AliSignal object from this track. +// +// mode = 0 : Only the reference to the specified signal is removed from +// the current track, without removing the (backward) reference(s) +// to this track from the AliSignal structure. +// 1 : The (backward) reference(s) to the current track are also automatically +// removed from the AliSignal (or derived) object specified in the +// input argument. +// +// The default is mode=1. + if (fSignals) { AliSignal* test=(AliSignal*)fSignals->Remove(&s); if (test) fSignals->Compress(); } + if (mode==1) s.RemoveTrack(*this,0); } /////////////////////////////////////////////////////////////////////////// -void AliTrack::RemoveSignals() +void AliTrack::RemoveSignals(Int_t mode) { // Remove all related AliSignal objects from this track. - if (fSignals) +// +// mode = 0 : All signal references are removed from the current track, +// without removing the (backward) references to this track from +// the corresponding AliSignal objects. +// 1 : The (backward) references to the current track are also automatically +// removed from the corresponding AliSignal (or derived) objects. +// +// The default is mode=1. + + if (!fSignals) return; + + Int_t ns=GetNsignals(); + for (Int_t i=0; iClear(); - delete fSignals; - fSignals=0; + AliSignal* sx=(AliSignal*)fSignals->At(i); + if (sx && mode==1) sx->RemoveTrack(*this,0); } + + delete fSignals; + fSignals=0; } /////////////////////////////////////////////////////////////////////////// Int_t AliTrack::GetNsignals() const @@ -759,6 +846,21 @@ Int_t AliTrack::GetNsignals() const return nsig; } /////////////////////////////////////////////////////////////////////////// +Int_t AliTrack::GetNsignals(const char* classname) const +{ +// Provide the number of stored signals of the specified class. + + Int_t nsigs=0; + for (Int_t isig=1; isig<=GetNsignals(); isig++) + { + TObject* obj=GetSignal(isig); + if (!obj) continue; + + if (obj->InheritsFrom(classname)) nsigs++; + } + return nsigs; +} +/////////////////////////////////////////////////////////////////////////// AliSignal* AliTrack::GetSignal(Int_t j) const { // Provide the related AliSignal number j. @@ -895,7 +997,7 @@ void AliTrack::SetBeginPoint(AliPosition& p) fBegin=new AliPositionObj(p); } /////////////////////////////////////////////////////////////////////////// -AliPosition* AliTrack::GetBeginPoint() +AliPosition* AliTrack::GetBeginPoint() const { // Provide the position of the track begin-point. return fBegin; @@ -908,7 +1010,7 @@ void AliTrack::SetEndPoint(AliPosition& p) fEnd=new AliPositionObj(p); } /////////////////////////////////////////////////////////////////////////// -AliPosition* AliTrack::GetEndPoint() +AliPosition* AliTrack::GetEndPoint() const { // Provide the position of the track end-point. return fEnd; @@ -925,7 +1027,7 @@ void AliTrack::SetReferencePoint(AliPosition& p) fRef=new AliPositionObj(p); } /////////////////////////////////////////////////////////////////////////// -AliPosition* AliTrack::GetReferencePoint() +AliPosition* AliTrack::GetReferencePoint() const { // Provide the position of the track reference-point. // The reference-point is the point on the track in which the @@ -955,25 +1057,41 @@ void AliTrack::SetMass() } } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetPt() +Double_t AliTrack::GetPt(Float_t scale) { -// Provide trans. momentum value w.r.t. z-axis. +// Provide the transverse momentum value w.r.t. z-axis. +// By default the value is returned in the units as it was stored in the track +// structure. However, the user can select a different momentum unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV/c, so specification +// of scale=0.001 will provide the transverse momentum in MeV/c. // 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(); + if (scale>0) + { + norm*=fEscale/scale; + fDresult*=fEscale/scale; + } return norm; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetPl() +Double_t AliTrack::GetPl(Float_t scale) { -// Provide long. momentum value w.r.t. z-axis. +// Provide the longitudinal momentum value w.r.t. z-axis. +// By default the value is returned in the units as it was stored in the track +// structure. However, the user can select a different momentum unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV/c, so specification +// of scale=0.001 will provide the longitudinal momentum in MeV/c. // 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(); @@ -983,34 +1101,66 @@ Double_t AliTrack::GetPl() Double_t a[3]; v.GetVector(a,"sph"); if (cos(a[1])<0) pl=-pl; + if (scale>0) + { + pl*=fEscale/scale; + fDresult*=fEscale/scale; + } return pl; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetEt() +Double_t AliTrack::GetEt(Float_t scale) { -// Provide trans. energy value w.r.t. z-axis. +// Provide transverse energy value w.r.t. z-axis. +// By default the value is returned in the units as it was stored in the track +// structure. However, the user can select a different energy unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV, so specification +// of scale=0.001 will provide the transverse energy in MeV. // The error on the value can be obtained by GetResultError() // after invokation of GetEt(). + Double_t et=GetScaTrans(); + if (scale>0) + { + et*=fEscale/scale; + fDresult*=fEscale/scale; + } return et; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetEl() +Double_t AliTrack::GetEl(Float_t scale) { -// Provide long. energy value w.r.t. z-axis. +// Provide longitudinal energy value w.r.t. z-axis. +// By default the value is returned in the units as it was stored in the track +// structure. However, the user can select a different energy unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV, so specification +// of scale=0.001 will provide the longitudinal energy in MeV. // 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(); + if (scale>0) + { + el*=fEscale/scale; + fDresult*=fEscale/scale; + } return el; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetMt() +Double_t AliTrack::GetMt(Float_t scale) { // Provide transverse mass value w.r.t. z-axis. +// By default the value is returned in the units as it was stored in the track +// structure. However, the user can select a different energy unit scale by +// specification of the scale parameter. +// The convention is that scale=1 corresponds to GeV, so specification +// of scale=0.001 will provide the transverse mass in MeV. // The error on the value can be obtained by GetResultError() // after invokation of GetMt(). Double_t pt=GetPt(); @@ -1023,6 +1173,11 @@ Double_t AliTrack::GetMt() if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt); fDresult=sqrt(dmt2); + if (scale>0) + { + mt*=fEscale/scale; + fDresult*=fEscale/scale; + } return mt; } /////////////////////////////////////////////////////////////////////////// @@ -1084,7 +1239,7 @@ void AliTrack::SetImpactPoint(AliPosition& p,TString q) } } /////////////////////////////////////////////////////////////////////////// -AliPosition* AliTrack::GetImpactPoint(TString q) +AliPosition* AliTrack::GetImpactPoint(TString q) const { // Provide the position of the impact-point in the plane "q=0". // Here q denotes one of the axes X, Y or Z. @@ -1132,48 +1287,40 @@ void AliTrack::SetClosestPoint(AliPosition& p) fClosest=new AliPositionObj(p); } /////////////////////////////////////////////////////////////////////////// -AliPosition* AliTrack::GetClosestPoint() +AliPosition* AliTrack::GetClosestPoint() const { // Provide the point of closest approach w.r.t. some reference return fClosest; } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetChi2(Float_t chi2) +void AliTrack::SetEscale(Float_t scale) { -// 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) +// Indicate the energy/momentum scale as used by the user. +// The convention is that scale=1 indicates values in units +// of GeV, GeV/c or GeV/c**2. +// So, in case one decides to store values in units of MeV, MeV/c or MeV/c**2 +// the scale indicator should be set to scale=0.001. +// +// By default scale=1 is set in the constructor. + + if (scale>0) { - cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl; + fEscale=scale; } else { - fNdf=ndf; + cout << " *AliTrack::SetEscale* Invalid scale value : " << scale << endl; } } /////////////////////////////////////////////////////////////////////////// -Float_t AliTrack::GetChi2() const -{ -// Provide the chi-squared value of the track fit. - return fChi2; -} -/////////////////////////////////////////////////////////////////////////// -Int_t AliTrack::GetNdf() const +Float_t AliTrack::GetEscale() const { -// Provide the number of degrees of freedom for the track fit. - return fNdf; +// Provide the energy/momentum scale as used by the user. +// The convention is that scale=1 indicates values in units +// of GeV, GeV/c or GeV/c**2. +// So, a value of scale=0.001 indicates that energy/momentum values are +// stored in units of MeV, MeV/c or MeV/c**2. + return fEscale; } /////////////////////////////////////////////////////////////////////////// void AliTrack::SetParticleCode(Int_t code) @@ -1188,13 +1335,13 @@ Int_t AliTrack::GetParticleCode() const return fCode; } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetParentTrack(AliTrack* t) +void AliTrack::SetParentTrack(AliTrack * const t) { // Set pointer to the parent track. fParent=t; } /////////////////////////////////////////////////////////////////////////// -AliTrack* AliTrack::GetParentTrack() +AliTrack* AliTrack::GetParentTrack() const { // Provide pointer to the parent track. return fParent; @@ -1212,7 +1359,7 @@ Float_t AliTrack::GetProb() const return fProb; } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetFitDetails(TObject* obj) +void AliTrack::SetFitDetails(const TObject* obj) { // Enter the object containing the fit details. // In case an object to hold fit details was already present, this @@ -1248,7 +1395,7 @@ void AliTrack::SetFitDetails(TObject* obj) if (obj) fFit=obj->Clone(); } /////////////////////////////////////////////////////////////////////////// -TObject* AliTrack::GetFitDetails() +TObject* AliTrack::GetFitDetails() const { // Provide the pointer to the object containing the fit details. return fFit; @@ -1261,7 +1408,7 @@ void AliTrack::SetTimestamp(AliTimestamp& t) fTstamp=new AliTimestamp(t); } /////////////////////////////////////////////////////////////////////////// -AliTimestamp* AliTrack::GetTimestamp() +AliTimestamp* AliTrack::GetTimestamp() const { // Provide the timestamp of this track. return fTstamp; @@ -1277,6 +1424,154 @@ void AliTrack::RemoveTimestamp() } } /////////////////////////////////////////////////////////////////////////// +Double_t AliTrack::GetDistance(AliPosition* const 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* const 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 { // Make a deep copy of the current object and provide the pointer to the copy.