Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFunctor1DBinding.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id$
5 * Authors: *
6 * WV, Wouter Verkerke, NIKHEF, verkerke@nikhef.nl *
7 * *
8 * Copyright (c) 2000-2008, NIKHEF, Regents of the University of California *
9 * and Stanford University. All rights reserved. *
10 * *
11 *****************************************************************************/
12
13/** \class RooFunctor1DBinding
14 \ingroup Roofit
15
16RooCFunction1Binding is a templated implementation of class RooAbsReal that binds
17generic C(++) functions to a RooAbsReal argument thus allowing generic C++
18functions to be used as RooFit functions. Instances of function binding
19classes are fully functional RooFit function objects with one exception:
20if the bound function is _not_ a standard TMath or MathMore function the
21class cannot be persisted in a RooWorkspace without registering the function
22pointer first using RooCFunction1Binding<T1,T2>::register().
23**/
24
25/** \class RooFunctor1DPdfBinding
26 \ingroup Roofit
27**/
28
29#include "RooFunctor1DBinding.h"
30
31using std::ostream;
32
33
34////////////////////////////////////////////////////////////////////////////////
35
37 RooAbsReal(name,title),
38 func(&ftor),
39 var("x","x",this,x)
40{
41}
42
43////////////////////////////////////////////////////////////////////////////////
44
47 func(other.func),
48 var("x",this,other.var)
49{
50 // Copy constructor
51}
52
53////////////////////////////////////////////////////////////////////////////////
54
55void RooFunctor1DBinding::printArgs(ostream& os) const {
56 // Print object arguments and name/address of function pointer
57 os << "[ function=" << func << " " ;
58 for (Int_t i=0 ; i<numProxies() ; i++) {
59 RooAbsProxy* p = getProxy(i) ;
60 if (!TString(p->name()).BeginsWith("!")) {
61 p->print(os) ;
62 os << " " ;
63 }
64 }
65 os << "]" ;
66}
67
68////////////////////////////////////////////////////////////////////////////////
69
71 // Return value of embedded function using value of referenced variable x
72 return (*func)(var.arg().getVal()) ;
73 }
74
75////////////////////////////////////////////////////////////////////////////////
76
78 RooAbsPdf(name,title),
79 func(&ftor),
80 var("x","x",this,x)
81{
82}
83
84////////////////////////////////////////////////////////////////////////////////
85
88 func(other.func),
89 var("x",this,other.var)
90{
91 // Copy constructor
92}
93
94////////////////////////////////////////////////////////////////////////////////
95
96void RooFunctor1DPdfBinding::printArgs(ostream& os) const {
97 // Print object arguments and name/address of function pointer
98 os << "[ function=" << func << " " ;
99 for (Int_t i=0 ; i<numProxies() ; i++) {
100 RooAbsProxy* p = getProxy(i) ;
101 if (!TString(p->name()).BeginsWith("!")) {
102 p->print(os) ;
103 os << " " ;
104 }
105 }
106 os << "]" ;
107}
108
109////////////////////////////////////////////////////////////////////////////////
110
112 // Return value of embedded function using value of referenced variable x
113 return (*func)(var.arg().getVal()) ;
114 }
115
116namespace RooFit {
117
121
123 return new RooFunctor1DPdfBinding(name,name,ftor,var) ;
124 }
125
126}
winID h TVirtualViewer3D TVirtualGLPainter p
char name[80]
Definition TGX11.cxx:142
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition IFunction.h:157
Int_t numProxies() const
Return the number of registered proxies.
RooAbsProxy * getProxy(Int_t index) const
Return the nth proxy from the proxy list.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
Abstract interface for proxy classes.
Definition RooAbsProxy.h:37
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
RooCFunction1Binding is a templated implementation of class RooAbsReal that binds generic C(++) funct...
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
void printArgs(std::ostream &os) const override
Print object arguments, ie its proxies.
const ROOT::Math::IBaseFunctionOneDim * func
RooFunctor1DBinding()=default
ROOT::Math::IBaseFunctionOneDim const * func
RooFunctor1DPdfBinding()=default
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
void printArgs(std::ostream &os) const override
Print object arguments, ie its proxies.
const T & arg() const
Return reference to object held in proxy.
Basic string class.
Definition TString.h:137
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:633
Double_t x[n]
Definition legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:73
RooAbsPdf * bindPdf(const char *name, CFUNCD1D func, RooAbsReal &x)
RooAbsReal * bindFunction(const char *name, CFUNCD1D func, RooAbsReal &x)