File indexing completed on 2026-09-13 09:25:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
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 #include "RooAbsBinning.h"
0024
0025 #include <memory>
0026 #include <list>
0027 #include <map>
0028 #include <string>
0029
0030 class RooArgSet ;
0031 class RooFormula ;
0032 class RooAbsRealLValue;
0033
0034 class RooFormulaVar : public RooAbsReal {
0035 public:
0036
0037 RooFormulaVar();
0038 ~RooFormulaVar() override;
0039 RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents, bool checkVariables = true);
0040 RooFormulaVar(const char *name, const char *title, const RooArgList& dependents, bool checkVariables = true);
0041 RooFormulaVar(const RooFormulaVar& other, const char* name=nullptr);
0042 TObject* clone(const char* newname=nullptr) const override { return new RooFormulaVar(*this,newname); }
0043
0044 bool ok() const;
0045 const char* expression() const { return _formExpr.Data(); }
0046 const RooArgList& dependents() const { return _actualVars; }
0047
0048
0049 inline RooAbsArg* getParameter(const char* name) const {
0050 return _actualVars.find(name) ;
0051 }
0052
0053 inline RooAbsArg* getParameter(Int_t index) const {
0054 return _actualVars.at(index) ;
0055 }
0056
0057 inline size_t nParameters() const {
0058 return _actualVars.size();
0059 }
0060
0061
0062 bool readFromStream(std::istream& is, bool compact, bool verbose=false) override ;
0063 void writeToStream(std::ostream& os, bool compact) const override ;
0064
0065
0066 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent= "") const override ;
0067 void printMetaArgs(std::ostream& os) const override ;
0068
0069
0070
0071 void dumpFormula();
0072
0073 double defaultErrorLevel() const override ;
0074
0075 void setBinning(const RooAbsRealLValue &obs, const RooAbsBinning &binning, bool checkFlatness = true);
0076 const RooAbsBinning *getBinning(const RooAbsRealLValue &obs) const;
0077 bool removeBinning(const RooAbsRealLValue &obs);
0078
0079 bool isBinnedDistribution(const RooArgSet &obs) const override;
0080 std::list<double>* binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const override ;
0081 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override ;
0082
0083
0084 double evaluate() const override ;
0085 void doEval(RooFit::EvalContext &ctx) const override;
0086
0087 std::string getUniqueFuncName() const;
0088
0089 std::unique_ptr<RooAbsArg>
0090 compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override;
0091
0092 protected:
0093
0094 bool redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
0095
0096 bool isValidReal(double , bool ) const override {return true;}
0097
0098 private:
0099 RooFormula& getFormula() const;
0100
0101 RooListProxy _actualVars ;
0102 mutable RooFormula *_formula = nullptr;
0103 mutable RooArgSet* _nset{nullptr};
0104 TString _formExpr ;
0105
0106 std::map<int, std::unique_ptr<RooAbsBinning>> _binnings;
0107
0108
0109 ClassDefOverride(RooFormulaVar, 2)
0110 };
0111
0112 #endif