Mantid
Loading...
Searching...
No Matches
PeakBackground.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 +
7#include <utility>
8
12
13using namespace Mantid::API;
14using namespace Mantid::Kernel;
16
17namespace Mantid::Crystal {
18
19//----------------------------------------------------------------------------------------------
22PeakBackground::PeakBackground(IPeaksWorkspace_const_sptr peaksWS, const double &radiusEstimate,
23 const double &thresholdSignal, const Mantid::API::MDNormalization normalisation,
24 const SpecialCoordinateSystem coordinates)
25 : HardThresholdBackground(thresholdSignal, normalisation), m_peaksWS(std::move(peaksWS)),
26 m_radiusEstimate(radiusEstimate), m_mdCoordinates(coordinates) {
27
28 if (m_mdCoordinates == QLab) {
30 } else if (m_mdCoordinates == QSample) {
34 } else {
35 throw std::invalid_argument("Unknown CoordinateSystem provided to PeakBackground");
36 }
37}
38
41
44 const VMD &center = iterator->getCenter();
45 V3D temp(center[0], center[1], center[2]); // This assumes dims 1, 2, and 3
46 // in the workspace correspond to
47 // positions.
48
49 for (int i = 0; i < m_peaksWS->getNumberPeaks(); ++i) {
50 const IPeak &peak = m_peaksWS->getPeak(i);
51 V3D coords = m_coordFunction(&peak);
52 if (coords.distance(temp) < m_radiusEstimate) {
53 return false;
54 }
55 }
56 }
57 return true;
58}
59
61
62} // namespace Mantid::Crystal
This is an interface to an iterator of an IMDWorkspace.
Definition: IMDIterator.h:39
virtual Mantid::Kernel::VMD getCenter() const =0
Returns the position of the center of the box pointed to.
HardThresholdBackground : Implementation of BackgroundStrategy using a fixed background signal value ...
bool isBackground(Mantid::API::IMDIterator *iterator) const override
Overriden isBackground.
PeakBackground : Extension of HardThresholdBackground to consider regions of the image as background ...
double m_radiusEstimate
Radius estimate.
PeakBackground(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, const double &radiusEstimate, const double &thresholdSignal, const Mantid::API::MDNormalization normalisation, const Mantid::Kernel::SpecialCoordinateSystem coordinates)
Constructor.
bool isBackground(Mantid::API::IMDIterator *iterator) const override
Overriden is background function.
void configureIterator(Mantid::API::IMDIterator *const iterator) const override
Overriden configure iterator function.
Mantid::API::IPeaksWorkspace_const_sptr m_peaksWS
Peak workspace containing peaks of interest.
PeakBackground * clone() const override
Virutal constructor.
Mantid::Kernel::SpecialCoordinateSystem m_mdCoordinates
MD coordinates to use.
boost::function< Mantid::Kernel::V3D(const Mantid::Geometry::IPeak *)> m_coordFunction
Pointer to member function used for coordinate determination.
Structure describing a single-crystal peak.
Definition: IPeak.h:26
virtual Mantid::Kernel::V3D getQSampleFrame() const =0
virtual Mantid::Kernel::V3D getQLabFrame() const =0
virtual Mantid::Kernel::V3D getHKL() const =0
QLab : Q in the lab frame MDFrame.
Definition: QLab.h:21
QSample : Q in the sample frame.
Definition: QSample.h:21
Class for 3D vectors.
Definition: V3D.h:34
double distance(const V3D &v) const noexcept
Calculates the distance between two vectors.
Definition: V3D.h:287
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
Definition: IMDIterator.h:25
std::shared_ptr< const IPeaksWorkspace > IPeaksWorkspace_const_sptr
shared pointer to Mantid::API::IPeaksWorkspace (const version)
SpecialCoordinateSystem
Special coordinate systems for Q3D.
STL namespace.