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 http://www.mantidproject.org/Writing_custom_ConvertTo_MD_transformation
40 for detailed description of this
41 * class place in the algorithms hierarchy.
42 *
43
44 @date 2011-28-12
45*/
46
49class MANTID_MDALGORITHMS_DLL MDWSDescription : public API::LogManager {
50public: // for the time being
53 std::string AlgID;
54 // the matrix which describes target coordinate system of the workspace and
55 // connected with convert_to_factor;
57 // the vector which represent linear form of momentum transformation
58 std::vector<double> m_RotMatrix;
59
60 // preprocessed detectors workspace:
62 // helper parameter, which identifies if we are building new workspace or
63 // adding data to the existing one. Allows to generate clearer error messages
65 //=======================
66 /*---> accessors: */
67 unsigned int nDimensions() const { return m_NDims; }
68
69 std::vector<std::string> getDimNames() const { return m_DimNames; }
70 std::vector<std::string> getDimIDs() const { return m_DimIDs; }
71 std::vector<std::string> getDimUnits() const { return m_DimUnits; }
72 std::vector<double> getDimMin() const { return m_DimMin; }
73 std::vector<double> getDimMax() const { return m_DimMax; }
74 std::vector<size_t> getNBins() const { return m_NBins; }
75 std::vector<coord_t> getAddCoord() const { return m_AddCoord; }
76 std::string getEModeStr() const;
77 Kernel::DeltaEMode::Type getEMode() const { return m_Emode; }
78 std::string getQMode() const { return AlgID; }
79
81 bool isLorentsCorrections() const { return m_LorentzCorr; }
82 double absMin() const { return m_AbsMin; }
83 void getMinMax(std::vector<double> &min, std::vector<double> &max) const;
84 std::vector<double> getTransfMatrix() const { return m_RotMatrix; }
85
86 // workspace related helper functions, providing access to various workspace
87 // functions
88 API::MatrixWorkspace_const_sptr getInWS() const { return m_InWS; }
89 void setWS(API::MatrixWorkspace_sptr otherMatrixWS);
90 const std::string &getWSName() const { return m_InWS->getName(); }
91 bool isPowder() const;
92 bool isQ3DMode() const;
93 bool hasLattice() const;
94
95 std::shared_ptr<Geometry::OrientedLattice> getLattice() const { return getOrientedLattice(m_InWS); }
96 Kernel::Matrix<double> getGoniometerMatr() const;
97 bool hasGoniometer() const;
98
100 MDWSDescription(unsigned int nDimensions = 0);
101
103 void buildFromMDWS(const API::IMDEventWorkspace_const_sptr &pWS);
106 void setUpMissingParameters(const MDWSDescription &SourceMatrWS);
107
110 void buildFromMatrixWS(const API::MatrixWorkspace_sptr &pWS, const std::string &QMode, const std::string &dEMode,
111 const std::vector<std::string> &dimPropertyNames = std::vector<std::string>());
112
114 void checkWSCorresponsMDWorkspace(const MDWSDescription &NewMDWorkspaceD);
115
116 void setMinMax(const std::vector<double> &minVal, const std::vector<double> &maxVal);
117 void setDimName(unsigned int nDim, const std::string &Name);
118 // this is rather misleading function, as MD workspace do not have dimension
119 // units
120 void setDimUnit(unsigned int nDim, const std::string &Unit);
122 void setLorentsCorr(bool On = false) { m_LorentzCorr = On; }
123 void setAbsMin(double absMin) { m_AbsMin = absMin; }
124 // static helper functions:
127 static void checkMinMaxNdimConsistent(const std::vector<double> &minVal, const std::vector<double> &maxVal);
130 static void fillAddProperties(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D,
131 const std::vector<std::string> &dimPropertyNames, std::vector<coord_t> &AddCoord);
132
133 static std::shared_ptr<Geometry::OrientedLattice>
134 getOrientedLattice(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D);
135
137 void setCoordinateSystem(const Mantid::Kernel::SpecialCoordinateSystem system);
139 Mantid::Kernel::SpecialCoordinateSystem getCoordinateSystem() const;
141 void setFrame(const std::string &frameKey);
143 Geometry::MDFrame_uptr getFrame(size_t d) const;
144
146 void setNumBins(const std::vector<int> &nBins_toSplit);
147
148protected: // until MDWSDesctiptionDepricatedExist
153 unsigned int m_NDims;
154 // shared pointer to the source matrix workspace
161 double m_AbsMin;
164 std::vector<coord_t> m_AddCoord;
167 std::vector<std::string> m_DimNames;
170 std::vector<std::string> m_DimIDs;
173 std::vector<std::string> m_DimUnits;
175 std::vector<size_t> m_NBins;
178 std::vector<double> m_DimMin, m_DimMax;
179 //********************* internal helpers
182 void resizeDimDescriptions(unsigned int nDimensions, size_t nBins = 10);
183
184private:
188 std::string m_frameKey;
189};
190} // namespace MDAlgorithms
191} // 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
API::MatrixWorkspace_sptr m_InWS
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