Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 virtual double nearestBoundary(double x) const;
43
44 void setRange(double xlo, double xhi) override;
45
46 /// Return the lower bound value
47 double lowBound() const override {
48 return _xlo;
49 }
50
51 /// Return the upper bound value
52 double highBound() const override {
53 return _xhi;
54 }
55
56 /// Return the average bin width
57 double averageBinWidth() const override {
58 return (highBound() - lowBound()) / numBins();
59 }
60 double* array() const override;
61
62 double binCenter(Int_t bin) const override;
63 double binWidth(Int_t bin) const override;
64 double binLow(Int_t bin) const override;
65 double binHigh(Int_t bin) const override;
66
67 bool addBoundary(double boundary);
68 void addBoundaryPair(double boundary, double mirrorPoint = 0);
69 void addUniform(Int_t nBins, double xlo, double xhi);
70 bool removeBoundary(double boundary);
71
72 std::string translateBinNumber(RooFit::Experimental::CodegenContext &ctx, RooAbsArg const &var, int coef) const override;
73
74protected:
75
76 bool binEdges(Int_t bin, double& xlo, double& xhi) const;
77 void updateBinCount();
78
79 double _xlo = 0.0; ///< Lower bound
80 double _xhi = 0.0; ///< Upper bound
81 bool _ownBoundLo = true; ///< Does the lower bound coincide with a bin boundary
82 bool _ownBoundHi = true; ///< Does the upper bound coincide with a bin boundary
83 Int_t _nbins; ///< Number of bins
84
85 std::vector<double> _boundaries; ///< Boundaries
86 mutable double* _array = nullptr; ///<! Array of boundaries
87 mutable Int_t _blo = 0.0; ///<! bin number for _xlo
88
89 ClassDefOverride(RooBinning,3) // Generic binning specification
90};
91
92#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
char name[80]
Definition TGX11.cxx:110
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
Abstract base class for RooRealVar binning definitions.
Int_t numBins() const
Return number of bins.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Implements a RooAbsBinning in terms of an array of boundary values, posing no constraints on the choi...
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.
void updateBinCount()
Update the internal bin counter.
double highBound() const override
Return the upper bound value.
Definition RooBinning.h:52
double _xhi
Upper bound.
Definition RooBinning.h:80
Int_t _blo
! bin number for _xlo
Definition RooBinning.h:87
std::vector< double > _boundaries
Boundaries.
Definition RooBinning.h:85
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:57
~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...
RooBinning(double xlo=-RooNumber::infinity(), double xhi=RooNumber::infinity(), const char *name=nullptr)
Constructor for an initially empty binning defining the range [xlo,xhi].
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'.
std::string translateBinNumber(RooFit::Experimental::CodegenContext &ctx, RooAbsArg const &var, int coef) const override
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:82
double * _array
! Array of boundaries
Definition RooBinning.h:86
double binWidth(Int_t bin) const override
Return the width of the requested bin.
Int_t _nbins
Number of bins.
Definition RooBinning.h:83
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:81
double lowBound() const override
Return the lower bound value.
Definition RooBinning.h:47
double _xlo
Lower bound.
Definition RooBinning.h:79
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.
A class to maintain the context for squashing of RooFit models into code.
static constexpr double infinity()
Return internal infinity representation.
Definition RooNumber.h:25
Variable that can be changed from the outside.
Definition RooRealVar.h:37
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