Skip to content

Commit

Permalink
Add flags for workspace and spec names in minimizer string
Browse files Browse the repository at this point in the history
Refs #11651
  • Loading branch information
DanNixon committed May 1, 2015
1 parent 3f8dd3d commit 35f2a68
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Expand Up @@ -107,6 +107,9 @@ class DLLExport PlotPeakByLogValue : public API::Algorithm {

/// Create a list of input workspace names
std::vector<InputData> makeNames() const;

/// Create a minimizer string based on template string provided
std::string getMinimizerString(const std::string & wsName, const std::string & specIndex) const;
};

} // namespace CurveFitting
Expand Down
21 changes: 19 additions & 2 deletions Code/Mantid/Framework/CurveFitting/src/PlotPeakByLogValue.cpp
Expand Up @@ -9,6 +9,7 @@
#include <algorithm>
#include <Poco/StringTokenizer.h>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/replace.hpp>

#include "MantidCurveFitting/PlotPeakByLogValue.h"
#include "MantidAPI/AlgorithmManager.h"
Expand Down Expand Up @@ -244,7 +245,7 @@ void PlotPeakByLogValue::exec() {
<< " with " << std::endl;
g_log.debug() << ifun->asString() << std::endl;

std::string spectrum_index = boost::lexical_cast<std::string>(j);
const std::string spectrum_index = boost::lexical_cast<std::string>(j);
std::string wsBaseName = "";

if (createFitOutput)
Expand All @@ -259,7 +260,7 @@ void PlotPeakByLogValue::exec() {
fit->setProperty("WorkspaceIndex", j);
fit->setPropertyValue("StartX", getPropertyValue("StartX"));
fit->setPropertyValue("EndX", getPropertyValue("EndX"));
fit->setPropertyValue("Minimizer", getPropertyValue("Minimizer"));
fit->setPropertyValue("Minimizer", getMinimizerString(wsNames[i].name, spectrum_index));
fit->setPropertyValue("CostFunction", getPropertyValue("CostFunction"));
fit->setPropertyValue("MaxIterations", getPropertyValue("MaxIterations"));
fit->setProperty("CalcErrors", true);
Expand Down Expand Up @@ -554,5 +555,21 @@ PlotPeakByLogValue::makeNames() const {
return nameList;
}

/**
* Formats the minimizer string for a given spectrum from a given workspace.
*
* @param wsName Name of workspace being fitted
* @param specIndex Index of spectrum being fitted
* @return Formatted minimizer string
*/
std::string PlotPeakByLogValue::getMinimizerString(const std::string & wsName, const std::string & specIndex) const {
std::string format = getPropertyValue("Minimizer");
std::string wsBaseName = wsName + "_" + specIndex;
boost::replace_all(format, "$wsname", wsName);
boost::replace_all(format, "$wsindex", specIndex);
boost::replace_all(format, "$basename", wsBaseName);
return format;
}

} // namespace CurveFitting
} // namespace Mantid

0 comments on commit 35f2a68

Please sign in to comment.