//Renata Kopecna

#ifndef DESIGN_HH
#define DESIGN_HH

#include <TH1D.h>
#include <TH2D.h>
#include <TCanvas.h>
#include <TGraphErrors.h>
#include <TLine.h>
#include <TLatex.h>

//=========================================
//
//          Latex in plots
//
//=========================================

std::string latex_decay(bool DTF);
std::string latex_Kst_decay(bool DTF);
std::string MeVc();
std::string GeVc();
std::string GeVc_2();
std::string latex_pull();
std::string latex_angle(std::string angle, bool &is_ctl, bool &is_ctk, bool &is_phi);
const std::string LATEX_Q2  = "q^{2}";
const std::string LATEX_TL  = "#theta_{L}";
const std::string LATEX_CTL = "cos#theta_{L}";
const std::string LATEX_TK  = "#theta_{K}";
const std::string LATEX_CTK = "cos#theta_{K}";
const std::string LATEX_PHI = "#phi";
const std::string EVENTS_TAG = "Weighted candidates";

//Define the angles as chars, because ROOT
//Very not cool to have a function here, but also very not
//cool of ROOT to not accept strings and I cannot be bothered
const char *LATEX_Q2_CH();
const char *LATEX_TL_CH();
const char *LATEX_CTL_CH();
const char *LATEX_TK_CH();
const char *LATEX_CTK_CH();
const char *LATEX_PHI_CH();

const Color_t pWaveColor = kSpring;
const Color_t sWaveColor = kOrange;
const Color_t psInterferenceColor = kMagenta-10;


std::string q2_label(double low_q2, double high_q2);

//=========================================
//
//          General
//
//=========================================

void set_gStyle();
//Save several file types in one go
void saveTCanvas(TCanvas *c, std::string name, std::vector<std::string> types);
TLine *threeSigmaLine(double min, double max, bool plus);
TLine *oneSigmaLine(double min, double max, bool plus);

void plotAndSave(TH1D *hist, std::string canvasName, std::string targetPath, std::string plotType);
void plotAndSave(TH2D *hist, std::string canvasName, std::string targetPath, std::string plotType);
void plotAndSaveWithLine(TH1D* hist, TF1 *line,  std::string canvasName, std::string targetPath, std::string plotType);
TLatex *getPrettyTex(double TextFontSize, int TextAlign);

//=========================================
//
//  Angular correction plots
//
//=========================================
void plotAngular(TH1D *hist, TH1D *moments, bool write, std::string name, std::string appendix, std::string q2region, TLatex *tex, std::string folderName);
void plotAngular(TH1D *hist, TH1D *moments, bool write, std::string name, std::string appendix, std::string folderName);
void plotAngular(TH2D *hist, TH2D *moments, bool write, std::string name, std::string appendix, std::string q2region, TLatex *tex, std::string folderName);
void plotAngular(TH2D *hist, TH2D *moments, bool write, std::string name, std::string appendix, std::string folderName);
void plotAngularInOne(TCanvas *c, int whichC, TH1D *moments, TH1D *ub, TH1D *hist, TH1D* ml,  bool run_minuit, double q2min, double q2max, double y, bool cross);
void labelAngularScan(std::vector<int>scan_low, std::vector<int>scan_range,TH2D *hist);


//=========================================
//
//  Fit results plots
//
//=========================================
int design_pull_basic(TH1D *pull, Float_t textsize, double eff_pullHeight);
int design_pull(TH1D *pull, Color_t lineColor, Color_t fillColor, double eff_pullHeight, double pullFrameRange);
int design_pull(TGraphErrors *pull, Color_t lineColor, Color_t fillColor, double eff_pullHeight, double pullFrameRange);
//Draw shaded boxes at q2 regions of resonances
void drawResonances(TCanvas *c, double min, double max);
void drawResonances(TPad *c, double min, double max);

int design_YieldInQ2(int Run, TGraphErrors *graphSig, TGraphErrors *graphBkg, TGraphErrors *graphSignificance, TGraphErrors *CMS, bool fixRange, std::string savePath, std::vector<std::string> extensions);
int design_SignificanceInQ2(int Run, TGraphErrors *graphSignificance, TGraphErrors *CMS, bool fixRange, std::string savePath, std::vector<std::string> extensions);

#endif // DESIGN_HH
