CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Validation/RecoParticleFlow/interface/TH2Analyzer.h

Go to the documentation of this file.
00001 #ifndef __Validation_RecoParticleFlow_TH2Analyzer__
00002 #define __Validation_RecoParticleFlow_TH2Analyzer__
00003 
00004 #include <vector>
00005 
00006 #include <TObject.h>
00007 
00008 class TH2;
00009 class TH1D;
00010 class TH2D;
00011 
00012 // EN FAIT NON ? 
00013 // check why white window in colin's case
00014 // are you making copies of histograms without changing the name? 
00015 // names could be handled in the following way:
00016 // - give a name to each instance of TH2Analyzer in constructor
00017 // - all histograms of the corresponding TH2Analyzer are created with a name (key)
00018 // which starts with name_RMS
00019 
00020 class TH2Analyzer : public TObject {
00021 
00022  public:
00023   TH2Analyzer( const TH2* h, int rebin=1) : 
00024     hist2D_(h), 
00025     rebinnedHist2D_(0),
00026     average_(0),
00027     RMS_(0),
00028     sigmaGauss_(0),
00029     meanXslice_(0) {
00030     Eval(rebin);
00031   }
00032 
00033   TH2Analyzer( const TH2* h, const int binxmin, const int binxmax,
00034                const int rebin, const bool cst_binning=true) : 
00035     hist2D_(h), 
00036     rebinnedHist2D_(0),
00037     average_(0),
00038     RMS_(0),
00039     sigmaGauss_(0),
00040     meanXslice_(0) {
00041     Eval(rebin, binxmin, binxmax, cst_binning);
00042   } 
00043 
00044   ~TH2Analyzer() {Reset(); }
00045 
00046   void Reset();
00047 
00048   void SetHisto( const TH2* h ) {hist2D_ = h;}
00049 
00050   void Eval(const int rebinFactor);
00051   void Eval(const int rebinFactor, const int binxmin, const int binxmax,
00052             const bool cst_binning);
00053   
00054   TH1D* Average() { return average_; }
00055   TH1D* RMS() { return RMS_; }
00056   TH1D* SigmaGauss() { return sigmaGauss_; }
00057   TH1D* MeanX() { return meanXslice_; }
00058 
00059   // add an histo for chi2 /  ndof 
00060   // add a function FitSlice(int i)
00061   // not now: work along Y
00062 
00063  private:
00064 
00065   void ProcessSlices(  const TH2D* histo );
00066 
00067   // no need for const, because i is copied
00068   void ProcessSlice(const int i, TH1D* histo ) const;
00069 
00070   const TH2* hist2D_;
00071   TH2D*      rebinnedHist2D_;
00072   TH1D*      average_;
00073   TH1D*      RMS_;
00074   TH1D*      sigmaGauss_;
00075   TH1D*      meanXslice_;
00076 
00077   //std::vector< TH1D* > parameters_; // if we are not fitting with a gauss function
00078   ClassDef(TH2Analyzer, 1);
00079 
00080 };
00081 
00082 #endif