BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
RectangularDetector.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
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_DEVICE_DETECTOR_RECTANGULARDETECTOR_H
16 #define BORNAGAIN_DEVICE_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 public:
34  };
35 
36  //! Rectangular detector constructor
37  //! @param nxbins Number of bins (pixels) in x-direction
38  //! @param width Width of the detector in mm along x-direction
39  //! @param nybins Number of bins (pixels) in y-direction
40  //! @param height Height of the detector in mm along y-direction
41  RectangularDetector(size_t nxbins, double width, size_t nybins, double height);
42 
45 
46  RectangularDetector* clone() const override;
47  std::string className() const final { return "RectangularDetector"; }
48 
49  void setDetectorNormal(const Direction& direction) override;
50 
51  void setDetectorPosition(R3 normal_to_detector, double u0, double v0,
52  R3 direction = R3(0.0, -1.0, 0.0));
53 
54  void setPerpendicularToSampleX(double distance, double u0, double v0);
55  void setPerpendicularToDirectBeam(double distance, double u0, double v0);
56  void setPerpendicularToReflectedBeam(double distance, double u0 = 0.0, double v0 = 0.0);
57 
58  void setDirectBeamPosition(double u0, double v0);
59 
60  double width() const;
61  double height() const;
62  size_t xSize() const;
63  size_t ySize() const;
64  R3 getNormalVector() const;
65  double getU0() const;
66  double getV0() const;
67  R3 getDirectionVector() const;
68  double getDistance() const;
69  double getDirectBeamU0() const;
70  double getDirectBeamV0() const;
72 
73  //! Returns default axes units
74  Coords defaultCoords() const override { return Coords::MM; }
75 
77  ICoordSystem* offspecCoords(IAxis* beamAxis, const Direction& beamDirection) const override;
78  CoordSystem2D* scatteringCoords(const Beam& beam) const override;
79 
80 private:
81  //! Creates an IPixel for the given Datafield object and index
82  IPixel* createPixel(size_t index) const override;
83 
84  //! Returns the name for the axis with given index
85  std::string axisName(size_t index) const override;
86 
87  //! Returns index of pixel that contains the specular wavevector.
88  //! If no pixel contains this specular wavevector, the number of pixels is
89  //! returned. This corresponds to an overflow index.
90  size_t indexOfSpecular(const Beam& beam) const override;
91 
92  //! swap function
94 
95  void setDistanceAndOffset(double distance, double u0, double v0);
96  void initNormalVector(R3 central_k);
97  void initUandV(double alpha_i);
98 
100  double m_u0, m_v0; //!< position of normal vector hitting point in detector coordinates
101  R3 m_direction; //!< direction vector of detector coordinate system
102  double m_distance; //!< distance from sample origin to the detector plane
103  double m_dbeam_u0, m_dbeam_v0; //!< position of direct beam in detector coordinates
107 };
108 
109 #endif // BORNAGAIN_DEVICE_DETECTOR_RECTANGULARDETECTOR_H
Defines common detector interface.
An incident neutron or x-ray beam.
Definition: Beam.h:28
Interface for objects that provide axis translations to different units for IDetector objects.
Definition: CoordSystem2D.h:32
A direction in three-dimensional space.
Definition: Direction.h:24
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27
Interface to provide axis translations to different units for simulation output.
Definition: ICoordSystem.h:40
Abstract detector interface.
Definition: IDetector.h:57
Interface for a function that maps [0,1]x[0,1] to the kvectors in a pixel. Abstract base class for Sp...
Definition: IPixel.h:29
A flat rectangular detector with axes and resolution function.
RectangularDetector(const RectangularDetector &other)
void initNormalVector(R3 central_k)
CoordSystem2D * scatteringCoords(const Beam &beam) const override
R3 m_direction
direction vector of detector coordinate system
void setDirectBeamPosition(double u0, double v0)
double m_dbeam_v0
position of direct beam in detector coordinates
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
void initUandV(double alpha_i)
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)
void setPerpendicularToReflectedBeam(double distance, double u0=0.0, double v0=0.0)
~RectangularDetector() override
EDetectorArrangement getDetectorArrangment() const
Coords defaultCoords() const override
Returns default axes units.
RectangularDetector * clone() const override
size_t indexOfSpecular(const Beam &beam) const override
Returns index of pixel that contains the specular wavevector. If no pixel contains this specular wave...
void setDetectorPosition(R3 normal_to_detector, double u0, double v0, R3 direction=R3(0.0, -1.0, 0.0))
IPixel * createPixel(size_t index) const override
Creates an IPixel for the given Datafield object and index.
double getDirectBeamV0() 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
void setDetectorNormal(const Direction &direction) override
Inits detector with the beam settings.
RectangularDetector(size_t nxbins, double width, size_t nybins, double height)
Rectangular detector constructor.
ICoordSystem * offspecCoords(IAxis *beamAxis, const Direction &beamDirection) const override
void setDistanceAndOffset(double distance, double u0, double v0)
void swapContent(RectangularDetector &other)
swap function
RectangularPixel * regionOfInterestPixel() const
A pixel in a RectangularDetector.
Coords
Definition: Tags.h:20