Mantid
Loading...
Searching...
No Matches
TableWorkspaceDomainCreator.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
13#include "MantidCurveFitting/DllConfig.h"
16
17#include <list>
18#include <memory>
19#include <utility>
20
21namespace Mantid {
22namespace API {
23class FunctionDomain;
24class FunctionDomain1D;
25class FunctionValues;
26class TableWorkspace;
27} // namespace API
28
29namespace CurveFitting {
30
31class MANTID_CURVEFITTING_DLL TableWorkspaceDomainCreator : public API::IDomainCreator {
32public:
33 // Constructor
34 TableWorkspaceDomainCreator(Kernel::IPropertyManager *fit, const std::string &workspacePropertyName,
35 DomainType domainType = Simple);
37 TableWorkspaceDomainCreator(DomainType domainType = Simple);
38
39 // Declare properties that specify the dataset within the workspace to fit to.
40 void declareDatasetProperties(const std::string &suffix = "", bool addProp = true) override;
41
42 // Create a domain from the input workspace
43 void createDomain(std::shared_ptr<API::FunctionDomain> &domain, std::shared_ptr<API::FunctionValues> &values,
44 size_t i0 = 0) override;
45
46 // Create an output workspace.
47 std::shared_ptr<API::Workspace> createOutputWorkspace(const std::string &baseName, API::IFunction_sptr function,
48 std::shared_ptr<API::FunctionDomain> domain,
49 std::shared_ptr<API::FunctionValues> values,
50 const std::string &outputWorkspacePropertyName) override;
51
54 void setWorkspace(API::ITableWorkspace_sptr ws) { m_tableWorkspace = std::move(ws); }
58 void setRange(double startX, double endX) {
59 m_startX = startX;
60 m_endX = endX;
61 }
64 void setMaxSize(size_t maxSize) { m_maxSize = maxSize; }
65
70 void setColumnNames(const std::string &xColName, const std::string &yColName, const std::string &errColName) const {
71 m_xColName = xColName;
72 m_yColName = yColName;
73 m_errColName = errColName;
74 }
75
76 size_t getDomainSize() const override;
77
78 void initFunction(API::IFunction_sptr function) override;
79
80private:
82 std::pair<size_t, size_t> getXInterval(std::vector<double> XData) const;
84 void setParameters() const;
86 void setXYEColumnNames(const API::ITableWorkspace_sptr &ws) const;
88 std::shared_ptr<API::MatrixWorkspace> createEmptyResultWS(const size_t nhistograms, const size_t nyvalues);
90 void setInitialValues(API::IFunction &function);
91 // Unrolls function into its constituent parts if it is a composite and adds
92 // it to the list. Note this is recursive
93 void appendCompositeFunctionMembers(std::list<API::IFunction_sptr> &functionList,
94 const API::IFunction_sptr &function) const;
95 // Create separate Convolutions for each component of the model of a
96 // convolution
97 void appendConvolvedCompositeFunctionMembers(std::list<API::IFunction_sptr> &functionList,
98 const API::IFunction_sptr &function) const;
100 void addFunctionValuesToWS(const API::IFunction_sptr &function, std::shared_ptr<API::MatrixWorkspace> &ws,
101 const size_t wsIndex, const std::shared_ptr<API::FunctionDomain> &domain,
102 const std::shared_ptr<API::FunctionValues> &resultValues) const;
104 void setAndValidateWorkspace(const API::Workspace_sptr &ws) const;
105
118
122 mutable double m_startX;
124 mutable double m_endX;
126 mutable size_t m_maxSize;
128 mutable std::vector<double> m_exclude;
130 std::weak_ptr<API::FunctionDomain1D> m_domain;
131 std::weak_ptr<API::FunctionValues> m_values;
136
140 mutable std::string m_xColName;
142 mutable std::string m_yColName;
144 mutable std::string m_errColName;
145
147 mutable bool m_noErrCol;
148};
149
150} // namespace CurveFitting
151} // namespace Mantid
An base class for domain creators for use in Fit.
DomainType
Type of domain to create.
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163
std::string m_startXPropertyName
Store startX property name.
size_t m_startRowNo
Store number of the first row used in fitting.
std::string m_workspacePropertyName
Store workspace property name.
std::string m_maxSizePropertyName
Store maxSize property name.
std::weak_ptr< API::FunctionDomain1D > m_domain
Store the created domain and values.
void setWorkspace(API::ITableWorkspace_sptr ws)
Set the workspace.
bool m_noErrCol
Flag to indicate if no error column was found.
void setRange(double startX, double endX)
Set the startX and endX.
std::vector< double > m_exclude
Ranges that must be excluded from fit.
std::string m_yColumnPropertyName
Store YColumnName property name.
std::string m_xColumnPropertyName
Store XColumnName property name.
std::string m_errColName
Store the Y Error column name.
std::string m_excludePropertyName
Store the Exclude property name.
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.
void setMaxSize(size_t maxSize)
Set max size for Sequential and Parallel domains.
API::ITableWorkspace_sptr m_tableWorkspace
The input TableWorkspace.
std::string m_errorColumnPropertyName
Store errorColumnName property name.
Interface to PropertyManager.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
Helper class which provides the Collimation Length for SANS instruments.