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"
17#include "MantidKernel/V3D.h"
18
19// IsamplePosition should be IsampleOrientation
20namespace Mantid {
21//----------------------------------------------------------------------
22// Forward declarations
23//----------------------------------------------------------------------
24namespace Kernel {
25class Logger;
26}
27
28namespace DataObjects {
29//==========================================================================================
38class MANTID_DATAOBJECTS_DLL LeanElasticPeaksWorkspace : public Mantid::API::IPeaksWorkspace {
39public:
40 using ColumnAndDirection = std::pair<std::string, bool>;
41
42public:
43 const std::string id() const override { return "LeanElasticPeaksWorkspace"; }
44
47
58 API::LogManager_sptr logs() override;
59 API::LogManager_const_sptr getLogs() const override;
60
62 std::unique_ptr<LeanElasticPeaksWorkspace> clone() const {
63 return std::unique_ptr<LeanElasticPeaksWorkspace>(doClone());
64 }
65
67 std::unique_ptr<LeanElasticPeaksWorkspace> cloneEmpty() const {
68 return std::unique_ptr<LeanElasticPeaksWorkspace>(doCloneEmpty());
69 }
70
71 void appendFile(std::string filename, Geometry::Instrument_sptr inst);
72
75 bool customSort() const override { return true; }
76
77 void sort(std::vector<ColumnAndDirection> &criteria) override;
78
79 int getNumberPeaks() const override;
80 std::string getConvention() const override;
81 void removePeak(int peakNum) override;
82 void removePeaks(std::vector<int> badPeaks) override;
83 void addPeak(const Geometry::IPeak &peak) override;
85 void addPeak(LeanElasticPeak &&peak);
86 void addPeak(const Kernel::V3D &position, const Kernel::SpecialCoordinateSystem &frame) override;
87 LeanElasticPeak &getPeak(size_t const peakNum) override;
88 const LeanElasticPeak &getPeak(size_t const peakNum) const override;
89
90 std::unique_ptr<Geometry::IPeak> createPeak(const Kernel::V3D &QLabFrame,
91 std::optional<double> detectorDistance = std::nullopt) const override;
92
93 std::unique_ptr<Geometry::IPeak> createPeak(const Kernel::V3D &Position,
94 const Kernel::SpecialCoordinateSystem &frame) const override;
95
96 std::unique_ptr<Geometry::IPeak> createPeakQSample(const Kernel::V3D &position) const override;
97
98 std::vector<std::pair<std::string, std::string>> peakInfo(const Kernel::V3D &qFrame, bool labCoords) const override;
99
100 std::unique_ptr<Geometry::IPeak> createPeakHKL(const Kernel::V3D &HKL) const override;
101
102 std::unique_ptr<Geometry::IPeak> createPeak() const override;
103
104 int peakInfoNumber(const Kernel::V3D &qFrame, bool labCoords) const override;
105
106 std::vector<LeanElasticPeak> &getPeaks();
107 const std::vector<LeanElasticPeak> &getPeaks() const;
108 bool hasIntegratedPeaks() const override;
109 size_t getMemorySize() const override;
110
114 API::ITableWorkspace_sptr createDetectorTable() const override;
115
117 void setCoordinateSystem(const Kernel::SpecialCoordinateSystem coordinateSystem) override;
118
120 Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override;
121
122 // ====================================== ITableWorkspace Methods
123 // ==================================
125 size_t columnCount() const override { return static_cast<int>(m_columns.size()); }
126
128 size_t rowCount() const override { return getNumberPeaks(); }
129
131 std::shared_ptr<Mantid::API::Column> getColumn(const std::string &name) override {
132 return getColumn(getColumnIndex(name));
133 }
134
136 std::shared_ptr<const Mantid::API::Column> getColumn(const std::string &name) const override {
137 return getColumn(getColumnIndex(name));
138 }
139
141 virtual size_t getColumnIndex(const std::string &name) const;
142
144 std::shared_ptr<Mantid::API::Column> getColumn(size_t index) override;
145
148 API::Column_const_sptr getColumn(size_t index) const override;
149 // ====================================== End ITableWorkspace Methods
150 // ==================================
151
152 //---------------------------------------------------------------------------------------------
154 std::vector<std::string> getColumnNames() const override { return this->m_columnNames; }
156 bool threadSafe() const override { return true; }
157
158 // --- Nexus Methods ---
159 // Save to Nexus
160 void saveNexus(Nexus::File *file) const override;
161
162protected:
165
166private:
167 LeanElasticPeaksWorkspace *doClone() const override { return new LeanElasticPeaksWorkspace(*this); }
169 ITableWorkspace *doCloneColumns(const std::vector<std::string> &colNames) const override;
170
172 void initColumns();
174 void addPeakColumn(const std::string &name);
175
176 // ====================================== ITableWorkspace Methods
177 // ==================================
178
179 // ===== Methods that are not implemented (read-only table) ==========
180 API::Column_sptr addColumn(const std::string & /*type*/, const std::string & /*name*/) override {
182 "LeanElasticPeaksWorkspace structure is read-only. Cannot add column.");
183 }
184
185 bool addColumns(const std::string & /*type*/, const std::string & /*name*/, size_t /*n*/) override {
186 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace structure is read-only. Cannot add "
187 "columns.");
188 }
189
190 void removeColumn(const std::string & /*name*/) override {
192 "LeanElasticPeaksWorkspace structure is read-only. Cannot remove "
193 "column.");
194 }
195
196 void setRowCount(size_t /*count*/) override {
198 "LeanElasticPeaksWorkspace structure is read-only. Cannot setRowCount");
199 }
200
201 size_t insertRow(size_t /*index*/) override {
203 "LeanElasticPeaksWorkspace structure is read-only. Cannot insertRow");
204 }
205
206 void removeRow(size_t /*index*/) override {
208 "LeanElasticPeaksWorkspace structure is read-only. Cannot removeRow.");
209 }
210
212 void find(size_t /*value*/, size_t & /*row*/, size_t /*col*/) override {
213 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
214 }
216 void find(double /*value*/, size_t & /*row*/, size_t /*col*/) override {
217 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
218 }
220 void find(float /*value*/, size_t & /*row*/, size_t /*col*/) override {
221 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
222 }
225 void find(API::Boolean /*value*/, size_t & /*row*/, size_t /*col*/) override {
226 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
227 }
230 void find(const std::string & /*value*/, size_t & /*row*/, size_t /*col*/) override {
231 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
232 }
235 void find(const Mantid::Kernel::V3D & /*value*/, size_t & /*row*/, size_t /*col*/) override {
236 throw Mantid::Kernel::Exception::NotImplementedError("LeanElasticPeaksWorkspace::find() not implemented.");
237 }
238
239 // ====================================== End ITableWorkspace Methods
240 // ==================================
241
243 std::vector<LeanElasticPeak> m_peaks;
244
246 std::vector<std::shared_ptr<Mantid::DataObjects::PeakColumn<LeanElasticPeak>>> m_columns;
247
249 std::vector<std::string> m_columnNames;
250
253};
254
256using LeanElasticPeaksWorkspace_sptr = std::shared_ptr<LeanElasticPeaksWorkspace>;
257
259using LeanElasticPeaksWorkspace_const_sptr = std::shared_ptr<const LeanElasticPeaksWorkspace>;
260} // namespace DataObjects
261} // namespace Mantid
262
263// Instantiated and exported by DataObjects/src/PropertyWithValue.cpp
265 Mantid::Kernel::PropertyWithValue<std::shared_ptr<Mantid::DataObjects::LeanElasticPeaksWorkspace>>);
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::LeanElasticPeaksWorkspace > >)
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: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< 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:210