/
OneMinusExponentialCor.cpp
59 lines (49 loc) · 2.16 KB
/
OneMinusExponentialCor.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
59
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAlgorithms/OneMinusExponentialCor.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/ListValidator.h"
using namespace Mantid::API;
using namespace Mantid::Kernel;
namespace Mantid {
namespace Algorithms {
// Register the class into the algorithm factory
DECLARE_ALGORITHM(OneMinusExponentialCor)
OneMinusExponentialCor::OneMinusExponentialCor()
: UnaryOperation(), m_c(0.), m_c1(0.), m_divide(false) {}
void OneMinusExponentialCor::defineProperties() {
auto mustBePositive = boost::make_shared<BoundedValidator<double>>();
mustBePositive->setLower(0.0);
declareProperty("C", 1.0, mustBePositive, "The positive value by which the "
"entire exponent calculation is "
"multiplied (see formula below).");
declareProperty("C1", 1.0, "The value by which the entire calculation is "
"multiplied (see formula below).");
std::vector<std::string> operations(2);
operations[0] = "Multiply";
operations[1] = "Divide";
declareProperty("Operation", "Divide",
boost::make_shared<Kernel::StringListValidator>(operations),
"Whether to divide (the default) or multiply the data by the "
"correction function.");
}
void OneMinusExponentialCor::retrieveProperties() {
m_c = getProperty("C");
m_c1 = getProperty("C1");
std::string op = getProperty("Operation");
m_divide = op == "Divide";
}
void OneMinusExponentialCor::performUnaryOperation(const double XIn,
const double YIn,
const double EIn,
double &YOut, double &EOut) {
double factor = m_c1 * (1.0 - exp(-1.0 * m_c * XIn));
if (m_divide)
factor = 1.0 / factor;
// Multiply the data and error by the correction factor
YOut = YIn * factor;
EOut = EIn * factor;
}
} // namespace Algorithms
} // namespace Mantid