23#define MDBOX_TRACK_CENTROID
26namespace DataObjects {
28#ifndef __INTEL_COMPILER
62 std::string
getEventType()
const override {
return MDE::getTypeName(); }
67 bool isLeaf() const override final {
return getNumChildren() == 0; }
71 size_t getID()
const override {
return m_fileID; }
74 void setID(
const size_t &newID)
override { m_fileID = newID; }
94 void getEventsData(std::vector<coord_t> & ,
size_t &nColumns)
const override { nColumns = 0; }
111 virtual size_t addEvents(
const std::vector<MDE> &events);
127 const bool useOnePercentBackgroundCorrection =
true)
const override = 0;
131 signal_t &signal)
const override = 0;
136 std::vector<signal_t> &signal_fit)
const override = 0;
149 std::unique_ptr<coord_t[]>
getVertexesArray(
size_t &numVertices,
const size_t outDimensions,
150 const bool *maskDim)
const override;
165 throw std::invalid_argument(
"Invalid dimension passed to MDBox::setExtents");
167 extents[dim].setExtents(min, max);
176 for (
size_t dim = 0; dim < nd; dim++) {
177 this->extents[dim].setExtents(min[dim], max[dim]);
190 size_t ndm1 = nd - 1;
194 for (
size_t d = 0;
d < ndm1; ++
d)
195 mess += extents[
d].extentsStr() +
",";
197 mess += extents[ndm1].extentsStr();
211 for (
size_t d = 0;
d < nd; ++
d)
212 center[
d] = extents[
d].getCentre();
221 for (
size_t d = 0;
d < nd;
d++) {
222 volume *= double(extents[
d].getSize());
226 m_inverseVolume =
coord_t(1. / volume);
286 uint32_t
getDepth()
const override {
return m_depth; }
316 template <
typename EventIterator>
void calcCaches(
const EventIterator &begin,
const EventIterator &end);
358 using sptr = std::shared_ptr<MDBoxBase<MDE, nd>>;
362#ifndef __INTEL_COMPILER
366template <
typename MDE,
size_t nd>
367template <
typename EventIterator>
372 coord_t *centroid = m_centroid;
373 std::fill_n(centroid, nd, 0.0f);
374 for (
auto it = begin; it != end; ++it) {
375 auto evSignal = it->getSignal();
376 m_signal += evSignal;
377 m_errorSquared += it->getErrorSquared();
380 for (
auto d = 0u;
d < nd;
d++) {
382 centroid[
d] += it->getCenter(
d) *
static_cast<coord_t>(evSignal);
388 for (
size_t d = 0;
d < nd; ++
d) {
389 centroid[
d] *= reciprocal;
#define TMDE_CLASS
Macro to make declaring template classes faster.
This class is used by MDBox and MDGridBox in order to intelligently determine optimal behavior.
MDBin : Class describing a single bin in a dense, Multidimensional histogram.
Templated super-class of a multi-dimensional event "box".
std::unique_ptr< coord_t[]> getVertexesArray(size_t &numVertices) const override
virtual size_t addEvents(const std::vector< MDE > &events)
MDBoxBase(Mantid::API::BoxController *const boxController=nullptr, const uint32_t depth=0, const size_t boxID=UNDEF_SIZET)
virtual size_t addEventUnsafe(const MDE &point)=0
Add a single event, with no mutex locking.
virtual signal_t getTotalWeight() const
Returns the total weight of all events within.
const IMDNode * getBoxAtCoord(const coord_t *) override
Returns the lowest-level box at the given coordinates.
virtual void generalBin(MDBin< MDE, nd > &bin, Mantid::Geometry::MDImplicitFunction &function) const =0
General binning method for any shape.
void setExtents(double min[nd], double max[nd])
Set the extents of this box.
std::string getExtentsStr() const
Returns the extents as a string, for convenience.
MDBoxBase(const MDBoxBase< MDE, nd > &box, Mantid::API::BoxController *const otherBC)
virtual void centerpointBin(MDBin< MDE, nd > &bin, bool *fullyContained) const =0
Perform centerpoint binning of events.
virtual std::vector< MDE > * getEventsCopy()=0
Return a copy of contained events.
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 setSignal(const signal_t signal) override
Sets the integrated signal from all points within (mostly used for testing)
signal_t getSignal() const override
Returns the integrated signal from all points within.
std::shared_ptr< MDBoxBase< MDE, nd > > sptr
Convenience typedef for a shared pointer to a this type of class.
signal_t m_errorSquared
Cached total error (squared) from all points within.
void calcCaches(const EventIterator &begin, const EventIterator &end)
Calculates caches if the events are known.
virtual signal_t getErrorSquaredNormalized() const
Returns the integrated error squared from all points within, normalized for the cell volume.
void setParent(IMDNode *parent) override
Return a pointer to the parent box.
MDBoxBase(Mantid::API::BoxController *const boxController, const uint32_t depth, const size_t boxID, const std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > &extentsVector)
void getCenter(coord_t *const center) const override
Get the center of the box.
coord_t getInverseVolume() const override
Return the inverse of the volume of the cell.
virtual void calculateGridCaches()
void setDepth(uint32_t depth)
For testing, mostly: set the recursion depth of this box.
bool isLeaf() const override final
Is this node a leaf: getNumChildren() == 0.
uint32_t getDepth() const override
For testing, mostly: return the recursion depth of this box.
signal_t getErrorSquared() const override
Returns the integrated error squared from all points within.
IMDNode * getParent() override
Return a pointer to the parent box.
void transformDimensions(std::vector< double > &scaling, std::vector< double > &offset) override
std::mutex m_dataMutex
Mutex for modifying the event list or box averages.
coord_t getBoxSize(size_t d)
For testing: return the internal-stored size of each box in each dimension.
signal_t m_signal
Cached total signal from all points within.
signal_t getError() const override
Returns the integrated error from all points within.
virtual void setTotalWeight(const signal_t total)
Sets the total weight from all points within (mostly used for testing)
size_t m_fileID
The id which specify location of this box in a linear chain of ordered boxes (e.g.
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...
void calcVolume() override
Compute the volume of the box by simply multiplying each dimension range.
void centroidSphere(Mantid::API::CoordTransform &radiusTransform, const coord_t radiusSquared, coord_t *centroid, signal_t &signal) const override=0
Find the centroid around a sphere.
Mantid::API::BoxController * getBoxController() const override
coord_t m_inverseVolume
Inverse of the volume of the cell, to be used for normalized signal.
coord_t getVolume() const
Return the volume of the cell.
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=0
Sphere (peak) integration.
virtual size_t addEvent(const MDE &point)=0
Add a single event.
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=0
Cylinder (peak) integration.
std::string getEventType() const override
std::vector< Mantid::Kernel::VMD > getVertexes() const override
void setErrorSquared(const signal_t ErrorSquared) override
Sets the integrated error squared from all points within (mostly used for testing)
virtual size_t addEventsUnsafe(const std::vector< MDE > &events)
const IMDNode * getParent() const override
Return a pointer to the parent box (const)
signal_t getSignalNormalized() const override
Returns the integrated signal from all points within, normalized for the cell volume.
uint32_t m_depth
Recursion depth.
size_t getID() const override
Mantid::API::BoxController * getBoxController() override
void setInverseVolume(const coord_t invVolume) override
Sets the inverse of the volume of the cell.
std::unique_ptr< coord_t[]> getVertexesArray(size_t &numVertices, const size_t outDimensions, const bool *maskDim) const override
Mantid::API::BoxController *const m_BoxController
The box splitting controller, shared with all boxes in the hierarchy.
Mantid::Geometry::MDDimensionExtents< coord_t > & getExtents(size_t dim) override
Get the extents for this box.
void setExtents(size_t dim, double min, double max)
Set the extents of this box.
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 t...
MDBoxBase(const MDBoxBase< MDE, nd > &box)
unsigned int getCoordType() const override
Mantid::API::IMDNode * m_parent
Pointer to the parent of this box. NULL if no parent.
signal_t m_totalWeight
Cached total weight of all events Set when refreshCache() is called.
Simple class that holds the extents (min/max) of a given dimension in a MD workspace or MDBox.
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
Helper class which provides the Collimation Length for SANS instruments.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
double signal_t
Typedef for the signal recorded in a MDBox, etc.