RooHist.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooHist.h,v 1.22 2007/05/11 09:11:30 verkerke Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_HIST
00017 #define ROO_HIST
00018 
00019 #include "TGraphAsymmErrors.h"
00020 #include "RooPlotable.h"
00021 #include "RooAbsData.h"
00022 
00023 class TH1;
00024 class RooCurve ;
00025 
00026 class RooHist : public TGraphAsymmErrors, public RooPlotable {
00027 public:
00028   RooHist() ;
00029   RooHist(Double_t nominalBinWidth, Double_t nSigma= 1, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
00030   RooHist(const TH1 &data, Double_t nominalBinWidth= 0, Double_t nSigma= 1, RooAbsData::ErrorType=RooAbsData::Poisson, 
00031           Double_t xErrorFrac=1.0, Bool_t correctForBinWidth=kTRUE, Double_t scaleFactor=1.);
00032   RooHist(const TH1 &data1, const TH1 &data2, Double_t nominalBinWidth= 0, Double_t nSigma= 1, RooAbsData::ErrorType=RooAbsData::Poisson,
00033           Double_t xErrorFrac=1.0, Bool_t efficiency=kFALSE, Double_t scaleFactor=1.0);
00034   RooHist(const RooHist& hist1, const RooHist& hist2, Double_t wgt1=1.0, Double_t wgt2=1.0, 
00035           RooAbsData::ErrorType etype=RooAbsData::Poisson, Double_t xErrorFrac=1.0) ;
00036   virtual ~RooHist();
00037 
00038   // add a datapoint for a bin with n entries, using a Poisson error
00039   void addBin(Axis_t binCenter, Double_t n, Double_t binWidth= 0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
00040   // add a datapoint for a bin with n entries, using a given error
00041   void addBinWithError(Axis_t binCenter, Double_t n, Double_t elow, Double_t ehigh, Double_t binWidth= 0, 
00042                        Double_t xErrorFrac=1.0, Bool_t correctForBinWidth=kTRUE, Double_t scaleFactor=1.0);
00043   // add a datapoint for a bin with n entries, using a given x and y error
00044   void addBinWithXYError(Axis_t binCenter, Double_t n, Double_t exlow, Double_t exhigh, Double_t eylow, Double_t eyhigh, 
00045                          Double_t scaleFactor=1.0);
00046   // add a datapoint for the asymmetry (n1-n2)/(n1+n2), using a binomial error
00047   void addAsymmetryBin(Axis_t binCenter, Int_t n1, Int_t n2, Double_t binWidth= 0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
00048   // add a datapoint for the asymmetry (n1-n2)/(n1+n2), using sum-of-weights error
00049   void addAsymmetryBinWithError(Axis_t binCenter, Double_t n1, Double_t n2, Double_t en1, Double_t en2, Double_t binWidth= 0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
00050 
00051   // add a datapoint for the efficiency (n1)/(n1+n2), using a binomial error
00052   void addEfficiencyBin(Axis_t binCenter, Int_t n1, Int_t n2, Double_t binWidth= 0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
00053   // add a datapoint for the efficiency (n1)/(n1+n2), using a sum-of-weights error
00054   void addEfficiencyBinWithError(Axis_t binCenter, Double_t n1, Double_t n2, Double_t en1, Double_t en2, Double_t binWidth= 0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
00055 
00056   virtual void printName(ostream& os) const ;
00057   virtual void printTitle(ostream& os) const ;
00058   virtual void printClassName(ostream& os) const ;
00059   virtual void printMultiline(ostream& os, Int_t content, Bool_t verbose=kFALSE, TString indent= "") const;
00060 
00061   inline virtual void Print(Option_t *options= 0) const {
00062     // Printing interface
00063     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
00064   }
00065 
00066   Double_t getFitRangeNEvt() const;
00067   Double_t getFitRangeNEvt(Double_t xlo, Double_t xhi) const ;
00068   Double_t getFitRangeBinW() const;
00069   inline Double_t getNominalBinWidth() const { return _nominalBinWidth; }
00070   inline void setRawEntries(Double_t n) { _rawEntries = n ; } 
00071 
00072   Bool_t hasIdenticalBinning(const RooHist& other) const ;
00073 
00074   RooHist* makeResidHist(const RooCurve& curve,bool normalize=false) const;
00075   RooHist* makePullHist(const RooCurve& curve) const {return makeResidHist(curve,false); }
00076 
00077 
00078   Bool_t isIdentical(const RooHist& other, Double_t tol=1e-6) const ;
00079 
00080 
00081 protected:
00082   void initialize();
00083   Int_t roundBin(Double_t y);
00084 
00085 private:
00086   Double_t _nominalBinWidth ; // Average bin width
00087   Double_t _nSigma ;          // Number of 'sigmas' error bars represent
00088   Double_t _entries ;         // Number of entries in histogram
00089   Double_t _rawEntries;        // Number of entries in source dataset
00090 
00091   ClassDef(RooHist,1) // 1-dimensional histogram with error bars
00092 };
00093 
00094 #endif

Generated on Tue Jul 5 14:26:12 2011 for ROOT_528-00b_version by  doxygen 1.5.1