BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DepthProbeInstrumentItem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/DepthProbeInstrumentItem.cpp
6 //! @brief Implements DepthProbeInstrumentItem class
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"
24 
25 const QString DepthProbeInstrumentItem::P_BEAM = "Beam";
26 const QString DepthProbeInstrumentItem::P_Z_AXIS = "Z axis";
27 
29 {
30  setItemName("DepthProbeInstrument");
31 
32  addProperty<SpecularBeamItem>(P_BEAM);
33 
34  auto axisItem = beamItem()->currentInclinationAxisItem();
35  axisItem->setLowerBound(0.0);
36  axisItem->setUpperBound(1.0);
37  axisItem->setBinCount(500);
38 
39  auto axis = addProperty<BasicAxisItem>(P_Z_AXIS);
40  axis->setLowerBound(-100.0);
41  axis->setUpperBound(100.0);
42  axis->getItem(BasicAxisItem::P_TITLE)->setVisible(false);
43  axis->getItem(BasicAxisItem::P_NBINS)
44  ->setToolTip("Number of points in scan across sample bulk");
45  axis->getItem(BasicAxisItem::P_MIN_DEG)
46  ->setToolTip("Starting value below sample horizont in nm");
47  axis->getItem(BasicAxisItem::P_MAX_DEG)->setToolTip("Ending value above sample horizont in nm");
48 }
49 
51 {
52  return item<SpecularBeamItem>(P_BEAM);
53 }
54 
55 std::unique_ptr<Instrument> DepthProbeInstrumentItem::createInstrument() const
56 {
57  throw std::runtime_error("DepthProbeInstrumentItem::createInstrument()");
58 }
59 
60 std::vector<int> DepthProbeInstrumentItem::shape() const
61 {
62  return std::vector<int>(); // no certain shape to avoid linking to real data
63 }
64 
66 {
67  throw std::runtime_error("DepthProbeInstrumentItem::updateToRealData()");
68 }
69 
71 {
72  return "DepthProbe";
73 }
74 
75 std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation() const
76 {
77  std::unique_ptr<DepthProbeSimulation> simulation = std::make_unique<DepthProbeSimulation>();
78 
79  const auto axis_item = beamItem()->currentInclinationAxisItem();
80 
81  auto axis = axis_item->createAxis(Units::deg);
82 
83  simulation->setBeamParameters(beamItem()->wavelength(), static_cast<int>(axis->size()),
84  axis->lowerBound(), axis->upperBound());
85 
86  auto depthAxisItem = dynamic_cast<BasicAxisItem*>(getItem(P_Z_AXIS));
87  auto depthAxis = depthAxisItem->createAxis(1.0);
88  simulation->setZSpan(depthAxis->size(), depthAxis->lowerBound(), depthAxis->upperBound());
89 
91  "Wavelength", *beamItem()->item<BeamWavelengthItem>(SpecularBeamItem::P_WAVELENGTH),
92  *simulation.get());
93 
95  "InclinationAngle",
96  *beamItem()->item<SpecularBeamInclinationItem>(SpecularBeamItem::P_INCLINATION_ANGLE),
97  *simulation.get());
98 
99  return simulation;
100 }
101 
102 std::unique_ptr<IUnitConverter> DepthProbeInstrumentItem::createUnitConverter() const
103 {
104  return createSimulation()->createUnitConverter();
105 }
Defines various axis items.
Defines BeamItem hierarchy.
Defines class BeamWavelengthItem.
Defines DepthProbeInstrumentItem class.
Defines class DepthProbeSimulation.
Defines interface UnitConverterSimple and its subclasses.
Declares the class SpecularBeamInclinationItem.
Defines class TransformToDomain.
Defines some unit conversion factors and other constants in namespace Units.
static const QString P_NBINS
Definition: AxesItems.h:26
static const QString P_MAX_DEG
Definition: AxesItems.h:28
static const QString P_TITLE
Definition: AxesItems.h:29
void setLowerBound(double value)
Definition: AxesItems.cpp:47
virtual std::unique_ptr< IAxis > createAxis(double scale) const
Definition: AxesItems.cpp:72
static const QString P_MIN_DEG
Definition: AxesItems.h:27
static const QString P_WAVELENGTH
Definition: BeamItems.h:29
static const QString P_INCLINATION_ANGLE
Definition: BeamItems.h:30
std::unique_ptr< Instrument > createInstrument() const override
std::unique_ptr< IUnitConverter > createUnitConverter() const
SpecularBeamItem * beamItem() const override
virtual QString defaultName() const override
The default user visible name when creating an instrument.
std::unique_ptr< DepthProbeSimulation > createSimulation() const
void updateToRealData(const RealDataItem *item) override
std::vector< int > shape() const override
The RealDataItem class represents intensity data imported from file and intended for fitting.
Definition: RealDataItem.h:35
void setItemName(const QString &name)
Set item name, add property if necessary.
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.
BasicAxisItem * currentInclinationAxisItem()
Definition: BeamItems.cpp:161
void setBeamDistribution(const std::string &parameter_name, const BeamDistributionItem &item, ISimulation &simulation)
static constexpr double deg
Definition: Units.h:46