From 5e68a3ce0a8de6f718d0bb573f54592918c71a3c Mon Sep 17 00:00:00 2001
From: Peter Peterson <petersonpf@ornl.gov>
Date: Thu, 15 Mar 2012 11:14:03 -0400
Subject: [PATCH] Refs #4983. Changed from string to IFitFunction in
 GetDetectorOffsets.

---
 .../inc/MantidAlgorithms/GetDetectorOffsets.h      |  2 +-
 .../Algorithms/src/GetDetectorOffsets.cpp          | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h b/Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h
index 447c72f0993..a5ed80be69a 100644
--- a/Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h
+++ b/Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h
@@ -58,7 +58,7 @@ private:
   /// Call Gaussian as a sub-algorithm to fit the peak in a spectrum
   double fitSpectra(const int64_t s);
   /// Create a function string from the given parameters and the algorithm inputs
-  std::string createFunctionString(const double peakHeight, const double peakLoc); 
+  API::IFitFunction_sptr createFunction(const double peakHeight, const double peakLoc);
   /// Read in all the input parameters
   void retrieveProperties();
   
diff --git a/Code/Mantid/Framework/Algorithms/src/GetDetectorOffsets.cpp b/Code/Mantid/Framework/Algorithms/src/GetDetectorOffsets.cpp
index 07a854e8ea9..dd5dd331c54 100644
--- a/Code/Mantid/Framework/Algorithms/src/GetDetectorOffsets.cpp
+++ b/Code/Mantid/Framework/Algorithms/src/GetDetectorOffsets.cpp
@@ -212,9 +212,9 @@ namespace Mantid
       fit_alg->setProperty("EndX",Xmax);
       fit_alg->setProperty("MaxIterations",100);
 
-      std::string fun_str = createFunctionString(peakHeight, peakLoc);
+      IFitFunction_sptr fun_ptr = createFunction(peakHeight, peakLoc);
       
-      fit_alg->setPropertyValue("Function",fun_str);
+      fit_alg->setProperty("Function",fun_ptr);
       fit_alg->executeAsSubAlg();
       std::string fitStatus = fit_alg->getProperty("OutputStatus");
       //Pixel with large offset will be masked
@@ -232,7 +232,7 @@ namespace Mantid
      * @param peakHeight :: The height of the peak
      * @param peakLoc :: The location of the peak
      */
-    std::string GetDetectorOffsets::createFunctionString(const double peakHeight, const double peakLoc) 
+    IFitFunction_sptr GetDetectorOffsets::createFunction(const double peakHeight, const double peakLoc)
     {
       FunctionFactoryImpl & creator = FunctionFactory::Instance();
       IBackgroundFunction *background = 
@@ -244,11 +244,11 @@ namespace Mantid
       const double sigma(10.0);
       peak->setWidth(2.0*std::sqrt(2.0*std::log(2.0))*sigma);
 
-      CompositeFunctionMW fitFunc; //Takes ownership of the functions
-      fitFunc.addFunction(background);
-      fitFunc.addFunction(peak);
+      CompositeFunctionMW* fitFunc = new CompositeFunctionMW(); //Takes ownership of the functions
+      fitFunc->addFunction(background);
+      fitFunc->addFunction(peak);
 
-      return fitFunc.asString();
+      return boost::shared_ptr<IFitFunction>(fitFunc);
     }
 
 
-- 
GitLab