Bug fixed for conversion to same float value for start/end timestamps
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackParam.cxx
CommitLineData
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
56316147 18//-----------------------------------------------------------------------------
19// Class AliMUONTrackParam
20//-------------------------
21// Track parameters in ALICE dimuon spectrometer
22//-----------------------------------------------------------------------------
a9e2aefa 23
37827b29 24#include "AliMUONTrackParam.h"
96ebe67e 25#include "AliMUONVCluster.h"
22ccc301 26
211c52eb 27#include "AliESDMuonTrack.h"
37827b29 28#include "AliLog.h"
22ccc301 29
22ccc301 30#include <TMath.h>
ea94c18b 31
32#include <Riostream.h>
a9e2aefa 33
7945aae7 34/// \cond CLASSIMP
a9e2aefa 35ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
7945aae7 36/// \endcond
a9e2aefa 37
61adb9bd 38 //_________________________________________________________________________
30178c30 39AliMUONTrackParam::AliMUONTrackParam()
54d7ba50 40 : TObject(),
208f139e 41 fZ(0.),
ea94c18b 42 fParameters(5,1),
208f139e 43 fCovariances(0x0),
ea94c18b 44 fPropagator(0x0),
45 fExtrapParameters(0x0),
46 fExtrapCovariances(0x0),
47 fSmoothParameters(0x0),
48 fSmoothCovariances(0x0),
96ebe67e 49 fClusterPtr(0x0),
50 fOwnCluster(kFALSE),
ea94c18b 51 fRemovable(kFALSE),
b709ac13 52 fAloneInChamber(kTRUE),
ea94c18b 53 fTrackChi2(0.),
54 fLocalChi2(0.)
30178c30 55{
37827b29 56 /// Constructor
30178c30 57}
61adb9bd 58
30178c30 59 //_________________________________________________________________________
de2cd600 60AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
61 : TObject(theMUONTrackParam),
208f139e 62 fZ(theMUONTrackParam.fZ),
ea94c18b 63 fParameters(theMUONTrackParam.fParameters),
208f139e 64 fCovariances(0x0),
ea94c18b 65 fPropagator(0x0),
66 fExtrapParameters(0x0),
67 fExtrapCovariances(0x0),
68 fSmoothParameters(0x0),
69 fSmoothCovariances(0x0),
96ebe67e 70 fClusterPtr(0x0),
71 fOwnCluster(theMUONTrackParam.fOwnCluster),
ea94c18b 72 fRemovable(theMUONTrackParam.fRemovable),
b709ac13 73 fAloneInChamber(theMUONTrackParam.fAloneInChamber),
ea94c18b 74 fTrackChi2(theMUONTrackParam.fTrackChi2),
75 fLocalChi2(theMUONTrackParam.fLocalChi2)
de2cd600 76{
2457f726 77 /// Copy constructor
208f139e 78 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
ea94c18b 79 if (theMUONTrackParam.fPropagator) fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
80 if (theMUONTrackParam.fExtrapParameters) fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
81 if (theMUONTrackParam.fExtrapCovariances) fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
82 if (theMUONTrackParam.fSmoothParameters) fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
83 if (theMUONTrackParam.fSmoothCovariances) fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
96ebe67e 84
1467f4ba 85 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
96ebe67e 86 else fClusterPtr = theMUONTrackParam.fClusterPtr;
de2cd600 87}
88
89 //_________________________________________________________________________
90AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
61adb9bd 91{
2457f726 92 /// Asignment operator
30178c30 93 if (this == &theMUONTrackParam)
61adb9bd 94 return *this;
95
30178c30 96 // base class assignement
97 TObject::operator=(theMUONTrackParam);
98
ea94c18b 99 fZ = theMUONTrackParam.fZ;
100
101 fParameters = theMUONTrackParam.fParameters;
208f139e 102
103 if (theMUONTrackParam.fCovariances) {
104 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
105 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
019df241 106 } else {
208f139e 107 delete fCovariances;
108 fCovariances = 0x0;
109 }
110
ea94c18b 111 if (theMUONTrackParam.fPropagator) {
112 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
113 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
019df241 114 } else {
ea94c18b 115 delete fPropagator;
116 fPropagator = 0x0;
117 }
118
119 if (theMUONTrackParam.fExtrapParameters) {
120 if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
121 else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
019df241 122 } else {
ea94c18b 123 delete fExtrapParameters;
124 fExtrapParameters = 0x0;
125 }
126
127 if (theMUONTrackParam.fExtrapCovariances) {
128 if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
129 else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
019df241 130 } else {
ea94c18b 131 delete fExtrapCovariances;
132 fExtrapCovariances = 0x0;
133 }
134
135 if (theMUONTrackParam.fSmoothParameters) {
136 if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
137 else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
019df241 138 } else {
ea94c18b 139 delete fSmoothParameters;
140 fSmoothParameters = 0x0;
141 }
142
143 if (theMUONTrackParam.fSmoothCovariances) {
144 if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
145 else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
019df241 146 } else {
ea94c18b 147 delete fSmoothCovariances;
148 fSmoothCovariances = 0x0;
149 }
150
96ebe67e 151 fOwnCluster = theMUONTrackParam.fOwnCluster;
1467f4ba 152 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
96ebe67e 153 else fClusterPtr = theMUONTrackParam.fClusterPtr;
ea94c18b 154
155 fRemovable = theMUONTrackParam.fRemovable;
156
b709ac13 157 fAloneInChamber = theMUONTrackParam.fAloneInChamber;
158
ea94c18b 159 fTrackChi2 = theMUONTrackParam.fTrackChi2;
160 fLocalChi2 = theMUONTrackParam.fLocalChi2;
161
61adb9bd 162 return *this;
163}
de2cd600 164
165 //__________________________________________________________________________
166AliMUONTrackParam::~AliMUONTrackParam()
61adb9bd 167{
de2cd600 168/// Destructor
208f139e 169 DeleteCovariances();
ea94c18b 170 delete fPropagator;
171 delete fExtrapParameters;
172 delete fExtrapCovariances;
173 delete fSmoothParameters;
174 delete fSmoothCovariances;
96ebe67e 175 if(fOwnCluster) delete fClusterPtr;
de2cd600 176}
177
178 //__________________________________________________________________________
ea94c18b 179void
180AliMUONTrackParam::Clear(Option_t* /*opt*/)
181{
96ebe67e 182 /// clear memory
ea94c18b 183 DeleteCovariances();
184 delete fPropagator; fPropagator = 0x0;
185 delete fExtrapParameters; fExtrapParameters = 0x0;
186 delete fExtrapCovariances; fExtrapCovariances = 0x0;
187 delete fSmoothParameters; fSmoothParameters = 0x0;
188 delete fSmoothCovariances; fSmoothCovariances = 0x0;
96ebe67e 189 if(fOwnCluster) {
190 delete fClusterPtr; fClusterPtr = 0x0;
191 }
de2cd600 192}
193
211c52eb 194 //_________________________________________________________________________
195void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack)
196{
60765b06 197 /// Get parameters from ESD track
ea94c18b 198 fZ = esdMuonTrack.GetZ();
199 fParameters(0,0) = esdMuonTrack.GetNonBendingCoor();
200 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaX());
201 fParameters(2,0) = esdMuonTrack.GetBendingCoor();
202 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaY());
203 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentum();
211c52eb 204}
205
206 //_________________________________________________________________________
ea94c18b 207void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack) const
211c52eb 208{
60765b06 209 /// Set parameters in ESD track
ea94c18b 210 esdMuonTrack.SetZ(fZ);
211 esdMuonTrack.SetNonBendingCoor(fParameters(0,0));
212 esdMuonTrack.SetThetaX(TMath::ATan(fParameters(1,0)));
213 esdMuonTrack.SetBendingCoor(fParameters(2,0));
214 esdMuonTrack.SetThetaY(TMath::ATan(fParameters(3,0)));
215 esdMuonTrack.SetInverseBendingMomentum(fParameters(4,0));
211c52eb 216}
217
22ccc301 218 //_________________________________________________________________________
61fed964 219void AliMUONTrackParam::GetParamFromDCA(const AliESDMuonTrack& esdMuonTrack)
220{
221 /// Get parameters from ESD track
222 fZ = esdMuonTrack.GetZ();
223 fParameters(0,0) = esdMuonTrack.GetNonBendingCoorAtDCA();
224 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaXAtDCA());
225 fParameters(2,0) = esdMuonTrack.GetBendingCoorAtDCA();
226 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaYAtDCA());
227 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentumAtDCA();
228}
229
230 //_________________________________________________________________________
231void AliMUONTrackParam::SetParamForDCA(AliESDMuonTrack& esdMuonTrack) const
232{
233 /// Set parameters in ESD track
234 esdMuonTrack.SetNonBendingCoorAtDCA(fParameters(0,0));
235 esdMuonTrack.SetThetaXAtDCA(TMath::ATan(fParameters(1,0)));
236 esdMuonTrack.SetBendingCoorAtDCA(fParameters(2,0));
237 esdMuonTrack.SetThetaYAtDCA(TMath::ATan(fParameters(3,0)));
238 esdMuonTrack.SetInverseBendingMomentumAtDCA(fParameters(4,0));
239}
240
241//_________________________________________________________________________
22ccc301 242void AliMUONTrackParam::GetParamFromUncorrected(const AliESDMuonTrack& esdMuonTrack)
243{
60765b06 244 /// Get parameters from ESD track
ea94c18b 245 fZ = esdMuonTrack.GetZUncorrected();
246 fParameters(0,0) = esdMuonTrack.GetNonBendingCoorUncorrected();
247 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaXUncorrected());
248 fParameters(2,0) = esdMuonTrack.GetBendingCoorUncorrected();
249 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaYUncorrected());
250 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentumUncorrected();
22ccc301 251}
252
61fed964 253//_________________________________________________________________________
ea94c18b 254void AliMUONTrackParam::SetParamForUncorrected(AliESDMuonTrack& esdMuonTrack) const
22ccc301 255{
60765b06 256 /// Set parameters in ESD track
ea94c18b 257 esdMuonTrack.SetZUncorrected(fZ);
258 esdMuonTrack.SetNonBendingCoorUncorrected(fParameters(0,0));
259 esdMuonTrack.SetThetaXUncorrected(TMath::ATan(fParameters(1,0)));
260 esdMuonTrack.SetBendingCoorUncorrected(fParameters(2,0));
261 esdMuonTrack.SetThetaYUncorrected(TMath::ATan(fParameters(3,0)));
262 esdMuonTrack.SetInverseBendingMomentumUncorrected(fParameters(4,0));
22ccc301 263}
264
61fed964 265//_________________________________________________________________________
60765b06 266void AliMUONTrackParam::GetCovFrom(const AliESDMuonTrack& esdMuonTrack)
267{
268 /// Get parameters covariances from ESD track
269
270 // Get ESD covariance matrix
271 if (!fCovariances) fCovariances = new TMatrixD(5,5);
272 esdMuonTrack.GetCovariances(*fCovariances);
273
274 // compute Jacobian to change the coordinate system
275 // from (X,thetaX,Y,thetaY,c/pYZ) to (X,slopeX,Y,slopeY,c/pYZ)
276 Double_t cosThetaX = TMath::Cos(TMath::ATan(fParameters(1,0)));
277 Double_t cosThetaY = TMath::Cos(TMath::ATan(fParameters(3,0)));
278 TMatrixD jacob(5,5);
279 jacob.Zero();
280 jacob(0,0) = 1.;
281 jacob(1,1) = 1. / cosThetaX / cosThetaX;
282 jacob(2,2) = 1.;
283 jacob(3,3) = 1. / cosThetaY / cosThetaY;
284 jacob(4,4) = 1.;
285
286 // compute covariance matrix in ESD coordinate system
287 TMatrixD tmp(*fCovariances,TMatrixD::kMultTranspose,jacob);
288 *fCovariances = TMatrixD(jacob,TMatrixD::kMult,tmp);
289
290}
291
292 //_________________________________________________________________________
293void AliMUONTrackParam::SetCovFor(AliESDMuonTrack& esdMuonTrack) const
294{
295 /// Set parameters covariances in ESD track
296
297 // set null matrix if covariances does not exist
298 if (!fCovariances) {
299 TMatrixD tmp(5,5);
300 tmp.Zero();
301 esdMuonTrack.SetCovariances(tmp);
302 return;
303 }
304
305 // compute Jacobian to change the coordinate system
306 // from (X,slopeX,Y,slopeY,c/pYZ) to (X,thetaX,Y,thetaY,c/pYZ)
307 Double_t cosThetaX = TMath::Cos(TMath::ATan(fParameters(1,0)));
308 Double_t cosThetaY = TMath::Cos(TMath::ATan(fParameters(3,0)));
309 TMatrixD jacob(5,5);
310 jacob.Zero();
311 jacob(0,0) = 1.;
312 jacob(1,1) = cosThetaX * cosThetaX;
313 jacob(2,2) = 1.;
314 jacob(3,3) = cosThetaY * cosThetaY;
315 jacob(4,4) = 1.;
316
317 // compute covariance matrix in ESD coordinate system
318 TMatrixD tmp(*fCovariances,TMatrixD::kMultTranspose,jacob);
319 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
320 esdMuonTrack.SetCovariances(tmp2);
321
322}
323
a9e2aefa 324 //__________________________________________________________________________
6464217e 325Double_t AliMUONTrackParam::Px() const
b8dc484b 326{
22ccc301 327 /// return p_x from track parameters
b8dc484b 328 Double_t pYZ, pZ, pX;
329 pYZ = 0;
ea94c18b 330 if ( TMath::Abs(fParameters(4,0)) > 0 )
331 pYZ = TMath::Abs(1.0 / fParameters(4,0));
332 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
333 pX = pZ * fParameters(1,0);
b8dc484b 334 return pX;
335}
37827b29 336
b8dc484b 337 //__________________________________________________________________________
6464217e 338Double_t AliMUONTrackParam::Py() const
b8dc484b 339{
22ccc301 340 /// return p_y from track parameters
b8dc484b 341 Double_t pYZ, pZ, pY;
342 pYZ = 0;
ea94c18b 343 if ( TMath::Abs(fParameters(4,0)) > 0 )
344 pYZ = TMath::Abs(1.0 / fParameters(4,0));
345 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
346 pY = pZ * fParameters(3,0);
b8dc484b 347 return pY;
348}
37827b29 349
b8dc484b 350 //__________________________________________________________________________
6464217e 351Double_t AliMUONTrackParam::Pz() const
b8dc484b 352{
22ccc301 353 /// return p_z from track parameters
b8dc484b 354 Double_t pYZ, pZ;
355 pYZ = 0;
ea94c18b 356 if ( TMath::Abs(fParameters(4,0)) > 0 )
357 pYZ = TMath::Abs(1.0 / fParameters(4,0));
358 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
b8dc484b 359 return pZ;
360}
37827b29 361
b8dc484b 362 //__________________________________________________________________________
6464217e 363Double_t AliMUONTrackParam::P() const
b8dc484b 364{
22ccc301 365 /// return p from track parameters
b8dc484b 366 Double_t pYZ, pZ, p;
367 pYZ = 0;
ea94c18b 368 if ( TMath::Abs(fParameters(4,0)) > 0 )
369 pYZ = TMath::Abs(1.0 / fParameters(4,0));
370 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
b8dc484b 371 p = TMath::Abs(pZ) *
ea94c18b 372 TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
b8dc484b 373 return p;
374
375}
4d03a78e 376
208f139e 377 //__________________________________________________________________________
ea94c18b 378const TMatrixD& AliMUONTrackParam::GetCovariances() const
208f139e 379{
380 /// Return the covariance matrix (create it before if needed)
381 if (!fCovariances) {
382 fCovariances = new TMatrixD(5,5);
ea94c18b 383 fCovariances->Zero();
208f139e 384 }
ea94c18b 385 return *fCovariances;
386}
208f139e 387
388 //__________________________________________________________________________
ea94c18b 389void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
208f139e 390{
391 /// Set the covariance matrix
ea94c18b 392 if (fCovariances) *fCovariances = covariances;
393 else fCovariances = new TMatrixD(covariances);
208f139e 394}
395
396 //__________________________________________________________________________
ea94c18b 397void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
208f139e 398{
399 /// Set the covariance matrix
400 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
401 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
402}
403
404 //__________________________________________________________________________
ea94c18b 405void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
208f139e 406{
407 /// Set the diagonal terms of the covariance matrix (variances)
408 if (!fCovariances) fCovariances = new TMatrixD(5,5);
ea94c18b 409 fCovariances->Zero();
208f139e 410 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
411}
412
413 //__________________________________________________________________________
414void AliMUONTrackParam::DeleteCovariances()
415{
416 /// Delete the covariance matrix
686772dc 417 delete fCovariances;
208f139e 418 fCovariances = 0x0;
419}
420
421 //__________________________________________________________________________
ea94c18b 422const TMatrixD& AliMUONTrackParam::GetPropagator() const
208f139e 423{
ea94c18b 424 /// Return the propagator (create it before if needed)
425 if (!fPropagator) {
426 fPropagator = new TMatrixD(5,5);
019df241 427 fPropagator->UnitMatrix();
208f139e 428 }
ea94c18b 429 return *fPropagator;
96ebe67e 430}
ea94c18b 431
432 //__________________________________________________________________________
433void AliMUONTrackParam::ResetPropagator()
434{
435 /// Reset the propagator
019df241 436 if (fPropagator) fPropagator->UnitMatrix();
ea94c18b 437}
438
439 //__________________________________________________________________________
440void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
441{
442 /// Update the propagator
ea94c18b 443 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
444 else fPropagator = new TMatrixD(propagator);
445}
446
447 //__________________________________________________________________________
448const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
449{
450 /// Return extrapolated parameters (create it before if needed)
451 if (!fExtrapParameters) {
452 fExtrapParameters = new TMatrixD(5,1);
453 fExtrapParameters->Zero();
454 }
455 return *fExtrapParameters;
456 }
457
458 //__________________________________________________________________________
459void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
460{
461 /// Set extrapolated parameters
ea94c18b 462 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
463 else fExtrapParameters = new TMatrixD(extrapParameters);
464}
465
466 //__________________________________________________________________________
467const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
468{
469 /// Return the extrapolated covariance matrix (create it before if needed)
470 if (!fExtrapCovariances) {
471 fExtrapCovariances = new TMatrixD(5,5);
472 fExtrapCovariances->Zero();
473 }
474 return *fExtrapCovariances;
475 }
476
477 //__________________________________________________________________________
478void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
479{
480 /// Set the extrapolated covariance matrix
ea94c18b 481 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
482 else fExtrapCovariances = new TMatrixD(extrapCovariances);
483}
484
485 //__________________________________________________________________________
486const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
487{
488 /// Return the smoothed parameters (create it before if needed)
489 if (!fSmoothParameters) {
490 fSmoothParameters = new TMatrixD(5,1);
491 fSmoothParameters->Zero();
492 }
493 return *fSmoothParameters;
494 }
495
496 //__________________________________________________________________________
497void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
498{
499 /// Set the smoothed parameters
ea94c18b 500 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
501 else fSmoothParameters = new TMatrixD(smoothParameters);
502}
503
504 //__________________________________________________________________________
505const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
506{
507 /// Return the smoothed covariance matrix (create it before if needed)
508 if (!fSmoothCovariances) {
509 fSmoothCovariances = new TMatrixD(5,5);
510 fSmoothCovariances->Zero();
511 }
512 return *fSmoothCovariances;
513 }
514
515 //__________________________________________________________________________
516void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
517{
518 /// Set the smoothed covariance matrix
ea94c18b 519 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
520 else fSmoothCovariances = new TMatrixD(smoothCovariances);
208f139e 521}
522
7d98b674 523//__________________________________________________________________________
524void AliMUONTrackParam::SetClusterPtr(AliMUONVCluster* cluster, Bool_t owner)
525{
526 /// set pointeur to associated cluster
527 if (fOwnCluster) delete fClusterPtr;
528 fClusterPtr = cluster;
529 fOwnCluster = owner;
530}
531
208f139e 532 //__________________________________________________________________________
533Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
534{
535 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
96ebe67e 536 /// Returns 1 (0, -1) if the current Z
537 /// is smaller than (equal to, larger than) Z of trackParam
847cbaef 538 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
539 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
208f139e 540 else return(-1);
541}
542
61fed964 543 //__________________________________________________________________________
544Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const
545{
546 /// Return kTRUE if the two set of track parameters are compatible within sigma2Cut
547 /// Set chi2 to the compatible chi2 value
548 /// Note that parameter covariances must exist for at least one set of parameters
549 /// Note also that if parameters are not given at the same Z, results will be meaningless
550
551 // reset chi2 value
552 chi2 = 0.;
553
554 // ckeck covariance matrices
555 if (!fCovariances && !trackParam.fCovariances) {
556 AliError("Covariance matrix must exist for at least one set of parameters");
557 return kFALSE;
558 }
559
560 Double_t maxChi2 = 5. * sigma2Cut * sigma2Cut; // 5 degrees of freedom
561
562 // check Z parameters
563 if (fZ != trackParam.fZ)
564 AliWarning(Form("Parameters are given at different Z position (%le : %le): results are meaningless", fZ, trackParam.fZ));
565
566 // compute the parameter residuals
567 TMatrixD deltaParam(fParameters, TMatrixD::kMinus, trackParam.fParameters);
568
569 // build the error matrix
570 TMatrixD weight(5,5);
571 if (fCovariances) weight += *fCovariances;
572 if (trackParam.fCovariances) weight += *(trackParam.fCovariances);
573
574 // invert the error matrix to get the parameter weights if possible
575 if (weight.Determinant() == 0) {
576 AliError("Cannot compute the compatibility chi2");
577 return kFALSE;
578 }
579 weight.Invert();
580
581 // compute the compatibility chi2
582 TMatrixD tmp(deltaParam, TMatrixD::kTransposeMult, weight);
583 TMatrixD mChi2(tmp, TMatrixD::kMult, deltaParam);
584
585 // set chi2 value
586 chi2 = mChi2(0,0);
587
588 // check compatibility
589 if (chi2 > maxChi2) return kFALSE;
590
591 return kTRUE;
592}
593
594 //__________________________________________________________________________
6464217e 595void AliMUONTrackParam::Print(Option_t* opt) const
596{
2457f726 597 /// Printing TrackParam information
598 /// "full" option for printing all the information about the TrackParam
6464217e 599 TString sopt(opt);
600 sopt.ToUpper();
601
602 if ( sopt.Contains("FULL") ) {
ea94c18b 603 cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./fParameters(4,0) <<
604 ", NonBendSlope=" << setw(5) << setprecision(3) << fParameters(1,0)*180./TMath::Pi() <<
605 ", BendSlope=" << setw(5) << setprecision(3) << fParameters(3,0)*180./TMath::Pi() <<
606 ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << fParameters(0,0) <<
607 "," << setw(5) << setprecision(3) << fParameters(2,0) <<
608 "," << setw(5) << setprecision(3) << fZ <<
6464217e 609 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
610 "," << setw(5) << setprecision(3) << Py() <<
611 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;
612 }
613 else {
614 cout << "<AliMUONTrackParam>" << endl;
615 }
616
617}