BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
CoordSystem2D.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Coord/CoordSystem2D.h
6 //! @brief Defines interface CoordSystem2D and its subclasses.
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_COORD_COORDSYSTEM2D_H
21 #define BORNAGAIN_DEVICE_COORD_COORDSYSTEM2D_H
22 
25 
26 class Beam;
27 class Direction;
28 class RectangularPixel;
29 
30 //! Interface for objects that provide axis translations to different units for IDetector objects
31 
32 class CoordSystem2D : public ICoordSystem {
33 public:
34  CoordSystem2D(const Direction& direction, double wavelength = 0);
35  CoordSystem2D(const OwningVector<IAxis>& axes, const Direction& direction,
36  double wavelength = 0);
37  ~CoordSystem2D() override = default;
38 
39  size_t rank() const override { return m_axes.size(); }
40 
41  double calculateMin(size_t i_axis, Coords units) const override;
42  double calculateMax(size_t i_axis, Coords units) const override;
43  size_t axisSize(size_t i_axis) const override;
44 
45  //! Returns list of units that are available for all 2D detectors.
46  //! Further units may be added by child classes.
47  std::vector<Coords> availableUnits() const override;
48 
49  IAxis* createConvertedAxis(size_t i_axis, Coords units) const override;
50 
51 protected:
52  CoordSystem2D(const CoordSystem2D& other);
53 
54  void addAxisData(std::string name, double min, double max, size_t nbins);
55 
57  double m_wavelength;
58  double m_alpha_i;
59  double m_phi_i;
60 
61 private:
62  virtual double calculateValue(size_t i_axis, Coords units, double value) const = 0;
63 };
64 
65 
66 //! ICoordSystem class that handles the unit translations for spherical detectors
67 //! Its default units are radians for both axes
68 
70 public:
71  SphericalCoords(const OwningVector<IAxis>& axes, const Direction& direction, double wavelength);
72  ~SphericalCoords() override;
73 
74  SphericalCoords* clone() const override;
75 
76  std::vector<Coords> availableUnits() const override;
77 
78  Coords defaultUnits() const override { return Coords::DEGREES; }
79 
80 private:
81  SphericalCoords(const SphericalCoords& other); //!< used by clone()
82  double calculateValue(size_t i_axis, Coords units, double value) const override;
83  std::vector<std::map<Coords, std::string>> createNameMaps() const override;
84 };
85 
86 
87 //! ICoordSystem class that handles the unit translations for rectangular detectors
88 //! Its default units are mm for both axes
89 
90 class ImageCoords : public CoordSystem2D {
91 public:
92  ImageCoords(const OwningVector<IAxis>& axes, RectangularPixel* regionOfInterestPixel,
93  const Direction& direction, double wavelength);
94  ~ImageCoords() override;
95 
96  ImageCoords* clone() const override;
97 
98  std::vector<Coords> availableUnits() const override;
99 
100  Coords defaultUnits() const override { return Coords::MM; }
101 
102 private:
103  ImageCoords(const ImageCoords& other); //!< used by clone()
104  double calculateValue(size_t i_axis, Coords units, double value) const override;
105  std::vector<std::map<Coords, std::string>> createNameMaps() const override;
106 
107  std::unique_ptr<RectangularPixel> m_detector_pixel;
108 };
109 
110 
111 //! ICoordSystem class that handles the unit translations for off-specular simulations
112 //! with a spherical detector
113 //! Its default units are radians for both axes
114 
116 public:
117  OffspecCoordinates(const OwningVector<IAxis>& axes, const Direction& direction);
118 
119  OffspecCoordinates* clone() const override;
120 
121  Coords defaultUnits() const override { return Coords::DEGREES; }
122 
123 private:
124  OffspecCoordinates(const OffspecCoordinates& other); //!< used by clone()
125  double calculateValue(size_t i_axis, Coords units, double value) const override;
126  std::vector<std::map<Coords, std::string>> createNameMaps() const override;
127 };
128 
129 
130 //! DepthProbeCoordinates class handles the unit translations for depth probe simulations
131 //! Its default units are radians for x-axis and nm for y-axis
132 
134 public:
135  DepthProbeCoordinates(const OwningVector<IAxis>& axes, const Direction& direction,
136  double wavelength);
138 
139  DepthProbeCoordinates* clone() const override;
140 
141  std::vector<Coords> availableUnits() const override;
142 
143  Coords defaultUnits() const override { return Coords::DEGREES; }
144 
145 private:
146  DepthProbeCoordinates(const DepthProbeCoordinates& other); //!< used by clone()
147  double calculateValue(size_t, Coords units, double value) const override;
148  std::vector<std::map<Coords, std::string>> createNameMaps() const override;
149 };
150 
151 #endif // BORNAGAIN_DEVICE_COORD_COORDSYSTEM2D_H
152 #endif // USER_API
Defines interface ICoordSystem and possible axis units.
Defines and implements templated class OwningVector.
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
~CoordSystem2D() override=default
OwningVector< IAxis > m_axes
Definition: CoordSystem2D.h:56
size_t axisSize(size_t i_axis) const override
size_t rank() const override
Definition: CoordSystem2D.h:39
virtual double calculateValue(size_t i_axis, Coords units, double value) const =0
void addAxisData(std::string name, double min, double max, size_t nbins)
double m_wavelength
Definition: CoordSystem2D.h:57
std::vector< Coords > availableUnits() const override
Returns list of units that are available for all 2D detectors. Further units may be added by child cl...
CoordSystem2D(const Direction &direction, double wavelength=0)
double calculateMin(size_t i_axis, Coords units) const override
double calculateMax(size_t i_axis, Coords units) const override
double m_alpha_i
Definition: CoordSystem2D.h:58
IAxis * createConvertedAxis(size_t i_axis, Coords units) const override
DepthProbeCoordinates class handles the unit translations for depth probe simulations Its default uni...
DepthProbeCoordinates(const OwningVector< IAxis > &axes, const Direction &direction, double wavelength)
std::vector< Coords > availableUnits() const override
Returns list of units that are available for all 2D detectors. Further units may be added by child cl...
DepthProbeCoordinates * clone() const override
~DepthProbeCoordinates() override
Coords defaultUnits() const override
double calculateValue(size_t, Coords units, double value) const override
std::vector< std::map< Coords, std::string > > createNameMaps() const override
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
ICoordSystem class that handles the unit translations for rectangular detectors Its default units are...
Definition: CoordSystem2D.h:90
std::vector< Coords > availableUnits() const override
Returns list of units that are available for all 2D detectors. Further units may be added by child cl...
Coords defaultUnits() const override
double calculateValue(size_t i_axis, Coords units, double value) const override
ImageCoords(const OwningVector< IAxis > &axes, RectangularPixel *regionOfInterestPixel, const Direction &direction, double wavelength)
std::unique_ptr< RectangularPixel > m_detector_pixel
std::vector< std::map< Coords, std::string > > createNameMaps() const override
~ImageCoords() override
ImageCoords * clone() const override
ICoordSystem class that handles the unit translations for off-specular simulations with a spherical d...
OffspecCoordinates * clone() const override
OffspecCoordinates(const OwningVector< IAxis > &axes, const Direction &direction)
Coords defaultUnits() const override
double calculateValue(size_t i_axis, Coords units, double value) const override
std::vector< std::map< Coords, std::string > > createNameMaps() const override
size_t size() const
Definition: OwningVector.h:70
A pixel in a RectangularDetector.
ICoordSystem class that handles the unit translations for spherical detectors Its default units are r...
Definition: CoordSystem2D.h:69
std::vector< Coords > availableUnits() const override
Returns list of units that are available for all 2D detectors. Further units may be added by child cl...
std::vector< std::map< Coords, std::string > > createNameMaps() const override
SphericalCoords * clone() const override
SphericalCoords(const OwningVector< IAxis > &axes, const Direction &direction, double wavelength)
Coords defaultUnits() const override
Definition: CoordSystem2D.h:78
double calculateValue(size_t i_axis, Coords units, double value) const override
~SphericalCoords() override
Coords
Definition: Tags.h:20