1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 // Class AliMUONTrackParam
20 //-------------------------
21 // Track parameters in ALICE dimuon spectrometer
22 //-----------------------------------------------------------------------------
24 #include "AliMUONTrackParam.h"
25 #include "AliMUONHitForRec.h"
27 #include "AliESDMuonTrack.h"
32 #include <Riostream.h>
35 ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
38 //_________________________________________________________________________
39 AliMUONTrackParam::AliMUONTrackParam()
45 fExtrapParameters(0x0),
46 fExtrapCovariances(0x0),
47 fSmoothParameters(0x0),
48 fSmoothCovariances(0x0),
51 fAloneInChamber(kTRUE),
58 //_________________________________________________________________________
59 AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
60 : TObject(theMUONTrackParam),
61 fZ(theMUONTrackParam.fZ),
62 fParameters(theMUONTrackParam.fParameters),
65 fExtrapParameters(0x0),
66 fExtrapCovariances(0x0),
67 fSmoothParameters(0x0),
68 fSmoothCovariances(0x0),
69 fHitForRecPtr(theMUONTrackParam.fHitForRecPtr),
70 fRemovable(theMUONTrackParam.fRemovable),
71 fAloneInChamber(theMUONTrackParam.fAloneInChamber),
72 fTrackChi2(theMUONTrackParam.fTrackChi2),
73 fLocalChi2(theMUONTrackParam.fLocalChi2)
76 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
77 if (theMUONTrackParam.fPropagator) fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
78 if (theMUONTrackParam.fExtrapParameters) fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
79 if (theMUONTrackParam.fExtrapCovariances) fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
80 if (theMUONTrackParam.fSmoothParameters) fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
81 if (theMUONTrackParam.fSmoothCovariances) fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
84 //_________________________________________________________________________
85 AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
87 /// Asignment operator
88 if (this == &theMUONTrackParam)
91 // base class assignement
92 TObject::operator=(theMUONTrackParam);
94 fZ = theMUONTrackParam.fZ;
96 fParameters = theMUONTrackParam.fParameters;
98 if (theMUONTrackParam.fCovariances) {
99 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
100 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
106 if (theMUONTrackParam.fPropagator) {
107 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
108 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
114 if (theMUONTrackParam.fExtrapParameters) {
115 if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
116 else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
118 delete fExtrapParameters;
119 fExtrapParameters = 0x0;
122 if (theMUONTrackParam.fExtrapCovariances) {
123 if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
124 else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
126 delete fExtrapCovariances;
127 fExtrapCovariances = 0x0;
130 if (theMUONTrackParam.fSmoothParameters) {
131 if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
132 else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
134 delete fSmoothParameters;
135 fSmoothParameters = 0x0;
138 if (theMUONTrackParam.fSmoothCovariances) {
139 if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
140 else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
142 delete fSmoothCovariances;
143 fSmoothCovariances = 0x0;
146 fHitForRecPtr = theMUONTrackParam.fHitForRecPtr;
148 fRemovable = theMUONTrackParam.fRemovable;
150 fAloneInChamber = theMUONTrackParam.fAloneInChamber;
152 fTrackChi2 = theMUONTrackParam.fTrackChi2;
153 fLocalChi2 = theMUONTrackParam.fLocalChi2;
158 //__________________________________________________________________________
159 AliMUONTrackParam::~AliMUONTrackParam()
164 delete fExtrapParameters;
165 delete fExtrapCovariances;
166 delete fSmoothParameters;
167 delete fSmoothCovariances;
170 //__________________________________________________________________________
172 AliMUONTrackParam::Clear(Option_t* /*opt*/)
174 /// Delete the covariance matrix
176 delete fPropagator; fPropagator = 0x0;
177 delete fExtrapParameters; fExtrapParameters = 0x0;
178 delete fExtrapCovariances; fExtrapCovariances = 0x0;
179 delete fSmoothParameters; fSmoothParameters = 0x0;
180 delete fSmoothCovariances; fSmoothCovariances = 0x0;
183 //__________________________________________________________________________
184 AliMUONHitForRec* AliMUONTrackParam::GetHitForRecPtr(void) const
186 /// return pointer to HitForRec attached to the current TrackParam
187 /// this method should not be called when fHitForRecPtr == NULL
188 if (!fHitForRecPtr) AliWarning("fHitForRecPtr == NULL");
189 return fHitForRecPtr;
192 //_________________________________________________________________________
193 void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack)
195 /// Get parameters from ESD track
196 fZ = esdMuonTrack.GetZ();
197 fParameters(0,0) = esdMuonTrack.GetNonBendingCoor();
198 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaX());
199 fParameters(2,0) = esdMuonTrack.GetBendingCoor();
200 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaY());
201 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentum();
204 //_________________________________________________________________________
205 void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack) const
207 /// Set parameters in ESD track
208 esdMuonTrack.SetZ(fZ);
209 esdMuonTrack.SetNonBendingCoor(fParameters(0,0));
210 esdMuonTrack.SetThetaX(TMath::ATan(fParameters(1,0)));
211 esdMuonTrack.SetBendingCoor(fParameters(2,0));
212 esdMuonTrack.SetThetaY(TMath::ATan(fParameters(3,0)));
213 esdMuonTrack.SetInverseBendingMomentum(fParameters(4,0));
216 //_________________________________________________________________________
217 void AliMUONTrackParam::GetParamFromUncorrected(const AliESDMuonTrack& esdMuonTrack)
219 /// Get parameters from ESD track
220 fZ = esdMuonTrack.GetZUncorrected();
221 fParameters(0,0) = esdMuonTrack.GetNonBendingCoorUncorrected();
222 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaXUncorrected());
223 fParameters(2,0) = esdMuonTrack.GetBendingCoorUncorrected();
224 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaYUncorrected());
225 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentumUncorrected();
228 //_________________________________________________________________________
229 void AliMUONTrackParam::SetParamForUncorrected(AliESDMuonTrack& esdMuonTrack) const
231 /// Set parameters in ESD track
232 esdMuonTrack.SetZUncorrected(fZ);
233 esdMuonTrack.SetNonBendingCoorUncorrected(fParameters(0,0));
234 esdMuonTrack.SetThetaXUncorrected(TMath::ATan(fParameters(1,0)));
235 esdMuonTrack.SetBendingCoorUncorrected(fParameters(2,0));
236 esdMuonTrack.SetThetaYUncorrected(TMath::ATan(fParameters(3,0)));
237 esdMuonTrack.SetInverseBendingMomentumUncorrected(fParameters(4,0));
240 //_________________________________________________________________________
241 void AliMUONTrackParam::GetCovFrom(const AliESDMuonTrack& esdMuonTrack)
243 /// Get parameters covariances from ESD track
245 // Get ESD covariance matrix
246 if (!fCovariances) fCovariances = new TMatrixD(5,5);
247 esdMuonTrack.GetCovariances(*fCovariances);
249 // compute Jacobian to change the coordinate system
250 // from (X,thetaX,Y,thetaY,c/pYZ) to (X,slopeX,Y,slopeY,c/pYZ)
251 Double_t cosThetaX = TMath::Cos(TMath::ATan(fParameters(1,0)));
252 Double_t cosThetaY = TMath::Cos(TMath::ATan(fParameters(3,0)));
256 jacob(1,1) = 1. / cosThetaX / cosThetaX;
258 jacob(3,3) = 1. / cosThetaY / cosThetaY;
261 // compute covariance matrix in ESD coordinate system
262 TMatrixD tmp(*fCovariances,TMatrixD::kMultTranspose,jacob);
263 *fCovariances = TMatrixD(jacob,TMatrixD::kMult,tmp);
267 //_________________________________________________________________________
268 void AliMUONTrackParam::SetCovFor(AliESDMuonTrack& esdMuonTrack) const
270 /// Set parameters covariances in ESD track
272 // set null matrix if covariances does not exist
276 esdMuonTrack.SetCovariances(tmp);
280 // compute Jacobian to change the coordinate system
281 // from (X,slopeX,Y,slopeY,c/pYZ) to (X,thetaX,Y,thetaY,c/pYZ)
282 Double_t cosThetaX = TMath::Cos(TMath::ATan(fParameters(1,0)));
283 Double_t cosThetaY = TMath::Cos(TMath::ATan(fParameters(3,0)));
287 jacob(1,1) = cosThetaX * cosThetaX;
289 jacob(3,3) = cosThetaY * cosThetaY;
292 // compute covariance matrix in ESD coordinate system
293 TMatrixD tmp(*fCovariances,TMatrixD::kMultTranspose,jacob);
294 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
295 esdMuonTrack.SetCovariances(tmp2);
299 //__________________________________________________________________________
300 Double_t AliMUONTrackParam::Px() const
302 /// return p_x from track parameters
303 Double_t pYZ, pZ, pX;
305 if ( TMath::Abs(fParameters(4,0)) > 0 )
306 pYZ = TMath::Abs(1.0 / fParameters(4,0));
307 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
308 pX = pZ * fParameters(1,0);
312 //__________________________________________________________________________
313 Double_t AliMUONTrackParam::Py() const
315 /// return p_y from track parameters
316 Double_t pYZ, pZ, pY;
318 if ( TMath::Abs(fParameters(4,0)) > 0 )
319 pYZ = TMath::Abs(1.0 / fParameters(4,0));
320 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
321 pY = pZ * fParameters(3,0);
325 //__________________________________________________________________________
326 Double_t AliMUONTrackParam::Pz() const
328 /// return p_z from track parameters
331 if ( TMath::Abs(fParameters(4,0)) > 0 )
332 pYZ = TMath::Abs(1.0 / fParameters(4,0));
333 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
337 //__________________________________________________________________________
338 Double_t AliMUONTrackParam::P() const
340 /// return p from track parameters
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)
347 TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
352 //__________________________________________________________________________
353 const TMatrixD& AliMUONTrackParam::GetCovariances() const
355 /// Return the covariance matrix (create it before if needed)
357 fCovariances = new TMatrixD(5,5);
358 fCovariances->Zero();
360 return *fCovariances;
363 //__________________________________________________________________________
364 void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
366 /// Set the covariance matrix
367 if (fCovariances) *fCovariances = covariances;
368 else fCovariances = new TMatrixD(covariances);
371 //__________________________________________________________________________
372 void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
374 /// Set the covariance matrix
375 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
376 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
379 //__________________________________________________________________________
380 void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
382 /// Set the diagonal terms of the covariance matrix (variances)
383 if (!fCovariances) fCovariances = new TMatrixD(5,5);
384 fCovariances->Zero();
385 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
388 //__________________________________________________________________________
389 void AliMUONTrackParam::DeleteCovariances()
391 /// Delete the covariance matrix
396 //__________________________________________________________________________
397 const TMatrixD& AliMUONTrackParam::GetPropagator() const
399 /// Return the propagator (create it before if needed)
401 fPropagator = new TMatrixD(5,5);
402 fPropagator->UnitMatrix();
407 //__________________________________________________________________________
408 void AliMUONTrackParam::ResetPropagator()
410 /// Reset the propagator
411 if (fPropagator) fPropagator->UnitMatrix();
414 //__________________________________________________________________________
415 void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
417 /// Update the propagator
418 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
419 else fPropagator = new TMatrixD(propagator);
422 //__________________________________________________________________________
423 const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
425 /// Return extrapolated parameters (create it before if needed)
426 if (!fExtrapParameters) {
427 fExtrapParameters = new TMatrixD(5,1);
428 fExtrapParameters->Zero();
430 return *fExtrapParameters;
433 //__________________________________________________________________________
434 void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
436 /// Set extrapolated parameters
437 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
438 else fExtrapParameters = new TMatrixD(extrapParameters);
441 //__________________________________________________________________________
442 const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
444 /// Return the extrapolated covariance matrix (create it before if needed)
445 if (!fExtrapCovariances) {
446 fExtrapCovariances = new TMatrixD(5,5);
447 fExtrapCovariances->Zero();
449 return *fExtrapCovariances;
452 //__________________________________________________________________________
453 void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
455 /// Set the extrapolated covariance matrix
456 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
457 else fExtrapCovariances = new TMatrixD(extrapCovariances);
460 //__________________________________________________________________________
461 const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
463 /// Return the smoothed parameters (create it before if needed)
464 if (!fSmoothParameters) {
465 fSmoothParameters = new TMatrixD(5,1);
466 fSmoothParameters->Zero();
468 return *fSmoothParameters;
471 //__________________________________________________________________________
472 void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
474 /// Set the smoothed parameters
475 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
476 else fSmoothParameters = new TMatrixD(smoothParameters);
479 //__________________________________________________________________________
480 const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
482 /// Return the smoothed covariance matrix (create it before if needed)
483 if (!fSmoothCovariances) {
484 fSmoothCovariances = new TMatrixD(5,5);
485 fSmoothCovariances->Zero();
487 return *fSmoothCovariances;
490 //__________________________________________________________________________
491 void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
493 /// Set the smoothed covariance matrix
494 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
495 else fSmoothCovariances = new TMatrixD(smoothCovariances);
498 //__________________________________________________________________________
499 Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
501 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
502 /// Returns 1 (0, -1) if Z of current TrackHit
503 /// is smaller than (equal to, larger than) Z of TrackHit
505 if (fHitForRecPtr->GetZ() != fZ)
506 AliWarning("track parameters are given at a different z position than the one of the corresponding hit");
508 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
509 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
513 //_____________________________________________-
514 void AliMUONTrackParam::Print(Option_t* opt) const
516 /// Printing TrackParam information
517 /// "full" option for printing all the information about the TrackParam
521 if ( sopt.Contains("FULL") ) {
522 cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./fParameters(4,0) <<
523 ", NonBendSlope=" << setw(5) << setprecision(3) << fParameters(1,0)*180./TMath::Pi() <<
524 ", BendSlope=" << setw(5) << setprecision(3) << fParameters(3,0)*180./TMath::Pi() <<
525 ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << fParameters(0,0) <<
526 "," << setw(5) << setprecision(3) << fParameters(2,0) <<
527 "," << setw(5) << setprecision(3) << fZ <<
528 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
529 "," << setw(5) << setprecision(3) << Py() <<
530 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;
533 cout << "<AliMUONTrackParam>" << endl;