]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackParam.cxx
New option to discard mono-cathod clusters (by changing their resolution) and refit...
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackParam.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
56316147 18//-----------------------------------------------------------------------------
19// Class AliMUONTrackParam
20//-------------------------
21// Track parameters in ALICE dimuon spectrometer
22//-----------------------------------------------------------------------------
a9e2aefa 23
37827b29 24#include "AliMUONTrackParam.h"
96ebe67e 25#include "AliMUONVCluster.h"
22ccc301 26
37827b29 27#include "AliLog.h"
22ccc301 28
22ccc301 29#include <TMath.h>
ea94c18b 30
31#include <Riostream.h>
a9e2aefa 32
cdd730d0 33using std::setw;
34using std::setprecision;
35using std::endl;
36using std::cout;
7945aae7 37/// \cond CLASSIMP
a9e2aefa 38ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
7945aae7 39/// \endcond
a9e2aefa 40
61adb9bd 41 //_________________________________________________________________________
30178c30 42AliMUONTrackParam::AliMUONTrackParam()
54d7ba50 43 : TObject(),
208f139e 44 fZ(0.),
ea94c18b 45 fParameters(5,1),
208f139e 46 fCovariances(0x0),
ea94c18b 47 fPropagator(0x0),
48 fExtrapParameters(0x0),
49 fExtrapCovariances(0x0),
50 fSmoothParameters(0x0),
51 fSmoothCovariances(0x0),
96ebe67e 52 fClusterPtr(0x0),
53 fOwnCluster(kFALSE),
ea94c18b 54 fRemovable(kFALSE),
55 fTrackChi2(0.),
56 fLocalChi2(0.)
30178c30 57{
37827b29 58 /// Constructor
6b191dea 59 fParameters.Zero();
30178c30 60}
61adb9bd 61
30178c30 62 //_________________________________________________________________________
de2cd600 63AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
64 : TObject(theMUONTrackParam),
208f139e 65 fZ(theMUONTrackParam.fZ),
ea94c18b 66 fParameters(theMUONTrackParam.fParameters),
208f139e 67 fCovariances(0x0),
ea94c18b 68 fPropagator(0x0),
69 fExtrapParameters(0x0),
70 fExtrapCovariances(0x0),
71 fSmoothParameters(0x0),
72 fSmoothCovariances(0x0),
96ebe67e 73 fClusterPtr(0x0),
74 fOwnCluster(theMUONTrackParam.fOwnCluster),
ea94c18b 75 fRemovable(theMUONTrackParam.fRemovable),
76 fTrackChi2(theMUONTrackParam.fTrackChi2),
77 fLocalChi2(theMUONTrackParam.fLocalChi2)
de2cd600 78{
2457f726 79 /// Copy constructor
208f139e 80 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
ea94c18b 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));
96ebe67e 86
1467f4ba 87 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
96ebe67e 88 else fClusterPtr = theMUONTrackParam.fClusterPtr;
de2cd600 89}
90
91 //_________________________________________________________________________
92AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
61adb9bd 93{
2457f726 94 /// Asignment operator
30178c30 95 if (this == &theMUONTrackParam)
61adb9bd 96 return *this;
97
30178c30 98 // base class assignement
99 TObject::operator=(theMUONTrackParam);
100
ea94c18b 101 fZ = theMUONTrackParam.fZ;
102
103 fParameters = theMUONTrackParam.fParameters;
208f139e 104
105 if (theMUONTrackParam.fCovariances) {
106 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
107 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
019df241 108 } else {
208f139e 109 delete fCovariances;
110 fCovariances = 0x0;
111 }
112
ea94c18b 113 if (theMUONTrackParam.fPropagator) {
114 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
115 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
019df241 116 } else {
ea94c18b 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));
019df241 124 } else {
ea94c18b 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));
019df241 132 } else {
ea94c18b 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));
019df241 140 } else {
ea94c18b 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));
019df241 148 } else {
ea94c18b 149 delete fSmoothCovariances;
150 fSmoothCovariances = 0x0;
151 }
152
7332f213 153 if (fOwnCluster) delete fClusterPtr;
96ebe67e 154 fOwnCluster = theMUONTrackParam.fOwnCluster;
1467f4ba 155 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
96ebe67e 156 else fClusterPtr = theMUONTrackParam.fClusterPtr;
ea94c18b 157
158 fRemovable = theMUONTrackParam.fRemovable;
159
160 fTrackChi2 = theMUONTrackParam.fTrackChi2;
161 fLocalChi2 = theMUONTrackParam.fLocalChi2;
162
61adb9bd 163 return *this;
164}
de2cd600 165
166 //__________________________________________________________________________
167AliMUONTrackParam::~AliMUONTrackParam()
61adb9bd 168{
de2cd600 169/// Destructor
208f139e 170 DeleteCovariances();
ea94c18b 171 delete fPropagator;
172 delete fExtrapParameters;
173 delete fExtrapCovariances;
174 delete fSmoothParameters;
175 delete fSmoothCovariances;
96ebe67e 176 if(fOwnCluster) delete fClusterPtr;
de2cd600 177}
178
179 //__________________________________________________________________________
ea94c18b 180void
181AliMUONTrackParam::Clear(Option_t* /*opt*/)
182{
96ebe67e 183 /// clear memory
ea94c18b 184 DeleteCovariances();
185 delete fPropagator; fPropagator = 0x0;
186 delete fExtrapParameters; fExtrapParameters = 0x0;
187 delete fExtrapCovariances; fExtrapCovariances = 0x0;
188 delete fSmoothParameters; fSmoothParameters = 0x0;
189 delete fSmoothCovariances; fSmoothCovariances = 0x0;
96ebe67e 190 if(fOwnCluster) {
191 delete fClusterPtr; fClusterPtr = 0x0;
192 }
22ccc301 193}
194
b8dc484b 195 //__________________________________________________________________________
6464217e 196Double_t AliMUONTrackParam::Px() const
b8dc484b 197{
22ccc301 198 /// return p_x from track parameters
0e894e58 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);
b8dc484b 207}
37827b29 208
b8dc484b 209 //__________________________________________________________________________
6464217e 210Double_t AliMUONTrackParam::Py() const
b8dc484b 211{
22ccc301 212 /// return p_y from track parameters
0e894e58 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);
b8dc484b 221}
37827b29 222
b8dc484b 223 //__________________________________________________________________________
6464217e 224Double_t AliMUONTrackParam::Pz() const
b8dc484b 225{
22ccc301 226 /// return p_z from track parameters
0e894e58 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));
b8dc484b 231}
37827b29 232
b8dc484b 233 //__________________________________________________________________________
6464217e 234Double_t AliMUONTrackParam::P() const
b8dc484b 235{
22ccc301 236 /// return p from track parameters
0e894e58 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)
b1fea02e 240 return - pZ * TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
0e894e58 241 } else return FLT_MAX;
b45fd22b 242}
4d03a78e 243
208f139e 244 //__________________________________________________________________________
ea94c18b 245const TMatrixD& AliMUONTrackParam::GetCovariances() const
208f139e 246{
247 /// Return the covariance matrix (create it before if needed)
248 if (!fCovariances) {
249 fCovariances = new TMatrixD(5,5);
ea94c18b 250 fCovariances->Zero();
208f139e 251 }
ea94c18b 252 return *fCovariances;
253}
208f139e 254
255 //__________________________________________________________________________
ea94c18b 256void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
208f139e 257{
258 /// Set the covariance matrix
ea94c18b 259 if (fCovariances) *fCovariances = covariances;
260 else fCovariances = new TMatrixD(covariances);
208f139e 261}
262
263 //__________________________________________________________________________
ea94c18b 264void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
208f139e 265{
266 /// Set the covariance matrix
267 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
268 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
269}
270
271 //__________________________________________________________________________
ea94c18b 272void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
208f139e 273{
274 /// Set the diagonal terms of the covariance matrix (variances)
275 if (!fCovariances) fCovariances = new TMatrixD(5,5);
ea94c18b 276 fCovariances->Zero();
208f139e 277 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
278}
279
280 //__________________________________________________________________________
281void AliMUONTrackParam::DeleteCovariances()
282{
283 /// Delete the covariance matrix
686772dc 284 delete fCovariances;
208f139e 285 fCovariances = 0x0;
286}
287
288 //__________________________________________________________________________
ea94c18b 289const TMatrixD& AliMUONTrackParam::GetPropagator() const
208f139e 290{
ea94c18b 291 /// Return the propagator (create it before if needed)
292 if (!fPropagator) {
293 fPropagator = new TMatrixD(5,5);
019df241 294 fPropagator->UnitMatrix();
208f139e 295 }
ea94c18b 296 return *fPropagator;
96ebe67e 297}
ea94c18b 298
299 //__________________________________________________________________________
300void AliMUONTrackParam::ResetPropagator()
301{
302 /// Reset the propagator
019df241 303 if (fPropagator) fPropagator->UnitMatrix();
ea94c18b 304}
305
306 //__________________________________________________________________________
307void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
308{
309 /// Update the propagator
ea94c18b 310 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
311 else fPropagator = new TMatrixD(propagator);
312}
313
314 //__________________________________________________________________________
315const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
316{
317 /// Return extrapolated parameters (create it before if needed)
318 if (!fExtrapParameters) {
319 fExtrapParameters = new TMatrixD(5,1);
320 fExtrapParameters->Zero();
321 }
322 return *fExtrapParameters;
323 }
324
325 //__________________________________________________________________________
326void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
327{
328 /// Set extrapolated parameters
ea94c18b 329 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
330 else fExtrapParameters = new TMatrixD(extrapParameters);
331}
332
333 //__________________________________________________________________________
334const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
335{
336 /// Return the extrapolated covariance matrix (create it before if needed)
337 if (!fExtrapCovariances) {
338 fExtrapCovariances = new TMatrixD(5,5);
339 fExtrapCovariances->Zero();
340 }
341 return *fExtrapCovariances;
342 }
343
344 //__________________________________________________________________________
345void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
346{
347 /// Set the extrapolated covariance matrix
ea94c18b 348 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
349 else fExtrapCovariances = new TMatrixD(extrapCovariances);
350}
351
352 //__________________________________________________________________________
353const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
354{
355 /// Return the smoothed parameters (create it before if needed)
356 if (!fSmoothParameters) {
357 fSmoothParameters = new TMatrixD(5,1);
358 fSmoothParameters->Zero();
359 }
360 return *fSmoothParameters;
361 }
362
363 //__________________________________________________________________________
364void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
365{
366 /// Set the smoothed parameters
ea94c18b 367 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
368 else fSmoothParameters = new TMatrixD(smoothParameters);
369}
370
371 //__________________________________________________________________________
372const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
373{
374 /// Return the smoothed covariance matrix (create it before if needed)
375 if (!fSmoothCovariances) {
376 fSmoothCovariances = new TMatrixD(5,5);
377 fSmoothCovariances->Zero();
378 }
379 return *fSmoothCovariances;
380 }
381
382 //__________________________________________________________________________
383void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
384{
385 /// Set the smoothed covariance matrix
ea94c18b 386 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
387 else fSmoothCovariances = new TMatrixD(smoothCovariances);
208f139e 388}
389
7d98b674 390//__________________________________________________________________________
391void AliMUONTrackParam::SetClusterPtr(AliMUONVCluster* cluster, Bool_t owner)
392{
393 /// set pointeur to associated cluster
394 if (fOwnCluster) delete fClusterPtr;
395 fClusterPtr = cluster;
396 fOwnCluster = owner;
397}
398
208f139e 399 //__________________________________________________________________________
400Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
401{
402 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
96ebe67e 403 /// Returns 1 (0, -1) if the current Z
404 /// is smaller than (equal to, larger than) Z of trackParam
847cbaef 405 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
406 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
208f139e 407 else return(-1);
408}
409
61fed964 410 //__________________________________________________________________________
411Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const
412{
413 /// Return kTRUE if the two set of track parameters are compatible within sigma2Cut
414 /// Set chi2 to the compatible chi2 value
415 /// Note that parameter covariances must exist for at least one set of parameters
416 /// Note also that if parameters are not given at the same Z, results will be meaningless
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)
1130977f 431 AliWarning(Form("Parameters are given at different Z position (%e : %e): results are meaningless", fZ, trackParam.fZ));
61fed964 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 //__________________________________________________________________________
6464217e 462void AliMUONTrackParam::Print(Option_t* opt) const
463{
2457f726 464 /// Printing TrackParam information
465 /// "full" option for printing all the information about the TrackParam
6464217e 466 TString sopt(opt);
467 sopt.ToUpper();
468
469 if ( sopt.Contains("FULL") ) {
ea94c18b 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 <<
6464217e 476 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
477 "," << setw(5) << setprecision(3) << Py() <<
4ea3f013 478 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c"
479 "," << "local chi2=" << GetLocalChi2() << endl;
6464217e 480 }
481 else {
482 cout << "<AliMUONTrackParam>" << endl;
483 }
484
485}