34 "Input Peaks Workspace");
36 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
37 mustBePositive->setLower(0.0);
40 this->
declareProperty(
"MinD", -1.0, mustBePositive,
"Lower Bound on Lattice Parameters a, b, c");
41 this->
declareProperty(
"MaxD", -1.0, mustBePositive,
"Upper Bound on Lattice Parameters a, b, c");
42 this->
declareProperty(
"Tolerance", 0.15, mustBePositive,
"Indexing Tolerance (0.15)");
45 "The resolution of the search through possible "
46 "orientations is specified by this parameter. One to "
47 "two degrees per step is usually adequate.");
58 double degrees_per_step = this->
getProperty(
"DegreesPerStep");
62 int n_peaks = ws->getNumberPeaks();
64 std::vector<V3D> q_vectors;
65 for (
int i = 0; i < n_peaks; i++) {
66 q_vectors.emplace_back(ws->getPeak(i).getQSampleFrame());
77 g_log.
notice(std::string(
"Found Invalid UB...peaks used might not be linearly independent"));
81 std::vector<double> sigabc(7);
82 std::vector<V3D> miller_ind;
83 std::vector<V3D> indexed_qs;
85 miller_ind.reserve(q_vectors.size());
86 indexed_qs.reserve(q_vectors.size());
91 g_log.
notice() <<
"New UB will index " << num_indexed <<
" Peaks out of " << n_peaks <<
" with tolerance of "
92 << std::setprecision(3) << std::setw(5) <<
tolerance <<
"\n";
94 auto lattice = std::make_unique<OrientedLattice>();
96 lattice->setError(sigabc[0], sigabc[1], sigabc[2], sigabc[3], sigabc[4], sigabc[5]);
99 ws->mutableSample().setOrientedLattice(std::move(lattice));
#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.
int version() const override
Algorithm's version for identification.
void exec() override
Run the algorithm.
const std::string category() const override
Algorithm's category for identification.
const std::string name() const override
Algorithm's name for identification.
void init() override
Initialise the properties.
static int GetIndexedPeaks(const Kernel::DblMatrix &UB, const std::vector< Kernel::V3D > &q_vectors, double required_tolerance, std::vector< Kernel::V3D > &miller_indices, std::vector< Kernel::V3D > &indexed_qs, double &fit_error)
Get lists of indices and Qs for peaks indexed by the specified UB matrix.
static double Find_UB(Kernel::DblMatrix &UB, const std::vector< Kernel::V3D > &q_vectors, OrientedLattice &lattice, double required_tolerance, int base_index, size_t num_initial, double degrees_per_step, bool fixAll=false, int iterations=1)
Find the UB matrix that most nearly indexes the specified qxyz values given the lattice parameters.
static bool CheckUB(const Kernel::DblMatrix &UB)
Check that the specified UB is reasonable for an orientation matrix.
static int NumberIndexed(const Kernel::DblMatrix &UB, const std::vector< Kernel::V3D > &q_vectors, double tolerance)
Calculate the number of Q vectors that are mapped to integer indices by UB.
static double Optimize_UB(Kernel::DblMatrix &UB, const std::vector< Kernel::V3D > &hkl_vectors, const std::vector< Kernel::V3D > &q_vectors, std::vector< double > &sigabc)
Find the UB matrix that most nearly maps hkl to qxyz for 3 or more peaks.
void notice(const std::string &msg)
Logs at notice level.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
@ InOut
Both an input & output workspace.