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

#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::DetectorInfom_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::InstrumentRayTracerm_rayTracer
 instrument ray tracer object for searching in rectangular detectors More...
 
const bool m_usingFullRayTrace
 flag for whether to use InstrumentRayTracer or NearestNeighbours More...
 

Detailed Description

Definition at line 39 of file DetectorSearcher.h.

Member Typedef Documentation

◆ DetectorSearchResult

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.

Constructor & Destructor Documentation

◆ DetectorSearcher()

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

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

Member Function Documentation

◆ checkInteceptWithNeighbours()

std::tuple< bool, size_t > DetectorSearcher::checkInteceptWithNeighbours ( const Kernel::V3D direction,
const Kernel::NearestNeighbours< 3 >::NearestNeighbourResults &  neighbours 
) const
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.

Parameters
direction:: real space direction vector
neighbours:: vector of nearest neighbours to check
Returns
tuple of <detector hit, index of correct index in m_IndexMap>

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

◆ convertQtoDirection()

V3D DetectorSearcher::convertQtoDirection ( const Kernel::V3D q) const
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.

Parameters
q:: a Qlab vector
Returns
a direction in detector space

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

◆ createDetectorCache()

void DetectorSearcher::createDetectorCache ( )
private

◆ findDetectorIndex()

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

Parameters
q:: the Qlab vector to find a detector for
Returns
tuple with data <detector found, detector index>

Definition at line 106 of file DetectorSearcher.cpp.

References m_usingFullRayTrace, Mantid::Kernel::V3D::nullVector(), searchUsingInstrumentRayTracing(), and searchUsingNearestNeighbours().

◆ handleTubeGap()

DetectorSearcher::DetectorSearchResult DetectorSearcher::handleTubeGap ( const Kernel::V3D detectorDir,
const Kernel::NearestNeighbours< 3 >::NearestNeighbourResults &  neighbours 
)
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.

Parameters
detectorDir:: the predicted direction towards a detector
neighbours:: the NearestNeighbour results to check interception with
Returns
a detector search result with whether a detector was hit

Definition at line 187 of file DetectorSearcher.cpp.

References checkInteceptWithNeighbours(), m_indexMap, m_instrument, and Mantid::Kernel::normalize().

Referenced by searchUsingNearestNeighbours().

◆ searchUsingInstrumentRayTracing()

DetectorSearcher::DetectorSearchResult DetectorSearcher::searchUsingInstrumentRayTracing ( const Kernel::V3D q)
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

Parameters
q:: the Qlab vector to find a detector for
Returns
tuple with data <detector found, detector index>

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

◆ searchUsingNearestNeighbours()

DetectorSearcher::DetectorSearchResult DetectorSearcher::searchUsingNearestNeighbours ( const Kernel::V3D q)
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

Parameters
q:: the Qlab vector to find a detector for
Returns
tuple with data <detector found, detector index>

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

Member Data Documentation

◆ m_crystallography_convention

const double Mantid::API::DetectorSearcher::m_crystallography_convention
private

flag for whether the crystallography convention is to be used

Definition at line 73 of file DetectorSearcher.h.

Referenced by convertQtoDirection(), and createDetectorCache().

◆ m_detectorCacheSearch

std::unique_ptr<Kernel::NearestNeighbours<3> > Mantid::API::DetectorSearcher::m_detectorCacheSearch
private

Detector search cache for fast look-up of detectors.

Definition at line 81 of file DetectorSearcher.h.

Referenced by createDetectorCache(), and searchUsingNearestNeighbours().

◆ m_detInfo

const Geometry::DetectorInfo& Mantid::API::DetectorSearcher::m_detInfo
private

detector info for the instrument

Definition at line 75 of file DetectorSearcher.h.

Referenced by checkInteceptWithNeighbours(), createDetectorCache(), and searchUsingInstrumentRayTracing().

◆ m_indexMap

std::vector<size_t> Mantid::API::DetectorSearcher::m_indexMap
private

vector of detector indicies used in the search

Definition at line 79 of file DetectorSearcher.h.

Referenced by checkInteceptWithNeighbours(), createDetectorCache(), handleTubeGap(), and searchUsingNearestNeighbours().

◆ m_instrument

Geometry::Instrument_const_sptr Mantid::API::DetectorSearcher::m_instrument
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().

◆ m_rayTracer

std::unique_ptr<Geometry::InstrumentRayTracer> Mantid::API::DetectorSearcher::m_rayTracer
private

instrument ray tracer object for searching in rectangular detectors

Definition at line 83 of file DetectorSearcher.h.

Referenced by DetectorSearcher(), and searchUsingInstrumentRayTracing().

◆ m_usingFullRayTrace

const bool Mantid::API::DetectorSearcher::m_usingFullRayTrace
private

flag for whether to use InstrumentRayTracer or NearestNeighbours

Definition at line 71 of file DetectorSearcher.h.

Referenced by DetectorSearcher(), and findDetectorIndex().


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