BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RectangularDetector.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/Detector/RectangularDetector.h
6 //! @brief Defines class RectangularDetector.
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_RECTANGULARDETECTOR_H
16 #define BORNAGAIN_CORE_DETECTOR_RECTANGULARDETECTOR_H
17 
19 
20 class IPixel;
21 class RectangularPixel;
22 
23 //! A flat rectangular detector with axes and resolution function.
24 //! @ingroup detector
25 
27 {
28 public:
35  };
36 
37  //! Rectangular detector constructor
38  //! @param nxbins Number of bins (pixels) in x-direction
39  //! @param width Width of the detector in mm along x-direction
40  //! @param nybins Number of bins (pixels) in y-direction
41  //! @param height Height of the detector in mm along y-direction
42  RectangularDetector(size_t nxbins, double width, size_t nybins, double height);
43 
45 
46  RectangularDetector* clone() const override;
47 
48  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
49 
51 
52  void init(const Beam& beam) override;
53 
54  void setPosition(const kvector_t normal_to_detector, double u0, double v0,
55  const kvector_t direction = kvector_t(0.0, -1.0, 0.0));
56 
57  void setPerpendicularToSampleX(double distance, double u0, double v0);
58  void setPerpendicularToDirectBeam(double distance, double u0, double v0);
59  void setPerpendicularToReflectedBeam(double distance, double u0 = 0.0, double v0 = 0.0);
60 
61  void setDirectBeamPosition(double u0, double v0);
62 
63  double getWidth() const;
64  double getHeight() const;
65  size_t getNbinsX() const;
66  size_t getNbinsY() const;
67  kvector_t getNormalVector() const;
68  double getU0() const;
69  double getV0() const;
71  double getDistance() const;
72  double getDirectBeamU0() const;
73  double getDirectBeamV0() const;
75 
76  //! return default axes units
77  Axes::Units defaultAxesUnits() const override;
78 
80 
81 protected:
82  //! Creates an IPixel for the given OutputData object and index
83  IPixel* createPixel(size_t index) const override;
84 
85  //! Returns the name for the axis with given index
86  std::string axisName(size_t index) const override;
87 
88  //! Returns index of pixel that contains the specular wavevector.
89  //! If no pixel contains this specular wavevector, the number of pixels is
90  //! returned. This corresponds to an overflow index.
91  size_t indexOfSpecular(const Beam& beam) const override;
92 
93  //! swap function
95 
96 private:
97  void setDistanceAndOffset(double distance, double u0, double v0);
98  void initNormalVector(const kvector_t central_k);
99  void initUandV(double alpha_i);
100 
102  double m_u0, m_v0; //!< position of normal vector hitting point in detector coordinates
103  kvector_t m_direction; //!< direction vector of detector coordinate system
104  double m_distance; //!< distance from sample origin to the detector plane
105  double m_dbeam_u0, m_dbeam_v0; //!< position of direct beam in detector coordinates
109 };
110 
111 #endif // BORNAGAIN_CORE_DETECTOR_RECTANGULARDETECTOR_H
Defines interface IDetector2D.
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
Beam defined by wavelength, direction and intensity.
Definition: Beam.h:27
Abstract 2D detector interface.
Definition: IDetector2D.h:31
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
Interface for a function that maps [0,1]x[0,1] to the kvectors in a pixel.
Definition: IPixel.h:24
A flat rectangular detector with axes and resolution function.
void setDirectBeamPosition(double u0, double v0)
double m_dbeam_v0
position of direct beam in detector coordinates
void initUandV(double alpha_i)
void init(const Beam &beam) override
Inits detector with the beam settings.
double m_v0
position of normal vector hitting point in detector coordinates
void setPerpendicularToSampleX(double distance, double u0, double v0)
void setPerpendicularToDirectBeam(double distance, double u0, double v0)
kvector_t m_direction
direction vector of detector coordinate system
void initNormalVector(const kvector_t central_k)
void setPerpendicularToReflectedBeam(double distance, double u0=0.0, double v0=0.0)
Axes::Units defaultAxesUnits() const override
return default axes units
EDetectorArrangement getDetectorArrangment() const
RectangularDetector * clone() const override
size_t indexOfSpecular(const Beam &beam) const override
Returns index of pixel that contains the specular wavevector.
void setPosition(const kvector_t normal_to_detector, double u0, double v0, const kvector_t direction=kvector_t(0.0, -1.0, 0.0))
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
IPixel * createPixel(size_t index) const override
Creates an IPixel for the given OutputData object and index.
double getDirectBeamV0() const
kvector_t getDirectionVector() const
double m_distance
distance from sample origin to the detector plane
std::string axisName(size_t index) const override
Returns the name for the axis with given index.
EDetectorArrangement m_detector_arrangement
double getDirectBeamU0() const
RectangularDetector(size_t nxbins, double width, size_t nybins, double height)
Rectangular detector constructor.
kvector_t getNormalVector() const
void setDistanceAndOffset(double distance, double u0, double v0)
void swapContent(RectangularDetector &other)
swap function
RectangularPixel * regionOfInterestPixel() const
A pixel in a RectangularDetector.