]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
a9e2aefa | 17 | |
3831f268 | 18 | /////////////////////////////////////////////////// |
19 | // | |
20 | // Track parameters | |
21 | // in | |
22 | // ALICE | |
23 | // dimuon | |
24 | // spectrometer | |
a9e2aefa | 25 | // |
3831f268 | 26 | /////////////////////////////////////////////////// |
a9e2aefa | 27 | |
37827b29 | 28 | #include "AliMUONTrackParam.h" |
22ccc301 | 29 | #include "AliMUONHitForRec.h" |
30 | ||
211c52eb | 31 | #include "AliESDMuonTrack.h" |
37827b29 | 32 | #include "AliLog.h" |
22ccc301 | 33 | |
34 | #include <Riostream.h> | |
35 | #include <TMath.h> | |
36 | #include <TMatrixD.h> | |
a9e2aefa | 37 | |
7945aae7 | 38 | /// \cond CLASSIMP |
a9e2aefa | 39 | ClassImp(AliMUONTrackParam) // Class implementation in ROOT context |
7945aae7 | 40 | /// \endcond |
a9e2aefa | 41 | |
61adb9bd | 42 | //_________________________________________________________________________ |
30178c30 | 43 | AliMUONTrackParam::AliMUONTrackParam() |
54d7ba50 | 44 | : TObject(), |
208f139e | 45 | fNonBendingCoor(0.), |
54d7ba50 | 46 | fNonBendingSlope(0.), |
54d7ba50 | 47 | fBendingCoor(0.), |
208f139e | 48 | fBendingSlope(0.), |
49 | fInverseBendingMomentum(0.), | |
50 | fZ(0.), | |
51 | fCovariances(0x0), | |
de2cd600 | 52 | fHitForRecPtr(0x0) |
30178c30 | 53 | { |
37827b29 | 54 | /// Constructor |
30178c30 | 55 | } |
61adb9bd | 56 | |
30178c30 | 57 | //_________________________________________________________________________ |
de2cd600 | 58 | AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam) |
59 | : TObject(theMUONTrackParam), | |
208f139e | 60 | fNonBendingCoor(theMUONTrackParam.fNonBendingCoor), |
de2cd600 | 61 | fNonBendingSlope(theMUONTrackParam.fNonBendingSlope), |
de2cd600 | 62 | fBendingCoor(theMUONTrackParam.fBendingCoor), |
208f139e | 63 | fBendingSlope(theMUONTrackParam.fBendingSlope), |
64 | fInverseBendingMomentum(theMUONTrackParam.fInverseBendingMomentum), | |
65 | fZ(theMUONTrackParam.fZ), | |
66 | fCovariances(0x0), | |
de2cd600 | 67 | fHitForRecPtr(theMUONTrackParam.fHitForRecPtr) |
68 | { | |
2457f726 | 69 | /// Copy constructor |
208f139e | 70 | if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances)); |
de2cd600 | 71 | } |
72 | ||
73 | //_________________________________________________________________________ | |
74 | AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam) | |
61adb9bd | 75 | { |
2457f726 | 76 | /// Asignment operator |
30178c30 | 77 | if (this == &theMUONTrackParam) |
61adb9bd | 78 | return *this; |
79 | ||
30178c30 | 80 | // base class assignement |
81 | TObject::operator=(theMUONTrackParam); | |
82 | ||
208f139e | 83 | fNonBendingCoor = theMUONTrackParam.fNonBendingCoor; |
84 | fNonBendingSlope = theMUONTrackParam.fNonBendingSlope; | |
85 | fBendingCoor = theMUONTrackParam.fBendingCoor; | |
86 | fBendingSlope = theMUONTrackParam.fBendingSlope; | |
87 | fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum; | |
88 | fZ = theMUONTrackParam.fZ; | |
89 | ||
90 | if (theMUONTrackParam.fCovariances) { | |
91 | if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances); | |
92 | else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances)); | |
93 | } else if (fCovariances) { | |
94 | delete fCovariances; | |
95 | fCovariances = 0x0; | |
96 | } | |
97 | ||
61adb9bd | 98 | return *this; |
99 | } | |
de2cd600 | 100 | |
101 | //__________________________________________________________________________ | |
102 | AliMUONTrackParam::~AliMUONTrackParam() | |
61adb9bd | 103 | { |
de2cd600 | 104 | /// Destructor |
208f139e | 105 | DeleteCovariances(); |
de2cd600 | 106 | } |
107 | ||
108 | //__________________________________________________________________________ | |
109 | void AliMUONTrackParam::SetTrackParam(AliMUONTrackParam& theMUONTrackParam) | |
110 | { | |
208f139e | 111 | /// Set track parameters from "TrackParam" leaving pointer to fHitForRecPtr and parameter covariances unchanged |
112 | fNonBendingCoor = theMUONTrackParam.fNonBendingCoor; | |
113 | fNonBendingSlope = theMUONTrackParam.fNonBendingSlope; | |
114 | fBendingCoor = theMUONTrackParam.fBendingCoor; | |
115 | fBendingSlope = theMUONTrackParam.fBendingSlope; | |
116 | fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum; | |
117 | fZ = theMUONTrackParam.fZ; | |
de2cd600 | 118 | } |
54d7ba50 | 119 | |
de2cd600 | 120 | //__________________________________________________________________________ |
121 | AliMUONHitForRec* AliMUONTrackParam::GetHitForRecPtr(void) const | |
122 | { | |
123 | /// return pointer to HitForRec attached to the current TrackParam | |
124 | /// this method should not be called when fHitForRecPtr == NULL | |
208f139e | 125 | if (!fHitForRecPtr) AliWarning("fHitForRecPtr == NULL"); |
de2cd600 | 126 | return fHitForRecPtr; |
127 | } | |
128 | ||
211c52eb | 129 | //_________________________________________________________________________ |
130 | void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack) | |
131 | { | |
2457f726 | 132 | /// assigned value form ESD track. |
208f139e | 133 | fInverseBendingMomentum = esdMuonTrack.GetInverseBendingMomentum(); |
134 | fBendingSlope = TMath::Tan(esdMuonTrack.GetThetaY()); | |
135 | fNonBendingSlope = TMath::Tan(esdMuonTrack.GetThetaX()); | |
136 | fZ = esdMuonTrack.GetZ(); | |
137 | fBendingCoor = esdMuonTrack.GetBendingCoor(); | |
138 | fNonBendingCoor = esdMuonTrack.GetNonBendingCoor(); | |
211c52eb | 139 | } |
140 | ||
141 | //_________________________________________________________________________ | |
142 | void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack) | |
143 | { | |
2457f726 | 144 | /// assigned value form ESD track. |
211c52eb | 145 | esdMuonTrack.SetInverseBendingMomentum(fInverseBendingMomentum); |
146 | esdMuonTrack.SetThetaX(TMath::ATan(fNonBendingSlope)); | |
147 | esdMuonTrack.SetThetaY(TMath::ATan(fBendingSlope)); | |
148 | esdMuonTrack.SetZ(fZ); | |
149 | esdMuonTrack.SetBendingCoor(fBendingCoor); | |
150 | esdMuonTrack.SetNonBendingCoor(fNonBendingCoor); | |
151 | } | |
152 | ||
22ccc301 | 153 | //_________________________________________________________________________ |
154 | void AliMUONTrackParam::GetParamFromUncorrected(const AliESDMuonTrack& esdMuonTrack) | |
155 | { | |
156 | /// assigned value form ESD track. | |
157 | fInverseBendingMomentum = esdMuonTrack.GetInverseBendingMomentumUncorrected(); | |
158 | fBendingSlope = TMath::Tan(esdMuonTrack.GetThetaYUncorrected()); | |
159 | fNonBendingSlope = TMath::Tan(esdMuonTrack.GetThetaXUncorrected()); | |
160 | fZ = esdMuonTrack.GetZUncorrected(); | |
161 | fBendingCoor = esdMuonTrack.GetBendingCoorUncorrected(); | |
162 | fNonBendingCoor = esdMuonTrack.GetNonBendingCoorUncorrected(); | |
163 | } | |
164 | ||
165 | //_________________________________________________________________________ | |
166 | void AliMUONTrackParam::SetParamForUncorrected(AliESDMuonTrack& esdMuonTrack) | |
167 | { | |
168 | /// assigned value form ESD track. | |
169 | esdMuonTrack.SetInverseBendingMomentumUncorrected(fInverseBendingMomentum); | |
170 | esdMuonTrack.SetThetaXUncorrected(TMath::ATan(fNonBendingSlope)); | |
171 | esdMuonTrack.SetThetaYUncorrected(TMath::ATan(fBendingSlope)); | |
172 | esdMuonTrack.SetZUncorrected(fZ); | |
173 | esdMuonTrack.SetBendingCoorUncorrected(fBendingCoor); | |
174 | esdMuonTrack.SetNonBendingCoorUncorrected(fNonBendingCoor); | |
175 | } | |
176 | ||
b8dc484b | 177 | //__________________________________________________________________________ |
6464217e | 178 | Double_t AliMUONTrackParam::Px() const |
b8dc484b | 179 | { |
22ccc301 | 180 | /// return p_x from track parameters |
b8dc484b | 181 | Double_t pYZ, pZ, pX; |
182 | pYZ = 0; | |
183 | if ( TMath::Abs(fInverseBendingMomentum) > 0 ) | |
184 | pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); | |
185 | pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) | |
186 | pX = pZ * fNonBendingSlope; | |
187 | return pX; | |
188 | } | |
37827b29 | 189 | |
b8dc484b | 190 | //__________________________________________________________________________ |
6464217e | 191 | Double_t AliMUONTrackParam::Py() const |
b8dc484b | 192 | { |
22ccc301 | 193 | /// return p_y from track parameters |
b8dc484b | 194 | Double_t pYZ, pZ, pY; |
195 | pYZ = 0; | |
196 | if ( TMath::Abs(fInverseBendingMomentum) > 0 ) | |
197 | pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); | |
198 | pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) | |
199 | pY = pZ * fBendingSlope; | |
200 | return pY; | |
201 | } | |
37827b29 | 202 | |
b8dc484b | 203 | //__________________________________________________________________________ |
6464217e | 204 | Double_t AliMUONTrackParam::Pz() const |
b8dc484b | 205 | { |
22ccc301 | 206 | /// return p_z from track parameters |
b8dc484b | 207 | Double_t pYZ, pZ; |
208 | pYZ = 0; | |
209 | if ( TMath::Abs(fInverseBendingMomentum) > 0 ) | |
210 | pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); | |
211 | pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) | |
212 | return pZ; | |
213 | } | |
37827b29 | 214 | |
b8dc484b | 215 | //__________________________________________________________________________ |
6464217e | 216 | Double_t AliMUONTrackParam::P() const |
b8dc484b | 217 | { |
22ccc301 | 218 | /// return p from track parameters |
b8dc484b | 219 | Double_t pYZ, pZ, p; |
220 | pYZ = 0; | |
221 | if ( TMath::Abs(fInverseBendingMomentum) > 0 ) | |
222 | pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); | |
223 | pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) | |
224 | p = TMath::Abs(pZ) * | |
225 | TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope + fNonBendingSlope * fNonBendingSlope); | |
226 | return p; | |
227 | ||
b45fd22b | 228 | } |
4d03a78e | 229 | |
208f139e | 230 | //__________________________________________________________________________ |
231 | TMatrixD* AliMUONTrackParam::GetCovariances() | |
232 | { | |
233 | /// Return the covariance matrix (create it before if needed) | |
234 | if (!fCovariances) { | |
235 | fCovariances = new TMatrixD(5,5); | |
236 | (*fCovariances) = 0; | |
237 | } | |
238 | return fCovariances; | |
239 | } | |
240 | ||
241 | //__________________________________________________________________________ | |
242 | void AliMUONTrackParam::SetCovariances(TMatrixD* covariances) | |
243 | { | |
244 | /// Set the covariance matrix | |
245 | if (covariances == fCovariances) return; // nothing to be done | |
246 | if (fCovariances) *fCovariances = *covariances; | |
247 | else fCovariances = new TMatrixD(*covariances); | |
248 | } | |
249 | ||
250 | //__________________________________________________________________________ | |
251 | void AliMUONTrackParam::SetCovariances(Double_t matrix[5][5]) | |
252 | { | |
253 | /// Set the covariance matrix | |
254 | if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0])); | |
255 | else fCovariances = new TMatrixD(5,5,&(matrix[0][0])); | |
256 | } | |
257 | ||
258 | //__________________________________________________________________________ | |
259 | void AliMUONTrackParam::SetVariances(Double_t matrix[5][5]) | |
260 | { | |
261 | /// Set the diagonal terms of the covariance matrix (variances) | |
262 | if (!fCovariances) fCovariances = new TMatrixD(5,5); | |
263 | (*fCovariances) = 0; | |
264 | for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i]; | |
265 | } | |
266 | ||
267 | //__________________________________________________________________________ | |
268 | void AliMUONTrackParam::DeleteCovariances() | |
269 | { | |
270 | /// Delete the covariance matrix | |
271 | if (fCovariances) delete fCovariances; | |
272 | fCovariances = 0x0; | |
273 | } | |
274 | ||
275 | //__________________________________________________________________________ | |
276 | void AliMUONTrackParam::EvalCovariances(AliMUONHitForRec* hit2) | |
277 | { | |
278 | /// Evaluate covariances assuming the track is only a straight line | |
279 | /// between the HitForRec attached to the current TrackParam and hit2. | |
280 | /// Nothing can be done on fInverseBendingMomentum (-> 50% err). | |
281 | ||
282 | // Allocate memory if needed | |
283 | if (!fCovariances) fCovariances = new TMatrixD(5,5); | |
284 | ||
285 | // Reset the covariance matrix | |
286 | (*fCovariances) = 0; | |
287 | ||
288 | if (!fHitForRecPtr) { | |
289 | AliWarning("fHitForRecPtr == NULL: cannot calculate TrackParam covariances"); | |
290 | return; | |
291 | } | |
292 | ||
293 | Double_t dz = fHitForRecPtr->GetZ() - hit2->GetZ(); | |
294 | ||
295 | // Non bending plane | |
296 | (*fCovariances)(0,0) = fHitForRecPtr->GetNonBendingReso2(); | |
297 | (*fCovariances)(0,1) = fHitForRecPtr->GetNonBendingReso2() / dz; | |
298 | (*fCovariances)(1,0) = (*fCovariances)(0,1); | |
299 | (*fCovariances)(1,1) = ( fHitForRecPtr->GetNonBendingReso2() + hit2->GetNonBendingReso2() ) / dz / dz; | |
300 | // Bending plane | |
301 | (*fCovariances)(2,2) = fHitForRecPtr->GetBendingReso2(); | |
302 | (*fCovariances)(2,3) = fHitForRecPtr->GetBendingReso2() / dz; | |
303 | (*fCovariances)(3,2) = (*fCovariances)(2,3); | |
304 | (*fCovariances)(3,3) = ( fHitForRecPtr->GetBendingReso2() + hit2->GetBendingReso2() ) / dz / dz; | |
305 | // Inverse bending momentum | |
306 | (*fCovariances)(4,4) = 0.5*fInverseBendingMomentum * 0.5*fInverseBendingMomentum; // error 50% | |
307 | ||
308 | } | |
309 | ||
310 | //__________________________________________________________________________ | |
311 | Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const | |
312 | { | |
313 | /// "Compare" function to sort with decreasing Z (spectro. muon Z <0). | |
314 | /// Returns 1 (0, -1) if Z of current TrackHit | |
315 | /// is smaller than (equal to, larger than) Z of TrackHit | |
847cbaef | 316 | if (fHitForRecPtr) { |
317 | if (fHitForRecPtr->GetZ() != fZ) | |
318 | AliWarning("track parameters are given at a different z position than the one of the corresponding hit"); | |
319 | } | |
320 | if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1); | |
321 | else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0); | |
208f139e | 322 | else return(-1); |
323 | } | |
324 | ||
6464217e | 325 | //_____________________________________________- |
326 | void AliMUONTrackParam::Print(Option_t* opt) const | |
327 | { | |
2457f726 | 328 | /// Printing TrackParam information |
329 | /// "full" option for printing all the information about the TrackParam | |
6464217e | 330 | TString sopt(opt); |
331 | sopt.ToUpper(); | |
332 | ||
333 | if ( sopt.Contains("FULL") ) { | |
334 | cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./GetInverseBendingMomentum() << | |
335 | ", NonBendSlope=" << setw(5) << setprecision(3) << GetNonBendingSlope()*180./TMath::Pi() << | |
336 | ", BendSlope=" << setw(5) << setprecision(3) << GetBendingSlope()*180./TMath::Pi() << | |
337 | ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << GetNonBendingCoor() << | |
338 | "," << setw(5) << setprecision(3) << GetBendingCoor() << | |
339 | "," << setw(5) << setprecision(3) << GetZ() << | |
340 | ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() << | |
341 | "," << setw(5) << setprecision(3) << Py() << | |
342 | "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl; | |
343 | } | |
344 | else { | |
345 | cout << "<AliMUONTrackParam>" << endl; | |
346 | } | |
347 | ||
348 | } |