Mantid
Loading...
Searching...
No Matches
PeaksWorkspace.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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
11#include "MantidDataObjects/DllConfig.h"
17#include "MantidKernel/V3D.h"
18
20// IsamplePosition should be IsampleOrientation
21namespace Mantid {
22//----------------------------------------------------------------------
23// Forward declarations
24//----------------------------------------------------------------------
25namespace Kernel {
26class Logger;
27}
28
29namespace DataObjects {
30//==========================================================================================
38class MANTID_DATAOBJECTS_DLL PeaksWorkspace : public Mantid::API::IPeaksWorkspace {
39public:
40 using ColumnAndDirection = std::pair<std::string, bool>;
41
42public:
43 const std::string id() const override { return "PeaksWorkspace"; }
44
46 PeaksWorkspace &operator=(const PeaksWorkspace &other) = delete;
47
58 API::LogManager_sptr logs() override;
59 API::LogManager_const_sptr getLogs() const override;
60
62 std::unique_ptr<PeaksWorkspace> clone() const { return std::unique_ptr<PeaksWorkspace>(doClone()); }
63
65 std::unique_ptr<PeaksWorkspace> cloneEmpty() const { return std::unique_ptr<PeaksWorkspace>(doCloneEmpty()); }
66
67 void appendFile(std::string filename, Geometry::Instrument_sptr inst);
68
71 bool customSort() const override { return true; }
72
73 void sort(std::vector<ColumnAndDirection> &criteria) override;
74
75 int getNumberPeaks() const override;
76 std::string getConvention() const override;
77 void removePeak(int peakNum) override;
78 void removePeaks(std::vector<int> badPeaks) override;
79 void addPeak(const Geometry::IPeak &peak) override;
81 void addPeak(Peak &&peak);
82 void addPeak(const Kernel::V3D &position, const Kernel::SpecialCoordinateSystem &frame) override;
83 Peak &getPeak(size_t const peakNum) override;
84 const Peak &getPeak(size_t const peakNum) const override;
85
86 IPeak_uptr createPeak(const Kernel::V3D &QLabFrame,
87 std::optional<double> detectorDistance = std::nullopt) const override;
88
89 IPeak_uptr createPeak(const Kernel::V3D &Position, const Kernel::SpecialCoordinateSystem &frame) const override;
90
91 IPeak_uptr createPeakQSample(const Kernel::V3D &position) const override;
92
93 std::vector<std::pair<std::string, std::string>> peakInfo(const Kernel::V3D &qFrame, bool labCoords) const override;
94
95 IPeak_uptr createPeakHKL(const Kernel::V3D &HKL) const override;
96
97 IPeak_uptr createPeak() const override;
98
99 int peakInfoNumber(const Kernel::V3D &qFrame, bool labCoords) const override;
100
101 std::vector<Peak> &getPeaks();
102 const std::vector<Peak> &getPeaks() const;
103 bool hasIntegratedPeaks() const override;
104 size_t getMemorySize() const override;
105
109 API::ITableWorkspace_sptr createDetectorTable() const override;
110
112 void setCoordinateSystem(const Kernel::SpecialCoordinateSystem coordinateSystem) override;
113
115 Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override;
116
117 // ====================================== ITableWorkspace Methods
118 // ==================================
120 size_t columnCount() const override { return static_cast<int>(m_columns.size()); }
121
123 size_t rowCount() const override { return getNumberPeaks(); }
124
126 std::shared_ptr<Mantid::API::Column> getColumn(const std::string &name) override {
127 return getColumn(getColumnIndex(name));
128 }
129
131 std::shared_ptr<const Mantid::API::Column> getColumn(const std::string &name) const override {
132 return getColumn(getColumnIndex(name));
133 }
134
136 virtual size_t getColumnIndex(const std::string &name) const;
137
139 std::shared_ptr<Mantid::API::Column> getColumn(size_t index) override;
140
143 API::Column_const_sptr getColumn(size_t index) const override;
144 // ====================================== End ITableWorkspace Methods
145 // ==================================
146
147 //---------------------------------------------------------------------------------------------
149 std::vector<std::string> getColumnNames() const override { return this->m_columnNames; }
151 bool threadSafe() const override { return true; }
152
153 // --- Nexus Methods ---
154 // Save to Nexus
155 void saveNexus(Nexus::File *file) const override;
156
157protected:
159 PeaksWorkspace(const PeaksWorkspace &other);
160
161private:
162 PeaksWorkspace *doClone() const override { return new PeaksWorkspace(*this); }
163 PeaksWorkspace *doCloneEmpty() const override { return new PeaksWorkspace(); }
164 ITableWorkspace *doCloneColumns(const std::vector<std::string> &colNames) const override;
165
167 void initColumns();
169 void addPeakColumn(const std::string &name);
170
171 // ====================================== ITableWorkspace Methods
172 // ==================================
173
174 // ===== Methods that are not implemented (read-only table) ==========
175 API::Column_sptr addColumn(const std::string & /*type*/, const std::string & /*name*/) override {
176 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot add column.");
177 }
178
179 bool addColumns(const std::string & /*type*/, const std::string & /*name*/, size_t /*n*/) override {
180 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot add columns.");
181 }
182
183 void removeColumn(const std::string & /*name*/) override {
185 "PeaksWorkspace structure is read-only. Cannot remove column.");
186 }
187
188 void setRowCount(size_t /*count*/) override {
189 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot setRowCount");
190 }
191
192 size_t insertRow(size_t /*index*/) override {
193 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot insertRow");
194 }
195
196 void removeRow(size_t /*index*/) override {
197 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot removeRow.");
198 }
199
201 void find(size_t /*value*/, size_t & /*row*/, size_t /*col*/) override {
202 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
203 }
205 void find(double /*value*/, size_t & /*row*/, size_t /*col*/) override {
206 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
207 }
209 void find(float /*value*/, size_t & /*row*/, size_t /*col*/) override {
210 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
211 }
214 void find(API::Boolean /*value*/, size_t & /*row*/, size_t /*col*/) override {
215 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
216 }
219 void find(const std::string & /*value*/, size_t & /*row*/, size_t /*col*/) override {
220 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
221 }
224 void find(const Mantid::Kernel::V3D & /*value*/, size_t & /*row*/, size_t /*col*/) override {
225 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
226 }
227
228 // ====================================== End ITableWorkspace Methods
229 // ==================================
230
232 std::vector<Peak> m_peaks;
233
235 std::vector<std::shared_ptr<Mantid::DataObjects::PeakColumn<Peak>>> m_columns;
236
238 std::vector<std::string> m_columnNames;
239
242};
243
245using PeaksWorkspace_sptr = std::shared_ptr<PeaksWorkspace>;
246
248using PeaksWorkspace_const_sptr = std::shared_ptr<const PeaksWorkspace>;
249} // namespace DataObjects
250} // namespace Mantid
251
252// Instantiated and exported by DataObjects/src/PropertyWithValue.cpp
254 Mantid::Kernel::PropertyWithValue<std::shared_ptr<Mantid::DataObjects::PeaksWorkspace>>);
255
256#ifndef DataObjects_EXPORTS
258namespace Mantid::API {
260extern template class MANTID_DATAOBJECTS_DLL WorkspaceProperty<DataObjects::PeaksWorkspace>;
262} // namespace Mantid::API
263#endif
std::string name
Definition Run.cpp:60
double position
Definition GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
MANTID_DATAOBJECTS_EXTERN_TEMPLATE(Mantid::Kernel::PropertyWithValue< std::shared_ptr< Mantid::DataObjects::PeaksWorkspace > >)
Interface to the class Mantid::DataObjects::PeaksWorkspace.
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
Structure describing a single-crystal peak.
Definition Peak.h:34
The class PeaksWorkspace stores information about a set of SCD peaks.
void find(API::Boolean, size_t &, size_t) override
find method to get the index of API::Boolean value cell in a table workspace
const std::string id() const override
Return the workspace typeID.
void find(float, size_t &, size_t) override
find method to get the index of float cell value in a table workspace
void setRowCount(size_t) override
Resizes the workspace.
std::vector< std::shared_ptr< Mantid::DataObjects::PeakColumn< Peak > > > m_columns
Column shared pointers.
std::pair< std::string, bool > ColumnAndDirection
void removeColumn(const std::string &) override
Removes a column.
std::vector< Peak > m_peaks
Vector of Peak contained within.
PeaksWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
std::vector< std::string > getColumnNames() const override
Returns a vector of all column names.
PeaksWorkspace & operator=(const PeaksWorkspace &other)=delete
std::vector< std::string > m_columnNames
Column names.
std::shared_ptr< Mantid::API::Column > getColumn(const std::string &name) override
Gets the shared pointer to a column by name.
bool addColumns(const std::string &, const std::string &, size_t) override
Creates n new columns of the same type.
void find(double, size_t &, size_t) override
find method to get the index of double cell value in a table workspace
size_t insertRow(size_t) override
Inserts a row before row pointed to by index and fills it with default vales.
std::unique_ptr< PeaksWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
void find(size_t, size_t &, size_t) override
find method to get the index of integer cell value in a table workspace
API::Column_sptr addColumn(const std::string &, const std::string &) override
Creates a new column.
void removeRow(size_t) override
Delets a row if it exists.
std::unique_ptr< PeaksWorkspace > clone() const
Returns a clone of the workspace.
bool threadSafe() const override
This is always threadsafe.
PeaksWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
void find(const Mantid::Kernel::V3D &, size_t &, size_t) override
find method to get the index of Mantid::Kernel::V3D cell value in a table workspace
std::shared_ptr< const Mantid::API::Column > getColumn(const std::string &name) const override
Gets the shared pointer to a column by name.
void find(const std::string &, size_t &, size_t) override
find method to get the index of cellstd::string value in a table workspace
void appendFile(std::string filename, Geometry::Instrument_sptr inst)
size_t columnCount() const override
Number of columns in the workspace.
Kernel::SpecialCoordinateSystem m_coordSystem
Coordinates.
size_t rowCount() const override
Number of rows in the workspace.
HKL : HKL MDFrame.
Definition HKL.h:20
Structure describing a single-crystal peak.
Definition IPeak.h:26
Marks code as not implemented yet.
Definition Exception.h:138
The concrete, templated class for properties.
Class for 3D vectors.
Definition V3D.h:35
std::shared_ptr< const LogManager > LogManager_const_sptr
shared pointer to the logManager base class (const version)
Definition LogManager.h:228
std::shared_ptr< Column > Column_sptr
Definition Column.h:229
std::shared_ptr< LogManager > LogManager_sptr
shared pointer to the logManager base class
Definition LogManager.h:226
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const Column > Column_const_sptr
Definition Column.h:230
std::shared_ptr< const PeaksWorkspace > PeaksWorkspace_const_sptr
Typedef for a shared pointer to a const peaks workspace.
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
std::unique_ptr< IPeak > IPeak_uptr
Definition IPeak.h:108
SpecialCoordinateSystem
Special coordinate systems for Q3D.
Helper class which provides the Collimation Length for SANS instruments.
As TableColumn stores its data in a std::vector bool type cannot be used in the same way as the other...
Definition Column.h:210