+void AliESDMuonTrack::Copy(TObject &obj) const {
+
+ // this overwrites the virtual TOBject::Copy()
+ // to allow run time copying without casting
+ // in AliESDEvent
+
+ if(this==&obj)return;
+ AliESDMuonTrack *robj = dynamic_cast<AliESDMuonTrack*>(&obj);
+ if(!robj)return; // not an AliESDMuonTrack
+ *robj = *this;
+
+}
+
+
+//__________________________________________________________________________
+AliESDMuonTrack::~AliESDMuonTrack()
+{
+ /// Destructor
+ delete fClusters;
+}
+
+//__________________________________________________________________________
+void AliESDMuonTrack::Clear(Option_t* opt)
+{
+ /// Clear arrays
+ if (fClusters) fClusters->Clear(opt);
+}
+
+//__________________________________________________________________________
+void AliESDMuonTrack::Reset()
+{
+ /// Reset to default values
+ SetUniqueID(0);
+ fInverseBendingMomentum = FLT_MAX;
+ fThetaX = 0.;
+ fThetaY = 0.;
+ fZ = 0.;
+ fBendingCoor = 0.;
+ fNonBendingCoor = 0.;
+ fInverseBendingMomentumAtDCA = FLT_MAX;
+ fThetaXAtDCA = 0.;
+ fThetaYAtDCA = 0.;
+ fBendingCoorAtDCA = 0.;
+ fNonBendingCoorAtDCA = 0.;
+ fInverseBendingMomentumUncorrected = FLT_MAX;
+ fThetaXUncorrected = 0.;
+ fThetaYUncorrected = 0.;
+ fZUncorrected = 0.;
+ fBendingCoorUncorrected = 0.;
+ fNonBendingCoorUncorrected = 0.;
+ fChi2 = 0.;
+ fChi2MatchTrigger = 0.;
+ fLocalTrigger = 0;
+ fX1Pattern = 0;
+ fY1Pattern = 0;
+ fX2Pattern = 0;
+ fY2Pattern = 0;
+ fX3Pattern = 0;
+ fY3Pattern = 0;
+ fX4Pattern = 0;
+ fY4Pattern = 0;
+ fMuonClusterMap = 0;
+ fHitsPatternInTrigCh = 0;
+ fNHit = 0;
+ delete fClusters; fClusters = 0x0;
+ for (Int_t i = 0; i < 15; i++) fCovariances[i] = 0.;
+}
+
+//_____________________________________________________________________________
+void AliESDMuonTrack::GetCovariances(TMatrixD& cov) const
+{
+ // return covariance matrix of uncorrected parameters
+ cov.ResizeTo(5,5);
+ for (Int_t i = 0; i < 5; i++)
+ for (Int_t j = 0; j <= i; j++)
+ cov(i,j) = cov (j,i) = fCovariances[i*(i+1)/2 + j];
+}
+
+//_____________________________________________________________________________
+void AliESDMuonTrack::SetCovariances(const TMatrixD& cov)
+{
+ // set reduced covariance matrix of uncorrected parameters
+ for (Int_t i = 0; i < 5; i++)
+ for (Int_t j = 0; j <= i; j++)
+ fCovariances[i*(i+1)/2 + j] = cov(i,j);
+
+}
+
+//_____________________________________________________________________________
+void AliESDMuonTrack::GetCovarianceXYZPxPyPz(Double_t cov[21]) const
+{
+ // return reduced covariance matrix of uncorrected parameters in (X,Y,Z,Px,Py,Pz) coordinate system
+ //
+ // Cov(x,x) ... : cov[0]
+ // Cov(y,x) ... : cov[1] cov[2]
+ // Cov(z,x) ... : cov[3] cov[4] cov[5]
+ // Cov(px,x)... : cov[6] cov[7] cov[8] cov[9]
+ // Cov(py,x)... : cov[10] cov[11] cov[12] cov[13] cov[14]
+ // Cov(pz,x)... : cov[15] cov[16] cov[17] cov[18] cov[19] cov[20]
+ //
+ // Get ESD covariance matrix into a TMatrixD
+ TMatrixD covESD(5,5);
+ GetCovariances(covESD);
+
+ // compute Jacobian to change the coordinate system
+ // from (X,thetaX,Y,thetaY,c/pYZ) to (X,Y,Z,pX,pY,pZ)
+ Double_t tanThetaX = TMath::Tan(fThetaXUncorrected);
+ Double_t tanThetaY = TMath::Tan(fThetaYUncorrected);
+ Double_t cosThetaX2 = TMath::Cos(fThetaXUncorrected) * TMath::Cos(fThetaXUncorrected);
+ Double_t cosThetaY2 = TMath::Cos(fThetaYUncorrected) * TMath::Cos(fThetaYUncorrected);
+ Double_t pZ = PzUncorrected();
+ Double_t dpZdthetaY = - fInverseBendingMomentumUncorrected * fInverseBendingMomentumUncorrected *
+ pZ * pZ * pZ * tanThetaY / cosThetaY2;
+ Double_t dpZdinvpYZ = (fInverseBendingMomentumUncorrected != 0.) ? - pZ / fInverseBendingMomentumUncorrected : - FLT_MAX;
+ TMatrixD jacob(6,5);
+ jacob.Zero();
+ jacob(0,0) = 1.;
+ jacob(1,2) = 1.;
+ jacob(3,1) = pZ / cosThetaX2;
+ jacob(3,3) = dpZdthetaY * tanThetaX;
+ jacob(3,4) = dpZdinvpYZ * tanThetaX;
+ jacob(4,3) = dpZdthetaY * tanThetaY + pZ / cosThetaY2;
+ jacob(4,4) = dpZdinvpYZ * tanThetaY;
+ jacob(5,3) = dpZdthetaY;
+ jacob(5,4) = dpZdinvpYZ;
+
+ // compute covariance matrix in AOD coordinate system
+ TMatrixD tmp(covESD,TMatrixD::kMultTranspose,jacob);
+ TMatrixD covAOD(jacob,TMatrixD::kMult,tmp);
+
+ // Get AOD covariance matrix into co[21]
+ for (Int_t i = 0; i < 6; i++)
+ for (Int_t j = 0; j <= i; j++)
+ cov[i*(i+1)/2 + j] = covAOD(i,j);
+
+}
+