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 {
52class MANTID_ALGORITHMS_DLL ConvertUnits : public API::DistributedAlgorithm {
53public:
55 const std::string name() const override { return "ConvertUnits"; }
57 const std::string summary() const override { return "Performs a unit change on the X values of a workspace"; }
58
60 int version() const override { return 1; }
61 const std::vector<std::string> seeAlso() const override {
62 return {"ConvertAxisByFormula", "ConvertAxesToRealSpace", "ConvertSpectrumAxis", "ConvertToYSpace"};
63 }
65 const std::string category() const override { return "Transforms\\Units"; }
66
67protected:
69 void reverse(const API::MatrixWorkspace_sptr &WS);
70
74
75 const std::string workspaceMethodName() const override { return "convertUnits"; }
76 const std::string workspaceMethodInputProperty() const override { return "InputWorkspace"; }
77
78 // Overridden Algorithm methods
79 void init() override;
80 void exec() override;
81
82 void setupMemberVariables(const API::MatrixWorkspace_const_sptr &inputWS);
83 virtual void storeEModeOnWorkspace(API::MatrixWorkspace_sptr outputWS);
84 API::MatrixWorkspace_sptr setupOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWS);
85
88 API::MatrixWorkspace_sptr executeUnitConversion(const API::MatrixWorkspace_sptr &inputWS);
89
92 API::MatrixWorkspace_sptr convertQuickly(const API::MatrixWorkspace_const_sptr &inputWS, const double &factor,
93 const double &power);
94
97 virtual API::MatrixWorkspace_sptr convertViaTOF(Kernel::Unit_const_sptr fromUnit,
99
100 // Calls Rebin as a Child Algorithm to align the bins of the output workspace
102 const std::vector<double> calculateRebinParams(const API::MatrixWorkspace_const_sptr &workspace) const;
103
104 void putBackBinWidth(const API::MatrixWorkspace_sptr &outputWS);
105
106 std::size_t m_numberOfSpectra{0};
107 bool m_distribution{false};
109 bool m_inputEvents{false};
112};
113
114} // namespace Algorithms
115} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
Base class for algorithms that treat all spectra independently, i.e., we can trivially parallelize ov...
Converts the units in which a workspace is represented.
Definition: ConvertUnits.h:52
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition: ConvertUnits.h:55
Kernel::Unit_const_sptr m_inputUnit
The unit of the input workspace.
Definition: ConvertUnits.h:110
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
Definition: ConvertUnits.h:65
const std::string workspaceMethodName() const override
Definition: ConvertUnits.h:75
const std::string workspaceMethodInputProperty() const override
Returns the name of the input workspace property used by the calling object.
Definition: ConvertUnits.h:76
int version() const override
Algorithm's version for identification overriding a virtual method.
Definition: ConvertUnits.h:60
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Definition: ConvertUnits.h:61
Kernel::Unit_sptr m_outputUnit
The unit we're going to.
Definition: ConvertUnits.h:111
const std::string summary() const override
Summary of algorithms purpose.
Definition: ConvertUnits.h:57
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:231
std::shared_ptr< Unit > Unit_sptr
Shared pointer to the Unit base class.
Definition: Unit.h:229
Helper class which provides the Collimation Length for SANS instruments.