Mantid
Loading...
Searching...
No Matches
ClearMaskFlag.cpp
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 +
8
13
14namespace Mantid::Algorithms {
15
16using namespace Geometry;
17using namespace API;
18using Kernel::Direction;
19
20// Register the algorithm into the AlgorithmFactory
21DECLARE_ALGORITHM(ClearMaskFlag)
22
23
24const std::string ClearMaskFlag::name() const { return "ClearMaskFlag"; }
25
27int ClearMaskFlag::version() const { return 1; }
28
30const std::string ClearMaskFlag::category() const { return "Transforms\\Masking"; }
31
35 declareProperty(std::make_unique<WorkspaceProperty<>>("Workspace", "", Direction::InOut),
36 "Workspace to clear the mask flag of.");
37 declareProperty("ComponentName", "",
38 "Specify the instrument component to clear the "
39 "mask. If empty clears the mask flag for "
40 "the whole instrument.");
41}
42
46 MatrixWorkspace_sptr ws = getProperty("Workspace");
47 std::string componentName = getPropertyValue("ComponentName");
48 auto &detectorInfo = ws->mutableDetectorInfo();
49
50 if (!componentName.empty()) {
51 std::vector<IDetector_const_sptr> detectors;
52 ws->getInstrument()->getDetectorsInBank(detectors, componentName);
53 for (const auto &det : detectors) {
54 auto index = detectorInfo.indexOf(det->getID());
55 detectorInfo.setMasked(index, false);
56 }
57 } else {
58 detectorInfo.clearMaskFlags();
59 }
60}
61
62} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
A property class for workspaces.
ClearMaskFlag : Delete the mask flag/bit on all spectra in a workspace.
Definition: ClearMaskFlag.h:17
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
const std::string category() const override
Algorithm's category for identification.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
STL namespace.
@ InOut
Both an input & output workspace.
Definition: Property.h:55