/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Id$ */ /////////////////////////////////////////////////////////////////////////////// // // // track parameters in "external" format // // // // The track parameters are: // // - local y coordinate // // - local z coordinate // // - sin of azimutal angle // // - tan of dip angle // // - charge/pt // // The parametrisation is given at the local x coordinate fX and the // // azimuthal angle fAlpha. // // // // The external parametrisation can be used to exchange track parameters // // between different detectors. // // // /////////////////////////////////////////////////////////////////////////////// #include "AliExternalTrackParam.h" #include "AliKalmanTrack.h" ClassImp(AliExternalTrackParam) //_____________________________________________________________________________ AliExternalTrackParam::AliExternalTrackParam() : fX(0), fAlpha(0) { // // default constructor // for (Int_t i = 0; i < 5; i++) fP[i] = 0; for (Int_t i = 0; i < 15; i++) fC[i] = 0; } //_____________________________________________________________________________ AliExternalTrackParam::AliExternalTrackParam(Double_t x, Double_t alpha, const Double_t param[5], const Double_t covar[15]) : fX(x), fAlpha(alpha) { // // create external track parameters from given arguments // for (Int_t i = 0; i < 5; i++) fP[i] = param[i]; for (Int_t i = 0; i < 15; i++) fC[i] = covar[i]; } //_____________________________________________________________________________ AliExternalTrackParam::AliExternalTrackParam(const AliKalmanTrack& track) : fAlpha(track.GetAlpha()) { // // track.GetExternalParameters(fX,fP); track.GetExternalCovariance(fC); } //_____________________________________________________________________________ void AliExternalTrackParam::Set(const AliKalmanTrack& track) { // // fAlpha=track.GetAlpha(); track.GetExternalParameters(fX,fP); track.GetExternalCovariance(fC); } //_____________________________________________________________________________ void AliExternalTrackParam::Reset() { fX=fAlpha=0.; for (Int_t i = 0; i < 5; i++) fP[i] = 0; for (Int_t i = 0; i < 15; i++) fC[i] = 0; } Double_t AliExternalTrackParam::GetP() const { //--------------------------------------------------------------------- // This function returns the track momentum // Results for (nearly) straight tracks are meaningless ! //--------------------------------------------------------------------- if (TMath::Abs(fP[4])<=0) return 0; return TMath::Sqrt(1.+ fP[3]*fP[3])/TMath::Abs(fP[4]); } //_______________________________________________________________________ Double_t AliExternalTrackParam::GetD(Double_t b,Double_t x,Double_t y) const { //------------------------------------------------------------------ // This function calculates the transverse impact parameter // with respect to a point with global coordinates (x,y) // in the magnetic field "b" (kG) //------------------------------------------------------------------ Double_t convconst=0.299792458*b/1000.; Double_t rp4=fP[4]*convconst; Double_t xt=fX, yt=fP[0]; Double_t sn=TMath::Sin(fAlpha), cs=TMath::Cos(fAlpha); Double_t a = x*cs + y*sn; y = -x*sn + y*cs; x=a; xt-=x; yt-=y; sn=rp4*xt - fP[2]; cs=rp4*yt + TMath::Sqrt(1.- fP[2]*fP[2]); a=2*(xt*fP[2] - yt*TMath::Sqrt(1.- fP[2]*fP[2]))-rp4*(xt*xt + yt*yt); if (rp4<0) a=-a; return a/(1 + TMath::Sqrt(sn*sn + cs*cs)); } Bool_t Local2GlobalMomentum(Double_t p[3],Double_t alpha) { //---------------------------------------------------------------- // This function performs local->global transformation of the // track momentum. // When called, the arguments are: // p[0] = 1/pt of the track; // p[1] = sine of local azim. angle of the track momentum; // p[2] = tangent of the track momentum dip angle; // alpha - rotation angle. // The result is returned as: // p[0] = px // p[1] = py // p[2] = pz // Results for (nearly) straight tracks are meaningless ! //---------------------------------------------------------------- if (TMath::Abs(p[0])<=0) return kFALSE; if (TMath::Abs(p[1])> 0.999999) return kFALSE; Double_t pt=1./TMath::Abs(p[0]); Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha); Double_t r=TMath::Sqrt(1 - p[1]*p[1]); p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2]; return kTRUE; } Bool_t Local2GlobalPosition(Double_t r[3],Double_t alpha) { //---------------------------------------------------------------- // This function performs local->global transformation of the // track position. // When called, the arguments are: // r[0] = local x // r[1] = local y // r[2] = local z // alpha - rotation angle. // The result is returned as: // r[0] = global x // r[1] = global y // r[2] = global z //---------------------------------------------------------------- Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha), x=r[0]; r[0]=x*cs - r[1]*sn; r[1]=x*sn + r[1]*cs; return kTRUE; } Bool_t AliExternalTrackParam::GetPxPyPz(Double_t *p) const { //--------------------------------------------------------------------- // This function returns the global track momentum components // Results for (nearly) straight tracks are meaningless ! //--------------------------------------------------------------------- p[0]=fP[4]; p[1]=fP[2]; p[2]=fP[3]; return Local2GlobalMomentum(p,fAlpha); } Bool_t AliExternalTrackParam::GetXYZ(Double_t *r) const { //--------------------------------------------------------------------- // This function returns the global track position //--------------------------------------------------------------------- r[0]=fX; r[1]=fP[0]; r[2]=fP[1]; return Local2GlobalPosition(r,fAlpha); } Bool_t AliExternalTrackParam::GetCovarianceXYZPxPyPz(Double_t cv[21]) const { //--------------------------------------------------------------------- // This function returns the global covariance matrix of the track params // // Cov(x,x) ... : cv[0] // Cov(y,x) ... : cv[1] cv[2] // Cov(z,x) ... : cv[3] cv[4] cv[5] // Cov(px,x)... : cv[6] cv[7] cv[8] cv[9] // Cov(py,x)... : cv[10] cv[11] cv[12] cv[13] cv[14] // Cov(pz,x)... : cv[15] cv[16] cv[17] cv[18] cv[19] cv[20] // // Results for (nearly) straight tracks are meaningless ! //--------------------------------------------------------------------- if (TMath::Abs(fP[4])<=0) { for (Int_t i=0; i<21; i++) cv[i]=0.; return kFALSE; } if (TMath::Abs(fP[2]) > 0.999999) { for (Int_t i=0; i<21; i++) cv[i]=0.; return kFALSE; } Double_t pt=1./TMath::Abs(fP[4]); Double_t cs=TMath::Cos(fAlpha), sn=TMath::Sin(fAlpha); Double_t r=TMath::Sqrt(1-fP[2]*fP[2]); Double_t m00=-sn, m10=cs; Double_t m23=-pt*(sn + fP[2]*cs/r), m43=-pt*pt*(r*cs - fP[2]*sn); Double_t m24= pt*(cs - fP[2]*sn/r), m44=-pt*pt*(r*sn + fP[2]*cs); Double_t m35=pt, m45=-pt*pt*fP[3]; cv[0 ] = fC[0]*m00*m00; cv[1 ] = fC[0]*m00*m10; cv[2 ] = fC[0]*m10*m10; cv[3 ] = fC[1]*m00; cv[4 ] = fC[1]*m10; cv[5 ] = fC[2]; cv[6 ] = m00*(fC[3]*m23 + fC[10]*m43); cv[7 ] = m10*(fC[3]*m23 + fC[10]*m43); cv[8 ] = fC[4]*m23 + fC[11]*m43; cv[9 ] = m23*(fC[5]*m23 + fC[12]*m43) + m43*(fC[12]*m23 + fC[14]*m43); cv[10] = m00*(fC[3]*m24 + fC[10]*m44); cv[11] = m10*(fC[3]*m24 + fC[10]*m44); cv[12] = fC[4]*m24 + fC[11]*m44; cv[13] = m23*(fC[5]*m24 + fC[12]*m44) + m43*(fC[12]*m24 + fC[14]*m44); cv[14] = m24*(fC[5]*m24 + fC[12]*m44) + m44*(fC[12]*m24 + fC[14]*m44); cv[15] = m00*(fC[6]*m35 + fC[10]*m45); cv[16] = m10*(fC[6]*m35 + fC[10]*m45); cv[17] = fC[7]*m35 + fC[11]*m45; cv[18] = m23*(fC[8]*m35 + fC[12]*m45) + m43*(fC[13]*m35 + fC[14]*m45); cv[19] = m24*(fC[8]*m35 + fC[12]*m45) + m44*(fC[13]*m35 + fC[14]*m45); cv[20] = m35*(fC[9]*m35 + fC[13]*m45) + m45*(fC[13]*m35 + fC[14]*m45); return kTRUE; } Bool_t AliExternalTrackParam::GetPxPyPzAt(Double_t x, Double_t b, Double_t *p) const { //--------------------------------------------------------------------- // This function returns the global track momentum extrapolated to // the radial position "x" (cm) in the magnetic field "b" (kG) //--------------------------------------------------------------------- Double_t convconst=0.299792458*b/1000.; p[0]=fP[4]; p[1]=fP[2]+(x-fX)*fP[4]*convconst; p[2]=fP[3]; return Local2GlobalMomentum(p,fAlpha); } Bool_t AliExternalTrackParam::GetXYZAt(Double_t x, Double_t b, Double_t *r) const { //--------------------------------------------------------------------- // This function returns the global track position extrapolated to // the radial position "x" (cm) in the magnetic field "b" (kG) //--------------------------------------------------------------------- Double_t convconst=0.299792458*b/1000.; Double_t dx=x-fX; Double_t f1=fP[2], f2=f1 + dx*fP[4]*convconst; if (TMath::Abs(f2) >= 0.9999) return kFALSE; Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2); r[0] = x; r[1] = fP[0] + dx*(f1+f2)/(r1+r2); r[2] = fP[1] + dx*(f1+f2)/(f1*r2 + f2*r1)*fP[3]; return Local2GlobalPosition(r,fAlpha); } //_____________________________________________________________________________ void AliExternalTrackParam::Print(Option_t* /*option*/) const { // print the parameters and the covariance matrix printf("AliExternalTrackParam: x = %-12g alpha = %-12g\n", fX, fAlpha); printf(" parameters: %12g %12g %12g %12g %12g\n", fP[0], fP[1], fP[2], fP[3], fP[4]); printf(" covariance: %12g\n", fC[0]); printf(" %12g %12g\n", fC[1], fC[2]); printf(" %12g %12g %12g\n", fC[3], fC[4], fC[5]); printf(" %12g %12g %12g %12g\n", fC[6], fC[7], fC[8], fC[9]); printf(" %12g %12g %12g %12g %12g\n", fC[10], fC[11], fC[12], fC[13], fC[14]); }