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

Description

Definition at line 174 of file InstrumentItems.h.

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

Public Member Functions

virtual bool alignedWith (const RealDataItem *item) const
 
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
 

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:

◆ 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 * GISASInstrumentItem::createCoordSystem ( ) const
overridevirtual

Implements InstrumentItem.

Definition at line 427 of file InstrumentItems.cpp.

428 {
429  const auto instrument = createInstrument();
430  return instrument->detector().scatteringCoords(instrument->beam());
431 }
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
virtual BeamItem * beamItem() const

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

Referenced by createCoordSystem(), and OffspecInstrumentItem::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 GISASInstrumentItem::defaultName ( ) const
overridevirtual

The default user visible name when creating an instrument.

Implements InstrumentItem.

Definition at line 417 of file InstrumentItems.cpp.

418 {
419  return "GISAS";
420 }

◆ 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(), shape(), OffspecInstrumentItem::shape(), updateToRealData(), and OffspecInstrumentItem::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 GISASInstrumentItem::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 422 of file InstrumentItems.cpp.

423 {
424  return "GISAS";
425 }

◆ is()

◆ isDetectorPropertyName()

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

◆ serialize()

void Instrument2DItem::serialize ( Streamer s)
overridevirtualinherited

Reimplemented from InstrumentItem.

Reimplemented in OffspecInstrumentItem.

Definition at line 339 of file InstrumentItems.cpp.

340 {
341  s.assertVersion(0);
342  Serialize::rwBaseClass<InstrumentItem>(s, "InstrumentItem", this);
343  Serialize::rwSelected<DetectorItemCatalog>(s, m_detectorItem);
344 }
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26

References Streamer::assertVersion(), and Instrument2DItem::m_detectorItem.

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 > GISASInstrumentItem::shape ( ) const
overridevirtual

Implements InstrumentItem.

Definition at line 398 of file InstrumentItems.cpp.

399 {
400  auto* detector_item = detectorItem();
401  return {detector_item->xSize(), detector_item->ySize()};
402 }

References Instrument2DItem::detectorItem().

Referenced by updateToRealData().

Here is the call graph for this function:

◆ updateToRealData()

void GISASInstrumentItem::updateToRealData ( const RealDataItem item)
overridevirtual

Implements InstrumentItem.

Definition at line 404 of file InstrumentItems.cpp.

405 {
406  if (!item)
407  return;
408 
409  const auto data_shape = item->shape();
410  if (shape().size() != data_shape.size())
411  throw Error("Error in GISASInstrumentItem::updateToRealData: The type of "
412  "instrument is incompatible with passed data shape.");
413  detectorItem()->setXSize(data_shape[0]);
414  detectorItem()->setYSize(data_shape[1]);
415 }
virtual void setYSize(size_t ny)=0
sets the size of y-axis of the detector
virtual void setXSize(size_t nx)=0
sets the size of x-axis of the detector
std::vector< int > shape() const override

References Instrument2DItem::detectorItem(), Error, DetectorItem::setXSize(), 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: