-
Notifications
You must be signed in to change notification settings - Fork 122
/
ChangeQConvention.cpp
65 lines (56 loc) · 2.37 KB
/
ChangeQConvention.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
63
64
65
// 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 "MantidMDAlgorithms/ChangeQConvention.h"
#include "MantidAPI/CoordTransform.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/Progress.h"
#include "MantidDataObjects/BoxControllerNeXusIO.h"
#include "MantidDataObjects/MDBox.h"
#include "MantidDataObjects/MDBoxFlatTree.h"
#include "MantidDataObjects/MDBoxIterator.h"
#include "MantidDataObjects/MDEventFactory.h"
#include "MantidDataObjects/MDEventWorkspace.h"
#include "MantidDataObjects/MDHistoWorkspace.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/EnabledWhenProperty.h"
#include "MantidKernel/Matrix.h"
#include "MantidKernel/System.h"
#include <Poco/File.h>
using namespace Mantid::Kernel;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Geometry;
namespace Mantid {
namespace MDAlgorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(ChangeQConvention)
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void ChangeQConvention::init() {
declareProperty(std::make_unique<WorkspaceProperty<IMDWorkspace>>("InputWorkspace", "", Direction::InOut),
"An input MDEventWorkspace or MDHistoWorkspace.");
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void ChangeQConvention::exec() {
IMDWorkspace_sptr ws = getProperty("InputWorkspace");
std::string convention = ws->getConvention();
g_log.information() << "Transforming Q in workspace\n";
Algorithm_sptr transform_alg = createChildAlgorithm("TransformMD");
transform_alg->setProperty("InputWorkspace", std::dynamic_pointer_cast<IMDWorkspace>(ws));
transform_alg->setProperty("Scaling", "-1.0");
transform_alg->executeAsChildAlg();
ws = transform_alg->getProperty("OutputWorkspace");
ws->setConvention(convention);
ws->changeQConvention();
setProperty("InputWorkspace", ws);
}
} // namespace MDAlgorithms
} // namespace Mantid