/
OneMinusExponentialCor.cpp
61 lines (51 loc) · 2.3 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
60
61
// 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 & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAlgorithms/OneMinusExponentialCor.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/ListValidator.h"
using namespace Mantid::API;
using namespace Mantid::Kernel;
namespace Mantid::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 = std::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", std::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 Mantid::Algorithms