Logo ROOT  
Reference Guide
RooConvIntegrandBinding.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
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) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
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
17/**
18\file RooConvIntegrandBinding.cxx
19\class RooConvIntegrandBinding
20\ingroup Roofitcore
21
22Implementation of RooAbsFunc that represent the the integrand
23of a generic (numeric) convolution A (x) B so that it can be
24passed to a numeric integrator. This is a utility class for
25RooNumConvPdf
26**/
27
29#include "RooAbsReal.h"
30#include "RooArgSet.h"
31#include "RooAbsRealLValue.h"
32#include "RooMsgService.h"
33
34#include <assert.h>
35
36using namespace std;
37
39;
40
41
42////////////////////////////////////////////////////////////////////////////////
43
45 RooAbsReal& xprime, RooAbsReal& x,
46 const RooArgSet* nset, Bool_t clipInvalid) :
47
48 RooAbsFunc(2), _func(&func), _model(&model), _vars(0), _nset(nset), _clipInvalid(clipInvalid)
49{
50 // Constructor where func and model
51 //
52 // 'func' = func(xprime)
53 // 'model' = model(xprime)
54 //
55 // and
56
57 // 'xprime' is the RRV that should be connected to func and model
58 // (i.e. the variable that will be integrated over)
59 // 'x' is RRV that represents the value at which the convolution is calculated
60 // (this variable should _not_ be connected to func and model)
61 //
62 // this function returns RCBB[x',x] = f[x']*g[x-x'], i.e. the substiturion g[x'] --> g[x-x']
63 // is taken care internally
64 //
65 // The integral of this binding over its 1st arg yields the convolution (f (x) g)[x]
66 //
67
68 // allocate memory
69 _vars= new RooAbsRealLValue*[2];
70 if(0 == _vars) {
72 return;
73 }
74
75 // check that all of the arguments are real valued and store them
76 _vars[0]= dynamic_cast<RooAbsRealLValue*>(&xprime);
77 if(0 == _vars[0]) {
78 oocoutE(&func,InputArguments) << "RooConvIntegrandBinding: cannot bind to ";
79 xprime.Print("1");
81 }
82
83 _vars[1]= dynamic_cast<RooAbsRealLValue*>(&x);
84 if(0 == _vars[1]) {
85 oocoutE(&func,InputArguments) << "RooConvIntegrandBinding: cannot bind to ";
86 x.Print("1");
88 }
89
91}
92
93
94
95////////////////////////////////////////////////////////////////////////////////
96/// Destructor
97
99{
100 if(0 != _vars) delete[] _vars;
101}
102
103
104////////////////////////////////////////////////////////////////////////////////
105/// Load external input values
106
107void RooConvIntegrandBinding::loadValues(const Double_t xvector[], Bool_t clipInvalid) const
108{
109 _xvecValid = kTRUE ;
110 for(UInt_t index= 0; index < _dimension; index++) {
111 if (clipInvalid && !_vars[index]->isValidReal(xvector[index])) {
113 } else {
114 //cout << "RooConvBasBinding::loadValues[" << index << "] loading value " << xvector[index] << endl ;
115 _vars[index]->setVal(xvector[index]);
116 }
117 }
118}
119
120
121////////////////////////////////////////////////////////////////////////////////
122/// Evaluate self at given parameter values
123
125{
126 assert(isValid());
127 _ncall++ ;
128
129 // First evaluate function at x'
130 loadValues(xvector);
131 if (!_xvecValid) return 0 ;
132 //cout << "RooConvIntegrandBinding::operator(): evaluating f(x') at x' = " << xvector[0] << endl ;
133 Double_t f_xp = _func->getVal(_nset) ;
134
135 // Next evaluate model at x-x'
136 const Double_t xvec_tmp[2] = { xvector[1]-xvector[0] , xvector[1] } ;
137 loadValues(xvec_tmp,kTRUE);
138 if (!_xvecValid) return 0 ;
139 Double_t g_xmxp = _model->getVal(_nset) ;
140
141 //cout << "RooConvIntegrandBinding::operator(): evaluating g(x-x') at x-x' = " << _vars[0]->getVal() << " = " << g_xmxp << endl ;
142 //cout << "RooConvIntegrandBinding::operator(): return value = " << f_xp << " * " << g_xmxp << " = " << f_xp*g_xmxp << endl ;
143
144 //cout << "_vars[0] = " << _vars[0]->getVal() << " _vars[1] = " << _vars[1]->getVal() << endl ;
145 //cout << "_xvec[0] = " << xvector[0] << " _xvec[1] = " << xvector[1] << endl ;
146
147 return f_xp*g_xmxp ;
148}
149
150
151////////////////////////////////////////////////////////////////////////////////
152/// Retrieve lower limit of i-th observable
153
155{
156 assert(isValid());
157 return _vars[index]->getMin();
158}
159
160
161////////////////////////////////////////////////////////////////////////////////
162/// Retrieve upper limit of i-th observable
163
165{
166 assert(isValid());
167 return _vars[index]->getMax();
168}
#define oocoutE(o, a)
Definition: RooMsgService.h:48
const Bool_t kFALSE
Definition: RtypesCore.h:101
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:375
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
void Print(Option_t *options=0) const override
Print the object to the defaultPrintStream().
Definition: RooAbsArg.h:346
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Definition: RooAbsFunc.h:27
Bool_t isValid() const
Definition: RooAbsFunc.h:37
UInt_t _dimension
Number of observables.
Definition: RooAbsFunc.h:79
Int_t _ncall
Function call counter.
Definition: RooAbsFunc.h:78
Bool_t _valid
Is binding in valid state?
Definition: RooAbsFunc.h:80
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual void setVal(Double_t value)=0
Set the current value of the object. Needs to be overridden by implementations.
virtual Double_t getMin(const char *name=0) const
Get minimum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:63
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:93
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:57
Implementation of RooAbsFunc that represent the the integrand of a generic (numeric) convolution A (x...
Double_t getMaxLimit(UInt_t dimension) const override
Retrieve upper limit of i-th observable.
Double_t getMinLimit(UInt_t dimension) const override
Retrieve lower limit of i-th observable.
Double_t operator()(const Double_t xvector[]) const override
Evaluate self at given parameter values.
void loadValues(const Double_t xvector[], Bool_t clipInvalid=kFALSE) const
Load external input values.
Bool_t _xvecValid
If true _xvec defines a valid point.
const RooAbsReal * _func
Pointer to input function.
const RooAbsReal * _model
Pointer to input resolution model.
RooAbsRealLValue ** _vars
Array of pointers to variables.
const RooArgSet * _nset
Normalization set to be used for function evaluations.
~RooConvIntegrandBinding() override
Destructor.
RooConvIntegrandBinding(const RooAbsReal &func, const RooAbsReal &model, RooAbsReal &x, RooAbsReal &xprime, const RooArgSet *nset=0, Bool_t clipInvalid=kFALSE)
Double_t x[n]
Definition: legend1.C:17
@ InputArguments
Definition: RooGlobalFunc.h:64