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 **************************************************************************/
21 #include "AliTrackParam.h"
22 #include "AliExternalTrackParam.h"
24 ///////////////////////////////////////////////////////////////////////////////
26 // class for fast math //
28 // Class with a table for fast calculation of the //
29 // asins. The valuse are calculated via //
30 // linear interpolation. The values and the deltas are stored //
32 ///////////////////////////////////////////////////////////////////////////////
35 Double_t AliFastMath::fgFastAsin[20000];
37 AliFastMath::AliFastMath()
40 // Standard constructor
41 // Initialises the asin tables
43 for (Int_t i=0;i<10000;i++){
44 fgFastAsin[2*i] = TMath::ASin(i/10000.);
45 fgFastAsin[2*i+1] = (TMath::ASin((i+1)/10000.)-fgFastAsin[2*i]);
49 Double_t AliFastMath::FastAsin(Double_t x)
52 // Fast interpolation for the Asin
55 Int_t index = int(x*10000);
56 return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1];
59 Int_t index = int(x*10000);
60 return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
64 ///////////////////////////////////////////////////////////////////////////////
66 // base class for track parameters //
68 // The idea of having a separate class for the track parametrisation and //
69 // not including it in the track classes itself is to not duplicate code. //
70 // Track classes which use the same parametrisation can include a track //
71 // parameters object for their common parametrisation. The code, e.g. for //
72 // the propagation, does not need to be duplicated. //
74 // The AliTrackParam and its derived classes //
75 // - know the current track parameters and their covariance matrix as well //
76 // as the local x coordinate and azimuthal angle alpha of the current //
78 // - can rotate their local coordinate system //
79 // - can create a parametrisation in external format from itself //
80 // - can propagate through material or vacuum //
81 // - can calculate a chi^2 for a cluster //
82 // - can update the parameters using the position and covariance of a //
85 // In addition some methods to get quantities useful for analysis, like //
86 // the momentum, are implemented. //
88 ///////////////////////////////////////////////////////////////////////////////
91 ClassImp(AliTrackParam)
93 //_____________________________________________________________________________
94 Bool_t AliTrackParam::RotateAndPropagateTo(Double_t alpha, Double_t x,
97 // Rotate the reference axis for the parametrisation to the given angle and
98 // propagate the track parameters to the given x coordinate assuming vacuum.
99 // If length is not NULL, the change of track length is added to it.
101 if (!RotateTo(alpha)) return kFALSE;
102 if (!PropagateTo(x, length)) return kFALSE;
106 //_____________________________________________________________________________
107 Double_t AliTrackParam::GetDsdx() const
109 // get the change of track length s per step in x: ds/dx
111 TVector3 x(TMath::Cos(Alpha()), TMath::Sin(Alpha()), 0);
112 TVector3 p = Momentum();
114 if (xp == 0) return 1.E6;
119 //_____________________________________________________________________________
120 Double_t AliTrackParam::Phi() const
122 // get the azimuthal angre
124 return Momentum().Phi();
127 //_____________________________________________________________________________
128 Double_t AliTrackParam::SigmaPhi() const
130 // get the error of the azimuthal angle
132 AliExternalTrackParam* param = CreateExternalParam();
133 Double_t result = param->SigmaPhi();
138 //_____________________________________________________________________________
139 Double_t AliTrackParam::Theta() const
141 // the the polar angle
143 return Momentum().Theta();
146 //_____________________________________________________________________________
147 Double_t AliTrackParam::SigmaTheta() const
149 // get the error of the polar angle
151 AliExternalTrackParam* param = CreateExternalParam();
152 Double_t result = param->SigmaTheta();
157 //_____________________________________________________________________________
158 Double_t AliTrackParam::Eta() const
160 // get the pseudorapidity
162 return Momentum().Eta();
165 //_____________________________________________________________________________
166 Double_t AliTrackParam::Px() const
168 // get the x component of the momentum
170 return Momentum().Px();
173 //_____________________________________________________________________________
174 Double_t AliTrackParam::Py() const
176 // get the y component of the momentum
178 return Momentum().Py();
181 //_____________________________________________________________________________
182 Double_t AliTrackParam::Pz() const
184 // get the z component of the momentum
186 return Momentum().Pz();
189 //_____________________________________________________________________________
190 Double_t AliTrackParam::Pt() const
192 // get the transversal component of the momentum
194 return Momentum().Pt();
197 //_____________________________________________________________________________
198 Double_t AliTrackParam::SigmaPt() const
200 // get the error of the transversal component of the momentum
202 AliExternalTrackParam* param = CreateExternalParam();
203 Double_t result = param->SigmaPt();
208 //_____________________________________________________________________________
209 Double_t AliTrackParam::P() const
211 // get the absolute momentum
213 return Momentum().Mag();
216 //_____________________________________________________________________________
217 TVector3 AliTrackParam::Momentum() const
219 // get the momentum vector
221 AliExternalTrackParam* param = CreateExternalParam();
222 TVector3 result = param->Momentum();
227 //_____________________________________________________________________________
228 TVector3 AliTrackParam::Position() const
230 // get the current spatial position in global coordinates
232 Double_t sinAlpha = TMath::Sin(Alpha());
233 Double_t cosAlpha = TMath::Cos(Alpha());
234 return TVector3(X()*cosAlpha - Y()*sinAlpha,
235 X()*sinAlpha + Y()*cosAlpha,
239 //_____________________________________________________________________________
240 TVector3 AliTrackParam::PositionAt(Double_t x) const
242 // get the spatial position at x in global coordinates
246 if (!GetProlongationAt(x, y, z)) return TVector3(0,0,0);
247 Double_t sinAlpha = TMath::Sin(Alpha());
248 Double_t cosAlpha = TMath::Cos(Alpha());
249 return TVector3(x*cosAlpha - y*sinAlpha, x*sinAlpha + y*cosAlpha, z);