Mantid
Loading...
Searching...
No Matches
ConvertUnits.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 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#pragma once
8
10#include "MantidAlgorithms/DllConfig.h"
12#include "MantidKernel/Unit.h"
13
14namespace Mantid {
15namespace Algorithms {
16
22class MANTID_ALGORITHMS_DLL ConvertUnits : public API::Algorithm {
23public:
25 const std::string name() const override { return "ConvertUnits"; }
27 const std::string summary() const override { return "Performs a unit change on the X values of a workspace"; }
29 int version() const override { return 1; }
30 const std::vector<std::string> seeAlso() const override {
31 return {"ConvertAxisByFormula", "ConvertAxesToRealSpace", "ConvertSpectrumAxis", "ConvertToYSpace"};
32 }
34 const std::string category() const override { return "Transforms\\Units"; }
35
36protected:
38 void reverse(const API::MatrixWorkspace_sptr &WS);
39
43
44 const std::string workspaceMethodName() const override { return "convertUnits"; }
45 const std::string workspaceMethodInputProperty() const override { return "InputWorkspace"; }
46
47 // Overridden Algorithm methods
48 void init() override;
49 void exec() override;
50
51 void setupMemberVariables(const API::MatrixWorkspace_const_sptr &inputWS);
52 virtual void storeEModeOnWorkspace(API::MatrixWorkspace_sptr outputWS);
53 API::MatrixWorkspace_sptr setupOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWS);
54
57 API::MatrixWorkspace_sptr executeUnitConversion(const API::MatrixWorkspace_sptr &inputWS);
58
61 API::MatrixWorkspace_sptr convertQuickly(const API::MatrixWorkspace_const_sptr &inputWS, const double &factor,
62 const double &power);
63
66 virtual API::MatrixWorkspace_sptr convertViaTOF(Kernel::Unit_const_sptr fromUnit,
68
69 // Calls Rebin as a Child Algorithm to align the bins of the output workspace
71 const std::vector<double> calculateRebinParams(const API::MatrixWorkspace_const_sptr &workspace) const;
72
73 void putBackBinWidth(const API::MatrixWorkspace_sptr &outputWS);
74
75 std::size_t m_numberOfSpectra{0};
76 bool m_distribution{false};
78 bool m_inputEvents{false};
81};
82
83} // namespace Algorithms
84} // namespace Mantid
IPeaksWorkspace_sptr workspace
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
Converts the units in which a workspace is represented.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Kernel::Unit_const_sptr m_inputUnit
The unit of the input workspace.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
const std::string workspaceMethodName() const override
const std::string workspaceMethodInputProperty() const override
Returns the name of the input workspace property used by the calling object.
int version() const override
Algorithm's version for identification overriding a virtual method.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Kernel::Unit_sptr m_outputUnit
The unit we're going to.
const std::string summary() const override
Summary of algorithms purpose.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const Unit > Unit_const_sptr
Shared pointer to the Unit base class (const version)
Definition Unit.h:196
std::shared_ptr< Unit > Unit_sptr
Shared pointer to the Unit base class.
Definition Unit.h:194
Helper class which provides the Collimation Length for SANS instruments.