Mantid
Loading...
Searching...
No Matches
PowerLawCorrection.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#include <cmath>
13
14using namespace Mantid::API;
15using namespace Mantid::Kernel;
16
17namespace Mantid::Algorithms {
18// Register the class into the algorithm factory
19DECLARE_ALGORITHM(PowerLawCorrection)
20
22
24 // We need an array property for the coefficients of the PowerLaw: C0*X^C1
25 declareProperty("C0", 1.0, "The value by which the entire calculation is multiplied");
26 declareProperty("C1", 1.0, "The power by which the x value is raised");
27}
28
30 m_c0 = getProperty("C0");
31 m_c1 = getProperty("C1");
32}
33
34void PowerLawCorrection::performUnaryOperation(const double XIn, const double YIn, const double EIn, double &YOut,
35 double &EOut) {
36 double factor = m_c0 * pow(XIn, m_c1);
37 // Multiply the data and error by the correction factor
38 YOut = YIn * factor;
39 EOut = EIn * factor;
40}
41
42} // 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 the value of an exponential function which is ev...
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_c0
The constant by which to multiply.
void defineProperties() override
A virtual function in which additional properties of an algorithm should be declared.
double m_c1
The power to raise by.
UnaryOperation supports the implementation of a Unary operation on an input workspace.