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
11#include "MantidDataObjects/DllConfig.h"
16
17namespace Mantid {
18namespace DataObjects {
19
20// Reference Docs
21// Concepts: TODO
22// API: TODO
23
24class MANTID_DATAOBJECTS_DLL MaskWorkspace : public SpecialWorkspace2D, public API::IMaskWorkspace {
25public:
26 MaskWorkspace() = default;
27 MaskWorkspace(std::size_t numvectors);
28 MaskWorkspace(const Mantid::Geometry::Instrument_const_sptr &instrument, const bool includeMonitors = false);
30 inline MaskWorkspace(const std::vector<detid_t> &detids) : SpecialWorkspace2D(detids) { this->clearMask(); }
31
33 std::unique_ptr<MaskWorkspace> clone() const { return std::unique_ptr<MaskWorkspace>(doClone()); }
35 std::unique_ptr<MaskWorkspace> cloneEmpty() const { return std::unique_ptr<MaskWorkspace>(doCloneEmpty()); }
36 MaskWorkspace &operator=(const MaskWorkspace &other) = delete;
37 bool containsDetID(const detid_t detectorID) const override;
38 bool containsDetIDs(const std::set<detid_t> &detectorIDs) const override;
39 bool containsDetIDs(const std::vector<detid_t> &detectorIDs) const override;
40 bool isMasked(const detid_t detectorID) const override;
41 bool isMasked(const std::set<detid_t> &detectorIDs) const override;
42 bool isMaskedIndex(const std::size_t wkspIndex) const;
43 void setMasked(const detid_t detectorID, const bool mask = true) override;
44 void setMasked(const std::set<detid_t> &detectorIDs, const bool mask = true) override;
45 void setMaskedIndex(const std::size_t wkspIndex, const bool mask = true);
46 std::size_t getNumberMasked() const override;
47 std::set<detid_t> getMaskedDetectors() const;
48 std::set<std::size_t> getMaskedWkspIndices() const;
49
50 const std::string id() const override;
51
53 void copyFrom(std::shared_ptr<const SpecialWorkspace2D> sourcews) override;
54
56 void combineToDetectorMasks(Mantid::Geometry::DetectorInfo &detectors) const;
57
59 void combineToDetectorMasks() { combineToDetectorMasks(mutableDetectorInfo()); }
60
62 void combineFromDetectorMasks(const Mantid::Geometry::DetectorInfo &detectors);
63
66
68 bool isConsistentWithDetectorMasks(const Mantid::Geometry::DetectorInfo &detectors) const;
69
71 bool isConsistentWithDetectorMasks() const { return isConsistentWithDetectorMasks(detectorInfo()); }
72
73protected:
75 MaskWorkspace(const MaskWorkspace &) = default;
76
78 const std::string toString() const override;
79
80private:
81 MaskWorkspace *doClone() const override { return new MaskWorkspace(*this); }
82 MaskWorkspace *doCloneEmpty() const override { return new MaskWorkspace(); }
83
84 IMaskWorkspace *doInterfaceClone() const override { return doClone(); }
86 void clearMask();
87
89 bool hasInstrument() const;
90};
91
93using MaskWorkspace_sptr = std::shared_ptr<MaskWorkspace>;
94
96using MaskWorkspace_const_sptr = std::shared_ptr<const MaskWorkspace>;
97
98} // namespace DataObjects
99} // namespace Mantid
100
101// Instantiated and exported by DataObjects/src/PropertyWithValue.cpp
103 Mantid::Kernel::PropertyWithValue<std::shared_ptr<Mantid::DataObjects::MaskWorkspace>>);
104
105#ifndef DataObjects_EXPORTS
107namespace Mantid::API {
109extern template class MANTID_DATAOBJECTS_DLL WorkspaceProperty<DataObjects::MaskWorkspace>;
111} // namespace Mantid::API
112#endif
MANTID_DATAOBJECTS_EXTERN_TEMPLATE(Mantid::Kernel::PropertyWithValue< std::shared_ptr< Mantid::DataObjects::MaskWorkspace > >)
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.
MaskWorkspace(const std::vector< detid_t > &detids)
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....
The concrete, templated class for properties.
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.