Mantid
Loading...
Searching...
No Matches
SpectrumDetectorMapping.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2013 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include <set>
10#include <vector>
11#ifndef Q_MOC_RUN
12#include <unordered_map>
13#endif
14
15#include "MantidAPI/DllConfig.h"
18
19namespace Mantid {
20namespace API {
21
30class MANTID_API_DLL SpectrumDetectorMapping {
31 using sdmap = std::unordered_map<specnum_t, std::set<detid_t>>;
32
33public:
34 explicit SpectrumDetectorMapping(const MatrixWorkspace_const_sptr &workspace, const bool useSpecNoIndex = true);
35 SpectrumDetectorMapping(const std::vector<specnum_t> &spectrumNumbers, const std::vector<detid_t> &detectorIDs,
36 const std::vector<detid_t> &ignoreDetIDs = std::vector<detid_t>());
37 SpectrumDetectorMapping(const specnum_t *const spectrumNumbers, const detid_t *const detectorIDs,
38 size_t arrayLengths);
40 virtual ~SpectrumDetectorMapping() = default;
41
42 std::set<specnum_t> getSpectrumNumbers() const;
43 const std::set<detid_t> &getDetectorIDsForSpectrumNo(const specnum_t spectrumNo) const;
44 const std::set<detid_t> &getDetectorIDsForSpectrumIndex(const size_t spectrumIndex) const;
45 const sdmap &getMapping() const;
46 bool indexIsSpecNumber() const;
47
48private:
49 void fillMapFromArray(const specnum_t *const spectrumNumbers, const detid_t *const detectorIDs,
50 const size_t arrayLengths);
51 void fillMapFromVector(const std::vector<specnum_t> &spectrumNumbers, const std::vector<detid_t> &detectorIDs,
52 const std::vector<detid_t> &ignoreDetIDs);
53
57};
58
59} // namespace API
60} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
A minimal class to hold the mapping between the spectrum number and its related detector ID numbers f...
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
virtual ~SpectrumDetectorMapping()=default
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
Helper class which provides the Collimation Length for SANS instruments.
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16