38 "Input Peaks Workspace");
40 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
41 mustBePositive->setLower(0.0);
45 "Indexing Tolerance (0.15)");
47 std::vector<double> identity_matrix(9, 0.0);
48 identity_matrix[0] = 1;
49 identity_matrix[4] = 1;
50 identity_matrix[8] = 1;
52 auto threeBythree = std::make_shared<ArrayLengthValidator<double> >(9);
55 std::make_unique<
ArrayProperty<double>>(
"HKLTransform", std::move(identity_matrix), std::move(threeBythree)),
56 "Specify 3x3 HKL transform matrix as a comma separated list of 9 "
60 "Whether to obtain the error in the lattice parameters. "
61 "Set this to false if there are not enough peaks to do an optimization");
64 "Gets set with the number of indexed peaks.");
67 "Gets set with the average HKL indexing error.");
75 throw std::runtime_error(
"Could not read the peaks workspace");
82 throw std::runtime_error(
"ERROR: The stored UB is not a valid orientation matrix");
85 std::vector<double> tran_vec =
getProperty(
"HKLTransform");
88 std::ostringstream str_stream;
89 str_stream << hkl_tran;
90 std::string hkl_tran_string = str_stream.
str();
91 g_log.
notice() <<
"Applying Tranformation " << hkl_tran_string <<
'\n';
94 throw std::runtime_error(
"ERROR: The specified transform must be a 3 X 3 matrix.\n" + hkl_tran_string);
98 double det = hkl_tran_inverse.
Invert();
100 if (
fabs(det) < 1.0e-5) {
101 throw std::runtime_error(
"ERROR: The specified matrix is invalid (essentially singular.)" + hkl_tran_string);
104 std::ostringstream error_stream;
105 error_stream << hkl_tran;
106 throw std::runtime_error(
"ERROR: The determinant of the matrix is negative.\n" + str_stream.str());
112 UB = UB * hkl_tran_inverse;
113 g_log.
notice() <<
"Transformed UB = " << UB <<
'\n';
122 std::vector<double> sigabc(6);
124 bool redetermine_error = this->
getProperty(
"FindError");
126 if (redetermine_error) {
128 o_lattice.
setError(sigabc[0], sigabc[1], sigabc[2], sigabc[3], sigabc[4], sigabc[5]);
130 o_lattice.
setError(0, 0, 0, 0, 0, 0);
133 ws->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>(o_lattice));
135 int n_peaks = ws->getNumberPeaks();
140 std::vector<V3D> miller_indices;
141 std::vector<V3D> q_vectors;
142 for (
int i = 0; i < n_peaks; i++) {
143 IPeak &peak = ws->getPeak(i);
147 miller_indices.emplace_back(hkl_tran * hkl - modHKL * peak.
getIntMNP());
148 peak.
setHKL(hkl_tran * hkl);
157 g_log.
notice() <<
"Transformed Miller indices on previously valid indexed Peaks.\n";
158 g_log.
notice() <<
"Set hkl to 0,0,0 on peaks previously indexed out of tolerance.\n";
159 g_log.
notice() <<
"Now, " << num_indexed <<
" are indexed with average error " << average_error <<
"\n";
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
A property class for workspaces.
Structure describing a single-crystal peak.
virtual void setHKL(double H, double K, double L)=0
virtual Mantid::Kernel::V3D getIntHKL() const =0
virtual Mantid::Kernel::V3D getQSampleFrame() const =0
virtual void setIntHKL(const Mantid::Kernel::V3D &HKL)=0
virtual Mantid::Kernel::V3D getHKL() const =0
virtual Mantid::Kernel::V3D getIntMNP() const =0
static double IndexingError(const Kernel::DblMatrix &UB, const std::vector< Kernel::V3D > &hkls, const std::vector< Kernel::V3D > &q_vectors)
Find the average indexing error for UB with the specified q's and hkls.
static bool CheckUB(const Kernel::DblMatrix &UB)
Check that the specified UB is reasonable for an orientation matrix.
Class to implement UB matrix.
void setUB(const Kernel::DblMatrix &newUB)
Sets the UB matrix and recalculates lattice parameters.
const Kernel::DblMatrix & getUB() const
Get the UB matrix.
const Kernel::DblMatrix & getModHKL() const
Get modulation vectors for satellites.
void setModHKL(double _dh1, double _dk1, double _dl1, double _dh2, double _dk2, double _dl2, double _dh3, double _dk3, double _dl3)
Set modulation vectors for satellites.
void setError(double _aerr, double _berr, double _cerr, double _alphaerr, double _betaerr, double _gammaerr, const int angleunit=angDegrees)
Set lattice parameter errors.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
T Invert()
LU inversion routine.
size_t numRows() const
Return the number of rows in the matrix.
size_t numCols() const
Return the number of columns in the matrix.
std::string str() const
Convert the matrix into a simple linear string expression.
The concrete, templated class for properties.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
@ InOut
Both an input & output workspace.
@ Input
An input workspace.
@ Output
An output workspace.