Skip to content

Commit

Permalink
Re #11711 Store fitting results in m_data in the PeakFitting step
Browse files Browse the repository at this point in the history
  • Loading branch information
raquelalvarezbanos committed May 7, 2015
1 parent f800b2b commit 5de8e0d
Showing 1 changed file with 3 additions and 30 deletions.
Expand Up @@ -19,37 +19,9 @@ namespace CustomInterfaces

MatrixWorkspace_sptr ALCPeakFittingModel::exportWorkspace()
{
if ( m_data && m_fittedPeaks) {
if ( m_data->getNumberHistograms() == 3 ) {

// Create a new workspace by cloning data one
IAlgorithm_sptr clone = AlgorithmManager::Instance().create("CloneWorkspace");
clone->setChild(true); // Don't want workspaces in ADS
clone->setProperty("InputWorkspace", boost::const_pointer_cast<MatrixWorkspace>(m_data));
clone->setProperty("OutputWorkspace", "__NotUsed");
clone->execute();

Workspace_sptr cloneResult = clone->getProperty("OutputWorkspace");

// Calculate function values for all data X values
MatrixWorkspace_sptr peaks = ALCHelper::createWsFromFunction(m_fittedPeaks, m_data->readX(0));

// Merge two workspaces
IAlgorithm_sptr join = AlgorithmManager::Instance().create("ConjoinWorkspaces");
join->setChild(true);
join->setProperty("InputWorkspace1", cloneResult);
join->setProperty("InputWorkspace2", peaks);
join->setProperty("CheckOverlapping", false);
join->execute();

MatrixWorkspace_sptr result = join->getProperty("InputWorkspace1");

// Update axis lables so that it's understandable what's what on workspace data view / plot
TextAxis* yAxis = new TextAxis(result->getNumberHistograms());
yAxis->setLabel(0,"Data");
yAxis->setLabel(1,"FittedPeaks");
result->replaceAxis(1,yAxis);

return result;
return boost::const_pointer_cast<MatrixWorkspace>(m_data);

} else {

Expand Down Expand Up @@ -84,6 +56,7 @@ namespace CustomInterfaces
fit->setProperty("CreateOutput", true);
fit->execute();

m_data = fit->getProperty("OutputWorkspace");
m_parameterTable = fit->getProperty("OutputParameters");

setFittedPeaks(static_cast<IFunction_sptr>(fit->getProperty("Function")));
Expand Down

0 comments on commit 5de8e0d

Please sign in to comment.