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(center), 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
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());
86 V3D minPt, maxPt;
87 minPt[m_horIdx] = std::max(sampleMin[m_horIdx], m_min[m_horIdx]);
88 maxPt[m_horIdx] = std::min(sampleMax[m_horIdx], m_min[m_horIdx] + m_width);
89 minPt[m_upIdx] = std::max(sampleMin[m_upIdx], m_min[m_upIdx]);
90 maxPt[m_upIdx] = std::min(sampleMax[m_upIdx], m_min[m_upIdx] + m_height);
91 minPt[m_beamIdx] = sampleMin[m_beamIdx];
92 maxPt[m_beamIdx] = sampleMax[m_beamIdx];
93
94 return Geometry::BoundingBox(maxPt.X(), maxPt.Y(), maxPt.Z(), minPt.X(), minPt.Y(), minPt.Z());
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.
RectangularBeamProfile(const Geometry::ReferenceFrame &frame, const Kernel::V3D &center, double width, double height)
Construct a beam profile.
Geometry::BoundingBox defineActiveRegion(const Geometry::BoundingBox &) const override
Compute a region that defines how the beam illuminates the given sample/can.
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:33
const Kernel::V3D & minPoint() const
Returns the min point of the box.
Definition BoundingBox.h:89
const Kernel::V3D & maxPoint() const
Returns the min point of the box.
Definition BoundingBox.h:91
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:238
constexpr double Y() const noexcept
Get y.
Definition V3D.h:239
constexpr double Z() const noexcept
Get z.
Definition V3D.h:240
Helper class which provides the Collimation Length for SANS instruments.