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

Description

Definition at line 185 of file InstrumentItems.h.

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

Public Member Functions

 OffspecInstrumentItem ()
 
virtual bool alignedWith (const RealDataItem *item) const
 
 AXIS_PROPERTY (alphaAxis)
 
BackgroundItembackgroundItem () const
 
SelectionDescriptor< BackgroundItem * > backgroundSelection () const
 
virtual BeamItembeamItem () const
 
ICoordSystem * createCoordSystem () const override
 
InstrumentItemcreateCopy () const
 Creates an exact copy; also ID is the same! More...
 
std::unique_ptr< InstrumentcreateInstrument () const
 
OffspecSimulation * createOffspecSimulation (const MultiLayer &sample) const
 
ScatteringSimulation * createScatteringSimulation (const MultiLayer &sample) const
 
QString defaultName () const override
 The default user visible name when creating an instrument. More...
 
QString description () const
 
GroupItemdetectorGroup ()
 
DetectorItemdetectorItem () const
 
SelectionDescriptor< DetectorItem * > detectorSelection () const
 
 DOUBLE_PROPERTY (analyzerTotalTransmission, AnalyzerTotalTransmission)
 
QString id () const
 
void importMasks (const MaskContainerItem *maskContainer) override
 
QString instrumentName () const
 
QString instrumentType () const override
 The type as how to show it on the UI. Do not use for type checking or similar! More...
 
template<typename T >
bool is () const
 
void serialize (Streamer &s) override
 
template<typename T >
T * setBackgroundType ()
 
void setDescription (const QString &description)
 
template<typename T >
T * setDetectorType ()
 
void setId (const QString &id)
 
void setInstrumentName (const QString &instrumentName)
 
void setWithPolarizerAnalyzer (bool with)
 
std::vector< int > shape () const override
 
void updateToRealData (const RealDataItem *item) override
 
 VECTOR_PROPERTY (analyzerDirection, AnalyzerDirection)
 
 VECTOR_PROPERTY (polarization, Polarization)
 
bool withPolarizerAnalyzer () const
 

Static Public Member Functions

static bool isDetectorPropertyName (const QString &name)
 

Protected Member Functions

template<typename T >
T * beam () const
 

Protected Attributes

SelectionProperty< BackgroundItem * > m_backgroundItem
 
std::unique_ptr< BeamItemm_beamItem
 
QString m_description
 
SelectionProperty< DetectorItem * > m_detectorItem
 
QString m_id
 
QString m_name
 
bool m_withPolarizerAnalyzer
 

Constructor & Destructor Documentation

◆ OffspecInstrumentItem()

OffspecInstrumentItem::OffspecInstrumentItem ( )

Definition at line 437 of file InstrumentItems.cpp.

438 {
439  m_alphaAxis.initNbins("Nbins", "Number of points in scan");
440  m_alphaAxis.initMin("Min", "Starting value", 0.0, Unit::degree, RealLimits::limited(-90, 90));
441  m_alphaAxis.initMax("Max", "Ending value", 10.0, Unit::degree, RealLimits::limited(-90, 90));
442 
443  auto* beam_item = dynamic_cast<GISASBeamItem*>(beamItem());
444  beam_item->setInclinationAngleGetter([=]() { return m_alphaAxis.min(); });
445 }
@ degree
void setInclinationAngleGetter(std::function< double()> getter)
Explicitly set a getter function for the inclination angle.
Definition: BeamItems.cpp:222
virtual BeamItem * beamItem() const

References InstrumentItem::beamItem(), degree, and GISASBeamItem::setInclinationAngleGetter().

Here is the call graph for this function:

Member Function Documentation

◆ alignedWith()

bool InstrumentItem::alignedWith ( const RealDataItem item) const
virtualinherited

Reimplemented in SpecularInstrumentItem.

Definition at line 129 of file InstrumentItems.cpp.

130 {
131  return shape() == item->shape();
132 }
virtual std::vector< int > shape() const =0
std::vector< int > shape() const
Returns the shape of underlying data item.

References RealDataItem::shape(), and InstrumentItem::shape().

Referenced by LinkInstrumentManager::onInstrumentChanged(), and SimulationView::validateSimulationSetup().

Here is the call graph for this function:

◆ AXIS_PROPERTY()

OffspecInstrumentItem::AXIS_PROPERTY ( alphaAxis  )

◆ backgroundItem()

BackgroundItem * InstrumentItem::backgroundItem ( ) const
inherited

Definition at line 119 of file InstrumentItems.cpp.

120 {
121  return m_backgroundItem.get();
122 }
SelectionProperty< BackgroundItem * > m_backgroundItem
T get() const
Direct access to the stored pointer.

References SelectionProperty< T >::get(), and InstrumentItem::m_backgroundItem.

Here is the call graph for this function:

◆ backgroundSelection()

SelectionDescriptor< BackgroundItem * > InstrumentItem::backgroundSelection ( ) const
inherited

◆ beam()

template<typename T >
T * InstrumentItem::beam
protectedinherited

◆ beamItem()

◆ createCoordSystem()

ICoordSystem * OffspecInstrumentItem::createCoordSystem ( ) const
overridevirtual

Implements InstrumentItem.

Definition at line 483 of file InstrumentItems.cpp.

484 {
485  IAxis* alphaAxis =
486  new FixedBinAxis("alpha", m_alphaAxis.nbins(), m_alphaAxis.min() * Units::deg,
487  m_alphaAxis.max() * Units::deg);
488  const auto instrument = createInstrument();
489  return instrument->detector().offspecCoords(alphaAxis, instrument->beam().direction());
490 }
std::unique_ptr< Instrument > createInstrument() const

References Instrument2DItem::createInstrument().

Here is the call graph for this function:

◆ createCopy()

InstrumentItem * InstrumentItem::createCopy ( ) const
inherited

Creates an exact copy; also ID is the same!

Definition at line 76 of file InstrumentItems.cpp.

77 {
78  const auto type = InstrumentItemCatalog::type(this);
79  auto* copy = InstrumentItemCatalog::create(type);
80  GUI::Util::copyContents(this, copy);
81  return copy;
82 }
static Type type(const InstrumentItem *item)
Returns the enum type of the given item.
static InstrumentItem * create(Type type)
Creates the item of the given type.
void copyContents(const T *source, T *dest)
Definition: Backup.h:46

References GUI::Util::copyContents(), InstrumentItemCatalog::create(), and InstrumentItemCatalog::type().

Referenced by JobItem::copyInstrumentIntoJob(), and InstrumentCollection::insertCopy().

Here is the call graph for this function:

◆ createInstrument()

std::unique_ptr< Instrument > Instrument2DItem::createInstrument ( ) const
inherited

Definition at line 361 of file InstrumentItems.cpp.

362 {
363  auto beam = beamItem()->createBeam();
364  auto detector = detectorItem()->createDetector();
365  detector->setDetectorNormal(beam->direction().zReflected());
366 
367  return std::make_unique<Instrument>(*beam, *detector);
368 }
std::unique_ptr< Beam > createBeam() const
Definition: BeamItems.cpp:97
std::unique_ptr< IDetector > createDetector() const
DetectorItem * detectorItem() const

References InstrumentItem::beam(), InstrumentItem::beamItem(), BeamItem::createBeam(), DetectorItem::createDetector(), and Instrument2DItem::detectorItem().

Referenced by GISASInstrumentItem::createCoordSystem(), and createCoordSystem().

Here is the call graph for this function:

◆ createOffspecSimulation()

OffspecSimulation * Instrument2DItem::createOffspecSimulation ( const MultiLayer &  sample) const
inherited

Definition at line 382 of file InstrumentItems.cpp.

383 {
384  auto beam = beamItem()->createBeam();
385  beam->setPolarization(m_polarization);
386  auto detector = detectorItem()->createDetector();
387  detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
388  detector->setDetectorNormal(beam->direction().zReflected());
389 
390  auto* result = new OffspecSimulation(*beam, sample, *detector);
391  return result;
392 }

References InstrumentItem::beam(), InstrumentItem::beamItem(), BeamItem::createBeam(), DetectorItem::createDetector(), and Instrument2DItem::detectorItem().

Here is the call graph for this function:

◆ createScatteringSimulation()

ScatteringSimulation * Instrument2DItem::createScatteringSimulation ( const MultiLayer &  sample) const
inherited

Definition at line 370 of file InstrumentItems.cpp.

371 {
372  auto beam = beamItem()->createBeam();
373  beam->setPolarization(m_polarization);
374  auto detector = detectorItem()->createDetector();
375  detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
376  detector->setDetectorNormal(beam->direction().zReflected());
377 
378  auto* result = new ScatteringSimulation(*beam, sample, *detector);
379  return result;
380 }

References InstrumentItem::beam(), InstrumentItem::beamItem(), BeamItem::createBeam(), DetectorItem::createDetector(), and Instrument2DItem::detectorItem().

Here is the call graph for this function:

◆ defaultName()

QString OffspecInstrumentItem::defaultName ( ) const
overridevirtual

The default user visible name when creating an instrument.

Implements InstrumentItem.

Definition at line 473 of file InstrumentItems.cpp.

474 {
475  return "Offspec";
476 }

◆ description()

QString InstrumentItem::description ( ) const
inherited

Definition at line 104 of file InstrumentItems.cpp.

105 {
106  return m_description;
107 }

References InstrumentItem::m_description.

Referenced by InstrumentItem::setDescription().

◆ detectorGroup()

GroupItem* Instrument2DItem::detectorGroup ( )
inherited

◆ detectorItem()

DetectorItem * Instrument2DItem::detectorItem ( ) const
inherited

Definition at line 346 of file InstrumentItems.cpp.

347 {
348  return m_detectorItem.get();
349 }
SelectionProperty< DetectorItem * > m_detectorItem

References SelectionProperty< T >::get(), and Instrument2DItem::m_detectorItem.

Referenced by Instrument2DItem::createInstrument(), Instrument2DItem::createOffspecSimulation(), Instrument2DItem::createScatteringSimulation(), Instrument2DItem::importMasks(), GISASInstrumentItem::shape(), shape(), GISASInstrumentItem::updateToRealData(), and updateToRealData().

Here is the call graph for this function:

◆ detectorSelection()

SelectionDescriptor< DetectorItem * > Instrument2DItem::detectorSelection ( ) const
inherited

Definition at line 351 of file InstrumentItems.cpp.

352 {
353  return m_detectorItem;
354 }

References Instrument2DItem::m_detectorItem.

Referenced by DetectorEditor::DetectorEditor(), and DetectorEditor::createDetectorWidgets().

◆ DOUBLE_PROPERTY()

InstrumentItem::DOUBLE_PROPERTY ( analyzerTotalTransmission  ,
AnalyzerTotalTransmission   
)
inherited

◆ id()

QString InstrumentItem::id ( ) const
inherited

◆ importMasks()

void Instrument2DItem::importMasks ( const MaskContainerItem maskContainer)
overridevirtualinherited

Reimplemented from InstrumentItem.

Definition at line 356 of file InstrumentItems.cpp.

357 {
358  detectorItem()->importMasks(maskContainer);
359 }
void importMasks(const MaskContainerItem *maskContainer)

References Instrument2DItem::detectorItem(), and DetectorItem::importMasks().

Here is the call graph for this function:

◆ instrumentName()

◆ instrumentType()

QString OffspecInstrumentItem::instrumentType ( ) const
overridevirtual

The type as how to show it on the UI. Do not use for type checking or similar!

Implements InstrumentItem.

Definition at line 478 of file InstrumentItems.cpp.

479 {
480  return "Off specular";
481 }

◆ is()

◆ isDetectorPropertyName()

static bool Instrument2DItem::isDetectorPropertyName ( const QString &  name)
staticinherited

◆ serialize()

void OffspecInstrumentItem::serialize ( Streamer s)
overridevirtual

Reimplemented from Instrument2DItem.

Definition at line 447 of file InstrumentItems.cpp.

448 {
449  s.assertVersion(0);
450  Serialize::rwBaseClass<Instrument2DItem>(s, "Instrument2DItem", this);
451  m_alphaAxis.rwAxisProperty(s, "alphaAxis");
452 }
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26

References Streamer::assertVersion().

Here is the call graph for this function:

◆ setBackgroundType()

template<typename T >
T * InstrumentItem::setBackgroundType
inherited

Definition at line 205 of file InstrumentItems.h.

206 {
207  m_backgroundItem.set<T>();
208  return dynamic_cast<T*>(m_backgroundItem.get());
209 }
void set(T t, bool callInitializer=false)
Directly set the new item.

References SelectionProperty< T >::get(), InstrumentItem::m_backgroundItem, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ setDescription()

void InstrumentItem::setDescription ( const QString &  description)
inherited

Definition at line 109 of file InstrumentItems.cpp.

110 {
112 }
QString description() const

References InstrumentItem::description(), and InstrumentItem::m_description.

Referenced by InstrumentView::onInstrumentdescriptionEdited(), and InstrumentsTreeModel::setData().

Here is the call graph for this function:

◆ setDetectorType()

template<typename T >
T * Instrument2DItem::setDetectorType
inherited

Definition at line 212 of file InstrumentItems.h.

213 {
214  m_detectorItem.set<T>();
215  return dynamic_cast<T*>(m_detectorItem.get());
216 }

◆ setId()

void InstrumentItem::setId ( const QString &  id)
inherited

Definition at line 89 of file InstrumentItems.cpp.

90 {
91  m_id = id;
92 }
QString id() const

References InstrumentItem::id(), and InstrumentItem::m_id.

Referenced by InstrumentCollection::insertCopy().

Here is the call graph for this function:

◆ setInstrumentName()

void InstrumentItem::setInstrumentName ( const QString &  instrumentName)
inherited

Definition at line 94 of file InstrumentItems.cpp.

95 {
97 }
QString instrumentName() const

References InstrumentItem::instrumentName(), and InstrumentItem::m_name.

Referenced by InstrumentsEditController::addCopy(), InstrumentsTreeModel::setData(), InstrumentsEditController::setInstrumentName(), and GUI::Model::JobFunctions::setupJobItemInstrument().

Here is the call graph for this function:

◆ setWithPolarizerAnalyzer()

void InstrumentItem::setWithPolarizerAnalyzer ( bool  with)
inherited

◆ shape()

std::vector< int > OffspecInstrumentItem::shape ( ) const
overridevirtual

Implements InstrumentItem.

Definition at line 454 of file InstrumentItems.cpp.

455 {
456  return {(int)m_alphaAxis.nbins(), detectorItem()->ySize()};
457 }
virtual int ySize() const =0
Returns the size of y-axis of the detector.

References Instrument2DItem::detectorItem(), and DetectorItem::ySize().

Referenced by updateToRealData().

Here is the call graph for this function:

◆ updateToRealData()

void OffspecInstrumentItem::updateToRealData ( const RealDataItem item)
overridevirtual

Implements InstrumentItem.

Definition at line 459 of file InstrumentItems.cpp.

460 {
461  if (!dataItem)
462  return;
463 
464  const auto data_shape = dataItem->shape();
465  if (shape().size() != data_shape.size())
466  throw Error("Error in OffspecInstrumentItem::updateToRealData: The type of "
467  "instrument is incompatible with passed data shape.");
468 
469  m_alphaAxis.setNbins(data_shape[0]);
470  detectorItem()->setYSize(data_shape[1]);
471 }
virtual void setYSize(size_t ny)=0
sets the size of y-axis of the detector
std::vector< int > shape() const override

References Instrument2DItem::detectorItem(), Error, DetectorItem::setYSize(), RealDataItem::shape(), and shape().

Here is the call graph for this function:

◆ VECTOR_PROPERTY() [1/2]

InstrumentItem::VECTOR_PROPERTY ( analyzerDirection  ,
AnalyzerDirection   
)
inherited

◆ VECTOR_PROPERTY() [2/2]

InstrumentItem::VECTOR_PROPERTY ( polarization  ,
Polarization   
)
inherited

◆ withPolarizerAnalyzer()

bool InstrumentItem::withPolarizerAnalyzer ( ) const
inherited

Member Data Documentation

◆ m_backgroundItem

◆ m_beamItem

◆ m_description

QString InstrumentItem::m_description
protectedinherited

◆ m_detectorItem

◆ m_id

QString InstrumentItem::m_id
protectedinherited

◆ m_name

QString InstrumentItem::m_name
protectedinherited

◆ m_withPolarizerAnalyzer

bool InstrumentItem::m_withPolarizerAnalyzer
protectedinherited

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