Mantid
Loading...
Searching...
No Matches
LogarithmMD.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 +
9
10using namespace Mantid::Kernel;
11using namespace Mantid::API;
12
13namespace Mantid::MDAlgorithms {
14
15// Register the algorithm into the AlgorithmFactory
16DECLARE_ALGORITHM(LogarithmMD)
17
18//----------------------------------------------------------------------------------------------
20const std::string LogarithmMD::name() const { return "LogarithmMD"; }
21
23int LogarithmMD::version() const { return 1; }
24
25//----------------------------------------------------------------------------------------------
26
27//----------------------------------------------------------------------------------------------
30 declareProperty("Filler", 0.0,
31 "Some values in a workspace can normally be "
32 "zeros or may get negative values after "
33 "transformations\n"
34 "log(x) is not defined for such values, so "
35 "here is the value, that will be placed as "
36 "the result of log(x<=0) operation\n"
37 "Default value is 0");
38 declareProperty("Natural", true,
39 "Switch to choose between natural or base "
40 "10 logarithm. Default true (natural).");
41}
42
43//----------------------------------------------------------------------------------------------
46 if (!m_in_histo)
47 throw std::runtime_error(this->name() + " can only be run on a MDHistoWorkspace.");
48}
49
50//----------------------------------------------------------------------------------------------
53 throw std::runtime_error(this->name() + " can only be run on a MDHistoWorkspace.");
54}
55
56//----------------------------------------------------------------------------------------------
59 bool natural = getProperty("Natural");
60 double filler = getProperty("Filler");
61 if (natural)
62 out->log(filler);
63 else
64 out->log10(filler);
65}
66
67} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
LogarithmMD : natural logarithm of a MDHistoWorkspace.
Definition: LogarithmMD.h:19
int version() const override
Algorithm's version for identification.
Definition: LogarithmMD.cpp:23
const std::string name() const override
Algorithm's name for identification.
Definition: LogarithmMD.cpp:20
void execHisto(Mantid::DataObjects::MDHistoWorkspace_sptr out) override
Run the algorithm with a MDHistoWorkspace.
Definition: LogarithmMD.cpp:58
void execEvent(Mantid::API::IMDEventWorkspace_sptr out) override
Run the algorithm on a MDEventWorkspace.
Definition: LogarithmMD.cpp:52
void checkInputs() override
Check the inputs and throw if the algorithm cannot be run.
Definition: LogarithmMD.cpp:45
void initExtraProperties() override
Optional method to be subclassed to add properties.
Definition: LogarithmMD.cpp:29
Mantid::DataObjects::MDHistoWorkspace_sptr m_in_histo
Input workspace (MDHisto)
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
STL namespace.