Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#include "MantidAlgorithms/SampleCorrections/SparseWorkspace.h"
#include "MantidGeometry/IComponent.h"
#include "MantidGeometry/Instrument/SampleEnvironment.h"
#include "MantidGeometry/Objects/CSGObject.h"
#include "MantidKernel/PseudoRandomNumberGenerator.h"

#include <boost/container/small_vector.hpp>
#include <shared_mutex>

namespace Mantid {
namespace API {
Expand Down Expand Up @@ -69,6 +70,15 @@ struct ComponentWorkspaceMapping {
std::shared_ptr<int> scatterCount = std::make_shared<int>(0);
};

/** Object for holding collimator parameteres loaded from instrument parameters file
*/
struct CollimatorInfo {
double m_innerRadius;
double m_halfAngularExtent;
double m_plateHeight;
Kernel::V3D m_axisVec;
};

/** Calculates a multiple scattering correction
* Based on Muscat Fortran code provided by Spencer Howells

Expand Down Expand Up @@ -112,6 +122,9 @@ class MANTID_ALGORITHMS_DLL DiscusMultipleScatteringCorrection : public API::Alg
API::MatrixWorkspace_sptr integrateWS(const API::MatrixWorkspace_sptr &ws);
void getXMinMax(const Mantid::API::MatrixWorkspace &ws, double &xmin, double &xmax) const;
void prepareSampleBeamGeometry(const API::MatrixWorkspace_sptr &inputWS);
const std::shared_ptr<Geometry::CSGObject>
createCollimatorHexahedronShape(const Kernel::V3D &samplePos, const Mantid::Geometry::DetectorInfo &detectorInfo,
const size_t &histogramIndex);

private:
void init() override;
Expand All @@ -122,11 +135,15 @@ class MANTID_ALGORITHMS_DLL DiscusMultipleScatteringCorrection : public API::Alg
std::tuple<std::vector<double>, std::vector<double>>
simulatePaths(const int nEvents, const int nScatters, Kernel::PseudoRandomNumberGenerator &rng,
const ComponentWorkspaceMappings &componentWorkspaces, const double kinc,
const std::vector<double> &wValues, const Kernel::V3D &detPos, bool specialSingleScatterCalc);
const std::vector<double> &wValues, bool specialSingleScatterCalc,
const Mantid::Geometry::DetectorInfo &detectorInfo, const size_t &histogramIndex);
std::tuple<bool, std::vector<double>> scatter(const int nScatters, Kernel::PseudoRandomNumberGenerator &rng,
const ComponentWorkspaceMappings &componentWorkspaces,
const double kinc, const std::vector<double> &wValues,
const Kernel::V3D &detPos, bool specialSingleScatterCalc);
bool specialSingleScatterCalc,
const Mantid::Geometry::DetectorInfo &detectorInfo,
const size_t &histogramIndex);

Geometry::Track start_point(Kernel::PseudoRandomNumberGenerator &rng);
Geometry::Track generateInitialTrack(Kernel::PseudoRandomNumberGenerator &rng);
void inc_xyz(Geometry::Track &track, double vl);
Expand Down Expand Up @@ -160,6 +177,12 @@ class MANTID_ALGORITHMS_DLL DiscusMultipleScatteringCorrection : public API::Alg
const Geometry::IObject *shapeObjectWithScatter);
void addWorkspaceToDiscus2DData(const Geometry::IObject_const_sptr &shape, const std::string_view &matName,
API::MatrixWorkspace_sptr ws);
void loadCollimatorInfo();
double getDoubleParamFromIDF(std::string paramName);
Kernel::V3D getV3DParamFromIDF(std::string paramName);
const std::shared_ptr<Geometry::CSGObject> readFromCollimatorCorridorCache(const std::size_t &histogramIndex);
void writeToCollimatorCorridorCache(const std::size_t &histogramIndex,
const std::shared_ptr<Geometry::CSGObject> &collimatorCorridorCsgObj);
long long m_callsToInterceptSurface{0};
long long m_IkCalculations{0};
std::map<int, int> m_attemptsToGenerateInitialTrack;
Expand All @@ -177,6 +200,10 @@ class MANTID_ALGORITHMS_DLL DiscusMultipleScatteringCorrection : public API::Alg
bool m_NormalizeSQ{};
Geometry::BoundingBox m_activeRegion;
std::unique_ptr<IBeamProfile> m_beamProfile;
Mantid::Geometry::Instrument_const_sptr m_instrument;
std::unique_ptr<CollimatorInfo> m_collimatorInfo;
std::map<std::size_t, std::shared_ptr<Geometry::CSGObject>> m_collimatorCorridorCache;
mutable std::shared_mutex m_mutexCorridorCache;
};
} // namespace Algorithms
} // namespace Mantid
Loading
Loading