Mantid
Loading...
Searching...
No Matches
ExponentialCorrection.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//----------------------------------------------------------------------
12
13using namespace Mantid::API;
14using namespace Mantid::Kernel;
15
16namespace Mantid::Algorithms {
17// Register the class into the algorithm factory
18DECLARE_ALGORITHM(ExponentialCorrection)
19
20ExponentialCorrection::ExponentialCorrection() : UnaryOperation(), m_c0(0.), m_c1(0.), m_divide(false) {}
21
23 declareProperty("C0", 1.0, "The value by which the entire exponent calculation is multiplied.");
24 declareProperty("C1", 0.0, "The value by which the x value is multiplied prior to exponentiation.");
25 getPointerToProperty("InputWorkspace")->setDocumentation("The name of the workspace to apply the correction to.");
26 getPointerToProperty("OutputWorkspace")
27 ->setDocumentation("The name to use for the corrected workspace (can be "
28 "the same as the input one).");
29
30 std::vector<std::string> operations(2);
31 operations[0] = "Multiply";
32 operations[1] = "Divide";
33 declareProperty("Operation", "Divide", std::make_shared<Kernel::StringListValidator>(operations),
34 "Whether to divide (the default) or multiply the data by the "
35 "correction function.");
36}
37
39 m_c0 = getProperty("C0");
40 m_c1 = getProperty("C1");
41 std::string op = getProperty("Operation");
42 m_divide = op == "Divide";
43}
44
45void ExponentialCorrection::performUnaryOperation(const double XIn, const double YIn, const double EIn, double &YOut,
46 double &EOut) {
47 double factor = m_c0 * exp(-1.0 * m_c1 * XIn);
48 if (m_divide)
49 factor = 1.0 / factor;
50
51 // Multiply the data and error by the correction factor
52 YOut = YIn * factor;
53 EOut = EIn * factor;
54}
55
56} // 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
Kernel::Property * getPointerToProperty(const std::string &name) const override
Get a property by name.
Definition: Algorithm.cpp:2033
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 the value of an exponential function which is ev...
double m_c0
The constant by which to multiply the exponential.
double m_c1
The constant term in the exponent.
bool m_divide
Whether the data should be divided by the correction (true) or multiplied by it (false)
void defineProperties() override
A virtual function in which additional properties of an algorithm should be declared.
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'.
UnaryOperation supports the implementation of a Unary operation on an input workspace.
void setDocumentation(const std::string &documentation)
Sets the user level description of the property.
Definition: Property.cpp:134