94 const std::string
name()
const override {
return "DiscusMultipleScatteringCorrection"; }
96 int version()
const override {
return 1; }
97 const std::vector<std::string>
seeAlso()
const override {
98 return {
"MayersSampleCorrection",
"CarpenterSampleCorrection",
"VesuvioCalculateMS"};
101 const std::string
category()
const override {
return "CorrectionFunctions"; }
104 return "Calculates a multiple scattering correction using a Monte Carlo method";
106 const std::string
alias()
const override {
return "Muscat"; }
110 virtual std::shared_ptr<SparseWorkspace> createSparseWorkspace(
const API::MatrixWorkspace &modelWS,
111 const size_t nXPoints,
const size_t rows,
112 const size_t columns);
113 virtual std::unique_ptr<InterpolationOption> createInterpolateOption();
114 double interpolateFlat(
const DiscusData1D &histToInterpolate,
double x);
115 std::tuple<double, int> sampleQW(
const std::shared_ptr<DiscusData2D> &CumulativeProb,
double x);
116 double interpolateSquareRoot(
const DiscusData1D &histToInterpolate,
double x);
117 double interpolateGaussian(
const DiscusData1D &histToInterpolate,
double x);
119 void updateTrackDirection(
Geometry::Track &track,
const double cosT,
const double phi);
120 void integrateCumulative(
const DiscusData1D &h,
const double xmin,
const double xmax, std::vector<double> &resultX,
121 std::vector<double> &resultY,
const bool returnCumulative);
125 const std::shared_ptr<Geometry::CSGObject>
127 const size_t &histogramIndex);
130 void init()
override;
131 void exec()
override;
132 std::map<std::string, std::string> validateInputs()
override;
134 std::tuple<double, double> new_vector(
const Kernel::Material &material,
double k,
bool specialSingleScatterCalc);
135 std::tuple<std::vector<double>, std::vector<double>>
137 const ComponentWorkspaceMappings &componentWorkspaces,
const double kinc,
138 const std::vector<double> &wValues,
bool specialSingleScatterCalc,
141 const ComponentWorkspaceMappings &componentWorkspaces,
142 const double kinc,
const std::vector<double> &wValues,
143 bool specialSingleScatterCalc,
145 const size_t &histogramIndex);
152 bool specialSingleScatterCalc,
153 const ComponentWorkspaceMappings &componentWorkspaces);
158 void correctForWorkspaceNameClash(std::string &wsName);
160 void createInvPOfQWorkspaces(ComponentWorkspaceMappings &matWSs,
size_t nhists);
161 void convertToLogWorkspace(
const std::shared_ptr<DiscusData2D> &SOfQ);
162 void calculateQSQIntegralAsFunctionOfK(ComponentWorkspaceMappings &matWSs,
const std::vector<double> &specialKs);
163 void prepareCumulativeProbForQ(
double kinc,
const ComponentWorkspaceMappings &PInvOfQs);
164 void prepareQSQ(
double kinc);
165 double getKf(
const double deltaE,
const double kinc);
166 std::tuple<double, double, int, double> sampleQWUniform(
const std::vector<double> &wValues,
168 void prepareStructureFactors();
170 std::tuple<double, double> getKinematicRange(
double kf,
double ki);
171 std::vector<std::tuple<double, int, double>> generateInputKOutputWList(
const double efixed,
172 std::span<double const> xPoints);
173 std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>
174 integrateQSQ(
const std::shared_ptr<DiscusData2D> &QSQ,
double kinc,
const bool returnCumulative);
175 double getQSQIntegral(
const DiscusData1D &QSQScaleFactor,
double k);
180 void loadCollimatorInfo();
181 double getDoubleParamFromIDF(std::string paramName);
182 Kernel::V3D getV3DParamFromIDF(std::string paramName);
183 const std::shared_ptr<Geometry::CSGObject> readFromCollimatorCorridorCache(
const std::size_t &histogramIndex);
184 void writeToCollimatorCorridorCache(
const std::size_t &histogramIndex,
185 const std::shared_ptr<Geometry::CSGObject> &collimatorCorridorCsgObj);
186 long long m_callsToInterceptSurface{0};
187 long long m_IkCalculations{0};
189 int m_maxScatterPtAttempts{};
194 bool m_importanceSampling{};
196 bool m_simulateEnergiesIndependently{};
200 bool m_NormalizeSQ{};