]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/ESD/AliESDMuonTrack.cxx
Wrong coverity fix -- now OK
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDMuonTrack.cxx
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 //
20 /// \class AliESDMuonTrack
21 ///  Class to describe the MUON tracks in the Event Summary Data class
22 ///  This is where the results of reconstruction are stored for the muons
23 ///
24 /// \author G.Martinez
25 //
26 ///////////////////////////////////////////////////////////////////////////////
27
28 #include "AliESDMuonTrack.h"
29 #include "AliESDMuonCluster.h"
30 #include "AliESDEvent.h"
31
32 #include <TClonesArray.h>
33 #include <TLorentzVector.h>
34 #include <TMath.h>
35
36 ClassImp(AliESDMuonTrack)
37
38 //_____________________________________________________________________________
39 AliESDMuonTrack::AliESDMuonTrack ():
40   AliVParticle(),
41   fInverseBendingMomentum(FLT_MAX),
42   fThetaX(0),
43   fThetaY(0),
44   fZ(0),
45   fBendingCoor(0),
46   fNonBendingCoor(0),
47   fInverseBendingMomentumAtDCA(FLT_MAX),
48   fThetaXAtDCA(0),
49   fThetaYAtDCA(0),
50   fBendingCoorAtDCA(0),
51   fNonBendingCoorAtDCA(0),
52   fInverseBendingMomentumUncorrected(FLT_MAX),
53   fThetaXUncorrected(0),
54   fThetaYUncorrected(0),
55   fZUncorrected(0),
56   fBendingCoorUncorrected(0),
57   fNonBendingCoorUncorrected(0),
58   fRAtAbsorberEnd(0),
59   fChi2(0),
60   fChi2MatchTrigger(0),
61   fLocalTrigger(0),
62   fX1Pattern(0),
63   fY1Pattern(0),
64   fX2Pattern(0),
65   fY2Pattern(0),
66   fX3Pattern(0),
67   fY3Pattern(0),
68   fX4Pattern(0),
69   fY4Pattern(0),
70   fMuonClusterMap(0),
71   fHitsPatternInTrigCh(0),
72   fNHit(0),
73   fClusters(0x0),
74   fLabel(-1),
75   fESDEvent(0)
76
77 {
78   //
79   /// Default constructor
80   //
81   for (Int_t i = 0; i < 15; i++) fCovariances[i] = 0;
82 }
83
84
85 //_____________________________________________________________________________
86 AliESDMuonTrack::AliESDMuonTrack (const AliESDMuonTrack& muonTrack):
87   AliVParticle(muonTrack),
88   fInverseBendingMomentum(muonTrack.fInverseBendingMomentum),
89   fThetaX(muonTrack.fThetaX),
90   fThetaY(muonTrack.fThetaY),
91   fZ(muonTrack.fZ),
92   fBendingCoor(muonTrack.fBendingCoor),
93   fNonBendingCoor(muonTrack.fNonBendingCoor),
94   fInverseBendingMomentumAtDCA(muonTrack.fInverseBendingMomentumAtDCA),
95   fThetaXAtDCA(muonTrack.fThetaXAtDCA),
96   fThetaYAtDCA(muonTrack.fThetaYAtDCA),
97   fBendingCoorAtDCA(muonTrack.fBendingCoorAtDCA),
98   fNonBendingCoorAtDCA(muonTrack.fNonBendingCoorAtDCA),
99   fInverseBendingMomentumUncorrected(muonTrack.fInverseBendingMomentumUncorrected),
100   fThetaXUncorrected(muonTrack.fThetaXUncorrected),
101   fThetaYUncorrected(muonTrack.fThetaYUncorrected),
102   fZUncorrected(muonTrack.fZUncorrected),
103   fBendingCoorUncorrected(muonTrack.fBendingCoorUncorrected),
104   fNonBendingCoorUncorrected(muonTrack.fNonBendingCoorUncorrected),
105   fRAtAbsorberEnd(muonTrack.fRAtAbsorberEnd),
106   fChi2(muonTrack.fChi2),
107   fChi2MatchTrigger(muonTrack.fChi2MatchTrigger),
108   fLocalTrigger(muonTrack.fLocalTrigger),
109   fX1Pattern(muonTrack.fX1Pattern),
110   fY1Pattern(muonTrack.fY1Pattern),
111   fX2Pattern(muonTrack.fX2Pattern),
112   fY2Pattern(muonTrack.fY2Pattern),
113   fX3Pattern(muonTrack.fX3Pattern),
114   fY3Pattern(muonTrack.fY3Pattern),
115   fX4Pattern(muonTrack.fX4Pattern),
116   fY4Pattern(muonTrack.fY4Pattern),
117   fMuonClusterMap(muonTrack.fMuonClusterMap),
118   fHitsPatternInTrigCh(muonTrack.fHitsPatternInTrigCh),
119   fNHit(muonTrack.fNHit),
120   fClusters(0x0),
121   fLabel(muonTrack.fLabel),
122   fESDEvent(muonTrack.fESDEvent)
123 {
124   //
125   /// Copy constructor
126   /// Deep copy implemented
127   //
128   for (Int_t i = 0; i < 15; i++) fCovariances[i] = muonTrack.fCovariances[i];
129   
130   // necessary to make a copy of the objects and not only the pointers in TClonesArray
131   if (muonTrack.fClusters) {
132     fClusters = new TClonesArray("AliESDMuonCluster",muonTrack.fClusters->GetEntriesFast());
133     AliESDMuonCluster *cluster = (AliESDMuonCluster*) muonTrack.fClusters->First();
134     while (cluster) {
135       new ((*fClusters)[fClusters->GetEntriesFast()]) AliESDMuonCluster(*cluster);
136       cluster = (AliESDMuonCluster*) muonTrack.fClusters->After(cluster);
137     }
138   }
139 }
140
141 //_____________________________________________________________________________
142 AliESDMuonTrack& AliESDMuonTrack::operator=(const AliESDMuonTrack& muonTrack)
143 {
144   // 
145   /// Equal operator for a deep copy
146   //
147   if (this == &muonTrack)
148     return *this;
149
150   AliVParticle::operator=(muonTrack); // don't forget to invoke the base class' assignment operator
151   
152   fInverseBendingMomentum = muonTrack.fInverseBendingMomentum; 
153   fThetaX                 = muonTrack.fThetaX;           
154   fThetaY                 = muonTrack.fThetaY;           
155   fZ                      = muonTrack.fZ;                
156   fBendingCoor            = muonTrack.fBendingCoor;      
157   fNonBendingCoor         = muonTrack.fNonBendingCoor;   
158   
159   fInverseBendingMomentumAtDCA = muonTrack.fInverseBendingMomentumAtDCA; 
160   fThetaXAtDCA                 = muonTrack.fThetaXAtDCA;           
161   fThetaYAtDCA                 = muonTrack.fThetaYAtDCA;           
162   fBendingCoorAtDCA            = muonTrack.fBendingCoorAtDCA;      
163   fNonBendingCoorAtDCA         = muonTrack.fNonBendingCoorAtDCA;   
164   
165   fInverseBendingMomentumUncorrected = muonTrack.fInverseBendingMomentumUncorrected; 
166   fThetaXUncorrected                 = muonTrack.fThetaXUncorrected;           
167   fThetaYUncorrected                 = muonTrack.fThetaYUncorrected;           
168   fZUncorrected                      = muonTrack.fZUncorrected;                
169   fBendingCoorUncorrected            = muonTrack.fBendingCoorUncorrected;      
170   fNonBendingCoorUncorrected         = muonTrack.fNonBendingCoorUncorrected;   
171   
172   for (Int_t i = 0; i < 15; i++) fCovariances[i] = muonTrack.fCovariances[i];
173   
174   fRAtAbsorberEnd            = muonTrack.fRAtAbsorberEnd;
175   
176   fChi2                   = muonTrack.fChi2;             
177   fNHit                   = muonTrack.fNHit; 
178
179   fLocalTrigger           = muonTrack.fLocalTrigger;  
180   fX1Pattern              = muonTrack.fX1Pattern;  
181   fY1Pattern              = muonTrack.fY1Pattern;  
182   fX2Pattern              = muonTrack.fX2Pattern;  
183   fY2Pattern              = muonTrack.fY2Pattern;  
184   fX3Pattern              = muonTrack.fX3Pattern;  
185   fY3Pattern              = muonTrack.fY3Pattern;  
186   fX4Pattern              = muonTrack.fX4Pattern;  
187   fY4Pattern              = muonTrack.fY4Pattern;  
188   fChi2MatchTrigger       = muonTrack.fChi2MatchTrigger; 
189
190   fHitsPatternInTrigCh    = muonTrack.fHitsPatternInTrigCh;
191  
192   fMuonClusterMap         = muonTrack.fMuonClusterMap;
193
194   fLabel                  = muonTrack.fLabel;
195   
196   fESDEvent               = muonTrack.fESDEvent;
197
198   // necessary to make a copy of the objects and not only the pointers in TClonesArray
199   delete fClusters;
200   if (muonTrack.fClusters) {
201     fClusters = new TClonesArray("AliESDMuonCluster",muonTrack.fClusters->GetEntriesFast());
202     AliESDMuonCluster *cluster = (AliESDMuonCluster*) muonTrack.fClusters->First();
203     while (cluster) {
204       new ((*fClusters)[fClusters->GetEntriesFast()]) AliESDMuonCluster(*cluster);
205       cluster = (AliESDMuonCluster*) muonTrack.fClusters->After(cluster);
206     }
207   } else fClusters = 0x0;
208   
209   return *this;
210 }
211
212 void AliESDMuonTrack::Copy(TObject &obj) const {
213   
214   /// This overwrites the virtual TOBject::Copy()
215   /// to allow run time copying without casting
216   /// in AliESDEvent
217
218   if(this==&obj)return;
219   AliESDMuonTrack *robj = dynamic_cast<AliESDMuonTrack*>(&obj);
220   if(!robj)return; // not an AliESDMuonTrack
221   *robj = *this;
222
223 }
224
225
226 //__________________________________________________________________________
227 AliESDMuonTrack::~AliESDMuonTrack()
228 {
229   /// Destructor
230   delete fClusters;
231 }
232
233 //__________________________________________________________________________
234 void AliESDMuonTrack::Clear(Option_t* opt)
235 {
236   /// Clear arrays
237   if (opt && opt[0] == 'C') {
238     if (fClusters) fClusters->Clear("C");
239   } else {
240     delete fClusters;
241     fClusters = 0x0;
242   }
243 }
244
245 //__________________________________________________________________________
246 void AliESDMuonTrack::Reset()
247 {
248   /// Reset to default values
249   SetUniqueID(0);
250   fInverseBendingMomentum = FLT_MAX;
251   fThetaX = 0.;
252   fThetaY = 0.;
253   fZ = 0.;
254   fBendingCoor = 0.;
255   fNonBendingCoor = 0.;
256   fInverseBendingMomentumAtDCA = FLT_MAX;
257   fThetaXAtDCA = 0.;
258   fThetaYAtDCA = 0.;
259   fBendingCoorAtDCA = 0.;
260   fNonBendingCoorAtDCA = 0.;
261   fInverseBendingMomentumUncorrected = FLT_MAX;
262   fThetaXUncorrected = 0.;
263   fThetaYUncorrected = 0.;
264   fZUncorrected = 0.;
265   fBendingCoorUncorrected = 0.;
266   fNonBendingCoorUncorrected = 0.;
267   fRAtAbsorberEnd = 0.;
268   fChi2 = 0.;
269   fChi2MatchTrigger = 0.;
270   fLocalTrigger = 0;
271   fX1Pattern = 0;
272   fY1Pattern = 0;
273   fX2Pattern = 0;
274   fY2Pattern = 0;
275   fX3Pattern = 0;
276   fY3Pattern = 0;
277   fX4Pattern = 0;
278   fY4Pattern = 0;
279   fMuonClusterMap = 0;
280   fHitsPatternInTrigCh = 0;
281   fNHit = 0;
282   delete fClusters; fClusters = 0x0;
283   for (Int_t i = 0; i < 15; i++) fCovariances[i] = 0.;
284   fLabel = -1;
285   fESDEvent = 0;
286 }
287
288 //_____________________________________________________________________________
289 void AliESDMuonTrack::GetCovariances(TMatrixD& cov) const
290 {
291   /// return covariance matrix of uncorrected parameters
292   cov.ResizeTo(5,5);
293   for (Int_t i = 0; i < 5; i++)
294     for (Int_t j = 0; j <= i; j++)
295       cov(i,j) = cov (j,i) = fCovariances[i*(i+1)/2 + j];
296 }
297
298 //_____________________________________________________________________________
299 void AliESDMuonTrack::SetCovariances(const TMatrixD& cov)
300 {
301   /// set reduced covariance matrix of uncorrected parameters
302   for (Int_t i = 0; i < 5; i++)
303     for (Int_t j = 0; j <= i; j++)
304       fCovariances[i*(i+1)/2 + j] = cov(i,j);
305
306 }
307
308 //_____________________________________________________________________________
309 void AliESDMuonTrack::GetCovarianceXYZPxPyPz(Double_t cov[21]) const
310 {
311   /// return reduced covariance matrix of uncorrected parameters in (X,Y,Z,Px,Py,Pz) coordinate system
312   /// 
313   /// - Cov(x,x) ... :   cov[0]
314   /// - Cov(y,x) ... :   cov[1]  cov[2]
315   /// - Cov(z,x) ... :   cov[3]  cov[4]  cov[5]
316   /// - Cov(px,x)... :   cov[6]  cov[7]  cov[8]  cov[9]
317   /// - Cov(py,x)... :   cov[10] cov[11] cov[12] cov[13] cov[14]
318   /// - Cov(pz,x)... :   cov[15] cov[16] cov[17] cov[18] cov[19] cov[20]
319   ///
320   /// Get ESD covariance matrix into a TMatrixD
321   TMatrixD covESD(5,5);
322   GetCovariances(covESD);
323
324   // compute Jacobian to change the coordinate system
325   // from (X,thetaX,Y,thetaY,c/pYZ) to (X,Y,Z,pX,pY,pZ)
326   Double_t tanThetaX = TMath::Tan(fThetaXUncorrected);
327   Double_t tanThetaY = TMath::Tan(fThetaYUncorrected);
328   Double_t cosThetaX2 = TMath::Cos(fThetaXUncorrected) * TMath::Cos(fThetaXUncorrected);
329   Double_t cosThetaY2 = TMath::Cos(fThetaYUncorrected) * TMath::Cos(fThetaYUncorrected);
330   Double_t pZ = PzUncorrected();
331   Double_t dpZdthetaY = - fInverseBendingMomentumUncorrected * fInverseBendingMomentumUncorrected *
332                           pZ * pZ * pZ * tanThetaY / cosThetaY2;
333   Double_t dpZdinvpYZ = (fInverseBendingMomentumUncorrected != 0.) ? - pZ / fInverseBendingMomentumUncorrected : - FLT_MAX;
334   TMatrixD jacob(6,5);
335   jacob.Zero();
336   jacob(0,0) = 1.;
337   jacob(1,2) = 1.;
338   jacob(3,1) = pZ / cosThetaX2;
339   jacob(3,3) = dpZdthetaY * tanThetaX;
340   jacob(3,4) = dpZdinvpYZ * tanThetaX;
341   jacob(4,3) = dpZdthetaY * tanThetaY + pZ / cosThetaY2;
342   jacob(4,4) = dpZdinvpYZ * tanThetaY;
343   jacob(5,3) = dpZdthetaY;
344   jacob(5,4) = dpZdinvpYZ;
345   
346   // compute covariance matrix in AOD coordinate system
347   TMatrixD tmp(covESD,TMatrixD::kMultTranspose,jacob);
348   TMatrixD covAOD(jacob,TMatrixD::kMult,tmp);
349   
350   // Get AOD covariance matrix into co[21]
351   for (Int_t i = 0; i < 6; i++)
352     for (Int_t j = 0; j <= i; j++)
353       cov[i*(i+1)/2 + j] = covAOD(i,j);
354   
355 }
356
357 //_____________________________________________________________________________
358 Double_t AliESDMuonTrack::Px() const
359 {
360   /// return p_x from track parameters
361   Double_t nonBendingSlope = TMath::Tan(fThetaX);
362   Double_t bendingSlope    = TMath::Tan(fThetaY);
363   Double_t pYZ = (fInverseBendingMomentum != 0.) ? TMath::Abs(1. / fInverseBendingMomentum) : - FLT_MAX;
364   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
365   return pZ * nonBendingSlope;
366 }
367
368 //_____________________________________________________________________________
369 Double_t AliESDMuonTrack::Py() const
370 {
371   /// return p_y from track parameters
372   Double_t bendingSlope = TMath::Tan(fThetaY);
373   Double_t pYZ = (fInverseBendingMomentum != 0.) ? TMath::Abs(1. / fInverseBendingMomentum) : - FLT_MAX;
374   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
375   return pZ * bendingSlope;
376 }
377
378 //_____________________________________________________________________________
379 Double_t AliESDMuonTrack::Pz() const
380 {
381   /// return p_z from track parameters
382   Double_t bendingSlope = TMath::Tan(fThetaY);
383   Double_t pYZ = (fInverseBendingMomentum != 0.) ? TMath::Abs(1. / fInverseBendingMomentum) : - FLT_MAX;
384   return -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
385 }
386
387 //_____________________________________________________________________________
388 Double_t AliESDMuonTrack::P() const
389 {
390   /// return p from track parameters
391   Double_t nonBendingSlope = TMath::Tan(fThetaX);
392   Double_t bendingSlope    = TMath::Tan(fThetaY);
393   Double_t pYZ = (fInverseBendingMomentum != 0.) ? TMath::Abs(1. / fInverseBendingMomentum) : - FLT_MAX;
394   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
395   return -pZ * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
396 }
397
398 //_____________________________________________________________________________
399 void AliESDMuonTrack::LorentzP(TLorentzVector& vP) const
400 {
401   /// return Lorentz momentum vector from track parameters
402   Double_t muonMass = M();
403   Double_t nonBendingSlope = TMath::Tan(fThetaX);
404   Double_t bendingSlope    = TMath::Tan(fThetaY);
405   Double_t pYZ = (fInverseBendingMomentum != 0.) ? TMath::Abs(1. / fInverseBendingMomentum) : - FLT_MAX;
406   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
407   Double_t pX  = pZ * nonBendingSlope;
408   Double_t pY  = pZ * bendingSlope;
409   Double_t e   = TMath::Sqrt(muonMass*muonMass + pX*pX + pY*pY + pZ*pZ);
410   vP.SetPxPyPzE(pX, pY, pZ, e);
411 }
412
413 //_____________________________________________________________________________
414 Double_t AliESDMuonTrack::PxAtDCA() const
415 {
416   /// return p_x from track parameters
417   Double_t nonBendingSlope = TMath::Tan(fThetaXAtDCA);
418   Double_t bendingSlope    = TMath::Tan(fThetaYAtDCA);
419   Double_t pYZ = (fInverseBendingMomentumAtDCA != 0.) ? TMath::Abs(1. / fInverseBendingMomentumAtDCA) : - FLT_MAX;
420   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
421   return pZ * nonBendingSlope;
422 }
423
424 //_____________________________________________________________________________
425 Double_t AliESDMuonTrack::PyAtDCA() const
426 {
427   /// return p_y from track parameters
428   Double_t bendingSlope = TMath::Tan(fThetaYAtDCA);
429   Double_t pYZ = (fInverseBendingMomentumAtDCA != 0.) ? TMath::Abs(1. / fInverseBendingMomentumAtDCA) : - FLT_MAX;
430   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
431   return pZ * bendingSlope;
432 }
433
434 //_____________________________________________________________________________
435 Double_t AliESDMuonTrack::PzAtDCA() const
436 {
437   /// return p_z from track parameters
438   Double_t bendingSlope = TMath::Tan(fThetaYAtDCA);
439   Double_t pYZ = (fInverseBendingMomentumAtDCA != 0.) ? TMath::Abs(1. / fInverseBendingMomentumAtDCA) : - FLT_MAX;
440   return -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
441 }
442
443 //_____________________________________________________________________________
444 Double_t AliESDMuonTrack::PAtDCA() const
445 {
446   /// return p from track parameters
447   Double_t nonBendingSlope = TMath::Tan(fThetaXAtDCA);
448   Double_t bendingSlope    = TMath::Tan(fThetaYAtDCA);
449   Double_t pYZ = (fInverseBendingMomentumAtDCA != 0.) ? TMath::Abs(1. / fInverseBendingMomentumAtDCA) : - FLT_MAX;
450   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
451   return -pZ * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
452 }
453
454 //_____________________________________________________________________________
455 void AliESDMuonTrack::LorentzPAtDCA(TLorentzVector& vP) const
456 {
457   /// return Lorentz momentum vector from track parameters
458   Double_t muonMass = M();
459   Double_t nonBendingSlope = TMath::Tan(fThetaXAtDCA);
460   Double_t bendingSlope    = TMath::Tan(fThetaYAtDCA);
461   Double_t pYZ = (fInverseBendingMomentumAtDCA != 0.) ? TMath::Abs(1. / fInverseBendingMomentumAtDCA) : - FLT_MAX;
462   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
463   Double_t pX  = pZ * nonBendingSlope;
464   Double_t pY  = pZ * bendingSlope;
465   Double_t e   = TMath::Sqrt(muonMass*muonMass + pX*pX + pY*pY + pZ*pZ);
466   vP.SetPxPyPzE(pX, pY, pZ, e);
467 }
468
469 //_____________________________________________________________________________
470 Double_t AliESDMuonTrack::PxUncorrected() const
471 {
472   /// return p_x from track parameters
473   Double_t nonBendingSlope = TMath::Tan(fThetaXUncorrected);
474   Double_t bendingSlope    = TMath::Tan(fThetaYUncorrected);
475   Double_t pYZ = (fInverseBendingMomentumUncorrected != 0.) ? TMath::Abs(1. / fInverseBendingMomentumUncorrected) : - FLT_MAX;
476   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
477   return pZ * nonBendingSlope;
478 }
479
480 //_____________________________________________________________________________
481 Double_t AliESDMuonTrack::PyUncorrected() const
482 {
483   /// return p_y from track parameters
484   Double_t bendingSlope = TMath::Tan(fThetaYUncorrected);
485   Double_t pYZ = (fInverseBendingMomentumUncorrected != 0.) ? TMath::Abs(1. / fInverseBendingMomentumUncorrected) : - FLT_MAX;
486   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
487   return pZ * bendingSlope;
488 }
489
490 //_____________________________________________________________________________
491 Double_t AliESDMuonTrack::PzUncorrected() const
492 {
493   /// return p_z from track parameters
494   Double_t bendingSlope = TMath::Tan(fThetaYUncorrected);
495   Double_t pYZ = (fInverseBendingMomentumUncorrected != 0.) ? TMath::Abs(1. / fInverseBendingMomentumUncorrected) : - FLT_MAX;
496   return -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
497 }
498
499 //_____________________________________________________________________________
500 Double_t AliESDMuonTrack::PUncorrected() const
501 {
502   /// return p from track parameters
503   Double_t nonBendingSlope = TMath::Tan(fThetaXUncorrected);
504   Double_t bendingSlope    = TMath::Tan(fThetaYUncorrected);
505   Double_t pYZ = (fInverseBendingMomentumUncorrected != 0.) ? TMath::Abs(1. / fInverseBendingMomentumUncorrected) : - FLT_MAX;
506   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
507   return -pZ * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
508 }
509
510 //_____________________________________________________________________________
511 void AliESDMuonTrack::LorentzPUncorrected(TLorentzVector& vP) const
512 {
513   /// return Lorentz momentum vector from track parameters
514   Double_t muonMass = M();
515   Double_t nonBendingSlope = TMath::Tan(fThetaXUncorrected);
516   Double_t bendingSlope    = TMath::Tan(fThetaYUncorrected);
517   Double_t pYZ = (fInverseBendingMomentumUncorrected != 0.) ? TMath::Abs(1. / fInverseBendingMomentumUncorrected) : - FLT_MAX;
518   Double_t pZ  = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);  // spectro. (z<0)
519   Double_t pX  = pZ * nonBendingSlope;
520   Double_t pY  = pZ * bendingSlope;
521   Double_t e   = TMath::Sqrt(muonMass*muonMass + pX*pX + pY*pY + pZ*pZ);
522   vP.SetPxPyPzE(pX, pY, pZ, e);
523 }
524
525 //_____________________________________________________________________________
526 Int_t AliESDMuonTrack::GetNDF() const
527 {
528   /// return the number of degrees of freedom
529   
530   Int_t ndf = 2 * static_cast<Int_t>(fNHit) - 5;
531   return (ndf > 0) ? ndf : 0;
532 }
533
534 //_____________________________________________________________________________
535 Double_t AliESDMuonTrack::GetNormalizedChi2() const
536 {
537   /// return the chi2 value divided by the number of degrees of freedom
538   
539   Int_t ndf = GetNDF();
540   return (ndf > 0) ? fChi2 / static_cast<Double_t>(ndf) : 0.;
541 }
542
543 //_____________________________________________________________________________
544 Int_t AliESDMuonTrack::GetMatchTrigger() const
545 {
546   ///  backward compatibility after replacing fMatchTrigger by fLocalTrigger
547   ///  - 0 track does not match trigger
548   ///  - 1 track match but does not pass pt cut
549   ///  - 2 track match Low pt cut
550   ///  - 3 track match High pt cut
551
552   if (!LoCircuit()) {
553     return 0;
554   } else if (LoLpt() == 0 && LoHpt() == 0) {
555     return 1;
556   } else if (LoLpt() >  0 && LoHpt() == 0) {
557     return 2;
558   } else {
559     return 3;
560   }
561
562 }
563
564 //_____________________________________________________________________________
565 Bool_t AliESDMuonTrack::MatchTriggerDigits() const
566 {
567   // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
568   
569   Int_t nMatchedChambers = 0;
570   for (Int_t ich=0; ich<4; ich++)
571     if (IsChamberHit(fHitsPatternInTrigCh, 0, ich) &&
572         IsChamberHit(fHitsPatternInTrigCh, 1, ich)) nMatchedChambers++;
573   
574   return (nMatchedChambers >= 2);
575 }
576
577 //_____________________________________________________________________________
578 Int_t AliESDMuonTrack::GetNClusters() const
579 {
580   /// return the number of clusters associated to the track
581   if (!fClusters) return 0;
582   
583   return fClusters->GetEntriesFast();
584 }
585
586 //_____________________________________________________________________________
587 TClonesArray& AliESDMuonTrack::GetClusters() const
588 {
589   /// return the array of clusters associated to the track
590   if (!fClusters) fClusters = new TClonesArray("AliESDMuonCluster",10);
591   
592   return *fClusters;
593 }
594
595 //_____________________________________________________________________________
596 void AliESDMuonTrack::AddCluster(const AliESDMuonCluster &cluster)
597 {
598   /// add a cluster to the TClonesArray of clusters associated to the track
599   if (!fClusters) fClusters = new TClonesArray("AliESDMuonCluster",10);
600   
601   new ((*fClusters)[fClusters->GetEntriesFast()]) AliESDMuonCluster(cluster);
602 }
603
604 //_____________________________________________________________________________
605 Bool_t AliESDMuonTrack::ClustersStored() const
606 {
607   /// return kTRUE if the clusters associated to the track are registered
608   if (GetNClusters() == 0) return kFALSE;
609   
610   return kTRUE;
611 }
612
613 //_____________________________________________________________________________
614 void AliESDMuonTrack::SetFiredChamber(UShort_t& pattern, Int_t cathode, Int_t chamber)
615 {
616   /// Turn on the bit corresponding to fired chameber
617   pattern |= (0x1 << ( 7 - ( 4*cathode + chamber )));
618 }
619
620 //_____________________________________________________________________________
621 void AliESDMuonTrack::AddEffInfo(UShort_t& pattern, Int_t slatOrInfo, EAliTriggerChPatternFlag effType)
622 {
623   /// Add efficiency flag and crossed RPC or info on rejected track
624   pattern |= effType << 8;
625   pattern |= slatOrInfo << 10;
626 }
627
628 //_____________________________________________________________________________
629 Bool_t AliESDMuonTrack::IsChamberHit(UShort_t pattern, Int_t cathode, Int_t chamber)
630
631   /// Check if chamber was was hit
632   return (pattern >> (7 - ( 4*cathode + chamber ))) & 0x1;
633 }
634
635 //_____________________________________________________________________________
636 Int_t AliESDMuonTrack::GetEffFlag(UShort_t pattern)
637 {
638   /// Get Efficiency flag
639   return (pattern >> 8) & 0x03;
640 }
641
642 //_____________________________________________________________________________
643 Int_t AliESDMuonTrack::GetSlatOrInfo(UShort_t pattern) 
644 {
645   /// Getting crossed slat or info
646   return (pattern >> 10) & 0x1F;
647 }