Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Public Member Functions | Protected Attributes | List of all members
kome::objects::PeakElement Class Reference

peak element More...

#include <PeakElement.h>

Collaboration diagram for kome::objects::PeakElement:
Collaboration graph
[legend]

Public Member Functions

 PeakElement ()
 constructor
 
 PeakElement (Peaks *peaks)
 constructor
 
 PeakElement (Peaks *peaks, const double x, const double y)
 constructor More...
 
virtual ~PeakElement ()
 destructor
 
void setX (const double x)
 sets x element value More...
 
double getX ()
 gets x element value More...
 
void setY (const double y)
 sets y element value More...
 
double getY ()
 gets y element value More...
 
void setLeft (const double x, const double y)
 sets peak left More...
 
double getLeftX ()
 gets x element of peak left More...
 
double getLeftY ()
 gets y element of peak left More...
 
void setRight (const double x, const double y)
 sets peak right More...
 
double getRightX ()
 gets x element of peak right More...
 
double getRightY ()
 gets y elemtn of peak right More...
 
void setApex (const double x, const double y)
 sets peak apex More...
 
double getApexX ()
 gets x element of peak apex More...
 
double getApexY ()
 gets y element of peak apex More...
 
void searchApex (kome::core::XYData &xyData)
 searches apex More...
 
bool hasApex ()
 judges whether this peak has apex information or not. More...
 
void setArea (const double area)
 sets area More...
 
double getArea ()
 gets peak area More...
 
bool hasArea ()
 judges whether this peak has area value or not More...
 
double calcArea (kome::core::XYData &xyData)
 calculates area More...
 
void setFwhm (const double fwhm)
 sets the FWHM More...
 
double getFwhm ()
 gets the FWHM More...
 
bool hasFwhm ()
 judges whether this peak has FWHM value of not More...
 
double calcFwhm (kome::core::XYData &xyData)
 calculates FWHM More...
 
void setId (int id)
 sets peak ID More...
 
int getId ()
 gets peak ID
 
void setCharge (const int charge)
 sets the charge state More...
 
int getCharge ()
 gets the charge state More...
 

Protected Attributes

Peaksm_peaks
 
double m_x
 
double m_y
 
kome::core::Point< double > m_left
 
kome::core::Point< double > m_right
 
kome::core::Point< double > m_apex
 
int m_charge
 
double m_area
 
double m_fwhm
 
int m_peakId
 

Detailed Description

peak element

Definition at line 28 of file PeakElement.h.

Constructor & Destructor Documentation

kome::objects::PeakElement::PeakElement ( Peaks peaks,
const double  x,
const double  y 
)

constructor

Parameters
[in]peakspeaks object
[in]xx element value
[in]yy element value

Definition at line 67 of file PeakElement.cpp.

68  : m_x( x ), m_y( y ), m_left( x, 0.0 ), m_right( x, 0.0 ), m_apex( x, y )
69 {
70  m_peaks = peaks;
71 
72  m_area = - FLT_MAX;
73  m_fwhm = - FLT_MAX;
74 
75  m_charge = -1;
76 
77  // issue peak id
78  if( m_peaks != NULL ){
79  m_peakId = m_peaks->issueId( this );
80  }
81 }
int issueId(PeakElement *peakElement)
to issue the peak id
Definition: Peaks.cpp:579
kome::core::Point< double > m_left
Definition: PeakElement.h:68
#define NULL
Definition: CoreMacros.h:18
kome::core::Point< double > m_apex
Definition: PeakElement.h:74
kome::core::Point< double > m_right
Definition: PeakElement.h:71

Here is the call graph for this function:

Member Function Documentation

double kome::objects::PeakElement::calcArea ( kome::core::XYData xyData)

calculates area

Parameters
[in]xyDatadata points
Returns
area

Definition at line 255 of file PeakElement.cpp.

255  {
256  // calculate area
257  double s = 0.0;
258 
259  // base line
260  const double lx = getLeftX();
261  const double ly = getLeftY();
262  const double rx = getRightX();
263  const double ry = getRightY();
264 
265  const double w = rx - lx;
266  if( w < 0.0000001 ) {
267  return s;
268  }
269 
270  const double a = ( ry - ly ) / w;
271 
272  // index
273  int idx0 = xyData.getNearestIndex( lx );
274  int idx1 = xyData.getNearestIndex( rx );
275 
276  for( int i = idx0; i < idx1 - 1; i++ ) {
277  // coordinates
278  const double x0 = xyData.getX( i );
279  const double x1 = xyData.getX( i + 1 );
280  const double y0 = xyData.getY( i ) - ( a * ( x0 - lx ) + ly );
281  const double y1 = xyData.getY( i + 1 ) - ( a * ( x1 - lx ) + ly );
282 
283  if( y0 >= 0.0 && y1 >= 0.0 ) {
284  s += ( y0 + y1 ) * ( x1 - x0 ) / 2.0; // @date 2011/02/23 <Comment> OKADA : ‘δŒ`‚̖ʐρFiγ’κ(y0){‰Ί’κ(y1)j~‚‚³(x1-x0)€‚Q
285  }
286  // baseline‚̏㑀‚̖ʐς̂݋‚ί‚ι
287  else if( y0 > 0.0 ) { // @date 2011/02/23 <Comment> OKADA : (y1<0.0)‚̏ꍇA
288  s += - y0 * y0 * ( x1 - x0 ) / ( y1 - y0 ) / 2.0; // ŽOŠpŒ`‚̍‚‚³Fy0 * ( x1 - x0 ) / ( y1 - y0 )
289  }
290  else if( y1 > 0.0 ) { // @date 2011/02/23 <Comment> OKADA : (y0<0.0)‚̏ꍇ
291  s += y1 * y1 * ( x1 - x0 ) / ( y1 - y0 ) / 2.0;
292  }
293  }
294 
295  // apex
296  searchApex( xyData );
297 
298  return s;
299 }
double getX(const unsigned int index)
gets x coordinate
Definition: XYData.cpp:224
void searchApex(kome::core::XYData &xyData)
searches apex
double getRightX()
gets x element of peak right
double getY(const unsigned int index)
gets y coordinate
Definition: XYData.cpp:243
double getRightY()
gets y elemtn of peak right
double getLeftX()
gets x element of peak left
int getNearestIndex(const double x)
gets nearest index
Definition: XYData.cpp:313
double getLeftY()
gets y element of peak left

Here is the call graph for this function:

double kome::objects::PeakElement::calcFwhm ( kome::core::XYData xyData)

calculates FWHM

Parameters
[in]xyDatadata points
Returns
FWHM

Definition at line 321 of file PeakElement.cpp.

321  {
322  // return value
323  double fwhm = -1.0;
324 
325  // apex
326  if( m_apex.px < 0.0 ) {
327  searchApex( xyData );
328  }
329 
330  const double ax = m_apex.px;
331  const double ay = m_apex.py;
332  if( ax < 0.0 ) {
333  return fwhm;
334  }
335  const double height = ay / 2.0;
336 
337  int idx = xyData.getNearestIndex( ax );
338  if( idx < 0 || ax >= (double)xyData.getLength() ) {
339  return fwhm;
340  }
341 
342  // left
343  double lx = -1.0;
344  double prevX = ax;
345  double prevY = ay;
346  for( int i = idx - 1; i >= 0 && lx < 0.0; i-- ) {
347  const double x = xyData.getX( i );
348  const double y = xyData.getY( i );
349 
350  if( prevY >= height && y <= height ) {
351  if( fabs( y - prevY ) < 0.00001 ) {
352  lx = prevX;
353  }
354  else {
355  lx = ( prevX * ( y - height ) + x * ( height - prevY ) ) / ( y - prevY );
356  }
357  }
358  else if( y > ay ) {
359  i = -1;
360  }
361 
362  prevX = x;
363  prevY = y;
364  }
365 
366  if( lx < 0.0 ) {
367  return fwhm;
368  }
369 
370  // right
371  double rx = -1.0;
372  prevX = ax;
373  prevY = ay;
374  for( int i = idx + 1; i < (int)xyData.getLength() && rx < 0.0; i++ ) {
375  const double x = xyData.getX( i );
376  const double y = xyData.getY( i );
377 
378  if( prevY >= height && y <= height ) {
379  if( fabs( y - prevY ) < 0.00001 ) {
380  rx = prevX;
381  }
382  else {
383  rx = ( prevX * ( y - height ) + x * ( height - prevY ) ) / ( y - prevY );
384  }
385  }
386  else if( y > ay ) {
387  i = (int)xyData.getLength();
388  }
389 
390  prevX = x;
391  prevY = y;
392  }
393 
394  if( rx < 0.0 ) {
395  return fwhm;
396  }
397 
398  fwhm = fabs( rx - lx );
399 
400  return fwhm;
401 }
double getX(const unsigned int index)
gets x coordinate
Definition: XYData.cpp:224
void searchApex(kome::core::XYData &xyData)
searches apex
double getY(const unsigned int index)
gets y coordinate
Definition: XYData.cpp:243
kome::core::Point< double > m_apex
Definition: PeakElement.h:74
int getNearestIndex(const double x)
gets nearest index
Definition: XYData.cpp:313
unsigned int getLength()
gets the number of points @return the number of points
Definition: XYData.cpp:216

Here is the call graph for this function:

double kome::objects::PeakElement::getApexX ( )

gets x element of peak apex

Returns
x element of peak apex

Definition at line 173 of file PeakElement.cpp.

173  {
174  if( m_apex.px < 0.0 ) {
175  m_peaks->calcArea();
176  }
177  return m_apex.px;
178 }
void calcArea()
calculates area
Definition: Peaks.cpp:226
kome::core::Point< double > m_apex
Definition: PeakElement.h:74

Here is the call graph for this function:

double kome::objects::PeakElement::getApexY ( )

gets y element of peak apex

Returns
y element of peak apex

Definition at line 181 of file PeakElement.cpp.

181  {
182  if( m_apex.px < 0.0 ) {
183  m_peaks->calcArea();
184  }
185  return m_apex.py;
186 }
void calcArea()
calculates area
Definition: Peaks.cpp:226
kome::core::Point< double > m_apex
Definition: PeakElement.h:74

Here is the call graph for this function:

double kome::objects::PeakElement::getArea ( )

gets peak area

Returns
peak area

Definition at line 241 of file PeakElement.cpp.

241  {
242  if( !hasArea() && m_peaks != NULL ) {
243  m_peaks->calcArea();
244  }
245 
246  return m_area;
247 }
void calcArea()
calculates area
Definition: Peaks.cpp:226
#define NULL
Definition: CoreMacros.h:18
bool hasArea()
judges whether this peak has area value or not

Here is the call graph for this function:

int kome::objects::PeakElement::getCharge ( )

gets the charge state

Returns
charge state

Definition at line 419 of file PeakElement.cpp.

419  {
420  return m_charge;
421 }
double kome::objects::PeakElement::getFwhm ( )

gets the FWHM

Returns
FWHM

Definition at line 307 of file PeakElement.cpp.

307  {
308  if( !hasFwhm() && m_peaks != NULL ) {
309  m_peaks->calcArea();
310  }
311 
312  return m_fwhm;
313 }
bool hasFwhm()
judges whether this peak has FWHM value of not
void calcArea()
calculates area
Definition: Peaks.cpp:226
#define NULL
Definition: CoreMacros.h:18

Here is the call graph for this function:

double kome::objects::PeakElement::getLeftX ( )

gets x element of peak left

Returns
x element of peak left

Definition at line 134 of file PeakElement.cpp.

134  {
135  return m_left.px;
136 }
kome::core::Point< double > m_left
Definition: PeakElement.h:68
double kome::objects::PeakElement::getLeftY ( )

gets y element of peak left

Returns
y element of peak left

Definition at line 139 of file PeakElement.cpp.

139  {
140  return m_left.py;
141 }
kome::core::Point< double > m_left
Definition: PeakElement.h:68
double kome::objects::PeakElement::getRightX ( )

gets x element of peak right

Returns
x element of peak right

Definition at line 157 of file PeakElement.cpp.

157  {
158  return m_right.px;
159 }
kome::core::Point< double > m_right
Definition: PeakElement.h:71
double kome::objects::PeakElement::getRightY ( )

gets y elemtn of peak right

Returns
y elemtn of peak right

Definition at line 162 of file PeakElement.cpp.

162  {
163  return m_right.py;
164 }
kome::core::Point< double > m_right
Definition: PeakElement.h:71
double kome::objects::PeakElement::getX ( )

gets x element value

Returns
x element

Definition at line 100 of file PeakElement.cpp.

100  {
101  return m_x;
102 }
double kome::objects::PeakElement::getY ( )

gets y element value

Returns
y element

Definition at line 117 of file PeakElement.cpp.

117  {
118  return m_y;
119 }
bool kome::objects::PeakElement::hasApex ( )

judges whether this peak has apex information or not.

Returns
If true, this peak has apex information

Definition at line 231 of file PeakElement.cpp.

231  {
232  return ( m_apex.px >= 0.0 );
233 }
kome::core::Point< double > m_apex
Definition: PeakElement.h:74
bool kome::objects::PeakElement::hasArea ( )

judges whether this peak has area value or not

Returns
If true, this peak has area value

Definition at line 250 of file PeakElement.cpp.

250  {
251  return ( m_area > -1000.0 );
252 }
bool kome::objects::PeakElement::hasFwhm ( )

judges whether this peak has FWHM value of not

Returns
If true, this peak has FWHM value

Definition at line 316 of file PeakElement.cpp.

316  {
317  return ( m_fwhm > -1000.0 );
318 }
void kome::objects::PeakElement::searchApex ( kome::core::XYData xyData)

searches apex

Parameters
[in]xyDatadata points

Definition at line 189 of file PeakElement.cpp.

189  {
190  // left X
191  const double lx = getLeftX();
192  const double rx = getRightX();
193 
194  // index
195  int idx0 = xyData.searchIndex( lx );
196  if( idx0 < 0 ) {
197  idx0 = - idx0 - 2;
198  if( idx0 < 0 ) {
199  idx0 = 0;
200  }
201  }
202  int idx1 = xyData.searchIndex( rx );
203  if( idx1 < 0 ) {
204  idx1 = - idx1 - 1;
205  if( idx1 >= (int)xyData.getLength() ) {
206  idx1 = (int)xyData.getLength() - 1;
207  }
208  }
209 
210  // apex
211  double apexY = 0.0;
212  double apexX = -1.0;
213  for( int i = idx0; i <= idx1; i++ ) {
214  const double x = xyData.getX( i );
215  const double y = xyData.getY( i );
216 
217  if( y > apexY || apexX < 0.0 ) {
218  apexX = x;
219  apexY = y;
220  }
221  }
222 
223  // set
224  if( apexX >= 0.0 ) {
225  m_apex.px = apexX;
226  m_apex.py = apexY;
227  }
228 }
double getX(const unsigned int index)
gets x coordinate
Definition: XYData.cpp:224
double getRightX()
gets x element of peak right
double getY(const unsigned int index)
gets y coordinate
Definition: XYData.cpp:243
double getLeftX()
gets x element of peak left
kome::core::Point< double > m_apex
Definition: PeakElement.h:74
int searchIndex(const double x)
searches index of specified x value.
Definition: XYData.cpp:276
unsigned int getLength()
gets the number of points @return the number of points
Definition: XYData.cpp:216

Here is the call graph for this function:

void kome::objects::PeakElement::setApex ( const double  x,
const double  y 
)

sets peak apex

Parameters
[in]xx element of peak apex
[in]yy element of peak apex

Definition at line 167 of file PeakElement.cpp.

167  {
168  m_apex.px = x;
169  m_apex.py = y;
170 }
kome::core::Point< double > m_apex
Definition: PeakElement.h:74
void kome::objects::PeakElement::setArea ( const double  area)

sets area

Parameters
[in]areaarea

Definition at line 236 of file PeakElement.cpp.

236  {
237  m_area = area;
238 }
void kome::objects::PeakElement::setCharge ( const int  charge)

sets the charge state

Parameters
[in]chargecharge state

Definition at line 414 of file PeakElement.cpp.

414  {
415  m_charge = charge;
416 }
void kome::objects::PeakElement::setFwhm ( const double  fwhm)

sets the FWHM

Parameters
[in]fwhmFWHM

Definition at line 302 of file PeakElement.cpp.

302  {
303  m_fwhm = fwhm;
304 }
void kome::objects::PeakElement::setId ( int  id)

sets peak ID

Parameters
[in]idpeak ID

Definition at line 404 of file PeakElement.cpp.

404  {
405  m_peakId = id;
406 }
void kome::objects::PeakElement::setLeft ( const double  x,
const double  y 
)

sets peak left

Parameters
[in]xx element of peak left
[in]yy element of peak left

Definition at line 122 of file PeakElement.cpp.

122  {
123  if( m_left.px != x || m_left.py != y ) {
124  m_left.px = x;
125  m_left.py = y;
126 
127  m_area = - FLT_MAX;
128  m_apex.px = -1.0;
129  m_apex.py = -1.0;
130  }
131 }
kome::core::Point< double > m_left
Definition: PeakElement.h:68
kome::core::Point< double > m_apex
Definition: PeakElement.h:74
void kome::objects::PeakElement::setRight ( const double  x,
const double  y 
)

sets peak right

Parameters
[in]xx element of peak right
[in]yy element of peak right

Definition at line 144 of file PeakElement.cpp.

144  {
145  if( m_right.px != x || m_right.py != y ) {
146  // set
147  m_right.px = x;
148  m_right.py = y;
149 
150  m_area = - FLT_MAX;
151  m_apex.px = -1.0;
152  m_apex.py = -1.0;
153  }
154 }
kome::core::Point< double > m_apex
Definition: PeakElement.h:74
kome::core::Point< double > m_right
Definition: PeakElement.h:71
void kome::objects::PeakElement::setX ( const double  x)

sets x element value

Parameters
[in]xx element

Definition at line 88 of file PeakElement.cpp.

88  {
89  m_x = x;
90 
91  if( m_left.px < 0.0 ) {
92  m_left.px = x;
93  }
94  if( m_right.px < 0.0 ) {
95  m_right.px = x;
96  }
97 }
kome::core::Point< double > m_left
Definition: PeakElement.h:68
kome::core::Point< double > m_right
Definition: PeakElement.h:71
void kome::objects::PeakElement::setY ( const double  y)

sets y element value

Parameters
[in]yy element

Definition at line 105 of file PeakElement.cpp.

105  {
106  m_y = y;
107 
108  if( m_left.py < 0.0 ) {
109  m_left.py = 0.0;
110  }
111  if( m_right.py < 0.0 ) {
112  m_right.py = 0.0;
113  }
114 }
kome::core::Point< double > m_left
Definition: PeakElement.h:68
kome::core::Point< double > m_right
Definition: PeakElement.h:71

Member Data Documentation

kome::core::Point< double > kome::objects::PeakElement::m_apex
protected

apex

Definition at line 74 of file PeakElement.h.

double kome::objects::PeakElement::m_area
protected

peak area

Definition at line 81 of file PeakElement.h.

int kome::objects::PeakElement::m_charge
protected

charge

Definition at line 77 of file PeakElement.h.

double kome::objects::PeakElement::m_fwhm
protected

FWHM

Definition at line 84 of file PeakElement.h.

kome::core::Point< double > kome::objects::PeakElement::m_left
protected

peak left

Definition at line 68 of file PeakElement.h.

int kome::objects::PeakElement::m_peakId
protected

peak ID

Definition at line 87 of file PeakElement.h.

Peaks* kome::objects::PeakElement::m_peaks
protected

peaks

Definition at line 59 of file PeakElement.h.

kome::core::Point< double > kome::objects::PeakElement::m_right
protected

peak right

Definition at line 71 of file PeakElement.h.

double kome::objects::PeakElement::m_x
protected

x element value

Definition at line 62 of file PeakElement.h.

double kome::objects::PeakElement::m_y
protected

y element value

Definition at line 65 of file PeakElement.h.


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