// ----------------------------------------------------------------------//
// fp13.exe                                                              //
//                                                                       //
// Usage: fp13.exe [-n nEvents] -f fp13.txt                              //
//                                                                       //
// This is the driver program for the analysis class fp13Analysis.       //
// ----------------------------------------------------------------------//

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include "fp13Analysis.hh"

int main(int argc, char *argv[]) {
    
    int maxEvents(99999999); 
    
    char dataFile[200]; sprintf(dataFile, "fp13.txt");               // Default setting for data file
    
    for (int i = 0; i < argc; i++){                                  // Parsing of command line arguments
	if (!strcmp(argv[i],"-n")) maxEvents = atoi(argv[++i]);      // number of events to run over   
	if (!strcmp(argv[i],"-f")) sprintf(dataFile, argv[++i]);
    }  
    
    fp13Analysis A; 
    A.openDataFile(dataFile);                                        // Open data file for input 
    A.bookHistograms();                                              // Declare and create all histograms
    int done(0);
    
    for (int evt = 0; evt < maxEvents; ++evt) {
	done = A.readEvent();                                        // read in next event
	A.analyze();                                                 // do the analysis: apply selection cuts, fill histograms, ...
	if (done) break;
    }
    
    A.dumpHistograms();                                              // Save output 
    A.dumpAllHistograms("fp13.root");                                // Save output (txt)
}
