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
12#include "MantidAPI/Workspace.h"
14#include <cstdint>
15#include <vector>
16
17namespace Mantid {
18
19namespace Geometry {
20class MDImplicitFunction;
21}
22
23namespace API {
24
25static const signal_t MDMaskValue = std::numeric_limits<double>::quiet_NaN();
26
40class MANTID_API_DLL IMDWorkspace : public Workspace, public API::MDGeometry {
41public:
42 IMDWorkspace(const Parallel::StorageMode storageMode = Parallel::StorageMode::Cloned);
43 IMDWorkspace &operator=(const IMDWorkspace &other) = delete;
44
48 struct LinePlot {
49 std::vector<coord_t> x;
50 std::vector<signal_t> y;
51 std::vector<signal_t> e;
52 };
53
55 std::unique_ptr<IMDWorkspace> clone() const { return std::unique_ptr<IMDWorkspace>(doClone()); }
56
58 std::unique_ptr<IMDWorkspace> cloneEmpty() const { return std::unique_ptr<IMDWorkspace>(doCloneEmpty()); }
59
66 virtual uint64_t getNPoints() const = 0;
67 /*** Get the number of events, associated with the workspace
68 * For MDEvenWorkspace it is equal to the number of points
69 * For regularly gridded workspace (MDHistoWorkspace and MatrixWorkspace),
70 * it is the number of contributed non-zero events.
71 */
72 virtual uint64_t getNEvents() const = 0;
73
75 virtual std::vector<std::unique_ptr<IMDIterator>>
76 createIterators(size_t suggestedNumCores = 1, Mantid::Geometry::MDImplicitFunction *function = nullptr) const = 0;
77
79 virtual signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const = 0;
80
82 // is masked, used for plotting
84 const Mantid::API::MDNormalization &normalization) const = 0;
85
87 virtual LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end,
88 Mantid::API::MDNormalization normalize) const;
89
90 std::unique_ptr<IMDIterator> createIterator(Mantid::Geometry::MDImplicitFunction *function = nullptr) const;
91
92 std::string getConvention() const;
93 void setConvention(std::string convention);
94 std::string changeQConvention();
95
96 signal_t getSignalAtVMD(const Mantid::Kernel::VMD &coords,
98
100 getSignalWithMaskAtVMD(const Mantid::Kernel::VMD &coords,
102
104 virtual void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) = 0;
105
107 virtual void clearMDMasking() = 0;
112 virtual void clearFileBacked(bool /* loadFileContentsToMemory*/) {}
115 virtual ITableWorkspace_sptr makeBoxTable(size_t /*start*/, size_t /* num*/) {
116 throw Kernel::Exception::NotImplementedError("This method is not generally implemented ");
117 }
118
119 // Preferred normalization to use for display
120 virtual MDNormalization displayNormalization() const;
121
122 // Preferred normalization to use for displaying histo workspaces
123 virtual MDNormalization displayNormalizationHisto() const;
124
125 // Check if this class is an instance of MDHistoWorkspace
126 virtual bool isMDHistoWorkspace() const { return false; }
127
128 // Check if this class has an oriented lattice on a sample object
129 virtual bool hasOrientedLattice() const = 0;
130
131protected:
133 IMDWorkspace(const IMDWorkspace &) = default;
134
135 void makeSinglePointWithNaN(std::vector<coord_t> &x, std::vector<signal_t> &y, std::vector<signal_t> &e) const;
136
137 const std::string toString() const override;
138
139private:
140 std::string m_convention;
141 IMDWorkspace *doClone() const override = 0;
142 IMDWorkspace *doCloneEmpty() const override = 0;
143};
144
146using IMDWorkspace_sptr = std::shared_ptr<IMDWorkspace>;
148using IMDWorkspace_const_sptr = std::shared_ptr<const IMDWorkspace>;
149} // namespace API
150} // namespace Mantid
Basic MD Workspace Abstract Class.
Definition: IMDWorkspace.h:40
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...
Definition: IMDWorkspace.h:112
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
Definition: IMDWorkspace.h:126
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.
Definition: IMDWorkspace.h:55
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.
Definition: IMDWorkspace.h:58
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.
Definition: IMDWorkspace.h:115
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:37
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
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)
Definition: IMDWorkspace.h:148
static const signal_t MDMaskValue
Definition: IMDWorkspace.h:25
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
Definition: IMDWorkspace.h:146
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
std::vector< signal_t > y
Definition: IMDWorkspace.h:50
std::vector< signal_t > e
Definition: IMDWorkspace.h:51