Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFormulaVar.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooFormulaVar.h,v 1.29 2007/08/09 19:55:47 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_FORMULA_VAR
17#define ROO_FORMULA_VAR
18
19#include "RooAbsReal.h"
20#include "RooArgList.h"
21#include "RooListProxy.h"
22#include "RooTrace.h"
23#include "RooAbsBinning.h"
24
25#include <memory>
26#include <list>
27#include <map>
28#include <string>
29
30class RooArgSet ;
31class RooFormula ;
33
34class RooFormulaVar : public RooAbsReal {
35public:
36 // Constructors, assignment etc
38 ~RooFormulaVar() override;
39 RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents, bool checkVariables = true);
40 RooFormulaVar(const char *name, const char *title, const RooArgList& dependents, bool checkVariables = true);
41 RooFormulaVar(const RooFormulaVar& other, const char* name=nullptr);
42 TObject* clone(const char* newname=nullptr) const override { return new RooFormulaVar(*this,newname); }
43
44 bool ok() const;
45 const char* expression() const { return _formExpr.Data(); }
46 const RooArgList& dependents() const { return _actualVars; }
47
48 /// Return pointer to parameter with given name.
49 inline RooAbsArg* getParameter(const char* name) const {
50 return _actualVars.find(name) ;
51 }
52 /// Return pointer to parameter at given index.
54 return _actualVars.at(index) ;
55 }
56 /// Return the number of parameters.
57 inline size_t nParameters() const {
58 return _actualVars.size();
59 }
60
61 // I/O streaming interface (machine readable)
62 bool readFromStream(std::istream& is, bool compact, bool verbose=false) override ;
63 void writeToStream(std::ostream& os, bool compact) const override ;
64
65 // Printing interface (human readable)
66 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent= "") const override ;
67 void printMetaArgs(std::ostream& os) const override ;
68
69 // Debugging
70 /// Dump the formula to stdout.
71 void dumpFormula();
72
73 double defaultErrorLevel() const override ;
74
75 void setBinning(const RooAbsRealLValue &obs, const RooAbsBinning &binning, bool checkFlatness = true);
76 bool removeBinning(const RooAbsRealLValue &obs);
77
78 bool isBinnedDistribution(const RooArgSet &obs) const override;
79 std::list<double>* binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const override ;
80 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override ;
81
82 // Function evaluation
83 double evaluate() const override ;
84 void doEval(RooFit::EvalContext &ctx) const override;
85
86 std::string getUniqueFuncName() const;
87
88 std::unique_ptr<RooAbsArg>
90
91 protected:
92 // Post-processing of server redirection
94
95 bool isValidReal(double /*value*/, bool /*printError*/) const override {return true;}
96
97 private:
98 RooFormula& getFormula() const;
99
100 RooListProxy _actualVars ; ///< Actual parameters used by formula engine
101 mutable RooFormula *_formula = nullptr; ///<! Formula engine
102 mutable RooArgSet* _nset{nullptr}; ///<! Normalization set to be passed along to contents
103 TString _formExpr ; ///< Formula expression string
104
105 std::map<int, std::unique_ptr<RooAbsBinning>> _binnings; ///< User-defined binnings, keyed by the observable's index
106 ///< in _actualVars, for a piecewise-flat distribution
107
108 ClassDefOverride(RooFormulaVar, 2) // Real-valued function of other RooAbsArgs calculated by a TFormula expression
109};
110
111#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
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 char Point_t Rectangle_t WindowAttributes_t index
char name[80]
Definition TGX11.cxx:145
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
Abstract base class for RooRealVar binning definitions.
Abstract container object that can hold multiple RooAbsArg objects.
Storage_t::size_type size() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
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:63
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
RooAbsArg * getParameter(Int_t index) const
Return pointer to parameter at given index.
~RooFormulaVar() override
RooAbsArg * getParameter(const char *name) const
Return pointer to parameter with given name.
std::map< int, std::unique_ptr< RooAbsBinning > > _binnings
User-defined binnings, keyed by the observable's index in _actualVars, for a piecewise-flat distribut...
RooListProxy _actualVars
Actual parameters used by formula engine.
std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return the boundaries of the binning set with setBinning() that fall within [xlo, xhi].
const char * expression() const
bool isBinnedDistribution(const RooArgSet &obs) const override
Return true if a binning was set with setBinning() for every observable in the integration set obs.
RooFormula & getFormula() const
Return reference to internal RooFormula object.
RooFormula * _formula
! Formula engine
void doEval(RooFit::EvalContext &ctx) const override
Base function for computing multiple values of a RooAbsReal.
void dumpFormula()
Dump the formula to stdout.
double defaultErrorLevel() const override
Return the default error level for MINUIT error analysis If the formula contains one or more RooNLLVa...
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return sampling hints that draw the piecewise-flat shape exactly if a binning was set for this observ...
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override
Propagate server change information to embedded RooFormula object.
void setBinning(const RooAbsRealLValue &obs, const RooAbsBinning &binning, bool checkFlatness=true)
Declare that this function is piecewise constant (flat) within the bins of the given binning of the o...
bool ok() const
const RooArgList & dependents() const
bool removeBinning(const RooAbsRealLValue &obs)
Remove a binning previously declared with setBinning() for observable obs, reverting to the generic n...
TObject * clone(const char *newname=nullptr) const override
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from given stream.
TString _formExpr
Formula expression string.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print info about this object to the specified stream.
std::string getUniqueFuncName() const
double evaluate() const override
Calculate current value of object from internal formula.
size_t nParameters() const
Return the number of parameters.
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to given stream.
void printMetaArgs(std::ostream &os) const override
Add formula expression as meta argument in printing interface.
RooArgSet * _nset
! Normalization set to be passed along to contents
bool isValidReal(double, bool) const override
Interface function to check if given value is a valid value for this object. Returns true unless over...
Mother of all ROOT objects.
Definition TObject.h:42
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384