RooFormulaVar.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooFormulaVar.h,v 1.29 2007/08/09 19:55:47 wouter Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_FORMULA_VAR
00017 #define ROO_FORMULA_VAR
00018 
00019 #include "RooAbsReal.h"
00020 #include "RooFormula.h"
00021 #include "RooArgList.h"
00022 #include "RooListProxy.h"
00023 
00024 class RooArgSet ;
00025 
00026 class RooFormulaVar : public RooAbsReal {
00027 public:
00028   // Constructors, assignment etc
00029   inline RooFormulaVar() : _formula(0), _nset(0) { }
00030   RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents);
00031   RooFormulaVar(const char *name, const char *title, const RooArgList& dependents);
00032   RooFormulaVar(const RooFormulaVar& other, const char* name=0);
00033   virtual TObject* clone(const char* newname) const { return new RooFormulaVar(*this,newname); }
00034   virtual ~RooFormulaVar();
00035 
00036   inline Bool_t ok() const { return formula().ok() ; }
00037 
00038   inline RooAbsArg* getParameter(const char* name) const { 
00039     // Return pointer to parameter with given name
00040     return _actualVars.find(name) ; 
00041   }
00042   inline RooAbsArg* getParameter(Int_t index) const { 
00043     // Return pointer to parameter at given index
00044     return _actualVars.at(index) ; 
00045   }
00046 
00047   // I/O streaming interface (machine readable)
00048   virtual Bool_t readFromStream(istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
00049   virtual void writeToStream(ostream& os, Bool_t compact) const ;
00050 
00051   // Printing interface (human readable)
00052   virtual void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent= "") const ;
00053   void printMetaArgs(ostream& os) const ;
00054 
00055   // Debugging
00056   void dumpFormula() { formula().dump() ; }
00057 
00058   virtual Double_t getVal(const RooArgSet* set=0) const ;
00059 
00060   virtual Double_t defaultErrorLevel() const ;
00061 
00062 protected:
00063 
00064   // Function evaluation
00065   virtual Double_t evaluate() const ;
00066   RooFormula& formula() const ;
00067 
00068   // Post-processing of server redirection
00069   virtual Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;
00070 
00071   virtual Bool_t isValidReal(Double_t value, Bool_t printError) const ;
00072 
00073   RooListProxy _actualVars ;     // Actual parameters used by formula engine
00074   mutable RooFormula* _formula ; //! Formula engine 
00075   mutable RooArgSet* _nset ;     //! Normalization set to be passed along to contents
00076   TString _formExpr ;            // Formula expression string
00077 
00078   ClassDef(RooFormulaVar,1) // Real-valued function of other RooAbsArgs calculated by a TFormula expression
00079 };
00080 
00081 #endif

Generated on Tue Jul 5 14:26:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1