BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
RectangularPixel Class Reference

Description

A pixel in a RectangularDetector.

Definition at line 29 of file RectangularPixel.h.

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

Public Member Functions

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

Private Member Functions

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

Private Attributes

const R3 m_corner_pos
 
const R3 m_height
 
const R3 m_normal
 
double m_solid_angle
 
const R3 m_width
 

Constructor & Destructor Documentation

◆ RectangularPixel()

RectangularPixel::RectangularPixel ( const R3 &  corner_pos,
const R3 &  width,
const R3 &  height 
)

Definition at line 19 of file RectangularPixel.cpp.

20  : m_corner_pos(corner_pos)
21  , m_width(width)
22  , m_height(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 }
double calculateSolidAngle() const

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  R3 position = getPosition(0.5, 0.5);
74  double length = position.mag();
75  return std::abs(position.dot(m_normal)) / std::pow(length, 3);
76 }
R3 getPosition(double x, double y) const

References getPosition(), and m_normal.

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 R3 &corner_pos, const R3 &width, const R3 &height)

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

Here is the call graph for this function:

◆ createAxis()

IAxis * RectangularPixel::createAxis ( size_t  n) const

Definition at line 78 of file RectangularPixel.cpp.

79 {
80  const auto k00 = getPosition(0.0, 0.0);
81  const auto k01 = getPosition(0.0, 1.0);
82  const double alpha_f_min = M_PI_2 - R3Util::theta(k00);
83  const double alpha_f_max = M_PI_2 - R3Util::theta(k01);
84 
85  return new FixedBinAxis("alpha_f", alpha_f_min, alpha_f_max, n);
86 }
#define M_PI_2
Definition: Constants.h:45
Axis with fixed bin size.
Definition: FixedBinAxis.h:23

References getPosition(), and M_PI_2.

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), R3(), R3());
38 }

References RectangularPixel(), and getPosition().

Here is the call graph for this function:

◆ getK()

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

Implements IPixel.

Definition at line 40 of file RectangularPixel.cpp.

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

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

Here is the call graph for this function:

◆ getPosition()

R3 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(), createAxis(), 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  R3 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 getPosition(), m_normal, and m_solid_angle.

Here is the call graph for this function:

◆ normalizeLength()

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

Definition at line 66 of file RectangularPixel.cpp.

67 {
68  return direction.unit() * length;
69 }

Referenced by getK().

◆ 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 R3 RectangularPixel::m_corner_pos
private

Definition at line 46 of file RectangularPixel.h.

Referenced by clone(), and getPosition().

◆ m_height

const R3 RectangularPixel::m_height
private

Definition at line 48 of file RectangularPixel.h.

Referenced by clone(), and getPosition().

◆ m_normal

const R3 RectangularPixel::m_normal
private

Definition at line 49 of file RectangularPixel.h.

Referenced by calculateSolidAngle(), and integrationFactor().

◆ m_solid_angle

double RectangularPixel::m_solid_angle
mutableprivate

Definition at line 50 of file RectangularPixel.h.

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

◆ m_width

const R3 RectangularPixel::m_width
private

Definition at line 47 of file RectangularPixel.h.

Referenced by clone(), and getPosition().


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