Mantid
Loading...
Searching...
No Matches
IMDWorkspace.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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
9#include "MantidAPI/DllConfig.h"
13#include "MantidAPI/Workspace.h"
16#include <cstdint>
17#include <vector>
18
19namespace Mantid {
20
21namespace Geometry {
22class MDImplicitFunction;
23}
24
25namespace API {
26
27static const signal_t MDMaskValue = std::numeric_limits<double>::quiet_NaN();
28
42class MANTID_API_DLL IMDWorkspace : public Workspace, public API::MDGeometry {
43public:
45 IMDWorkspace &operator=(const IMDWorkspace &other) = delete;
46
50 struct LinePlot {
51 std::vector<coord_t> x;
52 std::vector<signal_t> y;
53 std::vector<signal_t> e;
54 };
55
57 std::unique_ptr<IMDWorkspace> clone() const { return std::unique_ptr<IMDWorkspace>(doClone()); }
58
60 std::unique_ptr<IMDWorkspace> cloneEmpty() const { return std::unique_ptr<IMDWorkspace>(doCloneEmpty()); }
61
68 virtual uint64_t getNPoints() const = 0;
69 /*** Get the number of events, associated with the workspace
70 * For MDEvenWorkspace it is equal to the number of points
71 * For regularly gridded workspace (MDHistoWorkspace and MatrixWorkspace),
72 * it is the number of contributed non-zero events.
73 */
74 virtual uint64_t getNEvents() const = 0;
75
77 virtual std::vector<std::unique_ptr<IMDIterator>>
78 createIterators(size_t suggestedNumCores = 1, Mantid::Geometry::MDImplicitFunction *function = nullptr) const = 0;
79
81 virtual signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const = 0;
82
84 // is masked, used for plotting
86 const Mantid::API::MDNormalization &normalization) const = 0;
87
89 virtual LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end,
90 Mantid::API::MDNormalization normalize) const;
91
92 std::unique_ptr<IMDIterator> createIterator(Mantid::Geometry::MDImplicitFunction *function = nullptr) const;
93
94 const std::string &getConvention() const;
95 void setConvention(std::string convention);
96 std::string changeQConvention();
97
98 signal_t getSignalAtVMD(const Mantid::Kernel::VMD &coords,
100
102 getSignalWithMaskAtVMD(const Mantid::Kernel::VMD &coords,
104
106 virtual void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) = 0;
107
109 virtual void clearMDMasking() = 0;
114 virtual void clearFileBacked(bool /* loadFileContentsToMemory*/) {}
117 virtual ITableWorkspace_sptr makeBoxTable(size_t /*start*/, size_t /* num*/) {
118 throw Kernel::Exception::NotImplementedError("This method is not generally implemented ");
119 }
120
121 // Preferred normalization to use for display
122 virtual MDNormalization displayNormalization() const;
123
124 // Preferred normalization to use for displaying histo workspaces
125 virtual MDNormalization displayNormalizationHisto() const;
126
127 // Check if this class is an instance of MDHistoWorkspace
128 virtual bool isMDHistoWorkspace() const { return false; }
129
130 // Check if this class has an oriented lattice on a sample object
131 virtual bool hasOrientedLattice() const = 0;
132
133protected:
135 IMDWorkspace(const IMDWorkspace &) = default;
136
137 void makeSinglePointWithNaN(std::vector<coord_t> &x, std::vector<signal_t> &y, std::vector<signal_t> &e) const;
138
139 const std::string toString() const override;
140
141private:
142 std::string m_convention;
143 IMDWorkspace *doClone() const override = 0;
144 IMDWorkspace *doCloneEmpty() const override = 0;
145};
146
148using IMDWorkspace_sptr = std::shared_ptr<IMDWorkspace>;
150using IMDWorkspace_const_sptr = std::shared_ptr<const IMDWorkspace>;
151} // namespace API
152} // namespace Mantid
153
154// Instantiated and exported by API/src/PropertyWithValue.cpp
155MANTID_API_EXTERN_TEMPLATE(Mantid::Kernel::PropertyWithValue<std::shared_ptr<Mantid::API::IMDWorkspace>>);
MANTID_API_EXTERN_TEMPLATE(Mantid::Kernel::PropertyWithValue< std::shared_ptr< Mantid::API::IMDWorkspace > >)
Basic MD Workspace Abstract Class.
virtual void setMDMasking(std::unique_ptr< Mantid::Geometry::MDImplicitFunction > maskingRegion)=0
Setter for the masking region.
virtual void clearFileBacked(bool)
if a workspace was filebacked, this should clear file-based status, delete file-based information and...
virtual signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const =0
Returns the (normalized) signal at a given coordinates.
IMDWorkspace(const IMDWorkspace &)=default
Protected copy constructor. May be used by childs for cloning.
virtual bool isMDHistoWorkspace() const
IMDWorkspace * doCloneEmpty() const override=0
Virtual cloneEmpty method.
IMDWorkspace & operator=(const IMDWorkspace &other)=delete
virtual uint64_t getNEvents() const =0
virtual Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const =0
std::unique_ptr< IMDWorkspace > clone() const
Returns a clone of the workspace.
virtual void clearMDMasking()=0
Clear existing masks.
virtual bool hasOrientedLattice() const =0
std::unique_ptr< IMDWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
virtual signal_t getSignalWithMaskAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const =0
Returns the (normalized) signal at a given coordinates or 0 if the value.
virtual uint64_t getNPoints() const =0
Get the number of points associated with the workspace.
virtual ITableWorkspace_sptr makeBoxTable(size_t, size_t)
this is the method to build table workspace from any workspace.
virtual std::vector< std::unique_ptr< IMDIterator > > createIterators(size_t suggestedNumCores=1, Mantid::Geometry::MDImplicitFunction *function=nullptr) const =0
Creates a new iterator pointing to the first cell in the workspace.
IMDWorkspace * doClone() const override=0
Virtual clone method. Not implemented to force implementation in children.
Describes the geometry (i.e.
Definition MDGeometry.h:36
Base Workspace Abstract Class.
Definition Workspace.h:30
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
Marks code as not implemented yet.
Definition Exception.h:138
The concrete, templated class for properties.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const IMDWorkspace > IMDWorkspace_const_sptr
Shared pointer to the IMDWorkspace base class (const version)
static const signal_t MDMaskValue
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
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
std::string toString(const T &value)
Convert values to strings.
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.