Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsRealLValue.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooAbsRealLValue.h,v 1.37 2007/07/13 21:50:24 wouter 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_REAL_LVALUE
17#define ROO_ABS_REAL_LVALUE
18
19#include <cmath>
20#include <cfloat>
21#include <utility>
22#include "TString.h"
23
24#include "RooAbsReal.h"
25#include "RooNumber.h"
26#include "RooAbsLValue.h"
27#include "RooAbsBinning.h"
28
29class RooArgSet ;
30
32public:
33 // Constructors, assignment etc.
34 inline RooAbsRealLValue() { }
35 RooAbsRealLValue(const char *name, const char *title, const char *unit= "") ;
36 RooAbsRealLValue(const RooAbsRealLValue& other, const char* name=nullptr);
37
38 // Parameter value and error accessors
39 /// Set the current value of the object. Needs to be overridden by implementations.
40 virtual void setVal(double value)=0;
41 /// Set the current value of the object. The rangeName is ignored.
42 /// Can be overridden by derived classes to e.g. check if the value fits in the given range.
43 virtual void setVal(double value, const char* /*rangeName*/) {
44 return setVal(value) ;
45 }
46 virtual RooAbsArg& operator=(double newValue);
47
48 // Implementation of RooAbsLValue
49 void setBin(Int_t ibin, const char* rangeName=nullptr) override ;
50 Int_t getBin(const char* rangeName=nullptr) const override { return getBinning(rangeName).binNumber(getVal()) ; }
51 Int_t numBins(const char* rangeName=nullptr) const override { return getBins(rangeName) ; }
52 double getBinWidth(Int_t i, const char* rangeName=nullptr) const override { return getBinning(rangeName).binWidth(i) ; }
53 double volume(const char* rangeName) const override { return getMax(rangeName)-getMin(rangeName) ; }
54 void randomize(const char* rangeName=nullptr) override;
55
56 const RooAbsBinning* getBinningPtr(const char* rangeName) const override { return &getBinning(rangeName) ; }
57 Int_t getBin(const RooAbsBinning* ptr) const override { return ptr->binNumber(getVal()) ; }
58
59 virtual void setBin(Int_t ibin, const RooAbsBinning& binning) ;
60 virtual Int_t getBin(const RooAbsBinning& binning) const { return binning.binNumber(getVal()) ; }
61 virtual Int_t numBins(const RooAbsBinning& binning) const { return binning.numBins() ; }
62 virtual double getBinWidth(Int_t i, const RooAbsBinning& binning) const { return binning.binWidth(i) ; }
63 virtual double volume(const RooAbsBinning& binning) const { return binning.highBound() - binning.lowBound() ; }
64 virtual void randomize(const RooAbsBinning& binning) ;
65
66
67 // Get fit range limits
68
69 /// Retrieve binning configuration with given name or default binning.
70 virtual const RooAbsBinning& getBinning(const char* name=nullptr, bool verbose=true, bool createOnTheFly=false) const = 0 ;
71 /// Retrieve binning configuration with given name or default binning.
72 virtual RooAbsBinning& getBinning(const char* name=nullptr, bool verbose=true, bool createOnTheFly=false) = 0 ;
73 /// Check if binning with given name has been defined.
74 virtual bool hasBinning(const char* name) const = 0 ;
75 bool inRange(const char* name) const override ;
76 /// Get number of bins of currently defined range.
77 /// \param name Optionally, request number of bins for range with given name.
78 virtual Int_t getBins(const char* name=nullptr) const { return getBinning(name).numBins(); }
79 /// Get minimum of currently defined range.
80 /// \param name Optionally, request minimum of range with given name.
81 virtual double getMin(const char* name=nullptr) const { return getBinning(name).lowBound(); }
82 /// Get maximum of currently defined range.
83 /// \param name Optionally, request maximum of range with given name.
84 virtual double getMax(const char* name=nullptr) const { return getBinning(name).highBound(); }
85 /// Get low and high bound of the variable.
86 /// \param name Optional range name. If not given, the default range will be used.
87 /// \return A pair with [lowerBound, upperBound]
88 std::pair<double, double> getRange(const char* name = nullptr) const {
89 const auto& binning = getBinning(name);
90 return {binning.lowBound(), binning.highBound()};
91 }
92 /// Check if variable has a lower bound.
93 inline bool hasMin(const char* name=nullptr) const { return !RooNumber::isInfinite(getMin(name)); }
94 /// Check if variable has an upper bound.
95 inline bool hasMax(const char* name=nullptr) const { return !RooNumber::isInfinite(getMax(name)); }
96 /// Check if variable has a binning with given name.
97 bool hasRange(const char* name) const override { return hasBinning(name) ; }
98
99 // Jacobian term management
100 virtual bool isJacobianOK(const RooArgSet& depList) const ;
101 virtual double jacobian() const { return 1 ; }
102
103 inline bool isLValue() const override { return true; }
104
105 // Test a value against our fit range
106 bool inRange(double value, const char* rangeName, double* clippedValue=nullptr) const;
107 void inRange(std::span<const double> values, std::string const& rangeName, std::vector<bool>& out) const;
108 bool isValidReal(double value, bool printError=false) const override ;
109
110 // Constant and Projected flags
111 inline void setConstant(bool value= true) { setAttribute("Constant",value); setValueDirty() ; setShapeDirty() ; }
112
113 // I/O streaming interface (machine readable)
114 bool readFromStream(std::istream& is, bool compact, bool verbose=false) override ;
115 void writeToStream(std::ostream& os, bool compact) const override ;
116
117 // Printing interface (human readable)
118 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
119
120
121 // Build 1-dimensional plots
122 RooPlot* frame(const RooCmdArg& arg1, const RooCmdArg& arg2={},
123 const RooCmdArg& arg3={}, const RooCmdArg& arg4={}, const RooCmdArg& arg5={},
124 const RooCmdArg& arg6={}, const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) const ;
125 RooPlot *frame(const RooLinkedList& cmdList) const ;
126 RooPlot *frame(double lo, double hi, Int_t nbins) const;
127 RooPlot *frame(double lo, double hi) const;
128 RooPlot *frame(Int_t nbins) const;
129 RooPlot *frame() const;
130
131 // Create empty 1,2, and 3D histograms from a list of 1-3 RooAbsReals
132 TH1 *createHistogram(const char *name,
133 const RooCmdArg& arg1={}, const RooCmdArg& arg2={},
134 const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
135 const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
136 const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) const ;
137 TH1 *createHistogram(const char *name, const RooLinkedList& cmdList) const ;
138
139 TH1F *createHistogram(const char *name, const char *yAxisLabel) const ;
140 TH1F *createHistogram(const char *name, const char *yAxisLabel, double xlo, double xhi, Int_t nBins) const ;
141 TH1F *createHistogram(const char *name, const char *yAxisLabel, const RooAbsBinning& bins) const ;
142
143 TH2F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const char *zAxisLabel=nullptr,
144 double* xlo=nullptr, double* xhi=nullptr, Int_t* nBins=nullptr) const ;
145 TH2F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const char *zAxisLabel, const RooAbsBinning** bins) const ;
146
147
148 TH3F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const RooAbsRealLValue &zvar,
149 const char *tAxisLabel, double* xlo=nullptr, double* xhi=nullptr, Int_t* nBins=nullptr) const ;
150 TH3F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const RooAbsRealLValue &zvar, const char* tAxisLabel, const RooAbsBinning** bins) const ;
151
152 static TH1* createHistogram(const char *name, RooArgList &vars, const char *tAxisLabel, double* xlo, double* xhi, Int_t* nBins) ;
153 static TH1* createHistogram(const char *name, RooArgList &vars, const char *tAxisLabel, const RooAbsBinning** bins) ;
154
155 RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet* nset=nullptr, const RooNumIntConfig* cfg=nullptr, const char* rangeName=nullptr) const override;
156
157protected:
158
159 virtual void setValFast(double value) { setVal(value) ; }
160
161 bool fitRangeOKForPlotting() const ;
162 void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) override ;
163
164 ClassDefOverride(RooAbsRealLValue,1) // Abstract modifiable real-valued object
165};
166
167#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
#define hi
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
Definition RooAbsArg.h:493
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition RooAbsArg.h:488
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
Abstract base class for RooRealVar binning definitions.
int binNumber(double x) const
Returns the bin number corresponding to the value x.
Int_t numBins() const
Return number of bins.
virtual double highBound() const =0
virtual double lowBound() const =0
virtual double binWidth(Int_t bin) const =0
Abstract base class for objects that are lvalues, i.e.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
bool isLValue() const override
Is this argument an l-value, i.e., can it appear on the left-hand side of an assignment expression?...
Int_t numBins(const char *rangeName=nullptr) const override
Int_t getBin(const RooAbsBinning *ptr) const override
virtual Int_t getBins(const char *name=nullptr) const
Get number of bins of currently defined range.
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooArgSet *nset=nullptr, const RooNumIntConfig *cfg=nullptr, const char *rangeName=nullptr) const override
Create an object that represents the integral of the function over one or more observables listed in ...
virtual void setValFast(double value)
virtual void setVal(double value, const char *)
Set the current value of the object.
bool isValidReal(double value, bool printError=false) const override
Check if given value is valid.
void setConstant(bool value=true)
virtual double jacobian() const
virtual const RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false) const =0
Retrieve binning configuration with given name or default binning.
virtual bool isJacobianOK(const RooArgSet &depList) const
virtual double volume(const RooAbsBinning &binning) const
Int_t getBin(const char *rangeName=nullptr) const override
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
RooPlot * frame() const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
bool hasMax(const char *name=nullptr) const
Check if variable has an upper bound.
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true) override
Copy cache of another RooAbsArg to our cache.
bool fitRangeOKForPlotting() const
Check if fit range is usable as plot range, i.e.
void setBin(Int_t ibin, const char *rangeName=nullptr) override
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
double getBinWidth(Int_t i, const char *rangeName=nullptr) const override
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to given stream.
void randomize(const char *rangeName=nullptr) override
Set a new value sampled from a uniform distribution over the fit range.
TH1 * createHistogram(const char *name, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
virtual void setVal(double value)=0
Set the current value of the object. Needs to be overridden by implementations.
virtual bool hasBinning(const char *name) const =0
Check if binning with given name has been defined.
double volume(const char *rangeName) const override
virtual Int_t getBin(const RooAbsBinning &binning) const
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from given stream.
bool inRange(const char *name) const override
Check if current value is inside range with given name.
const RooAbsBinning * getBinningPtr(const char *rangeName) const override
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Structure printing.
virtual RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false)=0
Retrieve binning configuration with given name or default binning.
bool hasRange(const char *name) const override
Check if variable has a binning with given name.
std::pair< double, double > getRange(const char *name=nullptr) const
Get low and high bound of the variable.
virtual double getBinWidth(Int_t i, const RooAbsBinning &binning) const
virtual RooAbsArg & operator=(double newValue)
Assignment operator from a double.
virtual Int_t numBins(const RooAbsBinning &binning) const
bool hasMin(const char *name=nullptr) const
Check if variable has a lower bound.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Named container for two doubles, two integers two object points and three string pointers that can be...
Definition RooCmdArg.h:26
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
Definition RooNumber.h:27
Plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:45
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:621
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
3-D histogram with a float per channel (see TH1 documentation)
Definition TH3.h:317
Basic string class.
Definition TString.h:139
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:35