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