ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooFormulaVar.h,v 1.29 2007/08/09 19:55:47 wouter Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_FORMULA_VAR
#define ROO_FORMULA_VAR

#include "RooAbsReal.h"
#include "RooFormula.h"
#include "RooArgList.h"
#include "RooListProxy.h"

class RooArgSet ;

class RooFormulaVar : public RooAbsReal {
public:
  // Constructors, assignment etc
  inline RooFormulaVar() : _formula(0), _nset(0) { }
  RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents);
  RooFormulaVar(const char *name, const char *title, const RooArgList& dependents);
  RooFormulaVar(const RooFormulaVar& other, const char* name=0);
  virtual TObject* clone(const char* newname) const { return new RooFormulaVar(*this,newname); }
  virtual ~RooFormulaVar();

  inline Bool_t ok() const { return formula().ok() ; }

  inline RooAbsArg* getParameter(const char* name) const { 
    // Return pointer to parameter with given name
    return _actualVars.find(name) ; 
  }
  inline RooAbsArg* getParameter(Int_t index) const { 
    // Return pointer to parameter at given index
    return _actualVars.at(index) ; 
  }

  // I/O streaming interface (machine readable)
  virtual Bool_t readFromStream(istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
  virtual void writeToStream(ostream& os, Bool_t compact) const ;

  // Printing interface (human readable)
  virtual void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent= "") const ;
  void printMetaArgs(ostream& os) const ;

  // Debugging
  void dumpFormula() { formula().dump() ; }

  virtual Double_t getVal(const RooArgSet* set=0) const ;

  virtual Double_t defaultErrorLevel() const ;

protected:

  // Function evaluation
  virtual Double_t evaluate() const ;
  RooFormula& formula() const ;

  // Post-processing of server redirection
  virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;

  virtual Bool_t isValidReal(Double_t value, Bool_t printError) const ;

  RooListProxy _actualVars ;     // Actual parameters used by formula engine
  mutable RooFormula* _formula ; //! Formula engine 
  mutable RooArgSet* _nset ;     //! Normalization set to be passed along to contents
  TString _formExpr ;            // Formula expression string

  ClassDef(RooFormulaVar,1) // Real-valued function of other RooAbsArgs calculated by a TFormula expression
};

#endif
 RooFormulaVar.h:1
 RooFormulaVar.h:2
 RooFormulaVar.h:3
 RooFormulaVar.h:4
 RooFormulaVar.h:5
 RooFormulaVar.h:6
 RooFormulaVar.h:7
 RooFormulaVar.h:8
 RooFormulaVar.h:9
 RooFormulaVar.h:10
 RooFormulaVar.h:11
 RooFormulaVar.h:12
 RooFormulaVar.h:13
 RooFormulaVar.h:14
 RooFormulaVar.h:15
 RooFormulaVar.h:16
 RooFormulaVar.h:17
 RooFormulaVar.h:18
 RooFormulaVar.h:19
 RooFormulaVar.h:20
 RooFormulaVar.h:21
 RooFormulaVar.h:22
 RooFormulaVar.h:23
 RooFormulaVar.h:24
 RooFormulaVar.h:25
 RooFormulaVar.h:26
 RooFormulaVar.h:27
 RooFormulaVar.h:28
 RooFormulaVar.h:29
 RooFormulaVar.h:30
 RooFormulaVar.h:31
 RooFormulaVar.h:32
 RooFormulaVar.h:33
 RooFormulaVar.h:34
 RooFormulaVar.h:35
 RooFormulaVar.h:36
 RooFormulaVar.h:37
 RooFormulaVar.h:38
 RooFormulaVar.h:39
 RooFormulaVar.h:40
 RooFormulaVar.h:41
 RooFormulaVar.h:42
 RooFormulaVar.h:43
 RooFormulaVar.h:44
 RooFormulaVar.h:45
 RooFormulaVar.h:46
 RooFormulaVar.h:47
 RooFormulaVar.h:48
 RooFormulaVar.h:49
 RooFormulaVar.h:50
 RooFormulaVar.h:51
 RooFormulaVar.h:52
 RooFormulaVar.h:53
 RooFormulaVar.h:54
 RooFormulaVar.h:55
 RooFormulaVar.h:56
 RooFormulaVar.h:57
 RooFormulaVar.h:58
 RooFormulaVar.h:59
 RooFormulaVar.h:60
 RooFormulaVar.h:61
 RooFormulaVar.h:62
 RooFormulaVar.h:63
 RooFormulaVar.h:64
 RooFormulaVar.h:65
 RooFormulaVar.h:66
 RooFormulaVar.h:67
 RooFormulaVar.h:68
 RooFormulaVar.h:69
 RooFormulaVar.h:70
 RooFormulaVar.h:71
 RooFormulaVar.h:72
 RooFormulaVar.h:73
 RooFormulaVar.h:74
 RooFormulaVar.h:75
 RooFormulaVar.h:76
 RooFormulaVar.h:77
 RooFormulaVar.h:78
 RooFormulaVar.h:79
 RooFormulaVar.h:80
 RooFormulaVar.h:81