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

Description

Definition at line 111 of file DistributionItems.h.

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

Public Member Functions

 DistributionLorentzItem ()
 
std::unique_ptr< IDistribution1D > createDistribution (double scale=1.0) const override
 
std::unique_ptr< IRangedDistribution > createIRangedDistribution (double scale) const override
 
double deviation (double scale) const override
 
DoubleDescriptors distributionValues (bool withMean=true) const override
 
 DOUBLE_PROPERTY (hwhm, Hwhm)
 
 DOUBLE_PROPERTY (mean, Mean)
 
 DOUBLE_PROPERTY (sigmaFactor, SigmaFactor)
 
bool hasSigmaFactor () const
 
void initDistribution (double value) override
 
template<typename T >
bool is () const
 
RealLimits limits () const
 
void serialize (Streamer &s)
 Serialization of contents. More...
 
void setLimits (const RealLimits &limits) override
 
void setMeanDecimals (uint d)
 
void setUnit (const variant< QString, Unit > &unit) override
 Set the unit of the distributed value. More...
 
 UINT_PROPERTY (numberOfSamples, NumberOfSamples)
 

Protected Member Functions

void addToSerialization (DoubleProperty *d)
 
void initSigmaFactor ()
 

Protected Attributes

RealLimits m_limits
 

Private Attributes

QVector< DoubleProperty * > m_serializationProperties
 

Constructor & Destructor Documentation

◆ DistributionLorentzItem()

DistributionLorentzItem::DistributionLorentzItem ( )

Definition at line 168 of file DistributionItems.cpp.

170 {
171  initSigmaFactor();
172 
173  m_hwhm.init("HWHM", "", 1.0, Unit::unitless, "hwhm");
174  addToSerialization(&m_hwhm);
175 }
@ unitless
void addToSerialization(DoubleProperty *d)
SymmetricResolutionItem(double mean, int decimals=3, const QString &meanLabel="Mean")

References DistributionItem::addToSerialization(), DistributionItem::initSigmaFactor(), and unitless.

Here is the call graph for this function:

Member Function Documentation

◆ addToSerialization()

◆ createDistribution()

std::unique_ptr< IDistribution1D > DistributionLorentzItem::createDistribution ( double  scale = 1.0) const
overridevirtual

Implements DistributionItem.

Definition at line 183 of file DistributionItems.cpp.

184 {
185  return std::make_unique<DistributionLorentz>(scale * m_mean, scale * m_hwhm);
186 }

◆ createIRangedDistribution()

std::unique_ptr< IRangedDistribution > DistributionLorentzItem::createIRangedDistribution ( double  scale) const
overridevirtual

Implements SymmetricResolutionItem.

Definition at line 189 of file DistributionItems.cpp.

190 {
191  return std::make_unique<RangedDistributionLorentz>(numberOfSamples(), sigmaFactor(),
192  m_limits.scaledLimits(scale));
193 }

References DistributionItem::m_limits.

◆ deviation()

double DistributionLorentzItem::deviation ( double  scale) const
overridevirtual

Implements SymmetricResolutionItem.

Definition at line 195 of file DistributionItems.cpp.

196 {
197  return m_hwhm * scale;
198 }

◆ distributionValues()

DoubleDescriptors DistributionLorentzItem::distributionValues ( bool  withMean = true) const
overridevirtual

Implements DistributionItem.

Definition at line 211 of file DistributionItems.cpp.

212 {
213  return withMean ? DoubleDescriptors{mean(), hwhm(), sigmaFactor()}
214  : DoubleDescriptors{hwhm(), sigmaFactor()};
215 }
QList< DoubleDescriptor > DoubleDescriptors

◆ DOUBLE_PROPERTY() [1/3]

DistributionLorentzItem::DOUBLE_PROPERTY ( hwhm  ,
Hwhm   
)

◆ DOUBLE_PROPERTY() [2/3]

SymmetricResolutionItem::DOUBLE_PROPERTY ( mean  ,
Mean   
)
inherited

◆ DOUBLE_PROPERTY() [3/3]

DistributionItem::DOUBLE_PROPERTY ( sigmaFactor  ,
SigmaFactor   
)
inherited

◆ hasSigmaFactor()

bool DistributionItem::hasSigmaFactor ( ) const
inherited

Definition at line 45 of file DistributionItems.cpp.

46 {
47  return m_sigmaFactor.isInitialized();
48 }

Referenced by DistributionPlot::plot_multiple_values().

◆ initDistribution()

void DistributionLorentzItem::initDistribution ( double  value)
overridevirtual

Reimplemented from DistributionItem.

Definition at line 200 of file DistributionItems.cpp.

201 {
202  double hw(0.1 * std::abs(value));
203  if (hw == 0.0)
204  hw = 0.1;
205 
206  setMean(value);
207  setHwhm(hw);
208  m_hwhm.setLimits(RealLimits::lowerLimited(0.0));
209 }

◆ initSigmaFactor()

void DistributionItem::initSigmaFactor ( )
protectedinherited

Definition at line 34 of file DistributionItems.cpp.

35 {
36  m_sigmaFactor.init("Sigma factor", "", 2.0, Unit::unitless, "sigmaFactor");
37  addToSerialization(&m_sigmaFactor);
38 }

References DistributionItem::addToSerialization(), and unitless.

Referenced by DistributionCosineItem::DistributionCosineItem(), DistributionGaussianItem::DistributionGaussianItem(), DistributionLogNormalItem::DistributionLogNormalItem(), and DistributionLorentzItem().

Here is the call graph for this function:

◆ is()

template<typename T >
bool DistributionItem::is ( ) const
inlineinherited

Definition at line 33 of file DistributionItems.h.

34  {
35  return dynamic_cast<const T*>(this) != nullptr;
36  }

Referenced by DistributionPlot::plot_distributions(), DistributionPlot::plot_multiple_values(), and DistributionPlot::plot_single_value().

◆ limits()

RealLimits DistributionItem::limits ( ) const
inherited

◆ serialize()

void DistributionItem::serialize ( Streamer s)
inherited

Serialization of contents.

Important: limits and a changed unit (with setUnit) will not be serialized here. They have to be set again by the owner of DistributionItem after reading it

Definition at line 50 of file DistributionItems.cpp.

51 {
52  s.assertVersion(0);
53  Serialize::rwProperty(s, m_numberOfSamples);
54 
55  for (auto* p : m_serializationProperties)
56  Serialize::rwProperty(s, *p);
57 
58  // m_limits and a changed unit (with setUnit) will not be serialized here. They have to be set
59  // again by the owner of DistributionItem after reading it
60 }
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwProperty(Streamer &s, DoubleProperty &d)

References Streamer::assertVersion(), DistributionItem::m_serializationProperties, and Serialize::rwProperty().

Here is the call graph for this function:

◆ setLimits()

void SymmetricResolutionItem::setLimits ( const RealLimits &  limits)
overridevirtualinherited

Reimplemented from DistributionItem.

Definition at line 81 of file DistributionItems.cpp.

82 {
84  m_mean.setLimits(limits);
85 }
RealLimits limits() const
virtual void setLimits(const RealLimits &limits)

References DistributionItem::limits(), and DistributionItem::setLimits().

Here is the call graph for this function:

◆ setMeanDecimals()

void SymmetricResolutionItem::setMeanDecimals ( uint  d)
inherited

Definition at line 87 of file DistributionItems.cpp.

88 {
89  m_mean.setDecimals(d);
90 }

◆ setUnit()

void DistributionLorentzItem::setUnit ( const variant< QString, Unit > &  unit)
overridevirtual

Set the unit of the distributed value.

Reimplemented from SymmetricResolutionItem.

Definition at line 177 of file DistributionItems.cpp.

178 {
180  m_hwhm.setUnit(unit);
181 }
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.

References SymmetricResolutionItem::setUnit().

Here is the call graph for this function:

◆ UINT_PROPERTY()

DistributionItem::UINT_PROPERTY ( numberOfSamples  ,
NumberOfSamples   
)
inherited

Member Data Documentation

◆ m_limits

◆ m_serializationProperties

QVector<DoubleProperty*> DistributionItem::m_serializationProperties
privateinherited

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