Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:52

0001 #ifndef PLOT_COMPARE_UTILITY__H
0002 #define PLOT_COMPARE_UTILITY__H
0003 
0004 #include "HistoData.h"
0005 
0006 #include <map>
0007 #include <string>
0008 #include <vector>
0009 
0010 #ifndef HTML1D
0011 #define HTML1D
0012 #endif
0013 
0014 class TFile;
0015 class TH1;
0016 
0017 class PlotCompareUtility {
0018 public:
0019   // BasePath = the path to data in the DQM root file (eg.,
0020   // "DQMData/METTask/ECAL/data") Prefix = the prefix common to all histograms
0021   // in area (eg., "METTask_" or "")
0022   PlotCompareUtility(std::string Reference,
0023                      std::string New,
0024                      std::string NewBasePath,
0025                      std::string NewPrefix = "",
0026                      std::string RefBasePath = "",
0027                      std::string RefPrefix = "");
0028   virtual ~PlotCompareUtility();
0029 
0030   // Axis Conventions (For Specifying Profiles, Projections, etc.)
0031   enum Axis { axisX, axisY /*, axisZ -- maybe later? */ };
0032 
0033   // Getters for HistoData Information
0034   std::vector<HistoData> *getHistos() { return &histos; }
0035   std::vector<HistoData> *getProjectionsX(HistoData *HD) { return &projectionsX[HD]; }
0036   std::vector<HistoData> *getProjectionsY(HistoData *HD) { return &projectionsY[HD]; }
0037   int getNumHistos() const { return histos.size(); }
0038   // int getNumProjectionsX(HistoData *HD) const { return
0039   // projectionsX[HD].size(); } int getNumProjectionsY(HistoData *HD) const {
0040   // return projectionsY[HD].size(); }
0041 
0042   // Getters for Statistical Comparisons
0043   double getKSThreshold() const { return ksThreshold; }
0044   double getChi2Threshold() const { return chi2Threshold; }
0045   double getThreshold() const;  // the lowest non-zero test threshold
0046   bool getFinalResult() const { return finalResult; }
0047 
0048   // Getters for Drawing Options
0049   int getSummaryWidth() const { return summaryWidth; }
0050   int getSummaryHeight() const { return summaryHeight; }
0051   int getSummaryBarsThickness() const { return summaryBarsThickness; }
0052   int getSummaryTopMargin() const { return summaryTopMargin; }
0053   int getSummaryLeftMargin() const { return summaryLeftMargin; }
0054   int getSummaryRightMargin() const { return summaryRightMargin; }
0055   int getSummaryBottomMargin() const { return summaryBottomMargin; }
0056   int getProjectionsHeight() const { return projectionsHeight; }
0057   int getProjectionsWidth() const { return projectionsWidth; }
0058   int getProjectionsBarsThickness() const { return projectionsBarsThickness; }
0059   int getProjectionsTopMargin() const { return projectionsTopMargin; }
0060   int getProjectionsLeftMargin() const { return projectionsLeftMargin; }
0061   int getProjectionsRightMargin() const { return projectionsRightMargin; }
0062   int getProjectionsBottomMargin() const { return projectionsBottomMargin; }
0063   int getPlotsHeight() const { return plotsHeight; }
0064   int getPlotsWidth() const { return plotsWidth; }
0065   int getPlotsTopMargin() const { return plotsTopMargin; }
0066   int getPlotsLeftMargin() const { return plotsLeftMargin; }
0067   int getPlotsRightMargin() const { return plotsRightMargin; }
0068   int getPlotsBottomMargin() const { return plotsBottomMargin; }
0069 
0070   // Setters for Statistical Comparisons
0071   void setKSThreshold(double Threshold) { ksThreshold = Threshold; }
0072   void setChi2Threshold(double Threshold) { chi2Threshold = Threshold; }
0073 
0074   // Setters for Drawing Options
0075   void setSummaryWidth(int Pixels) { summaryWidth = Pixels; }
0076   void setSummaryHeight(int Pixels) { summaryHeight = Pixels; }
0077   void setSummaryBarsThickness(int Pixels) { summaryBarsThickness = Pixels; }
0078   void setSummaryTopMargin(int Pixels) { summaryTopMargin = Pixels; }
0079   void setSummaryLeftMargin(int Pixels) { summaryLeftMargin = Pixels; }
0080   void setSummaryRightMargin(int Pixels) { summaryRightMargin = Pixels; }
0081   void setSummaryBottomMargin(int Pixels) { summaryBottomMargin = Pixels; }
0082   void setProjectionsiWidth(int Pixels) { projectionsWidth = Pixels; }
0083   void setProjectionsHeight(int Pixels) { projectionsHeight = Pixels; }
0084   void setProjectionsBarsThickness(int Pixels) { projectionsBarsThickness = Pixels; }
0085   void setProjectionsTopMargin(int Pixels) { projectionsTopMargin = Pixels; }
0086   void setProjectionsLeftMargin(int Pixels) { projectionsLeftMargin = Pixels; }
0087   void setProjectionsRightMargin(int Pixels) { projectionsRightMargin = Pixels; }
0088   void setProjectionsBottomMargin(int Pixels) { projectionsBottomMargin = Pixels; }
0089   void setPlotsHeight(int Pixels) { plotsHeight = Pixels; }
0090   void setPlotsWidth(int Pixels) { plotsWidth = Pixels; }
0091   void setPlotsTopMargin(int Pixels) { plotsTopMargin = Pixels; }
0092   void setPlotsLeftMargin(int Pixels) { plotsLeftMargin = Pixels; }
0093   void setPlotsRightMargin(int Pixels) { plotsRightMargin = Pixels; }
0094   void setPlotsBottomMargin(int Pixels) { plotsBottomMargin = Pixels; }
0095 
0096   // Add HistoData Objects for Comparison
0097   HistoData *addHistoData(std::string NewName, std::string RefName, int PlotType);
0098   HistoData *addHistoData(std::string Name, int PlotType) { return addHistoData(Name, Name, PlotType); }
0099   HistoData *addProjectionXData(
0100       HistoData *Parent, std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto);
0101   HistoData *addProjectionYData(
0102       HistoData *Parent, std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto);
0103   void clearHistos() { histos.clear(); }
0104   void clearProjectionsX(HistoData *Parent) { projectionsX[Parent].clear(); }
0105   void clearProjectionsY(HistoData *Parent) { projectionsY[Parent].clear(); }
0106 
0107   // Misc. Utilities
0108   bool compare(HistoData *);
0109   void makeDefaultPlots();
0110   void makePlots(HistoData *);
0111   void makeHTML(HistoData *);
0112   void makeSummary(std::string Name);
0113   void makeSummaryPlot(std::string Name);
0114   void makeSummaryHTML(std::string Name);
0115   // void makeProjectionsSummary();
0116   // void makeProjectionsSummaryPlots();
0117   // void makeProjectionsSummaryHTML();
0118   bool isValid() const;
0119   void dump();
0120 
0121 private:
0122   // data holders for histogram types
0123   std::vector<HistoData> histos;
0124   std::map<HistoData *, std::vector<HistoData>> projectionsX;
0125   std::map<HistoData *, std::vector<HistoData>> projectionsY;
0126 
0127   // file pointers and file organization
0128   TFile *refFile;
0129   TFile *newFile;
0130   std::string newBasePath;
0131   std::string newPrefix;
0132   std::string refBasePath;
0133   std::string refPrefix;
0134 
0135   // statistical thresholds
0136   double ksThreshold;
0137   double chi2Threshold;
0138 
0139   // private (implementation/helper) functions
0140   template <int PlotType>
0141   bool compare(HistoData *);
0142   template <int PlotType>
0143   void makePlots(HistoData *);
0144   template <int PlotType>
0145   void makeHTML(HistoData *);
0146   void centerRebin(TH1 *, TH1 *);
0147   void renormalize(TH1 *, TH1 *);
0148 
0149   // summary settings
0150   int summaryWidth;   // user defined
0151   int summaryHeight;  // set by plotter
0152   int summaryBarsThickness;
0153   int summaryTopMargin;
0154   int summaryLeftMargin;
0155   int summaryRightMargin;
0156   int summaryBottomMargin;
0157 
0158   // 2d projections summary settings
0159   int projectionsWidth;   // set by plotter
0160   int projectionsHeight;  // user defined
0161   int projectionsBarsThickness;
0162   int projectionsTopMargin;
0163   int projectionsLeftMargin;
0164   int projectionsRightMargin;
0165   int projectionsBottomMargin;
0166 
0167   // 1d distribution plots settings
0168   int plotsWidth;   // user defined
0169   int plotsHeight;  // user defined
0170   int plotsTopMargin;
0171   int plotsLeftMargin;
0172   int plotsRightMargin;
0173   int plotsBottomMargin;
0174 
0175   // true if all run tests pass, false if any fail
0176   bool finalResult;
0177 };
0178 
0179 #endif  // PLOT_COMPARE_UTILITY__H