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);
98  HistoData *addHistoData(std::string Name, int PlotType) { return addHistoData(Name, Name, 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 *);
112  void makeSummary(std::string Name);
113  void makeSummaryPlot(std::string Name);
114  void makeSummaryHTML(std::string Name);
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
int getSummaryRightMargin() const
PlotCompareUtility(std::string Reference, std::string New, std::string NewBasePath, std::string NewPrefix="", std::string RefBasePath="", std::string RefPrefix="")
int getPlotsLeftMargin() const
void setProjectionsTopMargin(int Pixels)
void renormalize(TH1 *, TH1 *)
void setSummaryRightMargin(int Pixels)
int getProjectionsHeight() const
void setProjectionsBottomMargin(int Pixels)
void setProjectionsBarsThickness(int Pixels)
PlotType
void setProjectionsHeight(int Pixels)
int getSummaryTopMargin() const
int getProjectionsBottomMargin() const
void setSummaryLeftMargin(int Pixels)
bool getFinalResult() const
void setSummaryHeight(int Pixels)
double getChi2Threshold() const
std::vector< HistoData > * getProjectionsY(HistoData *HD)
int getPlotsRightMargin() const
std::vector< HistoData > * getHistos()
void setPlotsWidth(int Pixels)
int getSummaryHeight() const
void setProjectionsLeftMargin(int Pixels)
HistoData * addHistoData(std::string Name, int PlotType)
void makePlots(HistoData *)
void setSummaryWidth(int Pixels)
int getSummaryBarsThickness() const
void makeHTML(HistoData *)
void setProjectionsRightMargin(int Pixels)
void setSummaryTopMargin(int Pixels)
int getNumHistos() const
std::vector< HistoData > histos
int getProjectionsBarsThickness() const
int getProjectionsTopMargin() const
std::map< HistoData *, std::vector< HistoData > > projectionsY
void setPlotsRightMargin(int Pixels)
int getSummaryLeftMargin() const
bool isValid() const
int getSummaryWidth() const
double getThreshold() const
int getPlotsHeight() const
std::map< HistoData *, std::vector< HistoData > > projectionsX
virtual ~PlotCompareUtility()
void setPlotsBottomMargin(int Pixels)
void clearProjectionsY(HistoData *Parent)
void setPlotsTopMargin(int Pixels)
HistoData * addProjectionXData(HistoData *Parent, std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto)
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 compare(HistoData *)
int getPlotsTopMargin() const
int getPlotsWidth() const
void setProjectionsiWidth(int Pixels)
int getPlotsBottomMargin() const
double getKSThreshold() const
int getProjectionsLeftMargin() const
int getProjectionsWidth() const
void makeSummary(std::string Name)
void makeSummaryHTML(std::string Name)
int getProjectionsRightMargin() const
void setChi2Threshold(double Threshold)
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)
int getSummaryBottomMargin() const
HistoData * addHistoData(std::string NewName, std::string RefName, int PlotType)