49 template <
class DataArrayT>
54 typename DataArrayT::iterator it = a.begin();
55 for (; it != a.end(); ++it)
57 if (it->getName() == name)
return it;
62 template <
class DataArrayT>
65 typename DataArrayT::const_iterator it = a.begin();
66 for (; it != a.end(); ++it)
68 if (it->getName() == name)
return it;
74 template <
typename PeakContainerT>
77 const double pos_start,
79 const bool ignore_data_arrays =
false
82 typename PeakContainerT::iterator it_start = p.PosBegin(pos_start);
83 typename PeakContainerT::iterator it_end = p.PosEnd(pos_end);
84 if (!ignore_data_arrays)
86 Size hops_left = std::distance(p.begin(), it_start);
87 Size n_elems = std::distance(it_start, it_end);
89 typename PeakContainerT::StringDataArrays& SDAs = p.getStringDataArrays();
92 if (sda.size() == p.size())
94 sda.erase(sda.begin() + hops_left + n_elems, sda.end());
95 sda.erase(sda.begin(), sda.begin() + hops_left);
99 typename PeakContainerT::FloatDataArrays& FDAs = p.getFloatDataArrays();
102 if (fda.size() == p.size())
104 fda.erase(fda.begin() + hops_left + n_elems, fda.end());
105 fda.erase(fda.begin(), fda.begin() + hops_left);
109 typename PeakContainerT::IntegerDataArrays& IDAs = p.getIntegerDataArrays();
112 if (ida.size() == p.size())
114 ida.erase(ida.begin() + hops_left + n_elems, ida.end());
115 ida.erase(ida.begin(), ida.begin() + hops_left);
119 if (it_start == it_end)
125 p.erase(it_end, p.end());
126 p.erase(p.begin(), it_start);
130 template <
typename PeakContainerT>
133 if (p.empty())
return;
135 typename PeakContainerT::iterator it = std::min_element(p.begin(), p.end(),
138 return a.getIntensity() < b.getIntensity();
141 const double rebase = - it->getIntensity();
144 peak.setIntensity(peak.getIntensity() + rebase);
170 template <
typename PeakContainerT>
173 if (!p.getFloatDataArrays().empty() || !p.getStringDataArrays().empty() || !p.getIntegerDataArrays().empty())
175 OPENMS_LOG_WARN <<
"Warning: data arrays are being ignored in the method SpectrumHelper::makePeakPositionUnique().\n";
178 if (p.empty())
return;
182 double current_position = p.begin()->getPos();
183 PeakContainerT p_new;
184 double intensity_new(0);
185 std::vector<double> intensities_at_same_position;
188 if (peak.getPos() > current_position)
196 case IntensityAveragingMethod::MIN: intensity_new = *std::min_element(intensities_at_same_position.begin(), intensities_at_same_position.end());
break;
197 case IntensityAveragingMethod::MAX: intensity_new = *std::max_element(intensities_at_same_position.begin(), intensities_at_same_position.end());
break;
200 p_new.push_back(peak_new);
202 current_position = peak.getPos();
203 intensities_at_same_position.clear();
206 intensities_at_same_position.push_back(peak.getIntensity());
215 case IntensityAveragingMethod::MIN : intensity_new = *std::min_element(intensities_at_same_position.begin(), intensities_at_same_position.end());
break;
216 case IntensityAveragingMethod::MAX : intensity_new = *std::max_element(intensities_at_same_position.begin(), intensities_at_same_position.end());
break;
219 p_new.push_back(peak_new);