CMS 3D CMS Logo

PlotCompareUtility.h

Go to the documentation of this file.
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   // BasePath = the path to data in the DQM root file (eg., "DQMData/METTask/ECAL/data")
00021   // Prefix = the prefix common to all histograms in area (eg., "METTask_" or "")
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   // Axis Conventions (For Specifying Profiles, Projections, etc.)
00027   enum Axis { axisX, axisY /*, axisZ -- maybe later? */ };
00028 
00029   // Getters for HistoData Information
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   //int getNumProjectionsX(HistoData *HD) const { return projectionsX[HD].size(); }
00035   //int getNumProjectionsY(HistoData *HD) const { return projectionsY[HD].size(); }
00036 
00037   // Getters for Statistical Comparisons
00038   double getKSThreshold() const { return ksThreshold; }
00039   double getChi2Threshold() const { return chi2Threshold; }
00040   double getThreshold() const; // the lowest non-zero test threshold
00041   bool getFinalResult() const { return finalResult; }
00042 
00043   // Getters for Drawing Options
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   // Setters for Statistical Comparisons
00066   void setKSThreshold(double Threshold) { ksThreshold = Threshold; }
00067   void setChi2Threshold(double Threshold) { chi2Threshold = Threshold; }
00068 
00069   // Setters for Drawing Options
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   // Add HistoData Objects for Comparison
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   // Misc. Utilities
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   //void makeProjectionsSummary();
00109   //void makeProjectionsSummaryPlots();
00110   //void makeProjectionsSummaryHTML();
00111   bool isValid() const;
00112   void dump();
00113 
00114 private:
00115 
00116   // data holders for histogram types
00117   std::vector<HistoData> histos;
00118   std::map<HistoData *,std::vector<HistoData> > projectionsX;
00119   std::map<HistoData *,std::vector<HistoData> > projectionsY;
00120 
00121   // file pointers and file organization
00122   TFile *refFile;
00123   TFile *newFile;
00124   std::string newBasePath;
00125   std::string newPrefix;
00126   std::string refBasePath;
00127   std::string refPrefix;
00128 
00129   // statistical thresholds
00130   double ksThreshold;
00131   double chi2Threshold;
00132 
00133   // private (implementation/helper) functions
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   // summary settings
00141   int summaryWidth; // user defined
00142   int summaryHeight; // set by plotter
00143   int summaryBarsThickness;
00144   int summaryTopMargin;
00145   int summaryLeftMargin;
00146   int summaryRightMargin;
00147   int summaryBottomMargin;
00148 
00149   // 2d projections summary settings
00150   int projectionsWidth; // set by plotter
00151   int projectionsHeight; // user defined
00152   int projectionsBarsThickness;
00153   int projectionsTopMargin;
00154   int projectionsLeftMargin;
00155   int projectionsRightMargin;
00156   int projectionsBottomMargin;
00157 
00158   // 1d distribution plots settings
00159   int plotsWidth; // user defined
00160   int plotsHeight; // user defined
00161   int plotsTopMargin;
00162   int plotsLeftMargin;
00163   int plotsRightMargin;
00164   int plotsBottomMargin;
00165 
00166   // true if all run tests pass, false if any fail
00167   bool finalResult;
00168 
00169 };
00170 
00171 #endif // PLOT_COMPARE_UTILITY__H

Generated on Tue Jun 9 17:49:36 2009 for CMSSW by  doxygen 1.5.4