Logo ROOT   6.10/09
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 class RooArgSet ;
26 
27 class RooFormulaVar : public RooAbsReal {
28 public:
29  // Constructors, assignment etc
30  inline RooFormulaVar() : _formula(0), _nset(0) { }
31  RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents);
32  RooFormulaVar(const char *name, const char *title, const RooArgList& dependents);
33  RooFormulaVar(const RooFormulaVar& other, const char* name=0);
34  virtual TObject* clone(const char* newname) const { return new RooFormulaVar(*this,newname); }
35  virtual ~RooFormulaVar();
36 
37  inline Bool_t ok() const { return formula().ok() ; }
38 
39  inline RooAbsArg* getParameter(const char* name) const {
40  // Return pointer to parameter with given name
41  return _actualVars.find(name) ;
42  }
43  inline RooAbsArg* getParameter(Int_t index) const {
44  // Return pointer to parameter at given index
45  return _actualVars.at(index) ;
46  }
47 
48  // I/O streaming interface (machine readable)
49  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
50  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;
51 
52  // Printing interface (human readable)
53  virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent= "") const ;
54  void printMetaArgs(std::ostream& os) const ;
55 
56  // Debugging
57  void dumpFormula() { formula().dump() ; }
58 
59  virtual Double_t defaultErrorLevel() const ;
60 
61  virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
62  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
63 
64 protected:
65 
66  // Function evaluation
67  virtual Double_t evaluate() const ;
68  RooFormula& formula() const ;
69 
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 ;
74 
75  RooListProxy _actualVars ; // Actual parameters used by formula engine
76  mutable RooFormula* _formula ; //! Formula engine
77  mutable RooArgSet* _nset ; //! Normalization set to be passed along to contents
78  TString _formExpr ; // Formula expression string
79 
80  ClassDef(RooFormulaVar,1) // Real-valued function of other RooAbsArgs calculated by a TFormula expression
81 };
82 
83 #endif
TString _formExpr
Normalization set to be passed along to contents.
Definition: RooFormulaVar.h:78
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.
Bool_t ok()
Definition: RooFormula.h:50
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Propagate server change information to embedded RooFormula object.
RooFormula * _formula
Definition: RooFormulaVar.h:76
void dumpFormula()
Definition: RooFormulaVar.h:57
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void printMetaArgs(std::ostream &os) const
Add formula expression as meta argument in printing interface.
#define ClassDef(name, id)
Definition: Rtypes.h:297
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to given stream.
virtual Double_t defaultErrorLevel() const
Return the default error level for MINUIT error analysis If the formula contains one or more RooNLLVa...
RooFormula an implementation of ROOT::v5::TFormula that interfaces it to RooAbsArg value objects...
Definition: RooFormula.h:27
RooAbsArg * getParameter(Int_t index) const
Definition: RooFormulaVar.h:43
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from given stream.
virtual ~RooFormulaVar()
Destructor.
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
RooListProxy _actualVars
Definition: RooFormulaVar.h:75
bool verbose
RooFormula & formula() const
Return reference to internal RooFormula object.
RooArgSet * _nset
Formula engine.
Definition: RooFormulaVar.h:77
RooListProxy is the concrete proxy for RooArgList objects.
Definition: RooListProxy.h:25
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual TObject * clone(const char *newname) const
Definition: RooFormulaVar.h:34
RooAbsArg * find(const char *name) const
Find object with given name in list.
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
virtual Bool_t isValidReal(Double_t value, Bool_t printError) const
Check if given value is valid.
Bool_t ok() const
Definition: RooFormulaVar.h:37
Mother of all ROOT objects.
Definition: TObject.h:37
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects...
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.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
void dump()
DEBUG: Dump state information.
Definition: RooFormula.cxx:166
RooAbsArg * getParameter(const char *name) const
Definition: RooFormulaVar.h:39
virtual Double_t evaluate() const
Calculate current value of object from internal formula.
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.