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"
31 #include <Riostream.h>
34 ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
37 //_________________________________________________________________________
38 AliMUONTrackParam::AliMUONTrackParam()
44 fExtrapParameters(0x0),
45 fExtrapCovariances(0x0),
46 fSmoothParameters(0x0),
47 fSmoothCovariances(0x0),
57 //_________________________________________________________________________
58 AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
59 : TObject(theMUONTrackParam),
60 fZ(theMUONTrackParam.fZ),
61 fParameters(theMUONTrackParam.fParameters),
64 fExtrapParameters(0x0),
65 fExtrapCovariances(0x0),
66 fSmoothParameters(0x0),
67 fSmoothCovariances(0x0),
69 fOwnCluster(theMUONTrackParam.fOwnCluster),
70 fRemovable(theMUONTrackParam.fRemovable),
71 fTrackChi2(theMUONTrackParam.fTrackChi2),
72 fLocalChi2(theMUONTrackParam.fLocalChi2)
75 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
76 if (theMUONTrackParam.fPropagator) fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
77 if (theMUONTrackParam.fExtrapParameters) fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
78 if (theMUONTrackParam.fExtrapCovariances) fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
79 if (theMUONTrackParam.fSmoothParameters) fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
80 if (theMUONTrackParam.fSmoothCovariances) fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
82 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
83 else fClusterPtr = theMUONTrackParam.fClusterPtr;
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));
108 if (theMUONTrackParam.fPropagator) {
109 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
110 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
116 if (theMUONTrackParam.fExtrapParameters) {
117 if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
118 else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
120 delete fExtrapParameters;
121 fExtrapParameters = 0x0;
124 if (theMUONTrackParam.fExtrapCovariances) {
125 if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
126 else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
128 delete fExtrapCovariances;
129 fExtrapCovariances = 0x0;
132 if (theMUONTrackParam.fSmoothParameters) {
133 if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
134 else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
136 delete fSmoothParameters;
137 fSmoothParameters = 0x0;
140 if (theMUONTrackParam.fSmoothCovariances) {
141 if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
142 else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
144 delete fSmoothCovariances;
145 fSmoothCovariances = 0x0;
148 if (fOwnCluster) delete fClusterPtr;
149 fOwnCluster = theMUONTrackParam.fOwnCluster;
150 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
151 else fClusterPtr = theMUONTrackParam.fClusterPtr;
153 fRemovable = theMUONTrackParam.fRemovable;
155 fTrackChi2 = theMUONTrackParam.fTrackChi2;
156 fLocalChi2 = theMUONTrackParam.fLocalChi2;
161 //__________________________________________________________________________
162 AliMUONTrackParam::~AliMUONTrackParam()
167 delete fExtrapParameters;
168 delete fExtrapCovariances;
169 delete fSmoothParameters;
170 delete fSmoothCovariances;
171 if(fOwnCluster) delete fClusterPtr;
174 //__________________________________________________________________________
176 AliMUONTrackParam::Clear(Option_t* /*opt*/)
180 delete fPropagator; fPropagator = 0x0;
181 delete fExtrapParameters; fExtrapParameters = 0x0;
182 delete fExtrapCovariances; fExtrapCovariances = 0x0;
183 delete fSmoothParameters; fSmoothParameters = 0x0;
184 delete fSmoothCovariances; fSmoothCovariances = 0x0;
186 delete fClusterPtr; fClusterPtr = 0x0;
190 //__________________________________________________________________________
191 Double_t AliMUONTrackParam::Px() const
193 /// return p_x from track parameters
194 Double_t pYZ, pZ, pX;
196 if ( TMath::Abs(fParameters(4,0)) > 0 )
197 pYZ = TMath::Abs(1.0 / fParameters(4,0));
198 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
199 pX = pZ * fParameters(1,0);
203 //__________________________________________________________________________
204 Double_t AliMUONTrackParam::Py() const
206 /// return p_y from track parameters
207 Double_t pYZ, pZ, pY;
209 if ( TMath::Abs(fParameters(4,0)) > 0 )
210 pYZ = TMath::Abs(1.0 / fParameters(4,0));
211 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
212 pY = pZ * fParameters(3,0);
216 //__________________________________________________________________________
217 Double_t AliMUONTrackParam::Pz() const
219 /// return p_z from track parameters
222 if ( TMath::Abs(fParameters(4,0)) > 0 )
223 pYZ = TMath::Abs(1.0 / fParameters(4,0));
224 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
228 //__________________________________________________________________________
229 Double_t AliMUONTrackParam::P() const
231 /// return p from track parameters
234 if ( TMath::Abs(fParameters(4,0)) > 0 )
235 pYZ = TMath::Abs(1.0 / fParameters(4,0));
236 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
238 TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
243 //__________________________________________________________________________
244 const TMatrixD& AliMUONTrackParam::GetCovariances() const
246 /// Return the covariance matrix (create it before if needed)
248 fCovariances = new TMatrixD(5,5);
249 fCovariances->Zero();
251 return *fCovariances;
254 //__________________________________________________________________________
255 void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
257 /// Set the covariance matrix
258 if (fCovariances) *fCovariances = covariances;
259 else fCovariances = new TMatrixD(covariances);
262 //__________________________________________________________________________
263 void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
265 /// Set the covariance matrix
266 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
267 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
270 //__________________________________________________________________________
271 void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
273 /// Set the diagonal terms of the covariance matrix (variances)
274 if (!fCovariances) fCovariances = new TMatrixD(5,5);
275 fCovariances->Zero();
276 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
279 //__________________________________________________________________________
280 void AliMUONTrackParam::DeleteCovariances()
282 /// Delete the covariance matrix
287 //__________________________________________________________________________
288 const TMatrixD& AliMUONTrackParam::GetPropagator() const
290 /// Return the propagator (create it before if needed)
292 fPropagator = new TMatrixD(5,5);
293 fPropagator->UnitMatrix();
298 //__________________________________________________________________________
299 void AliMUONTrackParam::ResetPropagator()
301 /// Reset the propagator
302 if (fPropagator) fPropagator->UnitMatrix();
305 //__________________________________________________________________________
306 void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
308 /// Update the propagator
309 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
310 else fPropagator = new TMatrixD(propagator);
313 //__________________________________________________________________________
314 const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
316 /// Return extrapolated parameters (create it before if needed)
317 if (!fExtrapParameters) {
318 fExtrapParameters = new TMatrixD(5,1);
319 fExtrapParameters->Zero();
321 return *fExtrapParameters;
324 //__________________________________________________________________________
325 void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
327 /// Set extrapolated parameters
328 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
329 else fExtrapParameters = new TMatrixD(extrapParameters);
332 //__________________________________________________________________________
333 const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
335 /// Return the extrapolated covariance matrix (create it before if needed)
336 if (!fExtrapCovariances) {
337 fExtrapCovariances = new TMatrixD(5,5);
338 fExtrapCovariances->Zero();
340 return *fExtrapCovariances;
343 //__________________________________________________________________________
344 void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
346 /// Set the extrapolated covariance matrix
347 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
348 else fExtrapCovariances = new TMatrixD(extrapCovariances);
351 //__________________________________________________________________________
352 const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
354 /// Return the smoothed parameters (create it before if needed)
355 if (!fSmoothParameters) {
356 fSmoothParameters = new TMatrixD(5,1);
357 fSmoothParameters->Zero();
359 return *fSmoothParameters;
362 //__________________________________________________________________________
363 void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
365 /// Set the smoothed parameters
366 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
367 else fSmoothParameters = new TMatrixD(smoothParameters);
370 //__________________________________________________________________________
371 const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
373 /// Return the smoothed covariance matrix (create it before if needed)
374 if (!fSmoothCovariances) {
375 fSmoothCovariances = new TMatrixD(5,5);
376 fSmoothCovariances->Zero();
378 return *fSmoothCovariances;
381 //__________________________________________________________________________
382 void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
384 /// Set the smoothed covariance matrix
385 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
386 else fSmoothCovariances = new TMatrixD(smoothCovariances);
389 //__________________________________________________________________________
390 void AliMUONTrackParam::SetClusterPtr(AliMUONVCluster* cluster, Bool_t owner)
392 /// set pointeur to associated cluster
393 if (fOwnCluster) delete fClusterPtr;
394 fClusterPtr = cluster;
398 //__________________________________________________________________________
399 Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
401 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
402 /// Returns 1 (0, -1) if the current Z
403 /// is smaller than (equal to, larger than) Z of trackParam
404 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
405 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
409 //__________________________________________________________________________
410 Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const
412 /// Return kTRUE if the two set of track parameters are compatible within sigma2Cut
413 /// Set chi2 to the compatible chi2 value
414 /// Note that parameter covariances must exist for at least one set of parameters
415 /// Note also that if parameters are not given at the same Z, results will be meaningless
420 // ckeck covariance matrices
421 if (!fCovariances && !trackParam.fCovariances) {
422 AliError("Covariance matrix must exist for at least one set of parameters");
426 Double_t maxChi2 = 5. * sigma2Cut * sigma2Cut; // 5 degrees of freedom
428 // check Z parameters
429 if (fZ != trackParam.fZ)
430 AliWarning(Form("Parameters are given at different Z position (%le : %le): results are meaningless", fZ, trackParam.fZ));
432 // compute the parameter residuals
433 TMatrixD deltaParam(fParameters, TMatrixD::kMinus, trackParam.fParameters);
435 // build the error matrix
436 TMatrixD weight(5,5);
437 if (fCovariances) weight += *fCovariances;
438 if (trackParam.fCovariances) weight += *(trackParam.fCovariances);
440 // invert the error matrix to get the parameter weights if possible
441 if (weight.Determinant() == 0) {
442 AliError("Cannot compute the compatibility chi2");
447 // compute the compatibility chi2
448 TMatrixD tmp(deltaParam, TMatrixD::kTransposeMult, weight);
449 TMatrixD mChi2(tmp, TMatrixD::kMult, deltaParam);
454 // check compatibility
455 if (chi2 > maxChi2) return kFALSE;
460 //__________________________________________________________________________
461 void AliMUONTrackParam::Print(Option_t* opt) const
463 /// Printing TrackParam information
464 /// "full" option for printing all the information about the TrackParam
468 if ( sopt.Contains("FULL") ) {
469 cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./fParameters(4,0) <<
470 ", NonBendSlope=" << setw(5) << setprecision(3) << fParameters(1,0)*180./TMath::Pi() <<
471 ", BendSlope=" << setw(5) << setprecision(3) << fParameters(3,0)*180./TMath::Pi() <<
472 ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << fParameters(0,0) <<
473 "," << setw(5) << setprecision(3) << fParameters(2,0) <<
474 "," << setw(5) << setprecision(3) << fZ <<
475 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
476 "," << setw(5) << setprecision(3) << Py() <<
477 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;
480 cout << "<AliMUONTrackParam>" << endl;