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),
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),
70 fOwnCluster(theMUONTrackParam.fOwnCluster),
71 fRemovable(theMUONTrackParam.fRemovable),
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));
83 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
84 else fClusterPtr = theMUONTrackParam.fClusterPtr;
87 //_________________________________________________________________________
88 AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
90 /// Asignment operator
91 if (this == &theMUONTrackParam)
94 // base class assignement
95 TObject::operator=(theMUONTrackParam);
97 fZ = theMUONTrackParam.fZ;
99 fParameters = theMUONTrackParam.fParameters;
101 if (theMUONTrackParam.fCovariances) {
102 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
103 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
109 if (theMUONTrackParam.fPropagator) {
110 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
111 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
117 if (theMUONTrackParam.fExtrapParameters) {
118 if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
119 else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
121 delete fExtrapParameters;
122 fExtrapParameters = 0x0;
125 if (theMUONTrackParam.fExtrapCovariances) {
126 if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
127 else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
129 delete fExtrapCovariances;
130 fExtrapCovariances = 0x0;
133 if (theMUONTrackParam.fSmoothParameters) {
134 if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
135 else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
137 delete fSmoothParameters;
138 fSmoothParameters = 0x0;
141 if (theMUONTrackParam.fSmoothCovariances) {
142 if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
143 else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
145 delete fSmoothCovariances;
146 fSmoothCovariances = 0x0;
149 if (fOwnCluster) delete fClusterPtr;
150 fOwnCluster = theMUONTrackParam.fOwnCluster;
151 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
152 else fClusterPtr = theMUONTrackParam.fClusterPtr;
154 fRemovable = theMUONTrackParam.fRemovable;
156 fTrackChi2 = theMUONTrackParam.fTrackChi2;
157 fLocalChi2 = theMUONTrackParam.fLocalChi2;
162 //__________________________________________________________________________
163 AliMUONTrackParam::~AliMUONTrackParam()
168 delete fExtrapParameters;
169 delete fExtrapCovariances;
170 delete fSmoothParameters;
171 delete fSmoothCovariances;
172 if(fOwnCluster) delete fClusterPtr;
175 //__________________________________________________________________________
177 AliMUONTrackParam::Clear(Option_t* /*opt*/)
181 delete fPropagator; fPropagator = 0x0;
182 delete fExtrapParameters; fExtrapParameters = 0x0;
183 delete fExtrapCovariances; fExtrapCovariances = 0x0;
184 delete fSmoothParameters; fSmoothParameters = 0x0;
185 delete fSmoothCovariances; fSmoothCovariances = 0x0;
187 delete fClusterPtr; fClusterPtr = 0x0;
191 //__________________________________________________________________________
192 Double_t AliMUONTrackParam::Px() const
194 /// return p_x from track parameters
196 if (TMath::Abs(fParameters(4,0)) > 0) {
197 Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX;
198 pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
200 pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
202 return pZ * fParameters(1,0);
205 //__________________________________________________________________________
206 Double_t AliMUONTrackParam::Py() const
208 /// return p_y from track parameters
210 if (TMath::Abs(fParameters(4,0)) > 0) {
211 Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX;
212 pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
214 pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
216 return pZ * fParameters(3,0);
219 //__________________________________________________________________________
220 Double_t AliMUONTrackParam::Pz() const
222 /// return p_z from track parameters
223 if (TMath::Abs(fParameters(4,0)) > 0) {
224 Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0));
225 return - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
226 } else return - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
229 //__________________________________________________________________________
230 Double_t AliMUONTrackParam::P() const
232 /// return p from track parameters
233 if (TMath::Abs(fParameters(4,0)) > 0) {
234 Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0));
235 Double_t pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
236 return - pZ * TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
237 } else return FLT_MAX;
240 //__________________________________________________________________________
241 const TMatrixD& AliMUONTrackParam::GetCovariances() const
243 /// Return the covariance matrix (create it before if needed)
245 fCovariances = new TMatrixD(5,5);
246 fCovariances->Zero();
248 return *fCovariances;
251 //__________________________________________________________________________
252 void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
254 /// Set the covariance matrix
255 if (fCovariances) *fCovariances = covariances;
256 else fCovariances = new TMatrixD(covariances);
259 //__________________________________________________________________________
260 void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
262 /// Set the covariance matrix
263 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
264 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
267 //__________________________________________________________________________
268 void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
270 /// Set the diagonal terms of the covariance matrix (variances)
271 if (!fCovariances) fCovariances = new TMatrixD(5,5);
272 fCovariances->Zero();
273 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
276 //__________________________________________________________________________
277 void AliMUONTrackParam::DeleteCovariances()
279 /// Delete the covariance matrix
284 //__________________________________________________________________________
285 const TMatrixD& AliMUONTrackParam::GetPropagator() const
287 /// Return the propagator (create it before if needed)
289 fPropagator = new TMatrixD(5,5);
290 fPropagator->UnitMatrix();
295 //__________________________________________________________________________
296 void AliMUONTrackParam::ResetPropagator()
298 /// Reset the propagator
299 if (fPropagator) fPropagator->UnitMatrix();
302 //__________________________________________________________________________
303 void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
305 /// Update the propagator
306 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
307 else fPropagator = new TMatrixD(propagator);
310 //__________________________________________________________________________
311 const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
313 /// Return extrapolated parameters (create it before if needed)
314 if (!fExtrapParameters) {
315 fExtrapParameters = new TMatrixD(5,1);
316 fExtrapParameters->Zero();
318 return *fExtrapParameters;
321 //__________________________________________________________________________
322 void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
324 /// Set extrapolated parameters
325 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
326 else fExtrapParameters = new TMatrixD(extrapParameters);
329 //__________________________________________________________________________
330 const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
332 /// Return the extrapolated covariance matrix (create it before if needed)
333 if (!fExtrapCovariances) {
334 fExtrapCovariances = new TMatrixD(5,5);
335 fExtrapCovariances->Zero();
337 return *fExtrapCovariances;
340 //__________________________________________________________________________
341 void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
343 /// Set the extrapolated covariance matrix
344 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
345 else fExtrapCovariances = new TMatrixD(extrapCovariances);
348 //__________________________________________________________________________
349 const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
351 /// Return the smoothed parameters (create it before if needed)
352 if (!fSmoothParameters) {
353 fSmoothParameters = new TMatrixD(5,1);
354 fSmoothParameters->Zero();
356 return *fSmoothParameters;
359 //__________________________________________________________________________
360 void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
362 /// Set the smoothed parameters
363 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
364 else fSmoothParameters = new TMatrixD(smoothParameters);
367 //__________________________________________________________________________
368 const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
370 /// Return the smoothed covariance matrix (create it before if needed)
371 if (!fSmoothCovariances) {
372 fSmoothCovariances = new TMatrixD(5,5);
373 fSmoothCovariances->Zero();
375 return *fSmoothCovariances;
378 //__________________________________________________________________________
379 void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
381 /// Set the smoothed covariance matrix
382 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
383 else fSmoothCovariances = new TMatrixD(smoothCovariances);
386 //__________________________________________________________________________
387 void AliMUONTrackParam::SetClusterPtr(AliMUONVCluster* cluster, Bool_t owner)
389 /// set pointeur to associated cluster
390 if (fOwnCluster) delete fClusterPtr;
391 fClusterPtr = cluster;
395 //__________________________________________________________________________
396 Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
398 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
399 /// Returns 1 (0, -1) if the current Z
400 /// is smaller than (equal to, larger than) Z of trackParam
401 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
402 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
406 //__________________________________________________________________________
407 Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const
409 /// Return kTRUE if the two set of track parameters are compatible within sigma2Cut
410 /// Set chi2 to the compatible chi2 value
411 /// Note that parameter covariances must exist for at least one set of parameters
412 /// Note also that if parameters are not given at the same Z, results will be meaningless
417 // ckeck covariance matrices
418 if (!fCovariances && !trackParam.fCovariances) {
419 AliError("Covariance matrix must exist for at least one set of parameters");
423 Double_t maxChi2 = 5. * sigma2Cut * sigma2Cut; // 5 degrees of freedom
425 // check Z parameters
426 if (fZ != trackParam.fZ)
427 AliWarning(Form("Parameters are given at different Z position (%e : %e): results are meaningless", fZ, trackParam.fZ));
429 // compute the parameter residuals
430 TMatrixD deltaParam(fParameters, TMatrixD::kMinus, trackParam.fParameters);
432 // build the error matrix
433 TMatrixD weight(5,5);
434 if (fCovariances) weight += *fCovariances;
435 if (trackParam.fCovariances) weight += *(trackParam.fCovariances);
437 // invert the error matrix to get the parameter weights if possible
438 if (weight.Determinant() == 0) {
439 AliError("Cannot compute the compatibility chi2");
444 // compute the compatibility chi2
445 TMatrixD tmp(deltaParam, TMatrixD::kTransposeMult, weight);
446 TMatrixD mChi2(tmp, TMatrixD::kMult, deltaParam);
451 // check compatibility
452 if (chi2 > maxChi2) return kFALSE;
457 //__________________________________________________________________________
458 void AliMUONTrackParam::Print(Option_t* opt) const
460 /// Printing TrackParam information
461 /// "full" option for printing all the information about the TrackParam
465 if ( sopt.Contains("FULL") ) {
466 cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./fParameters(4,0) <<
467 ", NonBendSlope=" << setw(5) << setprecision(3) << fParameters(1,0)*180./TMath::Pi() <<
468 ", BendSlope=" << setw(5) << setprecision(3) << fParameters(3,0)*180./TMath::Pi() <<
469 ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << fParameters(0,0) <<
470 "," << setw(5) << setprecision(3) << fParameters(2,0) <<
471 "," << setw(5) << setprecision(3) << fZ <<
472 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
473 "," << setw(5) << setprecision(3) << Py() <<
474 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c"
475 "," << "local chi2=" << GetLocalChi2() << endl;
478 cout << "<AliMUONTrackParam>" << endl;