Mantid
Loading...
Searching...
No Matches
ClearInstrumentParameters.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 +
11
12namespace Mantid::Algorithms {
13
14// Register the algorithm into the AlgorithmFactory
15DECLARE_ALGORITHM(ClearInstrumentParameters)
16
17using namespace Kernel;
18using namespace API;
19
21const std::string ClearInstrumentParameters::name() const { return "ClearInstrumentParameters"; }
22
24const std::string ClearInstrumentParameters::summary() const {
25 return "Clears all the parameters associated with a workspace's instrument.";
26}
27
29int ClearInstrumentParameters::version() const { return 1; }
30
32const std::string ClearInstrumentParameters::category() const { return "DataHandling\\Instrument"; }
33
38 std::make_unique<WorkspaceProperty<>>("Workspace", "", Direction::InOut, std::make_shared<InstrumentValidator>()),
39 "Workspace whose instrument parameters are to be cleared.");
40}
41
45 const MatrixWorkspace_sptr ws = getProperty("Workspace");
46 // Clear old parameters. We also want to clear fields stored in DetectorInfo
47 // (masking, positions, rotations). By setting the base instrument (which
48 // does not include a ParameterMap or DetectorInfo) we make use of the
49 // mechanism in ExperimentInfo that builds a clean DetectorInfo from the
50 // instrument being set.
51 const auto instrument = ws->getInstrument();
52 ws->setInstrument(instrument->baseInstrument());
53}
54
55} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
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
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
A property class for workspaces.
const std::string name() const override
Algorithm's name for identification.
const std::string summary() const override
Summary of the algorithm's purpose.
void init() override
Initialize the algorithm's properties.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ InOut
Both an input & output workspace.
Definition: Property.h:55