Mantid
Loading...
Searching...
No Matches
LoadISISPolarizationEfficiencies.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 +
8
10#include "MantidAPI/TextAxis.h"
13#include "MantidHistogramData/Histogram.h"
14#include "MantidHistogramData/Interpolate.h"
15
16#include <limits>
17
18namespace Mantid::DataHandling {
19
20using namespace Mantid::Kernel;
21using namespace Mantid::API;
22
23// Register the algorithm into the AlgorithmFactory
25
26//----------------------------------------------------------------------------------------------
27
28
29const std::string LoadISISPolarizationEfficiencies::name() const { return "LoadISISPolarizationEfficiencies"; }
30
33
36 return "Loads ISIS reflectometry polarization efficiency factors from files: "
37 "one factor per file.";
38}
39
40const std::vector<std::string> LoadISISPolarizationEfficiencies::seeAlso() const {
41 return {"CreatePolarizationEfficiencies", "JoinISISPolarizationEfficiencies", "PolarizationEfficiencyCor"};
42}
43
44//----------------------------------------------------------------------------------------------
48 declareProperty(std::make_unique<API::FileProperty>(Pp, "", API::FileProperty::OptionalLoad),
49 "Path to the file containing the Pp polarization efficiency "
50 "in XYE columns.");
51
52 declareProperty(std::make_unique<API::FileProperty>(Ap, "", API::FileProperty::OptionalLoad),
53 "Path to the file containing the Ap polarization efficiency "
54 "in XYE columns.");
55
56 declareProperty(std::make_unique<API::FileProperty>(Rho, "", API::FileProperty::OptionalLoad),
57 "Path to the file containing the Rho polarization efficiency "
58 "in XYE columns.");
59
60 declareProperty(std::make_unique<API::FileProperty>(Alpha, "", API::FileProperty::OptionalLoad),
61 "Path to the file containing the Alpha polarization efficiency "
62 "in XYE columns.");
63
64 declareProperty(std::make_unique<API::FileProperty>(P1, "", API::FileProperty::OptionalLoad),
65 "Path to the file containing the P1 polarization efficiency "
66 "in XYE columns.");
67
68 declareProperty(std::make_unique<API::FileProperty>(P2, "", API::FileProperty::OptionalLoad),
69 "Path to the file containing the P2 polarization efficiency "
70 "in XYE columns.");
71
72 declareProperty(std::make_unique<API::FileProperty>(F1, "", API::FileProperty::OptionalLoad),
73 "Path to the file containing the F1 polarization efficiency "
74 "in XYE columns.");
75
76 declareProperty(std::make_unique<API::FileProperty>(F2, "", API::FileProperty::OptionalLoad),
77 "Path to the file containing the F2 polarization efficiency "
78 "in XYE columns.");
79
81}
82
86
87 auto alg = createChildAlgorithm("JoinISISPolarizationEfficiencies");
88 alg->initialize();
89 for (auto const &propName : props) {
90 auto loader = createChildAlgorithm("Load");
91 loader->initialize();
92 loader->setPropertyValue("Filename", getPropertyValue(propName));
93 loader->execute();
94 Workspace_sptr output = loader->getProperty("OutputWorkspace");
95 auto ws = std::dynamic_pointer_cast<MatrixWorkspace>(output);
96 if (!ws) {
97 throw std::invalid_argument("File " + propName + " cannot be loaded into a MatrixWorkspace.");
98 }
99 if (ws->getNumberHistograms() != 1) {
100 throw std::runtime_error("Loaded workspace must contain a single histogram. Found " +
101 std::to_string(ws->getNumberHistograms()));
102 }
103 alg->setProperty(propName, ws);
104 }
105 alg->execute();
106 MatrixWorkspace_sptr outWS = alg->getProperty("OutputWorkspace");
107 return outWS;
108}
109
110} // namespace Mantid::DataHandling
#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
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Definition: Algorithm.cpp:842
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
Definition: FileProperty.h:53
static std::string const Pp
Names of the efficiency properties.
LoadISISPolarizationEfficiencies : Load reflectometry polarization efficiency correction factors from...
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
int version() const override
Algorithm's version for identification.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
API::MatrixWorkspace_sptr createEfficiencies(std::vector< std::string > const &props) override
Load efficiencies from files and put them into a single workspace.
void init() override
Initialize the algorithm's properties.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
STL namespace.
std::string to_string(const wide_integer< Bits, Signed > &n)