-
Notifications
You must be signed in to change notification settings - Fork 122
/
ClearInstrumentParameters.cpp
62 lines (52 loc) · 2.27 KB
/
ClearInstrumentParameters.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAlgorithms/ClearInstrumentParameters.h"
#include "MantidAPI/InstrumentValidator.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidGeometry/Instrument.h"
namespace Mantid {
namespace Algorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(ClearInstrumentParameters)
using namespace Kernel;
using namespace API;
/// Algorithm's name for identification. @see Algorithm::name
const std::string ClearInstrumentParameters::name() const {
return "ClearInstrumentParameters";
}
/// Summary of the algorithm's purpose. @see Algorithm::summary
const std::string ClearInstrumentParameters::summary() const {
return "Clears all the parameters associated with a workspace's instrument.";
}
/// Algorithm's version for identification. @see Algorithm::version
int ClearInstrumentParameters::version() const { return 1; }
/// Algorithm's category for identification. @see Algorithm::category
const std::string ClearInstrumentParameters::category() const {
return "DataHandling\\Instrument";
}
/** Initialize the algorithm's properties.
*/
void ClearInstrumentParameters::init() {
declareProperty(std::make_unique<WorkspaceProperty<>>(
"Workspace", "", Direction::InOut,
std::make_shared<InstrumentValidator>()),
"Workspace whose instrument parameters are to be cleared.");
}
/** Execute the algorithm.
*/
void ClearInstrumentParameters::exec() {
const MatrixWorkspace_sptr ws = getProperty("Workspace");
// Clear old parameters. We also want to clear fields stored in DetectorInfo
// (masking, positions, rotations). By setting the base instrument (which
// does not include a ParameterMap or DetectorInfo) we make use of the
// mechanism in ExperimentInfo that builds a clean DetectorInfo from the
// instrument being set.
const auto instrument = ws->getInstrument();
ws->setInstrument(instrument->baseInstrument());
}
} // namespace Algorithms
} // namespace Mantid