BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DetectorItem Class Referenceabstract

Description

Definition at line 29 of file DetectorItems.h.

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

Public Member Functions

virtual ~DetectorItem ()=default
 
virtual double axesToCoreUnitsFactor () const
 Scales the values provided by axes (to perform deg->rad conversion on the way to domain). More...
 
std::unique_ptr< IDetector > createDetector () const
 
void importMasks (const MaskContainerItem *maskContainer)
 
MaskItemsmaskItems ()
 
ResolutionFunctionItemresolutionFunction () const
 
SelectionDescriptor< ResolutionFunctionItem * > resolutionFunctionSelection () const
 
virtual void serialize (Streamer &s)=0
 
template<typename T >
T * setResolutionFunctionType ()
 
virtual void setXSize (size_t nx)=0
 sets the size of x-axis of the detector More...
 
virtual void setYSize (size_t ny)=0
 sets the size of y-axis of the detector More...
 
virtual int xSize () const =0
 Returns the size of x-axis of the detector. More...
 
virtual int ySize () const =0
 Returns the size of y-axis of the detector. More...
 

Protected Member Functions

 DetectorItem ()
 
void addMasksToCore (IDetector *detector) const
 
virtual std::unique_ptr< IDetector > createDomainDetector () const =0
 
std::unique_ptr< IResolutionFunction2D > createResolutionFunction () const
 

Protected Attributes

MaskItems m_maskItems
 for creation of domain detector; only filled and relevant in jobs More...
 
SelectionProperty< ResolutionFunctionItem * > m_resolutionFunction
 

Constructor & Destructor Documentation

◆ ~DetectorItem()

virtual DetectorItem::~DetectorItem ( )
virtualdefault

◆ DetectorItem()

DetectorItem::DetectorItem ( )
protected

Definition at line 24 of file DetectorItems.cpp.

24 {}

Member Function Documentation

◆ addMasksToCore()

void DetectorItem::addMasksToCore ( IDetector *  detector) const
protected

Definition at line 62 of file DetectorItems.cpp.

63 {
64  const double scale = axesToCoreUnitsFactor();
65  const auto maskItems = m_maskItems.maskItems();
66  for (auto maskIter = maskItems.rbegin(); maskIter != maskItems.rend(); maskIter++) {
67  if (auto* roiItem = dynamic_cast<RegionOfInterestItem*>(*maskIter)) {
68  const double xlow = scale * roiItem->xLow();
69  const double ylow = scale * roiItem->yLow();
70  const double xup = scale * roiItem->xUp();
71  const double yup = scale * roiItem->yUp();
72  detector->setRegionOfInterest(xlow, ylow, xup, yup);
73  } else {
74  std::unique_ptr<IShape2D> shape((*maskIter)->createShape(scale));
75  detector->addMask(*shape, (*maskIter)->maskValue());
76  }
77  }
78 }
MaskItems & maskItems()
virtual double axesToCoreUnitsFactor() const
Scales the values provided by axes (to perform deg->rad conversion on the way to domain).
Definition: DetectorItems.h:57
MaskItems m_maskItems
for creation of domain detector; only filled and relevant in jobs
Definition: DetectorItems.h:68
QVector< MaskItem * > maskItems() const
Definition: MaskItems.cpp:502

References axesToCoreUnitsFactor(), m_maskItems, maskItems(), and MaskItems::maskItems().

Referenced by createDetector().

Here is the call graph for this function:

◆ axesToCoreUnitsFactor()

virtual double DetectorItem::axesToCoreUnitsFactor ( ) const
inlinevirtual

Scales the values provided by axes (to perform deg->rad conversion on the way to domain).

Reimplemented in SphericalDetectorItem.

Definition at line 57 of file DetectorItems.h.

57 { return 1.0; }

Referenced by addMasksToCore(), and createResolutionFunction().

◆ createDetector()

std::unique_ptr< IDetector > DetectorItem::createDetector ( ) const

Definition at line 26 of file DetectorItems.cpp.

27 {
28  auto result = createDomainDetector();
29  addMasksToCore(result.get());
30 
31  if (auto resFunc = createResolutionFunction())
32  result->setResolutionFunction(*resFunc);
33 
34  return result;
35 }
std::unique_ptr< IResolutionFunction2D > createResolutionFunction() const
virtual std::unique_ptr< IDetector > createDomainDetector() const =0
void addMasksToCore(IDetector *detector) const

References addMasksToCore(), createDomainDetector(), and createResolutionFunction().

Referenced by Instrument2DItem::createInstrument(), Instrument2DItem::createOffspecSimulation(), and Instrument2DItem::createScatteringSimulation().

Here is the call graph for this function:

◆ createDomainDetector()

virtual std::unique_ptr<IDetector> DetectorItem::createDomainDetector ( ) const
protectedpure virtual

Implemented in SphericalDetectorItem, and RectangularDetectorItem.

Referenced by createDetector().

◆ createResolutionFunction()

std::unique_ptr< IResolutionFunction2D > DetectorItem::createResolutionFunction ( ) const
protected

Definition at line 57 of file DetectorItems.cpp.

58 {
60 }
SelectionProperty< ResolutionFunctionItem * > m_resolutionFunction
Definition: DetectorItems.h:69
virtual std::unique_ptr< IResolutionFunction2D > createResolutionFunction(double scale=1.0) const =0

References axesToCoreUnitsFactor(), ResolutionFunctionItem::createResolutionFunction(), and m_resolutionFunction.

Referenced by createDetector().

Here is the call graph for this function:

◆ importMasks()

void DetectorItem::importMasks ( const MaskContainerItem maskContainer)

Definition at line 37 of file DetectorItems.cpp.

38 {
39  m_maskItems.copy(maskContainer);
40 }
void copy(const MaskContainerItem *maskContainer)
Copy the mask items stored in the given maskContainer.
Definition: MaskItems.cpp:507

References MaskItems::copy(), and m_maskItems.

Referenced by Instrument2DItem::importMasks().

Here is the call graph for this function:

◆ maskItems()

MaskItems & DetectorItem::maskItems ( )

Definition at line 42 of file DetectorItems.cpp.

43 {
44  return m_maskItems;
45 }

References m_maskItems.

Referenced by addMasksToCore().

◆ resolutionFunction()

ResolutionFunctionItem * DetectorItem::resolutionFunction ( ) const

Definition at line 47 of file DetectorItems.cpp.

48 {
49  return m_resolutionFunction.get();
50 }
T get() const
Direct access to the stored pointer.

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

Here is the call graph for this function:

◆ resolutionFunctionSelection()

◆ serialize()

virtual void DetectorItem::serialize ( Streamer s)
pure virtual

◆ setResolutionFunctionType()

template<typename T >
T * DetectorItem::setResolutionFunctionType

Definition at line 73 of file DetectorItems.h.

74 {
76  return dynamic_cast<T*>(m_resolutionFunction.get());
77 }
void set(T t, bool callInitializer=false)
Directly set the new item.

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

Here is the call graph for this function:

◆ setXSize()

virtual void DetectorItem::setXSize ( size_t  nx)
pure virtual

sets the size of x-axis of the detector

Implemented in SphericalDetectorItem, and RectangularDetectorItem.

Referenced by GISASInstrumentItem::updateToRealData().

◆ setYSize()

virtual void DetectorItem::setYSize ( size_t  ny)
pure virtual

sets the size of y-axis of the detector

Implemented in SphericalDetectorItem, and RectangularDetectorItem.

Referenced by GISASInstrumentItem::updateToRealData(), and OffspecInstrumentItem::updateToRealData().

◆ xSize()

virtual int DetectorItem::xSize ( ) const
pure virtual

Returns the size of x-axis of the detector.

Implemented in SphericalDetectorItem, and RectangularDetectorItem.

◆ ySize()

virtual int DetectorItem::ySize ( ) const
pure virtual

Returns the size of y-axis of the detector.

Implemented in SphericalDetectorItem, and RectangularDetectorItem.

Referenced by OffspecInstrumentItem::shape().

Member Data Documentation

◆ m_maskItems

MaskItems DetectorItem::m_maskItems
protected

for creation of domain detector; only filled and relevant in jobs

Definition at line 68 of file DetectorItems.h.

Referenced by addMasksToCore(), importMasks(), maskItems(), RectangularDetectorItem::serialize(), and SphericalDetectorItem::serialize().

◆ m_resolutionFunction


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