Mantid
Loading...
Searching...
No Matches
LeanElasticPeaksWorkspace.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
18// IsamplePosition should be IsampleOrientation
19namespace Mantid {
20//----------------------------------------------------------------------
21// Forward declarations
22//----------------------------------------------------------------------
23namespace Kernel {
24class Logger;
25}
26
27namespace DataObjects {
28//==========================================================================================
37class MANTID_DATAOBJECTS_DLL LeanElasticPeaksWorkspace : public Mantid::API::IPeaksWorkspace {
38public:
39 using ColumnAndDirection = std::pair<std::string, bool>;
40
41public:
42 const std::string id() const override { return "LeanElasticPeaksWorkspace"; }
43
46
57 API::LogManager_sptr logs() override;
58 API::LogManager_const_sptr getLogs() const override;
59
61 std::unique_ptr<LeanElasticPeaksWorkspace> clone() const {
62 return std::unique_ptr<LeanElasticPeaksWorkspace>(doClone());
63 }
64
66 std::unique_ptr<LeanElasticPeaksWorkspace> cloneEmpty() const {
67 return std::unique_ptr<LeanElasticPeaksWorkspace>(doCloneEmpty());
68 }
69
70 void appendFile(std::string filename, Geometry::Instrument_sptr inst);
71
74 bool customSort() const override { return true; }
75
76 void sort(std::vector<ColumnAndDirection> &criteria) override;
77
78 int getNumberPeaks() const override;
79 std::string getConvention() const override;
80 void removePeak(int peakNum) override;
81 void removePeaks(std::vector<int> badPeaks) override;
82 void addPeak(const Geometry::IPeak &peak) override;
84 void addPeak(LeanElasticPeak &&peak);
85 void addPeak(const Kernel::V3D &position, const Kernel::SpecialCoordinateSystem &frame) override;
86 LeanElasticPeak &getPeak(int peakNum) override;
87 const LeanElasticPeak &getPeak(int peakNum) const override;
88
89 std::unique_ptr<Geometry::IPeak> createPeak(const Kernel::V3D &QLabFrame,
90 boost::optional<double> detectorDistance = boost::none) const override;
91
92 std::unique_ptr<Geometry::IPeak> createPeak(const Kernel::V3D &Position,
93 const Kernel::SpecialCoordinateSystem &frame) const override;
94
95 std::unique_ptr<Geometry::IPeak> createPeakQSample(const Kernel::V3D &position) const override;
96
97 std::vector<std::pair<std::string, std::string>> peakInfo(const Kernel::V3D &qFrame, bool labCoords) const override;
98
99 std::unique_ptr<Geometry::IPeak> createPeakHKL(const Kernel::V3D &HKL) const override;
100
101 std::unique_ptr<Geometry::IPeak> createPeak() const override;
102
103 int peakInfoNumber(const Kernel::V3D &qFrame, bool labCoords) const override;
104
105 std::vector<LeanElasticPeak> &getPeaks();
106 const std::vector<LeanElasticPeak> &getPeaks() const;
107 bool hasIntegratedPeaks() const override;
108 size_t getMemorySize() const override;
109
113 API::ITableWorkspace_sptr createDetectorTable() const override;
114
116 void setCoordinateSystem(const Kernel::SpecialCoordinateSystem coordinateSystem) override;
117
119 Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override;
120
121 // ====================================== ITableWorkspace Methods
122 // ==================================
124 size_t columnCount() const override { return static_cast<int>(m_columns.size()); }
125
127 size_t rowCount() const override { return getNumberPeaks(); }
128
130 std::shared_ptr<Mantid::API::Column> getColumn(const std::string &name) override {
131 return getColumn(getColumnIndex(name));
132 }
133
135 std::shared_ptr<const Mantid::API::Column> getColumn(const std::string &name) const override {
136 return getColumn(getColumnIndex(name));
137 }
138
140 virtual size_t getColumnIndex(const std::string &name) const;
141
143 std::shared_ptr<Mantid::API::Column> getColumn(size_t index) override;
144
147 API::Column_const_sptr getColumn(size_t index) const override;
148 // ====================================== End ITableWorkspace Methods
149 // ==================================
150
151 //---------------------------------------------------------------------------------------------
153 std::vector<std::string> getColumnNames() const override { return this->m_columnNames; }
155 bool threadSafe() const override { return true; }
156
157 // --- Nexus Methods ---
158 // Save to Nexus
159 void saveNexus(::NeXus::File *file) const override;
160
161protected:
164
165private:
166 LeanElasticPeaksWorkspace *doClone() const override { return new LeanElasticPeaksWorkspace(*this); }
168 ITableWorkspace *doCloneColumns(const std::vector<std::string> &colNames) const override;
169
171 void initColumns();
173 void addPeakColumn(const std::string &name);
174
175 // ====================================== ITableWorkspace Methods
176 // ==================================
177
178 // ===== Methods that are not implemented (read-only table) ==========
179 API::Column_sptr addColumn(const std::string & /*type*/, const std::string & /*name*/) override {
181 "LeanElasticPeaksWorkspace structure is read-only. Cannot add column.");
182 }
183
184 bool addColumns(const std::string & /*type*/, const std::string & /*name*/, size_t /*n*/) override {
185 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace structure is read-only. Cannot add "
186 "columns.");
187 }
188
189 void removeColumn(const std::string & /*name*/) override {
191 "LeanElasticPeaksWorkspace structure is read-only. Cannot remove "
192 "column.");
193 }
194
195 void setRowCount(size_t /*count*/) override {
197 "LeanElasticPeaksWorkspace structure is read-only. Cannot setRowCount");
198 }
199
200 size_t insertRow(size_t /*index*/) override {
202 "LeanElasticPeaksWorkspace structure is read-only. Cannot insertRow");
203 }
204
205 void removeRow(size_t /*index*/) override {
207 "LeanElasticPeaksWorkspace structure is read-only. Cannot removeRow.");
208 }
209
211 void find(size_t /*value*/, size_t & /*row*/, size_t /*col*/) override {
212 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
213 }
215 void find(double /*value*/, size_t & /*row*/, size_t /*col*/) override {
216 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
217 }
219 void find(float /*value*/, size_t & /*row*/, size_t /*col*/) override {
220 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
221 }
224 void find(API::Boolean /*value*/, size_t & /*row*/, size_t /*col*/) override {
225 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
226 }
229 void find(const std::string & /*value*/, size_t & /*row*/, size_t /*col*/) override {
230 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
231 }
234 void find(const Mantid::Kernel::V3D & /*value*/, size_t & /*row*/, size_t /*col*/) override {
235 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
236 }
237
238 // ====================================== End ITableWorkspace Methods
239 // ==================================
240
242 std::vector<LeanElasticPeak> m_peaks;
243
245 std::vector<std::shared_ptr<Mantid::DataObjects::PeakColumn<LeanElasticPeak>>> m_columns;
246
248 std::vector<std::string> m_columnNames;
249
252};
253
255using LeanElasticPeaksWorkspace_sptr = std::shared_ptr<LeanElasticPeaksWorkspace>;
256
258using LeanElasticPeaksWorkspace_const_sptr = std::shared_ptr<const LeanElasticPeaksWorkspace>;
259} // namespace DataObjects
260} // 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.
The class LeanElasticPeaksWorkspace stores information about a set of SCD lean peaks.
void find(const std::string &, size_t &, size_t) override
find method to get the index of cellstd::string value in a table workspace
std::unique_ptr< LeanElasticPeaksWorkspace > clone() const
Returns a clone of the workspace.
void appendFile(std::string filename, Geometry::Instrument_sptr inst)
void find(API::Boolean, size_t &, size_t) override
find method to get the index of API::Boolean value cell in a table workspace
LeanElasticPeaksWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
LeanElasticPeaksWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
void find(float, size_t &, size_t) override
find method to get the index of float cell value in a table workspace
API::Column_sptr addColumn(const std::string &, const std::string &) override
Creates a new column.
std::shared_ptr< Mantid::API::Column > getColumn(const std::string &name) override
Gets the shared pointer to a column by name.
void find(size_t, size_t &, size_t) override
find method to get the index of integer cell value in a table workspace
Kernel::SpecialCoordinateSystem m_coordSystem
Coordinates.
std::unique_ptr< LeanElasticPeaksWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
std::vector< std::string > m_columnNames
Column names.
size_t columnCount() const override
Number of columns in the workspace.
bool addColumns(const std::string &, const std::string &, size_t) override
Creates n new columns of the same type.
void setRowCount(size_t) override
Resizes the workspace.
void find(double, size_t &, size_t) override
find method to get the index of double cell value in a table workspace
size_t rowCount() const override
Number of rows in the workspace.
void removeColumn(const std::string &) override
Removes a column.
std::vector< std::shared_ptr< Mantid::DataObjects::PeakColumn< LeanElasticPeak > > > m_columns
Column shared pointers.
std::vector< LeanElasticPeak > m_peaks
Vector of Peak contained within.
std::vector< std::string > getColumnNames() const override
Returns a vector of all column names.
void removeRow(size_t) override
Delets a row if it exists.
size_t insertRow(size_t) override
Inserts a row before row pointed to by index and fills it with default vales.
LeanElasticPeaksWorkspace & operator=(const LeanElasticPeaksWorkspace &other)=delete
const std::string id() const override
Return the workspace typeID.
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 Mantid::Kernel::V3D &, size_t &, size_t) override
find method to get the index of Mantid::Kernel::V3D cell value in a table workspace
bool threadSafe() const override
This is always threadsafe.
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< LeanElasticPeaksWorkspace > LeanElasticPeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< const LeanElasticPeaksWorkspace > LeanElasticPeaksWorkspace_const_sptr
Typedef for a shared pointer to a const peaks workspace.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
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