#ifndef EventDiscriminator_h
#define EventDiscriminator_h

#include <string>
#include <map>

class TH1F;

class Event;

class EventDiscriminator {

 public:

  EventDiscriminator();
  ~EventDiscriminator();

  enum EventType { signal, background };

  // create histograms
  void book();

  // fill histograms for "signal" or "background" events
  void fill( const Event& ev, EventType type );
  // save histograms for "signal" or "background" events
  void save( const std::string& name, EventType type );
  // read all histograms
  void read( const std::string& name );

  // compute discriminating variable for an event
  float get( const Event& ev );

 private:

  EventDiscriminator           ( const EventDiscriminator& x );
  EventDiscriminator& operator=( const EventDiscriminator& x );

  // normalize histogram to have s=1 with s=sum of bin content
  void normalizeHisto( TH1F* h );
  // compute event variables
  void compute( const Event& ev );
  // compute probabilities for a variable
  void get( float x,
            float& dSig, float& dBkg,
            TH1F*  hSig,  TH1F* hBkg );
  // event variables
  float ptSum;
  float ptMin;
  float ptMax;
  float phiDMin;
  float phiDMax;
  float etaDMin;
  float etaDMax;

  // histograms for signal
  TH1F* hSig_ptSum;
  TH1F* hSig_ptMin;
  TH1F* hSig_ptMax;
  TH1F* hSig_phiDMin;
  TH1F* hSig_phiDMax;
  TH1F* hSig_etaDMin;
  TH1F* hSig_etaDMax;
  // histograms for background
  TH1F* hBkg_ptSum;
  TH1F* hBkg_ptMin;
  TH1F* hBkg_ptMax;
  TH1F* hBkg_phiDMin;
  TH1F* hBkg_phiDMax;
  TH1F* hBkg_etaDMin;
  TH1F* hBkg_etaDMax;

};

#endif

