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 "AliMUONVCluster.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),
52 fAloneInChamber(kTRUE),
59 //_________________________________________________________________________
60 AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
61 : TObject(theMUONTrackParam),
62 fZ(theMUONTrackParam.fZ),
63 fParameters(theMUONTrackParam.fParameters),
66 fExtrapParameters(0x0),
67 fExtrapCovariances(0x0),
68 fSmoothParameters(0x0),
69 fSmoothCovariances(0x0),
71 fOwnCluster(theMUONTrackParam.fOwnCluster),
72 fRemovable(theMUONTrackParam.fRemovable),
73 fAloneInChamber(theMUONTrackParam.fAloneInChamber),
74 fTrackChi2(theMUONTrackParam.fTrackChi2),
75 fLocalChi2(theMUONTrackParam.fLocalChi2)
78 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
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));
85 if(fOwnCluster) fClusterPtr = theMUONTrackParam.fClusterPtr->CreateCopy();
86 else fClusterPtr = theMUONTrackParam.fClusterPtr;
89 //_________________________________________________________________________
90 AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
92 /// Asignment operator
93 if (this == &theMUONTrackParam)
96 // base class assignement
97 TObject::operator=(theMUONTrackParam);
99 fZ = theMUONTrackParam.fZ;
101 fParameters = theMUONTrackParam.fParameters;
103 if (theMUONTrackParam.fCovariances) {
104 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
105 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
111 if (theMUONTrackParam.fPropagator) {
112 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
113 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
119 if (theMUONTrackParam.fExtrapParameters) {
120 if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
121 else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
123 delete fExtrapParameters;
124 fExtrapParameters = 0x0;
127 if (theMUONTrackParam.fExtrapCovariances) {
128 if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
129 else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
131 delete fExtrapCovariances;
132 fExtrapCovariances = 0x0;
135 if (theMUONTrackParam.fSmoothParameters) {
136 if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
137 else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
139 delete fSmoothParameters;
140 fSmoothParameters = 0x0;
143 if (theMUONTrackParam.fSmoothCovariances) {
144 if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
145 else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
147 delete fSmoothCovariances;
148 fSmoothCovariances = 0x0;
151 fOwnCluster = theMUONTrackParam.fOwnCluster;
152 if(fOwnCluster) fClusterPtr = theMUONTrackParam.fClusterPtr->CreateCopy();
153 else fClusterPtr = theMUONTrackParam.fClusterPtr;
155 fRemovable = theMUONTrackParam.fRemovable;
157 fAloneInChamber = theMUONTrackParam.fAloneInChamber;
159 fTrackChi2 = theMUONTrackParam.fTrackChi2;
160 fLocalChi2 = theMUONTrackParam.fLocalChi2;
165 //__________________________________________________________________________
166 AliMUONTrackParam::~AliMUONTrackParam()
171 delete fExtrapParameters;
172 delete fExtrapCovariances;
173 delete fSmoothParameters;
174 delete fSmoothCovariances;
175 if(fOwnCluster) delete fClusterPtr;
178 //__________________________________________________________________________
180 AliMUONTrackParam::Clear(Option_t* /*opt*/)
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;
190 delete fClusterPtr; fClusterPtr = 0x0;
194 //_________________________________________________________________________
195 void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack)
197 /// Get parameters from ESD track
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();
206 //_________________________________________________________________________
207 void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack) const
209 /// Set parameters in ESD track
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));
218 //_________________________________________________________________________
219 void AliMUONTrackParam::GetParamFromUncorrected(const AliESDMuonTrack& esdMuonTrack)
221 /// Get parameters from ESD track
222 fZ = esdMuonTrack.GetZUncorrected();
223 fParameters(0,0) = esdMuonTrack.GetNonBendingCoorUncorrected();
224 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaXUncorrected());
225 fParameters(2,0) = esdMuonTrack.GetBendingCoorUncorrected();
226 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaYUncorrected());
227 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentumUncorrected();
230 //_________________________________________________________________________
231 void AliMUONTrackParam::SetParamForUncorrected(AliESDMuonTrack& esdMuonTrack) const
233 /// Set parameters in ESD track
234 esdMuonTrack.SetZUncorrected(fZ);
235 esdMuonTrack.SetNonBendingCoorUncorrected(fParameters(0,0));
236 esdMuonTrack.SetThetaXUncorrected(TMath::ATan(fParameters(1,0)));
237 esdMuonTrack.SetBendingCoorUncorrected(fParameters(2,0));
238 esdMuonTrack.SetThetaYUncorrected(TMath::ATan(fParameters(3,0)));
239 esdMuonTrack.SetInverseBendingMomentumUncorrected(fParameters(4,0));
242 //_________________________________________________________________________
243 void AliMUONTrackParam::GetCovFrom(const AliESDMuonTrack& esdMuonTrack)
245 /// Get parameters covariances from ESD track
247 // Get ESD covariance matrix
248 if (!fCovariances) fCovariances = new TMatrixD(5,5);
249 esdMuonTrack.GetCovariances(*fCovariances);
251 // compute Jacobian to change the coordinate system
252 // from (X,thetaX,Y,thetaY,c/pYZ) to (X,slopeX,Y,slopeY,c/pYZ)
253 Double_t cosThetaX = TMath::Cos(TMath::ATan(fParameters(1,0)));
254 Double_t cosThetaY = TMath::Cos(TMath::ATan(fParameters(3,0)));
258 jacob(1,1) = 1. / cosThetaX / cosThetaX;
260 jacob(3,3) = 1. / cosThetaY / cosThetaY;
263 // compute covariance matrix in ESD coordinate system
264 TMatrixD tmp(*fCovariances,TMatrixD::kMultTranspose,jacob);
265 *fCovariances = TMatrixD(jacob,TMatrixD::kMult,tmp);
269 //_________________________________________________________________________
270 void AliMUONTrackParam::SetCovFor(AliESDMuonTrack& esdMuonTrack) const
272 /// Set parameters covariances in ESD track
274 // set null matrix if covariances does not exist
278 esdMuonTrack.SetCovariances(tmp);
282 // compute Jacobian to change the coordinate system
283 // from (X,slopeX,Y,slopeY,c/pYZ) to (X,thetaX,Y,thetaY,c/pYZ)
284 Double_t cosThetaX = TMath::Cos(TMath::ATan(fParameters(1,0)));
285 Double_t cosThetaY = TMath::Cos(TMath::ATan(fParameters(3,0)));
289 jacob(1,1) = cosThetaX * cosThetaX;
291 jacob(3,3) = cosThetaY * cosThetaY;
294 // compute covariance matrix in ESD coordinate system
295 TMatrixD tmp(*fCovariances,TMatrixD::kMultTranspose,jacob);
296 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
297 esdMuonTrack.SetCovariances(tmp2);
301 //__________________________________________________________________________
302 Double_t AliMUONTrackParam::Px() const
304 /// return p_x from track parameters
305 Double_t pYZ, pZ, pX;
307 if ( TMath::Abs(fParameters(4,0)) > 0 )
308 pYZ = TMath::Abs(1.0 / fParameters(4,0));
309 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
310 pX = pZ * fParameters(1,0);
314 //__________________________________________________________________________
315 Double_t AliMUONTrackParam::Py() const
317 /// return p_y from track parameters
318 Double_t pYZ, pZ, pY;
320 if ( TMath::Abs(fParameters(4,0)) > 0 )
321 pYZ = TMath::Abs(1.0 / fParameters(4,0));
322 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
323 pY = pZ * fParameters(3,0);
327 //__________________________________________________________________________
328 Double_t AliMUONTrackParam::Pz() const
330 /// return p_z from track parameters
333 if ( TMath::Abs(fParameters(4,0)) > 0 )
334 pYZ = TMath::Abs(1.0 / fParameters(4,0));
335 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
339 //__________________________________________________________________________
340 Double_t AliMUONTrackParam::P() const
342 /// return p from track parameters
345 if ( TMath::Abs(fParameters(4,0)) > 0 )
346 pYZ = TMath::Abs(1.0 / fParameters(4,0));
347 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
349 TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
354 //__________________________________________________________________________
355 const TMatrixD& AliMUONTrackParam::GetCovariances() const
357 /// Return the covariance matrix (create it before if needed)
359 fCovariances = new TMatrixD(5,5);
360 fCovariances->Zero();
362 return *fCovariances;
365 //__________________________________________________________________________
366 void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
368 /// Set the covariance matrix
369 if (fCovariances) *fCovariances = covariances;
370 else fCovariances = new TMatrixD(covariances);
373 //__________________________________________________________________________
374 void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
376 /// Set the covariance matrix
377 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
378 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
381 //__________________________________________________________________________
382 void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
384 /// Set the diagonal terms of the covariance matrix (variances)
385 if (!fCovariances) fCovariances = new TMatrixD(5,5);
386 fCovariances->Zero();
387 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
390 //__________________________________________________________________________
391 void AliMUONTrackParam::DeleteCovariances()
393 /// Delete the covariance matrix
398 //__________________________________________________________________________
399 const TMatrixD& AliMUONTrackParam::GetPropagator() const
401 /// Return the propagator (create it before if needed)
403 fPropagator = new TMatrixD(5,5);
404 fPropagator->UnitMatrix();
409 //__________________________________________________________________________
410 void AliMUONTrackParam::ResetPropagator()
412 /// Reset the propagator
413 if (fPropagator) fPropagator->UnitMatrix();
416 //__________________________________________________________________________
417 void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
419 /// Update the propagator
420 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
421 else fPropagator = new TMatrixD(propagator);
424 //__________________________________________________________________________
425 const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
427 /// Return extrapolated parameters (create it before if needed)
428 if (!fExtrapParameters) {
429 fExtrapParameters = new TMatrixD(5,1);
430 fExtrapParameters->Zero();
432 return *fExtrapParameters;
435 //__________________________________________________________________________
436 void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
438 /// Set extrapolated parameters
439 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
440 else fExtrapParameters = new TMatrixD(extrapParameters);
443 //__________________________________________________________________________
444 const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
446 /// Return the extrapolated covariance matrix (create it before if needed)
447 if (!fExtrapCovariances) {
448 fExtrapCovariances = new TMatrixD(5,5);
449 fExtrapCovariances->Zero();
451 return *fExtrapCovariances;
454 //__________________________________________________________________________
455 void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
457 /// Set the extrapolated covariance matrix
458 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
459 else fExtrapCovariances = new TMatrixD(extrapCovariances);
462 //__________________________________________________________________________
463 const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
465 /// Return the smoothed parameters (create it before if needed)
466 if (!fSmoothParameters) {
467 fSmoothParameters = new TMatrixD(5,1);
468 fSmoothParameters->Zero();
470 return *fSmoothParameters;
473 //__________________________________________________________________________
474 void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
476 /// Set the smoothed parameters
477 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
478 else fSmoothParameters = new TMatrixD(smoothParameters);
481 //__________________________________________________________________________
482 const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
484 /// Return the smoothed covariance matrix (create it before if needed)
485 if (!fSmoothCovariances) {
486 fSmoothCovariances = new TMatrixD(5,5);
487 fSmoothCovariances->Zero();
489 return *fSmoothCovariances;
492 //__________________________________________________________________________
493 void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
495 /// Set the smoothed covariance matrix
496 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
497 else fSmoothCovariances = new TMatrixD(smoothCovariances);
500 //__________________________________________________________________________
501 Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
503 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
504 /// Returns 1 (0, -1) if the current Z
505 /// is smaller than (equal to, larger than) Z of trackParam
506 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
507 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
511 //_____________________________________________-
512 void AliMUONTrackParam::Print(Option_t* opt) const
514 /// Printing TrackParam information
515 /// "full" option for printing all the information about the TrackParam
519 if ( sopt.Contains("FULL") ) {
520 cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./fParameters(4,0) <<
521 ", NonBendSlope=" << setw(5) << setprecision(3) << fParameters(1,0)*180./TMath::Pi() <<
522 ", BendSlope=" << setw(5) << setprecision(3) << fParameters(3,0)*180./TMath::Pi() <<
523 ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << fParameters(0,0) <<
524 "," << setw(5) << setprecision(3) << fParameters(2,0) <<
525 "," << setw(5) << setprecision(3) << fZ <<
526 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
527 "," << setw(5) << setprecision(3) << Py() <<
528 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;
531 cout << "<AliMUONTrackParam>" << endl;