Skip to content

Commit

Permalink
RE 7248_MantidEV_show_distance_between_last_points_picked
Browse files Browse the repository at this point in the history
The getUB() method of MantidEVWorker now includes a parameter
indicating whether or not the UB should be converted to
lab coordinates.  If lab_coords is true, the goniometer
rotation matrix is obtained from the first peak in the
peaks workspace and is multiplied times UB to get a UB
in lab_coordinates.

refs #7248
  • Loading branch information
DennisMikkelson committed Jun 11, 2013
1 parent 1f21e02 commit fa9f48d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ class DLLExport MantidEVWorker
/// Display UB and lattice parameters in MantidPlot
bool showUB( const std::string & peaks_ws_name );

/// Get the current UB matrix from the peaks workspace
/// Get the current UB matrix from the peaks workspace in sample or lab coords
bool getUB( const std::string & peaks_ws_name,
bool lab_coords,
Mantid::Kernel::Matrix<double> & UB );

/// Get Info about a Q-Vector from a PeaksWorkspace
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MantidEV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,8 @@ void MantidEV::showInfo( bool lab_coords, Mantid::Kernel::V3D q_point )
info.push_back( Q_dist_str );

Mantid::Kernel::Matrix<double> UB(3,3,false);
if ( worker->getUB( peaks_ws_name, UB ) ) // if the peaks workspace has a UB, also find the
{ // distance between points in HKL.
if ( worker->getUB( peaks_ws_name, lab_coords, UB ) ) // if the peaks workspace has a UB, also find the
{ // distance between points in HKL.
Mantid::Kernel::Matrix<double> UBinv( UB );
UBinv.Invert();
Mantid::Kernel::V3D hkl_1 = UBinv * last_Q;
Expand Down
15 changes: 15 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MantidEVWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidDataObjects/Peak.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include <exception>

Expand Down Expand Up @@ -947,13 +948,19 @@ bool MantidEVWorker::showUB( const std::string & peaks_ws_name )
*
* @param peaks_ws_name The name of the peaks workspace with the UB
* matrix.
* @param lab_coords If true, multiply the goniometer matrix
* times UB before returning it, so that
* the UB is expressed in lab-coordinates,
* otherwise, return the UB as it is stored
* in the sample.
* @param UB 3x3 matrix of doubles to be filled out with
* the UB matrix if one exists in the specified
* peaks workspace.
* @return true if the UB matrix was found and returned in the UB
* parameter.
*/
bool MantidEVWorker::getUB( const std::string & peaks_ws_name,
bool lab_coords,
Mantid::Kernel::Matrix<double> & UB )
{
if ( !isPeaksWorkspace( peaks_ws_name ) )
Expand All @@ -968,6 +975,14 @@ bool MantidEVWorker::getUB( const std::string & peaks_ws_name,
{
Mantid::Geometry::OrientedLattice o_lattice = peaks_ws->mutableSample().getOrientedLattice();
UB = o_lattice.getUB();

if ( lab_coords ) // Try to get goniometer matrix from first peak
{ // and adjust UB for goniometer rotation
Mantid::DataObjects::Peak peak = Mantid::DataObjects::Peak(peaks_ws->getPeak(0));
Mantid::Kernel::Matrix<double> goniometer_matrix(3, 3, true);
goniometer_matrix = peak.getGoniometerMatrix();
UB = goniometer_matrix * UB;
}
}
catch(...)
{
Expand Down

0 comments on commit fa9f48d

Please sign in to comment.