/
EqualToMD.cpp
57 lines (46 loc) · 2 KB
/
EqualToMD.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
#include "MantidMDAlgorithms/EqualToMD.h"
#include "MantidKernel/System.h"
using namespace Mantid::Kernel;
using namespace Mantid::API;
namespace Mantid {
namespace MDAlgorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(EqualToMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
EqualToMD::EqualToMD() {}
//----------------------------------------------------------------------------------------------
/** Destructor
*/
EqualToMD::~EqualToMD() {}
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string EqualToMD::name() const { return "EqualToMD"; }
/// Algorithm's version for identification. @see Algorithm::version
int EqualToMD::version() const { return 1; }
//----------------------------------------------------------------------------------------------
/// Extra properties
void EqualToMD::initExtraProperties() {
declareProperty(
"Tolerance", 1e-5,
"Tolerance when performing the == comparison. Default 10^-5.");
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and operand
void EqualToMD::execHistoHisto(
Mantid::DataObjects::MDHistoWorkspace_sptr out,
Mantid::DataObjects::MDHistoWorkspace_const_sptr operand) {
double tolerance = getProperty("Tolerance");
out->equalTo(*operand, tolerance);
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and a scalar on the RHS
void EqualToMD::execHistoScalar(
Mantid::DataObjects::MDHistoWorkspace_sptr out,
Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar) {
double tolerance = getProperty("Tolerance");
out->equalTo(scalar->dataY(0)[0], tolerance);
}
} // namespace Mantid
} // namespace MDAlgorithms