Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:25

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitModels                                                     *
0004  *    File: $Id: RooPolyFunc.h,v 1.8 2007/05/11 09:13:07 verkerke 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) 2021:                                                       *
0010  *      CERN, Switzerland                                                    *
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 RooFit_RooFit_RooPolyFunc_h
0017 #define RooFit_RooFit_RooPolyFunc_h
0018 
0019 #include "RooAbsReal.h"
0020 #include "RooRealVar.h"
0021 #include "RooListProxy.h"
0022 
0023 #include <vector>
0024 
0025 class RooRealVar;
0026 class RooArgList;
0027 
0028 class RooPolyFunc : public RooAbsReal {
0029 public:
0030    RooPolyFunc();
0031    RooPolyFunc(const char *name, const char *title, RooAbsReal &x, const RooAbsCollection &coefList);
0032    RooPolyFunc(const char *name, const char *title, RooAbsReal &x, RooAbsReal &y, const RooAbsCollection &coefList);
0033    RooPolyFunc(const char *name, const char *title, const RooAbsCollection &vars);
0034    RooPolyFunc(const RooPolyFunc &other, const char *name = nullptr);
0035    RooPolyFunc &operator=(const RooPolyFunc &other) = delete;
0036    RooPolyFunc &operator=(RooPolyFunc &&other) = delete;
0037    TObject *clone(const char *newname) const override { return new RooPolyFunc(*this, newname); }
0038 
0039    std::string asString() const;
0040    inline const RooArgList &variables() const { return _vars; }
0041    inline const std::vector<std::unique_ptr<RooListProxy>> &terms() const { return _terms; }
0042    inline RooRealVar *getCoefficient(const RooArgList &term)
0043    {
0044       return static_cast<RooRealVar *>(term.at(term.size() - 1));
0045    }
0046    inline RooRealVar *getExponent(const RooArgList &term, RooRealVar *v)
0047    {
0048       return static_cast<RooRealVar *>(term.at(_vars.index(v)));
0049    }
0050 
0051    void addTerm(double coefficient);
0052    void addTerm(double coefficient, const RooAbsCollection &exponents);
0053    void addTerm(double coefficient, const RooAbsReal &var1, int exp1);
0054    void addTerm(double coefficient, const RooAbsReal &var1, int exp1, const RooAbsReal &var2, int exp2);
0055 
0056    static std::unique_ptr<RooPolyFunc>
0057    taylorExpand(const char *name, const char *title, RooAbsReal &func, const RooArgList &observables, int order = 1,
0058                 std::vector<double> const &observableValues = {}, double eps1 = 1e-6, double eps2 = 1e-3);
0059 
0060 protected:
0061    void setCoordinate(const RooAbsCollection &observables, std::vector<double> const &observableValues);
0062    RooListProxy _vars;
0063    std::vector<std::unique_ptr<RooListProxy>> _terms;
0064 
0065    /// Evaluation
0066    double evaluate() const override;
0067 
0068    ClassDefOverride(RooPolyFunc, 1) // Polynomial Function
0069 };
0070 
0071 #endif