]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackParam.cxx
Simplifications, now that pedestal subprocessor is taking care of deciding whether...
[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
7945aae7 33/// \cond CLASSIMP
a9e2aefa 34ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
7945aae7 35/// \endcond
a9e2aefa 36
61adb9bd 37 //_________________________________________________________________________
30178c30 38AliMUONTrackParam::AliMUONTrackParam()
54d7ba50 39 : TObject(),
208f139e 40 fZ(0.),
ea94c18b 41 fParameters(5,1),
208f139e 42 fCovariances(0x0),
ea94c18b 43 fPropagator(0x0),
44 fExtrapParameters(0x0),
45 fExtrapCovariances(0x0),
46 fSmoothParameters(0x0),
47 fSmoothCovariances(0x0),
96ebe67e 48 fClusterPtr(0x0),
49 fOwnCluster(kFALSE),
ea94c18b 50 fRemovable(kFALSE),
51 fTrackChi2(0.),
52 fLocalChi2(0.)
30178c30 53{
37827b29 54 /// Constructor
6b191dea 55 fParameters.Zero();
30178c30 56}
61adb9bd 57
30178c30 58 //_________________________________________________________________________
de2cd600 59AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
60 : TObject(theMUONTrackParam),
208f139e 61 fZ(theMUONTrackParam.fZ),
ea94c18b 62 fParameters(theMUONTrackParam.fParameters),
208f139e 63 fCovariances(0x0),
ea94c18b 64 fPropagator(0x0),
65 fExtrapParameters(0x0),
66 fExtrapCovariances(0x0),
67 fSmoothParameters(0x0),
68 fSmoothCovariances(0x0),
96ebe67e 69 fClusterPtr(0x0),
70 fOwnCluster(theMUONTrackParam.fOwnCluster),
ea94c18b 71 fRemovable(theMUONTrackParam.fRemovable),
72 fTrackChi2(theMUONTrackParam.fTrackChi2),
73 fLocalChi2(theMUONTrackParam.fLocalChi2)
de2cd600 74{
2457f726 75 /// Copy constructor
208f139e 76 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
ea94c18b 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));
96ebe67e 82
1467f4ba 83 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
96ebe67e 84 else fClusterPtr = theMUONTrackParam.fClusterPtr;
de2cd600 85}
86
87 //_________________________________________________________________________
88AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
61adb9bd 89{
2457f726 90 /// Asignment operator
30178c30 91 if (this == &theMUONTrackParam)
61adb9bd 92 return *this;
93
30178c30 94 // base class assignement
95 TObject::operator=(theMUONTrackParam);
96
ea94c18b 97 fZ = theMUONTrackParam.fZ;
98
99 fParameters = theMUONTrackParam.fParameters;
208f139e 100
101 if (theMUONTrackParam.fCovariances) {
102 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
103 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
019df241 104 } else {
208f139e 105 delete fCovariances;
106 fCovariances = 0x0;
107 }
108
ea94c18b 109 if (theMUONTrackParam.fPropagator) {
110 if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator);
111 else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
019df241 112 } else {
ea94c18b 113 delete fPropagator;
114 fPropagator = 0x0;
115 }
116
117 if (theMUONTrackParam.fExtrapParameters) {
118 if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters);
119 else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
019df241 120 } else {
ea94c18b 121 delete fExtrapParameters;
122 fExtrapParameters = 0x0;
123 }
124
125 if (theMUONTrackParam.fExtrapCovariances) {
126 if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances);
127 else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
019df241 128 } else {
ea94c18b 129 delete fExtrapCovariances;
130 fExtrapCovariances = 0x0;
131 }
132
133 if (theMUONTrackParam.fSmoothParameters) {
134 if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters);
135 else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
019df241 136 } else {
ea94c18b 137 delete fSmoothParameters;
138 fSmoothParameters = 0x0;
139 }
140
141 if (theMUONTrackParam.fSmoothCovariances) {
142 if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances);
143 else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
019df241 144 } else {
ea94c18b 145 delete fSmoothCovariances;
146 fSmoothCovariances = 0x0;
147 }
148
7332f213 149 if (fOwnCluster) delete fClusterPtr;
96ebe67e 150 fOwnCluster = theMUONTrackParam.fOwnCluster;
1467f4ba 151 if(fOwnCluster) fClusterPtr = static_cast<AliMUONVCluster*>(theMUONTrackParam.fClusterPtr->Clone());
96ebe67e 152 else fClusterPtr = theMUONTrackParam.fClusterPtr;
ea94c18b 153
154 fRemovable = theMUONTrackParam.fRemovable;
155
156 fTrackChi2 = theMUONTrackParam.fTrackChi2;
157 fLocalChi2 = theMUONTrackParam.fLocalChi2;
158
61adb9bd 159 return *this;
160}
de2cd600 161
162 //__________________________________________________________________________
163AliMUONTrackParam::~AliMUONTrackParam()
61adb9bd 164{
de2cd600 165/// Destructor
208f139e 166 DeleteCovariances();
ea94c18b 167 delete fPropagator;
168 delete fExtrapParameters;
169 delete fExtrapCovariances;
170 delete fSmoothParameters;
171 delete fSmoothCovariances;
96ebe67e 172 if(fOwnCluster) delete fClusterPtr;
de2cd600 173}
174
175 //__________________________________________________________________________
ea94c18b 176void
177AliMUONTrackParam::Clear(Option_t* /*opt*/)
178{
96ebe67e 179 /// clear memory
ea94c18b 180 DeleteCovariances();
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;
96ebe67e 186 if(fOwnCluster) {
187 delete fClusterPtr; fClusterPtr = 0x0;
188 }
22ccc301 189}
190
b8dc484b 191 //__________________________________________________________________________
6464217e 192Double_t AliMUONTrackParam::Px() const
b8dc484b 193{
22ccc301 194 /// return p_x from track parameters
0e894e58 195 Double_t pZ;
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)
199 } else {
200 pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
201 }
202 return pZ * fParameters(1,0);
b8dc484b 203}
37827b29 204
b8dc484b 205 //__________________________________________________________________________
6464217e 206Double_t AliMUONTrackParam::Py() const
b8dc484b 207{
22ccc301 208 /// return p_y from track parameters
0e894e58 209 Double_t pZ;
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)
213 } else {
214 pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
215 }
216 return pZ * fParameters(3,0);
b8dc484b 217}
37827b29 218
b8dc484b 219 //__________________________________________________________________________
6464217e 220Double_t AliMUONTrackParam::Pz() const
b8dc484b 221{
22ccc301 222 /// return p_z from track parameters
0e894e58 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));
b8dc484b 227}
37827b29 228
b8dc484b 229 //__________________________________________________________________________
6464217e 230Double_t AliMUONTrackParam::P() const
b8dc484b 231{
22ccc301 232 /// return p from track parameters
0e894e58 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)
b1fea02e 236 return - pZ * TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
0e894e58 237 } else return FLT_MAX;
b45fd22b 238}
4d03a78e 239
208f139e 240 //__________________________________________________________________________
ea94c18b 241const TMatrixD& AliMUONTrackParam::GetCovariances() const
208f139e 242{
243 /// Return the covariance matrix (create it before if needed)
244 if (!fCovariances) {
245 fCovariances = new TMatrixD(5,5);
ea94c18b 246 fCovariances->Zero();
208f139e 247 }
ea94c18b 248 return *fCovariances;
249}
208f139e 250
251 //__________________________________________________________________________
ea94c18b 252void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
208f139e 253{
254 /// Set the covariance matrix
ea94c18b 255 if (fCovariances) *fCovariances = covariances;
256 else fCovariances = new TMatrixD(covariances);
208f139e 257}
258
259 //__________________________________________________________________________
ea94c18b 260void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
208f139e 261{
262 /// Set the covariance matrix
263 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
264 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
265}
266
267 //__________________________________________________________________________
ea94c18b 268void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
208f139e 269{
270 /// Set the diagonal terms of the covariance matrix (variances)
271 if (!fCovariances) fCovariances = new TMatrixD(5,5);
ea94c18b 272 fCovariances->Zero();
208f139e 273 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
274}
275
276 //__________________________________________________________________________
277void AliMUONTrackParam::DeleteCovariances()
278{
279 /// Delete the covariance matrix
686772dc 280 delete fCovariances;
208f139e 281 fCovariances = 0x0;
282}
283
284 //__________________________________________________________________________
ea94c18b 285const TMatrixD& AliMUONTrackParam::GetPropagator() const
208f139e 286{
ea94c18b 287 /// Return the propagator (create it before if needed)
288 if (!fPropagator) {
289 fPropagator = new TMatrixD(5,5);
019df241 290 fPropagator->UnitMatrix();
208f139e 291 }
ea94c18b 292 return *fPropagator;
96ebe67e 293}
ea94c18b 294
295 //__________________________________________________________________________
296void AliMUONTrackParam::ResetPropagator()
297{
298 /// Reset the propagator
019df241 299 if (fPropagator) fPropagator->UnitMatrix();
ea94c18b 300}
301
302 //__________________________________________________________________________
303void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
304{
305 /// Update the propagator
ea94c18b 306 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
307 else fPropagator = new TMatrixD(propagator);
308}
309
310 //__________________________________________________________________________
311const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
312{
313 /// Return extrapolated parameters (create it before if needed)
314 if (!fExtrapParameters) {
315 fExtrapParameters = new TMatrixD(5,1);
316 fExtrapParameters->Zero();
317 }
318 return *fExtrapParameters;
319 }
320
321 //__________________________________________________________________________
322void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
323{
324 /// Set extrapolated parameters
ea94c18b 325 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
326 else fExtrapParameters = new TMatrixD(extrapParameters);
327}
328
329 //__________________________________________________________________________
330const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
331{
332 /// Return the extrapolated covariance matrix (create it before if needed)
333 if (!fExtrapCovariances) {
334 fExtrapCovariances = new TMatrixD(5,5);
335 fExtrapCovariances->Zero();
336 }
337 return *fExtrapCovariances;
338 }
339
340 //__________________________________________________________________________
341void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
342{
343 /// Set the extrapolated covariance matrix
ea94c18b 344 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
345 else fExtrapCovariances = new TMatrixD(extrapCovariances);
346}
347
348 //__________________________________________________________________________
349const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
350{
351 /// Return the smoothed parameters (create it before if needed)
352 if (!fSmoothParameters) {
353 fSmoothParameters = new TMatrixD(5,1);
354 fSmoothParameters->Zero();
355 }
356 return *fSmoothParameters;
357 }
358
359 //__________________________________________________________________________
360void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
361{
362 /// Set the smoothed parameters
ea94c18b 363 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
364 else fSmoothParameters = new TMatrixD(smoothParameters);
365}
366
367 //__________________________________________________________________________
368const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
369{
370 /// Return the smoothed covariance matrix (create it before if needed)
371 if (!fSmoothCovariances) {
372 fSmoothCovariances = new TMatrixD(5,5);
373 fSmoothCovariances->Zero();
374 }
375 return *fSmoothCovariances;
376 }
377
378 //__________________________________________________________________________
379void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
380{
381 /// Set the smoothed covariance matrix
ea94c18b 382 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
383 else fSmoothCovariances = new TMatrixD(smoothCovariances);
208f139e 384}
385
7d98b674 386//__________________________________________________________________________
387void AliMUONTrackParam::SetClusterPtr(AliMUONVCluster* cluster, Bool_t owner)
388{
389 /// set pointeur to associated cluster
390 if (fOwnCluster) delete fClusterPtr;
391 fClusterPtr = cluster;
392 fOwnCluster = owner;
393}
394
208f139e 395 //__________________________________________________________________________
396Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
397{
398 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
96ebe67e 399 /// Returns 1 (0, -1) if the current Z
400 /// is smaller than (equal to, larger than) Z of trackParam
847cbaef 401 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
402 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
208f139e 403 else return(-1);
404}
405
61fed964 406 //__________________________________________________________________________
407Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const
408{
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
413
414 // reset chi2 value
415 chi2 = 0.;
416
417 // ckeck covariance matrices
418 if (!fCovariances && !trackParam.fCovariances) {
419 AliError("Covariance matrix must exist for at least one set of parameters");
420 return kFALSE;
421 }
422
423 Double_t maxChi2 = 5. * sigma2Cut * sigma2Cut; // 5 degrees of freedom
424
425 // check Z parameters
426 if (fZ != trackParam.fZ)
427 AliWarning(Form("Parameters are given at different Z position (%le : %le): results are meaningless", fZ, trackParam.fZ));
428
429 // compute the parameter residuals
430 TMatrixD deltaParam(fParameters, TMatrixD::kMinus, trackParam.fParameters);
431
432 // build the error matrix
433 TMatrixD weight(5,5);
434 if (fCovariances) weight += *fCovariances;
435 if (trackParam.fCovariances) weight += *(trackParam.fCovariances);
436
437 // invert the error matrix to get the parameter weights if possible
438 if (weight.Determinant() == 0) {
439 AliError("Cannot compute the compatibility chi2");
440 return kFALSE;
441 }
442 weight.Invert();
443
444 // compute the compatibility chi2
445 TMatrixD tmp(deltaParam, TMatrixD::kTransposeMult, weight);
446 TMatrixD mChi2(tmp, TMatrixD::kMult, deltaParam);
447
448 // set chi2 value
449 chi2 = mChi2(0,0);
450
451 // check compatibility
452 if (chi2 > maxChi2) return kFALSE;
453
454 return kTRUE;
455}
456
457 //__________________________________________________________________________
6464217e 458void AliMUONTrackParam::Print(Option_t* opt) const
459{
2457f726 460 /// Printing TrackParam information
461 /// "full" option for printing all the information about the TrackParam
6464217e 462 TString sopt(opt);
463 sopt.ToUpper();
464
465 if ( sopt.Contains("FULL") ) {
ea94c18b 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 <<
6464217e 472 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
473 "," << setw(5) << setprecision(3) << Py() <<
4ea3f013 474 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c"
475 "," << "local chi2=" << GetLocalChi2() << endl;
6464217e 476 }
477 else {
478 cout << "<AliMUONTrackParam>" << endl;
479 }
480
481}