/
ConvertToDistribution.cpp
45 lines (35 loc) · 1.44 KB
/
ConvertToDistribution.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAlgorithms/ConvertToDistribution.h"
#include "MantidAPI/HistogramValidator.h"
#include "MantidAPI/RawCountValidator.h"
#include "MantidKernel/CompositeValidator.h"
namespace Mantid {
namespace Algorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(ConvertToDistribution)
using namespace API;
void ConvertToDistribution::init() {
auto wsValidator = boost::make_shared<Kernel::CompositeValidator>();
wsValidator->add<HistogramValidator>();
wsValidator->add<RawCountValidator>();
declareProperty(Kernel::make_unique<WorkspaceProperty<>>(
"Workspace", "", Kernel::Direction::InOut, wsValidator),
"The name of the workspace to convert.");
}
void ConvertToDistribution::exec() {
MatrixWorkspace_sptr workspace = getProperty("Workspace");
WorkspaceHelpers::makeDistribution(workspace);
}
std::map<std::string, std::string> ConvertToDistribution::validateInputs() {
std::map<std::string, std::string> errors;
MatrixWorkspace_sptr workspace = getProperty("Workspace");
if (workspace && workspace->id() == "EventWorkspace") {
errors["Workspace"] = "Event workspaces cannot be directly converted to "
"distributions.";
}
return errors;
}
} // namespace Algorithms
} // namespace Mantid