Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::Geometry::DetectorInfo Class Reference

Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2.0. More...

#include <DetectorInfo.h>

Public Member Functions

double azimuthal (const size_t index) const
 
double azimuthal (const std::pair< size_t, size_t > &index) const
 
DetectorInfoIterator< DetectorInfobegin ()
 
const DetectorInfoIterator< const DetectorInfocbegin () const
 
const DetectorInfoIterator< const DetectorInfocend () const
 
void clearMaskFlags ()
 Sets all mask flags to false (unmasked). More...
 
const Geometry::IDetectordetector (const size_t index) const
 Return a const reference to the detector with given index. More...
 
const std::vector< detid_t > & detectorIDs () const
 Returns a sorted vector of all detector IDs. More...
 
 DetectorInfo (const DetectorInfo &other)
 Copy constructor. More...
 
 DetectorInfo (std::unique_ptr< Beamline::DetectorInfo > detectorInfo, std::shared_ptr< const Geometry::Instrument > instrument, std::shared_ptr< const std::vector< detid_t > > detectorIds, std::shared_ptr< const std::unordered_map< detid_t, size_t > > detIdToIndexMap)
 Construct DetectorInfo based on an Instrument. More...
 
double difcUncalibrated (const size_t index) const
 
std::tuple< double, double, double > diffractometerConstants (const size_t index, std::vector< detid_t > &calibratedDets, std::vector< detid_t > &uncalibratedDets) const
 
DetectorInfoIterator< DetectorInfoend ()
 
std::pair< double, double > geographicalAngles (const size_t index) const
 
std::pair< double, double > geographicalAngles (const std::pair< size_t, size_t > &index) const
 
bool hasMaskedDetectors () const
 Returns true if there are masked detectors. More...
 
size_t indexOf (const detid_t id) const
 Returns the index of the detector with the given detector ID. More...
 
bool isEquivalent (const DetectorInfo &other) const
 Returns true if the content of this is equivalent to the content of other. More...
 
bool isMasked (const size_t index) const
 Returns true if the detector is masked. More...
 
bool isMasked (const std::pair< size_t, size_t > &index) const
 Returns true if the detector is masked. More...
 
bool isMonitor (const size_t index) const
 Returns true if the detector is a monitor. More...
 
bool isMonitor (const std::pair< size_t, size_t > &index) const
 Returns true if the detector is a monitor. More...
 
bool isScanning () const
 Returns true if the beamline has scanning detectors. More...
 
double l1 () const
 Returns L1 (distance from source to sample). More...
 
double l2 (const size_t index) const
 Returns L2 (distance from sample to spectrum). More...
 
double l2 (const std::pair< size_t, size_t > &index) const
 Returns L2 (distance from sample to spectrum). More...
 
DetectorInfooperator= (const DetectorInfo &rhs)
 Assigns the contents of the non-wrapping part of rhs to this. More...
 
Kernel::V3D position (const size_t index) const
 Returns the position of the detector with given index. More...
 
Kernel::V3D position (const std::pair< size_t, size_t > &index) const
 Returns the position of the detector with given index. More...
 
Kernel::Quat rotation (const size_t index) const
 Returns the rotation of the detector with given index. More...
 
Kernel::Quat rotation (const std::pair< size_t, size_t > &index) const
 Returns the rotation of the detector with given index. More...
 
Kernel::V3D samplePosition () const
 Returns the sample position. More...
 
size_t scanCount () const
 Returns the scan count of the detector with given detector index. More...
 
const std::vector< std::pair< Types::Core::DateAndTime, Types::Core::DateAndTime > > scanIntervals () const
 Returns the scan interval of the detector with given index. More...
 
size_t scanSize () const
 
void setMasked (const size_t index, bool masked)
 Set the mask flag of the detector with given index. Not thread safe. More...
 
void setMasked (const std::pair< size_t, size_t > &index, bool masked)
 Set the mask flag of the detector with given index. Not thread safe. More...
 
void setPosition (const size_t index, const Kernel::V3D &position)
 Set the absolute position of the detector with given index. Not thread safe. More...
 
void setPosition (const std::pair< size_t, size_t > &index, const Kernel::V3D &position)
 Set the absolute position of the detector with given index. Not thread safe. More...
 
void setRotation (const size_t index, const Kernel::Quat &rotation)
 Set the absolute rotation of the detector with given index. Not thread safe. More...
 
void setRotation (const std::pair< size_t, size_t > &index, const Kernel::Quat &rotation)
 Set the absolute rotation of the detector with given index. Not thread safe. More...
 
double signedTwoTheta (const size_t index) const
 Returns signed 2 theta (signed scattering angle w.r.t. to beam direction). More...
 
double signedTwoTheta (const std::pair< size_t, size_t > &index) const
 Returns signed 2 theta (signed scattering angle w.r.t. to beam direction). More...
 
size_t size () const
 Returns the size of the DetectorInfo, i.e., the number of detectors in the instrument. More...
 
Kernel::V3D sourcePosition () const
 Returns the source position. More...
 
double twoTheta (const size_t index) const
 Returns 2 theta (scattering angle w.r.t. to beam direction). More...
 
double twoTheta (const std::pair< size_t, size_t > &index) const
 Returns 2 theta (scattering angle w.r.t. to beam direction). More...
 
 ~DetectorInfo ()
 

Private Member Functions

void clearPositionDependentParameters (const size_t index)
 
const Geometry::IDetectorgetDetector (const size_t index) const
 
std::shared_ptr< const Geometry::IDetectorgetDetectorPtr (const size_t index) const
 Helper used by SpectrumInfo. More...
 

Private Attributes

std::shared_ptr< const std::vector< detid_t > > m_detectorIDs
 
std::unique_ptr< Beamline::DetectorInfo > m_detectorInfo
 Pointer to the actual DetectorInfo object (non-wrapping part). More...
 
std::shared_ptr< const std::unordered_map< detid_t, size_t > > m_detIDToIndex
 
std::shared_ptr< const Geometry::Instrumentm_instrument
 
std::vector< std::shared_ptr< const Geometry::IDetector > > m_lastDetector
 
std::vector< size_t > m_lastIndex
 

Friends

class API::SpectrumInfo
 
class Instrument
 

Detailed Description

Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2.0.

The aim is to provide a nearly identical interface such that we can start refactoring existing code before the full-blown implementation of Instrument-2.0 is available.

DetectorInfo provides easy access to commonly used parameters of individual detectors, such as mask and monitor flags, L1, L2, and 2-theta.

This class is thread safe for read operations (const access) with OpenMP BUT NOT WITH ANY OTHER THREADING LIBRARY such as Poco threads or Intel TBB. There are no thread-safety guarantees for write operations (non-const access). Reads concurrent with writes or concurrent writes are not allowed.

Author
Simon Heybrock
Date
2016

Definition at line 49 of file DetectorInfo.h.

Constructor & Destructor Documentation

◆ DetectorInfo() [1/2]

Mantid::Geometry::DetectorInfo::DetectorInfo ( std::unique_ptr< Beamline::DetectorInfo >  detectorInfo,
std::shared_ptr< const Geometry::Instrument instrument,
std::shared_ptr< const std::vector< detid_t > >  detectorIds,
std::shared_ptr< const std::unordered_map< detid_t, size_t > >  detIdToIndexMap 
)

Construct DetectorInfo based on an Instrument.

The Instrument reference instrument must be the parameterized instrument obtained from a workspace. Detector ID -> index map provided as constructor argument.

Definition at line 26 of file DetectorInfo.cpp.

References m_detectorIDs, m_detIDToIndex, and m_instrument.

◆ DetectorInfo() [2/2]

Mantid::Geometry::DetectorInfo::DetectorInfo ( const DetectorInfo other)

Copy constructor.

Use with EXTREME CARE.

Public copy should not be used since proper links between DetectorInfo and ComponentInfo must be set up.

Definition at line 48 of file DetectorInfo.cpp.

◆ ~DetectorInfo()

Mantid::Geometry::DetectorInfo::~DetectorInfo ( )
default

Member Function Documentation

◆ azimuthal() [1/2]

double Mantid::Geometry::DetectorInfo::azimuthal ( const size_t  index) const

◆ azimuthal() [2/2]

double Mantid::Geometry::DetectorInfo::azimuthal ( const std::pair< size_t, size_t > &  index) const

◆ begin()

DetectorInfoIt Mantid::Geometry::DetectorInfo::begin ( )

Definition at line 451 of file DetectorInfo.cpp.

References size().

◆ cbegin()

const DetectorInfoConstIt Mantid::Geometry::DetectorInfo::cbegin ( ) const

Definition at line 429 of file DetectorInfo.cpp.

References size().

◆ cend()

const DetectorInfoConstIt Mantid::Geometry::DetectorInfo::cend ( ) const

Definition at line 431 of file DetectorInfo.cpp.

References size().

◆ clearMaskFlags()

void Mantid::Geometry::DetectorInfo::clearMaskFlags ( )

Sets all mask flags to false (unmasked).

Not thread safe.

This method was introduced to help with refactoring and may be removed in the future.

Definition at line 353 of file DetectorInfo.cpp.

References m_detectorInfo, and size().

Referenced by Mantid::DataObjects::MaskWorkspace::clearMask(), and export_DetectorInfo().

◆ clearPositionDependentParameters()

void Mantid::Geometry::DetectorInfo::clearPositionDependentParameters ( const size_t  index)
private

Definition at line 373 of file DetectorInfo.cpp.

References index, m_detectorIDs, and m_instrument.

Referenced by setPosition().

◆ detector()

const Geometry::IDetector & Mantid::Geometry::DetectorInfo::detector ( const size_t  index) const

◆ detectorIDs()

const std::vector< detid_t > & Mantid::Geometry::DetectorInfo::detectorIDs ( ) const

◆ difcUncalibrated()

double Mantid::Geometry::DetectorInfo::difcUncalibrated ( const size_t  index) const

◆ diffractometerConstants()

std::tuple< double, double, double > Mantid::Geometry::DetectorInfo::diffractometerConstants ( const size_t  index,
std::vector< detid_t > &  calibratedDets,
std::vector< detid_t > &  uncalibratedDets 
) const

◆ end()

DetectorInfoIt Mantid::Geometry::DetectorInfo::end ( )

Definition at line 454 of file DetectorInfo.cpp.

References size().

◆ geographicalAngles() [1/2]

std::pair< double, double > Mantid::Geometry::DetectorInfo::geographicalAngles ( const size_t  index) const

◆ geographicalAngles() [2/2]

std::pair< double, double > Mantid::Geometry::DetectorInfo::geographicalAngles ( const std::pair< size_t, size_t > &  index) const

Definition at line 312 of file DetectorInfo.cpp.

References index, m_instrument, position, and samplePosition().

◆ getDetector()

const Geometry::IDetector & Mantid::Geometry::DetectorInfo::getDetector ( const size_t  index) const
private

◆ getDetectorPtr()

std::shared_ptr< const Geometry::IDetector > Mantid::Geometry::DetectorInfo::getDetectorPtr ( const size_t  index) const
private

Helper used by SpectrumInfo.

Definition at line 444 of file DetectorInfo.cpp.

References getDetector(), index, m_lastDetector, and PARALLEL_THREAD_NUMBER.

Referenced by Mantid::API::SpectrumInfo::getDetector().

◆ hasMaskedDetectors()

bool Mantid::Geometry::DetectorInfo::hasMaskedDetectors ( ) const

Returns true if there are masked detectors.

Definition at line 101 of file DetectorInfo.cpp.

References m_detectorInfo.

Referenced by export_DetectorInfo().

◆ indexOf()

std::size_t Mantid::Geometry::DetectorInfo::indexOf ( const detid_t  id) const

◆ isEquivalent()

bool Mantid::Geometry::DetectorInfo::isEquivalent ( const DetectorInfo other) const

Returns true if the content of this is equivalent to the content of other.

Here "equivalent" implies equality of all member, except for positions and rotations, which are treated specially:

  • Positions that differ by less than 1 nm = 1e-9 m are considered equivalent.
  • Rotations that imply relative position changes of less than 1 nm = 1e-9 m with a rotation center that is 1000 m away are considered equivalent. Note that in both cases the actual limit may be lower, but it is guarenteed that any LARGER differences are NOT considered equivalent.

Definition at line 77 of file DetectorInfo.cpp.

References m_detectorInfo.

Referenced by export_DetectorInfo().

◆ isMasked() [1/2]

bool Mantid::Geometry::DetectorInfo::isMasked ( const size_t  index) const

◆ isMasked() [2/2]

bool Mantid::Geometry::DetectorInfo::isMasked ( const std::pair< size_t, size_t > &  index) const

Returns true if the detector is masked.

Definition at line 98 of file DetectorInfo.cpp.

References index, and m_detectorInfo.

◆ isMonitor() [1/2]

bool Mantid::Geometry::DetectorInfo::isMonitor ( const size_t  index) const

◆ isMonitor() [2/2]

bool Mantid::Geometry::DetectorInfo::isMonitor ( const std::pair< size_t, size_t > &  index) const

Returns true if the detector is a monitor.

Definition at line 92 of file DetectorInfo.cpp.

References index, and m_detectorInfo.

◆ isScanning()

bool Mantid::Geometry::DetectorInfo::isScanning ( ) const

Returns true if the beamline has scanning detectors.

Definition at line 86 of file DetectorInfo.cpp.

References m_detectorInfo.

Referenced by Mantid::API::SpectrumInfo::diffractometerConstants().

◆ l1()

double Mantid::Geometry::DetectorInfo::l1 ( ) const

◆ l2() [1/2]

double Mantid::Geometry::DetectorInfo::l2 ( const size_t  index) const

Returns L2 (distance from sample to spectrum).

For monitors this is defined such that L1+L2 = source-detector distance, i.e., for a monitor in the beamline between source and sample L2 is negative.

Definition at line 108 of file DetectorInfo.cpp.

References index, isMonitor(), l1(), position, samplePosition(), and sourcePosition().

Referenced by Mantid::Algorithms::CreateLogTimeCorrection::calculateCorrections(), export_DetectorInfo(), Mantid::Algorithms::CreateLogTimeCorrection::generateCorrectionTable(), Mantid::Algorithms::SolidAngleHelpers::Rectangle::solidAngle(), Mantid::Algorithms::SolidAngleHelpers::Tube::solidAngle(), and Mantid::Algorithms::SolidAngleHelpers::Wing::solidAngle().

◆ l2() [2/2]

double Mantid::Geometry::DetectorInfo::l2 ( const std::pair< size_t, size_t > &  index) const

Returns L2 (distance from sample to spectrum).

For monitors this is defined such that L1+L2 = source-detector distance, i.e., for a monitor in the beamline between source and sample L2 is negative.

Definition at line 120 of file DetectorInfo.cpp.

References index, isMonitor(), l1(), position, samplePosition(), and sourcePosition().

◆ operator=()

DetectorInfo & Mantid::Geometry::DetectorInfo::operator= ( const DetectorInfo rhs)

Assigns the contents of the non-wrapping part of rhs to this.

Definition at line 54 of file DetectorInfo.cpp.

References detectorIDs(), m_detectorInfo, and rhs.

◆ position() [1/2]

Kernel::V3D Mantid::Geometry::DetectorInfo::position ( const size_t  index) const

◆ position() [2/2]

Kernel::V3D Mantid::Geometry::DetectorInfo::position ( const std::pair< size_t, size_t > &  index) const

Returns the position of the detector with given index.

Definition at line 327 of file DetectorInfo.cpp.

References index, m_detectorInfo, and Mantid::Kernel::toV3D().

◆ rotation() [1/2]

Kernel::Quat Mantid::Geometry::DetectorInfo::rotation ( const size_t  index) const

Returns the rotation of the detector with given index.

Definition at line 332 of file DetectorInfo.cpp.

References index, m_detectorInfo, and Mantid::Kernel::toQuat().

Referenced by Mantid::DataObjects::ScanningWorkspaceBuilder::buildRelativeRotationsForScans(), and export_DetectorInfo().

◆ rotation() [2/2]

Kernel::Quat Mantid::Geometry::DetectorInfo::rotation ( const std::pair< size_t, size_t > &  index) const

Returns the rotation of the detector with given index.

Definition at line 337 of file DetectorInfo.cpp.

References index, m_detectorInfo, and Mantid::Kernel::toQuat().

◆ samplePosition()

Kernel::V3D Mantid::Geometry::DetectorInfo::samplePosition ( ) const

◆ scanCount()

size_t Mantid::Geometry::DetectorInfo::scanCount ( ) const

Returns the scan count of the detector with given detector index.

Definition at line 418 of file DetectorInfo.cpp.

References m_detectorInfo.

Referenced by Mantid::DataObjects::ScanningWorkspaceBuilder::buildRelativeRotationsForScans(), and Mantid::Algorithms::MergeRuns::buildScanIntervals().

◆ scanIntervals()

const std::vector< std::pair< Types::Core::DateAndTime, Types::Core::DateAndTime > > Mantid::Geometry::DetectorInfo::scanIntervals ( ) const

Returns the scan interval of the detector with given index.

The interval start and end values would typically correspond to nanoseconds since 1990, as in Types::Core::DateAndTime.

Definition at line 424 of file DetectorInfo.cpp.

References m_detectorInfo.

Referenced by Mantid::Algorithms::MergeRuns::buildScanIntervals().

◆ scanSize()

size_t Mantid::Geometry::DetectorInfo::scanSize ( ) const

◆ setMasked() [1/2]

void Mantid::Geometry::DetectorInfo::setMasked ( const size_t  index,
bool  masked 
)

Set the mask flag of the detector with given index. Not thread safe.

Definition at line 342 of file DetectorInfo.cpp.

References index, and m_detectorInfo.

Referenced by export_DetectorInfo(), Mantid::API::ExperimentInfo::populateWithParameter(), Mantid::API::ExperimentInfo::readParameterMap(), and Mantid::API::SpectrumInfo::setMasked().

◆ setMasked() [2/2]

void Mantid::Geometry::DetectorInfo::setMasked ( const std::pair< size_t, size_t > &  index,
bool  masked 
)

Set the mask flag of the detector with given index. Not thread safe.

Definition at line 345 of file DetectorInfo.cpp.

References index, and m_detectorInfo.

◆ setPosition() [1/2]

void Mantid::Geometry::DetectorInfo::setPosition ( const size_t  index,
const Kernel::V3D position 
)

◆ setPosition() [2/2]

void Mantid::Geometry::DetectorInfo::setPosition ( const std::pair< size_t, size_t > &  index,
const Kernel::V3D position 
)

Set the absolute position of the detector with given index. Not thread safe.

Definition at line 366 of file DetectorInfo.cpp.

References clearPositionDependentParameters(), index, m_detectorInfo, position, and Mantid::Kernel::toVector3d().

◆ setRotation() [1/2]

void Mantid::Geometry::DetectorInfo::setRotation ( const size_t  index,
const Kernel::Quat rotation 
)

Set the absolute rotation of the detector with given index. Not thread safe.

Definition at line 382 of file DetectorInfo.cpp.

References index, m_detectorInfo, rotation, and Mantid::Kernel::toQuaterniond().

Referenced by Mantid::DataObjects::ScanningWorkspaceBuilder::buildRelativeRotationsForScans(), and Mantid::DataObjects::ScanningWorkspaceBuilder::buildRotations().

◆ setRotation() [2/2]

void Mantid::Geometry::DetectorInfo::setRotation ( const std::pair< size_t, size_t > &  index,
const Kernel::Quat rotation 
)

Set the absolute rotation of the detector with given index. Not thread safe.

Definition at line 387 of file DetectorInfo.cpp.

References index, m_detectorInfo, rotation, and Mantid::Kernel::toQuaterniond().

◆ signedTwoTheta() [1/2]

double Mantid::Geometry::DetectorInfo::signedTwoTheta ( const size_t  index) const

Returns signed 2 theta (signed scattering angle w.r.t. to beam direction).

Definition at line 160 of file DetectorInfo.cpp.

References index, isMonitor(), m_instrument, position, samplePosition(), and sourcePosition().

◆ signedTwoTheta() [2/2]

double Mantid::Geometry::DetectorInfo::signedTwoTheta ( const std::pair< size_t, size_t > &  index) const

Returns signed 2 theta (signed scattering angle w.r.t. to beam direction).

Definition at line 185 of file DetectorInfo.cpp.

References index, isMonitor(), m_instrument, position, samplePosition(), and sourcePosition().

◆ size()

size_t Mantid::Geometry::DetectorInfo::size ( ) const

◆ sourcePosition()

Kernel::V3D Mantid::Geometry::DetectorInfo::sourcePosition ( ) const

◆ twoTheta() [1/2]

double Mantid::Geometry::DetectorInfo::twoTheta ( const size_t  index) const

Returns 2 theta (scattering angle w.r.t. to beam direction).

Definition at line 128 of file DetectorInfo.cpp.

References index, isMonitor(), position, samplePosition(), and sourcePosition().

Referenced by export_DetectorInfo().

◆ twoTheta() [2/2]

double Mantid::Geometry::DetectorInfo::twoTheta ( const std::pair< size_t, size_t > &  index) const

Returns 2 theta (scattering angle w.r.t. to beam direction).

Definition at line 144 of file DetectorInfo.cpp.

References index, isMonitor(), position, samplePosition(), and sourcePosition().

Friends And Related Function Documentation

◆ API::SpectrumInfo

friend class API::SpectrumInfo
friend

Definition at line 113 of file DetectorInfo.h.

◆ Instrument

friend class Instrument
friend

Definition at line 114 of file DetectorInfo.h.

Member Data Documentation

◆ m_detectorIDs

std::shared_ptr<const std::vector<detid_t> > Mantid::Geometry::DetectorInfo::m_detectorIDs
private

◆ m_detectorInfo

std::unique_ptr<Beamline::DetectorInfo> Mantid::Geometry::DetectorInfo::m_detectorInfo
private

◆ m_detIDToIndex

std::shared_ptr<const std::unordered_map<detid_t, size_t> > Mantid::Geometry::DetectorInfo::m_detIDToIndex
private

Definition at line 131 of file DetectorInfo.h.

Referenced by DetectorInfo(), and indexOf().

◆ m_instrument

std::shared_ptr<const Geometry::Instrument> Mantid::Geometry::DetectorInfo::m_instrument
private

◆ m_lastDetector

std::vector<std::shared_ptr<const Geometry::IDetector> > Mantid::Geometry::DetectorInfo::m_lastDetector
mutableprivate

Definition at line 133 of file DetectorInfo.h.

Referenced by getDetector(), and getDetectorPtr().

◆ m_lastIndex

std::vector<size_t> Mantid::Geometry::DetectorInfo::m_lastIndex
mutableprivate

Definition at line 134 of file DetectorInfo.h.

Referenced by getDetector().


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