Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Mantid::API::WorkspaceNearestNeighbours Class Reference

This class is not intended for direct use. More...

#include <WorkspaceNearestNeighbours.h>

Public Member Functions

std::map< specnum_t, Mantid::Kernel::V3Dneighbours (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::V3DneighboursInRadius (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::V3DdefaultNeighbours (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 SpectrumInfom_spectrumInfo
 A reference to the SpectrumInfo. More...
 
const std::vector< specnum_tm_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...
 

Detailed Description

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.

Member Typedef Documentation

◆ Graph

using Mantid::API::WorkspaceNearestNeighbours::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> >
private

typedef for Graph object used to hold the calculated information

Definition at line 71 of file WorkspaceNearestNeighbours.h.

◆ MapIV

using Mantid::API::WorkspaceNearestNeighbours::MapIV = std::unordered_map<specnum_t, Vertex>
private

map object of int to Graph Vertex descriptor

Definition at line 77 of file WorkspaceNearestNeighbours.h.

◆ Vertex

using Mantid::API::WorkspaceNearestNeighbours::Vertex = boost::graph_traits<Graph>::vertex_descriptor
private

Vertex descriptor object for Graph.

Definition at line 75 of file WorkspaceNearestNeighbours.h.

Constructor & Destructor Documentation

◆ WorkspaceNearestNeighbours()

Mantid::API::WorkspaceNearestNeighbours::WorkspaceNearestNeighbours ( int  nNeighbours,
const SpectrumInfo spectrumInfo,
std::vector< specnum_t spectrumNumbers,
bool  ignoreMaskedDetectors = false 
)

Constructor.

Parameters
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.

Member Function Documentation

◆ build()

void Mantid::API::WorkspaceNearestNeighbours::build ( const int  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.

Parameters
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().

◆ defaultNeighbours()

std::map< specnum_t, V3D > Mantid::API::WorkspaceNearestNeighbours::defaultNeighbours ( const specnum_t  spectrum) const
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.

Parameters
spectrum:: The spectrum number
Returns
map of detID to distance
Exceptions
NotFoundErrorif 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().

◆ getSpectraDetectors()

std::vector< size_t > Mantid::API::WorkspaceNearestNeighbours::getSpectraDetectors ( )
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().

◆ neighbours()

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.

Parameters
spectrum:: Spectrum No of the central pixel
Returns
map of Detector ID's to distance

Definition at line 47 of file WorkspaceNearestNeighbours.cpp.

References defaultNeighbours().

Referenced by neighboursInRadius().

◆ 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.

Parameters
spectrum:: Spectrum No of the central pixel
radius:: cut-off distance for detector list to returns
Returns
map of Detector ID's to distance
Exceptions
NotFoundErrorif 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.

Member Data Documentation

◆ m_bIgnoreMaskedDetectors

bool Mantid::API::WorkspaceNearestNeighbours::m_bIgnoreMaskedDetectors
private

Flag indicating that masked detectors should be ignored.

Definition at line 102 of file WorkspaceNearestNeighbours.h.

Referenced by getSpectraDetectors().

◆ m_cutoff

double Mantid::API::WorkspaceNearestNeighbours::m_cutoff
private

The largest value of the distance to a nearest neighbour.

Definition at line 88 of file WorkspaceNearestNeighbours.h.

Referenced by build(), and neighboursInRadius().

◆ m_edgeLength

boost::property_map<Graph,boost::edge_name_t>::type Mantid::API::WorkspaceNearestNeighbours::m_edgeLength
private

property map holding the edge's related Distance value.

Definition at line 96 of file WorkspaceNearestNeighbours.h.

Referenced by build(), and defaultNeighbours().

◆ m_graph

Graph Mantid::API::WorkspaceNearestNeighbours::m_graph
private

boost::graph object

Definition at line 92 of file WorkspaceNearestNeighbours.h.

Referenced by build(), and defaultNeighbours().

◆ m_noNeighbours

int Mantid::API::WorkspaceNearestNeighbours::m_noNeighbours
private

The current number of nearest neighbours.

Definition at line 86 of file WorkspaceNearestNeighbours.h.

Referenced by build(), neighboursInRadius(), and WorkspaceNearestNeighbours().

◆ m_radius

double Mantid::API::WorkspaceNearestNeighbours::m_radius
mutableprivate

Cached radius value. used to avoid uncessary recalculations.

Definition at line 100 of file WorkspaceNearestNeighbours.h.

Referenced by neighboursInRadius().

◆ m_scale

Kernel::V3D Mantid::API::WorkspaceNearestNeighbours::m_scale
private

V3D for scaling.

Definition at line 98 of file WorkspaceNearestNeighbours.h.

Referenced by build().

◆ m_specToVertex

MapIV Mantid::API::WorkspaceNearestNeighbours::m_specToVertex
private

map between the DetectorID and the Graph node descriptor

Definition at line 90 of file WorkspaceNearestNeighbours.h.

Referenced by build(), and defaultNeighbours().

◆ m_spectrumInfo

const SpectrumInfo& Mantid::API::WorkspaceNearestNeighbours::m_spectrumInfo
private

A reference to the SpectrumInfo.

Definition at line 66 of file WorkspaceNearestNeighbours.h.

Referenced by build(), and getSpectraDetectors().

◆ m_spectrumNumbers

const std::vector<specnum_t> Mantid::API::WorkspaceNearestNeighbours::m_spectrumNumbers
private

Vector of spectrum numbers.

Definition at line 68 of file WorkspaceNearestNeighbours.h.

Referenced by build(), and getSpectraDetectors().

◆ m_vertexID

boost::property_map<Graph,boost::vertex_name_t>::type Mantid::API::WorkspaceNearestNeighbours::m_vertexID
private

property map holding the node's related DetectorID's

Definition at line 94 of file WorkspaceNearestNeighbours.h.

Referenced by build(), and defaultNeighbours().


The documentation for this class was generated from the following files: