Mantid
|
#include <DetectorSearcher.h>
Public Types | |
using | DetectorSearchResult = std::tuple< bool, size_t > |
Search result type representing whether a detector was found and if so which detector index it was. More... | |
Public Member Functions | |
DetectorSearcher (const Geometry::Instrument_const_sptr &instrument, const Geometry::DetectorInfo &detInfo) | |
Create a new DetectorSearcher with the given instrument & detectors. More... | |
DetectorSearchResult | findDetectorIndex (const Kernel::V3D &q) |
Find a detector that intsects with the given Qlab vector. More... | |
Private Member Functions | |
std::tuple< bool, size_t > | checkInteceptWithNeighbours (const Kernel::V3D &direction, const Kernel::NearestNeighbours< 3 >::NearestNeighbourResults &neighbours) const |
Check whether the given direction in detector space intercepts with a detector. More... | |
Kernel::V3D | convertQtoDirection (const Kernel::V3D &q) const |
Helper function to convert a Qlab vector to a direction in detector space. More... | |
void | createDetectorCache () |
Helper function to build the nearest neighbour tree. More... | |
DetectorSearchResult | handleTubeGap (const Kernel::V3D &detectorDir, const Kernel::NearestNeighbours< 3 >::NearestNeighbourResults &neighbours) |
Helper function to handle the tube gap parameter in tube instruments. More... | |
DetectorSearchResult | searchUsingInstrumentRayTracing (const Kernel::V3D &q) |
Attempt to find a detector using a full instrument ray tracing strategy. More... | |
DetectorSearchResult | searchUsingNearestNeighbours (const Kernel::V3D &q) |
Attempt to find a detector using a nearest neighbours search strategy. More... | |
Private Attributes | |
const double | m_crystallography_convention |
flag for whether the crystallography convention is to be used More... | |
std::unique_ptr< Kernel::NearestNeighbours< 3 > > | m_detectorCacheSearch |
Detector search cache for fast look-up of detectors. More... | |
const Geometry::DetectorInfo & | m_detInfo |
detector info for the instrument More... | |
std::vector< size_t > | m_indexMap |
vector of detector indicies used in the search More... | |
Geometry::Instrument_const_sptr | m_instrument |
handle to the instrument to search for detectors in More... | |
std::unique_ptr< Geometry::InstrumentRayTracer > | m_rayTracer |
instrument ray tracer object for searching in rectangular detectors More... | |
const bool | m_usingFullRayTrace |
flag for whether to use InstrumentRayTracer or NearestNeighbours More... | |
Definition at line 39 of file DetectorSearcher.h.
using Mantid::API::DetectorSearcher::DetectorSearchResult = std::tuple<bool, size_t> |
Search result type representing whether a detector was found and if so which detector index it was.
Definition at line 43 of file DetectorSearcher.h.
DetectorSearcher::DetectorSearcher | ( | const Geometry::Instrument_const_sptr & | instrument, |
const Geometry::DetectorInfo & | detInfo | ||
) |
Create a new DetectorSearcher with the given instrument & detectors.
Create a new DetectorSearcher for the given instrument.
The search strategy will be determined in the constructor based on the given instrument geometry
instrument | :: the instrument to find detectors in |
detInfo | :: the Geometry::DetectorInfo object for this instrument |
Definition at line 37 of file DetectorSearcher.cpp.
References createDetectorCache(), m_rayTracer, and m_usingFullRayTrace.
|
private |
Check whether the given direction in detector space intercepts with a detector.
Check whether the given direction in real space intersects with any of the k nearest neighbours.
direction | :: real space direction vector |
neighbours | :: vector of nearest neighbours to check |
Definition at line 223 of file DetectorSearcher.cpp.
References Mantid::Geometry::DetectorInfo::detector(), Mantid::Geometry::BoundingBox::doesLineIntersect(), index, m_detInfo, m_indexMap, Mantid::Geometry::Track::reset(), and Mantid::Geometry::DetectorInfo::samplePosition().
Referenced by handleTubeGap(), and searchUsingNearestNeighbours().
|
private |
Helper function to convert a Qlab vector to a direction in detector space.
Helper method to convert a vector in Qlab to a direction in detector space.
q | :: a Qlab vector |
Definition at line 250 of file DetectorSearcher.cpp.
References m_crystallography_convention, m_instrument, Mantid::Kernel::V3D::norm(), and Mantid::Kernel::V3D::scalar_prod().
Referenced by searchUsingInstrumentRayTracing(), and searchUsingNearestNeighbours().
|
private |
Helper function to build the nearest neighbour tree.
Create a NearestNeighbours search tree for the current instrument.
Definition at line 61 of file DetectorSearcher.cpp.
References Mantid::API::E1(), Mantid::Geometry::DetectorInfo::isMasked(), Mantid::Geometry::DetectorInfo::isMonitor(), m_crystallography_convention, m_detectorCacheSearch, m_detInfo, m_indexMap, m_instrument, Mantid::Kernel::normalize(), Mantid::Geometry::DetectorInfo::position(), and Mantid::Geometry::DetectorInfo::size().
Referenced by DetectorSearcher().
DetectorSearcher::DetectorSearchResult DetectorSearcher::findDetectorIndex | ( | const Kernel::V3D & | q | ) |
Find a detector that intsects with the given Qlab vector.
Find the index of a detector given a vector in Qlab space.
If no detector is found the first parameter of the returned tuple is false
q | :: the Qlab vector to find a detector for |
Definition at line 106 of file DetectorSearcher.cpp.
References m_usingFullRayTrace, Mantid::Kernel::V3D::nullVector(), searchUsingInstrumentRayTracing(), and searchUsingNearestNeighbours().
|
private |
Helper function to handle the tube gap parameter in tube instruments.
Handle the tube-gap parameter in tube based instruments.
This will check for interceptions with the nearest neighbours by "wiggling" the predicted detector direction slightly.
detectorDir | :: the predicted direction towards a detector |
neighbours | :: the NearestNeighbour results to check interception with |
Definition at line 187 of file DetectorSearcher.cpp.
References checkInteceptWithNeighbours(), m_indexMap, m_instrument, and Mantid::Kernel::normalize().
Referenced by searchUsingNearestNeighbours().
|
private |
Attempt to find a detector using a full instrument ray tracing strategy.
Find the index of a detector given a vector in Qlab space using a ray tracing search strategy.
If no detector is found the first parameter of the returned tuple is false
q | :: the Qlab vector to find a detector for |
Definition at line 127 of file DetectorSearcher.cpp.
References convertQtoDirection(), Mantid::Geometry::DetectorInfo::indexOf(), Mantid::Geometry::DetectorInfo::isMasked(), Mantid::Geometry::DetectorInfo::isMonitor(), m_detInfo, and m_rayTracer.
Referenced by findDetectorIndex().
|
private |
Attempt to find a detector using a nearest neighbours search strategy.
Find the index of a detector given a vector in Qlab space using a nearest neighbours search strategy.
If no detector is found the first parameter of the returned tuple is false
q | :: the Qlab vector to find a detector for |
Definition at line 151 of file DetectorSearcher.cpp.
References checkInteceptWithNeighbours(), convertQtoDirection(), Mantid::API::g_log, handleTubeGap(), index, Mantid::Kernel::Logger::information(), m_detectorCacheSearch, m_indexMap, and m_instrument.
Referenced by findDetectorIndex().
|
private |
flag for whether the crystallography convention is to be used
Definition at line 73 of file DetectorSearcher.h.
Referenced by convertQtoDirection(), and createDetectorCache().
|
private |
Detector search cache for fast look-up of detectors.
Definition at line 81 of file DetectorSearcher.h.
Referenced by createDetectorCache(), and searchUsingNearestNeighbours().
|
private |
detector info for the instrument
Definition at line 75 of file DetectorSearcher.h.
Referenced by checkInteceptWithNeighbours(), createDetectorCache(), and searchUsingInstrumentRayTracing().
|
private |
vector of detector indicies used in the search
Definition at line 79 of file DetectorSearcher.h.
Referenced by checkInteceptWithNeighbours(), createDetectorCache(), handleTubeGap(), and searchUsingNearestNeighbours().
|
private |
handle to the instrument to search for detectors in
Definition at line 77 of file DetectorSearcher.h.
Referenced by convertQtoDirection(), createDetectorCache(), handleTubeGap(), and searchUsingNearestNeighbours().
|
private |
instrument ray tracer object for searching in rectangular detectors
Definition at line 83 of file DetectorSearcher.h.
Referenced by DetectorSearcher(), and searchUsingInstrumentRayTracing().
|
private |
flag for whether to use InstrumentRayTracer or NearestNeighbours
Definition at line 71 of file DetectorSearcher.h.
Referenced by DetectorSearcher(), and findDetectorIndex().