22Kernel::Logger g_Log(
"MDWSTransform");
24using namespace CnvrtToMD;
52 const std::string &FrameRequested,
53 const std::string &QScaleRequested)
const {
56 std::vector<double> transf =
getTransfMatrix(TargWSDescription, FrameID, ScaleID);
75 bool hasLattice = TargWSDescription.
hasLattice();
97 switch (CoordFrameID) {
102 throw std::invalid_argument(
" Sample frame needs goniometer to be defined on the workspace ");
106 throw std::invalid_argument(
" HKL frame needs UB matrix defined on the workspace ");
108 g_Log.warning() <<
" HKL frame does not have goniometer defined on the "
109 "workspace. Assuming unit goniometer matrix\n";
112 throw std::runtime_error(
" Unexpected argument in MDWSTransform::checkTargetFrame");
121 bool powderMode = TargWSDescription.
isPowder();
122 bool has_lattice(
true);
126 if (!(powderMode || has_lattice)) {
127 const std::string &inWsName = TargWSDescription.
getWSName();
129 g_Log.information() <<
"Can not obtain transformation matrix from the input workspace: " << inWsName
130 <<
" as no oriented lattice has been defined. \n"
131 "Will use unit transformation matrix.\n";
140 switch (CoordFrameID) {
166 throw(std::invalid_argument(
" Unknown or undefined Target Frame ID"));
172 std::vector<double> rotMat = mat.
getVector();
173 g_Log.debug() <<
" *********** Q-transformation matrix ***********************\n";
174 g_Log.debug() <<
"*** *qx ! *qy ! *qz !\n";
175 g_Log.debug() <<
"q1= " << rotMat[0] <<
" ! " << rotMat[1] <<
" ! " << rotMat[2] <<
" !\n";
176 g_Log.debug() <<
"q2= " << rotMat[3] <<
" ! " << rotMat[4] <<
" ! " << rotMat[5] <<
" !\n";
177 g_Log.debug() <<
"q3= " << rotMat[6] <<
" ! " << rotMat[7] <<
" ! " << rotMat[8] <<
" !\n";
178 g_Log.debug() <<
" *********** *********************** ***********************\n";
188 if (!(TargWSDescription.
hasLattice() || UnitUB)) {
189 throw(std::invalid_argument(
"this function should be called only on "
190 "workspace with defined oriented lattice"));
208 std::vector<Kernel::V3D> dim_directions;
209 std::vector<Kernel::V3D> uv(2);
213 for (
size_t i = 0; i < 3; ++i)
214 for (
size_t j = 0; j < 3; ++j)
215 Wmat[i][j] = dim_directions[j][i];
220 std::shared_ptr<Geometry::OrientedLattice> spLatt;
229 Transf = spLatt->getU();
235 double dMax(-1.e+32);
236 for (
int i = 0; i < 3; i++)
237 dMax = (dMax > spLatt->a(i)) ? (dMax) : (spLatt->a(i));
238 for (
int i = 0; i < 3; i++)
239 Scale[i][i] = (2 * M_PI) / dMax;
240 Transf = spLatt->getU();
248 for (
int i = 0; i < 3; i++) {
249 Scale[i][i] = (2 * M_PI) / spLatt->a(i);
251 Transf = spLatt->getU();
258 Scale = spLatt->getUB() * (2 * M_PI);
263 throw(std::invalid_argument(
"unrecognized conversion mode"));
266 return Transf * Scale * Wmat;
280 std::vector<Kernel::V3D> dimDirections;
282 std::vector<std::string> dimNames = TargWSDescription.
getDimNames();
287 std::vector<double> LatPar(3, 1);
293 for (
int i = 0; i < 3; i++)
294 LatPar[i] = spLatt->a(i);
301 dimNames[0] =
"Q_lab_x";
302 dimNames[1] =
"Q_lab_y";
303 dimNames[2] =
"Q_lab_z";
309 dimNames[0] =
"Q_sample_x";
310 dimNames[1] =
"Q_sample_y";
311 dimNames[2] =
"Q_sample_z";
326 throw(std::invalid_argument(
" Unknown or undefined Target Frame ID"));
329 dimDirections.resize(3);
334 std::vector<Kernel::V3D> uv(2);
341 for (
int i = 0; i < 3; i++)
344 for (
int i = 0; i < 3; i++)
348 for (
int i = 0; i < 3; i++)
352 double dMax(-1.e+32);
353 for (
int i = 0; i < 3; i++)
354 dMax = (dMax > LatPar[i]) ? (dMax) : (LatPar[i]);
355 for (
int i = 0; i < 3; i++)
360 std::vector<double> len;
362 x = Bm * dimDirections[0];
363 len.emplace_back(2 * M_PI *
x.norm());
364 x = Bm * dimDirections[1];
365 len.emplace_back(2 * M_PI *
x.norm());
366 x = Bm * dimDirections[2];
367 len.emplace_back(2 * M_PI *
x.norm());
368 for (
int i = 0; i < 3; i++)
374 const std::string &QScaleRequested)
const {
387 if (vect.size() == 3) {
390 g_Log.warning() << message;
397 const std::vector<double> &wt) {
399 bool u_default(
true), v_default(
true), w_default(
true);
401 u_default =
v3DIsDefault(ut,
" u projection vector specified but its dimensions are "
402 "not equal to 3, using default values [1,0,0]\n");
403 v_default =
v3DIsDefault(vt,
" v projection vector specified but its dimensions are "
404 "not equal to 3, using default values [0,1,0]\n");
405 w_default =
v3DIsDefault(wt,
" w projection vector specified but its dimensions are "
406 "not equal to 3, using default values [0,0,1]\n");
434 throw std::invalid_argument(
"Projections are coplanar");
443 throw(std::invalid_argument(
" The Q scale with ID: " + ScID +
" is unavailable"));
457 throw(std::invalid_argument(
" The Target Frame with ID: " + FrameID +
" is unavailable"));
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
static const std::string HKLName
Class to implement UB matrix.
static const std::string QLabName
static const std::string QSampleName
T Invert()
LU inversion routine.
std::vector< T > getVector() const
static std::vector< V3D > makeVectorsOrthogonal(const std::vector< V3D > &vectors)
Take a list of 2 vectors and makes a 3D orthogonal system out of them The first vector i0 is taken as...
constexpr V3D cross_prod(const V3D &v) const noexcept
Cross product (this * argument)
helper class describes the properties of target MD workspace, which should be obtained as the result ...
std::shared_ptr< Geometry::OrientedLattice > getLattice() const
bool isQ3DMode() const
Is the algorithm running in Q3D mode?
void setDimName(unsigned int nDim, const std::string &Name)
set specific (non-default) dimension name
void setFrame(const std::string &frameKey)
Set the md frame.
std::vector< std::string > getDimNames() const
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.
const std::string & getWSName() const
Kernel::DblMatrix m_Wtransf
bool isPowder() const
Method checks if the workspace is expected to be processed in powder mode.
void setCoordinateSystem(const Mantid::Kernel::SpecialCoordinateSystem system)
Set the special coordinate system if any.
MANTID_KERNEL_DLL int isMember(const std::vector< std::string > &group, const std::string &candidate)
checks if the candidate is the member of the group
constexpr double Tolerance
Standard tolerance value.
TargetFrame
enum describes availible target coordinate systems for Q3D mode
CoordScaling
enum descrines availble momentum scalings, interpreted by this class
std::string DLLExport sprintfd(const double data, const double eps)
creates string representation of the number with accuracy, cpecified by eps
std::string DLLExport makeAxisName(const Kernel::V3D &Dir, const std::vector< std::string > &QNames)
function to build mslice-like axis name from the vector, which describes crystallographic direction a...