1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // base class for track parameters //
22 // The idea of having a separate class for the track parametrisation and //
23 // not including it in the track classes itself is to not duplicate code. //
24 // Track classes which use the same parametrisation can include a track //
25 // parameters object for their common parametrisation. The code, e.g. for //
26 // the propagation, does not need to be duplicated. //
28 // The AliTrackParam and its derived classes //
29 // - know the current track parameters and their covariance matrix as well //
30 // as the local x coordinate and azimuthal angle alpha of the current //
32 // - can rotate their local coordinate system //
33 // - can create a parametrisation in external format from itself //
34 // - can propagate through material or vacuum //
35 // - can calculate a chi^2 for a cluster //
36 // - can update the parameters using the position and covariance of a //
39 // In addition some methods to get quantities useful for analysis, like //
40 // the momentum, are implemented. //
42 ///////////////////////////////////////////////////////////////////////////////
45 #include "AliTrackParam.h"
46 #include "AliExternalTrackParam.h"
47 #include "AliRunLoader.h"
52 Double_t FastMath::fgFastAsin[20000];
56 for (Int_t i=0;i<10000;i++){
57 fgFastAsin[2*i] = TMath::ASin(i/10000.);
58 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
62 Double_t FastMath::FastAsin(Double_t x)
65 Int_t index = int(x*10000);
66 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
69 Int_t index = int(x*10000);
70 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
77 ClassImp(AliTrackParam)
82 //_____________________________________________________________________________
83 Bool_t AliTrackParam::RotateAndPropagateTo(Double_t alpha, Double_t x,
86 // Rotate the reference axis for the parametrisation to the given angle and
87 // propagate the track parameters to the given x coordinate assuming vacuum.
88 // If length is not NULL, the change of track length is added to it.
90 if (!RotateTo(alpha)) return kFALSE;
91 if (!PropagateTo(x, length)) return kFALSE;
95 //_____________________________________________________________________________
96 Double_t AliTrackParam::GetDsdx() const
98 // get the change of track length s per step in x: ds/dx
100 TVector3 x(TMath::Cos(Alpha()), TMath::Sin(Alpha()), 0);
101 TVector3 p = Momentum();
103 if (xp == 0) return 1.E6;
108 //_____________________________________________________________________________
109 Double_t AliTrackParam::Phi() const
111 // get the azimuthal angre
113 return Momentum().Phi();
116 //_____________________________________________________________________________
117 Double_t AliTrackParam::SigmaPhi() const
119 // get the error of the azimuthal angle
121 AliExternalTrackParam* param = CreateExternalParam();
122 Double_t result = param->SigmaPhi();
127 //_____________________________________________________________________________
128 Double_t AliTrackParam::Theta() const
130 // the the polar angle
132 return Momentum().Theta();
135 //_____________________________________________________________________________
136 Double_t AliTrackParam::SigmaTheta() const
138 // get the error of the polar angle
140 AliExternalTrackParam* param = CreateExternalParam();
141 Double_t result = param->SigmaTheta();
146 //_____________________________________________________________________________
147 Double_t AliTrackParam::Eta() const
149 // get the pseudorapidity
151 return Momentum().Eta();
154 //_____________________________________________________________________________
155 Double_t AliTrackParam::Px() const
157 // get the x component of the momentum
159 return Momentum().Px();
162 //_____________________________________________________________________________
163 Double_t AliTrackParam::Py() const
165 // get the y component of the momentum
167 return Momentum().Py();
170 //_____________________________________________________________________________
171 Double_t AliTrackParam::Pz() const
173 // get the z component of the momentum
175 return Momentum().Pz();
178 //_____________________________________________________________________________
179 Double_t AliTrackParam::Pt() const
181 // get the transversal component of the momentum
183 return Momentum().Pt();
186 //_____________________________________________________________________________
187 Double_t AliTrackParam::SigmaPt() const
189 // get the error of the transversal component of the momentum
191 AliExternalTrackParam* param = CreateExternalParam();
192 Double_t result = param->SigmaPt();
197 //_____________________________________________________________________________
198 Double_t AliTrackParam::P() const
200 // get the absolute momentum
202 return Momentum().Mag();
205 //_____________________________________________________________________________
206 TVector3 AliTrackParam::Momentum() const
208 // get the momentum vector
210 AliExternalTrackParam* param = CreateExternalParam();
211 TVector3 result = param->Momentum();
216 //_____________________________________________________________________________
217 TVector3 AliTrackParam::Position() const
219 // get the current spatial position in global coordinates
221 Double_t sinAlpha = TMath::Sin(Alpha());
222 Double_t cosAlpha = TMath::Cos(Alpha());
223 return TVector3(X()*cosAlpha - Y()*sinAlpha,
224 X()*sinAlpha + Y()*cosAlpha,
228 //_____________________________________________________________________________
229 TVector3 AliTrackParam::PositionAt(Double_t x) const
231 // get the spatial position at x in global coordinates
235 if (!GetProlongationAt(x, y, z)) return TVector3(0,0,0);
236 Double_t sinAlpha = TMath::Sin(Alpha());
237 Double_t cosAlpha = TMath::Cos(Alpha());
238 return TVector3(x*cosAlpha - y*sinAlpha, x*sinAlpha + y*cosAlpha, z);