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

API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2.0. More...

#include <SpectrumInfo.h>

Public Member Functions

double azimuthal (const size_t index) const
 Returns the out-of-plane angle in radians (angle w.r.t.
 
SpectrumInfoIterator< SpectrumInfo > begin ()
 
Geometry::BoundingBox boundingBox (const size_t index) const
 Returns the bounding box of the detector(s) of the spectrum with given index.
 
const SpectrumInfoIterator< const SpectrumInfo > cbegin () const
 
const SpectrumInfoIterator< const SpectrumInfo > cend () const
 
void createDetectorIdLogMessages (const std::vector< detid_t > &detids, int64_t wsIndex) const
 
const Geometry::IDetector & detector (const size_t index) const
 Return a const reference to the detector or detector group of the spectrum with given index.
 
size_t detectorCount () const
 
double difcUncalibrated (const size_t index) const
 Calculate average uncalibrated DIFC value of detectors associated with this spectrum.
 
Kernel::UnitParametersMap diffractometerConstants (const size_t index) const
 Calculate average diffractometer constants (DIFA, DIFC, TZERO) of detectors associated with this spectrum.
 
Kernel::UnitParametersMap diffractometerConstants (const size_t index, std::vector< detid_t > &uncalibratedDets) const
 Calculate average diffractometer constants (DIFA, DIFC, TZERO) of detectors associated with this spectrum.
 
SpectrumInfoIterator< SpectrumInfo > end ()
 
detid_t firstDetectorID (const size_t index) const
 Returns the detector ID of the first detector of the spectrum with given index.
 
size_t firstDetectorIndex (const size_t index) const
 Returns the detector index of the first detector of the spectrum with given index.
 
std::pair< double, double > geographicalAngles (const size_t index) const
 Calculate latitude and longitude for given spectrum index.
 
void getDetectorValues (const Kernel::Unit &inputUnit, const Kernel::Unit &outputUnit, const Kernel::DeltaEMode::Type emode, const bool signedTheta, int64_t wsIndex, Kernel::UnitParametersMap &pmap) const
 Get the detector values relevant to unit conversion for a workspace index.
 
bool hasDetectors (const size_t index) const
 Returns true if the spectrum is associated with detectors in the instrument.
 
bool hasUniqueDetector (const size_t index) const
 Returns true if the spectrum is associated with exactly one detector.
 
bool isMasked (const size_t index) const
 Returns true if the detector(s) associated with the spectrum are masked.
 
bool isMonitor (const size_t index) const
 Returns true if the detector(s) associated with the spectrum are monitors.
 
double l1 () const
 Returns L1 (distance from source to sample).
 
double l2 (const size_t index) const
 Returns L2 (distance from sample to spectrum).
 
double phi (const size_t index) const
 Returns the angle of the spectrum position about the lab-frame z axis, atan2(y, x), in radians.
 
double phiOffset (const size_t index, const double offset) const
 Returns phi() reflected about offset (radians): offset - phi for phi >= 0 and -(offset + phi) otherwise.
 
Kernel::V3D position (const size_t index) const
 Returns the position of the spectrum with given index.
 
Kernel::V3D samplePosition () const
 Returns the sample position.
 
void setMasked (const size_t index, bool masked)
 Set the mask flag of the spectrum with given index.
 
const Kernel::cow_ptr< std::vector< SpectrumDefinition > > & sharedSpectrumDefinitions () const
 
double signedTwoTheta (const size_t index) const
 Returns the signed scattering angle 2 theta in radians (angle w.r.t.
 
double signedTwoTheta (const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis) const
 Returns the average signed angle between the vectors from observer to each detector of the spectrum and axis, signed using the instrument's theta-sign axis (ReferenceFrame::vecThetaSign).
 
double signedTwoTheta (const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis, const Kernel::V3D &instrumentUp) const
 Returns the average signed angle between the vectors from observer to each detector of the spectrum and axis, signed according to the rotation direction relative to axis and instrumentUp.
 
size_t size () const
 Returns the size of the SpectrumInfo, i.e., the number of spectra.
 
Kernel::V3D sourcePosition () const
 Returns the source position.
 
const SpectrumDefinition & spectrumDefinition (const size_t index) const
 Returns a const reference to the SpectrumDefinition of the spectrum.
 
 SpectrumInfo (const Beamline::SpectrumInfo &spectrumInfo, const ExperimentInfo &experimentInfo, Geometry::DetectorInfo &detectorInfo)
 
double twoTheta (const size_t index) const
 Returns the scattering angle 2 theta in radians (angle w.r.t.
 
double twoTheta (const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis) const
 Returns the average angle between the vectors from observer to each detector of the spectrum and axis.
 
 ~SpectrumInfo ()
 

Private Member Functions

const SpectrumDefinition & checkAndGetSpectrumDefinition (const size_t index) const
 
const Geometry::IDetector & getDetector (const size_t index) const
 

Private Attributes

Geometry::DetectorInfo & m_detectorInfo
 
const ExperimentInfo & m_experimentInfo
 
std::vector< std::shared_ptr< const Geometry::IDetector > > m_lastDetector
 
std::vector< size_t > m_lastIndex
 
const Beamline::SpectrumInfo & m_spectrumInfo
 

Friends

class ExperimentInfo
 

Detailed Description

API::SpectrumInfo is an intermediate step towards a SpectrumInfo 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.

SpectrumInfo provides easy access to commonly used parameters of individual spectra (which may correspond to one or more 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 54 of file SpectrumInfo.h.

Constructor & Destructor Documentation

◆ SpectrumInfo()

Mantid::API::SpectrumInfo::SpectrumInfo ( const Beamline::SpectrumInfo &  spectrumInfo,
const ExperimentInfo &  experimentInfo,
Geometry::DetectorInfo &  detectorInfo 
)

Definition at line 34 of file SpectrumInfo.cpp.

◆ ~SpectrumInfo()

Mantid::API::SpectrumInfo::~SpectrumInfo ( )
default

Member Function Documentation

◆ azimuthal()

double Mantid::API::SpectrumInfo::azimuthal ( const size_t  index) const

Returns the out-of-plane angle in radians (angle w.r.t.

to vecPointingHorizontal direction).

Throws an exception if the spectrum is a monitor.

Definition at line 118 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), index, and Mantid::Geometry::x.

Referenced by export_SpectrumInfo(), and MantidQt::MantidWidgets::ImageInfoModelMatrixWS::info().

◆ begin()

SpectrumInfoIt Mantid::API::SpectrumInfo::begin ( )

Definition at line 492 of file SpectrumInfo.cpp.

◆ boundingBox()

Geometry::BoundingBox Mantid::API::SpectrumInfo::boundingBox ( const size_t  index) const

Returns the bounding box of the detector(s) of the spectrum with given index.

For spectra with more than one detector this is the union of the bounding boxes of the detectors. Throws Kernel::Exception::NotFoundError if the spectrum has no detectors.

Definition at line 476 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), Mantid::API::ExperimentInfo::componentInfo(), Mantid::Geometry::BoundingBox::grow(), index, and m_experimentInfo.

◆ cbegin()

const SpectrumInfoConstIt Mantid::API::SpectrumInfo::cbegin ( ) const

Definition at line 497 of file SpectrumInfo.cpp.

◆ cend()

const SpectrumInfoConstIt Mantid::API::SpectrumInfo::cend ( ) const

Definition at line 500 of file SpectrumInfo.cpp.

References size().

◆ checkAndGetSpectrumDefinition()

const SpectrumDefinition & Mantid::API::SpectrumInfo::checkAndGetSpectrumDefinition ( const size_t  index) const
private

◆ createDetectorIdLogMessages()

void Mantid::API::SpectrumInfo::createDetectorIdLogMessages ( const std::vector< detid_t > &  detids,
int64_t  wsIndex 
) const

◆ detector()

const Geometry::IDetector & Mantid::API::SpectrumInfo::detector ( const size_t  index) const

◆ detectorCount()

size_t Mantid::API::SpectrumInfo::detectorCount ( ) const

Definition at line 45 of file SpectrumInfo.cpp.

References m_spectrumInfo.

Referenced by export_SpectrumInfo().

◆ difcUncalibrated()

double Mantid::API::SpectrumInfo::difcUncalibrated ( const size_t  index) const

Calculate average uncalibrated DIFC value of detectors associated with this spectrum.

Parameters
indexIndex of the spectrum that DIFC is required for
Returns
The average DIFC

Definition at line 282 of file SpectrumInfo.cpp.

References index, l1(), Mantid::Kernel::l2, Mantid::Kernel::Units::tofToDSpacingFactor(), and Mantid::Kernel::twoTheta.

Referenced by Mantid::Algorithms::RemoveLowResTOF::calcTofMin(), diffractometerConstants(), export_SpectrumInfo(), getDetectorValues(), and Mantid::Algorithms::CreateDetectorTable::getDiffConst().

◆ diffractometerConstants() [1/2]

UnitParametersMap Mantid::API::SpectrumInfo::diffractometerConstants ( const size_t  index) const

Calculate average diffractometer constants (DIFA, DIFC, TZERO) of detectors associated with this spectrum.

Use calibrated values where possible, filling in with uncalibrated values where they're missing

Parameters
indexIndex of the spectrum that constants are required for
Returns
map containing the average constants

Definition at line 272 of file SpectrumInfo.cpp.

References diffractometerConstants(), and index.

◆ diffractometerConstants() [2/2]

UnitParametersMap Mantid::API::SpectrumInfo::diffractometerConstants ( const size_t  index,
std::vector< detid_t > &  warningDets 
) const

Calculate average diffractometer constants (DIFA, DIFC, TZERO) of detectors associated with this spectrum.

Use calibrated values where possible, filling in with uncalibrated values where they're missing

Parameters
indexIndex of the spectrum that constants are required for
warningDetsA vector containing the det ids where an uncalibrated value was used in the situation where some dets have calibrated values and some don't
Returns
map containing the average constants

Definition at line 233 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), Mantid::Kernel::difa, Mantid::Kernel::difc, difcUncalibrated(), Mantid::Geometry::DetectorInfo::diffractometerConstants(), index, Mantid::Geometry::DetectorInfo::isScanning(), m_detectorInfo, spectrumDefinition(), and Mantid::Kernel::tzero.

Referenced by diffractometerConstants(), export_SpectrumInfo(), Mantid::DataHandling::SaveGSS::generateBankHeader(), getDetectorValues(), and Mantid::Algorithms::CreateDetectorTable::getDiffConst().

◆ end()

SpectrumInfoIt Mantid::API::SpectrumInfo::end ( )

Definition at line 495 of file SpectrumInfo.cpp.

References size().

◆ firstDetectorID()

detid_t Mantid::API::SpectrumInfo::firstDetectorID ( const size_t  index) const

Returns the detector ID of the first detector of the spectrum with given index.

For spectra with more than one detector this is the ID of the first entry in the spectrum definition. Throws Kernel::Exception::NotFoundError if the spectrum has no detectors.

Definition at line 458 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), Mantid::Geometry::DetectorInfo::detid(), index, and m_detectorInfo.

Referenced by Mantid::MDAlgorithms::MDNormBase::calculateNormInner(), Mantid::DataHandling::GenerateGroupingPowder::createGroups(), Mantid::Algorithms::CreateDetectorTable::getQ(), Mantid::DataHandling::GenerateGroupingPowder::saveAsPAR(), and Mantid::Algorithms::CreateDetectorTable::setup().

◆ firstDetectorIndex()

size_t Mantid::API::SpectrumInfo::firstDetectorIndex ( const size_t  index) const

Returns the detector index of the first detector of the spectrum with given index.

For spectra with more than one detector this is the first entry in the spectrum definition. The index is valid for both DetectorInfo and ComponentInfo. Throws Kernel::Exception::NotFoundError if the spectrum has no detectors.

Definition at line 467 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), and index.

◆ geographicalAngles()

std::pair< double, double > Mantid::API::SpectrumInfo::geographicalAngles ( const size_t  index) const

Calculate latitude and longitude for given spectrum index.

Parameters
indexIndex of the spectrum that lat/long are required for
Returns
A pair containing the latitude and longitude values.

Definition at line 203 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), Mantid::Geometry::DetectorInfo::geographicalAngles(), index, m_detectorInfo, size(), and spectrumDefinition().

Referenced by Mantid::Algorithms::SparseWorkspace::bilinearInterpolateFromDetectorGrid(), Mantid::Algorithms::SparseWorkspace::extremeAngles(), geographicalAngles(), and Mantid::Algorithms::SparseWorkspace::interpolateFromDetectorGrid().

◆ getDetector()

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

◆ getDetectorValues()

void Mantid::API::SpectrumInfo::getDetectorValues ( const Kernel::Unit &  inputUnit,
const Kernel::Unit &  outputUnit,
const Kernel::DeltaEMode::Type  emode,
const bool  signedTheta,
int64_t  wsIndex,
Kernel::UnitParametersMap &  pmap 
) const

Get the detector values relevant to unit conversion for a workspace index.

Parameters
inputUnit:: The input unit (Empty implies "all")
outputUnit:: The output unit (Empty implies "all")
emode:: The energy mode
signedTheta:: Return twotheta with sign or without
wsIndex:: The workspace index
pmap:: a map containing values for conversion parameters that are required by unit classes to perform their conversions eg efixed. It can contain values on the way in if a look up isn't desired here eg if value supplied in parameters to the calling algorithm

Definition at line 301 of file SpectrumInfo.cpp.

References createDetectorIdLogMessages(), Mantid::Kernel::Logger::debug(), detector(), difcUncalibrated(), diffractometerConstants(), Mantid::Kernel::DeltaEMode::Elastic, Mantid::API::g_log, Mantid::API::ExperimentInfo::getEFixedGivenEMode(), hasDetectors(), isMonitor(), Mantid::Kernel::l2, m_experimentInfo, signedTwoTheta(), Mantid::Kernel::twoTheta, Mantid::Kernel::Unit::unitID(), and Mantid::Kernel::Logger::warning().

Referenced by Mantid::Crystal::FindSXPeaksHelper::PeakFindingStrategy::convertToTOF(), Mantid::Algorithms::CalculatePlaczek::exec(), Mantid::Algorithms::BackgroundHelper::removeBackground(), MantidQt::MantidWidgets::ImageInfoModelMatrixWS::setUnitsInfo(), Mantid::Crystal::FindSXPeaksHelper::SXPeak::SXPeak(), and Mantid::Algorithms::RemoveBins::transformRangeUnit().

◆ hasDetectors()

bool Mantid::API::SpectrumInfo::hasDetectors ( const size_t  index) const

◆ hasUniqueDetector()

bool Mantid::API::SpectrumInfo::hasUniqueDetector ( const size_t  index) const

◆ isMasked()

bool Mantid::API::SpectrumInfo::isMasked ( const size_t  index) const

◆ isMonitor()

bool Mantid::API::SpectrumInfo::isMonitor ( const size_t  index) const

◆ l1()

double Mantid::API::SpectrumInfo::l1 ( ) const

◆ l2()

double Mantid::API::SpectrumInfo::l2 ( const size_t  index) const

◆ phi()

double Mantid::API::SpectrumInfo::phi ( const size_t  index) const

Returns the angle of the spectrum position about the lab-frame z axis, atan2(y, x), in radians.

This is the Instrument-2.0 replacement for IDetector::getPhi. For a spectrum with several detectors the angle of the average position is returned, not the average of the angles. It is measured from the lab origin and ignores the reference frame; see azimuthal() for the angle about the beam measured from the sample.

Definition at line 173 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), index, m_detectorInfo, Mantid::Geometry::DetectorInfo::phi(), Mantid::Kernel::Tolerance, and Mantid::Geometry::x.

Referenced by Mantid::Algorithms::AbsorptionCorrection::calculateDistances(), Mantid::Algorithms::PaalmanPingsAbsorptionCorrection::calculateDistances(), Mantid::Algorithms::MultipleScatteringCorrection::calculateL2Ds(), Mantid::Algorithms::MultipleScatteringCorrection::calculateL2Ds(), Mantid::MDAlgorithms::MDNormBase::calculateNormInner(), Mantid::Crystal::FindSXPeaksHelper::PeakFindingStrategy::calculatePhi(), export_SpectrumInfo(), and phiOffset().

◆ phiOffset()

double Mantid::API::SpectrumInfo::phiOffset ( const size_t  index,
const double  offset 
) const

Returns phi() reflected about offset (radians): offset - phi for phi >= 0 and -(offset + phi) otherwise.

This is the Instrument-2.0 replacement for IDetector::getPhiOffset.

Definition at line 194 of file SpectrumInfo.cpp.

References index, and phi().

Referenced by export_SpectrumInfo().

◆ position()

Kernel::V3D Mantid::API::SpectrumInfo::position ( const size_t  index) const

◆ samplePosition()

Kernel::V3D Mantid::API::SpectrumInfo::samplePosition ( ) const

◆ setMasked()

void Mantid::API::SpectrumInfo::setMasked ( const size_t  index,
bool  masked 
)

Set the mask flag of the spectrum with given index.

Not thread safe.

Currently this simply sets the mask flags for the underlying detectors.

Definition at line 389 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), index, m_detectorInfo, and Mantid::Geometry::DetectorInfo::setMasked().

Referenced by export_SpectrumInfo(), and Mantid::Algorithms::BinaryOperation::propagateSpectraMask().

◆ sharedSpectrumDefinitions()

const Kernel::cow_ptr< std::vector< SpectrumDefinition > > & Mantid::API::SpectrumInfo::sharedSpectrumDefinitions ( ) const

◆ signedTwoTheta() [1/3]

double Mantid::API::SpectrumInfo::signedTwoTheta ( const size_t  index) const

◆ signedTwoTheta() [2/3]

double Mantid::API::SpectrumInfo::signedTwoTheta ( const size_t  index,
const Kernel::V3D &  observer,
const Kernel::V3D &  axis 
) const

Returns the average signed angle between the vectors from observer to each detector of the spectrum and axis, signed using the instrument's theta-sign axis (ReferenceFrame::vecThetaSign).

Definition at line 158 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), index, signedTwoTheta(), and Mantid::Geometry::x.

◆ signedTwoTheta() [3/3]

double Mantid::API::SpectrumInfo::signedTwoTheta ( const size_t  index,
const Kernel::V3D &  observer,
const Kernel::V3D &  axis,
const Kernel::V3D &  instrumentUp 
) const

Returns the average signed angle between the vectors from observer to each detector of the spectrum and axis, signed according to the rotation direction relative to axis and instrumentUp.

This is the Instrument-2.0 replacement for IDetector::getSignedTwoTheta. No monitor check is performed.

Definition at line 145 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), index, signedTwoTheta(), and Mantid::Geometry::x.

◆ size()

size_t Mantid::API::SpectrumInfo::size ( ) const

◆ sourcePosition()

Kernel::V3D Mantid::API::SpectrumInfo::sourcePosition ( ) const

◆ spectrumDefinition()

const SpectrumDefinition & Mantid::API::SpectrumInfo::spectrumDefinition ( const size_t  index) const

◆ twoTheta() [1/2]

double Mantid::API::SpectrumInfo::twoTheta ( const size_t  index) const

◆ twoTheta() [2/2]

double Mantid::API::SpectrumInfo::twoTheta ( const size_t  index,
const Kernel::V3D &  observer,
const Kernel::V3D &  axis 
) const

Returns the average angle between the vectors from observer to each detector of the spectrum and axis.

This is the Instrument-2.0 replacement for IDetector::getTwoTheta. Unlike twoTheta(index), the observer and axis are supplied by the caller rather than taken from the sample and beam, and no monitor check is performed.

Definition at line 131 of file SpectrumInfo.cpp.

References checkAndGetSpectrumDefinition(), index, Mantid::Kernel::twoTheta, and Mantid::Geometry::x.

Friends And Related Symbol Documentation

◆ ExperimentInfo

friend class ExperimentInfo
friend

Definition at line 112 of file SpectrumInfo.h.

Member Data Documentation

◆ m_detectorInfo

Geometry::DetectorInfo& Mantid::API::SpectrumInfo::m_detectorInfo
private

◆ m_experimentInfo

const ExperimentInfo& Mantid::API::SpectrumInfo::m_experimentInfo
private

◆ m_lastDetector

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

Definition at line 124 of file SpectrumInfo.h.

Referenced by getDetector().

◆ m_lastIndex

std::vector<size_t> Mantid::API::SpectrumInfo::m_lastIndex
mutableprivate

Definition at line 125 of file SpectrumInfo.h.

Referenced by getDetector().

◆ m_spectrumInfo

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

Definition at line 123 of file SpectrumInfo.h.

Referenced by detectorCount(), sharedSpectrumDefinitions(), size(), and spectrumDefinition().


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