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);