13#include "MantidDataObjects/DllConfig.h"
21namespace DataObjects {
45 MDHistoWorkspace(std::vector<Mantid::Geometry::MDHistoDimension_sptr> &dimensions,
47 MDHistoWorkspace(std::vector<Mantid::Geometry::IMDDimension_sptr> &dimensions,
52 std::unique_ptr<MDHistoWorkspace>
clone()
const {
return std::unique_ptr<MDHistoWorkspace>(doClone()); }
55 std::unique_ptr<MDHistoWorkspace>
cloneEmpty()
const {
return std::unique_ptr<MDHistoWorkspace>(doCloneEmpty()); }
57 void init(std::vector<Mantid::Geometry::MDHistoDimension_sptr> &dimensions);
58 void init(std::vector<Mantid::Geometry::IMDDimension_sptr> &dimensions);
62 const std::string
id()
const override {
return "MDHistoWorkspace"; }
64 size_t getMemorySize()
const override;
68 uint64_t
getNPoints()
const override {
return m_length; }
70 uint64_t getNEvents()
const override;
71 std::vector<std::unique_ptr<Mantid::API::IMDIterator>>
72 createIterators(
size_t suggestedNumCores = 1,
81 void checkWorkspaceSize(
const MDHistoWorkspace &other,
const std::string &operation);
100 void log(
double filler = 0.0);
101 void log10(
double filler = 0.0);
103 void power(
double exponent);
113 void lessThan(
const signal_t signal);
115 void greaterThan(
const signal_t signal);
177 std::unique_ptr<coord_t[]> getVertexesArray(
size_t linearIndex,
size_t &numVertices)
const;
179 Kernel::VMD getCenter(
size_t linearIndex)
const override;
208 return std::sqrt(m_errorsSquared[index1 + indexMultiplier[0] * index2]);
214 return std::sqrt(m_errorsSquared[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3]);
220 return std::sqrt(m_errorsSquared[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 +
221 indexMultiplier[2] * index4]);
235 return m_signals[index1 + indexMultiplier[0] * index2];
241 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3];
247 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 + indexMultiplier[2] * index4];
256 return m_signals[index1 + indexMultiplier[0] * index2] * m_inverseVolume;
262 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3] * m_inverseVolume;
268 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 + indexMultiplier[2] * index4] *
275 return std::sqrt(m_errorsSquared[
index]) * m_inverseVolume;
281 return getErrorAt(index1, index2) * m_inverseVolume;
287 return getErrorAt(index1, index2, index3) * m_inverseVolume;
293 return getErrorAt(index1, index2, index3, index4) * m_inverseVolume;
300 if (
index < m_length)
301 return m_errorsSquared[
index];
303 throw std::invalid_argument(
"MDHistoWorkspace::array index out of range");
309 if (
index < m_length)
310 return m_signals[
index];
312 throw std::invalid_argument(
"MDHistoWorkspace::array index out of range");
317 if (this->getNumDims() != 2)
318 throw std::runtime_error(
"Workspace does not have 2 dimensions!");
319 return index1 + indexMultiplier[0] * index2;
322 size_t getLinearIndex(
size_t index1,
size_t index2,
size_t index3)
const override {
323 if (this->getNumDims() != 3)
324 throw std::runtime_error(
"Workspace does not have 3 dimensions!");
325 return index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3;
328 size_t getLinearIndex(
size_t index1,
size_t index2,
size_t index3,
size_t index4)
const override {
329 if (this->getNumDims() != 4)
330 throw std::runtime_error(
"Workspace does not have 4 dimensions!");
331 return index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 + indexMultiplier[2] * index4;
339 size_t nd = this->getNumDims();
340 size_t out =
index[0];
341 for (
size_t d = 1;
d < nd;
d++)
342 out += indexMultiplier[
d - 1] *
index[
d];
346 size_t getLinearIndexAtCoord(
const coord_t *coords)
const;
353 if (
index < m_length)
354 return m_signals[
index];
356 throw std::invalid_argument(
"MDHistoWorkspace::array index out of range");
361 virtual std::vector<signal_t> getSignalDataVector()
const;
362 virtual std::vector<signal_t> getErrorDataVector()
const;
365 void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion)
override;
367 void setMDMaskAt(
const size_t &
index,
bool mask);
370 void clearMDMasking()
override;
372 uint64_t sumNContribEvents()
const;
373 void updateSum() { m_nEventsContributed = sumNContribEvents(); }
376 static size_t sizeOfElement();
396 void initVertexesArray();
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
Abstract interface to MDHistoWorkspace, for use in exposing to Python.
signal_t & signalAt(size_t index) override
signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell v...
coord_t m_inverseVolume
Inverse of the volume of EACH cell.
size_t getLinearIndex(size_t index1, size_t index2, size_t index3) const override
bool isMDHistoWorkspace() const override
Return if this workspace is a MDHistoWorkspace. Will always return true.
std::unique_ptr< bool[]> m_masks
Linear array of masks for each bin.
const signal_t * getNumEventsArray() const override
signal_t getNumEventsAt(size_t index) const
Returns the number of contributing events from the bin at the specified index.
const bool * getMaskArray() const
MDHistoWorkspace & operator=(const MDHistoWorkspace &other)=delete
const size_t * getIndexMultiplier() const
std::vector< size_t > m_indexMax
Max index into each dimension.
signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell v...
signal_t getSignalNormalizedAt(size_t index) const override
Get the signal at the specified index, normalized by cell volume.
std::unique_ptr< MDHistoWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
size_t numDimensions
Number of dimensions in this workspace.
signal_t getErrorNormalizedAt(size_t index1, size_t index2) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell v...
signal_t getErrorAt(size_t index) const override
Get the error of the signal at the specified index.
size_t getLinearIndex(size_t index1, size_t index2) const override
const coord_t * getBinWidths() const
Return the aray of bin withs (the linear length of a box) for each dimension.
signal_t getErrorAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
Get the error at the specified index given in 4 dimensions (typically X,Y,Z,t)
signal_t getSignalAt(size_t index) const override
Get the signal at the specified index.
void setNumEventsAt(size_t index, signal_t value)
Sets the number of contributing events in the bin at the specified index.
std::unique_ptr< MDHistoWorkspace > clone() const
Returns a clone of the workspace.
std::vector< coord_t > m_origin
Vector of the origin in each dimension.
MDHistoWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
signal_t getErrorAt(size_t index1, size_t index2, size_t index3) const override
Get the error at the specified index given in 4 dimensions (typically X,Y,Z,t)
uint64_t m_nEventsContributed
the number of events, contributed into the workspace;
signal_t & operator[](const size_t &index) override
Array subscript operator.
coord_t getInverseVolume() const override
uint64_t getNPoints() const override
Get the number of points (bins in this case) associated with the workspace;.
std::vector< signal_t > m_errorsSquared
Linear array of errors for each bin.
std::vector< coord_t > m_boxLength
Vector of the length of the box in each dimension.
signal_t * mutableSignalArray() override
signal_t getSignalAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
size_t m_length
Length of the m_signals / m_errorsSquared arrays.
const std::string id() const override
A string ID for the class.
size_t getLinearIndex(size_t index1, size_t index2, size_t index3, size_t index4) const override
MDHistoWorkspace & operator&=(const MDHistoWorkspace &b)
std::vector< size_t > m_indexMaker
For converting to/from linear index to tdimensions.
bool * mutableMaskArray()
const signal_t * getErrorSquaredArray() const override
void makeSingleBinWithNaN(std::vector< coord_t > &x, std::vector< signal_t > &y, std::vector< signal_t > &e) const
std::vector< coord_t > m_vertexesArray
Pre-calculated vertexes array for the 0th box.
signal_t & errorSquaredAt(size_t index) override
signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell v...
signal_t getErrorNormalizedAt(size_t index) const override
Get the error of the signal at the specified index, normalized by cell volume.
bool getIsMaskedAt(size_t index) const
Getter for the masking at a specified linear index.
signal_t getSignalNormalizedAt(size_t index1, size_t index2) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell v...
Mantid::API::MDNormalization m_displayNormalization
Display normalization to use.
signal_t getErrorAt(size_t index1, size_t index2) const override
Get the error at the specified index given in 4 dimensions (typically X,Y,Z,t)
const signal_t * getSignalArray() const override
signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell v...
std::vector< size_t > indexMultiplier
To find the index into the linear array, dim0 + indexMultiplier[0]*dim1 + ...
signal_t getSignalAt(size_t index1, size_t index2) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
std::vector< signal_t > m_signals
Linear array of signals for each bin.
void setSignalAt(size_t index, signal_t value) override
Sets the signal at the specified index.
void setErrorSquaredAt(size_t index, signal_t value) override
Sets the error (squared) at the specified index.
size_t getLinearIndex(size_t *index) const
Get the linear index into the array.
signal_t * mutableErrorSquaredArray() override
MDHistoWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
signal_t getSignalAt(size_t index1, size_t index2, size_t index3) const override
Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
signal_t * mutableNumEventsArray() override
std::vector< signal_t > m_numEvents
Number of contributing events for each bin.
Kernel::SpecialCoordinateSystem m_coordSystem
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Divide two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Subtracts two workspaces.
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
@ NoNormalization
Don't normalize = return raw counts.
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
std::shared_ptr< const MDHistoWorkspace > MDHistoWorkspace_const_sptr
A shared pointer to a const MDHistoWorkspace.
std::shared_ptr< MDHistoDimension > MDHistoDimension_sptr
Shared pointer to a MDHistoDimension.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
Helper class which provides the Collimation Length for SANS instruments.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
double signal_t
Typedef for the signal recorded in a MDBox, etc.
Holds X, Y, E for a line plot.