#include <iostream>
#include <iomanip>

#include "TROOT.h"
#include "TFile.h"

#include "JSupport/JMultipleFileScanner.hh"

#include "JCompass/JEvt.hh"
#include "JCompass/JSupport.hh"

#include "JLang/JStreamObjectOutput.hh"
#include "JLang/JPipe.hh"
#include "JROOT/JROOTClassSelector.hh"

#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"


/**
 * \file
 *
 * Auxiliary program to print compass events.
 * \author mdejong
 */
int main(int argc, char **argv)
{
  using namespace std;
  using namespace JPP;

  typedef JCompassTypes_t  typelist;

  JMultipleFileScanner<typelist> inputFile;
  JLimit_t&           numberOfEvents = inputFile.getLimit();
  JROOTClassSelection selection      = getROOTClassSelection<typelist>();
  int                 debug;

  try {

    JParser<> zap("Auxiliary program to print acoustic events.");

    zap['f'] = make_field(inputFile);
    zap['n'] = make_field(numberOfEvents)   = 1;
    zap['C'] = make_field(selection,
                          "Precede name of data structure by a '+' or '-' "
                          "to add or remove data types in the output, respectively."
                          "\nROOT wildcards are accepted.") = JPARSER::initialised();
    zap['d'] = make_field(debug)            = 1;

    zap(argc, argv);
  }
  catch(const exception &error) {
    FATAL(error.what() << endl);
  }

  JStreamObjectOutput<typelist> out(cout);

  inputFile | JValve<typelist>(selection) | out;
}