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