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

Description

Definition at line 157 of file DistributionItems.h.

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

Public Member Functions

 DistributionCosineItem ()
 
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 (mean, Mean)
 
 DOUBLE_PROPERTY (sigma, Sigma)
 
 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

◆ DistributionCosineItem()

DistributionCosineItem::DistributionCosineItem ( )

Definition at line 309 of file DistributionItems.cpp.

311 {
312  initSigmaFactor();
313  m_sigma.init("Sigma", "", 1.0, Unit::unitless, 3, RealLimits::lowerLimited(0.0), "sigma");
314  addToSerialization(&m_sigma);
315 }
@ 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 > DistributionCosineItem::createDistribution ( double  scale = 1.0) const
overridevirtual

Implements DistributionItem.

Definition at line 323 of file DistributionItems.cpp.

324 {
325  return std::make_unique<DistributionCosine>(scale * m_mean, scale * sigma());
326 }

◆ createIRangedDistribution()

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

Implements SymmetricResolutionItem.

Definition at line 329 of file DistributionItems.cpp.

330 {
331  return std::make_unique<RangedDistributionCosine>(numberOfSamples(), sigmaFactor(),
332  m_limits.scaledLimits(scale));
333 }

References DistributionItem::m_limits.

◆ deviation()

double DistributionCosineItem::deviation ( double  scale) const
overridevirtual

Implements SymmetricResolutionItem.

Definition at line 335 of file DistributionItems.cpp.

336 {
337  return sigma() * scale;
338 }

◆ distributionValues()

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

Implements DistributionItem.

Definition at line 350 of file DistributionItems.cpp.

351 {
352  return withMean ? DoubleDescriptors{mean(), sigma(), sigmaFactor()}
353  : DoubleDescriptors{sigma(), sigmaFactor()};
354  ;
355 }
QList< DoubleDescriptor > DoubleDescriptors

◆ DOUBLE_PROPERTY() [1/3]

SymmetricResolutionItem::DOUBLE_PROPERTY ( mean  ,
Mean   
)
inherited

◆ DOUBLE_PROPERTY() [2/3]

DistributionCosineItem::DOUBLE_PROPERTY ( sigma  ,
Sigma   
)

◆ 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 DistributionCosineItem::initDistribution ( double  value)
overridevirtual

Reimplemented from DistributionItem.

Definition at line 340 of file DistributionItems.cpp.

341 {
342  double sigma(0.1 * std::abs(value));
343  if (sigma == 0.0)
344  sigma = 0.1;
345 
346  setMean(value);
347  setSigma(sigma);
348 }

◆ 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(), DistributionGaussianItem::DistributionGaussianItem(), DistributionLogNormalItem::DistributionLogNormalItem(), and DistributionLorentzItem::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 DistributionCosineItem::setUnit ( const variant< QString, Unit > &  unit)
overridevirtual

Set the unit of the distributed value.

Reimplemented from SymmetricResolutionItem.

Definition at line 317 of file DistributionItems.cpp.

318 {
320  m_sigma.setUnit(unit);
321 }
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: