Skip to content

Commit

Permalink
Group the output workspaces
Browse files Browse the repository at this point in the history
Refs #11651
  • Loading branch information
DanNixon committed May 1, 2015
1 parent 35f2a68 commit 73794ae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Expand Up @@ -109,7 +109,9 @@ class DLLExport PlotPeakByLogValue : public API::Algorithm {
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;
std::string getMinimizerString(const std::string & wsName, const std::string & specIndex);

std::map<std::string, std::vector<std::string>> m_minimizerWorkspaces;
};

} // namespace CurveFitting
Expand Down
33 changes: 32 additions & 1 deletion Code/Mantid/Framework/CurveFitting/src/PlotPeakByLogValue.cpp
Expand Up @@ -12,6 +12,7 @@
#include <boost/algorithm/string/replace.hpp>

#include "MantidCurveFitting/PlotPeakByLogValue.h"
#include "MantidAPI/IFuncMinimizer.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/FuncMinimizerFactory.h"
#include "MantidAPI/CostFunctionFactory.h"
Expand All @@ -28,6 +29,11 @@
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/MandatoryValidator.h"

namespace
{
Mantid::Kernel::Logger g_log("PlotPeakByLogValue");
}

namespace Mantid {
namespace CurveFitting {

Expand Down Expand Up @@ -341,6 +347,17 @@ void PlotPeakByLogValue::exec() {
groupAlg->setProperty("OutputWorkspace", baseName + "_Workspaces");
groupAlg->execute();
}

for(auto it = m_minimizerWorkspaces.begin(); it != m_minimizerWorkspaces.end(); ++it)
{
const std::string paramName = (*it).first;
API::IAlgorithm_sptr groupAlg =
AlgorithmManager::Instance().createUnmanaged("GroupWorkspaces");
groupAlg->initialize();
groupAlg->setProperty("InputWorkspaces", (*it).second);
groupAlg->setProperty("OutputWorkspace", baseName + "_" + paramName);
groupAlg->execute();
}
}

/** Get a workspace identified by an InputData structure.
Expand Down Expand Up @@ -562,12 +579,26 @@ PlotPeakByLogValue::makeNames() const {
* @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 PlotPeakByLogValue::getMinimizerString(const std::string & wsName, const std::string & specIndex) {
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);

auto minimizer = FuncMinimizerFactory::Instance().createMinimizer(format);
auto minimizerProps = minimizer->getProperties();
for(auto it = minimizerProps.begin(); it != minimizerProps.end(); ++it)
{
Mantid::API::WorkspaceProperty<> *wsProp = dynamic_cast<Mantid::API::WorkspaceProperty<> *>(*it);
if(wsProp)
{
std::string wsPropName = (*it)->name();
std::string wsPropValue = (*it)->value();
m_minimizerWorkspaces[wsPropName].push_back(wsPropValue);
}
}

return format;
}

Expand Down

0 comments on commit 73794ae

Please sign in to comment.