13#include "MantidAlgorithms/DllConfig.h"
21#include <boost/container/small_vector.hpp>
38 std::vector<double>
X;
39 std::vector<double>
Y;
47 DiscusData2D(
const std::vector<DiscusData1D> &data,
const std::shared_ptr<std::vector<double>> &specAxis)
49 std::unique_ptr<DiscusData2D>
createCopy(
bool clearY =
false);
64 std::shared_ptr<DiscusData2D>
SQ;
65 std::shared_ptr<DiscusData2D>
logSQ{};
67 std::shared_ptr<DiscusData2D>
QSQ{};
84 const std::string
name()
const override {
return "DiscusMultipleScatteringCorrection"; }
86 int version()
const override {
return 1; }
87 const std::vector<std::string>
seeAlso()
const override {
88 return {
"MayersSampleCorrection",
"CarpenterSampleCorrection",
"VesuvioCalculateMS"};
91 const std::string
category()
const override {
return "CorrectionFunctions"; }
93 const std::string
summary()
const override {
94 return "Calculates a multiple scattering correction using a Monte Carlo method";
96 const std::string
alias()
const override {
return "Muscat"; }
100 virtual std::shared_ptr<SparseWorkspace> createSparseWorkspace(
const API::MatrixWorkspace &modelWS,
101 const size_t nXPoints,
const size_t rows,
102 const size_t columns);
103 virtual std::unique_ptr<InterpolationOption> createInterpolateOption();
104 double interpolateFlat(
const DiscusData1D &histToInterpolate,
double x);
105 std::tuple<double, int> sampleQW(
const std::shared_ptr<DiscusData2D> &CumulativeProb,
double x);
106 double interpolateSquareRoot(
const DiscusData1D &histToInterpolate,
double x);
107 double interpolateGaussian(
const DiscusData1D &histToInterpolate,
double x);
109 void updateTrackDirection(
Geometry::Track &track,
const double cosT,
const double phi);
110 void integrateCumulative(
const DiscusData1D &h,
const double xmin,
const double xmax, std::vector<double> &resultX,
111 std::vector<double> &resultY,
const bool returnCumulative);
117 void init()
override;
118 void exec()
override;
119 std::map<std::string, std::string> validateInputs()
override;
121 std::tuple<double, double> new_vector(
const Kernel::Material &material,
double k,
bool specialSingleScatterCalc);
123 ComponentWorkspaceMappings &componentWorkspaces,
const double kinc,
124 const std::vector<double> &wValues,
const Kernel::V3D &detPos,
125 bool specialSingleScatterCalc);
127 const ComponentWorkspaceMappings &componentWorkspaces,
128 const double kinc,
const std::vector<double> &wValues,
129 const Kernel::V3D &detPos,
bool specialSingleScatterCalc);
135 bool specialSingleScatterCalc,
136 const ComponentWorkspaceMappings &componentWorkspaces);
141 void correctForWorkspaceNameClash(std::string &wsName);
143 void createInvPOfQWorkspaces(ComponentWorkspaceMappings &matWSs,
size_t nhists);
144 void convertToLogWorkspace(
const std::shared_ptr<DiscusData2D> &SOfQ);
145 void calculateQSQIntegralAsFunctionOfK(ComponentWorkspaceMappings &matWSs,
const std::vector<double> &specialKs);
146 void prepareCumulativeProbForQ(
double kinc,
const ComponentWorkspaceMappings &PInvOfQs);
147 void prepareQSQ(
double kinc);
148 double getKf(
const double deltaE,
const double kinc);
149 std::tuple<double, double, int, double> sampleQWUniform(
const std::vector<double> &wValues,
151 void prepareStructureFactors();
153 std::tuple<double, double> getKinematicRange(
double kf,
double ki);
154 std::vector<std::tuple<double, int, double>> generateInputKOutputWList(
const double efixed,
155 const std::vector<double> &xPoints);
156 std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>
157 integrateQSQ(
const std::shared_ptr<DiscusData2D> &QSQ,
double kinc,
const bool returnCumulative);
158 double getQSQIntegral(
const DiscusData1D &QSQScaleFactor,
double k);
163 long long m_callsToInterceptSurface{0};
164 long long m_IkCalculations{0};
166 int m_maxScatterPtAttempts{};
171 bool m_importanceSampling{};
173 bool m_simulateEnergiesIndependently{};
177 bool m_NormalizeSQ{};
Base class from which all concrete algorithm classes should be derived.
Base MatrixWorkspace Abstract Class.
std::vector< DiscusData1D > m_data
DiscusData2D(const std::vector< DiscusData1D > &data, const std::shared_ptr< std::vector< double > > &specAxis)
const std::vector< double > & getSpecAxisValues()
std::vector< DiscusData1D > & histograms()
DiscusData1D & histogram(const size_t i)
size_t getNumberHistograms()
std::shared_ptr< std::vector< double > > m_specAxis
std::unique_ptr< DiscusData2D > createCopy(bool clearY=false)
Calculates a multiple scattering correction Based on Muscat Fortran code provided by Spencer Howells.
ComponentWorkspaceMappings m_SQWSs
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
std::map< int, int > m_attemptsToGenerateInitialTrack
const std::string alias() const override
function to return any aliases of the algorithm.
const std::string category() const override
Algorithm's category for identification.
const std::string summary() const override
Summary of algorithms purpose.
const std::string name() const override
Algorithm's name.
int version() const override
Algorithm's version.
std::shared_ptr< const DiscusData1D > m_sigmaSS
bool checkGroups() override
Check the input workspace properties for groups.
Geometry::IObject_const_sptr m_sampleShape
virtual ~DiscusMultipleScatteringCorrection()=default
std::unique_ptr< IBeamProfile > m_beamProfile
boost::container::small_vector< ComponentWorkspaceMapping, 5 > ComponentWorkspaceMappings
std::shared_ptr< const Geometry::ReferenceFrame > m_refframe
Geometry::BoundingBox m_activeRegion
Class to provide a consistent interface to an interpolation option on algorithms.
Defines functions and utilities to create and deal with sparse instruments.
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
IObject : Interface for geometry objects.
Defines a single instance of a SampleEnvironment.
Defines a track as a start point and a direction.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Defines a 1D pseudo-random number generator, i.e.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const IObject > IObject_const_sptr
Typdef for a shared pointer to a const object.
Helper class which provides the Collimation Length for SANS instruments.
std::shared_ptr< int > scatterCount
Geometry::IObject_const_sptr ComponentPtr
std::shared_ptr< DiscusData2D > QSQ
std::shared_ptr< DiscusData2D > SQ
std::string_view materialName
std::shared_ptr< DiscusData1D > QSQScaleFactor
std::shared_ptr< DiscusData2D > logSQ
std::shared_ptr< DiscusData2D > InvPOfQ
DiscusData1D(std::vector< double > X, std::vector< double > Y)
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...