CMS 3D CMS Logo

Comparator.h
Go to the documentation of this file.
1 #ifndef __Validation_RecoParticleFlow_Comparator__
2 #define __Validation_RecoParticleFlow_Comparator__
3 
4 #include <cmath>
5 
6 #include <TF1.h>
7 #include <TFile.h>
8 #include <TH1.h>
9 #include <TLegend.h>
10 
11 /* #include <string> */
12 
13 class Style;
14 
15 class Comparator {
16 public:
17  enum Mode { NORMAL, SCALE, RATIO, GRAPH, EFF };
18 
19  Comparator() : rebin_(-1), xMin_(0), xMax_(0), resetAxis_(false), s0_(nullptr), s1_(nullptr), legend_(0, 0, 1, 1) {}
20 
21  Comparator(const char *file0, const char *dir0, const char *file1, const char *dir1)
22  : rebin_(-1), xMin_(0), xMax_(0), resetAxis_(false), s0_(nullptr), s1_(nullptr), legend_(0, 0, 1, 1) {
23  SetDirs(file0, dir0, file1, dir1);
24  }
25 
28  void SetDirs(const char *file0, const char *dir0, const char *file1, const char *dir1);
29 
30  // set the rebinning factor and the range
31  void SetAxis(int rebin, float xmin, float xmax) {
32  rebin_ = rebin;
33  xMin_ = xmin;
34  xMax_ = xmax;
35  resetAxis_ = true;
36  }
37 
38  // set the rebinning factor, unset the range
39  void SetAxis(int rebin) {
40  rebin_ = rebin;
41  resetAxis_ = false;
42  }
43 
44  // draws a Y projection of a slice along X
45  void DrawSlice(const char *key, int binxmin, int binxmax, Mode mode);
46 
47  void DrawMeanSlice(const char *key, const int rebinFactor, Mode mode);
48  void DrawSigmaSlice(const char *key, const int rebinFactor, Mode mode);
49  void DrawGaussSigmaSlice(const char *key, const int rebinFactor, Mode mode);
51  const char *key, const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning, Mode mode);
53  const char *key, const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning, Mode mode);
54  void DrawGaussSigmaOverMeanSlice(const char *key, const char *key2, const int rebinFactor, Mode mode);
55 
56  void Draw(const char *key, Mode mode);
57 
58  void Draw(const char *key0, const char *key1, Mode mode);
59 
60  // return the two temporary 1d histograms, that have just
61  // been plotted
62  TH1 *h0() { return h0_; }
63  TH1 *h1() { return h1_; }
64 
65  TLegend &Legend() { return legend_; }
66  const TLegend &Legend() const { return legend_; }
67 
68  // set the styles for further plots
69  void SetStyles(Style *s0, Style *s1, const char *leg0, const char *leg1);
70 
71  TH1 *Histo(const char *key, unsigned dirIndex);
72 
73  TDirectory *dir0() { return dir0_; }
74  TDirectory *dir1() { return dir1_; }
75 
76 private:
77  // retrieve an histogram in one of the two directories
78 
79  // draw 2 1D histograms.
80  // the histograms can be normalized to the same number of entries,
81  // or plotted as a ratio.
82  void Draw(TH1 *h0, TH1 *h1, Mode mode);
83 
84  int rebin_;
85  float xMin_;
86  float xMax_;
87  bool resetAxis_;
88 
89  TFile *file0_;
90  TDirectory *dir0_;
91  TFile *file1_;
92  TDirectory *dir1_;
93 
94  TH1 *h0_;
95  TH1 *h1_;
96 
99 
100  TLegend legend_;
101 };
102 
103 #endif
Comparator::RATIO
Definition: Comparator.h:17
Comparator::Histo
TH1 * Histo(const char *key, unsigned dirIndex)
Definition: Comparator.cc:349
funct::false
false
Definition: Factorize.h:29
Comparator::h0
TH1 * h0()
Definition: Comparator.h:62
Comparator::legend_
TLegend legend_
Definition: Comparator.h:100
Comparator::s1_
Style * s1_
Definition: Comparator.h:98
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
Comparator::Mode
Mode
Definition: Comparator.h:17
Comparator::Legend
const TLegend & Legend() const
Definition: Comparator.h:66
Comparator::NORMAL
Definition: Comparator.h:17
Comparator::dir1
TDirectory * dir1()
Definition: Comparator.h:74
Comparator::Comparator
Comparator()
Definition: Comparator.h:19
Comparator::DrawSigmaSlice
void DrawSigmaSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:89
Comparator::xMin_
float xMin_
Definition: Comparator.h:85
Comparator::Legend
TLegend & Legend()
Definition: Comparator.h:65
Comparator::h1_
TH1 * h1_
Definition: Comparator.h:95
Comparator::rebin_
int rebin_
Definition: Comparator.h:84
Comparator::Comparator
Comparator(const char *file0, const char *dir0, const char *file1, const char *dir1)
Definition: Comparator.h:21
Comparator::resetAxis_
bool resetAxis_
Definition: Comparator.h:87
Comparator::DrawSlice
void DrawSlice(const char *key, int binxmin, int binxmax, Mode mode)
Definition: Comparator.cc:42
Comparator::DrawGaussSigmaOverMeanXSlice
void DrawGaussSigmaOverMeanXSlice(const char *key, const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning, Mode mode)
Definition: Comparator.cc:195
Style
Definition: Style.py:1
Comparator::SetAxis
void SetAxis(int rebin, float xmin, float xmax)
Definition: Comparator.h:31
Comparator::Draw
void Draw(const char *key, Mode mode)
Definition: Comparator.cc:306
Comparator::dir0_
TDirectory * dir0_
Definition: Comparator.h:90
Comparator::GRAPH
Definition: Comparator.h:17
Comparator::SetAxis
void SetAxis(int rebin)
Definition: Comparator.h:39
timingPdfMaker.file1
file1
Definition: timingPdfMaker.py:78
Comparator::dir1_
TDirectory * dir1_
Definition: Comparator.h:92
Comparator::SetStyles
void SetStyles(Style *s0, Style *s1, const char *leg0, const char *leg1)
Definition: Comparator.cc:33
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
Comparator::dir0
TDirectory * dir0()
Definition: Comparator.h:73
Comparator::file0_
TFile * file0_
Definition: Comparator.h:89
Comparator::s0_
Style * s0_
Definition: Comparator.h:97
Comparator::EFF
Definition: Comparator.h:17
Comparator
Definition: Comparator.h:15
Comparator::h1
TH1 * h1()
Definition: Comparator.h:63
Comparator::SetDirs
void SetDirs(const char *file0, const char *dir0, const char *file1, const char *dir1)
Definition: Comparator.cc:17
Comparator::xMax_
float xMax_
Definition: Comparator.h:86
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
Comparator::file1_
TFile * file1_
Definition: Comparator.h:91
Comparator::DrawGaussSigmaOverMeanSlice
void DrawGaussSigmaOverMeanSlice(const char *key, const char *key2, const int rebinFactor, Mode mode)
Definition: Comparator.cc:276
crabWrapper.key
key
Definition: crabWrapper.py:19
Comparator::SCALE
Definition: Comparator.h:17
Comparator::DrawMeanSlice
void DrawMeanSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:73
Comparator::DrawGaussSigmaSlice
void DrawGaussSigmaSlice(const char *key, const int rebinFactor, Mode mode)
Definition: Comparator.cc:105
Comparator::h0_
TH1 * h0_
Definition: Comparator.h:94