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  TLegend& Legend() {return legend_;}
86  const TLegend& Legend() const {return legend_;}
87 
88  // set the styles for further plots
89  void SetStyles( Style* s0,
90  Style* s1,
91  const char* leg0,
92  const char* leg1);
93 
94  TH1* Histo( const char* key, unsigned dirIndex);
95 
96  TDirectory* dir0(){ return dir0_;}
97  TDirectory* dir1(){ return dir1_;}
98 
99 private:
100 
101  // retrieve an histogram in one of the two directories
102 
103  // draw 2 1D histograms.
104  // the histograms can be normalized to the same number of entries,
105  // or plotted as a ratio.
106  void Draw( TH1* h0, TH1* h1, Mode mode );
107 
108  int rebin_;
109  float xMin_;
110  float xMax_;
112 
113  TFile* file0_;
114  TDirectory* dir0_;
115  TFile* file1_;
116  TDirectory* dir1_;
117 
118  TH1* h0_;
119  TH1* h1_;
120 
123 
124  TLegend legend_;
125 
126 };
127 
128 #endif
void SetStyles(Style *s0, Style *s1, const char *leg0, const char *leg1)
Definition: Comparator.cc:35
TLegend & Legend()
Definition: Comparator.h:85
TDirectory * dir1()
Definition: Comparator.h:97
void DrawSigmaSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:102
void SetAxis(int rebin, float xmin, float xmax)
Definition: Comparator.h:47
const TLegend & Legend() const
Definition: Comparator.h:86
TFile * file0_
Definition: Comparator.h:113
bool resetAxis_
Definition: Comparator.h:111
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:96
Style * s0_
Definition: Comparator.h:121
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:114
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:122
float xMin_
Definition: Comparator.h:109
float xMax_
Definition: Comparator.h:110
TDirectory * dir1_
Definition: Comparator.h:116
TH1 * h1_
Definition: Comparator.h:119
TH1 * Histo(const char *key, unsigned dirIndex)
Definition: Comparator.cc:341
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
TLegend legend_
Definition: Comparator.h:124
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:115
void DrawGaussSigmaOverMeanSlice(const char *key, const char *key2, const int rebinFactor, Mode mode)
Definition: Comparator.cc:261
void DrawGaussSigmaSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:119
TH1 * h0_
Definition: Comparator.h:118
volatile std::atomic< bool > shutdown_flag false
void SetAxis(int rebin)
Definition: Comparator.h:57
Definition: NicePlot.h:7