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
19
20namespace Mantid {
21namespace DataObjects {
22
37class MANTID_DATAOBJECTS_DLL MDEventWorkspace : public API::IMDEventWorkspace {
38
39public:
41 using sptr = std::shared_ptr<MDEventWorkspace<MDE, nd>>;
43 using MDEventType = MDE;
44
49 virtual ~MDEventWorkspace() override = default;
50
52 std::unique_ptr<MDEventWorkspace> clone() const { return std::unique_ptr<MDEventWorkspace>(doClone()); }
53
55 std::unique_ptr<MDEventWorkspace> cloneEmpty() const { return std::unique_ptr<MDEventWorkspace>(doCloneEmpty()); }
56
58 void initialize() override;
59
60 const std::string id() const override;
61
62 //------------------------ IMDWorkspace Methods
63 //-----------------------------------------
64
66 size_t getNumDims() const override;
67
69 uint64_t getNPoints() const override;
70 uint64_t getNEvents() const override { return getNPoints(); }
71
73 std::vector<std::unique_ptr<Mantid::API::IMDIterator>>
74 createIterators(size_t suggestedNumCores = 1,
75 Mantid::Geometry::MDImplicitFunction *function = nullptr) const override;
76
78 signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override;
79
81 // or 0 if masked
82 signal_t getSignalWithMaskAtCoord(const coord_t *coords,
83 const Mantid::API::MDNormalization &normalization) const override;
84
85 bool isInBounds(const coord_t *coords) const;
86
87 signal_t getNormalizedSignal(const API::IMDNode *box, const Mantid::API::MDNormalization &normalization) const;
88
89 signal_t getNormalizedError(const API::IMDNode *box, const Mantid::API::MDNormalization &normalization) const;
90
91 LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end,
92 API::MDNormalization normalize) const override;
93
94 // Get ordered list of boundaries in position-along-the-line coordinates
95 std::set<coord_t> getBoxBoundaryBisectsOnLine(const Kernel::VMD &start, const Kernel::VMD &end, const size_t num_d,
96 const Kernel::VMD &dir, const coord_t length) const;
97
98 //------------------------ (END) IMDWorkspace Methods
99 //-----------------------------------------
100
102 size_t getMemorySize() const override;
103
104 //------------------------ IMDEventWorkspace Methods
105 //-----------------------------------------
106
108 Mantid::API::BoxController_sptr getBoxController() override { return m_BoxController; }
109
111 Mantid::API::BoxController_const_sptr getBoxController() const override { return m_BoxController; }
112
113 std::vector<std::string> getBoxControllerStats() const override;
114
116 bool isFileBacked() const override { return m_BoxController->isFileBacked(); }
117
118 std::vector<coord_t> estimateResolution() const override;
119
120 void splitAllIfNeeded(Kernel::ThreadScheduler *ts) override;
121
122 void splitTrackedBoxes(Kernel::ThreadScheduler *ts);
123
124 void splitBox() override;
125
126 void refreshCache() override;
127
128 std::string getEventTypeName() const override;
130 size_t sizeofEvent() const override { return sizeof(MDE); }
131
132 void setMinRecursionDepth(size_t minDepth) override;
133
134 Mantid::API::ITableWorkspace_sptr makeBoxTable(size_t start, size_t num) override;
135 //------------------------ (END) IMDEventWorkspace Methods
136 //-----------------------------------------
137
138 void getBoxes(std::vector<API::IMDNode *> &boxes, size_t maxDepth, bool leafOnly) override {
139 this->getBox()->getBoxes(boxes, maxDepth, leafOnly);
140 }
141
142 size_t addEvent(const MDE &event);
143
144 size_t addEvents(const std::vector<MDE> &events);
145
146 std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> getMinimumExtents(size_t depth = 2) const override;
147
149 bool isGridBox() { return dynamic_cast<MDGridBox<MDE, nd> *>(data.get()) != nullptr; }
150
152 MDBoxBase<MDE, nd> *getBox() { return data.get(); }
153
156 const MDBoxBase<MDE, nd> *getBox() const { return data.get(); }
157
160 void setBox(API::IMDNode *box) override {
161 data = std::unique_ptr<MDBoxBase<MDE, nd>>(dynamic_cast<MDBoxBase<MDE, nd> *>(box));
162 }
163
165 void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) override;
166
168 void clearMDMasking() override;
169
171 Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override;
173 void setCoordinateSystem(const Kernel::SpecialCoordinateSystem coordSystem) override;
175 virtual void setFileBacked(const std::string &fileName);
176 void setFileBacked() override;
179 void clearFileBacked(bool LoadFileBackedData) override;
180
183 void setDisplayNormalizationHisto(Mantid::API::MDNormalization preferredNormalizationHisto) override;
184 Mantid::API::MDNormalization displayNormalizationHisto() const override;
185
187 void setDisplayNormalization(Mantid::API::MDNormalization preferredNormalization) override;
188 Mantid::API::MDNormalization displayNormalization() const override;
189
190protected:
193
195 void getBoundariesInDimension(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &dir,
196 const size_t num_boundaries, const coord_t length, const coord_t dir_current_dim,
197 const coord_t box_size, std::set<coord_t> &mid_points) const;
198
201
203 std::unique_ptr<MDBoxBase<MDE, nd>> data;
204
205 // std::shared_ptr<BoxCtrlChangesList > m_BoxController;
210
211private:
212 MDEventWorkspace *doClone() const override { return new MDEventWorkspace(*this); }
213
214 MDEventWorkspace *doCloneEmpty() const override { return new MDEventWorkspace(); }
215
217};
218
219} // namespace DataObjects
220
221} // namespace Mantid
#define TMDE_CLASS
Macro to make declaring template classes faster.
Definition MDTypes.h:59
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.
Kernel::SpecialCoordinateSystem m_coordSystem
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
void getBoxes(std::vector< API::IMDNode * > &boxes, size_t maxDepth, bool leafOnly) override
std::unique_ptr< MDEventWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
API::BoxController_sptr m_BoxController
Box controller in use.
uint64_t getNEvents() const override
const MDBoxBase< MDE, nd > * getBox() const
bool isGridBox()
Return true if the underlying box is a MDGridBox.
MDEventWorkspace< MDE, nd > & operator=(const MDEventWorkspace< MDE, nd > &other)=delete
std::unique_ptr< MDEventWorkspace > clone() const
Returns a clone of the workspace.
MDEventWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
Mantid::API::MDNormalization m_displayNormalization
Display normalization for the event workspace itself.
Mantid::API::MDNormalization m_displayNormalizationHisto
Display normalization to pass onto generated histo workspaces.
MDE MDEventType
Typedef to access the MDEventType.
void setBox(API::IMDNode *box) override
Set the base-level box contained within.
size_t sizeofEvent() const override
return the size (in bytes) of an event, this workspace contains
std::unique_ptr< MDBoxBase< MDE, nd > > data
MDBox containing all of the events in the workspace.
MDEventWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
Mantid::API::BoxController_const_sptr getBoxController() const override
Returns the BoxController used in this workspace.
virtual ~MDEventWorkspace() override=default
Mantid::API::BoxController_sptr getBoxController() override
Returns the BoxController used in this workspace.
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