///////////////////////////////////////////////////////////////////
//
// This processor counts events and periodically prints a status
// message showing the number of physics events and the number of
// triggered events so far.  In order for the count of triggered
// events to be accurate, this processor must be run after a DAQ
// processor which simulates the trigger.
//
// The "update" parameter controls the update interval.  See SetI()
// for details.
//
// Author: Stan Seibert <volsung@physics.utexas.edu>
//
// REVISION HISTORY:
//         2013-11-26 : P Jones - altered comments and const correctness.
//
///////////////////////////////////////////////////////////////////

#ifndef __RAT_CountProc__
#define __RAT_CountProc__

#include <RAT/Processor.hh>

#include <string>

namespace RAT
{

class CountProc : public Processor
{
public:
  // Create new count processor.
  //
  // Default update interval is to print a status line for every physics event.
  CountProc();

  // Destroy count processor.
  virtual ~CountProc();

  // Applies the id command
  //
  // param: should be id
  // value: should be the id string
  // Throws ParamUnknown if param is not id
  virtual void SetS( const std::string& param, const std::string& value );

  // Applies the update command
  //
  // param: should be update
  // value: should be the update interval
  // Throws ParamUnknown if param is not update
  // Throws ParamInvalid if value is not >0
  virtual void SetI( const std::string& param, const int value );

  // Called for each event
  //
  // Increment event counters, print message if number of physics events is divisible by update interval.
  //
  // run: run information to process
  // ds: entry information to process
  // Returns as OK always.
  virtual Processor::Result DSEvent( DS::Run& run, DS::Entry& ds );

protected:
  std::string fID; // Option Id for this count processor
  int fDsCount;        // Number of physics events
  int fEvCount;        // Number of triggered events
  int fUpdateInterval; // Number of physics events per update line
};

} // namespace RAT

#endif