54 auto compositeValidator = std::make_shared<CompositeValidator>();
55 compositeValidator->add(std::make_shared<API::WorkspaceUnitValidator>(
"Wavelength"));
56 compositeValidator->add(std::make_shared<API::HistogramValidator>());
60 "An input workspace in wavelength");
63 "An output workspace.");
68 if (parameter ==
nullptr) {
69 std::stringstream stream;
71 <<
" and all of it's parent components, have no "
72 "fitting type parameters. This algorithm "
73 "cannot be run without fitting parameters. See "
74 "wiki help for details on setup.";
76 throw std::runtime_error(stream.str());
95 const auto ¶mMap = inWS->constInstrumentParameters();
96 const auto &spectrumInfo = inWS->spectrumInfo();
97 const auto &det = spectrumInfo.detector(wsIndex);
98 const std::string type =
"fitting";
103 const std::string &fitFunctionName = foundFittingParam.
getFunction();
105 using ParamNames = std::vector<std::string>;
106 ParamNames allParamNames = function->getParameterNames();
109 for (
auto &
name : allParamNames) {
115 throw std::runtime_error(
"A Forumla has not been provided for a fit function");
118 if (!resultUnitStr.empty() && resultUnitStr !=
"Wavelength") {
119 throw std::runtime_error(
"Units for function parameters must be in Wavelength");
124 double paramValue = p.Eval();
126 function->setParameter(fitParam.
getName(), paramValue);
129 auto wavelengths = inWS->points(wsIndex);
132 function->function(domain, values);
134 auto &
Y = denominatorWS->mutableY(wsIndex);
135 for (
size_t i = 0; i < domain.
size(); ++i) {
139 denominatorWS->mutableE(wsIndex) = 0.0;
151 const size_t nHistograms = inWS->getNumberHistograms();
152 const auto progress_items =
static_cast<size_t>(double(nHistograms) * 1.2);
153 Progress prog(
this, 0.0, 1.0, progress_items);
157 cloneAlg->setProperty(
"InputWorkspace", inWS);
158 cloneAlg->setPropertyValue(
"OutputWorkspace",
"temp");
159 cloneAlg->executeAsChildAlg();
167 for (
int wsIndex = 0; wsIndex < static_cast<int>(nHistograms); ++wsIndex) {
174 for (
size_t wsIndex = 0; wsIndex < nHistograms; ++wsIndex) {
179 return denominatorWS;
194 divideAlg->setRethrows(
true);
195 divideAlg->setProperty(
"LHSWorkspace", inWS);
196 divideAlg->setProperty(
"RHSWorkspace", denominatorWS);
197 divideAlg->executeAsChildAlg();
#define DECLARE_ALGORITHM(classname)
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Implements FunctionDomain1D with its own storage in form of a std::vector.
size_t size() const override
Return the number of arguments in the domain.
A class to store values calculated by a function.
Helper class for reporting progress from algorithms.
A property class for workspaces.
NormaliseByDetector : Normalises a workspace with respect to the detector efficiency function stored ...
std::shared_ptr< Mantid::API::MatrixWorkspace > processHistograms(const std::shared_ptr< Mantid::API::MatrixWorkspace > &inWS)
Block to process histograms.
const Mantid::Geometry::FitParameter tryParseFunctionParameter(const Mantid::Geometry::Parameter_sptr ¶meter, const Geometry::IDetector &det)
Try to parse a function parameter and extract the correctly typed parameter.
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
const std::string category() const override
Algorithm's category for identification.
void processHistogram(size_t wsIndex, const std::shared_ptr< const Mantid::API::MatrixWorkspace > &inWS, const std::shared_ptr< Mantid::API::MatrixWorkspace > &denominatorWS, Mantid::API::Progress &prog)
Process indivdual histogram.
const bool m_parallelExecution
Flag to indicate that the histograms should be processed in parallel.
int version() const override
Algorithm's version for identification.
const std::string name() const override
Algorithm's name for identification.
Store information about a fitting parameter such as its value if it is constrained or tied.
const std::string & getName() const
get name
const std::string & getFormula() const
get formula
const std::string & getFunction() const
get function
const std::string & getResultUnit() const
get result formula unit, and Empty string is no unit has been specified
virtual std::string getName() const =0
Get the IComponent name.
Interface class for detector objects.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void warning(const std::string &msg)
Logs at warning level.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< Parameter > Parameter_sptr
Typedef for the shared pointer.
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
@ Input
An input workspace.
@ Output
An output workspace.