////////////////////////////////////////////////////////////////////////
/// \class RAT::ChannelEfficiency
///
/// \brief  Calculates the detection efficiency of a channel.
///
/// \author Phil G Jones <p.g.jones@qmul.ac.uk>
/// \author Gabriel Orebi Gann <gorebigann@lbl.gov> -- contact person
///
/// REVISION HISTORY:\n
///     26/06/2013 : P G Jones - New file, code from DetectorConstructor,
///                              originally by GDOG. \n
///     09/07/2015 : GDOG - add a function to return ave chan. eff. on normal+OWL
///
/// \details Calculate the efficiency of detecting single photoelectron
///         pulses given the detector threshold.
///
////////////////////////////////////////////////////////////////////////

#ifndef __RAT_ChannelEfficiency_hh__
#define __RAT_ChannelEfficiency_hh__

#include <vector>

namespace RAT
{
class ChannelEfficiency
{
public:
  /// Singleton class instance
  inline static ChannelEfficiency* Get();

  /// Calculate the Channel Efficiencies
  void BeginOfRun();
  /// Return the efficiency for channel lcn
  double GetChannelEfficiency( const int lcn ) const { return fChannelEfficiency[lcn]; }
  /// Return the average channel efficiency (with or without OWLs included)
  double GetAverageEfficiency() const { return fAverageEfficiency; }
  double GetAverageEffPlusOWLs() const { return fAveEffPlusOWL;}
private:
  std::vector<double> fChannelEfficiency; ///< Channel efficiency by LCN
  double fAverageEfficiency; ///< Average channel efficiency on normal tubes
  double fAveEffPlusOWL;     // Average channel efficiency on normal + OWL tubes

  /// Prevent usage of methods below
  ChannelEfficiency();
  ChannelEfficiency( ChannelEfficiency& );
  void operator=( ChannelEfficiency& );
};

inline ChannelEfficiency*
ChannelEfficiency::Get()
{
  static ChannelEfficiency channelEfficiency;
  return &channelEfficiency;
}

} //::RAT

#endif