00001 #ifndef PLOT_COMPARE_UTILITY__H
00002 #define PLOT_COMPARE_UTILITY__H
00003
00004 #include "HistoData.h"
00005
00006 #include <vector>
00007 #include <map>
00008 #include <string>
00009
00010 #ifndef HTML1D
00011 #define HTML1D
00012 #endif
00013
00014 class TFile;
00015 class TH1;
00016
00017 class PlotCompareUtility {
00018 public:
00019
00020
00021
00022 PlotCompareUtility(std::string Reference, std::string New, std::string NewBasePath,
00023 std::string NewPrefix = "", std::string RefBasePath = "", std::string RefPrefix = "");
00024 virtual ~PlotCompareUtility();
00025
00026
00027 enum Axis { axisX, axisY };
00028
00029
00030 std::vector<HistoData> *getHistos() { return &histos; }
00031 std::vector<HistoData> *getProjectionsX(HistoData *HD) { return &projectionsX[HD]; }
00032 std::vector<HistoData> *getProjectionsY(HistoData *HD) { return &projectionsY[HD]; }
00033 int getNumHistos() const { return histos.size(); }
00034
00035
00036
00037
00038 double getKSThreshold() const { return ksThreshold; }
00039 double getChi2Threshold() const { return chi2Threshold; }
00040 double getThreshold() const;
00041 bool getFinalResult() const { return finalResult; }
00042
00043
00044 int getSummaryWidth() const { return summaryWidth; }
00045 int getSummaryHeight() const { return summaryHeight; }
00046 int getSummaryBarsThickness() const { return summaryBarsThickness; }
00047 int getSummaryTopMargin() const { return summaryTopMargin; }
00048 int getSummaryLeftMargin() const { return summaryLeftMargin; }
00049 int getSummaryRightMargin() const { return summaryRightMargin; }
00050 int getSummaryBottomMargin() const { return summaryBottomMargin; }
00051 int getProjectionsHeight() const { return projectionsHeight; }
00052 int getProjectionsWidth() const { return projectionsWidth; }
00053 int getProjectionsBarsThickness() const { return projectionsBarsThickness; }
00054 int getProjectionsTopMargin() const { return projectionsTopMargin; }
00055 int getProjectionsLeftMargin() const { return projectionsLeftMargin; }
00056 int getProjectionsRightMargin() const { return projectionsRightMargin; }
00057 int getProjectionsBottomMargin() const { return projectionsBottomMargin; }
00058 int getPlotsHeight() const { return plotsHeight; }
00059 int getPlotsWidth() const { return plotsWidth; }
00060 int getPlotsTopMargin() const { return plotsTopMargin; }
00061 int getPlotsLeftMargin() const { return plotsLeftMargin; }
00062 int getPlotsRightMargin() const { return plotsRightMargin; }
00063 int getPlotsBottomMargin() const { return plotsBottomMargin; }
00064
00065
00066 void setKSThreshold(double Threshold) { ksThreshold = Threshold; }
00067 void setChi2Threshold(double Threshold) { chi2Threshold = Threshold; }
00068
00069
00070 void setSummaryWidth(int Pixels) { summaryWidth = Pixels; }
00071 void setSummaryHeight(int Pixels) { summaryHeight = Pixels; }
00072 void setSummaryBarsThickness(int Pixels) { summaryBarsThickness = Pixels; }
00073 void setSummaryTopMargin(int Pixels) { summaryTopMargin = Pixels; }
00074 void setSummaryLeftMargin(int Pixels) { summaryLeftMargin = Pixels; }
00075 void setSummaryRightMargin(int Pixels) { summaryRightMargin = Pixels; }
00076 void setSummaryBottomMargin(int Pixels) { summaryBottomMargin = Pixels; }
00077 void setProjectionsiWidth(int Pixels) { projectionsWidth = Pixels; }
00078 void setProjectionsHeight(int Pixels) { projectionsHeight = Pixels; }
00079 void setProjectionsBarsThickness(int Pixels) { projectionsBarsThickness = Pixels; }
00080 void setProjectionsTopMargin(int Pixels) { projectionsTopMargin = Pixels; }
00081 void setProjectionsLeftMargin(int Pixels) { projectionsLeftMargin = Pixels; }
00082 void setProjectionsRightMargin(int Pixels) { projectionsRightMargin = Pixels; }
00083 void setProjectionsBottomMargin(int Pixels) { projectionsBottomMargin = Pixels; }
00084 void setPlotsHeight(int Pixels) { plotsHeight = Pixels; }
00085 void setPlotsWidth(int Pixels) { plotsWidth = Pixels; }
00086 void setPlotsTopMargin(int Pixels) { plotsTopMargin = Pixels; }
00087 void setPlotsLeftMargin(int Pixels) { plotsLeftMargin = Pixels; }
00088 void setPlotsRightMargin(int Pixels) { plotsRightMargin = Pixels; }
00089 void setPlotsBottomMargin(int Pixels) { plotsBottomMargin = Pixels; }
00090
00091
00092 HistoData *addHistoData(std::string NewName, std::string RefName, int PlotType);
00093 HistoData *addHistoData(std::string Name, int PlotType) { return addHistoData(Name,Name,PlotType); }
00094 HistoData *addProjectionXData(HistoData *Parent, std::string Name, int PlotType, int Bin, TH1* NewHisto, TH1* RefHisto);
00095 HistoData *addProjectionYData(HistoData *Parent, std::string Name, int PlotType, int Bin, TH1* NewHisto, TH1* RefHisto);
00096 void clearHistos() { histos.clear(); }
00097 void clearProjectionsX(HistoData *Parent) { projectionsX[Parent].clear(); }
00098 void clearProjectionsY(HistoData *Parent) { projectionsY[Parent].clear(); }
00099
00100
00101 bool compare(HistoData *);
00102 void makeDefaultPlots();
00103 void makePlots(HistoData *);
00104 void makeHTML(HistoData *);
00105 void makeSummary(std::string Name);
00106 void makeSummaryPlot(std::string Name);
00107 void makeSummaryHTML(std::string Name);
00108
00109
00110
00111 bool isValid() const;
00112 void dump();
00113
00114 private:
00115
00116
00117 std::vector<HistoData> histos;
00118 std::map<HistoData *,std::vector<HistoData> > projectionsX;
00119 std::map<HistoData *,std::vector<HistoData> > projectionsY;
00120
00121
00122 TFile *refFile;
00123 TFile *newFile;
00124 std::string newBasePath;
00125 std::string newPrefix;
00126 std::string refBasePath;
00127 std::string refPrefix;
00128
00129
00130 double ksThreshold;
00131 double chi2Threshold;
00132
00133
00134 template <int PlotType> bool compare(HistoData *);
00135 template <int PlotType> void makePlots(HistoData *);
00136 template <int PlotType> void makeHTML(HistoData *);
00137 void centerRebin(TH1 *, TH1 *);
00138 void renormalize(TH1 *, TH1 *);
00139
00140
00141 int summaryWidth;
00142 int summaryHeight;
00143 int summaryBarsThickness;
00144 int summaryTopMargin;
00145 int summaryLeftMargin;
00146 int summaryRightMargin;
00147 int summaryBottomMargin;
00148
00149
00150 int projectionsWidth;
00151 int projectionsHeight;
00152 int projectionsBarsThickness;
00153 int projectionsTopMargin;
00154 int projectionsLeftMargin;
00155 int projectionsRightMargin;
00156 int projectionsBottomMargin;
00157
00158
00159 int plotsWidth;
00160 int plotsHeight;
00161 int plotsTopMargin;
00162 int plotsLeftMargin;
00163 int plotsRightMargin;
00164 int plotsBottomMargin;
00165
00166
00167 bool finalResult;
00168
00169 };
00170
00171 #endif // PLOT_COMPARE_UTILITY__H