PeakType fillPeak(double rt, double mz, double it)
{
  PeakType p;
  p.setIntensity((OpenMS::Peak2D::IntensityType)it);
  p.setMZ(mz);
  p.setRT((rt));
  return p;
}
  MSSpectrum<FeatureFinderAlgorithmIsotopeWavelet::PeakType>* FeatureFinderAlgorithmIsotopeWavelet::createHRData(const UInt i)
  {
    MSSpectrum<PeakType> spec((*this->map_)[i]);

    const MSSpectrum<PeakType>& specr((*this->map_)[i]);

    for (UInt j = 0; j < spec.size() - 1; ++j)
    {
      spec[j].setMZ(-1 * (specr[j + 1].getMZ() - specr[j].getMZ()));
      spec[j].setIntensity((specr[j].getIntensity() + specr[j + 1].getIntensity()));
    }
    spec[spec.size() - 1].setMZ(-1); spec[spec.size() - 1].setIntensity(-1);

    ConstRefVector<MSSpectrum<PeakType> > c_sorted_spec(spec.begin(), spec.end());
    //Sort in ascending order according to the intensities present in the transform
    c_sorted_spec.sortByPosition();

#ifdef OPENMS_DEBUG_ISOTOPE_WAVELET
    std::ofstream ofilex("spacings.trans");
    for (UInt j = 0; j < spec.size() - 1; ++j)
    {
      ofilex << ::std::setprecision(12) << std::fixed << spec[j].getMZ() << "\t" << spec[j].getIntensity() << std::endl;
    }
    ofilex.close();
#endif

    UInt pos = 0;
    while (c_sorted_spec[pos].getIntensity() <= 0)
    {
      if (++pos >= c_sorted_spec.size())
      {
        std::cout << "Detected empty scan or a scan that cannot be interpolated with zeros in HR mode. " << std::endl;
        std::cout << "Please check scan # " << i << " of your data set." << std::endl;
        exit(-1);
      }
    }
    double bound = -1 * c_sorted_spec[pos].getMZ();

    if (bound > (1. / max_charge_) / 2.)
    {
      //that might be case for simulated spectra,
      //which might show a very artificial spacing
      bound = (1. / max_charge_) / 2. / 4.;
    }

    MSSpectrum<PeakType>* new_spec = new MSSpectrum<PeakType>;
    new_spec->reserve(200000);
    new_spec->setRT(((*this->map_)[i]).getRT());
    PeakType p; p.setMZ(specr[0].getMZ()); p.setIntensity(specr[0].getIntensity());
    new_spec->push_back(p);

    UInt count;
    for (UInt j = 0; j < spec.size() - 1; ++j)
    {
      count = 0;
      while (-spec[j].getMZ() - count * bound > bound)
      {
        ++count;
        p.setMZ(specr[j].getMZ() + count * bound); p.setIntensity(0);
        new_spec->push_back(p);
      }
      p.setMZ(specr[j + 1].getMZ()); p.setIntensity(specr[j + 1].getIntensity());
      new_spec->push_back(p);
    }

#ifdef OPENMS_DEBUG_ISOTOPE_WAVELET
    std::ofstream ofiley("new_spec.trans");
    for (UInt j = 0; j < new_spec->size(); ++j)
    {
      ofiley << ::std::setprecision(12) << std::fixed << (*new_spec)[j].getMZ() << "\t" << (*new_spec)[j].getIntensity() << std::endl;
    }
    ofiley.close();
#endif

    return new_spec;
  }
 void  fillIntensity(PeakType& peak) const
 {
   peak.setIntensity(getIntensity(peak.getPosition()));
 }