BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
BeamDistributionItem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Device/BeamDistributionItem.cpp
6 //! @brief Implements class BeamDistributionItem
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 
20 #include "Param/Distrib/Distributions.h"
21 
22 std::unique_ptr<ParameterDistribution> BeamDistributionItem::getParameterDistributionForName(
23  ParameterDistribution::WhichParameter which) const
24 {
25  if (const auto* d = distribution()) {
26  auto distribution1D = createDistribution1D();
27 
28  if (distribution1D) {
29  const auto nbrOfSamples = d->numberOfSamples();
30  const double sigmaFactor = d->hasSigmaFactor() ? d->sigmaFactor() : 0.0;
31  const auto limits = d->limits().scaledLimits(scaleFactor());
32 
33  return std::make_unique<ParameterDistribution>(which, *distribution1D, nbrOfSamples,
34  sigmaFactor, limits);
35  }
36  }
37  return {};
38 }
39 
41 {
42  std::unique_ptr<IDistribution1D> domainDistr = createDistribution1D();
43  if (domainDistr)
44  return domainDistr->mean() / scaleFactor();
45  return dynamic_cast<SymmetricResolutionItem*>(distribution())->mean();
46 }
47 
49 {
50  auto* d = new DistributionNoneItem();
51  d->setMean(value);
53 }
54 
56 {
57  return 1.0;
58 }
59 
61 {
62  return m_distribution.get();
63 }
64 
66 {
67  return m_distribution;
68 }
69 
71 {
73 }
74 
75 std::unique_ptr<IDistribution1D> BeamDistributionItem::createDistribution1D() const
76 {
78 }
Defines class BeamDistributionItem.
Defines class DistributionItemCatalog.
Defines class DoubleDescriptor.
Defines class GroupItem.
Defines class Streamer.
SelectionDescriptor< DistributionItem * > distributionSelection() const
DistributionItem * distribution() const
void setDistribution(DistributionItem *d)
virtual std::unique_ptr< IDistribution1D > createDistribution1D() const
void resetToValue(double value)
virtual double scaleFactor() const
std::unique_ptr< ParameterDistribution > getParameterDistributionForName(ParameterDistribution::WhichParameter which) const
SelectionProperty< DistributionItem * > m_distribution
virtual double meanValue() const
virtual std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const =0
Describes a selection (various possibilities and the current one).
void set(T t, bool callInitializer=false)
Directly set the new item.
T get() const
Direct access to the stored pointer.