-
Notifications
You must be signed in to change notification settings - Fork 122
/
OneStepMDEW.cpp
71 lines (59 loc) · 2.61 KB
/
OneStepMDEW.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
66
67
68
69
70
71
#include "MantidMDAlgorithms/OneStepMDEW.h"
#include "MantidKernel/System.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidAPI/IMDEventWorkspace.h"
//#include "MantidNexus/LoadEventNexus.h"
//#include "MantidDataObjects/ConvertToDiffractionMDWorkspace.h"
namespace Mantid {
namespace MDAlgorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(OneStepMDEW)
using namespace Mantid::Kernel;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
//----------------------------------------------------------------------------------------------
/** Constructor
*/
OneStepMDEW::OneStepMDEW() {
this->useAlgorithm("ConvertToDiffractionMDWorkspace");
}
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void OneStepMDEW::init() {
this->declareProperty(
make_unique<FileProperty>("Filename", "", FileProperty::Load, ".nxs"),
"The name (including its full or relative path) of the Nexus file to\n"
"attempt to load. The file extension must either be .nxs or .NXS");
this->declareProperty(make_unique<WorkspaceProperty<Workspace>>(
"OutputWorkspace", "", Direction::Output),
"Name of the output MDEventWorkspace.");
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void OneStepMDEW::exec() {
std::string tempWsName = getPropertyValue("OutputWorkspace") + "_nxs";
// -------- First we load the event nexus file -------------
Algorithm_sptr loadAlg = createChildAlgorithm("LoadEventNexus", 0, 2);
loadAlg->initialize();
loadAlg->setPropertyValue("Filename", getPropertyValue("Filename"));
loadAlg->setPropertyValue("OutputWorkspace", tempWsName);
loadAlg->executeAsChildAlg();
Workspace_sptr temp = loadAlg->getProperty("OutputWorkspace");
IEventWorkspace_sptr tempWS =
boost::dynamic_pointer_cast<IEventWorkspace>(temp);
// --------- Now Convert -------------------------------
Algorithm_sptr childAlg =
createChildAlgorithm("ConvertToDiffractionMDWorkspace", 2, 4, true, 1);
childAlg->setProperty("InputWorkspace", tempWS);
childAlg->setProperty<bool>("ClearInputWorkspace", false);
childAlg->setProperty<bool>("LorentzCorrection", true);
childAlg->executeAsChildAlg();
IMDEventWorkspace_sptr outWS = childAlg->getProperty("OutputWorkspace");
setProperty<Workspace_sptr>("OutputWorkspace", outWS);
}
} // namespace Mantid
} // namespace MDAlgorithms