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