Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFormula.h
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*
4 * Project: RooFit
5 *
6 * Copyright (c) 2023, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
13#ifndef ROO_FORMULA
14#define ROO_FORMULA
15
16#include "RooPrintable.h"
17#include "RooArgList.h"
18#include "RooArgSet.h"
19#include "RooFit/EvalContext.h"
20
21#include "TFormula.h"
22
23#include <memory>
24#include <vector>
25#include <string>
26
27class RooAbsReal;
28
29class RooFormula : public TNamed {
30public:
31 // Constructors etc.
32 RooFormula(const char *name, const char *formula, const RooArgList &varList, bool checkVariables = true);
33 RooFormula(const RooFormula &other, const char *name = nullptr);
34 TObject *Clone(const char *newName = nullptr) const override { return new RooFormula(*this, newName); }
35
36 RooFormula &operator=(const RooFormula &other) = delete;
38
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Return list of arguments which are used in the formula.
41 RooArgSet actualDependents() const { return usedVariables(); }
43
44 bool ok() const { return _tFormula != nullptr; }
45 /// Evaluate all parameters/observables, and then evaluate formula.
46 double eval(const RooArgSet *nset = nullptr) const;
47 void doEval(RooArgList const &actualVars, RooFit::EvalContext &) const;
48
49 void printMultiline(std::ostream &os, Int_t contents, bool verbose = false, TString indent = "") const;
50
51 std::string formulaString() const { return _tFormula ? _tFormula->GetTitle() : ""; }
52 TFormula* getTFormula() const { return _tFormula.get(); }
53
54private:
55 std::string processFormula(std::string origFormula) const;
57 void installFormulaOrThrow(const std::string &formula);
58
59 std::vector<bool> _varIsUsed; ///<! Track whether a given variable is in use or not
60 RooArgList _origList; ///<! Original list of dependents
61 std::unique_ptr<TFormula> _tFormula; ///<! The formula used to compute values
62};
63
64#endif
65
66/// \endcond
int Int_t
Definition RtypesCore.h:45
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:110
void operator=(const TProof &)
Abstract container object that can hold multiple RooAbsArg objects.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
The Formula class.
Definition TFormula.h:89
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139