22#include <boost/lexical_cast.hpp>
33 std::string ERR =
"setDimName::Dimension index: " +
std::to_string(nDim) +
35 throw(std::invalid_argument(ERR));
45 std::string ERR =
"setDimUnit::Dimension index: " +
std::to_string(nDim) +
47 throw(std::invalid_argument(ERR));
67 const std::string &dEMode,
const std::vector<std::string> &dimPropertyNames) {
93 throw(std::invalid_argument(
" dimension limits vectors and dimension "
94 "description vectors inconsistent as have "
97 throw(std::invalid_argument(
" dimension limits vectors and dimension description vectors "
98 "inconsistent as have different length\n"
99 " Are you trying to add to existing workspace with convertToMD, "
100 "which generates workspace with different number of dimensions?"));
108 for (
unsigned int i = 0; i <
m_NDims; i++) {
109 if (i < nMatrixDim) {
114 m_DimIDs[i] = dimPropertyNames[i - nMatrixDim];
115 m_DimNames[i] = dimPropertyNames[i - nMatrixDim];
116 m_DimUnits[i] = dimPropertyNames[i - nMatrixDim];
124 if ((
m_InWS !=
nullptr) && (
m_InWS->run().getNumGoniometers() > 0))
125 return m_InWS->run().getGoniometer().isDefined();
133 return m_InWS->run().getGoniometer().getR();
143 m_NDims =
static_cast<unsigned int>(pWS->getNumDims());
152 for (
size_t i = 0; i <
m_NDims; i++) {
206 std::string ERR =
"Dimension numbers are inconsistent: this workspace has " +
std::to_string(
m_NDims) +
208 throw(std::invalid_argument(ERR));
212 throw(std::invalid_argument(
"Workspace description has not been correctly "
213 "defined, as emode has not been defined"));
236 : m_Wtransf(3, 3, true), m_RotMatrix(9, 0), m_buildingNewWorkspace(true), m_Emode(Kernel::
DeltaEMode::
Undefined),
237 m_LorentzCorr(false), m_AbsMin(0.), m_coordinateSystem(
Mantid::Kernel::
None) {
256 for (
size_t i = 0; i <
m_NDims; i++) {
269 if (!(nBins_toSplit.size() == 1 || nBins_toSplit.size() == this->m_NDims))
270 throw std::invalid_argument(
" Number of dimensions: " +
std::to_string(nBins_toSplit.size()) +
271 " defining number of bins to split into is not equal to total number "
277 bool propagateOneNum =
true;
278 if (nBins_toSplit.size() == this->m_NDims)
279 propagateOneNum =
false;
281 for (
size_t i = 0; i < this->
m_NDims; i++) {
283 this->
m_NBins[i] = nBins_toSplit[0];
285 this->
m_NBins[i] = nBins_toSplit[i];
295 m_DimMin.assign(minVal.begin(), minVal.end());
296 m_DimMax.assign(maxVal.begin(), maxVal.end());
311 return (this->
AlgID ==
"|Q|") || (this->
AlgID.empty() && !
m_InWS->sample().hasOrientedLattice());
330 const std::vector<std::string> &dimPropertyNames,
331 std::vector<coord_t> &AddCoord) {
332 size_t nDimPropNames = dimPropertyNames.size();
333 if (AddCoord.size() != nDimPropNames)
334 AddCoord.resize(nDimPropNames);
335 const auto &runObj = inWS2D->run();
337 for (
size_t i = 0; i < nDimPropNames; i++) {
341 }
catch (std::invalid_argument &) {
342 std::string ERR =
" Can not interpret property, used as dimension.\n Property: " + dimPropertyNames[i] +
343 " cannot be converted into a double.";
344 throw(std::invalid_argument(ERR));
353 if (minVal.size() != maxVal.size()) {
354 std::string ERR =
" number of specified min dimension values: " +
std::to_string(minVal.size()) +
355 " and number of max values: " +
std::to_string(maxVal.size()) +
" are not consistent\n";
356 throw(std::invalid_argument(ERR));
359 for (
size_t i = 0; i < minVal.size(); i++) {
360 if (maxVal[i] <= minVal[i]) {
361 std::string ERR =
" min value " + boost::lexical_cast<std::string>(minVal[i]) +
" not less then max value" +
362 boost::lexical_cast<std::string>(maxVal[i]) +
" in direction: " +
std::to_string(i) +
"\n";
363 throw(std::invalid_argument(ERR));
369std::shared_ptr<Geometry::OrientedLattice>
372 std::shared_ptr<Geometry::OrientedLattice> orl;
373 if (inWS2D->sample().hasOrientedLattice())
374 orl = std::shared_ptr<Geometry::OrientedLattice>(
double value
The value of the point.
The class describes one dimension of multidimensional dataset representing an orthogonal dimension an...
virtual coord_t getMaximum() const =0
virtual coord_t getMinimum() const =0
virtual std::string getName() const =0
virtual const Kernel::UnitLabel getUnits() const =0
virtual const std::string & getDimensionId() const =0
short name which identify the dimension among other dimension.
virtual size_t getNBins() const =0
Input argument type for MDFrameFactory chainable factory.
Class to implement UB matrix.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
The base units (abstract) class.
Interface to set of sub-classes used by ConvertToMD algorithm and responsible for conversion of input...
virtual std::vector< std::string > getDefaultDimID(Kernel::DeltaEMode::Type dEmode, API::MatrixWorkspace_const_sptr inWS) const =0
when one builds MD workspace, he needs a dimension names/ID-s which can be different for different Q-...
virtual std::vector< std::string > outputUnitID(Kernel::DeltaEMode::Type dEmode, API::MatrixWorkspace_const_sptr inWS) const =0
The transformation generates output MD events in particular units.
virtual unsigned int getNMatrixDimensions(Kernel::DeltaEMode::Type mode, API::MatrixWorkspace_const_sptr inWS) const =0
return the number of dimensions, calculated by the transformation from the workspace.
helper class describes the properties of target MD workspace, which should be obtained as the result ...
void setMinMax(const std::vector< double > &minVal, const std::vector< double > &maxVal)
function sets up min-max values to the dimensions, described by the class
void resizeDimDescriptions(unsigned int nDimensions, size_t nBins=10)
helper function to resize all vectors, responsible for MD dimensions in one go
bool isQ3DMode() const
Is the algorithm running in Q3D mode?
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
bool m_buildingNewWorkspace
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
void setDimName(unsigned int nDim, const std::string &Name)
set specific (non-default) dimension name
void setUpMissingParameters(const MDWSDescription &SourceMatrWS)
copy some parameters from the input workspace, as target md WS do not have all information about the ...
void setNumBins(const std::vector< int > &nBins_toSplit)
sets number of bins each dimension is split
static std::shared_ptr< Geometry::OrientedLattice > getOrientedLattice(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D)
function retrieves copy of the oriented lattice from the workspace
std::string m_frameKey
Frame key. For frame to use.
void setFrame(const std::string &frameKey)
Set the md frame.
Geometry::MDFrame_uptr getFrame(size_t d) const
Retrieve the md frame.
static void checkMinMaxNdimConsistent(const std::vector< double > &minVal, const std::vector< double > &maxVal)
helper function checks if min values are less them max values and are consistent between each other
Mantid::Kernel::SpecialCoordinateSystem m_coordinateSystem
Coordinate system.
Kernel::Matrix< double > getGoniometerMatr() const
method returns goniometer matrix if one is defined on the workspace or unit matrix if there are no su...
void setDimUnit(unsigned int nDim, const std::string &Unit)
this is rather misleading function, as MD workspace does not currently have dimension units.
bool hasGoniometer() const
Method checks if input workspace has defined goniometer.
void buildFromMDWS(const API::IMDEventWorkspace_const_sptr &pWS)
method builds MD Event description from existing MD event workspace
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::string getEModeStr() const
Returns symbolic representation of current Emode.
std::vector< size_t > m_NBins
if defined, specifies number of bins split in each dimension
std::vector< double > m_DimMax
std::string AlgID
the string which describes ChildAlgorithm, used to convert source ws to target MD ws.
Mantid::Kernel::SpecialCoordinateSystem getCoordinateSystem() const
unsigned int m_NDims
the variable which describes the number of the dimensions, in the target workspace.
void buildFromMatrixWS(const API::MatrixWorkspace_sptr &pWS, const std::string &QMode, const std::string &dEMode, const std::vector< std::string > &dimPropertyNames=std::vector< std::string >())
method builds MD Event ws description from a matrix workspace and the transformations,...
unsigned int nDimensions() const
void setWS(API::MatrixWorkspace_sptr otherMatrixWS)
void getMinMax(std::vector< double > &min, std::vector< double > &max) const
get vector of minimal and maximal values from the class
std::vector< double > m_DimMin
minimal and maximal values for the workspace dimensions.
Kernel::DblMatrix m_Wtransf
MDWSDescription(unsigned int nDimensions=0)
constructor
bool isPowder() const
Method checks if the workspace is expected to be processed in powder mode.
std::vector< std::string > m_DimIDs
the ID-s for the target workspace, which allow to identify the dimensions according to their ID
static void fillAddProperties(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D, const std::vector< std::string > &dimPropertyNames, std::vector< coord_t > &AddCoord)
function extracts the coordinates from additional workspace properties and places them to AddCoord ve...
API::MatrixWorkspace_sptr m_InWS
std::vector< double > m_RotMatrix
void checkWSCorresponsMDWorkspace(const MDWSDescription &NewMDWorkspaceD)
compare two descriptions and select the complimentary result.
void setCoordinateSystem(const Mantid::Kernel::SpecialCoordinateSystem system)
Set the special coordinate system if any.
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::unique_ptr< MDFrame > MDFrame_uptr
MDFrameFactory_uptr MANTID_GEOMETRY_DLL makeMDFrameFactoryChain()
Make a complete factory chain.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
Mantid::Kernel::Matrix< double > DblMatrix
Helper class which provides the Collimation Length for SANS instruments.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
std::string to_string(const wide_integer< Bits, Signed > &n)
Defines the possible energy transfer modes:
static std::string asString(const Type mode)
Return a string representation of the given mode.
static Type fromString(const std::string &modeStr)
Returns the emode from the given string.
@ Undefined
this mode should not be displayed among modes availible to select but may have string representation