Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooFormulaVar.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooFormulaVar.h,v 1.29 2007/08/09 19:55:47 wouter Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_FORMULA_VAR
0017 #define ROO_FORMULA_VAR
0018 
0019 #include "RooAbsReal.h"
0020 #include "RooArgList.h"
0021 #include "RooListProxy.h"
0022 #include "RooTrace.h"
0023 
0024 #include <memory>
0025 #include <list>
0026 
0027 class RooArgSet ;
0028 class RooFormula ;
0029 
0030 class RooFormulaVar : public RooAbsReal {
0031 public:
0032   // Constructors, assignment etc
0033   RooFormulaVar();
0034   ~RooFormulaVar() override;
0035   RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents, bool checkVariables = true);
0036   RooFormulaVar(const char *name, const char *title, const RooArgList& dependents, bool checkVariables = true);
0037   RooFormulaVar(const RooFormulaVar& other, const char* name=nullptr);
0038   TObject* clone(const char* newname) const override { return new RooFormulaVar(*this,newname); }
0039 
0040   bool ok() const;
0041   const char* expression() const { return _formExpr.Data(); }
0042   const RooArgList& dependents() const { return _actualVars; }
0043 
0044   /// Return pointer to parameter with given name.
0045   inline RooAbsArg* getParameter(const char* name) const {
0046     return _actualVars.find(name) ;
0047   }
0048   /// Return pointer to parameter at given index.
0049   inline RooAbsArg* getParameter(Int_t index) const {
0050     return _actualVars.at(index) ;
0051   }
0052   /// Return the number of parameters.
0053   inline size_t nParameters() const {
0054     return _actualVars.size();
0055   }
0056 
0057   // I/O streaming interface (machine readable)
0058   bool readFromStream(std::istream& is, bool compact, bool verbose=false) override ;
0059   void writeToStream(std::ostream& os, bool compact) const override ;
0060 
0061   // Printing interface (human readable)
0062   void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent= "") const override ;
0063   void printMetaArgs(std::ostream& os) const override ;
0064 
0065   // Debugging
0066   /// Dump the formula to stdout.
0067   void dumpFormula();
0068 
0069   double defaultErrorLevel() const override ;
0070 
0071   std::list<double>* binBoundaries(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
0072   std::list<double>* plotSamplingHint(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
0073 
0074   // Function evaluation
0075   double evaluate() const override ;
0076   void doEval(RooFit::EvalContext &ctx) const override;
0077   void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
0078 
0079   protected:
0080   // Post-processing of server redirection
0081   bool redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
0082 
0083   bool isValidReal(double /*value*/, bool /*printError*/) const override {return true;}
0084 
0085   private:
0086   RooFormula& getFormula() const;
0087 
0088   RooListProxy _actualVars ;     ///< Actual parameters used by formula engine
0089   mutable RooFormula *_formula = nullptr; ///<! Formula engine
0090   mutable RooArgSet* _nset{nullptr}; ///<! Normalization set to be passed along to contents
0091   TString _formExpr ;            ///< Formula expression string
0092 
0093   ClassDefOverride(RooFormulaVar,1) // Real-valued function of other RooAbsArgs calculated by a TFormula expression
0094 };
0095 
0096 #endif