Mantid
Loading...
Searching...
No Matches
Q1DWeighted.h
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 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
14#include "MantidAlgorithms/DllConfig.h"
15
16namespace Mantid {
17namespace Algorithms {
55class MANTID_ALGORITHMS_DLL Q1DWeighted final : public API::Algorithm {
56public:
58 const std::string name() const override { return "Q1DWeighted"; }
60 const std::string summary() const override {
61 return "Performs azimuthal averaging on a 2D SANS data to produce I(Q).";
62 }
63
65 int version() const override { return (1); }
66 const std::vector<std::string> seeAlso() const override { return {"Q1D"}; }
68 const std::string category() const override { return "SANS"; }
69
70private:
72 API::MatrixWorkspace_sptr createOutputWorkspace(const API::MatrixWorkspace_const_sptr &, const size_t,
73 const std::vector<double> &, const size_t);
74
75 void bootstrap(const API::MatrixWorkspace_const_sptr &);
76 void calculate(const API::MatrixWorkspace_const_sptr &);
77 void finalize(const API::MatrixWorkspace_const_sptr &);
78 void fillMonochromaticOutput(API::MatrixWorkspace_sptr &, const size_t);
79 void fillTOFOutput(API::MatrixWorkspace_sptr &, const size_t);
80
81 struct Wedge {
82 Wedge(double innerRadius, double outerRadius, double centerX, double centerY, double angleMiddle, double angleRange)
83 : innerRadius(innerRadius), outerRadius(outerRadius), centerX(centerX), centerY(centerY),
84 angleMiddle(angleMiddle), angleRange(angleRange) {}
87 double centerX;
88 double centerY;
90 double angleRange;
91
98 bool isSymmetric(const Wedge &other) {
99 double diffAngle = std::fabs(std::fmod(this->angleMiddle - other.angleMiddle, M_PI));
100
101 double epsilon = 1e-3;
102 bool hasSameRadii = this->innerRadius == other.innerRadius && this->outerRadius == other.outerRadius;
103
104 bool hasSameCenter = this->centerX == other.centerX && this->centerY == other.centerY;
105
106 bool hasSameAngleRange = std::fabs(this->angleRange - other.angleRange) < epsilon;
107
108 bool hasSymmetricalAngle = std::fabs(diffAngle - M_PI) < epsilon || diffAngle < epsilon;
109
110 return (hasSameRadii && hasSameCenter && hasSameAngleRange && hasSymmetricalAngle);
111 }
112 };
113
114 void getTableShapes();
115 void getViewportParams(const std::string &, std::map<std::string, std::vector<double>> &);
116 void getWedgeParams(const std::vector<std::string> &, const std::map<std::string, std::vector<double>> &);
117 bool checkIfSymetricalWedge(Wedge &Wedge);
118 void checkIfSuperposedWedges();
119
120 std::vector<std::vector<std::vector<double>>> m_intensities;
121 std::vector<std::vector<std::vector<double>>> m_errors;
122 std::vector<std::vector<std::vector<double>>> m_normalisation;
123 std::vector<double> m_qBinEdges;
124 size_t m_nQ;
125 size_t m_nBins;
126 size_t m_nWedges;
127
128 std::vector<Wedge> m_wedgesParameters;
129
130 size_t m_nSpec;
138
140 void init() override;
142 void exec() override;
143};
144} // namespace Algorithms
145} // namespace Mantid
double innerRadius
Definition: Rasterize.cpp:39
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
Part of data reduction for SANS.
Definition: Q1DWeighted.h:55
std::vector< Wedge > m_wedgesParameters
Definition: Q1DWeighted.h:128
std::vector< std::vector< std::vector< double > > > m_intensities
Definition: Q1DWeighted.h:120
int version() const override
Algorithm's version.
Definition: Q1DWeighted.h:65
std::vector< std::vector< std::vector< double > > > m_errors
Definition: Q1DWeighted.h:121
const std::string category() const override
Algorithm's category for identification.
Definition: Q1DWeighted.h:68
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Definition: Q1DWeighted.h:66
const std::string name() const override
Algorithm's name.
Definition: Q1DWeighted.h:58
std::vector< double > m_qBinEdges
Definition: Q1DWeighted.h:123
std::vector< std::vector< std::vector< double > > > m_normalisation
Definition: Q1DWeighted.h:122
const std::string summary() const override
Summary of algorithms purpose.
Definition: Q1DWeighted.h:60
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
Helper class which provides the Collimation Length for SANS instruments.
bool isSymmetric(const Wedge &other)
isSymmetric determines if the two wedges have a center symmetry with one another.
Definition: Q1DWeighted.h:98
Wedge(double innerRadius, double outerRadius, double centerX, double centerY, double angleMiddle, double angleRange)
Definition: Q1DWeighted.h:82