using namespace std;
#include <iostream>
#include <fstream>
#include <string>

#include "TFile.h"
#include "TH1.h"

#include "FitEfficiency.h"
#include "TApplication.h"

int main( int argc, char* argv[] ) {

  // file names: ROOT file with plot to fit and text file for parameters
  string name_i( argv[1] );
  string name_o( argv[2] );

  // object to plot directly the fit result
  TApplication app( "tkplot", &argc, argv );
  // open ROOT file and retrieve histo
  TFile* file = new TFile( name_i.c_str() );
  TH1F* hreff = dynamic_cast<TH1F*>( file->Get( "hreff" ) );

  // create fitting object
  FitEfficiency* eFunc = FitEfficiency::instance();
  eFunc->fit( hreff );
  eFunc->dump( name_o.c_str() );

  // run the graphics
  app.Run( kTRUE );

  return 0;

}

