00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OPENMS_KERNEL_PICKEDPEAK1D_H
00028 #define OPENMS_KERNEL_PICKEDPEAK1D_H
00029
00030 #include <OpenMS/KERNEL/Peak1D.h>
00031 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakShapeType.h>
00032
00033 #include <math.h>
00034
00035 namespace OpenMS
00036 {
00047 class PickedPeak1D
00048 : public Peak1D
00049 {
00050 public:
00051
00053 inline PickedPeak1D():
00054 Peak1D(),
00055 r_value_(0),
00056 area_(0),
00057 fwhm_(0),
00058 left_width_paramter_(0),
00059 right_width_paramter_(0),
00060 type_(PeakShapeType::UNDEFINED),
00061 charge_(0),
00062 signal_to_noise_(0)
00063 {
00064 }
00065
00067 inline PickedPeak1D(PickedPeak1D const& p)
00068 :
00069 Peak1D(p),
00070 r_value_(p.r_value_),
00071 area_(p.area_),
00072 fwhm_(p.fwhm_),
00073 left_width_paramter_(p.left_width_paramter_),
00074 right_width_paramter_(p.right_width_paramter_),
00075 type_(p.type_),
00076 charge_(p.charge_),
00077 signal_to_noise_(p.signal_to_noise_)
00078 {
00079 }
00080
00082 ~PickedPeak1D()
00083 {
00084 }
00085
00087 inline DoubleReal getRValue() const { return r_value_; }
00089 inline void setRValue(DoubleReal r_value) { r_value_ = r_value; }
00090
00092 inline DoubleReal getArea() const { return area_; }
00094 inline void setArea(DoubleReal area) { area_ = area; }
00095
00097 inline DoubleReal getFWHM() const { return fwhm_; }
00099 inline void setFWHM(DoubleReal fwhm) { fwhm_ = fwhm; }
00100
00102 inline DoubleReal getLeftWidthParameter() const { return left_width_paramter_; }
00104 inline void setLeftWidthParameter(DoubleReal left_width_paramter) { left_width_paramter_ = left_width_paramter; }
00105
00107 inline DoubleReal getRightWidthParameter() const { return right_width_paramter_; }
00109 inline void setRightWidthParameter(DoubleReal right_width_paramter) { right_width_paramter_ = right_width_paramter; }
00110
00112 inline const PeakShapeType::Enum& getPeakShape() const { return type_; }
00114 inline void setPeakShape(const PeakShapeType::Enum& type) { type_ = type; }
00115
00117 inline Int getCharge() const { return charge_; }
00119 inline void setCharge(Int charge) { charge_ = charge; }
00120
00122 inline DoubleReal getSN() const { return signal_to_noise_; }
00124 inline void setSN(DoubleReal signal_to_noise) { signal_to_noise_ = signal_to_noise; }
00125
00127 inline PickedPeak1D& operator = (const PickedPeak1D& rhs)
00128 {
00129 if (this==&rhs) return *this;
00130
00131 Peak1D::operator = (rhs);
00132 r_value_ = rhs.r_value_;
00133 area_ = rhs.area_;
00134 fwhm_ = rhs.fwhm_;
00135 left_width_paramter_ = rhs.left_width_paramter_;
00136 right_width_paramter_= rhs.right_width_paramter_;
00137 type_ = rhs.type_;
00138 charge_ = rhs.charge_;
00139 signal_to_noise_ = rhs.signal_to_noise_;
00140
00141 return *this;
00142 }
00143
00145 inline bool operator == (const PickedPeak1D& rhs) const
00146 {
00147 return r_value_ == rhs.r_value_ &&
00148 area_ == rhs.area_ &&
00149 fwhm_ == rhs.fwhm_ &&
00150 type_ == rhs.type_ &&
00151 charge_ == rhs.charge_ &&
00152 left_width_paramter_ == rhs.left_width_paramter_ &&
00153 right_width_paramter_ == rhs.right_width_paramter_ &&
00154 signal_to_noise_ == rhs.signal_to_noise_ &&
00155 Peak1D::operator==(rhs);
00156 }
00157
00159 inline bool operator != (const PickedPeak1D& rhs) const
00160 {
00161 return !(operator == (rhs));
00162 }
00163
00167 inline DoubleReal getSymmetricMeasure() const
00168 {
00169 DoubleReal value=0.;
00170
00171 if (left_width_paramter_ < right_width_paramter_)
00172 value = left_width_paramter_/right_width_paramter_;
00173 else
00174 value = right_width_paramter_/left_width_paramter_;
00175
00176 return value;
00177 }
00178
00182 inline DoubleReal operator () (DoubleReal x) const
00183 {
00184 DoubleReal value;
00185
00186 switch (type_)
00187 {
00188 case PeakShapeType::LORENTZ_PEAK:
00189 if (x <= getMZ())
00190 value = getIntensity()/(1.+pow(left_width_paramter_*(x - getMZ()), 2));
00191 else
00192 value = getIntensity()/(1.+pow(right_width_paramter_*(x - getMZ()), 2));
00193 break;
00194
00195 case PeakShapeType::SECH_PEAK:
00196 if ( x <= getMZ())
00197 value = getIntensity()/pow(cosh(left_width_paramter_*(x-getMZ())), 2);
00198 else
00199 value = getIntensity()/pow(cosh(right_width_paramter_*(x-getMZ())), 2);
00200 break;
00201
00202 default:
00203 value = -1.;
00204 break;
00205 }
00206
00207 return value;
00208 }
00209
00221 struct WidthLess
00222 : public std::binary_function <PickedPeak1D, PickedPeak1D, bool>
00223 {
00224 inline bool operator () (const PickedPeak1D& a, const PickedPeak1D& b)
00225 {
00226 DoubleReal a_width=0;
00227 DoubleReal b_width=0;
00228
00229 switch (a.type_)
00230 {
00231 case PeakShapeType::LORENTZ_PEAK:
00232 {
00233 a_width = sqrt(10*a.getIntensity()-1)/a.left_width_paramter_;
00234 a_width+= sqrt(10*a.getIntensity()-1)/a.right_width_paramter_;
00235 }
00236 break;
00237
00238 case PeakShapeType::SECH_PEAK:
00239 {
00240 a_width = acosh(sqrt(3*a.getIntensity())/3)/a.left_width_paramter_;
00241 a_width+= acosh(sqrt(3*a.getIntensity())/3)/a.right_width_paramter_;
00242 }
00243 break;
00244
00245 default:
00246 {
00247 a_width = -1.;
00248 }
00249 break;
00250 }
00251
00252 switch (b.type_)
00253 {
00254 case PeakShapeType::LORENTZ_PEAK:
00255 {
00256 b_width = sqrt(10*b.getIntensity()-1)/b.left_width_paramter_;
00257 b_width+= sqrt(10*b.getIntensity()-1)/b.right_width_paramter_;
00258 }
00259 break;
00260
00261 case PeakShapeType::SECH_PEAK:
00262 {
00263 b_width = acosh(sqrt(3*b.getIntensity())/3)/b.left_width_paramter_;
00264 b_width+= acosh(sqrt(3*b.getIntensity())/3)/b.right_width_paramter_;
00265 }
00266 break;
00267
00268 default:
00269 {
00270 b_width= -1.;
00271 }
00272 break;
00273 }
00274
00275 return (a_width < b_width);
00276 }
00277
00284 inline bool operator () ( PositionType const & left, PositionType const & right ) const throw()
00285 {
00286 return (left < right );
00287 }
00288 };
00290
00291 protected:
00293 DoubleReal r_value_;
00295 DoubleReal area_;
00297 DoubleReal fwhm_;
00299 DoubleReal left_width_paramter_;
00300 DoubleReal right_width_paramter_;
00302 PeakShapeType::Enum type_;
00304 Int charge_;
00306 DoubleReal signal_to_noise_;
00307
00308 };
00309
00310 }
00311
00312 #endif // OPENMS_KERNEL_DPICKEDPEAK_H