Logo ROOT   6.10/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 Double_t averageBinWidth() const
Definition: RooBinning.h:57
virtual void setRange(Double_t xlo, Double_t xhi)
Change the defined range associated with this binning.
Definition: RooBinning.cxx:232
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual Double_t * array() const
Return array of boundary values.
Definition: RooBinning.cxx:218
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:52
Double_t _xlo
Definition: RooBinning.h:80
virtual Double_t binHigh(Int_t bin) const
Return the upper bound of the requested bin.
Definition: RooBinning.cxx:313
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:172
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:195
Bool_t addBoundary(Double_t boundary)
Add bin boundary at given value.
Definition: RooBinning.cxx:110
RooAbsBinning * clone(const char *name=0) const
Definition: RooBinning.h:36
Int_t _nbins
Definition: RooBinning.h:84
Double_t x[n]
Definition: legend1.C:17
virtual Int_t numBoundaries() const
Definition: RooBinning.h:39
#define ClassDef(name, id)
Definition: Rtypes.h:297
Bool_t _ownBoundHi
Definition: RooBinning.h:83
virtual Double_t nearestBoundary(Double_t x) const
Return the value of the nearest boundary to x.
Definition: RooBinning.cxx:208
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values, posing no constraints on the choice of binning, thus allowing variable bin sizes.
Definition: RooBinning.h:29
virtual Double_t binWidth(Int_t bin) const
Return the width of the requested bin.
Definition: RooBinning.cxx:293
Bool_t binEdges(Int_t bin, Double_t &xlo, Double_t &xhi) const
Return upper and lower bound of bin &#39;bin&#39;.
Definition: RooBinning.cxx:270
~RooBinning()
Destructor.
Definition: RooBinning.cxx:102
virtual Double_t lowBound() const
Definition: RooBinning.h:49
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
Double_t _xhi
Definition: RooBinning.h:81
Bool_t hasBoundary(Double_t boundary)
Check if boundary exists at given value.
Definition: RooBinning.cxx:164
void updateBinCount()
Update the internal bin counter.
Definition: RooBinning.cxx:252
static Double_t infinity()
Return internal infinity representation.
Definition: RooNumber.cxx:49
Double_t * _array
Definition: RooBinning.h:87
std::vector< Double_t > _boundaries
Definition: RooBinning.h:86
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:185
RooAbsBinning is the abstract base class for RooRealVar binning definitions This class defines the in...
Definition: RooAbsBinning.h:26
double Double_t
Definition: RtypesCore.h:55
Int_t numBins() const
Definition: RooAbsBinning.h:37
virtual Double_t binLow(Int_t bin) const
Return the lower bound of the requested bin.
Definition: RooBinning.cxx:303
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:139
void addBoundaryPair(Double_t boundary, Double_t mirrorPoint=0)
Add pair of boundaries: one at &#39;boundary&#39; and one at 2*mirrorPoint-boundary.
Definition: RooBinning.cxx:130
Bool_t _ownBoundLo
Definition: RooBinning.h:82
virtual Double_t binCenter(Int_t bin) const
Return the position of the center of bin &#39;bin&#39;.
Definition: RooBinning.cxx:283
virtual Double_t highBound() const
Definition: RooBinning.h:53