Mantid
Loading...
Searching...
No Matches
MaskWorkspace.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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
14
15namespace Mantid {
16namespace DataObjects {
17
18class MANTID_DATAOBJECTS_DLL MaskWorkspace : public SpecialWorkspace2D, public API::IMaskWorkspace {
19public:
20 MaskWorkspace() = default;
21 MaskWorkspace(std::size_t numvectors);
22 MaskWorkspace(const Mantid::Geometry::Instrument_const_sptr &instrument, const bool includeMonitors = false);
24
26 std::unique_ptr<MaskWorkspace> clone() const { return std::unique_ptr<MaskWorkspace>(doClone()); }
28 std::unique_ptr<MaskWorkspace> cloneEmpty() const { return std::unique_ptr<MaskWorkspace>(doCloneEmpty()); }
29 MaskWorkspace &operator=(const MaskWorkspace &other) = delete;
30 bool isMasked(const detid_t detectorID) const override;
31 bool isMasked(const std::set<detid_t> &detectorIDs) const override;
32 bool isMaskedIndex(const std::size_t wkspIndex) const;
33 void setMasked(const detid_t detectorID, const bool mask = true) override;
34 void setMasked(const std::set<detid_t> &detectorIDs, const bool mask = true) override;
35 void setMaskedIndex(const std::size_t wkspIndex, const bool mask = true);
36 std::size_t getNumberMasked() const override;
37 std::set<detid_t> getMaskedDetectors() const;
38 std::set<std::size_t> getMaskedWkspIndices() const;
39
40 const std::string id() const override;
41
43 void copyFrom(std::shared_ptr<const SpecialWorkspace2D> sourcews) override;
44
46 void combineToDetectorMasks(Mantid::Geometry::DetectorInfo &detectors) const;
47
49 void combineToDetectorMasks() { combineToDetectorMasks(mutableDetectorInfo()); }
50
52 void combineFromDetectorMasks(const Mantid::Geometry::DetectorInfo &detectors);
53
56
58 bool isConsistentWithDetectorMasks(const Mantid::Geometry::DetectorInfo &detectors) const;
59
61 bool isConsistentWithDetectorMasks() const { return isConsistentWithDetectorMasks(detectorInfo()); }
62
63protected:
65 MaskWorkspace(const MaskWorkspace &) = default;
66
68 const std::string toString() const override;
69
70private:
71 MaskWorkspace *doClone() const override { return new MaskWorkspace(*this); }
72 MaskWorkspace *doCloneEmpty() const override { return new MaskWorkspace(); }
73
74 IMaskWorkspace *doInterfaceClone() const override { return doClone(); }
76 void clearMask();
77
79 bool hasInstrument() const;
80};
81
83using MaskWorkspace_sptr = std::shared_ptr<MaskWorkspace>;
84
86using MaskWorkspace_const_sptr = std::shared_ptr<const MaskWorkspace>;
87
88} // namespace DataObjects
89} // namespace Mantid
This class provides an interface to a MaskWorkspace.
std::unique_ptr< MaskWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
MaskWorkspace & operator=(const MaskWorkspace &other)=delete
MaskWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
bool isConsistentWithDetectorMasks() const
Test consistency between the values from this workspace and its own detectors' mask flags.
void combineFromDetectorMasks()
Ensure that this workspace's values include the values from its own detectors' mask flags.
MaskWorkspace(const MaskWorkspace &)=default
Protected copy constructor. May be used by childs for cloning.
std::unique_ptr< MaskWorkspace > clone() const
Returns a clone of the workspace.
void combineToDetectorMasks()
Ensure that this mask workspace's detectors mask flags include the workspace values.
MaskWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
IMaskWorkspace * doInterfaceClone() const override
returns a clone of the workspace as the interface
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< const MaskWorkspace > MaskWorkspace_const_sptr
shared pointer to a const MaskWorkspace
std::shared_ptr< MaskWorkspace > MaskWorkspace_sptr
shared pointer to the MaskWorkspace class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
std::string toString(const T &value)
Convert values to strings.
Helper class which provides the Collimation Length for SANS instruments.