Mantid
Loading...
Searching...
No Matches
DisplayNormalizationSetter.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include <utility>
8
13
14namespace Mantid::MDAlgorithms {
15
25 const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ,
27 if (std::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(mdWorkspace)) {
28 setNormalizationMDEvent(mdWorkspace, underlyingWorkspace, isQ, mode);
29 } else {
30 throw std::runtime_error("Setting the display normaliztion is currently "
31 "only implemented for MDEvent Workspaces");
32 }
33}
34
44 const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace,
45 bool isQ, const Mantid::Kernel::DeltaEMode::Type &mode) {
46
47 auto isEventWorkspace =
48 static_cast<bool>(std::dynamic_pointer_cast<Mantid::DataObjects::EventWorkspace>(underlyingWorkspace));
51
52 // If is not Q
53 if (!isQ) {
54 displayNormalizationHisto = Mantid::API::MDNormalization::VolumeNormalization;
55 // 2. If Energy mode is elastic --> Volume Normalization
56 } else if (mode == Mantid::Kernel::DeltaEMode::Elastic) {
57 displayNormalizationHisto = Mantid::API::MDNormalization::VolumeNormalization;
58 // 3. If Energy is inelastic and underlying workspace is event workspace -->
59 // use no normalization
60 } else if (isEventWorkspace) {
61 displayNormalizationHisto = Mantid::API::MDNormalization::NoNormalization;
62 // 4. If Eneregy is inelastic and underlying workspace is other workspace
63 // --> use num event normalization
64 } else {
66 }
67
68 applyNormalizationMDEvent(mdWorkspace, displayNormalization, displayNormalizationHisto);
69}
70
80 Mantid::API::MDNormalization displayNormalization,
81 Mantid::API::MDNormalization displayNormalizationHisto) {
82 auto ws = std::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(mdWorkspace);
83 ws->setDisplayNormalization(displayNormalization);
84 ws->setDisplayNormalizationHisto(displayNormalizationHisto);
85}
86} // namespace Mantid::MDAlgorithms
void setNormalizationMDEvent(const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ=false, const Mantid::Kernel::DeltaEMode::Type &mode=Mantid::Kernel::DeltaEMode::Elastic)
Sets the display normalization for MDEventWorkspaces.
void operator()(const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ=false, const Mantid::Kernel::DeltaEMode::Type &mode=Mantid::Kernel::DeltaEMode::Elastic)
Sets the display normalization.
void applyNormalizationMDEvent(const Mantid::API::IMDWorkspace_sptr &mdWorkspace, Mantid::API::MDNormalization displayNormalization, Mantid::API::MDNormalization displayNormalizationHisto)
Apply the normalization to an MDEvent Workspace.
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
Definition: IMDWorkspace.h:146
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
Definition: IMDIterator.h:25
@ VolumeNormalization
Divide the signal by the volume of the box/bin.
Definition: IMDIterator.h:29
@ NumEventsNormalization
Divide the signal by the number of events that contributed to it.
Definition: IMDIterator.h:31
@ NoNormalization
Don't normalize = return raw counts.
Definition: IMDIterator.h:27
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...
Definition: DeltaEMode.h:29