Go to the documentation of this file.00001 #ifndef CompHist_h
00002 #define CompHist_h
00003
00004 #include <memory>
00005 #include <string>
00006 #include <vector>
00007 #include <sstream>
00008 #include <fstream>
00009 #include <iostream>
00010
00011 #include "Validation/RecoJets/interface/ConfigFile.h"
00012 #include "Validation/RecoJets/interface/RootSystem.h"
00013 #include "Validation/RecoJets/interface/RootHistograms.h"
00014
00015
00016 namespace HistStyle{
00017 static const int Line = 0;
00018 static const int Marker = 1;
00019 static const int Filled = 2;
00020 }
00021
00022 template <class T>
00023 void readVector(std::string s, std::vector<T>& vec)
00024 {
00025 std::stringstream stream( s );
00026 T buffer;
00027 while (!stream.eof()) {
00028 stream >> buffer;
00029 if(!stream.str().empty()){
00030 vec.push_back( buffer );
00031 }
00032 }
00033 }
00034
00035 class CompHist{
00036
00037 public:
00038
00039 enum RootOutput{ kFirstOnly, kLastOnly, kAll};
00040 enum HistFilter{ kBeginsWith, kEndsWith, kContains};
00041
00042 public:
00043
00044 CompHist():verbose_(false){};
00045 CompHist(bool verbose):verbose_(verbose){};
00046
00047 virtual ~CompHist(){};
00048 virtual void readConfig( std::string )=0;
00049
00050 std::string writeAs(){return writeAs_;}
00051 void setVerbose(bool val) {verbose_=val; return;}
00052 bool verbose() {return verbose_;}
00053 void loadHistograms(std::vector<std::string>&, std::vector<TObjArray>&);
00054 void loadHistograms();
00055 void drawPs();
00056 void drawEps();
00057 void draw(TCanvas&, TLegend&, int&, int&);
00058 bool histFilter(TString&, std::vector<std::string>&);
00059 bool histFilter(TString&, std::vector<std::string>&, CompHist::HistFilter);
00060 void writeOutput(CompHist::RootOutput);
00061 void writeOutput(){writeOutput(kAll);};
00062
00063 protected:
00064
00065
00066 void configBlockIO(ConfigFile&);
00067 void configBlockHist(ConfigFile&);
00068 void readLabels(std::string, std::vector<std::string>&);
00069 bool isOutputRequested(){return rootOutDir_.size()>1;};
00070 void readHistogramList();
00071
00072
00073 std::string legend(int);
00074
00075
00076 void setLegendStyle(TLegend&);
00077 void setCanvasStyle(TCanvas&);
00078 void setCanvLog(TCanvas&, int);
00079 void setCanvGrid(TCanvas&, int);
00080 void setAxesStyle(TH1&, const char*, const char*);
00081 void setHistStyles(TH1F&, int, int);
00082 void setHistLabels(TH1F&, int);
00083 void setHistScale(TH1F&, int);
00084 void setHistMax(TH1F&, int);
00085 void setHistMin(TH1F&, int);
00086 void setLineWidth (TH1F&, int);
00087 void setLineStyle(TH1F&, int);
00088 void setLineColor(TH1F&, int);
00089 void setFillStyle(TH1F&, int);
00090 void setFillColor(TH1F&, int);
00091 void setMarkerStyle(TH1F&, int);
00092 void setMarkerColor(TH1F&, int);
00093 void setMarkerSize(TH1F&, int);
00094 double findMaximum(int);
00095
00096 protected:
00097
00098
00099
00100
00101
00102
00103 std::string filterOpt_;
00104 std::string histFile_;
00105 std::vector<std::string> dirNameList_;
00106 std::vector<std::string> fileNameList_;
00107 std::vector<std::string> plotFilterList_;
00108 std::vector<std::string> histFilterList_;
00109 std::string output_;
00110 std::string rootOutDir_;
00111 std::string writeTo_, writeAs_;
00112 std::vector<std::string> outputLabelList_;
00113
00114
00115 std::vector<short int> gridX_, gridY_;
00116 std::vector<short int> logX_, logY_;
00117 std::vector<short int> histStyle_;
00118 std::vector<short int> histColor_;
00119 std::vector<short int> commonStyle_;
00120 std::vector<short int> commonWidth_;
00121 std::vector<short int> markerStyle_;
00122 std::vector<double> markerSize_;
00123 std::vector<std::string> xAxes_, yAxes_;
00124 std::vector<double> min_, max_;
00125 std::vector<double> scale_;
00126 std::vector<short int> errors_;
00127
00128
00129 double legXLeft_, legXRight_;
00130 double legYLower_, legYUpper_;
00131 std::vector<std::string> legendEntries_;
00132
00133
00134
00135
00136 bool verbose_;
00137 std::vector<TFile*> fileList_;
00138 std::vector<TObjArray> sampleList_;
00139 std::vector<std::string> histList_;
00140 };
00141 #endif