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

A minimal class to hold the mapping between the spectrum number and its related detector ID numbers for a dataset. More...

#include <SpectrumDetectorMapping.h>

Public Member Functions

const std::set< detid_t > & getDetectorIDsForSpectrumIndex (const size_t spectrumIndex) const
 
const std::set< detid_t > & getDetectorIDsForSpectrumNo (const specnum_t spectrumNo) const
 
const sdmapgetMapping () const
 
std::set< specnum_tgetSpectrumNumbers () const
 
bool indexIsSpecNumber () const
 
 SpectrumDetectorMapping ()
 Default constructor;. More...
 
 SpectrumDetectorMapping (const MatrixWorkspace_const_sptr &workspace, const bool useSpecNoIndex=true)
 Constructor that fills the map from the spectrum-detector relationships in the given workspace. More...
 
 SpectrumDetectorMapping (const specnum_t *const spectrumNumbers, const detid_t *const detectorIDs, size_t arrayLengths)
 Constructor that fills the map from a pair c-style arrays. More...
 
 SpectrumDetectorMapping (const std::vector< specnum_t > &spectrumNumbers, const std::vector< detid_t > &detectorIDs, const std::vector< detid_t > &ignoreDetIDs=std::vector< detid_t >())
 Constructor that fills the map from a pair of vectors, ignoring the IDs in the optional ignore list. More...
 
virtual ~SpectrumDetectorMapping ()=default
 

Private Types

using sdmap = std::unordered_map< specnum_t, std::set< detid_t > >
 

Private Member Functions

void fillMapFromArray (const specnum_t *const spectrumNumbers, const detid_t *const detectorIDs, const size_t arrayLengths)
 Called by the c-array constructors to do the actual filling. More...
 
void fillMapFromVector (const std::vector< specnum_t > &spectrumNumbers, const std::vector< detid_t > &detectorIDs, const std::vector< detid_t > &ignoreDetIDs)
 Called by the vector constructors to do the actual filling. More...
 

Private Attributes

bool m_indexIsSpecNo
 
sdmap m_mapping
 The mapping of a spectrum number to zero or more detector IDs. More...
 

Detailed Description

A minimal class to hold the mapping between the spectrum number and its related detector ID numbers for a dataset.

Normally, this mapping is contained within the collection of ISpectrum objects held by the workspace. This class can be useful when you want to pass just this information and not the entire workspace, or you want to store some mapping that related to spectra that are not yet, or no longer, contained in the workspace.

Definition at line 30 of file SpectrumDetectorMapping.h.

Member Typedef Documentation

◆ sdmap

using Mantid::API::SpectrumDetectorMapping::sdmap = std::unordered_map<specnum_t, std::set<detid_t> >
private

Definition at line 31 of file SpectrumDetectorMapping.h.

Constructor & Destructor Documentation

◆ SpectrumDetectorMapping() [1/4]

Mantid::API::SpectrumDetectorMapping::SpectrumDetectorMapping ( const MatrixWorkspace_const_sptr workspace,
const bool  useSpecNoIndex = true 
)
explicit

Constructor that fills the map from the spectrum-detector relationships in the given workspace.

Exceptions
std::invalid_argumentif a null workspace pointer is passed in

Definition at line 16 of file SpectrumDetectorMapping.cpp.

References index, m_indexIsSpecNo, m_mapping, and workspace.

◆ SpectrumDetectorMapping() [2/4]

Mantid::API::SpectrumDetectorMapping::SpectrumDetectorMapping ( const std::vector< specnum_t > &  spectrumNumbers,
const std::vector< detid_t > &  detectorIDs,
const std::vector< detid_t > &  ignoreDetIDs = std::vector<detid_t>() 
)

Constructor that fills the map from a pair of vectors, ignoring the IDs in the optional ignore list.

Exceptions
std::invalid_argumentif the spectrumNumbers & detectorIDs vectors are not of equal length

Definition at line 40 of file SpectrumDetectorMapping.cpp.

References fillMapFromVector().

◆ SpectrumDetectorMapping() [3/4]

Mantid::API::SpectrumDetectorMapping::SpectrumDetectorMapping ( const specnum_t *const  spectrumNumbers,
const detid_t *const  detectorIDs,
size_t  arrayLengths 
)

Constructor that fills the map from a pair c-style arrays.

Not safe! Prefer the vector constructor where possible!

Exceptions
std::invalid_argumentif a null array pointer is passed in

Definition at line 56 of file SpectrumDetectorMapping.cpp.

References fillMapFromArray().

◆ SpectrumDetectorMapping() [4/4]

Mantid::API::SpectrumDetectorMapping::SpectrumDetectorMapping ( )

Default constructor;.

Definition at line 87 of file SpectrumDetectorMapping.cpp.

◆ ~SpectrumDetectorMapping()

virtual Mantid::API::SpectrumDetectorMapping::~SpectrumDetectorMapping ( )
virtualdefault

Member Function Documentation

◆ fillMapFromArray()

void Mantid::API::SpectrumDetectorMapping::fillMapFromArray ( const specnum_t *const  spectrumNumbers,
const detid_t *const  detectorIDs,
const size_t  arrayLengths 
)
private

Called by the c-array constructors to do the actual filling.

Definition at line 67 of file SpectrumDetectorMapping.cpp.

References m_mapping.

Referenced by SpectrumDetectorMapping().

◆ fillMapFromVector()

void Mantid::API::SpectrumDetectorMapping::fillMapFromVector ( const std::vector< specnum_t > &  spectrumNumbers,
const std::vector< detid_t > &  detectorIDs,
const std::vector< detid_t > &  ignoreDetIDs 
)
private

Called by the vector constructors to do the actual filling.

Definition at line 75 of file SpectrumDetectorMapping.cpp.

References m_mapping.

Referenced by SpectrumDetectorMapping().

◆ getDetectorIDsForSpectrumIndex()

const std::set< detid_t > & Mantid::API::SpectrumDetectorMapping::getDetectorIDsForSpectrumIndex ( const size_t  spectrumIndex) const

◆ getDetectorIDsForSpectrumNo()

const std::set< detid_t > & Mantid::API::SpectrumDetectorMapping::getDetectorIDsForSpectrumNo ( const specnum_t  spectrumNo) const

◆ getMapping()

const SpectrumDetectorMapping::sdmap & Mantid::API::SpectrumDetectorMapping::getMapping ( ) const

◆ getSpectrumNumbers()

std::set< specnum_t > Mantid::API::SpectrumDetectorMapping::getSpectrumNumbers ( ) const
Returns
An ordered set of the unique spectrum numbers

Definition at line 90 of file SpectrumDetectorMapping.cpp.

References m_mapping.

Referenced by Mantid::DataHandling::LoadEventNexusIndexSetup::makeIndexInfo().

◆ indexIsSpecNumber()

bool Mantid::API::SpectrumDetectorMapping::indexIsSpecNumber ( ) const

Member Data Documentation

◆ m_indexIsSpecNo

bool Mantid::API::SpectrumDetectorMapping::m_indexIsSpecNo
private

◆ m_mapping

sdmap Mantid::API::SpectrumDetectorMapping::m_mapping
private

The mapping of a spectrum number to zero or more detector IDs.

Definition at line 56 of file SpectrumDetectorMapping.h.

Referenced by fillMapFromArray(), fillMapFromVector(), getDetectorIDsForSpectrumIndex(), getDetectorIDsForSpectrumNo(), getMapping(), getSpectrumNumbers(), and SpectrumDetectorMapping().


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