]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // Class AliMUONTrackParam | |
20 | //------------------------- | |
21 | // Track parameters in ALICE dimuon spectrometer | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
24 | #include "AliMUONTrackParam.h" | |
25 | #include "AliMUONVCluster.h" | |
26 | ||
27 | #include "AliLog.h" | |
28 | ||
29 | #include <TMath.h> | |
30 | ||
31 | #include <Riostream.h> | |
32 | ||
33 | using std::setw; | |
34 | using std::setprecision; | |
35 | using std::endl; | |
36 | using std::cout; | |
37 | /// \cond CLASSIMP | |
38 | ClassImp(AliMUONTrackParam) // Class implementation in ROOT context | |
39 | /// \endcond | |
40 | ||
41 | //_________________________________________________________________________ | |
42 | AliMUONTrackParam::AliMUONTrackParam() | |
43 | : TObject(), | |
44 | fZ(0.), | |
45 | fParameters(5,1), | |
46 | fCovariances(0x0), | |
47 | fPropagator(0x0), | |
48 | fExtrapParameters(0x0), | |
49 | fExtrapCovariances(0x0), | |
50 | fSmoothParameters(0x0), | |
51 | fSmoothCovariances(0x0), | |
52 | fClusterPtr(0x0), | |
53 | fOwnCluster(kFALSE), | |
54 | fRemovable(kFALSE), | |
55 | fTrackChi2(0.), | |
56 | fLocalChi2(0.) | |
57 | { | |
58 | /// Constructor | |
59 | fParameters.Zero(); | |
60 | } | |
61 | ||
62 | //_________________________________________________________________________ | |
63 | AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam) | |
64 | : TObject(theMUONTrackParam), | |
65 | fZ(theMUONTrackParam.fZ), | |
66 | fParameters(theMUONTrackParam.fParameters), | |
67 | fCovariances(0x0), | |
68 | fPropagator(0x0), | |
69 | fExtrapParameters(0x0), | |
70 | fExtrapCovariances(0x0), | |
71 | fSmoothParameters(0x0), | |
72 | fSmoothCovariances(0x0), | |
73 | fClusterPtr(0x0), | |
74 | fOwnCluster(theMUONTrackParam.fOwnCluster), | |
75 | fRemovable(theMUONTrackParam.fRemovable), | |
76 | fTrackChi2(theMUONTrackParam.fTrackChi2), | |
77 | fLocalChi2(theMUONTrackParam.fLocalChi2) | |
78 | { | |
79 | /// Copy constructor | |
80 | if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances)); | |
81 | if (theMUONTrackParam.fPropagator) fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator)); | |
82 | if (theMUONTrackParam.fExtrapParameters) fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters)); | |
83 | if (theMUONTrackParam.fExtrapCovariances) fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances)); | |
84 | if (theMUONTrackParam.fSmoothParameters) fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters)); | |
85 | if (theMUONTrackParam.fSmoothCovariances) fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances)); | |
86 | ||
87 | if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone()); | |
88 | else fClusterPtr = theMUONTrackParam.fClusterPtr; | |
89 | } | |
90 | ||
91 | //_________________________________________________________________________ | |
92 | AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam) | |
93 | { | |
94 | /// Asignment operator | |
95 | if (this == &theMUONTrackParam) | |
96 | return *this; | |
97 | ||
98 | // base class assignement | |
99 | TObject::operator=(theMUONTrackParam); | |
100 | ||
101 | fZ = theMUONTrackParam.fZ; | |
102 | ||
103 | fParameters = theMUONTrackParam.fParameters; | |
104 | ||
105 | if (theMUONTrackParam.fCovariances) { | |
106 | if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances); | |
107 | else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances)); | |
108 | } else { | |
109 | delete fCovariances; | |
110 | fCovariances = 0x0; | |
111 | } | |
112 | ||
113 | if (theMUONTrackParam.fPropagator) { | |
114 | if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator); | |
115 | else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator)); | |
116 | } else { | |
117 | delete fPropagator; | |
118 | fPropagator = 0x0; | |
119 | } | |
120 | ||
121 | if (theMUONTrackParam.fExtrapParameters) { | |
122 | if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters); | |
123 | else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters)); | |
124 | } else { | |
125 | delete fExtrapParameters; | |
126 | fExtrapParameters = 0x0; | |
127 | } | |
128 | ||
129 | if (theMUONTrackParam.fExtrapCovariances) { | |
130 | if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances); | |
131 | else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances)); | |
132 | } else { | |
133 | delete fExtrapCovariances; | |
134 | fExtrapCovariances = 0x0; | |
135 | } | |
136 | ||
137 | if (theMUONTrackParam.fSmoothParameters) { | |
138 | if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters); | |
139 | else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters)); | |
140 | } else { | |
141 | delete fSmoothParameters; | |
142 | fSmoothParameters = 0x0; | |
143 | } | |
144 | ||
145 | if (theMUONTrackParam.fSmoothCovariances) { | |
146 | if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances); | |
147 | else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances)); | |
148 | } else { | |
149 | delete fSmoothCovariances; | |
150 | fSmoothCovariances = 0x0; | |
151 | } | |
152 | ||
153 | if (fOwnCluster) delete fClusterPtr; | |
154 | fOwnCluster = theMUONTrackParam.fOwnCluster; | |
155 | if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone()); | |
156 | else fClusterPtr = theMUONTrackParam.fClusterPtr; | |
157 | ||
158 | fRemovable = theMUONTrackParam.fRemovable; | |
159 | ||
160 | fTrackChi2 = theMUONTrackParam.fTrackChi2; | |
161 | fLocalChi2 = theMUONTrackParam.fLocalChi2; | |
162 | ||
163 | return *this; | |
164 | } | |
165 | ||
166 | //__________________________________________________________________________ | |
167 | AliMUONTrackParam::~AliMUONTrackParam() | |
168 | { | |
169 | /// Destructor | |
170 | DeleteCovariances(); | |
171 | delete fPropagator; | |
172 | delete fExtrapParameters; | |
173 | delete fExtrapCovariances; | |
174 | delete fSmoothParameters; | |
175 | delete fSmoothCovariances; | |
176 | if(fOwnCluster) delete fClusterPtr; | |
177 | } | |
178 | ||
179 | //__________________________________________________________________________ | |
180 | void | |
181 | AliMUONTrackParam::Clear(Option_t* /*opt*/) | |
182 | { | |
183 | /// clear memory | |
184 | DeleteCovariances(); | |
185 | delete fPropagator; fPropagator = 0x0; | |
186 | delete fExtrapParameters; fExtrapParameters = 0x0; | |
187 | delete fExtrapCovariances; fExtrapCovariances = 0x0; | |
188 | delete fSmoothParameters; fSmoothParameters = 0x0; | |
189 | delete fSmoothCovariances; fSmoothCovariances = 0x0; | |
190 | if(fOwnCluster) { | |
191 | delete fClusterPtr; fClusterPtr = 0x0; | |
192 | } | |
193 | } | |
194 | ||
195 | //__________________________________________________________________________ | |
196 | Double_t AliMUONTrackParam::Px() const | |
197 | { | |
198 | /// return p_x from track parameters | |
199 | Double_t pZ; | |
200 | if (TMath::Abs(fParameters(4,0)) > 0) { | |
201 | Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX; | |
202 | pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) | |
203 | } else { | |
204 | pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); | |
205 | } | |
206 | return pZ * fParameters(1,0); | |
207 | } | |
208 | ||
209 | //__________________________________________________________________________ | |
210 | Double_t AliMUONTrackParam::Py() const | |
211 | { | |
212 | /// return p_y from track parameters | |
213 | Double_t pZ; | |
214 | if (TMath::Abs(fParameters(4,0)) > 0) { | |
215 | Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX; | |
216 | pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) | |
217 | } else { | |
218 | pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); | |
219 | } | |
220 | return pZ * fParameters(3,0); | |
221 | } | |
222 | ||
223 | //__________________________________________________________________________ | |
224 | Double_t AliMUONTrackParam::Pz() const | |
225 | { | |
226 | /// return p_z from track parameters | |
227 | if (TMath::Abs(fParameters(4,0)) > 0) { | |
228 | Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0)); | |
229 | return - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) | |
230 | } else return - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); | |
231 | } | |
232 | ||
233 | //__________________________________________________________________________ | |
234 | Double_t AliMUONTrackParam::P() const | |
235 | { | |
236 | /// return p from track parameters | |
237 | if (TMath::Abs(fParameters(4,0)) > 0) { | |
238 | Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0)); | |
239 | Double_t pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) | |
240 | return - pZ * TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); | |
241 | } else return FLT_MAX; | |
242 | } | |
243 | ||
244 | //__________________________________________________________________________ | |
245 | const TMatrixD& AliMUONTrackParam::GetCovariances() const | |
246 | { | |
247 | /// Return the covariance matrix (create it before if needed) | |
248 | if (!fCovariances) { | |
249 | fCovariances = new TMatrixD(5,5); | |
250 | fCovariances->Zero(); | |
251 | } | |
252 | return *fCovariances; | |
253 | } | |
254 | ||
255 | //__________________________________________________________________________ | |
256 | void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances) | |
257 | { | |
258 | /// Set the covariance matrix | |
259 | if (fCovariances) *fCovariances = covariances; | |
260 | else fCovariances = new TMatrixD(covariances); | |
261 | } | |
262 | ||
263 | //__________________________________________________________________________ | |
264 | void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5]) | |
265 | { | |
266 | /// Set the covariance matrix | |
267 | if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0])); | |
268 | else fCovariances = new TMatrixD(5,5,&(matrix[0][0])); | |
269 | } | |
270 | ||
271 | //__________________________________________________________________________ | |
272 | void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5]) | |
273 | { | |
274 | /// Set the diagonal terms of the covariance matrix (variances) | |
275 | if (!fCovariances) fCovariances = new TMatrixD(5,5); | |
276 | fCovariances->Zero(); | |
277 | for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i]; | |
278 | } | |
279 | ||
280 | //__________________________________________________________________________ | |
281 | void AliMUONTrackParam::DeleteCovariances() | |
282 | { | |
283 | /// Delete the covariance matrix | |
284 | delete fCovariances; | |
285 | fCovariances = 0x0; | |
286 | } | |
287 | ||
288 | //__________________________________________________________________________ | |
289 | const TMatrixD& AliMUONTrackParam::GetPropagator() const | |
290 | { | |
291 | /// Return the propagator (create it before if needed) | |
292 | if (!fPropagator) { | |
293 | fPropagator = new TMatrixD(5,5); | |
294 | fPropagator->UnitMatrix(); | |
295 | } | |
296 | return *fPropagator; | |
297 | } | |
298 | ||
299 | //__________________________________________________________________________ | |
300 | void AliMUONTrackParam::ResetPropagator() | |
301 | { | |
302 | /// Reset the propagator | |
303 | if (fPropagator) fPropagator->UnitMatrix(); | |
304 | } | |
305 | ||
306 | //__________________________________________________________________________ | |
307 | void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator) | |
308 | { | |
309 | /// Update the propagator | |
310 | if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator); | |
311 | else fPropagator = new TMatrixD(propagator); | |
312 | } | |
313 | ||
314 | //__________________________________________________________________________ | |
315 | const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const | |
316 | { | |
317 | /// Return extrapolated parameters (create it before if needed) | |
318 | if (!fExtrapParameters) { | |
319 | fExtrapParameters = new TMatrixD(5,1); | |
320 | fExtrapParameters->Zero(); | |
321 | } | |
322 | return *fExtrapParameters; | |
323 | } | |
324 | ||
325 | //__________________________________________________________________________ | |
326 | void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters) | |
327 | { | |
328 | /// Set extrapolated parameters | |
329 | if (fExtrapParameters) *fExtrapParameters = extrapParameters; | |
330 | else fExtrapParameters = new TMatrixD(extrapParameters); | |
331 | } | |
332 | ||
333 | //__________________________________________________________________________ | |
334 | const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const | |
335 | { | |
336 | /// Return the extrapolated covariance matrix (create it before if needed) | |
337 | if (!fExtrapCovariances) { | |
338 | fExtrapCovariances = new TMatrixD(5,5); | |
339 | fExtrapCovariances->Zero(); | |
340 | } | |
341 | return *fExtrapCovariances; | |
342 | } | |
343 | ||
344 | //__________________________________________________________________________ | |
345 | void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances) | |
346 | { | |
347 | /// Set the extrapolated covariance matrix | |
348 | if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances; | |
349 | else fExtrapCovariances = new TMatrixD(extrapCovariances); | |
350 | } | |
351 | ||
352 | //__________________________________________________________________________ | |
353 | const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const | |
354 | { | |
355 | /// Return the smoothed parameters (create it before if needed) | |
356 | if (!fSmoothParameters) { | |
357 | fSmoothParameters = new TMatrixD(5,1); | |
358 | fSmoothParameters->Zero(); | |
359 | } | |
360 | return *fSmoothParameters; | |
361 | } | |
362 | ||
363 | //__________________________________________________________________________ | |
364 | void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters) | |
365 | { | |
366 | /// Set the smoothed parameters | |
367 | if (fSmoothParameters) *fSmoothParameters = smoothParameters; | |
368 | else fSmoothParameters = new TMatrixD(smoothParameters); | |
369 | } | |
370 | ||
371 | //__________________________________________________________________________ | |
372 | const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const | |
373 | { | |
374 | /// Return the smoothed covariance matrix (create it before if needed) | |
375 | if (!fSmoothCovariances) { | |
376 | fSmoothCovariances = new TMatrixD(5,5); | |
377 | fSmoothCovariances->Zero(); | |
378 | } | |
379 | return *fSmoothCovariances; | |
380 | } | |
381 | ||
382 | //__________________________________________________________________________ | |
383 | void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances) | |
384 | { | |
385 | /// Set the smoothed covariance matrix | |
386 | if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances; | |
387 | else fSmoothCovariances = new TMatrixD(smoothCovariances); | |
388 | } | |
389 | ||
390 | //__________________________________________________________________________ | |
391 | void AliMUONTrackParam::SetClusterPtr(AliMUONVCluster* cluster, Bool_t owner) | |
392 | { | |
393 | /// set pointeur to associated cluster | |
394 | if (fOwnCluster) delete fClusterPtr; | |
395 | fClusterPtr = cluster; | |
396 | fOwnCluster = owner; | |
397 | } | |
398 | ||
399 | //__________________________________________________________________________ | |
400 | Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const | |
401 | { | |
402 | /// "Compare" function to sort with decreasing Z (spectro. muon Z <0). | |
403 | /// Returns 1 (0, -1) if the current Z | |
404 | /// is smaller than (equal to, larger than) Z of trackParam | |
405 | if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1); | |
406 | else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0); | |
407 | else return(-1); | |
408 | } | |
409 | ||
410 | //__________________________________________________________________________ | |
411 | Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const | |
412 | { | |
413 | /// Return kTRUE if the two set of track parameters are compatible within sigma2Cut | |
414 | /// Set chi2 to the compatible chi2 value | |
415 | /// Note that parameter covariances must exist for at least one set of parameters | |
416 | /// Note also that if parameters are not given at the same Z, results will be meaningless | |
417 | ||
418 | // reset chi2 value | |
419 | chi2 = 0.; | |
420 | ||
421 | // ckeck covariance matrices | |
422 | if (!fCovariances && !trackParam.fCovariances) { | |
423 | AliError("Covariance matrix must exist for at least one set of parameters"); | |
424 | return kFALSE; | |
425 | } | |
426 | ||
427 | Double_t maxChi2 = 5. * sigma2Cut * sigma2Cut; // 5 degrees of freedom | |
428 | ||
429 | // check Z parameters | |
430 | if (fZ != trackParam.fZ) | |
431 | AliWarning(Form("Parameters are given at different Z position (%e : %e): results are meaningless", fZ, trackParam.fZ)); | |
432 | ||
433 | // compute the parameter residuals | |
434 | TMatrixD deltaParam(fParameters, TMatrixD::kMinus, trackParam.fParameters); | |
435 | ||
436 | // build the error matrix | |
437 | TMatrixD weight(5,5); | |
438 | if (fCovariances) weight += *fCovariances; | |
439 | if (trackParam.fCovariances) weight += *(trackParam.fCovariances); | |
440 | ||
441 | // invert the error matrix to get the parameter weights if possible | |
442 | if (weight.Determinant() == 0) { | |
443 | AliError("Cannot compute the compatibility chi2"); | |
444 | return kFALSE; | |
445 | } | |
446 | weight.Invert(); | |
447 | ||
448 | // compute the compatibility chi2 | |
449 | TMatrixD tmp(deltaParam, TMatrixD::kTransposeMult, weight); | |
450 | TMatrixD mChi2(tmp, TMatrixD::kMult, deltaParam); | |
451 | ||
452 | // set chi2 value | |
453 | chi2 = mChi2(0,0); | |
454 | ||
455 | // check compatibility | |
456 | if (chi2 > maxChi2) return kFALSE; | |
457 | ||
458 | return kTRUE; | |
459 | } | |
460 | ||
461 | //__________________________________________________________________________ | |
462 | void AliMUONTrackParam::Print(Option_t* opt) const | |
463 | { | |
464 | /// Printing TrackParam information | |
465 | /// "full" option for printing all the information about the TrackParam | |
466 | TString sopt(opt); | |
467 | sopt.ToUpper(); | |
468 | ||
469 | if ( sopt.Contains("FULL") ) { | |
470 | cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./fParameters(4,0) << | |
471 | ", NonBendSlope=" << setw(5) << setprecision(3) << fParameters(1,0)*180./TMath::Pi() << | |
472 | ", BendSlope=" << setw(5) << setprecision(3) << fParameters(3,0)*180./TMath::Pi() << | |
473 | ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << fParameters(0,0) << | |
474 | "," << setw(5) << setprecision(3) << fParameters(2,0) << | |
475 | "," << setw(5) << setprecision(3) << fZ << | |
476 | ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() << | |
477 | "," << setw(5) << setprecision(3) << Py() << | |
478 | "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" | |
479 | "," << "local chi2=" << GetLocalChi2() << endl; | |
480 | } | |
481 | else { | |
482 | cout << "<AliMUONTrackParam>" << endl; | |
483 | } | |
484 | ||
485 | } |