CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Validation/RecoParticleFlow/interface/Comparator.h

Go to the documentation of this file.
00001 #ifndef __Validation_RecoParticleFlow_Comparator__
00002 #define __Validation_RecoParticleFlow_Comparator__
00003 
00004 #include <math.h>
00005 
00006 #include <TLegend.h>
00007 #include <TFile.h>
00008 #include <TH1.h>
00009 #include <TF1.h>
00010 
00011 /* #include <string> */
00012 
00013 class Style;
00014 
00015 class Comparator {
00016 
00017 public:
00018 
00019   enum Mode {
00020     NORMAL,
00021     SCALE,
00022     RATIO,
00023     GRAPH,
00024     EFF
00025   };
00026 
00027   Comparator() : rebin_(-1), xMin_(0), xMax_(0), resetAxis_(false), 
00028                  s0_(0), s1_(0), legend_(0,0,1,1) {}
00029 
00030   Comparator( const char* file0,
00031               const char* dir0,
00032               const char* file1,
00033               const char* dir1 ) : 
00034     rebin_(-1), xMin_(0), xMax_(0), resetAxis_(false), 
00035     s0_(0), s1_(0), legend_(0,0,1,1) {
00036     
00037     SetDirs( file0, dir0, file1, dir1);
00038   }
00039   
00041   void SetDirs( const char* file0,
00042                 const char* dir0,
00043                 const char* file1,
00044                 const char* dir1  );
00045 
00046   // set the rebinning factor and the range
00047   void SetAxis( int rebin,
00048                 float xmin, 
00049                 float xmax) {
00050     rebin_ = rebin;
00051     xMin_ = xmin;
00052     xMax_ = xmax;
00053     resetAxis_ = true;
00054   }
00055   
00056   // set the rebinning factor, unset the range
00057   void SetAxis( int rebin ) {
00058     rebin_ = rebin;
00059     resetAxis_ = false;
00060   }
00061 
00062   // draws a Y projection of a slice along X
00063   void DrawSlice( const char* key, 
00064                   int binxmin, int binxmax, 
00065                   Mode mode );
00066 
00067   void DrawMeanSlice(const char* key, const int rebinFactor, Mode mode);
00068   void DrawSigmaSlice(const char* key, const int rebinFactor, Mode mode);
00069   void DrawGaussSigmaSlice(const char* key, const int rebinFactor, Mode mode);
00070   void DrawGaussSigmaSlice(const char* key, const int rebinFactor, const int binxmin,
00071                            const int binxmax, const bool cst_binning, Mode mode);
00072   void DrawGaussSigmaOverMeanXSlice(const char* key, const int rebinFactor, const int binxmin,
00073                                     const int binxmax, const bool cst_binning, Mode mode);
00074   void DrawGaussSigmaOverMeanSlice(const char* key, const char* key2, const int rebinFactor, Mode mode);
00075 
00076   void Draw( const char* key, Mode mode);
00077   
00078   void Draw( const char* key0, const char* key1, Mode mode);
00079 
00080   // return the two temporary 1d histograms, that have just
00081   // been plotted
00082   TH1* h0() {return h0_;}
00083   TH1* h1() {return h1_;}
00084 
00085   const TLegend& Legend() {return legend_;}
00086   
00087   // set the styles for further plots
00088   void SetStyles( Style* s0, 
00089                   Style* s1,
00090                   const char* leg0,
00091                   const char* leg1);
00092    
00093   TH1* Histo( const char* key, unsigned dirIndex);
00094 
00095   TDirectory* dir0(){ return dir0_;}
00096   TDirectory* dir1(){ return dir1_;}
00097 
00098 private:
00099 
00100   // retrieve an histogram in one of the two directories
00101 
00102   // draw 2 1D histograms.
00103   // the histograms can be normalized to the same number of entries, 
00104   // or plotted as a ratio.
00105   void Draw( TH1* h0, TH1* h1, Mode mode );
00106 
00107   int rebin_;
00108   float xMin_;
00109   float xMax_;
00110   bool resetAxis_;
00111 
00112   TFile*      file0_;
00113   TDirectory* dir0_;
00114   TFile*      file1_;
00115   TDirectory* dir1_;
00116   
00117   TH1* h0_;
00118   TH1* h1_;
00119   
00120   Style* s0_;
00121   Style* s1_;
00122   
00123   TLegend legend_;
00124 
00125 };
00126 
00127 #endif