Logo ROOT  
Reference Guide
RooHist.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooHist.h,v 1.22 2007/05/11 09:11:30 verkerke Exp $
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 #ifndef ROO_HIST
17 #define ROO_HIST
18 
19 #include "TGraphAsymmErrors.h"
20 #include "RooPlotable.h"
21 #include "RooAbsData.h"
22 #include "RooAbsRealLValue.h"
23 
24 class TH1;
25 class RooCurve ;
26 
27 class RooHist : public TGraphAsymmErrors, public RooPlotable {
28 public:
29  RooHist() ;
30  RooHist(Double_t nominalBinWidth, Double_t nSigma= 1, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
31  RooHist(const TH1 &data, Double_t nominalBinWidth= 0, Double_t nSigma= 1, RooAbsData::ErrorType=RooAbsData::Poisson,
32  Double_t xErrorFrac=1.0, Bool_t correctForBinWidth=kTRUE, Double_t scaleFactor=1.);
33  RooHist(const TH1 &data1, const TH1 &data2, Double_t nominalBinWidth= 0, Double_t nSigma= 1, RooAbsData::ErrorType=RooAbsData::Poisson,
34  Double_t xErrorFrac=1.0, Bool_t efficiency=kFALSE, Double_t scaleFactor=1.0);
35  RooHist(const RooHist& hist1, const RooHist& hist2, Double_t wgt1=1.0, Double_t wgt2=1.0,
36  RooAbsData::ErrorType etype=RooAbsData::Poisson, Double_t xErrorFrac=1.0) ;
37  RooHist(const RooAbsReal &f, RooAbsRealLValue &x, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0, const RooArgSet *normVars = 0, const RooFitResult* fr = 0);
38  virtual ~RooHist();
39 
40  // add a datapoint for a bin with n entries, using a Poisson error
41  void addBin(Axis_t binCenter, Double_t n, Double_t binWidth= 0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0);
42  // add a datapoint for a bin with n entries, using a given error
43  void addBinWithError(Axis_t binCenter, Double_t n, Double_t elow, Double_t ehigh, Double_t binWidth= 0,
44  Double_t xErrorFrac=1.0, Bool_t correctForBinWidth=kTRUE, Double_t scaleFactor=1.0);
45  // add a datapoint for a bin with n entries, using a given x and y error
46  void addBinWithXYError(Axis_t binCenter, Double_t n, Double_t exlow, Double_t exhigh, Double_t eylow, Double_t eyhigh,
47  Double_t scaleFactor=1.0);
48  // add a datapoint for the asymmetry (n1-n2)/(n1+n2), using a binomial error
49  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);
50  // add a datapoint for the asymmetry (n1-n2)/(n1+n2), using sum-of-weights error
51  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);
52 
53  // add a datapoint for the efficiency (n1)/(n1+n2), using a binomial error
54  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);
55  // add a datapoint for the efficiency (n1)/(n1+n2), using a sum-of-weights error
56  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);
57 
58  virtual void printName(std::ostream& os) const ;
59  virtual void printTitle(std::ostream& os) const ;
60  virtual void printClassName(std::ostream& os) const ;
61  virtual void printMultiline(std::ostream& os, Int_t content, Bool_t verbose=kFALSE, TString indent= "") const;
62 
63  inline virtual void Print(Option_t *options= 0) const {
64  // Printing interface
66  }
67 
68  Double_t getFitRangeNEvt() const;
69  Double_t getFitRangeNEvt(Double_t xlo, Double_t xhi) const ;
70  Double_t getFitRangeBinW() const;
71  inline Double_t getNominalBinWidth() const { return _nominalBinWidth; }
72  inline void setRawEntries(Double_t n) { _rawEntries = n ; }
73 
74  Bool_t hasIdenticalBinning(const RooHist& other) const ;
75 
76  RooHist* makeResidHist(const RooCurve& curve,bool normalize=false, bool useAverage=false) const;
77  RooHist* makePullHist(const RooCurve& curve, bool useAverage=false) const
78  {return makeResidHist(curve,true,useAverage); }
79 
80 
81  Bool_t isIdentical(const RooHist& other, Double_t tol=1e-6) const ;
82 
83 
84 protected:
85  void initialize();
87 
88 private:
89  Double_t _nominalBinWidth ; // Average bin width
90  Double_t _nSigma ; // Number of 'sigmas' error bars represent
91  Double_t _entries ; // Number of entries in histogram
92  Double_t _rawEntries; // Number of entries in source dataset
93 
94  ClassDef(RooHist,1) // 1-dimensional histogram with error bars
95 };
96 
97 #endif
RooHist::printName
virtual void printName(std::ostream &os) const
Print name of RooHist.
Definition: RooHist.cxx:718
RooHist::_nominalBinWidth
Double_t _nominalBinWidth
Definition: RooHist.h:89
n
const Int_t n
Definition: legend1.C:16
RooHist::addEfficiencyBinWithError
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)
Add a bin to this histogram with the value n1/(n1+n2) using an error bar calculated with Binomial sta...
Definition: RooHist.cxx:596
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
e
#define e(i)
Definition: RSha256.hxx:103
f
#define f(i)
Definition: RSha256.hxx:104
RooHist::~RooHist
virtual ~RooHist()
Destructor.
Definition: RooHist.cxx:623
Option_t
const char Option_t
Definition: RtypesCore.h:66
RooHist::printClassName
virtual void printClassName(std::ostream &os) const
Print class name of RooHist.
Definition: RooHist.cxx:738
RooHist::getFitRangeBinW
Double_t getFitRangeBinW() const
Return (average) bin width of this RooHist.
Definition: RooHist.cxx:391
Axis_t
double Axis_t
Definition: RtypesCore.h:76
RooHist::RooHist
RooHist()
Default constructor.
Definition: RooHist.cxx:50
x
Double_t x[n]
Definition: legend1.C:17
indent
static void indent(ostringstream &buf, int indent_level)
Definition: TClingCallFunc.cxx:87
RooHist::addBin
void addBin(Axis_t binCenter, Double_t n, Double_t binWidth=0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0)
Add a bin to this histogram with the specified integer bin contents and using an error bar calculated...
Definition: RooHist.cxx:422
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooHist::Print
virtual void Print(Option_t *options=0) const
Print graph and errors values.
Definition: RooHist.h:63
RooHist::makePullHist
RooHist * makePullHist(const RooCurve &curve, bool useAverage=false) const
Definition: RooHist.h:77
TString
Basic string class.
Definition: TString.h:136
RooAbsData::ErrorType
ErrorType
Definition: RooAbsData.h:97
RooHist::setRawEntries
void setRawEntries(Double_t n)
Definition: RooHist.h:72
bool
RooFitResult
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
RooPrintable::defaultPrintContents
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
Definition: RooPrintable.cxx:233
RooPrintable::defaultPrintStream
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
Definition: RooPrintable.cxx:272
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooCurve
A RooCurve is a one-dimensional graphical representation of a real-valued function.
Definition: RooCurve.h:32
RooHist::addEfficiencyBin
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)
Add a bin to this histogram with the value n1/(n1+n2) using an error bar calculated with Binomial sta...
Definition: RooHist.cxx:569
RooHist::initialize
void initialize()
Perform common initialization for all constructors.
Definition: RooHist.cxx:339
RooHist::makeResidHist
RooHist * makeResidHist(const RooCurve &curve, bool normalize=false, bool useAverage=false) const
Create and return RooHist containing residuals w.r.t to given curve.
Definition: RooHist.cxx:750
y
Double_t y[n]
Definition: legend1.C:17
RooHist::addAsymmetryBinWithError
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)
Add a bin to this histogram with the value (n1-n2)/(n1+n2) using an error bar calculated with Binomia...
Definition: RooHist.cxx:543
TGraphAsymmErrors
TGraph with asymmetric error bars.
Definition: TGraphAsymmErrors.h:26
RooHist::isIdentical
Bool_t isIdentical(const RooHist &other, Double_t tol=1e-6) const
Return kTRUE if contents of this RooHist is identical within given relative tolerance to that of 'oth...
Definition: RooHist.cxx:662
RooHist
A RooHist is a graphical representation of binned data based on the TGraphAsymmErrors class.
Definition: RooHist.h:27
RooAbsData::Poisson
@ Poisson
Definition: RooAbsData.h:97
RooPlotable.h
RooHist::addAsymmetryBin
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)
Add a bin to this histogram with the value (n1-n2)/(n1+n2) using an error bar calculated with Binomia...
Definition: RooHist.cxx:517
RooHist::_rawEntries
Double_t _rawEntries
Definition: RooHist.h:92
RooAbsData.h
Double_t
double Double_t
Definition: RtypesCore.h:59
RooHist::printTitle
virtual void printTitle(std::ostream &os) const
Print title of RooHist.
Definition: RooHist.cxx:728
TGraphAsymmErrors.h
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
RooHist::_entries
Double_t _entries
Definition: RooHist.h:91
RooPrintable::printStream
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Definition: RooPrintable.cxx:75
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooHist::roundBin
Int_t roundBin(Double_t y)
Return the nearest positive integer to the input value and print a warning if an adjustment is requir...
Definition: RooHist.cxx:402
RooHist::addBinWithError
void addBinWithError(Axis_t binCenter, Double_t n, Double_t elow, Double_t ehigh, Double_t binWidth=0, Double_t xErrorFrac=1.0, Bool_t correctForBinWidth=kTRUE, Double_t scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
Definition: RooHist.cxx:472
RooPlotable
Class RooPotable is a base class for objects that can be inserted into RooPlots and take advantage of...
Definition: RooPlotable.h:26
RooHist::printMultiline
virtual void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const
Print info about this histogram to the specified output stream.
Definition: RooHist.cxx:694
RooHist::getFitRangeNEvt
Double_t getFitRangeNEvt() const
Return the number of events of the dataset associated with this RooHist.
Definition: RooHist.cxx:351
RooHist::getNominalBinWidth
Double_t getNominalBinWidth() const
Definition: RooHist.h:71
RooPrintable::defaultPrintStyle
virtual StyleOption defaultPrintStyle(Option_t *opt) const
Definition: RooPrintable.cxx:241
RooHist::hasIdenticalBinning
Bool_t hasIdenticalBinning(const RooHist &other) const
Return kTRUE if binning of this RooHist is identical to that of 'other'.
Definition: RooHist.cxx:632
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooAbsRealLValue.h
RooHist::_nSigma
Double_t _nSigma
Definition: RooHist.h:90
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
RooHist::addBinWithXYError
void addBinWithXYError(Axis_t binCenter, Double_t n, Double_t exlow, Double_t exhigh, Double_t eylow, Double_t eyhigh, Double_t scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
Definition: RooHist.cxx:497
int