Mantid
Loading...
Searching...
No Matches
ChangeQConvention.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#include "MantidAPI/Progress.h"
21#include "MantidKernel/Matrix.h"
22
23using namespace Mantid::Kernel;
24using namespace Mantid::API;
25using namespace Mantid::DataObjects;
26using namespace Mantid::Geometry;
27
28namespace Mantid::MDAlgorithms {
29
30// Register the algorithm into the AlgorithmFactory
31DECLARE_ALGORITHM(ChangeQConvention)
32
33//----------------------------------------------------------------------------------------------
36void ChangeQConvention::init() {
37 declareProperty(std::make_unique<WorkspaceProperty<IMDWorkspace>>("InputWorkspace", "", Direction::InOut),
38 "An input MDEventWorkspace or MDHistoWorkspace.");
39}
40
41//----------------------------------------------------------------------------------------------
45 IMDWorkspace_sptr ws = getProperty("InputWorkspace");
46 std::string convention = ws->getConvention();
47
48 g_log.information() << "Transforming Q in workspace\n";
49
50 Algorithm_sptr transform_alg = createChildAlgorithm("TransformMD");
51 transform_alg->setProperty("InputWorkspace", std::dynamic_pointer_cast<IMDWorkspace>(ws));
52 transform_alg->setProperty("Scaling", "-1.0");
53 transform_alg->executeAsChildAlg();
54 ws = transform_alg->getProperty("OutputWorkspace");
55 ws->setConvention(convention);
56 ws->changeQConvention();
57
58 setProperty("InputWorkspace", ws);
59}
60
61} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Kernel::Logger & g_log
Definition Algorithm.h:422
A property class for workspaces.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
Save a MDEventWorkspace to a .nxs file.
void exec() override
Run the algorithm.
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition Algorithm.h:52
@ InOut
Both an input & output workspace.
Definition Property.h:55