Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
RooChebychev.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
5 * Authors: *
6 * GR, Gerhard Raven, UC San Diego, Gerhard.Raven@slac.stanford.edu
7 * *
8 * Copyright (c) 2000-2005, Regents of the University of California *
9 * and Stanford University. All rights reserved. *
10 * *
11 * Redistribution and use in source and binary forms, *
12 * with or without modification, are permitted according to the terms *
13 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
14 *****************************************************************************/
15
16/** \class RooChebychev
17 \ingroup Roofit
18
19Chebychev polynomial p.d.f. of the first kind.
20
21The coefficient that goes with \f$ T_0(x)=1 \f$ (i.e. the constant polynomial) is
22implicitly assumed to be 1, and the list of coefficients supplied by callers
23starts with the coefficient that goes with \f$ T_1(x)=x \f$ (i.e. the linear term).
24**/
25
26#include "RooChebychev.h"
27#include "RooRealVar.h"
28#include "RooArgList.h"
29#include "RooNameReg.h"
30#include "RooBatchCompute.h"
31
33
34#include <cmath>
35
36
37////////////////////////////////////////////////////////////////////////////////
38
40
41////////////////////////////////////////////////////////////////////////////////
42/// Constructor
43
44RooChebychev::RooChebychev(const char* name, const char* title,
45 RooAbsReal& x, const RooArgList& coefList):
46 RooAbsPdf(name, title),
47 _x("x", "Dependent", this, x),
48 _coefList("coefList","List of coefficients",this)
49{
51}
52
53////////////////////////////////////////////////////////////////////////////////
54
57 _x("x", this, other._x),
58 _coefList(this,other._coefList),
59 _refRangeName(other._refRangeName)
60{
61}
62
63////////////////////////////////////////////////////////////////////////////////
64
66{
67 if (rangeName && (force || !_refRangeName)) {
68 _refRangeName = const_cast<TNamed*>(RooNameReg::instance().constPtr(rangeName));
69 }
70 if (!rangeName) {
71 _refRangeName = nullptr ;
72 }
73}
74
75////////////////////////////////////////////////////////////////////////////////
76
78{
79 // first bring the range of the variable _x to the normalised range [-1, 1]
80 // calculate sum_k c_k T_k(x) where x is given in the normalised range,
81 // c_0 = 1, and the higher coefficients are given in _coefList
82 double xmax = _x.max(_refRangeName ? _refRangeName->GetName() : nullptr);
83 double xmin = _x.min(_refRangeName ? _refRangeName->GetName() : nullptr);
84
85 std::vector<double> coeffs;
86 for (auto it : _coefList) {
87 coeffs.push_back(static_cast<const RooAbsReal &>(*it).getVal());
88 }
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Compute multiple values of Chebychev.
95{
96 std::vector<double> extraArgs;
97 extraArgs.reserve(_coefList.size() + 2);
98 for (auto *coef : _coefList) {
99 extraArgs.push_back(static_cast<const RooAbsReal *>(coef)->getVal());
100 }
101 extraArgs.push_back(_x.min(_refRangeName ? _refRangeName->GetName() : nullptr));
102 extraArgs.push_back(_x.max(_refRangeName ? _refRangeName->GetName() : nullptr));
104}
105
106////////////////////////////////////////////////////////////////////////////////
107
108
109Int_t RooChebychev::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /* rangeName */) const
110{
111 return matchArgs(allVars, analVars, _x) ? 1 : 0;
112}
113
114////////////////////////////////////////////////////////////////////////////////
115
116double RooChebychev::analyticalIntegral(Int_t code, const char *rangeName) const
117{
118 assert(1 == code);
119 (void)code;
120
121 double xmax = _x.max(_refRangeName ? _refRangeName->GetName() : nullptr);
122 double xmin = _x.min(_refRangeName ? _refRangeName->GetName() : nullptr);
123 unsigned int sz = _coefList.size();
124
125 std::vector<double> coeffs;
126 for (auto it : _coefList)
127 coeffs.push_back(static_cast<const RooAbsReal &>(*it).getVal());
128
130 _x.max(rangeName));
131}
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
float xmin
float xmax
Storage_t::size_type size() const
bool addTyped(const RooAbsCollection &list, bool silent=false)
Adds elements of a given RooAbsCollection to the container if they match the specified type.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
bool matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
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
Chebychev polynomial p.d.f.
void doEval(RooFit::EvalContext &) const override
Compute multiple values of Chebychev.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
RooArgList const & coefList() const
RooRealProxy _x
void selectNormalizationRange(const char *rangeName=nullptr, bool force=false) override
Interface function to force use of a given normalization range to interpret function value.
TNamed * _refRangeName
RooListProxy _coefList
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
std::span< double > output()
RooBatchCompute::Config config(RooAbsArg const *arg) const
static RooNameReg & instance()
Return reference to singleton instance.
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Double_t x[n]
Definition legend1.C:17
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
double chebychevIntegral(double const *coeffs, unsigned int nCoeffs, double xMin, double xMax, double xMinFull, double xMaxFull)
Definition MathFuncs.h:540
double chebychev(double *coeffs, unsigned int nCoeffs, double x_in, double xMin, double xMax)
Definition MathFuncs.h:139