QXRD  0.11.16
Public Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
QxrdFitterRingEllipse Class Reference

#include <qxrdfitterringellipse.h>

Inheritance diagram for QxrdFitterRingEllipse:
Inheritance graph
[legend]
Collaboration diagram for QxrdFitterRingEllipse:
Collaboration graph
[legend]

Public Member Functions

 QxrdFitterRingEllipse (QxrdCenterFinder *cf, int ringIndex, double x0, double y0)
 
 QxrdFitterRingEllipse ()
 
int fit ()
 
int ringIndex () const
 
double x0 () const
 
double y0 () const
 
double fittedX () const
 
double fittedY () const
 
double fittedA () const
 
double fittedB () const
 
double fittedRot () const
 
- Public Member Functions inherited from QxrdFitter
 QxrdFitter (QxrdCenterFinder *cf)
 
 QxrdFitter ()
 
QxrdCenterFindercf () const
 
FitResult reason () const
 
QString reasonString () const
 

Protected Attributes

int m_RingIndex
 
double m_X0
 
double m_Y0
 
double m_FittedX
 
double m_FittedY
 
double m_FittedA
 
double m_FittedB
 
double m_FittedRot
 
- Protected Attributes inherited from QxrdFitter
QxrdCenterFinderm_CenterFinder
 
FitResult m_Reason
 

Private Member Functions

void evaluate (double *parm, double *xv, int np, int nx)
 

Static Private Member Functions

static void staticEvaluate (double *parm, double *xv, int np, int nx, void *adata)
 

Additional Inherited Members

- Public Types inherited from QxrdFitter
enum  FitResult {
  Successful, NoResult, OutsideData, BadWidth,
  BadPosition, BadHeight, LastReason
}
 
- Static Public Member Functions inherited from QxrdFitter
static QString reasonString (FitResult i)
 

Detailed Description

Definition at line 6 of file qxrdfitterringellipse.h.

Constructor & Destructor Documentation

QxrdFitterRingEllipse::QxrdFitterRingEllipse ( QxrdCenterFinder cf,
int  ringIndex,
double  x0,
double  y0 
)
QxrdFitterRingEllipse::QxrdFitterRingEllipse ( )

Member Function Documentation

void QxrdFitterRingEllipse::evaluate ( double *  parm,
double *  xv,
int  np,
int  nx 
)
private

Definition at line 49 of file qxrdfitterringellipse.cpp.

References QxrdFitter::m_CenterFinder, m_RingIndex, QxrdCenterFinder::powderRingPoint(), QxrdPowderPoint::x(), and QxrdPowderPoint::y().

Referenced by staticEvaluate().

50 {
51  if (m_CenterFinder) {
52  double cx = parm[0];
53  double cy = parm[1];
54  double a = parm[2];
55  double b = parm[3];
56  double az = parm[4];
57 
58  double cosaz = cos(az);
59  double sinaz = sin(az);
60 
61  for (int i=0; i<nx; i++) {
63 
64  double ptaz = atan2(pt.y() - cy, pt.x() - cx) - az;
65 
66  double x = cx + a*cos(ptaz);
67  double y = cy + b*sin(ptaz);
68 
69  double xp = x*cosaz - y*sinaz;
70  double yp = x*sinaz + y*cosaz;
71 
72  double dx = xp - pt.x();
73  double dy = yp - pt.y();
74 
75  xv[i] = sqrt(dx*dx + dy*dy);
76  }
77  }
78 }
double y() const
QxrdCenterFinder * m_CenterFinder
Definition: qxrdfitter.h:31
QxrdPowderPoint powderRingPoint(int i) const
double x() const

Here is the call graph for this function:

Here is the caller graph for this function:

int QxrdFitterRingEllipse::fit ( )
virtual

Implements QxrdFitter.

Definition at line 80 of file qxrdfitterringellipse.cpp.

References QxrdCenterFinder::countPowderRingPoints(), QxrdFitter::m_CenterFinder, m_FittedA, m_FittedB, m_FittedRot, m_FittedX, m_FittedY, QxrdFitter::m_Reason, m_RingIndex, m_X0, m_Y0, QxrdFitter::NoResult, QxrdCenterFinder::powderRingPoint(), staticEvaluate(), QxrdFitter::Successful, QxrdPowderPoint::x(), and QxrdPowderPoint::y().

Referenced by QxrdCenterFinder::fitPowderEllipse(), and QxrdCenterFinder::fitPowderEllipses().

81 {
82  int niter = -1;
83 
84  if (m_CenterFinder) {
86  double rsum = 0;
87 
88  for (int i=0; i<npts; i++) {
90 
91  double dx = pt.x() - m_X0;
92  double dy = pt.y() - m_Y0;
93 
94  rsum += sqrt(dx*dx + dy*dy);
95  }
96 
97  double parms[5];
98  double info[LM_INFO_SZ];
99 
100  parms[0] = m_X0;
101  parms[1] = m_Y0;
102  parms[2] = rsum/npts;
103  parms[3] = rsum/npts;
104  parms[4] = 0;
105 
106  niter = dlevmar_dif(QxrdFitterRingEllipse::staticEvaluate,
107  parms, NULL, 5, npts,
108  m_CenterFinder->get_PeakFitIterations(),
109  NULL, info, NULL, NULL, this);
110 
111  if (niter > 0) {
113  m_FittedX = parms[0];
114  m_FittedY = parms[1];
115  m_FittedA = parms[2];
116  m_FittedB = parms[3];
117  m_FittedRot = parms[4];
118  } else {
119  m_Reason = NoResult;
120  }
121  }
122 
123  return niter;
124 }
double y() const
FitResult m_Reason
Definition: qxrdfitter.h:32
int countPowderRingPoints() const
static void staticEvaluate(double *parm, double *xv, int np, int nx, void *adata)
QxrdCenterFinder * m_CenterFinder
Definition: qxrdfitter.h:31
QxrdPowderPoint powderRingPoint(int i) const
double x() const

Here is the call graph for this function:

Here is the caller graph for this function:

double QxrdFitterRingEllipse::fittedA ( ) const
inline

Definition at line 19 of file qxrdfitterringellipse.h.

References m_FittedA.

Referenced by QxrdCenterFinder::fitPowderEllipse(), and QxrdCenterFinder::fitPowderEllipses().

19 { return m_FittedA; }

Here is the caller graph for this function:

double QxrdFitterRingEllipse::fittedB ( ) const
inline

Definition at line 20 of file qxrdfitterringellipse.h.

References m_FittedB.

Referenced by QxrdCenterFinder::fitPowderEllipse(), and QxrdCenterFinder::fitPowderEllipses().

20 { return m_FittedB; }

Here is the caller graph for this function:

double QxrdFitterRingEllipse::fittedRot ( ) const
inline

Definition at line 21 of file qxrdfitterringellipse.h.

References m_FittedRot.

Referenced by QxrdCenterFinder::fitPowderEllipse(), and QxrdCenterFinder::fitPowderEllipses().

21 { return m_FittedRot; }

Here is the caller graph for this function:

double QxrdFitterRingEllipse::fittedX ( ) const
inline

Definition at line 17 of file qxrdfitterringellipse.h.

References m_FittedX.

Referenced by QxrdCenterFinder::fitPowderEllipse(), and QxrdCenterFinder::fitPowderEllipses().

17 { return m_FittedX; }

Here is the caller graph for this function:

double QxrdFitterRingEllipse::fittedY ( ) const
inline

Definition at line 18 of file qxrdfitterringellipse.h.

References m_FittedY.

Referenced by QxrdCenterFinder::fitPowderEllipse(), and QxrdCenterFinder::fitPowderEllipses().

18 { return m_FittedY; }

Here is the caller graph for this function:

int QxrdFitterRingEllipse::ringIndex ( ) const
inline

Definition at line 14 of file qxrdfitterringellipse.h.

References m_RingIndex.

void QxrdFitterRingEllipse::staticEvaluate ( double *  parm,
double *  xv,
int  np,
int  nx,
void *  adata 
)
staticprivate

Definition at line 40 of file qxrdfitterringellipse.cpp.

References evaluate().

Referenced by fit().

41 {
43 
44  if (rf) {
45  rf->evaluate(p,hx,m,n);
46  }
47 }
void evaluate(double *parm, double *xv, int np, int nx)

Here is the call graph for this function:

Here is the caller graph for this function:

double QxrdFitterRingEllipse::x0 ( ) const
inline

Definition at line 15 of file qxrdfitterringellipse.h.

References m_X0.

15 { return m_X0; }
double QxrdFitterRingEllipse::y0 ( ) const
inline

Definition at line 16 of file qxrdfitterringellipse.h.

References m_Y0.

16 { return m_Y0; }

Member Data Documentation

double QxrdFitterRingEllipse::m_FittedA
protected

Definition at line 33 of file qxrdfitterringellipse.h.

Referenced by fit(), and fittedA().

double QxrdFitterRingEllipse::m_FittedB
protected

Definition at line 34 of file qxrdfitterringellipse.h.

Referenced by fit(), and fittedB().

double QxrdFitterRingEllipse::m_FittedRot
protected

Definition at line 35 of file qxrdfitterringellipse.h.

Referenced by fit(), and fittedRot().

double QxrdFitterRingEllipse::m_FittedX
protected

Definition at line 31 of file qxrdfitterringellipse.h.

Referenced by fit(), and fittedX().

double QxrdFitterRingEllipse::m_FittedY
protected

Definition at line 32 of file qxrdfitterringellipse.h.

Referenced by fit(), and fittedY().

int QxrdFitterRingEllipse::m_RingIndex
protected

Definition at line 28 of file qxrdfitterringellipse.h.

Referenced by evaluate(), fit(), and ringIndex().

double QxrdFitterRingEllipse::m_X0
protected

Definition at line 29 of file qxrdfitterringellipse.h.

Referenced by fit(), and x0().

double QxrdFitterRingEllipse::m_Y0
protected

Definition at line 30 of file qxrdfitterringellipse.h.

Referenced by fit(), and y0().


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