]>
Commit | Line | Data |
---|---|---|
51ad6848 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
a0209ae4 | 18 | #include <TVector3.h> |
19 | #include <TMath.h> | |
20 | ||
21 | #include "AliTrackParam.h" | |
22 | #include "AliExternalTrackParam.h" | |
23 | ||
24 | /////////////////////////////////////////////////////////////////////////////// | |
25 | // // | |
26 | // class for fast math // | |
27 | // // | |
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 // | |
31 | // // | |
32 | /////////////////////////////////////////////////////////////////////////////// | |
33 | ||
34 | ||
35 | Double_t AliFastMath::fgFastAsin[20000]; | |
36 | ||
37 | AliFastMath::AliFastMath() | |
38 | { | |
39 | // | |
40 | // Standard constructor | |
41 | // Initialises the asin tables | |
42 | // | |
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]); | |
46 | } | |
47 | } | |
48 | ||
49 | Double_t AliFastMath::FastAsin(Double_t x) | |
50 | { | |
51 | // | |
52 | // Fast interpolation for the Asin | |
53 | // | |
54 | if (x>0){ | |
55 | Int_t index = int(x*10000); | |
56 | return fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]; | |
57 | } else { | |
58 | x*=-1; | |
59 | Int_t index = int(x*10000); | |
60 | return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]); | |
61 | } | |
62 | } | |
63 | ||
51ad6848 | 64 | /////////////////////////////////////////////////////////////////////////////// |
65 | // // | |
66 | // base class for track parameters // | |
67 | // // | |
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. // | |
73 | // // | |
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 // | |
77 | // parametrisation // | |
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 // | |
83 | // cluster // | |
84 | // // | |
85 | // In addition some methods to get quantities useful for analysis, like // | |
86 | // the momentum, are implemented. // | |
87 | // // | |
88 | /////////////////////////////////////////////////////////////////////////////// | |
89 | ||
90 | ||
51ad6848 | 91 | ClassImp(AliTrackParam) |
92 | ||
51ad6848 | 93 | //_____________________________________________________________________________ |
94 | Bool_t AliTrackParam::RotateAndPropagateTo(Double_t alpha, Double_t x, | |
95 | Double_t* length) | |
96 | { | |
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. | |
100 | ||
101 | if (!RotateTo(alpha)) return kFALSE; | |
102 | if (!PropagateTo(x, length)) return kFALSE; | |
103 | return kTRUE; | |
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | Double_t AliTrackParam::GetDsdx() const | |
108 | { | |
109 | // get the change of track length s per step in x: ds/dx | |
110 | ||
111 | TVector3 x(TMath::Cos(Alpha()), TMath::Sin(Alpha()), 0); | |
112 | TVector3 p = Momentum(); | |
113 | Double_t xp = x*p; | |
114 | if (xp == 0) return 1.E6; | |
115 | return p.Mag() / xp; | |
116 | } | |
117 | ||
118 | ||
119 | //_____________________________________________________________________________ | |
120 | Double_t AliTrackParam::Phi() const | |
121 | { | |
122 | // get the azimuthal angre | |
123 | ||
124 | return Momentum().Phi(); | |
125 | } | |
126 | ||
127 | //_____________________________________________________________________________ | |
128 | Double_t AliTrackParam::SigmaPhi() const | |
129 | { | |
130 | // get the error of the azimuthal angle | |
131 | ||
132 | AliExternalTrackParam* param = CreateExternalParam(); | |
133 | Double_t result = param->SigmaPhi(); | |
134 | delete param; | |
135 | return result; | |
136 | } | |
137 | ||
138 | //_____________________________________________________________________________ | |
139 | Double_t AliTrackParam::Theta() const | |
140 | { | |
141 | // the the polar angle | |
142 | ||
143 | return Momentum().Theta(); | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | Double_t AliTrackParam::SigmaTheta() const | |
148 | { | |
149 | // get the error of the polar angle | |
150 | ||
151 | AliExternalTrackParam* param = CreateExternalParam(); | |
152 | Double_t result = param->SigmaTheta(); | |
153 | delete param; | |
154 | return result; | |
155 | } | |
156 | ||
157 | //_____________________________________________________________________________ | |
158 | Double_t AliTrackParam::Eta() const | |
159 | { | |
160 | // get the pseudorapidity | |
161 | ||
162 | return Momentum().Eta(); | |
163 | } | |
164 | ||
165 | //_____________________________________________________________________________ | |
166 | Double_t AliTrackParam::Px() const | |
167 | { | |
168 | // get the x component of the momentum | |
169 | ||
170 | return Momentum().Px(); | |
171 | } | |
172 | ||
173 | //_____________________________________________________________________________ | |
174 | Double_t AliTrackParam::Py() const | |
175 | { | |
176 | // get the y component of the momentum | |
177 | ||
178 | return Momentum().Py(); | |
179 | } | |
180 | ||
181 | //_____________________________________________________________________________ | |
182 | Double_t AliTrackParam::Pz() const | |
183 | { | |
184 | // get the z component of the momentum | |
185 | ||
186 | return Momentum().Pz(); | |
187 | } | |
188 | ||
189 | //_____________________________________________________________________________ | |
190 | Double_t AliTrackParam::Pt() const | |
191 | { | |
192 | // get the transversal component of the momentum | |
193 | ||
194 | return Momentum().Pt(); | |
195 | } | |
196 | ||
197 | //_____________________________________________________________________________ | |
198 | Double_t AliTrackParam::SigmaPt() const | |
199 | { | |
200 | // get the error of the transversal component of the momentum | |
201 | ||
202 | AliExternalTrackParam* param = CreateExternalParam(); | |
203 | Double_t result = param->SigmaPt(); | |
204 | delete param; | |
205 | return result; | |
206 | } | |
207 | ||
208 | //_____________________________________________________________________________ | |
209 | Double_t AliTrackParam::P() const | |
210 | { | |
211 | // get the absolute momentum | |
212 | ||
213 | return Momentum().Mag(); | |
214 | } | |
215 | ||
216 | //_____________________________________________________________________________ | |
217 | TVector3 AliTrackParam::Momentum() const | |
218 | { | |
219 | // get the momentum vector | |
220 | ||
221 | AliExternalTrackParam* param = CreateExternalParam(); | |
222 | TVector3 result = param->Momentum(); | |
223 | delete param; | |
224 | return result; | |
225 | } | |
226 | ||
227 | //_____________________________________________________________________________ | |
228 | TVector3 AliTrackParam::Position() const | |
229 | { | |
230 | // get the current spatial position in global coordinates | |
231 | ||
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, | |
236 | Z()); | |
237 | } | |
238 | ||
239 | //_____________________________________________________________________________ | |
240 | TVector3 AliTrackParam::PositionAt(Double_t x) const | |
241 | { | |
242 | // get the spatial position at x in global coordinates | |
243 | ||
244 | Double_t y; | |
245 | Double_t z; | |
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); | |
250 | } | |
251 |