Newer
Older
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
#include "MantidMDAlgorithms/DisplayNormalizationSetter.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidAPI/IMDEventWorkspace.h"
namespace Mantid {
namespace MDAlgorithms {
/**
* Sets the display normalization
* @param mdWorkspace: the MDWorkspace which needs its normalizations flags set
* @param underlyingWorkspace: the underlying workspace, ie EventWorkspace or
* Workspace2D
* @param isQ: if the transform is Q or not
* @param mode: the energy transfer mode
*/
void DisplayNormalizationSetter::
operator()(Mantid::API::IMDWorkspace_sptr mdWorkspace,
const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace,
bool isQ, const Mantid::Kernel::DeltaEMode::Type &mode) {
if (boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(
mdWorkspace)) {
setNormalizationMDEvent(mdWorkspace, underlyingWorkspace, isQ, mode);
} else {
throw std::runtime_error("Setting the display normaliztion is currently "
"only implemented for MDEvent Workspaces");
}
}
/**
* Sets the display normalization for MDEventWorkspaces
* @param mdWorkspace: the MDWorkspace which needs its normalizations flags set
* @param underlyingWorkspace: the underlying workspace, ie EventWorkspace or
* Workspace2D
* @param isQ: if the transform is Q or not
* @param mode: the energy transfer mode
*/
void DisplayNormalizationSetter::setNormalizationMDEvent(
Mantid::API::IMDWorkspace_sptr mdWorkspace,
const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ,
const Mantid::Kernel::DeltaEMode::Type &mode) {
auto isEventWorkspace = true;
if (boost::dynamic_pointer_cast<Mantid::DataObjects::EventWorkspace>(
underlyingWorkspace)) {
isEventWorkspace = true;
} else {
isEventWorkspace = false;
}
Mantid::API::MDNormalization displayNormalization(
Mantid::API::MDNormalization::VolumeNormalization);
Mantid::API::MDNormalization displayNormalizationHisto(
Mantid::API::MDNormalization::VolumeNormalization);
// If is not Q
if (!isQ) {
displayNormalizationHisto =
Mantid::API::MDNormalization::VolumeNormalization;
// 2. If Energy mode is elastic --> Volume Normalization
} else if (mode == Mantid::Kernel::DeltaEMode::Elastic) {
displayNormalizationHisto =
Mantid::API::MDNormalization::VolumeNormalization;
// 3. If Energy is inelastic and underlying workspace is event workspace -->
// use no normalization
} else if (isEventWorkspace) {
displayNormalizationHisto = Mantid::API::MDNormalization::NoNormalization;
// 4. If Eneregy is inelastic and underlying workspace is other workspace
// --> use num event normalization
} else {
displayNormalizationHisto =
Mantid::API::MDNormalization::NumEventsNormalization;
}
applyNormalizationMDEvent(mdWorkspace, displayNormalization,
displayNormalizationHisto);
}
/**
* Apply the normalization to an MDEvent Workspace
* @param mdWorkspace: the workspace which gets its normalization tags set
* @param displayNormalization: the display normalization for the MDEvent
* workspace
* @param displayNormalizationHisto: the display normalization for derived
* MDHisto workspaces
*/
void DisplayNormalizationSetter::applyNormalizationMDEvent(
Mantid::API::IMDWorkspace_sptr mdWorkspace,
Mantid::API::MDNormalization displayNormalization,
Mantid::API::MDNormalization displayNormalizationHisto) {
auto ws =
boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(mdWorkspace);
ws->setDisplayNormalization(displayNormalization);
ws->setDisplayNormalizationHisto(displayNormalizationHisto);
}
}
}