Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Mantid::DataObjects::MDBox Class Reference

Templated class for a multi-dimensional event "box". More...

#include <MDBox.h>

Inheritance diagram for Mantid::DataObjects::MDBox:
Mantid::DataObjects::MDBoxBase< MDE, nd >

Public Types

using EventIterator = typename std::vector< MDE >::const_iterator
 
using sptr = std::shared_ptr< MDBox< MDE, nd > >
 Typedef for a shared pointer to a MDBox.
 
using vec_t = std::vector< MDE >
 Typedef for a vector of the conatined events.
 
- Public Types inherited from Mantid::DataObjects::MDBoxBase< MDE, nd >
using sptr = std::shared_ptr< MDBoxBase< MDE, nd > >
 Convenience typedef for a shared pointer to a this type of class.
 

Public Member Functions

size_t addEvent (const MDE &Evnt) override
 Add a MDLeanEvent to the box.
 
size_t addEvents (const std::vector< MDE > &events) override
 Add Add all events .
 
size_t addEventsUnsafe (const std::vector< MDE > &events) override
 Add all of the events contained in a vector, with:
 
size_t addEventUnsafe (const MDE &Evnt) override
 Add a MDLeanEvent to the box, in a NON-THREAD-SAFE manner.
 
void buildAndAddEvent (const signal_t Signal, const signal_t errorSq, const std::vector< coord_t > &point, uint16_t expInfoIndex, uint16_t goniometerIndex, uint32_t detectorId) override
 Create event from the input data and add it to the box.
 
size_t buildAndAddEvents (const std::vector< signal_t > &sigErrSq, const std::vector< coord_t > &Coord, const std::vector< uint16_t > &expInfoIndex, const std::vector< uint16_t > &goniometernIndex, const std::vector< uint32_t > &detectorId) override
 Create and Add several events.
 
void buildAndAddEventUnsafe (const signal_t Signal, const signal_t errorSq, const std::vector< coord_t > &point, uint16_t expInfoIndex, uint16_t goniometernIndex, uint32_t detectorId) override
 Create MDEvent and add it to the box, in a NON-THREAD-SAFE manner.
 
void calculateCentroid (coord_t *centroid) const override
 Calculate the centroid of this box.
 
void calculateCentroid (coord_t *centroid, const int expInfoIndex) const override
 Calculate the centroid of this box.
 
void calculateDimensionStats (MDDimensionStats *stats) const
 Calculate the statistics for each dimension of this MDBox, using all the contained events.
 
void centerpointBin (MDBin< MDE, nd > &bin, bool *fullyContained) const override
 Perform centerpoint binning of events.
 
void centroidSphere (Mantid::API::CoordTransform &radiusTransform, const coord_t radiusSquared, coord_t *centroid, signal_t &signal) const override
 Find the centroid of all events contained within by doing a weighted average of their coordinates.
 
void clear () override
 Clear any points contained.
 
void clearDataFromMemory () override
 drop events data from memory but keep averages (and file-backed info)
 
void clearFileBacked (bool loadDiskBackedData) override
 clear file-backed information from the box if such information exists
 
void generalBin (MDBin< MDE, nd > &bin, Mantid::Geometry::MDImplicitFunction &function) const override
 General (non-axis-aligned) centerpoint binning method.
 
void getBoxes (std::vector< API::IMDNode * > &boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction *function) override
 
void getBoxes (std::vector< API::IMDNode * > &boxes, size_t, bool) override
 
void getBoxes (std::vector< API::IMDNode * > &outBoxes, const std::function< bool(API::IMDNode *)> &cond) final override
 Return all boxes contained within.
 
void getBoxes (std::vector< MDBoxBase< MDE, nd > * > &boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction *function)
 Fill a vector with all the boxes up to a certain depth.
 
void getBoxes (std::vector< MDBoxBase< MDE, nd > * > &boxes, size_t, bool)
 Fill a vector with all the boxes up to a certain depth.
 
coord_tgetCentroid () const override
 Return the centroid of this box.
 
API::IMDNodegetChild (size_t) override
 Return the indexth child MDBoxBase.
 
const std::vector< MDE > & getConstEvents () const
 Get vector of constant events to use.
 
size_t getDataInMemorySize () const override
 
std::vector< MDE > & getEvents ()
 Get vector of events to change.
 
const std::vector< MDE > & getEvents () const
 
std::vector< MDE > * getEventsCopy () override
 Allocate and return a vector with a copy of all events contained.
 
void getEventsData (std::vector< coord_t > &coordTable, size_t &nColumns) const override
 The method to convert events in a box into a table of coordinates/signal/errors casted into coord_t type Used to save events from plain binary file.
 
Kernel::ISaveablegetISaveable () const override
 
Kernel::ISaveablegetISaveable () override
 
bool getIsMasked () const override
 
uint64_t getNPoints () const override
 Returns the total number of points (events) in this box either they are all in memory, or on disk or partially on memory and partially on disk for partially loaded object substantially relies on correct settings of wasSaved and isLoaded switches of iSaveable object.
 
size_t getNumChildren () const override
 Get the # of children MDBoxBase'es (non-recursive)
 
size_t getNumDims () const override
 Returns the number of dimensions in this box.
 
size_t getNumMDBoxes () const override
 Returns the number of un-split MDBoxes in this box (including all children)
 
uint64_t getTotalDataSize () const override
 
void integrateCylinder (Mantid::API::CoordTransform &radiusTransform, const coord_t radius, const coord_t length, signal_t &signal, signal_t &errorSquared, std::vector< signal_t > &signal_fit) const override
 Integrate the signal within a sphere; for example, to perform single-crystal peak integration.
 
void integrateSphere (Mantid::API::CoordTransform &radiusTransform, const coord_t radiusSquared, signal_t &signal, signal_t &errorSquared, const coord_t innerRadiusSquared=0.0, const bool useOnePercentBackgroundCorrection=true) const override
 Integrate the signal within a sphere; for example, to perform single-crystal peak integration.
 
bool isBox () const override
 
bool isDataAdded () const
 
void loadAndAddFrom (API::IBoxControllerIO *const, uint64_t, size_t) override
 Load the box data of specified size from the disk location provided using the class, respoinsible for the file IO and append them to exisiting events Clear events vector first if overwriting the exisitng events is necessary.
 
void loadAndAddFrom (API::IBoxControllerIO *const, uint64_t, size_t, std::vector< coord_t > &) override
 Load the box data of specified size from the disk location provided using the class, respoinsible for the file IO and append them to exisiting events Clear events vector first if overwriting the exisitng events is necessary.
 
void mask () override
 Setter for masking the box.
 
 MDBox (const MDBox< MDE, nd > &other, Mantid::API::BoxController *const otherBC)
 Copy constructor.
 
 MDBox (Mantid::API::BoxController *const bc, const uint32_t depth, const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &extentsVector, EventIterator begin, EventIterator end)
 contructor for explicit creation of MDGridBox with known events in it
 
 MDBox (Mantid::API::BoxController *const splitter, const uint32_t depth, const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &extentsVector, const size_t nBoxEvents=UNDEF_SIZET, const size_t boxID=UNDEF_SIZET)
 Constructor.
 
 MDBox (Mantid::API::BoxController *const splitter, const uint32_t depth=0, const size_t nBoxEvents=UNDEF_SIZET, const size_t boxID=UNDEF_SIZET)
 Constructor/default constructor.
 
 MDBox (Mantid::API::BoxController_sptr &splitter, const uint32_t depth, const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &extentsVector, const size_t nBoxEvents=UNDEF_SIZET, const size_t boxID=UNDEF_SIZET)
 Constructor.
 
 MDBox (Mantid::API::BoxController_sptr &splitter, const uint32_t depth=0, const size_t nBoxEvents=UNDEF_SIZET, const size_t boxID=UNDEF_SIZET)
 Convenience Constructor/default constructor for accepting shared pointer.
 
void refreshCache (Kernel::ThreadScheduler *=nullptr) override
 Recalculate signal and various averages dependent on signal and the signal coordinates.
 
void releaseEvents ()
 For file-backed MDBoxes, this marks that the data vector is no longer "busy", and so it is safe for the MRU to cache it back to disk if needed.
 
void reserveMemoryForLoad (uint64_t) override
 Reserve all the memory required for loading in one step.
 
void saveAt (API::IBoxControllerIO *const, uint64_t) const override
 Save the box data to specific disk position using the class, responsible for the file IO.
 
void setChildren (const std::vector< API::IMDNode * > &, const size_t, const size_t) override
 Sets the children from a vector of children.
 
void setEventsData (const std::vector< coord_t > &coordTable) override
 The method to convert the table of data into vector of events Used to load events from plain binary file.
 
void setFileBacked () override
 Make this box file-backed but its place on the file is not identified yet.
 
void setFileBacked (const uint64_t, const size_t, const bool) override
 Make this box file-backed.
 
void splitAllIfNeeded (Mantid::Kernel::ThreadScheduler *=nullptr) override
 
void transformDimensions (std::vector< double > &scaling, std::vector< double > &offset) override
 Transform the dimensions contained in this box x' = x*scaling + offset.
 
void unmask () override
 Setter for unmasking the box.
 
 ~MDBox () override
 Destructor.
 
- Public Member Functions inherited from Mantid::DataObjects::MDBoxBase< MDE, nd >
virtual void calculateGridCaches ()
 
void calcVolume () override
 Compute the volume of the box by simply multiplying each dimension range.
 
const IMDNodegetBoxAtCoord (const coord_t *) override
 Returns the lowest-level box at the given coordinates.
 
Mantid::API::BoxControllergetBoxController () const override
 
Mantid::API::BoxControllergetBoxController () override
 
coord_t getBoxSize (size_t d)
 For testing: return the internal-stored size of each box in each dimension.
 
void getCenter (coord_t *const center) const override
 Get the center of the box.
 
unsigned int getCoordType () const override
 
uint32_t getDepth () const override
 For testing, mostly: return the recursion depth of this box.
 
signal_t getError () const override
 Returns the integrated error from all points within.
 
signal_t getErrorSquared () const override
 Returns the integrated error squared from all points within.
 
virtual signal_t getErrorSquaredNormalized () const
 Returns the integrated error squared from all points within, normalized for the cell volume.
 
void getEventsData (std::vector< coord_t > &, size_t &nColumns) const override
 The method to convert events in a box into a table of coodrinates/signal/errors casted into coord_t type Used to conver events into plain data array.
 
std::string getEventType () const override
 
Mantid::Geometry::MDDimensionExtents< coord_t > & getExtents (size_t dim) override
 Get the extents for this box.
 
std::string getExtentsStr () const
 Returns the extents as a string, for convenience.
 
size_t getID () const override
 
coord_t getInverseVolume () const override
 Return the inverse of the volume of the cell.
 
const IMDNodegetParent () const override
 Return a pointer to the parent box (const)
 
IMDNodegetParent () override
 Return a pointer to the parent box.
 
signal_t getSignal () const override
 Returns the integrated signal from all points within.
 
signal_t getSignalNormalized () const override
 Returns the integrated signal from all points within, normalized for the cell volume.
 
virtual signal_t getTotalWeight () const
 Returns the total weight of all events within.
 
std::vector< Mantid::Kernel::VMDgetVertexes () const override
 Return the vertices of corners of the box.
 
std::unique_ptr< coord_t[]> getVertexesArray (size_t &numVertices) const override
 Return the vertices of every corner of the box, but as a bare array of length numVertices * nd.
 
std::unique_ptr< coord_t[]> getVertexesArray (size_t &numVertices, const size_t outDimensions, const bool *maskDim) const override
 Return the vertices of every corner of the box, but to a reduced number of dimensions.
 
coord_t getVolume () const
 Return the volume of the cell.
 
bool isLeaf () const override final
 Is this node a leaf: getNumChildren() == 0.
 
 MDBoxBase (const MDBoxBase< MDE, nd > &box, Mantid::API::BoxController *const otherBC)
 Copy constructor.
 
 MDBoxBase (Mantid::API::BoxController *const boxController, const uint32_t depth, const size_t boxID, const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &extentsVector)
 Constructor with extents.
 
 MDBoxBase (Mantid::API::BoxController *const boxController=nullptr, const uint32_t depth=0, const size_t boxID=UNDEF_SIZET)
 Default constructor.
 
void setDepth (uint32_t depth)
 For testing, mostly: set the recursion depth of this box.
 
void setErrorSquared (const signal_t ErrorSquared) override
 Sets the integrated error squared from all points within (mostly used for testing)
 
void setEventsData (const std::vector< coord_t > &) override
 The method to convert the table of data into vector of events Used to convert from a vector of values (2D table in Fortran representation (by rows) into box events.
 
void setExtents (double min[nd], double max[nd])
 Set the extents of this box.
 
void setExtents (size_t dim, double min, double max)
 Set the extents of this box.
 
void setID (const size_t &newID) override
 sets the special id, which specify the position of this node in the chain linearly ordered nodes
 
void setInverseVolume (const coord_t invVolume) override
 Sets the inverse of the volume of the cell.
 
void setParent (IMDNode *parent) override
 Return a pointer to the parent box.
 
void setSignal (const signal_t signal) override
 Sets the integrated signal from all points within (mostly used for testing)
 
virtual void setTotalWeight (const signal_t total)
 Sets the total weight from all points within (mostly used for testing)
 
void transformDimensions (std::vector< double > &scaling, std::vector< double > &offset) override
 Transform the dimensions contained in this box x' = x*scaling + offset.
 

Protected Attributes

std::vector< MDE > data
 Vector of MDEvent's, in no particular order.
 
bool m_bIsMasked
 Flag indicating that masking has been applied.
 
std::unique_ptr< Kernel::ISaveablem_Saveable
 
- Protected Attributes inherited from Mantid::DataObjects::MDBoxBase< MDE, nd >
Mantid::Geometry::MDDimensionExtents< coord_textents [nd]
 Array of MDDimensionStats giving the extents and other stats on the box dimensions.
 
Mantid::API::BoxController *const m_BoxController
 The box splitting controller, shared with all boxes in the hierarchy.
 
coord_t m_centroid [nd]
 
std::mutex m_dataMutex
 Mutex for modifying the event list or box averages.
 
uint32_t m_depth
 Recursion depth.
 
signal_t m_errorSquared
 Cached total error (squared) from all points within.
 
size_t m_fileID
 The id which specify location of this box in a linear chain of ordered boxes (e.g.
 
coord_t m_inverseVolume
 Inverse of the volume of the cell, to be used for normalized signal.
 
Mantid::API::IMDNodem_parent
 Pointer to the parent of this box. NULL if no parent.
 
signal_t m_signal
 Cached total signal from all points within.
 
signal_t m_totalWeight
 Cached total weight of all events Set when refreshCache() is called.
 

Private Member Functions

void initMDBox (const size_t nBoxEvents)
 common part of mdBox constructor
 
 MDBox (const MDBox &)
 private default copy constructor as the only correct constructor is the one with the boxController;
 

Private Attributes

std::vector< coord_tm_tableData
 member to avoid reallocation
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::DataObjects::MDBoxBase< MDE, nd >
void calcCaches (const EventIterator &begin, const EventIterator &end)
 Calculates caches if the events are known.
 

Detailed Description

Templated class for a multi-dimensional event "box".

A box is a container of MDLeanEvent's within a certain range of values within the nd dimensions. This range defines a n-dimensional "box" or rectangular prism.

This class is a simple list of points with no more internal structure.

Template Parameters
nd:: the number of dimensions that each MDLeanEvent will be tracking. an int > 0.
Author
Janik Zikovsky, SNS
Date
Dec 7, 2010

Definition at line 45 of file MDBox.h.

Member Typedef Documentation

◆ EventIterator

using Mantid::DataObjects::MDBox::EventIterator = typename std::vector<MDE>::const_iterator

Definition at line 60 of file MDBox.h.

◆ sptr

using Mantid::DataObjects::MDBox::sptr = std::shared_ptr<MDBox<MDE, nd> >

Typedef for a shared pointer to a MDBox.

Definition at line 217 of file MDBox.h.

◆ vec_t

using Mantid::DataObjects::MDBox::vec_t = std::vector<MDE>

Typedef for a vector of the conatined events.

Definition at line 220 of file MDBox.h.

Constructor & Destructor Documentation

◆ MDBox() [1/7]

Mantid::DataObjects::MDBox::MDBox ( Mantid::API::BoxController_sptr splitter,
const uint32_t  depth = 0,
const size_t  nBoxEvents = UNDEF_SIZET,
const size_t  boxID = UNDEF_SIZET 
)

Convenience Constructor/default constructor for accepting shared pointer.

Parameters
splitter:: shared pointer to BoxController that controls how boxes split
depth:: splitting depth of the new box.
nBoxEvents:: number of events to reserve memory for.
boxID:: id for the given box

Definition at line 44 of file MDBox.hxx.

◆ MDBox() [2/7]

Mantid::DataObjects::MDBox::MDBox ( Mantid::API::BoxController *const  splitter,
const uint32_t  depth = 0,
const size_t  nBoxEvents = UNDEF_SIZET,
const size_t  boxID = UNDEF_SIZET 
)

Constructor/default constructor.

Parameters
splitter:: BoxController that controls how boxes split
depth:: splitting depth of the new box.
nBoxEvents:: number of events to reserve memory for.
boxID:: id for the given box

Definition at line 56 of file MDBox.hxx.

◆ MDBox() [3/7]

Mantid::DataObjects::MDBox::MDBox ( Mantid::API::BoxController_sptr splitter,
const uint32_t  depth,
const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &  extentsVector,
const size_t  nBoxEvents = UNDEF_SIZET,
const size_t  boxID = UNDEF_SIZET 
)

Constructor.

Parameters
splitter:: BoxController that controls how boxes split
depth:: splitting depth of the new box.
extentsVector:: vector defining the extents of the box in all n-dimensions
nBoxEvents:: number of events to reserve memory for.
boxID:: id for the given box

Definition at line 71 of file MDBox.hxx.

◆ MDBox() [4/7]

Mantid::DataObjects::MDBox::MDBox ( Mantid::API::BoxController *const  splitter,
const uint32_t  depth,
const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &  extentsVector,
const size_t  nBoxEvents = UNDEF_SIZET,
const size_t  boxID = UNDEF_SIZET 
)

Constructor.

Parameters
splitter:: BoxController that controls how boxes split
depth:: splitting depth of the new box.
extentsVector:: vector defining the extents
nBoxEvents:: Initial number of events to reserve memory for. If left undefined, the memory will be allocated on request.
boxID:: id for the given box

Definition at line 86 of file MDBox.hxx.

◆ MDBox() [5/7]

Mantid::DataObjects::MDBox::MDBox ( Mantid::API::BoxController *const  bc,
const uint32_t  depth,
const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &  extentsVector,
EventIterator  begin,
EventIterator  end 
)

contructor for explicit creation of MDGridBox with known events in it

Parameters
bc:: shared pointer to the BoxController, owned by workspace
depth:: recursive split depth
extentsVector:: size of the box
begin:: iterator to start
end:: iterator before ened (not included)

Definition at line 103 of file MDBox.hxx.

References Mantid::DataObjects::MDBoxBase::calcCaches(), data, Mantid::API::BoxController::isFileBacked(), and Mantid::DataObjects::MDBoxBase< MDE, nd >::m_BoxController.

◆ MDBox() [6/7]

Mantid::DataObjects::MDBox::MDBox ( const MDBox< MDE, nd > &  other,
Mantid::API::BoxController *const  otherBC 
)

Copy constructor.

Parameters
otherMDBox object to copy from.
otherBC- mandatory other box controller, which controls how this box will split.

Definition at line 131 of file MDBox.hxx.

◆ ~MDBox()

Mantid::DataObjects::MDBox::~MDBox ( )
override

Destructor.

Definition at line 22 of file MDBox.hxx.

◆ MDBox() [7/7]

Mantid::DataObjects::MDBox::MDBox ( const MDBox )
private

private default copy constructor as the only correct constructor is the one with the boxController;

Member Function Documentation

◆ addEvent()

size_t Mantid::DataObjects::MDBox::addEvent ( const MDE &  Evnt)
overridevirtual

Add a MDLeanEvent to the box.

Parameters
Evnt:: reference to a MDEvent to add.
Returns
Always returns 1

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 786 of file MDBox.hxx.

◆ addEvents()

size_t Mantid::DataObjects::MDBox::addEvents ( const std::vector< MDE > &  events)
overridevirtual

Add Add all events .

No bounds checking is made!

Parameters
events:: vector of events to be copied.
Returns
always returns 0

Reimplemented from Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 812 of file MDBox.hxx.

◆ addEventsUnsafe()

size_t Mantid::DataObjects::MDBox::addEventsUnsafe ( const std::vector< MDE > &  events)
overridevirtual

Add all of the events contained in a vector, with:

  • No bounds checking.
  • No thread-safety.
Parameters
events:: Vector of MDEvent

Reimplemented from Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 140 of file MDBox.hxx.

◆ addEventUnsafe()

size_t Mantid::DataObjects::MDBox::addEventUnsafe ( const MDE &  Evnt)
overridevirtual

Add a MDLeanEvent to the box, in a NON-THREAD-SAFE manner.

No lock is performed. This is only safe if no 2 threads will try to add to the same box at the same time.

Parameters
Evnt:: reference to a MDEvent to add.
Returns
Always returns 1

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 800 of file MDBox.hxx.

◆ buildAndAddEvent()

void Mantid::DataObjects::MDBox::buildAndAddEvent ( const signal_t  Signal,
const signal_t  errorSq,
const std::vector< coord_t > &  point,
uint16_t  expInfoIndex,
uint16_t  goniometerIndex,
uint32_t  detectorId 
)
override

Create event from the input data and add it to the box.

Parameters
Signal:: events signal
errorSq:: events Error squared
point:: reference to the vector of MDEvent coordinates
expInfoIndex:: run index of the experiment the event come from
goniometerIndex:: 0-based index determines the goniometer settings when this event occurred
detectorId:: the ID of the detector recoded the event

Definition at line 754 of file MDBox.hxx.

◆ buildAndAddEvents()

size_t Mantid::DataObjects::MDBox::buildAndAddEvents ( const std::vector< signal_t > &  sigErrSq,
const std::vector< coord_t > &  Coord,
const std::vector< uint16_t > &  expInfoIndex,
const std::vector< uint16_t > &  goniometerIndex,
const std::vector< uint32_t > &  detectorId 
)
override

Create and Add several events.

No bounds checking is made!

Returns
number of events rejected (0 as nothing is rejected here)

Definition at line 731 of file MDBox.hxx.

◆ buildAndAddEventUnsafe()

void Mantid::DataObjects::MDBox::buildAndAddEventUnsafe ( const signal_t  Signal,
const signal_t  errorSq,
const std::vector< coord_t > &  point,
uint16_t  expInfoIndex,
uint16_t  goniometerIndex,
uint32_t  detectorId 
)
override

Create MDEvent and add it to the box, in a NON-THREAD-SAFE manner.

No lock is performed. This is only safe if no 2 threads will try to add to the same box at the same time.

Parameters
Signal:: events signal
errorSq:: events Error squared
point:: reference to the vector of MDEvent coordinates
expInfoIndex:: run index of the experiment the event come from
goniometerIndex:: 0-based index determines the goniometer settings when this event occurred
detectorId:: the ID of the detector recoded the event

Definition at line 774 of file MDBox.hxx.

◆ calculateCentroid() [1/2]

void Mantid::DataObjects::MDBox::calculateCentroid ( coord_t centroid) const
override

Calculate the centroid of this box.

Parameters
centroid[out] :: nd-sized array that will be set to the centroid.

Definition at line 405 of file MDBox.hxx.

References Mantid::Geometry::d.

◆ calculateCentroid() [2/2]

void Mantid::DataObjects::MDBox::calculateCentroid ( coord_t centroid,
const int  expInfoIndex 
) const
override

Calculate the centroid of this box.

Parameters
centroid[out] :: nd-sized array that will be set to the centroid.
expInfoIndex[in] :: associated experiment-info index used to filter the events.

Definition at line 433 of file MDBox.hxx.

References Mantid::Geometry::d.

◆ calculateDimensionStats()

void Mantid::DataObjects::MDBox::calculateDimensionStats ( MDDimensionStats stats) const

Calculate the statistics for each dimension of this MDBox, using all the contained events.

Parameters
stats:: nd-sized fixed array of MDDimensionStats, reset to 0.0 before!

Definition at line 465 of file MDBox.hxx.

References Mantid::Geometry::d.

◆ centerpointBin()

void Mantid::DataObjects::MDBox::centerpointBin ( MDBin< MDE, nd > &  bin,
bool *  fullyContained 
) const
overridevirtual

Perform centerpoint binning of events.

Parameters
bin:: MDBin object giving the limits of events to accept.
fullyContained:: optional bool array sized [nd] of which dimensions are known to be fully contained (for MDSplitBox)

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 479 of file MDBox.hxx.

References Mantid::Geometry::d.

◆ centroidSphere()

void Mantid::DataObjects::MDBox::centroidSphere ( Mantid::API::CoordTransform radiusTransform,
const coord_t  radiusSquared,
coord_t centroid,
signal_t signal 
) const
overridevirtual

Find the centroid of all events contained within by doing a weighted average of their coordinates.

Parameters
radiusTransform:: nd-to-1 coordinate transformation that converts from these dimensions to the distance (squared) from the center of the sphere.
radiusSquared:: radius^2 below which to integrate
[out]centroid:: array of size [nd]; its centroid will be added
[out]signal:: set to the integrated signal

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 674 of file MDBox.hxx.

References Mantid::Geometry::d.

◆ clear()

void Mantid::DataObjects::MDBox::clear ( )
override

Clear any points contained.

Definition at line 146 of file MDBox.hxx.

◆ clearDataFromMemory()

void Mantid::DataObjects::MDBox::clearDataFromMemory ( )
override

drop events data from memory but keep averages (and file-backed info)

Clear the data[] vector ONLY but does not change the file-backed settings.

Used to free up the memory in a file-backed workspace without removing the events from disk.

Definition at line 167 of file MDBox.hxx.

◆ clearFileBacked()

void Mantid::DataObjects::MDBox::clearFileBacked ( bool  loadDiskBackedData)
override

clear file-backed information from the box if such information exists

Parameters
loadDiskBackedData– if true, load the data initially saved to HDD before breaking connection between the file and memory if false – just forget about the data on the HDD not entirely fool-proof, as if the data is actually loaded is controlled by isLoaded switch in ISaveable and this switch has to be set up correctly

Definition at line 943 of file MDBox.hxx.

◆ generalBin()

void Mantid::DataObjects::MDBox::generalBin ( MDBin< MDE, nd > &  bin,
Mantid::Geometry::MDImplicitFunction function 
) const
overridevirtual

General (non-axis-aligned) centerpoint binning method.

TODO: TEST THIS!

Parameters
bin:: a MDBin object giving the limits, aligned with the axes of the workspace, of where the non-aligned bin MIGHT be present.
function:: a ImplicitFunction that will evaluate true for any coordinate that is contained within the (non-axis-aligned) bin.

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 535 of file MDBox.hxx.

◆ getBoxes() [1/5]

void Mantid::DataObjects::MDBox::getBoxes ( std::vector< API::IMDNode * > &  boxes,
size_t  maxDepth,
bool  leafOnly,
Mantid::Geometry::MDImplicitFunction function 
)
override

Definition at line 202 of file MDBox.hxx.

◆ getBoxes() [2/5]

void Mantid::DataObjects::MDBox::getBoxes ( std::vector< API::IMDNode * > &  boxes,
size_t  ,
bool   
)
override

Definition at line 192 of file MDBox.hxx.

◆ getBoxes() [3/5]

void Mantid::DataObjects::MDBox::getBoxes ( std::vector< API::IMDNode * > &  outBoxes,
const std::function< bool(API::IMDNode *)> &  cond 
)
finaloverride

Return all boxes contained within.

Parameters
outBoxes:: vector to fill
cond:: condition to check (leaves on the tree)

Definition at line 214 of file MDBox.hxx.

◆ getBoxes() [4/5]

void Mantid::DataObjects::MDBox::getBoxes ( std::vector< MDBoxBase< MDE, nd > * > &  boxes,
size_t  maxDepth,
bool  leafOnly,
Mantid::Geometry::MDImplicitFunction function 
)

Fill a vector with all the boxes up to a certain depth.

Definition at line 198 of file MDBox.hxx.

◆ getBoxes() [5/5]

void Mantid::DataObjects::MDBox::getBoxes ( std::vector< MDBoxBase< MDE, nd > * > &  boxes,
size_t  ,
bool   
)

Fill a vector with all the boxes up to a certain depth.

Definition at line 189 of file MDBox.hxx.

◆ getCentroid()

coord_t * Mantid::DataObjects::MDBox::getCentroid ( ) const
override

Return the centroid of this box.

Definition at line 661 of file MDBox.hxx.

◆ getChild()

API::IMDNode * Mantid::DataObjects::MDBox::getChild ( size_t  )
inlineoverride

Return the indexth child MDBoxBase.

Definition at line 100 of file MDBox.h.

◆ getConstEvents()

const std::vector< MDE > & Mantid::DataObjects::MDBox::getConstEvents ( ) const

Get vector of constant events to use.

Returns a const reference to the events vector contained within.

Beware, that calling this funtion for file-based workspace sets dataBusy flag This flag prevents DB from clearing object from memory untill the events are released. One HAS TO call releaseEvents when finished using data on file-based WS to allow DB clearing them

VERY IMPORTANT: call MDBox::releaseEvents() when you are done accessing that data.

Definition at line 269 of file MDBox.hxx.

Referenced by Mantid::MDAlgorithms::BinMD::binMDBox(), Mantid::MDAlgorithms::CompareMDWorkspaces::compare2Boxes(), Mantid::MDAlgorithms::MinusMD::doMinus(), Mantid::MDAlgorithms::MergeMD::doPlus(), Mantid::MDAlgorithms::PlusMD::doPlus(), Mantid::DataObjects::MDBoxIterator::getEvents(), and Mantid::MDAlgorithms::SliceMD::slice().

◆ getDataInMemorySize()

size_t Mantid::DataObjects::MDBox::getDataInMemorySize ( ) const
inlineoverride

Definition at line 87 of file MDBox.h.

Referenced by Mantid::DataObjects::MDGridBox::splitAllIfNeeded().

◆ getEvents() [1/2]

std::vector< MDE > & Mantid::DataObjects::MDBox::getEvents ( )

Get vector of events to change.

Returns a reference to the events vector contained within.

Beware, that calling this funtion for file-based workspace sets both dataChanged and dataBusy flags first forces disk buffer to write the object contents to HDD when disk buffer is full and the second one prevents DB from clearing object from memory untill the events are released. One HAS TO call releaseEvents when finished using data on file-based WS

VERY IMPORTANT: call MDBox::releaseEvents() when you are done accessing that data.

Definition at line 243 of file MDBox.hxx.

Referenced by Mantid::MDAlgorithms::QTransform::applyCorrection(), Mantid::MDAlgorithms::ApplyDetailedBalanceMD::applyDetailedBalance(), Mantid::MDAlgorithms::SpectralMomentMD::applyScaling(), Mantid::MDAlgorithms::DgsScatteredTransmissionCorrectionMD::correctForTransmission(), Mantid::MDAlgorithms::MultiplyMD::execEventScalar(), Mantid::MDAlgorithms::FlippingRatioCorrectionMD::executeTemplatedMDE(), and Mantid::MDAlgorithms::FindPeaksMD::findPeaks().

◆ getEvents() [2/2]

const std::vector< MDE > & Mantid::DataObjects::MDBox::getEvents ( ) const

Definition at line 263 of file MDBox.hxx.

◆ getEventsCopy()

std::vector< MDE > * Mantid::DataObjects::MDBox::getEventsCopy ( )
overridevirtual

Allocate and return a vector with a copy of all events contained.

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 328 of file MDBox.hxx.

◆ getEventsData()

void Mantid::DataObjects::MDBox::getEventsData ( std::vector< coord_t > &  coordTable,
size_t &  nColumns 
) const
override

The method to convert events in a box into a table of coordinates/signal/errors casted into coord_t type Used to save events from plain binary file.

Parameters
coordTable– vector of events parameters in the form signal, error, [detID,rinId], eventsCoordinates....
nColumns– number of parameters for each event

Definition at line 307 of file MDBox.hxx.

◆ getISaveable() [1/2]

Kernel::ISaveable * Mantid::DataObjects::MDBox::getISaveable ( ) const
override

Definition at line 161 of file MDBox.hxx.

◆ getISaveable() [2/2]

Kernel::ISaveable * Mantid::DataObjects::MDBox::getISaveable ( )
override

Definition at line 160 of file MDBox.hxx.

Referenced by Mantid::DataObjects::MDGridBox::splitAllIfNeeded().

◆ getIsMasked()

bool Mantid::DataObjects::MDBox::getIsMasked ( ) const
inlineoverride

Definition at line 190 of file MDBox.h.

◆ getNPoints()

uint64_t Mantid::DataObjects::MDBox::getNPoints ( ) const
override

Returns the total number of points (events) in this box either they are all in memory, or on disk or partially on memory and partially on disk for partially loaded object substantially relies on correct settings of wasSaved and isLoaded switches of iSaveable object.

Definition at line 225 of file MDBox.hxx.

Referenced by Mantid::MDAlgorithms::BinMD::binMDBox(), and Mantid::DataObjects::MDGridBox::splitAllIfNeeded().

◆ getNumChildren()

size_t Mantid::DataObjects::MDBox::getNumChildren ( ) const
inlineoverride

Get the # of children MDBoxBase'es (non-recursive)

Definition at line 94 of file MDBox.h.

◆ getNumDims()

size_t Mantid::DataObjects::MDBox::getNumDims ( ) const
override

Returns the number of dimensions in this box.

Definition at line 180 of file MDBox.hxx.

◆ getNumMDBoxes()

size_t Mantid::DataObjects::MDBox::getNumMDBoxes ( ) const
override

Returns the number of un-split MDBoxes in this box (including all children)

Returns
:: 1 always since this is just a MD Box

Definition at line 185 of file MDBox.hxx.

◆ getTotalDataSize()

uint64_t Mantid::DataObjects::MDBox::getTotalDataSize ( ) const
inlineoverride

Definition at line 88 of file MDBox.h.

◆ initMDBox()

void Mantid::DataObjects::MDBox::initMDBox ( const size_t  nBoxEvents)
private

common part of mdBox constructor

Common part of MD box constructor.

Definition at line 114 of file MDBox.hxx.

◆ integrateCylinder()

void Mantid::DataObjects::MDBox::integrateCylinder ( Mantid::API::CoordTransform radiusTransform,
const coord_t  radius,
const coord_t  length,
signal_t signal,
signal_t errorSquared,
std::vector< signal_t > &  signal_fit 
) const
overridevirtual

Integrate the signal within a sphere; for example, to perform single-crystal peak integration.

The CoordTransform object could be used for more complex shapes, e.g. "lentil" integration, as long as it reduces the dimensions to a single value.

Parameters
radiusTransform:: nd-to-1 coordinate transformation that converts from these dimensions to the distance (squared) from the center of the sphere.
radius:: radius below which to integrate
length:: length below which to integrate
[out]signal:: set to the integrated signal
[out]errorSquared:: set to the integrated squared error.
[out]signal_fit:: evaluation parameter on fit

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 628 of file MDBox.hxx.

◆ integrateSphere()

void Mantid::DataObjects::MDBox::integrateSphere ( Mantid::API::CoordTransform radiusTransform,
const coord_t  radiusSquared,
signal_t integratedSignal,
signal_t errorSquared,
const coord_t  innerRadiusSquared = 0.0,
const bool  useOnePercentBackgroundCorrection = true 
) const
overridevirtual

Integrate the signal within a sphere; for example, to perform single-crystal peak integration.

The CoordTransform object could be used for more complex shapes, e.g. "lentil" integration, as long as it reduces the dimensions to a single value.

Parameters
radiusTransform:: nd-to-1 coordinate transformation that converts from these dimensions to the distance (squared) from the center of the sphere.
radiusSquared:: radius^2 below which to integrate
[out]integratedSignal:: set to the integrated signal
[out]errorSquared:: set to the integrated squared error.
innerRadiusSquared:: radius^2 above which to integrate
useOnePercentBackgroundCorrection:: some bonus correction

Implements Mantid::DataObjects::MDBoxBase< MDE, nd >.

Definition at line 564 of file MDBox.hxx.

◆ isBox()

bool Mantid::DataObjects::MDBox::isBox ( ) const
inlineoverride

Definition at line 97 of file MDBox.h.

◆ isDataAdded()

bool Mantid::DataObjects::MDBox::isDataAdded ( ) const
Returns
true if events were added to the box (using addEvent()) while the rest of the event list is cached to disk

Definition at line 393 of file MDBox.hxx.

◆ loadAndAddFrom() [1/2]

void Mantid::DataObjects::MDBox::loadAndAddFrom ( API::IBoxControllerIO * const  FileSaver,
uint64_t  filePosition,
size_t  nEvents 
)
override

Load the box data of specified size from the disk location provided using the class, respoinsible for the file IO and append them to exisiting events Clear events vector first if overwriting the exisitng events is necessary.

Parameters
FileSaver– the pointer to the class, responsible for file IO
filePosition– the place in the direct access file, where necessary data are located
nEvents– number of events reqested to load

Definition at line 916 of file MDBox.hxx.

◆ loadAndAddFrom() [2/2]

void Mantid::DataObjects::MDBox::loadAndAddFrom ( API::IBoxControllerIO * const  FileSaver,
uint64_t  filePosition,
size_t  nEvents,
std::vector< coord_t > &  tableDataTemp 
)
override

Load the box data of specified size from the disk location provided using the class, respoinsible for the file IO and append them to exisiting events Clear events vector first if overwriting the exisitng events is necessary.

Parameters
FileSaver– the pointer to the class, responsible for file IO
filePosition– the place in the direct access file, where necessary data are located
nEvents– number of events reqested to load
tableDataTemp– overload allows for passing previously allocated temporary memory

Definition at line 888 of file MDBox.hxx.

◆ mask()

void Mantid::DataObjects::MDBox::mask ( )
override

Setter for masking the box.

Definition at line 717 of file MDBox.hxx.

◆ refreshCache()

void Mantid::DataObjects::MDBox::refreshCache ( Kernel::ThreadScheduler = nullptr)
override

Recalculate signal and various averages dependent on signal and the signal coordinates.

Refresh the cache.

For MDBox, if MDBOX_TRACK_SIGNAL_WHEN_ADDING is defined, then the signal/error is tracked on adding, so this does nothing.

beware, that it wrongly accumulates signal and error when part of the data is on file and and some recent data were not saved to the HDD before adding new data This actually means that refreshCache has to be called only once in events adding process

TODO #4734: sum the individual weights of each event?

Definition at line 350 of file MDBox.hxx.

◆ releaseEvents()

void Mantid::DataObjects::MDBox::releaseEvents ( )

For file-backed MDBoxes, this marks that the data vector is no longer "busy", and so it is safe for the MRU to cache it back to disk if needed.

Definition at line 294 of file MDBox.hxx.

Referenced by Mantid::MDAlgorithms::BinMD::binMDBox(), and Mantid::MDAlgorithms::CompareMDWorkspaces::compare2Boxes().

◆ reserveMemoryForLoad()

void Mantid::DataObjects::MDBox::reserveMemoryForLoad ( uint64_t  size)
override

Reserve all the memory required for loading in one step.

Parameters
size– number of events to reserve for

Definition at line 876 of file MDBox.hxx.

Referenced by Mantid::MDAlgorithms::LoadMD::doLoad().

◆ saveAt()

void Mantid::DataObjects::MDBox::saveAt ( API::IBoxControllerIO * const  FileSaver,
uint64_t  position 
) const
override

Save the box data to specific disk position using the class, responsible for the file IO.

Parameters
FileSaver– the pointer to the class, responsible for File IO operations
position– the position of the data within the class.

Definition at line 847 of file MDBox.hxx.

◆ setChildren()

void Mantid::DataObjects::MDBox::setChildren ( const std::vector< API::IMDNode * > &  ,
const size_t  ,
const size_t   
)
inlineoverride

Sets the children from a vector of children.

Definition at line 103 of file MDBox.h.

◆ setEventsData()

void Mantid::DataObjects::MDBox::setEventsData ( const std::vector< coord_t > &  coordTable)
override

The method to convert the table of data into vector of events Used to load events from plain binary file.

Parameters
coordTable– vector of events parameters, which will be converted into events signal error and coordinates

Definition at line 323 of file MDBox.hxx.

◆ setFileBacked() [1/2]

void Mantid::DataObjects::MDBox::setFileBacked ( )
override

Make this box file-backed but its place on the file is not identified yet.

It will be identified by the disk buffer

Definition at line 835 of file MDBox.hxx.

References UNDEF_UINT64.

◆ setFileBacked() [2/2]

void Mantid::DataObjects::MDBox::setFileBacked ( const uint64_t  fileLocation,
const size_t  fileSize,
const bool  markSaved 
)
override

Make this box file-backed.

Parameters
fileLocation– the starting position of this box data are/should be located in the direct access file
fileSize– the size this box data occupy in the file (in the units of the number of events)
markSaved– set to true if the data indeed are physically there and one can indeed read then from there

Definition at line 827 of file MDBox.hxx.

◆ splitAllIfNeeded()

void Mantid::DataObjects::MDBox::splitAllIfNeeded ( Mantid::Kernel::ThreadScheduler = nullptr)
inlineoverride

Definition at line 157 of file MDBox.h.

Referenced by Mantid::DataObjects::MDGridBox::splitAllIfNeeded().

◆ transformDimensions()

void Mantid::DataObjects::MDBox::transformDimensions ( std::vector< double > &  scaling,
std::vector< double > &  offset 
)
override

Transform the dimensions contained in this box x' = x*scaling + offset.

Parameters
scaling:: multiply each coordinate by this value.
offset:: after multiplying, add this offset.

Definition at line 703 of file MDBox.hxx.

References Mantid::Geometry::d.

◆ unmask()

void Mantid::DataObjects::MDBox::unmask ( )
override

Setter for unmasking the box.

Definition at line 724 of file MDBox.hxx.

Member Data Documentation

◆ data

std::vector<MDE> Mantid::DataObjects::MDBox::data
mutableprotected

Vector of MDEvent's, in no particular order.

Definition at line 201 of file MDBox.h.

Referenced by MDBox().

◆ m_bIsMasked

bool Mantid::DataObjects::MDBox::m_bIsMasked
protected

Flag indicating that masking has been applied.

Definition at line 204 of file MDBox.h.

◆ m_Saveable

std::unique_ptr<Kernel::ISaveable> Mantid::DataObjects::MDBox::m_Saveable
mutableprotected

Definition at line 199 of file MDBox.h.

◆ m_tableData

std::vector<coord_t> Mantid::DataObjects::MDBox::m_tableData
private

member to avoid reallocation

Definition at line 213 of file MDBox.h.


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