Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::API::MatrixWorkspaceMDIterator Class Reference

IMDIterator-compatible implementation of an iterator through a MatrixWorkspace. More...

#include <MatrixWorkspaceMDIterator.h>

Inheritance diagram for Mantid::API::MatrixWorkspaceMDIterator:
Mantid::API::IMDIterator

Public Member Functions

std::vector< size_t > findNeighbourIndexes () const override
 Find neighbour indexes. More...
 
std::vector< size_t > findNeighbourIndexesFaceTouching () const override
 Find neighbour indexes face touching. More...
 
Mantid::Kernel::VMD getCenter () const override
 Returns the position of the center of the box pointed to. More...
 
size_t getDataSize () const override
 
signal_t getError () const override
 Returns the error for this box, same as innerError. More...
 
int32_t getInnerDetectorID (size_t index) const override
 For a given event/point in this box, return the detector ID. More...
 
signal_t getInnerError (size_t index) const override
 Returns the error of a given event. More...
 
uint16_t getInnerExpInfoIndex (size_t index) const override
 For a given event/point in this box, return the associated experiment-info index. More...
 
uint16_t getInnerGoniometerIndex (size_t index) const override
 For a given event/point in this box, return the associated experiment-info index. More...
 
coord_t getInnerPosition (size_t index, size_t dimension) const override
 Returns the position of a given event for a given dimension. More...
 
signal_t getInnerSignal (size_t index) const override
 Returns the signal of a given event. More...
 
bool getIsMasked () const override
 Getter for the masked state of the workspace. More...
 
size_t getLinearIndex () const override
 Get the linear index. More...
 
signal_t getNormalizedError () const override
 Returns the normalized error for this box. More...
 
signal_t getNormalizedSignal () const override
 Returns the normalized signal for this box. More...
 
size_t getNumEvents () const override
 Returns the number of events/points contained in this box. More...
 
signal_t getSignal () const override
 Returns the signal for this box, same as innerSignal. More...
 
std::unique_ptr< coord_t[]> getVertexesArray (size_t &numVertices) const override
 Return a list of vertexes defining the volume pointed to. More...
 
std::unique_ptr< coord_t[]> getVertexesArray (size_t &numVertices, const size_t outDimensions, const bool *maskDim) const override
 Return a list of vertexes defining the volume pointed to, enable masking of dimensions. More...
 
bool isWithinBounds (size_t index) const override
 Is index reachable by the iterator. More...
 
void jumpTo (size_t index) override
 Jump to the index^th cell. More...
 
 MatrixWorkspaceMDIterator (const MatrixWorkspace *workspace, Mantid::Geometry::MDImplicitFunction *function, size_t beginWI=0, size_t endWI=size_t(-1))
 Constructor. More...
 
bool next () override
 Advance to the next cell. More...
 
bool next (size_t skip) override
 Advance, skipping a certain number of cells. More...
 
bool valid () const override
 
- Public Member Functions inherited from Mantid::API::IMDIterator
virtual std::vector< size_t > findNeighbourIndexes () const =0
 Find neighbouring indexes vertex touching. More...
 
virtual std::vector< size_t > findNeighbourIndexesFaceTouching () const =0
 Find neighbouring indexes face touching. More...
 
virtual Mantid::Kernel::VMD getCenter () const =0
 Returns the position of the center of the box pointed to. More...
 
virtual size_t getDataSize () const =0
 Get the size of the data (number of entries that will be iterated through) More...
 
virtual signal_t getError () const =0
 Returns the total error for this box. More...
 
virtual int32_t getInnerDetectorID (size_t index) const =0
 For a given event/point in this box, return the detector ID. More...
 
virtual signal_t getInnerError (size_t index) const =0
 Returns the error of a given event. More...
 
virtual uint16_t getInnerExpInfoIndex (size_t index) const =0
 For a given event/point in this box, return the associated experiment-info index. More...
 
virtual uint16_t getInnerGoniometerIndex (size_t index) const =0
 For a given event/point in this box, return the goniometer index. More...
 
virtual coord_t getInnerPosition (size_t index, size_t dimension) const =0
 Returns the position of a given event for a given dimension. More...
 
virtual signal_t getInnerSignal (size_t index) const =0
 Returns the signal of a given event. More...
 
virtual bool getIsMasked () const =0
 Returns true if masking is used. More...
 
virtual size_t getLinearIndex () const =0
 Get the linear index. More...
 
Mantid::API::MDNormalization getNormalization () const
 
virtual signal_t getNormalizedError () const =0
 Returns the normalized error for this box. More...
 
virtual signal_t getNormalizedSignal () const =0
 Returns the normalized signal for this box. More...
 
virtual size_t getNumEvents () const =0
 Returns the number of events/points contained in this box. More...
 
virtual signal_t getSignal () const =0
 Returns the total signal for this box. More...
 
virtual std::unique_ptr< coord_t[]> getVertexesArray (size_t &numVertices) const =0
 Return a list of vertexes defining the volume pointed to. More...
 
virtual std::unique_ptr< coord_t[]> getVertexesArray (size_t &numVertices, const size_t outDimensions, const bool *maskDim) const =0
 Return a list of vertexes defining the volume pointed to, enable masking of dimensions. More...
 
 IMDIterator ()
 Default constructor. More...
 
virtual bool isWithinBounds (size_t index) const =0
 Is index reachable by the iterator. More...
 
virtual void jumpTo (size_t index)=0
 Jump to the index^th cell. More...
 
virtual bool next ()=0
 Advance to the next cell. More...
 
virtual bool next (size_t skip)=0
 Advance, skipping a certain number of cells. More...
 
void setNormalization (Mantid::API::MDNormalization normalization)
 Set how the signal will be normalized when calling getNormalizedSignal() More...
 
virtual bool valid () const =0
 Is the current position of the iterator valid? More...
 
virtual ~IMDIterator ()=default
 

Private Member Functions

void calcWorkspacePos (size_t newWI)
 Calculate the workspace index/x index for this iterator position. More...
 

Private Attributes

size_t m_beginWI
 Workspace index at which the iterator begins. More...
 
Mantid::Kernel::VMD m_center
 Coordinates of the center at the current iterator pos. More...
 
Mantid::Geometry::IMDDimension_const_sptr m_dimY
 The Y (vertical, e.g. spectra) dimension. More...
 
MantidVec m_E
 
size_t m_endWI
 Workspace index at which the iterator ends. More...
 
bool m_errorIsCached
 Error vector has been cached? More...
 
Mantid::Geometry::MDImplicitFunctionm_function
 Implicit function to limit volume searched. More...
 
bool m_isBinnedData
 Is the matrix workspace binned (true) e.g. Y vector is 1 shorter than X. More...
 
uint64_t m_max
 The maximum linear index in the workspace. More...
 
uint64_t m_pos
 The linear position/index into the MDHistoWorkspace. More...
 
const SpectrumInfom_spectrumInfo
 SpectrumInfo object, used for masking information. More...
 
std::vector< size_t > m_startIndices
 vector of starting index of the unraveled data array More...
 
double m_verticalBinSize
 For numeric axes, this is the size of the bin in the vertical direction. More...
 
size_t m_workspaceIndex
 Workspace index of the spectrum we are looking at. More...
 
const MatrixWorkspacem_ws
 Workspace being iterated. More...
 
MantidVec m_X
 Cached copies of X,Y,E at current workspace index. More...
 
size_t m_xIndex
 x-index, index into the Y[] data array of the spectrum. More...
 
MantidVec m_Y
 

Additional Inherited Members

- Protected Attributes inherited from Mantid::API::IMDIterator
Mantid::API::MDNormalization m_normalization
 Normalization method for getNormalizedSignal() More...
 

Detailed Description

IMDIterator-compatible implementation of an iterator through a MatrixWorkspace.

Date
2012-02-08

Definition at line 24 of file MatrixWorkspaceMDIterator.h.

Constructor & Destructor Documentation

◆ MatrixWorkspaceMDIterator()

Mantid::API::MatrixWorkspaceMDIterator::MatrixWorkspaceMDIterator ( const MatrixWorkspace workspace,
Mantid::Geometry::MDImplicitFunction function,
size_t  beginWI = 0,
size_t  endWI = size_t(-1) 
)

Constructor.

Parameters
workspace:: iterate through this workspace
function:: limiting implicit function
beginWI:: first workspace index to iterate
endWI:: end when you reach this workspace index

Definition at line 29 of file MatrixWorkspaceMDIterator.cpp.

References calcWorkspacePos(), Mantid::API::MatrixWorkspace::getDimension(), Mantid::API::MatrixWorkspace::getNumberHistograms(), Mantid::API::MatrixWorkspace::isHistogramData(), m_beginWI, m_center, m_dimY, m_endWI, m_isBinnedData, m_max, m_startIndices, m_workspaceIndex, m_ws, m_xIndex, and Mantid::API::MatrixWorkspace::readY().

Member Function Documentation

◆ calcWorkspacePos()

void Mantid::API::MatrixWorkspaceMDIterator::calcWorkspacePos ( size_t  newWI)
inlineprivate

◆ findNeighbourIndexes()

std::vector< size_t > Mantid::API::MatrixWorkspaceMDIterator::findNeighbourIndexes ( ) const
overridevirtual

Find neighbour indexes.

Returns
Neighbour indexes to the current index.

Implements Mantid::API::IMDIterator.

Definition at line 267 of file MatrixWorkspaceMDIterator.cpp.

◆ findNeighbourIndexesFaceTouching()

std::vector< size_t > Mantid::API::MatrixWorkspaceMDIterator::findNeighbourIndexesFaceTouching ( ) const
overridevirtual

Find neighbour indexes face touching.

Returns
Neighbour indexes to the current index.

Implements Mantid::API::IMDIterator.

Definition at line 275 of file MatrixWorkspaceMDIterator.cpp.

◆ getCenter()

Mantid::Kernel::VMD Mantid::API::MatrixWorkspaceMDIterator::getCenter ( ) const
overridevirtual

Returns the position of the center of the box pointed to.

Implements Mantid::API::IMDIterator.

Definition at line 216 of file MatrixWorkspaceMDIterator.cpp.

References m_center, m_isBinnedData, m_X, and m_xIndex.

Referenced by getInnerPosition(), and next().

◆ getDataSize()

size_t Mantid::API::MatrixWorkspaceMDIterator::getDataSize ( ) const
overridevirtual
Returns
the number of points to be iterated on

Implements Mantid::API::IMDIterator.

Definition at line 68 of file MatrixWorkspaceMDIterator.cpp.

References m_max.

◆ getError()

signal_t Mantid::API::MatrixWorkspaceMDIterator::getError ( ) const
overridevirtual

Returns the error for this box, same as innerError.

Implements Mantid::API::IMDIterator.

Definition at line 193 of file MatrixWorkspaceMDIterator.cpp.

References m_E, m_errorIsCached, m_workspaceIndex, m_ws, m_xIndex, and Mantid::API::MatrixWorkspace::readE().

Referenced by getInnerError(), and getNormalizedError().

◆ getInnerDetectorID()

int32_t Mantid::API::MatrixWorkspaceMDIterator::getInnerDetectorID ( size_t  index) const
overridevirtual

For a given event/point in this box, return the detector ID.

Implements Mantid::API::IMDIterator.

Definition at line 238 of file MatrixWorkspaceMDIterator.cpp.

◆ getInnerError()

signal_t Mantid::API::MatrixWorkspaceMDIterator::getInnerError ( size_t  index) const
overridevirtual

Returns the error of a given event.

Implements Mantid::API::IMDIterator.

Definition at line 249 of file MatrixWorkspaceMDIterator.cpp.

References getError().

◆ getInnerExpInfoIndex()

uint16_t Mantid::API::MatrixWorkspaceMDIterator::getInnerExpInfoIndex ( size_t  index) const
overridevirtual

For a given event/point in this box, return the associated experiment-info index.

Implements Mantid::API::IMDIterator.

Definition at line 232 of file MatrixWorkspaceMDIterator.cpp.

◆ getInnerGoniometerIndex()

uint16_t Mantid::API::MatrixWorkspaceMDIterator::getInnerGoniometerIndex ( size_t  index) const
overridevirtual

For a given event/point in this box, return the associated experiment-info index.

Implements Mantid::API::IMDIterator.

Definition at line 235 of file MatrixWorkspaceMDIterator.cpp.

◆ getInnerPosition()

coord_t Mantid::API::MatrixWorkspaceMDIterator::getInnerPosition ( size_t  index,
size_t  dimension 
) const
overridevirtual

Returns the position of a given event for a given dimension.

Implements Mantid::API::IMDIterator.

Definition at line 241 of file MatrixWorkspaceMDIterator.cpp.

References getCenter().

◆ getInnerSignal()

signal_t Mantid::API::MatrixWorkspaceMDIterator::getInnerSignal ( size_t  index) const
overridevirtual

Returns the signal of a given event.

Implements Mantid::API::IMDIterator.

Definition at line 246 of file MatrixWorkspaceMDIterator.cpp.

References getSignal().

◆ getIsMasked()

bool Mantid::API::MatrixWorkspaceMDIterator::getIsMasked ( ) const
overridevirtual

Getter for the masked state of the workspace.

Returns
True if the detector/detector-group at the workspace index is masked, or if there is no detector at that index.

Implements Mantid::API::IMDIterator.

Definition at line 256 of file MatrixWorkspaceMDIterator.cpp.

References Mantid::API::SpectrumInfo::hasDetectors(), Mantid::API::SpectrumInfo::isMasked(), m_spectrumInfo, and m_workspaceIndex.

◆ getLinearIndex()

size_t Mantid::API::MatrixWorkspaceMDIterator::getLinearIndex ( ) const
overridevirtual

Get the linear index.

Implements Mantid::API::IMDIterator.

Definition at line 280 of file MatrixWorkspaceMDIterator.cpp.

◆ getNormalizedError()

signal_t Mantid::API::MatrixWorkspaceMDIterator::getNormalizedError ( ) const
overridevirtual

◆ getNormalizedSignal()

signal_t Mantid::API::MatrixWorkspaceMDIterator::getNormalizedSignal ( ) const
overridevirtual

◆ getNumEvents()

size_t Mantid::API::MatrixWorkspaceMDIterator::getNumEvents ( ) const
overridevirtual

Returns the number of events/points contained in this box.

Returns
1 always: e.g. there is one (fake) event in the middle of the box.

Implements Mantid::API::IMDIterator.

Definition at line 228 of file MatrixWorkspaceMDIterator.cpp.

◆ getSignal()

signal_t Mantid::API::MatrixWorkspaceMDIterator::getSignal ( ) const
overridevirtual

Returns the signal for this box, same as innerSignal.

Implements Mantid::API::IMDIterator.

Definition at line 190 of file MatrixWorkspaceMDIterator.cpp.

References m_xIndex, and m_Y.

Referenced by getInnerSignal().

◆ getVertexesArray() [1/2]

std::unique_ptr< coord_t[]> Mantid::API::MatrixWorkspaceMDIterator::getVertexesArray ( size_t &  numVertices) const
overridevirtual

Return a list of vertexes defining the volume pointed to.

Implements Mantid::API::IMDIterator.

Definition at line 204 of file MatrixWorkspaceMDIterator.cpp.

◆ getVertexesArray() [2/2]

std::unique_ptr< coord_t[]> Mantid::API::MatrixWorkspaceMDIterator::getVertexesArray ( size_t &  numVertices,
const size_t  outDimensions,
const bool *  maskDim 
) const
overridevirtual

Return a list of vertexes defining the volume pointed to, enable masking of dimensions.

Implements Mantid::API::IMDIterator.

Definition at line 208 of file MatrixWorkspaceMDIterator.cpp.

◆ isWithinBounds()

bool Mantid::API::MatrixWorkspaceMDIterator::isWithinBounds ( size_t  index) const
overridevirtual

Is index reachable by the iterator.

Implements Mantid::API::IMDIterator.

Definition at line 284 of file MatrixWorkspaceMDIterator.cpp.

◆ jumpTo()

void Mantid::API::MatrixWorkspaceMDIterator::jumpTo ( size_t  index)
overridevirtual

Jump to the index^th cell.

No range checking is performed, for performance reasons!

Parameters
index:: point to jump to. Must be 0 <= index < getDataSize().

Implements Mantid::API::IMDIterator.

Definition at line 76 of file MatrixWorkspaceMDIterator.cpp.

References calcWorkspacePos(), index, lower, m_beginWI, m_pos, m_startIndices, and m_xIndex.

Referenced by next().

◆ next() [1/2]

bool Mantid::API::MatrixWorkspaceMDIterator::next ( )
overridevirtual

Advance to the next cell.

If the current cell is the last one in the workspace do nothing and return false.

Returns
true if you can continue iterating

Implements Mantid::API::IMDIterator.

Definition at line 125 of file MatrixWorkspaceMDIterator.cpp.

References calcWorkspacePos(), getCenter(), Mantid::Geometry::MDImplicitFunction::isPointContained(), m_center, m_function, m_max, m_pos, m_workspaceIndex, m_xIndex, and m_Y.

◆ next() [2/2]

bool Mantid::API::MatrixWorkspaceMDIterator::next ( size_t  skip)
overridevirtual

Advance, skipping a certain number of cells.

Parameters
skip:: how many to increase. If 1, then every point will be sampled.

Implements Mantid::API::IMDIterator.

Definition at line 154 of file MatrixWorkspaceMDIterator.cpp.

References jumpTo(), m_max, and m_pos.

◆ valid()

bool Mantid::API::MatrixWorkspaceMDIterator::valid ( ) const
overridevirtual
Returns
true if the iterator is valid. Check this at the start of an iteration, in case the very first point is not valid.

Implements Mantid::API::IMDIterator.

Definition at line 118 of file MatrixWorkspaceMDIterator.cpp.

References m_max, and m_pos.

Member Data Documentation

◆ m_beginWI

size_t Mantid::API::MatrixWorkspaceMDIterator::m_beginWI
private

Workspace index at which the iterator begins.

Definition at line 119 of file MatrixWorkspaceMDIterator.h.

Referenced by jumpTo(), and MatrixWorkspaceMDIterator().

◆ m_center

Mantid::Kernel::VMD Mantid::API::MatrixWorkspaceMDIterator::m_center
mutableprivate

Coordinates of the center at the current iterator pos.

Definition at line 99 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), getCenter(), MatrixWorkspaceMDIterator(), and next().

◆ m_dimY

Mantid::Geometry::IMDDimension_const_sptr Mantid::API::MatrixWorkspaceMDIterator::m_dimY
private

The Y (vertical, e.g. spectra) dimension.

Definition at line 113 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), and MatrixWorkspaceMDIterator().

◆ m_E

MantidVec Mantid::API::MatrixWorkspaceMDIterator::m_E
mutableprivate

Definition at line 104 of file MatrixWorkspaceMDIterator.h.

Referenced by getError().

◆ m_endWI

size_t Mantid::API::MatrixWorkspaceMDIterator::m_endWI
private

Workspace index at which the iterator ends.

Definition at line 122 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), and MatrixWorkspaceMDIterator().

◆ m_errorIsCached

bool Mantid::API::MatrixWorkspaceMDIterator::m_errorIsCached
mutableprivate

Error vector has been cached?

Definition at line 107 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), and getError().

◆ m_function

Mantid::Geometry::MDImplicitFunction* Mantid::API::MatrixWorkspaceMDIterator::m_function
private

Implicit function to limit volume searched.

Definition at line 90 of file MatrixWorkspaceMDIterator.h.

Referenced by next().

◆ m_isBinnedData

bool Mantid::API::MatrixWorkspaceMDIterator::m_isBinnedData
private

Is the matrix workspace binned (true) e.g. Y vector is 1 shorter than X.

Definition at line 110 of file MatrixWorkspaceMDIterator.h.

Referenced by getCenter(), and MatrixWorkspaceMDIterator().

◆ m_max

uint64_t Mantid::API::MatrixWorkspaceMDIterator::m_max
private

The maximum linear index in the workspace.

Definition at line 87 of file MatrixWorkspaceMDIterator.h.

Referenced by getDataSize(), MatrixWorkspaceMDIterator(), next(), and valid().

◆ m_pos

uint64_t Mantid::API::MatrixWorkspaceMDIterator::m_pos
private

The linear position/index into the MDHistoWorkspace.

Definition at line 84 of file MatrixWorkspaceMDIterator.h.

Referenced by jumpTo(), next(), and valid().

◆ m_spectrumInfo

const SpectrumInfo& Mantid::API::MatrixWorkspaceMDIterator::m_spectrumInfo
private

SpectrumInfo object, used for masking information.

Definition at line 129 of file MatrixWorkspaceMDIterator.h.

Referenced by getIsMasked().

◆ m_startIndices

std::vector<size_t> Mantid::API::MatrixWorkspaceMDIterator::m_startIndices
private

vector of starting index of the unraveled data array

Definition at line 116 of file MatrixWorkspaceMDIterator.h.

Referenced by jumpTo(), and MatrixWorkspaceMDIterator().

◆ m_verticalBinSize

double Mantid::API::MatrixWorkspaceMDIterator::m_verticalBinSize
private

For numeric axes, this is the size of the bin in the vertical direction.

It is 1.0 for spectrum axes

Definition at line 126 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), getNormalizedError(), and getNormalizedSignal().

◆ m_workspaceIndex

size_t Mantid::API::MatrixWorkspaceMDIterator::m_workspaceIndex
private

Workspace index of the spectrum we are looking at.

Definition at line 93 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), getError(), getIsMasked(), MatrixWorkspaceMDIterator(), and next().

◆ m_ws

const MatrixWorkspace* Mantid::API::MatrixWorkspaceMDIterator::m_ws
private

Workspace being iterated.

Definition at line 81 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), getError(), and MatrixWorkspaceMDIterator().

◆ m_X

MantidVec Mantid::API::MatrixWorkspaceMDIterator::m_X
private

Cached copies of X,Y,E at current workspace index.

Definition at line 102 of file MatrixWorkspaceMDIterator.h.

Referenced by calcWorkspacePos(), getCenter(), getNormalizedError(), and getNormalizedSignal().

◆ m_xIndex

size_t Mantid::API::MatrixWorkspaceMDIterator::m_xIndex
private

x-index, index into the Y[] data array of the spectrum.

Definition at line 96 of file MatrixWorkspaceMDIterator.h.

Referenced by getCenter(), getError(), getNormalizedError(), getNormalizedSignal(), getSignal(), jumpTo(), MatrixWorkspaceMDIterator(), and next().

◆ m_Y

MantidVec Mantid::API::MatrixWorkspaceMDIterator::m_Y
private

The documentation for this class was generated from the following files: