#include <iostream>
#include <fstream>

#include "DiscAnalysis.h"
#include "Event.h"

const Event* read( std::ifstream& file );
void dump( const Event& ev );

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

  // open input file
  std::string name = argv[1];
  std::ifstream file( name.c_str(), std::ios::binary );
  std::string hd_i = argv[2];
  std::string hist = argv[3];

  // objects for discriminator analysis
  DiscAnalysis disc;
  disc.init( hd_i );

  std::cout << "read events" << std::endl;
  // loop over events
  const Event* ev;
  while ( ( ev = read( file ) ) != 0 ) {
//    dump( *ev );
    disc.analyze( *ev );
    delete ev;
  }

  disc.save( hist );

  return 0;

}

