Logo ROOT  
Reference Guide
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 "RooFormula.h"
21 #include "RooArgList.h"
22 #include "RooListProxy.h"
23 #include "RooTrace.h"
24 
25 #include <memory>
26 #include <list>
27 
28 class RooArgSet ;
29 
30 class RooFormulaVar : public RooAbsReal {
31 public:
32  // Constructors, assignment etc
34  RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents, bool checkVariables = true);
35  RooFormulaVar(const char *name, const char *title, const RooArgList& dependents, bool checkVariables = true);
36  RooFormulaVar(const RooFormulaVar& other, const char* name=0);
37  virtual TObject* clone(const char* newname) const { return new RooFormulaVar(*this,newname); }
38 
39  inline Bool_t ok() const { return formula().ok() ; }
40 
41  inline RooAbsArg* getParameter(const char* name) const {
42  // Return pointer to parameter with given name
43  return _actualVars.find(name) ;
44  }
45  inline RooAbsArg* getParameter(Int_t index) const {
46  // Return pointer to parameter at given index
47  return _actualVars.at(index) ;
48  }
49 
50  // I/O streaming interface (machine readable)
51  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
52  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;
53 
54  // Printing interface (human readable)
55  virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent= "") const ;
56  void printMetaArgs(std::ostream& os) const ;
57 
58  // Debugging
59  void dumpFormula() { formula().dump() ; }
60 
61  virtual Double_t defaultErrorLevel() const ;
62 
63  virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
64  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
65 
66  // Function evaluation
67  virtual Double_t evaluate() const ;
68 
69  protected:
70  // Post-processing of server redirection
71  virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
72 
73  virtual Bool_t isValidReal(Double_t /*value*/, Bool_t /*printError*/) const {return true;}
74 
75  private:
76  RooFormula& formula() const;
77 
78  RooListProxy _actualVars ; // Actual parameters used by formula engine
79  std::unique_ptr<RooFormula> _formula{nullptr}; //! Formula engine
80  mutable RooArgSet* _nset{nullptr}; //! Normalization set to be passed along to contents
81  TString _formExpr ; // Formula expression string
82 
83  ClassDef(RooFormulaVar,1) // Real-valued function of other RooAbsArgs calculated by a TFormula expression
84 };
85 
86 #endif
RooFormulaVar::_actualVars
RooListProxy _actualVars
Definition: RooFormulaVar.h:78
RooFormulaVar::defaultErrorLevel
virtual Double_t defaultErrorLevel() const
Return the default error level for MINUIT error analysis If the formula contains one or more RooNLLVa...
Definition: RooFormulaVar.cxx:265
RooFormula
Definition: RooFormula.h:28
RooFormulaVar::evaluate
virtual Double_t evaluate() const
Calculate current value of object from internal formula.
Definition: RooFormulaVar.cxx:148
RooAbsReal.h
RooFormulaVar::plotSamplingHint
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &, Double_t, Double_t) const
Forward the plot sampling hint from the p.d.f. that defines the observable obs
Definition: RooFormulaVar.cxx:240
RooFormulaVar::binBoundaries
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Forward the plot sampling hint from the p.d.f. that defines the observable obs
Definition: RooFormulaVar.cxx:221
RooFormulaVar::printMultiline
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print info about this object to the specified stream.
Definition: RooFormulaVar.cxx:170
RooArgList
Definition: RooArgList.h:21
RooFormulaVar::readFromStream
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from given stream.
Definition: RooFormulaVar.cxx:196
RooAbsCollection::find
RooAbsArg * find(const char *name) const
Find object with given name in list.
Definition: RooAbsCollection.cxx:813
RooFormula::dump
void dump() const
DEBUG: Dump state information.
Definition: RooFormula.cxx:293
indent
static void indent(ostringstream &buf, int indent_level)
Definition: TClingCallFunc.cxx:87
RooFormula.h
RooAbsReal
Definition: RooAbsReal.h:61
RooArgList::at
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:88
RooFormulaVar::ok
Bool_t ok() const
Definition: RooFormulaVar.h:39
RooFormulaVar::writeToStream
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to given stream.
Definition: RooFormulaVar.cxx:207
TString
Definition: TString.h:136
RooFormulaVar::_formExpr
TString _formExpr
Normalization set to be passed along to contents.
Definition: RooFormulaVar.h:81
RooFormulaVar::_formula
std::unique_ptr< RooFormula > _formula
Definition: RooFormulaVar.h:79
bool
RooFormulaVar::_nset
RooArgSet * _nset
Formula engine.
Definition: RooFormulaVar.h:80
RooFormulaVar::getParameter
RooAbsArg * getParameter(Int_t index) const
Definition: RooFormulaVar.h:45
RooTrace.h
RooFormulaVar
Definition: RooFormulaVar.h:30
RooFormulaVar::getParameter
RooAbsArg * getParameter(const char *name) const
Definition: RooFormulaVar.h:41
RooFormulaVar::isValidReal
virtual Bool_t isValidReal(Double_t, Bool_t) const
Interface function to check if given value is a valid value for this object.
Definition: RooFormulaVar.h:73
RooFormula::ok
Bool_t ok()
Definition: RooFormula.h:67
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooFormulaVar::clone
virtual TObject * clone(const char *newname) const
Definition: RooFormulaVar.h:37
RooAbsCollection
Definition: RooAbsCollection.h:30
RooFormulaVar::printMetaArgs
void printMetaArgs(std::ostream &os) const
Add formula expression as meta argument in printing interface.
Definition: RooFormulaVar.cxx:185
RooListProxy
Definition: RooListProxy.h:24
RooListProxy.h
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooFormulaVar::dumpFormula
void dumpFormula()
Definition: RooFormulaVar.h:59
RooAbsArg
Definition: RooAbsArg.h:73
RooAbsRealLValue
Definition: RooAbsRealLValue.h:31
RooArgList.h
RooFormulaVar::formula
RooFormula & formula() const
Return reference to internal RooFormula object.
Definition: RooFormulaVar.cxx:131
RooFormulaVar::redirectServersHook
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Propagate server change information to embedded RooFormula object.
Definition: RooFormulaVar.cxx:157
RooFormulaVar::RooFormulaVar
RooFormulaVar()
Definition: RooFormulaVar.h:33
RooArgSet
Definition: RooArgSet.h:28
int