20 const auto source = instrument.
getSource();
22 const std::string beamShapeParam = source->getParameterAsString(
"beam-shape");
23 if (beamShapeParam ==
"Slit") {
24 const auto beamWidthParam = source->getNumberParameter(
"beam-width");
25 const auto beamHeightParam = source->getNumberParameter(
"beam-height");
26 if (beamWidthParam.size() == 1 && beamHeightParam.size() == 1) {
27 return std::make_unique<RectangularBeamProfile>(*frame, source->getPos(), beamWidthParam[0], beamHeightParam[0]);
29 }
else if (beamShapeParam ==
"Circle") {
30 const auto beamRadiusParam = source->getNumberParameter(
"beam-radius");
31 if (beamRadiusParam.size() == 1) {
32 return std::make_unique<CircularBeamProfile>(*frame, source->getPos(), beamRadiusParam[0]);
37 throw std::invalid_argument(
"Cannot determine beam profile without a sample shape and environment");
49 const double beamWidth = 2 * bboxCentre[frame->pointingHorizontal()] + bbox[frame->pointingHorizontal()];
50 const double beamHeight = 2 * bboxCentre[frame->pointingUp()] + bbox[frame->pointingUp()];
51 return std::make_unique<RectangularBeamProfile>(*frame, source->getPos(), beamWidth, beamHeight);
This class stores information about the sample used in particular run.
bool hasEnvironment() const
const Geometry::IObject & getShape() const
Return the sample shape.
const Geometry::SampleEnvironment & getEnvironment() const
Get a reference to the sample's environment.
static std::unique_ptr< IBeamProfile > createBeamProfile(const Geometry::Instrument &instrument, const API::Sample &sample)
Kernel::V3D width() const
Returns the width of the box.
Kernel::V3D centrePoint() const
Returns the centre of the bounding box.
virtual const BoundingBox & getBoundingBox() const =0
Return cached value of axis-aligned bounding box.
virtual bool hasValidShape() const =0
IComponent_const_sptr getSource() const
Gets a pointer to the source.
std::shared_ptr< const ReferenceFrame > getReferenceFrame() const
Get refernce Frame.
Geometry::BoundingBox boundingBox() const