11#include "MantidCrystal/DllConfig.h"
14#include <boost/tuple/tuple.hpp>
29struct MANTID_CRYSTAL_DLL
index {
30 index(
int h,
int k,
int l) : _h(h), _k(k), _l(l) {}
34 else if (i1.
_h > i2.
_h)
38 else if (i1.
_k > i2.
_k)
42 else if (i1.
_l > i2.
_l)
56 os <<
rhs._h <<
"," <<
rhs._k <<
"," <<
rhs._l;
66 void addHKL(
int h,
int k,
int l) { _hkls.insert(
index(h, k, l)); }
68 if (_hkls.size() != 1) {
69 throw std::logic_error(
"Expecting a single HKL value for each peak. Refinement incomplete.");
76 auto it = std::find(_hkls.cbegin(), _hkls.cend(),
index(h, k, l));
77 if (it != _hkls.cend())
88 auto it = _hkls.begin();
90 _hkls.erase(it, _hkls.end());
94 double measured_angle = this->angle(
rhs);
95 std::set<index>::iterator it1, it2;
98 for (it1 = _hkls.begin(); it1 != _hkls.end(); ++it1)
100 for (it2 =
rhs._hkls.begin(); it2 !=
rhs._hkls.end(); ++it2)
102 const index &index1 = *it1;
103 const index &index2 = *it2;
106 double reciprocalAngle = uc.
recAngle(index1.
_h, index1.
_k, index1.
_l, index2.
_h, index2.
_k, index2.
_l, 1);
110 if (std::abs(reciprocalAngle - measured_angle) <
tolerance) {
120 os <<
"Peak" <<
rhs._Q[0] <<
"," <<
rhs._Q[1] <<
"," <<
rhs._Q[2] <<
"\n";
121 std::copy(
rhs._hkls.begin(),
rhs._hkls.end(), std::ostream_iterator<index>(os,
":"));
133 const std::string
name()
const override {
return "IndexSXPeaks"; }
136 return "Takes a PeaksWorkspace and a B-Matrix and determines the HKL "
137 "values corresponding to each Single Crystal peak. Sets indexes on "
138 "the input/output workspace.";
143 const std::vector<std::string>
seeAlso()
const override {
return {
"IndexPeaks"}; }
145 const std::string
category()
const override {
return "Crystal\\Peaks"; }
151 void validateNotColinear(
const std::vector<PeakCandidate> &peakCandidates)
const;
153 void init()
override;
155 void exec()
override;
const std::vector< double > & rhs
std::map< DeltaEMode::Type, std::string > index
Base class from which all concrete algorithm classes should be derived.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
const std::string summary() const override
Summary of algorithms purpose.
int version() const override
Algorithm's version for identification overriding a virtual method.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
double angle(const PeakCandidate &rhs) const
friend std::ostream & operator<<(std::ostream &os, const PeakCandidate &rhs)
PeakCandidate(double qx, double qy, double qz)
void clean(PeakCandidate &rhs, const Mantid::Geometry::UnitCell &uc, double tolerance)
void delHKL(int h, int k, int l)
size_t candidateHKLSize() const
Mantid::Kernel::V3D getHKL() const
void addHKL(int h, int k, int l)
double getdSpacing() const
void setIndex(const std::set< index > &s)
const Mantid::Kernel::V3D & getQ() const
Class to implement unit cell of crystals.
double recAngle(double h1, double k1, double l1, double h2, double k2, double l2, const int angleunit=angDegrees) const
Calculate the angle in degrees or radians between two reciprocal vectors (h1,k1,l1) and (h2,...
Helper class which provides the Collimation Length for SANS instruments.
Peak indexing algorithm, which works by assigning multiple possible HKL values to each peak and then ...
friend bool operator==(const index &i1, const index &i2)
friend std::ostream & operator<<(std::ostream &os, const index &rhs)
friend bool operator<(const index &i1, const index &i2)
index(int h, int k, int l)