BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ScanResolution.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/Resolution/ScanResolution.h
6 //! @brief Defines scan resolution 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_CORE_DETECTOR_SCANRESOLUTION_H
16 #define BORNAGAIN_CORE_DETECTOR_SCANRESOLUTION_H
17 
18 #include "Base/Types/ICloneable.h"
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 class RangedDistribution;
25 class RealLimits;
26 
27 //! Container for reflectivity resolution data.
28 class ScanResolution : public ICloneable
29 {
30 protected:
31  using DistrOutput = std::vector<std::vector<ParameterSample>>;
32 
33 public:
34  ~ScanResolution() override;
35  static ScanResolution* scanRelativeResolution(const RangedDistribution& distr, double stddev);
37  const std::vector<double>& stddevs);
38  static ScanResolution* scanAbsoluteResolution(const RangedDistribution& distr, double stddev);
40  const std::vector<double>& stddevs);
41 #ifndef SWIG
43 
44  ScanResolution* clone() const override = 0;
45  const RangedDistribution* distribution() const { return m_distr.get(); }
46  size_t nSamples() const;
47 
48  virtual DistrOutput generateSamples(double mean, size_t n_times) const = 0;
49  virtual DistrOutput generateSamples(const std::vector<double>& mean) const = 0;
50  virtual std::vector<double> stdDevs(double mean, size_t n_times) const = 0;
51  virtual std::vector<double> stdDevs(const std::vector<double>& mean) const = 0;
52  bool empty() const { return !m_distr; }
53 
54  //! Prints object definition in python format.
55  std::string print() const;
56 #endif // SWIG
57 protected:
59  ScanResolution(const RangedDistribution& distr);
60  virtual std::string name() const = 0;
61  virtual std::string printStdDevs() const = 0;
62 
63 private:
64  std::unique_ptr<RangedDistribution> m_distr; //!< basic distribution function
65 };
66 
67 inline std::ostream& operator<<(std::ostream& os, const ScanResolution& scan_resolution)
68 {
69  return os << scan_resolution.print();
70 }
71 
72 #endif // BORNAGAIN_CORE_DETECTOR_SCANRESOLUTION_H
Defines and implements the standard mix-in ICloneable.
Defines class ParameterSample.
std::ostream & operator<<(std::ostream &os, const BasicVector3D< T > &a)
Output to stream.
Interface for polymorphic classes that should not be copied, except by explicit cloning.
Definition: ICloneable.h:25
Interface for one-dimensional ranged distributions.
Limits for a real fit parameter.
Definition: RealLimits.h:25
Container for reflectivity resolution data.
const RangedDistribution * distribution() const
std::vector< std::vector< ParameterSample > > DistrOutput
bool empty() const
virtual std::string printStdDevs() const =0
static ScanResolution * scanRelativeResolution(const RangedDistribution &distr, double stddev)
ScanResolution * clone() const override=0
size_t nSamples() const
~ScanResolution() override
static ScanResolution * scanEmptyResolution()
static ScanResolution * scanAbsoluteResolution(const RangedDistribution &distr, double stddev)
virtual std::string name() const =0
std::unique_ptr< RangedDistribution > m_distr
basic distribution function
std::string print() const
Prints object definition in python format.
virtual std::vector< double > stdDevs(double mean, size_t n_times) const =0
virtual DistrOutput generateSamples(const std::vector< double > &mean) const =0
virtual DistrOutput generateSamples(double mean, size_t n_times) const =0
virtual std::vector< double > stdDevs(const std::vector< double > &mean) const =0