]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackExtrap.cxx
fix
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackExtrap.cxx
index 19c34641ebca1ff4d2b2d66a9f82dcb4a36e327e..3ab3ebee54f560ed7d687d10b78107c4d9c46575 100644 (file)
 #include "AliMUONConstants.h"
 #include "AliMUONReconstructor.h"
 
-#include "AliMagF.h" 
+#include "AliMagF.h"
+#include "AliExternalTrackParam.h"
 
-#include <TMath.h>
+#include <TGeoGlobalMagField.h>
 #include <TGeoManager.h>
+#include <TMath.h>
+#include <TDatabasePDG.h>
 
 #include <Riostream.h>
 
@@ -38,7 +41,6 @@
 ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context
 /// \endcond
 
-const AliMagF* AliMUONTrackExtrap::fgkField = 0x0;
 const Double_t AliMUONTrackExtrap::fgkSimpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
 const Double_t AliMUONTrackExtrap::fgkSimpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
       Double_t AliMUONTrackExtrap::fgSimpleBValue = 0.;
@@ -49,26 +51,15 @@ const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.;
 const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002;
 
 //__________________________________________________________________________
-void AliMUONTrackExtrap::SetField(const AliMagF* magField)
+void AliMUONTrackExtrap::SetField()
 {
-  /// set magnetic field
-  
-  // set field map
-  fgkField = magField;
-  if (!fgkField) {
-    cout<<"E-AliMUONTrackExtrap::SetField: fgkField = 0x0"<<endl;
-    return;
-  }
-  
-  // set field on/off flag
-  fgFieldON = (fgkField->Factor() == 0.) ? kFALSE : kTRUE;
-  
-  // set field at the centre of the dipole
-  if (fgFieldON) {
-    Float_t b[3] = {0.,0.,0.}, x[3] = {50.,50.,(Float_t) fgkSimpleBPosition};
-    fgkField->Field(x,b);
-    fgSimpleBValue = (Double_t) b[0];
-  } else fgSimpleBValue = 0.;
+  /// set field on/off flag;  
+  /// set field at the centre of the dipole
+  const Double_t x[3] = {50.,50.,fgkSimpleBPosition};
+  Double_t b[3] = {0.,0.,0.};
+  TGeoGlobalMagField::Instance()->Field(x,b);
+  fgSimpleBValue = b[0];
+  fgFieldON = fgSimpleBValue ? kTRUE : kFALSE;
   
 }
 
@@ -82,12 +73,7 @@ Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingM
   
   if (bendingMomentum == 0.) return 1.e10;
   
-  if (!fgkField) {
-    cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
-    exit(-1);
-  }
-  
-  const Double_t kCorrectionFactor = 0.9; // impact parameter is 10% overestimated
+  const Double_t kCorrectionFactor = 1.1; // impact parameter is 10% underestimated
   
   return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / bendingMomentum);
 }
@@ -103,11 +89,6 @@ AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam)
   
   if (impactParam == 0.) return 1.e10;
   
-  if (!fgkField) {
-    cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
-    exit(-1);
-  }
-  
   const Double_t kCorrectionFactor = 1.1; // bending momentum is 10% underestimated
   
   if (fgFieldON) 
@@ -121,9 +102,9 @@ AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam)
 }
 
 //__________________________________________________________________________
-void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
+void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
 {
-  /// Track parameters (and their covariances if any) linearly extrapolated to the plane at "zEnd".
+  /// Track parameters linearly extrapolated to the plane at "zEnd".
   /// On return, results from the extrapolation are updated in trackParam.
   
   if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
@@ -133,29 +114,43 @@ void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t
   trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
   trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
   trackParam->SetZ(zEnd);
+}
+
+//__________________________________________________________________________
+void AliMUONTrackExtrap::LinearExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
+{
+  /// Track parameters and their covariances linearly extrapolated to the plane at "zEnd".
+  /// On return, results from the extrapolation are updated in trackParam.
   
-  // Update track parameters covariances if any
-  if (trackParam->CovariancesExist()) {
-    TMatrixD paramCov(trackParam->GetCovariances());
-    paramCov(0,0) += dZ * dZ * paramCov(1,1) + 2. * dZ * paramCov(0,1);
-    paramCov(0,1) += dZ * paramCov(1,1);
-    paramCov(1,0) = paramCov(0,1);
-    paramCov(2,2) += dZ * dZ * paramCov(3,3) + 2. * dZ * paramCov(2,3);
-    paramCov(2,3) += dZ * paramCov(3,3);
-    paramCov(3,2) = paramCov(2,3);
-    trackParam->SetCovariances(paramCov);
-    
-    // Update the propagator if required
-    if (updatePropagator) {
-      TMatrixD jacob(5,5);
-      jacob.UnitMatrix();
-      jacob(0,1) = dZ;
-      jacob(2,3) = dZ;
-      trackParam->UpdatePropagator(jacob);
-    }
-    
+  if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
+  
+  // No need to propagate the covariance matrix if it does not exist
+  if (!trackParam->CovariancesExist()) {
+    cout<<"W-AliMUONTrackExtrap::LinearExtrapToZCov: Covariance matrix does not exist"<<endl;
+    // Extrapolate linearly track parameters to "zEnd"
+    LinearExtrapToZ(trackParam,zEnd);
+    return;
   }
   
+  // Compute track parameters
+  Double_t dZ = zEnd - trackParam->GetZ();
+  trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
+  trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
+  trackParam->SetZ(zEnd);
+  
+  // Calculate the jacobian related to the track parameters linear extrapolation to "zEnd"
+  TMatrixD jacob(5,5);
+  jacob.UnitMatrix();
+  jacob(0,1) = dZ;
+  jacob(2,3) = dZ;
+  
+  // Extrapolate track parameter covariances to "zEnd"
+  TMatrixD tmp(trackParam->GetCovariances(),TMatrixD::kMultTranspose,jacob);
+  TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
+  trackParam->SetCovariances(tmp2);
+  
+  // Update the propagator if required
+  if (updatePropagator) trackParam->UpdatePropagator(jacob);
 }
 
 //__________________________________________________________________________
@@ -291,7 +286,7 @@ void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUO
   trackParam->SetNonBendingCoor(v3[0]); // X
   trackParam->SetBendingCoor(v3[1]); // Y
   trackParam->SetZ(v3[2]); // Z
-  Double_t pYZ = v3[6] * TMath::Sqrt(1.0 - v3[3] * v3[3]);
+  Double_t pYZ = v3[6] * TMath::Sqrt((1.-v3[3])*(1.+v3[3]));
   trackParam->SetInverseBendingMomentum(charge/pYZ);
   trackParam->SetBendingSlope(v3[4]/v3[5]);
   trackParam->SetNonBendingSlope(v3[3]/v3[5]);
@@ -306,7 +301,7 @@ void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zE
   if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
   
   if (!fgFieldON) { // linear extrapolation if no magnetic field
-    AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd,updatePropagator);
+    AliMUONTrackExtrap::LinearExtrapToZCov(trackParam,zEnd,updatePropagator);
     return;
   }
   
@@ -336,6 +331,7 @@ void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zE
   TMatrixD jacob(5,5);
   jacob.Zero();
   TMatrixD dParam(5,1);
+  Double_t direction[5] = {-1.,-1.,1.,1.,-1.};
   for (Int_t i=0; i<5; i++) {
     // Skip jacobian calculation for parameters with no associated error
     if (kParamCov(i,i) <= 0.) continue;
@@ -344,7 +340,7 @@ void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zE
     for (Int_t j=0; j<5; j++) {
       if (j==i) {
         dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
-       if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramSave(4,0)); // variation always in the same direction
+       dParam(j,0) *= TMath::Sign(1.,direction[j]*paramSave(j,0)); // variation always in the same direction
       } else dParam(j,0) = 0.;
     }
     
@@ -387,11 +383,6 @@ void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double
   Double_t covCorrSlope = alpha2 * (pathLength * f0 - f1);
   Double_t varSlop = alpha2 * f0;
   
-  // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
-  Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
-  Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
-                            (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
-  
   // Set MCS covariance matrix
   TMatrixD newParamCov(param->GetCovariances());
   // Non bending plane
@@ -400,12 +391,20 @@ void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double
   // Bending plane
   newParamCov(2,2) += varCoor;       newParamCov(2,3) += covCorrSlope;
   newParamCov(3,2) += covCorrSlope;  newParamCov(3,3) += varSlop;
-  // Inverse bending momentum (due to dependences with bending and non bending slopes)
-  newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
-  newParamCov(4,1) += dqPxydSlopeX * varSlop;      newParamCov(1,4) += dqPxydSlopeX * varSlop;
-  newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
-  newParamCov(4,3) += dqPxydSlopeY * varSlop;      newParamCov(3,4) += dqPxydSlopeY * varSlop;
-  newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
+  
+  // Set momentum related covariances if B!=0
+  if (fgFieldON) {
+    // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeY
+    Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
+    Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
+                              (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
+    // Inverse bending momentum (due to dependences with bending and non bending slopes)
+    newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
+    newParamCov(4,1) += dqPxydSlopeX * varSlop;      newParamCov(1,4) += dqPxydSlopeX * varSlop;
+    newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
+    newParamCov(4,3) += dqPxydSlopeY * varSlop;      newParamCov(3,4) += dqPxydSlopeY * varSlop;
+    newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
+  }
   
   // Set new covariances
   param->SetCovariances(newParamCov);
@@ -430,7 +429,7 @@ void AliMUONTrackExtrap::CorrectMCSEffectInAbsorber(AliMUONTrackParam* param,
   
   // Get track parameters and covariances in the Branson plane corrected for magnetic field effect
   ExtrapToZCov(param,zVtx);
-  LinearExtrapToZ(param,zB);
+  LinearExtrapToZCov(param,zB);
   
   // compute track parameters at vertex
   TMatrixD newParam(5,1);
@@ -491,16 +490,21 @@ void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param,
   TMatrixD newParamCov(param->GetCovariances());
   Cov2CovP(param->GetParameters(),newParamCov);
   
-  // Add effects of energy loss fluctuation to covariances
-  newParamCov(4,4) += sigmaELoss2;
-  
   // Compute new parameters corrected for energy loss
+  Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
+  Double_t p = param->P();
+  Double_t e = TMath::Sqrt(p*p + muMass*muMass);
+  Double_t eCorr = e + eLoss;
+  Double_t pCorr = TMath::Sqrt(eCorr*eCorr - muMass*muMass);
   Double_t nonBendingSlope = param->GetNonBendingSlope();
   Double_t bendingSlope = param->GetBendingSlope();
-  param->SetInverseBendingMomentum(param->GetCharge() / (param->P() + eLoss) *
+  param->SetInverseBendingMomentum(param->GetCharge() / pCorr *
                                   TMath::Sqrt(1.0 + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope) /
                                   TMath::Sqrt(1.0 + bendingSlope*bendingSlope));
   
+  // Add effects of energy loss fluctuation to covariances
+  newParamCov(4,4) += eCorr * eCorr / pCorr / pCorr * sigmaELoss2;
+  
   // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
   CovP2Cov(param->GetParameters(),newParamCov);
   
@@ -664,11 +668,6 @@ void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Dou
   Double_t varSlop     = theta02;
   Double_t covCorrSlope = pathLength * theta02 / 2.;
   
-  // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
-  Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
-  Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
-                           (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
-  
   // Set MCS covariance matrix
   TMatrixD newParamCov(param->GetCovariances());
   // Non bending plane
@@ -677,12 +676,20 @@ void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Dou
   // Bending plane
   newParamCov(2,2) += varCoor;       newParamCov(2,3) += covCorrSlope;
   newParamCov(3,2) += covCorrSlope;  newParamCov(3,3) += varSlop;
-  // Inverse bending momentum (due to dependences with bending and non bending slopes)
-  newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
-  newParamCov(4,1) += dqPxydSlopeX * varSlop;      newParamCov(1,4) += dqPxydSlopeX * varSlop;
-  newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
-  newParamCov(4,3) += dqPxydSlopeY * varSlop;      newParamCov(3,4) += dqPxydSlopeY * varSlop;
-  newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
+  
+  // Set momentum related covariances if B!=0
+  if (fgFieldON) {
+    // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeY
+    Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
+    Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
+                              (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
+    // Inverse bending momentum (due to dependences with bending and non bending slopes)
+    newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
+    newParamCov(4,1) += dqPxydSlopeX * varSlop;      newParamCov(1,4) += dqPxydSlopeX * varSlop;
+    newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
+    newParamCov(4,3) += dqPxydSlopeY * varSlop;      newParamCov(3,4) += dqPxydSlopeY * varSlop;
+    newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
+  }
   
   // Set new covariances
   param->SetCovariances(newParamCov);
@@ -755,8 +762,8 @@ void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
     trackXYZIn[2] = trackParamIn.GetZ();
   }
   Double_t pTot = trackParam->P();
-  Double_t pathLength, f0, f1, f2, meanRho, deltaP, sigmaDeltaP2;
-  if (!GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,deltaP,sigmaDeltaP2)) {
+  Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2;
+  if (!GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2)) {
     cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Unable to take into account the absorber effects"<<endl;
     if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
     else ExtrapToZ(trackParam,zVtx);
@@ -769,10 +776,10 @@ void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
     if (correctForEnergyLoss) {
       
       // Correct for multiple scattering and energy loss
-      CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
+      CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
       CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
                                 trackXYZIn[2], pathLength, f0, f1, f2);
-      CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
+      CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
       
     } else {
       
@@ -786,10 +793,10 @@ void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
     if (correctForEnergyLoss) {
       
       // Correct for energy loss add multiple scattering dispersion in covariance matrix
-      CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
+      CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
       AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
       ExtrapToZCov(trackParam, trackXYZIn[2]);
-      CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
+      CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
       ExtrapToZCov(trackParam, zVtx);
       
     } else {
@@ -866,7 +873,13 @@ Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackPar
   Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2;
   GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2);
   
-  return totalELoss;
+  // total momentum corrected for energy loss
+  Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
+  Double_t e = TMath::Sqrt(pTot*pTot + muMass*muMass);
+  Double_t eCorr = e + totalELoss;
+  Double_t pTotCorr = TMath::Sqrt(eCorr*eCorr - muMass*muMass);
+  
+  return pTotCorr - pTot;
 }
 
 //__________________________________________________________________________
@@ -874,19 +887,14 @@ Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Do
 {
   /// Returns the mean total momentum energy loss of muon with total momentum='pTotal'
   /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
-  Double_t muMass = 0.105658369; // GeV
-  Double_t eMass = 0.510998918e-3; // GeV
-  Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
-  Double_t i = 9.5e-9; // mean exitation energy per atomic Z (GeV)
-  Double_t p2=pTotal*pTotal;
-  Double_t beta2=p2/(p2 + muMass*muMass);
-  
-  Double_t w = k * rho * pathLength * atomicZ / atomicA / beta2;
+  Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
   
-  if (beta2/(1-beta2)>3.5*3.5)
-    return w * (log(2.*eMass*3.5/(i*atomicZ)) + 0.5*log(beta2/(1-beta2)) - beta2);
+  // mean exitation energy (GeV)
+  Double_t i;
+  if (atomicZ < 13) i = (12. * atomicZ + 7.) * 1.e-9;
+  else i = (9.76 * atomicZ + 58.8 * TMath::Power(atomicZ,-0.19)) * 1.e-9;
   
-  return w * (log(2.*eMass*beta2/(1-beta2)/(i*atomicZ)) - beta2);
+  return pathLength * rho * AliExternalTrackParam::BetheBlochGeant(pTotal/muMass, rho, 0.20, 3.00, i, atomicZ/atomicA);
 }
 
 //__________________________________________________________________________
@@ -894,7 +902,7 @@ Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pa
 {
   /// Returns the total momentum energy loss fluctuation of muon with total momentum='pTotal'
   /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
-  Double_t muMass = 0.105658369; // GeV
+  Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
   //Double_t eMass = 0.510998918e-3; // GeV
   Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
   Double_t p2=pTotal*pTotal;
@@ -1013,7 +1021,7 @@ void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Doub
     xyz[2]    = vect[kiz] + 0.5 * step * vect[kipz];
 
     //cmodif: call gufld (xyz, h) changed into:
-    GetField (xyz, h);
+    TGeoGlobalMagField::Instance()->Field(xyz,h);
  
     h2xy = h[0]*h[0] + h[1]*h[1];
     h[3] = h[2]*h[2]+ h2xy;
@@ -1230,8 +1238,7 @@ void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step,
       rest  = step - tl;
       if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
       //cmodif: call gufld(vout,f) changed into:
-
-      GetField(vout,f);
+      TGeoGlobalMagField::Instance()->Field(vout,f);
 
       // *
       // *             start of integration
@@ -1275,7 +1282,7 @@ void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step,
       xyzt[2] = zt;
 
       //cmodif: call gufld(xyzt,f) changed into:
-      GetField(xyzt,f);
+      TGeoGlobalMagField::Instance()->Field(xyzt,f);
 
       at     = a + secxs[0];
       bt     = b + secys[0];
@@ -1312,7 +1319,7 @@ void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step,
       xyzt[2] = zt;
 
       //cmodif: call gufld(xyzt,f) changed into:
-      GetField(xyzt,f);
+      TGeoGlobalMagField::Instance()->Field(xyzt,f);
 
       z      = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
       y      = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
@@ -1397,21 +1404,3 @@ void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step,
     return;
 }
 
-//___________________________________________________________
-void  AliMUONTrackExtrap::GetField(Double_t *Position, Double_t *Field)
-{
-  /// interface for arguments in double precision (Why ? ChF)
-  Float_t x[3], b[3];
-  
-  x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
-  
-  if (fgkField) fgkField->Field(x,b);
-  else {
-    cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
-    exit(-1);
-  }
-  
-  Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];
-  
-  return;
-}