////////////////////////////////////////////////////////////////////////
/// \class RAT::PMTSelectors::MedianCut
///
/// \brief  Select PMT hits relative to the median of the hit time distribution.
///
/// \author M. Mottram <m.mottram@qmul.ac.uk> -- contact person
///
/// REVISION HISTORY:
///     - 2014-09-02: M. Mottram New file
///     - 2014-11-26: Matt Strait - doxygen fixes
///
/// \details Default cut is interval (-50, +50) ns relative to the median.
///         Structure taken from ModeCut.
///
////////////////////////////////////////////////////////////////////////

#ifndef __RAT_PMTSelector_MedianCut__
#define __RAT_PMTSelector_MedianCut__

#include <RAT/FitterPMT.hh>
#include <RAT/PMTSelector.hh>

namespace RAT
{

namespace PMTSelectors
{

class MedianCut : public PMTSelector
{
public:
    /// Return the Name
    ///
    /// @return name of the selector
    std::string GetName() const { return Name(); };

    /// Fitter structure name
    ///
    /// @return name of the selector
    static std::string Name() { return std::string( "medianCut" ); }

    /// Initialise the selector
    ///
    /// @param[in] param option string
    void Initialise( const std::string& param );

    /// Begin of run function - not implemented
    void BeginOfRun( DS::Run& ) { }

    /// End of run function - not implemented
    void EndOfRun( DS::Run& ) { }

    /// Set parameter values
    ///
    /// @param[in] param string name of the parameter
    /// @param[in] value to set
    void SetD( const std::string& param, double value );

    /// Main Selector function
    ///
    /// @param[in] data vector of PMT data to select PMTs from
    /// @param[in] vertex of interest
    /// @return vector of FitterPMTs to use in the fit
    std::vector<FitterPMT> GetSelectedPMTs( const std::vector<FitterPMT>& data,
                                            const DS::FitVertex& vertex );

    /// Get median PMT hit time
    ///
    /// @param[in] data vector of PMT data
    /// @param[out] median time
    double GetMedianTime(const std::vector<FitterPMT>& data) const;

protected:
    double fLowCut;  ///< Low time cut relative to median (ns)
    double fHighCut; ///< High time cut relative to median (ns)
};

} //::PMTSelectors

} //::RAT

#endif