Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mantid::CurveFitting::IMWDomainCreator Class Reference

A base class for domain creators taking 1D data from a spectrum of a matrix workspace. More...

#include <IMWDomainCreator.h>

Inheritance diagram for Mantid::CurveFitting::IMWDomainCreator:
Mantid::API::IDomainCreator Mantid::CurveFitting::FitMW Mantid::CurveFitting::HistogramDomainCreator

Public Member Functions

std::shared_ptr< API::WorkspacecreateOutputWorkspace (const std::string &baseName, API::IFunction_sptr function, std::shared_ptr< API::FunctionDomain > domain, std::shared_ptr< API::FunctionValues > values, const std::string &outputWorkspacePropertyName) override
 Create an output workspace. More...
 
void declareDatasetProperties (const std::string &suffix="", bool addProp=true) override
 Declare properties that specify the dataset within the workspace to fit to. More...
 
size_t getDomainSize () const override
 Return the size of the domain to be created. More...
 
 IMWDomainCreator (Kernel::IPropertyManager *fit, const std::string &workspacePropertyName, DomainType domainType=Simple)
 Constructor. More...
 
void initFunction (API::IFunction_sptr function) override
 Initialize the function. More...
 
void setRange (double startX, double endX)
 Set the startX and endX. More...
 
void setWorkspace (std::shared_ptr< API::MatrixWorkspace > ws)
 Set the workspace. More...
 
void setWorkspaceIndex (size_t wi)
 Set the workspace index. More...
 
- Public Member Functions inherited from Mantid::API::IDomainCreator
virtual void createDomain (std::shared_ptr< API::FunctionDomain > &domain, std::shared_ptr< API::FunctionValues > &values, size_t i0=0)=0
 Create a domain and values from the input workspace. More...
 
virtual std::shared_ptr< API::WorkspacecreateOutputWorkspace (const std::string &baseName, API::IFunction_sptr function, std::shared_ptr< API::FunctionDomain > domain, std::shared_ptr< API::FunctionValues > values, const std::string &outputWorkspacePropertyName="OutputWorkspace")
 Create an output workspace filled with data simulated with the fitting function. More...
 
virtual void declareDatasetProperties (const std::string &suffix="", bool addProp=true)
 Declare properties that specify the dataset within the workspace to fit to. More...
 
virtual size_t getDomainSize () const =0
 Return the size of the domain to be created. More...
 
 IDomainCreator (Kernel::IPropertyManager *manager, std::vector< std::string > workspacePropertyNames, DomainType domainType=Simple)
 Constrcutor. More...
 
void ignoreInvalidData (bool yes)
 Set to ignore invalid data. More...
 
virtual void initFunction (API::IFunction_sptr function)
 Initialize the function. More...
 
virtual void initialize (Kernel::IPropertyManager *, const std::string &, DomainType)
 Initialize. More...
 
void separateCompositeMembersInOutput (const bool value, const bool conv=false)
 Toggle output of either just composite or composite + members. More...
 
virtual ~IDomainCreator ()=default
 Virtual destructor. More...
 

Protected Member Functions

void addFunctionValuesToWS (const API::IFunction_sptr &function, std::shared_ptr< API::MatrixWorkspace > &ws, const size_t wsIndex, const std::shared_ptr< API::FunctionDomain > &domain, const std::shared_ptr< API::FunctionValues > &resultValues) const
 Add the calculated function values to the workspace. More...
 
void appendCompositeFunctionMembers (std::list< API::IFunction_sptr > &functionList, const API::IFunction_sptr &function) const
 
void appendConvolvedCompositeFunctionMembers (std::list< API::IFunction_sptr > &functionList, const API::IFunction_sptr &function) const
 If the fit function is Convolution and flag m_convolutionCompositeMembers is set and Convolution's second function (the model) is composite then use members of the model for the output. More...
 
std::shared_ptr< API::MatrixWorkspacecreateEmptyResultWS (const size_t nhistograms, const size_t nyvalues)
 Creates the blank output workspace of the correct size. More...
 
std::pair< size_t, size_t > getXInterval () const
 Calculate size and starting iterator in the X array. More...
 
void setInitialValues (API::IFunction &function)
 Set initial values for parameters with default values. More...
 
virtual void setParameters () const
 Set all parameters. More...
 
- Protected Member Functions inherited from Mantid::API::IDomainCreator
void declareProperty (Kernel::Property *prop, const std::string &doc)
 Declare a property to the algorithm. More...
 

Protected Attributes

std::weak_ptr< API::FunctionDomain1Dm_domain
 Store the created domain and values. More...
 
double m_endX
 endX More...
 
std::string m_endXPropertyName
 Store endX property name. More...
 
std::shared_ptr< API::MatrixWorkspacem_matrixWorkspace
 The input MareixWorkspace. More...
 
size_t m_startIndex
 
double m_startX
 startX More...
 
std::string m_startXPropertyName
 Store startX property name. More...
 
std::weak_ptr< API::FunctionValuesm_values
 
size_t m_workspaceIndex
 The workspace index. More...
 
std::string m_workspaceIndexPropertyName
 Store workspace index property name. More...
 
std::string m_workspacePropertyName
 Store workspace property name. More...
 
- Protected Attributes inherited from Mantid::API::IDomainCreator
bool m_convolutionCompositeMembers
 Perform convolution of output composite components. More...
 
DomainType m_domainType
 Domain type. More...
 
bool m_ignoreInvalidData
 Flag to ignore nans, infinities and zero errors. More...
 
Kernel::IPropertyManagerm_manager
 Pointer to a property manager. More...
 
bool m_outputCompositeMembers
 Output separate composite function values. More...
 
std::vector< std::string > m_workspacePropertyNames
 Property names for workspaces to get the data from. More...
 

Additional Inherited Members

- Public Types inherited from Mantid::API::IDomainCreator
enum  DomainType { Simple = 0 , Sequential , Parallel }
 Type of domain to create. More...
 

Detailed Description

A base class for domain creators taking 1D data from a spectrum of a matrix workspace.

Definition at line 34 of file IMWDomainCreator.h.

Constructor & Destructor Documentation

◆ IMWDomainCreator()

Mantid::CurveFitting::IMWDomainCreator::IMWDomainCreator ( Kernel::IPropertyManager fit,
const std::string &  workspacePropertyName,
IMWDomainCreator::DomainType  domainType = Simple 
)

Constructor.

Parameters
fit:: Property manager with properties defining the domain to be created
workspacePropertyName:: Name of the workspace property.
domainType:: Type of the domain: Simple, Sequential, or Parallel.

Definition at line 50 of file IMWDomainCreator.cpp.

References m_workspacePropertyName, and Mantid::API::IDomainCreator::m_workspacePropertyNames.

Member Function Documentation

◆ addFunctionValuesToWS()

void Mantid::CurveFitting::IMWDomainCreator::addFunctionValuesToWS ( const API::IFunction_sptr function,
std::shared_ptr< API::MatrixWorkspace > &  ws,
const size_t  wsIndex,
const std::shared_ptr< API::FunctionDomain > &  domain,
const std::shared_ptr< API::FunctionValues > &  resultValues 
) const
protected

Add the calculated function values to the workspace.

Estimate an error for each calculated value.

Parameters
functionThe function to evaluate
wsA workspace to fill
wsIndexThe index to store the values
domainThe domain to calculate the values over
resultValuesA presized values holder for the results

Definition at line 379 of file IMWDomainCreator.cpp.

References Mantid::Geometry::d, Mantid::API::Jacobian::get(), sigma, and tmp.

Referenced by createOutputWorkspace().

◆ appendCompositeFunctionMembers()

void Mantid::CurveFitting::IMWDomainCreator::appendCompositeFunctionMembers ( std::list< API::IFunction_sptr > &  functionList,
const API::IFunction_sptr function 
) const
protected
Parameters
functionListThe current list of functions to append to
functionA function that may or not be composite

Definition at line 314 of file IMWDomainCreator.cpp.

References appendCompositeFunctionMembers(), appendConvolvedCompositeFunctionMembers(), and Mantid::API::IDomainCreator::m_convolutionCompositeMembers.

Referenced by appendCompositeFunctionMembers(), and createOutputWorkspace().

◆ appendConvolvedCompositeFunctionMembers()

void Mantid::CurveFitting::IMWDomainCreator::appendConvolvedCompositeFunctionMembers ( std::list< API::IFunction_sptr > &  functionList,
const API::IFunction_sptr function 
) const
protected

If the fit function is Convolution and flag m_convolutionCompositeMembers is set and Convolution's second function (the model) is composite then use members of the model for the output.

Parameters
functionList:: A list of Convolutions constructed from the resolution of the fitting function (index 0) and members of the model.
functionA Convolution function which model may or may not be a composite function.
Returns
True if all conditions are fulfilled and it is possible to produce the output.

Definition at line 350 of file IMWDomainCreator.cpp.

Referenced by appendCompositeFunctionMembers().

◆ createEmptyResultWS()

API::MatrixWorkspace_sptr Mantid::CurveFitting::IMWDomainCreator::createEmptyResultWS ( const size_t  nhistograms,
const size_t  nyvalues 
)
protected

Creates the blank output workspace of the correct size.

Creates a workspace to hold the results.

If the input workspace contains histogram data then so will this It assigns the X and input data values but no Y,E data for any functions

Parameters
nhistogramsThe number of histograms
nyvaluesThe number of y values to hold

Definition at line 197 of file IMWDomainCreator.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance(), m_matrixWorkspace, m_startIndex, and m_workspaceIndex.

Referenced by createOutputWorkspace().

◆ createOutputWorkspace()

std::shared_ptr< API::Workspace > Mantid::CurveFitting::IMWDomainCreator::createOutputWorkspace ( const std::string &  baseName,
API::IFunction_sptr  function,
std::shared_ptr< API::FunctionDomain domain,
std::shared_ptr< API::FunctionValues values,
const std::string &  outputWorkspacePropertyName 
)
overridevirtual

Create an output workspace.

Create an output workspace with the calculated values.

Parameters
baseName:: Specifies the name of the output workspace
function:: A Pointer to the fitting function
domain:: The domain containing x-values for the function
values:: A API::FunctionValues instance containing the fitting data
outputWorkspacePropertyName:: The property name

Reimplemented from Mantid::API::IDomainCreator.

Definition at line 244 of file IMWDomainCreator.cpp.

References addFunctionValuesToWS(), appendCompositeFunctionMembers(), createEmptyResultWS(), Mantid::API::IDomainCreator::declareProperty(), Mantid::API::IDomainCreator::m_manager, m_matrixWorkspace, Mantid::API::IDomainCreator::m_outputCompositeMembers, Mantid::Kernel::Direction::Output, Mantid::API::TextAxis::setLabel(), Mantid::Kernel::IPropertyManager::setProperty(), and Mantid::Kernel::IPropertyManager::setPropertyValue().

Referenced by Mantid::CurveFitting::FitMW::createOutputWorkspace(), and Mantid::CurveFitting::HistogramDomainCreator::createOutputWorkspace().

◆ declareDatasetProperties()

void Mantid::CurveFitting::IMWDomainCreator::declareDatasetProperties ( const std::string &  suffix = "",
bool  addProp = true 
)
overridevirtual

Declare properties that specify the dataset within the workspace to fit to.

Parameters
suffix:: names the dataset
addProp:: allows for the declaration of certain properties of the dataset

Reimplemented from Mantid::API::IDomainCreator.

Definition at line 87 of file IMWDomainCreator.cpp.

References Mantid::API::IDomainCreator::declareProperty(), Mantid::EMPTY_DBL(), Mantid::Kernel::IPropertyManager::existsProperty(), m_endXPropertyName, Mantid::API::IDomainCreator::m_manager, m_startXPropertyName, and m_workspaceIndexPropertyName.

Referenced by Mantid::CurveFitting::FitMW::declareDatasetProperties().

◆ getDomainSize()

size_t Mantid::CurveFitting::IMWDomainCreator::getDomainSize ( ) const
overridevirtual

Return the size of the domain to be created.

Implements Mantid::API::IDomainCreator.

Definition at line 169 of file IMWDomainCreator.cpp.

References getXInterval(), and setParameters().

◆ getXInterval()

std::pair< size_t, size_t > Mantid::CurveFitting::IMWDomainCreator::getXInterval ( ) const
protected

Calculate size and starting iterator in the X array.

Returns
:: A pair of start iterator and size of the data.

Definition at line 112 of file IMWDomainCreator.cpp.

References Mantid::EMPTY_DBL(), m_endX, m_matrixWorkspace, m_startX, m_workspaceIndex, setParameters(), and Mantid::Geometry::X.

Referenced by Mantid::CurveFitting::FitMW::createDomain(), Mantid::CurveFitting::HistogramDomainCreator::createDomain(), and getDomainSize().

◆ initFunction()

void Mantid::CurveFitting::IMWDomainCreator::initFunction ( API::IFunction_sptr  function)
overridevirtual

Initialize the function.

Initialize the function with the workspace.

Parameters
function:: Function to initialize.

Reimplemented from Mantid::API::IDomainCreator.

Definition at line 180 of file IMWDomainCreator.cpp.

References m_endX, m_matrixWorkspace, m_startX, m_workspaceIndex, setInitialValues(), and setParameters().

◆ setInitialValues()

void Mantid::CurveFitting::IMWDomainCreator::setInitialValues ( API::IFunction function)
protected

Set initial values for parameters with default values.

Parameters
function: A function to set parameters for.

Definition at line 228 of file IMWDomainCreator.cpp.

References Mantid::CurveFitting::ParameterEstimator::estimate(), m_domain, and m_values.

Referenced by initFunction().

◆ setParameters()

void Mantid::CurveFitting::IMWDomainCreator::setParameters ( ) const
protectedvirtual

◆ setRange()

void Mantid::CurveFitting::IMWDomainCreator::setRange ( double  startX,
double  endX 
)
inline

Set the startX and endX.

Parameters
startX:: Start of the domain
endX:: End of the domain

Definition at line 60 of file IMWDomainCreator.h.

◆ setWorkspace()

void Mantid::CurveFitting::IMWDomainCreator::setWorkspace ( std::shared_ptr< API::MatrixWorkspace ws)
inline

Set the workspace.

Parameters
ws:: workspace to set.

Definition at line 53 of file IMWDomainCreator.h.

Referenced by Mantid::CurveFitting::FitMW::createDomain().

◆ setWorkspaceIndex()

void Mantid::CurveFitting::IMWDomainCreator::setWorkspaceIndex ( size_t  wi)
inline

Set the workspace index.

Parameters
wi:: workspace index to set.

Definition at line 56 of file IMWDomainCreator.h.

Member Data Documentation

◆ m_domain

std::weak_ptr<API::FunctionDomain1D> Mantid::CurveFitting::IMWDomainCreator::m_domain
mutableprotected

◆ m_endX

double Mantid::CurveFitting::IMWDomainCreator::m_endX
mutableprotected

endX

Definition at line 104 of file IMWDomainCreator.h.

Referenced by getXInterval(), initFunction(), and setParameters().

◆ m_endXPropertyName

std::string Mantid::CurveFitting::IMWDomainCreator::m_endXPropertyName
protected

Store endX property name.

Definition at line 95 of file IMWDomainCreator.h.

Referenced by declareDatasetProperties(), and setParameters().

◆ m_matrixWorkspace

std::shared_ptr<API::MatrixWorkspace> Mantid::CurveFitting::IMWDomainCreator::m_matrixWorkspace
mutableprotected

◆ m_startIndex

size_t Mantid::CurveFitting::IMWDomainCreator::m_startIndex
protected

◆ m_startX

double Mantid::CurveFitting::IMWDomainCreator::m_startX
mutableprotected

startX

Definition at line 102 of file IMWDomainCreator.h.

Referenced by getXInterval(), initFunction(), and setParameters().

◆ m_startXPropertyName

std::string Mantid::CurveFitting::IMWDomainCreator::m_startXPropertyName
protected

Store startX property name.

Definition at line 93 of file IMWDomainCreator.h.

Referenced by declareDatasetProperties(), and setParameters().

◆ m_values

std::weak_ptr<API::FunctionValues> Mantid::CurveFitting::IMWDomainCreator::m_values
mutableprotected

◆ m_workspaceIndex

size_t Mantid::CurveFitting::IMWDomainCreator::m_workspaceIndex
mutableprotected

◆ m_workspaceIndexPropertyName

std::string Mantid::CurveFitting::IMWDomainCreator::m_workspaceIndexPropertyName
protected

Store workspace index property name.

Definition at line 91 of file IMWDomainCreator.h.

Referenced by declareDatasetProperties(), and setParameters().

◆ m_workspacePropertyName

std::string Mantid::CurveFitting::IMWDomainCreator::m_workspacePropertyName
protected

Store workspace property name.

Definition at line 89 of file IMWDomainCreator.h.

Referenced by IMWDomainCreator(), and setParameters().


The documentation for this class was generated from the following files: