Skip to content

Commit

Permalink
Re #9199. Changes in MDEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Apr 2, 2014
1 parent 2d563c2 commit 0fd8a20
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/FitMD.h
Expand Up @@ -65,10 +65,11 @@ namespace Mantid
virtual void createDomain(
boost::shared_ptr<API::FunctionDomain>&,
boost::shared_ptr<API::IFunctionValues>&, size_t i0);
virtual void createOutputWorkspace(const std::string& baseName,
virtual boost::shared_ptr<API::Workspace> createOutputWorkspace(const std::string& baseName,
API::IFunction_sptr function,
boost::shared_ptr<API::FunctionDomain> domain,
boost::shared_ptr<API::IFunctionValues> values);
boost::shared_ptr<API::IFunctionValues> values,
const std::string& outputWorkspacePropertyName = "OutputWorkspace");

/// Return the size of the domain to be created.
virtual size_t getDomainSize() const;
Expand Down
27 changes: 17 additions & 10 deletions Code/Mantid/Framework/MDEvents/src/FitMD.cpp
Expand Up @@ -136,35 +136,37 @@ namespace Mantid
* @param function :: The function used for the calculation
* @param domain :: A pointer to the input domain
* @param ivalues :: A pointer to the calculated values
* @param outputWorkspacePropertyName :: The property name
*/
void FitMD::createOutputWorkspace(const std::string& baseName,
boost::shared_ptr<API::Workspace> FitMD::createOutputWorkspace(const std::string& baseName,
API::IFunction_sptr,
boost::shared_ptr<API::FunctionDomain> domain,
boost::shared_ptr<API::IFunctionValues> ivalues)
boost::shared_ptr<API::IFunctionValues> ivalues,
const std::string& outputWorkspacePropertyName)
{
auto values = boost::dynamic_pointer_cast<API::FunctionValues>(ivalues);
if (!values)
{
return;
return boost::shared_ptr<API::Workspace>();
}
auto functionMD = boost::dynamic_pointer_cast<API::FunctionDomainMD>(domain);
if(!functionMD)
{
return;
return boost::shared_ptr<API::Workspace>();
}
API::IMDWorkspace_const_sptr domainWS = functionMD->getWorkspace();
auto inputWS = boost::dynamic_pointer_cast<const API::IMDEventWorkspace>(domainWS);
if(!inputWS)
{
return;
return boost::shared_ptr<API::Workspace>();
}
auto outputWS = MDEventFactory::CreateMDWorkspace(inputWS->getNumDims(), "MDEvent");
// Add events
// TODO: Generalize to ND (the current framework is a bit limiting)
auto mdWS = boost::dynamic_pointer_cast<MDEvents::MDEventWorkspace<MDEvents::MDEvent<4>,4> >(outputWS);
if(!mdWS)
{
return;
return boost::shared_ptr<API::Workspace>();
}

// Bins extents and meta data
Expand Down Expand Up @@ -223,10 +225,15 @@ namespace Mantid
API::MemoryManager::Instance().releaseFreeMemory();

// Store it
declareProperty(new API::WorkspaceProperty<API::IMDEventWorkspace>("OutputWorkspace","",Direction::Output),
"Name of the output Workspace holding resulting simulated spectrum");
m_manager->setPropertyValue("OutputWorkspace",baseName+"Workspace");
m_manager->setProperty("OutputWorkspace",outputWS);
if ( !outputWorkspacePropertyName.empty() )
{
declareProperty(new API::WorkspaceProperty<API::IMDEventWorkspace>(outputWorkspacePropertyName,"",Direction::Output),
"Name of the output Workspace holding resulting simulated spectrum");
m_manager->setPropertyValue(outputWorkspacePropertyName,baseName+"Workspace");
m_manager->setProperty(outputWorkspacePropertyName,outputWS);
}

return outputWS;
}

/**
Expand Down

0 comments on commit 0fd8a20

Please sign in to comment.