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