15namespace MDAlgorithms {
45 "An input MDEventWorkspace. Must have an axis as DeltaE");
48 "The integer exponent of energy transfer (default: 1)");
51 "The output MDEventWorkspace with events scaled by DeltaE^Moment");
60 std::map<std::string, std::string> output;
66 std::string error_str(
"No dimension containing energy transfer was found.");
69 for (std::size_t dim_num = 0; dim_num < input_ws->getNumDims(); dim_num++) {
70 if (input_ws->getDimension(dim_num)->getName() ==
"DeltaE") {
77 if (error_str !=
"") {
78 output[
"InputWorkspace"] = error_str;
95 if (input_ws->getName() == output_ws_name) {
100 output_ws = input_ws->clone();
112 output_ws->refreshCache();
115 output_ws->clearMDMasking();
125template <
typename MDE,
size_t nd>
129 std::vector<API::IMDNode *> boxes;
131 auto numBoxes = int(boxes.size());
134 for (
int i = 0; i < numBoxes; ++i) {
137 if (box && !box->getIsMasked()) {
139 std::vector<MDE> &events = box->
getEvents();
141 for (
auto it = events.begin(); it != events.end(); ++it) {
147 auto intensity = it->getSignal() * factor;
148 it->setSignal(intensity);
151 auto error2 = it->getErrorSquared() * factor * factor;
153 it->setErrorSquared(error2);
157 box->releaseEvents();
#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...
#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 PRAGMA_OMP(expression)
#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.
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.
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.
A property class for workspaces.
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.
bool isFileBacked() const override
MDBoxBase< MDE, nd > * getBox()
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
The concrete, templated class for properties.
SpectralMomentMD : Multiply MD events by DeltaE^n.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
void exec() override
Execute the algorithm.
void applyScaling(typename Mantid::DataObjects::MDEventWorkspace< MDE, nd >::sptr ws)
Apply weight to each MDEvent.
std::map< std::string, std::string > validateInputs() override
Validate inputs.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
void init() override
Initialize the algorithm's properties.
size_t mDeltaEIndex
index of the MD dimension index for DeltaE
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
Helper class which provides the Collimation Length for SANS instruments.
@ Input
An input workspace.
@ Output
An output workspace.