BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
QzScan.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sim/Scan/QzScan.h
6 //! @brief Declares QzScan 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_QZSCAN_H
16 #define BORNAGAIN_SIM_SCAN_QZSCAN_H
17 
18 #include "Sim/Scan/ISpecularScan.h"
19 #include <memory>
20 
21 class ParameterSample;
23 class ScanResolution;
24 
25 //! Scan type with z-components of scattering vector as coordinate values.
26 //! Wavelength and incident angles are not accessible separately.
27 
28 class QzScan : public ISpecularScan {
29 public:
30  //! Accepts qz-value vector (in inverse nm)
31  QzScan(std::vector<double> qs_nm);
32  QzScan(const IAxis& qs_nm);
33  //! Sets q-defined specular scan. Accepts either numpy array of q-values sorted in ascending
34  //! order or an IAxis object with q-values. Alternatively an axis can be defined in-place, then
35  //! the first passed parameter is the number of bins, second - minimum on-axis q-value,
36  //! third - maximum on-axis q_value.
37  QzScan(int nbins, double qz_min, double qz_max);
38 
39  ~QzScan() override;
40  QzScan* clone() const override;
41 
42  const ScanResolution* resolution() const { return m_resolution.get(); }
43 
44  double wavelength() const override { return 1.0; } // TODO (ISSUE #303)
45 
46 #ifndef SWIG
47  //! Generates simulation elements for specular simulations
48  std::vector<SpecularElement> generateElements() const override;
49 
50  //! Returns coordinate axis assigned to the data holder
51  const IAxis* coordinateAxis() const override { return m_qs.get(); }
52 
53  //! Returns IFootprintFactor object pointer
54  const IFootprintFactor* footprintFactor() const override { return nullptr; }
55 
56  //! Returns footprint correction factor for a range of simulation elements of size _n_elements_
57  //! and starting from element with index _i_.
58  std::vector<double> footprint(size_t i, size_t n_elements) const override;
59 
60  //! Returns the number of simulation elements
61  size_t numberOfElements() const override;
62 
63  CoordSystem1D* createCoordSystem() const override;
64 
65  //! Returns intensity vector corresponding to convolution of given simulation elements
66  std::vector<double> createIntensities(const std::vector<SpecularElement>& eles) const override;
67 
68 #endif // USER_API
69 
70  //! Sets q resolution values via ScanResolution object.
72 
73  void setRelativeQResolution(const IRangedDistribution& distr, double rel_dev);
74  //! Sets qz resolution values via IRangedDistribution and values of relative deviations
75  //! (that is, _rel_dev_ equals standard deviation divided by the mean value).
76  //! _rel_dev_ can be either single-valued or a numpy array. In the latter case the length of the
77  //! array should coinside with the length of the qz-axis.
79  const std::vector<double>& rel_dev);
80 
81  void setAbsoluteQResolution(const IRangedDistribution& distr, double std_dev);
82  //! Sets qz resolution values via IRangedDistribution and values of standard deviations.
83  //! _std_dev_ can be either single-valued or a numpy array. In the latter case the length of the
84  //! array should coinside with the length of the qz-axis.
86  const std::vector<double>& std_dev);
87 
88  void setOffset(double offset) { m_offset = offset; }
89  double offset() const { return m_offset; }
90 
91 private:
92  QzScan(IAxis* qs_nm);
93 
94  std::vector<double> generateQzVector() const;
95  std::vector<std::vector<ParameterSample>> applyQResolution() const;
96 
97  const std::unique_ptr<IAxis> m_qs;
98  std::unique_ptr<ScanResolution> m_resolution;
99 
100  double m_offset = 0.;
101 };
102 
103 #endif // BORNAGAIN_SIM_SCAN_QZSCAN_H
Declares interface ISpecularScan.
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.
Scan type with z-components of scattering vector as coordinate values. Wavelength and incident angles...
Definition: QzScan.h:28
const IFootprintFactor * footprintFactor() const override
Returns IFootprintFactor object pointer.
Definition: QzScan.h:54
double m_offset
Definition: QzScan.h:100
double wavelength() const override
Definition: QzScan.h:44
void setRelativeQResolution(const IRangedDistribution &distr, double rel_dev)
Definition: QzScan.cpp:125
~QzScan() override
std::vector< double > createIntensities(const std::vector< SpecularElement > &eles) const override
Returns intensity vector corresponding to convolution of given simulation elements.
Definition: QzScan.cpp:102
QzScan(std::vector< double > qs_nm)
Accepts qz-value vector (in inverse nm)
Definition: QzScan.cpp:39
void setQResolution(const ScanResolution &resolution)
Sets q resolution values via ScanResolution object.
Definition: QzScan.cpp:120
const IAxis * coordinateAxis() const override
Returns coordinate axis assigned to the data holder.
Definition: QzScan.h:51
void setAbsoluteQResolution(const IRangedDistribution &distr, double std_dev)
Definition: QzScan.cpp:140
CoordSystem1D * createCoordSystem() const override
Definition: QzScan.cpp:97
std::vector< SpecularElement > generateElements() const override
Generates simulation elements for specular simulations.
Definition: QzScan.cpp:70
const std::unique_ptr< IAxis > m_qs
Definition: QzScan.h:97
size_t numberOfElements() const override
Returns the number of simulation elements.
Definition: QzScan.cpp:92
std::unique_ptr< ScanResolution > m_resolution
Definition: QzScan.h:98
QzScan * clone() const override
Definition: QzScan.cpp:56
const ScanResolution * resolution() const
Definition: QzScan.h:42
std::vector< std::vector< ParameterSample > > applyQResolution() const
Definition: QzScan.cpp:167
std::vector< double > generateQzVector() const
Definition: QzScan.cpp:155
void setOffset(double offset)
Definition: QzScan.h:88
double offset() const
Definition: QzScan.h:89
std::vector< double > footprint(size_t i, size_t n_elements) const override
Returns footprint correction factor for a range of simulation elements of size n_elements and startin...
Definition: QzScan.cpp:83
Container for reflectivity resolution data.