AliRoot Core  edcc906 (edcc906)
AliMUONTrackParam.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 /* $Id$ */
17 
18 //-----------------------------------------------------------------------------
19 // Class AliMUONTrackParam
20 //-------------------------
21 // Track parameters in ALICE dimuon spectrometer
22 //-----------------------------------------------------------------------------
23 
24 #include "AliMUONTrackParam.h"
25 #include "AliMUONVCluster.h"
26 
27 #include "AliLog.h"
28 
29 #include <TMath.h>
30 
31 #include <Riostream.h>
32 
33 using std::setw;
34 using std::setprecision;
35 using std::endl;
36 using std::cout;
38 ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
40 
41  //_________________________________________________________________________
43  : TObject(),
44  fZ(0.),
45  fParameters(5,1),
46  fCovariances(0x0),
47  fPropagator(0x0),
48  fExtrapParameters(0x0),
49  fExtrapCovariances(0x0),
50  fSmoothParameters(0x0),
51  fSmoothCovariances(0x0),
52  fClusterPtr(0x0),
53  fOwnCluster(kFALSE),
54  fRemovable(kFALSE),
55  fTrackChi2(0.),
56  fLocalChi2(0.)
57 {
59  fParameters.Zero();
60 }
61 
62  //_________________________________________________________________________
64  : TObject(theMUONTrackParam),
65  fZ(theMUONTrackParam.fZ),
66  fParameters(theMUONTrackParam.fParameters),
67  fCovariances(0x0),
68  fPropagator(0x0),
69  fExtrapParameters(0x0),
70  fExtrapCovariances(0x0),
71  fSmoothParameters(0x0),
72  fSmoothCovariances(0x0),
73  fClusterPtr(0x0),
74  fOwnCluster(theMUONTrackParam.fOwnCluster),
75  fRemovable(theMUONTrackParam.fRemovable),
76  fTrackChi2(theMUONTrackParam.fTrackChi2),
77  fLocalChi2(theMUONTrackParam.fLocalChi2)
78 {
80  if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
81  if (theMUONTrackParam.fPropagator) fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
82  if (theMUONTrackParam.fExtrapParameters) fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
83  if (theMUONTrackParam.fExtrapCovariances) fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
84  if (theMUONTrackParam.fSmoothParameters) fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
85  if (theMUONTrackParam.fSmoothCovariances) fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
86 
87  if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
88  else fClusterPtr = theMUONTrackParam.fClusterPtr;
89 }
90 
91  //_________________________________________________________________________
93 {
95  if (this == &theMUONTrackParam)
96  return *this;
97 
98  // base class assignement
99  TObject::operator=(theMUONTrackParam);
100 
101  fZ = theMUONTrackParam.fZ;
102 
103  fParameters = theMUONTrackParam.fParameters;
104 
105  if (theMUONTrackParam.fCovariances) {
106  if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
107  else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
108  } else {
109  delete fCovariances;
110  fCovariances = 0x0;
111  }
112 
113  if (theMUONTrackParam.fPropagator) {
114  if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
115  else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
116  } else {
117  delete fPropagator;
118  fPropagator = 0x0;
119  }
120 
121  if (theMUONTrackParam.fExtrapParameters) {
122  if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
123  else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
124  } else {
125  delete fExtrapParameters;
126  fExtrapParameters = 0x0;
127  }
128 
129  if (theMUONTrackParam.fExtrapCovariances) {
130  if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
131  else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
132  } else {
133  delete fExtrapCovariances;
134  fExtrapCovariances = 0x0;
135  }
136 
137  if (theMUONTrackParam.fSmoothParameters) {
138  if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
139  else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
140  } else {
141  delete fSmoothParameters;
142  fSmoothParameters = 0x0;
143  }
144 
145  if (theMUONTrackParam.fSmoothCovariances) {
146  if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
147  else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
148  } else {
149  delete fSmoothCovariances;
150  fSmoothCovariances = 0x0;
151  }
152 
153  if (fOwnCluster) delete fClusterPtr;
154  fOwnCluster = theMUONTrackParam.fOwnCluster;
155  if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
156  else fClusterPtr = theMUONTrackParam.fClusterPtr;
157 
158  fRemovable = theMUONTrackParam.fRemovable;
159 
160  fTrackChi2 = theMUONTrackParam.fTrackChi2;
161  fLocalChi2 = theMUONTrackParam.fLocalChi2;
162 
163  return *this;
164 }
165 
166  //__________________________________________________________________________
168 {
171  delete fPropagator;
172  delete fExtrapParameters;
173  delete fExtrapCovariances;
174  delete fSmoothParameters;
175  delete fSmoothCovariances;
176  if(fOwnCluster) delete fClusterPtr;
177 }
178 
179  //__________________________________________________________________________
180 void
181 AliMUONTrackParam::Clear(Option_t* /*opt*/)
182 {
185  delete fPropagator; fPropagator = 0x0;
186  delete fExtrapParameters; fExtrapParameters = 0x0;
188  delete fSmoothParameters; fSmoothParameters = 0x0;
190  if(fOwnCluster) {
191  delete fClusterPtr; fClusterPtr = 0x0;
192  }
193 }
194 
195  //__________________________________________________________________________
196 Double_t AliMUONTrackParam::Px() const
197 {
199  Double_t pZ;
200  if (TMath::Abs(fParameters(4,0)) > 0) {
201  Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX;
202  pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
203  } else {
204  pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
205  }
206  return pZ * fParameters(1,0);
207 }
208 
209  //__________________________________________________________________________
210 Double_t AliMUONTrackParam::Py() const
211 {
213  Double_t pZ;
214  if (TMath::Abs(fParameters(4,0)) > 0) {
215  Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX;
216  pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
217  } else {
218  pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
219  }
220  return pZ * fParameters(3,0);
221 }
222 
223  //__________________________________________________________________________
224 Double_t AliMUONTrackParam::Pz() const
225 {
227  if (TMath::Abs(fParameters(4,0)) > 0) {
228  Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0));
229  return - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
230  } else return - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
231 }
232 
233  //__________________________________________________________________________
234 Double_t AliMUONTrackParam::P() const
235 {
237  if (TMath::Abs(fParameters(4,0)) > 0) {
238  Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0));
239  Double_t pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
240  return - pZ * TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
241  } else return FLT_MAX;
242 }
243 
244  //__________________________________________________________________________
246 {
248  if (!fCovariances) {
249  fCovariances = new TMatrixD(5,5);
250  fCovariances->Zero();
251  }
252  return *fCovariances;
253 }
254 
255  //__________________________________________________________________________
257 {
259  if (fCovariances) *fCovariances = covariances;
260  else fCovariances = new TMatrixD(covariances);
261 }
262 
263  //__________________________________________________________________________
264 void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
265 {
267  if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
268  else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
269 }
270 
271  //__________________________________________________________________________
272 void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
273 {
275  if (!fCovariances) fCovariances = new TMatrixD(5,5);
276  fCovariances->Zero();
277  for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
278 }
279 
280  //__________________________________________________________________________
282 {
284  delete fCovariances;
285  fCovariances = 0x0;
286 }
287 
288  //__________________________________________________________________________
290 {
292  if (!fPropagator) {
293  fPropagator = new TMatrixD(5,5);
294  fPropagator->UnitMatrix();
295  }
296  return *fPropagator;
297 }
298 
299  //__________________________________________________________________________
301 {
303  if (fPropagator) fPropagator->UnitMatrix();
304 }
305 
306  //__________________________________________________________________________
308 {
310  if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
311  else fPropagator = new TMatrixD(propagator);
312 }
313 
314  //__________________________________________________________________________
316 {
318  if (!fExtrapParameters) {
319  fExtrapParameters = new TMatrixD(5,1);
320  fExtrapParameters->Zero();
321  }
322  return *fExtrapParameters;
323  }
324 
325  //__________________________________________________________________________
327 {
329  if (fExtrapParameters) *fExtrapParameters = extrapParameters;
330  else fExtrapParameters = new TMatrixD(extrapParameters);
331 }
332 
333  //__________________________________________________________________________
335 {
337  if (!fExtrapCovariances) {
338  fExtrapCovariances = new TMatrixD(5,5);
339  fExtrapCovariances->Zero();
340  }
341  return *fExtrapCovariances;
342  }
343 
344  //__________________________________________________________________________
345 void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
346 {
348  if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
349  else fExtrapCovariances = new TMatrixD(extrapCovariances);
350 }
351 
352  //__________________________________________________________________________
354 {
356  if (!fSmoothParameters) {
357  fSmoothParameters = new TMatrixD(5,1);
358  fSmoothParameters->Zero();
359  }
360  return *fSmoothParameters;
361  }
362 
363  //__________________________________________________________________________
365 {
367  if (fSmoothParameters) *fSmoothParameters = smoothParameters;
368  else fSmoothParameters = new TMatrixD(smoothParameters);
369 }
370 
371  //__________________________________________________________________________
373 {
375  if (!fSmoothCovariances) {
376  fSmoothCovariances = new TMatrixD(5,5);
377  fSmoothCovariances->Zero();
378  }
379  return *fSmoothCovariances;
380  }
381 
382  //__________________________________________________________________________
383 void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
384 {
386  if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
387  else fSmoothCovariances = new TMatrixD(smoothCovariances);
388 }
389 
390 //__________________________________________________________________________
392 {
394  if (fOwnCluster) delete fClusterPtr;
395  fClusterPtr = cluster;
396  fOwnCluster = owner;
397 }
398 
399  //__________________________________________________________________________
400 Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
401 {
405  if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
406  else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
407  else return(-1);
408 }
409 
410  //__________________________________________________________________________
411 Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const
412 {
417 
418  // reset chi2 value
419  chi2 = 0.;
420 
421  // ckeck covariance matrices
422  if (!fCovariances && !trackParam.fCovariances) {
423  AliError("Covariance matrix must exist for at least one set of parameters");
424  return kFALSE;
425  }
426 
427  Double_t maxChi2 = 5. * sigma2Cut * sigma2Cut; // 5 degrees of freedom
428 
429  // check Z parameters
430  if (fZ != trackParam.fZ)
431  AliWarning(Form("Parameters are given at different Z position (%e : %e): results are meaningless", fZ, trackParam.fZ));
432 
433  // compute the parameter residuals
434  TMatrixD deltaParam(fParameters, TMatrixD::kMinus, trackParam.fParameters);
435 
436  // build the error matrix
437  TMatrixD weight(5,5);
438  if (fCovariances) weight += *fCovariances;
439  if (trackParam.fCovariances) weight += *(trackParam.fCovariances);
440 
441  // invert the error matrix to get the parameter weights if possible
442  if (weight.Determinant() == 0) {
443  AliError("Cannot compute the compatibility chi2");
444  return kFALSE;
445  }
446  weight.Invert();
447 
448  // compute the compatibility chi2
449  TMatrixD tmp(deltaParam, TMatrixD::kTransposeMult, weight);
450  TMatrixD mChi2(tmp, TMatrixD::kMult, deltaParam);
451 
452  // set chi2 value
453  chi2 = mChi2(0,0);
454 
455  // check compatibility
456  if (chi2 > maxChi2) return kFALSE;
457 
458  return kTRUE;
459 }
460 
461  //__________________________________________________________________________
462 void AliMUONTrackParam::Print(Option_t* opt) const
463 {
466  TString sopt(opt);
467  sopt.ToUpper();
468 
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"
479  "," << "local chi2=" << GetLocalChi2() << endl;
480  }
481  else {
482  cout << "<AliMUONTrackParam>" << endl;
483  }
484 
485 }
void SetSmoothParameters(const TMatrixD &parameters)
Double_t GetLocalChi2() const
return the local chi2 of the associated cluster with respect to the track
TMatrixD * fPropagator
! Jacobian used to extrapolate the track parameters and covariances to the actual z position ...
TMatrixD * fSmoothParameters
! Track parameters obtained using smoother
const TMatrixD & GetSmoothCovariances() const
AliMUONVCluster * fClusterPtr
! Pointer to associated cluster if any
Double_t GetZ() const
return Z coordinate (cm)
Double_t fTrackChi2
! Chi2 of the track when the associated cluster was attached
Double_t fZ
Z coordinate (cm)
const TMatrixD & GetExtrapCovariances() const
Track parameters in ALICE dimuon spectrometer.
Double_t fLocalChi2
! Local chi2 of the associated cluster with respect to the track
void SetExtrapParameters(const TMatrixD &parameters)
#define AliWarning(message)
Definition: AliLog.h:541
Bool_t CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &normChi2) const
Int_t Compare(const TObject *trackParam) const
TMatrixD * fCovariances
Covariance matrix of track parameters.
void SetVariances(const Double_t matrix[5][5])
void SetSmoothCovariances(const TMatrixD &covariances)
Double_t chi2
Definition: AnalyzeLaser.C:7
abstract base class for clusters
TMatrixD * fSmoothCovariances
! Covariance matrix obtained using smoother
Double_t Py() const
void SetClusterPtr(AliMUONVCluster *cluster, Bool_t owner=kFALSE)
void SetExtrapCovariances(const TMatrixD &covariances)
const TMatrixD & GetSmoothParameters() const
TMatrixD * fExtrapParameters
! Track parameters extrapolated to the actual z position (not filtered by Kalman) ...
Bool_t fOwnCluster
! Ownership of the associated cluster
TMatrixD * fExtrapCovariances
! Covariance matrix extrapolated to the actual z position (not filtered by Kalman) ...
virtual void Clear(Option_t *opt="")
Double_t P() const
TMatrixD fParameters
Track parameters.
const TMatrixD & GetExtrapParameters() const
virtual void Print(Option_t *opt="") const
Double_t Px() const
Bool_t fRemovable
! kTRUE if the associated cluster can be removed from the track it belongs to
Double_t Pz() const
void UpdatePropagator(const TMatrixD &propagator)
#define AliError(message)
Definition: AliLog.h:591
void SetCovariances(const TMatrixD &covariances)
AliMUONTrackParam & operator=(const AliMUONTrackParam &theMUONTrackParam)
const TMatrixD & GetCovariances() const
const TMatrixD & GetPropagator() const
class TMatrixT< Double_t > TMatrixD