-
Notifications
You must be signed in to change notification settings - Fork 122
/
ConvertToDiffractionMDWorkspace2.cpp
79 lines (67 loc) · 2.98 KB
/
ConvertToDiffractionMDWorkspace2.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
72
73
74
75
76
77
78
79
// 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/ConvertToDiffractionMDWorkspace2.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataObjects/MDEventWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/EnabledWhenProperty.h"
#include "MantidKernel/ListValidator.h"
#include "MantidMDAlgorithms/ConvertToMDMinMaxLocal.h"
#include "MantidMDAlgorithms/MDTransfFactory.h"
#include "MantidMDAlgorithms/MDWSTransform.h"
#include <algorithm>
#include <limits>
using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace Mantid::DataObjects;
using namespace Mantid::Geometry;
namespace Mantid::MDAlgorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(ConvertToDiffractionMDWorkspace2)
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void ConvertToDiffractionMDWorkspace2::init() {
// initilise common properties between versions
BaseConvertToDiffractionMDWorkspace::init();
std::vector<double> extents = {-50.0, 50.0};
declareProperty(std::make_unique<ArrayProperty<double>>("Extents", std::move(extents)),
"A comma separated list of min, max for each dimension,\n"
"specifying the extents of each dimension. Optional, default "
"+- 50 in each dimension.");
setPropertyGroup("Extents", getBoxSettingsGroupName());
}
/** Splits extents accepted by convertToDiffreactionMD workspace in the form
*min1,max1 or min1,max1,min2,max2,min3,max3
* into tso vectors min(3),max(3) accepted by convertToMD
* @param Extents -- the vector of extents consititing of 2 or 6 elements
* @param minVal -- 3-vector of minimal values for 3 processed dimensions
* @param maxVal -- 3-vector of maximal values for 3 processed dimensions
*
* @return minVal and maxVal -- two vectors with minimal and maximal values of
*the momentums in the target workspace.
*/
void ConvertToDiffractionMDWorkspace2::convertExtents(const std::vector<double> &Extents, std::vector<double> &minVal,
std::vector<double> &maxVal) {
minVal.resize(3);
maxVal.resize(3);
if (Extents.size() == 2) {
for (size_t d = 0; d < 3; d++) {
minVal[d] = Extents[0];
maxVal[d] = Extents[1];
}
} else if (Extents.size() == 6) {
for (size_t d = 0; d < 3; d++) {
minVal[d] = Extents[2 * d + 0];
maxVal[d] = Extents[2 * d + 1];
}
} else
throw std::invalid_argument("You must specify either 2 or 6 extents (min,max).");
}
} // namespace Mantid::MDAlgorithms