BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RectangularPixel Class Reference

A pixel in a RectangularDetector. More...

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

Public Member Functions

 RectangularPixel (const kvector_t &corner_pos, const kvector_t &width, const kvector_t &height)
 
RectangularPixelclone () const override
 
RectangularPixelcreateZeroSizePixel (double x, double y) const override
 
kvector_t getK (double x, double y, double wavelength) const override
 
kvector_t getPosition (double x, double y) const
 
double integrationFactor (double x, double y) const override
 
double solidAngle () const override
 

Private Member Functions

double calculateSolidAngle () const
 
kvector_t normalizeLength (const kvector_t direction, double length) const
 

Private Attributes

const kvector_t m_corner_pos
 
const kvector_t m_height
 
const kvector_t m_normal
 
double m_solid_angle
 
const kvector_t m_width
 

Detailed Description

A pixel in a RectangularDetector.

Definition at line 27 of file RectangularPixel.h.

Constructor & Destructor Documentation

◆ RectangularPixel()

RectangularPixel::RectangularPixel ( const kvector_t corner_pos,
const kvector_t width,
const kvector_t height 
)

Definition at line 18 of file RectangularPixel.cpp.

20  : m_corner_pos(std::move(corner_pos))
21  , m_width(std::move(width))
22  , m_height(std::move(height))
23  , m_normal(width.cross(height))
24 {
25  // TODO URGENT: why allow solid angle <=0 ??
26  auto solid_angle_value = calculateSolidAngle();
27  m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value;
28 }
auto cross(const BasicVector3D< U > &v) const
Returns cross product of vectors (linear in both arguments).
const kvector_t m_corner_pos
const kvector_t m_width
double calculateSolidAngle() const
const kvector_t m_normal
const kvector_t m_height

References calculateSolidAngle(), and m_solid_angle.

Referenced by clone(), and createZeroSizePixel().

Here is the call graph for this function:

Member Function Documentation

◆ calculateSolidAngle()

double RectangularPixel::calculateSolidAngle ( ) const
private

Definition at line 71 of file RectangularPixel.cpp.

72 {
73  kvector_t position = getPosition(0.5, 0.5);
74  double length = position.mag();
75  return std::abs(position.dot(m_normal)) / std::pow(length, 3);
76 }
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
double mag() const
Returns magnitude of the vector.
kvector_t getPosition(double x, double y) const

References BasicVector3D< T >::dot(), getPosition(), m_normal, and BasicVector3D< T >::mag().

Referenced by RectangularPixel().

Here is the call graph for this function:

◆ clone()

RectangularPixel * RectangularPixel::clone ( ) const
overridevirtual

Implements IPixel.

Definition at line 30 of file RectangularPixel.cpp.

31 {
33 }
RectangularPixel(const kvector_t &corner_pos, const kvector_t &width, const kvector_t &height)

References RectangularPixel(), m_corner_pos, m_height, and m_width.

Here is the call graph for this function:

◆ createZeroSizePixel()

RectangularPixel * RectangularPixel::createZeroSizePixel ( double  x,
double  y 
) const
overridevirtual

Implements IPixel.

Definition at line 35 of file RectangularPixel.cpp.

36 {
37  return new RectangularPixel(getPosition(x, y), kvector_t(), kvector_t());
38 }
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21

References RectangularPixel(), and getPosition().

Here is the call graph for this function:

◆ getK()

kvector_t RectangularPixel::getK ( double  x,
double  y,
double  wavelength 
) const
overridevirtual

Implements IPixel.

Definition at line 40 of file RectangularPixel.cpp.

41 {
42  kvector_t direction = getPosition(x, y);
43  double length = M_TWOPI / wavelength;
44  return normalizeLength(direction, length);
45 }
#define M_TWOPI
Definition: Constants.h:54
kvector_t normalizeLength(const kvector_t direction, double length) const

References getPosition(), M_TWOPI, and normalizeLength().

Here is the call graph for this function:

◆ getPosition()

kvector_t RectangularPixel::getPosition ( double  x,
double  y 
) const

Definition at line 47 of file RectangularPixel.cpp.

48 {
49  return m_corner_pos + x * m_width + y * m_height;
50 }

References m_corner_pos, m_height, and m_width.

Referenced by calculateSolidAngle(), createZeroSizePixel(), getK(), and integrationFactor().

◆ integrationFactor()

double RectangularPixel::integrationFactor ( double  x,
double  y 
) const
overridevirtual

Implements IPixel.

Definition at line 52 of file RectangularPixel.cpp.

53 {
54  if (m_solid_angle == 0.0)
55  return 1.0;
56  kvector_t position = getPosition(x, y);
57  double length = position.mag();
58  return std::abs(position.dot(m_normal)) / std::pow(length, 3) / m_solid_angle;
59 }

References BasicVector3D< T >::dot(), getPosition(), m_normal, m_solid_angle, and BasicVector3D< T >::mag().

Here is the call graph for this function:

◆ normalizeLength()

kvector_t RectangularPixel::normalizeLength ( const kvector_t  direction,
double  length 
) const
private

Definition at line 66 of file RectangularPixel.cpp.

67 {
68  return direction.unit() * length;
69 }
BasicVector3D< T > unit() const
Returns unit vector in direction of this. Throws for null vector.

References BasicVector3D< T >::unit().

Referenced by getK().

Here is the call graph for this function:

◆ solidAngle()

double RectangularPixel::solidAngle ( ) const
overridevirtual

Implements IPixel.

Definition at line 61 of file RectangularPixel.cpp.

62 {
63  return m_solid_angle;
64 }

References m_solid_angle.

Member Data Documentation

◆ m_corner_pos

const kvector_t RectangularPixel::m_corner_pos
private

Definition at line 42 of file RectangularPixel.h.

Referenced by clone(), and getPosition().

◆ m_height

const kvector_t RectangularPixel::m_height
private

Definition at line 44 of file RectangularPixel.h.

Referenced by clone(), and getPosition().

◆ m_normal

const kvector_t RectangularPixel::m_normal
private

Definition at line 45 of file RectangularPixel.h.

Referenced by calculateSolidAngle(), and integrationFactor().

◆ m_solid_angle

double RectangularPixel::m_solid_angle
mutableprivate

Definition at line 46 of file RectangularPixel.h.

Referenced by RectangularPixel(), integrationFactor(), and solidAngle().

◆ m_width

const kvector_t RectangularPixel::m_width
private

Definition at line 43 of file RectangularPixel.h.

Referenced by clone(), and getPosition().


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