Mantid
Loading...
Searching...
No Matches
RectangularBeamProfile.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
8#include "MantidAPI/Sample.h"
13#include "MantidKernel/V3D.h"
14
15namespace Mantid {
16using Kernel::V3D;
17namespace Algorithms {
18
27 double width, double height)
28 : IBeamProfile(), m_upIdx(frame.pointingUp()), m_beamIdx(frame.pointingAlongBeam()),
29 m_horIdx(frame.pointingHorizontal()), m_width(width), m_height(height), m_min(), m_beamDir() {
30 m_min[m_upIdx] = center[m_upIdx] - 0.5 * height;
31 m_min[m_horIdx] = center[m_horIdx] - 0.5 * width;
32 m_min[m_beamIdx] = center[m_beamIdx];
33 m_beamDir[m_beamIdx] = 1.0;
34}
35
43 V3D pt;
44 pt[m_upIdx] = m_min[m_upIdx] + rng.nextValue() * m_height;
45 pt[m_horIdx] = m_min[m_horIdx] + rng.nextValue() * m_width;
47 return {pt, m_beamDir};
48}
49
60 const Geometry::BoundingBox &bounds) const {
61 auto rngRay = generatePoint(rng);
62 auto &rngPt = rngRay.startPos;
63 const V3D minBound(bounds.minPoint()), maxBound(bounds.maxPoint());
64 if (rngPt[m_upIdx] > maxBound[m_upIdx])
65 rngPt[m_upIdx] = maxBound[m_upIdx];
66 else if (rngPt[m_upIdx] < minBound[m_upIdx])
67 rngPt[m_upIdx] = minBound[m_upIdx];
68
69 if (rngPt[m_horIdx] > maxBound[m_horIdx])
70 rngPt[m_horIdx] = maxBound[m_horIdx];
71 else if (rngPt[m_horIdx] < minBound[m_horIdx])
72 rngPt[m_horIdx] = minBound[m_horIdx];
73 return rngRay;
74}
75
82 // In the beam direction use the maximum sample extent other wise restrict
83 // the active region to the width/height of beam
84 const auto &sampleMin(sampleBox.minPoint());
85 const auto &sampleMax(sampleBox.maxPoint());
87 minPoint[m_horIdx] = std::max(sampleMin[m_horIdx], m_min[m_horIdx]);
88 maxPoint[m_horIdx] = std::min(sampleMax[m_horIdx], m_min[m_horIdx] + m_width);
89 minPoint[m_upIdx] = std::max(sampleMin[m_upIdx], m_min[m_upIdx]);
90 maxPoint[m_upIdx] = std::min(sampleMax[m_upIdx], m_min[m_upIdx] + m_height);
91 minPoint[m_beamIdx] = sampleMin[m_beamIdx];
92 maxPoint[m_beamIdx] = sampleMax[m_beamIdx];
93
95}
96
97} // namespace Algorithms
98} // namespace Mantid
double height
Definition: GetAllEi.cpp:155
specnum_t m_min
Base class for all classes defining a beam profile.
Definition: IBeamProfile.h:26
RectangularBeamProfile(const Geometry::ReferenceFrame &frame, const Kernel::V3D &center, double width, double height)
Construct a beam profile.
Kernel::V3D minPoint() const
Returns the min point of the profile.
Geometry::BoundingBox defineActiveRegion(const Geometry::BoundingBox &) const override
Compute a region that defines how the beam illuminates the given sample/can.
Kernel::V3D maxPoint() const
Returns the max point of the profile.
IBeamProfile::Ray generatePoint(Kernel::PseudoRandomNumberGenerator &rng) const override
Generate a random point within the beam profile using the supplied random number source.
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition: BoundingBox.h:34
const Kernel::V3D & minPoint() const
Returns the min point of the box.
Definition: BoundingBox.h:90
const Kernel::V3D & maxPoint() const
Returns the min point of the box.
Definition: BoundingBox.h:92
ReferenceFrame : Holds reference frame information from the geometry description file.
Defines a 1D pseudo-random number generator, i.e.
virtual double nextValue()=0
Return the next double in the sequence.
Class for 3D vectors.
Definition: V3D.h:34
constexpr double X() const noexcept
Get x.
Definition: V3D.h:232
constexpr double Y() const noexcept
Get y.
Definition: V3D.h:233
constexpr double Z() const noexcept
Get z.
Definition: V3D.h:234
Helper class which provides the Collimation Length for SANS instruments.