CMS 3D CMS Logo

PlotCompareUtility.h
Go to the documentation of this file.
1 #ifndef PLOT_COMPARE_UTILITY__H
2 #define PLOT_COMPARE_UTILITY__H
3 
4 #include "HistoData.h"
5 
6 #include <map>
7 #include <string>
8 #include <vector>
9 
10 #ifndef HTML1D
11 #define HTML1D
12 #endif
13 
14 class TFile;
15 class TH1;
16 
18 public:
19  // BasePath = the path to data in the DQM root file (eg.,
20  // "DQMData/METTask/ECAL/data") Prefix = the prefix common to all histograms
21  // in area (eg., "METTask_" or "")
23  std::string New,
24  std::string NewBasePath,
25  std::string NewPrefix = "",
26  std::string RefBasePath = "",
27  std::string RefPrefix = "");
28  virtual ~PlotCompareUtility();
29 
30  // Axis Conventions (For Specifying Profiles, Projections, etc.)
31  enum Axis { axisX, axisY /*, axisZ -- maybe later? */ };
32 
33  // Getters for HistoData Information
34  std::vector<HistoData> *getHistos() { return &histos; }
35  std::vector<HistoData> *getProjectionsX(HistoData *HD) { return &projectionsX[HD]; }
36  std::vector<HistoData> *getProjectionsY(HistoData *HD) { return &projectionsY[HD]; }
37  int getNumHistos() const { return histos.size(); }
38  // int getNumProjectionsX(HistoData *HD) const { return
39  // projectionsX[HD].size(); } int getNumProjectionsY(HistoData *HD) const {
40  // return projectionsY[HD].size(); }
41 
42  // Getters for Statistical Comparisons
43  double getKSThreshold() const { return ksThreshold; }
44  double getChi2Threshold() const { return chi2Threshold; }
45  double getThreshold() const; // the lowest non-zero test threshold
46  bool getFinalResult() const { return finalResult; }
47 
48  // Getters for Drawing Options
49  int getSummaryWidth() const { return summaryWidth; }
50  int getSummaryHeight() const { return summaryHeight; }
52  int getSummaryTopMargin() const { return summaryTopMargin; }
53  int getSummaryLeftMargin() const { return summaryLeftMargin; }
54  int getSummaryRightMargin() const { return summaryRightMargin; }
56  int getProjectionsHeight() const { return projectionsHeight; }
57  int getProjectionsWidth() const { return projectionsWidth; }
63  int getPlotsHeight() const { return plotsHeight; }
64  int getPlotsWidth() const { return plotsWidth; }
65  int getPlotsTopMargin() const { return plotsTopMargin; }
66  int getPlotsLeftMargin() const { return plotsLeftMargin; }
67  int getPlotsRightMargin() const { return plotsRightMargin; }
68  int getPlotsBottomMargin() const { return plotsBottomMargin; }
69 
70  // Setters for Statistical Comparisons
73 
74  // Setters for Drawing Options
75  void setSummaryWidth(int Pixels) { summaryWidth = Pixels; }
76  void setSummaryHeight(int Pixels) { summaryHeight = Pixels; }
77  void setSummaryBarsThickness(int Pixels) { summaryBarsThickness = Pixels; }
78  void setSummaryTopMargin(int Pixels) { summaryTopMargin = Pixels; }
79  void setSummaryLeftMargin(int Pixels) { summaryLeftMargin = Pixels; }
80  void setSummaryRightMargin(int Pixels) { summaryRightMargin = Pixels; }
81  void setSummaryBottomMargin(int Pixels) { summaryBottomMargin = Pixels; }
82  void setProjectionsiWidth(int Pixels) { projectionsWidth = Pixels; }
83  void setProjectionsHeight(int Pixels) { projectionsHeight = Pixels; }
85  void setProjectionsTopMargin(int Pixels) { projectionsTopMargin = Pixels; }
86  void setProjectionsLeftMargin(int Pixels) { projectionsLeftMargin = Pixels; }
87  void setProjectionsRightMargin(int Pixels) { projectionsRightMargin = Pixels; }
88  void setProjectionsBottomMargin(int Pixels) { projectionsBottomMargin = Pixels; }
89  void setPlotsHeight(int Pixels) { plotsHeight = Pixels; }
90  void setPlotsWidth(int Pixels) { plotsWidth = Pixels; }
91  void setPlotsTopMargin(int Pixels) { plotsTopMargin = Pixels; }
92  void setPlotsLeftMargin(int Pixels) { plotsLeftMargin = Pixels; }
93  void setPlotsRightMargin(int Pixels) { plotsRightMargin = Pixels; }
94  void setPlotsBottomMargin(int Pixels) { plotsBottomMargin = Pixels; }
95 
96  // Add HistoData Objects for Comparison
97  HistoData *addHistoData(std::string NewName, std::string RefName, int PlotType);
100  HistoData *Parent, std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto);
102  HistoData *Parent, std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto);
103  void clearHistos() { histos.clear(); }
104  void clearProjectionsX(HistoData *Parent) { projectionsX[Parent].clear(); }
105  void clearProjectionsY(HistoData *Parent) { projectionsY[Parent].clear(); }
106 
107  // Misc. Utilities
108  bool compare(HistoData *);
109  void makeDefaultPlots();
110  void makePlots(HistoData *);
111  void makeHTML(HistoData *);
115  // void makeProjectionsSummary();
116  // void makeProjectionsSummaryPlots();
117  // void makeProjectionsSummaryHTML();
118  bool isValid() const;
119  void dump();
120 
121 private:
122  // data holders for histogram types
123  std::vector<HistoData> histos;
124  std::map<HistoData *, std::vector<HistoData>> projectionsX;
125  std::map<HistoData *, std::vector<HistoData>> projectionsY;
126 
127  // file pointers and file organization
128  TFile *refFile;
129  TFile *newFile;
134 
135  // statistical thresholds
136  double ksThreshold;
138 
139  // private (implementation/helper) functions
140  template <int PlotType>
141  bool compare(HistoData *);
142  template <int PlotType>
143  void makePlots(HistoData *);
144  template <int PlotType>
145  void makeHTML(HistoData *);
146  void centerRebin(TH1 *, TH1 *);
147  void renormalize(TH1 *, TH1 *);
148 
149  // summary settings
150  int summaryWidth; // user defined
151  int summaryHeight; // set by plotter
157 
158  // 2d projections summary settings
159  int projectionsWidth; // set by plotter
160  int projectionsHeight; // user defined
166 
167  // 1d distribution plots settings
168  int plotsWidth; // user defined
169  int plotsHeight; // user defined
174 
175  // true if all run tests pass, false if any fail
177 };
178 
179 #endif // PLOT_COMPARE_UTILITY__H
PlotCompareUtility(std::string Reference, std::string New, std::string NewBasePath, std::string NewPrefix="", std::string RefBasePath="", std::string RefPrefix="")
int getSummaryLeftMargin() const
void setProjectionsTopMargin(int Pixels)
void renormalize(TH1 *, TH1 *)
void setSummaryRightMargin(int Pixels)
void setProjectionsBottomMargin(int Pixels)
void setProjectionsBarsThickness(int Pixels)
PlotType
void setProjectionsHeight(int Pixels)
int getPlotsBottomMargin() const
void setSummaryLeftMargin(int Pixels)
bool getFinalResult() const
int getSummaryBottomMargin() const
void setSummaryHeight(int Pixels)
std::vector< HistoData > * getProjectionsY(HistoData *HD)
std::vector< HistoData > * getHistos()
int getProjectionsBarsThickness() const
void setPlotsWidth(int Pixels)
void setProjectionsLeftMargin(int Pixels)
int getProjectionsHeight() const
double getChi2Threshold() const
HistoData * addHistoData(std::string Name, int PlotType)
void makePlots(HistoData *)
void setSummaryWidth(int Pixels)
int getPlotsRightMargin() const
void makeHTML(HistoData *)
void setProjectionsRightMargin(int Pixels)
int getSummaryTopMargin() const
void setSummaryTopMargin(int Pixels)
std::vector< HistoData > histos
int getProjectionsTopMargin() const
std::map< HistoData *, std::vector< HistoData > > projectionsY
void setPlotsRightMargin(int Pixels)
int getPlotsLeftMargin() const
int getSummaryHeight() const
std::map< HistoData *, std::vector< HistoData > > projectionsX
virtual ~PlotCompareUtility()
void setPlotsBottomMargin(int Pixels)
void clearProjectionsY(HistoData *Parent)
void setPlotsTopMargin(int Pixels)
int getPlotsTopMargin() const
HistoData * addProjectionXData(HistoData *Parent, std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto)
int getSummaryWidth() const
double getKSThreshold() const
int getSummaryBarsThickness() const
void setSummaryBottomMargin(int Pixels)
std::vector< HistoData > * getProjectionsX(HistoData *HD)
HistoData * addProjectionYData(HistoData *Parent, std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto)
bool isValid() const
bool compare(HistoData *)
int getPlotsHeight() const
int getSummaryRightMargin() const
int getProjectionsWidth() const
void setProjectionsiWidth(int Pixels)
double getThreshold() const
void makeSummary(std::string Name)
void makeSummaryHTML(std::string Name)
void setChi2Threshold(double Threshold)
int getProjectionsBottomMargin() const
void setSummaryBarsThickness(int Pixels)
void setPlotsHeight(int Pixels)
void setPlotsLeftMargin(int Pixels)
void setKSThreshold(double Threshold)
void makeSummaryPlot(std::string Name)
void centerRebin(TH1 *, TH1 *)
void clearProjectionsX(HistoData *Parent)
HistoData * addHistoData(std::string NewName, std::string RefName, int PlotType)
int getProjectionsRightMargin() const
int getProjectionsLeftMargin() const