Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:13

0001 #ifndef __Validation_RecoParticleFlow_TH2Analyzer__
0002 #define __Validation_RecoParticleFlow_TH2Analyzer__
0003 
0004 #include <vector>
0005 
0006 #include <TObject.h>
0007 
0008 class TH2;
0009 class TH1D;
0010 class TH2D;
0011 
0012 // EN FAIT NON ?
0013 // check why white window in colin's case
0014 // are you making copies of histograms without changing the name?
0015 // names could be handled in the following way:
0016 // - give a name to each instance of TH2Analyzer in constructor
0017 // - all histograms of the corresponding TH2Analyzer are created with a name
0018 // (key) which starts with name_RMS
0019 
0020 class TH2Analyzer : public TObject {
0021 public:
0022   TH2Analyzer(const TH2 *h, int rebin = 1)
0023       : hist2D_(h),
0024         rebinnedHist2D_(nullptr),
0025         average_(nullptr),
0026         RMS_(nullptr),
0027         sigmaGauss_(nullptr),
0028         meanXslice_(nullptr) {
0029     Eval(rebin);
0030   }
0031 
0032   TH2Analyzer(const TH2 *h, const int binxmin, const int binxmax, const int rebin, const bool cst_binning = true)
0033       : hist2D_(h),
0034         rebinnedHist2D_(nullptr),
0035         average_(nullptr),
0036         RMS_(nullptr),
0037         sigmaGauss_(nullptr),
0038         meanXslice_(nullptr) {
0039     Eval(rebin, binxmin, binxmax, cst_binning);
0040   }
0041 
0042   ~TH2Analyzer() override { Reset(); }
0043 
0044   void Reset();
0045 
0046   void SetHisto(const TH2 *h) { hist2D_ = h; }
0047 
0048   void Eval(const int rebinFactor);
0049   void Eval(const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning);
0050 
0051   TH1D *Average() { return average_; }
0052   TH1D *RMS() { return RMS_; }
0053   TH1D *SigmaGauss() { return sigmaGauss_; }
0054   TH1D *MeanX() { return meanXslice_; }
0055 
0056   // add an histo for chi2 /  ndof
0057   // add a function FitSlice(int i)
0058   // not now: work along Y
0059 
0060 private:
0061   void ProcessSlices(const TH2D *histo);
0062 
0063   // no need for const, because i is copied
0064   void ProcessSlice(const int i, TH1D *histo) const;
0065 
0066   const TH2 *hist2D_;
0067   TH2D *rebinnedHist2D_;
0068   TH1D *average_;
0069   TH1D *RMS_;
0070   TH1D *sigmaGauss_;
0071   TH1D *meanXslice_;
0072 
0073   // std::vector< TH1D* > parameters_; // if we are not fitting with a gauss
0074   // function
0075   ClassDefOverride(TH2Analyzer, 1);
0076 };
0077 
0078 #endif