Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooPolyFunc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * File: $Id: RooPolyFunc.h,v 1.8 2007/05/11 09:13:07 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2021: *
10 * CERN, Switzerland *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef RooFit_RooFit_RooPolyFunc_h
17#define RooFit_RooFit_RooPolyFunc_h
18
19#include "RooAbsReal.h"
20#include "RooRealVar.h"
21#include "RooListProxy.h"
22
23#include <vector>
24
25class RooRealVar;
26class RooArgList;
27
28class RooPolyFunc : public RooAbsReal {
29public:
31 RooPolyFunc(const char *name, const char *title, RooAbsReal &x, const RooAbsCollection &coefList);
32 RooPolyFunc(const char *name, const char *title, RooAbsReal &x, RooAbsReal &y, const RooAbsCollection &coefList);
33 RooPolyFunc(const char *name, const char *title, const RooAbsCollection &vars);
34 RooPolyFunc(const RooPolyFunc &other, const char *name = nullptr);
35 RooPolyFunc &operator=(const RooPolyFunc &other) = delete;
36 RooPolyFunc &operator=(RooPolyFunc &&other) = delete;
37 TObject *clone(const char *newname) const override { return new RooPolyFunc(*this, newname); }
38
39 std::string asString() const;
40 inline const RooArgList &variables() const { return _vars; }
41 inline const std::vector<std::unique_ptr<RooListProxy>> &terms() const { return _terms; }
43 {
44 return static_cast<RooRealVar *>(term.at(term.size() - 1));
45 }
47 {
48 return static_cast<RooRealVar *>(term.at(_vars.index(v)));
49 }
50
51 void addTerm(double coefficient);
52 void addTerm(double coefficient, const RooAbsCollection &exponents);
53 void addTerm(double coefficient, const RooAbsReal &var1, int exp1);
54 void addTerm(double coefficient, const RooAbsReal &var1, int exp1, const RooAbsReal &var2, int exp2);
55
56 static std::unique_ptr<RooPolyFunc>
57 taylorExpand(const char *name, const char *title, RooAbsReal &func, const RooArgList &observables, int order = 1,
58 std::vector<double> const &observableValues = {}, double eps1 = 1e-6, double eps2 = 1e-3);
59
60protected:
61 void setCoordinate(const RooAbsCollection &observables, std::vector<double> const &observableValues);
63 std::vector<std::unique_ptr<RooListProxy>> _terms;
64
65 /// Evaluation
66 double evaluate() const override;
67
68 ClassDefOverride(RooPolyFunc, 1) // Polynomial Function
69};
70
71#endif
#define e(i)
Definition RSha256.hxx:103
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
char name[80]
Definition TGX11.cxx:110
Abstract container object that can hold multiple RooAbsArg objects.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
Storage_t::size_type size() const
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
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition RooArgList.h:110
RooPolyFunc implements a polynomial function in multi-variables.
Definition RooPolyFunc.h:28
RooRealVar * getExponent(const RooArgList &term, RooRealVar *v)
Definition RooPolyFunc.h:46
const RooArgList & variables() const
Definition RooPolyFunc.h:40
RooPolyFunc & operator=(RooPolyFunc &&other)=delete
RooPolyFunc & operator=(const RooPolyFunc &other)=delete
RooListProxy _vars
Definition RooPolyFunc.h:62
RooRealVar * getCoefficient(const RooArgList &term)
Definition RooPolyFunc.h:42
double evaluate() const override
Evaluation.
RooPolyFunc(const char *name, const char *title, RooAbsReal &x, const RooAbsCollection &coefList)
RooPolyFunc()
Default constructor.
RooPolyFunc(const char *name, const char *title, RooAbsReal &x, RooAbsReal &y, const RooAbsCollection &coefList)
void setCoordinate(const RooAbsCollection &observables, std::vector< double > const &observableValues)
const std::vector< std::unique_ptr< RooListProxy > > & terms() const
Definition RooPolyFunc.h:41
void addTerm(double coefficient)
coverity[UNINIT_CTOR]
static std::unique_ptr< RooPolyFunc > taylorExpand(const char *name, const char *title, RooAbsReal &func, const RooArgList &observables, int order=1, std::vector< double > const &observableValues={}, double eps1=1e-6, double eps2=1e-3)
Taylor expanding given function in terms of observables around observableValues.
TObject * clone(const char *newname) const override
Definition RooPolyFunc.h:37
std::string asString() const
Return to RooPolyFunc as a string.
std::vector< std::unique_ptr< RooListProxy > > _terms
Definition RooPolyFunc.h:63
Variable that can be changed from the outside.
Definition RooRealVar.h:37
Mother of all ROOT objects.
Definition TObject.h:41
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17