-
Notifications
You must be signed in to change notification settings - Fork 122
/
ConvertToDistribution.cpp
51 lines (41 loc) · 1.75 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
46
47
48
49
50
51
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
//----------------------------------------------------------------------
// 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 = std::make_shared<Kernel::CompositeValidator>();
wsValidator->add<HistogramValidator>();
wsValidator->add<RawCountValidator>();
declareProperty(std::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