Mantid
Loading...
Searching...
No Matches
UnitsConversionHelper.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
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
13#include "MantidKernel/Unit.h"
15
16namespace Mantid {
17namespace MDAlgorithms {
25namespace CnvrtToMD {
26// possible situations with unit conversion
28 ConvertNo, //< no, input workspace has the same units as output workspace or
29 // in units used by Q-dE algorithms naturally
30 ConvertFast, //< the input workspace has different units from the requested
31 // and fast conversion is possible
32 ConvertByTOF, //< conversion possible via TOF
33 ConvertFromTOF //< Input workspace units are the TOF
34};
35} // namespace CnvrtToMD
36class MANTID_MDALGORITHMS_DLL UnitsConversionHelper {
37 // variables for units conversion:
38 // pointer to input workspace units
40 // pointer to target workspace units
42
43 // the ID, which specifies what kind of unit conversion should be used.
45
46 // these variables needed and used in the case of fast units conversion
47 double m_Factor, m_Power;
48 // these variables needed and used for conversion through TOF
50
51 double m_L1, m_Efix, m_TwoTheta, m_L2, m_DIFA, m_DIFC, m_TZERO;
52 std::vector<double> const *m_pTwoThetas;
53 std::vector<double> const *m_pL2s;
54 // pointer to detector specific input energy (eFixed) defined for indirect
55 // instruments;
57 std::vector<double> const *m_pDIFAs;
58 std::vector<double> const *m_pDIFCs;
59 std::vector<double> const *m_pTZEROs;
60
61public:
63 void initialize(const MDWSDescription &targetWSDescr, const std::string &unitsTo, bool forceViaTOF = false);
64 void initialize(const std::string &unitsFrom, const std::string &unitsTo,
65 const DataObjects::TableWorkspace_const_sptr &DetWS, int Emode, bool forceViaTOF = false);
66 void updateConversion(size_t i);
67 double convertUnits(double val) const;
68
69 bool isUnitConverted() const;
70 std::pair<double, double> getConversionRange(double x1, double x2) const;
71 // copy constructor
73
74protected: // for testing
77 CnvrtToMD::ConvertUnits analyzeUnitsConversion(const std::string &UnitsFrom, const std::string &UnitsTo,
78 bool forceViaTOF = false);
79};
80
81} // namespace MDAlgorithms
82} // namespace Mantid
const std::vector< double > & m_L2
Definition: LoadEMU.cpp:231
helper class describes the properties of target MD workspace, which should be obtained as the result ...
std::shared_ptr< const TableWorkspace > TableWorkspace_const_sptr
shared pointer to Mantid::DataObjects::TableWorkspace (const version)
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.