93 const std::string
name()
const override {
return "DiscusMultipleScatteringCorrection"; }
95 int version()
const override {
return 1; }
96 const std::vector<std::string>
seeAlso()
const override {
97 return {
"MayersSampleCorrection",
"CarpenterSampleCorrection",
"VesuvioCalculateMS"};
100 const std::string
category()
const override {
return "CorrectionFunctions"; }
103 return "Calculates a multiple scattering correction using a Monte Carlo method";
105 const std::string
alias()
const override {
return "Muscat"; }
109 virtual std::shared_ptr<SparseWorkspace> createSparseWorkspace(
const API::MatrixWorkspace &modelWS,
110 const size_t nXPoints,
const size_t rows,
111 const size_t columns);
112 virtual std::unique_ptr<InterpolationOption> createInterpolateOption();
113 double interpolateFlat(
const DiscusData1D &histToInterpolate,
double x);
114 std::tuple<double, int> sampleQW(
const std::shared_ptr<DiscusData2D> &CumulativeProb,
double x);
115 double interpolateSquareRoot(
const DiscusData1D &histToInterpolate,
double x);
116 double interpolateGaussian(
const DiscusData1D &histToInterpolate,
double x);
118 void updateTrackDirection(
Geometry::Track &track,
const double cosT,
const double phi);
119 void integrateCumulative(
const DiscusData1D &h,
const double xmin,
const double xmax, std::vector<double> &resultX,
120 std::vector<double> &resultY,
const bool returnCumulative);
124 const std::shared_ptr<Geometry::CSGObject>
126 const size_t &histogramIndex);
129 void init()
override;
130 void exec()
override;
131 std::map<std::string, std::string> validateInputs()
override;
133 std::tuple<double, double> new_vector(
const Kernel::Material &material,
double k,
bool specialSingleScatterCalc);
134 std::tuple<std::vector<double>, std::vector<double>>
136 const ComponentWorkspaceMappings &componentWorkspaces,
const double kinc,
137 const std::vector<double> &wValues,
bool specialSingleScatterCalc,
140 const ComponentWorkspaceMappings &componentWorkspaces,
141 const double kinc,
const std::vector<double> &wValues,
142 bool specialSingleScatterCalc,
144 const size_t &histogramIndex);
151 bool specialSingleScatterCalc,
152 const ComponentWorkspaceMappings &componentWorkspaces);
157 void correctForWorkspaceNameClash(std::string &wsName);
159 void createInvPOfQWorkspaces(ComponentWorkspaceMappings &matWSs,
size_t nhists);
160 void convertToLogWorkspace(
const std::shared_ptr<DiscusData2D> &SOfQ);
161 void calculateQSQIntegralAsFunctionOfK(ComponentWorkspaceMappings &matWSs,
const std::vector<double> &specialKs);
162 void prepareCumulativeProbForQ(
double kinc,
const ComponentWorkspaceMappings &PInvOfQs);
163 void prepareQSQ(
double kinc);
164 double getKf(
const double deltaE,
const double kinc);
165 std::tuple<double, double, int, double> sampleQWUniform(
const std::vector<double> &wValues,
167 void prepareStructureFactors();
169 std::tuple<double, double> getKinematicRange(
double kf,
double ki);
170 std::vector<std::tuple<double, int, double>> generateInputKOutputWList(
const double efixed,
171 const std::vector<double> &xPoints);
172 std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>
173 integrateQSQ(
const std::shared_ptr<DiscusData2D> &QSQ,
double kinc,
const bool returnCumulative);
174 double getQSQIntegral(
const DiscusData1D &QSQScaleFactor,
double k);
179 void loadCollimatorInfo();
180 double getDoubleParamFromIDF(std::string paramName);
181 Kernel::V3D getV3DParamFromIDF(std::string paramName);
182 const std::shared_ptr<Geometry::CSGObject> readFromCollimatorCorridorCache(
const std::size_t &histogramIndex);
183 void writeToCollimatorCorridorCache(
const std::size_t &histogramIndex,
184 const std::shared_ptr<Geometry::CSGObject> &collimatorCorridorCsgObj);
185 long long m_callsToInterceptSurface{0};
186 long long m_IkCalculations{0};
188 int m_maxScatterPtAttempts{};
193 bool m_importanceSampling{};
195 bool m_simulateEnergiesIndependently{};
199 bool m_NormalizeSQ{};