13#include "MantidDataObjects/DllConfig.h"
22namespace DataObjects {
46 MDHistoWorkspace(std::vector<Mantid::Geometry::MDHistoDimension_sptr> &dimensions,
48 MDHistoWorkspace(std::vector<Mantid::Geometry::IMDDimension_sptr>
const &dimensions,
53 std::unique_ptr<MDHistoWorkspace>
clone()
const {
return std::unique_ptr<MDHistoWorkspace>(doClone()); }
56 std::unique_ptr<MDHistoWorkspace>
cloneEmpty()
const {
return std::unique_ptr<MDHistoWorkspace>(doCloneEmpty()); }
58 void init(std::vector<Mantid::Geometry::MDHistoDimension_sptr> &dimensions);
59 void init(std::vector<Mantid::Geometry::IMDDimension_sptr>
const &dimensions);
63 const std::string
id()
const override {
return "MDHistoWorkspace"; }
65 size_t getMemorySize()
const override;
69 uint64_t
getNPoints()
const override {
return m_length; }
71 uint64_t getNEvents()
const override;
72 std::vector<std::unique_ptr<Mantid::API::IMDIterator>>
73 createIterators(
size_t suggestedNumCores = 1,
82 void checkWorkspaceSize(
const MDHistoWorkspace &other,
const std::string &operation);
101 void log(
double filler = 0.0);
102 void log10(
double filler = 0.0);
104 void power(
double exponent);
114 void lessThan(
const signal_t signal);
116 void greaterThan(
const signal_t signal);
178 std::unique_ptr<coord_t[]> getVertexesArray(
size_t linearIndex,
size_t &numVertices)
const;
180 Kernel::VMD getCenter(
size_t linearIndex)
const override;
209 return std::sqrt(m_errorsSquared[index1 + indexMultiplier[0] * index2]);
215 return std::sqrt(m_errorsSquared[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3]);
221 return std::sqrt(m_errorsSquared[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 +
222 indexMultiplier[2] * index4]);
236 return m_signals[index1 + indexMultiplier[0] * index2];
242 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3];
248 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 + indexMultiplier[2] * index4];
257 return m_signals[index1 + indexMultiplier[0] * index2] * m_inverseVolume;
263 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3] * m_inverseVolume;
269 return m_signals[index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 + indexMultiplier[2] * index4] *
276 return std::sqrt(m_errorsSquared[
index]) * m_inverseVolume;
282 return getErrorAt(index1, index2) * m_inverseVolume;
288 return getErrorAt(index1, index2, index3) * m_inverseVolume;
294 return getErrorAt(index1, index2, index3, index4) * m_inverseVolume;
301 if (
index < m_length)
302 return m_errorsSquared[
index];
304 throw std::invalid_argument(
"MDHistoWorkspace::array index out of range");
310 if (
index < m_length)
311 return m_signals[
index];
313 throw std::invalid_argument(
"MDHistoWorkspace::array index out of range");
318 if (this->getNumDims() != 2)
319 throw std::runtime_error(
"Workspace does not have 2 dimensions!");
320 return index1 + indexMultiplier[0] * index2;
323 size_t getLinearIndex(
size_t index1,
size_t index2,
size_t index3)
const override {
324 if (this->getNumDims() != 3)
325 throw std::runtime_error(
"Workspace does not have 3 dimensions!");
326 return index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3;
329 size_t getLinearIndex(
size_t index1,
size_t index2,
size_t index3,
size_t index4)
const override {
330 if (this->getNumDims() != 4)
331 throw std::runtime_error(
"Workspace does not have 4 dimensions!");
332 return index1 + indexMultiplier[0] * index2 + indexMultiplier[1] * index3 + indexMultiplier[2] * index4;
340 size_t nd = this->getNumDims();
341 size_t out =
index[0];
342 for (
size_t d = 1;
d < nd;
d++)
343 out += indexMultiplier[
d - 1] *
index[
d];
347 size_t getLinearIndexAtCoord(
const coord_t *coords)
const;
354 if (
index < m_length)
355 return m_signals[
index];
357 throw std::invalid_argument(
"MDHistoWorkspace::array index out of range");
362 virtual std::vector<signal_t> getSignalDataVector()
const;
363 virtual std::vector<signal_t> getErrorDataVector()
const;
366 void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion)
override;
368 void setMDMaskAt(
const size_t &
index,
bool mask);
371 void clearMDMasking()
override;
373 uint64_t sumNContribEvents()
const;
374 void updateSum() { m_nEventsContributed = sumNContribEvents(); }
377 static size_t sizeOfElement();
397 void initVertexesArray();
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
MANTID_DATAOBJECTS_EXTERN_TEMPLATE(Mantid::Kernel::PropertyWithValue< std::shared_ptr< Mantid::DataObjects::MDHistoWorkspace > >)
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 getLinearIndex(const size_t *index) const
Get the linear index into the array.
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.
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.
The concrete, templated class for properties.
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.