CMS 3D CMS Logo

TH2Analyzer.h
Go to the documentation of this file.
1 #ifndef __Validation_RecoParticleFlow_TH2Analyzer__
2 #define __Validation_RecoParticleFlow_TH2Analyzer__
3 
4 #include <vector>
5 
6 #include <TObject.h>
7 
8 class TH2;
9 class TH1D;
10 class TH2D;
11 
12 // EN FAIT NON ?
13 // check why white window in colin's case
14 // are you making copies of histograms without changing the name?
15 // names could be handled in the following way:
16 // - give a name to each instance of TH2Analyzer in constructor
17 // - all histograms of the corresponding TH2Analyzer are created with a name
18 // (key) which starts with name_RMS
19 
20 class TH2Analyzer : public TObject {
21 public:
22  TH2Analyzer(const TH2 *h, int rebin = 1)
23  : hist2D_(h),
24  rebinnedHist2D_(nullptr),
25  average_(nullptr),
26  RMS_(nullptr),
27  sigmaGauss_(nullptr),
28  meanXslice_(nullptr) {
29  Eval(rebin);
30  }
31 
32  TH2Analyzer(const TH2 *h, const int binxmin, const int binxmax, const int rebin, const bool cst_binning = true)
33  : hist2D_(h),
34  rebinnedHist2D_(nullptr),
35  average_(nullptr),
36  RMS_(nullptr),
37  sigmaGauss_(nullptr),
38  meanXslice_(nullptr) {
39  Eval(rebin, binxmin, binxmax, cst_binning);
40  }
41 
42  ~TH2Analyzer() override { Reset(); }
43 
44  void Reset();
45 
46  void SetHisto(const TH2 *h) { hist2D_ = h; }
47 
48  void Eval(const int rebinFactor);
49  void Eval(const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning);
50 
51  TH1D *Average() { return average_; }
52  TH1D *RMS() { return RMS_; }
53  TH1D *SigmaGauss() { return sigmaGauss_; }
54  TH1D *MeanX() { return meanXslice_; }
55 
56  // add an histo for chi2 / ndof
57  // add a function FitSlice(int i)
58  // not now: work along Y
59 
60 private:
61  void ProcessSlices(const TH2D *histo);
62 
63  // no need for const, because i is copied
64  void ProcessSlice(const int i, TH1D *histo) const;
65 
66  const TH2 *hist2D_;
68  TH1D *average_;
69  TH1D *RMS_;
70  TH1D *sigmaGauss_;
71  TH1D *meanXslice_;
72 
73  // std::vector< TH1D* > parameters_; // if we are not fitting with a gauss
74  // function
76 };
77 
78 #endif
TH1D * SigmaGauss()
Definition: TH2Analyzer.h:53
~TH2Analyzer() override
Definition: TH2Analyzer.h:42
void ProcessSlice(const int i, TH1D *histo) const
Definition: TH2Analyzer.cc:261
ClassDefOverride(TH2Analyzer, 1)
void SetHisto(const TH2 *h)
Definition: TH2Analyzer.h:46
TH2D * rebinnedHist2D_
Definition: TH2Analyzer.h:67
TH2Analyzer(const TH2 *h, int rebin=1)
Definition: TH2Analyzer.h:22
TH1D * sigmaGauss_
Definition: TH2Analyzer.h:70
void Eval(const int rebinFactor)
Definition: TH2Analyzer.cc:16
TH1D * meanXslice_
Definition: TH2Analyzer.h:71
void ProcessSlices(const TH2D *histo)
Definition: TH2Analyzer.cc:230
TH1D * MeanX()
Definition: TH2Analyzer.h:54
TH1D * RMS()
Definition: TH2Analyzer.h:52
TH2Analyzer(const TH2 *h, const int binxmin, const int binxmax, const int rebin, const bool cst_binning=true)
Definition: TH2Analyzer.h:32
const TH2 * hist2D_
Definition: TH2Analyzer.h:66
TH1D * RMS_
Definition: TH2Analyzer.h:69
void Reset()
Definition: TH2Analyzer.cc:57
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
TH1D * Average()
Definition: TH2Analyzer.h:51
TH1D * average_
Definition: TH2Analyzer.h:68