BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
AlphaScan.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sim/Scan/AlphaScan.h
6 //! @brief Declares AlphaScan class.
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_SIM_SCAN_ALPHASCAN_H
16 #define BORNAGAIN_SIM_SCAN_ALPHASCAN_H
17 
18 #include "Sim/Scan/ISpecularScan.h"
19 #include <memory>
20 
21 class ParameterSample;
23 class ScanResolution;
24 
25 //! Scan type with inclination angles as coordinate values and a unique wavelength.
26 //! Features footprint correction.
27 class AlphaScan : public ISpecularScan {
28 public:
29  AlphaScan(double wl, std::vector<double> inc_angle);
30  AlphaScan(double wl, const IAxis& inc_angle);
31  //! Sets angle-defined specular scan. The first parameter is always a wavelength in nm.
32  //! Second parameter is either a numpy array of incident angles in radians or an IAxis object
33  //! with angle values. Alternatively an axis can be defined in-place, then
34  //! the second passed parameter is the number of bins, third - minimum on-axis angle value,
35  //! fourth - maximum on-axis angle value.
36  AlphaScan(double wl, int nbins, double alpha_i_min, double alpha_i_max);
37  ~AlphaScan() override;
38  AlphaScan* clone() const override;
39 
40 #ifndef SWIG
41  //! Generates simulation elements for specular simulations
42  std::vector<SpecularElement> generateElements() const override;
43 
44  //! Returns coordinate axis assigned to the data holder
45  const IAxis* coordinateAxis() const override { return m_inc_angle.get(); }
46 
47  //! Returns IFootprintFactor object pointer
48  const IFootprintFactor* footprintFactor() const override { return m_footprint.get(); }
49 
50  //! Returns footprint correction factor for a range of simulation elements of size _n_elements_
51  //! and starting from element with index _i_.
52  std::vector<double> footprint(size_t start, size_t n_elements) const override;
53 
54  //! Returns the number of simulation elements
55  size_t numberOfElements() const override;
56 
57  CoordSystem1D* createCoordSystem() const override;
58 
59  //! Returns intensity vector corresponding to convolution of given simulation elements
60  std::vector<double> createIntensities(const std::vector<SpecularElement>& eles) const override;
61 
62  // TODO: remove these getters after transition to the new resolution machinery is finished
63  const ScanResolution* wavelengthResolution() const { return m_wl_resolution.get(); }
64  const ScanResolution* angleResolution() const { return m_inc_resolution.get(); }
65 #endif // USER_API
66 
67  double wavelength() const override { return m_wl; }
68 
69  //! Sets footprint correction factor
70  void setFootprintFactor(const IFootprintFactor* f_factor);
71 
72  //! Sets wavelength resolution values via ScanResolution object.
73  void setWavelengthResolution(const ScanResolution& resolution);
74 
75  void setRelativeWavelengthResolution(const IRangedDistribution& distr, double rel_dev);
76  //! Sets wavelength resolution values via IRangedDistribution and values of relative deviations
77  //! (that is, _rel_dev_ equals standard deviation divided by the mean value).
78  //! _rel_dev_ can be either single-valued or a numpy array. In the latter case the length of the
79  //! array should coinside with the length of the inclination angle axis.
81  const std::vector<double>& rel_dev);
82 
83  void setAbsoluteWavelengthResolution(const IRangedDistribution& distr, double std_dev);
84  //! Sets wavelength resolution values via IRangedDistribution and values of standard deviations.
85  //! _std_dev_ can be either single-valued or a numpy array. In the latter case the length of the
86  //! array should coinside with the length of the inclination angle axis.
88  const std::vector<double>& std_dev);
89 
90  //! Sets angle resolution values via ScanResolution object.
91  void setAngleResolution(const ScanResolution& resolution);
92 
93  void setRelativeAngularResolution(const IRangedDistribution& distr, double rel_dev);
94  //! Sets angular resolution values via IRangedDistribution and values of relative deviations
95  //! (that is, _rel_dev_ equals standard deviation divided by the mean value).
96  //! _rel_dev_ can be either single-valued or a numpy array. In the latter case the length of the
97  //! array should coinside with the length of the inclination angle axis.
99  const std::vector<double>& rel_dev);
100 
101  void setAbsoluteAngularResolution(const IRangedDistribution& distr, double std_dev);
102  //! Sets angular resolution values via IRangedDistribution and values of standard deviations.
103  //! _std_dev_ can be either single-valued or a numpy array. In the latter case the length of the
104  //! array should coinside with the length of the inclination angle axis.
106  const std::vector<double>& std_dev);
107 
108 private:
109  using DistrOutput = std::vector<std::vector<ParameterSample>>;
110 
111  void checkInitialization();
114 
115  const double m_wl;
116  const std::unique_ptr<IAxis> m_inc_angle;
117  std::unique_ptr<IFootprintFactor> m_footprint;
118 
119  std::unique_ptr<ScanResolution> m_wl_resolution;
120  std::unique_ptr<ScanResolution> m_inc_resolution;
121 };
122 
123 #endif // BORNAGAIN_SIM_SCAN_ALPHASCAN_H
Declares interface ISpecularScan.
Scan type with inclination angles as coordinate values and a unique wavelength. Features footprint co...
Definition: AlphaScan.h:27
CoordSystem1D * createCoordSystem() const override
Definition: AlphaScan.cpp:230
std::unique_ptr< IFootprintFactor > m_footprint
Definition: AlphaScan.h:117
std::unique_ptr< ScanResolution > m_wl_resolution
Definition: AlphaScan.h:119
void setAbsoluteAngularResolution(const IRangedDistribution &distr, double std_dev)
Definition: AlphaScan.cpp:173
DistrOutput applyIncResolution() const
Definition: AlphaScan.cpp:278
void setAngleResolution(const ScanResolution &resolution)
Sets angle resolution values via ScanResolution object.
Definition: AlphaScan.cpp:153
AlphaScan * clone() const override
Definition: AlphaScan.cpp:75
void checkInitialization()
Definition: AlphaScan.cpp:259
const IAxis * coordinateAxis() const override
Returns coordinate axis assigned to the data holder.
Definition: AlphaScan.h:45
std::vector< double > footprint(size_t start, size_t n_elements) const override
Returns footprint correction factor for a range of simulation elements of size n_elements and startin...
Definition: AlphaScan.cpp:188
void setFootprintFactor(const IFootprintFactor *f_factor)
Sets footprint correction factor.
Definition: AlphaScan.cpp:113
const IFootprintFactor * footprintFactor() const override
Returns IFootprintFactor object pointer.
Definition: AlphaScan.h:48
std::unique_ptr< ScanResolution > m_inc_resolution
Definition: AlphaScan.h:120
const ScanResolution * angleResolution() const
Definition: AlphaScan.h:64
void setWavelengthResolution(const ScanResolution &resolution)
Sets wavelength resolution values via ScanResolution object.
Definition: AlphaScan.cpp:118
double wavelength() const override
Definition: AlphaScan.h:67
void setRelativeAngularResolution(const IRangedDistribution &distr, double rel_dev)
Definition: AlphaScan.cpp:158
std::vector< std::vector< ParameterSample > > DistrOutput
Definition: AlphaScan.h:109
~AlphaScan() override
std::vector< double > createIntensities(const std::vector< SpecularElement > &eles) const override
Returns intensity vector corresponding to convolution of given simulation elements.
Definition: AlphaScan.cpp:235
const double m_wl
Definition: AlphaScan.h:115
DistrOutput applyWlResolution() const
Definition: AlphaScan.cpp:273
AlphaScan(double wl, std::vector< double > inc_angle)
Definition: AlphaScan.cpp:48
void setRelativeWavelengthResolution(const IRangedDistribution &distr, double rel_dev)
Definition: AlphaScan.cpp:123
void setAbsoluteWavelengthResolution(const IRangedDistribution &distr, double std_dev)
Definition: AlphaScan.cpp:138
std::vector< SpecularElement > generateElements() const override
Generates simulation elements for specular simulations.
Definition: AlphaScan.cpp:90
const std::unique_ptr< IAxis > m_inc_angle
Definition: AlphaScan.h:116
size_t numberOfElements() const override
Returns the number of simulation elements.
Definition: AlphaScan.cpp:225
const ScanResolution * wavelengthResolution() const
Definition: AlphaScan.h:63
Abstract base class to support coordinate transforms and axis labels for 1D scans....
Definition: CoordSystem1D.h:33
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27
Abstract base for classes that calculate the beam footprint factor.
Interface for one-dimensional ranged distributions. All derived distributions allow for generating sa...
Abstract base class for all types of specular scans.
Definition: ISpecularScan.h:34
A parameter value with a weight, as obtained when sampling from a distribution.
Container for reflectivity resolution data.