Mantid
Loading...
Searching...
No Matches
PowerMD.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9
10using namespace Mantid::Kernel;
11using namespace Mantid::API;
12
13namespace Mantid::MDAlgorithms {
14
15// Register the algorithm into the AlgorithmFactory
16DECLARE_ALGORITHM(PowerMD)
17
18//----------------------------------------------------------------------------------------------
20const std::string PowerMD::name() const { return "PowerMD"; }
21
23int PowerMD::version() const { return 1; }
24
25//----------------------------------------------------------------------------------------------
26
27//----------------------------------------------------------------------------------------------
30 declareProperty("Exponent", 2.0, "Power to which to raise the values. Default 2.0.");
31}
32
33//----------------------------------------------------------------------------------------------
36 if (!m_in_histo)
37 throw std::runtime_error(this->name() + " can only be run on a MDHistoWorkspace.");
38}
39
40//----------------------------------------------------------------------------------------------
43 throw std::runtime_error(this->name() + " can only be run on a MDHistoWorkspace.");
44}
45
46//----------------------------------------------------------------------------------------------
49 double exponent = getProperty("Exponent");
50 out->power(exponent);
51}
52
53} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
PowerMD : raise a MDHistoWorkspace to a power.
Definition: PowerMD.h:19
int version() const override
Algorithm's version for identification.
Definition: PowerMD.cpp:23
void checkInputs() override
Check the inputs and throw if the algorithm cannot be run.
Definition: PowerMD.cpp:35
void execHisto(Mantid::DataObjects::MDHistoWorkspace_sptr out) override
Run the algorithm with a MDHistoWorkspace.
Definition: PowerMD.cpp:48
void initExtraProperties() override
Optional method to be subclassed to add properties.
Definition: PowerMD.cpp:29
void execEvent(Mantid::API::IMDEventWorkspace_sptr out) override
Run the algorithm on a MDEventWorkspace.
Definition: PowerMD.cpp:42
const std::string name() const override
Algorithm's name for identification.
Definition: PowerMD.cpp:20
Mantid::DataObjects::MDHistoWorkspace_sptr m_in_histo
Input workspace (MDHisto)
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
STL namespace.