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"
16#include "MantidKernel/V3D.h"
17
19// IsamplePosition should be IsampleOrientation
20namespace Mantid {
21//----------------------------------------------------------------------
22// Forward declarations
23//----------------------------------------------------------------------
24namespace Kernel {
25class Logger;
26}
27
28namespace DataObjects {
29//==========================================================================================
37class MANTID_DATAOBJECTS_DLL PeaksWorkspace : public Mantid::API::IPeaksWorkspace {
38public:
39 using ColumnAndDirection = std::pair<std::string, bool>;
40
41public:
42 const std::string id() const override { return "PeaksWorkspace"; }
43
45 PeaksWorkspace &operator=(const PeaksWorkspace &other) = delete;
46
57 API::LogManager_sptr logs() override;
58 API::LogManager_const_sptr getLogs() const override;
59
61 std::unique_ptr<PeaksWorkspace> clone() const { return std::unique_ptr<PeaksWorkspace>(doClone()); }
62
64 std::unique_ptr<PeaksWorkspace> cloneEmpty() const { return std::unique_ptr<PeaksWorkspace>(doCloneEmpty()); }
65
66 void appendFile(std::string filename, Geometry::Instrument_sptr inst);
67
70 bool customSort() const override { return true; }
71
72 void sort(std::vector<ColumnAndDirection> &criteria) override;
73
74 int getNumberPeaks() const override;
75 std::string getConvention() const override;
76 void removePeak(int peakNum) override;
77 void removePeaks(std::vector<int> badPeaks) override;
78 void addPeak(const Geometry::IPeak &peak) override;
80 void addPeak(Peak &&peak);
81 void addPeak(const Kernel::V3D &position, const Kernel::SpecialCoordinateSystem &frame) override;
82 Peak &getPeak(int peakNum) override;
83 const Peak &getPeak(int peakNum) const override;
84
85 IPeak_uptr createPeak(const Kernel::V3D &QLabFrame,
86 boost::optional<double> detectorDistance = boost::none) const override;
87
88 IPeak_uptr createPeak(const Kernel::V3D &Position, const Kernel::SpecialCoordinateSystem &frame) const override;
89
90 IPeak_uptr createPeakQSample(const Kernel::V3D &position) const override;
91
92 std::vector<std::pair<std::string, std::string>> peakInfo(const Kernel::V3D &qFrame, bool labCoords) const override;
93
94 IPeak_uptr createPeakHKL(const Kernel::V3D &HKL) const override;
95
96 IPeak_uptr createPeak() const override;
97
98 int peakInfoNumber(const Kernel::V3D &qFrame, bool labCoords) const override;
99
100 std::vector<Peak> &getPeaks();
101 const std::vector<Peak> &getPeaks() const;
102 bool hasIntegratedPeaks() const override;
103 size_t getMemorySize() const override;
104
108 API::ITableWorkspace_sptr createDetectorTable() const override;
109
111 void setCoordinateSystem(const Kernel::SpecialCoordinateSystem coordinateSystem) override;
112
114 Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override;
115
116 // ====================================== ITableWorkspace Methods
117 // ==================================
119 size_t columnCount() const override { return static_cast<int>(m_columns.size()); }
120
122 size_t rowCount() const override { return getNumberPeaks(); }
123
125 std::shared_ptr<Mantid::API::Column> getColumn(const std::string &name) override {
126 return getColumn(getColumnIndex(name));
127 }
128
130 std::shared_ptr<const Mantid::API::Column> getColumn(const std::string &name) const override {
131 return getColumn(getColumnIndex(name));
132 }
133
135 virtual size_t getColumnIndex(const std::string &name) const;
136
138 std::shared_ptr<Mantid::API::Column> getColumn(size_t index) override;
139
142 API::Column_const_sptr getColumn(size_t index) const override;
143 // ====================================== End ITableWorkspace Methods
144 // ==================================
145
146 //---------------------------------------------------------------------------------------------
148 std::vector<std::string> getColumnNames() const override { return this->m_columnNames; }
150 bool threadSafe() const override { return true; }
151
152 // --- Nexus Methods ---
153 // Save to Nexus
154 void saveNexus(::NeXus::File *file) const override;
155
156protected:
158 PeaksWorkspace(const PeaksWorkspace &other);
159
160private:
161 PeaksWorkspace *doClone() const override { return new PeaksWorkspace(*this); }
162 PeaksWorkspace *doCloneEmpty() const override { return new PeaksWorkspace(); }
163 ITableWorkspace *doCloneColumns(const std::vector<std::string> &colNames) const override;
164
166 void initColumns();
168 void addPeakColumn(const std::string &name);
169
170 // ====================================== ITableWorkspace Methods
171 // ==================================
172
173 // ===== Methods that are not implemented (read-only table) ==========
174 API::Column_sptr addColumn(const std::string & /*type*/, const std::string & /*name*/) override {
175 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot add column.");
176 }
177
178 bool addColumns(const std::string & /*type*/, const std::string & /*name*/, size_t /*n*/) override {
179 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot add columns.");
180 }
181
182 void removeColumn(const std::string & /*name*/) override {
184 "PeaksWorkspace structure is read-only. Cannot remove column.");
185 }
186
187 void setRowCount(size_t /*count*/) override {
188 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot setRowCount");
189 }
190
191 size_t insertRow(size_t /*index*/) override {
192 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot insertRow");
193 }
194
195 void removeRow(size_t /*index*/) override {
196 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot removeRow.");
197 }
198
200 void find(size_t /*value*/, size_t & /*row*/, size_t /*col*/) override {
201 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
202 }
204 void find(double /*value*/, size_t & /*row*/, size_t /*col*/) override {
205 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
206 }
208 void find(float /*value*/, size_t & /*row*/, size_t /*col*/) override {
209 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
210 }
213 void find(API::Boolean /*value*/, size_t & /*row*/, size_t /*col*/) override {
214 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
215 }
218 void find(const std::string & /*value*/, size_t & /*row*/, size_t /*col*/) override {
219 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
220 }
223 void find(const Mantid::Kernel::V3D & /*value*/, size_t & /*row*/, size_t /*col*/) override {
224 throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace::find() not implemented.");
225 }
226
227 // ====================================== End ITableWorkspace Methods
228 // ==================================
229
231 std::vector<Peak> m_peaks;
232
234 std::vector<std::shared_ptr<Mantid::DataObjects::PeakColumn<Peak>>> m_columns;
235
237 std::vector<std::string> m_columnNames;
238
241};
242
244using PeaksWorkspace_sptr = std::shared_ptr<PeaksWorkspace>;
245
247using PeaksWorkspace_const_sptr = std::shared_ptr<const PeaksWorkspace>;
248} // namespace DataObjects
249} // namespace Mantid
double position
Definition: GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
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
bool customSort() const override
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:21
Structure describing a single-crystal peak.
Definition: IPeak.h:26
Marks code as not implemented yet.
Definition: Exception.h:138
Class for 3D vectors.
Definition: V3D.h:34
std::shared_ptr< const LogManager > LogManager_const_sptr
shared pointer to the logManager base class (const version)
Definition: LogManager.h:210
std::shared_ptr< Column > Column_sptr
Definition: Column.h:228
std::shared_ptr< LogManager > LogManager_sptr
shared pointer to the logManager base class
Definition: LogManager.h:208
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const Column > Column_const_sptr
Definition: Column.h:229
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:103
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:209