Mantid
Loading...
Searching...
No Matches
Workspace2D.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//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
13#include "MantidDataObjects/DllConfig.h"
17
18namespace Mantid {
19
20namespace DataObjects {
30class MANTID_DATAOBJECTS_DLL Workspace2D : public API::HistoWorkspace {
31public:
36 const std::string id() const override { return "Workspace2D"; }
37
39 Workspace2D &operator=(const Workspace2D &other) = delete;
40 ~Workspace2D() override;
41
43 std::unique_ptr<Workspace2D> clone() const { return std::unique_ptr<Workspace2D>(doClone()); }
44
46 std::unique_ptr<Workspace2D> cloneEmpty() const { return std::unique_ptr<Workspace2D>(doCloneEmpty()); }
47
49 bool isRaggedWorkspace() const override;
50
51 // section required for iteration
52 std::size_t size() const override;
53
54 std::size_t blocksize() const override;
55
57 std::size_t getNumberBins(const std::size_t &index) const override;
59 std::size_t getMaxNumberBins() const override;
60
62 std::size_t getNumberHistograms() const override;
63
64 Histogram1D &getSpectrum(const size_t index) override {
65 invalidateCommonBinsFlag();
66 return getSpectrumWithoutInvalidation(index);
67 }
68 const Histogram1D &getSpectrum(const size_t index) const override;
69
71 void generateHistogram(const std::size_t index, std::span<double const> X, MantidVec &Y, MantidVec &E,
72 bool skipError = false) const override;
73
77 void setMonitorList(const std::vector<specnum_t> &mList) { m_monitorList = mList; }
78
80 void setImageY(const API::MantidImage &image, size_t start = 0, bool parallelExecution = true) override;
82 void setImageE(const API::MantidImage &image, size_t start = 0, bool parallelExecution = true) override;
84 void setImageYAndE(const API::MantidImage &imageY, const API::MantidImage &imageE, size_t start = 0,
85 bool loadAsRectImg = false, double scale_1 = 1.0, [[maybe_unused]] bool parallelExecution = true);
86
87protected:
89 Workspace2D(const Workspace2D &other);
90
92 void init(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength) override;
93 void init(const HistogramData::Histogram &histogram) override;
94
96 std::vector<specnum_t> m_monitorList;
97
99 std::vector<std::unique_ptr<Histogram1D>> data;
100
101private:
102 Workspace2D *doClone() const override;
103 Workspace2D *doCloneEmpty() const override;
104
105 Histogram1D &getSpectrumWithoutInvalidation(const size_t index) override;
106 virtual std::size_t getHistogramNumberHelper() const;
107};
108} // namespace DataObjects
109} // Namespace Mantid
110
111// Instantiated and exported by DataObjects/src/PropertyWithValue.cpp
113 Mantid::Kernel::PropertyWithValue<std::shared_ptr<Mantid::DataObjects::Workspace2D>>);
114
115#ifndef DataObjects_EXPORTS
117namespace Mantid::API {
119extern template class MANTID_DATAOBJECTS_DLL WorkspaceProperty<DataObjects::Workspace2D>;
121} // namespace Mantid::API
122#endif
std::map< DeltaEMode::Type, std::string > index
MANTID_DATAOBJECTS_EXTERN_TEMPLATE(Mantid::Kernel::PropertyWithValue< std::shared_ptr< Mantid::DataObjects::Workspace2D > >)
HistoWorkspace is an abstract base class for MatrixWorkspace types that are NOT event workspaces.
1D histogram implementation.
Definition Histogram1D.h:19
Concrete workspace implementation.
Definition Workspace2D.h:30
std::vector< std::unique_ptr< Histogram1D > > data
A vector that holds the 1D histograms.
Definition Workspace2D.h:99
const std::string id() const override
Gets the name of the workspace type.
Definition Workspace2D.h:36
Workspace2D & operator=(const Workspace2D &other)=delete
~Workspace2D() override
Destructor.
std::unique_ptr< Workspace2D > clone() const
Returns a clone of the workspace.
Definition Workspace2D.h:43
std::vector< specnum_t > m_monitorList
a vector holding workspace index of monitors in the workspace
Definition Workspace2D.h:96
std::unique_ptr< Workspace2D > cloneEmpty() const
Returns a default-initialized clone of the workspace.
Definition Workspace2D.h:46
Histogram1D & getSpectrum(const size_t index) override
Return the underlying ISpectrum ptr at the given workspace index.
Definition Workspace2D.h:64
void setMonitorList(const std::vector< specnum_t > &mList)
sets the monitorWorkspace indexlist
Definition Workspace2D.h:77
The concrete, templated class for properties.
std::vector< std::vector< double > > MantidImage
typedef for the image type
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition cow_ptr.h:172