42 "Input Peaks Workspace");
44 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
45 mustBePositive->setLower(0.0);
47 auto atLeast3Int = std::make_shared<BoundedValidator<int>>();
48 atLeast3Int->setLower(3);
52 "Lower Bound on Lattice Parameters a, b, c");
55 "Upper Bound on Lattice Parameters a, b, c");
58 "Number of Peaks to Use on First Pass(20)");
62 "Indexing Tolerance (0.15)");
75 double degrees_per_step = 1;
79 throw std::runtime_error(
"Could not read the peaks workspace");
81 int n_peaks = ws->getNumberPeaks();
83 std::vector<V3D> q_vectors;
84 q_vectors.reserve(n_peaks);
86 for (
int i = 0; i < n_peaks; i++)
87 q_vectors.emplace_back(ws->getPeak(i).getQSampleFrame());
93 std::cout <<
"Error = " <<
error <<
'\n';
94 std::cout <<
"UB = " << UB <<
'\n';
98 g_log.
notice(std::string(
"Found Invalid UB...peaks used might not be linearly independent"));
103 std::vector<double> sigabc(7);
104 std::vector<V3D> miller_ind;
105 std::vector<V3D> indexed_qs;
107 miller_ind.reserve(q_vectors.size());
108 indexed_qs.reserve(q_vectors.size());
114 sprintf(logInfo, std::string(
"New UB will index %1d Peaks out of %1d with tolerance %5.3f").c_str(), num_indexed,
118 auto lattice = std::make_unique<OrientedLattice>();
120 lattice->setError(sigabc[0], sigabc[1], sigabc[2], sigabc[3], sigabc[4], sigabc[5]);
123 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.
void deprecatedDate(const std::string &)
The date the algorithm was deprecated on.
void useAlgorithm(const std::string &, const int version=-1)
The algorithm to use instead of this one.
A property class for workspaces.
const std::string category() const override
Algorithm's category for identification.
void init() override
Initialise the properties.
int version() const override
Algorithm's version for identification.
FindUBUsingMinMaxD()
Constructor.
const std::string name() const override
Algorithm's name for identification.
void exec() override
Run the algorithm.
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.
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.