]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackParam.cxx
Add path for buspatch cable length file
[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
3831f268 18///////////////////////////////////////////////////
19//
20// Track parameters
21// in
22// ALICE
23// dimuon
24// spectrometer
a9e2aefa 25//
3831f268 26///////////////////////////////////////////////////
a9e2aefa 27
37827b29 28#include "AliMUONTrackParam.h"
22ccc301 29#include "AliMUONHitForRec.h"
30
211c52eb 31#include "AliESDMuonTrack.h"
37827b29 32#include "AliLog.h"
22ccc301 33
22ccc301 34#include <TMath.h>
ea94c18b 35
36#include <Riostream.h>
a9e2aefa 37
7945aae7 38/// \cond CLASSIMP
a9e2aefa 39ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
7945aae7 40/// \endcond
a9e2aefa 41
61adb9bd 42 //_________________________________________________________________________
30178c30 43AliMUONTrackParam::AliMUONTrackParam()
54d7ba50 44 : TObject(),
208f139e 45 fZ(0.),
ea94c18b 46 fParameters(5,1),
208f139e 47 fCovariances(0x0),
ea94c18b 48 fPropagator(0x0),
49 fExtrapParameters(0x0),
50 fExtrapCovariances(0x0),
51 fSmoothParameters(0x0),
52 fSmoothCovariances(0x0),
53 fHitForRecPtr(0x0),
54 fRemovable(kFALSE),
55 fTrackChi2(0.),
56 fLocalChi2(0.)
30178c30 57{
37827b29 58 /// Constructor
30178c30 59}
61adb9bd 60
30178c30 61 //_________________________________________________________________________
de2cd600 62AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
63 : TObject(theMUONTrackParam),
208f139e 64 fZ(theMUONTrackParam.fZ),
ea94c18b 65 fParameters(theMUONTrackParam.fParameters),
208f139e 66 fCovariances(0x0),
ea94c18b 67 fPropagator(0x0),
68 fExtrapParameters(0x0),
69 fExtrapCovariances(0x0),
70 fSmoothParameters(0x0),
71 fSmoothCovariances(0x0),
72 fHitForRecPtr(theMUONTrackParam.fHitForRecPtr),
73 fRemovable(theMUONTrackParam.fRemovable),
74 fTrackChi2(theMUONTrackParam.fTrackChi2),
75 fLocalChi2(theMUONTrackParam.fLocalChi2)
de2cd600 76{
2457f726 77 /// Copy constructor
208f139e 78 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
ea94c18b 79 if (theMUONTrackParam.fPropagator) fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator));
80 if (theMUONTrackParam.fExtrapParameters) fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters));
81 if (theMUONTrackParam.fExtrapCovariances) fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances));
82 if (theMUONTrackParam.fSmoothParameters) fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters));
83 if (theMUONTrackParam.fSmoothCovariances) fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances));
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));
103 } else if (fCovariances) {
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));
111 } else if (fPropagator) {
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));
119 } else if (fExtrapParameters) {
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));
127 } else if (fExtrapCovariances) {
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));
135 } else if (fSmoothParameters) {
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));
143 } else if (fSmoothCovariances) {
144 delete fSmoothCovariances;
145 fSmoothCovariances = 0x0;
146 }
147
148 fHitForRecPtr = theMUONTrackParam.fHitForRecPtr;
149
150 fRemovable = theMUONTrackParam.fRemovable;
151
152 fTrackChi2 = theMUONTrackParam.fTrackChi2;
153 fLocalChi2 = theMUONTrackParam.fLocalChi2;
154
61adb9bd 155 return *this;
156}
de2cd600 157
158 //__________________________________________________________________________
159AliMUONTrackParam::~AliMUONTrackParam()
61adb9bd 160{
de2cd600 161/// Destructor
208f139e 162 DeleteCovariances();
ea94c18b 163 delete fPropagator;
164 delete fExtrapParameters;
165 delete fExtrapCovariances;
166 delete fSmoothParameters;
167 delete fSmoothCovariances;
de2cd600 168}
169
170 //__________________________________________________________________________
ea94c18b 171void
172AliMUONTrackParam::Clear(Option_t* /*opt*/)
173{
174 /// Delete the covariance matrix
175 DeleteCovariances();
176 delete fPropagator; fPropagator = 0x0;
177 delete fExtrapParameters; fExtrapParameters = 0x0;
178 delete fExtrapCovariances; fExtrapCovariances = 0x0;
179 delete fSmoothParameters; fSmoothParameters = 0x0;
180 delete fSmoothCovariances; fSmoothCovariances = 0x0;
de2cd600 181}
54d7ba50 182
de2cd600 183 //__________________________________________________________________________
184AliMUONHitForRec* AliMUONTrackParam::GetHitForRecPtr(void) const
185{
186/// return pointer to HitForRec attached to the current TrackParam
187/// this method should not be called when fHitForRecPtr == NULL
208f139e 188 if (!fHitForRecPtr) AliWarning("fHitForRecPtr == NULL");
de2cd600 189 return fHitForRecPtr;
190}
191
211c52eb 192 //_________________________________________________________________________
193void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack)
194{
2457f726 195 /// assigned value form ESD track.
ea94c18b 196 fZ = esdMuonTrack.GetZ();
197 fParameters(0,0) = esdMuonTrack.GetNonBendingCoor();
198 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaX());
199 fParameters(2,0) = esdMuonTrack.GetBendingCoor();
200 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaY());
201 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentum();
211c52eb 202}
203
204 //_________________________________________________________________________
ea94c18b 205void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack) const
211c52eb 206{
2457f726 207 /// assigned value form ESD track.
ea94c18b 208 esdMuonTrack.SetZ(fZ);
209 esdMuonTrack.SetNonBendingCoor(fParameters(0,0));
210 esdMuonTrack.SetThetaX(TMath::ATan(fParameters(1,0)));
211 esdMuonTrack.SetBendingCoor(fParameters(2,0));
212 esdMuonTrack.SetThetaY(TMath::ATan(fParameters(3,0)));
213 esdMuonTrack.SetInverseBendingMomentum(fParameters(4,0));
211c52eb 214}
215
22ccc301 216 //_________________________________________________________________________
217void AliMUONTrackParam::GetParamFromUncorrected(const AliESDMuonTrack& esdMuonTrack)
218{
219 /// assigned value form ESD track.
ea94c18b 220 fZ = esdMuonTrack.GetZUncorrected();
221 fParameters(0,0) = esdMuonTrack.GetNonBendingCoorUncorrected();
222 fParameters(1,0) = TMath::Tan(esdMuonTrack.GetThetaXUncorrected());
223 fParameters(2,0) = esdMuonTrack.GetBendingCoorUncorrected();
224 fParameters(3,0) = TMath::Tan(esdMuonTrack.GetThetaYUncorrected());
225 fParameters(4,0) = esdMuonTrack.GetInverseBendingMomentumUncorrected();
22ccc301 226}
227
228 //_________________________________________________________________________
ea94c18b 229void AliMUONTrackParam::SetParamForUncorrected(AliESDMuonTrack& esdMuonTrack) const
22ccc301 230{
231 /// assigned value form ESD track.
ea94c18b 232 esdMuonTrack.SetZUncorrected(fZ);
233 esdMuonTrack.SetNonBendingCoorUncorrected(fParameters(0,0));
234 esdMuonTrack.SetThetaXUncorrected(TMath::ATan(fParameters(1,0)));
235 esdMuonTrack.SetBendingCoorUncorrected(fParameters(2,0));
236 esdMuonTrack.SetThetaYUncorrected(TMath::ATan(fParameters(3,0)));
237 esdMuonTrack.SetInverseBendingMomentumUncorrected(fParameters(4,0));
22ccc301 238}
239
b8dc484b 240 //__________________________________________________________________________
6464217e 241Double_t AliMUONTrackParam::Px() const
b8dc484b 242{
22ccc301 243 /// return p_x from track parameters
b8dc484b 244 Double_t pYZ, pZ, pX;
245 pYZ = 0;
ea94c18b 246 if ( TMath::Abs(fParameters(4,0)) > 0 )
247 pYZ = TMath::Abs(1.0 / fParameters(4,0));
248 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
249 pX = pZ * fParameters(1,0);
b8dc484b 250 return pX;
251}
37827b29 252
b8dc484b 253 //__________________________________________________________________________
6464217e 254Double_t AliMUONTrackParam::Py() const
b8dc484b 255{
22ccc301 256 /// return p_y from track parameters
b8dc484b 257 Double_t pYZ, pZ, pY;
258 pYZ = 0;
ea94c18b 259 if ( TMath::Abs(fParameters(4,0)) > 0 )
260 pYZ = TMath::Abs(1.0 / fParameters(4,0));
261 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
262 pY = pZ * fParameters(3,0);
b8dc484b 263 return pY;
264}
37827b29 265
b8dc484b 266 //__________________________________________________________________________
6464217e 267Double_t AliMUONTrackParam::Pz() const
b8dc484b 268{
22ccc301 269 /// return p_z from track parameters
b8dc484b 270 Double_t pYZ, pZ;
271 pYZ = 0;
ea94c18b 272 if ( TMath::Abs(fParameters(4,0)) > 0 )
273 pYZ = TMath::Abs(1.0 / fParameters(4,0));
274 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
b8dc484b 275 return pZ;
276}
37827b29 277
b8dc484b 278 //__________________________________________________________________________
6464217e 279Double_t AliMUONTrackParam::P() const
b8dc484b 280{
22ccc301 281 /// return p from track parameters
b8dc484b 282 Double_t pYZ, pZ, p;
283 pYZ = 0;
ea94c18b 284 if ( TMath::Abs(fParameters(4,0)) > 0 )
285 pYZ = TMath::Abs(1.0 / fParameters(4,0));
286 pZ = -pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0)
b8dc484b 287 p = TMath::Abs(pZ) *
ea94c18b 288 TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0));
b8dc484b 289 return p;
290
b45fd22b 291}
4d03a78e 292
208f139e 293 //__________________________________________________________________________
ea94c18b 294const TMatrixD& AliMUONTrackParam::GetCovariances() const
208f139e 295{
296 /// Return the covariance matrix (create it before if needed)
297 if (!fCovariances) {
298 fCovariances = new TMatrixD(5,5);
ea94c18b 299 fCovariances->Zero();
208f139e 300 }
ea94c18b 301 return *fCovariances;
302}
208f139e 303
304 //__________________________________________________________________________
ea94c18b 305void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances)
208f139e 306{
307 /// Set the covariance matrix
ea94c18b 308 if (&covariances == fCovariances) return; // nothing to be done
309 if (fCovariances) *fCovariances = covariances;
310 else fCovariances = new TMatrixD(covariances);
208f139e 311}
312
313 //__________________________________________________________________________
ea94c18b 314void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5])
208f139e 315{
316 /// Set the covariance matrix
317 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
318 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
319}
320
321 //__________________________________________________________________________
ea94c18b 322void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5])
208f139e 323{
324 /// Set the diagonal terms of the covariance matrix (variances)
325 if (!fCovariances) fCovariances = new TMatrixD(5,5);
ea94c18b 326 fCovariances->Zero();
208f139e 327 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
328}
329
330 //__________________________________________________________________________
331void AliMUONTrackParam::DeleteCovariances()
332{
333 /// Delete the covariance matrix
686772dc 334 delete fCovariances;
208f139e 335 fCovariances = 0x0;
336}
337
338 //__________________________________________________________________________
ea94c18b 339const TMatrixD& AliMUONTrackParam::GetPropagator() const
208f139e 340{
ea94c18b 341 /// Return the propagator (create it before if needed)
342 if (!fPropagator) {
343 fPropagator = new TMatrixD(5,5);
344 fPropagator->Zero();
208f139e 345 }
ea94c18b 346 return *fPropagator;
347 }
348
349 //__________________________________________________________________________
350void AliMUONTrackParam::ResetPropagator()
351{
352 /// Reset the propagator
353 if (!fPropagator) fPropagator = new TMatrixD(5,5);
354 fPropagator->UnitMatrix();
355}
356
357 //__________________________________________________________________________
358void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator)
359{
360 /// Update the propagator
361 if (&propagator == fPropagator) return; // nothing to be done
362 if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator);
363 else fPropagator = new TMatrixD(propagator);
364}
365
366 //__________________________________________________________________________
367const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const
368{
369 /// Return extrapolated parameters (create it before if needed)
370 if (!fExtrapParameters) {
371 fExtrapParameters = new TMatrixD(5,1);
372 fExtrapParameters->Zero();
373 }
374 return *fExtrapParameters;
375 }
376
377 //__________________________________________________________________________
378void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters)
379{
380 /// Set extrapolated parameters
381 if (&extrapParameters == fExtrapParameters) return; // nothing to be done
382 if (fExtrapParameters) *fExtrapParameters = extrapParameters;
383 else fExtrapParameters = new TMatrixD(extrapParameters);
384}
385
386 //__________________________________________________________________________
387const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const
388{
389 /// Return the extrapolated covariance matrix (create it before if needed)
390 if (!fExtrapCovariances) {
391 fExtrapCovariances = new TMatrixD(5,5);
392 fExtrapCovariances->Zero();
393 }
394 return *fExtrapCovariances;
395 }
396
397 //__________________________________________________________________________
398void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances)
399{
400 /// Set the extrapolated covariance matrix
401 if (&extrapCovariances == fExtrapCovariances) return; // nothing to be done
402 if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances;
403 else fExtrapCovariances = new TMatrixD(extrapCovariances);
404}
405
406 //__________________________________________________________________________
407const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const
408{
409 /// Return the smoothed parameters (create it before if needed)
410 if (!fSmoothParameters) {
411 fSmoothParameters = new TMatrixD(5,1);
412 fSmoothParameters->Zero();
413 }
414 return *fSmoothParameters;
415 }
416
417 //__________________________________________________________________________
418void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters)
419{
420 /// Set the smoothed parameters
421 if (&smoothParameters == fSmoothParameters) return; // nothing to be done
422 if (fSmoothParameters) *fSmoothParameters = smoothParameters;
423 else fSmoothParameters = new TMatrixD(smoothParameters);
424}
425
426 //__________________________________________________________________________
427const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const
428{
429 /// Return the smoothed covariance matrix (create it before if needed)
430 if (!fSmoothCovariances) {
431 fSmoothCovariances = new TMatrixD(5,5);
432 fSmoothCovariances->Zero();
433 }
434 return *fSmoothCovariances;
435 }
436
437 //__________________________________________________________________________
438void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances)
439{
440 /// Set the smoothed covariance matrix
441 if (&smoothCovariances == fSmoothCovariances) return; // nothing to be done
442 if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances;
443 else fSmoothCovariances = new TMatrixD(smoothCovariances);
208f139e 444}
445
446 //__________________________________________________________________________
447Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
448{
449 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
450 /// Returns 1 (0, -1) if Z of current TrackHit
451 /// is smaller than (equal to, larger than) Z of TrackHit
847cbaef 452 if (fHitForRecPtr) {
453 if (fHitForRecPtr->GetZ() != fZ)
454 AliWarning("track parameters are given at a different z position than the one of the corresponding hit");
455 }
456 if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
457 else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
208f139e 458 else return(-1);
459}
460
6464217e 461//_____________________________________________-
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() <<
478 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;
479 }
480 else {
481 cout << "<AliMUONTrackParam>" << endl;
482 }
483
484}