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
15
#include "
Device/Beam/FootprintSquare.h
"
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
25
FootprintSquare::FootprintSquare
(
double
width_ratio)
26
:
FootprintSquare
(
std
::vector<double>{width_ratio})
27
{
28
}
29
30
FootprintSquare
*
FootprintSquare::clone
()
const
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"
);
Constants.h
Defines M_PI and some more mathematical constants.
M_PI_2
#define M_PI_2
Definition:
Constants.h:45
FootprintSquare.h
Defines class FootprintSquare.
FootprintSquare
Rectangular beam footprint.
Definition:
FootprintSquare.h:23
FootprintSquare::clone
FootprintSquare * clone() const override
Definition:
FootprintSquare.cpp:30
FootprintSquare::calculate
double calculate(double alpha) const override
Calculate footprint correction coefficient from the beam incident angle alpha.
Definition:
FootprintSquare.cpp:35
FootprintSquare::FootprintSquare
FootprintSquare(const std::vector< double > P)
Definition:
FootprintSquare.cpp:20
IFootprintFactor
Abstract base for classes that calculate the beam footprint factor.
Definition:
IFootprintFactor.h:28
IFootprintFactor::widthRatio
double widthRatio() const
Definition:
IFootprintFactor.h:37
IFootprintFactor::m_width_ratio
const double & m_width_ratio
Definition:
IFootprintFactor.h:45
std
Definition:
filesystem.h:81
Device
Beam
FootprintSquare.cpp
Generated by
1.9.1