22#define MDBOX_TRACK_CENTROID
25namespace DataObjects {
27#ifndef __INTEL_COMPILER
61 std::string
getEventType()
const override {
return MDE::getTypeName(); }
66 bool isLeaf() const override final {
return getNumChildren() == 0; }
70 size_t getID()
const override {
return m_fileID; }
73 void setID(
const size_t &newID)
override { m_fileID = newID; }
93 void getEventsData(std::vector<coord_t> & ,
size_t &nColumns)
const override { nColumns = 0; }
110 virtual size_t addEvents(
const std::vector<MDE> &events);
111 virtual size_t addEventsUnsafe(
const std::vector<MDE> &events);
116 const bool useOnePercentBackgroundCorrection =
true)
const override = 0;
120 signal_t &signal)
const override = 0;
125 std::vector<signal_t> &signal_fit)
const override = 0;
136 std::vector<Mantid::Kernel::VMD> getVertexes()
const override;
137 std::unique_ptr<coord_t[]> getVertexesArray(
size_t &numVertices)
const override;
138 std::unique_ptr<coord_t[]> getVertexesArray(
size_t &numVertices,
const size_t outDimensions,
139 const bool *maskDim)
const override;
140 void transformDimensions(std::vector<double> &scaling, std::vector<double> &offset)
override;
154 throw std::invalid_argument(
"Invalid dimension passed to MDBox::setExtents");
156 extents[dim].setExtents(min, max);
165 for (
size_t dim = 0; dim < nd; dim++) {
166 this->extents[dim].setExtents(min[dim], max[dim]);
179 size_t ndm1 = nd - 1;
183 for (
size_t d = 0;
d < ndm1; ++
d)
184 mess += extents[
d].extentsStr() +
",";
186 mess += extents[ndm1].extentsStr();
200 for (
size_t d = 0;
d < nd; ++
d)
201 center[
d] = extents[
d].getCentre();
210 for (
size_t d = 0;
d < nd;
d++) {
211 volume *= double(extents[
d].getSize());
215 m_inverseVolume =
coord_t(1. / volume);
275 uint32_t
getDepth()
const override {
return m_depth; }
305 template <
typename EventIterator>
void calcCaches(
const EventIterator &begin,
const EventIterator &end);
347 using sptr = std::shared_ptr<MDBoxBase<MDE, nd>>;
351#ifndef __INTEL_COMPILER
355template <
typename MDE,
size_t nd>
356template <
typename EventIterator>
361 coord_t *centroid = m_centroid;
362 std::fill_n(centroid, nd, 0.0f);
363 for (
auto it = begin; it != end; ++it) {
364 auto evSignal = it->getSignal();
365 m_signal += evSignal;
366 m_errorSquared += it->getErrorSquared();
369 for (
auto d = 0u;
d < nd;
d++) {
371 centroid[
d] += it->getCenter(
d) *
static_cast<coord_t>(evSignal);
377 for (
size_t d = 0;
d < nd; ++
d) {
378 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.
Templated super-class of a multi-dimensional event "box".
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.
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.
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.
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.
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
void setErrorSquared(const signal_t ErrorSquared) override
Sets the integrated error squared from all points within (mostly used for testing)
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.
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.
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.