17 : m_indexIsSpecNo(useSpecNoIndex) {
19 throw std::invalid_argument(
"SpectrumDetectorMapping: Null shared workspace pointer passed");
22 for (
size_t i = 0; i <
workspace->getNumberHistograms(); ++i) {
23 auto &spectrum =
workspace->getSpectrum(i);
27 index = spectrum.getSpectrumNo();
29 index =
static_cast<int>(i);
41 const std::vector<detid_t> &detectorIDs,
42 const std::vector<detid_t> &ignoreDetIDs)
43 : m_indexIsSpecNo(true) {
44 if (spectrumNumbers.size() != detectorIDs.size()) {
45 throw std::invalid_argument(
"SpectrumDetectorMapping: Different length "
46 "spectrum number & detector ID array passed");
57 const detid_t *
const detectorIDs,
size_t arrayLengths)
58 : m_indexIsSpecNo(true) {
59 if (spectrumNumbers ==
nullptr || detectorIDs ==
nullptr) {
60 throw std::invalid_argument(
"SpectrumDetectorMapping: Null array pointer passed");
68 const size_t arrayLengths) {
69 for (
size_t i = 0; i < arrayLengths; ++i) {
70 m_mapping[spectrumNumbers[i]].insert(detectorIDs[i]);
76 const std::vector<detid_t> &detectorIDs,
77 const std::vector<detid_t> &ignoreDetIDs) {
78 std::set<detid_t> ignoreIDs(ignoreDetIDs.begin(), ignoreDetIDs.end());
79 const size_t nspec(spectrumNumbers.size());
80 for (
size_t i = 0; i < nspec; ++i) {
81 auto id = detectorIDs[i];
82 if (ignoreIDs.count(
id) == 0)
91 std::set<specnum_t> specs;
93 for (
auto it =
m_mapping.begin(); it != itend; ++it) {
94 specs.insert(it->first);
101 throw std::runtime_error(
"Indices are in the spectrum detector map, not spectrum number.");
107 throw std::runtime_error(
"Spectrum numbers are in the spectrum detector map, not index.");
108 return m_mapping.at(
static_cast<int>(spectrumIndex));
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
SpectrumDetectorMapping()
Default constructor;.
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.
sdmap m_mapping
The mapping of a spectrum number to zero or more detector IDs.
std::unordered_map< specnum_t, std::set< detid_t > > sdmap
const sdmap & getMapping() const
const std::set< detid_t > & getDetectorIDsForSpectrumNo(const specnum_t spectrumNo) const
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.
const std::set< detid_t > & getDetectorIDsForSpectrumIndex(const size_t spectrumIndex) const
bool indexIsSpecNumber() const
std::set< specnum_t > getSpectrumNumbers() const
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
int32_t specnum_t
Typedef for a spectrum Number.