Mantid
Loading...
Searching...
No Matches
ConvertCWPDMDToSpectra.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 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
12#include "MantidKernel/V3D.h"
13#include "MantidMDAlgorithms/DllConfig.h"
14
15namespace Mantid {
16
17namespace MDAlgorithms {
18
19//----------------------------------------------------------------------------------------------
27inline double calculateDspaceFrom2Theta(const double &twotheta, const double &wavelength) {
28 return (0.5 * wavelength / sin(twotheta * 0.5 * M_PI / 180.));
29}
30
31//----------------------------------------------------------------------------------------------
39inline double calculate2ThetaFromD(const double &dspace, const double &wavelength) {
40 return (2.0 * asin(0.5 * wavelength / dspace) * 180. / M_PI);
41}
42
43//----------------------------------------------------------------------------------------------
51inline double calculateQFrom2Theta(const double &twotheta, const double &wavelength) {
52 return (4. * M_PI * sin(twotheta * 0.5 * M_PI / 180.) / wavelength);
53}
54
55//----------------------------------------------------------------------------------------------
63inline double calcualte2ThetaFromQ(const double &q, const double &wavelength) {
64 return (2.0 * asin(q * wavelength * 0.25 / M_PI) * 180. / M_PI);
65}
66
67//----------------------------------------------------------------------------------------------
74inline double calculate2Theta(const Kernel::V3D &detpos, const Kernel::V3D &samplepos) {
75 return detpos.angle(samplepos);
76}
77
82class MANTID_MDALGORITHMS_DLL ConvertCWPDMDToSpectra final : public API::Algorithm {
83public:
85 const std::string name() const override { return "ConvertCWPDMDToSpectra"; }
86
88 const std::string summary() const override {
89 return "Convert constant wavelength (CW) powder diffraction (PD) data in "
90 "MDEventWorksapces "
91 " to a single-spectrum MatrixWorkspace, i.e., binning the "
92 "diffraction data "
93 " to single spectrum according to neutron's scattering angle, "
94 "d-spacing or Q. ";
95 }
96
98 int version() const override { return (1); }
99
101 const std::string category() const override { return "Diffraction\\ConstantWavelength;Diffraction\\Focussing"; }
102
103private:
105 void init() override;
106
108 void exec() override;
109
112 const API::IMDEventWorkspace_const_sptr &monitorws,
113 const std::string &targetunit,
114 const std::map<int, double> &map_runwavelength, const double xmin,
115 const double xmax, const double binsize, bool dolinearinterpolation,
116 const std::vector<detid_t> &vec_excludeddets);
117
119 void findXBoundary(const API::IMDEventWorkspace_const_sptr &dataws, const std::string &targetunit,
120 const std::map<int, double> &map_runwavelength, double &xmin, double &xmax);
121
123 void binMD(const API::IMDEventWorkspace_const_sptr &mdws, const char &unitbit,
124 const std::map<int, double> &map_runlambda, const std::vector<double> &vecx, std::vector<double> &vecy,
125 const std::vector<detid_t> &vec_excludedet);
126
128 void linearInterpolation(const API::MatrixWorkspace_sptr &matrixws, const double &infinitesimal);
129
131 void setupSampleLogs(const API::MatrixWorkspace_sptr &matrixws, const API::IMDEventWorkspace_const_sptr &inputmdws);
132
134 void scaleMatrixWorkspace(const API::MatrixWorkspace_sptr &matrixws, const double &scalefactor,
135 const double &infinitesimal);
136
138 void convertUnits(API::MatrixWorkspace_sptr matrixws, const std::string &targetunit, const double &wavelength);
139
140 bool isExcluded(const std::vector<detid_t> &vec_excludedet, const detid_t detid);
141
143 double m_infitesimal = 1.0E-10;
144};
145
146} // namespace MDAlgorithms
147} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
Class for 3D vectors.
Definition: V3D.h:34
double angle(const V3D &) const
Angle between this and another vector.
Definition: V3D.cpp:165
ConvertCWPDMDToSpectra : Convert one MDWorkspaces containing reactor-source powder diffractometer's d...
const std::string category() const override
Algorithm's category for identification.
const std::string summary() const override
Summary of algorithms purpose.
int version() const override
Algorithm's version.
const std::string name() const override
Algorithm's name.
void convertUnits(API::MatrixWorkspace_sptr matrixws, const std::string &targetunit, const double &wavelength)
Convert units from 2theta to d-spacing or Q.
std::shared_ptr< const IMDEventWorkspace > IMDEventWorkspace_const_sptr
Shared pointer to Mantid::API::IMDEventWorkspace (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
double calcualte2ThetaFromQ(const double &q, const double &wavelength)
Calculate detector's 2theta value from Q 2theta = 2*asin(lambda*Q/(4pi))
double calculateDspaceFrom2Theta(const double &twotheta, const double &wavelength)
Calculate d-space value from detector's position (2theta/theta) and wavelength.
double calculate2ThetaFromD(const double &dspace, const double &wavelength)
Calcualte detector's 2theta value from d-spacing value 2theta = 2*asin(lamba/2/d)
double calculateQFrom2Theta(const double &twotheta, const double &wavelength)
Calculate Q value from detector's positin (2theta/theta) and wavelength q = 2 k sin(theta) = (4 pi)/(...
double calculate2Theta(const Kernel::V3D &detpos, const Kernel::V3D &samplepos)
Calculate 2theta value of detector postion from sample position.
Helper class which provides the Collimation Length for SANS instruments.