Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
27 class RooArgSet ;
28 
29 class RooFormulaVar : public RooAbsReal {
30 public:
31  // Constructors, assignment etc
32  RooFormulaVar() { }
33  RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents, bool checkVariables = true);
34  RooFormulaVar(const char *name, const char *title, const RooArgList& dependents, bool checkVariables = true);
35  RooFormulaVar(const RooFormulaVar& other, const char* name=0);
36  virtual TObject* clone(const char* newname) const { return new RooFormulaVar(*this,newname); }
37 
38  inline Bool_t ok() const { return formula().ok() ; }
39 
40  inline RooAbsArg* getParameter(const char* name) const {
41  // Return pointer to parameter with given name
42  return _actualVars.find(name) ;
43  }
44  inline RooAbsArg* getParameter(Int_t index) const {
45  // Return pointer to parameter at given index
46  return _actualVars.at(index) ;
47  }
48 
49  // I/O streaming interface (machine readable)
50  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
51  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;
52 
53  // Printing interface (human readable)
54  virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent= "") const ;
55  void printMetaArgs(std::ostream& os) const ;
56 
57  // Debugging
58  void dumpFormula() { formula().dump() ; }
59 
60  virtual Double_t defaultErrorLevel() const ;
61 
62  virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
63  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
64 
65  // Function evaluation
66  virtual Double_t evaluate() const ;
67 
68  protected:
69  // Post-processing of server redirection
70  virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
71 
72  virtual Bool_t isValidReal(Double_t /*value*/, Bool_t /*printError*/) const {return true;}
73 
74  private:
75  RooFormula& formula() const;
76 
77  RooListProxy _actualVars ; // Actual parameters used by formula engine
78  std::unique_ptr<RooFormula> _formula{nullptr}; //! Formula engine
79  mutable RooArgSet* _nset{nullptr}; //! Normalization set to be passed along to contents
80  TString _formExpr ; // Formula expression string
81 
82  ClassDef(RooFormulaVar,1) // Real-valued function of other RooAbsArgs calculated by a TFormula expression
83 };
84 
85 #endif