BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ConvolutionDetectorResolution.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Resolution/ConvolutionDetectorResolution.h
6 //! @brief Defines class ConvolutionDetectorResolution.
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_RESOLUTION_CONVOLUTIONDETECTORRESOLUTION_H
21 #define BORNAGAIN_DEVICE_RESOLUTION_CONVOLUTIONDETECTORRESOLUTION_H
22 
25 
26 //! Convolutes the intensity in 1 or 2 dimensions with a resolution function.
27 //! @ingroup detector
28 
29 //! Limitation: this class assumes that the data points are evenly distributed on each axis
30 
32 public:
33  using cumulative_DF_1d = double (*)(double);
34 
35  //! Constructor taking a 1 dimensional resolution function as argument.
37 
38  //! Constructor taking a 2 dimensional resolution function as argument.
39  ConvolutionDetectorResolution(const IResolutionFunction2D& p_res_function_2d);
40 
42 
43  ConvolutionDetectorResolution* clone() const override;
44  std::string className() const final { return "ConvolutionDetectorResolution"; }
45 
46  //! Convolve given intensities with the encapsulated resolution.
47  void applyDetectorResolution(Datafield* p_intensity_map) const override;
48 
50 
51  std::vector<const INode*> nodeChildren() const override;
52 
53 protected:
55 
56 private:
57  void setResolutionFunction(const IResolutionFunction2D& resFunc);
58  void apply1dConvolution(Datafield* p_intensity_map) const;
59  void apply2dConvolution(Datafield* p_intensity_map) const;
60  double getIntegratedPDF1d(double x, double step) const;
61  double getIntegratedPDF2d(double x, double step_x, double y, double step_y) const;
62 
63  size_t m_rank;
65  std::unique_ptr<IResolutionFunction2D> m_res_function_2d;
66 };
67 
69 {
70  return m_res_function_2d.get();
71 }
72 
73 #endif // BORNAGAIN_DEVICE_RESOLUTION_CONVOLUTIONDETECTORRESOLUTION_H
74 #endif // USER_API
Defines interface IDetectorResolution.
Defines interface class IResolutionFunction2D.
Convolutes the intensity in 1 or 2 dimensions with a resolution function.
double getIntegratedPDF1d(double x, double step) const
void setResolutionFunction(const IResolutionFunction2D &resFunc)
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
std::vector< const INode * > nodeChildren() const override
Returns all children.
const IResolutionFunction2D * getResolutionFunction2D() const
~ConvolutionDetectorResolution() override
std::unique_ptr< IResolutionFunction2D > m_res_function_2d
ConvolutionDetectorResolution(cumulative_DF_1d res_function_1d)
Constructor taking a 1 dimensional resolution function as argument.
void apply1dConvolution(Datafield *p_intensity_map) const
void applyDetectorResolution(Datafield *p_intensity_map) const override
Convolve given intensities with the encapsulated resolution.
ConvolutionDetectorResolution * clone() const override
void apply2dConvolution(Datafield *p_intensity_map) const
double getIntegratedPDF2d(double x, double step_x, double y, double step_y) const
Stores radiation power per bin.
Definition: Datafield.h:30
Interface for detector resolution algorithms.
Interface providing two-dimensional resolution function.