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

Description

BeamInclinationAxisItem contains inclination angle axis for specular/off-specular simulations and also provides distribution functionality. Considering distribution, differs from BeamInclinationAngleItem by any distribution mean value being always zero.

Definition at line 26 of file SpecularBeamInclinationItem.h.

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

Public Member Functions

 SpecularBeamInclinationItem (const InstrumentItem *owningInstrument)
 
BasicAxisItemalphaAxis () const
 The currently selected axis. More...
 
DistributionItemdistribution () const
 
SelectionDescriptor< DistributionItem * > distributionSelection () const
 
std::unique_ptr< ParameterDistribution > getParameterDistributionForName (ParameterDistribution::WhichParameter which) const
 
void initPointwiseAxis (const IAxis &axis, QString units)
 
void initUniformAxis (const IAxis &axis)
 
virtual double meanValue () const
 
bool pointwiseAlphaAxisDefined () const
 True if a pointwise axis was defined. More...
 
bool pointwiseAlphaAxisSelected () const
 True if pointwise axis is selected. More...
 
void resetToValue (double value)
 
double scaleFactor () const override
 
void selectPointwiseAxis ()
 
void selectUniformAxis ()
 
void serialize (Streamer &s) override
 
void setDistribution (DistributionItem *d)
 
template<typename T >
T * setDistributionType ()
 
bool uniformAlphaAxisSelected () const
 True if uniform axis is selected. More...
 

Protected Member Functions

virtual std::unique_ptr< IDistribution1D > createDistribution1D () const
 

Protected Attributes

SelectionProperty< DistributionItem * > m_distribution
 

Private Attributes

bool m_currentAxisIsUniformAxis
 
const InstrumentItemm_owningInstrument
 
std::unique_ptr< PointwiseAxisItemm_pointwiseAlphaAxis
 
std::unique_ptr< BasicAxisItemm_uniformAlphaAxis
 

Constructor & Destructor Documentation

◆ SpecularBeamInclinationItem()

SpecularBeamInclinationItem::SpecularBeamInclinationItem ( const InstrumentItem owningInstrument)
explicit

Definition at line 63 of file SpecularBeamInclinationItem.cpp.

65  , m_owningInstrument(owningInstrument)
66 {
68  "Distribution", "", "distribution", DistributionItemCatalog::symmetricTypes(),
69  initDistribution);
70 
71  m_uniformAlphaAxis.reset(new BasicAxisItem());
72  setAxisPresentationDefaults(m_uniformAlphaAxis.get());
74 }
The BeamDistributionItem handles wavelength, inclination and azimuthal parameter distribution for Bea...
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.
const InstrumentItem * m_owningInstrument
std::unique_ptr< BasicAxisItem > m_uniformAlphaAxis

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

Here is the call graph for this function:

Member Function Documentation

◆ alphaAxis()

BasicAxisItem * SpecularBeamInclinationItem::alphaAxis ( ) const

◆ 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:

◆ initPointwiseAxis()

void SpecularBeamInclinationItem::initPointwiseAxis ( const IAxis &  axis,
QString  units 
)

Definition at line 135 of file SpecularBeamInclinationItem.cpp.

136 {
137  if (!m_pointwiseAlphaAxis) {
139  m_pointwiseAlphaAxis->setOwningInstrument(m_owningInstrument);
140  setAxisPresentationDefaults(m_pointwiseAlphaAxis.get());
141  }
142 
143  m_pointwiseAlphaAxis->init(axis, units);
144  m_pointwiseAlphaAxis->updateIndicators();
145 }
Item for non-uniform axis with specified coordinates.

References m_owningInstrument, and m_pointwiseAlphaAxis.

Referenced by SpecularBeamItem::updateToData().

◆ initUniformAxis()

void SpecularBeamInclinationItem::initUniformAxis ( const IAxis &  axis)

Definition at line 130 of file SpecularBeamInclinationItem.cpp.

131 {
132  m_uniformAlphaAxis->setBinCount(static_cast<int>(axis.size()));
133 }

References m_uniformAlphaAxis.

Referenced by SpecularBeamItem::updateToData().

◆ 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 BeamWavelengthItem::wavelength().

Here is the call graph for this function:

◆ pointwiseAlphaAxisDefined()

bool SpecularBeamInclinationItem::pointwiseAlphaAxisDefined ( ) const

True if a pointwise axis was defined.

It still is no necessarily the selected axis! Not to be confused with pointwiseAlphaAxisSelected

Definition at line 104 of file SpecularBeamInclinationItem.cpp.

105 {
106  return m_pointwiseAlphaAxis.get() != nullptr;
107 }

References m_pointwiseAlphaAxis.

Referenced by InclinationAnglesEditor::InclinationAnglesEditor(), and selectPointwiseAxis().

◆ pointwiseAlphaAxisSelected()

bool SpecularBeamInclinationItem::pointwiseAlphaAxisSelected ( ) const

True if pointwise axis is selected.

Not to be confused with pointwiseAlphaAxisDefined

Definition at line 109 of file SpecularBeamInclinationItem.cpp.

110 {
112 }

References m_currentAxisIsUniformAxis.

Referenced by InclinationAnglesEditor::InclinationAnglesEditor(), and InclinationAnglesEditor::onAxisTypeSelected().

◆ 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 SpecularBeamInclinationItem::scaleFactor ( ) const
overridevirtual

Reimplemented from BeamDistributionItem.

Definition at line 94 of file SpecularBeamInclinationItem.cpp.

95 {
96  return Units::deg;
97 }

◆ selectPointwiseAxis()

void SpecularBeamInclinationItem::selectPointwiseAxis ( )

Definition at line 124 of file SpecularBeamInclinationItem.cpp.

125 {
126  ASSERT(pointwiseAlphaAxisDefined());
128 }
bool pointwiseAlphaAxisDefined() const
True if a pointwise axis was defined.

References m_currentAxisIsUniformAxis, and pointwiseAlphaAxisDefined().

Referenced by InclinationAnglesEditor::onAxisTypeSelected(), and SpecularBeamItem::updateToData().

Here is the call graph for this function:

◆ selectUniformAxis()

void SpecularBeamInclinationItem::selectUniformAxis ( )

◆ serialize()

void SpecularBeamInclinationItem::serialize ( Streamer s)
overridevirtual

Implements BeamDistributionItem.

Definition at line 76 of file SpecularBeamInclinationItem.cpp.

77 {
78  s.assertVersion(0);
79  Serialize::rwSelected<DistributionItemCatalog>(s, m_distribution);
80  Serialize::rwValue(s, "currentAxisIsUniformAxis", m_currentAxisIsUniformAxis);
81  Serialize::rwInitializable<BasicAxisItem>(s, "uniformAxis", m_uniformAlphaAxis,
82  setAxisPresentationDefaults);
83  Serialize::rwInitializable<PointwiseAxisItem>(s, "pointwiseAxis", m_pointwiseAlphaAxis,
84  setAxisPresentationDefaults);
85 
86  if (s.xmlReader()) {
87  m_distribution->setLimits(RealLimits::limited(-90.0, 90.0));
90  m_pointwiseAlphaAxis->setOwningInstrument(m_owningInstrument);
91  }
92 }
@ degree
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
void rwValue(Streamer &s, const QString &tag, bool &val)
Definition: Serialize.cpp:19

References Streamer::assertVersion(), degree, m_currentAxisIsUniformAxis, BeamDistributionItem::m_distribution, m_owningInstrument, m_pointwiseAlphaAxis, m_uniformAlphaAxis, Serialize::rwValue(), 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:

◆ uniformAlphaAxisSelected()

bool SpecularBeamInclinationItem::uniformAlphaAxisSelected ( ) const

True if uniform axis is selected.

Definition at line 114 of file SpecularBeamInclinationItem.cpp.

115 {
117 }

References m_currentAxisIsUniformAxis.

Referenced by SpecularInstrumentItem::alignedWith().

Member Data Documentation

◆ m_currentAxisIsUniformAxis

bool SpecularBeamInclinationItem::m_currentAxisIsUniformAxis
private

◆ m_distribution

◆ m_owningInstrument

const InstrumentItem* SpecularBeamInclinationItem::m_owningInstrument
private

Definition at line 61 of file SpecularBeamInclinationItem.h.

Referenced by initPointwiseAxis(), and serialize().

◆ m_pointwiseAlphaAxis

std::unique_ptr<PointwiseAxisItem> SpecularBeamInclinationItem::m_pointwiseAlphaAxis
private

◆ m_uniformAlphaAxis

std::unique_ptr<BasicAxisItem> SpecularBeamInclinationItem::m_uniformAlphaAxis
private

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