Mantid
Loading...
Searching...
No Matches
HKLFilterWavelength.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include <sstream>
9#include <stdexcept>
10#include <utility>
11
12namespace Mantid::Geometry {
13
14using namespace Kernel;
15
17HKLFilterWavelength::HKLFilterWavelength(Kernel::DblMatrix ub, double lambdaMin, double lambdaMax)
18 : m_ub(std::move(ub)), m_lambdaMin(lambdaMin), m_lambdaMax(lambdaMax) {
20}
21
23std::string HKLFilterWavelength::getDescription() const noexcept {
24 std::ostringstream strm;
25 strm << "(" << m_lambdaMin << " <= lambda <= " << m_lambdaMax << ")";
26
27 return strm.str();
28}
29
31bool HKLFilterWavelength::isAllowed(const Kernel::V3D &hkl) const noexcept {
32 V3D q = m_ub * hkl;
33 double lambda = (2.0 * q.Z()) / (q.norm2());
34
35 return lambda >= m_lambdaMin && lambda <= m_lambdaMax;
36}
37
40 if (m_lambdaMin <= 0.0) {
41 throw std::range_error("LambdaMin cannot be <= 0.");
42 }
43
44 if (m_lambdaMax <= m_lambdaMin) {
45 throw std::range_error("LambdaMax cannot be smaller than LambdaMin.");
46 }
47}
48
49} // namespace Mantid::Geometry
const std::vector< double > * lambda
bool isAllowed(const Kernel::V3D &hkl) const noexcept override
Returns true if lambda of the reflection is within the limits.
void checkProperLambdaRangeValues() const
Throws std::range_error exceptions if limits are <= 0 or max >= min.
HKLFilterWavelength(Kernel::DblMatrix ub, double lambdaMin, double lambdaMax)
Constructor, takes an orientation matrix and lambda min/max.
std::string getDescription() const noexcept override
Returns a description for the filter.
Class for 3D vectors.
Definition: V3D.h:34
constexpr double norm2() const noexcept
Vector length squared.
Definition: V3D.h:265
constexpr double Z() const noexcept
Get z.
Definition: V3D.h:234
STL namespace.