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
22#include <TNamed.h>
23
24class RooAbsRealLValue ;
25class RooAbsArg ;
26class RooAbsReal ;
27namespace RooFit {
28namespace Detail {
29class CodeSquashContext;
30}
31}
32
33class RooAbsBinning : public TNamed, public RooPrintable {
34public:
35
36 RooAbsBinning(const char* name=nullptr) : TNamed{name, name} {}
38 // Copy constructor
39 }
40 TObject* Clone(const char* newname=nullptr) const override { return clone(newname) ; }
41 virtual RooAbsBinning* clone(const char* name=nullptr) const = 0 ;
42
43 /// Return number of bins.
44 Int_t numBins() const {
45 return numBoundaries()-1 ;
46 }
47 virtual Int_t numBoundaries() const = 0 ;
48
49 /// Compute the bin indices for multiple values of `x`.
50 ///
51 /// For each element in the input, the corresponding output element will be
52 /// increased by `coef * binIdx`. This is useful for aggregating
53 /// multi-dimensional bin indices inplace.
54 ///
55 /// param[in] x The read-only input array of values of `x`.
56 /// param[out] bins The output array. Note that the initial values don't get
57 /// replaced! The result is added to the array elements.
58 /// param[in] n The size of the input and output arrays.
59 /// param[in] coef The multiplication factor that is applied to all calculated bin indices.
60 virtual void binNumbers(double const * x, int * bins, std::size_t n, int coef=1) const = 0 ;
61
62 /// Returns the bin number corresponding to the value `x`.
63 ///
64 /// \note This `inline` function is implemented by calling the vectorized
65 /// function `RooAbsBinning::binNumbers()`. If you want to calculate
66 /// the bin indices for multiple values, use that one for better
67 /// performance.
68 inline int binNumber(double x) const {
69 int out = 0.0;
70 binNumbers(&x, &out, 1);
71 return out;
72 }
73
74 virtual std::string translateBinNumber(RooFit::Detail::CodeSquashContext &ctx, RooAbsArg const &var, int coef) const;
75
76 virtual double binCenter(Int_t bin) const = 0 ;
77 virtual double binWidth(Int_t bin) const = 0 ;
78 virtual double binLow(Int_t bin) const = 0 ;
79 virtual double binHigh(Int_t bin) const = 0 ;
80 virtual bool isUniform() const { return false ; }
81
82 virtual void setRange(double xlo, double xhi) = 0 ;
83 /// Change lower bound to xlo.
84 virtual void setMin(double xlo) {
85 setRange(xlo,highBound()) ;
86 }
87 /// Change upper bound to xhi.
88 virtual void setMax(double xhi) {
89 setRange(lowBound(),xhi) ;
90 }
91
92 virtual double lowBound() const = 0 ;
93 virtual double highBound() const = 0 ;
94 virtual double averageBinWidth() const = 0 ;
95
96
97 virtual double* array() const = 0 ;
98
99 inline void Print(Option_t *options= nullptr) const override {
100 // Printing interface
102 }
103
104 void printName(std::ostream& os) const override ;
105 void printTitle(std::ostream& os) const override ;
106 void printClassName(std::ostream& os) const override ;
107 void printArgs(std::ostream& os) const override ;
108 void printValue(std::ostream& os) const override ;
109
110 /// Interface function. If true, min/max of binning is parameterized by external RooAbsReals.
111 /// Default to `false`, unless overridden by a sub class.
112 virtual bool isParameterized() const {
113 return false ;
114 }
115 /// Return pointer to RooAbsReal parameterized lower bound, if any.
116 virtual RooAbsReal* lowBoundFunc() const {
117 return nullptr ;
118 }
119 /// Return pointer to RooAbsReal parameterized upper bound, if any.
120 virtual RooAbsReal* highBoundFunc() const {
121 return nullptr ;
122 }
123 /// If true (default), the range definition can be shared across clones of a RooRealVar.
124 virtual bool isShareable() const {
125 return true ;
126 }
127 /// Hook interface function to execute code upon insertion into a RooAbsRealLValue.
128 virtual void insertHook(RooAbsRealLValue&) const { }
129 /// Hook interface function to execute code upon removal from a RooAbsRealLValue.
130 virtual void removeHook(RooAbsRealLValue&) const { }
131
132
133protected:
134
135 ClassDefOverride(RooAbsBinning,2) // Abstract base class for binning specification
136};
137
138#endif
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:79
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 std::string translateBinNumber(RooFit::Detail::CodeSquashContext &ctx, RooAbsArg const &var, int coef) const
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 class to maintain the context for squashing of RooFit models into code.
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
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26