BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SphericalDetectorItem Class Reference

Description

Definition at line 21 of file SphericalDetectorItem.h.

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

Public Member Functions

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

Protected Member Functions

void addMasksToCore (IDetector *detector) const
 
std::unique_ptr< IDetector > createDomainDetector () const override
 
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

◆ SphericalDetectorItem()

SphericalDetectorItem::SphericalDetectorItem ( )

Definition at line 29 of file SphericalDetectorItem.cpp.

30 {
32  "Resolution function", "Detector resolution function", "resolutionFunction",
33  initResolutionFunction);
34 
35  m_phiAxis.initNbins("Nbins", "Number of phi-axis bins");
36  m_phiAxis.initMin("Min", "Lower edge of first phi-bin", -1.0, Unit::degree,
37  RealLimits::limited(-90, 90));
38  m_phiAxis.initMax("Max", "Upper edge of last phi-bin", 1.0, Unit::degree,
39  RealLimits::limited(-90, 90));
40 
41  m_alphaAxis.initNbins("Nbins", "Number of alpha-axis bins");
42  m_alphaAxis.initMin("Min", "Lower edge of first alpha-bin", 0.0, Unit::degree,
43  RealLimits::limited(-90, 90));
44  m_alphaAxis.initMax("Max", "Upper edge of last alpha-bin", 2.0, Unit::degree,
45  RealLimits::limited(-90, 90));
46 }
@ degree
SelectionProperty< ResolutionFunctionItem * > m_resolutionFunction
Definition: DetectorItems.h:69
void initWithInitializer(const QString &label, const QString &tooltip, const QString &persistentTag, std::function< void(T newItem, const T oldItem)> initializer)
Initialize by means of a catalog class and an initializer function.

References degree, SelectionProperty< T >::initWithInitializer(), and DetectorItem::m_resolutionFunction.

Here is the call graph for this function:

Member Function Documentation

◆ addMasksToCore()

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

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 DetectorItem::axesToCoreUnitsFactor(), DetectorItem::m_maskItems, DetectorItem::maskItems(), and MaskItems::maskItems().

Referenced by DetectorItem::createDetector().

Here is the call graph for this function:

◆ axesToCoreUnitsFactor()

double SphericalDetectorItem::axesToCoreUnitsFactor ( ) const
overridevirtual

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

Reimplemented from DetectorItem.

Definition at line 96 of file SphericalDetectorItem.cpp.

97 {
98  return Units::deg;
99 }

◆ AXIS_PROPERTY() [1/2]

SphericalDetectorItem::AXIS_PROPERTY ( alphaAxis  )

◆ AXIS_PROPERTY() [2/2]

SphericalDetectorItem::AXIS_PROPERTY ( phiAxis  )

◆ createDetector()

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

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 DetectorItem::addMasksToCore(), DetectorItem::createDomainDetector(), and DetectorItem::createResolutionFunction().

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

Here is the call graph for this function:

◆ createDomainDetector()

std::unique_ptr< IDetector > SphericalDetectorItem::createDomainDetector ( ) const
overrideprotectedvirtual

Implements DetectorItem.

Definition at line 63 of file SphericalDetectorItem.cpp.

64 {
65  const int n_x = m_phiAxis.nbins();
66  const double x_min = Units::deg2rad(m_phiAxis.min());
67  const double x_max = Units::deg2rad(m_phiAxis.max());
68 
69  const int n_y = m_alphaAxis.nbins();
70  const double y_min = Units::deg2rad(m_alphaAxis.min());
71  const double y_max = Units::deg2rad(m_alphaAxis.max());
72 
73  return std::make_unique<SphericalDetector>(n_x, x_min, x_max, n_y, y_min, y_max);
74 }

◆ createResolutionFunction()

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

Definition at line 57 of file DetectorItems.cpp.

58 {
60 }
virtual std::unique_ptr< IResolutionFunction2D > createResolutionFunction(double scale=1.0) const =0

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

Referenced by DetectorItem::createDetector().

Here is the call graph for this function:

◆ importMasks()

void DetectorItem::importMasks ( const MaskContainerItem maskContainer)
inherited

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 DetectorItem::m_maskItems.

Referenced by Instrument2DItem::importMasks().

Here is the call graph for this function:

◆ maskItems()

MaskItems & DetectorItem::maskItems ( )
inherited

Definition at line 42 of file DetectorItems.cpp.

43 {
44  return m_maskItems;
45 }

References DetectorItem::m_maskItems.

Referenced by DetectorItem::addMasksToCore().

◆ resolutionFunction()

ResolutionFunctionItem * DetectorItem::resolutionFunction ( ) const
inherited

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 DetectorItem::m_resolutionFunction.

Here is the call graph for this function:

◆ resolutionFunctionSelection()

◆ serialize()

void SphericalDetectorItem::serialize ( Streamer s)
overridevirtual

Implements DetectorItem.

Definition at line 48 of file SphericalDetectorItem.cpp.

49 {
50  s.assertVersion(0);
51  // base class members
52  Serialize::rwClass(s, "masks", m_maskItems);
53  Serialize::rwSelected<ResolutionFunctionItemCatalog>(s, m_resolutionFunction);
54 
55  // own members
56  m_phiAxis.rwAxisProperty(s, "phiAxis");
57  m_alphaAxis.rwAxisProperty(s, "alphaAxis");
58 
59  if (s.xmlReader())
61 }
virtual void setUnit(const std::variant< QString, Unit > &)
Set the unit of the distributed value.
QXmlStreamReader * xmlReader()
Returns stream reader or nullptr.
Definition: Streamer.h:48
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwClass(Streamer &s, const QString &tag, T &t)
Serializes an item from a class that provides the function void serialize(Streamer&).
Definition: Serialize.h:77

References Streamer::assertVersion(), degree, DetectorItem::m_maskItems, DetectorItem::m_resolutionFunction, Serialize::rwClass(), ResolutionFunctionItem::setUnit(), and Streamer::xmlReader().

Here is the call graph for this function:

◆ setResolutionFunctionType()

template<typename T >
T * DetectorItem::setResolutionFunctionType
inherited

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(), DetectorItem::m_resolutionFunction, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ setXSize()

void SphericalDetectorItem::setXSize ( size_t  nx)
overridevirtual

sets the size of x-axis of the detector

Implements DetectorItem.

Definition at line 86 of file SphericalDetectorItem.cpp.

87 {
88  m_phiAxis.setNbins(nx);
89 }

◆ setYSize()

void SphericalDetectorItem::setYSize ( size_t  ny)
overridevirtual

sets the size of y-axis of the detector

Implements DetectorItem.

Definition at line 91 of file SphericalDetectorItem.cpp.

92 {
93  m_alphaAxis.setNbins(ny);
94 }

◆ xSize()

int SphericalDetectorItem::xSize ( ) const
overridevirtual

Returns the size of x-axis of the detector.

Implements DetectorItem.

Definition at line 76 of file SphericalDetectorItem.cpp.

77 {
78  return m_phiAxis.nbins();
79 }

◆ ySize()

int SphericalDetectorItem::ySize ( ) const
overridevirtual

Returns the size of y-axis of the detector.

Implements DetectorItem.

Definition at line 81 of file SphericalDetectorItem.cpp.

82 {
83  return m_alphaAxis.nbins();
84 }

Member Data Documentation

◆ m_maskItems

MaskItems DetectorItem::m_maskItems
protectedinherited

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

Definition at line 68 of file DetectorItems.h.

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

◆ m_resolutionFunction


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