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#include "MantidKernel/System.h"
23#include <Poco/File.h>
24
25using namespace Mantid::Kernel;
26using namespace Mantid::API;
27using namespace Mantid::DataObjects;
28using namespace Mantid::Geometry;
29
30namespace Mantid::MDAlgorithms {
31
32// Register the algorithm into the AlgorithmFactory
33DECLARE_ALGORITHM(ChangeQConvention)
34
35//----------------------------------------------------------------------------------------------
38void ChangeQConvention::init() {
39 declareProperty(std::make_unique<WorkspaceProperty<IMDWorkspace>>("InputWorkspace", "", Direction::InOut),
40 "An input MDEventWorkspace or MDHistoWorkspace.");
41}
42
43//----------------------------------------------------------------------------------------------
47 IMDWorkspace_sptr ws = getProperty("InputWorkspace");
48 std::string convention = ws->getConvention();
49
50 g_log.information() << "Transforming Q in workspace\n";
51
52 Algorithm_sptr transform_alg = createChildAlgorithm("TransformMD");
53 transform_alg->setProperty("InputWorkspace", std::dynamic_pointer_cast<IMDWorkspace>(ws));
54 transform_alg->setProperty("Scaling", "-1.0");
55 transform_alg->executeAsChildAlg();
56 ws = transform_alg->getProperty("OutputWorkspace");
57 ws->setConvention(convention);
58 ws->changeQConvention();
59
60 setProperty("InputWorkspace", ws);
61}
62
63} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
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.
Definition: Algorithm.cpp:842
Kernel::Logger & g_log
Definition: Algorithm.h:451
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:105
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.
Definition: IMDWorkspace.h:146
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition: Algorithm.h:61
@ InOut
Both an input & output workspace.
Definition: Property.h:55