diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8077bcfd755c0cbb1ba1ac02f1fa5f54a03dcae7..2e2eb006c83468a3d429dce29ba5c76f7012fd6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -234,7 +234,6 @@ target_link_libraries(DICT ${ROOT_LIBRARIES})
 #add the custom libraries
 add_library(cparser include/cparser.cpp)
 add_library(geometry include/TFRGeometry.cpp)
-add_library(mscattering include/TFRMultipleScattering.cpp)
 add_library(propagator include/TFRPropagator.cpp)
 add_library(kalmanfilter include/TFRKalmanFilter)
 add_library(chisqfit include/TFRChiSquaredFit.cpp)
@@ -259,7 +258,7 @@ foreach( appsourcefile ${APP_SOURCES} )
     add_executable( ${executablename} ${appsourcefile} ${ROOT_HEADERS} )
 
     # link all the libraries
-    target_link_libraries( ${executablename} cparser geometry mscattering propagator chisqfit kalmanfilter DICT ${ROOT_LIBRARIES} )
+    target_link_libraries( ${executablename} cparser geometry propagator chisqfit kalmanfilter DICT ${ROOT_LIBRARIES} )
 
 endforeach( appsourcefile ${APP_SOURCES} )
 
diff --git a/include/TFRChiSquaredFit.cpp b/include/TFRChiSquaredFit.cpp
index bc16e868186d535077eb5fb38423f1922c7a833b..86733f8138b988a67f38de4a501c6d9c28c0dd42 100644
--- a/include/TFRChiSquaredFit.cpp
+++ b/include/TFRChiSquaredFit.cpp
@@ -112,7 +112,8 @@ bool TFRChiSquaredFit::FitLinear1D(TFRTrack *track, bool xz_view){
 //----------
 // Perform a 1D linear fit, with matrix formalism
 //----------
-bool TFRChiSquaredFit::FitLinear1D_matrix(TFRTrack *track, bool xz_view){
+bool TFRChiSquaredFit::FitLinear1D_matrix(TFRTrack *track, bool xz_view,
+					  TFRGeometry *detector_geo){
 
   //linear formalism:
   // f = Ap
@@ -172,16 +173,30 @@ bool TFRChiSquaredFit::FitLinear1D_matrix(TFRTrack *track, bool xz_view){
     //should I fit the x or y position of the clusters?
     if(xz_view){
       X(i) = curr_cluster->GetX();
-      
-      //let's assume uncorrelated measurements
       V(i, i) = curr_cluster->GetCovariance()(0, 0);
     }
     else{
       X(i) = curr_cluster->GetY();
-      
-      //let's assume uncorrelated measurements
       V(i, i) = curr_cluster->GetCovariance()(1, 1); 
-    }
+    }  //if(xz_view)
+
+    //should I take in account the multiple scattering?                                                                                                                                           
+    if(detector_geo->GetMultipleScattStatus()){
+      //assume momentum and Kaon mass...                                                                                                                                                          
+      double momentum	= 5000.;
+      double beta = sqrt(1. - pow(493.7/momentum, 2));
+      
+      //the first cluster is not effected                                                                                                                                                         
+      if(i != 0){
+	V(i, i) += (pow(A(i, 1) - A(i - 1., 1), 2.)
+		    * pow(detector_geo->GetMultipleScattering()->GetThetaRMSGauss(curr_cluster->GetLayer().GetXoverXZero(),
+										  beta, momentum, 1),
+			  2.));
+	
+	//let's forget the off-diagional elements, for now...
+	
+      }  //if(i != 0)
+    }  //if(detector_geo->GetMultipleScattStatus())
     
     ++i;
     
@@ -239,7 +254,8 @@ bool TFRChiSquaredFit::FitLinear1D_matrix(TFRTrack *track, bool xz_view){
 //----------
 // Perform a 1D quadratic fit, with matrix formalism
 //----------
-bool TFRChiSquaredFit::FitQuadratic1D_matrix(TFRTrack *track, bool xz_view){
+bool TFRChiSquaredFit::FitQuadratic1D_matrix(TFRTrack *track, bool xz_view,
+					     TFRGeometry *detector_geo){
 
   //almost the same of the linear case, with the only difference of the dimensionality:
   // f = Ap
@@ -285,17 +301,32 @@ bool TFRChiSquaredFit::FitQuadratic1D_matrix(TFRTrack *track, bool xz_view){
     //should I fit the x or y position of the clusters?
     if(xz_view){
       X(i) = curr_cluster->GetX();
-      
-      //let's assume uncorrelated measurements
       V(i, i) = curr_cluster->GetCovariance()(0, 0);
     }
     else{
       X(i) = curr_cluster->GetY();
-      
-      //let's assume uncorrelated measurements                                                                                                                                                             
       V(i, i) = curr_cluster->GetCovariance()(1, 1);
     }
     
+    //should I take in account the multiple scattering?
+    if(detector_geo->GetMultipleScattStatus()){
+
+      //assume momentum and Kaon mass...
+      double momentum   = 5000.;
+      double beta = sqrt(1. - pow(493.7/momentum, 2));
+      
+      //the first cluster is not effected
+      if(i != 0){
+        V(i, i) += (pow(A(i, 1) - A(i - 1., 1), 2.)
+                    * pow(detector_geo->GetMultipleScattering()->GetThetaRMSGauss(curr_cluster->GetLayer().GetXoverXZero(),
+                                                                                  beta, momentum, 1),
+                          2.));
+	
+        //let's forget the off-diagional elements, for now...                                                                                                                                      
+	
+      }  //if(i != 0)
+    }  //if(detector_geo->GetMultipleScattStatus())
+    
     ++i;
     
   }  //loop over the clusters
@@ -343,7 +374,8 @@ bool TFRChiSquaredFit::FitQuadratic1D_matrix(TFRTrack *track, bool xz_view){
 //----------
 // Perform a 2D linear fit, with matrix formalism
 //----------
-bool TFRChiSquaredFit::FitLinear2D_matrix(TFRTrack *track){
+bool TFRChiSquaredFit::FitLinear2D_matrix(TFRTrack *track,
+					  TFRGeometry *detector_geo){
   
   //linear formalism:                                                                                                                                                                              
   // f = Ap
@@ -423,6 +455,8 @@ bool TFRChiSquaredFit::FitLinear2D_matrix(TFRTrack *track){
     
     //let's assume uncorrelated measurements on x and y
     V.SetSub(i*2, i*2, curr_cluster->GetCovariance());
+
+    //to write the multiple scattering contribution to the covariance!
     
     ++i;
     
diff --git a/include/TFRChiSquaredFit.h b/include/TFRChiSquaredFit.h
index 54c0ced95b3e551f0771fc6c94d41f97c7d9dd48..34436912a2e528fa8b1c4e306fbe1a8fce40a001 100644
--- a/include/TFRChiSquaredFit.h
+++ b/include/TFRChiSquaredFit.h
@@ -36,13 +36,15 @@ class TFRChiSquaredFit {
   bool FitLinear1D(TFRTrack *track, bool xz_view = true);
 
   /*! Perform a 1D linear fit, with matrix formalism */
-  bool FitLinear1D_matrix(TFRTrack *track, bool xz_view = true);
+  bool FitLinear1D_matrix(TFRTrack *track, bool xz_view,
+			  TFRGeometry *detector_geo);
   
   /*! Perform a 1D quadratic fit, with matrix formalism */
-  bool FitQuadratic1D_matrix(TFRTrack *track, bool xz_view = true);
+  bool FitQuadratic1D_matrix(TFRTrack *track, bool xz_view,
+			     TFRGeometry *detector_geo);
 
   /*! Perform a 2D linear fit, with matrix formalism */
-  bool FitLinear2D_matrix(TFRTrack *track);
+  bool FitLinear2D_matrix(TFRTrack *track, TFRGeometry *detector_geo);
   
  protected:
 
diff --git a/include/TFRGeometry.cpp b/include/TFRGeometry.cpp
index 4e4a50b60aaac05b814b2b3f5f8d4f12292724c3..c593852bc5d8a12dd207cda698a7a0f8b68627f8 100644
--- a/include/TFRGeometry.cpp
+++ b/include/TFRGeometry.cpp
@@ -10,26 +10,6 @@
 //------------
 TFRGeometry::TFRGeometry(const std::string configFile_name){
 
-  //-------------------------------//
-  // setup the default propagator  //
-  //-------------------------------//
-
-  /*
-  propagator = new TEveTrackPropagator();
-  
-  //setup the Runge Kutta stepper
-  propagator->SetStepper(TEveTrackPropagator::kRungeKutta);
-
-  //set a uniform magnetic field on x direction
-  propagator->SetMagField(0., 10., 0.);
-
-  //some other options
-  propagator->SetFitDaughters(kFALSE);      //do not follow the daughters particles
-  propagator->SetMaxZ(1000.);               //maximum z-coordinate to propagate, cm
-  propagator->SetMaxR(100000000);           //maximum bending radius to propagate, cm
-  propagator->SetDelta(pow(10., -6.));      //'error' on trajectory reconstruction
-  */
-  
   //-----------------------------------------------//
   //  set the geometry from the input config file  //
   //-----------------------------------------------//
@@ -41,8 +21,7 @@ TFRGeometry::TFRGeometry(const std::string configFile_name){
   //----------------------------------//
   
   //loop over the detector layers, to create the keys of the map (i.e. indexing by layer id)
-  
-  //I've no clue why the hell in ROOT there aren't nice implementations of iterators,                                                                                                                  
+  //I've no clue why the hell in ROOT there aren't nice implementations of iterators,
   //but just this stupid way (that I even didn't used at my C course during my bachelor)
   TIter it_layer((TFRLayers*) this->GetLayers());
   TFRLayer *curr_layer;
@@ -50,7 +29,6 @@ TFRGeometry::TFRGeometry(const std::string configFile_name){
   //loop over the detector layers
   while((curr_layer = (TFRLayer*) it_layer.Next()))
     layer_map.insert(std::make_pair(curr_layer->GetID(), curr_layer));
-
   
   //--------------------------//
   //  set the magnetic field  //
@@ -65,10 +43,12 @@ TFRGeometry::TFRGeometry(const std::string configFile_name){
   B_mag = configFile.get<double>("B_field.magnitude");
 
 
-  //--------------------------------------//
-  //  set the multiple scattering status  //
-  //--------------------------------------//
+  //-------------------------------//
+  //  set the multiple scattering  //
+  //-------------------------------//
 
+  mult_scatt = new TFRMultipleScattering();
+  
   if(configFile.get<unsigned int>("multiple_scattering") == 1)
     multiple_scattering = true;
   else
diff --git a/include/TFRGeometry.h b/include/TFRGeometry.h
index 740256f71c9f51f83d7b88a9deeaf2c8816e3479..7370452c98e22dd5d530d8b39c722882d264af77 100644
--- a/include/TFRGeometry.h
+++ b/include/TFRGeometry.h
@@ -23,6 +23,7 @@
 #include "TFRMCHit.h"
 #include "TFRCluster.h"
 #include "TFRLayer.h"
+#include "TFRMultipleScattering.h"
 
 using namespace std;
 
@@ -87,7 +88,10 @@ class TFRGeometry {
 
   /*! Returns the magnitude of the magnetic field */
   inline double GetBMag() const {return B_mag;};
-
+  
+  /*! Get the multiple scattering */
+  inline TFRMultipleScattering* GetMultipleScattering(){return mult_scatt;}
+    
   /*! Set the multiple scattering status (enabled/disabled) */
   inline void SetMultipleScattStatus(bool _multiple_scattering) {
     multiple_scattering = _multiple_scattering;}
@@ -102,9 +106,6 @@ class TFRGeometry {
   /*! Geometry tag */
   std::string tag;
   
-  /*! Track propagator */ 
-  //TEveTrackPropagator *propagator;
-  
   /*! Detector layers */
   TFRLayers *layers;
   
@@ -120,6 +121,9 @@ class TFRGeometry {
   /*! Magnitude of the magnetic field */
   double B_mag;
 
+  /*! Multiple scattering */
+  TFRMultipleScattering *mult_scatt;
+  
   /*! Status of the multiple scattering simulation (enabled/disabled) */
   bool multiple_scattering;
   
diff --git a/include/TFRMultipleScattering.cpp b/include/TFRMultipleScattering.cpp
deleted file mode 100644
index c6b0e4f4d191e3bff9f3ea4e1d4b9121b2595804..0000000000000000000000000000000000000000
--- a/include/TFRMultipleScattering.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-/*!
- *  @author    Alessio Piucci
- *  @brief     Library to handle the simulation of the multiple scattering
- */
-
-#include "TFRMultipleScattering.h"
diff --git a/include/TFRMultipleScattering.h b/include/TFRMultipleScattering.h
index 1f7edf21a032f12e61b81c3c671d5f5b92f7b868..b4ee40ead619977395f61d377b966052bd685d9a 100644
--- a/include/TFRMultipleScattering.h
+++ b/include/TFRMultipleScattering.h
@@ -17,9 +17,6 @@
 #include "TROOT.h"
 #include "TRandom3.h"
 
-//custom libraries
-#include "TFRLayer.h"
-
 using namespace std;
 
 class TFRMultipleScattering {
@@ -36,9 +33,9 @@ class TFRMultipleScattering {
   ~TFRMultipleScattering( );
 
   /*! Returns the angular deviation with Gaussian approximation */
-  inline double GetThetaGauss(const TFRLayer layer,
+  inline double GetThetaGauss(const double x_over_Xzero,
 			      const double beta, const double p, const int charge) const
-      { return random->Gaus(0., GetThetaRMSGauss(layer.GetXoverXZero(), beta, p, charge)); };
+      { return random->Gaus(0., GetThetaRMSGauss(x_over_Xzero, beta, p, charge)); };
   
   /*! Returns the rms theta for Gaussian approximation */
   inline double GetThetaRMSGauss(const double x_over_Xzero,
diff --git a/include/TFRPropagator.cpp b/include/TFRPropagator.cpp
index e7820cdd4e75db7be71fbdfa0ce276ba82283f9d..01ec1f5c1cf7c4df79dd6a726cb2bfbbe0d80944 100644
--- a/include/TFRPropagator.cpp
+++ b/include/TFRPropagator.cpp
@@ -272,20 +272,21 @@ bool TFRPropagator::AddScatteringToCovariance(TFRState *state, TFRLayer *layer){
   
   if(x < xmin || x > xmax || y < ymin || y > ymax) return false;
 
-  //Check wether we should calcualte the effect of MS at this point.
+  //Check wether we should calculate the effect of MS at this point.
   if(!m_useMs || !m_geo->GetMultipleScattStatus()) return true;
 
   //Get multiple scattering factor (how much material)
   double XoverXZero = layer->GetXoverXZero();
   
-  //Calculate the expected angular defelction
+  //Calculate the expected angular deflection
   double momentum = fabs(1.0/(state->GetStateVect())[4]);
   
   //assume kaon mass
-  double beta = sqrt(1.-pow(493.7/momentum,2));
+  double beta = sqrt(1. - pow(493.7/momentum, 2));
   
-  double angleRms = m_multiplescattering->GetThetaRMSGauss(XoverXZero, beta, momentum, 1); 
-  //Tranlsate this angle in variations of tx and ty, tan(alpah) = x/z = tx (Good enough approximation also for the 2D scattering case)
+  double angleRms = m_geo->GetMultipleScattering()->GetThetaRMSGauss(XoverXZero, beta, momentum, 1); 
+  
+  //Translate this angle in variations of tx and ty, tan(alpah) = x/z = tx (Good enough approximation also for the 2D scattering case)
   double txRms2 = pow((1+pow((state->GetStateVect())[2],2))*angleRms,2);
   double tyRms2 = pow((1+pow((state->GetStateVect())[3],2))*angleRms,2);//TODO
   
diff --git a/include/TFRPropagator.h b/include/TFRPropagator.h
index 16880f945e82581305e969773ceeb4335c43700a..f3582803ae449ee4f56084fd4aa4ad65e1de8528 100644
--- a/include/TFRPropagator.h
+++ b/include/TFRPropagator.h
@@ -19,7 +19,6 @@
 #include "TFRLayer.h"
 #include "TFRState.h"
 #include "TFRGeometry.h"
-#include "TFRMultipleScattering.h"
 
 using namespace std;
 
@@ -31,9 +30,7 @@ class TFRPropagator {
   
   /*! Standard constructor */
   TFRPropagator(TFRGeometry *_geometry, bool useMultipleScattering = false) :
-   m_geo(_geometry), m_useMs(useMultipleScattering) {
-  m_multiplescattering = new TFRMultipleScattering();
-  }
+   m_geo(_geometry), m_useMs(useMultipleScattering) {}
 
   /*! Destructor */
   ~TFRPropagator( ){ };
@@ -44,22 +41,22 @@ class TFRPropagator {
   /*! Get the information wether multiple scattering is taken into account or not */
   bool MultipleScatteringUsed() const {return m_useMs;};
   
-  /*! Set wether multiple scattering is taken into account or not*/
+  /*! Set wether multiple scattering is taken into account or not */
   void UseMultipleScattering(bool ms) { m_useMs = ms;};
 
-  /*! Extrapolate a state to a given z position. Returns false if the track is extrapolated ouside a detector layer or if the particle is replected by the magnetic field*/
+  /*! Extrapolate a state to a given z position. Returns false if the track is extrapolated ouside a detector layer or if the particle is replected by the magnetic field */
   bool PropagateState(TFRState *state, double z);
   
-  /*! Extrapolate a state to a given z position without taking into account multiple scattering at layers. Returns false if the track is extrapolated ouside a detector layer or if the particle is replected by the magnetic field*/
+  /*! Extrapolate a state to a given z position without taking into account multiple scattering at layers. Returns false if the track is extrapolated ouside a detector layer or if the particle is replected by the magnetic field */
   bool PropagateStateNoScattering(TFRState *state, double z);
   
   /*! Extrapolate a state to a given z position with a straight line */
   void PropagateStateStraight(TFRState *state, double z);
   
-  /*! Extrapolate a state to a given z position in a constant magnetic field. Returns false if the particle is replected by the magnetic field*/
+  /*! Extrapolate a state to a given z position in a constant magnetic field. Returns false if the particle is replected by the magnetic field */
   bool PropagateStateInBField(TFRState *state, double z);
 
-  /*! Add the effect ofmultiple scattering at a certain layer to the covariance matrix of the state*/
+  /*! Add the effect of multiple scattering at a certain layer to the covariance matrix of the state */
   bool AddScatteringToCovariance(TFRState *state, TFRLayer *layer);
   
  protected:
@@ -69,9 +66,6 @@ class TFRPropagator {
   /*! The used geometry */
   TFRGeometry *m_geo;
 
-  /*! Class to deal with multiple scattering */
-  TFRMultipleScattering *m_multiplescattering;
-
   /*! take into account multiple scattering or not*/
   bool m_useMs;
   
diff --git a/slides/day_4_performance.odp b/slides/day_4_performance.odp
index b5ea1ddf052e482b0a3d55d8aec9f0eebb739f7d..3c510be9b5cd9275d14ff46b1b3387a66556d2d1 100644
Binary files a/slides/day_4_performance.odp and b/slides/day_4_performance.odp differ
diff --git a/src/detector_sim.cpp b/src/detector_sim.cpp
index 262565ffca2219dcb28cc9dad936c0cee0a97ff6..385b9d2279b78ff38e7e5ae588d3c598b93b7a07 100644
--- a/src/detector_sim.cpp
+++ b/src/detector_sim.cpp
@@ -25,7 +25,6 @@
 #include "../include/TFRParticle.h"
 #include "../include/TFRGeometry.h"
 #include "../include/TFRPropagator.h"
-#include "../include/TFRMultipleScattering.h"
 
 using namespace std;
 
@@ -139,9 +138,6 @@ int main(int argc, char **argv){
   TRandom3 *random_ms = new TRandom3();   //multiple scattering
   random_ms->SetSeed(1);
 
-  //set the tool required to simulate the multiple scattering
-  TFRMultipleScattering *mscattering = new TFRMultipleScattering();
-  
   //I've no clue why the hell in ROOT there aren't nice implementations of iterators,
   //but just this stupid way (that I even didn't used at my C course during my bachelor)
   TIter it_event(event_list);
@@ -166,23 +162,6 @@ int main(int argc, char **argv){
       if(curr_particle->GetCharge() == 0)
 	continue;
       
-      /*
-      //set a TEveRecTrack, required for the propagation of a TEveTrack
-      TEveRecTrackD *temp_track = new TEveRecTrackD();
-
-      temp_track->fV.Set(curr_particle->GetVertex());
-      temp_track->fP.Set(curr_particle->GetMomentum());
-      temp_track->fSign = curr_particle->GetCharge();
-      
-      TEveTrack *prop_track = new TEveTrack(temp_track, detector_geo->GetPropagator());
-      
-      prop_track->GetPropagator()->InitTrack(curr_particle->GetVertex(),
-					     curr_particle->GetCharge());
-      
-      //propagate the particle!
-      //TEve_track-->MakeTrack();
-      */
-      
       //I've no clue why the hell in ROOT there aren't nice implementations of iterators,
       //but just this stupid way (that I even didn't used at my C course during my bachelor)
       TIter it_layer((TFRLayers*) detector_geo->GetLayers());
@@ -202,15 +181,6 @@ int main(int argc, char **argv){
 	
 	TFRMCHit *intersection = new TFRMCHit(*curr_layer);
 	
-	/*
-	//check if the intersection is valid
-	if(prop_track->GetPropagator()->IntersectPlane(temp_track->fP,
-	curr_layer->GetPosition(), curr_layer->GetOrtVersor(),
-	intersection_position)){
-	
-	intersection->SetPosition(intersection_position);
-	*/
-	
 	//check if the intersection is valid
 	if(propagator->PropagateState(temp_state, curr_layer->GetZ())){
 	  
@@ -222,10 +192,10 @@ int main(int argc, char **argv){
 	  if(detector_geo->GetMultipleScattStatus()){
 
 	    //get the angle by wich the track is reflected (the full angle between track before and after scattering)
-	    double theta_ms = sqrt(2.) * mscattering->GetThetaGauss(*curr_layer,
-								    curr_particle->GetBeta(),
-								    curr_particle->GetMomentumMod(),
-								    curr_particle->GetCharge());
+	    double theta_ms = sqrt(2.) * detector_geo->GetMultipleScattering()->GetThetaGauss(curr_layer->GetXoverXZero(),
+											      curr_particle->GetBeta(),
+											      curr_particle->GetMomentumMod(),
+											      curr_particle->GetCharge());
 	    
 	    //Express the current momentum in the coordinate system where z is along the momentum
 	    double sinalpha = temp_state->GetMomentum()[0]
@@ -267,19 +237,6 @@ int main(int argc, char **argv){
 
 	  }  //if(detector_geo->GetMultipleScattStatus())
 	  
-	  /*
-	    temp_track->fP.Set(TEveVectorD(pxz * sin(alpha + theta_ms),
-	    temp_track->fP[1],
-	    pxz * cos(alpha + theta_ms)));
-	  */
-	  
-	  /*
-	  //update the propagator
-	  prop_track = new TEveTrack(temp_track, detector_geo->GetPropagator());
-	  prop_track->GetPropagator()->InitTrack(temp_track->fV,
-	  curr_particle->GetCharge());
-	  */
-	  
 	  //add the intersection to the vector of the hits of the particle
 	  intersection->SetPosition(TVector3(temp_state->GetX(),
 					     temp_state->GetY(),
diff --git a/src/fitting_chi2_linear.cpp b/src/fitting_chi2_linear.cpp
index 16843b6636bb774938cbe8ab7be87fbf4c798c6d..708ed01c6954b5b351ddfcef3da2b8266b1b0888 100644
--- a/src/fitting_chi2_linear.cpp
+++ b/src/fitting_chi2_linear.cpp
@@ -116,13 +116,13 @@ bool fitStraightTracklets(TFRTrack *track,
   //  now I can finally fit the two tracklets  //
   //-------------------------------------------//
   
-  if(!chi2_fit->FitLinear1D_matrix(track_beforeB)){
+  if(!chi2_fit->FitLinear1D_matrix(track_beforeB, true, detector_geo)){
     std::cout << "Error: problem with linear chi2 fitting of the tracklet before B." << std::endl;
     track->SetFitStatus(false);
     return false;
   }
   
-  if(!chi2_fit->FitLinear1D_matrix(track_afterB)){
+  if(!chi2_fit->FitLinear1D_matrix(track_afterB, true, detector_geo)){
     std::cout << "Error: problem with linear chi2 fitting of the tracklet after B." << std::endl;
     track->SetFitStatus(false);
     return false;
@@ -181,7 +181,7 @@ bool fitStraightTracklets(TFRTrack *track,
   //  linear fit on the xy plane  //
   //------------------------------//
 
-  if(!chi2_fit->FitLinear1D_matrix(track_beforeB, false)){
+  if(!chi2_fit->FitLinear1D_matrix(track_beforeB, false, detector_geo)){
     std::cout << "Error: problem with linear chi2 fitting of the tracklet before B on the yz plane." << std::endl;
     track->SetFitStatus(false);
     return false;
@@ -246,7 +246,7 @@ bool extrapolateVertex(TFRTrack *track,
   //----------------------------//
   
   //fit the straight tracklet with the 2D chi2 fit
-  if(!chi2_fit->FitLinear2D_matrix(track_beforeB)){
+  if(!chi2_fit->FitLinear2D_matrix(track_beforeB, detector_geo)){
     std::cout << "Error: problem with linear 2D chi2 fitting of the tracklet before B." << std::endl;
     track->SetFitStatus(false);
     return false;
diff --git a/src/fitting_chi2_quadratic.cpp b/src/fitting_chi2_quadratic.cpp
index 494ea6b665e4fb0dc9edfdef2e5bdfa16b203ff6..34d7e6f339fe6f612c442ad5cdf76f8c6948e494 100644
--- a/src/fitting_chi2_quadratic.cpp
+++ b/src/fitting_chi2_quadratic.cpp
@@ -89,14 +89,14 @@ bool fitStraightAndParabola(TFRTrack *track,
   //-------------------------------------------//
 
   //fit the straight tracklet
-  if(!chi2_fit->FitLinear1D_matrix(track_beforeB)){
+  if(!chi2_fit->FitLinear1D_matrix(track_beforeB, true, detector_geo)){
     std::cout << "Error: problem with linear chi2 fitting of the tracklet before B." << std::endl;
     track->SetFitStatus(false);
     return false;
   }
   
   //fit the parabolic tracklet
-  if(!chi2_fit->FitQuadratic1D_matrix(track_inB)){
+  if(!chi2_fit->FitQuadratic1D_matrix(track_inB, true, detector_geo)){
     std::cout << "Error: problem with parabolic chi2 fitting of the tracklet in B." << std::endl;
     track->SetFitStatus(false);
     return false;
@@ -152,7 +152,7 @@ bool fitStraightAndParabola(TFRTrack *track,
   //  linear fit on the xy plane  //
   //------------------------------//
   
-  if(!chi2_fit->FitLinear1D_matrix(track_beforeB, false)){
+  if(!chi2_fit->FitLinear1D_matrix(track_beforeB, false, detector_geo)){
     std::cout << "Error: problem with linear chi2 fitting of the tracklet before B on the yz plane." << std::endl;
     track->SetFitStatus(false);
     return false;
@@ -217,7 +217,7 @@ bool extrapolateVertex(TFRTrack *track,
   //----------------------------//
   
   //fit the straight tracklet with the 2D chi2 fit
-  if(!chi2_fit->FitLinear2D_matrix(track_beforeB)){
+  if(!chi2_fit->FitLinear2D_matrix(track_beforeB, detector_geo)){
     std::cout << "Error: problem with linear 2D chi2 fitting of the tracklet before B." << std::endl;
     track->SetFitStatus(false);
     return false;