Mantid
Loading...
Searching...
No Matches
ConvertToDistribution.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//----------------------------------------------------------------------
14
15namespace Mantid::Algorithms {
16
17// Register the algorithm into the AlgorithmFactory
18DECLARE_ALGORITHM(ConvertToDistribution)
19
20using namespace API;
21
23 auto wsValidator = std::make_shared<Kernel::CompositeValidator>();
24 wsValidator->add<HistogramValidator>();
25 wsValidator->add<RawCountValidator>();
26 declareProperty(std::make_unique<WorkspaceProperty<>>("Workspace", "", Kernel::Direction::InOut, wsValidator),
27 "The name of the workspace to convert.");
28}
29
32
34}
35
36std::map<std::string, std::string> ConvertToDistribution::validateInputs() {
37 std::map<std::string, std::string> errors;
38
40 if (workspace && workspace->id() == "EventWorkspace") {
41 errors["Workspace"] = "Event workspaces cannot be directly converted to "
42 "distributions.";
43 }
44
45 return errors;
46}
47
48} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
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
A validator which checks that a workspace contains histogram data (the default) or point data as requ...
A validator which checks that a workspace contains raw counts in its bins.
A property class for workspaces.
std::map< std::string, std::string > validateInputs() override
Validate inputs.
void init() override
Initialisation code.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
static void makeDistribution(const MatrixWorkspace_sptr &workspace, const bool forwards=true)
Divides the data in a workspace by the bin width to make it a distribution.
@ InOut
Both an input & output workspace.
Definition: Property.h:55