BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FootprintSquare.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Beam/FootprintSquare.cpp
6 //! @brief Implements class FootprintSquare.
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/Math/Constants.h"
17 #include <algorithm>
18 #include <stdexcept>
19 
20 FootprintSquare::FootprintSquare(const std::vector<double> P)
21  : IFootprintFactor({"FootprintSquare", "class_tooltip", {}}, P)
22 {
23 }
24 
26  : FootprintSquare(std::vector<double>{width_ratio})
27 {
28 }
29 
31 {
32  return new FootprintSquare(m_width_ratio);
33 }
34 
35 double FootprintSquare::calculate(double alpha) const
36 {
37  if (alpha < 0.0 || alpha > M_PI_2)
38  return 0.0;
39  if (widthRatio() == 0.0)
40  return 1.0;
41  const double arg = std::sin(alpha) / widthRatio();
42  return std::min(arg, 1.0);
43 }
44 
45 static_assert(!std::is_copy_constructible<FootprintSquare>::value,
46  "FootprintSquare should not be copy constructable");
47 static_assert(!std::is_copy_assignable<FootprintSquare>::value,
48  "FootprintSquare should not be copy assignable");
Defines M_PI and some more mathematical constants.
#define M_PI_2
Definition: Constants.h:45
Defines class FootprintSquare.
Rectangular beam footprint.
FootprintSquare * clone() const override
double calculate(double alpha) const override
Calculate footprint correction coefficient from the beam incident angle alpha.
FootprintSquare(const std::vector< double > P)
Abstract base for classes that calculate the beam footprint factor.
double widthRatio() const
const double & m_width_ratio
Definition: filesystem.h:81