Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsBinning.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooAbsBinning.h,v 1.13 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_ABS_BINNING
17#define ROO_ABS_BINNING
18
19#include "Rtypes.h"
20#include "RooPrintable.h"
21#include "TNamed.h"
22class RooAbsRealLValue ;
23class RooAbsReal ;
24
25class RooAbsBinning : public TNamed, public RooPrintable {
26public:
27
28 RooAbsBinning(const char* name=nullptr) : TNamed{name, name} {}
29 RooAbsBinning(const RooAbsBinning& other, const char* name=nullptr) : TNamed(name,name), RooPrintable(other) {
30 // Copy constructor
31 }
32 TObject* Clone(const char* newname=nullptr) const override { return clone(newname) ; }
33 virtual RooAbsBinning* clone(const char* name=nullptr) const = 0 ;
34
35 /// Return number of bins.
36 Int_t numBins() const {
37 return numBoundaries()-1 ;
38 }
39 virtual Int_t numBoundaries() const = 0 ;
40
41 /// Compute the bin indices for multiple values of `x`.
42 ///
43 /// For each element in the input, the corresponding output element will be
44 /// increased by `coef * binIdx`. This is useful for aggregating
45 /// multi-dimensional bin indices inplace.
46 ///
47 /// param[in] x The read-only input array of values of `x`.
48 /// param[out] bins The output array. Note that the initial values don't get
49 /// replaced! The result is added to the array elements.
50 /// param[in] n The size of the input and output arrays.
51 /// param[in] coef The multiplication factor that is applied to all calculated bin indices.
52 virtual void binNumbers(double const * x, int * bins, std::size_t n, int coef=1) const = 0 ;
53
54 /// Returns the bin number corresponding to the value `x`.
55 ///
56 /// \note This `inline` function is implemented by calling the vectorized
57 /// function `RooAbsBinning::binNumbers()`. If you want to calculate
58 /// the bin indices for multiple values, use that one for better
59 /// performance.
60 inline int binNumber(double x) const {
61 int out = 0.0;
62 binNumbers(&x, &out, 1);
63 return out;
64 }
65
66 virtual double binCenter(Int_t bin) const = 0 ;
67 virtual double binWidth(Int_t bin) const = 0 ;
68 virtual double binLow(Int_t bin) const = 0 ;
69 virtual double binHigh(Int_t bin) const = 0 ;
70 virtual bool isUniform() const { return false ; }
71
72 virtual void setRange(double xlo, double xhi) = 0 ;
73 /// Change lower bound to xlo.
74 virtual void setMin(double xlo) {
75 setRange(xlo,highBound()) ;
76 }
77 /// Change upper bound to xhi.
78 virtual void setMax(double xhi) {
79 setRange(lowBound(),xhi) ;
80 }
81
82 virtual double lowBound() const = 0 ;
83 virtual double highBound() const = 0 ;
84 virtual double averageBinWidth() const = 0 ;
85
86
87 virtual double* array() const = 0 ;
88
89 inline void Print(Option_t *options= nullptr) const override {
90 // Printing interface
92 }
93
94 void printName(std::ostream& os) const override ;
95 void printTitle(std::ostream& os) const override ;
96 void printClassName(std::ostream& os) const override ;
97 void printArgs(std::ostream& os) const override ;
98 void printValue(std::ostream& os) const override ;
99
100 /// Interface function. If true, min/max of binning is parameterized by external RooAbsReals.
101 /// Default to `false`, unless overridden by a sub class.
102 virtual bool isParameterized() const {
103 return false ;
104 }
105 /// Return pointer to RooAbsReal parameterized lower bound, if any.
106 virtual RooAbsReal* lowBoundFunc() const {
107 return nullptr ;
108 }
109 /// Return pointer to RooAbsReal parameterized upper bound, if any.
110 virtual RooAbsReal* highBoundFunc() const {
111 return nullptr ;
112 }
113 /// If true (default), the range definition can be shared across clones of a RooRealVar.
114 virtual bool isShareable() const {
115 return true ;
116 }
117 /// Hook interface function to execute code upon insertion into a RooAbsRealLValue.
118 virtual void insertHook(RooAbsRealLValue&) const { }
119 /// Hook interface function to execute code upon removal from a RooAbsRealLValue.
120 virtual void removeHook(RooAbsRealLValue&) const { }
121
122
123protected:
124
125 ClassDefOverride(RooAbsBinning,2) // Abstract base class for binning specification
126};
127
128#endif
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
char name[80]
Definition TGX11.cxx:110
Abstract base class for RooRealVar binning definitions.
void printTitle(std::ostream &os) const override
Print binning title.
virtual void removeHook(RooAbsRealLValue &) const
Hook interface function to execute code upon removal from a RooAbsRealLValue.
int binNumber(double x) const
Returns the bin number corresponding to the value x.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
virtual void binNumbers(double const *x, int *bins, std::size_t n, int coef=1) const =0
Compute the bin indices for multiple values of x.
virtual double binCenter(Int_t bin) const =0
RooAbsBinning(const RooAbsBinning &other, const char *name=nullptr)
Int_t numBins() const
Return number of bins.
virtual bool isShareable() const
If true (default), the range definition can be shared across clones of a RooRealVar.
virtual double averageBinWidth() const =0
virtual void insertHook(RooAbsRealLValue &) const
Hook interface function to execute code upon insertion into a RooAbsRealLValue.
virtual bool isParameterized() const
Interface function.
virtual double binLow(Int_t bin) const =0
virtual bool isUniform() const
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
virtual double highBound() const =0
virtual void setRange(double xlo, double xhi)=0
virtual void setMin(double xlo)
Change lower bound to xlo.
virtual double lowBound() const =0
virtual RooAbsReal * highBoundFunc() const
Return pointer to RooAbsReal parameterized upper bound, if any.
virtual double binHigh(Int_t bin) const =0
virtual Int_t numBoundaries() const =0
void printArgs(std::ostream &os) const override
Print binning arguments (the RooAbsReal objects represening the variable bin boundaries for parameter...
virtual double * array() const =0
virtual RooAbsReal * lowBoundFunc() const
Return pointer to RooAbsReal parameterized lower bound, if any.
void printClassName(std::ostream &os) const override
Print binning class name.
void printName(std::ostream &os) const override
Print binning name.
virtual double binWidth(Int_t bin) const =0
RooAbsBinning(const char *name=nullptr)
void printValue(std::ostream &os) const override
Print binning value, i.e the bin boundary positions.
virtual void setMax(double xhi)
Change upper bound to xhi.
virtual RooAbsBinning * clone(const char *name=nullptr) const =0
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
A 'mix-in' base class that define the standard RooFit plotting and printing methods.
virtual StyleOption defaultPrintStyle(Option_t *opt) const
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
static std::ostream & defaultPrintStream(std::ostream *os=nullptr)
Return a reference to the current default stream to use in Print().
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16