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 ///////////////////////////////////////////////////
26 ///////////////////////////////////////////////////
28 #include "AliMUONTrackParam.h"
29 #include "AliMUONHitForRec.h"
31 #include "AliESDMuonTrack.h"
36 #include <Riostream.h>
39 ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
42 //_________________________________________________________________________
43 AliMUONTrackParam::AliMUONTrackParam()
49 fExtrapParameters(0x0),
50 fExtrapCovariances(0x0),
51 fSmoothParameters(0x0),
52 fSmoothCovariances(0x0),
61 //_________________________________________________________________________
62 AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
63 : TObject(theMUONTrackParam),
64 fZ(theMUONTrackParam.fZ),
65 fParameters(theMUONTrackParam.fParameters),
68 fExtrapParameters(0x0),
69 fExtrapCovariances(0x0),
70 fSmoothParameters(0x0),
71 fSmoothCovariances(0x0),
72 fHitForRecPtr(theMUONTrackParam.fHitForRecPtr),
73 fRemovable(theMUONTrackParam.fRemovable),
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));
86 //_________________________________________________________________________
87 AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
89 /// Asignment operator
90 if (this == &theMUONTrackParam)
93 // base class assignement
94 TObject::operator=(theMUONTrackParam);
96 fZ = theMUONTrackParam.fZ;
98 fParameters = theMUONTrackParam.fParameters;
100 if (theMUONTrackParam.fCovariances) {
101 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
102 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
103 } else if (fCovariances) {
108 if (theMUONTrackParam.fPropagator) {
109 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
110 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
111 } else if (fPropagator) {
116 if (theMUONTrackParam.fExtrapParameters) {
117 if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
118 else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
119 } else if (fExtrapParameters) {
120 delete fExtrapParameters;
121 fExtrapParameters = 0x0;
124 if (theMUONTrackParam.fExtrapCovariances) {
125 if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
126 else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
127 } else if (fExtrapCovariances) {
128 delete fExtrapCovariances;
129 fExtrapCovariances = 0x0;
132 if (theMUONTrackParam.fSmoothParameters) {
133 if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
134 else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
135 } else if (fSmoothParameters) {
136 delete fSmoothParameters;
137 fSmoothParameters = 0x0;
140 if (theMUONTrackParam.fSmoothCovariances) {
141 if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
142 else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
143 } else if (fSmoothCovariances) {
144 delete fSmoothCovariances;
145 fSmoothCovariances = 0x0;
148 fHitForRecPtr = theMUONTrackParam.fHitForRecPtr;
150 fRemovable = theMUONTrackParam.fRemovable;
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 /// assigned value form 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 /// assigned value form 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 /// assigned value form 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 /// assigned value form 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 Double_t AliMUONTrackParam::Px() const
243 /// return p_x from track parameters
244 Double_t pYZ, pZ, pX;
246 if ( TMath::Abs(fParameters(4,0)) > 0 )
247 pYZ = TMath::Abs(1.0 / fParameters(4,0));
248 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
249 pX = pZ * fParameters(1,0);
253 //__________________________________________________________________________
254 Double_t AliMUONTrackParam::Py() const
256 /// return p_y from track parameters
257 Double_t pYZ, pZ, pY;
259 if ( TMath::Abs(fParameters(4,0)) > 0 )
260 pYZ = TMath::Abs(1.0 / fParameters(4,0));
261 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
262 pY = pZ * fParameters(3,0);
266 //__________________________________________________________________________
267 Double_t AliMUONTrackParam::Pz() const
269 /// return p_z from track parameters
272 if ( TMath::Abs(fParameters(4,0)) > 0 )
273 pYZ = TMath::Abs(1.0 / fParameters(4,0));
274 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
278 //__________________________________________________________________________
279 Double_t AliMUONTrackParam::P() const
281 /// return p from track parameters
284 if ( TMath::Abs(fParameters(4,0)) > 0 )
285 pYZ = TMath::Abs(1.0 / fParameters(4,0));
286 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
288 TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
293 //__________________________________________________________________________
294 const TMatrixD& AliMUONTrackParam::GetCovariances() const
296 /// Return the covariance matrix (create it before if needed)
298 fCovariances = new TMatrixD(5,5);
299 fCovariances->Zero();
301 return *fCovariances;
304 //__________________________________________________________________________
305 void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
307 /// Set the covariance matrix
308 if (&covariances == fCovariances) return; // nothing to be done
309 if (fCovariances) *fCovariances = covariances;
310 else fCovariances = new TMatrixD(covariances);
313 //__________________________________________________________________________
314 void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
316 /// Set the covariance matrix
317 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
318 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
321 //__________________________________________________________________________
322 void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
324 /// Set the diagonal terms of the covariance matrix (variances)
325 if (!fCovariances) fCovariances = new TMatrixD(5,5);
326 fCovariances->Zero();
327 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
330 //__________________________________________________________________________
331 void AliMUONTrackParam::DeleteCovariances()
333 /// Delete the covariance matrix
338 //__________________________________________________________________________
339 const TMatrixD& AliMUONTrackParam::GetPropagator() const
341 /// Return the propagator (create it before if needed)
343 fPropagator = new TMatrixD(5,5);
349 //__________________________________________________________________________
350 void AliMUONTrackParam::ResetPropagator()
352 /// Reset the propagator
353 if (!fPropagator) fPropagator = new TMatrixD(5,5);
354 fPropagator->UnitMatrix();
357 //__________________________________________________________________________
358 void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
360 /// Update the propagator
361 if (&propagator == fPropagator) return; // nothing to be done
362 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
363 else fPropagator = new TMatrixD(propagator);
366 //__________________________________________________________________________
367 const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
369 /// Return extrapolated parameters (create it before if needed)
370 if (!fExtrapParameters) {
371 fExtrapParameters = new TMatrixD(5,1);
372 fExtrapParameters->Zero();
374 return *fExtrapParameters;
377 //__________________________________________________________________________
378 void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
380 /// Set extrapolated parameters
381 if (&extrapParameters == fExtrapParameters) return; // nothing to be done
382 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
383 else fExtrapParameters = new TMatrixD(extrapParameters);
386 //__________________________________________________________________________
387 const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
389 /// Return the extrapolated covariance matrix (create it before if needed)
390 if (!fExtrapCovariances) {
391 fExtrapCovariances = new TMatrixD(5,5);
392 fExtrapCovariances->Zero();
394 return *fExtrapCovariances;
397 //__________________________________________________________________________
398 void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
400 /// Set the extrapolated covariance matrix
401 if (&extrapCovariances == fExtrapCovariances) return; // nothing to be done
402 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
403 else fExtrapCovariances = new TMatrixD(extrapCovariances);
406 //__________________________________________________________________________
407 const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
409 /// Return the smoothed parameters (create it before if needed)
410 if (!fSmoothParameters) {
411 fSmoothParameters = new TMatrixD(5,1);
412 fSmoothParameters->Zero();
414 return *fSmoothParameters;
417 //__________________________________________________________________________
418 void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
420 /// Set the smoothed parameters
421 if (&smoothParameters == fSmoothParameters) return; // nothing to be done
422 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
423 else fSmoothParameters = new TMatrixD(smoothParameters);
426 //__________________________________________________________________________
427 const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
429 /// Return the smoothed covariance matrix (create it before if needed)
430 if (!fSmoothCovariances) {
431 fSmoothCovariances = new TMatrixD(5,5);
432 fSmoothCovariances->Zero();
434 return *fSmoothCovariances;
437 //__________________________________________________________________________
438 void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
440 /// Set the smoothed covariance matrix
441 if (&smoothCovariances == fSmoothCovariances) return; // nothing to be done
442 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
443 else fSmoothCovariances = new TMatrixD(smoothCovariances);
446 //__________________________________________________________________________
447 Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
449 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
450 /// Returns 1 (0, -1) if Z of current TrackHit
451 /// is smaller than (equal to, larger than) Z of TrackHit
453 if (fHitForRecPtr->GetZ() != fZ)
454 AliWarning("track parameters are given at a different z position than the one of the corresponding hit");
456 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
457 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
461 //_____________________________________________-
462 void AliMUONTrackParam::Print(Option_t* opt) const
464 /// Printing TrackParam information
465 /// "full" option for printing all the information about the TrackParam
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" << endl;
481 cout << "<AliMUONTrackParam>" << endl;