BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SphericalPixel.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/Detector/SphericalPixel.cpp
6 //! @brief Implements class SphericalPixel.
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/Axis/Bin.h"
17 
18 SphericalPixel::SphericalPixel(const Bin1D& alpha_bin, const Bin1D& phi_bin)
19  : m_alpha(alpha_bin.m_lower), m_phi(phi_bin.m_lower), m_dalpha(alpha_bin.getBinSize()),
20  m_dphi(phi_bin.getBinSize())
21 {
22  auto solid_angle_value = std::abs(m_dphi * (std::sin(m_alpha + m_dalpha) - std::sin(m_alpha)));
23  m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value;
24 }
25 
27 {
28  return new SphericalPixel(*this);
29 }
30 
32 {
33  double phi = m_phi + x * m_dphi;
34  double alpha = m_alpha + y * m_dalpha;
35  Bin1D alpha_bin(alpha, alpha);
36  Bin1D phi_bin(phi, phi);
37  return new SphericalPixel(alpha_bin, phi_bin);
38 }
39 
40 kvector_t SphericalPixel::getK(double x, double y, double wavelength) const
41 {
42  double phi = m_phi + x * m_dphi;
43  double alpha = m_alpha + y * m_dalpha;
44  return vecOfLambdaAlphaPhi(wavelength, alpha, phi);
45 }
46 
47 double SphericalPixel::getIntegrationFactor(double /* x */, double y) const
48 {
49  if (m_dalpha == 0.0)
50  return 1.0;
51  double alpha = m_alpha + y * m_dalpha;
52  return std::cos(alpha) * m_dalpha / (std::sin(m_alpha + m_dalpha) - std::sin(m_alpha));
53 }
54 
56 {
57  return m_solid_angle;
58 }
BasicVector3D< double > vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Creates a vector<double> as a wavevector with given wavelength and angles.
Defines structs Bin1D, Bin1DCVector.
Defines class SphericalPixel.
A pixel in a SphericalDetector.
SphericalPixel * createZeroSizePixel(double x, double y) const override
SphericalPixel * clone() const override
double m_solid_angle
SphericalPixel(const Bin1D &alpha_bin, const Bin1D &phi_bin)
kvector_t getK(double x, double y, double wavelength) const override
double getIntegrationFactor(double x, double y) const override
double getSolidAngle() const override
Definition: Bin.h:20