BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
BeamWavelengthItem Class Reference

Description

Definition at line 20 of file BeamWavelengthItem.h.

Inheritance diagram for BeamWavelengthItem:
[legend]
Collaboration diagram for BeamWavelengthItem:
[legend]

Public Member Functions

 BeamWavelengthItem ()
 
DistributionItemdistribution () const
 
SelectionDescriptor< DistributionItem * > distributionSelection () const
 
std::unique_ptr< ParameterDistribution > getParameterDistributionForName (ParameterDistribution::WhichParameter which) const
 
virtual double meanValue () const
 
void resetToValue (double value)
 
virtual double scaleFactor () const
 
void serialize (Streamer &s) override
 
void setDistribution (DistributionItem *d)
 
template<typename T >
T * setDistributionType ()
 
double wavelength () const
 Returns wavelength. In the case of distribution applied, returns its mean. More...
 

Protected Member Functions

 BeamWavelengthItem (bool onlySymmetricDistributions)
 
virtual std::unique_ptr< IDistribution1D > createDistribution1D () const
 

Protected Attributes

SelectionProperty< DistributionItem * > m_distribution
 

Constructor & Destructor Documentation

◆ BeamWavelengthItem() [1/2]

BeamWavelengthItem::BeamWavelengthItem ( )

Definition at line 43 of file BeamWavelengthItem.cpp.

44  : BeamWavelengthItem(false)
45 {
46 }

◆ BeamWavelengthItem() [2/2]

BeamWavelengthItem::BeamWavelengthItem ( bool  onlySymmetricDistributions)
protected

Definition at line 48 of file BeamWavelengthItem.cpp.

49 {
51  "Distribution", "", "distribution",
52  onlySymmetricDistributions ? DistributionItemCatalog::symmetricTypes()
53  : DistributionItemCatalog::types(),
54  initDistribution);
55 }
SelectionProperty< DistributionItem * > m_distribution
static QVector< Type > symmetricTypes()
Types of symmetric distributions.
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.

References SelectionProperty< T >::initWithInitializer(), BeamDistributionItem::m_distribution, DistributionItemCatalog::symmetricTypes(), and DistributionItemCatalog::types().

Here is the call graph for this function:

Member Function Documentation

◆ createDistribution1D()

std::unique_ptr< IDistribution1D > BeamDistributionItem::createDistribution1D ( ) const
protectedvirtualinherited

Definition at line 75 of file BeamDistributionItem.cpp.

76 {
78 }
DistributionItem * distribution() const
virtual double scaleFactor() const
virtual std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const =0

References DistributionItem::createDistribution(), BeamDistributionItem::distribution(), and BeamDistributionItem::scaleFactor().

Referenced by BeamDistributionItem::getParameterDistributionForName(), and BeamDistributionItem::meanValue().

Here is the call graph for this function:

◆ distribution()

DistributionItem * BeamDistributionItem::distribution ( ) const
inherited

◆ distributionSelection()

SelectionDescriptor< DistributionItem * > BeamDistributionItem::distributionSelection ( ) const
inherited

◆ getParameterDistributionForName()

std::unique_ptr< ParameterDistribution > BeamDistributionItem::getParameterDistributionForName ( ParameterDistribution::WhichParameter  which) const
inherited

Definition at line 22 of file BeamDistributionItem.cpp.

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 }
virtual std::unique_ptr< IDistribution1D > createDistribution1D() const

References BeamDistributionItem::createDistribution1D(), BeamDistributionItem::distribution(), and BeamDistributionItem::scaleFactor().

Here is the call graph for this function:

◆ meanValue()

double BeamDistributionItem::meanValue ( ) const
virtualinherited

Definition at line 40 of file BeamDistributionItem.cpp.

41 {
42  std::unique_ptr<IDistribution1D> domainDistr = createDistribution1D();
43  if (domainDistr)
44  return domainDistr->mean() / scaleFactor();
45  return dynamic_cast<SymmetricResolutionItem*>(distribution())->mean();
46 }

References BeamDistributionItem::createDistribution1D(), BeamDistributionItem::distribution(), and BeamDistributionItem::scaleFactor().

Referenced by BeamAzimuthalAngleItem::azimuthalAngle(), BeamInclinationAngleItem::inclinationAngle(), and wavelength().

Here is the call graph for this function:

◆ resetToValue()

void BeamDistributionItem::resetToValue ( double  value)
inherited

Definition at line 48 of file BeamDistributionItem.cpp.

49 {
50  auto* d = new DistributionNoneItem();
51  d->setMean(value);
53 }
void set(T t, bool callInitializer=false)
Directly set the new item.

References BeamDistributionItem::m_distribution, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ scaleFactor()

double BeamDistributionItem::scaleFactor ( ) const
virtualinherited

◆ serialize()

void BeamWavelengthItem::serialize ( Streamer s)
overridevirtual

Implements BeamDistributionItem.

Definition at line 57 of file BeamWavelengthItem.cpp.

58 {
59  s.assertVersion(0);
60  Serialize::rwSelected<DistributionItemCatalog>(s, m_distribution);
61 
62  if (s.xmlReader()) {
63  m_distribution->setLimits(RealLimits::positive());
65  }
66 }
@ nanometer
virtual void setLimits(const RealLimits &limits)
virtual void setUnit(const variant< QString, Unit > &unit)=0
Set the unit of the distributed value.
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

References Streamer::assertVersion(), BeamDistributionItem::m_distribution, nanometer, DistributionItem::setLimits(), DistributionItem::setUnit(), and Streamer::xmlReader().

Here is the call graph for this function:

◆ setDistribution()

void BeamDistributionItem::setDistribution ( DistributionItem d)
inherited

Definition at line 70 of file BeamDistributionItem.cpp.

71 {
73 }

References BeamDistributionItem::m_distribution, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ setDistributionType()

template<typename T >
T * BeamDistributionItem::setDistributionType
inherited

Definition at line 52 of file BeamDistributionItem.h.

53 {
54  m_distribution.set<T>();
55  return dynamic_cast<T*>(m_distribution.get());
56 }

References SelectionProperty< T >::get(), BeamDistributionItem::m_distribution, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ wavelength()

double BeamWavelengthItem::wavelength ( ) const

Returns wavelength. In the case of distribution applied, returns its mean.

Definition at line 68 of file BeamWavelengthItem.cpp.

69 {
71 }
virtual double meanValue() const

References BeamDistributionItem::meanValue().

Referenced by SpecularBeamWavelengthItem::setToRange().

Here is the call graph for this function:

Member Data Documentation

◆ m_distribution


The documentation for this class was generated from the following files: