17using namespace DataObjects;
18using namespace Kernel;
19using namespace Geometry;
40 std::vector<std::string> fileExtensions{
".txt"};
64 file.open(filename.c_str(), std::ios::in);
65 }
catch (std::ifstream::failure &e) {
66 g_log.
error() <<
"Cannot open file: " << filename;
71 using box_collection = std::deque<std::string>;
72 box_collection box_elements;
73 std::copy(std::istream_iterator<std::string>(file), std::istream_iterator<std::string>(),
74 std::back_inserter(box_elements));
82 if (box_elements.size() != nElements) {
83 throw std::invalid_argument(
"The number of data entries in the file, does "
84 "not match up with the specified "
90 double *errors = ws->mutableErrorSquaredArray();
93 size_t currentBox = 0;
94 for (
auto it = box_elements.begin(); it != box_elements.end(); it += 2) {
96 double signal = std::stod(*(temp));
97 double error = std::stod(*(++temp));
98 signals[currentBox] = signal;
#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.
@ Load
allowed here which will be passed to the algorithm
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
void initGenericImportProps()
Initialise the properties associated with the generic import (those to do with dimensionality).
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)
ImportMDHistoWorkspace : Takes a text file containing structured signal and error information and imp...
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
void exec() override
Execute the algorithm.
const std::string category() const override
Algorithm's category for identification.
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
double signal_t
Typedef for the signal recorded in a MDBox, etc.