BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SimulationElement.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Pixel/SimulationElement.cpp
6 //! @brief Implements class SimulationElement.
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 
16 #include "Base/Pixel/IPixel.h"
17 #include "Base/Vector/Direction.h"
18 
19 SimulationElement::SimulationElement(double wavelength, double alpha_i, double phi_i,
20  std::unique_ptr<IPixel> pixel,
21  const Eigen::Matrix2cd& beam_polarization,
22  const Eigen::Matrix2cd& analyzer, bool isSpecular_)
23  : m_polarization(beam_polarization, analyzer)
24  , m_wavelength(wavelength)
25  , m_alpha_i(alpha_i)
26  , m_phi_i(phi_i)
27  , m_k_i(vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i))
28  , m_mean_kf(pixel->getK(0.5, 0.5, m_wavelength))
29  , m_pixel(std::move(pixel))
30  , m_is_specular(isSpecular_)
31  , m_intensity(0.0)
32 {
33 }
34 
36  : m_polarization(other.m_polarization)
37  , m_wavelength(other.m_wavelength)
38  , m_alpha_i(other.m_alpha_i)
39  , m_phi_i(other.m_phi_i)
40  , m_k_i(other.m_k_i)
41  , m_mean_kf(other.m_mean_kf)
42  , m_pixel(std::move(other.m_pixel->clone()))
43  , m_is_specular(other.m_is_specular)
44  , m_intensity(other.m_intensity)
45 {
46 }
47 
49 
51 
53 {
54  return {m_wavelength,
55  m_alpha_i,
56  m_phi_i,
57  std::unique_ptr<IPixel>(m_pixel->createZeroSizePixel(x, y)), // TODO simplify
61 }
62 
64 {
65  return m_k_i;
66 }
67 
69 {
70  return m_mean_kf;
71 }
72 
73 //! Returns outgoing wavevector Kf for in-pixel coordinates x,y.
74 //! In-pixel coordinates take values from 0 to 1.
75 kvector_t SimulationElement::getKf(double x, double y) const
76 {
77  return m_pixel->getK(x, y, m_wavelength);
78 }
79 
81 {
82  return getKi() - getMeanKf();
83 }
84 
85 //! Returns scattering vector Q, with Kf determined from in-pixel coordinates x,y.
86 //! In-pixel coordinates take values from 0 to 1.
87 kvector_t SimulationElement::getQ(double x, double y) const
88 {
89  return getKi() - m_pixel->getK(x, y, m_wavelength);
90 }
91 
92 double SimulationElement::getAlpha(double x, double y) const
93 {
94  return M_PI_2 - getKf(x, y).theta();
95 }
96 
97 double SimulationElement::getPhi(double x, double y) const
98 {
99  return getKf(x, y).phi();
100 }
101 
102 double SimulationElement::integrationFactor(double x, double y) const
103 {
104  return m_pixel->integrationFactor(x, y);
105 }
106 
108 {
109  return m_pixel->solidAngle();
110 }
#define M_PI_2
Definition: Constants.h:45
kvector_t vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Definition: Direction.cpp:19
Defines class Direction.
Defines and implements interface IPixel.
Defines class SimulationElement.
double theta() const
Returns polar angle.
double phi() const
Returns azimuth angle.
Eigen::Matrix2cd getAnalyzerOperator() const
Gets the polarization analyzer operator (in spin basis along z-axis)
Eigen::Matrix2cd getPolarization() const
Gets the polarization density matrix (in spin basis along z-axis)
Data stucture containing both input and output of a single detector cell.
const PolarizationHandler m_polarization
const bool m_is_specular
double solidAngle() const
SimulationElement pointElement(double x, double y) const
Returns copy of this SimulationElement with k_f given by in-pixel coordinate x,y.
SimulationElement()=delete
kvector_t getMeanKf() const
kvector_t meanQ() const
const double m_wavelength
wavelength of beam
const double m_phi_i
incident angle in xy plane
kvector_t getKf(double x, double y) const
Returns outgoing wavevector Kf for in-pixel coordinates x,y.
kvector_t getKi() const
const kvector_t m_mean_kf
cached value of mean_kf
const double m_alpha_i
incident grazing angle
double integrationFactor(double x, double y) const
kvector_t getQ(double x, double y) const
Returns scattering vector Q, with Kf determined from in-pixel coordinates x,y.
const kvector_t m_k_i
cached value of k_i
std::unique_ptr< IPixel > m_pixel
double getAlpha(double x, double y) const
double getPhi(double x, double y) const
Definition: filesystem.h:81