-
Notifications
You must be signed in to change notification settings - Fork 122
/
PowerMD.cpp
58 lines (47 loc) · 2.22 KB
/
PowerMD.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidMDAlgorithms/PowerMD.h"
#include "MantidKernel/System.h"
using namespace Mantid::Kernel;
using namespace Mantid::API;
namespace Mantid {
namespace MDAlgorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(PowerMD)
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string PowerMD::name() const { return "PowerMD"; }
/// Algorithm's version for identification. @see Algorithm::version
int PowerMD::version() const { return 1; }
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
/// Optional method to be subclassed to add properties
void PowerMD::initExtraProperties() {
declareProperty("Exponent", 2.0,
"Power to which to raise the values. Default 2.0.");
}
//----------------------------------------------------------------------------------------------
/// Check the inputs and throw if the algorithm cannot be run
void PowerMD::checkInputs() {
if (!m_in_histo)
throw std::runtime_error(this->name() +
" can only be run on a MDHistoWorkspace.");
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm on a MDEventWorkspace
void PowerMD::execEvent(Mantid::API::IMDEventWorkspace_sptr /*out*/) {
throw std::runtime_error(this->name() +
" can only be run on a MDHistoWorkspace.");
}
//----------------------------------------------------------------------------------------------
/// PowerMD::Run the algorithm with a MDHistoWorkspace
void PowerMD::execHisto(Mantid::DataObjects::MDHistoWorkspace_sptr out) {
double exponent = getProperty("Exponent");
out->power(exponent);
}
} // namespace MDAlgorithms
} // namespace Mantid