#include <iostream>
#include <iomanip>

#include "km3net-dataformat/online/JDAQTriggerMask.hh"

#include "JTrigger/JTriggerBits.hh"

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


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

  int          debug;

  try {

    JParser<> zap("Auxiliary program to print trigger bits.");

    zap['d'] = make_field(debug)               = 1;

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

  size_t number_of_trigger_bits = 0;

  for (size_t i = 1; i <= NUMBER_OF_TRIGGER_BITS; ++i) {

    const char* const buffer = getTriggerName(i);

    if (buffer != NULL) {

      cout << (number_of_trigger_bits == 0 ? "" : " ") << buffer;

      ++number_of_trigger_bits;
    }
  }
  
  if (number_of_trigger_bits != 0) {
    cout << endl;
  }

  return 0;
}