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

#include <TableWorkspaceDomainCreator.h>

Inheritance diagram for Mantid::CurveFitting::TableWorkspaceDomainCreator:
Mantid::API::IDomainCreator

Public Member Functions

void createDomain (std::shared_ptr< API::FunctionDomain > &domain, std::shared_ptr< API::FunctionValues > &values, size_t i0=0) override
 Create a domain from the input workspace. More...
 
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 with the calculated values. 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...
 
void initFunction (API::IFunction_sptr function) override
 Initialize the function with the workspace. More...
 
void setColumnNames (const std::string &xColName, const std::string &yColName, const std::string &errColName) const
 Set the names Of the x, y and error columns. More...
 
void setMaxSize (size_t maxSize)
 Set max size for Sequential and Parallel domains. More...
 
void setRange (double startX, double endX)
 Set the startX and endX. More...
 
void setWorkspace (API::ITableWorkspace_sptr ws)
 Set the workspace. More...
 
 TableWorkspaceDomainCreator (DomainType domainType=Simple)
 Constructor. More...
 
 TableWorkspaceDomainCreator (Kernel::IPropertyManager *fit, const std::string &workspacePropertyName, DomainType domainType=Simple)
 Constructor. 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...
 

Private 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 (std::vector< double > XData) const
 Calculate size and starting iterator in the X array. More...
 
void setAndValidateWorkspace (const API::Workspace_sptr &ws) const
 Check workspace is in the correct form. More...
 
void setInitialValues (API::IFunction &function)
 Set initial values for parameters with default values. More...
 
void setParameters () const
 Set all parameters. More...
 
void setXYEColumnNames (const API::ITableWorkspace_sptr &ws) const
 Set the names of the X, Y and Error columns. More...
 

Private 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::string m_errColName
 Store the Y Error column name. More...
 
std::string m_errorColumnPropertyName
 Store errorColumnName property name. More...
 
std::vector< double > m_exclude
 Ranges that must be excluded from fit. More...
 
std::string m_excludePropertyName
 Store the Exclude property name. More...
 
size_t m_maxSize
 Max size for seq domain. More...
 
std::string m_maxSizePropertyName
 Store maxSize property name. More...
 
bool m_noErrCol
 Flag to indicate if no error column was found. More...
 
size_t m_startRowNo
 Store number of the first row used in fitting. More...
 
double m_startX
 startX More...
 
std::string m_startXPropertyName
 Store startX property name. More...
 
API::ITableWorkspace_sptr m_tableWorkspace
 The input TableWorkspace. More...
 
std::weak_ptr< API::FunctionValuesm_values
 
std::string m_workspacePropertyName
 Store workspace property name. More...
 
std::string m_xColName
 Store the X column name. More...
 
std::string m_xColumnPropertyName
 Store XColumnName property name. More...
 
std::string m_yColName
 Store the Y column name. More...
 
std::string m_yColumnPropertyName
 Store YColumnName property name. More...
 

Additional Inherited Members

- Public Types inherited from Mantid::API::IDomainCreator
enum  DomainType { Simple = 0 , Sequential , Parallel }
 Type of domain to create. 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 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...
 

Detailed Description

Definition at line 31 of file TableWorkspaceDomainCreator.h.

Constructor & Destructor Documentation

◆ TableWorkspaceDomainCreator() [1/2]

Mantid::CurveFitting::TableWorkspaceDomainCreator::TableWorkspaceDomainCreator ( Kernel::IPropertyManager fit,
const std::string &  workspacePropertyName,
TableWorkspaceDomainCreator::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 122 of file TableWorkspaceDomainCreator.cpp.

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

◆ TableWorkspaceDomainCreator() [2/2]

Mantid::CurveFitting::TableWorkspaceDomainCreator::TableWorkspaceDomainCreator ( TableWorkspaceDomainCreator::DomainType  domainType = Simple)

Constructor.

Methods setWorkspace and setRange must becalled set up the creator.

Parameters
domainType:: Type of the domain: Simple, Sequential, or Parallel.

Definition at line 138 of file TableWorkspaceDomainCreator.cpp.

Member Function Documentation

◆ addFunctionValuesToWS()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::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
private

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 428 of file TableWorkspaceDomainCreator.cpp.

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

Referenced by createOutputWorkspace().

◆ appendCompositeFunctionMembers()

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

Definition at line 363 of file TableWorkspaceDomainCreator.cpp.

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

Referenced by appendCompositeFunctionMembers(), and createOutputWorkspace().

◆ appendConvolvedCompositeFunctionMembers()

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

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 399 of file TableWorkspaceDomainCreator.cpp.

Referenced by appendCompositeFunctionMembers().

◆ createDomain()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::createDomain ( std::shared_ptr< API::FunctionDomain > &  domain,
std::shared_ptr< API::FunctionValues > &  values,
size_t  i0 = 0 
)
overridevirtual

◆ createEmptyResultWS()

API::MatrixWorkspace_sptr Mantid::CurveFitting::TableWorkspaceDomainCreator::createEmptyResultWS ( const size_t  nhistograms,
const size_t  nyvalues 
)
private

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 533 of file TableWorkspaceDomainCreator.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance(), m_errColName, m_startRowNo, m_tableWorkspace, m_xColName, and m_yColName.

Referenced by createOutputWorkspace().

◆ createOutputWorkspace()

std::shared_ptr< API::Workspace > Mantid::CurveFitting::TableWorkspaceDomainCreator::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 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 299 of file TableWorkspaceDomainCreator.cpp.

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

◆ declareDatasetProperties()

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

◆ getDomainSize()

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

Return the size of the domain to be created.

Implements Mantid::API::IDomainCreator.

Definition at line 573 of file TableWorkspaceDomainCreator.cpp.

References getXInterval(), m_tableWorkspace, m_xColName, setParameters(), and Mantid::Geometry::X.

◆ getXInterval()

std::pair< size_t, size_t > Mantid::CurveFitting::TableWorkspaceDomainCreator::getXInterval ( std::vector< double >  xData) const
private

Calculate size and starting iterator in the X array.

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

Definition at line 615 of file TableWorkspaceDomainCreator.cpp.

References Mantid::EMPTY_DBL(), m_endX, m_startX, and setParameters().

Referenced by createDomain(), and getDomainSize().

◆ initFunction()

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

Initialize the function with the workspace.

Parameters
function:: Function to initialize.

Reimplemented from Mantid::API::IDomainCreator.

Definition at line 590 of file TableWorkspaceDomainCreator.cpp.

References m_tableWorkspace, setInitialValues(), and setParameters().

◆ setAndValidateWorkspace()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::setAndValidateWorkspace ( const API::Workspace_sptr ws) const
private

Check workspace is in the correct form.

Set the table workspace.

Clones the input workspace and makes workspace into form: x data | y data | error data

Exceptions
std::runtime_errorif the Exclude property has an odd number of entries.

Definition at line 756 of file TableWorkspaceDomainCreator.cpp.

References m_errColName, m_noErrCol, m_tableWorkspace, m_xColName, m_yColName, and setXYEColumnNames().

Referenced by setParameters().

◆ setColumnNames()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::setColumnNames ( const std::string &  xColName,
const std::string &  yColName,
const std::string &  errColName 
) const
inline

Set the names Of the x, y and error columns.

Parameters
xColName:: name of the x column
yColName:: name of the y column
errColName:: name of the y error column

Definition at line 70 of file TableWorkspaceDomainCreator.h.

Referenced by setXYEColumnNames().

◆ setInitialValues()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::setInitialValues ( API::IFunction function)
private

Set initial values for parameters with default values.

Parameters
function: A function to set parameters for.

Definition at line 603 of file TableWorkspaceDomainCreator.cpp.

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

Referenced by initFunction().

◆ setMaxSize()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::setMaxSize ( size_t  maxSize)
inline

Set max size for Sequential and Parallel domains.

Parameters
maxSize:: Maximum size of each simple domain

Definition at line 64 of file TableWorkspaceDomainCreator.h.

◆ setParameters()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::setParameters ( ) const
private

◆ setRange()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::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 58 of file TableWorkspaceDomainCreator.h.

◆ setWorkspace()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::setWorkspace ( API::ITableWorkspace_sptr  ws)
inline

Set the workspace.

Parameters
ws:: workspace to set.

Definition at line 54 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain().

◆ setXYEColumnNames()

void Mantid::CurveFitting::TableWorkspaceDomainCreator::setXYEColumnNames ( const API::ITableWorkspace_sptr ws) const
private

Set the names of the X, Y and Error columns.

Get the X, Y and Error column names as a vector.

If no error column is found there will only be 2 entries in the vector. Gets the name from arguments if specified otherwise it check if any columns have been set as plot type X, Y or Yerror. If none found it will return an error

Returns
:: a vector containing the X and Y column names and the error column if it has been set
Exceptions
std::invalid_argumentif no X or Y value can be found or are of the wrong type.

Definition at line 701 of file TableWorkspaceDomainCreator.cpp.

References Mantid::Kernel::IPropertyManager::getProperty(), m_errorColumnPropertyName, Mantid::API::IDomainCreator::m_manager, m_xColumnPropertyName, m_yColumnPropertyName, and setColumnNames().

Referenced by setAndValidateWorkspace().

Member Data Documentation

◆ m_domain

std::weak_ptr<API::FunctionDomain1D> Mantid::CurveFitting::TableWorkspaceDomainCreator::m_domain
private

Store the created domain and values.

Definition at line 130 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), and setInitialValues().

◆ m_endX

double Mantid::CurveFitting::TableWorkspaceDomainCreator::m_endX
mutableprivate

endX

Definition at line 124 of file TableWorkspaceDomainCreator.h.

Referenced by getXInterval(), and setParameters().

◆ m_endXPropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_endXPropertyName
private

Store endX property name.

Definition at line 111 of file TableWorkspaceDomainCreator.h.

Referenced by declareDatasetProperties(), and setParameters().

◆ m_errColName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_errColName
mutableprivate

Store the Y Error column name.

Definition at line 144 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), createEmptyResultWS(), and setAndValidateWorkspace().

◆ m_errorColumnPropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_errorColumnPropertyName
private

Store errorColumnName property name.

Definition at line 117 of file TableWorkspaceDomainCreator.h.

Referenced by declareDatasetProperties(), and setXYEColumnNames().

◆ m_exclude

std::vector<double> Mantid::CurveFitting::TableWorkspaceDomainCreator::m_exclude
mutableprivate

Ranges that must be excluded from fit.

Definition at line 128 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), and setParameters().

◆ m_excludePropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_excludePropertyName
private

Store the Exclude property name.

Definition at line 135 of file TableWorkspaceDomainCreator.h.

Referenced by declareDatasetProperties(), and setParameters().

◆ m_maxSize

size_t Mantid::CurveFitting::TableWorkspaceDomainCreator::m_maxSize
mutableprivate

Max size for seq domain.

Definition at line 126 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), and setParameters().

◆ m_maxSizePropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_maxSizePropertyName
private

Store maxSize property name.

Definition at line 133 of file TableWorkspaceDomainCreator.h.

Referenced by declareDatasetProperties(), and setParameters().

◆ m_noErrCol

bool Mantid::CurveFitting::TableWorkspaceDomainCreator::m_noErrCol
mutableprivate

Flag to indicate if no error column was found.

Definition at line 147 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), and setAndValidateWorkspace().

◆ m_startRowNo

size_t Mantid::CurveFitting::TableWorkspaceDomainCreator::m_startRowNo
private

Store number of the first row used in fitting.

Definition at line 138 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), and createEmptyResultWS().

◆ m_startX

double Mantid::CurveFitting::TableWorkspaceDomainCreator::m_startX
mutableprivate

startX

Definition at line 122 of file TableWorkspaceDomainCreator.h.

Referenced by getXInterval(), and setParameters().

◆ m_startXPropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_startXPropertyName
private

Store startX property name.

Definition at line 109 of file TableWorkspaceDomainCreator.h.

Referenced by declareDatasetProperties(), and setParameters().

◆ m_tableWorkspace

API::ITableWorkspace_sptr Mantid::CurveFitting::TableWorkspaceDomainCreator::m_tableWorkspace
mutableprivate

The input TableWorkspace.

Definition at line 120 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), createEmptyResultWS(), getDomainSize(), initFunction(), and setAndValidateWorkspace().

◆ m_values

std::weak_ptr<API::FunctionValues> Mantid::CurveFitting::TableWorkspaceDomainCreator::m_values
private

Definition at line 131 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), and setInitialValues().

◆ m_workspacePropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_workspacePropertyName
private

Store workspace property name.

Definition at line 107 of file TableWorkspaceDomainCreator.h.

Referenced by setParameters(), and TableWorkspaceDomainCreator().

◆ m_xColName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_xColName
mutableprivate

Store the X column name.

Definition at line 140 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), createEmptyResultWS(), getDomainSize(), and setAndValidateWorkspace().

◆ m_xColumnPropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_xColumnPropertyName
private

Store XColumnName property name.

Definition at line 113 of file TableWorkspaceDomainCreator.h.

Referenced by declareDatasetProperties(), and setXYEColumnNames().

◆ m_yColName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_yColName
mutableprivate

Store the Y column name.

Definition at line 142 of file TableWorkspaceDomainCreator.h.

Referenced by createDomain(), createEmptyResultWS(), and setAndValidateWorkspace().

◆ m_yColumnPropertyName

std::string Mantid::CurveFitting::TableWorkspaceDomainCreator::m_yColumnPropertyName
private

Store YColumnName property name.

Definition at line 115 of file TableWorkspaceDomainCreator.h.

Referenced by declareDatasetProperties(), and setXYEColumnNames().


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