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 <Poco/File.h>
23
24using namespace Mantid::Kernel;
25using namespace Mantid::API;
26using namespace Mantid::DataObjects;
27using namespace Mantid::Geometry;
28
29namespace Mantid::MDAlgorithms {
30
31// Register the algorithm into the AlgorithmFactory
32DECLARE_ALGORITHM(ChangeQConvention)
33
34//----------------------------------------------------------------------------------------------
37void ChangeQConvention::init() {
38 declareProperty(std::make_unique<WorkspaceProperty<IMDWorkspace>>("InputWorkspace", "", Direction::InOut),
39 "An input MDEventWorkspace or MDHistoWorkspace.");
40}
41
42//----------------------------------------------------------------------------------------------
46 IMDWorkspace_sptr ws = getProperty("InputWorkspace");
47 std::string convention = ws->getConvention();
48
49 g_log.information() << "Transforming Q in workspace\n";
50
51 Algorithm_sptr transform_alg = createChildAlgorithm("TransformMD");
52 transform_alg->setProperty("InputWorkspace", std::dynamic_pointer_cast<IMDWorkspace>(ws));
53 transform_alg->setProperty("Scaling", "-1.0");
54 transform_alg->executeAsChildAlg();
55 ws = transform_alg->getProperty("OutputWorkspace");
56 ws->setConvention(convention);
57 ws->changeQConvention();
58
59 setProperty("InputWorkspace", ws);
60}
61
62} // 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