Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "RooDouble.h"
21#include "RooAbsBinning.h"
22#include "RooNumber.h"
23#include <vector>
24class RooAbsPdf;
25class RooRealVar;
26
27
28class RooBinning : public RooAbsBinning {
29public:
30
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()); }
37
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;
45
46 virtual void setRange(Double_t xlo, Double_t xhi);
47
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;
61
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;
66
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);
71
72 Bool_t hasBoundary(Double_t boundary);
73
74protected:
75
76 Bool_t binEdges(Int_t bin, Double_t& xlo, Double_t& xhi) const;
77 void updateBinCount();
78
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
84
85 std::vector<Double_t> _boundaries; // Boundaries
86 mutable Double_t* _array; //! Array of boundaries
87 mutable Int_t _blo; //! bin number for _xlo
88
89 ClassDef(RooBinning,3) // Generic binning specification
90};
91
92#endif
double Double_t
Definition RtypesCore.h:59
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
Int_t numBins() const
Return number of bins.
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
Definition RooBinning.h:28
virtual void setRange(Double_t xlo, Double_t xhi)
Change the defined range associated with this binning.
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...
virtual Double_t averageBinWidth() const
Definition RooBinning.h:56
virtual Double_t binLow(Int_t bin) const
Return the lower bound of the requested bin.
Bool_t hasBoundary(Double_t boundary)
Check if boundary exists at given value.
virtual Double_t binCenter(Int_t bin) const
Return the position of the center of bin 'bin'.
void updateBinCount()
Update the internal bin counter.
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,...
virtual Int_t numBoundaries() const
Definition RooBinning.h:38
Double_t * _array
Definition RooBinning.h:86
virtual Double_t highBound() const
Definition RooBinning.h:52
Double_t _xlo
Definition RooBinning.h:79
Bool_t _ownBoundLo
Definition RooBinning.h:81
Int_t _blo
Array of boundaries.
Definition RooBinning.h:87
RooAbsBinning * clone(const char *name=0) const
Definition RooBinning.h:35
Bool_t _ownBoundHi
Definition RooBinning.h:82
Bool_t binEdges(Int_t bin, Double_t &xlo, Double_t &xhi) const
Return upper and lower bound of bin 'bin'.
void addUniform(Int_t nBins, Double_t xlo, Double_t xhi)
Add array of nbins uniformly sized bins in range [xlo,xhi].
Bool_t addBoundary(Double_t boundary)
Add bin boundary at given value.
void addBoundaryPair(Double_t boundary, Double_t mirrorPoint=0)
Add pair of boundaries: one at 'boundary' and one at 2*mirrorPoint-boundary.
~RooBinning()
Destructor.
Bool_t removeBoundary(Double_t boundary)
Remove boundary at given value.
virtual Double_t binHigh(Int_t bin) const
Return the upper bound of the requested bin.
virtual Double_t lowBound() const
Definition RooBinning.h:48
virtual Double_t binWidth(Int_t bin) const
Return the width of the requested bin.
Int_t _nbins
Definition RooBinning.h:83
virtual Double_t nearestBoundary(Double_t x) const
Return the value of the nearest boundary to x.
Double_t _xhi
Definition RooBinning.h:80
std::vector< Double_t > _boundaries
Definition RooBinning.h:85
virtual Double_t * array() const
Return array of boundary values.
static Double_t infinity()
Return internal infinity representation.
Definition RooNumber.cxx:49
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Double_t x[n]
Definition legend1.C:17