Mantid
Loading...
Searching...
No Matches
MDEventWorkspace.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
12//#include "MantidDataObjects/BoxCtrlChangesList.h"
20
21namespace Mantid {
22namespace DataObjects {
23
38class MANTID_DATAOBJECTS_DLL MDEventWorkspace : public API::IMDEventWorkspace {
39
40public:
42 using sptr = std::shared_ptr<MDEventWorkspace<MDE, nd>>;
44 using MDEventType = MDE;
45
50 virtual ~MDEventWorkspace() override = default;
51
53 std::unique_ptr<MDEventWorkspace> clone() const { return std::unique_ptr<MDEventWorkspace>(doClone()); }
54
56 std::unique_ptr<MDEventWorkspace> cloneEmpty() const { return std::unique_ptr<MDEventWorkspace>(doCloneEmpty()); }
57
59 void initialize() override;
60
61 const std::string id() const override;
62
63 //------------------------ IMDWorkspace Methods
64 //-----------------------------------------
65
67 size_t getNumDims() const override;
68
70 uint64_t getNPoints() const override;
71 uint64_t getNEvents() const override { return getNPoints(); }
72
74 std::vector<std::unique_ptr<Mantid::API::IMDIterator>>
75 createIterators(size_t suggestedNumCores = 1,
76 Mantid::Geometry::MDImplicitFunction *function = nullptr) const override;
77
79 signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override;
80
82 // or 0 if masked
84 const Mantid::API::MDNormalization &normalization) const override;
85
86 bool isInBounds(const coord_t *coords) const;
87
89
91
93 API::MDNormalization normalize) const override;
94
95 // Get ordered list of boundaries in position-along-the-line coordinates
96 std::set<coord_t> getBoxBoundaryBisectsOnLine(const Kernel::VMD &start, const Kernel::VMD &end, const size_t num_d,
97 const Kernel::VMD &dir, const coord_t length) const;
98
99 //------------------------ (END) IMDWorkspace Methods
100 //-----------------------------------------
101
103 size_t getMemorySize() const override;
104
105 //------------------------ IMDEventWorkspace Methods
106 //-----------------------------------------
107
109 Mantid::API::BoxController_sptr getBoxController() override { return m_BoxController; }
110
112 Mantid::API::BoxController_const_sptr getBoxController() const override { return m_BoxController; }
113
114 std::vector<std::string> getBoxControllerStats() const override;
115
117 bool isFileBacked() const override { return m_BoxController->isFileBacked(); }
118
119 std::vector<coord_t> estimateResolution() const override;
120
122
124
125 void splitBox() override;
126
127 void refreshCache() override;
128
129 std::string getEventTypeName() const override;
131 size_t sizeofEvent() const override { return sizeof(MDE); }
132
133 void setMinRecursionDepth(size_t minDepth) override;
134
135 Mantid::API::ITableWorkspace_sptr makeBoxTable(size_t start, size_t num) override;
136 //------------------------ (END) IMDEventWorkspace Methods
137 //-----------------------------------------
138
139 void getBoxes(std::vector<API::IMDNode *> &boxes, size_t maxDepth, bool leafOnly) override {
140 this->getBox()->getBoxes(boxes, maxDepth, leafOnly);
141 }
142
143 size_t addEvent(const MDE &event);
144
145 size_t addEvents(const std::vector<MDE> &events);
146
147 std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> getMinimumExtents(size_t depth = 2) const override;
148
150 bool isGridBox() { return dynamic_cast<MDGridBox<MDE, nd> *>(data.get()) != nullptr; }
151
153 MDBoxBase<MDE, nd> *getBox() { return data.get(); }
154
157 const MDBoxBase<MDE, nd> *getBox() const { return data.get(); }
158
161 void setBox(API::IMDNode *box) override {
162 data = std::unique_ptr<MDBoxBase<MDE, nd>>(dynamic_cast<MDBoxBase<MDE, nd> *>(box));
163 }
164
166 void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) override;
167
169 void clearMDMasking() override;
170
174 void setCoordinateSystem(const Kernel::SpecialCoordinateSystem coordSystem) override;
176 virtual void setFileBacked(const std::string &fileName);
177 void setFileBacked() override;
180 void clearFileBacked(bool LoadFileBackedData) override;
181
184 void setDisplayNormalizationHisto(Mantid::API::MDNormalization preferredNormalizationHisto) override;
186
188 void setDisplayNormalization(Mantid::API::MDNormalization preferredNormalization) override;
190
191protected:
194
197 const size_t num_boundaries, const coord_t length, const coord_t dir_current_dim,
198 const coord_t box_size, std::set<coord_t> &mid_points) const;
199
202
204 std::unique_ptr<MDBoxBase<MDE, nd>> data;
205
206 // std::shared_ptr<BoxCtrlChangesList > m_BoxController;
211
212private:
213 MDEventWorkspace *doClone() const override { return new MDEventWorkspace(*this); }
214
215 MDEventWorkspace *doCloneEmpty() const override { return new MDEventWorkspace(); }
216
218};
219
220} // namespace DataObjects
221
222} // namespace Mantid
#define TMDE_CLASS
Macro to make declaring template classes faster.
Definition: MDTypes.h:58
Abstract base class for multi-dimension event workspaces (MDEventWorkspace).
Templated super-class of a multi-dimensional event "box".
Definition: MDBoxBase.h:50
Templated class for the multi-dimensional event workspace.
std::set< coord_t > getBoxBoundaryBisectsOnLine(const Kernel::VMD &start, const Kernel::VMD &end, const size_t num_d, const Kernel::VMD &dir, const coord_t length) const
void splitTrackedBoxes(Kernel::ThreadScheduler *ts)
size_t getMemorySize() const override
Mantid::API::MDNormalization displayNormalization() const override
void getBoxes(std::vector< API::IMDNode * > &boxes, size_t maxDepth, bool leafOnly) override
Mantid::API::BoxController_const_sptr getBoxController() const override
Returns the BoxController used in this workspace.
size_t addEvent(const MDE &event)
signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
Returns the (normalized) signal at a given coordinates.
MDEventWorkspace< MDE, nd > & operator=(const MDEventWorkspace< MDE, nd > &other)=delete
std::unique_ptr< MDBoxBase< MDE, nd > > data
MDBox containing all of the events in the workspace.
std::vector< Mantid::Geometry::MDDimensionExtents< coord_t > > getMinimumExtents(size_t depth=2) const override
Get the minimum extents that hold the data.
bool isGridBox()
Return true if the underlying box is a MDGridBox.
std::string getEventTypeName() const override
Return the type of event contained, as a string. MDEvent or MDLeanEvent.
Kernel::SpecialCoordinateSystem m_coordSystem
MDE MDEventType
Typedef to access the MDEventType.
uint64_t getNPoints() const override
void clearMDMasking() override
Clear masking.
const MDBoxBase< MDE, nd > * getBox() const
void setMDMasking(std::unique_ptr< Mantid::Geometry::MDImplicitFunction > maskingRegion) override
Apply masking.
void clearFileBacked(bool LoadFileBackedData) override
if workspace was file-backed, this should clear file-backed information and close back-up files.
MDEventWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
void setDisplayNormalizationHisto(Mantid::API::MDNormalization preferredNormalizationHisto) override
Preferred visual normalizaiton method for any histo workspaces created from this.
void splitBox() override
Split the top-level MDBox into a MDGridBox.
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
bool isInBounds(const coord_t *coords) const
void splitAllIfNeeded(Kernel::ThreadScheduler *ts) override
Split all boxes that exceed the split threshold.
signal_t getSignalWithMaskAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
Returns the (normalized) signal at a given coordinates.
std::unique_ptr< MDEventWorkspace > clone() const
Returns a clone of the workspace.
MDEventWorkspace(Mantid::API::MDNormalization preferredNormalization=Mantid::API::MDNormalization::VolumeNormalization, Mantid::API::MDNormalization preferredNormalizationHisto=Mantid::API::MDNormalization::VolumeNormalization)
void setCoordinateSystem(const Kernel::SpecialCoordinateSystem coordSystem) override
Set the coordinate system.
Mantid::API::MDNormalization displayNormalizationHisto() const override
Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override
Get the coordinate system.
std::vector< coord_t > estimateResolution() const override
std::unique_ptr< MDEventWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
void refreshCache() override
Refresh the cache (integrated signal of each box)
size_t sizeofEvent() const override
return the size (in bytes) of an event, this workspace contains
void setDisplayNormalization(Mantid::API::MDNormalization preferredNormalization) override
Preferred visual normalization method.
void initialize() override
Perform initialization after dimensions (and others) have been set.
virtual ~MDEventWorkspace() override=default
virtual void setFileBacked(const std::string &fileName)
make the workspace file backed if it has not been already file backed;
signal_t getNormalizedError(const API::IMDNode *box, const Mantid::API::MDNormalization &normalization) const
MDEventWorkspace(const MDEventWorkspace< MDE, nd > &other)
Protected copy constructor. May be used by childs for cloning.
void setMinRecursionDepth(size_t minDepth) override
Recurse down to a minimum depth.
signal_t getNormalizedSignal(const API::IMDNode *box, const Mantid::API::MDNormalization &normalization) const
void getBoundariesInDimension(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &dir, const size_t num_boundaries, const coord_t length, const coord_t dir_current_dim, const coord_t box_size, std::set< coord_t > &mid_points) const
Insert box bisects in position-along-line coords in a single dimension.
Mantid::API::MDNormalization m_displayNormalizationHisto
Display normalization to pass onto generated histo workspaces.
std::vector< std::string > getBoxControllerStats() const override
Returns some information about the box controller, to be displayed in the GUI, for example.
LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end, API::MDNormalization normalize) const override
Method to generate a line plot through a MD-workspace.
Mantid::API::BoxController_sptr getBoxController() override
Returns the BoxController used in this workspace.
size_t getNumDims() const override
void setFileBacked() override
set filebacked on the contained box
MDEventWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
API::BoxController_sptr m_BoxController
Box controller in use.
void setBox(API::IMDNode *box) override
Set the base-level box contained within.
std::vector< std::unique_ptr< Mantid::API::IMDIterator > > createIterators(size_t suggestedNumCores=1, Mantid::Geometry::MDImplicitFunction *function=nullptr) const override
Creates a new iterator pointing to the first cell (box) in the workspace.
const std::string id() const override
A string ID for the class.
Mantid::API::ITableWorkspace_sptr makeBoxTable(size_t start, size_t num) override
this is the method to build table workspace from any workspace.
Mantid::API::MDNormalization m_displayNormalization
Display normalization for the event workspace itself.
uint64_t getNEvents() const override
size_t addEvents(const std::vector< MDE > &events)
Templated class for a GRIDDED multi-dimensional event "box".
Definition: MDGridBox.h:42
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
The ThreadScheduler object defines how tasks are allocated to threads and in what order.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const BoxController > BoxController_const_sptr
Shared ptr to a const BoxController.
std::shared_ptr< BoxController > BoxController_sptr
Shared ptr to BoxController.
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
Definition: IMDIterator.h:25
@ VolumeNormalization
Divide the signal by the volume of the box/bin.
Definition: IMDIterator.h:29
SpecialCoordinateSystem
Special coordinate systems for Q3D.
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,...
Definition: MDTypes.h:27
double signal_t
Typedef for the signal recorded in a MDBox, etc.
Definition: MDTypes.h:36
Holds X, Y, E for a line plot.
Definition: IMDWorkspace.h:48