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. More...
 
SpectrumInfoIterator< SpectrumInfobegin ()
 
const SpectrumInfoIterator< const SpectrumInfocbegin () const
 
const SpectrumInfoIterator< const SpectrumInfocend () const
 
void createDetectorIdLogMessages (const std::vector< detid_t > &detids, int64_t wsIndex) const
 
const Geometry::IDetectordetector (const size_t index) const
 Return a const reference to the detector or detector group of the spectrum with given index. More...
 
size_t detectorCount () const
 
double difcUncalibrated (const size_t index) const
 Calculate average uncalibrated DIFC value of detectors associated with this spectrum. More...
 
Kernel::UnitParametersMap diffractometerConstants (const size_t index) const
 Calculate average diffractometer constants (DIFA, DIFC, TZERO) of detectors associated with this spectrum. More...
 
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. More...
 
SpectrumInfoIterator< SpectrumInfoend ()
 
std::pair< double, double > geographicalAngles (const size_t index) const
 Calculate latitude and longitude for given spectrum index. More...
 
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. More...
 
bool hasDetectors (const size_t index) const
 Returns true if the spectrum is associated with detectors in the instrument. More...
 
bool hasUniqueDetector (const size_t index) const
 Returns true if the spectrum is associated with exactly one detector. More...
 
bool isMasked (const size_t index) const
 Returns true if the detector(s) associated with the spectrum are masked. More...
 
bool isMonitor (const size_t index) const
 Returns true if the detector(s) associated with the spectrum are monitors. 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...
 
Kernel::V3D position (const size_t index) const
 Returns the position of the spectrum with given index. More...
 
Kernel::V3D samplePosition () const
 Returns the sample position. More...
 
void setMasked (const size_t index, bool masked)
 Set the mask flag of the spectrum with given index. More...
 
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. More...
 
size_t size () const
 Returns the size of the SpectrumInfo, i.e., the number of spectra. More...
 
Kernel::V3D sourcePosition () const
 Returns the source position. More...
 
const SpectrumDefinition & spectrumDefinition (const size_t index) const
 Returns a const reference to the SpectrumDefinition of the spectrum. More...
 
 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. More...
 
 ~SpectrumInfo ()
 

Private Member Functions

const SpectrumDefinition & checkAndGetSpectrumDefinition (const size_t index) const
 
const Geometry::IDetectorgetDetector (const size_t index) const
 

Private Attributes

Geometry::DetectorInfom_detectorInfo
 
const ExperimentInfom_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 53 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 29 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 113 of file SpectrumInfo.cpp.

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

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

◆ begin()

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

Definition at line 368 of file SpectrumInfo.cpp.

◆ cbegin()

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

Definition at line 373 of file SpectrumInfo.cpp.

◆ cend()

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

Definition at line 376 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 40 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 203 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::populateTable().

◆ 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 193 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 155 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::populateTable().

◆ end()

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

Definition at line 371 of file SpectrumInfo.cpp.

References size().

◆ 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 125 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 222 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

Returns true if the spectrum is associated with exactly one detector.

Definition at line 301 of file SpectrumInfo.cpp.

References index, and spectrumDefinition().

Referenced by export_SpectrumInfo().

◆ 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

◆ 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 310 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()

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

Returns the signed scattering angle 2 theta in radians (angle w.r.t.

to beam direction).

Throws an exception if the spectrum is a monitor.

Definition at line 99 of file SpectrumInfo.cpp.

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

Referenced by export_SpectrumInfo(), getDetectorValues(), MantidQt::MantidWidgets::ImageInfoModelMatrixWS::info(), Mantid::Algorithms::populateTable(), Mantid::Algorithms::ConvertAxisByFormula::setGeometryValues(), and signedTwoTheta().

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

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

Friends And Related Function Documentation

◆ ExperimentInfo

friend class ExperimentInfo
friend

Definition at line 102 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 111 of file SpectrumInfo.h.

Referenced by getDetector().

◆ m_lastIndex

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

Definition at line 112 of file SpectrumInfo.h.

Referenced by getDetector().

◆ m_spectrumInfo

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

Definition at line 110 of file SpectrumInfo.h.

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


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