/**
 * @file bu2kstarmumu_plotter.hh
 * @author Christoph Langenbruch, Renata Kopecna
 * @date 2009-03-18
 *
 */

#ifndef BU2KSTARMUMU_PLOTTER_H
#define BU2KSTARMUMU_PLOTTER_H

#include <plotter.hh>
#include <bu2kstarmumu_pdf.hh>

#include <TFile.h>
#include <TH1D.h>

namespace fcnc {

///class to plots the data and the fitted pdf, also plots the efficiencies 
class bu2kstarmumu_plotter: public plotter {//was derived from plotter
public: 
    ///constructor
    bu2kstarmumu_plotter(options* o);
    ///destructor
    ~bu2kstarmumu_plotter();
    ///plots all projections
    ///
    int design_pdf(TH1D *pdf, Color_t lineColor, Color_t fillColor, int fillStyle, double eff_pullHeight, bool doPull);

    int plot_data(bu2kstarmumu_pdf* prob, bu2kstarmumu_parameters* params, std::vector<event>* events, std::string prefix, std::string postfix="", bool signalregion=false);

    int plot_data(pdf* prob, parameters* params, std::vector<event>* ev, std::string index) {
        return plot_data(dynamic_cast<bu2kstarmumu_pdf*>(prob), dynamic_cast<bu2kstarmumu_parameters*>(params), ev, index);
    };
    void plot_pdfs(std::vector<bu2kstarmumu_pdf*> * probs, std::vector<bu2kstarmumu_parameters*> * params, std::string postfix, bool signalregion=false);
    void plot_added_pdfs(std::vector<bu2kstarmumu_pdf*> * probs, std::vector<bu2kstarmumu_parameters*> * params, std::vector<std::vector<event>*> * events, std::string prefix, std::string postfix, bool signalregion=false);
    void SetPulls(bool drawpulls=true);

    //Plot yields of sig and bkg in one go together with significance and the CMS measurement
    //Technically this could be in the scritps, but whatever at this point //TODO
    int plotYieldInQ2(bool fixRange, std::vector<fcnc::parameters*> fitParams[], std::vector<fcnc::pdf*> pdf[], int nPDFs, std::vector<UInt_t>nEvts[],  std::string prefix, std::string plotName);
private:
    ///pointer to options object
    options* opts;
    ///draw pull distribuions under plots?
    bool pulls;
    ///root output file
    TFile* output;
    ///tex sizes
    double texsizelarge=0.06, texsizesmall=0.04;
    ///plots the mass projection.
    void plot_m(bu2kstarmumu_pdf* prob, bu2kstarmumu_parameters* params, std::vector<event>* events, std::string prefix, std::string postfix, bool logarithmic=false, bool printC=false);
    void plot_mkpi(bu2kstarmumu_pdf* prob, bu2kstarmumu_parameters* params, std::vector<event>* events, std::string prefix, std::string postfix, bool signalregion=false, bool logarithmic=false, bool printC=false);
    ///plots a given angle projection
    void plot_angle(bu2kstarmumu_pdf* prob, bu2kstarmumu_parameters* params, std::vector<event>* events, std::string prefix, std::string postfix, bool signalregion=false, std::string angle = "ctl", bool printC=false);
    ///plots of pdfs added into one signal histogram!
    void plot_m_added_pdfs(std::vector<bu2kstarmumu_pdf*> * probs, std::vector<bu2kstarmumu_parameters*> * params, std::vector<std::vector<event>*> * events, std::string prefix, std::string postfix, bool logarithmic=false, bool printC=false);
    void plot_mkpi_added_pdfs(std::vector<bu2kstarmumu_pdf*> * probs, std::vector<bu2kstarmumu_parameters*> * params, std::vector<std::vector<event>*> * events, std::string prefix, std::string postfix, bool signalregion=false, bool logarithmic=false, bool printC=false);
    void plot_angle_added_pdfs(std::vector<bu2kstarmumu_pdf*> * probs, std::vector<bu2kstarmumu_parameters*> * params, std::vector<std::vector<event>*> * events, std::string prefix, std::string postfix,  bool signalregion=false, std::string angle = "ctl", bool printC=false);


};

}

#endif
