BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SphericalDetectorItem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Device/SphericalDetectorItem.cpp
6 //! @brief Implements class SphericalDetectorItem
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 
16 #include "Base/Const/Units.h"
17 #include "Device/Detector/SphericalDetector.h"
21 
22 namespace {
23 void initResolutionFunction(ResolutionFunctionItem* newFunc, const ResolutionFunctionItem*)
24 {
25  newFunc->setUnit(Unit::degree);
26 }
27 } // namespace
28 
30 {
32  "Resolution function", "Detector resolution function", "resolutionFunction",
33  initResolutionFunction);
34 
35  m_phiAxis.initNbins("Nbins", "Number of phi-axis bins");
36  m_phiAxis.initMin("Min", "Lower edge of first phi-bin", -1.0, Unit::degree,
37  RealLimits::limited(-90, 90));
38  m_phiAxis.initMax("Max", "Upper edge of last phi-bin", 1.0, Unit::degree,
39  RealLimits::limited(-90, 90));
40 
41  m_alphaAxis.initNbins("Nbins", "Number of alpha-axis bins");
42  m_alphaAxis.initMin("Min", "Lower edge of first alpha-bin", 0.0, Unit::degree,
43  RealLimits::limited(-90, 90));
44  m_alphaAxis.initMax("Max", "Upper edge of last alpha-bin", 2.0, Unit::degree,
45  RealLimits::limited(-90, 90));
46 }
47 
49 {
50  s.assertVersion(0);
51  // base class members
52  Serialize::rwClass(s, "masks", m_maskItems);
53  Serialize::rwSelected<ResolutionFunctionItemCatalog>(s, m_resolutionFunction);
54 
55  // own members
56  m_phiAxis.rwAxisProperty(s, "phiAxis");
57  m_alphaAxis.rwAxisProperty(s, "alphaAxis");
58 
59  if (s.xmlReader())
61 }
62 
63 std::unique_ptr<IDetector> SphericalDetectorItem::createDomainDetector() const
64 {
65  const int n_x = m_phiAxis.nbins();
66  const double x_min = Units::deg2rad(m_phiAxis.min());
67  const double x_max = Units::deg2rad(m_phiAxis.max());
68 
69  const int n_y = m_alphaAxis.nbins();
70  const double y_min = Units::deg2rad(m_alphaAxis.min());
71  const double y_max = Units::deg2rad(m_alphaAxis.max());
72 
73  return std::make_unique<SphericalDetector>(n_x, x_min, x_max, n_y, y_min, y_max);
74 }
75 
77 {
78  return m_phiAxis.nbins();
79 }
80 
82 {
83  return m_alphaAxis.nbins();
84 }
85 
87 {
88  m_phiAxis.setNbins(nx);
89 }
90 
92 {
93  m_alphaAxis.setNbins(ny);
94 }
95 
97 {
98  return Units::deg;
99 }
Defines class ResolutionFunctionItemCatalog.
Defines family of ResolutionFunctionItem.
Defines class Streamer.
Defines class SphericalDetectorItem.
@ degree
MaskItems m_maskItems
for creation of domain detector; only filled and relevant in jobs
Definition: DetectorItems.h:68
SelectionProperty< ResolutionFunctionItem * > m_resolutionFunction
Definition: DetectorItems.h:69
virtual void setUnit(const std::variant< QString, Unit > &)
Set the unit of the distributed value.
void initWithInitializer(const QString &label, const QString &tooltip, const QString &persistentTag, std::function< void(T newItem, const T oldItem)> initializer)
Initialize by means of a catalog class and an initializer function.
int xSize() const override
Returns the size of x-axis of the detector.
void setYSize(size_t ny) override
sets the size of y-axis of the detector
std::unique_ptr< IDetector > createDomainDetector() const override
int ySize() const override
Returns the size of y-axis of the detector.
void serialize(Streamer &s) override
void setXSize(size_t nx) override
sets the size of x-axis of the detector
double axesToCoreUnitsFactor() const override
Scales the values provided by axes (to perform deg->rad conversion on the way to domain).
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
QXmlStreamReader * xmlReader()
Returns stream reader or nullptr.
Definition: Streamer.h:48
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwClass(Streamer &s, const QString &tag, T &t)
Serializes an item from a class that provides the function void serialize(Streamer&).
Definition: Serialize.h:77