Logo ROOT   6.16/01
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
28#include "RooFit.h"
29
31#include "RooAbsReal.h"
32#include "RooArgSet.h"
33#include "RooAbsRealLValue.h"
34#include "RooMsgService.h"
35
36#include <assert.h>
37
38using namespace std;
39
41;
42
43
44////////////////////////////////////////////////////////////////////////////////
45
47 RooAbsReal& xprime, RooAbsReal& x,
48 const RooArgSet* nset, Bool_t clipInvalid) :
49
50 RooAbsFunc(2), _func(&func), _model(&model), _vars(0), _nset(nset), _clipInvalid(clipInvalid)
51{
52 // Constructor where func and model
53 //
54 // 'func' = func(xprime)
55 // 'model' = model(xprime)
56 //
57 // and
58
59 // 'xprime' is the RRV that should be connected to func and model
60 // (i.e. the variable that will be integrated over)
61 // 'x' is RRV that represents the value at which the convolution is calculated
62 // (this variable should _not_ be connected to func and model)
63 //
64 // this function returns RCBB[x',x] = f[x']*g[x-x'], i.e. the substiturion g[x'] --> g[x-x']
65 // is taken care internally
66 //
67 // The integral of this binding over its 1st arg yields the convolution (f (x) g)[x]
68 //
69
70 // allocate memory
71 _vars= new RooAbsRealLValue*[2];
72 if(0 == _vars) {
74 return;
75 }
76
77 // check that all of the arguments are real valued and store them
78 _vars[0]= dynamic_cast<RooAbsRealLValue*>(&xprime);
79 if(0 == _vars[0]) {
80 oocoutE(&func,InputArguments) << "RooConvIntegrandBinding: cannot bind to ";
81 xprime.Print("1");
83 }
84
85 _vars[1]= dynamic_cast<RooAbsRealLValue*>(&x);
86 if(0 == _vars[1]) {
87 oocoutE(&func,InputArguments) << "RooConvIntegrandBinding: cannot bind to ";
88 x.Print("1");
90 }
91
93}
94
95
96
97////////////////////////////////////////////////////////////////////////////////
98/// Destructor
99
101{
102 if(0 != _vars) delete[] _vars;
103}
104
105
106////////////////////////////////////////////////////////////////////////////////
107/// Load external input values
108
109void RooConvIntegrandBinding::loadValues(const Double_t xvector[], Bool_t clipInvalid) const
110{
111 _xvecValid = kTRUE ;
112 for(UInt_t index= 0; index < _dimension; index++) {
113 if (clipInvalid && !_vars[index]->isValidReal(xvector[index])) {
115 } else {
116 //cout << "RooConvBasBinding::loadValues[" << index << "] loading value " << xvector[index] << endl ;
117 _vars[index]->setVal(xvector[index]);
118 }
119 }
120}
121
122
123////////////////////////////////////////////////////////////////////////////////
124/// Evaluate self at given parameter values
125
127{
128 assert(isValid());
129 _ncall++ ;
130
131 // First evaluate function at x'
132 loadValues(xvector);
133 if (!_xvecValid) return 0 ;
134 //cout << "RooConvIntegrandBinding::operator(): evaluating f(x') at x' = " << xvector[0] << endl ;
135 Double_t f_xp = _func->getVal(_nset) ;
136
137 // Next evaluate model at x-x'
138 const Double_t xvec_tmp[2] = { xvector[1]-xvector[0] , xvector[1] } ;
139 loadValues(xvec_tmp,kTRUE);
140 if (!_xvecValid) return 0 ;
141 Double_t g_xmxp = _model->getVal(_nset) ;
142
143 //cout << "RooConvIntegrandBinding::operator(): evaluating g(x-x') at x-x' = " << _vars[0]->getVal() << " = " << g_xmxp << endl ;
144 //cout << "RooConvIntegrandBinding::operator(): return value = " << f_xp << " * " << g_xmxp << " = " << f_xp*g_xmxp << endl ;
145
146 //cout << "_vars[0] = " << _vars[0]->getVal() << " _vars[1] = " << _vars[1]->getVal() << endl ;
147 //cout << "_xvec[0] = " << xvector[0] << " _xvec[1] = " << xvector[1] << endl ;
148
149 return f_xp*g_xmxp ;
150}
151
152
153////////////////////////////////////////////////////////////////////////////////
154/// Retrieve lower limit of i-th observable
155
157{
158 assert(isValid());
159 return _vars[index]->getMin();
160}
161
162
163////////////////////////////////////////////////////////////////////////////////
164/// Retrieve upper limit of i-th observable
165
167{
168 assert(isValid());
169 return _vars[index]->getMax();
170}
#define oocoutE(o, a)
Definition: RooMsgService.h:47
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:363
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooAbsArg.h:227
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Definition: RooAbsFunc.h:23
Bool_t isValid() const
Definition: RooAbsFunc.h:33
UInt_t _dimension
Definition: RooAbsFunc.h:74
Int_t _ncall
Definition: RooAbsFunc.h:73
Bool_t _valid
Definition: RooAbsFunc.h:75
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
virtual void setVal(Double_t value)=0
virtual Double_t getMin(const char *name=0) const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Double_t getVal(const RooArgSet *set=0) const
Evaluate object. Returns either cached value or triggers a recalculation.
Definition: RooAbsReal.h:64
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
Implementation of RooAbsFunc that represent the the integrand of a generic (numeric) convolution A (x...
virtual Double_t getMinLimit(UInt_t dimension) const
Retrieve lower limit of i-th observable.
void loadValues(const Double_t xvector[], Bool_t clipInvalid=kFALSE) const
Load external input values.
virtual Double_t getMaxLimit(UInt_t dimension) const
Retrieve upper limit of i-th observable.
virtual ~RooConvIntegrandBinding()
Destructor.
virtual Double_t operator()(const Double_t xvector[]) const
Evaluate self at given parameter values.
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:58
STL namespace.