Logo ROOT   master
Reference Guide
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
19 #include "Rtypes.h"
20 #include "RooDouble.h"
21 #include "RooAbsBinning.h"
22 #include "RooNumber.h"
23 #include <vector>
24 class RooAbsPdf;
25 class RooRealVar;
28 class RooBinning : public RooAbsBinning {
29 public:
31  RooBinning(Double_t xlo = -RooNumber::infinity(), Double_t xhi = RooNumber::infinity(), const char* name = 0);
32  RooBinning(Int_t nBins, Double_t xlo, Double_t xhi, const char* name = 0);
33  RooBinning(Int_t nBins, const Double_t* boundaries, const char* name = 0);
34  RooBinning(const RooBinning& other, const char* name = 0);
35  RooAbsBinning* clone(const char* name = 0) const { return new RooBinning(*this,name?name:GetName()); }
36  ~RooBinning();
38  virtual Int_t numBoundaries() const {
39  // Return the number boundaries
40  return _nbins+1;
41  }
42  virtual Int_t binNumber(Double_t x) const;
43  virtual Int_t rawBinNumber(Double_t x) const;
44  virtual Double_t nearestBoundary(Double_t x) const;
46  virtual void setRange(Double_t xlo, Double_t xhi);
48  virtual Double_t lowBound() const {
49  // Return the lower bound value
50  return _xlo;
51  }
52  virtual Double_t highBound() const {
53  // Return the upper bound value
54  return _xhi;
55  }
56  virtual Double_t averageBinWidth() const {
57  // Return the average bin width
58  return (highBound() - lowBound()) / numBins();
59  }
60  virtual Double_t* array() const;
62  virtual Double_t binCenter(Int_t bin) const;
63  virtual Double_t binWidth(Int_t bin) const;
64  virtual Double_t binLow(Int_t bin) const;
65  virtual Double_t binHigh(Int_t bin) const;
67  Bool_t addBoundary(Double_t boundary);
68  void addBoundaryPair(Double_t boundary, Double_t mirrorPoint = 0);
69  void addUniform(Int_t nBins, Double_t xlo, Double_t xhi);
70  Bool_t removeBoundary(Double_t boundary);
72  Bool_t hasBoundary(Double_t boundary);
74 protected:
76  Bool_t binEdges(Int_t bin, Double_t& xlo, Double_t& xhi) const;
77  void updateBinCount();
79  Double_t _xlo; // Lower bound
80  Double_t _xhi; // Upper bound
81  Bool_t _ownBoundLo; // Does the lower bound coincide with a bin boundary
82  Bool_t _ownBoundHi; // Does the upper bound coincide with a bin boundary
83  Int_t _nbins; // Numer of bins
85  std::vector<Double_t> _boundaries; // Boundaries
86  mutable Double_t* _array; //! Array of boundaries
87  mutable Int_t _blo; //! bin number for _xlo
89  ClassDef(RooBinning,3) // Generic binning specification
90 };
92 #endif
virtual Double_t averageBinWidth() const
Definition: RooBinning.h:56
virtual void setRange(Double_t xlo, Double_t xhi)
Change the defined range associated with this binning.
Definition: RooBinning.cxx:233
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:219
Int_t _blo
Array of boundaries.
Definition: RooBinning.h:87
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:53
Double_t _xlo
Definition: RooBinning.h:79
virtual Double_t binHigh(Int_t bin) const
Return the upper bound of the requested bin.
Definition: RooBinning.cxx:314
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:173
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:196
Bool_t addBoundary(Double_t boundary)
Add bin boundary at given value.
Definition: RooBinning.cxx:111
RooAbsBinning * clone(const char *name=0) const
Definition: RooBinning.h:35
Int_t _nbins
Definition: RooBinning.h:83
Double_t x[n]
Definition: legend1.C:17
virtual Int_t numBoundaries() const
Definition: RooBinning.h:38
#define ClassDef(name, id)
Definition: Rtypes.h:322
Bool_t _ownBoundHi
Definition: RooBinning.h:82
virtual Double_t nearestBoundary(Double_t x) const
Return the value of the nearest boundary to x.
Definition: RooBinning.cxx:209
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:28
virtual Double_t binWidth(Int_t bin) const
Return the width of the requested bin.
Definition: RooBinning.cxx:294
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:271
Definition: RooBinning.cxx:103
virtual Double_t lowBound() const
Definition: RooBinning.h:48
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
Double_t _xhi
Definition: RooBinning.h:80
Bool_t hasBoundary(Double_t boundary)
Check if boundary exists at given value.
Definition: RooBinning.cxx:165
void updateBinCount()
Update the internal bin counter.
Definition: RooBinning.cxx:253
static Double_t infinity()
Return internal infinity representation.
Definition: RooNumber.cxx:49
Double_t * _array
Definition: RooBinning.h:86
std::vector< Double_t > _boundaries
Definition: RooBinning.h:85
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:186
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:57
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:304
RooAbsPdf, the base class of all PDFs
Definition: RooAbsPdf.h:40
Bool_t removeBoundary(Double_t boundary)
Remove boundary at given value.
Definition: RooBinning.cxx:140
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:131
Bool_t _ownBoundLo
Definition: RooBinning.h:81
virtual Double_t binCenter(Int_t bin) const
Return the position of the center of bin &#39;bin&#39;.
Definition: RooBinning.cxx:284
virtual Double_t highBound() const
Definition: RooBinning.h:52
char name[80]
Definition: TGX11.cxx:109