21using namespace Kernel;
35 "The first set of peaks.");
37 "The second set of peaks.");
39 "The combined peaks list.");
42 "Whether to combine peaks that are identical across the two workspaces");
43 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
44 mustBePositive->setLower(0.0);
47 "Maximum difference in each component of Q for which peaks "
48 "are considered identical");
58 const bool CombineMatchingPeaks =
getProperty(
"CombineMatchingPeaks");
61 if (LHSWorkspace->getInstrument()->getName() != RHSWorkspace->getInstrument()->getName()) {
62 g_log.
warning(
"The two input workspaces do not appear to come from data "
63 "take on the same instrument");
65 if (LHSWorkspace->sample().getName() != RHSWorkspace->sample().getName()) {
66 g_log.
warning(
"The two input workspaces do not appear to relate to the same sample");
72 const int rhs_n_peaks = RHSWorkspace->getNumberPeaks();
81 std::vector<Kernel::V3D> rhsModVectors;
82 std::vector<Kernel::V3D> lhsModVectors;
85 for (
int i = 0; i < 3; ++i) {
86 const auto modVecR = RHSWorkspace->sample().getOrientedLattice().getModVec(i);
88 if (!(modVecR[0] == 0 && modVecR[1] == 0 && modVecR[2] == 0)) {
89 rhsModVectors.push_back(modVecR);
91 const auto modVecL = LHSWorkspace->sample().getOrientedLattice().getModVec(i);
92 if (!(modVecL[0] == 0 && modVecL[1] == 0 && modVecL[2] == 0)) {
93 lhsModVectors.push_back(modVecL);
98 std::remove_copy_if(rhsModVectors.begin(), rhsModVectors.end(), back_inserter(lhsModVectors),
100 return lhsModVectors.end() != std::find(lhsModVectors.begin(), lhsModVectors.end(), modVec);
104 if (lhsModVectors.size() > 3) {
105 g_log.
warning(
"There are too many modulation vectors. Using vectors from "
110 for (
size_t i = 0; i < lhsModVectors.size(); ++i) {
112 output->mutableSample().getOrientedLattice().setModVec1(lhsModVectors[i]);
114 output->mutableSample().getOrientedLattice().setModVec2(lhsModVectors[i]);
116 output->mutableSample().getOrientedLattice().setModVec3(lhsModVectors[i]);
120 }
catch (std::runtime_error &e) {
121 g_log.
error() <<
"Failed to combine modulation vectors with the following "
127 if (!CombineMatchingPeaks) {
130 for (
int i = 0; i < rhs_n_peaks; i++) {
131 output->addPeak(RHSWorkspace->getPeak(i));
140 const int lhs_n_peaks = LHSWorkspace->getNumberPeaks();
141 std::vector<V3D> q_vectors;
142 for (
int i = 0; i < lhs_n_peaks; i++)
143 q_vectors.emplace_back(LHSWorkspace->getPeak(i).getQSampleFrame());
147 for (
int j = 0; j < rhs_n_peaks; j++) {
153 for (
int i = 0; i < lhs_n_peaks; i++) {
163 output->addPeak(currentPeak);
#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 progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Helper class for reporting progress from algorithms.
A property class for workspaces.
const std::string category() const override
Algorithm's category for identification.
const std::string name() const override
Algorithm's name for identification.
int version() const override
Algorithm's version for identification.
void init() override
Initialises the algorithm's properties.
void exec() override
Executes the algorithm.
Structure describing a single-crystal peak.
virtual Mantid::Kernel::V3D getQSampleFrame() const =0
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
bool nullVector(const double tolerance=1e-3) const noexcept
Determine if the point is null.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
std::shared_ptr< const IPeaksWorkspace > IPeaksWorkspace_const_sptr
shared pointer to Mantid::API::IPeaksWorkspace (const version)
constexpr double Tolerance
Standard tolerance value.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.