39 throw std::runtime_error(
"Cannot multiply by a MDEventWorkspace on the RHS.");
41 throw std::runtime_error(
"A MDEventWorkspace can only be multiplied by a scalar.");
52 auto scalarError =
static_cast<float>(
m_rhs_scalar->e(0)[0]);
53 float scalarErrorSquared = scalarError * scalarError;
54 float scalarSquared = scalar * scalar;
58 std::vector<API::IMDNode *> boxes;
59 parentBox->
getBoxes(boxes, 1000,
true);
61 bool fileBackedTarget(
false);
64 fileBackedTarget =
true;
68 for (
auto &boxe : boxes) {
71 typename std::vector<MDE> &events = box->
getEvents();
72 size_t ic(events.size());
73 auto it = events.begin();
74 auto it_end = events.end();
75 for (; it != it_end; it++) {
77 float oldSignal = it->getSignal();
78 float signal = oldSignal * scalar;
79 float errorSquared = scalarSquared * it->getErrorSquared() + oldSignal * oldSignal * scalarErrorSquared;
80 it->setSignal(signal);
81 it->setErrorSquared(errorSquared);
84 if (fileBackedTarget && ic > 0) {
100 throw std::runtime_error(
"A MDEventWorkspace can only be multiplied by a scalar.");
102 throw std::runtime_error(
"MultiplyMD::execEvent(): Error creating output MDEventWorkspace.");
111 out->multiply(*operand);
118 out->multiply(scalar->y(0)[0], scalar->e(0)[0]);
#define DECLARE_ALGORITHM(classname)
#define CALL_MDEVENT_FUNCTION(funcname, workspace)
Macro that makes it possible to call a templated method for a MDEventWorkspace using a IMDEventWorksp...
void setFileNeedsUpdating(bool value)
Sets the marker set to true when a file-backed workspace needs its back-end file updated (by calling ...
virtual void getBoxes(std::vector< IMDNode * > &boxes, size_t maxDepth, bool leafOnly)=0
Fill a vector with all the boxes who are the childred of this one up to a certain depth.
Templated super-class of a multi-dimensional event "box".
Templated class for a multi-dimensional event "box".
std::vector< MDE > & getEvents()
Get vector of events to change.
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
void refreshCache() override
Refresh the cache of # of points, signal, and error.
bool isFileBacked() const override
MDBoxBase< MDE, nd > * getBox()
Mantid::API::BoxController_sptr getBoxController() override
Returns the BoxController used in this workspace.
Buffer objects that need to be written out to disk so as to optimize writing operations.
void toWrite(ISaveable *item)
Call this method when an object is ready to be written out to disk.
An interface for objects that can be cached or saved to disk.
Mantid::API::IMDEventWorkspace_sptr m_rhs_event
Mantid::API::IMDEventWorkspace_sptr m_lhs_event
For checkInputs.
Mantid::DataObjects::WorkspaceSingleValue_sptr m_rhs_scalar
Mantid::API::IMDEventWorkspace_sptr m_out_event
Output MDEventWorkspace.
MultiplyMD : multiplication operation for MDWorkspaces.
void checkInputs() override
Check the inputs and throw if the algorithm cannot be run.
bool commutative() const override
Is the operation commutative?
void execHistoScalar(Mantid::DataObjects::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar) override
Run the algorithm with a MDHisotWorkspace as output, scalar and operand.
void execHistoHisto(Mantid::DataObjects::MDHistoWorkspace_sptr out, Mantid::DataObjects::MDHistoWorkspace_const_sptr operand) override
Run the algorithm with a MDHisotWorkspace as output and operand.
void execEventScalar(typename Mantid::DataObjects::MDEventWorkspace< MDE, nd >::sptr ws)
Perform the operation with MDEventWorkpsace as LHS and a scalar as RHS Will do "ws *= scalar".
void execEvent() override
Run the algorithm with an MDEventWorkspace as output.
int version() const override
Algorithm's version for identification.
std::shared_ptr< const WorkspaceSingleValue > WorkspaceSingleValue_const_sptr
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
std::shared_ptr< const MDHistoWorkspace > MDHistoWorkspace_const_sptr
A shared pointer to a const MDHistoWorkspace.