39 auto validator = std::make_shared<CompositeValidator>();
42 auto mandatoryIntArrayValidator = std::make_shared<MandatoryValidator<std::vector<int>>>();
43 auto mandatoryDoubleArrayValidator = std::make_shared<MandatoryValidator<std::vector<double>>>();
44 auto mandatoryStrArrayValidator = std::make_shared<MandatoryValidator<std::vector<std::string>>>();
47 "Signal array for n-dimensional workspace");
50 "Error array for n-dimensional workspace");
53 "Number of pixels array for n-dimensional workspace. Optional, defaults "
56 "Dimensionality of the data in the file.");
59 "A comma separated list of min, max for each dimension,\n"
60 "specifying the extents of each dimension.");
63 "Number of bin in each dimension.");
66 "A comma separated list of the name of each dimension. "
67 "e.g. ('[H,0,0]','[0,K,0]','[0,0,L]') ");
70 "A comma separated list of the units of each dimension.");
73 "MDHistoWorkspace reflecting the input text file.");
75 " A comma separated list of the frames of each dimension. "
77 " **General Frame**: Any frame which is not a Q-based frame."
78 " **QLab**: Wave-vector converted into the lab frame."
79 " **QSample**: Wave-vector converted into the frame of the sample."
80 " **HKL**: Wave-vector converted into the crystal's HKL indices."
81 " Note if nothing is specified then the **General Frame** is being "
82 "selected. Also note that if you select a frame then this might override "
83 "your unit selection if it is not compatible with the frame.");
87 std::map<std::string, std::string> errors;
89 const std::vector<double> &signalValues =
getProperty(
"SignalInput");
90 const std::vector<double> &errorValues =
getProperty(
"ErrorInput");
91 const std::vector<double> &numberOfEvents =
getProperty(
"NumberOfEvents");
93 const std::string msg(
"All inputs must match size: " +
std::to_string(signalValues.size()));
95 if (signalValues.size() != errorValues.size()) {
96 errors[
"SignalInput"] = msg;
97 errors[
"ErrorInput"] = msg;
100 if ((!numberOfEvents.empty()) && (numberOfEvents.size() != signalValues.size()))
101 errors[
"NumberOfEvents"] = msg;
111 auto signals = ws->mutableSignalArray();
112 auto errors = ws->mutableErrorSquaredArray();
113 auto nEvents = ws->mutableNumEventsArray();
116 const std::vector<double> &signalValues =
getProperty(
"SignalInput");
117 const std::vector<double> &errorValues =
getProperty(
"ErrorInput");
118 const std::vector<double> &numberOfEvents =
getProperty(
"NumberOfEvents");
121 if (signalValues.size() != binProduct) {
122 const std::string msg(
"All inputs must match size: " +
std::to_string(binProduct));
123 throw std::invalid_argument(msg);
127 std::memcpy(signals, signalValues.data(), binProduct *
sizeof(
double));
128 std::transform(errorValues.cbegin(), errorValues.cend(), errors,
129 [](
const auto &
value) { return value * value; });
131 if (numberOfEvents.empty()) {
132 std::fill(nEvents, nEvents + binProduct, 1.0);
134 std::memcpy(nEvents, numberOfEvents.data(), binProduct *
sizeof(
double));
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
A property class for workspaces.
Support for a property that holds an array of values.
BoundedValidator is a validator that requires the values to be between upper or lower bounds,...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
Validator to check that a property is not left empty.
The concrete, templated class for properties.
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
const std::string category() const override
Algorithm's category for identification.
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
void exec() override
Execute the algorithm.
DataObjects::MDHistoWorkspace_sptr createEmptyOutputWorkspace()
Creates an empty md histo workspace (with dimensions)
size_t getBinProduct() const
Getter for the number of bins (product accross all dimensions)
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.