Logo ROOT  
Reference Guide
Go to the documentation of this file.
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 "RooAbsBinning.h"
21#include "RooNumber.h"
22#include <vector>
23class RooAbsPdf;
24class RooRealVar;
27class RooBinning : public RooAbsBinning {
30 RooBinning(double xlo = -RooNumber::infinity(), double xhi = RooNumber::infinity(), const char* name = 0);
31 RooBinning(Int_t nBins, double xlo, double xhi, const char* name = 0);
32 RooBinning(Int_t nBins, const double* boundaries, const char* name = 0);
33 RooBinning(const RooBinning& other, const char* name = 0);
34 RooAbsBinning* clone(const char* name = 0) const override { return new RooBinning(*this,name?name:GetName()); }
35 ~RooBinning() override;
37 /// Return the number boundaries
38 Int_t numBoundaries() const override {
39 return _nbins+1;
40 }
41 Int_t binNumber(double x) const override;
42 Int_t rawBinNumber(double x) const override;
43 virtual double nearestBoundary(double x) const;
45 void setRange(double xlo, double xhi) override;
47 /// Return the lower bound value
48 double lowBound() const override {
49 return _xlo;
50 }
52 /// Return the upper bound value
53 double highBound() const override {
54 return _xhi;
55 }
57 /// Return the average bin width
58 double averageBinWidth() const override {
59 return (highBound() - lowBound()) / numBins();
60 }
61 double* array() const override;
63 double binCenter(Int_t bin) const override;
64 double binWidth(Int_t bin) const override;
65 double binLow(Int_t bin) const override;
66 double binHigh(Int_t bin) const override;
68 bool addBoundary(double boundary);
69 void addBoundaryPair(double boundary, double mirrorPoint = 0);
70 void addUniform(Int_t nBins, double xlo, double xhi);
71 bool removeBoundary(double boundary);
73 bool hasBoundary(double boundary);
77 bool binEdges(Int_t bin, double& xlo, double& xhi) const;
78 void updateBinCount();
80 double _xlo; ///< Lower bound
81 double _xhi; ///< Upper bound
82 bool _ownBoundLo; ///< Does the lower bound coincide with a bin boundary
83 bool _ownBoundHi; ///< Does the upper bound coincide with a bin boundary
84 Int_t _nbins; ///< Numer of bins
86 std::vector<double> _boundaries; ///< Boundaries
87 mutable double* _array; ///<! Array of boundaries
88 mutable Int_t _blo; ///<! bin number for _xlo
90 ClassDefOverride(RooBinning,3) // Generic binning specification
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
char name[80]
Definition: TGX11.cxx:110
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
Definition: RooAbsBinning.h:26
Int_t numBins() const
Return number of bins.
Definition: RooAbsBinning.h:38
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
Definition: RooBinning.h:27
double binLow(Int_t bin) const override
Return the lower bound of the requested bin.
Definition: RooBinning.cxx:302
double * array() const override
Return array of boundary values.
Definition: RooBinning.cxx:217
Int_t rawBinNumber(double x) const override
Return sequential bin number that contains value x where bin zero is the first bin that is defined,...
Definition: RooBinning.cxx:194
Int_t binNumber(double x) const override
Return sequential bin number that contains value x where bin zero is the first bin with an upper boun...
Definition: RooBinning.cxx:184
void updateBinCount()
Update the internal bin counter.
Definition: RooBinning.cxx:251
double highBound() const override
Return the upper bound value.
Definition: RooBinning.h:53
double _xhi
Upper bound.
Definition: RooBinning.h:81
Int_t _blo
! bin number for _xlo
Definition: RooBinning.h:88
std::vector< double > _boundaries
Definition: RooBinning.h:86
RooAbsBinning * clone(const char *name=0) const override
Definition: RooBinning.h:34
Int_t numBoundaries() const override
Return the number boundaries.
Definition: RooBinning.h:38
double averageBinWidth() const override
Return the average bin width.
Definition: RooBinning.h:58
~RooBinning() override
Definition: RooBinning.cxx:101
bool addBoundary(double boundary)
Add bin boundary at given value.
Definition: RooBinning.cxx:109
void addUniform(Int_t nBins, double xlo, double xhi)
Add array of nbins uniformly sized bins in range [xlo,xhi].
Definition: RooBinning.cxx:171
double binCenter(Int_t bin) const override
Return the position of the center of bin 'bin'.
Definition: RooBinning.cxx:282
double binHigh(Int_t bin) const override
Return the upper bound of the requested bin.
Definition: RooBinning.cxx:312
bool _ownBoundHi
Does the upper bound coincide with a bin boundary.
Definition: RooBinning.h:83
double * _array
! Array of boundaries
Definition: RooBinning.h:87
double binWidth(Int_t bin) const override
Return the width of the requested bin.
Definition: RooBinning.cxx:292
RooBinning(double xlo=-RooNumber::infinity(), double xhi=RooNumber::infinity(), const char *name=0)
Constructor for an initially empty binning defining the range [xlo,xhi].
Definition: RooBinning.cxx:51
Int_t _nbins
Numer of bins.
Definition: RooBinning.h:84
void addBoundaryPair(double boundary, double mirrorPoint=0)
Add pair of boundaries: one at 'boundary' and one at 2*mirrorPoint-boundary.
Definition: RooBinning.cxx:129
bool _ownBoundLo
Does the lower bound coincide with a bin boundary.
Definition: RooBinning.h:82
double lowBound() const override
Return the lower bound value.
Definition: RooBinning.h:48
double _xlo
Lower bound.
Definition: RooBinning.h:80
bool removeBoundary(double boundary)
Remove boundary at given value.
Definition: RooBinning.cxx:138
virtual double nearestBoundary(double x) const
Return the value of the nearest boundary to x.
Definition: RooBinning.cxx:207
bool binEdges(Int_t bin, double &xlo, double &xhi) const
Return upper and lower bound of bin 'bin'.
Definition: RooBinning.cxx:269
bool hasBoundary(double boundary)
Check if boundary exists at given value.
Definition: RooBinning.cxx:163
void setRange(double xlo, double xhi) override
Change the defined range associated with this binning.
Definition: RooBinning.cxx:231
static double infinity()
Return internal infinity representation.
Definition: RooNumber.cxx:48
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
Double_t x[n]
Definition: legend1.C:17