Logo ROOT   6.16/01
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>
25class RooAbsPdf;
26class RooRealVar;
27
28
29class RooBinning : public RooAbsBinning {
30public:
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()); }
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);
72
73 Bool_t hasBoundary(Double_t boundary);
74
75protected:
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
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:324
RooAbsBinning is the abstract base class for RooRealVar binning definitions This class defines the in...
Definition: RooAbsBinning.h:26
Int_t numBins() const
Definition: RooAbsBinning.h:37
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
Definition: RooBinning.h:29
virtual void setRange(Double_t xlo, Double_t xhi)
Change the defined range associated with this binning.
Definition: RooBinning.cxx:233
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
virtual Double_t averageBinWidth() const
Definition: RooBinning.h:57
virtual Double_t binLow(Int_t bin) const
Return the lower bound of the requested bin.
Definition: RooBinning.cxx:304
Bool_t hasBoundary(Double_t boundary)
Check if boundary exists at given value.
Definition: RooBinning.cxx:165
virtual Double_t binCenter(Int_t bin) const
Return the position of the center of bin 'bin'.
Definition: RooBinning.cxx:284
void updateBinCount()
Update the internal bin counter.
Definition: RooBinning.cxx:253
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
virtual Int_t numBoundaries() const
Definition: RooBinning.h:39
Double_t * _array
Definition: RooBinning.h:87
virtual Double_t highBound() const
Definition: RooBinning.h:53
Double_t _xlo
Definition: RooBinning.h:80
Bool_t _ownBoundLo
Definition: RooBinning.h:82
Int_t _blo
Array of boundaries.
Definition: RooBinning.h:88
RooAbsBinning * clone(const char *name=0) const
Definition: RooBinning.h:36
Bool_t _ownBoundHi
Definition: RooBinning.h:83
Bool_t binEdges(Int_t bin, Double_t &xlo, Double_t &xhi) const
Return upper and lower bound of bin 'bin'.
Definition: RooBinning.cxx:271
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
Bool_t addBoundary(Double_t boundary)
Add bin boundary at given value.
Definition: RooBinning.cxx:111
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:131
~RooBinning()
Destructor.
Definition: RooBinning.cxx:103
Bool_t removeBoundary(Double_t boundary)
Remove boundary at given value.
Definition: RooBinning.cxx:140
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
virtual Double_t binHigh(Int_t bin) const
Return the upper bound of the requested bin.
Definition: RooBinning.cxx:314
virtual Double_t lowBound() const
Definition: RooBinning.h:49
virtual Double_t binWidth(Int_t bin) const
Return the width of the requested bin.
Definition: RooBinning.cxx:294
Int_t _nbins
Definition: RooBinning.h:84
virtual Double_t nearestBoundary(Double_t x) const
Return the value of the nearest boundary to x.
Definition: RooBinning.cxx:209
Double_t _xhi
Definition: RooBinning.h:81
std::vector< Double_t > _boundaries
Definition: RooBinning.h:86
virtual Double_t * array() const
Return array of boundary values.
Definition: RooBinning.cxx:219
static Double_t infinity()
Return internal infinity representation.
Definition: RooNumber.cxx:49
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Double_t x[n]
Definition: legend1.C:17