17using namespace Kernel;
24const std::string FACTOR(
"Factor");
25const std::string OPERATION(
"Operation");
28const std::string MULT(
"Multiply");
29const std::string ADD(
"Add");
37 declareProperty(PropertyNames::FACTOR, 1.0,
"The value by which to scale the input workspace");
38 std::vector<std::string> operations{Operation::MULT, Operation::ADD};
39 declareProperty(PropertyNames::OPERATION, Operation::MULT, std::make_shared<StringListValidator>(operations),
40 "Whether to multiply by, or add factor");
44 std::map<std::string, std::string> result;
49 const auto eventWS = std::dynamic_pointer_cast<const DataObjects::EventWorkspace>(inputWS);
61 const auto inPlace = bool(outputWS == inputWS);
63 outputWS = inputWS->clone();
65 const double factor =
getProperty(PropertyNames::FACTOR);
70 const auto hasDx = inputWS->hasDx(0);
73 bufferWS = inputWS->clone();
80 if (operation == Operation::MULT) {
81 progress.report(
"Multiplying factor...");
84 }
else if (operation == Operation::ADD) {
89 std::stringstream msg;
90 msg <<
"Do not know how to \"" << operation <<
"\"";
91 throw std::runtime_error(msg.str());
99 const auto numHist = bufferWS->getNumberHistograms();
101 outputWS->setSharedDx(
index, bufferWS->sharedDx(
index));
#define DECLARE_ALGORITHM(classname)
std::map< DeltaEMode::Type, std::string > index
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void exec() override
Execution code.
std::map< std::string, std::string > validateInputs() override
Method checking errors on ALL the inputs, before execution.
void init() override
Initialisation code.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
static const std::string OUTPUT_WORKSPACE
static const std::string INPUT_WORKSPACE
@ Input
An input workspace.
@ Output
An output workspace.