95 const std::string
name()
const override {
return "DiscusMultipleScatteringCorrection"; }
97 int version()
const override {
return 1; }
98 const std::vector<std::string>
seeAlso()
const override {
99 return {
"MayersSampleCorrection",
"CarpenterSampleCorrection",
"VesuvioCalculateMS"};
102 const std::string
category()
const override {
return "CorrectionFunctions"; }
105 return "Calculates a multiple scattering correction using a Monte Carlo method";
107 const std::string
alias()
const override {
return "Muscat"; }
111 virtual std::shared_ptr<SparseWorkspace> createSparseWorkspace(
const API::MatrixWorkspace &modelWS,
112 const size_t nXPoints,
const size_t rows,
113 const size_t columns);
114 virtual std::unique_ptr<InterpolationOption> createInterpolateOption();
115 double interpolateFlat(
const DiscusData1D &histToInterpolate,
double x);
116 std::tuple<double, int> sampleQW(
const std::shared_ptr<DiscusData2D> &CumulativeProb,
double x);
117 double interpolateSquareRoot(
const DiscusData1D &histToInterpolate,
double x);
118 double interpolateGaussian(
const DiscusData1D &histToInterpolate,
double x);
120 void updateTrackDirection(
Geometry::Track &track,
const double cosT,
const double phi);
121 void integrateCumulative(
const DiscusData1D &h,
const double xmin,
const double xmax, std::vector<double> &resultX,
122 std::vector<double> &resultY,
const bool returnCumulative);
126 const std::shared_ptr<Geometry::CSGObject>
128 const size_t &histogramIndex);
131 void init()
override;
132 void exec()
override;
133 std::map<std::string, std::string> validateInputs()
override;
135 std::tuple<double, double> new_vector(
const Kernel::Material &material,
double k,
bool specialSingleScatterCalc);
136 std::tuple<std::vector<double>, std::vector<double>>
138 const ComponentWorkspaceMappings &componentWorkspaces,
const double kinc,
139 const std::vector<double> &wValues,
bool specialSingleScatterCalc,
142 const ComponentWorkspaceMappings &componentWorkspaces,
143 const double kinc,
const std::vector<double> &wValues,
144 bool specialSingleScatterCalc,
146 const size_t &histogramIndex);
153 bool specialSingleScatterCalc,
154 const ComponentWorkspaceMappings &componentWorkspaces);
159 void correctForWorkspaceNameClash(std::string &wsName);
161 void createInvPOfQWorkspaces(ComponentWorkspaceMappings &matWSs,
size_t nhists);
162 void convertToLogWorkspace(
const std::shared_ptr<DiscusData2D> &SOfQ);
163 void calculateQSQIntegralAsFunctionOfK(ComponentWorkspaceMappings &matWSs,
const std::vector<double> &specialKs);
164 void prepareCumulativeProbForQ(
double kinc,
const ComponentWorkspaceMappings &PInvOfQs);
165 void prepareQSQ(
double kinc);
166 double getKf(
const double deltaE,
const double kinc);
167 std::tuple<double, double, int, double> sampleQWUniform(
const std::vector<double> &wValues,
169 void prepareStructureFactors();
171 std::tuple<double, double> getKinematicRange(
double kf,
double ki);
172 std::vector<std::tuple<double, int, double>> generateInputKOutputWList(
const double efixed,
173 std::span<double const> xPoints);
174 std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>
175 integrateQSQ(
const std::shared_ptr<DiscusData2D> &QSQ,
double kinc,
const bool returnCumulative);
176 double getQSQIntegral(
const DiscusData1D &QSQScaleFactor,
double k);
181 void loadCollimatorInfo();
182 double getDoubleParamFromIDF(std::string paramName);
183 Kernel::V3D getV3DParamFromIDF(std::string paramName);
184 const std::shared_ptr<Geometry::CSGObject> readFromCollimatorCorridorCache(
const std::size_t &histogramIndex);
185 void writeToCollimatorCorridorCache(
const std::size_t &histogramIndex,
186 const std::shared_ptr<Geometry::CSGObject> &collimatorCorridorCsgObj);
187 long long m_callsToInterceptSurface{0};
188 long long m_IkCalculations{0};
190 int m_maxScatterPtAttempts{};
195 bool m_importanceSampling{};
197 bool m_simulateEnergiesIndependently{};
201 bool m_NormalizeSQ{};