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 "RooAbsBinning.h"
21#include "RooNumber.h"
22#include <vector>
23class RooAbsPdf;
24class RooRealVar;
25
26
27class RooBinning : public RooAbsBinning {
28public:
29
30 RooBinning(double xlo = -RooNumber::infinity(), double xhi = RooNumber::infinity(), const char* name = nullptr);
31 RooBinning(Int_t nBins, double xlo, double xhi, const char* name = nullptr);
32 RooBinning(Int_t nBins, const double* boundaries, const char* name = nullptr);
33 RooBinning(const RooBinning& other, const char* name = nullptr);
34 RooAbsBinning* clone(const char* name = nullptr) const override { return new RooBinning(*this,name?name:GetName()); }
35 ~RooBinning() override;
36
37 /// Return the number boundaries
38 Int_t numBoundaries() const override {
39 return _nbins+1;
40 }
41 void binNumbers(double const * x, int * bins, std::size_t n, int coef) const override;
42 Int_t rawBinNumber(double x) const;
43 virtual double nearestBoundary(double x) const;
44
45 void setRange(double xlo, double xhi) override;
46
47 /// Return the lower bound value
48 double lowBound() const override {
49 return _xlo;
50 }
51
52 /// Return the upper bound value
53 double highBound() const override {
54 return _xhi;
55 }
56
57 /// Return the average bin width
58 double averageBinWidth() const override {
59 return (highBound() - lowBound()) / numBins();
60 }
61 double* array() const override;
62
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;
67
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);
72
73protected:
74
75 bool binEdges(Int_t bin, double& xlo, double& xhi) const;
76 void updateBinCount();
77
78 double _xlo; ///< Lower bound
79 double _xhi; ///< Upper bound
80 bool _ownBoundLo; ///< Does the lower bound coincide with a bin boundary
81 bool _ownBoundHi; ///< Does the upper bound coincide with a bin boundary
82 Int_t _nbins; ///< Numer of bins
83
84 std::vector<double> _boundaries; ///< Boundaries
85 mutable double* _array; ///<! Array of boundaries
86 mutable Int_t _blo; ///<! bin number for _xlo
87
88 ClassDefOverride(RooBinning,3) // Generic binning specification
89};
90
91#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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:27
double binLow(Int_t bin) const override
Return the lower bound of the requested bin.
double * array() const override
Return array of boundary values.
Int_t rawBinNumber(double x) const
Return sequential bin number that contains value x where bin zero is the first bin that is defined,...
void updateBinCount()
Update the internal bin counter.
double highBound() const override
Return the upper bound value.
Definition RooBinning.h:53
double _xhi
Upper bound.
Definition RooBinning.h:79
Int_t _blo
! bin number for _xlo
Definition RooBinning.h:86
std::vector< double > _boundaries
Boundaries.
Definition RooBinning.h:84
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
Destructor.
bool addBoundary(double boundary)
Add bin boundary at given value.
void binNumbers(double const *x, int *bins, std::size_t n, int coef) const override
Return sequential bin number that contains value x where bin zero is the first bin with an upper boun...
void addUniform(Int_t nBins, double xlo, double xhi)
Add array of nbins uniformly sized bins in range [xlo,xhi].
double binCenter(Int_t bin) const override
Return the position of the center of bin 'bin'.
RooAbsBinning * clone(const char *name=nullptr) const override
Definition RooBinning.h:34
double binHigh(Int_t bin) const override
Return the upper bound of the requested bin.
bool _ownBoundHi
Does the upper bound coincide with a bin boundary.
Definition RooBinning.h:81
double * _array
! Array of boundaries
Definition RooBinning.h:85
double binWidth(Int_t bin) const override
Return the width of the requested bin.
Int_t _nbins
Numer of bins.
Definition RooBinning.h:82
void addBoundaryPair(double boundary, double mirrorPoint=0)
Add pair of boundaries: one at 'boundary' and one at 2*mirrorPoint-boundary.
bool _ownBoundLo
Does the lower bound coincide with a bin boundary.
Definition RooBinning.h:80
double lowBound() const override
Return the lower bound value.
Definition RooBinning.h:48
double _xlo
Lower bound.
Definition RooBinning.h:78
bool removeBoundary(double boundary)
Remove boundary at given value.
virtual double nearestBoundary(double x) const
Return the value of the nearest boundary to x.
bool binEdges(Int_t bin, double &xlo, double &xhi) const
Return upper and lower bound of bin 'bin'.
void setRange(double xlo, double xhi) override
Change the defined range associated with this binning.
static constexpr double infinity()
Return internal infinity representation.
Definition RooNumber.h:24
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
const Int_t n
Definition legend1.C:16