Commit bbab8668 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Consolidate code relating to Q convention.

Refs #26839
parent eae063cb
......@@ -14,6 +14,12 @@ class V3D;
namespace Mantid::Crystal {
/// return -1 if convention is "Crystallography" and 1 otherwise.
double qConventionFactor(const std::string &convention);
/// convenience overload to pull the convention from the config service
double qConventionFactor();
/// Tie together a modulated peak number with its offset
using MNPOffset = std::tuple<double, double, double, Kernel::V3D>;
......
......@@ -8,16 +8,35 @@
#include "MantidKernel/ArrayLengthValidator.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/V3D.h"
using Mantid::Kernel::ArrayLengthValidator;
using Mantid::Kernel::ArrayProperty;
using Mantid::Kernel::BoundedValidator;
using Mantid::Kernel::ConfigService;
using Mantid::Kernel::Direction;
using Mantid::Kernel::V3D;
namespace Mantid::Crystal {
/**
* @return -1 if Q.convention==Crystallography, else return 1.0
*/
double qConventionFactor(const std::string &convention) {
if (convention == "Crystallography") {
return -1.0;
}
return 1.0;
}
/**
* @return qConventionFactor for Q.convention setting in ConfigService
*/
double qConventionFactor() {
return qConventionFactor(ConfigService::Instance().getString("Q.convention"));
}
/**
* Append the common set of properties that relate to modulation vectors
* to the given algorithm
......
......@@ -9,6 +9,7 @@
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/Sample.h"
#include "MantidCrystal/PeakAlgorithmHelpers.h"
#include "MantidGeometry/Crystal/BasicHKLFilters.h"
#include "MantidGeometry/Crystal/EdgePixel.h"
#include "MantidGeometry/Crystal/HKLFilterWavelength.h"
......@@ -38,24 +39,11 @@ using namespace Mantid::DataObjects;
using namespace Mantid::Geometry;
using namespace Mantid::Kernel;
namespace {
/// Small helper function that return -1 if convention
/// is "Crystallography" and 1 otherwise.
double get_factor_for_q_convention(const std::string &convention) {
if (convention == "Crystallography") {
return -1.0;
}
return 1.0;
}
} // namespace
/** Constructor
*/
PredictPeaks::PredictPeaks()
: m_runNumber(-1), m_inst(), m_pw(), m_sfCalculator(),
m_qConventionFactor(get_factor_for_q_convention(
ConfigService::Instance().getString("Q.convention"))) {
m_qConventionFactor(qConventionFactor()) {
m_refConds = getAllReflectionConditions();
}
......@@ -510,7 +498,7 @@ void PredictPeaks::fillPossibleHKLsUsingPeaksWorkspace(
* for the convention stored in the workspace.
*/
double peaks_q_convention_factor =
get_factor_for_q_convention(peaksWorkspace->getConvention());
qConventionFactor(peaksWorkspace->getConvention());
for (int i = 0; i < static_cast<int>(peaksWorkspace->getNumberPeaks()); ++i) {
IPeak &p = peaksWorkspace->getPeak(i);
......
......@@ -9,6 +9,7 @@
#include "MantidAPI/Run.h"
#include "MantidAPI/Sample.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidCrystal/PeakAlgorithmHelpers.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidGeometry/Crystal/BasicHKLFilters.h"
#include "MantidGeometry/Crystal/HKLGenerator.h"
......@@ -30,23 +31,11 @@ namespace Crystal {
DECLARE_ALGORITHM(PredictSatellitePeaks)
namespace {
/// Small helper function that return -1 if convention
/// is "Crystallography" and 1 otherwise.
double get_factor_for_q_convention(const std::string &convention) {
if (convention == "Crystallography") {
return -1.0;
}
return 1.0;
}
} // namespace
/** Constructor
*/
PredictSatellitePeaks::PredictSatellitePeaks()
: m_qConventionFactor(get_factor_for_q_convention(
ConfigService::Instance().getString("Q.convention"))) {}
: m_qConventionFactor(qConventionFactor()) {}
/// Initialise the properties
void PredictSatellitePeaks::init() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment