45 auto validator = std::make_shared<CompositeValidator>();
48 auto mandatoryIntArrayValidator = std::make_shared<MandatoryValidator<std::vector<int>>>();
49 auto mandatoryDoubleArrayValidator = std::make_shared<MandatoryValidator<std::vector<double>>>();
50 auto mandatoryStrArrayValidator = std::make_shared<MandatoryValidator<std::vector<std::string>>>();
53 "Signal array for n-dimensional workspace");
56 "Error array for n-dimensional workspace");
59 "Number of pixels array for n-dimensional workspace. Optional, defaults "
62 "Dimensionality of the data in the file.");
65 "A comma separated list of min, max for each dimension,\n"
66 "specifying the extents of each dimension.");
69 "Number of bin in each dimension.");
72 "A comma separated list of the name of each dimension. "
73 "e.g. ('[H,0,0]','[0,K,0]','[0,0,L]') ");
76 "A comma separated list of the units of each dimension.");
79 "MDHistoWorkspace reflecting the input text file.");
81 " A comma separated list of the frames of each dimension. "
83 " **General Frame**: Any frame which is not a Q-based frame."
84 " **QLab**: Wave-vector converted into the lab frame."
85 " **QSample**: Wave-vector converted into the frame of the sample."
86 " **HKL**: Wave-vector converted into the crystal's HKL indices."
87 " Note if nothing is specified then the **General Frame** is being "
88 "selected. Also note that if you select a frame then this might override "
89 "your unit selection if it is not compatible with the frame.");
97 auto signals = ws->mutableSignalArray();
98 auto errors = ws->mutableErrorSquaredArray();
99 auto nEvents = ws->mutableNumEventsArray();
101 std::vector<double> signalValues =
getProperty(
"SignalInput");
102 std::vector<double> errorValues =
getProperty(
"ErrorInput");
103 std::vector<double> numberOfEvents =
getProperty(
"NumberOfEvents");
106 std::stringstream stream;
107 stream << binProduct;
108 if (binProduct != signalValues.size()) {
109 throw std::invalid_argument(
"Expected size of the SignalInput is: " + stream.str());
111 if (binProduct != errorValues.size()) {
112 throw std::invalid_argument(
"Expected size of the ErrorInput is: " + stream.str());
114 if (!numberOfEvents.empty() && binProduct != numberOfEvents.size()) {
115 throw std::invalid_argument(
"Expected size of the NumberOfEvents is: " + stream.str() +
116 ". Leave empty to auto fill with 1.0");
120 if (numberOfEvents.empty()) {
121 numberOfEvents = std::vector<double>(binProduct, 1.0);
125 std::copy(signalValues.begin(), signalValues.end(), signals);
126 std::vector<double> empty;
128 signalValues.swap(empty);
130 std::for_each(errorValues.begin(), errorValues.end(),
Square());
131 std::copy(errorValues.begin(), errorValues.end(), errors);
133 errorValues.swap(empty);
135 std::copy(numberOfEvents.begin(), numberOfEvents.end(), nEvents);
137 numberOfEvents.swap(empty);
#define DECLARE_ALGORITHM(classname)
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.
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.
@ Input
An input workspace.
@ Output
An output workspace.
Helper type to compute the square in-place.
void operator()(double &i)