Mantid
|
This class is not intended for direct use. More...
#include <WorkspaceNearestNeighbours.h>
Public Member Functions | |
std::map< specnum_t, Mantid::Kernel::V3D > | neighbours (specnum_t spectrum) const |
Returns a map of the spectrum numbers to the distances for the nearest neighbours. More... | |
std::map< specnum_t, Mantid::Kernel::V3D > | neighboursInRadius (specnum_t spectrum, double radius=0.0) const |
Returns a map of the spectrum numbers to the distances for the nearest neighbours. More... | |
WorkspaceNearestNeighbours (int nNeighbours, const SpectrumInfo &spectrumInfo, std::vector< specnum_t > spectrumNumbers, bool ignoreMaskedDetectors=false) | |
Constructor. More... | |
Protected Member Functions | |
std::vector< size_t > | getSpectraDetectors () |
Returns the list of valid spectrum indices. More... | |
Private Types | |
using | Graph = boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::property< boost::vertex_name_t, int64_t >, boost::property< boost::edge_name_t, Mantid::Kernel::V3D > > |
typedef for Graph object used to hold the calculated information More... | |
using | MapIV = std::unordered_map< specnum_t, Vertex > |
map object of int to Graph Vertex descriptor More... | |
using | Vertex = boost::graph_traits< Graph >::vertex_descriptor |
Vertex descriptor object for Graph. More... | |
Private Member Functions | |
void | build (const int noNeighbours) |
Construct the graph based on the given number of neighbours and the current instument and spectra-detector mapping. More... | |
std::map< specnum_t, Mantid::Kernel::V3D > | defaultNeighbours (const specnum_t spectrum) const |
Query the graph for the default number of nearest neighbours to specified detector. More... | |
Private Attributes | |
bool | m_bIgnoreMaskedDetectors |
Flag indicating that masked detectors should be ignored. More... | |
double | m_cutoff |
The largest value of the distance to a nearest neighbour. More... | |
boost::property_map< Graph, boost::edge_name_t >::type | m_edgeLength |
property map holding the edge's related Distance value. More... | |
Graph | m_graph |
boost::graph object More... | |
int | m_noNeighbours |
The current number of nearest neighbours. More... | |
double | m_radius |
Cached radius value. used to avoid uncessary recalculations. More... | |
Kernel::V3D | m_scale |
V3D for scaling. More... | |
MapIV | m_specToVertex |
map between the DetectorID and the Graph node descriptor More... | |
const SpectrumInfo & | m_spectrumInfo |
A reference to the SpectrumInfo. More... | |
const std::vector< specnum_t > | m_spectrumNumbers |
Vector of spectrum numbers. More... | |
boost::property_map< Graph, boost::vertex_name_t >::type | m_vertexID |
property map holding the node's related DetectorID's More... | |
This class is not intended for direct use.
Use WorkspaceNearestNeighbourInfo instead!
This class is used to find the nearest neighbours of a detector in the instrument geometry. This class can be queried through calls to the getNeighbours() function on a Detector object.
This class uses the ANN Library, from David M Mount and Sunil Arya which is incorporated into Mantid's Kernel module. Mantid uses version 1.1.2 of this library. ANN is available from http://www.cs.umd.edu/~mount/ANN/ and is released under the GNU LGPL.
Known potential issue: boost's graph has an issue that may cause compilation errors in some circumstances in the current version of boost used by Mantid (1.43) based on tr1::tie. This issue is fixed in later versions of boost, but should in theory be guarded against by this file only being included in ParameterMap.
Definition at line 50 of file WorkspaceNearestNeighbours.h.
|
private |
typedef for Graph object used to hold the calculated information
Definition at line 71 of file WorkspaceNearestNeighbours.h.
|
private |
map object of int to Graph Vertex descriptor
Definition at line 77 of file WorkspaceNearestNeighbours.h.
|
private |
Vertex descriptor object for Graph.
Definition at line 75 of file WorkspaceNearestNeighbours.h.
Mantid::API::WorkspaceNearestNeighbours::WorkspaceNearestNeighbours | ( | int | nNeighbours, |
const SpectrumInfo & | spectrumInfo, | ||
std::vector< specnum_t > | spectrumNumbers, | ||
bool | ignoreMaskedDetectors = false |
||
) |
Constructor.
nNeighbours | :: Number of neighbours to use |
spectrumInfo | :: Reference to the SpectrumInfo of the underlying workspace |
spectrumNumbers | :: Vector of spectrum numbers, defining the ordering of spectra |
ignoreMaskedDetectors | :: flag indicating that masked detectors should be ignored. |
Definition at line 33 of file WorkspaceNearestNeighbours.cpp.
References build(), and m_noNeighbours.
|
private |
Construct the graph based on the given number of neighbours and the current instument and spectra-detector mapping.
Builds a map based on the given number of neighbours.
noNeighbours | :: The number of nearest neighbours to use to build the graph |
Definition at line 111 of file WorkspaceNearestNeighbours.cpp.
References Mantid::API::SpectrumInfo::detector(), Mantid::Geometry::IComponent::getBoundingBox(), getSpectraDetectors(), index, m_cutoff, m_edgeLength, m_graph, m_noNeighbours, m_scale, m_specToVertex, m_spectrumInfo, m_spectrumNumbers, m_vertexID, Mantid::Kernel::V3D::norm(), Mantid::API::SpectrumInfo::position(), Mantid::Geometry::BoundingBox::width(), Mantid::Kernel::V3D::X(), Mantid::Kernel::V3D::Y(), and Mantid::Kernel::V3D::Z().
Referenced by neighboursInRadius(), and WorkspaceNearestNeighbours().
|
private |
Query the graph for the default number of nearest neighbours to specified detector.
Returns a map of the spectrum numbers to the nearest detectors and their distance from the detector specified in the argument.
spectrum | :: The spectrum number |
NotFoundError | if detector ID is not recognised |
Definition at line 195 of file WorkspaceNearestNeighbours.cpp.
References m_edgeLength, m_graph, m_specToVertex, and m_vertexID.
Referenced by neighbours(), and neighboursInRadius().
|
protected |
Returns the list of valid spectrum indices.
Definition at line 217 of file WorkspaceNearestNeighbours.cpp.
References Mantid::API::SpectrumInfo::isMasked(), Mantid::API::SpectrumInfo::isMonitor(), m_bIgnoreMaskedDetectors, m_spectrumInfo, and m_spectrumNumbers.
Referenced by build().
std::map< specnum_t, V3D > Mantid::API::WorkspaceNearestNeighbours::neighbours | ( | specnum_t | spectrum | ) | const |
Returns a map of the spectrum numbers to the distances for the nearest neighbours.
spectrum | :: Spectrum No of the central pixel |
Definition at line 47 of file WorkspaceNearestNeighbours.cpp.
References defaultNeighbours().
Referenced by neighboursInRadius().
std::map< specnum_t, V3D > Mantid::API::WorkspaceNearestNeighbours::neighboursInRadius | ( | specnum_t | spectrum, |
double | radius = 0.0 |
||
) | const |
Returns a map of the spectrum numbers to the distances for the nearest neighbours.
spectrum | :: Spectrum No of the central pixel |
radius | :: cut-off distance for detector list to returns |
NotFoundError | if component is not recognised as a detector |
Definition at line 59 of file WorkspaceNearestNeighbours.cpp.
References build(), defaultNeighbours(), m_cutoff, m_noNeighbours, m_radius, neighbours(), and radius.
|
private |
Flag indicating that masked detectors should be ignored.
Definition at line 102 of file WorkspaceNearestNeighbours.h.
Referenced by getSpectraDetectors().
|
private |
The largest value of the distance to a nearest neighbour.
Definition at line 88 of file WorkspaceNearestNeighbours.h.
Referenced by build(), and neighboursInRadius().
|
private |
property map holding the edge's related Distance value.
Definition at line 96 of file WorkspaceNearestNeighbours.h.
Referenced by build(), and defaultNeighbours().
|
private |
boost::graph object
Definition at line 92 of file WorkspaceNearestNeighbours.h.
Referenced by build(), and defaultNeighbours().
|
private |
The current number of nearest neighbours.
Definition at line 86 of file WorkspaceNearestNeighbours.h.
Referenced by build(), neighboursInRadius(), and WorkspaceNearestNeighbours().
|
mutableprivate |
Cached radius value. used to avoid uncessary recalculations.
Definition at line 100 of file WorkspaceNearestNeighbours.h.
Referenced by neighboursInRadius().
|
private |
|
private |
map between the DetectorID and the Graph node descriptor
Definition at line 90 of file WorkspaceNearestNeighbours.h.
Referenced by build(), and defaultNeighbours().
|
private |
A reference to the SpectrumInfo.
Definition at line 66 of file WorkspaceNearestNeighbours.h.
Referenced by build(), and getSpectraDetectors().
|
private |
Vector of spectrum numbers.
Definition at line 68 of file WorkspaceNearestNeighbours.h.
Referenced by build(), and getSpectraDetectors().
|
private |
property map holding the node's related DetectorID's
Definition at line 94 of file WorkspaceNearestNeighbours.h.
Referenced by build(), and defaultNeighbours().