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

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

#include <MDGridBox.h>

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

Public Types

using boxVector_t = std::vector< MDBoxBase< MDE, nd > * >
 Typedef for a vector of MDBoxBase pointers.
 
using sptr = std::shared_ptr< MDGridBox< MDE, nd > >
 Typedef for a shared pointer to a MDGridBox.
 
- 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 &event) override
 Add a single MDLeanEvent to the grid box.
 
size_t addEventUnsafe (const MDE &event) override
 Add a single MDLeanEvent to the grid box.
 
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 > &goniometerIndex, const std::vector< uint32_t > &detectorId) override
 Create and Add several (N) events into correspondent boxes; If the event is out/at of bounds it may be placed in very peculiar place!
 
void 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.
 
void calculateCentroid (coord_t *) const override
 The function used to satisfy IMDNode interface but the physical meaning is unclear.
 
void calculateCentroid (coord_t *, const int) const override
 The function used to satisfy IMDNode interface but the physical meaning is unclear.
 
void calculateGridCaches () override final
 Calculates caches for grid box recursively, assuming leafs have computed values.
 
void centerpointBin (MDBin< MDE, nd > &bin, bool *fullyContained) const override
 Perform centerpoint binning of events, with bins defined in axes perpendicular to the axes of the workspace.
 
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
 
void clearFileBacked (bool loadDiskBackedData) override
 Recursively clear the file-backed information stored in mdBoxes from the boxes if such information exists.
 
void generalBin (MDBin< MDE, nd > &, Mantid::Geometry::MDImplicitFunction &) const override
 General binning method for any shape.
 
const API::IMDNodegetBoxAtCoord (const coord_t *coords) override
 Returns the lowest-level box at the given coordinates.
 
std::vector< MDBoxBase< MDE, nd > * > & getBoxes ()
 For testing: get (a reference to) the vector of boxes.
 
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< API::IMDNode * > &outBoxes, size_t maxDepth, bool leafOnly) override
 Return all boxes contained within.
 
void getBoxes (std::vector< API::IMDNode * > &outBoxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction *function) override
 Return all boxes contained within, limited by an implicit function.
 
coord_tgetCentroid () const override
 The function used to satisfy IMDNode interface but the physical meaning is unclear.
 
API::IMDNodegetChild (size_t index) override
 Get a child box.
 
size_t getChildIndexFromID (size_t childId) const
 Get the child index from its ID.
 
size_t getDataInMemorySize () const override
 Recursiveluy calculates the amount of the data located in memory. Slow.
 
std::vector< MDE > * getEventsCopy () override
 Allocate and return a vector with a copy of all events contained.
 
Kernel::ISaveablegetISaveable () const override
 get const object responsible for saving the box to a file.
 
Kernel::ISaveablegetISaveable () override
 get object responsible for saving the box to a file.
 
bool getIsMasked () const override
 Getter for the masking status of the gridded box.
 
uint64_t getNPoints () const override
 Uses the cached value of points stored in the grid box.
 
size_t getNumChildren () const override
 
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 (recursively 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
 std::cout << "vertex at " << vertexCoord[0] << ", " << vertexCoord[1] << ", " << vertexCoord[2] << " is contained\n";
 
bool isBox () const override
 to avoid casting (which need also the number of dimensions) method say if Node is a box.
 
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.
 
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, responsible for the file IO.
 
void mask () override
 Setter for masking the box.
 
 MDGridBox (const MDGridBox< MDE, nd > &other, Mantid::API::BoxController *const otherBC)
 Copy constructor.
 
 MDGridBox (Mantid::API::BoxController *const bc, const uint32_t depth, const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &extentsVector)
 Constructor with a box controller.
 
 MDGridBox (MDBox< MDE, nd > *box)
 Constructor.
 
 MDGridBox (std::shared_ptr< API::BoxController > &bc, const uint32_t depth, const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &extentsVector)
 convenience Constructor, taking the shared pointer and extracting const pointer from it
 
void refreshCache (Kernel::ThreadScheduler *ts=nullptr) override
 Refresh the cache of nPoints, signal and error, by adding up all boxes (recursively).
 
void reserveMemoryForLoad (uint64_t) override
 
void saveAt (API::IBoxControllerIO *const, uint64_t) const override
 Save the box at specific disk position using the class, respoinsible for the file IO.
 
void setChild (size_t index, MDGridBox< MDE, nd > *newChild)
 Sets particular child MDgridBox at the index, specified by the input parameters.
 
void setChildren (const std::vector< API::IMDNode * > &otherBoxes, const size_t indexStart, const size_t indexEnd) override
 Directly set the children of the MDGridBox.
 
void setFileBacked () override
 Make the box file-backed without knowing its position on the HDD.
 
void setFileBacked (const uint64_t, const size_t, const bool) override
 Recursively make all underlaying boxes file-backed.
 
void setNPoints (const uint64_t &n)
 
void splitAllIfNeeded (Kernel::ThreadScheduler *ts=nullptr) override
 Goes through all the sub-boxes and splits them if they contain enough events to be worth it.
 
void splitContents (size_t index, Kernel::ThreadScheduler *ts=nullptr)
 Split a box that is contained in the GridBox, at the given index, into a MDGridBox.
 
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.
 
 ~MDGridBox () override
 Destructor.
 
- Public Member Functions inherited from Mantid::DataObjects::MDBoxBase< MDE, nd >
virtual size_t addEvents (const std::vector< MDE > &events)
 Add several events, starting and stopping at particular point in a vector.
 
virtual size_t addEventsUnsafe (const std::vector< MDE > &events)
 Add all of the events contained in a vector, with:
 
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.
 

Private Member Functions

size_t calculateChildIndex (const MDE &event) const
 Compute the index of the child box for the given event.
 
size_t computeSizesFromSplit ()
 Compute some data from the split[] array and the extents.
 
void fillBoxShell (const size_t tot, const coord_t ChildInverseVolume)
 Internal function to do main job of filling in a GridBox contents (part of the constructor)
 
size_t getLinearIndex (size_t *indices) const
 Helper function to get the index into the linear array given an array of indices for each dimension (0 to nd)
 
size_t initGridBox ()
 common part of MDGridBox contstructor;
 
 MDGridBox ()=default
 Private constructor as it does not work without box controller.
 
 MDGridBox (const MDGridBox< MDE, nd > &box)
 private default copy constructor as the only correct constructor is the one with box controller
 

Private Attributes

coord_t diagonalSquared
 Length (squared) of the diagonal through every dimension = sum( boxSize[i]^2 ) Used in some calculations like peak integration.
 
std::vector< MDBoxBase< MDE, nd > * > m_Children
 1D array of boxes contained within.
 
double m_SubBoxSize [nd]
 size of each sub-box (the one this GridBox can be split into) in correspondent direction
 
size_t nPoints
 Cached number of points contained (including all sub-boxes)
 
size_t numBoxes
 How many boxes in the boxes vector? This is just to avoid boxes.size() calls.
 
size_t split [nd]
 Each dimension is split into this many equally-sized boxes.
 
size_t splitCumul [nd]
 Cumulative dimension splitting: split[n] = 1*split[0]*split[..]*split[n-1].
 

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.
 
- 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.
 

Detailed Description

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

A MDGridBox contains a dense array with nd dimensions of MDBoxBase'es, each being either a regular MDBox or a MDGridBox itself.

This means that MDGridBoxes can be recursively gridded finer and finer.

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 42 of file MDGridBox.h.

Member Typedef Documentation

◆ boxVector_t

using Mantid::DataObjects::MDGridBox::boxVector_t = std::vector<MDBoxBase<MDE, nd> *>

Typedef for a vector of MDBoxBase pointers.

Definition at line 202 of file MDGridBox.h.

◆ sptr

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

Typedef for a shared pointer to a MDGridBox.

Definition at line 199 of file MDGridBox.h.

Constructor & Destructor Documentation

◆ MDGridBox() [1/6]

Mantid::DataObjects::MDGridBox::MDGridBox ( std::shared_ptr< API::BoxController > &  bc,
const uint32_t  depth,
const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &  extentsVector 
)

convenience Constructor, taking the shared pointer and extracting const pointer from it

Parameters
bc:: shared pointer to the BoxController, owned by workspace
depth:: recursive split depth
extentsVector:: size of the box

Definition at line 57 of file MDGridBox.hxx.

◆ MDGridBox() [2/6]

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

Constructor with a box controller.

Parameters
bc:: poineter to the BoxController, owned by workspace
depth:: recursive split depth
extentsVector:: size of the box

Definition at line 44 of file MDGridBox.hxx.

◆ MDGridBox() [3/6]

Mantid::DataObjects::MDGridBox::MDGridBox ( MDBox< MDE, nd > *  box)

Constructor.

Parameters
box:: MDBox containing the events to split

Definition at line 92 of file MDGridBox.hxx.

References Mantid::Geometry::d, and Mantid::Geometry::split().

◆ MDGridBox() [4/6]

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

Copy constructor.

Parameters
other:: MDGridBox to copy
otherBC:: mandatory pointer to other box controller, which will split this box. if it the same BC, as the one for the copied box, it needs to be taken explicitly from the copied box.

Definition at line 176 of file MDGridBox.hxx.

References Mantid::Geometry::d, and Mantid::Geometry::split().

◆ ~MDGridBox()

Mantid::DataObjects::MDGridBox::~MDGridBox ( )
override

Destructor.

Definition at line 242 of file MDGridBox.hxx.

References clear().

◆ MDGridBox() [5/6]

Mantid::DataObjects::MDGridBox::MDGridBox ( const MDGridBox< MDE, nd > &  box)
private

private default copy constructor as the only correct constructor is the one with box controller

◆ MDGridBox() [6/6]

Mantid::DataObjects::MDGridBox::MDGridBox ( )
privatedefault

Private constructor as it does not work without box controller.

Member Function Documentation

◆ addEvent()

size_t Mantid::DataObjects::MDGridBox::addEvent ( const MDE &  event)
inlineoverridevirtual

Add a single MDLeanEvent to the grid box.

If the boxes contained within are also gridded, this will recursively push the event down to the deepest level. Warning! No bounds checking is done (for performance). It must be known that the event is within the bounds of the grid box before adding.

Note! nPoints, signal and error must be re-calculated using refreshCache() after all events have been added.

Parameters
event:: reference to a MDLeanEvent to add.
Returns
1 if the event was added, 0 otherwise

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

Definition at line 1631 of file MDGridBox.hxx.

Referenced by Mantid::DataObjects::IF_EVENT< MDE, nd >::EXEC().

◆ addEventUnsafe()

size_t Mantid::DataObjects::MDGridBox::addEventUnsafe ( const MDE &  event)
inlineoverridevirtual

Add a single MDLeanEvent to the grid box.

If the boxes contained within are also gridded, this will recursively push the event down to the deepest level.

Warning! No bounds checking is done (for performance). It must be known that the event is within the bounds of the grid box before adding.

Warning! Call is NOT thread-safe. Only 1 thread should be writing to this box (or any child boxes) at a time

Note! nPoints, signal and error must be re-calculated using refreshCache() after all events have been added.

Parameters
event:: reference to a MDEvent to add.
Returns
1 if the event was added, 0 otherwise

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

Definition at line 1662 of file MDGridBox.hxx.

◆ buildAndAddEvent()

void Mantid::DataObjects::MDGridBox::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
goniometerIndex:: goniometer index
detectorId:: detector's ID

Definition at line 1594 of file MDGridBox.hxx.

◆ buildAndAddEvents()

size_t Mantid::DataObjects::MDGridBox::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 (N) events into correspondent boxes; If the event is out/at of bounds it may be placed in very peculiar place!

Parameters
sigErrSq:: vector of N-signals and errors where errror follows signal
Coord:: vector of MD event coordinates, nd(number of dimensions) coordinates for each event
expInfoIndex:: vector of experiment info indexes for N events.
goniometerIndex:: vector of goniometer info indices for N events
detectorId:: vector of detector's ID for N events.
Returns
number of events rejected (0 as nothing is rejected here)

Definition at line 1575 of file MDGridBox.hxx.

◆ buildAndAddEventUnsafe()

void Mantid::DataObjects::MDGridBox::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 MDEvent coordinates
expInfoIndex:: run index
goniometerIndex:: goniometer index
detectorId:: detector's ID

Definition at line 1612 of file MDGridBox.hxx.

◆ calculateCentroid() [1/2]

void Mantid::DataObjects::MDGridBox::calculateCentroid ( coord_t ) const
inlineoverride

The function used to satisfy IMDNode interface but the physical meaning is unclear.

Definition at line 178 of file MDGridBox.h.

◆ calculateCentroid() [2/2]

void Mantid::DataObjects::MDGridBox::calculateCentroid ( coord_t ,
const int   
) const
inlineoverride

The function used to satisfy IMDNode interface but the physical meaning is unclear.

Definition at line 185 of file MDGridBox.h.

◆ calculateChildIndex()

size_t Mantid::DataObjects::MDGridBox::calculateChildIndex ( const MDE &  event) const
private

Compute the index of the child box for the given event.

Parameters
eventA reference to an event

Definition at line 1726 of file MDGridBox.hxx.

References Mantid::Geometry::d.

◆ calculateGridCaches()

void Mantid::DataObjects::MDGridBox::calculateGridCaches ( )
finaloverridevirtual

Calculates caches for grid box recursively, assuming leafs have computed values.

Calculates caches for MDGridBoxes based on children caches, does nothing with MDBoxes

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

Definition at line 376 of file MDGridBox.hxx.

◆ centerpointBin()

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

Perform centerpoint binning of events, with bins defined in axes perpendicular to the axes of the workspace.

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 771 of file MDGridBox.hxx.

References Mantid::Geometry::d, and Mantid::Geometry::split().

◆ centroidSphere()

void Mantid::DataObjects::MDGridBox::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 1281 of file MDGridBox.hxx.

References Mantid::API::IMDNode::centroidSphere(), and Mantid::API::IMDNode::getCenter().

◆ clear()

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

Clear any points contained.

Definition at line 253 of file MDGridBox.hxx.

Referenced by ~MDGridBox().

◆ clearDataFromMemory()

void Mantid::DataObjects::MDGridBox::clearDataFromMemory ( )
inlineoverride

Definition at line 69 of file MDGridBox.h.

◆ clearFileBacked()

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

Recursively clear the file-backed information stored in mdBoxes from the boxes 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 1715 of file MDGridBox.hxx.

◆ computeSizesFromSplit()

size_t Mantid::DataObjects::MDGridBox::computeSizesFromSplit ( )
private

Compute some data from the split[] array and the extents.

Returns
:: the total number of boxes

Definition at line 222 of file MDGridBox.hxx.

References Mantid::Geometry::d, and Mantid::Geometry::split().

◆ fillBoxShell()

void Mantid::DataObjects::MDGridBox::fillBoxShell ( const size_t  tot,
const coord_t  ChildInverseVolume 
)
private

Internal function to do main job of filling in a GridBox contents (part of the constructor)

Definition at line 121 of file MDGridBox.hxx.

References Mantid::Geometry::d, Mantid::Geometry::split(), and UNDEF_SIZET.

◆ generalBin()

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

General binning method for any shape.

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

Definition at line 146 of file MDGridBox.h.

◆ getBoxAtCoord()

const API::IMDNode * Mantid::DataObjects::MDGridBox::getBoxAtCoord ( const coord_t coords)
override

Returns the lowest-level box at the given coordinates.

Parameters
coords:: nd-sized array of the coordinate of the point to look at
Returns
MDBoxBase pointer.

Definition at line 633 of file MDGridBox.hxx.

References Mantid::Geometry::d, index, and Mantid::Geometry::x.

◆ getBoxes() [1/4]

std::vector< MDBoxBase< MDE, nd > * > & Mantid::DataObjects::MDGridBox::getBoxes ( )
inline

For testing: get (a reference to) the vector of boxes.

Definition at line 173 of file MDGridBox.h.

◆ getBoxes() [2/4]

void Mantid::DataObjects::MDGridBox::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 621 of file MDGridBox.hxx.

◆ getBoxes() [3/4]

void Mantid::DataObjects::MDGridBox::getBoxes ( std::vector< API::IMDNode * > &  outBoxes,
size_t  maxDepth,
bool  leafOnly 
)
override

Return all boxes contained within.

Parameters
outBoxes:: vector to fill
maxDepth:: max depth value of the returned boxes.
leafOnly:: if true, only add the boxes that are no more subdivided (leaves on the tree)

Definition at line 413 of file MDGridBox.hxx.

◆ getBoxes() [4/4]

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

Return all boxes contained within, limited by an implicit function.

This method evaluates each vertex to see how it is contained by the implicit function. For example, if there are 4x4 boxes, there are 5x5 vertices to evaluate.

All boxes that might be touching the implicit function are returned (including ones that overlap without any point actually in the function).

Parameters
outBoxes:: vector to fill
maxDepth:: max depth value of the returned boxes.
leafOnly:: if true, only add the boxes that are no more subdivided (leaves on the tree)
function:: implicitFunction pointer

Definition at line 449 of file MDGridBox.hxx.

References Mantid::Geometry::d, Mantid::API::IMDNode::getBoxes(), and Mantid::Geometry::split().

◆ getCentroid()

coord_t * Mantid::DataObjects::MDGridBox::getCentroid ( ) const
inlineoverride

The function used to satisfy IMDNode interface but the physical meaning is unclear.

Definition at line 192 of file MDGridBox.h.

◆ getChild()

API::IMDNode * Mantid::DataObjects::MDGridBox::getChild ( size_t  index)
override

Get a child box.

Parameters
index:: index into the array, within range 0..getNumChildren()-1
Returns
the child MDBoxBase pointer.

Definition at line 298 of file MDGridBox.hxx.

References index.

◆ getChildIndexFromID()

size_t Mantid::DataObjects::MDGridBox::getChildIndexFromID ( size_t  childId) const

Get the child index from its ID.

Parameters
childId:: ID of the child you want
Returns
the index into the children of this grid box; size_t(-1) if NOT found.

Definition at line 691 of file MDGridBox.hxx.

References index.

◆ getDataInMemorySize()

size_t Mantid::DataObjects::MDGridBox::getDataInMemorySize ( ) const
override

Recursiveluy calculates the amount of the data located in memory. Slow.

Returns
the number of points (events) this box keeps in memory. May be different from total number of points for file based workspaces/boxes. Calculates recursively from child boxes

Definition at line 268 of file MDGridBox.hxx.

◆ getEventsCopy()

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

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

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

Definition at line 398 of file MDGridBox.hxx.

◆ getISaveable() [1/2]

Kernel::ISaveable * Mantid::DataObjects::MDGridBox::getISaveable ( ) const
inlineoverride

get const object responsible for saving the box to a file.

Returns
the const pointer the const object. The GridBox is not saveable at the moment so it is always NULL

Definition at line 63 of file MDGridBox.h.

◆ getISaveable() [2/2]

Kernel::ISaveable * Mantid::DataObjects::MDGridBox::getISaveable ( )
inlineoverride

get object responsible for saving the box to a file.

Returns
the const pointer to the object. The GridBox is not saveable at the moment so it is always NULL

Definition at line 59 of file MDGridBox.h.

◆ getIsMasked()

bool Mantid::DataObjects::MDGridBox::getIsMasked ( ) const
override

Getter for the masking status of the gridded box.

Returns
TRUE if ANY ONE of its referenced boxes is masked.

Definition at line 1500 of file MDGridBox.hxx.

References Mantid::API::IMDNode::getIsMasked().

◆ getLinearIndex()

size_t Mantid::DataObjects::MDGridBox::getLinearIndex ( size_t *  indices) const
inlineprivate

Helper function to get the index into the linear array given an array of indices for each dimension (0 to nd)

Parameters
indices:: array of size[nd]
Returns
size_t index into m_Children[].

Definition at line 329 of file MDGridBox.hxx.

References Mantid::Geometry::d.

◆ getNPoints()

uint64_t Mantid::DataObjects::MDGridBox::getNPoints ( ) const
inlineoverride

Uses the cached value of points stored in the grid box.

Returns
the total number of points (events) in this box (in memory and in file if present)

Definition at line 93 of file MDGridBox.h.

◆ getNumChildren()

size_t Mantid::DataObjects::MDGridBox::getNumChildren ( ) const
override
Returns
The number of children of the MDGridBox, not recursively

Definition at line 291 of file MDGridBox.hxx.

Referenced by Mantid::DataObjects::MDEventWorkspace< MDE, nd >::setMinRecursionDepth().

◆ getNumDims()

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

Returns the number of dimensions in this box.

Definition at line 264 of file MDGridBox.hxx.

◆ getNumMDBoxes()

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

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

Returns
:: the total # of MDBoxes in all children

Definition at line 279 of file MDGridBox.hxx.

◆ getTotalDataSize()

uint64_t Mantid::DataObjects::MDGridBox::getTotalDataSize ( ) const
inlineoverride
Returns
the amount of memory that the object's data ocupy. Currently uses cached value.

Definition at line 96 of file MDGridBox.h.

◆ initGridBox()

size_t Mantid::DataObjects::MDGridBox::initGridBox ( )
private

common part of MDGridBox contstructor;

Definition at line 65 of file MDGridBox.hxx.

References Mantid::Geometry::d, and Mantid::Geometry::split().

◆ integrateCylinder()

void Mantid::DataObjects::MDGridBox::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
signal[out] :: set to the integrated signal
errorSquared[out] :: set to the integrated squared error.
[out]signal_fit:: evaluation parameter on fit

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

Definition at line 1321 of file MDGridBox.hxx.

References Mantid::Geometry::d, Mantid::API::IMDNode::getCenter(), Mantid::API::IMDNode::getErrorSquared(), Mantid::API::IMDNode::getEventsData(), Mantid::API::IMDNode::getSignal(), Mantid::API::IMDNode::integrateCylinder(), and Mantid::Geometry::split().

◆ integrateSphere()

void Mantid::DataObjects::MDGridBox::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
overridevirtual

std::cout << "vertex at " << vertexCoord[0] << ", " << vertexCoord[1] << ", " << vertexCoord[2] << " is contained\n";

std::cout << "... added 1 vertex to box " << boxes[linearIndex]->getExtentsStr() << "\n"; std::cout << "Depth " << this->getDepth() << " with " << numFullyContained << " fully contained; " << numPartiallyContained << " partial. Signal = " << signal <<"\n"; 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
signal[out] :: set to the integrated signal
errorSquared[out] :: set to the integrated squared error.
innerRadiusSquared:: radius^2 above which to integrate
useOnePercentBackgroundCorrection:: use extra correction

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

Definition at line 1092 of file MDGridBox.hxx.

References Mantid::Geometry::d, and Mantid::Geometry::split().

◆ isBox()

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

to avoid casting (which need also the number of dimensions) method say if Node is a box.

if not, it is gridbox

Definition at line 107 of file MDGridBox.h.

◆ loadAndAddFrom() [1/2]

void Mantid::DataObjects::MDGridBox::loadAndAddFrom ( API::IBoxControllerIO * const  ,
uint64_t  ,
size_t   
)
inlineoverride

Load the box data of specified size from the disk location provided using the class, respoinsible for the file IO.

Definition at line 83 of file MDGridBox.h.

◆ loadAndAddFrom() [2/2]

void Mantid::DataObjects::MDGridBox::loadAndAddFrom ( API::IBoxControllerIO * const  ,
uint64_t  ,
size_t  ,
std::vector< coord_t > &   
)
inlineoverride

Load the box data of specified size from the disk location provided using the class, responsible for the file IO.

Overload that allows passing temporary memory

Definition at line 78 of file MDGridBox.h.

◆ mask()

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

Setter for masking the box.

Definition at line 1514 of file MDGridBox.hxx.

References Mantid::API::IMDNode::mask().

◆ refreshCache()

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

Refresh the cache of nPoints, signal and error, by adding up all boxes (recursively).

MDBoxes' totals are used directly.

Parameters
ts:: ThreadScheduler pointer to perform the caching in parallel. If NULL, it will be performed in series.

Definition at line 344 of file MDGridBox.hxx.

◆ reserveMemoryForLoad()

void Mantid::DataObjects::MDGridBox::reserveMemoryForLoad ( uint64_t  )
inlineoverride

Definition at line 85 of file MDGridBox.h.

◆ saveAt()

void Mantid::DataObjects::MDGridBox::saveAt ( API::IBoxControllerIO * const  ,
uint64_t   
) const
inlineoverride

Save the box at specific disk position using the class, respoinsible for the file IO.

Definition at line 74 of file MDGridBox.h.

◆ setChild()

void Mantid::DataObjects::MDGridBox::setChild ( size_t  index,
MDGridBox< MDE, nd > *  newChild 
)
inline

Sets particular child MDgridBox at the index, specified by the input parameters.

Parameters
index– the position of the new child in the list of GridBox children
newChild– the pointer to the new child grid box

Definition at line 1682 of file MDGridBox.hxx.

References index.

◆ setChildren()

void Mantid::DataObjects::MDGridBox::setChildren ( const std::vector< API::IMDNode * > &  otherBoxes,
const size_t  indexStart,
const size_t  indexEnd 
)
override

Directly set the children of the MDGridBox.

Used in file loading. Should not be called on a box with children; the existing children are NOT deleted.

Parameters
otherBoxes,:reference to a vector of boxes containing the children
indexStart:: start point in the vector
indexEnd:: end point in the vector, not-inclusive

Definition at line 309 of file MDGridBox.hxx.

◆ setFileBacked() [1/2]

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

Make the box file-backed without knowing its position on the HDD.

Works recursively through all children

Definition at line 1698 of file MDGridBox.hxx.

◆ setFileBacked() [2/2]

void Mantid::DataObjects::MDGridBox::setFileBacked ( const uint64_t  ,
const size_t  ,
const bool   
)
override

Recursively make all underlaying boxes file-backed.

Recursively make this and all underlaying boxes file-backed.

Not(yet?) implemented for gridboxes

Definition at line 1690 of file MDGridBox.hxx.

◆ setNPoints()

void Mantid::DataObjects::MDGridBox::setNPoints ( const uint64_t &  n)
inline

Definition at line 88 of file MDGridBox.h.

References n.

◆ splitAllIfNeeded()

void Mantid::DataObjects::MDGridBox::splitAllIfNeeded ( Kernel::ThreadScheduler ts = nullptr)
override

Goes through all the sub-boxes and splits them if they contain enough events to be worth it.

Parameters
ts:: optional ThreadScheduler * that will be used to parallelize recursive splitting. Set to NULL to do it serially.

Definition at line 706 of file MDGridBox.hxx.

References Mantid::DataObjects::MDBox::getDataInMemorySize(), Mantid::DataObjects::MDBoxBase::getDepth(), Mantid::DataObjects::MDBox::getISaveable(), Mantid::DataObjects::MDBox::getNPoints(), splitAllIfNeeded(), and Mantid::DataObjects::MDBox::splitAllIfNeeded().

Referenced by splitAllIfNeeded().

◆ splitContents()

void Mantid::DataObjects::MDGridBox::splitContents ( size_t  index,
Kernel::ThreadScheduler ts = nullptr 
)

Split a box that is contained in the GridBox, at the given index, into a MDGridBox.

Thread-safe as long as 'index' is different for all threads.

Parameters
index:: index into the boxes vector. Warning: No bounds check is made, don't give stupid values!
ts:: optional ThreadScheduler * that will be used to parallelize recursive splitting. Set to NULL for no recursive splitting.

Definition at line 661 of file MDGridBox.hxx.

References Mantid::DataObjects::MDBoxBase::getDepth(), and index.

Referenced by Mantid::DataObjects::MDEventWorkspace< MDE, nd >::setMinRecursionDepth().

◆ transformDimensions()

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

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

NON-RECURSIVE!

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

Definition at line 213 of file MDGridBox.hxx.

References Mantid::DataObjects::MDBoxBase::transformDimensions().

◆ unmask()

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

Setter for unmasking the box.

Definition at line 1523 of file MDGridBox.hxx.

References Mantid::API::IMDNode::unmask().

Member Data Documentation

◆ diagonalSquared

coord_t Mantid::DataObjects::MDGridBox::diagonalSquared
private

Length (squared) of the diagonal through every dimension = sum( boxSize[i]^2 ) Used in some calculations like peak integration.

Definition at line 228 of file MDGridBox.h.

◆ m_Children

std::vector<MDBoxBase<MDE, nd> *> Mantid::DataObjects::MDGridBox::m_Children
private

1D array of boxes contained within.

These map to the nd-array.

Definition at line 223 of file MDGridBox.h.

◆ m_SubBoxSize

double Mantid::DataObjects::MDGridBox::m_SubBoxSize[nd]
private

size of each sub-box (the one this GridBox can be split into) in correspondent direction

Definition at line 215 of file MDGridBox.h.

◆ nPoints

size_t Mantid::DataObjects::MDGridBox::nPoints
private

Cached number of points contained (including all sub-boxes)

Definition at line 231 of file MDGridBox.h.

◆ numBoxes

size_t Mantid::DataObjects::MDGridBox::numBoxes
private

How many boxes in the boxes vector? This is just to avoid boxes.size() calls.

Definition at line 219 of file MDGridBox.h.

◆ split

size_t Mantid::DataObjects::MDGridBox::split[nd]
private

Each dimension is split into this many equally-sized boxes.

Definition at line 209 of file MDGridBox.h.

◆ splitCumul

size_t Mantid::DataObjects::MDGridBox::splitCumul[nd]
private

Cumulative dimension splitting: split[n] = 1*split[0]*split[..]*split[n-1].

Definition at line 212 of file MDGridBox.h.


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