Mantid
Loading...
Searching...
No Matches
MDWSDescription.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 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
12
15
16#include "MantidKernel/Logger.h"
20
23
24#include "MantidMDAlgorithms/DllConfig.h"
25
26namespace Mantid {
27namespace MDAlgorithms {
28/*** Class wrapping together all parameters, related to conversion from a
29 workspace to MDEventoWorkspace
30 *
31 * used to provide common interface for subclasses, dealing with creation of
32 MD workspace and conversion of
33 * ws data into DataObjects
34 *
35 * It also defines some auxiliary functions, used for convenient description
36 of MD workspace
37 *
38 *
39 * See dev-docs/source/WritingCustomConvertToMDTransformation.rst for detailed description of this
40 * class place in the algorithms hierarchy.
41*/
42
45class MANTID_MDALGORITHMS_DLL MDWSDescription : public API::LogManager {
46public: // for the time being
49 std::string AlgID;
50 // the matrix which describes target coordinate system of the workspace and
51 // connected with convert_to_factor;
53 // the vector which represent linear form of momentum transformation
54 std::vector<double> m_RotMatrix;
55
56 // preprocessed detectors workspace:
58 // helper parameter, which identifies if we are building new workspace or
59 // adding data to the existing one. Allows to generate clearer error messages
61 //=======================
62 /*---> accessors: */
63 unsigned int nDimensions() const { return m_NDims; }
64
65 std::vector<std::string> getDimNames() const { return m_DimNames; }
66 std::vector<std::string> getDimIDs() const { return m_DimIDs; }
67 std::vector<std::string> getDimUnits() const { return m_DimUnits; }
68 std::vector<double> getDimMin() const { return m_DimMin; }
69 std::vector<double> getDimMax() const { return m_DimMax; }
70 std::vector<size_t> getNBins() const { return m_NBins; }
71 std::vector<coord_t> getAddCoord() const { return m_AddCoord; }
72 std::string getEModeStr() const;
73 Kernel::DeltaEMode::Type getEMode() const { return m_Emode; }
74 std::string getQMode() const { return AlgID; }
75
77 bool isLorentsCorrections() const { return m_LorentzCorr; }
78 double absMin() const { return m_AbsMin; }
79 void getMinMax(std::vector<double> &min, std::vector<double> &max) const;
80 std::vector<double> getTransfMatrix() const { return m_RotMatrix; }
81
82 // workspace related helper functions, providing access to various workspace
83 // functions
84 API::MatrixWorkspace_const_sptr getInWS() const { return m_InWS; }
85 void setWS(API::MatrixWorkspace_sptr otherMatrixWS);
86 const std::string &getWSName() const { return m_InWS->getName(); }
87 bool isPowder() const;
88 bool isQ3DMode() const;
89 bool hasLattice() const;
90
91 std::shared_ptr<Geometry::OrientedLattice> getLattice() const { return getOrientedLattice(m_InWS); }
92 Kernel::Matrix<double> getGoniometerMatr() const;
93 bool hasGoniometer() const;
94
96 MDWSDescription(unsigned int nDimensions = 0);
97
99 void buildFromMDWS(const API::IMDEventWorkspace_const_sptr &pWS);
102 void setUpMissingParameters(const MDWSDescription &SourceMatrWS);
103
106 void buildFromMatrixWS(const API::MatrixWorkspace_sptr &pWS, const std::string &QMode, const std::string &dEMode,
107 const std::vector<std::string> &dimPropertyNames = std::vector<std::string>());
108
110 void checkWSCorresponsMDWorkspace(const MDWSDescription &NewMDWorkspaceD);
111
112 void setMinMax(const std::vector<double> &minVal, const std::vector<double> &maxVal);
113 void setDimName(unsigned int nDim, const std::string &Name);
114 // this is rather misleading function, as MD workspace do not have dimension
115 // units
116 void setDimUnit(unsigned int nDim, const std::string &Unit);
118 void setLorentsCorr(bool On = false) { m_LorentzCorr = On; }
119 void setAbsMin(double absMin) { m_AbsMin = absMin; }
120 // static helper functions:
123 static void checkMinMaxNdimConsistent(const std::vector<double> &minVal, const std::vector<double> &maxVal);
126 static void fillAddProperties(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D,
127 const std::vector<std::string> &dimPropertyNames, std::vector<coord_t> &AddCoord);
128
129 static std::shared_ptr<Geometry::OrientedLattice>
130 getOrientedLattice(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D);
131
133 void setCoordinateSystem(const Mantid::Kernel::SpecialCoordinateSystem system);
135 Mantid::Kernel::SpecialCoordinateSystem getCoordinateSystem() const;
137 void setFrame(const std::string &frameKey);
139 Geometry::MDFrame_uptr getFrame(size_t d) const;
140
142 void setNumBins(const std::vector<int> &nBins_toSplit);
143
144protected: // until MDWSDesctiptionDepricatedExist
149 unsigned int m_NDims;
150 // shared pointer to the source matrix workspace
157 double m_AbsMin;
160 std::vector<coord_t> m_AddCoord;
163 std::vector<std::string> m_DimNames;
166 std::vector<std::string> m_DimIDs;
169 std::vector<std::string> m_DimUnits;
171 std::vector<size_t> m_NBins;
174 std::vector<double> m_DimMin, m_DimMax;
175 //********************* internal helpers
178 void resizeDimDescriptions(unsigned int nDimensions, size_t nBins = 10);
179
180private:
184 std::string m_frameKey;
185};
186} // namespace MDAlgorithms
187} // namespace Mantid
This class contains the information about the log entries.
Definition LogManager.h:44
The base units (abstract) class.
Definition Unit.h:41
helper class describes the properties of target MD workspace, which should be obtained as the result ...
std::shared_ptr< Geometry::OrientedLattice > getLattice() const
double m_AbsMin
hole near origin of Q
std::vector< std::string > m_DimNames
the names for the target workspace dimensions and properties of input MD workspace
Kernel::DeltaEMode::Type m_Emode
energy transfer analysis mode
std::vector< std::string > m_DimUnits
the units of target workspace dimensions and properties of input MD workspace dimensions
std::vector< std::string > getDimIDs() const
std::string m_frameKey
Frame key. For frame to use.
API::MatrixWorkspace_const_sptr getInWS() const
Mantid::Kernel::SpecialCoordinateSystem m_coordinateSystem
Coordinate system.
std::vector< std::string > getDimNames() const
bool isLorentsCorrections() const
check if one needs to perform Lorentz corrections
std::vector< size_t > getNBins() const
std::vector< coord_t > m_AddCoord
the vector of MD coordinates, which are obtained from workspace properties.
bool m_LorentzCorr
if one needs to calculate Lorentz corrections
std::vector< size_t > m_NBins
if defined, specifies number of bins split in each dimension
std::string AlgID
the string which describes ChildAlgorithm, used to convert source ws to target MD ws.
std::vector< std::string > getDimUnits() const
unsigned int m_NDims
the variable which describes the number of the dimensions, in the target workspace.
Kernel::DeltaEMode::Type getEMode() const
std::vector< coord_t > getAddCoord() const
const std::string & getWSName() const
std::vector< double > getDimMin() const
std::vector< std::string > m_DimIDs
the ID-s for the target workspace, which allow to identify the dimensions according to their ID
DataObjects::TableWorkspace_const_sptr m_PreprDetTable
void setLorentsCorr(bool On=false)
do we need to perform Lorentz corrections
std::vector< double > getTransfMatrix() const
std::vector< double > getDimMax() const
std::shared_ptr< const IMDEventWorkspace > IMDEventWorkspace_const_sptr
Shared pointer to Mantid::API::IMDEventWorkspace (const version)
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const TableWorkspace > TableWorkspace_const_sptr
shared pointer to Mantid::DataObjects::TableWorkspace (const version)
std::unique_ptr< MDFrame > MDFrame_uptr
Definition MDFrame.h:36
SpecialCoordinateSystem
Special coordinate systems for Q3D.
Helper class which provides the Collimation Length for SANS instruments.
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...
Definition DeltaEMode.h:29