37 throw(std::invalid_argument(
" MDTransfModQ::inputUnitID: this class "
38 "supports only conversion in Elastic and "
39 "Inelastic energy transfer modes"));
60 throw(std::invalid_argument(
"Unknown or unsupported energy conversion mode"));
80 double &ErrSq)
const {
105 " not equal to number of workspace dimensions: " +
std::to_string(nd);
106 throw(std::invalid_argument(ERR));
167 Coord[1] =
static_cast<coord_t>(deltaE);
170 double qx{0.0}, qy{0.0}, qz{0.0};
199 double qx = -
m_ex * k0;
200 double qy = -
m_ey * k0;
201 double qz = (1 -
m_ez) * k0;
216 std::vector<double> rez(2);
230 double eps_extr = ei * (1 - ez * ez);
231 if (eps_extr > eMin && eps_extr < eMax) {
243 throw std::invalid_argument(
"Undefined or unsupported energy conversion mode ");
259 throw(std::runtime_error(
"The detectors have not been preprocessed but "
260 "they have to before running initialize"));
280 "ModQ coordinate transformation: Min Q^2 value: " + boost::lexical_cast<std::string>(
m_DimMin[0]) +
281 " is more or equal then Max Q^2 value: " + boost::lexical_cast<std::string>(
m_DimMax[0]);
282 throw(std::invalid_argument(ERR));
291 volatile auto Ei = ConvParams.
m_PreprDetTable->getLogs()->getPropertyValueAsType<
double>(
"Ei");
308 throw(std::invalid_argument(
"MDTransfModQ::initialize::Unknown energy conversion mode"));
326 std::vector<std::string> default_dim_ID;
329 default_dim_ID.resize(1);
334 default_dim_ID.resize(2);
335 default_dim_ID[1] =
"DeltaE";
339 throw(std::invalid_argument(
"MDTransfModQ::getDefaultDimID::Unknown energy conversion mode"));
341 default_dim_ID[0] =
"|Q|";
343 return default_dim_ID;
359 UnitID[0] =
"Momentum";
361 UnitID[0] =
"MomentumTransfer";
368 : m_ex(0), m_ey(0), m_ez(1), m_DetDirecton(nullptr),
371 m_kFixed(1.), m_eFixed(1.), m_pEfixedArray(nullptr), m_pDetMasks(nullptr), m_invertRot(false) {}
392 setter(mdWorkspace, underlyingWorkspace, isQ,
m_Emode);
396 std::array<coord_t, 3> Q{};
407 const auto Qsq = Q[0] * Q[0] + Q[1] * Q[1] + Q[2] * Q[2];
411 Coord[0] =
static_cast<coord_t>(std::sqrt(Qsq));
420 Eigen::Map<const Eigen::Matrix<double, 3, 3, Eigen::RowMajor>> map_rm(
m_RotMat.data());
421 const Eigen::Vector3d qs(qx, qy, qz);
422 const Eigen::PartialPivLU<Eigen::Matrix<double, 3, 3, Eigen::RowMajor>> lu(map_rm);
423 Eigen::Vector3d coords = lu.solve(qs);
425 Coord[0] =
static_cast<coord_t>(coords[0]);
426 Coord[1] =
static_cast<coord_t>(coords[1]);
427 Coord[2] =
static_cast<coord_t>(coords[2]);
#define DECLARE_MD_TRANSFID(classname, regID)
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
DisplayNormalizationSetter: Sets the displaynormalization on a workspace based on several parameters ...
Class responsible for conversion of input workspace data into proper number of output dimensions for ...
void setDisplayNormalization(Mantid::API::IMDWorkspace_sptr mdWorkspace, Mantid::API::MatrixWorkspace_sptr underlyingWorkspace) const override
Set the display normalization for Q.
bool calcGenericVariables(std::vector< coord_t > &Coord, size_t nd) override
Method fills-in all additional properties requested by user and not defined by matrix workspace itsel...
MDTransfModQ()
constructor;
bool calcMatrixCoordInelastic(const double deltaE, std::vector< coord_t > &Coord) const
how to transform workspace data in inelastic case
std::vector< double > m_RotMat
Kernel::V3D const * m_DetDirecton
unsigned int m_NMatrixDim
bool applyCoordTransf(double qx, double qy, double qz, std::vector< coord_t > &Coord) const
bool calcMatrixCoordElastic(const double k0, std::vector< coord_t > &Coord) const
how to transform workspace data in elastic case
bool calcMatrixCoord(const double &deltaEOrK0, std::vector< coord_t > &Coord, double &signal, double &ErrSq) const override
Convert single point of matrix workspace into reciprocal space and (optionally) modify signal and err...
void calcMatrixCoordLinSys(double qx, double qy, double qz, std::array< coord_t, 3 > &Coord) const
std::vector< double > m_DimMin
unsigned int getNMatrixDimensions(Kernel::DeltaEMode::Type mode, API::MatrixWorkspace_const_sptr inWS=API::MatrixWorkspace_const_sptr()) const override
return the number of dimensions, calculated by the transformation from the workspace.
std::vector< double > m_DimMax
Kernel::DeltaEMode::Type m_Emode
std::vector< std::string > getEmodes() const override
energy conversion modes supported by this class; The class supports three standard energy conversion ...
std::vector< std::string > outputUnitID(Kernel::DeltaEMode::Type dEmode, API::MatrixWorkspace_const_sptr inWS=API::MatrixWorkspace_const_sptr()) const override
function returns units ID-s which this transformation prodiuces its ouptut.
std::vector< coord_t > m_AddDimCoordinates
the vector of the additional coordinates which define additional MD dimensions.
std::vector< std::string > getDefaultDimID(Kernel::DeltaEMode::Type dEmode, API::MatrixWorkspace_const_sptr inWS=API::MatrixWorkspace_const_sptr()) const override
the default dimID-s in ModQ mode are |Q| and dE if necessary
void initialize(const MDWSDescription &ConvParams) override
function initializes all variables necessary for converting workspace variables into MD variables in ...
std::vector< double > getExtremumPoints(const double eMin, const double eMax, size_t det_num) const override
method returns the vector of input coordinates values where the transformed coordinates reach its ext...
bool calcYDepCoordinates(std::vector< coord_t > &Coord, size_t i) override
Method updates the value of pre-processed detector coordinates in Q-space, used by other functions.
std::pair< coord_t, coord_t > getDimBounds(size_t dim) const override
helper class describes the properties of target MD workspace, which should be obtained as the result ...
Kernel::DeltaEMode::Type getEMode() const
std::vector< coord_t > getAddCoord() const
void getMinMax(std::vector< double > &min, std::vector< double > &max) const
get vector of minimal and maximal values from the class
DataObjects::TableWorkspace_const_sptr m_PreprDetTable
std::vector< double > getTransfMatrix() const
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
static constexpr double E_mev_toNeutronWavenumberSq
Transformation coefficient to transform neutron energy into neutron wavevector: K-neutron[m^-10] = sq...
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 const std::vector< std::string > availableTypes()
Returns the string list of available modes.
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...