20 #include <heinz/Complex.h>
25 constexpr
double INCLINATION_LIMIT =
M_PI_2 + 1e-10;
34 : m_intensity(intensity)
35 , m_wavelength(wavelength)
37 , m_alpha(direction.alpha())
38 , m_phi(direction.phi())
39 , m_alphaLimits(
RealLimits::limited(-INCLINATION_LIMIT, INCLINATION_LIMIT))
45 phiLimits.check(
"AzimuthalAngle",
m_phi);
50 return Beam(1.0, 1.0, {0, 0});
54 :
Beam(other.m_intensity, other.m_wavelength, other.direction())
82 return new Beam(*
this);
88 throw std::runtime_error(
"Invalid beam parameter: Wavelength can't be negative or zero.");
95 throw std::runtime_error(
96 "Invalid beam parameter: Inclination angle alpha_i can't be negative.");
125 phiLimits.check(
"azimuthal angle", value);
131 wavelengthLimits.check(
"wavelength", value);
142 if (bloch_vector.mag() > 1.0) {
143 throw std::runtime_error(
144 "Beam::setPolarization: "
145 "The given Bloch vector cannot represent a real physical ensemble");
Defines the macro ASSERT.
Defines M_PI and some more mathematical constants.
Defines class SpinMatrix.
An incident neutron or x-ray beam.
Direction direction() const
static Beam horizontalBeam()
void setAzimuthalAngleGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
void setPolarization(R3 bloch_vector)
Sets the polarization density matrix according to the given Bloch vector.
R3 m_beamPolarization
Bloch vector encoding the beam's polarization.
void setDirection(const Direction &direction)
void setInclinationAngleGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
double wavelength() const
void setInclination(double alpha)
Beam & operator=(const Beam &other)
const IFootprintFactor * footprintFactor() const
Returns footprint factor.
void setWavelengthGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
void setFootprintFactor(const IFootprintFactor &shape_factor)
Sets footprint factor to the beam.
std::unique_ptr< IFootprintFactor > m_shape_factor
footprint correction handler
void setInclinationLimits(const RealLimits &limits)
void setWavelength(double wavelength)
SpinMatrix polMatrix() const
Returns the polarization density matrix (in spin basis along z-axis)
double m_intensity
beam intensity (neutrons/sec)
std::vector< const INode * > nodeChildren() const override
Returns all children.
R3 polVector() const
Returns polarization density as Bloch vector.
A direction in three-dimensional space.
Limits for a real fit parameter.
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
static SpinMatrix FromBlochVector(const R3 &v)
Constructs matrix (I+v*s)/2, where s is the Pauli vector.