Logo ROOT  
Reference Guide
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 
29 class RooArgSet ;
30 
31 class RooAbsRealLValue : public RooAbsReal, public RooAbsLValue {
32 public:
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=0);
38  virtual ~RooAbsRealLValue();
39 
40  // Parameter value and error accessors
41  /// Set the current value of the object. Needs to be overridden by implementations.
42  virtual void setVal(Double_t value)=0;
43  /// Set the current value of the object. The rangeName is ignored.
44  /// Can be overridden by derived classes to e.g. check if the value fits in the given range.
45  virtual void setVal(Double_t value, const char* /*rangeName*/) {
46  return setVal(value) ;
47  }
48  virtual RooAbsArg& operator=(const RooAbsReal& other) ;
49  virtual RooAbsArg& operator=(Double_t newValue);
50 
51  // Implementation of RooAbsLValue
52  virtual void setBin(Int_t ibin, const char* rangeName=0) ;
53  virtual Int_t getBin(const char* rangeName=0) const { return getBinning(rangeName).binNumber(getVal()) ; }
54  virtual Int_t numBins(const char* rangeName=0) const { return getBins(rangeName) ; }
55  virtual Double_t getBinWidth(Int_t i, const char* rangeName=0) const { return getBinning(rangeName).binWidth(i) ; }
56  virtual Double_t volume(const char* rangeName) const { return getMax(rangeName)-getMin(rangeName) ; }
57  virtual void randomize(const char* rangeName=0);
58 
59  virtual const RooAbsBinning* getBinningPtr(const char* rangeName) const { return &getBinning(rangeName) ; }
60  virtual Int_t getBin(const RooAbsBinning* ptr) const { return ptr->binNumber(getVal()) ; }
61 
62  virtual void setBin(Int_t ibin, const RooAbsBinning& binning) ;
63  virtual Int_t getBin(const RooAbsBinning& binning) const { return binning.binNumber(getVal()) ; }
64  virtual Int_t numBins(const RooAbsBinning& binning) const { return binning.numBins() ; }
65  virtual Double_t getBinWidth(Int_t i, const RooAbsBinning& binning) const { return binning.binWidth(i) ; }
66  virtual Double_t volume(const RooAbsBinning& binning) const { return binning.highBound() - binning.lowBound() ; }
67  virtual void randomize(const RooAbsBinning& binning) ;
68 
69 
70  virtual void setBinFast(Int_t ibin, const RooAbsBinning& binning) ;
71 
72  // Get fit range limits
73 
74  /// Retrive binning configuration with given name or default binning.
75  virtual const RooAbsBinning& getBinning(const char* name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const = 0 ;
76  /// Retrive binning configuration with given name or default binning.
77  virtual RooAbsBinning& getBinning(const char* name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) = 0 ;
78  /// Check if binning with given name has been defined.
79  virtual Bool_t hasBinning(const char* name) const = 0 ;
80  virtual Bool_t inRange(const char* name) const ;
81  /// Get number of bins of currently defined range.
82  /// \param name Optionally, request number of bins for range with given name.
83  virtual Int_t getBins(const char* name=0) const { return getBinning(name).numBins(); }
84  /// Get miniminum of currently defined range.
85  /// \param name Optionally, request minimum of range with given name.
86  virtual Double_t getMin(const char* name=0) const { return getBinning(name).lowBound(); }
87  /// Get maximum of currently defined range.
88  /// \param name Optionally, request maximum of range with given name.
89  virtual Double_t getMax(const char* name=0) const { return getBinning(name).highBound(); }
90  /// Get low and high bound of the variable.
91  /// \param name Optional range name. If not given, the default range will be used.
92  /// \return A pair with [lowerBound, upperBound]
93  std::pair<double, double> getRange(const char* name = 0) const {
94  const auto& binning = getBinning(name);
95  return {binning.lowBound(), binning.highBound()};
96  }
97  /// Check if variable has a lower bound.
98  inline Bool_t hasMin(const char* name=0) const { return !RooNumber::isInfinite(getMin(name)); }
99  /// Check if variable has an upper bound.
100  inline Bool_t hasMax(const char* name=0) const { return !RooNumber::isInfinite(getMax(name)); }
101  /// Check if variable has a binning with given name.
102  virtual Bool_t hasRange(const char* name) const { return hasBinning(name) ; }
103 
104  // Jacobian term management
105  virtual Bool_t isJacobianOK(const RooArgSet& depList) const ;
106  virtual Double_t jacobian() const { return 1 ; }
107 
108  inline virtual Bool_t isLValue() const { return kTRUE; }
109 
110  // Test a value against our fit range
111  Bool_t inRange(Double_t value, const char* rangeName, Double_t* clippedValue=0) const;
112  virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const ;
113 
114  // Constant and Projected flags
115  inline void setConstant(Bool_t value= kTRUE) { setAttribute("Constant",value); setValueDirty() ; setShapeDirty() ; }
116 
117  // I/O streaming interface (machine readable)
118  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
119  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;
120 
121  // Printing interface (human readable)
122  virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
123 
124 
125  // Build 1-dimensional plots
126  RooPlot* frame(const RooCmdArg& arg1, const RooCmdArg& arg2=RooCmdArg::none(),
127  const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
128  const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) const ;
129  RooPlot *frame(const RooLinkedList& cmdList) const ;
130  RooPlot *frame(Double_t lo, Double_t hi, Int_t nbins) const;
131  RooPlot *frame(Double_t lo, Double_t hi) const;
132  RooPlot *frame(Int_t nbins) const;
133  RooPlot *frame() const;
134 
135  // Create empty 1,2, and 3D histograms from a list of 1-3 RooAbsReals
136  TH1 *createHistogram(const char *name,
137  const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
138  const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
139  const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
140  const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) const ;
141  TH1 *createHistogram(const char *name, const RooLinkedList& cmdList) const ;
142 
143  TH1F *createHistogram(const char *name, const char *yAxisLabel) const ;
144  TH1F *createHistogram(const char *name, const char *yAxisLabel, Double_t xlo, Double_t xhi, Int_t nBins) const ;
145  TH1F *createHistogram(const char *name, const char *yAxisLabel, const RooAbsBinning& bins) const ;
146 
147  TH2F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const char *zAxisLabel=0,
148  Double_t* xlo=0, Double_t* xhi=0, Int_t* nBins=0) const ;
149  TH2F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const char *zAxisLabel, const RooAbsBinning** bins) const ;
150 
151 
152  TH3F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const RooAbsRealLValue &zvar,
153  const char *tAxisLabel, Double_t* xlo=0, Double_t* xhi=0, Int_t* nBins=0) const ;
154  TH3F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const RooAbsRealLValue &zvar, const char* tAxisLabel, const RooAbsBinning** bins) const ;
155 
156  static TH1* createHistogram(const char *name, RooArgList &vars, const char *tAxisLabel, Double_t* xlo, Double_t* xhi, Int_t* nBins) ;
157  static TH1* createHistogram(const char *name, RooArgList &vars, const char *tAxisLabel, const RooAbsBinning** bins) ;
158 
159 protected:
160 
161  virtual void setValFast(Double_t value) { setVal(value) ; }
162 
163  Bool_t fitRangeOKForPlotting() const ;
164  void copyCache(const RooAbsArg* source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE) ;
165 
166  ClassDef(RooAbsRealLValue,1) // Abstract modifiable real-valued object
167 };
168 
169 #endif
RooAbsRealLValue::getRange
std::pair< double, double > getRange(const char *name=0) const
Get low and high bound of the variable.
Definition: RooAbsRealLValue.h:93
RooAbsRealLValue::inRange
virtual Bool_t inRange(const char *name) const
Check if current value is inside range with given name.
Definition: RooAbsRealLValue.cxx:504
RooCmdArg
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooAbsReal.h
RooAbsBinning::numBins
Int_t numBins() const
Return number of bins.
Definition: RooAbsBinning.h:38
RooAbsRealLValue::getBin
virtual Int_t getBin(const RooAbsBinning *ptr) const
Definition: RooAbsRealLValue.h:60
RooAbsRealLValue::getMax
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Definition: RooAbsRealLValue.h:89
RooAbsRealLValue::getBin
virtual Int_t getBin(const RooAbsBinning &binning) const
Definition: RooAbsRealLValue.h:63
RooAbsBinning::highBound
virtual Double_t highBound() const =0
RooAbsRealLValue::writeToStream
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to given stream.
Definition: RooAbsRealLValue.cxx:150
TH2F
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
RooAbsRealLValue::~RooAbsRealLValue
virtual ~RooAbsRealLValue()
Destructor.
Definition: RooAbsRealLValue.cxx:83
RooAbsBinning::binWidth
virtual Double_t binWidth(Int_t bin) const =0
RooAbsBinning::binNumber
virtual Int_t binNumber(Double_t x) const =0
RooAbsRealLValue::setValFast
virtual void setValFast(Double_t value)
Definition: RooAbsRealLValue.h:161
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooAbsRealLValue::operator=
RooAbsRealLValue & operator=(const RooAbsRealLValue &)=default
indent
static void indent(ostringstream &buf, int indent_level)
Definition: TClingCallFunc.cxx:87
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooAbsRealLValue::RooAbsRealLValue
RooAbsRealLValue()
Definition: RooAbsRealLValue.h:34
RooAbsRealLValue::hasMax
Bool_t hasMax(const char *name=0) const
Check if variable has an upper bound.
Definition: RooAbsRealLValue.h:100
TString
Basic string class.
Definition: TString.h:136
RooCmdArg::none
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:52
TString.h
bool
RooAbsRealLValue::getMin
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
Definition: RooAbsRealLValue.h:86
RooAbsRealLValue::getBinningPtr
virtual const RooAbsBinning * getBinningPtr(const char *rangeName) const
Definition: RooAbsRealLValue.h:59
RooAbsRealLValue::readFromStream
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from given stream.
Definition: RooAbsRealLValue.cxx:140
RooAbsLValue.h
hi
float type_of_call hi(const int &, const int &)
RooAbsRealLValue::isJacobianOK
virtual Bool_t isJacobianOK(const RooArgSet &depList) const
Definition: RooAbsRealLValue.cxx:1036
RooAbsRealLValue::volume
virtual Double_t volume(const RooAbsBinning &binning) const
Definition: RooAbsRealLValue.h:66
RooAbsRealLValue::numBins
virtual Int_t numBins(const char *rangeName=0) const
Definition: RooAbsRealLValue.h:54
RooAbsBinning.h
RooAbsRealLValue::copyCache
void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)
Copy cache of another RooAbsArg to our cache.
Definition: RooAbsRealLValue.cxx:376
RooAbsRealLValue::frame
RooPlot * frame() const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
Definition: RooAbsRealLValue.cxx:356
RooAbsRealLValue::getBinning
virtual RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE)=0
Retrive binning configuration with given name or default binning.
RooNumber::isInfinite
static Int_t isInfinite(Double_t x)
Return true if x is infinite by RooNumBer internal specification.
Definition: RooNumber.cxx:58
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooLinkedList
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
RooAbsBinning
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
Definition: RooAbsBinning.h:26
RooAbsRealLValue::isLValue
virtual Bool_t isLValue() const
Is this argument an l-value, i.e., can it appear on the left-hand side of an assignment expression?...
Definition: RooAbsRealLValue.h:108
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooAbsRealLValue::getBinWidth
virtual Double_t getBinWidth(Int_t i, const RooAbsBinning &binning) const
Definition: RooAbsRealLValue.h:65
TH3F
3-D histogram with a float per channel (see TH1 documentation)}
Definition: TH3.h:268
RooNumber.h
RooAbsRealLValue::hasBinning
virtual Bool_t hasBinning(const char *name) const =0
Check if binning with given name has been defined.
RooAbsRealLValue::getBin
virtual Int_t getBin(const char *rangeName=0) const
Definition: RooAbsRealLValue.h:53
RooAbsRealLValue::hasMin
Bool_t hasMin(const char *name=0) const
Check if variable has a lower bound.
Definition: RooAbsRealLValue.h:98
RooAbsRealLValue::fitRangeOKForPlotting
Bool_t fitRangeOKForPlotting() const
Check if fit range is usable as plot range, i.e.
Definition: RooAbsRealLValue.cxx:493
RooAbsRealLValue::hasRange
virtual Bool_t hasRange(const char *name) const
Check if variable has a binning with given name.
Definition: RooAbsRealLValue.h:102
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsArg::setShapeDirty
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
Definition: RooAbsArg.h:493
RooAbsRealLValue::setBinFast
virtual void setBinFast(Int_t ibin, const RooAbsBinning &binning)
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
Definition: RooAbsRealLValue.cxx:481
TH1F
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
RooAbsRealLValue::getBinWidth
virtual Double_t getBinWidth(Int_t i, const char *rangeName=0) const
Definition: RooAbsRealLValue.h:55
RooAbsRealLValue::numBins
virtual Int_t numBins(const RooAbsBinning &binning) const
Definition: RooAbsRealLValue.h:64
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooAbsArg::setAttribute
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:291
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
name
char name[80]
Definition: TGX11.cxx:110
RooAbsRealLValue::setConstant
void setConstant(Bool_t value=kTRUE)
Definition: RooAbsRealLValue.h:115
RooAbsRealLValue::randomize
virtual void randomize(const char *rangeName=0)
Set a new value sampled from a uniform distribution over the fit range.
Definition: RooAbsRealLValue.cxx:413
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsRealLValue::getBins
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
Definition: RooAbsRealLValue.h:83
RooAbsArg::setValueDirty
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition: RooAbsArg.h:488
RooAbsLValue
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
RooAbsRealLValue::isValidReal
virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const
Check if given value is valid.
Definition: RooAbsRealLValue.cxx:124
RooAbsRealLValue::volume
virtual Double_t volume(const char *rangeName) const
Definition: RooAbsRealLValue.h:56
RooAbsRealLValue::setVal
virtual void setVal(Double_t value)=0
Set the current value of the object. Needs to be overridden by implementations.
RooAbsRealLValue::jacobian
virtual Double_t jacobian() const
Definition: RooAbsRealLValue.h:106
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooAbsBinning::lowBound
virtual Double_t lowBound() const =0
RooAbsRealLValue::printMultiline
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
Definition: RooAbsRealLValue.cxx:386
RooAbsRealLValue::getBinning
virtual const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const =0
Retrive binning configuration with given name or default binning.
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
int
RooAbsRealLValue::setBin
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
Definition: RooAbsRealLValue.cxx:433
RooAbsRealLValue::createHistogram
TH1 * createHistogram(const char *name, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Definition: RooAbsRealLValue.cxx:524