BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Beam.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Beam/Beam.h
6 //! @brief Defines class Beam.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_DEVICE_BEAM_BEAM_H
16 #define BORNAGAIN_DEVICE_BEAM_BEAM_H
17 
18 #include "Base/Vector/Direction.h"
19 #include "Fit/Param/RealLimits.h"
20 #include "Param/Node/INode.h"
21 
22 class IFootprintFactor;
23 class SpinMatrix;
24 
25 //! An incident neutron or x-ray beam.
26 //! @ingroup beam
27 
28 class Beam : public INode {
29 public:
30  Beam(double intensity, double wavelength, const Direction& direction);
31  Beam(const Beam& other);
32  Beam& operator=(const Beam& other);
33  ~Beam() override;
34 
35  Beam* clone() const;
36  std::string className() const final { return "Beam"; }
37 
38  static Beam horizontalBeam();
39 
40  std::vector<const INode*> nodeChildren() const override;
41 
42  //! Returns the beam intensity in neutrons/sec
43  double intensity() const { return m_intensity; }
44  double wavelength() const { return m_wavelength; }
45  // Direction& direction() { return m_direction; }
46  Direction direction() const { return {m_alpha, m_phi}; } // TODO -> const .. &
47 
48  //! Returns polarization density as Bloch vector
49  R3 polVector() const;
50  //! Returns the polarization density matrix (in spin basis along z-axis)
51  SpinMatrix polMatrix() const;
52 
53  //! Returns footprint factor.
54  const IFootprintFactor* footprintFactor() const;
55 
56  //! Check for limits, set the value if within limits.
57  //! Throws if limits are violated.
58  void setInclinationAngleGuarded(double value);
59 
60  //! Check for limits, set the value if within limits.
61  //! Throws if limits are violated.
62  void setAzimuthalAngleGuarded(double value);
63 
64  //! Check for limits, set the value if within limits.
65  //! Throws if limits are violated.
66  void setWavelengthGuarded(double value);
67 
68 
69  void setWavelength(double wavelength);
70  void setDirection(const Direction& direction);
71  void setInclination(double alpha);
72  void setInclinationLimits(const RealLimits& limits);
73  //! Sets the beam intensity in neutrons/sec
75  //! Sets footprint factor to the beam.
76  void setFootprintFactor(const IFootprintFactor& shape_factor);
77  //! Sets the polarization density matrix according to the given Bloch vector
78  void setPolarization(R3 bloch_vector);
79 
80 private:
81  Beam(); // needed by Swig
82  double m_intensity; //!< beam intensity (neutrons/sec)
83  double m_wavelength;
84  // Direction m_direction; TODO
85  double m_alpha;
86  double m_phi;
87  std::unique_ptr<IFootprintFactor> m_shape_factor; //!< footprint correction handler
88  R3 m_beamPolarization; //!< Bloch vector encoding the beam's polarization
89 
91 
93 };
94 
95 #endif // BORNAGAIN_DEVICE_BEAM_BEAM_H
Defines class Direction.
Defines interface INode.
Defines class RealLimits.
An incident neutron or x-ray beam.
Definition: Beam.h:28
double m_alpha
Definition: Beam.h:85
RealLimits m_alphaLimits
Definition: Beam.h:90
Direction direction() const
Definition: Beam.h:46
static Beam horizontalBeam()
Definition: Beam.cpp:48
void setAzimuthalAngleGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
Definition: Beam.cpp:123
void setPolarization(R3 bloch_vector)
Sets the polarization density matrix according to the given Bloch vector.
Definition: Beam.cpp:140
R3 m_beamPolarization
Bloch vector encoding the beam's polarization.
Definition: Beam.h:88
void setDirection(const Direction &direction)
Definition: Beam.cpp:92
~Beam() override
double m_wavelength
Definition: Beam.h:83
void setIntensity(double intensity)
Sets the beam intensity in neutrons/sec.
Definition: Beam.h:74
void setInclinationAngleGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
Definition: Beam.cpp:117
double m_phi
Definition: Beam.h:86
double intensity() const
Returns the beam intensity in neutrons/sec.
Definition: Beam.h:43
double wavelength() const
Definition: Beam.h:44
void setInclination(double alpha)
Definition: Beam.cpp:102
Beam & operator=(const Beam &other)
Definition: Beam.cpp:61
friend class DepthProbeSimulationTest
Definition: Beam.h:92
const IFootprintFactor * footprintFactor() const
Returns footprint factor.
Definition: Beam.cpp:112
void setWavelengthGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
Definition: Beam.cpp:129
void setFootprintFactor(const IFootprintFactor &shape_factor)
Sets footprint factor to the beam.
Definition: Beam.cpp:135
std::unique_ptr< IFootprintFactor > m_shape_factor
footprint correction handler
Definition: Beam.h:87
void setInclinationLimits(const RealLimits &limits)
Definition: Beam.cpp:107
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Beam.h:36
Beam * clone() const
Definition: Beam.cpp:80
void setWavelength(double wavelength)
Definition: Beam.cpp:85
SpinMatrix polMatrix() const
Returns the polarization density matrix (in spin basis along z-axis)
Definition: Beam.cpp:155
double m_intensity
beam intensity (neutrons/sec)
Definition: Beam.h:82
std::vector< const INode * > nodeChildren() const override
Returns all children.
Definition: Beam.cpp:160
R3 polVector() const
Returns polarization density as Bloch vector.
Definition: Beam.cpp:150
A direction in three-dimensional space.
Definition: Direction.h:24
Abstract base for classes that calculate the beam footprint factor.
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:40
Limits for a real fit parameter.
Definition: RealLimits.h:24