28double calculatePolynomial(std::vector<double>
const &coefficients,
double x) {
29 double polynomial = coefficients[0];
32 for (
size_t i = 1; i < coefficients.size(); ++i) {
34 polynomial += coefficients[i] * xPow;
50 return "Converts polynomial factors to histograms with polarization "
55 return {
"JoinISISPolarizationEfficiencies",
"LoadISISPolarizationEfficiencies",
"PolarizationEfficiencyCor"};
61 "An input workspace to use the x-values from.");
64 "Effective polarizing power of the polarizing system. "
65 "Expressed as a ratio 0 < Pp < 1");
68 "Effective polarizing power of the analyzing system. "
69 "Expressed as a ratio 0 < Ap < 1");
72 "Ratio of efficiencies of polarizer spin-down to polarizer "
73 "spin-up. This is characteristic of the polarizer flipper. "
74 "Values are constants for each term in a polynomial "
78 "Ratio of efficiencies of analyzer spin-down to analyzer "
79 "spin-up. This is characteristic of the analyzer flipper. "
80 "Values are factors for each term in a polynomial "
99 std::vector<std::vector<double>> polynomialCoefficients;
101 for (
auto const &label : labels) {
102 polynomialCoefficients.emplace_back<std::vector<double>>(
getProperty(label));
106 auto sharedInX = inWS->sharedX(0);
110 auto axis1 = std::make_unique<TextAxis>(labels.size());
111 auto axis1Raw = axis1.get();
112 outWS->replaceAxis(1, std::move(axis1));
113 outWS->getAxis(0)->setUnit(inWS->getAxis(0)->unit()->unitID());
115 auto const x = inWS->points(0);
116 std::vector<double>
y(
x.size());
117 for (
size_t i = 0; i < labels.size(); ++i) {
118 outWS->setSharedX(i, sharedInX);
119 auto const &coefficients = polynomialCoefficients[i];
120 std::transform(
x.begin(),
x.end(),
y.begin(),
121 [&coefficients](
double v) { return calculatePolynomial(coefficients, v); });
122 outWS->mutableY(i) =
y;
123 axis1Raw->setLabel(i, labels[i]);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
A property class for workspaces.
static std::string const Rho
static std::string const Ap
static std::string const P2
static std::string const Pp
Names of the efficiency properties.
static std::string const F1
static std::string const Alpha
void initOutputWorkspace()
static std::string const F2
static std::string const P1
CreatePolarizationEfficiencies.
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
void init() override
Virtual method - must be overridden by concrete algorithm.
API::MatrixWorkspace_sptr createEfficiencies(std::vector< std::string > const &labels) override
Create the efficiencies workspace given names of input properties.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
const std::string summary() const override
function returns a summary message that will be displayed in the default GUI, and in the help.
Support for a property that holds an array of values.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Input
An input workspace.