CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Comparator.h
Go to the documentation of this file.
1 #ifndef __Validation_RecoParticleFlow_Comparator__
2 #define __Validation_RecoParticleFlow_Comparator__
3 
4 #include <math.h>
5 
6 #include <TLegend.h>
7 #include <TFile.h>
8 #include <TH1.h>
9 #include <TF1.h>
10 
11 /* #include <string> */
12 
13 class Style;
14 
15 class Comparator {
16 
17 public:
18 
19  enum Mode {
25  };
26 
28  s0_(0), s1_(0), legend_(0,0,1,1) {}
29 
30  Comparator( const char* file0,
31  const char* dir0,
32  const char* file1,
33  const char* dir1 ) :
34  rebin_(-1), xMin_(0), xMax_(0), resetAxis_(false),
35  s0_(0), s1_(0), legend_(0,0,1,1) {
36 
37  SetDirs( file0, dir0, file1, dir1);
38  }
39 
41  void SetDirs( const char* file0,
42  const char* dir0,
43  const char* file1,
44  const char* dir1 );
45 
46  // set the rebinning factor and the range
47  void SetAxis( int rebin,
48  float xmin,
49  float xmax) {
50  rebin_ = rebin;
51  xMin_ = xmin;
52  xMax_ = xmax;
53  resetAxis_ = true;
54  }
55 
56  // set the rebinning factor, unset the range
57  void SetAxis( int rebin ) {
58  rebin_ = rebin;
59  resetAxis_ = false;
60  }
61 
62  // draws a Y projection of a slice along X
63  void DrawSlice( const char* key,
64  int binxmin, int binxmax,
65  Mode mode );
66 
67  void DrawMeanSlice(const char* key, const int rebinFactor, Mode mode);
68  void DrawSigmaSlice(const char* key, const int rebinFactor, Mode mode);
69  void DrawGaussSigmaSlice(const char* key, const int rebinFactor, Mode mode);
70  void DrawGaussSigmaSlice(const char* key, const int rebinFactor, const int binxmin,
71  const int binxmax, const bool cst_binning, Mode mode);
72  void DrawGaussSigmaOverMeanXSlice(const char* key, const int rebinFactor, const int binxmin,
73  const int binxmax, const bool cst_binning, Mode mode);
74  void DrawGaussSigmaOverMeanSlice(const char* key, const char* key2, const int rebinFactor, Mode mode);
75 
76  void Draw( const char* key, Mode mode);
77 
78  void Draw( const char* key0, const char* key1, Mode mode);
79 
80  // return the two temporary 1d histograms, that have just
81  // been plotted
82  TH1* h0() {return h0_;}
83  TH1* h1() {return h1_;}
84 
85  const TLegend& Legend() {return legend_;}
86 
87  // set the styles for further plots
88  void SetStyles( Style* s0,
89  Style* s1,
90  const char* leg0,
91  const char* leg1);
92 
93  TH1* Histo( const char* key, unsigned dirIndex);
94 
95  TDirectory* dir0(){ return dir0_;}
96  TDirectory* dir1(){ return dir1_;}
97 
98 private:
99 
100  // retrieve an histogram in one of the two directories
101 
102  // draw 2 1D histograms.
103  // the histograms can be normalized to the same number of entries,
104  // or plotted as a ratio.
105  void Draw( TH1* h0, TH1* h1, Mode mode );
106 
107  int rebin_;
108  float xMin_;
109  float xMax_;
111 
112  TFile* file0_;
113  TDirectory* dir0_;
114  TFile* file1_;
115  TDirectory* dir1_;
116 
117  TH1* h0_;
118  TH1* h1_;
119 
122 
123  TLegend legend_;
124 
125 };
126 
127 #endif
void SetStyles(Style *s0, Style *s1, const char *leg0, const char *leg1)
Definition: Comparator.cc:35
TDirectory * dir1()
Definition: Comparator.h:96
void DrawSigmaSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:102
const TLegend & Legend()
Definition: Comparator.h:85
void SetAxis(int rebin, float xmin, float xmax)
Definition: Comparator.h:47
TFile * file0_
Definition: Comparator.h:112
bool resetAxis_
Definition: Comparator.h:110
Comparator(const char *file0, const char *dir0, const char *file1, const char *dir1)
Definition: Comparator.h:30
void Draw(const char *key, Mode mode)
Definition: Comparator.cc:293
TH1 * h1()
Definition: Comparator.h:83
TDirectory * dir0()
Definition: Comparator.h:95
Style * s0_
Definition: Comparator.h:120
void DrawGaussSigmaOverMeanXSlice(const char *key, const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning, Mode mode)
Definition: Comparator.cc:194
TDirectory * dir0_
Definition: Comparator.h:113
void DrawMeanSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:85
void SetDirs(const char *file0, const char *dir0, const char *file1, const char *dir1)
set the 2 files, and the directory within each file, in which the histograms will be compared ...
Definition: Comparator.cc:18
Style * s1_
Definition: Comparator.h:121
float xMin_
Definition: Comparator.h:108
float xMax_
Definition: Comparator.h:109
TDirectory * dir1_
Definition: Comparator.h:115
TH1 * h1_
Definition: Comparator.h:118
TH1 * Histo(const char *key, unsigned dirIndex)
Definition: Comparator.cc:341
TLegend legend_
Definition: Comparator.h:123
TH1 * h0()
Definition: Comparator.h:82
void DrawSlice(const char *key, int binxmin, int binxmax, Mode mode)
Definition: Comparator.cc:47
TFile * file1_
Definition: Comparator.h:114
void DrawGaussSigmaOverMeanSlice(const char *key, const char *key2, const int rebinFactor, Mode mode)
Definition: Comparator.cc:261
list key
Definition: combine.py:13
void DrawGaussSigmaSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:119
TH1 * h0_
Definition: Comparator.h:117
void SetAxis(int rebin)
Definition: Comparator.h:57
Definition: NicePlot.h:7