Mantid
Loading...
Searching...
No Matches
OneMinusExponentialCor.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 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
13
14using namespace Mantid::API;
15using namespace Mantid::Kernel;
16
17namespace Mantid::Algorithms {
18// Register the class into the algorithm factory
19DECLARE_ALGORITHM(OneMinusExponentialCor)
20
21OneMinusExponentialCor::OneMinusExponentialCor() : UnaryOperation(), m_c(0.), m_c1(0.), m_divide(false) {}
22
24 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
25 mustBePositive->setLower(0.0);
26 declareProperty("C", 1.0, mustBePositive,
27 "The positive value by which the "
28 "entire exponent calculation is "
29 "multiplied (see formula below).");
30
31 declareProperty("C1", 1.0,
32 "The value by which the entire calculation is "
33 "multiplied (see formula below).");
34
35 std::vector<std::string> operations(2);
36 operations[0] = "Multiply";
37 operations[1] = "Divide";
38 declareProperty("Operation", "Divide", std::make_shared<Kernel::StringListValidator>(operations),
39 "Whether to divide (the default) or multiply the data by the "
40 "correction function.");
41}
42
44 m_c = getProperty("C");
45 m_c1 = getProperty("C1");
46 std::string op = getProperty("Operation");
47 m_divide = op == "Divide";
48}
49
50void OneMinusExponentialCor::performUnaryOperation(const double XIn, const double YIn, const double EIn, double &YOut,
51 double &EOut) {
52 double factor = m_c1 * (1.0 - exp(-1.0 * m_c * XIn));
53 if (m_divide)
54 factor = 1.0 / factor;
55
56 // Multiply the data and error by the correction factor
57 YOut = YIn * factor;
58 EOut = EIn * factor;
59}
60
61} // namespace Mantid::Algorithms
#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
Corrects the data and error values on a workspace by one minus the value of an exponential function w...
void defineProperties() override
A virtual function in which additional properties of an algorithm should be declared.
bool m_divide
Whether the data should be divided by the correction (true) or multiplied by it (false)
void retrieveProperties() override
A virtual function in which additional properties should be retrieved into member variables.
void performUnaryOperation(const double XIn, const double YIn, const double EIn, double &YOut, double &EOut) override
Carries out the Unary operation on the current 'cell'.
double m_c
The constant term in the exponent.
UnaryOperation supports the implementation of a Unary operation on an input workspace.