Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:13

0001 #ifndef HISTO_DATA__H
0002 #define HISTO_DATA__H
0003 
0004 #include <TFile.h>
0005 #include <TH1.h>
0006 #include <cstring>
0007 #include <string>
0008 
0009 class HistoData {
0010 public:
0011   HistoData(
0012       std::string Name, int PlotType, int Bin, std::string NewPath, TFile *NewFile, std::string RefPath, TFile *RefFile);
0013   HistoData(std::string Name, int PlotType, int Bin, TH1 *NewHisto, TH1 *RefHisto);
0014   virtual ~HistoData() {}
0015 
0016   // Get General Information
0017   std::string getName() const { return name; }
0018   // PlotType getType() const { return type; }
0019   int getType() const { return type; }
0020   int getBin() const { return bin; }
0021   TH1 *getNewHisto() const { return newHisto; }
0022   TH1 *getRefHisto() const { return refHisto; }
0023   std::string getResultImage() const { return resultImage; }
0024   std::string getResultTarget() const { return resultTarget; }
0025 
0026   // Projections/Rebinning Getters
0027   bool getDoDrawErrorBars() const { return doDrawErrorBars; }
0028   bool getDoAllow1DRebinning() const { return doAllow1DRebinning; }
0029   bool getDoAllow2DRebinningX() const { return doAllow2DRebinningX; }
0030   bool getDoAllow2DRebinningY() const { return doAllow2DRebinningY; }
0031   bool getDoProjectionsX() const { return doProjectionsX; }
0032   bool getDoProjectionsY() const { return doProjectionsY; }
0033   int getMaxProjectionsX() const { return maxProjectionsX; }
0034   int getMaxProjectionsY() const { return maxProjectionsY; }
0035 
0036   // Get Test Results
0037   bool comparisonSuccess() const { return lowScore != 10 && !isEmpty; }
0038   float getKSScore() const { return ksScore; }
0039   float getChi2Score() const { return chi2Score; }
0040   float getLowScore() const { return lowScore; }
0041   float getHighScore() const { return highScore; }
0042   bool getResult() const { return result; }
0043   bool getIsEmpty() const { return isEmpty; }
0044 
0045   // Get Visual Attributes
0046   bool getLineUseFillColor() const { return lineUseFillColor; }
0047   int getSolidLineColor() const { return lineUseFillColor ? solidFillColor : solidLineColor; }
0048   int getSolidFillColor() const { return solidFillColor; }
0049   int getSolidFillStyle() const { return solidFillStyle; }
0050   int getShadedLineColor() const { return lineUseFillColor ? shadedFillColor : shadedLineColor; }
0051   int getShadedFillColor() const { return shadedFillColor; }
0052   int getShadedFillStyle() const { return shadedFillStyle; }
0053 
0054   // Set General Information
0055   void setName(std::string Name) { name = Name; }
0056   // void setType(PlotType Type) { type = Type; }
0057   void setType(int PlotType) { type = PlotType; }
0058   void setBin(int Bin) { bin = Bin; }
0059   void setResultImage(std::string Image) { resultImage = Image; }
0060   void setResultTarget(std::string Target) { resultTarget = Target; }
0061 
0062   // Projections/Rebinning Setters
0063   void setDoDrawErrorBars(bool Toggle) { doDrawErrorBars = Toggle; }
0064   void setDoAllow1DRebinning(bool Toggle) { doAllow1DRebinning = Toggle; }
0065   void setDoAllow2DRebinningX(bool Toggle) { doAllow2DRebinningX = Toggle; }
0066   void setDoAllow2DRebinningY(bool Toggle) { doAllow2DRebinningY = Toggle; }
0067   void setDoProjectionsX(bool Toggle) { doProjectionsX = Toggle; }
0068   void setDoProjectionsY(bool Toggle) { doProjectionsY = Toggle; }
0069   void setMaxProjections(int Num) {
0070     maxProjectionsX = Num;
0071     maxProjectionsY = Num;
0072   }
0073   void setMaxProjectionsX(bool Num) { maxProjectionsX = Num; }
0074   void setMaxProjectionsY(bool Num) { maxProjectionsY = Num; }
0075 
0076   // Set Test Results
0077   void setKSScore(float Score) { ksScore = Score; }
0078   void setChi2Score(float Score) { chi2Score = Score; }
0079   void setLowScore(float Score) { lowScore = Score; }
0080   void setHighScore(float Score) { highScore = Score; }
0081   void setResult(bool Result);  // also sets display colors
0082   void setIsEmpty(bool Toggle) { isEmpty = Toggle; }
0083 
0084   // Set Visual Attributes
0085   void setLineUseFillColor(bool Toggle) { lineUseFillColor = Toggle; }
0086   void setSolidLineColor(int Color) { solidLineColor = Color; }
0087   void setSolidFillColor(int Color) { solidFillColor = Color; }
0088   void setSolidFillStyle(int Style) { solidFillStyle = Style; }
0089   void setShadedLineColor(int Color) { shadedLineColor = Color; }
0090   void setShadedFillColor(int Color) { shadedFillColor = Color; }
0091   void setShadedFillStyle(int Style) { shadedFillStyle = Style; }
0092 
0093   // Misc Functions
0094   void drawResult(TH1 *Summary, bool Vertical = true, bool SetLabels = false);
0095   void clear() {
0096     newHisto->Clear();
0097     refHisto->Clear();
0098   };
0099   inline void dump();
0100 
0101 private:
0102   // Misc. Data
0103   std::string name;
0104   // PlotType type;
0105   int type;
0106   int bin;
0107   TH1 *newHisto;
0108   TH1 *refHisto;
0109   std::string resultImage;
0110   std::string resultTarget;
0111   bool doAllow1DRebinning;
0112   bool doDrawErrorBars;
0113 
0114   // 2D data members
0115   bool doAllow2DRebinningX;
0116   bool doAllow2DRebinningY;
0117   int maxProjectionsX;
0118   int maxProjectionsY;
0119   bool doProjectionsX;
0120   bool doProjectionsY;
0121 
0122   // Scores/Results
0123   float ksScore;
0124   float chi2Score;
0125   float lowScore;
0126   float highScore;
0127   bool result;
0128   bool isEmpty;
0129 
0130   // Attributes of Results Display
0131   int passColor, failColor, errorColor;
0132   int solidLineColor, solidFillColor, solidFillStyle;
0133   int shadedLineColor, shadedFillColor, shadedFillStyle;
0134   bool lineUseFillColor;
0135 
0136   // Implementation Function
0137   void initialize();
0138 };
0139 
0140 #endif  // HISTO_DATA__H