35 const std::string &workspacePropertyName)
37 m_workspacePropertyName(m_workspacePropertyNames.front()), m_matrixWorkspace() {}
51 std::shared_ptr<FunctionValues> &values,
size_t i0) {
55 throw std::invalid_argument(
"No matrix workspace assigned - can not create domain.");
61 for (
size_t i = 0; i < numberOfHistograms; ++i) {
65 spectrumDomain->setWorkspaceIndex(i);
71 domain.reset(seqDomain);
76 values->expand(i0 + domain->size());
101 std::shared_ptr<FunctionDomain> domain,
102 std::shared_ptr<FunctionValues> values,
103 const std::string &outputWorkspacePropertyName) {
108 std::shared_ptr<SeqDomain> seqDomain = std::dynamic_pointer_cast<SeqDomain>(domain);
111 throw std::invalid_argument(
"CreateOutputWorkspace requires SeqDomain.");
115 throw std::invalid_argument(
"No MatrixWorkspace assigned. Cannot construct "
116 "proper output workspace.");
123 for (
size_t i = 0; i < seqDomain->getNDomains(); ++i) {
127 seqDomain->getDomainAndValues(i, localDomain, localValues);
128 function->function(*localDomain, *localValues);
130 std::shared_ptr<FunctionDomain1DSpectrum> spectrumDomain =
131 std::dynamic_pointer_cast<FunctionDomain1DSpectrum>(localDomain);
133 if (spectrumDomain) {
134 size_t wsIndex = spectrumDomain->getWorkspaceIndex();
136 auto &yValues = outputWs->mutableY(wsIndex);
137 for (
size_t j = 0; j < yValues.size(); ++j) {
138 yValues[j] = localValues->getCalculated(j);
148 if (
m_manager && !outputWorkspacePropertyName.empty()) {
158 if (!std::dynamic_pointer_cast<Mantid::API::IEventWorkspace>(
m_matrixWorkspace)) {
160 outputWs->setDistribution(
true);
174 throw std::invalid_argument(
"No matrix workspace assigned.");
178 size_t totalSize = 0;
180 for (
size_t i = 0; i < nHist; ++i) {
198 if (!matrixWorkspace) {
199 throw std::invalid_argument(
"InputWorkspace must be a valid MatrixWorkspace.");
209 throw std::invalid_argument(
"No matrix workspace assigned.");
214 if (!spectrumInfo.hasDetectors(i)) {
217 return !spectrumInfo.isMasked(i);
IPeaksWorkspace_sptr workspace
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
A class to store values calculated by a function.
An base class for domain creators for use in Fit.
Kernel::IPropertyManager * m_manager
Pointer to a property manager.
void declareProperty(Kernel::Property *prop, const std::string &doc)
Declare a property to the algorithm.
DomainType m_domainType
Domain type.
A property class for workspaces.
FunctionDomain1DSpectrumCreator :
void setMatrixWorkspace(API::MatrixWorkspace_sptr matrixWorkspace)
Sets the matrix workspace this creator is working with.
SeqDomainSpectrumCreator :
size_t getDomainSize() const override
Returns the domain size.
void setParametersFromPropertyManager()
Tries to extract a workspace from the assigned property manager.
API::MatrixWorkspace_sptr m_matrixWorkspace
API::Workspace_sptr 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="OutputWorkspace") override
Creates an output workspace using the given function and domain.
SeqDomainSpectrumCreator(Kernel::IPropertyManager *manager, const std::string &workspacePropertyName)
Constructor.
std::string m_workspacePropertyName
void setMatrixWorkspace(const API::MatrixWorkspace_sptr &matrixWorkspace)
Sets the MatrixWorkspace the created domain is based on.
bool histogramIsUsable(size_t i) const
Determines whether a spectrum is masked, in case there is no instrument this always returns true.
void createDomain(std::shared_ptr< API::FunctionDomain > &domain, std::shared_ptr< API::FunctionValues > &values, size_t i0=0) override
Creates a sequential domain corresponding to the assigned MatrixWorkspace.
An implementation of CompositeDomain.
void addCreator(const API::IDomainCreator_sptr &creator)
Add new domain creator.
static SeqDomain * create(API::IDomainCreator::DomainType type)
Create an instance of SeqDomain in one of two forms: either SeqDomain for sequential domain creation ...
Interface to PropertyManager.
virtual void setPropertyValue(const std::string &name, const std::string &value)=0
Sets property value from a string.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
virtual TypedValue getProperty(const std::string &name) const =0
Get the value of a property.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< FunctionValues > FunctionValues_sptr
typedef for a shared pointer
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
std::shared_ptr< IDomainCreator > IDomainCreator_sptr
Typedef for a shared pointer to IDomainCreator.
std::shared_ptr< FunctionDomain > FunctionDomain_sptr
typedef for a shared pointer
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
@ Output
An output workspace.