Mantid
Loading...
Searching...
No Matches
SofQW.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#include <stdexcept>
8
24
25namespace Mantid::Algorithms {
26
27// Register the algorithm into the AlgorithmFactory
29
30using namespace API;
31using namespace DataObjects;
32using namespace Kernel;
33
37const std::string SofQW::summary() const {
38 return "Computes S(Q,w) via the SofQWNormalisedPolygon algorithm.\n"
39 "The output is a parallel-piped rebin, outputting a weighted-sum "
40 "of overlapping polygons normalised by the fractional area of each "
41 "overlap";
42}
43
48
54 auto wsValidator = std::make_shared<CompositeValidator>();
55 wsValidator->add<WorkspaceUnitValidator>("DeltaE");
56 wsValidator->add<SpectraAxisValidator>();
57 wsValidator->add<CommonBinsValidator>();
58 wsValidator->add<HistogramValidator>();
59 wsValidator->add<InstrumentValidator>();
60 alg.declareProperty(std::make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input, wsValidator),
61 "Reduced data in units of energy transfer DeltaE.\nThe "
62 "workspace must contain histogram data and have common "
63 "bins across all spectra.");
64 alg.declareProperty(std::make_unique<WorkspaceProperty<>>("OutputWorkspace", "", Direction::Output),
65 "The name to use for the q-omega workspace.");
66 alg.declareProperty(std::make_unique<ArrayProperty<double>>("QAxisBinning", std::make_shared<RebinParamsValidator>()),
67 "The bin parameters to use for the q axis (in the format used by the "
68 ":ref:`algm-Rebin` algorithm).");
69
70 const std::vector<std::string> propOptions{"Direct", "Indirect"};
71 alg.declareProperty("EMode", "", std::make_shared<StringListValidator>(propOptions),
72 "The energy transfer analysis mode (Direct/Indirect)");
73 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
74 mustBePositive->setLower(0.0);
75 alg.declareProperty("EFixed", 0.0, mustBePositive,
76 "The value of fixed energy: :math:`E_i` (EMode=Direct) "
77 "or :math:`E_f` (EMode=Indirect) (meV).\nMust be set "
78 "here if not available in the instrument definition.");
79 alg.declareProperty("ReplaceNaNs", false,
80 "If true, all NaN values in the output workspace are "
81 "replaced using the ReplaceSpecialValues algorithm.",
84 std::make_unique<ArrayProperty<double>>("EAxisBinning", std::make_shared<RebinParamsValidator>(true)),
85 "The bin parameters to use for the E axis (optional, in the format "
86 "used by the :ref:`algm-Rebin` algorithm).");
87 alg.declareProperty(std::make_unique<WorkspaceProperty<TableWorkspace>>("DetectorTwoThetaRanges", "",
89 "A table workspace use by SofQWNormalisedPolygon containing a 'Detector "
90 "ID' column as well as 'Min two theta' and 'Max two theta' columns "
91 "listing the detector's min and max scattering angles in radians.");
92}
93
95 std::string child = "SofQWNormalisedPolygon";
96
97 // Setup and run
98 Algorithm_sptr childAlg = std::dynamic_pointer_cast<Algorithm>(createChildAlgorithm(child, 0.0, 1.0));
99 // This will add the Method property to the child algorithm but it will be
100 // ignored anyway...
101 childAlg->copyPropertiesFrom(*this);
102 childAlg->execute();
103
104 MatrixWorkspace_sptr outputWS = childAlg->getProperty("OutputWorkspace");
105
106 this->setProperty("OutputWorkspace", outputWS);
107
108 // Progress reports & cancellation
109 MatrixWorkspace_const_sptr inputWorkspace = getProperty("InputWorkspace");
110 const size_t nHistos = inputWorkspace->getNumberHistograms();
111 auto m_progress = std::make_unique<Progress>(this, 0.0, 1.0, nHistos);
112 m_progress->report("Creating output workspace");
113}
114
115} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:542
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
A validator which provides a TENTATIVE check that a workspace contains common bins in each spectrum.
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) override
Create a Child Algorithm.
Kernel::IPropertyManager::TypedValue getProperty(const std::string &name) const override
Get the property held by this object.
A validator which checks that a workspace contains histogram data (the default) or point data as requ...
A validator which checks that a workspace has a valid instrument.
A validator which checks whether the input workspace has the Spectra number in the axis.
A property class for workspaces.
A validator which checks that the unit of the workspace referred to by a WorkspaceProperty is the exp...
static void createCommonInputProperties(API::Algorithm &alg)
Create the input properties on the given algorithm object.
Definition SofQW.cpp:53
const std::string summary() const override
Summary of algorithms purpose.
Definition SofQW.cpp:37
void init() override
Initialization code.
Definition SofQW.cpp:47
void exec() override
Execution code.
Definition SofQW.cpp:94
Support for a property that holds an array of values.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition Algorithm.h:52
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Input
An input workspace.
Definition Property.h:53
@ Output
An output workspace.
Definition Property.h:54