Mantid
Loading...
Searching...
No Matches
CircularBeamProfile.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
26 double radius)
27 : IBeamProfile(), m_upIdx(frame.pointingUp()), m_beamIdx(frame.pointingAlongBeam()),
28 m_horIdx(frame.pointingHorizontal()), m_radius(radius), m_min(), m_center(center), m_beamDir() {
32 m_beamDir[m_beamIdx] = 1.0;
33}
34
42 V3D pt;
43 const double rsq = m_radius * m_radius;
44 const double R = std::sqrt(rng.nextValue() * rsq);
45 const double theta = rng.nextValue() * M_PI * 2;
46 pt[m_upIdx] = R * cos(theta);
47 pt[m_horIdx] = R * sin(theta);
48 // Correct for centre point
49 pt[m_upIdx] += m_center[m_upIdx];
52 return {pt, m_beamDir};
53}
54
65 const Geometry::BoundingBox &bounds) const {
66 auto rngRay = generatePoint(rng);
67 auto &rngPt = rngRay.startPos;
68 const V3D minBound(bounds.minPoint()), maxBound(bounds.maxPoint());
69 if (rngPt[m_upIdx] > maxBound[m_upIdx])
70 rngPt[m_upIdx] = maxBound[m_upIdx];
71 else if (rngPt[m_upIdx] < minBound[m_upIdx])
72 rngPt[m_upIdx] = minBound[m_upIdx];
73
74 if (rngPt[m_horIdx] > maxBound[m_horIdx])
75 rngPt[m_horIdx] = maxBound[m_horIdx];
76 else if (rngPt[m_horIdx] < minBound[m_horIdx])
77 rngPt[m_horIdx] = minBound[m_horIdx];
78 return rngRay;
79}
80
88 // In the beam direction use the maximum sample extent other wise restrict
89 // the active region to the width/height of beam
90 const auto &sampleMin(sampleBox.minPoint());
91 const auto &sampleMax(sampleBox.maxPoint());
92 V3D minPoint, maxPoint;
93 minPoint[m_horIdx] = std::max(sampleMin[m_horIdx], m_min[m_horIdx]);
94 maxPoint[m_horIdx] = std::min(sampleMax[m_horIdx], m_center[m_horIdx] + m_radius);
95 minPoint[m_upIdx] = std::max(sampleMin[m_upIdx], m_min[m_upIdx]);
96 maxPoint[m_upIdx] = std::min(sampleMax[m_upIdx], m_center[m_upIdx] + m_radius);
97 minPoint[m_beamIdx] = sampleMin[m_beamIdx];
98 maxPoint[m_beamIdx] = sampleMax[m_beamIdx];
99
100 return Geometry::BoundingBox(maxPoint.X(), maxPoint.Y(), maxPoint.Z(), minPoint.X(), minPoint.Y(), minPoint.Z());
101}
102
103} // namespace Algorithms
104} // namespace Mantid
specnum_t m_min
double radius
Definition: Rasterize.cpp:31
CircularBeamProfile(const Geometry::ReferenceFrame &frame, const Kernel::V3D &center, double radius)
Construct a beam profile.
IBeamProfile::Ray generatePoint(Kernel::PseudoRandomNumberGenerator &rng) const override
Generate a random point within the beam profile using the supplied random number source.
Geometry::BoundingBox defineActiveRegion(const Geometry::BoundingBox &sampleBox) const override
Compute a region that defines how the beam illuminates the given sample/can.
Base class for all classes defining a beam profile.
Definition: IBeamProfile.h:26
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.