]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FASTSIM/AliMUONFastTracking.cxx
Flushing the buffer for debug purposes (R. Preghenella)
[u/mrichter/AliRoot.git] / FASTSIM / AliMUONFastTracking.cxx
index c4e4eb7e8b798698581cf5bb2601d69718c6629b..c38b83e4abf3fd9a17911ea99d8bb7fef114a2c0 100644 (file)
 
 /* $Id$ */
 
-#include "AliMUONFastTracking.h"
-#include "AliMUONFastTrackingEntry.h"
-#include <TMatrixD.h>
-#include <TSpline.h>
-#include <TFile.h>
-#include <TH1.h>
-#include <TH3.h>
-#include <TF1.h>
-#include <TRandom.h>
-#include <stdlib.h>
+//-------------------------------------------------------------------------
+//        Class AliMUONFastTracking 
+//
+//  Manager for the fast simulation of tracking in the muon spectrometer
+//  This class reads the lookup tables containing the parameterization 
+//  of the deltap, deltatheta, deltaphi for different background levels
+//  and provides the related smeared parameters. 
+//  Used by AliFastMuonTrackingEff, AliFastMuonTrackingAcc, 
+//  AliFastMuonTrackingRes. 
+//-------------------------------------------------------------------------
+
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+
 #include <Riostream.h>
+#include <TF1.h>
+#include <TFile.h>
+#include <TH3.h>
+#include <TMath.h>
+#include <TRandom.h>
+#include <TSpline.h>
 
+#include "AliMUONFastTracking.h"
+#include "AliMUONFastTrackingEntry.h"
+
+using std::cout;
+using std::endl;
 ClassImp(AliMUONFastTracking)
 
+
 AliMUONFastTracking* AliMUONFastTracking::fgMUONFastTracking=NULL;
 
 static Double_t FitP(Double_t *x, Double_t *par){
+// Fit function
     Double_t dx = x[0] - par[0];
     Double_t dx2 = x[0] - par[4];
     Double_t sigma = par[1] * ( 1 + par[2] * dx);
@@ -44,9 +60,34 @@ static Double_t FitP(Double_t *x, Double_t *par){
     Double_t fasymm = TMath::Exp(-0.5 * dx * dx / (sigma * sigma));
     Double_t sigma2 = par[1] * par[5];
     Double_t fgauss = TMath::Exp(-0.5 * dx2 * dx2 / (sigma2 * sigma2));
-    return TMath::Abs(fasymm + par[3] * fgauss);
+    Double_t value = fasymm + par[3] * fgauss; 
+    return TMath::Abs(value);
 } 
 
+AliMUONFastTracking::AliMUONFastTracking(const AliMUONFastTracking & ft):
+    TObject(),
+    fNbinp(10),
+    fPmin(0.),
+    fPmax(200.),
+    fDeltaP((fPmax-fPmin)/fNbinp),
+    fNbintheta(10),
+    fThetamin(2.),
+    fThetamax(9.),
+    fDeltaTheta((fThetamax-fThetamin)/fNbintheta),
+    fNbinphi(10),
+    fPhimin(-180.),
+    fPhimax(180.),
+    fDeltaPhi((fPhimax-fPhimin)/fNbinphi),
+    fPrintLevel(1),
+    fBkg(0.),
+    fSpline(0),
+    fClusterFinder(kOld)                                                                        
+{
+// Copy constructor
+    ft.Copy(*this);
+}
+
+
 AliMUONFastTracking* AliMUONFastTracking::Instance()
 { 
 // Set random number generator 
@@ -58,35 +99,34 @@ AliMUONFastTracking* AliMUONFastTracking::Instance()
     }
 }
 
-AliMUONFastTracking::AliMUONFastTracking() 
+AliMUONFastTracking::AliMUONFastTracking():
+    fNbinp(10),
+    fPmin(0.),
+    fPmax(200.),
+    fDeltaP((fPmax-fPmin)/fNbinp),
+    fNbintheta(10),
+    fThetamin(2.),
+    fThetamax(9.),
+    fDeltaTheta((fThetamax-fThetamin)/fNbintheta),
+    fNbinphi(10),
+    fPhimin(-180.),
+    fPhimax(180.),
+    fDeltaPhi((fPhimax-fPhimin)/fNbinphi),
+    fPrintLevel(1),
+    fBkg(0.),
+    fSpline(0),
+    fClusterFinder(kOld)
 {
-//    SetBackground();
-    
-    fPrintLevel = 1;  
-    // read binning; temporarily put by hand
-    Float_t pmin = 0, pmax = 200;
-    Int_t   nbinp = 10;
-    Float_t thetamin = 2, thetamax = 9;
-    Int_t   nbintheta=10;
-    Float_t phimin = -180, phimax =180;
-    Int_t   nbinphi=10;
-    //--------------------------------------
-
-    fNbinp = nbinp;
-    fPmin  = pmin;
-    fPmax  = pmax;
-    
-    fNbintheta = nbintheta;
-    fThetamin  = thetamin;
-    fThetamax  = thetamax;
-    
-    fNbinphi = nbinphi;
-    fPhimin  = phimin;
-    fPhimax  = phimax;
-    
-    fDeltaP     = (fPmax-fPmin)/fNbinp;
-    fDeltaTheta = (fThetamax-fThetamin)/fNbintheta;
-    fDeltaPhi   = (fPhimax-fPhimin)/fNbinphi;
+//
+// constructor
+//
+  for (Int_t i = 0; i<20;i++) {
+    for (Int_t j = 0; j<20; j++) {
+      for (Int_t k = 0; k<20; k++) {
+       fFitp[i][j][k] = 0x0;
+      }
+    }
+  }
 }
 
 void AliMUONFastTracking::Init(Float_t bkg)
@@ -106,32 +146,37 @@ void AliMUONFastTracking::Init(Float_t bkg)
   }
   
   char filename [100]; 
-  sprintf (filename,"$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT.root"); 
+  if (fClusterFinder==kOld) snprintf (filename, 100, "$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT.root"); 
+  else snprintf (filename, 100, "$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT-AZ.root"); 
+
   TFile *file = new TFile(filename); 
   ReadLUT(file);
   SetBackground(bkg);
-  UseSpline(1);
-  fFitp = new TF1("fit1",FitP,-20.,20.,6);
-  fFitp->SetNpx(200);    
+  UseSpline(0);
 }
 
 
 void AliMUONFastTracking::ReadLUT(TFile* file)
 {
+  //
+  // read the lookup tables from file
+  //
   TH3F *heff[5][3], *hacc[5][3], *hmeanp, *hsigmap, *hsigma1p, *hchi2p;
   TH3F *hnormg2, *hmeang2, *hsigmag2, *hmeantheta, *hsigmatheta, *hchi2theta;
   TH3F *hmeanphi, *hsigmaphi, *hchi2phi;
   char tag[40], tag2[40]; 
   
-  const Float_t bkg[4] = {0, 0.5, 1, 2};
+  printf ("Reading parameters from LUT file %s...\n",file->GetName());
+
+  const Float_t kBkg[4] = {0, 0.5, 1, 2};
   for (Int_t ibkg=0; ibkg<4; ibkg++) {
-    sprintf (tag,"BKG%g",bkg[ibkg]); 
+    snprintf (tag, 40, "BKG%g",kBkg[ibkg]); 
     file->cd(tag);
     for (Int_t isplp = 0; isplp<kSplitP; isplp++) { 
       for (Int_t ispltheta = 0; ispltheta<kSplitTheta; ispltheta++) { 
-       sprintf (tag2,"heff[%d][%d]",isplp,ispltheta); 
+       snprintf (tag2, 40, "heff[%d][%d]",isplp,ispltheta); 
        heff[isplp][ispltheta] = (TH3F*)gDirectory->Get(tag2);
-       sprintf (tag2,"hacc[%d][%d]",isplp,ispltheta); 
+       snprintf (tag2, 40, "hacc[%d][%d]",isplp,ispltheta); 
        hacc[isplp][ispltheta] = (TH3F*)gDirectory->Get(tag2);
       }
     }    
@@ -149,7 +194,6 @@ void AliMUONFastTracking::ReadLUT(TFile* file)
     hsigmaphi   = (TH3F*)gDirectory->Get("hsigmaphi");
     hchi2phi    = (TH3F*)gDirectory->Get("hchi2phi");
     
-    printf ("Reading parameters from LUT file %s...\n",file->GetName());
     for (Int_t ip=0; ip<fNbinp ;ip++) {
       for (Int_t itheta=0; itheta<fNbintheta ;itheta++) {
        for (Int_t iphi=0; iphi<fNbinphi ;iphi++) {
@@ -157,42 +201,27 @@ void AliMUONFastTracking::ReadLUT(TFile* file)
          Float_t theta = fThetamin + fDeltaTheta * (itheta + 0.5);
          Float_t phi   = fPhimin   + fDeltaPhi   * (iphi   + 0.5);
          
-         fEntry[ip][itheta][iphi][ibkg]->fP          = p;
-         fEntry[ip][itheta][iphi][ibkg]->fMeanp      = 
-           hmeanp->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fSigmap     = 
-           TMath::Abs(hsigmap->GetBinContent(ip+1,itheta+1,iphi+1));
-         fEntry[ip][itheta][iphi][ibkg]->fSigma1p    = 
-           hsigma1p->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fChi2p      = 
-           hchi2p->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fNormG2     = 
-           hnormg2->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fMeanG2     = 
-           hmeang2->GetBinContent(ip+1,itheta+1,iphi+1);
-         if (ibkg == 0)  fEntry[ip][itheta][iphi][ibkg]->fSigmaG2 = 9999;
-         else fEntry[ip][itheta][iphi][ibkg]->fSigmaG2    = 
-           hsigmag2->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fTheta      = theta;
-         fEntry[ip][itheta][iphi][ibkg]->fMeantheta  = 
-           hmeantheta->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fSigmatheta = 
-           TMath::Abs(hsigmatheta->GetBinContent(ip+1,itheta+1,iphi+1));
-         fEntry[ip][itheta][iphi][ibkg]->fChi2theta  = 
-           hchi2theta->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fPhi        = phi;
-         fEntry[ip][itheta][iphi][ibkg]->fMeanphi    = 
-           hmeanphi->GetBinContent(ip+1,itheta+1,iphi+1);
-         fEntry[ip][itheta][iphi][ibkg]->fSigmaphi   = 
-           TMath::Abs(hsigmaphi->GetBinContent(ip+1,itheta+1,iphi+1));
-         fEntry[ip][itheta][iphi][ibkg]->fChi2phi    = 
-           hchi2phi->GetBinContent(ip+1,itheta+1,iphi+1);
+         fEntry[ip][itheta][iphi][ibkg]->SetP(p);
+         fEntry[ip][itheta][iphi][ibkg]->SetMeanp(hmeanp->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetSigmap(TMath::Abs(hsigmap->GetBinContent(ip+1,itheta+1,iphi+1)));
+         fEntry[ip][itheta][iphi][ibkg]->SetSigma1p(hsigma1p->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetChi2p(hchi2p->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetNormG2(hnormg2->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetMeanG2(hmeang2->GetBinContent(ip+1,itheta+1,iphi+1));
+         if (ibkg == 0)  fEntry[ip][itheta][iphi][ibkg]->SetSigmaG2(9999);
+         else fEntry[ip][itheta][iphi][ibkg]->SetSigmaG2(hsigmag2->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetTheta(theta);
+         fEntry[ip][itheta][iphi][ibkg]->SetMeantheta(hmeantheta->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetSigmatheta(TMath::Abs(hsigmatheta->GetBinContent(ip+1,itheta+1,iphi+1)));
+         fEntry[ip][itheta][iphi][ibkg]->SetChi2theta(hchi2theta->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetPhi(phi);
+         fEntry[ip][itheta][iphi][ibkg]->SetMeanphi(hmeanphi->GetBinContent(ip+1,itheta+1,iphi+1));
+         fEntry[ip][itheta][iphi][ibkg]->SetSigmaphi(TMath::Abs(hsigmaphi->GetBinContent(ip+1,itheta+1,iphi+1)));
+         fEntry[ip][itheta][iphi][ibkg]->SetChi2phi(hchi2phi->GetBinContent(ip+1,itheta+1,iphi+1));
          for (Int_t i=0; i<kSplitP; i++) { 
            for (Int_t j=0; j<kSplitTheta; j++) { 
-             fEntry[ip][itheta][iphi][ibkg]->fAcc[i][j] = 
-               hacc[i][j]->GetBinContent(ip+1,itheta+1,iphi+1);
-             fEntry[ip][itheta][iphi][ibkg]->fEff[i][j] = 
-               heff[i][j]->GetBinContent(ip+1,itheta+1,iphi+1);
+             fEntry[ip][itheta][iphi][ibkg]->SetAcc(i,j,hacc[i][j]->GetBinContent(ip+1,itheta+1,iphi+1));
+             fEntry[ip][itheta][iphi][ibkg]->SetEff(i,j,heff[i][j]->GetBinContent(ip+1,itheta+1,iphi+1));
            }
          }
        } // iphi 
@@ -206,11 +235,11 @@ void AliMUONFastTracking::ReadLUT(TFile* file)
   for (Int_t ip=0; ip< fNbinp; ip++){
     for (Int_t itheta=0; itheta< fNbintheta; itheta++){
       for (Int_t iphi=0; iphi< fNbinphi; iphi++){
-       graph->SetPoint(0,0.5,fEntry[ip][itheta][iphi][1]->fSigmaG2);
-       graph->SetPoint(1,1,fEntry[ip][itheta][iphi][2]->fSigmaG2);
-       graph->SetPoint(2,2,fEntry[ip][itheta][iphi][3]->fSigmaG2);
+       graph->SetPoint(0,0.5,fEntry[ip][itheta][iphi][1]->GetSigmaG2());
+       graph->SetPoint(1,1,fEntry[ip][itheta][iphi][2]->GetSigmaG2());
+       graph->SetPoint(2,2,fEntry[ip][itheta][iphi][3]->GetSigmaG2());
        graph->Fit("f","q"); 
-       fEntry[ip][itheta][iphi][0]->fSigmaG2 = f->Eval(0); 
+       fEntry[ip][itheta][iphi][0]->SetSigmaG2(f->Eval(0)); 
       }
     }
   }
@@ -222,8 +251,11 @@ void AliMUONFastTracking::ReadLUT(TFile* file)
 void AliMUONFastTracking::GetBinning(Int_t &nbinp, Float_t &pmin, Float_t &pmax,
                                     Int_t &nbintheta, Float_t &thetamin, 
                                     Float_t &thetamax,
-                                    Int_t &nbinphi, Float_t &phimin, Float_t &phimax)
+                                    Int_t &nbinphi, Float_t &phimin, Float_t &phimax) const 
 {
+  //
+  // gets the binning for the discrete parametrizations in the lookup table
+  //
     nbinp = fNbinp;
     pmin  = fPmin;
     pmax  = fPmax;
@@ -238,42 +270,33 @@ void AliMUONFastTracking::GetBinning(Int_t &nbinp, Float_t &pmin, Float_t &pmax,
 
 void AliMUONFastTracking::GetIpIthetaIphi(Float_t p, Float_t theta, Float_t phi, 
                                          Int_t charge, Int_t &ip, Int_t &itheta, 
-                                         Int_t &iphi)
+                                         Int_t &iphi) const
 {
+  //
+  // gets the id of the cells in the LUT for a given (p,theta,phi, charge)
+  //
     if (charge < 0) phi = -phi;
     ip           = Int_t (( p - fPmin ) / fDeltaP);
     itheta       = Int_t (( theta - fThetamin ) / fDeltaTheta);
     iphi         = Int_t (( phi - fPhimin ) / fDeltaPhi);
     
-    if (ip< 0) {
-       printf ("Warning: ip= %d. Set to 0\n",ip);
-       ip = 0;
-    } 
-    if (ip>= fNbinp) {
-      //       printf ("Warning: ip = %d. Set to %d\n",ip,fNbinp-1);
-       ip = fNbinp-1;
-    } 
-    if (itheta< 0) {
-      //       printf ("Warning: itheta= %d. Set to 0\n",itheta);
-       itheta = 0;
-    } 
-    if (itheta>= fNbintheta) {
-      //       printf ("Warning: itheta = %d. Set to %d\n",itheta,fNbintheta-1);
-       itheta = fNbintheta-1;
-    } 
     
-    if (iphi< 0) {
-       printf ("Warning: iphi= %d. Set to 0\n",iphi);
-       iphi = 0;
-    } 
-    if (iphi>= fNbinphi) {
-       printf ("Warning: iphi = %d. Set to %d\n",iphi,fNbinphi-1);
-       iphi = fNbinphi-1;
-    } 
+    if (ip< 0)         ip = 0;
+    if (ip>= fNbinp) ip = fNbinp-1;
+    if (itheta< 0) itheta = 0;
+    if (itheta>= fNbintheta) itheta = fNbintheta-1;
+    
+    if (iphi< 0) iphi = 0;
+    if (iphi>= fNbinphi) iphi = fNbinphi-1;
 }
 
 void AliMUONFastTracking::GetSplit(Int_t ip, Int_t itheta, 
-                                  Int_t &nSplitP, Int_t &nSplitTheta) { 
+                                  Int_t &nSplitP, Int_t &nSplitTheta) const 
+{ 
+  //
+  // the first cell is splitted in more bins for theta and momentum
+  // parameterizations. Get the number of divisions for the splitted bins
+  //
   if (ip==0) nSplitP = 5; 
   else nSplitP = 2; 
   if (itheta==0) nSplitTheta = 3; 
@@ -282,6 +305,9 @@ void AliMUONFastTracking::GetSplit(Int_t ip, Int_t itheta,
 
 Float_t AliMUONFastTracking::Efficiency(Float_t p,   Float_t theta, 
                                        Float_t phi, Int_t charge){
+  //
+  // gets the tracking efficiency
+  //
   Int_t ip=0, itheta=0, iphi=0;
   GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
   Int_t nSplitP, nSplitTheta; 
@@ -291,12 +317,15 @@ Float_t AliMUONFastTracking::Efficiency(Float_t p,   Float_t theta,
   Int_t ibinp  = Int_t(nSplitP*(dp - fDeltaP * Int_t(dp / fDeltaP))/fDeltaP); 
   Float_t dtheta = theta - fThetamin;
   Int_t ibintheta  = Int_t(nSplitTheta*(dtheta - fDeltaTheta * Int_t(dtheta / fDeltaTheta))/fDeltaTheta); 
-  Float_t eff = fCurrentEntry[ip][itheta][iphi]->fEff[ibinp][ibintheta];
+  Float_t eff = fCurrentEntry[ip][itheta][iphi]->GetEff(ibinp,ibintheta);
   return eff;   
 }
 
 Float_t AliMUONFastTracking::Acceptance(Float_t p,   Float_t theta, 
                                        Float_t phi, Int_t charge){
+  //
+  // gets the geometrical acceptance
+  //
   if (theta<fThetamin || theta>fThetamax) return 0; 
   
   Int_t ip=0, itheta=0, iphi=0;
@@ -309,26 +338,32 @@ Float_t AliMUONFastTracking::Acceptance(Float_t p,   Float_t theta,
   Int_t ibinp  = Int_t(nSplitP*(dp - fDeltaP * Int_t(dp / fDeltaP))/fDeltaP); 
   Float_t dtheta = theta - fThetamin;
   Int_t ibintheta  = Int_t(nSplitTheta*(dtheta - fDeltaTheta * Int_t(dtheta / fDeltaTheta))/fDeltaTheta); 
-  Float_t acc = fCurrentEntry[ip][itheta][iphi]->fAcc[ibinp][ibintheta];
+  Float_t acc = fCurrentEntry[ip][itheta][iphi]->GetAcc(ibinp,ibintheta);
   return acc;   
 }
 
 Float_t AliMUONFastTracking::MeanP(Float_t p,   Float_t theta, 
-                           Float_t phi, Int_t charge)
+                           Float_t phi, Int_t charge) const
 {
+  //
+  // gets the mean value of the prec-pgen distribution
+  //
     Int_t ip=0, itheta=0, iphi=0;
     GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
-    return fCurrentEntry[ip][itheta][iphi]->fMeanp;
+    return fCurrentEntry[ip][itheta][iphi]->GetMeanp();
 }
 
 Float_t AliMUONFastTracking::SigmaP(Float_t p,   Float_t theta, 
-                                   Float_t phi, Int_t charge)
+                                   Float_t phi, Int_t charge) const
 {
+  //
+  // gets the width of the prec-pgen distribution
+  //
     Int_t ip=0, itheta=0, iphi=0;
     Int_t index;
     GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
     // central value and corrections with spline 
-    Float_t sigmap = fCurrentEntry[ip][itheta][iphi]->fSigmap;
+    Float_t sigmap = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
     if (!fSpline) return sigmap;
     // corrections vs p, theta, phi 
     index = iphi + fNbinphi * itheta;
@@ -336,9 +371,9 @@ Float_t AliMUONFastTracking::SigmaP(Float_t p,   Float_t theta,
     Float_t frac1 = fSplineSigmap[index][0]->Eval(p)/sigmap; 
     
     if (p>fPmax-fDeltaP/2.) {
-       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->fSigmap;
-       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->fSigmap;
-       Float_t s3 = fCurrentEntry[fNbinp-3][itheta][iphi]->fSigmap;
+       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmap();
+       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmap();
+       Float_t s3 = fCurrentEntry[fNbinp-3][itheta][iphi]->GetSigmap();
        Float_t p1  = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
        Float_t p2  = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
        Float_t p3  = fDeltaP * (fNbinp - 3 + 0.5) + fPmin;
@@ -367,89 +402,111 @@ Float_t AliMUONFastTracking::SigmaP(Float_t p,   Float_t theta,
 }
 
 Float_t AliMUONFastTracking::Sigma1P(Float_t p,   Float_t theta, 
-                           Float_t phi, Int_t charge)
+                           Float_t phi, Int_t charge) const
 {
+  //
+  // gets the width correction of the prec-pgen distribution (see FitP)
+  //
     Int_t ip=0, itheta=0, iphi=0;
     GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
     if (p>fPmax) {
        // linear extrapolation of sigmap for p out of range 
-       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->fSigma1p;
-       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->fSigma1p;
+       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigma1p();
+       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigma1p();
        Float_t p1  = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
        Float_t p2  = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
        Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) ); 
        return sigma;
     }
-    else return fCurrentEntry[ip][itheta][iphi]->fSigma1p;
+    else return fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
 }
 
 Float_t AliMUONFastTracking::NormG2(Float_t p,   Float_t theta, 
-                                   Float_t phi, Int_t charge)
+                                   Float_t phi, Int_t charge) const
 {
+  //
+  // gets the relative normalization of the background
+  // (gaussian) component in the prec-pgen distribution
+  //
     Int_t ip=0, itheta=0, iphi=0;
     GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
     if (p>fPmax) {
        // linear extrapolation of sigmap for p out of range 
-       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->fNormG2;
-       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->fNormG2;
+       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetNormG2();
+       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetNormG2();
        Float_t p1  = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
        Float_t p2  = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
        Float_t norm = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) ); 
        return norm;
     }
-    else return fCurrentEntry[ip][itheta][iphi]->fNormG2;
+    else return fCurrentEntry[ip][itheta][iphi]->GetNormG2();
 }
 
 Float_t AliMUONFastTracking::MeanG2(Float_t p,   Float_t theta, 
-                                   Float_t phi, Int_t charge)
+                                   Float_t phi, Int_t charge) const
 {
+  //
+  // gets the mean value of the background
+  // (gaussian) component in the prec-pgen distribution
+  //
     Int_t ip=0, itheta=0, iphi=0;
     GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
     if (p>fPmax) {
        // linear extrapolation of sigmap for p out of range 
-       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->fMeanG2;
-       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->fMeanG2;
+       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetMeanG2();
+       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetMeanG2();
        Float_t p1  = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
        Float_t p2  = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
        Float_t norm = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) ); 
        return norm;
     }
-    else return fCurrentEntry[ip][itheta][iphi]->fMeanG2;
+    else return fCurrentEntry[ip][itheta][iphi]->GetMeanG2();
 }
 
 Float_t AliMUONFastTracking::SigmaG2(Float_t p,   Float_t theta, 
-                                    Float_t phi, Int_t charge)
+                                    Float_t phi, Int_t charge) const
 {
+  //
+  // gets the width of the background
+  // (gaussian) component in the prec-pgen distribution
+  //
     Int_t ip=0, itheta=0, iphi=0;
     GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
     if (p>fPmax) {
        // linear extrapolation of sigmap for p out of range 
-       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->fSigmaG2;
-       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->fSigmaG2;
+       Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmaG2();
+       Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmaG2();
        Float_t p1  = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
        Float_t p2  = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
        Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) ); 
        return sigma;
     }
-    else return fCurrentEntry[ip][itheta][iphi]->fSigmaG2;
+    else return fCurrentEntry[ip][itheta][iphi]->GetSigmaG2();
 }
 
 
 Float_t AliMUONFastTracking::MeanTheta(Float_t p,   Float_t theta, 
-                                      Float_t phi, Int_t charge)
+                                      Float_t phi, Int_t charge) const
 {
+  //
+  // gets the mean value of the thetarec-thetagen distribution
+  //
     Int_t ip=0, itheta=0, iphi=0;
     GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
-    return fCurrentEntry[ip][itheta][iphi]->fMeantheta;
+    return fCurrentEntry[ip][itheta][iphi]->GetMeantheta();
 }
 
-Float_t AliMUONFastTracking::SigmaTheta(Float_t p,   Float_t theta, 
-                           Float_t phi, Int_t charge){
+Float_t AliMUONFastTracking::SigmaTheta(Float_t p,   Float_t theta,  
+                           Float_t phi, Int_t charge) const
+{
+  //
+  // gets the width of the thetarec-thetagen distribution
+  //
   Int_t ip=0, itheta=0, iphi=0;
   Int_t index;
   GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
   // central value and corrections with spline 
-  Float_t sigmatheta = fCurrentEntry[ip][itheta][iphi]->fSigmatheta;
+  Float_t sigmatheta = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
   if (!fSpline) return sigmatheta;
   // corrections vs p, theta, phi 
   index = iphi + fNbinphi * itheta;
@@ -457,8 +514,8 @@ Float_t AliMUONFastTracking::SigmaTheta(Float_t p,   Float_t theta,
   Float_t frac1 = fSplineSigmatheta[index][0]->Eval(p)/sigmatheta; 
   if (p>fPmax-fDeltaP/2.) {
     // linear extrapolation of sigmap for p out of range 
-    Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->fSigmatheta;
-    Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->fSigmatheta;
+    Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmatheta();
+    Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmatheta();
     Float_t p1  = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
     Float_t p2  = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
     Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) ); 
@@ -479,27 +536,34 @@ Float_t AliMUONFastTracking::SigmaTheta(Float_t p,   Float_t theta,
 
 
 Float_t AliMUONFastTracking::MeanPhi(Float_t p,   Float_t theta, 
-                           Float_t phi, Int_t charge){
+                           Float_t phi, Int_t charge) const
+{
+  //
+  // gets the mean value of the phirec-phigen distribution
+  //
   Int_t ip=0, itheta=0, iphi=0;
   GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
-  return fCurrentEntry[ip][itheta][iphi]->fMeanphi;
+  return fCurrentEntry[ip][itheta][iphi]->GetMeanphi();
 }
 
 Float_t AliMUONFastTracking::SigmaPhi(Float_t p,   Float_t theta, 
                            Float_t phi, Int_t charge){
+  //
+  // gets the width of the phirec-phigen distribution
+  //
   Int_t ip=0, itheta=0, iphi=0;
   Int_t index;
   GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
   // central value and corrections with spline 
-  Float_t sigmaphi = fCurrentEntry[ip][itheta][iphi]->fSigmaphi;
+  Float_t sigmaphi = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
   if (!fSpline) return sigmaphi;
   // corrections vs p, theta, phi 
   index = iphi + fNbinphi * itheta;
   Float_t frac1 = fSplineSigmaphi[index][0]->Eval(p)/sigmaphi; 
   Double_t xmin,ymin,xmax,ymax;
   if (p>fPmax-fDeltaP/2.) {
-    Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->fSigmaphi;
-    Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->fSigmaphi;
+    Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmaphi();
+    Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmaphi();
     Float_t p1  = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
     Float_t p2  = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
     Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) ); 
@@ -520,6 +584,10 @@ Float_t AliMUONFastTracking::SigmaPhi(Float_t p,   Float_t theta,
 }
 
 void AliMUONFastTracking::SetSpline(){
+  //
+  // sets the spline functions for a smooth behaviour of the parameters
+  // when going from one cell to another
+  //
   printf ("Setting spline functions...");
   char splname[40];
   Double_t x[20][3];
@@ -547,27 +615,23 @@ void AliMUONFastTracking::SetSpline(){
   for (Int_t itheta=0; itheta< fNbintheta; itheta++){
     for (Int_t iphi=0; iphi< fNbinphi; iphi++){
       for (Int_t ip=0; ip<fNbinp; ip++) {
-       //      for (Int_t i=0; i<5; i++) { 
-       //        yeff[5 * ip + i]  = fCurrentEntry[ip][itheta][iphi]->fEff[i];
-       //        yacc[5 * ip + i]  = fCurrentEntry[ip][itheta][iphi]->fAcc[i];
-       //      }
-       ysigmap[ip]     = fCurrentEntry[ip][itheta][iphi]->fSigmap;
-       ysigma1p[ip]    = fCurrentEntry[ip][itheta][iphi]->fSigma1p;
-       ysigmatheta[ip] = fCurrentEntry[ip][itheta][iphi]->fSigmatheta;
-       ysigmaphi[ip]   = fCurrentEntry[ip][itheta][iphi]->fSigmaphi;
+       ysigmap[ip]     = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
+       ysigma1p[ip]    = fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
+       ysigmatheta[ip] = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
+       ysigmaphi[ip]   = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
       }
       if (fPrintLevel>3) cout << " creating new spline " << splname << endl;
-      sprintf (splname,"fSplineEff[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineEff[%d][%d]",ispline,ivar);
       fSplineEff[ispline][ivar] = new TSpline3(splname,xsp2,yeff,5 * nbins[ivar]);
-      sprintf (splname,"fSplineAcc[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineAcc[%d][%d]",ispline,ivar);
       fSplineAcc[ispline][ivar] = new TSpline3(splname,xsp2,yacc,5 * nbins[ivar]);
-      sprintf (splname,"fSplineSigmap[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmap[%d][%d]",ispline,ivar);
       fSplineSigmap[ispline][ivar] = new TSpline3(splname,xspl,ysigmap,nbins[ivar]);
-      sprintf (splname,"fSplineSigma1p[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigma1p[%d][%d]",ispline,ivar);
       fSplineSigma1p[ispline][ivar] = new TSpline3(splname,xspl,ysigma1p,nbins[ivar]);
-      sprintf (splname,"fSplineSigmatheta[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmatheta[%d][%d]",ispline,ivar);
       fSplineSigmatheta[ispline][ivar] = new TSpline3(splname,xspl,ysigmatheta,nbins[ivar]);
-      sprintf (splname,"fSplineSigmaphi[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmaphi[%d][%d]",ispline,ivar);
       fSplineSigmaphi[ispline][ivar] = new TSpline3(splname,xspl,ysigmaphi,nbins[ivar]);
       ispline++;
     }
@@ -580,25 +644,23 @@ void AliMUONFastTracking::SetSpline(){
     for (Int_t iphi=0; iphi< fNbinphi; iphi++){
       for (Int_t itheta=0; itheta< fNbintheta; itheta++){
        // for efficiency and acceptance let's take the central value
-       //      yeff[itheta]        = fCurrentEntry[ip][itheta][iphi]->fEff[2];
-       //      yacc[itheta]        = fCurrentEntry[ip][itheta][iphi]->fAcc[2];
-       ysigmap[itheta]     = fCurrentEntry[ip][itheta][iphi]->fSigmap;
-       ysigma1p[itheta]    = fCurrentEntry[ip][itheta][iphi]->fSigma1p;
-       ysigmatheta[itheta] = fCurrentEntry[ip][itheta][iphi]->fSigmatheta;
-       ysigmaphi[itheta]   = fCurrentEntry[ip][itheta][iphi]->fSigmaphi;
+       ysigmap[itheta]     = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
+       ysigma1p[itheta]    = fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
+       ysigmatheta[itheta] = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
+       ysigmaphi[itheta]   = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
       }
       if (fPrintLevel>3) cout << " creating new spline " << splname << endl;
-      sprintf (splname,"fSplineEff[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineEff[%d][%d]",ispline,ivar);
       fSplineEff[ispline][ivar] = new TSpline3(splname,xspl,yeff, nbins[ivar]);
-      sprintf (splname,"fSplineAcc[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineAcc[%d][%d]",ispline,ivar);
       fSplineAcc[ispline][ivar] = new TSpline3(splname,xspl,yacc, nbins[ivar]);
-      sprintf (splname,"fSplineSigmap[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmap[%d][%d]",ispline,ivar);
       fSplineSigmap[ispline][ivar] = new TSpline3(splname,xspl,ysigmap,nbins[ivar]);
-      sprintf (splname,"fSplineSigma1p[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigma1p[%d][%d]",ispline,ivar);
       fSplineSigma1p[ispline][ivar] = new TSpline3(splname,xspl,ysigma1p,nbins[ivar]);
-      sprintf (splname,"fSplineSigmatheta[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmatheta[%d][%d]",ispline,ivar);
       fSplineSigmatheta[ispline][ivar] = new TSpline3(splname,xspl,ysigmatheta,nbins[ivar]);
-      sprintf (splname,"fSplineSigmaphi[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmaphi[%d][%d]",ispline,ivar);
       fSplineSigmaphi[ispline][ivar] = new TSpline3(splname,xspl,ysigmaphi,nbins[ivar]);
       ispline++;
     }
@@ -611,25 +673,23 @@ void AliMUONFastTracking::SetSpline(){
     for (Int_t itheta=0; itheta< fNbintheta; itheta++){
       for (Int_t iphi=0; iphi< fNbinphi; iphi++){
        // for efficiency and acceptance let's take the central value
-       //      yeff[iphi]        = fCurrentEntry[ip][itheta][iphi]->fEff[2];
-       //      yacc[iphi]        = fCurrentEntry[ip][itheta][iphi]->fAcc[2];
-       ysigmap[iphi]     = fCurrentEntry[ip][itheta][iphi]->fSigmap;
-       ysigma1p[iphi]    = fCurrentEntry[ip][itheta][iphi]->fSigma1p;
-       ysigmatheta[iphi] = fCurrentEntry[ip][itheta][iphi]->fSigmatheta;
-       ysigmaphi[iphi]   = fCurrentEntry[ip][itheta][iphi]->fSigmaphi;
+       ysigmap[iphi]     = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
+       ysigma1p[iphi]    = fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
+       ysigmatheta[iphi] = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
+       ysigmaphi[iphi]   = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
       }
       if (fPrintLevel>3) cout << " creating new spline " << splname << endl;
-      sprintf (splname,"fSplineEff[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineEff[%d][%d]",ispline,ivar);
       fSplineEff[ispline][ivar] = new TSpline3(splname,xspl,yeff, nbins[ivar]);
-      sprintf (splname,"fSplineAcc[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineAcc[%d][%d]",ispline,ivar);
       fSplineAcc[ispline][ivar] = new TSpline3(splname,xspl,yacc, nbins[ivar]);
-      sprintf (splname,"fSplineSigmap[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmap[%d][%d]",ispline,ivar);
       fSplineSigmap[ispline][ivar] = new TSpline3(splname,xspl,ysigmap,nbins[ivar]);
-      sprintf (splname,"fSplineSigma1p[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigma1p[%d][%d]",ispline,ivar);
       fSplineSigma1p[ispline][ivar] = new TSpline3(splname,xspl,ysigma1p,nbins[ivar]);
-      sprintf (splname,"fSplineSigmatheta[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmatheta[%d][%d]",ispline,ivar);
       fSplineSigmatheta[ispline][ivar] = new TSpline3(splname,xspl,ysigmatheta,nbins[ivar]);
-      sprintf (splname,"fSplineSigmaphi[%d][%d]",ispline,ivar);
+      snprintf (splname, 40, "fSplineSigmaphi[%d][%d]",ispline,ivar);
       fSplineSigmaphi[ispline][ivar] = new TSpline3(splname,xspl,ysigmaphi,nbins[ivar]);
       ispline++;
     }
@@ -637,82 +697,22 @@ void AliMUONFastTracking::SetSpline(){
   printf ("...done\n");
 }
   
-void AliMUONFastTracking::SmearMuon(Float_t pgen, Float_t thetagen, Float_t phigen, 
-                           Int_t charge, Float_t &psmear, Float_t &thetasmear,
-                           Float_t &phismear, Float_t &eff, Float_t &acc){
-
-  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  // IMPORTANT NOTICE TO THE USER
-  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  // THIS METHOD HAS BEEN REPLACED BY AliFastMuonTrackingEff::Evaluate()
-  // AND WILL BE DELETED SOON
-  // DO NOT USE THIS METHOD
-  // 
-
-  printf ("AliMUONFastTracking::SmearMuon()   THIS METHOD IS OBSOLETE ");
-  printf ("PLEASE REFER TO AliFastMuonTrackingEff::Evaluate()\n");
-  // angles are in degrees   
-  
-  Double_t meanp    = MeanP  (pgen, thetagen, phigen, charge);
-  Double_t sigmap   = SigmaP (pgen, thetagen, phigen, charge);
-  Double_t sigma1p  = Sigma1P(pgen, thetagen, phigen, charge);
-  Double_t normg2   = NormG2 (pgen, thetagen, phigen, charge);
-  Double_t meang2   = MeanG2 (pgen, thetagen, phigen, charge);
-  Double_t sigmag2  = SigmaG2(pgen, thetagen, phigen, charge);
-
-  printf ("fBkg = %g    normg2 (100,5,0,1) = %g \n",fBkg,NormG2(100,5,0,1));
-  printf ("fBkg = %g    meang2 (100,5,0,1) = %g \n",fBkg,MeanG2(100,5,0,1));
-  printf ("fBkg = %g    sigmag2 (100,5,0,1) = %g \n",fBkg,SigmaG2(100,5,0,1));
-  Int_t ip,itheta,iphi;
-  GetIpIthetaIphi(pgen, thetagen, phigen, charge, ip, itheta, iphi);
-  if (sigmap == 0) {
-    if (fPrintLevel>0) {
-      printf ("WARNING!!! sigmap=0:    ");
-      printf ("ip= %d itheta = %d iphi = %d   ", ip, itheta, iphi);  
-      printf ("p= %f theta = %f phi = %f\n", pgen, thetagen, phigen);  
-    }
-  }
-  
-  if (fPrintLevel>1) printf ("setting parameters: meanp = %f sigmap = %f sigma1p = %f normg2 = %f meang2 = %f sigmag2 = %f \n",meanp,sigmap,sigma1p,normg2,meang2,sigmag2);
-  fFitp->SetParameters(meanp,sigmap,sigma1p,normg2,meang2,sigmag2);
-  
-  Double_t meantheta  = MeanTheta (pgen, thetagen, phigen, charge);
-  Double_t sigmatheta = SigmaTheta(pgen, thetagen, phigen, charge);
-  Double_t meanphi    = MeanPhi   (pgen, thetagen, phigen, charge);
-  Double_t sigmaphi   = SigmaPhi  (pgen, thetagen, phigen, charge);
-  
-  // components different from ip=0 have the RMS bigger than mean
-  Float_t ptp[3]  =  { 1.219576,-0.354764,-0.690117 };
-  Float_t ptph[3] =  { 0.977522, 0.016269, 0.023158 }; 
-  Float_t pphp[3] =  { 1.303256,-0.464847,-0.869322 };
-  psmear   = pgen + fFitp->GetRandom();
-  Float_t dp = psmear - pgen; 
-  if (ip==0) sigmaphi *= pphp[0] + pphp[1] * dp + pphp[2] * dp*dp; 
-  phismear = phigen + gRandom->Gaus(meanphi, sigmaphi);
-  Float_t dphi = phismear - phigen; 
-
-  if (ip==0) sigmatheta *= ptp[0] + ptp[1] * dp + ptp[2] * dp*dp; 
-  if (ip==0) sigmatheta *= ptph[0] + ptph[1] * dphi + ptph[2] * dphi*dphi; 
-  thetasmear = thetagen + gRandom->Gaus(meantheta,sigmatheta);
-  eff      = Efficiency(pgen, thetagen, phigen, charge);
-  acc      = Acceptance(pgen, thetagen, phigen, charge);
-}
-
 void AliMUONFastTracking::SetBackground(Float_t bkg){
+  //
   // linear interpolation of the parameters in the LUT between 2 values where
   // the background has been actually calculated
-
+  //
   if (bkg>2) printf ("WARNING: unsafe extrapolation!\n");
   fBkg = bkg;
 
-  Float_t BKG[4] = {0, 0.5, 1, 2}; // bkg values for which LUT is calculated
+  Float_t bkgLevel[4] = {0, 0.5, 1, 2}; // bkg values for which LUT is calculated
   Int_t ibkg;
-  for (ibkg=0; ibkg<4; ibkg++) if ( bkg < BKG[ibkg]) break;
+  for (ibkg=0; ibkg<4; ibkg++) if ( bkg < bkgLevel[ibkg]) break;
   if (ibkg == 4) ibkg--;
   if (ibkg == 0) ibkg++;
   
-  Float_t x0 = BKG[ibkg-1];
-  Float_t x1 = BKG[ibkg];
+  Float_t x0 = bkgLevel[ibkg-1];
+  Float_t x1 = bkgLevel[ibkg];
   Float_t x = (bkg - x0) / (x1 - x0); 
   
   Float_t y0, y1;
@@ -720,50 +720,50 @@ void AliMUONFastTracking::SetBackground(Float_t bkg){
   for (Int_t ip=0; ip< fNbinp; ip++){
     for (Int_t itheta=0; itheta< fNbintheta; itheta++){
       for (Int_t iphi=0; iphi< fNbinphi; iphi++){
-       fCurrentEntry[ip][itheta][iphi]->fP = fEntry[ip][itheta][iphi][ibkg]->fP;
-       fCurrentEntry[ip][itheta][iphi]->fTheta = fEntry[ip][itheta][iphi][ibkg]->fTheta;
-       fCurrentEntry[ip][itheta][iphi]->fPhi = fEntry[ip][itheta][iphi][ibkg]->fPhi;
-       fCurrentEntry[ip][itheta][iphi]->fChi2p = -1;
-       fCurrentEntry[ip][itheta][iphi]->fChi2theta = -1;
-       fCurrentEntry[ip][itheta][iphi]->fChi2phi = -1;
-
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fMeanp;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fMeanp;
-       fCurrentEntry[ip][itheta][iphi]      ->fMeanp = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fMeantheta;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fMeantheta;
-       fCurrentEntry[ip][itheta][iphi]      ->fMeantheta = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fMeanphi;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fMeanphi;
-       fCurrentEntry[ip][itheta][iphi]      ->fMeanphi = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fSigmap;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fSigmap;
-       fCurrentEntry[ip][itheta][iphi]      ->fSigmap = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fSigmatheta;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fSigmatheta;
-       fCurrentEntry[ip][itheta][iphi]      ->fSigmatheta = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fSigmaphi;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fSigmaphi;
-       fCurrentEntry[ip][itheta][iphi]      ->fSigmaphi = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fSigma1p;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fSigma1p;
-       fCurrentEntry[ip][itheta][iphi]      ->fSigma1p = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fNormG2;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fNormG2;
-       fCurrentEntry[ip][itheta][iphi]      ->fNormG2 = (y1 - y0) * x + y0;
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fMeanG2;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fMeanG2;
-       fCurrentEntry[ip][itheta][iphi]      ->fMeanG2 = (y1 - y0) * x + y0;
+       fCurrentEntry[ip][itheta][iphi]->SetP(fEntry[ip][itheta][iphi][ibkg]->GetP());
+       fCurrentEntry[ip][itheta][iphi]->SetTheta(fEntry[ip][itheta][iphi][ibkg]->GetTheta());
+       fCurrentEntry[ip][itheta][iphi]->SetPhi(fEntry[ip][itheta][iphi][ibkg]->GetPhi());
+       fCurrentEntry[ip][itheta][iphi]->SetChi2p(-1);
+       fCurrentEntry[ip][itheta][iphi]->SetChi2theta(-1);
+       fCurrentEntry[ip][itheta][iphi]->SetChi2phi(-1);
+
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeanp();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetMeanp();
+       fCurrentEntry[ip][itheta][iphi]      ->SetMeanp((y1 - y0) * x + y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeantheta();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetMeantheta();
+       fCurrentEntry[ip][itheta][iphi]      ->SetMeantheta((y1 - y0) * x +y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeanphi();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetMeanphi();
+       fCurrentEntry[ip][itheta][iphi]      ->SetMeanphi((y1 - y0) * x + y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmap();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetSigmap();
+       fCurrentEntry[ip][itheta][iphi]      ->SetSigmap((y1 - y0) * x + y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmatheta();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetSigmatheta();
+       fCurrentEntry[ip][itheta][iphi]      ->SetSigmatheta((y1 - y0) * x+y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmaphi();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetSigmaphi();
+       fCurrentEntry[ip][itheta][iphi]      ->SetSigmaphi((y1 - y0) * x + y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigma1p();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetSigma1p();
+       fCurrentEntry[ip][itheta][iphi]      ->SetSigma1p((y1 - y0) * x + y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetNormG2();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetNormG2();
+       fCurrentEntry[ip][itheta][iphi]      ->SetNormG2((y1 - y0) * x + y0);
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeanG2();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetMeanG2();
+       fCurrentEntry[ip][itheta][iphi]      ->SetMeanG2((y1 - y0) * x + y0);
        
-       y0 = fEntry[ip][itheta][iphi][ibkg-1]->fSigmaG2;
-       y1 =   fEntry[ip][itheta][iphi][ibkg]->fSigmaG2;
-       fCurrentEntry[ip][itheta][iphi]      ->fSigmaG2 = (y1 - y0) * x + y0;
+       y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmaG2();
+       y1 =   fEntry[ip][itheta][iphi][ibkg]->GetSigmaG2();
+       fCurrentEntry[ip][itheta][iphi]      ->SetSigmaG2((y1 - y0) * x + y0);
        for (Int_t i=0; i<kSplitP; i++) {
          for (Int_t j=0; j<kSplitTheta; j++) {
-           fCurrentEntry[ip][itheta][iphi]->fAcc[i][j] = fEntry[ip][itheta][iphi][ibkg]->fAcc[i][j];
-           y0 = fEntry[ip][itheta][iphi][ibkg-1]->fEff[i][j];
-           y1 =   fEntry[ip][itheta][iphi][ibkg]->fEff[i][j];
-           fCurrentEntry[ip][itheta][iphi]->fEff[i][j] = (y1 - y0) * x + y0;
+           fCurrentEntry[ip][itheta][iphi]->SetAcc(i,j,fEntry[ip][itheta][iphi][ibkg]->GetAcc(i,j));
+           y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetEff(i,j);
+           y1 =   fEntry[ip][itheta][iphi][ibkg]->GetEff(i,j);
+           fCurrentEntry[ip][itheta][iphi]->SetEff(i,j, (y1 - y0) * x + y0);
          }
        }
       }
@@ -772,11 +772,32 @@ void AliMUONFastTracking::SetBackground(Float_t bkg){
   SetSpline();
 }
 
+TF1* AliMUONFastTracking::GetFitP(Int_t ip,Int_t itheta,Int_t iphi) { 
+  // gets the correct prec-pgen distribution for a given LUT cell 
+  if (!fFitp[ip][itheta][iphi]) {
+    char name[256];
+    snprintf(name, 256, "fit_%d_%d_%d", ip, itheta, iphi);
+    fFitp[ip][itheta][iphi] = new TF1(name ,FitP,-20.,20.,6);
+    fFitp[ip][itheta][iphi]->SetNpx(500);    
+    fFitp[ip][itheta][iphi]->SetParameters(0.,0.,0.,0.,0.,0.);    
+  }
+  return fFitp[ip][itheta][iphi]; 
+}
 
+AliMUONFastTracking& AliMUONFastTracking::operator=(const  AliMUONFastTracking& rhs)
+{
+// Assignment operator
+    rhs.Copy(*this);
+    return *this;
+}
 
-  // to guarantee a safe extrapolation for sigmag2 to 0<bkg<0.5, let's fit 
-  // with a straight line sigmag2 vs bkg for bkg=0.5, 1 and 2, and put the 
-  // sigma2(BKG=0) as the extrapolation of this fit 
+void AliMUONFastTracking::Copy(TObject&) const
+{
+    //
+    // Copy 
+    //
+    Fatal("Copy","Not implemented!\n");
+}