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