#include <iomanip>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
#include <ios>
#include "yields.h" 

using namespace std;

void Draw(double mass);
std::string flt2string( double& number);

  Yields Gonin;


int main()
{
  double Energy, Mass;
  double yvector[3];
  //  Yields Gonin;
  
  /*  std::cout<<"Enter energy in keV:    ";
  std::cin>>Energy;
  
  std::cout<<"Enter mass in MeV/c²:    ";
  std::cin>>Mass;
   


  // calculate yields
  //Yields(Energy,Mass*1000);

  // std::cout<<"Yield+:           "<<  Yield_plus<<std::endl;
  // std::cout<<"Yield neutral:    "<<  Yield_zero<<std::endl;



  Gonin.GetYields(Energy, Mass*1000,yvector);

  std::cout<<"Yield+:           "<<  yvector[0] <<std::endl;
  std::cout<<"Yield neutral:    "<<  yvector[1] <<std::endl;
  */

  Draw(Mass);
  return 0;
}

void Draw(double mass)
{
   double E;
   int i;
   i=1;
  std::string name, ref;
  name="gonin_";
  ref = flt2string(mass);
  name+=ref;
  name+=".dat";

  double yvector[3];
  ofstream Yprint("test6.txt");

   if (!Yprint.is_open()) exit(8);
   do 
     {
       E=i*0.25;
         Gonin.GetYields(E,105*1000,yvector);
     
	 Yprint << /*log(E*9)/log(10.)*/ E*9 <<" " << yvector[0]<< "  " <<yvector[1]<<std::endl;
       i++;
     }while(i<400);

   Yprint.close();
}



std::string flt2string( double& number)
{
  std::ostringstream oss;
  oss << number;
   return oss.str();
}

//
// gnuplot commands
// set ylabel "Yields"
// set xlabel "Energy [keV] in power of 10"
// set grid
// plot 'test.txt'  using 1:2 ti 'mu+', 'test.txt' using 1:3 ti 'mu0'
