23 using namespace kome::objects;
28 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
29 #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
58 && ( spectrum->
getStartRt() < startRt || startRt < 0.0 ) ) {
63 && ( spectrum->
getEndRt() > endRt || endRt < 0.0 ) ) {
88 double precursor = 0.0;
90 for(
unsigned int i = 0; i <
m_spectra.size(); i++ ) {
91 double tmpPrec =
m_spectra[ i ]->getPrecursor();
98 precursor /= (double)precCnt;
124 m_d = std::max( d, 0.0 );
135 std::string name =
"Average Spectrum";
142 name += FMT(
" %d spectra",
m_spectra.size() );
157 bool isProfile =
false;;
158 for(
unsigned int i = 0; i <
m_spectra.size() && !isProfile; i++ ) {
172 for(
unsigned int i = 0; i < dps.
getLength(); i++ ) {
173 const double x = dps.
getX( i );
176 if( ( minX < 0.0 || x >= minX ) && ( maxX < 0.0 || x <= maxX ) ) {
185 double minXX = double();
186 double maxXX = double();
193 for(
unsigned int i = 1; i <
m_spectra.size(); i++ ) {
194 double tmpMinX =
m_spectra[ i ]->getMinX();
195 double tmpMaxX =
m_spectra[ i ]->getMaxX();
197 minXX =
MIN( minXX, tmpMinX );
198 maxXX =
MAX( maxXX, tmpMaxX );
210 double intensity = 0.0;
211 for(
unsigned int i = 0; i <
m_spectra.size(); i++ ) {
212 intensity +=
m_spectra[ i ]->getTotalIntensity( minX, maxX );
222 double intensity = 0.0;
223 for(
unsigned int i = 0; i <
m_spectra.size(); i++ ) {
224 double y =
m_spectra[ i ]->getMaxIntensity( minX, maxX );
225 if( y > intensity ) {
236 if( spectra ==
NULL || num == 0 ) {
242 spectra[ 0 ]->
getXYData( &xyData, -1.0, -1.0,
false );
245 unsigned int mid = num / 2;
269 static bool lessPoint( Point& p0, Point& p1 ) {
270 return ( p0.x < p1.x );
273 std::vector< Point > points;
279 const unsigned int len0 = src0.
getLength();
280 for(
unsigned int i = 0; i < len0; i++ ) {
281 const double x = src0.
getX( i );
282 const double y = src0.
getY( i );
284 points.resize( points.size() + 1 );
287 points.back().spec = 0;
290 double tmpD = fabs( x - prevX );
300 const unsigned int len1 = src1.
getLength();
301 for(
unsigned int i = 0; i < len1; i++ ) {
302 const double x = src1.
getX( i );
303 const double y = src1.
getY( i );
305 points.resize( points.size() + 1 );
308 points.back().spec = 1;
311 double tmpD = fabs( x - prevX );
321 std::sort( points.begin(), points.end(), Point::lessPoint );
324 std::set< int > specSet;
327 for(
unsigned int i = 0; i < points.size(); i++ ) {
328 const double x = points[ i ].x;
329 const double y = points[ i ].y;
330 const int spec = points[ i ].spec;
332 if( !specSet.empty() ) {
333 double tmpX = sumX / sumY;
334 if( specSet.find( spec ) != specSet.end() || tmpX + d < x ) {
341 if( specSet.empty() ) {
350 specSet.insert( spec );
353 if( !specSet.empty() ) {
354 double tmpX = sumX / sumY;
double getStartRt()
gets the start of retention time
abstraction class of two dimention coordinate data
void setTotalIntensity(const double intensity)
sets total intensity of spectrum
void setMaxIntensity(const double intensity)
sets max intensity of spectrum
Spectrum * getSpectrum(const unsigned int idx)
gets spectrum
group of spectrum management class
static void mergeDataPoints(kome::core::XYData &src0, kome::core::XYData &src1, kome::core::XYData &dst)
merges data points
data points data of profile management class
std::vector< Spectrum * > m_spectra
static void getAveragedDataPoints(kome::objects::Spectrum **spectra, const unsigned int num, kome::core::XYData &xyData)
gets the averaged data points
double getX(const unsigned int index)
gets x coordinate
void setPrecursor(const int stage, const double precursor)
sets precursor
virtual double onGetMaxIntensity(const double minX, const double maxX)
This method is called by getMaxIntensity method. (override method)
void setEndRt(const double rt)
sets end retention time
void setName(const char *name)
sets spectrum name
virtual ~AveragedSpectrum()
destructor
void setCentroidMode(const bool centroidMode)
sets centroid mode or not
virtual double onGetTotalIntensity(const double minX, const double maxX)
This method is called by getTotalIntensity method. (override method)
virtual void onGetXRange(double *minX, double *maxX)
This method is called by getMinX or getMaxX method. (override method)
double getY(const unsigned int index)
gets y coordinate
virtual void onGetXYData(kome::core::XYData *const xyData, const double minX, const double maxX)
This method is called by getXYData method. (override method)
interfaces of AveragedSpectrum class
interfaces of DataGroupNode class
int getMsStage()
gets ms stage
interfaces of Sample class
void setMergeDistance(const double d)
sets the merge disntace
void addSpectrum(Spectrum *spectrum)
add spectrum to array
double getTotalIntensity(const double minX=-1.0, const double maxX=-1.0)
gets total intensity in specified range
AveragedSpectrum(DataGroupNode *group)
constructor
kome::core::XYData * getXYData()
gets xy data from data manager
void setMsStage(const int stage)
sets ms stage
void setStartRt(const double rt)
sets start retention time
void setBasePeakMass(const double mass)
sets base peak mass
double getMergeDistance()
gets the merge distance
spectrum information management class
unsigned int getNumberOfSpectra()
gets the number of spectra
double getEndRt()
gets the end of retention time
void addPoint(const double x, const double y)
adds point
void setGroup(DataGroupNode *group)
sets spectrum group
void setTitle(const char *title)
sets spectrum title
bool isCentroidMode()
judget wheter this spectrum is centroid mode
void updateTitle()
update title
double getMaxIntensity(const double minX=-1.0, const double maxX=-1.0)
gets max intensity in specified range
double getBasePeakMass()
gets base peak mass
unsigned int getLength()
gets the number of points @return the number of points