ROOT  6.06/09
Reference Guide
RooBinning.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooBinning.h,v 1.9 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_BINNING
17 #define ROO_BINNING
18 
19 #include "Rtypes.h"
20 #include "TList.h"
21 #include "RooDouble.h"
22 #include "RooAbsBinning.h"
23 #include "RooNumber.h"
24 #include <vector>
25 class RooAbsPdf;
26 class RooRealVar;
27 
28 
29 class RooBinning : public RooAbsBinning {
30 public:
31 
32  RooBinning(Double_t xlo = -RooNumber::infinity(), Double_t xhi = RooNumber::infinity(), const char* name = 0);
33  RooBinning(Int_t nBins, Double_t xlo, Double_t xhi, const char* name = 0);
34  RooBinning(Int_t nBins, const Double_t* boundaries, const char* name = 0);
35  RooBinning(const RooBinning& other, const char* name = 0);
36  RooAbsBinning* clone(const char* name = 0) const { return new RooBinning(*this,name?name:GetName()); }
37  ~RooBinning();
38 
39  virtual Int_t numBoundaries() const {
40  // Return the number boundaries
41  return _nbins+1;
42  }
43  virtual Int_t binNumber(Double_t x) const;
44  virtual Int_t rawBinNumber(Double_t x) const;
45  virtual Double_t nearestBoundary(Double_t x) const;
46 
47  virtual void setRange(Double_t xlo, Double_t xhi);
48 
49  virtual Double_t lowBound() const {
50  // Return the lower bound value
51  return _xlo;
52  }
53  virtual Double_t highBound() const {
54  // Return the upper bound value
55  return _xhi;
56  }
57  virtual Double_t averageBinWidth() const {
58  // Return the average bin width
59  return (highBound() - lowBound()) / numBins();
60  }
61  virtual Double_t* array() const;
62 
63  virtual Double_t binCenter(Int_t bin) const;
64  virtual Double_t binWidth(Int_t bin) const;
65  virtual Double_t binLow(Int_t bin) const;
66  virtual Double_t binHigh(Int_t bin) const;
67 
68  Bool_t addBoundary(Double_t boundary);
69  void addBoundaryPair(Double_t boundary, Double_t mirrorPoint = 0);
70  void addUniform(Int_t nBins, Double_t xlo, Double_t xhi);
71  Bool_t removeBoundary(Double_t boundary);
72 
73  Bool_t hasBoundary(Double_t boundary);
74 
75 protected:
76 
77  Bool_t binEdges(Int_t bin, Double_t& xlo, Double_t& xhi) const;
78  void updateBinCount();
79 
80  Double_t _xlo; // Lower bound
81  Double_t _xhi; // Upper bound
82  Bool_t _ownBoundLo; // Does the lower bound coincide with a bin boundary
83  Bool_t _ownBoundHi; // Does the upper bound coincide with a bin boundary
84  Int_t _nbins; // Numer of bins
85 
86  std::vector<Double_t> _boundaries; // Boundaries
87  mutable Double_t* _array; //! Array of boundaries
88  mutable Int_t _blo; //! bin number for _xlo
89 
90  ClassDef(RooBinning,3) // Generic binning specification
91 };
92 
93 #endif
virtual void setRange(Double_t xlo, Double_t xhi)
Change the defined range associated with this binning.
Definition: RooBinning.cxx:231
virtual Int_t numBoundaries() const
Definition: RooBinning.h:39
Int_t _blo
Array of boundaries.
Definition: RooBinning.h:88
RooBinning(Double_t xlo=-RooNumber::infinity(), Double_t xhi=RooNumber::infinity(), const char *name=0)
Constructor for an initially empty binning defining the range [xlo,xhi].
Definition: RooBinning.cxx:51
Double_t _xlo
Definition: RooBinning.h:80
void addUniform(Int_t nBins, Double_t xlo, Double_t xhi)
Add array of nbins uniformly sized bins in range [xlo,xhi].
Definition: RooBinning.cxx:171
RooAbsBinning * clone(const char *name=0) const
Definition: RooBinning.h:36
virtual Double_t nearestBoundary(Double_t x) const
Return the value of the nearest boundary to x.
Definition: RooBinning.cxx:207
virtual Double_t binWidth(Int_t bin) const
Return the width of the requested bin.
Definition: RooBinning.cxx:292
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t addBoundary(Double_t boundary)
Add bin boundary at given value.
Definition: RooBinning.cxx:109
virtual Double_t averageBinWidth() const
Definition: RooBinning.h:57
Int_t _nbins
Definition: RooBinning.h:84
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t _ownBoundHi
Definition: RooBinning.h:83
Int_t numBins() const
Definition: RooAbsBinning.h:37
~RooBinning()
Destructor.
Definition: RooBinning.cxx:101
virtual Double_t binLow(Int_t bin) const
Return the lower bound of the requested bin.
Definition: RooBinning.cxx:302
Double_t _xhi
Definition: RooBinning.h:81
Bool_t hasBoundary(Double_t boundary)
Check if boundary exists at given value.
Definition: RooBinning.cxx:163
void updateBinCount()
Update the internal bin counter.
Definition: RooBinning.cxx:251
virtual Int_t rawBinNumber(Double_t x) const
Return sequential bin number that contains value x where bin zero is the first bin that is defined...
Definition: RooBinning.cxx:194
static Double_t infinity()
Return internal infinity representation.
Definition: RooNumber.cxx:48
Double_t * _array
Definition: RooBinning.h:87
std::vector< Double_t > _boundaries
Definition: RooBinning.h:86
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual Double_t highBound() const
Definition: RooBinning.h:53
double Double_t
Definition: RtypesCore.h:55
virtual Int_t binNumber(Double_t x) const
Return sequential bin number that contains value x where bin zero is the first bin with an upper boun...
Definition: RooBinning.cxx:184
Bool_t binEdges(Int_t bin, Double_t &xlo, Double_t &xhi) const
Return upper and lower bound of bin 'bin'.
Definition: RooBinning.cxx:269
virtual Double_t lowBound() const
Definition: RooBinning.h:49
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual Double_t * array() const
Return array of boundary values.
Definition: RooBinning.cxx:217
virtual Double_t binHigh(Int_t bin) const
Return the upper bound of the requested bin.
Definition: RooBinning.cxx:312
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
Bool_t removeBoundary(Double_t boundary)
Remove boundary at given value.
Definition: RooBinning.cxx:138
void addBoundaryPair(Double_t boundary, Double_t mirrorPoint=0)
Add pair of boundaries: one at 'boundary' and one at 2*mirrorPoint-boundary.
Definition: RooBinning.cxx:129
Bool_t _ownBoundLo
Definition: RooBinning.h:82
virtual Double_t binCenter(Int_t bin) const
Return the position of the center of bin 'bin'.
Definition: RooBinning.cxx:282