Mantid
Loading...
Searching...
No Matches
MultipleScatteringCorrectionDistGraber.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7
15
16// --------------------------
17// DECLARATIONS
18// --------------------------
19// This class is a helper class for MultipleScatteringCorrection.
20// Its main purpose is to calculate and cache the distance for
21// - L_s1: source to first voxel in sample
22// - L_2d: second voxel in sample to detector
23
24namespace Mantid::Algorithms {
25
26using namespace Geometry;
27using namespace Kernel;
28
36 const double elementSize)
37 : m_sampleShape(&sampleShape), m_elementSize(elementSize) {}
38
45 auto integrationVolume = std::shared_ptr<const IObject>(m_sampleShape->clone());
46
47 // create the raster
48 auto raster = Geometry::Rasterize::calculate(beamDirection, *integrationVolume, m_elementSize);
49
50 // check if the raster is empty
51 if (raster.l1.size() == 0) {
52 throw std::runtime_error("Failed to rasterize sample shape.");
53 }
54
55 // compute and save
56 m_numVolumeElements = raster.l1.size();
57 m_LS1 = std::move(raster.l1);
58 m_elementPositions = std::move(raster.position);
59 m_elementVolumes = std::move(raster.volume);
60 m_totalVolume = raster.totalvolume;
61}
62} // namespace Mantid::Algorithms
const Geometry::IObject * m_sampleShape
The shape pointer is handeled by sample object, not distGraber.
MultipleScatteringCorrectionDistGraber(const Geometry::IObject &sampleShape, const double elementSize)
Construct a new Multiple Scattering Correction Dist Graber:: Multiple Scattering Correction Dist Grab...
std::vector< Kernel::V3D > m_elementPositions
Cached element positions.
void cacheLS1(const Mantid::Kernel::V3D &beamDirection)
pre-calculate the distance from source to L1 for all the voxels in the sample
IObject : Interface for geometry objects.
Definition: IObject.h:41
virtual IObject * clone() const =0
Class for 3D vectors.
Definition: V3D.h:34
MANTID_GEOMETRY_DLL Raster calculate(const Kernel::V3D &beamDirection, const IObject &shape, const double cubeSizeInMetre)
Definition: Rasterize.cpp:181