/** TStripHist
 *
 * A compound of a TH1D and a TGraph with a common Fill() method
 *
 * The TGraph is a strip chart that can be limited in number of
 * entries and/or displayed range.  The TH1D holds a histogram of all
 * "y" values of the graph from the first fill.
 */

#ifndef STRIPHIST_H
#define STRIPHIST_H

#include <TPad.h>
#include <string>

class TH1D;
class TGraph;

class StripHist {
    TGraph* fStrip;
    TH1D* fHist;

    double fStripRange;
    int fMaxStripEntries;
    std::string fYtitle;

public:
    
    /// Create a StripHist.
    StripHist(const char* name, const char* title);
    StripHist(const char* name, const char* title,
	      int nbin, double minbin, double maxbin);

    /// Access the strip TGraph
    TGraph& GetStrip() { return *fStrip; }

    /// Access the TH1D histogram
    TH1D& GetHist() { return *fHist; }

    /// Add point x,y to the strip chart and fill histogram with y and
    /// optional histweight
    void Fill(double x, double y, double histweight=1.0);
    
    /// Sets the Line Color of the TGraph
    void SetLineColor(int color = 0);

    /// Limit the range of the displayed strip chart.  Upon a Fill()
    /// this will remove later entries until the range is satisfied.
    /// Set to 0 (default) the range will be unlimited.
    void SetStripRange(double range);
    
    /// Limit the number of entries in the strip chart.  Upon a Fill()
    /// this will remove later entries until the limit is satisfied.
    /// Set to 0 (default) the range will be unlimited.
    void SetMaxStripEntries(int max);

    /// Set Y axis on Graph
    void SetGraphYTitle(const char* title = "");

    /// Draw the strip hist onto the current pad.  The option is
    /// for the strip.
    void Draw(Option_t* option="");

    /// Draw ONLY the strip graph.  The option is for the strip.
    void DrawStrip(Option_t* option="");

    /// Draw ONLY the strip hist.  The option is for the strip.
    void DrawHist(Option_t* option="");
      
    /// Reset histogram and graph
    void Reset();

    /// Get Minimum Y value of Graph
    double GetMin();
    
    /// Get Maximum Y value of Graph
    double GetMax();

    
    //ClassDef(StripHist,1)

};


#endif  // STRIPHIST_H
