23 const auto source = instrument.
getSource();
25 const std::string beamShapeParam = source->getParameterAsString(
"beam-shape");
26 if (beamShapeParam ==
"Slit") {
27 const auto beamWidthParam = source->getNumberParameter(
"beam-width");
28 const auto beamHeightParam = source->getNumberParameter(
"beam-height");
29 if (beamWidthParam.size() == 1 && beamHeightParam.size() == 1) {
30 return std::make_unique<RectangularBeamProfile>(*frame, source->getPos(), beamWidthParam[0], beamHeightParam[0]);
32 }
else if (beamShapeParam ==
"Circle") {
33 const auto beamRadiusParam = source->getNumberParameter(
"beam-radius");
34 if (beamRadiusParam.size() == 1) {
35 return std::make_unique<CircularBeamProfile>(*frame, source->getPos(), beamRadiusParam[0]);
40 throw std::invalid_argument(
"Cannot determine beam profile without a sample shape and environment");
54 const auto hor = frame->pointingHorizontal();
55 const auto up = frame->pointingUp();
56 const double beamWidth = 2 * std::max(std::abs(bboxMin[hor]), std::abs(bboxMax[hor]));
57 const double beamHeight = 2 * std::max(std::abs(bboxMin[up]), std::abs(bboxMax[up]));
58 return std::make_unique<RectangularBeamProfile>(*frame, source->getPos(), beamWidth, beamHeight);